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

transform comment before merging them into document

parent 1d17fcbf
No related branches found
No related tags found
1 merge request!105transform comment before merging them into document
......@@ -3,10 +3,12 @@ import React, { useEffect, useRef, useContext } from "react";
import applyDevTools from "prosemirror-dev-tools";
import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import "prosemirror-view/style/prosemirror.css";
import { trackedTransaction } from "wax-prosemirror-services";
import { WaxContext } from "./ioc-react";
import transformPasted from "./helpers/TransformPasted";
export default props => {
const {
......@@ -36,6 +38,9 @@ export default props => {
onBlur(view.state.doc.content);
}
: null
},
transformPasted: slice => {
return transformPasted(slice, view);
}
}
);
......
import { v4 as uuidv4 } from "uuid";
import { DocumentHelpers } from "wax-prosemirror-utilities";
const transformPasted = (slice, view) => {
const { content } = slice;
const commentNodes = DocumentHelpers.findChildrenByMark(
content,
view.state.schema.marks.comment,
true
);
const allComments = commentNodes.map(node => {
return node.node.marks.filter(comment => {
return comment.type.name === "comment";
});
});
allComments.forEach(comment => {
comment[0].attrs.id = uuidv4();
});
return slice;
};
export default transformPasted;
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