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