@editora/core 1.0.8 → 1.0.10

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.
Files changed (58) hide show
  1. package/README.md +6 -1
  2. package/dist/{ApprovalWorkflowPlugin.native-C3jtAYjG.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +136 -133
  3. package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
  4. package/dist/{BlocksLibraryPlugin.native-HMWKxWNs.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +90 -87
  5. package/dist/{BoldPlugin.native-BAzzoqU5.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
  6. package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
  7. package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
  8. package/dist/{CitationsPlugin.native-BnU0qCwR.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +132 -129
  9. package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
  10. package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
  11. package/dist/{ContentRulesPlugin.native-nBLQ8QFZ.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +105 -102
  12. package/dist/{DataBindingPlugin.native-jQ1JPRTp.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +49 -46
  13. package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
  14. package/dist/{DocSchemaPlugin.native-CHOge18O.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +55 -52
  15. package/dist/{EmbedIframePlugin.native-DKJx2OS7.mjs → EmbedIframePlugin.native-BF_-LjTq.mjs} +287 -115
  16. package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
  17. package/dist/{HistoryPlugin.native-TDnVMsEO.mjs → HistoryPlugin.native-D2wl32jV.mjs} +88 -103
  18. package/dist/{ItalicPlugin.native-CQjjDyUL.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
  19. package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
  20. package/dist/{MediaManagerPlugin.native-BiXiK8FC.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +204 -202
  21. package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
  22. package/dist/{PIIRedactionPlugin.native-DcsjmtV1.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +158 -155
  23. package/dist/{SlashCommandsPlugin.native-CmxvMEaE.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +2 -2
  24. package/dist/{SmartPastePlugin.native-BOKKtF07.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +127 -124
  25. package/dist/{SpecialCharactersPlugin.native-CZDato89.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +100 -76
  26. package/dist/{StrikethroughPlugin.native-0Be7j49s.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -26
  27. package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
  28. package/dist/{TranslationWorkflowPlugin.native-Bz6jDGvj.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +104 -101
  29. package/dist/{UnderlinePlugin.native-QpIcK4L2.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
  30. package/dist/editora.min.js +1 -1
  31. package/dist/editora.umd.js +1 -1
  32. package/dist/index-CPMGUZfB.js +10 -0
  33. package/dist/{index-DqC57IEH.mjs → index-DBoj6QfW.mjs} +17 -15
  34. package/dist/index.cjs.js +1 -1
  35. package/dist/index.esm.js +2 -2
  36. package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
  37. package/dist/plugin-loader.js +37 -37
  38. package/dist/webcomponent-core.js +18 -16
  39. package/dist/webcomponent-core.min.css +1 -1
  40. package/dist/webcomponent-core.min.js +139 -62
  41. package/dist/webcomponent.cjs.js +1 -1
  42. package/dist/webcomponent.esm.js +1 -1
  43. package/dist/webcomponent.js +50 -48
  44. package/dist/webcomponent.min.css +1 -1
  45. package/dist/webcomponent.min.js +1174 -1071
  46. package/package.json +11 -5
  47. package/LICENSE +0 -21
  48. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs +0 -48
  49. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs +0 -79
  50. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +0 -309
  51. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +0 -140
  52. package/dist/CodePlugin.native-DlpTPdkd.mjs +0 -2691
  53. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +0 -130
  54. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs +0 -64
  55. package/dist/MathPlugin.native-f_mDp8VL.mjs +0 -292
  56. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +0 -559
  57. package/dist/TemplatePlugin.native-CrpfKRJ8.mjs +0 -602
  58. package/dist/index-D1LOqg5C.js +0 -10
@@ -1,130 +0,0 @@
1
- const g = /* @__PURE__ */ new Set([
2
- "P",
3
- "DIV",
4
- "H1",
5
- "H2",
6
- "H3",
7
- "H4",
8
- "H5",
9
- "H6",
10
- "LI",
11
- "BLOCKQUOTE",
12
- "PRE"
13
- ]), l = (e) => g.has(e.tagName) && e.getAttribute("contenteditable") !== "true", h = () => {
14
- const e = window.getSelection();
15
- if (e && e.rangeCount > 0) {
16
- let t = e.getRangeAt(0).startContainer;
17
- for (; t && t !== document.body; ) {
18
- if (t.nodeType === Node.ELEMENT_NODE) {
19
- const r = t;
20
- if (r.getAttribute("contenteditable") === "true")
21
- return r;
22
- }
23
- t = t.parentNode;
24
- }
25
- }
26
- const n = document.activeElement;
27
- if (n) {
28
- if (n.getAttribute("contenteditable") === "true")
29
- return n;
30
- const t = n.closest('[contenteditable="true"]');
31
- if (t) return t;
32
- }
33
- return document.querySelector('[contenteditable="true"]');
34
- }, u = (e) => {
35
- let n = e;
36
- for (; n && n !== document.body; ) {
37
- if (n.nodeType === Node.ELEMENT_NODE) {
38
- const t = n;
39
- if (l(t)) return t;
40
- if (t.getAttribute("contenteditable") === "true") break;
41
- }
42
- n = n.parentNode;
43
- }
44
- return null;
45
- }, C = (e, n) => {
46
- const t = [], r = /* @__PURE__ */ new Set(), i = (o) => {
47
- !o || r.has(o) || n.contains(o) && l(o) && (r.add(o), t.push(o));
48
- };
49
- if (e.collapsed)
50
- return i(u(e.startContainer)), t;
51
- const s = document.createTreeWalker(
52
- n,
53
- NodeFilter.SHOW_ELEMENT,
54
- {
55
- acceptNode: (o) => {
56
- const d = o;
57
- if (!l(d)) return NodeFilter.FILTER_SKIP;
58
- if (typeof e.intersectsNode == "function")
59
- return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
60
- const a = document.createRange();
61
- return a.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, a) > 0 && e.compareBoundaryPoints(Range.START_TO_END, a) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
62
- }
63
- }
64
- );
65
- let c = s.nextNode();
66
- for (; c; )
67
- i(c), c = s.nextNode();
68
- return t.length === 0 && i(u(e.commonAncestorContainer)), t;
69
- }, T = (e, n) => {
70
- if (n === e.innerHTML) return;
71
- const t = window.execEditorCommand || window.executeEditorCommand;
72
- if (typeof t == "function")
73
- try {
74
- t("recordDomTransaction", e, n, e.innerHTML);
75
- } catch (r) {
76
- }
77
- }, f = (e) => {
78
- const n = h();
79
- if (!n) return !1;
80
- const t = window.getSelection();
81
- if (!t || t.rangeCount === 0) return !1;
82
- const r = t.getRangeAt(0);
83
- if (!n.contains(r.commonAncestorContainer)) return !1;
84
- const i = C(r, n);
85
- if (i.length === 0) return !1;
86
- const s = n.innerHTML;
87
- return i.forEach((c) => {
88
- e === "rtl" ? c.setAttribute("dir", "rtl") : c.removeAttribute("dir");
89
- }), T(n, s), n.dispatchEvent(new Event("input", { bubbles: !0 })), !0;
90
- }, E = () => ({
91
- name: "direction",
92
- toolbar: [
93
- {
94
- label: "Left to Right",
95
- command: "setDirectionLTR",
96
- icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
97
- shortcut: "Mod-Shift-l"
98
- },
99
- {
100
- label: "Right to Left",
101
- command: "setDirectionRTL",
102
- icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
103
- shortcut: "Mod-Shift-r"
104
- }
105
- ],
106
- commands: {
107
- setDirectionLTR: () => {
108
- try {
109
- return f(null);
110
- } catch (e) {
111
- return console.error("Failed to set LTR direction:", e), !1;
112
- }
113
- },
114
- setDirectionRTL: () => {
115
- try {
116
- return f("rtl");
117
- } catch (e) {
118
- return console.error("Failed to set RTL direction:", e), !1;
119
- }
120
- }
121
- },
122
- keymap: {
123
- "Mod-Shift-l": "setDirectionLTR",
124
- "Mod-Shift-r": "setDirectionRTL"
125
- }
126
- });
127
- export {
128
- E as DirectionPlugin
129
- };
130
- //# sourceMappingURL=DirectionPlugin.native-CDnbdNyl.mjs.map
@@ -1,64 +0,0 @@
1
- const t = () => {
2
- const e = (a) => {
3
- try {
4
- return document.execCommand("formatBlock", !1, a), !0;
5
- } catch (l) {
6
- return console.error(`Failed to set block type to ${a}:`, l), !1;
7
- }
8
- };
9
- return {
10
- name: "heading",
11
- // Toolbar button configuration with dropdown
12
- toolbar: [
13
- {
14
- label: "Heading",
15
- command: "setBlockType",
16
- type: "dropdown",
17
- options: [
18
- { value: "p", label: "Paragraph" },
19
- { value: "h1", label: "Heading 1" },
20
- { value: "h2", label: "Heading 2" },
21
- { value: "h3", label: "Heading 3" },
22
- { value: "h4", label: "Heading 4" },
23
- { value: "h5", label: "Heading 5" },
24
- { value: "h6", label: "Heading 6" }
25
- ],
26
- icon: '<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'
27
- }
28
- ],
29
- // Native command implementations
30
- commands: {
31
- /**
32
- * Set block type to specific heading level or paragraph
33
- */
34
- setBlockType: (a) => a ? e(a) : !1,
35
- /**
36
- * Set heading level 1
37
- */
38
- setHeading1: () => e("h1"),
39
- /**
40
- * Set heading level 2
41
- */
42
- setHeading2: () => e("h2"),
43
- /**
44
- * Set heading level 3
45
- */
46
- setHeading3: () => e("h3"),
47
- /**
48
- * Set to paragraph
49
- */
50
- setParagraph: () => e("p")
51
- },
52
- // Keyboard shortcuts
53
- keymap: {
54
- "Mod-Alt-1": "setHeading1",
55
- "Mod-Alt-2": "setHeading2",
56
- "Mod-Alt-3": "setHeading3",
57
- "Mod-Alt-0": "setParagraph"
58
- }
59
- };
60
- };
61
- export {
62
- t as HeadingPlugin
63
- };
64
- //# sourceMappingURL=HeadingPlugin.native-DrLYwQnQ.mjs.map
@@ -1,292 +0,0 @@
1
- const j = {
2
- latex: [
3
- { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
4
- { name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
5
- { name: "Power", formula: "x^{2}", description: "Exponent/power" },
6
- { name: "Subscript", formula: "x_{sub}", description: "Subscript" },
7
- { name: "Integral", formula: "\\int_{a}^{b} f(x) \\, dx", description: "Definite integral" },
8
- { name: "Summation", formula: "\\sum_{i=1}^{n} x_{i}", description: "Summation" },
9
- { name: "Limit", formula: "\\lim_{x \\to 0} f(x)", description: "Limit" },
10
- { name: "Derivative", formula: "\\frac{d}{dx} f(x)", description: "Derivative" },
11
- { name: "Matrix 2x2", formula: "\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}", description: "2x2 matrix" },
12
- { name: "System", formula: "\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}", description: "System of equations" }
13
- ],
14
- mathml: [
15
- { name: "Fraction", formula: "<mfrac><mi>a</mi><mi>b</mi></mfrac>", description: "Simple fraction" },
16
- { name: "Square Root", formula: "<msqrt><mi>x</mi></msqrt>", description: "Square root" },
17
- { name: "Power", formula: "<msup><mi>x</mi><mn>2</mn></msup>", description: "Exponent/power" },
18
- { name: "Subscript", formula: "<msub><mi>x</mi><mi>sub</mi></msub>", description: "Subscript" },
19
- { name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
20
- ]
21
- };
22
- let B = null, h = null, H = !1, g = null;
23
- const k = '[data-theme="dark"], .dark, .editora-theme-dark', O = () => new Promise((o, i) => {
24
- if (window.katex) {
25
- o(window.katex);
26
- return;
27
- }
28
- if (H) {
29
- const l = setInterval(() => {
30
- window.katex && (clearInterval(l), o(window.katex));
31
- }, 100);
32
- return;
33
- }
34
- H = !0;
35
- const r = document.createElement("link");
36
- r.rel = "stylesheet", r.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(r);
37
- const s = document.createElement("script");
38
- s.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", s.onload = () => o(window.katex), s.onerror = i, document.head.appendChild(s);
39
- }), q = () => {
40
- const o = window.getSelection();
41
- if (!o || o.rangeCount === 0) return null;
42
- const i = o.getRangeAt(0).startContainer, r = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement;
43
- return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
44
- }, K = (o) => {
45
- const i = o || q();
46
- if (i != null && i.closest(k)) return !0;
47
- const r = window.getSelection();
48
- if (r && r.rangeCount > 0) {
49
- const l = r.getRangeAt(0).startContainer, e = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
50
- if (e != null && e.closest(k)) return !0;
51
- }
52
- const s = document.activeElement;
53
- return s != null && s.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
54
- }, z = async (o, i) => {
55
- const r = i || (h == null ? void 0 : h.closest(".rte-content, .editora-content")) || q() || g;
56
- g = r || null;
57
- const s = window.getSelection();
58
- if (s && s.rangeCount > 0) {
59
- const t = s.getRangeAt(0);
60
- B = r && r.contains(t.commonAncestorContainer) ? t.cloneRange() : null;
61
- }
62
- await O();
63
- const l = K(r), e = l ? {
64
- overlay: "rgba(0, 0, 0, 0.62)",
65
- dialogBg: "#1f2937",
66
- border: "#3b4657",
67
- panelBg: "#222d3a",
68
- fieldBg: "#111827",
69
- fieldBorder: "#4b5563",
70
- text: "#e2e8f0",
71
- muted: "#94a3b8",
72
- templateBtnBg: "#273244",
73
- templateBtnHover: "#334155",
74
- templateBtnText: "#dbe7f7",
75
- templateSubText: "#9fb0c6",
76
- previewBg: "#111827",
77
- previewText: "#cbd5e1",
78
- cancelBg: "#334155",
79
- cancelText: "#e2e8f0",
80
- cancelBorder: "#4b5563",
81
- insertBg: "#3b82f6",
82
- insertHover: "#2563eb",
83
- invalid: "#f87171"
84
- } : {
85
- overlay: "rgba(0, 0, 0, 0.5)",
86
- dialogBg: "#ffffff",
87
- border: "#e1e5e9",
88
- panelBg: "#f8f9fa",
89
- fieldBg: "#ffffff",
90
- fieldBorder: "#ced4da",
91
- text: "#1f2937",
92
- muted: "#6c757d",
93
- templateBtnBg: "#ffffff",
94
- templateBtnHover: "#f8f9fa",
95
- templateBtnText: "#1f2937",
96
- templateSubText: "#6c757d",
97
- previewBg: "#f8f9fa",
98
- previewText: "#6c757d",
99
- cancelBg: "#ffffff",
100
- cancelText: "#1f2937",
101
- cancelBorder: "#ced4da",
102
- insertBg: "#007bff",
103
- insertHover: "#0069d9",
104
- invalid: "#cc0000"
105
- }, c = document.createElement("div");
106
- c.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${e.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;
107
- const d = document.createElement("div");
108
- d.style.cssText = `background: ${e.dialogBg}; border: 1px solid ${e.border}; border-radius: 8px; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); color: ${e.text};`;
109
- let m = (o == null ? void 0 : o.format) || "latex", T = (o == null ? void 0 : o.formula) || "", I = (o == null ? void 0 : o.inline) !== !1, x = null, L = "";
110
- d.innerHTML = `
111
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
112
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${o ? "Edit" : "Insert"} Math Formula</h2>
113
- <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${e.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
114
- </div>
115
-
116
- <div style="padding: 20px; overflow-y: auto; flex: 1;">
117
- <div style="margin-bottom: 20px;">
118
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
119
- <div style="display: flex; gap: 16px;">
120
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
121
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
122
- </div>
123
- </div>
124
-
125
- <div style="margin-bottom: 20px;">
126
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
127
- <div id="templates-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 200px; overflow-y: auto;"></div>
128
- </div>
129
-
130
- <div style="margin-bottom: 20px;">
131
- <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${I ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
132
- </div>
133
-
134
- <div style="margin-bottom: 20px;">
135
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
136
- <textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${e.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${e.fieldBg}; color: ${e.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
137
- </div>
138
-
139
- <div style="margin-bottom: 20px;">
140
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
141
- <div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.previewBg}; display: flex; align-items: center; justify-content: center; color: ${e.previewText};"></div>
142
- </div>
143
- </div>
144
-
145
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
146
- <button class="cancel-btn" style="padding: 10px 20px; background: ${e.cancelBg}; color: ${e.cancelText}; border: 1px solid ${e.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
147
- <button id="insert-btn" style="padding: 10px 20px; background: ${e.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${o ? "Update" : "Insert"}</button>
148
- </div>
149
- `, c.appendChild(d), document.body.appendChild(c);
150
- const u = d.querySelector("#formula-input"), v = d.querySelector("#preview-area"), E = d.querySelector("#templates-grid"), P = d.querySelectorAll('input[name="format"]'), R = d.querySelector("#inline-cb"), p = d.querySelector("#insert-btn"), f = d.querySelector(".close-btn"), y = d.querySelector(".cancel-btn"), _ = (t) => encodeURIComponent(t), F = (t) => {
151
- try {
152
- return decodeURIComponent(t);
153
- } catch (a) {
154
- return t;
155
- }
156
- }, S = () => {
157
- const t = j[m];
158
- E.innerHTML = t.map((a) => `
159
- <button type="button" data-formula="${_(a.formula)}" title="${a.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
160
- <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${a.name}</div>
161
- <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${a.formula.substring(0, 20)}...</div>
162
- </button>
163
- `).join("");
164
- }, N = () => {
165
- const t = u.value.trim(), a = `${m}:${t}`;
166
- if (a !== L) {
167
- if (L = a, !t) {
168
- v.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
169
- return;
170
- }
171
- p.disabled = !1;
172
- try {
173
- if (m === "latex") {
174
- const n = window.katex;
175
- v.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
176
- } else
177
- t.trim().startsWith("<math") ? v.innerHTML = t : v.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
178
- } catch (n) {
179
- v.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
180
- }
181
- }
182
- }, $ = () => {
183
- x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
184
- x = null, N();
185
- });
186
- }, C = (t) => {
187
- t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), w());
188
- }, w = () => {
189
- document.removeEventListener("keydown", C, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
190
- };
191
- f.onmouseover = () => {
192
- f.style.color = "#f8fafc", f.style.background = l ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
193
- }, f.onmouseout = () => {
194
- f.style.color = e.muted, f.style.background = "none";
195
- }, y.onmouseover = () => {
196
- y.style.background = l ? "#475569" : "#f3f4f6";
197
- }, y.onmouseout = () => {
198
- y.style.background = e.cancelBg;
199
- }, p.onmouseover = () => {
200
- p.disabled || (p.style.background = e.insertHover);
201
- }, p.onmouseout = () => {
202
- p.style.background = e.insertBg;
203
- }, E.addEventListener("mouseover", (t) => {
204
- const n = t.target.closest("button[data-formula]");
205
- n && (n.style.background = e.templateBtnHover);
206
- }), E.addEventListener("mouseout", (t) => {
207
- const n = t.target.closest("button[data-formula]");
208
- n && (n.style.background = e.templateBtnBg);
209
- }), E.addEventListener("click", (t) => {
210
- const n = t.target.closest("button[data-formula]");
211
- n && (u.value = F(n.getAttribute("data-formula") || ""), T = u.value, $());
212
- });
213
- const A = () => {
214
- const t = u.value.trim();
215
- if (!t) return;
216
- const a = { formula: t, format: m, inline: R.checked }, n = a.inline ? document.createElement("span") : document.createElement("div");
217
- if (n.className = a.inline ? "math-formula" : "math-block", n.setAttribute("data-math-formula", t), n.setAttribute("data-math-format", m), n.contentEditable = "false", n.style.cssText = a.inline ? "background: #f0f8ff; border: 1px solid #b8daff; border-radius: 4px; padding: 2px 6px; margin: 0 2px; color: #004085; display: inline-block; cursor: pointer;" : "background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; padding: 12px; margin: 8px 0; text-align: center; display: block; cursor: pointer;", m === "latex") {
218
- const b = window.katex;
219
- try {
220
- n.innerHTML = b.renderToString(t, {
221
- displayMode: !a.inline,
222
- throwOnError: !1
223
- });
224
- } catch (D) {
225
- n.textContent = a.inline ? `$${t}$` : `$$${t}$$`;
226
- }
227
- } else if (t.trim().startsWith("<math"))
228
- n.innerHTML = t;
229
- else {
230
- const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${a.inline ? "inline" : "block"}">${t}</math>`;
231
- n.innerHTML = b;
232
- }
233
- if (h)
234
- h.replaceWith(n);
235
- else if (B)
236
- B.deleteContents(), B.insertNode(n);
237
- else if (g && g.isConnected) {
238
- const b = document.createRange();
239
- b.selectNodeContents(g), b.collapse(!1), b.insertNode(n);
240
- }
241
- const M = n.closest(".rte-content, .editora-content") || g;
242
- M == null || M.dispatchEvent(new Event("input", { bubbles: !0 })), w();
243
- };
244
- f.addEventListener("click", w), y.addEventListener("click", w), p.addEventListener("click", A), c.addEventListener("click", (t) => {
245
- t.target === c && w();
246
- }), document.addEventListener("keydown", C, !0), P.forEach((t) => {
247
- t.addEventListener("change", (a) => {
248
- m = a.target.value, L = "", S(), $();
249
- });
250
- }), u.addEventListener("input", () => {
251
- T = u.value, $();
252
- }), u.addEventListener("keydown", (t) => {
253
- (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), A());
254
- }), S(), $(), u.focus();
255
- };
256
- if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
257
- window.__mathPluginDoubleClickInitialized = !0;
258
- const o = (r) => {
259
- const l = r.target.closest(".math-formula, .math-block");
260
- if (l) {
261
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h = l;
262
- const e = l.getAttribute("data-math-formula") || "", c = l.getAttribute("data-math-format") || "latex", d = l.classList.contains("math-formula");
263
- z({ formula: e, format: c, inline: d });
264
- }
265
- }, i = () => {
266
- document.addEventListener("dblclick", o, { capture: !0 });
267
- };
268
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : setTimeout(i, 100);
269
- }
270
- const U = () => ({
271
- name: "math",
272
- toolbar: [
273
- {
274
- label: "Insert Math",
275
- command: "insertMath",
276
- icon: '<svg width="24" height="24" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 4.8c.1-.5.5-.8 1-.8h10a1 1 0 1 1 0 2h-9.2L8.3 19.2a1 1 0 0 1-1.7.4l-3.4-4.2a1 1 0 0 1 1.6-1.2l2 2.5L9 4.8Zm9.7 5.5c.4.4.4 1 0 1.4L17 13.5l1.8 1.8a1 1 0 0 1-1.4 1.4L15.5 15l-1.8 1.8a1 1 0 0 1-1.4-1.4l1.8-1.8-1.8-1.8a1 1 0 0 1 1.4-1.4l1.8 1.8 1.8-1.8a1 1 0 0 1 1.4 0Z"></path></svg>'
277
- }
278
- ],
279
- commands: {
280
- insertMath: (o, i) => {
281
- const r = (i == null ? void 0 : i.contentElement) instanceof HTMLElement ? i.contentElement : null;
282
- return z(void 0, r), !0;
283
- }
284
- },
285
- keymap: {
286
- "Mod-Shift-m": "insertMath"
287
- }
288
- });
289
- export {
290
- U as MathPlugin
291
- };
292
- //# sourceMappingURL=MathPlugin.native-f_mDp8VL.mjs.map