From d76bf7af9ca607d912f1f961c77f998088fd9234 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 18 May 2021 12:12:10 +0300 Subject: [PATCH] copy paste notes --- .../src/helpers/TransformPasted.js | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/wax-prosemirror-core/src/helpers/TransformPasted.js b/wax-prosemirror-core/src/helpers/TransformPasted.js index d8e3ea425..9a4ce541f 100644 --- a/wax-prosemirror-core/src/helpers/TransformPasted.js +++ b/wax-prosemirror-core/src/helpers/TransformPasted.js @@ -1,6 +1,6 @@ /* 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(); + }); }); } -- GitLab