@editora/plugins 1.0.6 → 1.0.8
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 +57 -4
- package/dist/_commonjsHelpers-BH3jXuIh.js +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.mjs +33 -0
- package/dist/anchor.cjs.js +11 -11
- package/dist/anchor.esm.js +130 -107
- package/dist/anchoredPopover-BzqGPOAE.js +1 -0
- package/dist/anchoredPopover-Dts0IrgU.mjs +106 -0
- package/dist/background-color.cjs.js +3 -3
- package/dist/background-color.esm.js +116 -119
- package/dist/code.cjs.js +82 -102
- package/dist/code.esm.js +1172 -662
- package/dist/comments.cjs.js +10 -10
- package/dist/comments.esm.js +195 -177
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/documentManager-CTqRftU8.mjs +8369 -0
- package/dist/documentManager-Jf0RbSks.js +17 -0
- package/dist/embed-iframe.cjs.js +2 -2
- package/dist/embed-iframe.esm.js +8 -5
- package/dist/emojis.cjs.js +64 -39
- package/dist/emojis.esm.js +133 -104
- package/dist/html2canvas.esm-B5qzocYs.js +5 -0
- package/dist/html2canvas.esm-BWVIUcAF.mjs +4802 -0
- package/dist/{index-Bskk414V.mjs → index-BFsKNTTj.mjs} +50 -50
- 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-Cz1qItab.js → index.es-CE_A4QSm.js} +5 -5
- package/dist/{index.es-DEcRmSTY.mjs → index.es-DQ78mYYo.mjs} +4 -3
- package/dist/index.esm.js +87 -79
- package/dist/jspdf.es.min-BoS80556.js +77 -0
- package/dist/jspdf.es.min-DQCoX5yh.mjs +7889 -0
- package/dist/link.cjs.js +6 -6
- package/dist/link.esm.js +41 -39
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +151 -112
- package/dist/media-manager.cjs.js +15 -15
- package/dist/media-manager.esm.js +227 -206
- package/dist/merge-tag.cjs.js +44 -12
- package/dist/merge-tag.esm.js +368 -241
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +77 -69
- package/dist/special-characters.cjs.js +83 -45
- package/dist/special-characters.esm.js +149 -100
- package/dist/spell-check.cjs.js +9 -9
- package/dist/spell-check.esm.js +235 -216
- package/dist/template.cjs.js +14 -14
- package/dist/template.esm.js +157 -131
- package/dist/text-color.cjs.js +9 -9
- package/dist/text-color.esm.js +131 -115
- package/index.d.ts +51 -1
- package/package.json +6 -4
- package/dist/colorSelectionApply-C0iOfMWb.js +0 -1
- package/dist/colorSelectionApply-D8r_gV32.mjs +0 -63
- package/dist/documentManager-DRUc1-Cs.mjs +0 -37581
- package/dist/documentManager-_tQQfQi9.js +0 -317
- package/dist/index-D3pJyAsj.js +0 -1
package/dist/link.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,u=!1,l=null;const p='[data-theme="dark"], .dark, .editora-theme-dark',w=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},C=e=>{if(e){const n=e.startContainer;if((n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(p))return!0}return document.activeElement?.closest(p)?!0:document.body.matches(p)||document.documentElement.matches(p)},T=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
|
|
2
2
|
.link-dialog-overlay.rte-theme-dark .link-dialog {
|
|
3
3
|
background: #1f2937 !important;
|
|
4
4
|
border: 1px solid #4b5563 !important;
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
.link-dialog-overlay.rte-theme-dark .btn-submit:hover {
|
|
62
62
|
background: #2563eb !important;
|
|
63
63
|
}
|
|
64
|
-
`,document.head.appendChild(e)},
|
|
64
|
+
`,document.head.appendChild(e)},A=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,n=t.nodeType===Node.TEXT_NODE?t.parentElement:t,o=w(n);if(o){if(u&&l){l.href=e.url,l.textContent=e.text,l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const r=document.createRange();r.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(r))}else{const r=document.createElement("a");r.href=e.url,r.textContent=e.text,r.target=e.target,e.target==="_blank"&&r.setAttribute("rel","noopener noreferrer"),e.title&&(r.title=e.title),a.deleteContents(),a.insertNode(r),a.setStartAfter(r),a.setEndAfter(r);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(a))}o.focus(),a=null,u=!1,l=null}},k=(e,t)=>{T();const n=document.createElement("div");n.className="link-dialog-overlay",t&&n.classList.add("rte-theme-dark"),n.style.cssText=`
|
|
65
65
|
position: fixed;
|
|
66
66
|
top: 0;
|
|
67
67
|
left: 0;
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
type="text"
|
|
93
93
|
value="${e.text||""}"
|
|
94
94
|
placeholder="Enter link text"
|
|
95
|
-
style="width: 100%; padding:
|
|
95
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
96
96
|
/>
|
|
97
97
|
</div>
|
|
98
98
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
value="${e.url||""}"
|
|
104
104
|
placeholder="https://example.com"
|
|
105
105
|
required
|
|
106
|
-
style="width: 100%; padding:
|
|
106
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
107
107
|
/>
|
|
108
108
|
</div>
|
|
109
109
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
type="text"
|
|
114
114
|
value="${e.title||""}"
|
|
115
115
|
placeholder="Link tooltip text"
|
|
116
|
-
style="width: 100%; padding:
|
|
116
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
117
117
|
/>
|
|
118
118
|
</div>
|
|
119
119
|
<div class="form-group" style="margin-bottom: 0;">
|
|
@@ -135,4 +135,4 @@
|
|
|
135
135
|
</button>
|
|
136
136
|
</div>
|
|
137
137
|
</form>
|
|
138
|
-
`,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),
|
|
138
|
+
`,n.appendChild(o),document.body.appendChild(n);const r=o.querySelector("#link-form"),i=o.querySelector("#link-text"),d=o.querySelector("#link-url"),y=o.querySelector("#link-title"),v=o.querySelector("#link-target"),E=o.querySelector(".link-dialog-close"),L=o.querySelector(".btn-cancel"),b=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),c())},c=()=>{document.removeEventListener("keydown",b,!0),n.remove()};E.addEventListener("click",c),L.addEventListener("click",c),n.addEventListener("click",s=>{s.target===n&&c()}),document.addEventListener("keydown",b,!0),r.addEventListener("submit",s=>{s.preventDefault();const g=d.value.trim();g&&(A({text:i.value.trim()||g,url:g,target:v.checked?"_blank":"_self",title:y.value.trim()||void 0}),c())}),setTimeout(()=>i.focus(),100)},x=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const n=C(t),o=e.toString()||"",r=t.startContainer,d=(r.nodeType===Node.TEXT_NODE?r.parentElement:r)?.closest("a");return d?(u=!0,l=d,k({text:d.textContent||"",url:d.href,target:d.target||"_self",title:d.title||"",isEditing:!0},n)):(u=!1,l=null,k({text:o,url:"",target:"_self",isEditing:!1},n)),!0},h=()=>(document.execCommand("unlink",!1),!0),m=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},f=()=>{m("openLinkDialog",x),m("removeLink",h),m("createLink",e=>{e&&document.execCommand("createLink",!1,e)})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",f):f());const S=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:x,removeLink:h},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=S;
|
package/dist/link.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
let a = null,
|
|
2
|
-
const
|
|
1
|
+
let a = null, u = !1, l = null;
|
|
2
|
+
const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
3
3
|
if (!e) return null;
|
|
4
4
|
let t = e;
|
|
5
5
|
for (; t; ) {
|
|
@@ -8,13 +8,13 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
8
8
|
t = t.parentElement;
|
|
9
9
|
}
|
|
10
10
|
return null;
|
|
11
|
-
},
|
|
11
|
+
}, C = (e) => {
|
|
12
12
|
if (e) {
|
|
13
13
|
const n = e.startContainer;
|
|
14
|
-
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(
|
|
14
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(p)) return !0;
|
|
15
15
|
}
|
|
16
|
-
return document.activeElement?.closest(
|
|
17
|
-
},
|
|
16
|
+
return document.activeElement?.closest(p) ? !0 : document.body.matches(p) || document.documentElement.matches(p);
|
|
17
|
+
}, T = () => {
|
|
18
18
|
if (document.getElementById("rte-link-dialog-theme-styles")) return;
|
|
19
19
|
const e = document.createElement("style");
|
|
20
20
|
e.id = "rte-link-dialog-theme-styles", e.textContent = `
|
|
@@ -81,14 +81,14 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
81
81
|
background: #2563eb !important;
|
|
82
82
|
}
|
|
83
83
|
`, document.head.appendChild(e);
|
|
84
|
-
},
|
|
84
|
+
}, A = (e) => {
|
|
85
85
|
if (!a) {
|
|
86
86
|
console.warn("No selection range stored");
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o =
|
|
89
|
+
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, o = w(n);
|
|
90
90
|
if (o) {
|
|
91
|
-
if (
|
|
91
|
+
if (u && l) {
|
|
92
92
|
l.href = e.url, l.textContent = e.text, l.target = e.target, e.target === "_blank" ? l.setAttribute("rel", "noopener noreferrer") : l.removeAttribute("rel"), e.title ? l.title = e.title : l.removeAttribute("title");
|
|
93
93
|
const r = document.createRange();
|
|
94
94
|
r.selectNodeContents(l);
|
|
@@ -100,10 +100,10 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
100
100
|
const i = window.getSelection();
|
|
101
101
|
i && (i.removeAllRanges(), i.addRange(a));
|
|
102
102
|
}
|
|
103
|
-
o.focus(), a = null,
|
|
103
|
+
o.focus(), a = null, u = !1, l = null;
|
|
104
104
|
}
|
|
105
|
-
},
|
|
106
|
-
|
|
105
|
+
}, k = (e, t) => {
|
|
106
|
+
T();
|
|
107
107
|
const n = document.createElement("div");
|
|
108
108
|
n.className = "link-dialog-overlay", t && n.classList.add("rte-theme-dark"), n.style.cssText = `
|
|
109
109
|
position: fixed;
|
|
@@ -138,7 +138,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
138
138
|
type="text"
|
|
139
139
|
value="${e.text || ""}"
|
|
140
140
|
placeholder="Enter link text"
|
|
141
|
-
style="width: 100%; padding:
|
|
141
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
142
142
|
/>
|
|
143
143
|
</div>
|
|
144
144
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
@@ -149,7 +149,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
149
149
|
value="${e.url || ""}"
|
|
150
150
|
placeholder="https://example.com"
|
|
151
151
|
required
|
|
152
|
-
style="width: 100%; padding:
|
|
152
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
153
153
|
/>
|
|
154
154
|
</div>
|
|
155
155
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
@@ -159,7 +159,7 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
159
159
|
type="text"
|
|
160
160
|
value="${e.title || ""}"
|
|
161
161
|
placeholder="Link tooltip text"
|
|
162
|
-
style="width: 100%; padding:
|
|
162
|
+
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
163
163
|
/>
|
|
164
164
|
</div>
|
|
165
165
|
<div class="form-group" style="margin-bottom: 0;">
|
|
@@ -182,48 +182,50 @@ const c = '[data-theme="dark"], .dark, .editora-theme-dark', L = (e) => {
|
|
|
182
182
|
</div>
|
|
183
183
|
</form>
|
|
184
184
|
`, n.appendChild(o), document.body.appendChild(n);
|
|
185
|
-
const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"),
|
|
186
|
-
|
|
185
|
+
const r = o.querySelector("#link-form"), i = o.querySelector("#link-text"), d = o.querySelector("#link-url"), y = o.querySelector("#link-title"), v = o.querySelector("#link-target"), E = o.querySelector(".link-dialog-close"), L = o.querySelector(".btn-cancel"), b = (s) => {
|
|
186
|
+
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), c());
|
|
187
|
+
}, c = () => {
|
|
188
|
+
document.removeEventListener("keydown", b, !0), n.remove();
|
|
187
189
|
};
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}), r.addEventListener("submit", (
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
text: i.value.trim() ||
|
|
195
|
-
url:
|
|
196
|
-
target:
|
|
197
|
-
title:
|
|
198
|
-
}),
|
|
190
|
+
E.addEventListener("click", c), L.addEventListener("click", c), n.addEventListener("click", (s) => {
|
|
191
|
+
s.target === n && c();
|
|
192
|
+
}), document.addEventListener("keydown", b, !0), r.addEventListener("submit", (s) => {
|
|
193
|
+
s.preventDefault();
|
|
194
|
+
const g = d.value.trim();
|
|
195
|
+
g && (A({
|
|
196
|
+
text: i.value.trim() || g,
|
|
197
|
+
url: g,
|
|
198
|
+
target: v.checked ? "_blank" : "_self",
|
|
199
|
+
title: y.value.trim() || void 0
|
|
200
|
+
}), c());
|
|
199
201
|
}), setTimeout(() => i.focus(), 100);
|
|
200
|
-
},
|
|
202
|
+
}, x = () => {
|
|
201
203
|
const e = window.getSelection();
|
|
202
204
|
if (!e || e.rangeCount === 0) return !1;
|
|
203
205
|
const t = e.getRangeAt(0).cloneRange();
|
|
204
206
|
a = t;
|
|
205
|
-
const n =
|
|
206
|
-
return d ? (
|
|
207
|
+
const n = C(t), o = e.toString() || "", r = t.startContainer, d = (r.nodeType === Node.TEXT_NODE ? r.parentElement : r)?.closest("a");
|
|
208
|
+
return d ? (u = !0, l = d, k({
|
|
207
209
|
text: d.textContent || "",
|
|
208
210
|
url: d.href,
|
|
209
211
|
target: d.target || "_self",
|
|
210
212
|
title: d.title || "",
|
|
211
213
|
isEditing: !0
|
|
212
|
-
}, n)) : (
|
|
214
|
+
}, n)) : (u = !1, l = null, k({
|
|
213
215
|
text: o,
|
|
214
216
|
url: "",
|
|
215
217
|
target: "_self",
|
|
216
218
|
isEditing: !1
|
|
217
219
|
}, n)), !0;
|
|
218
|
-
}, h = () => (document.execCommand("unlink", !1), !0),
|
|
220
|
+
}, h = () => (document.execCommand("unlink", !1), !0), m = (e, t) => {
|
|
219
221
|
typeof window < "u" && window.registerEditorCommand?.(e, t);
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
+
}, f = () => {
|
|
223
|
+
m("openLinkDialog", x), m("removeLink", h), m("createLink", (e) => {
|
|
222
224
|
e && document.execCommand("createLink", !1, e);
|
|
223
225
|
});
|
|
224
226
|
};
|
|
225
|
-
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
226
|
-
const
|
|
227
|
+
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", f) : f());
|
|
228
|
+
const S = () => ({
|
|
227
229
|
name: "link",
|
|
228
230
|
marks: {
|
|
229
231
|
link: {
|
|
@@ -264,7 +266,7 @@ const A = () => ({
|
|
|
264
266
|
}
|
|
265
267
|
],
|
|
266
268
|
commands: {
|
|
267
|
-
openLinkDialog:
|
|
269
|
+
openLinkDialog: x,
|
|
268
270
|
removeLink: h
|
|
269
271
|
},
|
|
270
272
|
keymap: {
|
|
@@ -272,5 +274,5 @@ const A = () => ({
|
|
|
272
274
|
}
|
|
273
275
|
});
|
|
274
276
|
export {
|
|
275
|
-
|
|
277
|
+
S as LinkPlugin
|
|
276
278
|
};
|
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%; padding: 10px; 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
|
-
`,
|
|
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;
|