diff --git a/wax-prosemirror-core/src/helpers/TransformPasted.js b/wax-prosemirror-core/src/helpers/TransformPasted.js index d8e3ea42581e503cb4dd771e97fe289ca1e617f1..9a4ce541f0ae0911fedf9761b523e70031fa4dee 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(); + }); }); }