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

set active comment

parent 594d4e79
No related branches found
No related tags found
2 merge requests!548Merge yjs with standard comments,!545Overlapping comments
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
} }
span.comment .active-comment { .active-comment {
background-color: gold; background-color: gold;
/* color: black; */ /* color: black; */
} }
\ No newline at end of file
...@@ -33,6 +33,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ...@@ -33,6 +33,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
app, app,
activeView, activeView,
activeViewId, activeViewId,
options: { comments },
} = context; } = context;
const [isActive, setIsActive] = useState(false); const [isActive, setIsActive] = useState(false);
...@@ -164,7 +165,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ...@@ -164,7 +165,7 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
// } // }
setTimeout(() => { setTimeout(() => {
if (conversation.length === 0 && !clickPost) { if (conversation.length === 0 && !clickPost) {
onClickResolve(); // onClickResolve();
activeView.focus(); activeView.focus();
} }
}, 400); }, 400);
......
...@@ -52,6 +52,7 @@ export default ({ area, users }) => { ...@@ -52,6 +52,7 @@ export default ({ area, users }) => {
let activeTrackChange = null; let activeTrackChange = null;
const activeComment = commentPlugin.getState(activeView.state).comment; const activeComment = commentPlugin.getState(activeView.state).comment;
if (trakChangePlugin) if (trakChangePlugin)
activeTrackChange = trakChangePlugin.getState(activeView.state) activeTrackChange = trakChangePlugin.getState(activeView.state)
.trackChange; .trackChange;
......
/* eslint-disable */ /* eslint-disable consistent-return */
import { inRange, sortBy, last } from 'lodash';
import { minBy, maxBy, last } from 'lodash';
import { Plugin, PluginKey } from 'prosemirror-state'; import { Plugin, PluginKey } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view'; import { Decoration, DecorationSet } from 'prosemirror-view';
import { DocumentHelpers } from 'wax-prosemirror-core';
const commentPlugin = new PluginKey('commentPlugin'); const commentPlugin = new PluginKey('commentPlugin');
...@@ -12,18 +10,25 @@ const getComment = (state, context) => { ...@@ -12,18 +10,25 @@ const getComment = (state, context) => {
options: { comments }, options: { comments },
} = context; } = context;
if (!comments?.length) return; if (!comments?.length) return;
console.log('sds', comments);
return { let commentData = comments.filter(comment =>
from: comments[0].from, inRange(state.selection.from, comment.from, comment.to),
to: comments[0].to, );
attrs: comments[0].data,
id: comments[0].id, commentData = sortBy(commentData, ['from']);
// contained: commentOnSelection.contained,
}; if (commentData.length > 0) {
return {
from: last(commentData).from,
to: last(commentData).to,
attrs: last(commentData).data,
id: last(commentData).id,
// contained: commentOnSelection.contained,
};
}
return {};
}; };
c;
export default (key, context) => { export default (key, context) => {
return new Plugin({ return new Plugin({
key: commentPlugin, key: commentPlugin,
......
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