@editora/core 1.0.3 → 1.0.4

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 (131) hide show
  1. package/README.md +34 -0
  2. package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
  3. package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
  4. package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
  5. package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
  6. package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
  7. package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-0Zari_zp.mjs} +329 -310
  8. package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
  9. package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
  10. package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
  11. package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
  12. package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
  13. package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
  14. package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
  15. package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
  16. package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
  17. package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
  18. package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
  19. package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
  20. package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
  21. package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
  22. package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
  23. package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
  24. package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
  25. package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
  26. package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
  27. package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
  28. package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
  29. package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
  30. package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
  31. package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
  32. package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
  33. package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
  34. package/dist/core.css +1 -1
  35. package/dist/editora.min.js +31 -29
  36. package/dist/editora.umd.js +31 -29
  37. package/dist/index-CqWQFb3D.js +10 -0
  38. package/dist/index-OwnkG39N.mjs +2227 -0
  39. package/dist/index.cjs.js +14 -18
  40. package/dist/index.esm.js +204 -521
  41. package/dist/plugin-loader.js +26 -26
  42. package/dist/webcomponent-core.js +1286 -295
  43. package/dist/webcomponent-core.min.css +1 -1
  44. package/dist/webcomponent-core.min.js +100 -75
  45. package/dist/webcomponent.cjs.js +1 -1
  46. package/dist/webcomponent.esm.js +1 -1
  47. package/dist/webcomponent.js +1252 -261
  48. package/dist/webcomponent.min.css +1 -1
  49. package/dist/webcomponent.min.js +3616 -2109
  50. package/index.d.ts +355 -0
  51. package/package.json +19 -17
  52. package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
  53. package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
  54. package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
  55. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
  56. package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
  57. package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
  58. package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
  59. package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
  60. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
  61. package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
  62. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
  63. package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
  64. package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
  65. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
  66. package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
  67. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
  68. package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
  69. package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
  70. package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
  71. package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
  72. package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
  73. package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
  74. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
  75. package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
  76. package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
  77. package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
  78. package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
  79. package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
  80. package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
  81. package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
  82. package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
  83. package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
  84. package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
  85. package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
  86. package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
  87. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
  88. package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
  89. package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
  90. package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
  91. package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
  92. package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
  93. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
  94. package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
  95. package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
  96. package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
  97. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
  98. package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
  99. package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
  100. package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
  101. package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
  102. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
  103. package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
  104. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
  105. package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
  106. package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
  107. package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
  108. package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
  109. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
  110. package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
  111. package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
  112. package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
  113. package/dist/documentManager-irzj9n3V.mjs.map +0 -1
  114. package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
  115. package/dist/editora.min.js.map +0 -1
  116. package/dist/editora.umd.js.map +0 -1
  117. package/dist/index-BF5RBhL9.js +0 -4
  118. package/dist/index-BF5RBhL9.js.map +0 -1
  119. package/dist/index-BPsf460l.mjs +0 -1243
  120. package/dist/index-BPsf460l.mjs.map +0 -1
  121. package/dist/index.cjs.js.map +0 -1
  122. package/dist/index.es-CuicffkQ.mjs.map +0 -1
  123. package/dist/index.esm.js.map +0 -1
  124. package/dist/plugin-loader.js.map +0 -1
  125. package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
  126. package/dist/webcomponent-core.js.map +0 -1
  127. package/dist/webcomponent-core.min.js.map +0 -1
  128. package/dist/webcomponent.cjs.js.map +0 -1
  129. package/dist/webcomponent.esm.js.map +0 -1
  130. package/dist/webcomponent.js.map +0 -1
  131. package/dist/webcomponent.min.js.map +0 -1
@@ -1,5 +1,5 @@
1
- let r = null, a = !1, i = null;
2
- const v = (e) => {
1
+ let a = null, p = !1, i = null;
2
+ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
3
3
  if (!e) return null;
4
4
  let t = e;
5
5
  for (; t; ) {
@@ -9,29 +9,104 @@ const v = (e) => {
9
9
  }
10
10
  return null;
11
11
  }, w = (e) => {
12
- if (!r) {
12
+ if (e) {
13
+ const o = e.startContainer, n = o.nodeType === Node.ELEMENT_NODE ? o : o.parentElement;
14
+ if (n != null && n.closest(c)) return !0;
15
+ }
16
+ const t = document.activeElement;
17
+ return t != null && t.closest(c) ? !0 : document.body.matches(c) || document.documentElement.matches(c);
18
+ }, C = () => {
19
+ if (document.getElementById("rte-link-dialog-theme-styles")) return;
20
+ const e = document.createElement("style");
21
+ e.id = "rte-link-dialog-theme-styles", e.textContent = `
22
+ .link-dialog-overlay.rte-theme-dark .link-dialog {
23
+ background: #1f2937 !important;
24
+ border: 1px solid #4b5563 !important;
25
+ color: #e2e8f0 !important;
26
+ box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6) !important;
27
+ }
28
+
29
+ .link-dialog-overlay.rte-theme-dark .link-dialog-header {
30
+ border-bottom-color: #3b4657 !important;
31
+ background: #222d3a !important;
32
+ }
33
+
34
+ .link-dialog-overlay.rte-theme-dark .link-dialog-header h3,
35
+ .link-dialog-overlay.rte-theme-dark label {
36
+ color: #e2e8f0 !important;
37
+ }
38
+
39
+ .link-dialog-overlay.rte-theme-dark .link-dialog-close {
40
+ color: #94a3b8 !important;
41
+ }
42
+
43
+ .link-dialog-overlay.rte-theme-dark .link-dialog-close:hover {
44
+ background: #334155 !important;
45
+ color: #f8fafc !important;
46
+ border-radius: 4px;
47
+ }
48
+
49
+ .link-dialog-overlay.rte-theme-dark .link-dialog-footer {
50
+ border-top-color: #3b4657 !important;
51
+ background: #222d3a !important;
52
+ }
53
+
54
+ .link-dialog-overlay.rte-theme-dark input[type='text'],
55
+ .link-dialog-overlay.rte-theme-dark input[type='url'] {
56
+ background: #111827 !important;
57
+ border-color: #4b5563 !important;
58
+ color: #e2e8f0 !important;
59
+ }
60
+
61
+ .link-dialog-overlay.rte-theme-dark input[type='text']::placeholder,
62
+ .link-dialog-overlay.rte-theme-dark input[type='url']::placeholder {
63
+ color: #94a3b8 !important;
64
+ }
65
+
66
+ .link-dialog-overlay.rte-theme-dark .btn-cancel {
67
+ background: #334155 !important;
68
+ border-color: #4b5563 !important;
69
+ color: #e2e8f0 !important;
70
+ }
71
+
72
+ .link-dialog-overlay.rte-theme-dark .btn-cancel:hover {
73
+ background: #475569 !important;
74
+ border-color: #64748b !important;
75
+ }
76
+
77
+ .link-dialog-overlay.rte-theme-dark .btn-submit {
78
+ background: #3b82f6 !important;
79
+ }
80
+
81
+ .link-dialog-overlay.rte-theme-dark .btn-submit:hover {
82
+ background: #2563eb !important;
83
+ }
84
+ `, document.head.appendChild(e);
85
+ }, T = (e) => {
86
+ if (!a) {
13
87
  console.warn("No selection range stored");
14
88
  return;
15
89
  }
16
- const t = r.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, s = v(n);
17
- if (s) {
18
- if (a && i) {
90
+ const t = a.startContainer, o = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, n = L(o);
91
+ if (n) {
92
+ if (p && i) {
19
93
  i.href = e.url, i.textContent = e.text, i.target = e.target, e.target === "_blank" ? i.setAttribute("rel", "noopener noreferrer") : i.removeAttribute("rel"), e.title ? i.title = e.title : i.removeAttribute("title");
20
- const o = document.createRange();
21
- o.selectNodeContents(i);
94
+ const r = document.createRange();
95
+ r.selectNodeContents(i);
22
96
  const l = window.getSelection();
23
- l && (l.removeAllRanges(), l.addRange(o));
97
+ l && (l.removeAllRanges(), l.addRange(r));
24
98
  } else {
25
- const o = document.createElement("a");
26
- o.href = e.url, o.textContent = e.text, o.target = e.target, e.target === "_blank" && o.setAttribute("rel", "noopener noreferrer"), e.title && (o.title = e.title), r.deleteContents(), r.insertNode(o), r.setStartAfter(o), r.setEndAfter(o);
99
+ const r = document.createElement("a");
100
+ r.href = e.url, r.textContent = e.text, r.target = e.target, e.target === "_blank" && r.setAttribute("rel", "noopener noreferrer"), e.title && (r.title = e.title), a.deleteContents(), a.insertNode(r), a.setStartAfter(r), a.setEndAfter(r);
27
101
  const l = window.getSelection();
28
- l && (l.removeAllRanges(), l.addRange(r));
102
+ l && (l.removeAllRanges(), l.addRange(a));
29
103
  }
30
- s.focus(), r = null, a = !1, i = null;
104
+ n.focus(), a = null, p = !1, i = null;
31
105
  }
32
- }, g = (e) => {
33
- const t = document.createElement("div");
34
- t.className = "link-dialog-overlay", t.style.cssText = `
106
+ }, b = (e, t) => {
107
+ C();
108
+ const o = document.createElement("div");
109
+ o.className = "link-dialog-overlay", t && o.classList.add("rte-theme-dark"), o.style.cssText = `
35
110
  position: fixed;
36
111
  top: 0;
37
112
  left: 0;
@@ -107,50 +182,50 @@ const v = (e) => {
107
182
  </button>
108
183
  </div>
109
184
  </form>
110
- `, t.appendChild(n), document.body.appendChild(t);
111
- const s = n.querySelector("#link-form"), o = n.querySelector("#link-text"), l = n.querySelector("#link-url"), x = n.querySelector("#link-title"), k = n.querySelector("#link-target"), y = n.querySelector(".link-dialog-close"), h = n.querySelector(".btn-cancel"), d = () => {
112
- document.body.removeChild(t);
185
+ `, o.appendChild(n), document.body.appendChild(o);
186
+ const r = n.querySelector("#link-form"), l = n.querySelector("#link-text"), d = n.querySelector("#link-url"), x = n.querySelector("#link-title"), y = n.querySelector("#link-target"), v = n.querySelector(".link-dialog-close"), E = n.querySelector(".btn-cancel"), s = () => {
187
+ document.body.removeChild(o);
113
188
  };
114
- y.addEventListener("click", d), h.addEventListener("click", d), t.addEventListener("click", (c) => {
115
- c.target === t && d();
116
- }), s.addEventListener("submit", (c) => {
117
- c.preventDefault();
118
- const u = l.value.trim();
119
- u && (w({
120
- text: o.value.trim() || u,
121
- url: u,
122
- target: k.checked ? "_blank" : "_self",
189
+ v.addEventListener("click", s), E.addEventListener("click", s), o.addEventListener("click", (u) => {
190
+ u.target === o && s();
191
+ }), r.addEventListener("submit", (u) => {
192
+ u.preventDefault();
193
+ const g = d.value.trim();
194
+ g && (T({
195
+ text: l.value.trim() || g,
196
+ url: g,
197
+ target: y.checked ? "_blank" : "_self",
123
198
  title: x.value.trim() || void 0
124
- }), d());
125
- }), setTimeout(() => o.focus(), 100);
126
- }, b = () => {
199
+ }), s());
200
+ }), setTimeout(() => l.focus(), 100);
201
+ }, f = () => {
127
202
  const e = window.getSelection();
128
203
  if (!e || e.rangeCount === 0) return !1;
129
204
  const t = e.getRangeAt(0).cloneRange();
130
- r = t;
131
- const n = e.toString() || "", s = t.startContainer, o = s.nodeType === Node.TEXT_NODE ? s.parentElement : s, l = o == null ? void 0 : o.closest("a");
132
- return l ? (a = !0, i = l, g({
133
- text: l.textContent || "",
134
- url: l.href,
135
- target: l.target || "_self",
136
- title: l.title || "",
205
+ a = t;
206
+ const o = w(t), n = e.toString() || "", r = t.startContainer, l = r.nodeType === Node.TEXT_NODE ? r.parentElement : r, d = l == null ? void 0 : l.closest("a");
207
+ return d ? (p = !0, i = d, b({
208
+ text: d.textContent || "",
209
+ url: d.href,
210
+ target: d.target || "_self",
211
+ title: d.title || "",
137
212
  isEditing: !0
138
- })) : (a = !1, i = null, g({
213
+ }, o)) : (p = !1, i = null, b({
139
214
  text: n,
140
215
  url: "",
141
216
  target: "_self",
142
217
  isEditing: !1
143
- })), !0;
144
- }, m = () => (document.execCommand("unlink", !1), !0), p = (e, t) => {
145
- var n;
146
- typeof window != "undefined" && ((n = window.registerEditorCommand) == null || n.call(window, e, t));
147
- }, f = () => {
148
- p("openLinkDialog", b), p("removeLink", m), p("createLink", (e) => {
218
+ }, o)), !0;
219
+ }, h = () => (document.execCommand("unlink", !1), !0), m = (e, t) => {
220
+ var o;
221
+ typeof window != "undefined" && ((o = window.registerEditorCommand) == null || o.call(window, e, t));
222
+ }, k = () => {
223
+ m("openLinkDialog", f), m("removeLink", h), m("createLink", (e) => {
149
224
  e && document.execCommand("createLink", !1, e);
150
225
  });
151
226
  };
152
- typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f) : f());
153
- const L = () => ({
227
+ typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", k) : k());
228
+ const A = () => ({
154
229
  name: "link",
155
230
  marks: {
156
231
  link: {
@@ -191,16 +266,16 @@ const L = () => ({
191
266
  }
192
267
  ],
193
268
  commands: {
194
- openLinkDialog: b,
195
- removeLink: m
269
+ openLinkDialog: f,
270
+ removeLink: h
196
271
  },
197
272
  keymap: {
198
273
  "Mod-k": "openLinkDialog"
199
274
  }
200
275
  });
201
276
  export {
202
- L as LinkPlugin,
203
- b as openLinkDialog,
204
- m as removeLink
277
+ A as LinkPlugin,
278
+ f as openLinkDialog,
279
+ h as removeLink
205
280
  };
206
- //# sourceMappingURL=LinkPlugin.native-BdAOV-iu.mjs.map
281
+ //# sourceMappingURL=LinkPlugin.native-CS2g-G18.mjs.map
@@ -1,11 +1,58 @@
1
- const l = () => (document.execCommand("insertUnorderedList", !1), !0), s = () => (document.execCommand("insertOrderedList", !1), !0), e = (d, i) => {
1
+ const d = () => m("insertUnorderedList"), u = () => m("insertOrderedList");
2
+ function g() {
3
+ const o = window.getSelection();
4
+ if (o && o.rangeCount > 0) {
5
+ const t = o.getRangeAt(0).startContainer, r = t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement, e = r == null ? void 0 : r.closest('[contenteditable="true"], .rte-content, .editora-content');
6
+ if (e) return e;
7
+ }
8
+ const n = document.activeElement;
9
+ return n ? n.getAttribute("contenteditable") === "true" ? n : n.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
10
+ }
11
+ function f(o) {
12
+ o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach((t) => {
13
+ Array.from(t.childNodes).forEach((e) => {
14
+ if (e.nodeType === Node.TEXT_NODE) {
15
+ const l = (e.textContent || "").trim();
16
+ if (!l) {
17
+ t.removeChild(e);
18
+ return;
19
+ }
20
+ const s = document.createElement("li");
21
+ s.textContent = l, t.replaceChild(s, e);
22
+ return;
23
+ }
24
+ if (!(e instanceof HTMLElement)) {
25
+ t.removeChild(e);
26
+ return;
27
+ }
28
+ if (e.tagName === "LI")
29
+ return;
30
+ const i = document.createElement("li");
31
+ for (; e.firstChild; )
32
+ i.appendChild(e.firstChild);
33
+ t.replaceChild(i, e);
34
+ });
35
+ });
36
+ }
37
+ function m(o) {
38
+ const n = g();
39
+ if (!n) return !1;
40
+ const t = window.getSelection();
41
+ if (!t || t.rangeCount === 0) return !1;
42
+ const r = t.getRangeAt(0);
43
+ if (!n.contains(r.commonAncestorContainer)) return !1;
44
+ n.focus({ preventScroll: !0 });
45
+ const e = document.execCommand(o, !1);
46
+ return f(n), n.dispatchEvent(new Event("input", { bubbles: !0 })), e !== !1;
47
+ }
48
+ const c = (o, n) => {
2
49
  var t;
3
- typeof window != "undefined" && ((t = window.registerEditorCommand) == null || t.call(window, d, i));
4
- }, o = () => {
5
- e("toggleBulletList", l), e("toggleOrderedList", s);
50
+ typeof window != "undefined" && ((t = window.registerEditorCommand) == null || t.call(window, o, n));
51
+ }, a = () => {
52
+ c("toggleBulletList", d), c("toggleOrderedList", u);
6
53
  };
7
- typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", o) : o());
8
- const a = () => ({
54
+ typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a) : a());
55
+ const h = () => ({
9
56
  name: "list",
10
57
  nodes: {
11
58
  bulletList: {
@@ -43,8 +90,8 @@ const a = () => ({
43
90
  }
44
91
  ],
45
92
  commands: {
46
- toggleBulletList: l,
47
- toggleOrderedList: s
93
+ toggleBulletList: d,
94
+ toggleOrderedList: u
48
95
  },
49
96
  keymap: {
50
97
  "Mod-Shift-8": "toggleBulletList",
@@ -52,8 +99,8 @@ const a = () => ({
52
99
  }
53
100
  });
54
101
  export {
55
- a as ListPlugin,
56
- l as toggleBulletList,
57
- s as toggleOrderedList
102
+ h as ListPlugin,
103
+ d as toggleBulletList,
104
+ u as toggleOrderedList
58
105
  };
59
- //# sourceMappingURL=ListPlugin.native-CLFU5AUQ.mjs.map
106
+ //# sourceMappingURL=ListPlugin.native-V7EZC1lM.mjs.map
@@ -0,0 +1,251 @@
1
+ const C = {
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 h = null, w = null, E = !1;
23
+ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promise((o, d) => {
24
+ if (window.katex) {
25
+ o(window.katex);
26
+ return;
27
+ }
28
+ if (E) {
29
+ const i = setInterval(() => {
30
+ window.katex && (clearInterval(i), o(window.katex));
31
+ }, 100);
32
+ return;
33
+ }
34
+ E = !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 e = document.createElement("script");
38
+ e.src = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", e.onload = () => o(window.katex), e.onerror = d, document.head.appendChild(e);
39
+ }), H = () => {
40
+ const o = window.getSelection();
41
+ if (o && o.rangeCount > 0) {
42
+ const r = o.getRangeAt(0).startContainer, e = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
43
+ if (e != null && e.closest(y)) return !0;
44
+ }
45
+ const d = document.activeElement;
46
+ return d != null && d.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
47
+ }, T = async (o) => {
48
+ const d = window.getSelection();
49
+ d && d.rangeCount > 0 && (h = d.getRangeAt(0).cloneRange()), await q();
50
+ const r = H(), e = r ? {
51
+ overlay: "rgba(0, 0, 0, 0.62)",
52
+ dialogBg: "#1f2937",
53
+ border: "#3b4657",
54
+ panelBg: "#222d3a",
55
+ fieldBg: "#111827",
56
+ fieldBorder: "#4b5563",
57
+ text: "#e2e8f0",
58
+ muted: "#94a3b8",
59
+ templateBtnBg: "#273244",
60
+ templateBtnHover: "#334155",
61
+ templateBtnText: "#dbe7f7",
62
+ templateSubText: "#9fb0c6",
63
+ previewBg: "#111827",
64
+ previewText: "#cbd5e1",
65
+ cancelBg: "#334155",
66
+ cancelText: "#e2e8f0",
67
+ cancelBorder: "#4b5563",
68
+ insertBg: "#3b82f6",
69
+ insertHover: "#2563eb",
70
+ invalid: "#f87171"
71
+ } : {
72
+ overlay: "rgba(0, 0, 0, 0.5)",
73
+ dialogBg: "#ffffff",
74
+ border: "#e1e5e9",
75
+ panelBg: "#f8f9fa",
76
+ fieldBg: "#ffffff",
77
+ fieldBorder: "#ced4da",
78
+ text: "#1f2937",
79
+ muted: "#6c757d",
80
+ templateBtnBg: "#ffffff",
81
+ templateBtnHover: "#f8f9fa",
82
+ templateBtnText: "#1f2937",
83
+ templateSubText: "#6c757d",
84
+ previewBg: "#f8f9fa",
85
+ previewText: "#6c757d",
86
+ cancelBg: "#ffffff",
87
+ cancelText: "#1f2937",
88
+ cancelBorder: "#ced4da",
89
+ insertBg: "#007bff",
90
+ insertHover: "#0069d9",
91
+ invalid: "#cc0000"
92
+ }, i = document.createElement("div");
93
+ i.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;`;
94
+ const l = document.createElement("div");
95
+ l.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};`;
96
+ let s = (o == null ? void 0 : o.format) || "latex", u = (o == null ? void 0 : o.formula) || "", M = (o == null ? void 0 : o.inline) !== !1;
97
+ l.innerHTML = `
98
+ <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
99
+ <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${o ? "Edit" : "Insert"} Math Formula</h2>
100
+ <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>
101
+ </div>
102
+
103
+ <div style="padding: 20px; overflow-y: auto; flex: 1;">
104
+ <div style="margin-bottom: 20px;">
105
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
106
+ <div style="display: flex; gap: 16px;">
107
+ <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${s === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
108
+ <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${s === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
109
+ </div>
110
+ </div>
111
+
112
+ <div style="margin-bottom: 20px;">
113
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
114
+ <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>
115
+ </div>
116
+
117
+ <div style="margin-bottom: 20px;">
118
+ <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${M ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
119
+ </div>
120
+
121
+ <div style="margin-bottom: 20px;">
122
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
123
+ <textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 14px; background: ${e.fieldBg}; color: ${e.text};">${u}</textarea>
124
+ </div>
125
+
126
+ <div style="margin-bottom: 20px;">
127
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
128
+ <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>
129
+ </div>
130
+ </div>
131
+
132
+ <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
133
+ <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>
134
+ <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>
135
+ </div>
136
+ `, i.appendChild(l), document.body.appendChild(i);
137
+ const c = l.querySelector("#formula-input"), f = l.querySelector("#preview-area"), k = l.querySelector("#templates-grid"), L = l.querySelectorAll('input[name="format"]'), S = l.querySelector("#inline-cb"), m = l.querySelector("#insert-btn"), p = l.querySelector(".close-btn"), x = l.querySelector(".cancel-btn"), $ = () => {
138
+ const t = C[s];
139
+ k.innerHTML = t.map((n) => `
140
+ <button type="button" data-formula="${n.formula.replace(/"/g, "&quot;")}" title="${n.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left;">
141
+ <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
142
+ <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0, 20)}...</div>
143
+ </button>
144
+ `).join(""), k.querySelectorAll("button").forEach((n) => {
145
+ const a = n;
146
+ a.onmouseover = () => {
147
+ a.style.background = e.templateBtnHover;
148
+ }, a.onmouseout = () => {
149
+ a.style.background = e.templateBtnBg;
150
+ }, n.addEventListener("click", () => {
151
+ c.value = n.getAttribute("data-formula") || "", u = c.value, b();
152
+ });
153
+ });
154
+ }, b = () => {
155
+ const t = c.value.trim();
156
+ if (!t) {
157
+ f.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, m.disabled = !0;
158
+ return;
159
+ }
160
+ m.disabled = !1;
161
+ try {
162
+ if (s === "latex") {
163
+ const n = window.katex;
164
+ f.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
165
+ } else
166
+ t.trim().startsWith("<math") ? f.innerHTML = t : f.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
167
+ } catch (n) {
168
+ f.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
169
+ }
170
+ }, g = () => document.body.removeChild(i);
171
+ p.onmouseover = () => {
172
+ p.style.color = "#f8fafc", p.style.background = r ? "#334155" : "#e5e7eb", p.style.borderRadius = "4px";
173
+ }, p.onmouseout = () => {
174
+ p.style.color = e.muted, p.style.background = "none";
175
+ }, x.onmouseover = () => {
176
+ x.style.background = r ? "#475569" : "#f3f4f6";
177
+ }, x.onmouseout = () => {
178
+ x.style.background = e.cancelBg;
179
+ }, m.onmouseover = () => {
180
+ m.disabled || (m.style.background = e.insertHover);
181
+ }, m.onmouseout = () => {
182
+ m.style.background = e.insertBg;
183
+ };
184
+ const B = () => {
185
+ const t = c.value.trim();
186
+ if (!t) return;
187
+ const n = { formula: t, format: s, inline: S.checked }, a = n.inline ? document.createElement("span") : document.createElement("div");
188
+ if (a.className = n.inline ? "math-formula" : "math-block", a.setAttribute("data-math-formula", t), a.setAttribute("data-math-format", s), a.contentEditable = "false", a.style.cssText = n.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;", s === "latex") {
189
+ const v = window.katex;
190
+ try {
191
+ a.innerHTML = v.renderToString(t, {
192
+ displayMode: !n.inline,
193
+ throwOnError: !1
194
+ });
195
+ } catch (z) {
196
+ a.textContent = n.inline ? `$${t}$` : `$$${t}$$`;
197
+ }
198
+ } else if (t.trim().startsWith("<math"))
199
+ a.innerHTML = t;
200
+ else {
201
+ const v = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${n.inline ? "inline" : "block"}">${t}</math>`;
202
+ a.innerHTML = v;
203
+ }
204
+ w ? w.replaceWith(a) : h && (h.deleteContents(), h.insertNode(a)), g();
205
+ };
206
+ p.addEventListener("click", g), x.addEventListener("click", g), m.addEventListener("click", B), i.addEventListener("click", (t) => {
207
+ t.target === i && g();
208
+ }), L.forEach((t) => {
209
+ t.addEventListener("change", (n) => {
210
+ s = n.target.value, $(), b();
211
+ });
212
+ }), c.addEventListener("input", () => {
213
+ u = c.value, b();
214
+ }), c.addEventListener("keydown", (t) => {
215
+ (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), B());
216
+ }), $(), b(), c.focus();
217
+ };
218
+ if (typeof window != "undefined" && !window.__mathPluginDoubleClickInitialized) {
219
+ window.__mathPluginDoubleClickInitialized = !0;
220
+ const o = (r) => {
221
+ const i = r.target.closest(".math-formula, .math-block");
222
+ if (i) {
223
+ r.preventDefault(), r.stopPropagation(), r.stopImmediatePropagation(), w = i;
224
+ const l = i.getAttribute("data-math-formula") || "", s = i.getAttribute("data-math-format") || "latex", u = i.classList.contains("math-formula");
225
+ T({ formula: l, format: s, inline: u });
226
+ }
227
+ }, d = () => {
228
+ document.addEventListener("dblclick", o, { capture: !0 });
229
+ };
230
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", d) : setTimeout(d, 100);
231
+ }
232
+ const I = () => ({
233
+ name: "math",
234
+ toolbar: [
235
+ {
236
+ label: "Insert Math",
237
+ command: "insertMath",
238
+ 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>'
239
+ }
240
+ ],
241
+ commands: {
242
+ insertMath: () => (T(), !0)
243
+ },
244
+ keymap: {
245
+ "Mod-Shift-m": "insertMath"
246
+ }
247
+ });
248
+ export {
249
+ I as MathPlugin
250
+ };
251
+ //# sourceMappingURL=MathPlugin.native-KUxz0o8C.mjs.map