Skip to content
Snippets Groups Projects
Commit 309ae46f authored by chris's avatar chris
Browse files

populate content

parent 251ed7e4
No related branches found
No related tags found
1 merge request!407Hhmi fixes
......@@ -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}
/>
);
......
......@@ -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));
......
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