From 9156ccc42aa4252305236e89cd561a596c28c702 Mon Sep 17 00:00:00 2001 From: chris <kokosias@yahoo.gr> Date: Tue, 18 May 2021 12:16:34 +0300 Subject: [PATCH] find and replace look for note groups --- editors/demo/src/Editoria/Editoria.js | 2 +- .../src/components/findAndReplace/helpers.js | 24 +++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/editors/demo/src/Editoria/Editoria.js b/editors/demo/src/Editoria/Editoria.js index 98a5f9cb5..42a690860 100644 --- a/editors/demo/src/Editoria/Editoria.js +++ b/editors/demo/src/Editoria/Editoria.js @@ -50,7 +50,7 @@ const Editoria = () => { value={demo} // readonly layout={layout} - onChange={source => console.log(source)} + // onChange={source => console.log(source)} user={user} /> </> diff --git a/wax-prosemirror-components/src/components/findAndReplace/helpers.js b/wax-prosemirror-components/src/components/findAndReplace/helpers.js index 2100e93dd..5aee17bcd 100644 --- a/wax-prosemirror-components/src/components/findAndReplace/helpers.js +++ b/wax-prosemirror-components/src/components/findAndReplace/helpers.js @@ -32,14 +32,24 @@ const getAllResultsByView = (view, searchValue, matchCaseSearch) => { const getNotesIds = main => { const notesIds = []; - const notes = DocumentHelpers.findChildrenByType( - main.state.doc, - main.state.schema.nodes.footnote, - true, - ); - notes.forEach(note => { - notesIds.push(note.node.attrs.id); + const schemaNotes = []; + each(main.state.schema.nodes, node => { + if (node.groups.includes('notes')) schemaNotes.push(node); }); + + if (schemaNotes.length > 0) { + schemaNotes.forEach(schemaNote => { + const notes = DocumentHelpers.findChildrenByType( + main.state.doc, + main.state.schema.nodes[schemaNote.name], + true, + ); + notes.forEach(note => { + notesIds.push(note.node.attrs.id); + }); + }); + } + return notesIds; }; -- GitLab