@trafica/editor 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +15 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -4
- package/dist/index.mjs.map +1 -1
- package/dist/styles/editor.css +86 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1655,10 +1655,14 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map()) {
|
|
|
1655
1655
|
case "list_item":
|
|
1656
1656
|
return `<li>${serializeChildren(node.children)}</li>`;
|
|
1657
1657
|
case "check_list":
|
|
1658
|
-
return `<ul data-type="checklist">${serializeChildren(node.children)}</ul>`;
|
|
1658
|
+
return `<ul class="todo-list" data-type="checklist">${serializeChildren(node.children)}</ul>`;
|
|
1659
1659
|
case "check_list_item": {
|
|
1660
|
-
const checked = ((_g = node.attrs) == null ? void 0 : _g.checked)
|
|
1661
|
-
|
|
1660
|
+
const checked = !!((_g = node.attrs) == null ? void 0 : _g.checked);
|
|
1661
|
+
const dataChecked = checked ? ' data-checked="true"' : "";
|
|
1662
|
+
const itemClass = `todo-list__item${checked ? " todo-list__item_checked" : ""}`;
|
|
1663
|
+
const checkedAttr = checked ? ' checked="checked"' : "";
|
|
1664
|
+
const innerContent = serializeChildren(node.children);
|
|
1665
|
+
return `<li class="${itemClass}"${dataChecked}><label class="todo-list__label"><input type="checkbox" disabled="disabled"${checkedAttr}><span class="todo-list__label__description">${innerContent}</span></label></li>`;
|
|
1662
1666
|
}
|
|
1663
1667
|
case "code_block": {
|
|
1664
1668
|
const lang = ((_h = node.attrs) == null ? void 0 : _h.language) ? ` class="language-${node.attrs.language}"` : "";
|
|
@@ -1931,6 +1935,7 @@ function parseInlineChildren(el) {
|
|
|
1931
1935
|
results.push({ type: "text", text: "\n", marks: [...marks] });
|
|
1932
1936
|
return;
|
|
1933
1937
|
}
|
|
1938
|
+
if (tag === "input") return;
|
|
1934
1939
|
const newMarks = [...marks, ...getMarksForTag(tag, elem)];
|
|
1935
1940
|
for (const child of Array.from(elem.childNodes)) {
|
|
1936
1941
|
walk(child, newMarks);
|
|
@@ -2278,8 +2283,14 @@ function normalizeHTML(html) {
|
|
|
2278
2283
|
const parser = new DOMParser();
|
|
2279
2284
|
const doc = parser.parseFromString(out, "text/html");
|
|
2280
2285
|
doc.querySelectorAll(
|
|
2281
|
-
"script, style, iframe, object, embed, form,
|
|
2286
|
+
"script, style, iframe, object, embed, form, button, select, textarea, meta, link"
|
|
2282
2287
|
).forEach((el) => el.remove());
|
|
2288
|
+
doc.querySelectorAll("input").forEach((el) => {
|
|
2289
|
+
var _a;
|
|
2290
|
+
const isCheckbox = ((_a = el.getAttribute("type")) == null ? void 0 : _a.toLowerCase()) === "checkbox";
|
|
2291
|
+
const inTodoList = !!el.closest('ul[data-type="checklist"], ul.todo-list, li.todo-list__item, li[data-checked]');
|
|
2292
|
+
if (!isCheckbox || !inTodoList) el.remove();
|
|
2293
|
+
});
|
|
2283
2294
|
doc.querySelectorAll("b").forEach((el) => {
|
|
2284
2295
|
const fw = el.style.fontWeight;
|
|
2285
2296
|
if (fw === "normal" || fw === "400" || fw === "inherit" || fw === "") {
|