@editora/plugins 1.0.6 → 1.0.8

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 +57 -4
  2. package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
  3. package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
  4. package/dist/anchor.cjs.js +11 -11
  5. package/dist/anchor.esm.js +130 -107
  6. package/dist/anchoredPopover-BzqGPOAE.js +1 -0
  7. package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
  8. package/dist/background-color.cjs.js +3 -3
  9. package/dist/background-color.esm.js +116 -119
  10. package/dist/code.cjs.js +82 -102
  11. package/dist/code.esm.js +1172 -662
  12. package/dist/comments.cjs.js +10 -10
  13. package/dist/comments.esm.js +195 -177
  14. package/dist/document-manager.cjs.js +1 -1
  15. package/dist/document-manager.esm.js +1 -1
  16. package/dist/documentManager-CTqRftU8.mjs +8369 -0
  17. package/dist/documentManager-Jf0RbSks.js +17 -0
  18. package/dist/embed-iframe.cjs.js +2 -2
  19. package/dist/embed-iframe.esm.js +8 -5
  20. package/dist/emojis.cjs.js +64 -39
  21. package/dist/emojis.esm.js +133 -104
  22. package/dist/html2canvas.esm-B5qzocYs.js +5 -0
  23. package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
  24. package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
  25. package/dist/index-CvJk4DKa.js +221 -0
  26. package/dist/index-D3CycEFU.mjs +16543 -0
  27. package/dist/index-tqLTHcO6.js +1 -0
  28. package/dist/index.cjs.js +1 -1
  29. package/dist/{index.es-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
  30. package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
  31. package/dist/index.esm.js +87 -79
  32. package/dist/jspdf.es.min-BoS80556.js +77 -0
  33. package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
  34. package/dist/link.cjs.js +6 -6
  35. package/dist/link.esm.js +41 -39
  36. package/dist/math.cjs.js +21 -21
  37. package/dist/math.esm.js +151 -112
  38. package/dist/media-manager.cjs.js +15 -15
  39. package/dist/media-manager.esm.js +227 -206
  40. package/dist/merge-tag.cjs.js +44 -12
  41. package/dist/merge-tag.esm.js +368 -241
  42. package/dist/page-break.cjs.js +2 -2
  43. package/dist/page-break.esm.js +77 -69
  44. package/dist/special-characters.cjs.js +83 -45
  45. package/dist/special-characters.esm.js +149 -100
  46. package/dist/spell-check.cjs.js +9 -9
  47. package/dist/spell-check.esm.js +235 -216
  48. package/dist/template.cjs.js +14 -14
  49. package/dist/template.esm.js +157 -131
  50. package/dist/text-color.cjs.js +9 -9
  51. package/dist/text-color.esm.js +131 -115
  52. package/index.d.ts +51 -1
  53. package/package.json +6 -4
  54. package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
  55. package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
  56. package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
  57. package/dist/documentManager-_tQQfQi9.js +0 -317
  58. package/dist/index-D3pJyAsj.js +0 -1
package/dist/link.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const c='[data-theme="dark"], .dark, .editora-theme-dark',L=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},w=e=>{if(e){const n=e.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(c))return!0}return document.activeElement?.closest(c)?!0:document.body.matches(c)||document.documentElement.matches(c)},C=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const p='[data-theme="dark"], .dark, .editora-theme-dark',w=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},C=e=>{if(e){const n=e.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(p))return!0}return document.activeElement?.closest(p)?!0:document.body.matches(p)||document.documentElement.matches(p)},T=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
2
2
  .link-dialog-overlay.rte-theme-dark .link-dialog {
3
3
  background: #1f2937 !important;
4
4
  border: 1px solid #4b5563 !important;
@@ -61,7 +61,7 @@
61
61
  .link-dialog-overlay.rte-theme-dark .btn-submit:hover {
62
62
  background: #2563eb !important;
63
63
  }
64
- `,document.head.appendChild(e)},T=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=L(n);if(o){if(u&&l){l.href=e.url,l.textContent=e.text,l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const r=document.createRange();r.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");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);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(a))}o.focus(),a=null,u=!1,l=null}},b=(e,t)=>{C();const n=document.createElement("div");n.className="link-dialog-overlay",t&&n.classList.add("rte-theme-dark"),n.style.cssText=`
64
+ `,document.head.appendChild(e)},A=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=w(n);if(o){if(u&&l){l.href=e.url,l.textContent=e.text,l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const r=document.createRange();r.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");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);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(a))}o.focus(),a=null,u=!1,l=null}},k=(e,t)=>{T();const n=document.createElement("div");n.className="link-dialog-overlay",t&&n.classList.add("rte-theme-dark"),n.style.cssText=`
65
65
  position: fixed;
66
66
  top: 0;
67
67
  left: 0;
@@ -92,7 +92,7 @@
92
92
  type="text"
93
93
  value="${e.text||""}"
94
94
  placeholder="Enter link text"
95
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
95
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
96
96
  />
97
97
  </div>
98
98
  <div class="form-group" style="margin-bottom: 16px;">
@@ -103,7 +103,7 @@
103
103
  value="${e.url||""}"
104
104
  placeholder="https://example.com"
105
105
  required
106
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
106
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
107
107
  />
108
108
  </div>
109
109
  <div class="form-group" style="margin-bottom: 16px;">
@@ -113,7 +113,7 @@
113
113
  type="text"
114
114
  value="${e.title||""}"
115
115
  placeholder="Link tooltip text"
116
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
116
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
117
117
  />
118
118
  </div>
119
119
  <div class="form-group" style="margin-bottom: 0;">
@@ -135,4 +135,4 @@
135
135
  </button>
136
136
  </div>
137
137
  </form>
138
- `,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),x=o.querySelector("#link-title"),y=o.querySelector("#link-target"),v=o.querySelector(".link-dialog-close"),E=o.querySelector(".btn-cancel"),s=()=>{document.body.removeChild(n)};v.addEventListener("click",s),E.addEventListener("click",s),n.addEventListener("click",p=>{p.target===n&&s()}),r.addEventListener("submit",p=>{p.preventDefault();const m=d.value.trim();m&&(T({text:i.value.trim()||m,url:m,target:y.checked?"_blank":"_self",title:x.value.trim()||void 0}),s())}),setTimeout(()=>i.focus(),100)},f=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const n=w(t),o=e.toString()||"",r=t.startContainer,d=(r.nodeType===Node.TEXT_NODE?r.parentElement:r)?.closest("a");return d?(u=!0,l=d,b({text:d.textContent||"",url:d.href,target:d.target||"_self",title:d.title||"",isEditing:!0},n)):(u=!1,l=null,b({text:o,url:"",target:"_self",isEditing:!1},n)),!0},h=()=>(document.execCommand("unlink",!1),!0),g=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},k=()=>{g("openLinkDialog",f),g("removeLink",h),g("createLink",e=>{e&&document.execCommand("createLink",!1,e)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",k):k());const A=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:f,removeLink:h},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=A;
138
+ `,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),y=o.querySelector("#link-title"),v=o.querySelector("#link-target"),E=o.querySelector(".link-dialog-close"),L=o.querySelector(".btn-cancel"),b=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),c())},c=()=>{document.removeEventListener("keydown",b,!0),n.remove()};E.addEventListener("click",c),L.addEventListener("click",c),n.addEventListener("click",s=>{s.target===n&&c()}),document.addEventListener("keydown",b,!0),r.addEventListener("submit",s=>{s.preventDefault();const g=d.value.trim();g&&(A({text:i.value.trim()||g,url:g,target:v.checked?"_blank":"_self",title:y.value.trim()||void 0}),c())}),setTimeout(()=>i.focus(),100)},x=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const n=C(t),o=e.toString()||"",r=t.startContainer,d=(r.nodeType===Node.TEXT_NODE?r.parentElement:r)?.closest("a");return d?(u=!0,l=d,k({text:d.textContent||"",url:d.href,target:d.target||"_self",title:d.title||"",isEditing:!0},n)):(u=!1,l=null,k({text:o,url:"",target:"_self",isEditing:!1},n)),!0},h=()=>(document.execCommand("unlink",!1),!0),m=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},f=()=>{m("openLinkDialog",x),m("removeLink",h),m("createLink",e=>{e&&document.execCommand("createLink",!1,e)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",f):f());const S=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:x,removeLink:h},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=S;
package/dist/link.esm.js CHANGED
@@ -1,5 +1,5 @@
1
- let a = null, p = !1, l = null;
2
- const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
1
+ let a = null, u = !1, l = null;
2
+ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
3
3
  if (!e) return null;
4
4
  let t = e;
5
5
  for (; t; ) {
@@ -8,13 +8,13 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
8
8
  t = t.parentElement;
9
9
  }
10
10
  return null;
11
- }, w = (e) => {
11
+ }, C = (e) => {
12
12
  if (e) {
13
13
  const n = e.startContainer;
14
- if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(c)) return !0;
14
+ if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(p)) return !0;
15
15
  }
16
- return document.activeElement?.closest(c) ? !0 : document.body.matches(c) || document.documentElement.matches(c);
17
- }, C = () => {
16
+ return document.activeElement?.closest(p) ? !0 : document.body.matches(p) || document.documentElement.matches(p);
17
+ }, T = () => {
18
18
  if (document.getElementById("rte-link-dialog-theme-styles")) return;
19
19
  const e = document.createElement("style");
20
20
  e.id = "rte-link-dialog-theme-styles", e.textContent = `
@@ -81,14 +81,14 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
81
81
  background: #2563eb !important;
82
82
  }
83
83
  `, document.head.appendChild(e);
84
- }, T = (e) => {
84
+ }, A = (e) => {
85
85
  if (!a) {
86
86
  console.warn("No selection range stored");
87
87
  return;
88
88
  }
89
- const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o = L(n);
89
+ const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o = w(n);
90
90
  if (o) {
91
- if (p && l) {
91
+ if (u && l) {
92
92
  l.href = e.url, l.textContent = e.text, l.target = e.target, e.target === "_blank" ? l.setAttribute("rel", "noopener noreferrer") : l.removeAttribute("rel"), e.title ? l.title = e.title : l.removeAttribute("title");
93
93
  const r = document.createRange();
94
94
  r.selectNodeContents(l);
@@ -100,10 +100,10 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
100
100
  const i = window.getSelection();
101
101
  i && (i.removeAllRanges(), i.addRange(a));
102
102
  }
103
- o.focus(), a = null, p = !1, l = null;
103
+ o.focus(), a = null, u = !1, l = null;
104
104
  }
105
- }, b = (e, t) => {
106
- C();
105
+ }, k = (e, t) => {
106
+ T();
107
107
  const n = document.createElement("div");
108
108
  n.className = "link-dialog-overlay", t && n.classList.add("rte-theme-dark"), n.style.cssText = `
109
109
  position: fixed;
@@ -138,7 +138,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
138
138
  type="text"
139
139
  value="${e.text || ""}"
140
140
  placeholder="Enter link text"
141
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
141
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
142
142
  />
143
143
  </div>
144
144
  <div class="form-group" style="margin-bottom: 16px;">
@@ -149,7 +149,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
149
149
  value="${e.url || ""}"
150
150
  placeholder="https://example.com"
151
151
  required
152
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
152
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
153
153
  />
154
154
  </div>
155
155
  <div class="form-group" style="margin-bottom: 16px;">
@@ -159,7 +159,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
159
159
  type="text"
160
160
  value="${e.title || ""}"
161
161
  placeholder="Link tooltip text"
162
- style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px;"
162
+ style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
163
163
  />
164
164
  </div>
165
165
  <div class="form-group" style="margin-bottom: 0;">
@@ -182,48 +182,50 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
182
182
  </div>
183
183
  </form>
184
184
  `, n.appendChild(o), document.body.appendChild(n);
185
- const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"), x = o.querySelector("#link-title"), y = o.querySelector("#link-target"), v = o.querySelector(".link-dialog-close"), E = o.querySelector(".btn-cancel"), s = () => {
186
- document.body.removeChild(n);
185
+ const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"), y = o.querySelector("#link-title"), v = o.querySelector("#link-target"), E = o.querySelector(".link-dialog-close"), L = o.querySelector(".btn-cancel"), b = (s) => {
186
+ s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), c());
187
+ }, c = () => {
188
+ document.removeEventListener("keydown", b, !0), n.remove();
187
189
  };
188
- v.addEventListener("click", s), E.addEventListener("click", s), n.addEventListener("click", (u) => {
189
- u.target === n && s();
190
- }), r.addEventListener("submit", (u) => {
191
- u.preventDefault();
192
- const m = d.value.trim();
193
- m && (T({
194
- text: i.value.trim() || m,
195
- url: m,
196
- target: y.checked ? "_blank" : "_self",
197
- title: x.value.trim() || void 0
198
- }), s());
190
+ E.addEventListener("click", c), L.addEventListener("click", c), n.addEventListener("click", (s) => {
191
+ s.target === n && c();
192
+ }), document.addEventListener("keydown", b, !0), r.addEventListener("submit", (s) => {
193
+ s.preventDefault();
194
+ const g = d.value.trim();
195
+ g && (A({
196
+ text: i.value.trim() || g,
197
+ url: g,
198
+ target: v.checked ? "_blank" : "_self",
199
+ title: y.value.trim() || void 0
200
+ }), c());
199
201
  }), setTimeout(() => i.focus(), 100);
200
- }, f = () => {
202
+ }, x = () => {
201
203
  const e = window.getSelection();
202
204
  if (!e || e.rangeCount === 0) return !1;
203
205
  const t = e.getRangeAt(0).cloneRange();
204
206
  a = t;
205
- const n = w(t), o = e.toString() || "", r = t.startContainer, d = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("a");
206
- return d ? (p = !0, l = d, b({
207
+ const n = C(t), o = e.toString() || "", r = t.startContainer, d = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("a");
208
+ return d ? (u = !0, l = d, k({
207
209
  text: d.textContent || "",
208
210
  url: d.href,
209
211
  target: d.target || "_self",
210
212
  title: d.title || "",
211
213
  isEditing: !0
212
- }, n)) : (p = !1, l = null, b({
214
+ }, n)) : (u = !1, l = null, k({
213
215
  text: o,
214
216
  url: "",
215
217
  target: "_self",
216
218
  isEditing: !1
217
219
  }, n)), !0;
218
- }, h = () => (document.execCommand("unlink", !1), !0), g = (e, t) => {
220
+ }, h = () => (document.execCommand("unlink", !1), !0), m = (e, t) => {
219
221
  typeof window < "u" && window.registerEditorCommand?.(e, t);
220
- }, k = () => {
221
- g("openLinkDialog", f), g("removeLink", h), g("createLink", (e) => {
222
+ }, f = () => {
223
+ m("openLinkDialog", x), m("removeLink", h), m("createLink", (e) => {
222
224
  e && document.execCommand("createLink", !1, e);
223
225
  });
224
226
  };
225
- typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", k) : k());
226
- const A = () => ({
227
+ typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f) : f());
228
+ const S = () => ({
227
229
  name: "link",
228
230
  marks: {
229
231
  link: {
@@ -264,7 +266,7 @@ const A = () => ({
264
266
  }
265
267
  ],
266
268
  commands: {
267
- openLinkDialog: f,
269
+ openLinkDialog: x,
268
270
  removeLink: h
269
271
  },
270
272
  keymap: {
@@ -272,5 +274,5 @@ const A = () => ({
272
274
  }
273
275
  });
274
276
  export {
275
- A as LinkPlugin
277
+ S as LinkPlugin
276
278
  };
package/dist/math.cjs.js CHANGED
@@ -1,45 +1,45 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let h=null,w=null,E=!1;const y='[data-theme="dark"], .dark, .editora-theme-dark',q=()=>new Promise((a,s)=>{if(window.katex){a(window.katex);return}if(E){const i=setInterval(()=>{window.katex&&(clearInterval(i),a(window.katex))},100);return}E=!0;const o=document.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(o);const e=document.createElement("script");e.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",e.onload=()=>a(window.katex),e.onerror=s,document.head.appendChild(e)}),H=()=>{const a=window.getSelection();if(a&&a.rangeCount>0){const o=a.getRangeAt(0).startContainer;if((o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest(y))return!0}return document.activeElement?.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)},T=async a=>{const s=window.getSelection();s&&s.rangeCount>0&&(h=s.getRangeAt(0).cloneRange()),await q();const o=H(),e=o?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},i=document.createElement("div");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;`;const l=document.createElement("div");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};`;let d=a?.format||"latex",u=a?.formula||"",M=a?.inline!==!1;l.innerHTML=`
2
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${e.border}; background: ${e.panelBg};">
3
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">${a?"Edit":"Insert"} Math Formula</h2>
4
- <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>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F={latex:[{name:"Fraction",formula:"\\frac{a}{b}",description:"Simple fraction"},{name:"Square Root",formula:"\\sqrt{x}",description:"Square root"},{name:"Power",formula:"x^{2}",description:"Exponent/power"},{name:"Subscript",formula:"x_{sub}",description:"Subscript"},{name:"Integral",formula:"\\int_{a}^{b} f(x) \\, dx",description:"Definite integral"},{name:"Summation",formula:"\\sum_{i=1}^{n} x_{i}",description:"Summation"},{name:"Limit",formula:"\\lim_{x \\to 0} f(x)",description:"Limit"},{name:"Derivative",formula:"\\frac{d}{dx} f(x)",description:"Derivative"},{name:"Matrix 2x2",formula:"\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}",description:"2x2 matrix"},{name:"System",formula:"\\begin{cases} x + y = 1 \\\\ 2x - y = 0 \\end{cases}",description:"System of equations"}],mathml:[{name:"Fraction",formula:"<mfrac><mi>a</mi><mi>b</mi></mfrac>",description:"Simple fraction"},{name:"Square Root",formula:"<msqrt><mi>x</mi></msqrt>",description:"Square root"},{name:"Power",formula:"<msup><mi>x</mi><mn>2</mn></msup>",description:"Exponent/power"},{name:"Subscript",formula:"<msub><mi>x</mi><mi>sub</mi></msub>",description:"Subscript"},{name:"Parentheses",formula:'<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>',description:"Grouped expression"}]};let $=null,B=null,A=!1,b=null;const w='[data-theme="dark"], .dark, .editora-theme-dark',N=()=>new Promise((a,l)=>{if(window.katex){a(window.katex);return}if(A){const i=setInterval(()=>{window.katex&&(clearInterval(i),a(window.katex))},100);return}A=!0;const o=document.createElement("link");o.rel="stylesheet",o.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(o);const d=document.createElement("script");d.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",d.onload=()=>a(window.katex),d.onerror=l,document.head.appendChild(d)}),H=()=>{const a=window.getSelection();if(!a||a.rangeCount===0)return null;const l=a.getRangeAt(0).startContainer;return(l.nodeType===Node.ELEMENT_NODE?l:l.parentElement)?.closest(".rte-content, .editora-content")||null},j=a=>{if((a||H())?.closest(w))return!0;const o=window.getSelection();if(o&&o.rangeCount>0){const i=o.getRangeAt(0).startContainer;if((i.nodeType===Node.ELEMENT_NODE?i:i.parentElement)?.closest(w))return!0}return document.activeElement?.closest(w)?!0:document.body.matches(w)||document.documentElement.matches(w)},q=async(a,l)=>{const o=l||B?.closest(".rte-content, .editora-content")||H()||b;b=o||null;const d=window.getSelection();if(d&&d.rangeCount>0){const e=d.getRangeAt(0);$=o&&o.contains(e.commonAncestorContainer)?e.cloneRange():null}await N();const i=j(o),t=i?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",border:"#3b4657",panelBg:"#222d3a",fieldBg:"#111827",fieldBorder:"#4b5563",text:"#e2e8f0",muted:"#94a3b8",templateBtnBg:"#273244",templateBtnHover:"#334155",templateBtnText:"#dbe7f7",templateSubText:"#9fb0c6",previewBg:"#111827",previewText:"#cbd5e1",cancelBg:"#334155",cancelText:"#e2e8f0",cancelBorder:"#4b5563",insertBg:"#3b82f6",insertHover:"#2563eb",invalid:"#f87171"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",border:"#e1e5e9",panelBg:"#f8f9fa",fieldBg:"#ffffff",fieldBorder:"#ced4da",text:"#1f2937",muted:"#6c757d",templateBtnBg:"#ffffff",templateBtnHover:"#f8f9fa",templateBtnText:"#1f2937",templateSubText:"#6c757d",previewBg:"#f8f9fa",previewText:"#6c757d",cancelBg:"#ffffff",cancelText:"#1f2937",cancelBorder:"#ced4da",insertBg:"#007bff",insertHover:"#0069d9",invalid:"#cc0000"},c=document.createElement("div");c.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${t.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const s=document.createElement("div");s.style.cssText=`background: ${t.dialogBg}; border: 1px solid ${t.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: ${t.text};`;let m=a?.format||"latex",T=a?.formula||"",P=a?.inline!==!1,g=null,M="";s.innerHTML=`
2
+ <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
3
+ <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a?"Edit":"Insert"} Math Formula</h2>
4
+ <button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${t.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
5
5
  </div>
6
6
 
7
7
  <div style="padding: 20px; overflow-y: auto; flex: 1;">
8
8
  <div style="margin-bottom: 20px;">
9
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
9
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
10
10
  <div style="display: flex; gap: 16px;">
11
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${d==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
12
- <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="mathml" ${d==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
11
+ <label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
12
+ <label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
13
13
  </div>
14
14
  </div>
15
15
 
16
16
  <div style="margin-bottom: 20px;">
17
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
17
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
18
18
  <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>
19
19
  </div>
20
20
 
21
21
  <div style="margin-bottom: 20px;">
22
- <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${M?"checked":""} style="margin-right: 8px;"> Inline math</label>
22
+ <label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${P?"checked":""} style="margin-right: 8px;"> Inline math</label>
23
23
  </div>
24
24
 
25
25
  <div style="margin-bottom: 20px;">
26
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Formula:</label>
27
- <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>
26
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
27
+ <textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${t.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${t.fieldBg}; color: ${t.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${T}</textarea>
28
28
  </div>
29
29
 
30
30
  <div style="margin-bottom: 20px;">
31
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Preview:</label>
32
- <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>
31
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
32
+ <div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.previewBg}; display: flex; align-items: center; justify-content: center; color: ${t.previewText};"></div>
33
33
  </div>
34
34
  </div>
35
35
 
36
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${e.border}; background: ${e.panelBg};">
37
- <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>
38
- <button id="insert-btn" style="padding: 10px 20px; background: ${e.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a?"Update":"Insert"}</button>
36
+ <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
37
+ <button class="cancel-btn" style="padding: 10px 20px; background: ${t.cancelBg}; color: ${t.cancelText}; border: 1px solid ${t.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
38
+ <button id="insert-btn" style="padding: 10px 20px; background: ${t.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${a?"Update":"Insert"}</button>
39
39
  </div>
40
- `,i.appendChild(l),document.body.appendChild(i);const c=l.querySelector("#formula-input"),f=l.querySelector("#preview-area"),k=l.querySelector("#templates-grid"),S=l.querySelectorAll('input[name="format"]'),L=l.querySelector("#inline-cb"),m=l.querySelector("#insert-btn"),p=l.querySelector(".close-btn"),x=l.querySelector(".cancel-btn"),$=()=>{const t=C[d];k.innerHTML=t.map(n=>`
41
- <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;">
42
- <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
43
- <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0,20)}...</div>
40
+ `,c.appendChild(s),document.body.appendChild(c);const u=s.querySelector("#formula-input"),h=s.querySelector("#preview-area"),k=s.querySelector("#templates-grid"),_=s.querySelectorAll('input[name="format"]'),z=s.querySelector("#inline-cb"),p=s.querySelector("#insert-btn"),f=s.querySelector(".close-btn"),v=s.querySelector(".cancel-btn"),I=e=>encodeURIComponent(e),D=e=>{try{return decodeURIComponent(e)}catch{return e}},L=()=>{const e=F[m];k.innerHTML=e.map(r=>`
41
+ <button type="button" data-formula="${I(r.formula)}" title="${r.description}" style="padding: 8px; border: 1px solid ${t.fieldBorder}; border-radius: 4px; background: ${t.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
42
+ <div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
43
+ <div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0,20)}...</div>
44
44
  </button>
45
- `).join(""),k.querySelectorAll("button").forEach(n=>{const r=n;r.onmouseover=()=>{r.style.background=e.templateBtnHover},r.onmouseout=()=>{r.style.background=e.templateBtnBg},n.addEventListener("click",()=>{c.value=n.getAttribute("data-formula")||"",u=c.value,b()})})},b=()=>{const t=c.value.trim();if(!t){f.innerHTML=`<span style="color: ${e.previewText};">Enter a formula to see preview</span>`,m.disabled=!0;return}m.disabled=!1;try{if(d==="latex"){const n=window.katex;f.innerHTML=n.renderToString(t,{displayMode:!1,throwOnError:!1})}else t.trim().startsWith("<math")?f.innerHTML=t:f.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`}catch{f.innerHTML=`<span style="color: ${e.invalid};">Invalid formula</span>`}},g=()=>document.body.removeChild(i);p.onmouseover=()=>{p.style.color="#f8fafc",p.style.background=o?"#334155":"#e5e7eb",p.style.borderRadius="4px"},p.onmouseout=()=>{p.style.color=e.muted,p.style.background="none"},x.onmouseover=()=>{x.style.background=o?"#475569":"#f3f4f6"},x.onmouseout=()=>{x.style.background=e.cancelBg},m.onmouseover=()=>{m.disabled||(m.style.background=e.insertHover)},m.onmouseout=()=>{m.style.background=e.insertBg};const B=()=>{const t=c.value.trim();if(!t)return;const n={formula:t,format:d,inline:L.checked},r=n.inline?document.createElement("span"):document.createElement("div");if(r.className=n.inline?"math-formula":"math-block",r.setAttribute("data-math-formula",t),r.setAttribute("data-math-format",d),r.contentEditable="false",r.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;",d==="latex"){const v=window.katex;try{r.innerHTML=v.renderToString(t,{displayMode:!n.inline,throwOnError:!1})}catch{r.textContent=n.inline?`$${t}$`:`$$${t}$$`}}else if(t.trim().startsWith("<math"))r.innerHTML=t;else{const v=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${n.inline?"inline":"block"}">${t}</math>`;r.innerHTML=v}w?w.replaceWith(r):h&&(h.deleteContents(),h.insertNode(r)),g()};p.addEventListener("click",g),x.addEventListener("click",g),m.addEventListener("click",B),i.addEventListener("click",t=>{t.target===i&&g()}),S.forEach(t=>{t.addEventListener("change",n=>{d=n.target.value,$(),b()})}),c.addEventListener("input",()=>{u=c.value,b()}),c.addEventListener("keydown",t=>{(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),B())}),$(),b(),c.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const a=o=>{const i=o.target.closest(".math-formula, .math-block");if(i){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),w=i;const l=i.getAttribute("data-math-formula")||"",d=i.getAttribute("data-math-format")||"latex",u=i.classList.contains("math-formula");T({formula:l,format:d,inline:u})}},s=()=>{document.addEventListener("dblclick",a,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s):setTimeout(s,100)}const _=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",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>'}],commands:{insertMath:()=>(T(),!0)},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=_;
45
+ `).join("")},R=()=>{const e=u.value.trim(),r=`${m}:${e}`;if(r!==M){if(M=r,!e){h.innerHTML=`<span style="color: ${t.previewText};">Enter a formula to see preview</span>`,p.disabled=!0;return}p.disabled=!1;try{if(m==="latex"){const n=window.katex;h.innerHTML=n.renderToString(e,{displayMode:!1,throwOnError:!1})}else e.trim().startsWith("<math")?h.innerHTML=e:h.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`}catch{h.innerHTML=`<span style="color: ${t.invalid};">Invalid formula</span>`}}},E=()=>{g!==null&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{g=null,R()})},S=e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),y())},y=()=>{document.removeEventListener("keydown",S,!0),g!==null&&(cancelAnimationFrame(g),g=null),c.parentNode&&c.parentNode.removeChild(c)};f.onmouseover=()=>{f.style.color="#f8fafc",f.style.background=i?"#334155":"#e5e7eb",f.style.borderRadius="4px"},f.onmouseout=()=>{f.style.color=t.muted,f.style.background="none"},v.onmouseover=()=>{v.style.background=i?"#475569":"#f3f4f6"},v.onmouseout=()=>{v.style.background=t.cancelBg},p.onmouseover=()=>{p.disabled||(p.style.background=t.insertHover)},p.onmouseout=()=>{p.style.background=t.insertBg},k.addEventListener("mouseover",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnHover)}),k.addEventListener("mouseout",e=>{const n=e.target.closest("button[data-formula]");n&&(n.style.background=t.templateBtnBg)}),k.addEventListener("click",e=>{const n=e.target.closest("button[data-formula]");n&&(u.value=D(n.getAttribute("data-formula")||""),T=u.value,E())});const C=()=>{const e=u.value.trim();if(!e)return;const r={formula:e,format:m,inline:z.checked},n=r.inline?document.createElement("span"):document.createElement("div");if(n.className=r.inline?"math-formula":"math-block",n.setAttribute("data-math-formula",e),n.setAttribute("data-math-format",m),n.contentEditable="false",n.style.cssText=r.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"){const x=window.katex;try{n.innerHTML=x.renderToString(e,{displayMode:!r.inline,throwOnError:!1})}catch{n.textContent=r.inline?`$${e}$`:`$$${e}$$`}}else if(e.trim().startsWith("<math"))n.innerHTML=e;else{const x=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline?"inline":"block"}">${e}</math>`;n.innerHTML=x}if(B)B.replaceWith(n);else if($)$.deleteContents(),$.insertNode(n);else if(b&&b.isConnected){const x=document.createRange();x.selectNodeContents(b),x.collapse(!1),x.insertNode(n)}(n.closest(".rte-content, .editora-content")||b)?.dispatchEvent(new Event("input",{bubbles:!0})),y()};f.addEventListener("click",y),v.addEventListener("click",y),p.addEventListener("click",C),c.addEventListener("click",e=>{e.target===c&&y()}),document.addEventListener("keydown",S,!0),_.forEach(e=>{e.addEventListener("change",r=>{m=r.target.value,M="",L(),E()})}),u.addEventListener("input",()=>{T=u.value,E()}),u.addEventListener("keydown",e=>{(e.ctrlKey||e.metaKey)&&e.key==="Enter"&&(e.preventDefault(),C())}),L(),E(),u.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const a=o=>{const i=o.target.closest(".math-formula, .math-block");if(i){o.preventDefault(),o.stopPropagation(),o.stopImmediatePropagation(),B=i;const t=i.getAttribute("data-math-formula")||"",c=i.getAttribute("data-math-format")||"latex",s=i.classList.contains("math-formula");q({formula:t,format:c,inline:s})}},l=()=>{document.addEventListener("dblclick",a,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):setTimeout(l,100)}const O=()=>({name:"math",toolbar:[{label:"Insert Math",command:"insertMath",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>'}],commands:{insertMath:(a,l)=>{const o=l?.contentElement instanceof HTMLElement?l.contentElement:null;return q(void 0,o),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=O;