Skip to content
Snippets Groups Projects
Commit 251ed7e4 authored by chris's avatar chris
Browse files

keep all section headings

parent 5f063550
No related branches found
No related tags found
1 merge request!407Hhmi fixes
...@@ -25,10 +25,7 @@ const user = { ...@@ -25,10 +25,7 @@ const user = {
username: 'admin', username: 'admin',
}; };
const val = `<h3>33333</h3><section class="section"><div class="introduction" data-type="content_structure_element"><p>Intro</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\">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>`;
<div class="outline" data-type="content_structure_element"><h1>heading when i click note</h1><p>some text when i click note</p></div></section>
<section class="section"><div class="introduction" data-type="content_structure_element"><p>Intro</p></div>
<div class="outline" data-type="content_structure_element"><p>outline</p></div></section>`;
const Oen = () => { const Oen = () => {
const editorRef = useRef(); const editorRef = useRef();
...@@ -43,9 +40,9 @@ const Oen = () => { ...@@ -43,9 +40,9 @@ const Oen = () => {
value={val} value={val}
// readonly // readonly
layout={OenLayout} layout={OenLayout}
// onChange={debounce(source => { onChange={debounce(source => {
// console.log(JSON.stringify(source)); console.log(JSON.stringify(source));
// }, 200)} }, 200)}
user={user} user={user}
/> />
); );
......
...@@ -80,6 +80,7 @@ export default ({ setPosition, position }) => { ...@@ -80,6 +80,7 @@ export default ({ setPosition, position }) => {
} = main.state; } = main.state;
const allSectionNodes = []; const allSectionNodes = [];
const sectionHeadings = {};
doc.descendants((editorNode, index) => { doc.descendants((editorNode, index) => {
if (editorNode.type.name === 'oen_section') { if (editorNode.type.name === 'oen_section') {
...@@ -87,6 +88,16 @@ export default ({ setPosition, position }) => { ...@@ -87,6 +88,16 @@ export default ({ setPosition, position }) => {
} }
}); });
allSectionNodes.forEach((node, index) => {
node.content.content.forEach(contentNode => {
if (contentNode.type.name === 'heading2') {
sectionHeadings[index] = [contentNode.textContent];
} else if (!sectionHeadings[index]) {
sectionHeadings[index] = ['untitled'];
}
});
});
let sectionNode; let sectionNode;
let sectionNodePosition; let sectionNodePosition;
......
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