google-docs-components
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -25,5 +25,24 @@ "use strict"; | ||
const tag = list.ordered ? "ol" : "ul"; | ||
const toListItems = (elements) => { | ||
const listItems = []; | ||
elements.forEach((child) => { | ||
if (listItems.length && (child === null || child === void 0 ? void 0 : child.element) == "ul" || child.element == "ol") { | ||
listItems[listItems.length - 1].children.push(child); | ||
return; | ||
} | ||
if (child.children) { | ||
//Google Docs considers list items as paragraphs, but we don't want that in our html | ||
listItems.push(Object.assign({}, child, { element: "li" })); | ||
return; | ||
} | ||
listItems.push({ | ||
element: "li", | ||
children: [child] | ||
}); | ||
}); | ||
return listItems; | ||
}; | ||
const data = { | ||
element: tag, | ||
children: parseContent(list.items) | ||
children: toListItems(parseContent(list.items)) | ||
}; | ||
@@ -30,0 +49,0 @@ return data; |
@@ -19,5 +19,24 @@ import componentFromTable from "./processTable"; | ||
const tag = list.ordered ? "ol" : "ul"; | ||
const toListItems = (elements) => { | ||
const listItems = []; | ||
elements.forEach((child) => { | ||
if (listItems.length && (child === null || child === void 0 ? void 0 : child.element) == "ul" || child.element == "ol") { | ||
listItems[listItems.length - 1].children.push(child); | ||
return; | ||
} | ||
if (child.children) { | ||
//Google Docs considers list items as paragraphs, but we don't want that in our html | ||
listItems.push(Object.assign({}, child, { element: "li" })); | ||
return; | ||
} | ||
listItems.push({ | ||
element: "li", | ||
children: [child] | ||
}); | ||
}); | ||
return listItems; | ||
}; | ||
const data = { | ||
element: tag, | ||
children: parseContent(list.items) | ||
children: toListItems(parseContent(list.items)) | ||
}; | ||
@@ -24,0 +43,0 @@ return data; |
{ | ||
"name": "google-docs-components", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "./dist/cjs/index.js", | ||
@@ -5,0 +5,0 @@ "module": "./dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
46398
665