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 array-callback-return */
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
import { forEach } from 'lodash'; import { forEach, each } 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';
...@@ -36,15 +36,22 @@ const transformPasted = (slice, view) => { ...@@ -36,15 +36,22 @@ const transformPasted = (slice, view) => {
}); });
} }
if (view.state.schema.nodes.footnote) { const schemaNotes = [];
const notes = DocumentHelpers.findChildrenByType( each(view.state.schema.nodes, node => {
content, if (node.groups.includes('notes')) schemaNotes.push(node);
view.state.schema.nodes.footnote, });
true,
); if (schemaNotes.length > 0) {
schemaNotes.forEach(schemaNote => {
notes.forEach(note => { const notes = DocumentHelpers.findChildrenByType(
note.node.attrs.id = uuidv4(); 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