@editora/core 1.0.9 → 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 (99) hide show
  1. package/README.md +1 -1
  2. package/dist/{A11yCheckerPlugin.native-58d12bed.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +12 -23
  3. package/dist/{AnchorPlugin.native-289a112a.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +102 -112
  4. package/dist/{ApprovalWorkflowPlugin.native-449ce66c.mjs → ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs} +173 -209
  5. package/dist/{BackgroundColorPlugin.native-8aceb5cc.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +9 -16
  6. package/dist/BlockquotePlugin.native-57_Xcjl1.mjs +212 -0
  7. package/dist/{BlocksLibraryPlugin.native-1cc51e63.mjs → BlocksLibraryPlugin.native-5sdsXsiE.mjs} +149 -205
  8. package/dist/{BoldPlugin.native-f9d7f8e4.mjs → BoldPlugin.native-CSh_LiIJ.mjs} +11 -7
  9. package/dist/CapitalizationPlugin.native-DLV4oPmB.mjs +159 -0
  10. package/dist/ChecklistPlugin.native-BS-kMz9O.mjs +371 -0
  11. package/dist/{CitationsPlugin.native-169fb1e8.mjs → CitationsPlugin.native-DQgoCd1B.mjs} +196 -261
  12. package/dist/ClearFormattingPlugin.native-DIS6AN2t.mjs +172 -0
  13. package/dist/CodePlugin.native-C5l1IeSS.mjs +4570 -0
  14. package/dist/{CodeSamplePlugin.native-6cc0148e.mjs → CodeSamplePlugin.native-CgGoH-X4.mjs} +10 -19
  15. package/dist/{CommentsPlugin.native-03659874.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +28 -55
  16. package/dist/{ConditionalContentPlugin.native-4983143a.mjs → ConditionalContentPlugin.native-CfhY46rU.mjs} +51 -108
  17. package/dist/{ContentRulesPlugin.native-63ed405b.mjs → ContentRulesPlugin.native-vPx5nC73.mjs} +153 -200
  18. package/dist/{DataBindingPlugin.native-427e9d75.mjs → DataBindingPlugin.native-BoXwghTz.mjs} +88 -124
  19. package/dist/DirectionPlugin.native-Bl-QLFzO.mjs +153 -0
  20. package/dist/{DocSchemaPlugin.native-8e41eda0.mjs → DocSchemaPlugin.native-DUSVRHqT.mjs} +112 -166
  21. package/dist/{DocumentManagerPlugin.native-e69895ad.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +4 -4
  22. package/dist/EmbedIframePlugin.native-BF_-LjTq.mjs +740 -0
  23. package/dist/{EmojisPlugin.native-65c5ac47.mjs → EmojisPlugin.native-CitxxlWX.mjs} +6 -11
  24. package/dist/{FontFamilyPlugin.native-f9bc255a.mjs → FontFamilyPlugin.native-j8hMTbg4.mjs} +4 -7
  25. package/dist/{FontSizePlugin.native-f5647872.mjs → FontSizePlugin.native-B_jCh7dY.mjs} +10 -19
  26. package/dist/{FootnotePlugin.native-494657b3.mjs → FootnotePlugin.native-D730OGRm.mjs} +39 -77
  27. package/dist/{FullscreenPlugin.native-87ce92e9.mjs → FullscreenPlugin.native-ChXyxeNw.mjs} +1 -1
  28. package/dist/HeadingPlugin.native-DZdvubrQ.mjs +249 -0
  29. package/dist/{HistoryPlugin.native-92ed4be4.mjs → HistoryPlugin.native-D2wl32jV.mjs} +107 -143
  30. package/dist/{IndentPlugin.native-e4ee902b.mjs → IndentPlugin.native-BHixp8sP.mjs} +12 -23
  31. package/dist/{ItalicPlugin.native-7c95cfbc.mjs → ItalicPlugin.native-CmnlwFHB.mjs} +15 -11
  32. package/dist/{LineHeightPlugin.native-5668f78c.mjs → LineHeightPlugin.native-CM7iXdQj.mjs} +10 -19
  33. package/dist/{LinkPlugin.native-6df29111.mjs → LinkPlugin.native-DYCIcdTm.mjs} +5 -9
  34. package/dist/{ListPlugin.native-fe2e115a.mjs → ListPlugin.native-V7EZC1lM.mjs} +5 -9
  35. package/dist/MathPlugin.native-NwWPHVmj.mjs +369 -0
  36. package/dist/{MediaManagerPlugin.native-3cf48a00.mjs → MediaManagerPlugin.native-eOsTJFpw.mjs} +11 -21
  37. package/dist/{MentionPlugin.native-3b1e8c05.mjs → MentionPlugin.native-BMDlOqur.mjs} +45 -89
  38. package/dist/MergeTagPlugin.native-BzRVoD9-.mjs +580 -0
  39. package/dist/{PIIRedactionPlugin.native-7ab10b9f.mjs → PIIRedactionPlugin.native-g7j4jOmm.mjs} +210 -260
  40. package/dist/{PageBreakPlugin.native-1794c5fb.mjs → PageBreakPlugin.native-DijGuHJZ.mjs} +16 -31
  41. package/dist/{PreviewPlugin.native-f7b67cc0.mjs → PreviewPlugin.native-WuIwOAOR.mjs} +6 -11
  42. package/dist/{PrintPlugin.native-f6a168c2.mjs → PrintPlugin.native-7qt5v7L5.mjs} +3 -5
  43. package/dist/{SlashCommandsPlugin.native-8d45e511.mjs → SlashCommandsPlugin.native-BiN6ODw5.mjs} +36 -71
  44. package/dist/{SmartPastePlugin.native-a6c5efec.mjs → SmartPastePlugin.native-CZAEHkyt.mjs} +173 -219
  45. package/dist/{SpecialCharactersPlugin.native-7f06d4ba.mjs → SpecialCharactersPlugin.native-DaG4b19I.mjs} +101 -85
  46. package/dist/{SpellCheckPlugin.native-04e20834.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +21 -41
  47. package/dist/{StrikethroughPlugin.native-905e9501.mjs → StrikethroughPlugin.native-V0TL4F48.mjs} +12 -30
  48. package/dist/{TablePlugin.native-7d5458c1.mjs → TablePlugin.native-DrHX-efe.mjs} +30 -58
  49. package/dist/TemplatePlugin.native-DLjFUaPW.mjs +1150 -0
  50. package/dist/{TextAlignmentPlugin.native-9357b3ed.mjs → TextAlignmentPlugin.native-sM_1s00t.mjs} +6 -11
  51. package/dist/{TextColorPlugin.native-d53ed459.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +14 -26
  52. package/dist/{TrackChangesPlugin.native-e96da509.mjs → TrackChangesPlugin.native-Bghu2q4a.mjs} +58 -115
  53. package/dist/{TranslationWorkflowPlugin.native-4e711b1e.mjs → TranslationWorkflowPlugin.native-DdF16tgT.mjs} +191 -257
  54. package/dist/{UnderlinePlugin.native-8080c998.mjs → UnderlinePlugin.native-DZzg23rv.mjs} +8 -4
  55. package/dist/{VersionDiffPlugin.native-5bbeff85.mjs → VersionDiffPlugin.native-Bvxgy--t.mjs} +26 -51
  56. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  57. package/dist/{anchoredPopover-5cca53ba.mjs → anchoredPopover-Bxds0VoB.mjs} +1 -1
  58. package/dist/core.css +1 -0
  59. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  60. package/dist/{editorContainerHelpers-69585c07.mjs → editorContainerHelpers-C7kdWnS0.mjs} +2 -3
  61. package/dist/editora.min.js +13 -14
  62. package/dist/editora.umd.js +13 -14
  63. package/dist/{html2canvas.esm-c51cb3b9.mjs → html2canvas.esm-AYkPY5LS.mjs} +894 -978
  64. package/dist/index-BslAFzmv.mjs +16544 -0
  65. package/dist/index-CPMGUZfB.js +10 -0
  66. package/dist/{index-7da30697.mjs → index-DBoj6QfW.mjs} +127 -164
  67. package/dist/index.cjs.js +1 -1
  68. package/dist/index.es-BYD2KEo6.mjs +6666 -0
  69. package/dist/index.esm.js +7 -12
  70. package/dist/inlineFormatting-DJ0-NZtx.mjs +97 -0
  71. package/dist/{jspdf.es.min-780c82db.mjs → jspdf.es.min-BJGtOnRT.mjs} +3784 -4808
  72. package/dist/plugin-loader.js +67 -67
  73. package/dist/{purify.es-3bdbcfc5.mjs → purify.es-CKpwg8Tk.mjs} +10 -20
  74. package/dist/webcomponent-core.js +131 -168
  75. package/dist/webcomponent-core.min.css +1 -1
  76. package/dist/webcomponent-core.min.js +139 -63
  77. package/dist/webcomponent.cjs.js +1 -1
  78. package/dist/webcomponent.esm.js +1 -1
  79. package/dist/webcomponent.js +191 -228
  80. package/dist/webcomponent.min.css +1 -1
  81. package/dist/webcomponent.min.js +1240 -1344
  82. package/package.json +1 -1
  83. package/dist/BlockquotePlugin.native-3541c714.mjs +0 -49
  84. package/dist/CapitalizationPlugin.native-42c135dc.mjs +0 -80
  85. package/dist/ChecklistPlugin.native-3b397ee9.mjs +0 -330
  86. package/dist/ClearFormattingPlugin.native-77baa514.mjs +0 -145
  87. package/dist/CodePlugin.native-989cf0aa.mjs +0 -2740
  88. package/dist/DirectionPlugin.native-4e742f42.mjs +0 -139
  89. package/dist/EmbedIframePlugin.native-55209c87.mjs +0 -568
  90. package/dist/HeadingPlugin.native-e38c4a16.mjs +0 -64
  91. package/dist/MathPlugin.native-735bbac2.mjs +0 -296
  92. package/dist/MergeTagPlugin.native-31cf7d48.mjs +0 -584
  93. package/dist/TemplatePlugin.native-580f0f63.mjs +0 -617
  94. package/dist/_commonjsHelpers-69d58be2.mjs +0 -31
  95. package/dist/documentManager-8327fb6e.mjs +0 -9166
  96. package/dist/index-072ef022.js +0 -11
  97. package/dist/index-49d31221.mjs +0 -16860
  98. package/dist/index.es-b47a189f.mjs +0 -5782
  99. package/dist/style.css +0 -1
@@ -1,296 +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)
42
- return null;
43
- const i = o.getRangeAt(0).startContainer, r = i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement;
44
- return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
45
- }, K = (o) => {
46
- const i = o || q();
47
- if (i != null && i.closest(k))
48
- return !0;
49
- const r = window.getSelection();
50
- if (r && r.rangeCount > 0) {
51
- const l = r.getRangeAt(0).startContainer, e = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
52
- if (e != null && e.closest(k))
53
- return !0;
54
- }
55
- const s = document.activeElement;
56
- return s != null && s.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
57
- }, z = async (o, i) => {
58
- const r = i || (h == null ? void 0 : h.closest(".rte-content, .editora-content")) || q() || g;
59
- g = r || null;
60
- const s = window.getSelection();
61
- if (s && s.rangeCount > 0) {
62
- const t = s.getRangeAt(0);
63
- B = r && r.contains(t.commonAncestorContainer) ? t.cloneRange() : null;
64
- }
65
- await O();
66
- const l = K(r), e = l ? {
67
- overlay: "rgba(0, 0, 0, 0.62)",
68
- dialogBg: "#1f2937",
69
- border: "#3b4657",
70
- panelBg: "#222d3a",
71
- fieldBg: "#111827",
72
- fieldBorder: "#4b5563",
73
- text: "#e2e8f0",
74
- muted: "#94a3b8",
75
- templateBtnBg: "#273244",
76
- templateBtnHover: "#334155",
77
- templateBtnText: "#dbe7f7",
78
- templateSubText: "#9fb0c6",
79
- previewBg: "#111827",
80
- previewText: "#cbd5e1",
81
- cancelBg: "#334155",
82
- cancelText: "#e2e8f0",
83
- cancelBorder: "#4b5563",
84
- insertBg: "#3b82f6",
85
- insertHover: "#2563eb",
86
- invalid: "#f87171"
87
- } : {
88
- overlay: "rgba(0, 0, 0, 0.5)",
89
- dialogBg: "#ffffff",
90
- border: "#e1e5e9",
91
- panelBg: "#f8f9fa",
92
- fieldBg: "#ffffff",
93
- fieldBorder: "#ced4da",
94
- text: "#1f2937",
95
- muted: "#6c757d",
96
- templateBtnBg: "#ffffff",
97
- templateBtnHover: "#f8f9fa",
98
- templateBtnText: "#1f2937",
99
- templateSubText: "#6c757d",
100
- previewBg: "#f8f9fa",
101
- previewText: "#6c757d",
102
- cancelBg: "#ffffff",
103
- cancelText: "#1f2937",
104
- cancelBorder: "#ced4da",
105
- insertBg: "#007bff",
106
- insertHover: "#0069d9",
107
- invalid: "#cc0000"
108
- }, c = document.createElement("div");
109
- 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;`;
110
- const d = document.createElement("div");
111
- 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};`;
112
- 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 = "";
113
- d.innerHTML = `
114
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
115
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${o ? "Edit" : "Insert"} Math Formula</h2>
116
- <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>
117
- </div>
118
-
119
- <div style="padding: 20px; overflow-y: auto; flex: 1;">
120
- <div style="margin-bottom: 20px;">
121
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
122
- <div style="display: flex; gap: 16px;">
123
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
124
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
125
- </div>
126
- </div>
127
-
128
- <div style="margin-bottom: 20px;">
129
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
130
- <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>
131
- </div>
132
-
133
- <div style="margin-bottom: 20px;">
134
- <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${I ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
135
- </div>
136
-
137
- <div style="margin-bottom: 20px;">
138
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
139
- <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>
140
- </div>
141
-
142
- <div style="margin-bottom: 20px;">
143
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
144
- <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>
145
- </div>
146
- </div>
147
-
148
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
149
- <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>
150
- <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>
151
- </div>
152
- `, c.appendChild(d), document.body.appendChild(c);
153
- 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) => {
154
- try {
155
- return decodeURIComponent(t);
156
- } catch (a) {
157
- return t;
158
- }
159
- }, S = () => {
160
- const t = j[m];
161
- E.innerHTML = t.map((a) => `
162
- <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;">
163
- <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${a.name}</div>
164
- <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${a.formula.substring(0, 20)}...</div>
165
- </button>
166
- `).join("");
167
- }, N = () => {
168
- const t = u.value.trim(), a = `${m}:${t}`;
169
- if (a !== L) {
170
- if (L = a, !t) {
171
- v.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
172
- return;
173
- }
174
- p.disabled = !1;
175
- try {
176
- if (m === "latex") {
177
- const n = window.katex;
178
- v.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
179
- } else
180
- t.trim().startsWith("<math") ? v.innerHTML = t : v.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
181
- } catch (n) {
182
- v.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
183
- }
184
- }
185
- }, $ = () => {
186
- x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
187
- x = null, N();
188
- });
189
- }, C = (t) => {
190
- t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), w());
191
- }, w = () => {
192
- document.removeEventListener("keydown", C, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
193
- };
194
- f.onmouseover = () => {
195
- f.style.color = "#f8fafc", f.style.background = l ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
196
- }, f.onmouseout = () => {
197
- f.style.color = e.muted, f.style.background = "none";
198
- }, y.onmouseover = () => {
199
- y.style.background = l ? "#475569" : "#f3f4f6";
200
- }, y.onmouseout = () => {
201
- y.style.background = e.cancelBg;
202
- }, p.onmouseover = () => {
203
- p.disabled || (p.style.background = e.insertHover);
204
- }, p.onmouseout = () => {
205
- p.style.background = e.insertBg;
206
- }, E.addEventListener("mouseover", (t) => {
207
- const n = t.target.closest("button[data-formula]");
208
- n && (n.style.background = e.templateBtnHover);
209
- }), E.addEventListener("mouseout", (t) => {
210
- const n = t.target.closest("button[data-formula]");
211
- n && (n.style.background = e.templateBtnBg);
212
- }), E.addEventListener("click", (t) => {
213
- const n = t.target.closest("button[data-formula]");
214
- n && (u.value = F(n.getAttribute("data-formula") || ""), T = u.value, $());
215
- });
216
- const A = () => {
217
- const t = u.value.trim();
218
- if (!t)
219
- return;
220
- const a = { formula: t, format: m, inline: R.checked }, n = a.inline ? document.createElement("span") : document.createElement("div");
221
- 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") {
222
- const b = window.katex;
223
- try {
224
- n.innerHTML = b.renderToString(t, {
225
- displayMode: !a.inline,
226
- throwOnError: !1
227
- });
228
- } catch (D) {
229
- n.textContent = a.inline ? `$${t}$` : `$$${t}$$`;
230
- }
231
- } else if (t.trim().startsWith("<math"))
232
- n.innerHTML = t;
233
- else {
234
- const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${a.inline ? "inline" : "block"}">${t}</math>`;
235
- n.innerHTML = b;
236
- }
237
- if (h)
238
- h.replaceWith(n);
239
- else if (B)
240
- B.deleteContents(), B.insertNode(n);
241
- else if (g && g.isConnected) {
242
- const b = document.createRange();
243
- b.selectNodeContents(g), b.collapse(!1), b.insertNode(n);
244
- }
245
- const M = n.closest(".rte-content, .editora-content") || g;
246
- M == null || M.dispatchEvent(new Event("input", { bubbles: !0 })), w();
247
- };
248
- f.addEventListener("click", w), y.addEventListener("click", w), p.addEventListener("click", A), c.addEventListener("click", (t) => {
249
- t.target === c && w();
250
- }), document.addEventListener("keydown", C, !0), P.forEach((t) => {
251
- t.addEventListener("change", (a) => {
252
- m = a.target.value, L = "", S(), $();
253
- });
254
- }), u.addEventListener("input", () => {
255
- T = u.value, $();
256
- }), u.addEventListener("keydown", (t) => {
257
- (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), A());
258
- }), S(), $(), u.focus();
259
- };
260
- if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
261
- window.__mathPluginDoubleClickInitialized = !0;
262
- const o = (r) => {
263
- const l = r.target.closest(".math-formula, .math-block");
264
- if (l) {
265
- r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), h = l;
266
- const e = l.getAttribute("data-math-formula") || "", c = l.getAttribute("data-math-format") || "latex", d = l.classList.contains("math-formula");
267
- z({ formula: e, format: c, inline: d });
268
- }
269
- }, i = () => {
270
- document.addEventListener("dblclick", o, { capture: !0 });
271
- };
272
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : setTimeout(i, 100);
273
- }
274
- const U = () => ({
275
- name: "math",
276
- toolbar: [
277
- {
278
- label: "Insert Math",
279
- command: "insertMath",
280
- 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>'
281
- }
282
- ],
283
- commands: {
284
- insertMath: (o, i) => {
285
- const r = (i == null ? void 0 : i.contentElement) instanceof HTMLElement ? i.contentElement : null;
286
- return z(void 0, r), !0;
287
- }
288
- },
289
- keymap: {
290
- "Mod-Shift-m": "insertMath"
291
- }
292
- });
293
- export {
294
- U as MathPlugin
295
- };
296
- //# sourceMappingURL=MathPlugin.native-735bbac2.mjs.map