@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.
- package/README.md +5 -0
- package/dist/_commonjsHelpers-6763f629.js +1 -0
- package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +98 -80
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +128 -115
- package/dist/anchoredPopover-33f1358d.mjs +109 -0
- package/dist/anchoredPopover-8151d535.js +1 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +249 -208
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +68 -55
- package/dist/blockquote.esm.js +2 -1
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +245 -178
- package/dist/capitalization.esm.js +2 -1
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +82 -58
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +512 -439
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +33 -27
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +93 -82
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +653 -594
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +158 -116
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +432 -371
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +159 -105
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +368 -328
- package/dist/direction.esm.js +18 -9
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +308 -240
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +5 -4
- package/dist/documentManager-25b6203c.mjs +9122 -0
- package/dist/documentManager-b69e7054.js +17 -0
- package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +81 -73
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +77 -65
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +56 -54
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +47 -39
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +53 -37
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +117 -76
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +92 -70
- package/dist/html2canvas.esm-09133e29.js +22 -0
- package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +24 -12
- package/dist/index-656d224b.js +231 -0
- package/dist/index-6a8c48bb.js +1 -0
- package/dist/index-d027b7e2.mjs +16859 -0
- package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-730f2d98.mjs +5775 -0
- package/dist/index.es-dd40173b.js +18 -0
- package/dist/index.esm.js +128 -125
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +9 -8
- package/dist/jspdf.es.min-90db2c97.js +243 -0
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +24 -11
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +30 -24
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +25 -20
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +61 -59
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +146 -139
- package/dist/media-manager.cjs.js +38 -38
- package/dist/media-manager.esm.js +325 -308
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +286 -238
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +216 -177
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +49 -33
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +463 -393
- package/dist/preview.esm.js +10 -5
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +20 -17
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
- package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
- package/dist/slash-commands.cjs.js +3 -3
- package/dist/slash-commands.esm.js +212 -176
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +336 -280
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +69 -61
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +123 -97
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +19 -14
- package/dist/style.css +1 -0
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +225 -191
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +153 -124
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +27 -21
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +87 -70
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +162 -100
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +678 -602
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +157 -128
- package/package.json +13 -7
- package/LICENSE +0 -21
- package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
- package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/documentManager-CTqRftU8.mjs +0 -8369
- package/dist/documentManager-Jf0RbSks.js +0 -17
- package/dist/html2canvas.esm-B5qzocYs.js +0 -5
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-D3CycEFU.mjs +0 -16543
- package/dist/index-tqLTHcO6.js +0 -1
- package/dist/index.es-CE_A4QSm.js +0 -5
- package/dist/index.es-DQ78mYYo.mjs +0 -6665
- package/dist/jspdf.es.min-BoS80556.js +0 -77
- package/dist/plugins.css +0 -1
- /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
|
|
2
|
-
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${
|
|
3
|
-
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${
|
|
4
|
-
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${
|
|
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: ${
|
|
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: ${
|
|
12
|
-
<label style="cursor: pointer; color: ${
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
27
|
-
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${
|
|
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: ${
|
|
32
|
-
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${
|
|
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 ${
|
|
37
|
-
<button class="cancel-btn" style="padding: 10px 20px; background: ${
|
|
38
|
-
<button id="insert-btn" style="padding: 10px 20px; background: ${
|
|
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(
|
|
41
|
-
<button type="button" data-formula="${
|
|
42
|
-
<div style="font-weight: 600; font-size: 12px; color: ${
|
|
43
|
-
<div style="font-size: 10px; color: ${
|
|
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("")},
|
|
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
|
|
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
|
|
23
|
-
const
|
|
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
|
-
|
|
25
|
+
n(window.katex);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
window.katex && (clearInterval(
|
|
28
|
+
if (H) {
|
|
29
|
+
const l = setInterval(() => {
|
|
30
|
+
window.katex && (clearInterval(l), n(window.katex));
|
|
31
31
|
}, 100);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
}),
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
61
|
-
const
|
|
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: ${
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
let m =
|
|
108
|
-
|
|
109
|
-
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${
|
|
110
|
-
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${
|
|
111
|
-
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${
|
|
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: ${
|
|
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: ${
|
|
119
|
-
<label style="cursor: pointer; color: ${
|
|
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: ${
|
|
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: ${
|
|
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: ${
|
|
134
|
-
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${
|
|
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: ${
|
|
139
|
-
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${
|
|
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 ${
|
|
144
|
-
<button class="cancel-btn" style="padding: 10px 20px; background: ${
|
|
145
|
-
<button id="insert-btn" style="padding: 10px 20px; background: ${
|
|
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(
|
|
148
|
-
const u =
|
|
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(
|
|
155
|
+
return decodeURIComponent(t);
|
|
151
156
|
} catch {
|
|
152
|
-
return
|
|
157
|
+
return t;
|
|
153
158
|
}
|
|
154
|
-
},
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
<button type="button" data-formula="${
|
|
158
|
-
<div style="font-weight: 600; font-size: 12px; color: ${
|
|
159
|
-
<div style="font-size: 10px; color: ${
|
|
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
|
|
164
|
-
if (
|
|
165
|
-
if (L =
|
|
166
|
-
|
|
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
|
|
173
|
-
|
|
177
|
+
const o = window.katex;
|
|
178
|
+
v.innerHTML = o.renderToString(t, { displayMode: !1, throwOnError: !1 });
|
|
174
179
|
} else
|
|
175
|
-
|
|
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
|
-
|
|
182
|
+
v.innerHTML = `<span style="color: ${e.invalid};">Invalid formula</span>`;
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
|
-
},
|
|
185
|
+
}, $ = () => {
|
|
181
186
|
x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
|
|
182
|
-
x = null,
|
|
187
|
+
x = null, N();
|
|
183
188
|
});
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
document.removeEventListener("keydown",
|
|
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 =
|
|
195
|
+
f.style.color = "#f8fafc", f.style.background = l ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
|
|
191
196
|
}, f.onmouseout = () => {
|
|
192
|
-
f.style.color =
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
|
|
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 =
|
|
203
|
+
p.disabled || (p.style.background = e.insertHover);
|
|
199
204
|
}, p.onmouseout = () => {
|
|
200
|
-
p.style.background =
|
|
201
|
-
},
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
}),
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
}),
|
|
208
|
-
const
|
|
209
|
-
|
|
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
|
|
212
|
-
const
|
|
213
|
-
if (!
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
|
|
219
|
-
displayMode: !
|
|
224
|
+
o.innerHTML = b.renderToString(t, {
|
|
225
|
+
displayMode: !i.inline,
|
|
220
226
|
throwOnError: !1
|
|
221
227
|
});
|
|
222
228
|
} catch {
|
|
223
|
-
|
|
229
|
+
o.textContent = i.inline ? `$${t}$` : `$$${t}$$`;
|
|
224
230
|
}
|
|
225
|
-
} else if (
|
|
226
|
-
|
|
231
|
+
} else if (t.trim().startsWith("<math"))
|
|
232
|
+
o.innerHTML = t;
|
|
227
233
|
else {
|
|
228
|
-
const
|
|
229
|
-
|
|
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 (
|
|
232
|
-
|
|
233
|
-
else if (
|
|
234
|
-
|
|
235
|
-
else if (
|
|
236
|
-
const
|
|
237
|
-
|
|
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
|
-
|
|
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",
|
|
242
|
-
|
|
243
|
-
}), document.addEventListener("keydown",
|
|
244
|
-
|
|
245
|
-
m =
|
|
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,
|
|
249
|
-
}), u.addEventListener("keydown", (
|
|
250
|
-
(
|
|
251
|
-
}),
|
|
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
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
|
|
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
|
-
},
|
|
263
|
-
document.addEventListener("dblclick",
|
|
269
|
+
}, a = () => {
|
|
270
|
+
document.addEventListener("dblclick", n, { capture: !0 });
|
|
264
271
|
};
|
|
265
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
272
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", a) : setTimeout(a, 100);
|
|
266
273
|
}
|
|
267
|
-
const
|
|
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: (
|
|
278
|
-
const
|
|
279
|
-
return
|
|
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
|
-
|
|
294
|
+
D as MathPlugin
|
|
288
295
|
};
|