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

loop through each child

parent 93735c9d
No related branches found
No related tags found
1 merge request!168Fix rerender notes
......@@ -52,7 +52,7 @@ const Editoria = () => (
// value={`<p class="paragraph">This is the first paragraph</p><p class="paragraph">This is the second paragraph</p><p class="author">This is an author</p>`}
layout={EditoriaLayout}
// debug
// onChange={source => console.log(source)}
onChange={source => console.log(source)}
user={user}
/>
</Fragment>
......
......@@ -4,16 +4,19 @@ const getHTMLString = node => {
if (textContent) {
let strContent = textContent;
for (let i = 0; i < node.content.content[0].marks.length; i += 1) {
const mark = node.content.content[0].marks[i];
const { type: markType } = mark;
const domDetails = markType.spec.toDOM(mark);
const htmlAttrs = Object.keys(domDetails[1]).reduce(
(str, key) => `${str}${key}="${domDetails[1][key]}"`,
'',
);
const htmlTag = domDetails[0];
strContent = `<${htmlTag} ${htmlAttrs}>${strContent}</${htmlTag}>`;
for (let i = 0; i < node.content.content.length; i += 1) {
for (let j = 0; j < node.content.content[i].marks.length; j += 1) {
const mark = node.content.content[i].marks[j];
const { type: markType } = mark;
const domDetails = markType.spec.toDOM(mark);
const htmlAttrs = Object.keys(domDetails[1]).reduce(
(str, key) => `${str}${key}="${domDetails[1][key]}"`,
'',
);
const htmlTag = domDetails[0];
strContent = `<${htmlTag} ${htmlAttrs}>${strContent}</${htmlTag}>`;
}
}
return strContent;
}
......
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