@editora/plugins 1.0.11 → 1.0.13
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 +1 -1
- package/dist/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/code.cjs.js +121 -44
- package/dist/code.esm.js +2694 -889
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const u = "data-editora-selection-marker";
|
|
2
|
+
function w(t) {
|
|
3
|
+
return t ? t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement : null;
|
|
4
|
+
}
|
|
5
|
+
function m(t) {
|
|
6
|
+
return t ? t.getAttribute("contenteditable") === "true" ? t : t.querySelector('[contenteditable="true"]') : null;
|
|
7
|
+
}
|
|
8
|
+
function y(t) {
|
|
9
|
+
if (t?.contentElement instanceof HTMLElement) return t.contentElement;
|
|
10
|
+
const e = m(t?.editorElement ?? null);
|
|
11
|
+
if (e) return e;
|
|
12
|
+
const n = typeof window < "u" ? window.__editoraCommandEditorRoot : null, o = n instanceof HTMLElement ? m(n) : null;
|
|
13
|
+
if (o) return o;
|
|
14
|
+
const a = window.getSelection();
|
|
15
|
+
if (a && a.rangeCount > 0) {
|
|
16
|
+
const l = w(a.getRangeAt(0).startContainer)?.closest('.rte-content, .editora-content, [contenteditable="true"]');
|
|
17
|
+
if (l instanceof HTMLElement) return l;
|
|
18
|
+
}
|
|
19
|
+
const r = document.activeElement;
|
|
20
|
+
if (r instanceof HTMLElement) {
|
|
21
|
+
const c = r.closest('.rte-content, .editora-content, [contenteditable="true"]');
|
|
22
|
+
if (c instanceof HTMLElement) return c;
|
|
23
|
+
}
|
|
24
|
+
return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]');
|
|
25
|
+
}
|
|
26
|
+
function R(t) {
|
|
27
|
+
const e = window.getSelection();
|
|
28
|
+
if (!e || e.rangeCount === 0) return !1;
|
|
29
|
+
const n = e.getRangeAt(0);
|
|
30
|
+
return t.contains(n.startContainer) && t.contains(n.endContainer);
|
|
31
|
+
}
|
|
32
|
+
function E(t) {
|
|
33
|
+
const e = document.createElement("span");
|
|
34
|
+
return e.setAttribute(u, t), e.style.display = "inline-block", e.style.width = "0", e.style.height = "0", e.style.overflow = "hidden", e.style.lineHeight = "0", e.appendChild(document.createTextNode("\uFEFF")), e;
|
|
35
|
+
}
|
|
36
|
+
function S(t) {
|
|
37
|
+
const e = window.getSelection();
|
|
38
|
+
if (!e || e.rangeCount === 0) return null;
|
|
39
|
+
const n = e.getRangeAt(0);
|
|
40
|
+
if (!t.contains(n.startContainer) || !t.contains(n.endContainer))
|
|
41
|
+
return null;
|
|
42
|
+
const o = n.collapsed, a = E("start"), r = o ? null : E("end"), c = n.cloneRange();
|
|
43
|
+
if (r) {
|
|
44
|
+
const i = c.cloneRange();
|
|
45
|
+
i.collapse(!1), i.insertNode(r);
|
|
46
|
+
}
|
|
47
|
+
const l = c.cloneRange();
|
|
48
|
+
return l.collapse(!0), l.insertNode(a), () => {
|
|
49
|
+
const i = window.getSelection(), s = document.createRange(), d = t.querySelector(
|
|
50
|
+
`[${u}="start"]`
|
|
51
|
+
), f = t.querySelector(
|
|
52
|
+
`[${u}="end"]`
|
|
53
|
+
);
|
|
54
|
+
if (!i || !d) {
|
|
55
|
+
t.querySelectorAll(`[${u}]`).forEach((g) => g.remove());
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
o || !f ? (s.setStartBefore(d), s.collapse(!0)) : (s.setStartAfter(d), s.setEndBefore(f)), i.removeAllRanges(), i.addRange(s), d.remove(), f?.remove();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function b(t, e, n) {
|
|
62
|
+
if (e !== n) {
|
|
63
|
+
if (typeof window.execEditorCommand == "function") {
|
|
64
|
+
window.execEditorCommand("recordDomTransaction", t, e, n);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (typeof window.executeEditorCommand == "function")
|
|
68
|
+
try {
|
|
69
|
+
window.executeEditorCommand("recordDomTransaction", { editor: t, beforeHTML: e, afterHTML: n });
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function p(t) {
|
|
75
|
+
const e = y(t.context);
|
|
76
|
+
if (!e) return !1;
|
|
77
|
+
const n = e.innerHTML;
|
|
78
|
+
R(e) && e.focus({ preventScroll: !0 });
|
|
79
|
+
let o = !1;
|
|
80
|
+
try {
|
|
81
|
+
o = document.execCommand(t.command, !1);
|
|
82
|
+
} catch {
|
|
83
|
+
o = !1;
|
|
84
|
+
}
|
|
85
|
+
const a = e.innerHTML;
|
|
86
|
+
if (t.normalize && a !== n) {
|
|
87
|
+
const c = S(e);
|
|
88
|
+
t.normalize(e), c?.();
|
|
89
|
+
}
|
|
90
|
+
const r = e.innerHTML;
|
|
91
|
+
return n !== r && (b(e, n, r), e.dispatchEvent(new Event("input", { bubbles: !0 }))), o !== !1 || n !== r;
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
p as a
|
|
95
|
+
};
|
package/dist/italic.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./inlineFormatting-DOYOJdnD.js"),l=(e,t)=>o.applyInlineFormatting({command:"italic",context:t}),a=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},i=()=>{a("toggleItalic",l)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i());const n=()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:l},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}});exports.ItalicPlugin=n;
|
package/dist/italic.esm.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { a } from "./inlineFormatting-DuVTGXYG.mjs";
|
|
2
|
+
const o = (e, t) => a({
|
|
3
|
+
command: "italic",
|
|
4
|
+
context: t
|
|
5
|
+
}), l = (e, t) => {
|
|
6
|
+
typeof window < "u" && window.registerEditorCommand?.(e, t);
|
|
7
|
+
}, i = () => {
|
|
8
|
+
l("toggleItalic", o);
|
|
5
9
|
};
|
|
6
|
-
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
7
|
-
const
|
|
10
|
+
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", i) : i());
|
|
11
|
+
const d = () => ({
|
|
8
12
|
name: "italic",
|
|
9
13
|
marks: {
|
|
10
14
|
italic: {
|
|
@@ -28,7 +32,7 @@ const a = () => ({
|
|
|
28
32
|
}
|
|
29
33
|
],
|
|
30
34
|
commands: {
|
|
31
|
-
toggleItalic:
|
|
35
|
+
toggleItalic: o
|
|
32
36
|
},
|
|
33
37
|
keymap: {
|
|
34
38
|
"Mod-i": "toggleItalic",
|
|
@@ -36,5 +40,5 @@ const a = () => ({
|
|
|
36
40
|
}
|
|
37
41
|
});
|
|
38
42
|
export {
|
|
39
|
-
|
|
43
|
+
d as ItalicPlugin
|
|
40
44
|
};
|
package/dist/math.cjs.js
CHANGED
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O={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 T=null,S=null,H=!1,y=null,m=null;const k='[data-theme="dark"], .dark, .editora-theme-dark',K=()=>new Promise((e,t)=>{if(window.katex){e(window.katex);return}if(H){const s=setInterval(()=>{window.katex&&(clearInterval(s),e(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 l=document.createElement("script");l.src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js",l.onload=()=>e(window.katex),l.onerror=t,document.head.appendChild(l)}),_=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.getRangeAt(0).startContainer;return(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(".rte-content, .editora-content")||null},U=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,j=e=>U(e)?.closest('.rte-content, .editora-content, [contenteditable="true"]')||null,W=(e,t,r)=>{if(t!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,t,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:t,afterHTML:r})}catch{}}},G=e=>{if(!(e instanceof Element))return null;const t=e.closest(".math-formula, .math-block");return t instanceof HTMLElement?t:null},h=()=>{m&&(m.classList.remove("math-object-selected"),m.removeAttribute("data-rte-selected-object"),m=null)},X=e=>{if(m===e)return;h(),m=e,e.classList.add("math-object-selected"),e.setAttribute("data-rte-selected-object","true");const t=window.getSelection();if(!t)return;const r=document.createRange();r.selectNode(e),t.removeAllRanges(),t.addRange(r)},Z=(e,t)=>{const r=window.getSelection();if(!r)return;const l=document.createRange();t&&t.parentNode===e?l.setStartBefore(t):(l.selectNodeContents(e),l.collapse(!1)),l.collapse(!0),r.removeAllRanges(),r.addRange(l)},Q=e=>{if(e.childNodes.length>0)return;const t=document.createElement("p");t.appendChild(document.createElement("br")),e.appendChild(t)},J=()=>{if(!m||!m.isConnected)return h(),!1;const e=m,t=j(e);if(!t)return h(),!1;const r=t.innerHTML,l=e.nextSibling;e.remove(),Q(t),h(),Z(t,l);const s=t.innerHTML;return W(t,r,s),t.dispatchEvent(new window.Event("input",{bubbles:!0})),r!==s},V=()=>{if(document.getElementById("math-object-selection-styles"))return;const e=document.createElement("style");e.id="math-object-selection-styles",e.textContent=`
|
|
2
|
+
.math-object-selected {
|
|
3
|
+
outline: 2px solid #2563eb !important;
|
|
4
|
+
outline-offset: 2px;
|
|
5
|
+
box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
|
|
6
|
+
}
|
|
7
|
+
`,document.head.appendChild(e)},Y=()=>{typeof window>"u"||window.__mathPluginObjectSelectionInitialized||(window.__mathPluginObjectSelectionInitialized=!0,V(),document.addEventListener("pointerdown",e=>{const t=G(e.target);if(!t){e.target?.closest?.(".math-dialog-overlay")||h();return}e.preventDefault(),j(t)?.focus(),X(t)},!0),document.addEventListener("keydown",e=>{if(m){if(e.key==="Escape"){h();return}e.key!=="Backspace"&&e.key!=="Delete"||(e.preventDefault(),e.stopPropagation(),J())}},!0))},ee=e=>{if((e||_())?.closest(k))return!0;const r=window.getSelection();if(r&&r.rangeCount>0){const s=r.getRangeAt(0).startContainer;if((s.nodeType===Node.ELEMENT_NODE?s:s.parentElement)?.closest(k))return!0}return document.activeElement?.closest(k)?!0:document.body.matches(k)||document.documentElement.matches(k)},N=async(e,t)=>{const r=t||S?.closest(".rte-content, .editora-content")||_()||y;y=r||null;const l=window.getSelection();if(l&&l.rangeCount>0){const n=l.getRangeAt(0);T=r&&r.contains(n.commonAncestorContainer)?n.cloneRange():null}await K();const s=ee(r),o=s?{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"},d=document.createElement("div");d.className="math-dialog-overlay",d.style.cssText=`position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: ${o.overlay}; display: flex; align-items: center; justify-content: center; z-index: 99999;`;const c=document.createElement("div");c.style.cssText=`background: ${o.dialogBg}; border: 1px solid ${o.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: ${o.text};`;let u=e?.format||"latex",B=e?.formula||"",R=e?.inline!==!1,b=null,L="";c.innerHTML=`
|
|
8
|
+
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${o.border}; background: ${o.panelBg};">
|
|
9
|
+
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${o.text};">${e?"Edit":"Insert"} Math Formula</h2>
|
|
10
|
+
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${o.muted}; padding: 0; width: 30px; height: 30px; line-height: 1;">×</button>
|
|
5
11
|
</div>
|
|
6
12
|
|
|
7
13
|
<div style="padding: 20px; overflow-y: auto; flex: 1;">
|
|
8
14
|
<div style="margin-bottom: 20px;">
|
|
9
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${
|
|
15
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Format:</label>
|
|
10
16
|
<div style="display: flex; gap: 16px;">
|
|
11
|
-
<label style="cursor: pointer; color: ${
|
|
12
|
-
<label style="cursor: pointer; color: ${
|
|
17
|
+
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="latex" ${u==="latex"?"checked":""} style="margin-right: 6px;"> LaTeX</label>
|
|
18
|
+
<label style="cursor: pointer; color: ${o.text};"><input type="radio" name="format" value="mathml" ${u==="mathml"?"checked":""} style="margin-right: 6px;"> MathML</label>
|
|
13
19
|
</div>
|
|
14
20
|
</div>
|
|
15
21
|
|
|
16
22
|
<div style="margin-bottom: 20px;">
|
|
17
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${
|
|
23
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Quick Templates:</label>
|
|
18
24
|
<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
25
|
</div>
|
|
20
26
|
|
|
21
27
|
<div style="margin-bottom: 20px;">
|
|
22
|
-
<label style="cursor: pointer; color: ${
|
|
28
|
+
<label style="cursor: pointer; color: ${o.text};"><input type="checkbox" id="inline-cb" ${R?"checked":""} style="margin-right: 8px;"> Inline math</label>
|
|
23
29
|
</div>
|
|
24
30
|
|
|
25
31
|
<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 ${
|
|
32
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Formula:</label>
|
|
33
|
+
<textarea id="formula-input" rows="4" style="width: 100%; min-height: 112px; padding: 10px 12px; border: 1px solid ${o.fieldBorder}; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.45; background: ${o.fieldBg}; color: ${o.text}; box-sizing: border-box; overflow-x: hidden; overflow-y: auto; resize: vertical;">${B}</textarea>
|
|
28
34
|
</div>
|
|
29
35
|
|
|
30
36
|
<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 ${
|
|
37
|
+
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${o.text};">Preview:</label>
|
|
38
|
+
<div id="preview-area" style="min-height: 60px; padding: 15px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.previewBg}; display: flex; align-items: center; justify-content: center; color: ${o.previewText};"></div>
|
|
33
39
|
</div>
|
|
34
40
|
</div>
|
|
35
41
|
|
|
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: ${
|
|
42
|
+
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${o.border}; background: ${o.panelBg};">
|
|
43
|
+
<button class="cancel-btn" style="padding: 10px 20px; background: ${o.cancelBg}; color: ${o.cancelText}; border: 1px solid ${o.cancelBorder}; border-radius: 4px; cursor: pointer; font-size: 14px;">Cancel</button>
|
|
44
|
+
<button id="insert-btn" style="padding: 10px 20px; background: ${o.insertBg}; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 14px;" disabled>${e?"Update":"Insert"}</button>
|
|
39
45
|
</div>
|
|
40
|
-
`,
|
|
41
|
-
<button type="button" data-formula="${I(
|
|
42
|
-
<div style="font-weight: 600; font-size: 12px; color: ${
|
|
43
|
-
<div style="font-size: 10px; color: ${
|
|
46
|
+
`,d.appendChild(c),document.body.appendChild(d);const p=c.querySelector("#formula-input"),v=c.querySelector("#preview-area"),$=c.querySelector("#templates-grid"),P=c.querySelectorAll('input[name="format"]'),z=c.querySelector("#inline-cb"),f=c.querySelector("#insert-btn"),g=c.querySelector(".close-btn"),w=c.querySelector(".cancel-btn"),I=n=>encodeURIComponent(n),q=n=>{try{return decodeURIComponent(n)}catch{return n}},C=()=>{const n=O[u];$.innerHTML=n.map(i=>`
|
|
47
|
+
<button type="button" data-formula="${I(i.formula)}" title="${i.description}" style="padding: 8px; border: 1px solid ${o.fieldBorder}; border-radius: 4px; background: ${o.templateBtnBg}; cursor: pointer; text-align: left; transition: background-color 0.16s ease;">
|
|
48
|
+
<div style="font-weight: 600; font-size: 12px; color: ${o.templateBtnText};">${i.name}</div>
|
|
49
|
+
<div style="font-size: 10px; color: ${o.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${i.formula.substring(0,20)}...</div>
|
|
44
50
|
</button>
|
|
45
|
-
`).join("")},
|
|
51
|
+
`).join("")},F=()=>{const n=p.value.trim(),i=`${u}:${n}`;if(i!==L){if(L=i,!n){v.innerHTML=`<span style="color: ${o.previewText};">Enter a formula to see preview</span>`,f.disabled=!0;return}f.disabled=!1;try{if(u==="latex"){const a=window.katex;v.innerHTML=a.renderToString(n,{displayMode:!1,throwOnError:!1})}else n.trim().startsWith("<math")?v.innerHTML=n:v.innerHTML=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${n}</math>`}catch{v.innerHTML=`<span style="color: ${o.invalid};">Invalid formula</span>`}}},M=()=>{b!==null&&cancelAnimationFrame(b),b=requestAnimationFrame(()=>{b=null,F()})},A=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),E())},E=()=>{document.removeEventListener("keydown",A,!0),b!==null&&(cancelAnimationFrame(b),b=null),d.parentNode&&d.parentNode.removeChild(d)};g.onmouseover=()=>{g.style.color="#f8fafc",g.style.background=s?"#334155":"#e5e7eb",g.style.borderRadius="4px"},g.onmouseout=()=>{g.style.color=o.muted,g.style.background="none"},w.onmouseover=()=>{w.style.background=s?"#475569":"#f3f4f6"},w.onmouseout=()=>{w.style.background=o.cancelBg},f.onmouseover=()=>{f.disabled||(f.style.background=o.insertHover)},f.onmouseout=()=>{f.style.background=o.insertBg},$.addEventListener("mouseover",n=>{const a=n.target.closest("button[data-formula]");a&&(a.style.background=o.templateBtnHover)}),$.addEventListener("mouseout",n=>{const a=n.target.closest("button[data-formula]");a&&(a.style.background=o.templateBtnBg)}),$.addEventListener("click",n=>{const a=n.target.closest("button[data-formula]");a&&(p.value=q(a.getAttribute("data-formula")||""),B=p.value,M())});const D=()=>{const n=p.value.trim();if(!n)return;const i={formula:n,format:u,inline:z.checked},a=i.inline?document.createElement("span"):document.createElement("div");if(a.className=i.inline?"math-formula":"math-block",a.setAttribute("data-math-formula",n),a.setAttribute("data-math-format",u),a.contentEditable="false",a.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;",u==="latex"){const x=window.katex;try{a.innerHTML=x.renderToString(n,{displayMode:!i.inline,throwOnError:!1})}catch{a.textContent=i.inline?`$${n}$`:`$$${n}$$`}}else if(n.trim().startsWith("<math"))a.innerHTML=n;else{const x=`<math xmlns="http://www.w3.org/1998/Math/MathML" display="${i.inline?"inline":"block"}">${n}</math>`;a.innerHTML=x}if(S)S.replaceWith(a);else if(T)T.deleteContents(),T.insertNode(a);else if(y&&y.isConnected){const x=document.createRange();x.selectNodeContents(y),x.collapse(!1),x.insertNode(a)}(a.closest(".rte-content, .editora-content")||y)?.dispatchEvent(new Event("input",{bubbles:!0})),E()};g.addEventListener("click",E),w.addEventListener("click",E),f.addEventListener("click",D),d.addEventListener("click",n=>{n.target===d&&E()}),document.addEventListener("keydown",A,!0),P.forEach(n=>{n.addEventListener("change",i=>{u=i.target.value,L="",C(),M()})}),p.addEventListener("input",()=>{B=p.value,M()}),p.addEventListener("keydown",n=>{(n.ctrlKey||n.metaKey)&&n.key==="Enter"&&(n.preventDefault(),D())}),C(),M(),p.focus()};if(typeof window<"u"&&!window.__mathPluginDoubleClickInitialized){window.__mathPluginDoubleClickInitialized=!0;const e=r=>{const s=r.target.closest(".math-formula, .math-block");if(s){r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation(),h(),S=s;const o=s.getAttribute("data-math-formula")||"",d=s.getAttribute("data-math-format")||"latex",c=s.classList.contains("math-formula");N({formula:o,format:d,inline:c})}},t=()=>{document.addEventListener("dblclick",e,{capture:!0})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t,100)}const te=()=>({name:"math",init:Y,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:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:null;return N(void 0,r),!0}},keymap:{"Mod-Shift-m":"insertMath"}});exports.MathPlugin=te;
|