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

copy paste notes

parent 34cd9c6e
No related branches found
No related tags found
1 merge request!294Inline question
/* eslint-disable array-callback-return */
/* eslint-disable no-param-reassign */
import { forEach } from 'lodash';
import { forEach, each } from 'lodash';
import { v4 as uuidv4 } from 'uuid';
import { DocumentHelpers } from 'wax-prosemirror-utilities';
......@@ -36,15 +36,22 @@ const transformPasted = (slice, view) => {
});
}
if (view.state.schema.nodes.footnote) {
const notes = DocumentHelpers.findChildrenByType(
content,
view.state.schema.nodes.footnote,
true,
);
notes.forEach(note => {
note.node.attrs.id = uuidv4();
const schemaNotes = [];
each(view.state.schema.nodes, node => {
if (node.groups.includes('notes')) schemaNotes.push(node);
});
if (schemaNotes.length > 0) {
schemaNotes.forEach(schemaNote => {
const notes = DocumentHelpers.findChildrenByType(
content,
view.state.schema.nodes[schemaNote.name],
true,
);
notes.forEach(note => {
note.node.attrs.id = uuidv4();
});
});
}
......
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