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

temp

parent 2f1f8514
No related branches found
No related tags found
No related merge requests found
......@@ -306,7 +306,7 @@ export default {
// eslint-disable-next-line no-restricted-globals
connectionUrl: 'ws://localhost:5010',
// connectionUrl: 'ws://0.tcp.ap.ngrok.io:17607',
docIdentifier: 'prosemirror-demo777',
docIdentifier: 'prosemirror-demo77',
YjsType: 'prosemirror',
},
......
......@@ -23,9 +23,6 @@ export default class CommentsService extends Service {
});
}
this.app.context.setOption({
commentsMap: map,
});
return map;
},
context: this.app.context,
......
......@@ -21,7 +21,14 @@ const ConnectedCommentStyled = styled.div`
${override('Wax.CommentOuterBox')}
`;
export default ({ comment, top, commentId, recalculateTops, users }) => {
export default ({
comment,
top,
commentId,
recalculateTops,
users,
commentActive,
}) => {
const context = useContext(WaxContext);
const {
pmViews,
......@@ -48,13 +55,11 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
commentConfig && commentConfig.readOnly ? commentConfig.readOnly : false;
const showTitle =
commentConfig && commentConfig.showTitle ? commentConfig.showTitle : false;
const commentPlugin = app.PmPlugins.get('commentPlugin');
const [activeComment, setActiveComment] = useState(
commentPlugin.getState(activeView.state).comment,
);
const [activeComment, setActiveComment] = useState(commentActive);
useEffect(() => {
setIsActive(false);
setActiveComment(context.options.activeComment);
recalculateTops();
if (activeComment && commentId === activeComment.id) {
setIsActive(true);
......@@ -76,7 +81,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
comment.data.title = title || comment.data.title;
comment.data.conversation.push(obj);
console.log(comment);
context.activeView.dispatch(
context.activeView.state.tr.setMeta(CommentDecorationPluginKey, {
type: 'updateComment',
......@@ -89,6 +94,11 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
};
const onClickBox = () => {
setActiveComment(
CommentDecorationPluginKey.getState(activeView.state)
.getMap()
.get(commentId),
);
if (isActive) {
pmViews[viewId].focus();
return false;
......@@ -152,7 +162,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
/>
</ConnectedCommentStyled>
),
[isActive, top, conversation.length, users],
[isActive, top, conversation.length, users, context.options.activeComment],
);
return <>{MemorizedComponent}</>;
};
......@@ -33,7 +33,7 @@ const getComment = state => {
return undefined;
};
export default () => {
export default (key, context) => {
return new Plugin({
key: commentPlugin,
state: {
......@@ -44,6 +44,7 @@ export default () => {
const comment = getComment(newState);
let createDecoration;
if (comment) {
context.setOption({ activeComment: comment });
createDecoration = DecorationSet.create(newState.doc, [
Decoration.inline(comment.data.pmFrom, comment.data.pmTo, {
class: 'active-comment',
......
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