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

keep in grouped comments same id

parent 81629090
No related branches found
No related tags found
1 merge request!108show comments as one in plugin
import { forEach } from "lodash";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { DocumentHelpers } from "wax-prosemirror-utilities"; import { DocumentHelpers } from "wax-prosemirror-utilities";
...@@ -30,10 +31,12 @@ const transformPasted = (slice, view) => { ...@@ -30,10 +31,12 @@ const transformPasted = (slice, view) => {
return obj; return obj;
}, {}); }, {});
//TODO check to alter attr with transform forEach(Object.keys(groupedCommentsById), key => {
// allComments.forEach(comment => { let id = uuidv4();
// comment[0].attrs.id = uuidv4(); forEach(groupedCommentsById[key], comment => {
// }); comment.attrs.id = id;
});
});
notes.forEach(note => { notes.forEach(note => {
note.node.attrs.id = uuidv4(); note.node.attrs.id = uuidv4();
......
import { forEach } from "lodash";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import { DocumentHelpers } from "wax-prosemirror-utilities"; import { DocumentHelpers } from "wax-prosemirror-utilities";
...@@ -9,15 +10,26 @@ const transformPasted = (slice, view) => { ...@@ -9,15 +10,26 @@ const transformPasted = (slice, view) => {
true true
); );
const allComments = commentNodes.map(node => { const allComments = [];
return node.node.marks.filter(comment => {
return comment.type.name === "comment"; commentNodes.map(node => {
node.node.marks.map(comment => {
if (comment.type.name === "comment") {
allComments.push(comment);
}
}); });
}); });
//TODO check to alter attr with transform let groupedCommentsById = allComments.reduce((obj, mark) => {
allComments.forEach(comment => { obj[mark.attrs.id] = [...(obj[mark.attrs.id] || []), mark];
comment[0].attrs.id = uuidv4(); return obj;
}, {});
forEach(Object.keys(groupedCommentsById), key => {
let id = uuidv4();
forEach(groupedCommentsById[key], comment => {
comment.attrs.id = id;
});
}); });
return slice; return slice;
......
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