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