@editora/plugins 1.0.10 → 1.0.12

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