Skip to content
Snippets Groups Projects
Commit d06c3ae5 authored by chris's avatar chris
Browse files

temp comment position

parent 8e7f468f
No related branches found
No related tags found
1 merge request!80Comment discussion
...@@ -51,7 +51,7 @@ const Editoria = () => ( ...@@ -51,7 +51,7 @@ const Editoria = () => (
'<p class="paragraph">this is <span class="comment" id="1b87a19d-891c-4329-9482-b8ab8523c129" data-viewid="main" data-conversation="[]">some</span> content</p>' '<p class="paragraph">this is <span class="comment" id="1b87a19d-891c-4329-9482-b8ab8523c129" data-viewid="main" data-conversation="[]">some</span> content</p>'
} }
layout={EditoriaLayout} layout={EditoriaLayout}
onChange={source => console.log(source)} // onChange={source => console.log(source)}
user={user} user={user}
/> />
</Fragment> </Fragment>
......
...@@ -8,12 +8,10 @@ const CommentBoxStyled = styled.div` ...@@ -8,12 +8,10 @@ const CommentBoxStyled = styled.div`
flex-direction: column; flex-direction: column;
margin-top: 10px; margin-top: 10px;
background: black; background: black;
position: absolute;
top: ${props => (props.top ? `${props.top}px` : 0)};
`; `;
export default ({ mark, view }) => { export default ({ mark, view, top }) => {
useEffect(() => { return <CommentBoxStyled top={top} />;
console.log(document.getElementById(mark.attrs.id));
}, []);
return <CommentBoxStyled />;
}; };
import React, { Fragment } from "react"; import React, { Fragment, useEffect } from "react";
import { each } from "lodash";
import CommentBox from "./CommentBox"; import CommentBox from "./CommentBox";
//TODO find from marks actual comment mark //TODO find from marks actual comment mark
export default ({ comments, view }) => { export default ({ comments, view }) => {
let commentEl = null;
let commentElTop = 0;
let top = 0;
if (comments.length > 0) {
const WaxSurface = view.dom.getBoundingClientRect();
each(comments, (entry, pos) => {
commentElTop = 0;
commentEl = document.getElementById(entry.node.marks[0].attrs.id);
commentElTop = commentEl.getBoundingClientRect().top - WaxSurface.top;
entry.node.marks[0].top = 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;
});
}
};
useEffect(
() => {
console.log("change");
},
[setTops]
);
return ( return (
<Fragment> <Fragment>
{comments.map(comment => ( {comments.map(comment => {
<CommentBox if (comment) top = comment.node.marks[0].top;
key={comment.node.marks[0].attrs.id} console.log(comment.node.marks[0].attrs.id);
mark={comment.node.marks[0]} return (
view={view} <CommentBox
/> key={comment.node.marks[0].top}
))} mark={comment.node.marks[0]}
view={view}
top={top}
/>
);
})}
</Fragment> </Fragment>
); );
}; };
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment