diff --git a/editors/demo/src/OEN/OEN.js b/editors/demo/src/OEN/OEN.js index 9066fdf7877b1b104409df6eb2a381b9b20bf8fa..cb1f6e08f13af7f510cfb804d1904cf58b46c7f5 100644 --- a/editors/demo/src/OEN/OEN.js +++ b/editors/demo/src/OEN/OEN.js @@ -25,7 +25,7 @@ const user = { username: 'admin', }; -const val = `<p>first paragraph</p><section class=\"whatever\"><h2>Section 1 heading 2</h2><p class=\"paragraph\">normal text</p></section><section class=\"whatever\"><h2>Section 2 heading 2</h2><p class=\"paragraph\">normal text</p></section><section class=\"whatever\"><p class=\"paragraph\">dfsfsdfs</p><p class=\"paragraph\">normal text</p></section><section class=\"whatever\"><h2>Section 4 heading 2</h2><p class=\"paragraph\">normal text</p></section><p class=\"paragraph\">some text</p><div class=\"outline\" data-type=\"content_structure_element\"><p class=\"paragraph\"></p></div>`; +const val = `<p>first paragraph</p><section class=\"whatever\"><h2>Section 1 heading 2</h2><p class=\"paragraph\">normal text</p></section><section class=\"whatever\"><h2>Section 2 heading 2</h2><p class=\"paragraph\">normal text</p></section><section class=\"whatever\"><p class=\"paragraph\">some normal text</p><p class=\"paragraph\">more normal text</p></section><section class=\"whatever\"><h2>Section 4 heading 2</h2><p class=\"paragraph\">normal text</p></section><p class=\"paragraph\">some text</p><div class=\"outline\" data-type=\"content_structure_element\"><p class=\"paragraph\"></p></div>`; const Oen = () => { const editorRef = useRef(); @@ -40,9 +40,9 @@ const Oen = () => { value={val} // readonly layout={OenLayout} - onChange={debounce(source => { - console.log(JSON.stringify(source)); - }, 200)} + // onChange={debounce(source => { + // console.log(JSON.stringify(source)); + // }, 200)} user={user} /> ); diff --git a/wax-prosemirror-services/src/OENContainersService/PopulateHeadingsComponent.js b/wax-prosemirror-services/src/OENContainersService/PopulateHeadingsComponent.js index 0b565f4ec116196470b2b9d9e1fbc9c45ae65761..1b7e8adb6a152ad78582eaf5021e0f734e6c3b66 100644 --- a/wax-prosemirror-services/src/OENContainersService/PopulateHeadingsComponent.js +++ b/wax-prosemirror-services/src/OENContainersService/PopulateHeadingsComponent.js @@ -91,9 +91,9 @@ export default ({ setPosition, position }) => { allSectionNodes.forEach((node, index) => { node.content.content.forEach(contentNode => { if (contentNode.type.name === 'heading2') { - sectionHeadings[index] = [contentNode.textContent]; + sectionHeadings[index] = contentNode.textContent; } else if (!sectionHeadings[index]) { - sectionHeadings[index] = ['untitled']; + sectionHeadings[index] = 'untitled'; } }); }); @@ -101,6 +101,14 @@ export default ({ setPosition, position }) => { let sectionNode; let sectionNodePosition; + let content = `<ul>`; + + Object.keys(sectionHeadings).forEach(index => { + content += `<li>${sectionHeadings[index]}</li>`; + }); + + content += `</ul>`; + main.state.doc.nodesBetween(from, to, (node, pos) => { if (node.type.name === 'oen_container') { sectionNode = node; @@ -108,8 +116,6 @@ export default ({ setPosition, position }) => { } }); - let content = ''; - const parser = DOMParser.fromSchema(main.state.config.schema); const parsedContent = parser.parse(elementFromString(content));