@editora/core
Advanced tools
| const T = () => ({ | ||
| name: "clearFormatting", | ||
| // Toolbar button configuration | ||
| toolbar: [ | ||
| { | ||
| label: "Clear Formatting", | ||
| command: "clearFormatting", | ||
| icon: '<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>', | ||
| shortcut: "Mod-\\" | ||
| } | ||
| ], | ||
| // Native command implementations | ||
| commands: { | ||
| /** | ||
| * Remove all formatting from current selection | ||
| */ | ||
| clearFormatting: () => { | ||
| const t = h(); | ||
| if (!t) return !1; | ||
| const e = window.getSelection(); | ||
| if (!e || e.rangeCount === 0) return !1; | ||
| const n = e.getRangeAt(0); | ||
| if (!t.contains(n.commonAncestorContainer)) return !1; | ||
| const r = n.cloneRange(); | ||
| return t.focus({ preventScroll: !0 }), C(t, r), y(t, r), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0; | ||
| } | ||
| }, | ||
| // Keyboard shortcuts | ||
| keymap: { | ||
| "Mod-\\": "clearFormatting" | ||
| } | ||
| }), u = /* @__PURE__ */ new Set([ | ||
| "A", | ||
| "B", | ||
| "STRONG", | ||
| "I", | ||
| "EM", | ||
| "U", | ||
| "S", | ||
| "STRIKE", | ||
| "DEL", | ||
| "FONT", | ||
| "MARK", | ||
| "CODE", | ||
| "SUB", | ||
| "SUP" | ||
| ]), d = /* @__PURE__ */ new Set([ | ||
| "H1", | ||
| "H2", | ||
| "H3", | ||
| "H4", | ||
| "H5", | ||
| "H6", | ||
| "BLOCKQUOTE", | ||
| "PRE" | ||
| ]), g = [ | ||
| "color", | ||
| "background-color", | ||
| "font-size", | ||
| "font-family", | ||
| "font-weight", | ||
| "font-style", | ||
| "text-decoration", | ||
| "text-transform", | ||
| "line-height", | ||
| "letter-spacing", | ||
| "word-spacing", | ||
| "vertical-align", | ||
| "text-align", | ||
| "padding-left" | ||
| ]; | ||
| function h() { | ||
| const t = window.getSelection(); | ||
| if (t && t.rangeCount > 0) { | ||
| const n = t.getRangeAt(0).startContainer, r = n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement, o = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content'); | ||
| if (o) return o; | ||
| } | ||
| const e = document.activeElement; | ||
| return e ? e.getAttribute("contenteditable") === "true" ? e : e.closest('[contenteditable="true"], .rte-content, .editora-content') : null; | ||
| } | ||
| function c(t, e) { | ||
| try { | ||
| if (typeof t.intersectsNode == "function") | ||
| return t.intersectsNode(e); | ||
| } catch (r) { | ||
| } | ||
| const n = document.createRange(); | ||
| return e.nodeType === Node.ELEMENT_NODE ? n.selectNodeContents(e) : n.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, n) > 0 && t.compareBoundaryPoints(Range.START_TO_END, n) < 0; | ||
| } | ||
| function a(t) { | ||
| let e = 0, n = t; | ||
| for (; n && n.parentNode; ) | ||
| e += 1, n = n.parentNode; | ||
| return e; | ||
| } | ||
| function m(t) { | ||
| g.forEach((e) => { | ||
| t.style.removeProperty(e); | ||
| }), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.contains("rte-format-painted") && t.classList.remove("rte-format-painted"), t.classList.length === 0 && t.removeAttribute("class"); | ||
| } | ||
| function i(t) { | ||
| const e = t.parentNode; | ||
| if (e) { | ||
| for (; t.firstChild; ) | ||
| e.insertBefore(t.firstChild, t); | ||
| e.removeChild(t); | ||
| } | ||
| } | ||
| function E(t) { | ||
| return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol"); | ||
| } | ||
| function l(t) { | ||
| Array.from(t.children).forEach((e) => { | ||
| E(e) && e.remove(); | ||
| }); | ||
| } | ||
| function s(t) { | ||
| l(t), i(t); | ||
| } | ||
| function f(t) { | ||
| var n; | ||
| const e = document.createElement("p"); | ||
| for (Array.from(t.attributes).forEach((r) => { | ||
| e.setAttribute(r.name, r.value); | ||
| }); t.firstChild; ) | ||
| e.appendChild(t.firstChild); | ||
| e.innerHTML.trim() || (e.innerHTML = "<br>"), (n = t.parentNode) == null || n.replaceChild(e, t); | ||
| } | ||
| function p(t) { | ||
| return !/^(A|B|STRONG|I|EM|U|S|STRIKE|DEL|FONT|MARK|CODE|SUB|SUP|SPAN)$/.test(t.tagName) || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, svg, math"); | ||
| } | ||
| function N(t) { | ||
| Array.from( | ||
| t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span") | ||
| ).sort((n, r) => a(r) - a(n)).forEach((n) => { | ||
| n.isConnected && p(n) && n.remove(); | ||
| }); | ||
| } | ||
| function A(t) { | ||
| if (l(t), t.parentElement instanceof HTMLLIElement) { | ||
| s(t); | ||
| return; | ||
| } | ||
| if (Array.from(t.childNodes).filter((o) => o.nodeType !== Node.TEXT_NODE || (o.textContent || "").trim() !== "").some((o) => o instanceof HTMLElement && /^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))) { | ||
| s(t); | ||
| return; | ||
| } | ||
| f(t); | ||
| } | ||
| function y(t, e) { | ||
| Array.from( | ||
| t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre") | ||
| ).forEach((r) => { | ||
| if (c(e, r) && d.has(r.tagName)) { | ||
| if (r.tagName === "BLOCKQUOTE") { | ||
| A(r); | ||
| return; | ||
| } | ||
| f(r); | ||
| } | ||
| }); | ||
| } | ||
| function C(t, e) { | ||
| const n = Array.from( | ||
| t.querySelectorAll( | ||
| "a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]" | ||
| ) | ||
| ); | ||
| n.sort((r, o) => a(o) - a(r)), n.forEach((r) => { | ||
| if (r.isConnected && c(e, r) && !(r.getAttribute("contenteditable") === "false" || r.closest('[contenteditable="false"]'))) { | ||
| if (m(r), u.has(r.tagName)) { | ||
| i(r); | ||
| return; | ||
| } | ||
| r.tagName === "SPAN" && r.attributes.length === 0 && i(r); | ||
| } | ||
| }), N(t); | ||
| } | ||
| export { | ||
| T as ClearFormattingPlugin | ||
| }; | ||
| //# sourceMappingURL=ClearFormattingPlugin.native-B6ro3a1h.mjs.map |
| const g = '.rte-content, .editora-content, [contenteditable="true"]', st = "[data-editora-editor], .rte-editor, .editora-editor, editora-editor", b = "p,div,li,h1,h2,h3,h4,h5,h6,blockquote,pre,td,th", _ = "ul,ol", y = "b,strong,i,em,u,s,strike,font,span", w = "td,th", m = "data-editora-format-painter-bookmark", O = ["link", "address", "comments", "citations", "track-changes"], L = [ | ||
| "fontFamily", | ||
| "fontSize", | ||
| "color", | ||
| "backgroundColor", | ||
| "textTransform" | ||
| ], at = [ | ||
| "textAlign", | ||
| "lineHeight", | ||
| "marginLeft", | ||
| "marginRight" | ||
| ], lt = ["listStyleType"], ct = [ | ||
| "borderCollapse", | ||
| "borderSpacing", | ||
| "width" | ||
| ], ut = [ | ||
| "backgroundColor", | ||
| "textAlign", | ||
| "verticalAlign", | ||
| "borderTopColor", | ||
| "borderRightColor", | ||
| "borderBottomColor", | ||
| "borderLeftColor", | ||
| "borderTopStyle", | ||
| "borderRightStyle", | ||
| "borderBottomStyle", | ||
| "borderLeftStyle", | ||
| "borderTopWidth", | ||
| "borderRightWidth", | ||
| "borderBottomWidth", | ||
| "borderLeftWidth", | ||
| "paddingTop", | ||
| "paddingRight", | ||
| "paddingBottom", | ||
| "paddingLeft" | ||
| ], X = { | ||
| background: "backgroundcolor", | ||
| bgcolor: "backgroundcolor", | ||
| blockquote: "block", | ||
| blocks: "block", | ||
| font: "fontfamily", | ||
| fontname: "fontfamily", | ||
| fontsize: "fontsize", | ||
| foreground: "color", | ||
| forecolor: "color", | ||
| heading: "block", | ||
| headings: "block", | ||
| liststyle: "list", | ||
| lists: "list", | ||
| strike: "strikethrough", | ||
| tablecell: "table", | ||
| tablecells: "table", | ||
| textcolor: "color", | ||
| texttransform: "texttransform" | ||
| }, ft = '<svg width="24" height="24" focusable="false" viewBox="0 0 24 24"><path d="M17.8 3.2a2.8 2.8 0 0 1 4 4L14 15l-4-4 7.8-7.8Zm-1.4 4.2L19 10l1.4-1.4-2.6-2.6-1.4 1.4Zm-7.8 5 3 3-1.4 1.4c-.5.5-1.2.8-1.9.8H7.2l-1.6 1.6a2.7 2.7 0 0 1-3.8 0 1 1 0 0 1 0-1.4l6.8-5.4Zm-.2 3.2H9l-4.6 3.7c.2 0 .5-.2.7-.4l1.9-1.9c.2-.2.4-.3.7-.3h1.1c.2 0 .5-.1.6-.3l.2-.2-1.2-1.3ZM5.5 3l.7 1.8L8 5.5l-1.8.7L5.5 8l-.7-1.8L3 5.5l1.8-.7L5.5 3Zm3.8 4.4.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5.5-1.2Z" fill-rule="evenodd"></path></svg>', v = /* @__PURE__ */ new WeakMap(); | ||
| let I = null, P = !1, p = { | ||
| ignoredFormats: O, | ||
| keepActiveAfterMouseApply: !1 | ||
| }; | ||
| const ne = (t = {}) => { | ||
| var n, r; | ||
| const e = { | ||
| ignoredFormats: (n = t.ignoredFormats) != null ? n : O, | ||
| keepActiveAfterMouseApply: (r = t.keepActiveAfterMouseApply) != null ? r : !1 | ||
| }; | ||
| return p = e, { | ||
| name: "formatPainter", | ||
| toolbar: [ | ||
| { | ||
| label: "Format Painter", | ||
| command: "toggleFormatPainter", | ||
| icon: ft, | ||
| shortcut: "Ctrl+Alt+C / Ctrl+Alt+V" | ||
| } | ||
| ], | ||
| commands: { | ||
| retrieveFormats: (o, i) => Y(i, e), | ||
| paintFormats: (o, i) => J(i, e), | ||
| toggleFormatPainter: (o, i) => dt(i, e), | ||
| cancelFormatPainter: (o, i) => G(i) | ||
| }, | ||
| initialize: () => { | ||
| mt(); | ||
| } | ||
| }; | ||
| }; | ||
| function Y(t, e = p) { | ||
| const n = C(t); | ||
| if (!n) return !1; | ||
| const r = U(n, e); | ||
| if (!r) return !1; | ||
| const o = E(n); | ||
| return o.options = e, o.snapshot = r, I = r, M(n, !1), !0; | ||
| } | ||
| function J(t, e = p) { | ||
| const n = C(t); | ||
| if (!n) return !1; | ||
| const r = E(n); | ||
| r.options = e; | ||
| const o = r.snapshot || I; | ||
| return o ? Q(n, o) : !1; | ||
| } | ||
| function dt(t, e = p) { | ||
| const n = C(t); | ||
| if (!n) return !1; | ||
| const r = E(n); | ||
| if (r.options = e, r.active) | ||
| return h(n, !1), !0; | ||
| const o = U(n, e); | ||
| return o ? (r.snapshot = o, I = o, h(n, !0), !0) : !1; | ||
| } | ||
| function G(t) { | ||
| const e = C(t); | ||
| return e ? (h(e, !1), !0) : (document.querySelectorAll(`${g}.rte-format-painter-active`).forEach((n) => { | ||
| h(n, !1); | ||
| }), !0); | ||
| } | ||
| function mt() { | ||
| P || typeof document == "undefined" || (P = !0, document.addEventListener("keydown", Et, !0), document.addEventListener("mouseup", gt, !0)); | ||
| } | ||
| function Et(t) { | ||
| const e = t.key.toLowerCase(), n = t.ctrlKey || t.metaKey; | ||
| if (t.key === "Escape") { | ||
| G(); | ||
| return; | ||
| } | ||
| if (!n || !t.altKey || t.shiftKey) return; | ||
| const r = j() || C(); | ||
| if (r) { | ||
| if (e === "c") { | ||
| Y({ contentElement: r }, E(r).options) && t.preventDefault(); | ||
| return; | ||
| } | ||
| e === "v" && J({ contentElement: r }, E(r).options) && t.preventDefault(); | ||
| } | ||
| } | ||
| function gt(t) { | ||
| const e = t.target; | ||
| if (e != null && e.closest(".rte-toolbar-wrapper, .editora-toolbar-container")) return; | ||
| const n = e == null ? void 0 : e.closest(g); | ||
| if (!(n instanceof HTMLElement)) return; | ||
| const r = E(n); | ||
| if (!r.active || !r.snapshot) return; | ||
| const o = window.getSelection(); | ||
| if (!o || o.rangeCount === 0 || o.getRangeAt(0).collapsed) return; | ||
| Q(n, r.snapshot) && !r.options.keepActiveAfterMouseApply && h(n, !1); | ||
| } | ||
| function E(t) { | ||
| let e = v.get(t); | ||
| return e || (e = { snapshot: null, active: !1, options: p }, v.set(t, e)), e; | ||
| } | ||
| function C(t) { | ||
| var o; | ||
| if ((t == null ? void 0 : t.contentElement) instanceof HTMLElement) return t.contentElement; | ||
| const e = D((o = t == null ? void 0 : t.editorElement) != null ? o : null); | ||
| if (e) return e; | ||
| const n = typeof window != "undefined" ? window.__editoraCommandEditorRoot : null, r = D(n); | ||
| return r || j() || ht(); | ||
| } | ||
| function D(t) { | ||
| return t ? t.matches(g) ? t : t.querySelector(g) : null; | ||
| } | ||
| function j() { | ||
| const t = window.getSelection(); | ||
| if (!t || t.rangeCount === 0) return null; | ||
| const e = t.getRangeAt(0), n = d(e.commonAncestorContainer), r = n == null ? void 0 : n.closest(g); | ||
| return r instanceof HTMLElement ? r : null; | ||
| } | ||
| function ht() { | ||
| const t = document.activeElement; | ||
| if (!(t instanceof HTMLElement)) return null; | ||
| const e = t.closest(g); | ||
| return e instanceof HTMLElement ? e : null; | ||
| } | ||
| function d(t) { | ||
| return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null; | ||
| } | ||
| function U(t, e) { | ||
| const n = window.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0) : null, o = r ? r.collapsed ? r.startContainer : r.commonAncestorContainer : null, i = d(o) || t; | ||
| if (!t.contains(i)) return null; | ||
| const s = ee(e.ignoredFormats), a = nt(i, t), l = i.closest("li"), u = l == null ? void 0 : l.closest(_), f = i.closest(w), it = f == null ? void 0 : f.closest("table"); | ||
| return { | ||
| inline: pt(r, i, t, s), | ||
| block: !c(s, "block") && a ? Nt(a, s) : null, | ||
| list: !c(s, "list") && u ? bt(u, l) : null, | ||
| table: c(s, "table") ? null : kt(it, f, s), | ||
| ignoredFormats: s | ||
| }; | ||
| } | ||
| function pt(t, e, n, r) { | ||
| if (!t || t.collapsed) | ||
| return H(e, r); | ||
| const i = Ct(t, e, n).map((s) => H(s, r)); | ||
| return Tt(i); | ||
| } | ||
| function Ct(t, e, n) { | ||
| const r = [], o = document.createTreeWalker( | ||
| t.commonAncestorContainer, | ||
| NodeFilter.SHOW_TEXT, | ||
| { | ||
| acceptNode: (s) => !n.contains(s) || !t.intersectsNode(s) ? NodeFilter.FILTER_REJECT : (s.textContent || "").trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP | ||
| } | ||
| ); | ||
| let i = o.nextNode(); | ||
| for (; i && r.length < 64; ) { | ||
| const s = d(i); | ||
| s && !r.includes(s) && r.push(s), i = o.nextNode(); | ||
| } | ||
| return r.length > 0 ? r : [e]; | ||
| } | ||
| function H(t, e) { | ||
| const n = window.getComputedStyle(t), r = {}; | ||
| c(e, "bold") || (r.bold = St(t, n)), c(e, "italic") || (r.italic = At(t, n)), c(e, "underline") || (r.underline = $(t, n, "underline")), c(e, "strikethrough") || (r.strikethrough = $(t, n, "line-through")); | ||
| const o = {}; | ||
| return L.forEach((i) => { | ||
| if (c(e, i)) return; | ||
| const s = n[i]; | ||
| yt(i, s) && (o[i] = s); | ||
| }), { marks: r, styles: o }; | ||
| } | ||
| function Tt(t) { | ||
| const e = {}; | ||
| ["bold", "italic", "underline", "strikethrough"].forEach((o) => { | ||
| const i = t.map((s) => s.marks[o]).filter((s) => s != null); | ||
| i.length !== 0 && (e[o] = i.every(Boolean)); | ||
| }); | ||
| const r = {}; | ||
| return L.forEach((o) => { | ||
| const i = t.map((s) => s.styles[o]).filter((s) => !!s); | ||
| i.length === t.length && i.every((s) => s === i[0]) && (r[o] = i[0]); | ||
| }), { marks: e, styles: r }; | ||
| } | ||
| function Nt(t, e) { | ||
| const n = window.getComputedStyle(t), r = {}; | ||
| at.forEach((s) => { | ||
| if (c(e, s)) return; | ||
| const l = t.style[s] || n[s]; | ||
| Lt(s, l) && (r[s] = l); | ||
| }); | ||
| const o = {}, i = t.getAttribute("dir") || t.style.direction; | ||
| return (i === "ltr" || i === "rtl" || i === "auto") && (o.dir = i), { | ||
| tagName: rt(t), | ||
| styles: r, | ||
| attrs: o | ||
| }; | ||
| } | ||
| function bt(t, e) { | ||
| const n = {}; | ||
| lt.forEach((i) => { | ||
| const s = t.style[i] || window.getComputedStyle(t)[i]; | ||
| s && s !== "disc" && s !== "decimal" && (n[i] = s); | ||
| }); | ||
| const r = {}; | ||
| N(t, r, "data-type"), N(t, r, "type"); | ||
| const o = {}; | ||
| return e && (N(e, o, "data-type"), N(e, o, "data-checked")), { | ||
| tagName: t.tagName.toLowerCase() === "ol" ? "ol" : "ul", | ||
| styles: n, | ||
| attrs: r, | ||
| itemAttrs: o | ||
| }; | ||
| } | ||
| function kt(t, e, n) { | ||
| return !t && !e ? null : { | ||
| table: t ? W(t, ct, n) : null, | ||
| cell: e ? W(e, ut, n) : null | ||
| }; | ||
| } | ||
| function W(t, e, n) { | ||
| const r = window.getComputedStyle(t), o = {}; | ||
| return e.forEach((i) => { | ||
| if (c(n, i)) return; | ||
| const a = t.style[i] || r[i]; | ||
| Rt(i, a) && (o[i] = a); | ||
| }), { styles: o, attrs: {} }; | ||
| } | ||
| function St(t, e) { | ||
| if (t.closest("b,strong")) return !0; | ||
| const n = e.fontWeight; | ||
| return /^(bold|bolder|[5-9]\d{2,})$/.test(n); | ||
| } | ||
| function At(t, e) { | ||
| return !!t.closest("i,em") || e.fontStyle === "italic"; | ||
| } | ||
| function $(t, e, n) { | ||
| const r = n === "underline" ? "u" : "s,strike"; | ||
| return !!t.closest(r) || e.textDecorationLine.includes(n); | ||
| } | ||
| function yt(t, e) { | ||
| return !(!e || t === "backgroundColor" && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textTransform" && e === "none"); | ||
| } | ||
| function Lt(t, e) { | ||
| return !(!e || t === "textAlign" && e === "start" || t === "lineHeight" && e === "normal" || (t === "marginLeft" || t === "marginRight") && e === "0px"); | ||
| } | ||
| function Rt(t, e) { | ||
| return !(!e || (t === "backgroundColor" || t.endsWith("Color")) && (e === "rgba(0, 0, 0, 0)" || e === "transparent") || t === "textAlign" && e === "start" || t === "verticalAlign" && e === "middle" || t.endsWith("Width") && e === "0px" || t.endsWith("Style") && e === "none" || t.startsWith("padding") && e === "0px" || t === "borderSpacing" && e === "0px" || t === "width" && e === "auto"); | ||
| } | ||
| function Q(t, e) { | ||
| const n = window.getSelection(); | ||
| if (!n || n.rangeCount === 0) return !1; | ||
| const r = n.getRangeAt(0); | ||
| if (!t.contains(r.startContainer) || !t.contains(r.endContainer)) return !1; | ||
| const o = t.innerHTML, i = !r.collapsed, s = Jt(t); | ||
| Ft(t, r, e.table), wt(t, r, e), s == null || s(); | ||
| const a = window.getSelection(), l = a && a.rangeCount > 0 ? a.getRangeAt(0) : null; | ||
| i && a && l && t.contains(l.startContainer) && t.contains(l.endContainer) && Mt(l, a, e), Ut(t), Qt(t); | ||
| const u = t.innerHTML; | ||
| return o === u ? !1 : (te(t, o, u), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0); | ||
| } | ||
| function wt(t, e, n) { | ||
| const r = Xt(t, e); | ||
| n.list && zt(r, n.list), n.block && r.forEach((o) => { | ||
| const i = o.isConnected ? o : null; | ||
| if (!i) return; | ||
| const s = Vt(i, n.block.tagName); | ||
| k(s, n.block.styles), n.block.attrs.dir ? s.setAttribute("dir", n.block.attrs.dir) : s.removeAttribute("dir"); | ||
| }); | ||
| } | ||
| function Ft(t, e, n) { | ||
| var i; | ||
| if (!n) return; | ||
| const r = Kt(t, e); | ||
| if (n.cell && r.forEach((s) => { | ||
| k(s, n.cell.styles); | ||
| }), !n.table) return; | ||
| const o = /* @__PURE__ */ new Set(); | ||
| if (r.forEach((s) => { | ||
| const a = s.closest("table"); | ||
| a instanceof HTMLElement && o.add(a); | ||
| }), o.size === 0) { | ||
| const s = (i = d(e.startContainer)) == null ? void 0 : i.closest("table"); | ||
| s instanceof HTMLElement && t.contains(s) && o.add(s); | ||
| } | ||
| o.forEach((s) => { | ||
| k(s, n.table.styles); | ||
| }); | ||
| } | ||
| function Mt(t, e, n) { | ||
| vt(t); | ||
| const r = n.inline, o = t.cloneContents(); | ||
| if (Yt(o)) { | ||
| _t(t, e, n); | ||
| return; | ||
| } | ||
| const i = t.extractContents(); | ||
| qt(i, n); | ||
| const s = document.createDocumentFragment(), a = K("start"), l = K("end"); | ||
| s.appendChild(a), s.appendChild(et(i, r)), s.appendChild(l), t.insertNode(s), Dt(a, l, n); | ||
| const u = document.createRange(); | ||
| u.setStartAfter(a), u.setEndBefore(l), e.removeAllRanges(), e.addRange(u); | ||
| } | ||
| function _t(t, e, n) { | ||
| const r = Ot(t), o = []; | ||
| if (r.forEach((s) => { | ||
| var u; | ||
| let a = It(s, t); | ||
| if (!a || !a.data.trim() || $t(a)) return; | ||
| a = xt(a, n); | ||
| const l = et(document.createTextNode(a.data), n.inline); | ||
| (u = a.parentNode) == null || u.replaceChild(l, a), o.push(l); | ||
| }), o.length === 0) return; | ||
| const i = document.createRange(); | ||
| i.setStartBefore(o[0]), i.setEndAfter(o[o.length - 1]), e.removeAllRanges(), e.addRange(i); | ||
| } | ||
| function Ot(t) { | ||
| if (t.startContainer === t.endContainer && t.startContainer.nodeType === Node.TEXT_NODE) | ||
| return [t.startContainer]; | ||
| const e = [], n = document.createTreeWalker(t.commonAncestorContainer, NodeFilter.SHOW_TEXT, { | ||
| acceptNode: (o) => !o.textContent || !o.textContent.trim() || !t.intersectsNode(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT | ||
| }); | ||
| let r = n.nextNode(); | ||
| for (; r; ) | ||
| e.push(r), r = n.nextNode(); | ||
| return e; | ||
| } | ||
| function It(t, e) { | ||
| const n = t.data.length; | ||
| let r = 0, o = n; | ||
| if (t === e.startContainer && (r = Math.max(0, Math.min(e.startOffset, n))), t === e.endContainer && (o = Math.max(0, Math.min(e.endOffset, n))), r >= o) return null; | ||
| let i = t; | ||
| return o < i.data.length && i.splitText(o), r > 0 && (i = i.splitText(r)), i; | ||
| } | ||
| function xt(t, e) { | ||
| let n = t, r = n.parentElement; | ||
| for (; r && r.matches(y) && !x(r, e) && tt(r, e); ) | ||
| Bt(r, n), r = n.parentElement; | ||
| return n; | ||
| } | ||
| function Bt(t, e) { | ||
| const n = t.parentNode; | ||
| if (!n || e.parentNode !== t) return; | ||
| const r = t.cloneNode(!1), o = t.cloneNode(!1); | ||
| for (; t.firstChild && t.firstChild !== e; ) | ||
| r.appendChild(t.firstChild); | ||
| for (; e.nextSibling; ) | ||
| o.appendChild(e.nextSibling); | ||
| q(r) && n.insertBefore(r, t), n.insertBefore(e, t), q(o) && n.insertBefore(o, t), n.removeChild(t); | ||
| } | ||
| function q(t) { | ||
| return Array.from(t.childNodes).some((e) => e.nodeType !== Node.TEXT_NODE ? !0 : !!(e.textContent || "").trim()); | ||
| } | ||
| function vt(t) { | ||
| let e = d(t.startContainer), n = d(t.endContainer); | ||
| for (; e && e === n && e.matches(y); ) { | ||
| if (!Pt(t, e)) return; | ||
| t.selectNode(e), e = e.parentElement, n = d(t.endContainer); | ||
| } | ||
| } | ||
| function Pt(t, e) { | ||
| const n = document.createRange(); | ||
| return n.selectNodeContents(e), t.compareBoundaryPoints(Range.START_TO_START, n) === 0 && t.compareBoundaryPoints(Range.END_TO_END, n) === 0; | ||
| } | ||
| function Dt(t, e, n) { | ||
| let r = d(t.parentNode); | ||
| for (; r && r.contains(e); ) { | ||
| const o = r.parentElement; | ||
| r.matches(y) && !x(r, n) && Ht(r, t, e) && tt(r, n) && S(r), r = o; | ||
| } | ||
| } | ||
| function Ht(t, e, n) { | ||
| let r = "before"; | ||
| for (const o of Array.from(t.childNodes)) { | ||
| if (o === e) { | ||
| r = "inside"; | ||
| continue; | ||
| } | ||
| if (o === n) { | ||
| r = "after"; | ||
| continue; | ||
| } | ||
| if (r !== "inside" && !Wt(o)) | ||
| return !1; | ||
| } | ||
| return r === "after"; | ||
| } | ||
| function Wt(t) { | ||
| return t.nodeType === Node.TEXT_NODE ? !(t.textContent || "").replace(/\uFEFF/g, "").trim() : t.nodeType === Node.COMMENT_NODE ? ot(t) : t.nodeType !== Node.ELEMENT_NODE ? !0 : t.hasAttribute(m); | ||
| } | ||
| function tt(t, e) { | ||
| return t.matches("span") ? L.some((n) => !c(e.ignoredFormats, n)) : t.matches("b,strong") ? !c(e.ignoredFormats, "bold") : t.matches("i,em") ? !c(e.ignoredFormats, "italic") : t.matches("u") ? !c(e.ignoredFormats, "underline") : t.matches("s,strike") ? !c(e.ignoredFormats, "strikethrough") : !0; | ||
| } | ||
| function $t(t) { | ||
| if (t.nodeType !== Node.TEXT_NODE || (t.textContent || "").trim()) return !1; | ||
| const e = t.parentElement; | ||
| return !!(e != null && e.matches(_)); | ||
| } | ||
| function et(t, e) { | ||
| let n = t; | ||
| const r = Object.entries(e.styles); | ||
| if (r.length > 0) { | ||
| const o = document.createElement("span"); | ||
| o.classList.add("rte-format-painted"), r.forEach(([i, s]) => { | ||
| o.style.setProperty(B(i), s); | ||
| }), o.appendChild(n), n = o; | ||
| } | ||
| return e.marks.strikethrough && (n = T("s", n)), e.marks.underline && (n = T("u", n)), e.marks.italic && (n = T("i", n)), e.marks.bold && (n = T("b", n)), n; | ||
| } | ||
| function T(t, e) { | ||
| const n = document.createElement(t); | ||
| return n.appendChild(e), n; | ||
| } | ||
| function qt(t, e) { | ||
| Array.from(t.querySelectorAll(y)).forEach((n) => { | ||
| if (n instanceof HTMLElement && !x(n, e)) { | ||
| if (n.matches("span")) { | ||
| if (L.forEach((r) => { | ||
| c(e.ignoredFormats, r) || n.style.removeProperty(B(r)); | ||
| }), n.getAttribute("style") || n.attributes.length > 0) return; | ||
| S(n); | ||
| return; | ||
| } | ||
| n.matches("b,strong") && c(e.ignoredFormats, "bold") || n.matches("i,em") && c(e.ignoredFormats, "italic") || n.matches("u") && c(e.ignoredFormats, "underline") || n.matches("s,strike") && c(e.ignoredFormats, "strikethrough") || S(n); | ||
| } | ||
| }); | ||
| } | ||
| function x(t, e) { | ||
| return !!(t.matches("a") && c(e.ignoredFormats, "link") || R(t, "comment") && c(e.ignoredFormats, "comments") || R(t, "citation") && c(e.ignoredFormats, "citations") || R(t, "track") && c(e.ignoredFormats, "trackchanges")); | ||
| } | ||
| function R(t, e) { | ||
| const n = e.toLowerCase(); | ||
| return t.className.toString().toLowerCase().includes(n) ? !0 : Array.from(t.attributes).some((o) => { | ||
| const i = A(o.name), s = o.value.toLowerCase(); | ||
| return i.includes(n) || s.includes(n); | ||
| }); | ||
| } | ||
| function zt(t, e) { | ||
| t.filter((r) => r.tagName.toLowerCase() === "li").forEach((r) => { | ||
| const o = r.closest(_); | ||
| if (!o) return; | ||
| const i = Zt(o, e.tagName); | ||
| k(i, e.styles), Z(i, e.attrs), Z(r, e.itemAttrs); | ||
| }); | ||
| } | ||
| function Kt(t, e) { | ||
| var o; | ||
| const n = Array.from(t.querySelectorAll(w)).filter((i) => i instanceof HTMLElement && e.intersectsNode(i)); | ||
| if (n.length > 0) return n; | ||
| const r = (o = d(e.startContainer)) == null ? void 0 : o.closest(w); | ||
| return r instanceof HTMLElement && t.contains(r) ? [r] : []; | ||
| } | ||
| function k(t, e) { | ||
| Object.entries(e).forEach(([n, r]) => { | ||
| t.style.setProperty(B(n), r); | ||
| }); | ||
| } | ||
| function Vt(t, e) { | ||
| var o, i; | ||
| const n = rt(t); | ||
| if (n === e || n === "li" || n === "td" || n === "th") return t; | ||
| if (e === "blockquote") { | ||
| const s = document.createElement("blockquote"); | ||
| for (; t.firstChild; ) s.appendChild(t.firstChild); | ||
| return F(t, s), (o = t.parentNode) == null || o.replaceChild(s, t), s; | ||
| } | ||
| if (!/^(p|div|h[1-6]|pre)$/.test(e)) return t; | ||
| const r = document.createElement(e); | ||
| for (; t.firstChild; ) r.appendChild(t.firstChild); | ||
| return F(t, r), (i = t.parentNode) == null || i.replaceChild(r, t), r; | ||
| } | ||
| function Zt(t, e) { | ||
| var r; | ||
| if (t.tagName.toLowerCase() === e) return t; | ||
| const n = document.createElement(e); | ||
| for (; t.firstChild; ) n.appendChild(t.firstChild); | ||
| return F(t, n), (r = t.parentNode) == null || r.replaceChild(n, t), n; | ||
| } | ||
| function Xt(t, e) { | ||
| const n = Array.from(t.querySelectorAll(b)).filter((o) => o instanceof HTMLElement && e.intersectsNode(o)); | ||
| if (n.length > 0) | ||
| return n.filter((o) => !n.some((i) => i !== o && i.contains(o))); | ||
| const r = nt(d(e.startContainer), t); | ||
| return r ? [r] : []; | ||
| } | ||
| function nt(t, e) { | ||
| const n = t == null ? void 0 : t.closest(b); | ||
| return n instanceof HTMLElement && e.contains(n) ? n : null; | ||
| } | ||
| function rt(t) { | ||
| const e = t.tagName.toLowerCase(); | ||
| return e === "blockquote" || /^h[1-6]$/.test(e) || e === "pre" || e === "li" || e === "td" || e === "th" ? e : "p"; | ||
| } | ||
| function Yt(t) { | ||
| return Array.from(t.childNodes).some((e) => { | ||
| if (e.nodeType !== Node.ELEMENT_NODE) return !1; | ||
| const n = e; | ||
| return n.matches(b) || !!n.querySelector(b); | ||
| }); | ||
| } | ||
| function Jt(t) { | ||
| const e = window.getSelection(); | ||
| if (!e || e.rangeCount === 0) return null; | ||
| const n = e.getRangeAt(0); | ||
| if (!t.contains(n.startContainer) || !t.contains(n.endContainer)) return null; | ||
| const r = n.collapsed, o = z("start"), i = z("end"), s = n.cloneRange(); | ||
| if (!r) { | ||
| const l = s.cloneRange(); | ||
| l.collapse(!1), l.insertNode(i); | ||
| } | ||
| const a = s.cloneRange(); | ||
| return a.collapse(!0), a.insertNode(o), () => { | ||
| const l = V(t, "start"), u = V(t, "end"); | ||
| if (!l) return; | ||
| const f = document.createRange(); | ||
| r || !u ? (f.setStartAfter(l), f.collapse(!0)) : (f.setStartAfter(l), f.setEndBefore(u)), e.removeAllRanges(), e.addRange(f); | ||
| }; | ||
| } | ||
| function z(t) { | ||
| return document.createComment(`${m}:selection:${t}`); | ||
| } | ||
| function K(t) { | ||
| return document.createComment(`${m}:inline:${t}`); | ||
| } | ||
| function ot(t) { | ||
| return Gt(t) || jt(t); | ||
| } | ||
| function Gt(t) { | ||
| return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${m}:selection:start` || t.nodeValue === `${m}:selection:end`); | ||
| } | ||
| function jt(t) { | ||
| return t.nodeType === Node.COMMENT_NODE && (t.nodeValue === `${m}:inline:start` || t.nodeValue === `${m}:inline:end`); | ||
| } | ||
| function V(t, e) { | ||
| const n = `${m}:selection:${e}`, r = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT); | ||
| let o = r.nextNode(); | ||
| for (; o; ) { | ||
| if (o.nodeValue === n) return o; | ||
| o = r.nextNode(); | ||
| } | ||
| return null; | ||
| } | ||
| function Ut(t) { | ||
| t.querySelectorAll(`[${m}]`).forEach((o) => o.remove()); | ||
| const e = document.createTreeWalker(t, NodeFilter.SHOW_COMMENT), n = []; | ||
| let r = e.nextNode(); | ||
| for (; r; ) | ||
| ot(r) && n.push(r), r = e.nextNode(); | ||
| n.forEach((o) => o.remove()); | ||
| } | ||
| function Qt(t) { | ||
| t.querySelectorAll("span").forEach((e) => { | ||
| e instanceof HTMLElement && (e.attributes.length > 0 || S(e)); | ||
| }); | ||
| } | ||
| function S(t) { | ||
| const e = t.parentNode; | ||
| if (e) { | ||
| for (; t.firstChild; ) | ||
| e.insertBefore(t.firstChild, t); | ||
| e.removeChild(t); | ||
| } | ||
| } | ||
| function N(t, e, n) { | ||
| const r = t.getAttribute(n); | ||
| r != null && (e[n] = r); | ||
| } | ||
| function Z(t, e) { | ||
| ["data-type", "data-checked", "type"].forEach((n) => { | ||
| e[n] != null && t.setAttribute(n, e[n]); | ||
| }); | ||
| } | ||
| function F(t, e) { | ||
| Array.from(t.attributes).forEach((n) => { | ||
| n.name !== "style" && e.setAttribute(n.name, n.value); | ||
| }); | ||
| } | ||
| function h(t, e) { | ||
| const n = E(t); | ||
| if (n.active === e && t.classList.contains("rte-format-painter-active") === e) { | ||
| M(t, e); | ||
| return; | ||
| } | ||
| n.active = e, t.classList.toggle("rte-format-painter-active", e), M(t, e); | ||
| } | ||
| function M(t, e) { | ||
| const n = t.closest(st) || document; | ||
| n.querySelectorAll( | ||
| '[data-command="toggleFormatPainter"], [data-command="formatPainter"]' | ||
| ).forEach((o) => { | ||
| o instanceof HTMLElement && (o.classList.toggle("active", e), o.setAttribute("data-active", e ? "true" : "false"), o.setAttribute("aria-pressed", e ? "true" : "false")); | ||
| }), n.dispatchEvent( | ||
| new CustomEvent("editora:format-painter-toggle", { | ||
| bubbles: !0, | ||
| detail: { active: e } | ||
| }) | ||
| ); | ||
| } | ||
| function te(t, e, n) { | ||
| if (e === n) return; | ||
| const r = window.execEditorCommand || window.executeEditorCommand; | ||
| if (typeof r == "function") | ||
| try { | ||
| r("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n }); | ||
| } catch (o) { | ||
| try { | ||
| r("recordDomTransaction", t, e, n); | ||
| } catch (i) { | ||
| } | ||
| } | ||
| } | ||
| function ee(t) { | ||
| return (t != null ? t : O).map(A).map((e) => X[e] || e).filter(Boolean); | ||
| } | ||
| function c(t, e) { | ||
| const n = X[A(e)] || A(e); | ||
| return t.includes(n); | ||
| } | ||
| function A(t) { | ||
| return t.toLowerCase().replace(/[^a-z0-9]/g, ""); | ||
| } | ||
| function B(t) { | ||
| return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`); | ||
| } | ||
| export { | ||
| ne as FormatPainterPlugin | ||
| }; | ||
| //# sourceMappingURL=FormatPainterPlugin.native-CsMrKfFU.mjs.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./index-CPMGUZfB.js");class v{constructor(e){if(this.listeners=[],e instanceof l.PluginManager)this.pluginManager=e;else{const i=e;this.pluginManager=new l.PluginManager,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(n=>{this.pluginManager.register(n)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const t=this.pluginManager.buildSchema();this.state=l.EditorState.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(i=>{i.shortcut&&(t[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(i.ctrlKey||i.metaKey)&&n.push("ctrl"),i.shiftKey&&n.push("shift"),i.altKey&&n.push("alt");const o=i.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${o}`:o,a=t[s];a&&(i.preventDefault(),this.execCommand(a))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(o=>o.id&&o.id===e||o.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const i=this.commands[e];if(!i)return console.warn(`Command not found: ${e}`),!1;let n;return t!==void 0?n=i(this.state,t):n=i(this.state),n instanceof Promise?(n.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&this.setState(o)}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=null}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class b{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const n=(i=this.plugin.commands)==null?void 0:i[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function E(r){return new b(r)}function x(r={}){const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:n={},language:o="en",customDictionary:s=[],ignoreAllCaps:a=!0,ignoreNumbers:c=!0}=r;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:o}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:h=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:h=>(console.log("[Spellcheck] Add to dictionary:",h),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function w(r={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:o={},withCredentials:s=!1,chunkSize:a=1024*1024,enableChunking:c=!0,onProgress:h,onError:u,onSuccess:$}=r;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:d=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async d=>{if(console.log("[Media] Insert image command (not implemented)",d),!d)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(d.type)){const g=new Error(`File type ${d.type} not allowed`);return u==null||u(g),null}if(d.size>i){const g=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(g),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async d=>(console.log("[Media] Upload media (not implemented)",{name:d.name,size:d.size,type:d.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class p{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new p(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new p(this.doc,e)}update(e,t){return new p(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class m{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((i,n)=>`<button type="button" class="editora-btn ${i.type==="danger"?"editora-btn-danger":i.type==="primary"||i.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${i.label}</button>`).join(""):` | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./index-B5BzVUdg.js");class v{constructor(e){if(this.listeners=[],e instanceof l.PluginManager)this.pluginManager=e;else{const i=e;this.pluginManager=new l.PluginManager,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(n=>{this.pluginManager.register(n)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const t=this.pluginManager.buildSchema();this.state=l.EditorState.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(i=>{i.shortcut&&(t[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(i.ctrlKey||i.metaKey)&&n.push("ctrl"),i.shiftKey&&n.push("shift"),i.altKey&&n.push("alt");const o=i.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${o}`:o,a=t[s];a&&(i.preventDefault(),this.execCommand(a))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(o=>o.id&&o.id===e||o.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const i=this.commands[e];if(!i)return console.warn(`Command not found: ${e}`),!1;let n;return t!==void 0?n=i(this.state,t):n=i(this.state),n instanceof Promise?(n.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&this.setState(o)}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=null}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class b{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const n=(i=this.plugin.commands)==null?void 0:i[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function E(r){return new b(r)}function x(r={}){const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:n={},language:o="en",customDictionary:s=[],ignoreAllCaps:a=!0,ignoreNumbers:c=!0}=r;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:o}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:h=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:h=>(console.log("[Spellcheck] Add to dictionary:",h),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function w(r={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:o={},withCredentials:s=!1,chunkSize:a=1024*1024,enableChunking:c=!0,onProgress:h,onError:u,onSuccess:$}=r;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:d=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async d=>{if(console.log("[Media] Insert image command (not implemented)",d),!d)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(d.type)){const g=new Error(`File type ${d.type} not allowed`);return u==null||u(g),null}if(d.size>i){const g=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(g),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async d=>(console.log("[Media] Upload media (not implemented)",{name:d.name,size:d.size,type:d.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class p{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new p(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new p(this.doc,e)}update(e,t){return new p(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class m{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((i,n)=>`<button type="button" class="editora-btn ${i.type==="danger"?"editora-btn-danger":i.type==="primary"||i.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${i.label}</button>`).join(""):` | ||
| <button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button> | ||
@@ -3,0 +3,0 @@ <button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button> |
@@ -1,3 +0,3 @@ | ||
| import { P as g, E as y, a as b, T as f, R as v } from "./index-DBoj6QfW.mjs"; | ||
| import { C as G, h as O, F as V, K, i as B, S as W, b as X, e as _, d as Y, g as J, f as Q, c as Z } from "./index-DBoj6QfW.mjs"; | ||
| import { P as g, E as y, a as b, T as f, R as v } from "./index-YZ5TROdg.mjs"; | ||
| import { C as G, h as O, F as V, K, i as B, S as W, b as X, e as _, d as Y, g as J, f as Q, c as Z } from "./index-YZ5TROdg.mjs"; | ||
| class L { | ||
@@ -4,0 +4,0 @@ constructor(e) { |
@@ -11,2 +11,5 @@ const r = { | ||
| fontFamily: () => import("./FontFamilyPlugin.native-j8hMTbg4.mjs").then((n) => n.FontFamilyPlugin()), | ||
| formatPainter: () => import("./FormatPainterPlugin.native-CsMrKfFU.mjs").then((n) => n.FormatPainterPlugin()), | ||
| "format-painter": () => import("./FormatPainterPlugin.native-CsMrKfFU.mjs").then((n) => n.FormatPainterPlugin()), | ||
| formatpainter: () => import("./FormatPainterPlugin.native-CsMrKfFU.mjs").then((n) => n.FormatPainterPlugin()), | ||
| lineHeight: () => import("./LineHeightPlugin.native-CM7iXdQj.mjs").then((n) => n.LineHeightPlugin()), | ||
@@ -13,0 +16,0 @@ capitalization: () => import("./CapitalizationPlugin.native-DLV4oPmB.mjs").then((n) => n.CapitalizationPlugin()), |
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-CPMGUZfB.js");exports.RichTextEditorElement=e.RichTextEditorElement;exports.initWebComponent=e.initWebComponent; | ||
| "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-B5BzVUdg.js");exports.RichTextEditorElement=e.RichTextEditorElement;exports.initWebComponent=e.initWebComponent; | ||
| //# sourceMappingURL=webcomponent.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
| import { R as o, j as i } from "./index-DBoj6QfW.mjs"; | ||
| import { R as o, j as i } from "./index-YZ5TROdg.mjs"; | ||
| export { | ||
@@ -3,0 +3,0 @@ o as RichTextEditorElement, |
+1
-1
| { | ||
| "name": "@editora/core", | ||
| "version": "1.0.11", | ||
| "version": "1.0.12", | ||
| "description": "Framework-agnostic rich text editor core for React and web apps, built for enterprise editing workflows.", | ||
@@ -5,0 +5,0 @@ "author": "Ajay Kumar <ajaykr089@gmail.com>", |
| const C = () => ({ | ||
| name: "clearFormatting", | ||
| // Toolbar button configuration | ||
| toolbar: [ | ||
| { | ||
| label: "Clear Formatting", | ||
| command: "clearFormatting", | ||
| icon: '<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>', | ||
| shortcut: "Mod-\\" | ||
| } | ||
| ], | ||
| // Native command implementations | ||
| commands: { | ||
| /** | ||
| * Remove all formatting from current selection | ||
| */ | ||
| clearFormatting: () => { | ||
| const t = h(); | ||
| if (!t) return !1; | ||
| const e = window.getSelection(); | ||
| if (!e || e.rangeCount === 0) return !1; | ||
| const r = e.getRangeAt(0); | ||
| if (!t.contains(r.commonAncestorContainer)) return !1; | ||
| const n = r.cloneRange(); | ||
| return t.focus({ preventScroll: !0 }), A(t, n), N(t, n), t.dispatchEvent(new Event("input", { bubbles: !0 })), !0; | ||
| } | ||
| }, | ||
| // Keyboard shortcuts | ||
| keymap: { | ||
| "Mod-\\": "clearFormatting" | ||
| } | ||
| }), u = /* @__PURE__ */ new Set([ | ||
| "A", | ||
| "B", | ||
| "STRONG", | ||
| "I", | ||
| "EM", | ||
| "U", | ||
| "S", | ||
| "STRIKE", | ||
| "DEL", | ||
| "FONT", | ||
| "MARK", | ||
| "CODE", | ||
| "SUB", | ||
| "SUP" | ||
| ]), d = /* @__PURE__ */ new Set([ | ||
| "H1", | ||
| "H2", | ||
| "H3", | ||
| "H4", | ||
| "H5", | ||
| "H6", | ||
| "BLOCKQUOTE", | ||
| "PRE" | ||
| ]), g = [ | ||
| "color", | ||
| "background-color", | ||
| "font-size", | ||
| "font-family", | ||
| "font-weight", | ||
| "font-style", | ||
| "text-decoration", | ||
| "text-transform", | ||
| "line-height", | ||
| "letter-spacing", | ||
| "word-spacing", | ||
| "vertical-align", | ||
| "text-align", | ||
| "padding-left" | ||
| ]; | ||
| function h() { | ||
| const t = window.getSelection(); | ||
| if (t && t.rangeCount > 0) { | ||
| const r = t.getRangeAt(0).startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement, o = n == null ? void 0 : n.closest('[contenteditable="true"], .rte-content, .editora-content'); | ||
| if (o) return o; | ||
| } | ||
| const e = document.activeElement; | ||
| return e ? e.getAttribute("contenteditable") === "true" ? e : e.closest('[contenteditable="true"], .rte-content, .editora-content') : null; | ||
| } | ||
| function c(t, e) { | ||
| try { | ||
| if (typeof t.intersectsNode == "function") | ||
| return t.intersectsNode(e); | ||
| } catch (n) { | ||
| } | ||
| const r = document.createRange(); | ||
| return e.nodeType === Node.ELEMENT_NODE ? r.selectNodeContents(e) : r.selectNode(e), t.compareBoundaryPoints(Range.END_TO_START, r) > 0 && t.compareBoundaryPoints(Range.START_TO_END, r) < 0; | ||
| } | ||
| function i(t) { | ||
| let e = 0, r = t; | ||
| for (; r && r.parentNode; ) | ||
| e += 1, r = r.parentNode; | ||
| return e; | ||
| } | ||
| function m(t) { | ||
| g.forEach((e) => { | ||
| t.style.removeProperty(e); | ||
| }), (!t.getAttribute("style") || t.style.length === 0) && t.removeAttribute("style"), t.classList.contains("rte-text-color") && t.classList.remove("rte-text-color"), t.classList.contains("rte-bg-color") && t.classList.remove("rte-bg-color"), t.classList.length === 0 && t.removeAttribute("class"); | ||
| } | ||
| function a(t) { | ||
| const e = t.parentNode; | ||
| if (e) { | ||
| for (; t.firstChild; ) | ||
| e.insertBefore(t.firstChild, t); | ||
| e.removeChild(t); | ||
| } | ||
| } | ||
| function p(t) { | ||
| return t.tagName !== "P" || t.attributes.length > 0 || (t.textContent || "").trim() !== "" ? !1 : !t.querySelector("img, video, table, iframe, hr, pre, ul, ol"); | ||
| } | ||
| function l(t) { | ||
| Array.from(t.children).forEach((e) => { | ||
| p(e) && e.remove(); | ||
| }); | ||
| } | ||
| function s(t) { | ||
| l(t), a(t); | ||
| } | ||
| function f(t) { | ||
| var r; | ||
| const e = document.createElement("p"); | ||
| for (Array.from(t.attributes).forEach((n) => { | ||
| e.setAttribute(n.name, n.value); | ||
| }); t.firstChild; ) | ||
| e.appendChild(t.firstChild); | ||
| e.innerHTML.trim() || (e.innerHTML = "<br>"), (r = t.parentNode) == null || r.replaceChild(e, t); | ||
| } | ||
| function E(t) { | ||
| if (l(t), t.parentElement instanceof HTMLLIElement) { | ||
| s(t); | ||
| return; | ||
| } | ||
| if (Array.from(t.childNodes).filter((o) => o.nodeType !== Node.TEXT_NODE || (o.textContent || "").trim() !== "").some((o) => o instanceof HTMLElement && /^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(o.tagName))) { | ||
| s(t); | ||
| return; | ||
| } | ||
| f(t); | ||
| } | ||
| function N(t, e) { | ||
| Array.from( | ||
| t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre") | ||
| ).forEach((n) => { | ||
| if (c(e, n) && d.has(n.tagName)) { | ||
| if (n.tagName === "BLOCKQUOTE") { | ||
| E(n); | ||
| return; | ||
| } | ||
| f(n); | ||
| } | ||
| }); | ||
| } | ||
| function A(t, e) { | ||
| const r = Array.from( | ||
| t.querySelectorAll( | ||
| "a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]" | ||
| ) | ||
| ); | ||
| r.sort((n, o) => i(o) - i(n)), r.forEach((n) => { | ||
| if (n.isConnected && c(e, n) && !(n.getAttribute("contenteditable") === "false" || n.closest('[contenteditable="false"]'))) { | ||
| if (m(n), u.has(n.tagName)) { | ||
| a(n); | ||
| return; | ||
| } | ||
| n.tagName === "SPAN" && n.attributes.length === 0 && a(n); | ||
| } | ||
| }); | ||
| } | ||
| export { | ||
| C as ClearFormattingPlugin | ||
| }; | ||
| //# sourceMappingURL=ClearFormattingPlugin.native-DIS6AN2t.mjs.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
7287501
0.63%84
1.2%114583
0.69%79
-1.25%35
2.94%