Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax-prosemirror
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wax
wax-prosemirror
Commits
96c38b12
Commit
96c38b12
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
comment memo for now
parent
35b3aa2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!161
Connect ui
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-prosemirror-components/src/components/comments/ConnectedComment.js
+97
-97
97 additions, 97 deletions
...or-components/src/components/comments/ConnectedComment.js
with
97 additions
and
97 deletions
wax-prosemirror-components/src/components/comments/ConnectedComment.js
+
97
−
97
View file @
96c38b12
...
...
@@ -12,118 +12,118 @@ const ConnectedCommentStyled = styled.div`
`
;
export
default
({
comment
,
top
,
commentId
})
=>
{
const
MemorizedComponent
=
memo
(()
=>
{
const
{
view
,
view
:
{
main
:
{
props
:
{
user
},
},
// const MemorizedComponent = memo(() => {
const
{
view
,
view
:
{
main
:
{
props
:
{
user
},
},
app
,
activeView
,
}
=
useContext
(
WaxContext
);
},
app
,
activeView
,
}
=
useContext
(
WaxContext
);
const
{
state
,
dispatch
}
=
activeView
;
const
viewId
=
comment
.
attrs
.
viewid
;
const
{
state
,
dispatch
}
=
activeView
;
const
viewId
=
comment
.
attrs
.
viewid
;
const
allCommentsWithSameId
=
DocumentHelpers
.
findAllMarksWithSameId
(
view
[
viewId
].
state
,
comment
,
);
const
allCommentsWithSameId
=
DocumentHelpers
.
findAllMarksWithSameId
(
view
[
viewId
].
state
,
comment
,
);
const
commentMark
=
state
.
schema
.
marks
.
comment
;
const
commentMark
=
state
.
schema
.
marks
.
comment
;
let
active
=
false
;
let
active
=
false
;
const
styles
=
{
top
:
`
${
top
}
px`
,
};
const
styles
=
{
top
:
`
${
top
}
px`
,
};
const
commentPlugin
=
app
.
PmPlugins
.
get
(
'
commentPlugin
'
);
const
activeComment
=
commentPlugin
.
getState
(
activeView
.
state
).
comment
;
if
(
activeComment
&&
commentId
===
activeComment
.
attrs
.
id
)
active
=
true
;
const
onClickPost
=
content
=>
{
const
{
tr
}
=
state
;
const
obj
=
{
content
,
displayName
:
user
.
username
,
timestamp
:
Math
.
floor
(
Date
.
now
()
/
300000
),
};
comment
.
attrs
.
conversation
.
push
(
obj
);
allCommentsWithSameId
.
forEach
(
singleComment
=>
{
dispatch
(
tr
.
addMark
(
singleComment
.
pos
,
singleComment
.
pos
+
singleComment
.
nodeSize
,
commentMark
.
create
({
...((
comment
&&
comment
.
attrs
)
||
{}),
conversation
:
comment
.
attrs
.
conversation
,
}),
),
);
});
};
const
commentPlugin
=
app
.
PmPlugins
.
get
(
'
commentPlugin
'
);
const
activeComment
=
commentPlugin
.
getState
(
activeView
.
state
).
comment
;
if
(
activeComment
&&
commentId
===
activeComment
.
attrs
.
id
)
active
=
true
;
const
onClickBox
=
()
=>
{
if
(
active
)
{
view
[
viewId
].
focus
();
return
false
;
}
const
onClickPost
=
content
=>
{
const
{
tr
}
=
state
;
const
maxPos
=
maxBy
(
allCommentsWithSameId
,
'
pos
'
);
maxPos
.
pos
+=
last
(
allCommentsWithSameId
).
node
.
nodeSize
;
const
obj
=
{
content
,
displayName
:
user
.
username
,
timestamp
:
Math
.
floor
(
Date
.
now
()
/
300000
),
};
comment
.
attrs
.
conversation
.
push
(
obj
);
view
[
viewId
].
dispatch
(
view
[
viewId
].
state
.
tr
.
setSelection
(
new
TextSelection
(
view
[
viewId
].
state
.
tr
.
doc
.
resolve
(
maxPos
.
pos
,
maxPos
.
pos
),
),
allCommentsWithSameId
.
forEach
(
singleComment
=>
{
dispatch
(
tr
.
addMark
(
singleComment
.
pos
,
singleComment
.
pos
+
singleComment
.
nodeSize
,
commentMark
.
create
({
...((
comment
&&
comment
.
attrs
)
||
{}),
conversation
:
comment
.
attrs
.
conversation
,
}),
),
);
});
};
const
onClickBox
=
()
=>
{
if
(
active
)
{
view
[
viewId
].
focus
();
return
tru
e
;
}
;
return
fals
e
;
}
const
onClickResolve
=
()
=>
{
let
maxPos
=
comment
.
pos
;
let
minPos
=
comment
.
pos
;
const
maxPos
=
maxBy
(
allCommentsWithSameId
,
'
pos
'
);
maxPos
.
pos
+=
last
(
allCommentsWithSameId
).
node
.
nodeSize
;
allCommentsWithSameId
.
forEach
(
singleComment
=>
{
const
markPosition
=
DocumentHelpers
.
findMarkPosition
(
state
,
singleComment
.
pos
,
'
comment
'
,
);
if
(
markPosition
.
from
<
minPos
)
minPos
=
markPosition
.
from
;
if
(
markPosition
.
to
>
maxPos
)
maxPos
=
markPosition
.
to
;
});
if
(
allCommentsWithSameId
.
length
>
1
)
maxPos
+=
last
(
allCommentsWithSameId
).
node
.
nodeSize
;
dispatch
(
state
.
tr
.
removeMark
(
minPos
,
maxPos
,
commentMark
));
activeView
.
focus
();
};
return
(
<
ConnectedCommentStyled
data
-
box
=
{
commentId
}
style
=
{
styles
}
>
<
CommentBox
key
=
{
commentId
}
active
=
{
active
}
commentId
=
{
commentId
}
commentData
=
{
comment
.
attrs
.
conversation
}
onClickPost
=
{
onClickPost
}
onClickBox
=
{
onClickBox
}
onClickResolve
=
{
onClickResolve
}
/
>
<
/ConnectedCommentStyled
>
view
[
viewId
].
dispatch
(
view
[
viewId
].
state
.
tr
.
setSelection
(
new
TextSelection
(
view
[
viewId
].
state
.
tr
.
doc
.
resolve
(
maxPos
.
pos
,
maxPos
.
pos
),
),
),
);
});
return
<
MemorizedComponent
/>
;
view
[
viewId
].
focus
();
return
true
;
};
const
onClickResolve
=
()
=>
{
let
maxPos
=
comment
.
pos
;
let
minPos
=
comment
.
pos
;
allCommentsWithSameId
.
forEach
(
singleComment
=>
{
const
markPosition
=
DocumentHelpers
.
findMarkPosition
(
state
,
singleComment
.
pos
,
'
comment
'
,
);
if
(
markPosition
.
from
<
minPos
)
minPos
=
markPosition
.
from
;
if
(
markPosition
.
to
>
maxPos
)
maxPos
=
markPosition
.
to
;
});
if
(
allCommentsWithSameId
.
length
>
1
)
maxPos
+=
last
(
allCommentsWithSameId
).
node
.
nodeSize
;
dispatch
(
state
.
tr
.
removeMark
(
minPos
,
maxPos
,
commentMark
));
activeView
.
focus
();
};
return
(
<
ConnectedCommentStyled
data
-
box
=
{
commentId
}
style
=
{
styles
}
>
<
CommentBox
key
=
{
commentId
}
active
=
{
active
}
commentId
=
{
commentId
}
commentData
=
{
comment
.
attrs
.
conversation
}
onClickPost
=
{
onClickPost
}
onClickBox
=
{
onClickBox
}
onClickResolve
=
{
onClickResolve
}
/
>
<
/ConnectedCommentStyled
>
);
// });
// return <MemorizedComponent />;
};
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment