Newer
Older
import { minBy, maxBy, last } from 'lodash';
import { Plugin, PluginKey } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';
import { DocumentHelpers } from 'wax-prosemirror-core';
const getComment = (state, context) => {
const {
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,
};
state: {
init: (_, state) => {
},
apply(tr, prev, _, newState) {
let createDecoration;
if (comment) {
createDecoration = DecorationSet.create(newState.doc, [
Decoration.inline(comment.from, comment.to, {
]);
}
return {
comment,
const commentPluginState = state && commentPlugin.getState(state);
return commentPluginState.createDecoration;