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
b2d3d81b
Commit
b2d3d81b
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
rerender comments
parent
d06c3ae5
No related branches found
No related tags found
1 merge request
!80
Comment discussion
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
editors/editoria/src/Editoria.js
+1
-3
1 addition, 3 deletions
editors/editoria/src/Editoria.js
wax-prosemirror-components/src/components/comments/CommentsBoxList.js
+19
-28
19 additions, 28 deletions
...ror-components/src/components/comments/CommentsBoxList.js
with
20 additions
and
31 deletions
editors/editoria/src/Editoria.js
+
1
−
3
View file @
b2d3d81b
...
...
@@ -47,9 +47,7 @@ const Editoria = () => (
autoFocus
placeholder
=
"
Type Something...
"
fileUpload
=
{
file
=>
renderImage
(
file
)}
value
=
{
'
<p class="paragraph">this is <span class="comment" id="1b87a19d-891c-4329-9482-b8ab8523c129" data-viewid="main" data-conversation="[]">some</span> content</p>
'
}
value
=
{
""
}
layout
=
{
EditoriaLayout
}
// onChange={source => console.log(source)}
user
=
{
user
}
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-components/src/components/comments/CommentsBoxList.js
+
19
−
28
View file @
b2d3d81b
import
React
,
{
Fragment
,
use
Effect
}
from
"
react
"
;
import
React
,
{
Fragment
,
use
State
,
useEffect
,
useCallback
}
from
"
react
"
;
import
{
each
}
from
"
lodash
"
;
import
CommentBox
from
"
./CommentBox
"
;
//TODO find from marks actual comment mark
export
default
({
comments
,
view
})
=>
{
let
commentEl
=
null
;
let
commentElTop
=
0
;
let
top
=
0
;
const
[
position
,
setPosition
]
=
useState
();
const
setTops
=
useCallback
(()
=>
{
let
commentEl
=
null
;
let
commentElTop
=
0
;
const
allCommentsTop
=
{};
if
(
comments
.
length
>
0
)
{
const
WaxSurface
=
view
.
dom
.
getBoundingClientRect
();
each
(
comments
,
(
entry
,
pos
)
=>
{
commentElTop
=
0
;
commentEl
=
document
.
getElementById
(
entry
.
node
.
marks
[
0
].
attrs
.
id
);
const
WaxSurface
=
view
.
dom
.
getBoundingClientRect
();
const
id
=
entry
.
node
.
marks
[
0
].
attrs
.
id
;
commentEl
=
document
.
getElementById
(
id
);
commentElTop
=
commentEl
.
getBoundingClientRect
().
top
-
WaxSurface
.
top
;
entry
.
node
.
marks
[
0
].
top
=
commentElTop
;
allCommentsTop
[
id
]
=
commentElTop
;
});
}
const
setTops
=
()
=>
{
if
(
comments
.
length
>
0
)
{
each
(
comments
,
(
entry
,
pos
)
=>
{
const
WaxSurface
=
view
.
dom
.
getBoundingClientRect
();
commentElTop
=
0
;
commentEl
=
document
.
getElementById
(
entry
.
node
.
marks
[
0
].
attrs
.
id
);
commentElTop
=
commentEl
.
getBoundingClientRect
().
top
-
WaxSurface
.
top
;
entry
.
node
.
marks
[
0
].
top
=
commentElTop
;
return
commentElTop
;
});
}
};
return
allCommentsTop
;
});
useEffect
(
()
=>
{
console
.
log
(
"
change
"
);
setPosition
(
setTops
()
);
},
[
setTops
]
[
JSON
.
stringify
(
setTops
())
]
);
return
(
<
Fragment
>
{
comments
.
map
(
comment
=>
{
if
(
comment
)
top
=
comment
.
node
.
marks
[
0
].
top
;
console
.
log
(
comment
.
node
.
marks
[
0
].
attrs
.
id
);
const
id
=
comment
.
node
.
marks
[
0
].
attrs
.
id
;
return
(
<
CommentBox
key
=
{
comment
.
node
.
marks
[
0
].
top
}
key
=
{
comment
.
node
.
marks
[
0
].
attrs
.
id
}
mark
=
{
comment
.
node
.
marks
[
0
]}
view
=
{
view
}
top
=
{
top
}
top
=
{
position
[
id
]
}
/
>
);
})}
...
...
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