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