@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.mjs
CHANGED
|
@@ -1653,10 +1653,14 @@ function serializeBlock(node, idCounts = /* @__PURE__ */ new Map()) {
|
|
|
1653
1653
|
case "list_item":
|
|
1654
1654
|
return `<li>${serializeChildren(node.children)}</li>`;
|
|
1655
1655
|
case "check_list":
|
|
1656
|
-
return `<ul data-type="checklist">${serializeChildren(node.children)}</ul>`;
|
|
1656
|
+
return `<ul class="todo-list" data-type="checklist">${serializeChildren(node.children)}</ul>`;
|
|
1657
1657
|
case "check_list_item": {
|
|
1658
|
-
const checked = ((_g = node.attrs) == null ? void 0 : _g.checked)
|
|
1659
|
-
|
|
1658
|
+
const checked = !!((_g = node.attrs) == null ? void 0 : _g.checked);
|
|
1659
|
+
const dataChecked = checked ? ' data-checked="true"' : "";
|
|
1660
|
+
const itemClass = `todo-list__item${checked ? " todo-list__item_checked" : ""}`;
|
|
1661
|
+
const checkedAttr = checked ? ' checked="checked"' : "";
|
|
1662
|
+
const innerContent = serializeChildren(node.children);
|
|
1663
|
+
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>`;
|
|
1660
1664
|
}
|
|
1661
1665
|
case "code_block": {
|
|
1662
1666
|
const lang = ((_h = node.attrs) == null ? void 0 : _h.language) ? ` class="language-${node.attrs.language}"` : "";
|
|
@@ -1929,6 +1933,7 @@ function parseInlineChildren(el) {
|
|
|
1929
1933
|
results.push({ type: "text", text: "\n", marks: [...marks] });
|
|
1930
1934
|
return;
|
|
1931
1935
|
}
|
|
1936
|
+
if (tag === "input") return;
|
|
1932
1937
|
const newMarks = [...marks, ...getMarksForTag(tag, elem)];
|
|
1933
1938
|
for (const child of Array.from(elem.childNodes)) {
|
|
1934
1939
|
walk(child, newMarks);
|
|
@@ -2276,8 +2281,14 @@ function normalizeHTML(html) {
|
|
|
2276
2281
|
const parser = new DOMParser();
|
|
2277
2282
|
const doc = parser.parseFromString(out, "text/html");
|
|
2278
2283
|
doc.querySelectorAll(
|
|
2279
|
-
"script, style, iframe, object, embed, form,
|
|
2284
|
+
"script, style, iframe, object, embed, form, button, select, textarea, meta, link"
|
|
2280
2285
|
).forEach((el) => el.remove());
|
|
2286
|
+
doc.querySelectorAll("input").forEach((el) => {
|
|
2287
|
+
var _a;
|
|
2288
|
+
const isCheckbox = ((_a = el.getAttribute("type")) == null ? void 0 : _a.toLowerCase()) === "checkbox";
|
|
2289
|
+
const inTodoList = !!el.closest('ul[data-type="checklist"], ul.todo-list, li.todo-list__item, li[data-checked]');
|
|
2290
|
+
if (!isCheckbox || !inTodoList) el.remove();
|
|
2291
|
+
});
|
|
2281
2292
|
doc.querySelectorAll("b").forEach((el) => {
|
|
2282
2293
|
const fw = el.style.fontWeight;
|
|
2283
2294
|
if (fw === "normal" || fw === "400" || fw === "inherit" || fw === "") {
|