@editora/plugins 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 (140) hide show
  1. package/README.md +5 -0
  2. package/dist/_commonjsHelpers-6763f629.js +1 -0
  3. package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
  4. package/dist/a11y-checker.cjs.js +12 -12
  5. package/dist/a11y-checker.esm.js +98 -80
  6. package/dist/anchor.cjs.js +12 -12
  7. package/dist/anchor.esm.js +128 -115
  8. package/dist/anchoredPopover-33f1358d.mjs +109 -0
  9. package/dist/anchoredPopover-8151d535.js +1 -0
  10. package/dist/approval-workflow.cjs.js +40 -40
  11. package/dist/approval-workflow.esm.js +249 -208
  12. package/dist/background-color.cjs.js +2 -2
  13. package/dist/background-color.esm.js +68 -55
  14. package/dist/blockquote.esm.js +2 -1
  15. package/dist/blocks-library.cjs.js +45 -45
  16. package/dist/blocks-library.esm.js +245 -178
  17. package/dist/capitalization.esm.js +2 -1
  18. package/dist/checklist.cjs.js +1 -1
  19. package/dist/checklist.esm.js +82 -58
  20. package/dist/citations.cjs.js +37 -37
  21. package/dist/citations.esm.js +512 -439
  22. package/dist/clear-formatting.cjs.js +1 -1
  23. package/dist/clear-formatting.esm.js +33 -27
  24. package/dist/code-sample.cjs.js +14 -14
  25. package/dist/code-sample.esm.js +93 -82
  26. package/dist/code.cjs.js +32 -32
  27. package/dist/code.esm.js +653 -594
  28. package/dist/comments.cjs.js +6 -6
  29. package/dist/comments.esm.js +158 -116
  30. package/dist/conditional-content.cjs.js +90 -90
  31. package/dist/conditional-content.esm.js +432 -371
  32. package/dist/content-rules.cjs.js +7 -7
  33. package/dist/content-rules.esm.js +159 -105
  34. package/dist/data-binding.cjs.js +46 -46
  35. package/dist/data-binding.esm.js +368 -328
  36. package/dist/direction.esm.js +18 -9
  37. package/dist/doc-schema.cjs.js +29 -29
  38. package/dist/doc-schema.esm.js +308 -240
  39. package/dist/document-manager.cjs.js +1 -1
  40. package/dist/document-manager.esm.js +5 -4
  41. package/dist/documentManager-25b6203c.mjs +9122 -0
  42. package/dist/documentManager-b69e7054.js +17 -0
  43. package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
  44. package/dist/embed-iframe.cjs.js +4 -4
  45. package/dist/embed-iframe.esm.js +81 -73
  46. package/dist/emojis.cjs.js +8 -8
  47. package/dist/emojis.esm.js +77 -65
  48. package/dist/enterprise.cjs.js +1 -1
  49. package/dist/enterprise.esm.js +56 -54
  50. package/dist/font-family.cjs.js +1 -1
  51. package/dist/font-family.esm.js +47 -39
  52. package/dist/font-size.cjs.js +1 -1
  53. package/dist/font-size.esm.js +53 -37
  54. package/dist/footnote.cjs.js +2 -2
  55. package/dist/footnote.esm.js +117 -76
  56. package/dist/history.cjs.js +1 -1
  57. package/dist/history.esm.js +92 -70
  58. package/dist/html2canvas.esm-09133e29.js +22 -0
  59. package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
  60. package/dist/indent.cjs.js +1 -1
  61. package/dist/indent.esm.js +24 -12
  62. package/dist/index-656d224b.js +231 -0
  63. package/dist/index-6a8c48bb.js +1 -0
  64. package/dist/index-d027b7e2.mjs +16859 -0
  65. package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
  66. package/dist/index.cjs.js +1 -1
  67. package/dist/index.es-730f2d98.mjs +5775 -0
  68. package/dist/index.es-dd40173b.js +18 -0
  69. package/dist/index.esm.js +128 -125
  70. package/dist/italic.cjs.js +1 -1
  71. package/dist/italic.esm.js +9 -8
  72. package/dist/jspdf.es.min-90db2c97.js +243 -0
  73. package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
  74. package/dist/line-height.cjs.js +1 -1
  75. package/dist/line-height.esm.js +24 -11
  76. package/dist/link.cjs.js +5 -5
  77. package/dist/link.esm.js +30 -24
  78. package/dist/list.cjs.js +1 -1
  79. package/dist/list.esm.js +25 -20
  80. package/dist/lite.cjs.js +1 -1
  81. package/dist/lite.esm.js +61 -59
  82. package/dist/math.cjs.js +21 -21
  83. package/dist/math.esm.js +146 -139
  84. package/dist/media-manager.cjs.js +38 -38
  85. package/dist/media-manager.esm.js +325 -308
  86. package/dist/mentions.cjs.js +9 -9
  87. package/dist/mentions.esm.js +286 -238
  88. package/dist/merge-tag.cjs.js +2 -2
  89. package/dist/merge-tag.esm.js +216 -177
  90. package/dist/page-break.cjs.js +2 -2
  91. package/dist/page-break.esm.js +49 -33
  92. package/dist/pii-redaction.cjs.js +19 -19
  93. package/dist/pii-redaction.esm.js +463 -393
  94. package/dist/preview.esm.js +10 -5
  95. package/dist/print.cjs.js +4 -4
  96. package/dist/print.esm.js +20 -17
  97. package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
  98. package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
  99. package/dist/slash-commands.cjs.js +3 -3
  100. package/dist/slash-commands.esm.js +212 -176
  101. package/dist/smart-paste.cjs.js +27 -27
  102. package/dist/smart-paste.esm.js +336 -280
  103. package/dist/special-characters.cjs.js +7 -7
  104. package/dist/special-characters.esm.js +69 -61
  105. package/dist/spell-check.cjs.js +5 -5
  106. package/dist/spell-check.esm.js +123 -97
  107. package/dist/strikethrough.cjs.js +1 -1
  108. package/dist/strikethrough.esm.js +19 -14
  109. package/dist/style.css +1 -0
  110. package/dist/table.cjs.js +4 -4
  111. package/dist/table.esm.js +225 -191
  112. package/dist/template.cjs.js +11 -11
  113. package/dist/template.esm.js +153 -124
  114. package/dist/text-alignment.cjs.js +1 -1
  115. package/dist/text-alignment.esm.js +27 -21
  116. package/dist/text-color.cjs.js +3 -3
  117. package/dist/text-color.esm.js +87 -70
  118. package/dist/track-changes.cjs.js +2 -2
  119. package/dist/track-changes.esm.js +162 -100
  120. package/dist/translation-workflow.cjs.js +74 -74
  121. package/dist/translation-workflow.esm.js +678 -602
  122. package/dist/version-diff.cjs.js +14 -14
  123. package/dist/version-diff.esm.js +157 -128
  124. package/package.json +13 -7
  125. package/LICENSE +0 -21
  126. package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
  127. package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
  128. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  129. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  130. package/dist/documentManager-CTqRftU8.mjs +0 -8369
  131. package/dist/documentManager-Jf0RbSks.js +0 -17
  132. package/dist/html2canvas.esm-B5qzocYs.js +0 -5
  133. package/dist/index-CvJk4DKa.js +0 -221
  134. package/dist/index-D3CycEFU.mjs +0 -16543
  135. package/dist/index-tqLTHcO6.js +0 -1
  136. package/dist/index.es-CE_A4QSm.js +0 -5
  137. package/dist/index.es-DQ78mYYo.mjs +0 -6665
  138. package/dist/jspdf.es.min-BoS80556.js +0 -77
  139. package/dist/plugins.css +0 -1
  140. /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
package/dist/math.cjs.js CHANGED
@@ -1,45 +1,45 @@
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>
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j={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 B=null,h=null,H=!1,x=null;const k='[data-theme="dark"], .dark, .editora-theme-dark',O=()=>new Promise((n,a)=>{if(window.katex){n(window.katex);return}if(H){const l=setInterval(()=>{window.katex&&(clearInterval(l),n(window.katex))},100);return}H=!0;const r=document.createElement("link");r.rel="stylesheet",r.href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css",document.head.appendChild(r);const s=document.createElement("script");s.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",s.onload=()=>n(window.katex),s.onerror=a,document.head.appendChild(s)}),q=()=>{const n=window.getSelection();if(!n||n.rangeCount===0)return null;const a=n.getRangeAt(0).startContainer,r=a.nodeType===Node.ELEMENT_NODE?a:a.parentElement;return(r==null?void 0:r.closest(".rte-content, .editora-content"))||null},K=n=>{const a=n||q();if(a!=null&&a.closest(k))return!0;const r=window.getSelection();if(r&&r.rangeCount>0){const l=r.getRangeAt(0).startContainer,e=l.nodeType===Node.ELEMENT_NODE?l:l.parentElement;if(e!=null&&e.closest(k))return!0}const s=document.activeElement;return s!=null&&s.closest(k)?!0:document.body.matches(k)||document.documentElement.matches(k)},P=async(n,a)=>{const r=a||(h==null?void 0:h.closest(".rte-content, .editora-content"))||q()||x;x=r||null;const s=window.getSelection();if(s&&s.rangeCount>0){const t=s.getRangeAt(0);B=r&&r.contains(t.commonAncestorContainer)?t.cloneRange():null}await O();const l=K(r),e=l?{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: ${e.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const d=document.createElement("div");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};`;let m=(n==null?void 0:n.format)||"latex",T=(n==null?void 0:n.formula)||"",_=(n==null?void 0:n.inline)!==!1,b=null,L="";d.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};">${n?"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>
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: ${t.text};">Format:</label>
9
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
10
10
  <div style="display: flex; gap: 16px;">
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>
11
+ <label style="cursor: pointer; color: ${e.text};"><input type="radio" name="format" value="latex" ${m==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
12
+ <label style="cursor: pointer; color: ${e.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: ${t.text};">Quick Templates:</label>
17
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.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: ${t.text};"><input type="checkbox" id="inline-cb" ${P?"checked":""} style="margin-right: 8px;"> Inline math</label>
22
+ <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${_?"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: ${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>
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%; 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>
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: ${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>
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>
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 ${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>
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>${n?"Update":"Insert"}</button>
39
39
  </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>
40
+ `,c.appendChild(d),document.body.appendChild(c);const u=d.querySelector("#formula-input"),v=d.querySelector("#preview-area"),E=d.querySelector("#templates-grid"),z=d.querySelectorAll('input[name="format"]'),I=d.querySelector("#inline-cb"),p=d.querySelector("#insert-btn"),f=d.querySelector(".close-btn"),y=d.querySelector(".cancel-btn"),R=t=>encodeURIComponent(t),F=t=>{try{return decodeURIComponent(t)}catch{return t}},S=()=>{const t=j[m];E.innerHTML=t.map(i=>`
41
+ <button type="button" data-formula="${R(i.formula)}" title="${i.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;">
42
+ <div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${i.name}</div>
43
+ <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${i.formula.substring(0,20)}...</div>
44
44
  </button>
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;
45
+ `).join("")},N=()=>{const t=u.value.trim(),i=`${m}:${t}`;if(i!==L){if(L=i,!t){v.innerHTML=`<span style="color: ${e.previewText};">Enter a formula to see preview</span>`,p.disabled=!0;return}p.disabled=!1;try{if(m==="latex"){const o=window.katex;v.innerHTML=o.renderToString(t,{displayMode:!1,throwOnError:!1})}else t.trim().startsWith("<math")?v.innerHTML=t:v.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`}catch{v.innerHTML=`<span style="color: ${e.invalid};">Invalid formula</span>`}}},$=()=>{b!==null&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{b=null,N()})},C=t=>{t.key==="Escape"&&(t.preventDefault(),t.stopPropagation(),w())},w=()=>{document.removeEventListener("keydown",C,!0),b!==null&&(cancelAnimationFrame(b),b=null),c.parentNode&&c.parentNode.removeChild(c)};f.onmouseover=()=>{f.style.color="#f8fafc",f.style.background=l?"#334155":"#e5e7eb",f.style.borderRadius="4px"},f.onmouseout=()=>{f.style.color=e.muted,f.style.background="none"},y.onmouseover=()=>{y.style.background=l?"#475569":"#f3f4f6"},y.onmouseout=()=>{y.style.background=e.cancelBg},p.onmouseover=()=>{p.disabled||(p.style.background=e.insertHover)},p.onmouseout=()=>{p.style.background=e.insertBg},E.addEventListener("mouseover",t=>{const o=t.target.closest("button[data-formula]");o&&(o.style.background=e.templateBtnHover)}),E.addEventListener("mouseout",t=>{const o=t.target.closest("button[data-formula]");o&&(o.style.background=e.templateBtnBg)}),E.addEventListener("click",t=>{const o=t.target.closest("button[data-formula]");o&&(u.value=F(o.getAttribute("data-formula")||""),T=u.value,$())});const A=()=>{const t=u.value.trim();if(!t)return;const i={formula:t,format:m,inline:I.checked},o=i.inline?document.createElement("span"):document.createElement("div");if(o.className=i.inline?"math-formula":"math-block",o.setAttribute("data-math-formula",t),o.setAttribute("data-math-format",m),o.contentEditable="false",o.style.cssText=i.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 g=window.katex;try{o.innerHTML=g.renderToString(t,{displayMode:!i.inline,throwOnError:!1})}catch{o.textContent=i.inline?`$${t}$`:`$$${t}$$`}}else if(t.trim().startsWith("<math"))o.innerHTML=t;else{const g=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${i.inline?"inline":"block"}">${t}</math>`;o.innerHTML=g}if(h)h.replaceWith(o);else if(B)B.deleteContents(),B.insertNode(o);else if(x&&x.isConnected){const g=document.createRange();g.selectNodeContents(x),g.collapse(!1),g.insertNode(o)}const M=o.closest(".rte-content, .editora-content")||x;M==null||M.dispatchEvent(new Event("input",{bubbles:!0})),w()};f.addEventListener("click",w),y.addEventListener("click",w),p.addEventListener("click",A),c.addEventListener("click",t=>{t.target===c&&w()}),document.addEventListener("keydown",C,!0),z.forEach(t=>{t.addEventListener("change",i=>{m=i.target.value,L="",S(),$()})}),u.addEventListener("input",()=>{T=u.value,$()}),u.addEventListener("keydown",t=>{(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),A())}),S(),$(),u.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const n=r=>{const l=r.target.closest(".math-formula, .math-block");if(l){r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),h=l;const e=l.getAttribute("data-math-formula")||"",c=l.getAttribute("data-math-format")||"latex",d=l.classList.contains("math-formula");P({formula:e,format:c,inline:d})}},a=()=>{document.addEventListener("dblclick",n,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",a):setTimeout(a,100)}const D=()=>({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:(n,a)=>{const r=(a==null?void 0:a.contentElement)instanceof HTMLElement?a.contentElement:null;return P(void 0,r),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=D;
package/dist/math.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- const F = {
1
+ const j = {
2
2
  latex: [
3
3
  { name: "Fraction", formula: "\\frac{a}{b}", description: "Simple fraction" },
4
4
  { name: "Square Root", formula: "\\sqrt{x}", description: "Square root" },
@@ -19,46 +19,51 @@ const F = {
19
19
  { name: "Parentheses", formula: '<mfenced open="(" close=")"><mi>a</mi><mo>+</mo><mi>b</mi></mfenced>', description: "Grouped expression" }
20
20
  ]
21
21
  };
22
- let $ = null, B = null, A = !1, b = null;
23
- const w = '[data-theme="dark"], .dark, .editora-theme-dark', N = () => new Promise((a, l) => {
22
+ let B = null, h = null, H = !1, g = null;
23
+ const k = '[data-theme="dark"], .dark, .editora-theme-dark', O = () => new Promise((n, a) => {
24
24
  if (window.katex) {
25
- a(window.katex);
25
+ n(window.katex);
26
26
  return;
27
27
  }
28
- if (A) {
29
- const i = setInterval(() => {
30
- window.katex && (clearInterval(i), a(window.katex));
28
+ if (H) {
29
+ const l = setInterval(() => {
30
+ window.katex && (clearInterval(l), n(window.katex));
31
31
  }, 100);
32
32
  return;
33
33
  }
34
- A = !0;
35
- const o = document.createElement("link");
36
- o.rel = "stylesheet", o.href = "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", document.head.appendChild(o);
37
- const d = document.createElement("script");
38
- 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);
39
- }), H = () => {
40
- const a = window.getSelection();
41
- if (!a || a.rangeCount === 0) return null;
42
- const l = a.getRangeAt(0).startContainer;
43
- return (l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement)?.closest(".rte-content, .editora-content") || null;
44
- }, j = (a) => {
45
- if ((a || H())?.closest(w)) return !0;
46
- const o = window.getSelection();
47
- if (o && o.rangeCount > 0) {
48
- const i = o.getRangeAt(0).startContainer;
49
- if ((i.nodeType === Node.ELEMENT_NODE ? i : i.parentElement)?.closest(w)) return !0;
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 = () => n(window.katex), s.onerror = a, document.head.appendChild(s);
39
+ }), q = () => {
40
+ const n = window.getSelection();
41
+ if (!n || n.rangeCount === 0)
42
+ return null;
43
+ const a = n.getRangeAt(0).startContainer, r = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
44
+ return (r == null ? void 0 : r.closest(".rte-content, .editora-content")) || null;
45
+ }, K = (n) => {
46
+ const a = n || q();
47
+ if (a != null && a.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;
50
54
  }
51
- return document.activeElement?.closest(w) ? !0 : document.body.matches(w) || document.documentElement.matches(w);
52
- }, q = async (a, l) => {
53
- const o = l || B?.closest(".rte-content, .editora-content") || H() || b;
54
- b = o || null;
55
- const d = window.getSelection();
56
- if (d && d.rangeCount > 0) {
57
- const e = d.getRangeAt(0);
58
- $ = o && o.contains(e.commonAncestorContainer) ? e.cloneRange() : null;
55
+ const s = document.activeElement;
56
+ return s != null && s.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
57
+ }, z = async (n, a) => {
58
+ const r = a || (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;
59
64
  }
60
- await N();
61
- const i = j(o), t = i ? {
65
+ await O();
66
+ const l = K(r), e = l ? {
62
67
  overlay: "rgba(0, 0, 0, 0.62)",
63
68
  dialogBg: "#1f2937",
64
69
  border: "#3b4657",
@@ -101,170 +106,172 @@ const w = '[data-theme="dark"], .dark, .editora-theme-dark', N = () => new Promi
101
106
  insertHover: "#0069d9",
102
107
  invalid: "#cc0000"
103
108
  }, c = document.createElement("div");
104
- 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;`;
105
- const s = document.createElement("div");
106
- 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};`;
107
- let m = a?.format || "latex", T = a?.formula || "", z = a?.inline !== !1, x = null, L = "";
108
- s.innerHTML = `
109
- <div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${t.border}; background: ${t.panelBg};">
110
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${t.text};">${a ? "Edit" : "Insert"} Math Formula</h2>
111
- <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>
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 = (n == null ? void 0 : n.format) || "latex", T = (n == null ? void 0 : n.formula) || "", I = (n == null ? void 0 : n.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};">${n ? "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>
112
117
  </div>
113
118
 
114
119
  <div style="padding: 20px; overflow-y: auto; flex: 1;">
115
120
  <div style="margin-bottom: 20px;">
116
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Format:</label>
121
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Format:</label>
117
122
  <div style="display: flex; gap: 16px;">
118
- <label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="latex" ${m === "latex" ? "checked" : ""} style="margin-right: 6px;"> LaTeX</label>
119
- <label style="cursor: pointer; color: ${t.text};"><input type="radio" name="format" value="mathml" ${m === "mathml" ? "checked" : ""} style="margin-right: 6px;"> MathML</label>
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>
120
125
  </div>
121
126
  </div>
122
127
 
123
128
  <div style="margin-bottom: 20px;">
124
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Quick Templates:</label>
129
+ <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${e.text};">Quick Templates:</label>
125
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>
126
131
  </div>
127
132
 
128
133
  <div style="margin-bottom: 20px;">
129
- <label style="cursor: pointer; color: ${t.text};"><input type="checkbox" id="inline-cb" ${z ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
134
+ <label style="cursor: pointer; color: ${e.text};"><input type="checkbox" id="inline-cb" ${I ? "checked" : ""} style="margin-right: 8px;"> Inline math</label>
130
135
  </div>
131
136
 
132
137
  <div style="margin-bottom: 20px;">
133
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Formula:</label>
134
- <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>
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>
135
140
  </div>
136
141
 
137
142
  <div style="margin-bottom: 20px;">
138
- <label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${t.text};">Preview:</label>
139
- <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>
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>
140
145
  </div>
141
146
  </div>
142
147
 
143
- <div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${t.border}; background: ${t.panelBg};">
144
- <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>
145
- <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>
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>${n ? "Update" : "Insert"}</button>
146
151
  </div>
147
- `, c.appendChild(s), document.body.appendChild(c);
148
- const u = s.querySelector("#formula-input"), h = s.querySelector("#preview-area"), k = s.querySelector("#templates-grid"), I = s.querySelectorAll('input[name="format"]'), D = s.querySelector("#inline-cb"), p = s.querySelector("#insert-btn"), f = s.querySelector(".close-btn"), v = s.querySelector(".cancel-btn"), P = (e) => encodeURIComponent(e), R = (e) => {
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) => {
149
154
  try {
150
- return decodeURIComponent(e);
155
+ return decodeURIComponent(t);
151
156
  } catch {
152
- return e;
157
+ return t;
153
158
  }
154
- }, M = () => {
155
- const e = F[m];
156
- k.innerHTML = e.map((r) => `
157
- <button type="button" data-formula="${P(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;">
158
- <div style="font-weight: 600; font-size: 12px; color: ${t.templateBtnText};">${r.name}</div>
159
- <div style="font-size: 10px; color: ${t.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${r.formula.substring(0, 20)}...</div>
159
+ }, S = () => {
160
+ const t = j[m];
161
+ E.innerHTML = t.map((i) => `
162
+ <button type="button" data-formula="${_(i.formula)}" title="${i.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};">${i.name}</div>
164
+ <div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${i.formula.substring(0, 20)}...</div>
160
165
  </button>
161
166
  `).join("");
162
- }, _ = () => {
163
- const e = u.value.trim(), r = `${m}:${e}`;
164
- if (r !== L) {
165
- if (L = r, !e) {
166
- h.innerHTML = `<span style="color: ${t.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
167
+ }, N = () => {
168
+ const t = u.value.trim(), i = `${m}:${t}`;
169
+ if (i !== L) {
170
+ if (L = i, !t) {
171
+ v.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, p.disabled = !0;
167
172
  return;
168
173
  }
169
174
  p.disabled = !1;
170
175
  try {
171
176
  if (m === "latex") {
172
- const n = window.katex;
173
- h.innerHTML = n.renderToString(e, { displayMode: !1, throwOnError: !1 });
177
+ const o = window.katex;
178
+ v.innerHTML = o.renderToString(t, { displayMode: !1, throwOnError: !1 });
174
179
  } else
175
- e.trim().startsWith("<math") ? h.innerHTML = e : h.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`;
180
+ t.trim().startsWith("<math") ? v.innerHTML = t : v.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
176
181
  } catch {
177
- h.innerHTML = `<span style="color: ${t.invalid};">Invalid formula</span>`;
182
+ v.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
178
183
  }
179
184
  }
180
- }, E = () => {
185
+ }, $ = () => {
181
186
  x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
182
- x = null, _();
187
+ x = null, N();
183
188
  });
184
- }, S = (e) => {
185
- e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), y());
186
- }, y = () => {
187
- document.removeEventListener("keydown", S, !0), x !== null && (cancelAnimationFrame(x), x = null), c.parentNode && c.parentNode.removeChild(c);
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);
188
193
  };
189
194
  f.onmouseover = () => {
190
- f.style.color = "#f8fafc", f.style.background = i ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
195
+ f.style.color = "#f8fafc", f.style.background = l ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
191
196
  }, f.onmouseout = () => {
192
- f.style.color = t.muted, f.style.background = "none";
193
- }, v.onmouseover = () => {
194
- v.style.background = i ? "#475569" : "#f3f4f6";
195
- }, v.onmouseout = () => {
196
- v.style.background = t.cancelBg;
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;
197
202
  }, p.onmouseover = () => {
198
- p.disabled || (p.style.background = t.insertHover);
203
+ p.disabled || (p.style.background = e.insertHover);
199
204
  }, p.onmouseout = () => {
200
- p.style.background = t.insertBg;
201
- }, k.addEventListener("mouseover", (e) => {
202
- const n = e.target.closest("button[data-formula]");
203
- n && (n.style.background = t.templateBtnHover);
204
- }), k.addEventListener("mouseout", (e) => {
205
- const n = e.target.closest("button[data-formula]");
206
- n && (n.style.background = t.templateBtnBg);
207
- }), k.addEventListener("click", (e) => {
208
- const n = e.target.closest("button[data-formula]");
209
- n && (u.value = R(n.getAttribute("data-formula") || ""), T = u.value, E());
205
+ p.style.background = e.insertBg;
206
+ }, E.addEventListener("mouseover", (t) => {
207
+ const o = t.target.closest("button[data-formula]");
208
+ o && (o.style.background = e.templateBtnHover);
209
+ }), E.addEventListener("mouseout", (t) => {
210
+ const o = t.target.closest("button[data-formula]");
211
+ o && (o.style.background = e.templateBtnBg);
212
+ }), E.addEventListener("click", (t) => {
213
+ const o = t.target.closest("button[data-formula]");
214
+ o && (u.value = F(o.getAttribute("data-formula") || ""), T = u.value, $());
210
215
  });
211
- const C = () => {
212
- const e = u.value.trim();
213
- if (!e) return;
214
- const r = { formula: e, format: m, inline: D.checked }, n = r.inline ? document.createElement("span") : document.createElement("div");
215
- 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") {
216
- const g = window.katex;
216
+ const A = () => {
217
+ const t = u.value.trim();
218
+ if (!t)
219
+ return;
220
+ const i = { formula: t, format: m, inline: R.checked }, o = i.inline ? document.createElement("span") : document.createElement("div");
221
+ if (o.className = i.inline ? "math-formula" : "math-block", o.setAttribute("data-math-formula", t), o.setAttribute("data-math-format", m), o.contentEditable = "false", o.style.cssText = i.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;
217
223
  try {
218
- n.innerHTML = g.renderToString(e, {
219
- displayMode: !r.inline,
224
+ o.innerHTML = b.renderToString(t, {
225
+ displayMode: !i.inline,
220
226
  throwOnError: !1
221
227
  });
222
228
  } catch {
223
- n.textContent = r.inline ? `$${e}$` : `$$${e}$$`;
229
+ o.textContent = i.inline ? `$${t}$` : `$$${t}$$`;
224
230
  }
225
- } else if (e.trim().startsWith("<math"))
226
- n.innerHTML = e;
231
+ } else if (t.trim().startsWith("<math"))
232
+ o.innerHTML = t;
227
233
  else {
228
- const g = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline ? "inline" : "block"}">${e}</math>`;
229
- n.innerHTML = g;
234
+ const b = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${i.inline ? "inline" : "block"}">${t}</math>`;
235
+ o.innerHTML = b;
230
236
  }
231
- if (B)
232
- B.replaceWith(n);
233
- else if ($)
234
- $.deleteContents(), $.insertNode(n);
235
- else if (b && b.isConnected) {
236
- const g = document.createRange();
237
- g.selectNodeContents(b), g.collapse(!1), g.insertNode(n);
237
+ if (h)
238
+ h.replaceWith(o);
239
+ else if (B)
240
+ B.deleteContents(), B.insertNode(o);
241
+ else if (g && g.isConnected) {
242
+ const b = document.createRange();
243
+ b.selectNodeContents(g), b.collapse(!1), b.insertNode(o);
238
244
  }
239
- (n.closest(".rte-content, .editora-content") || b)?.dispatchEvent(new Event("input", { bubbles: !0 })), y();
245
+ const M = o.closest(".rte-content, .editora-content") || g;
246
+ M == null || M.dispatchEvent(new Event("input", { bubbles: !0 })), w();
240
247
  };
241
- f.addEventListener("click", y), v.addEventListener("click", y), p.addEventListener("click", C), c.addEventListener("click", (e) => {
242
- e.target === c && y();
243
- }), document.addEventListener("keydown", S, !0), I.forEach((e) => {
244
- e.addEventListener("change", (r) => {
245
- m = r.target.value, L = "", M(), E();
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", (i) => {
252
+ m = i.target.value, L = "", S(), $();
246
253
  });
247
254
  }), u.addEventListener("input", () => {
248
- T = u.value, E();
249
- }), u.addEventListener("keydown", (e) => {
250
- (e.ctrlKey || e.metaKey) && e.key === "Enter" && (e.preventDefault(), C());
251
- }), M(), E(), u.focus();
255
+ T = u.value, $();
256
+ }), u.addEventListener("keydown", (t) => {
257
+ (t.ctrlKey || t.metaKey) && t.key === "Enter" && (t.preventDefault(), A());
258
+ }), S(), $(), u.focus();
252
259
  };
253
260
  if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {
254
261
  window.__mathPluginDoubleClickInitialized = !0;
255
- const a = (o) => {
256
- const i = o.target.closest(".math-formula, .math-block");
257
- if (i) {
258
- o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(), B = i;
259
- const t = i.getAttribute("data-math-formula") || "", c = i.getAttribute("data-math-format") || "latex", s = i.classList.contains("math-formula");
260
- q({ formula: t, format: c, inline: s });
262
+ const n = (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 });
261
268
  }
262
- }, l = () => {
263
- document.addEventListener("dblclick", a, { capture: !0 });
269
+ }, a = () => {
270
+ document.addEventListener("dblclick", n, { capture: !0 });
264
271
  };
265
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l) : setTimeout(l, 100);
272
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a) : setTimeout(a, 100);
266
273
  }
267
- const K = () => ({
274
+ const D = () => ({
268
275
  name: "math",
269
276
  toolbar: [
270
277
  {
@@ -274,9 +281,9 @@ const K = () => ({
274
281
  }
275
282
  ],
276
283
  commands: {
277
- insertMath: (a, l) => {
278
- const o = l?.contentElement instanceof HTMLElement ? l.contentElement : null;
279
- return q(void 0, o), !0;
284
+ insertMath: (n, a) => {
285
+ const r = (a == null ? void 0 : a.contentElement) instanceof HTMLElement ? a.contentElement : null;
286
+ return z(void 0, r), !0;
280
287
  }
281
288
  },
282
289
  keymap: {
@@ -284,5 +291,5 @@ const K = () => ({
284
291
  }
285
292
  });
286
293
  export {
287
- K as MathPlugin
294
+ D as MathPlugin
288
295
  };