diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js index 8837b278e3d8c3e0e7c6f5a3ea237f63a71cfb22..aaa6ad801ce114851e6c462c6eaa1253592d0d0e 100644 --- a/editors/demo/src/Editoria/Editoria.js +++ b/editors/demo/src/Editoria/Editoria.js @@ -58,9 +58,9 @@ const Editoria = () => { value={demo} // readonly layout={layout} - // onChange={debounce(source => { - // console.log(JSON.stringify(source)); - // }, 200)} + onChange={debounce(source => { + console.log(JSON.stringify(source)); + }, 200)} user={user} scrollMargin={200} scrollThreshold={200} diff --git a/editors/demo/src/Editors.js b/editors/demo/src/Editors.js index 0e36a5c07cdfbce6f7c2095a8b1470e6f4c781f5..78a82dca42828507ad8168cf3eb705360720ee0d 100644 --- a/editors/demo/src/Editors.js +++ b/editors/demo/src/Editors.js @@ -90,7 +90,7 @@ const Editors = () => { case 'oen': return <OEN />; default: - return <HHMI />; + return <Editoria />; } }; diff --git a/wax-prosemirror-core/src/utilities/commands/Commands.js b/wax-prosemirror-core/src/utilities/commands/Commands.js index 563bd74239fd0225f9ad1f84275a9206ea7b2c9c..a8fbe6bdcc09824b393a79e7a990fc72a0b3c831 100644 --- a/wax-prosemirror-core/src/utilities/commands/Commands.js +++ b/wax-prosemirror-core/src/utilities/commands/Commands.js @@ -1,3 +1,4 @@ +/* eslint-disable no-multi-assign */ import { v4 as uuidv4 } from 'uuid'; import { toggleMark } from 'prosemirror-commands'; import { AddMarkStep } from 'prosemirror-transform'; @@ -178,6 +179,7 @@ const createComment = ( group, conversation, viewid, + title, })(state, dispatch); }; diff --git a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js index e9fad52a9e40d2524603e60613da2314bded7475..2435c2be684357b790c397fbca3c04a30326e15a 100644 --- a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js +++ b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js @@ -72,64 +72,6 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { } }, [activeComment]); - // const onClickPost = ({ commentValue, title }) => { - // setClickPost(true); - // const currentUser = user || (users || []).find(u => u.currentUser === true); - - // const obj = { - // content: commentValue, - // displayName: currentUser - // ? currentUser.displayName || currentUser.username - // : 'Anonymous', - // userId: currentUser ? currentUser.userId : '1', - // timestamp: Math.floor(Date.now()), - // }; - - // comment.attrs.title = title || comment.attrs.title; - // comment.attrs.conversation.push(obj); - - // const id = uuidv4(); - // allCommentsWithSameId.forEach(singleComment => { - // activeView.dispatch( - // activeView.state.tr.removeMark( - // singleComment.pos, - // singleComment.pos + singleComment.node.nodeSize, - // commentMark, - // ), - // ); - - // if (activeViewId !== 'main') { - // activeView.dispatch( - // activeView.state.tr - // .addMark( - // singleComment.pos, - // singleComment.pos + singleComment.node.nodeSize, - // commentMark.create({ - // id, - // group: comment.attrs.group, - // viewid: comment.attrs.viewid, - // conversation: comment.attrs.conversation, - // title: comment.attrs.title, - // }), - // ) - // .setMeta('forceUpdate', true), - // ); - // } - // }); - - // if (activeViewId === 'main') { - // Commands.createComment( - // pmViews.main.state, - // pmViews.main.dispatch, - // comment.attrs.group, - // comment.attrs.viewid, - // comment.attrs.conversation, - // ); - // } - // activeView.focus(); - // recalculateTops(); - // }; - const onClickPost = ({ commentValue, title }) => { setClickPost(true); const currentUser = user || (users || []).find(u => u.currentUser === true); @@ -156,22 +98,35 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ), ); - activeView.dispatch( - activeView.state.tr - .addMark( - singleComment.pos, - singleComment.pos + singleComment.node.nodeSize, - commentMark.create({ - id, - group: comment.attrs.group, - viewid: comment.attrs.viewid, - conversation: comment.attrs.conversation, - title: comment.attrs.title, - }), - ) - .setMeta('forceUpdate', true), - ); + if (activeViewId !== 'main') { + activeView.dispatch( + activeView.state.tr + .addMark( + singleComment.pos, + singleComment.pos + singleComment.node.nodeSize, + commentMark.create({ + id, + group: comment.attrs.group, + viewid: comment.attrs.viewid, + conversation: comment.attrs.conversation, + title: comment.attrs.title, + }), + ) + .setMeta('forceUpdate', true), + ); + } }); + + if (activeViewId === 'main') { + Commands.createComment( + pmViews.main.state, + pmViews.main.dispatch, + comment.attrs.group, + comment.attrs.viewid, + comment.attrs.conversation, + comment.attrs.title, + ); + } activeView.focus(); recalculateTops(); };