@editora/plugins 1.0.7 → 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 +50 -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 +3 -3
- 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/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,34 +19,46 @@ const C = {
|
|
|
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 (
|
|
28
|
+
if (A) {
|
|
29
29
|
const i = setInterval(() => {
|
|
30
30
|
window.katex && (clearInterval(i), a(window.katex));
|
|
31
31
|
}, 100);
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
A = !0;
|
|
35
35
|
const o = document.createElement("link");
|
|
36
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
|
|
38
|
-
|
|
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
39
|
}), H = () => {
|
|
40
40
|
const a = window.getSelection();
|
|
41
|
-
if (a
|
|
42
|
-
|
|
43
|
-
|
|
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;
|
|
44
50
|
}
|
|
45
|
-
return document.activeElement?.closest(
|
|
46
|
-
},
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const
|
|
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;
|
|
59
|
+
}
|
|
60
|
+
await N();
|
|
61
|
+
const i = j(o), t = i ? {
|
|
50
62
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
51
63
|
dialogBg: "#1f2937",
|
|
52
64
|
border: "#3b4657",
|
|
@@ -88,147 +100,171 @@ const y = '[data-theme="dark"], .dark, .editora-theme-dark', q = () => new Promi
|
|
|
88
100
|
insertBg: "#007bff",
|
|
89
101
|
insertHover: "#0069d9",
|
|
90
102
|
invalid: "#cc0000"
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
<div style="display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid ${
|
|
98
|
-
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${
|
|
99
|
-
<button class="close-btn" style="background: none; border: none; font-size: 28px; cursor: pointer; color: ${
|
|
103
|
+
}, c = document.createElement("div");
|
|
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>
|
|
100
112
|
</div>
|
|
101
113
|
|
|
102
114
|
<div style="padding: 20px; overflow-y: auto; flex: 1;">
|
|
103
115
|
<div style="margin-bottom: 20px;">
|
|
104
|
-
<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>
|
|
105
117
|
<div style="display: flex; gap: 16px;">
|
|
106
|
-
<label style="cursor: pointer; color: ${
|
|
107
|
-
<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>
|
|
108
120
|
</div>
|
|
109
121
|
</div>
|
|
110
122
|
|
|
111
123
|
<div style="margin-bottom: 20px;">
|
|
112
|
-
<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>
|
|
113
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>
|
|
114
126
|
</div>
|
|
115
127
|
|
|
116
128
|
<div style="margin-bottom: 20px;">
|
|
117
|
-
<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>
|
|
118
130
|
</div>
|
|
119
131
|
|
|
120
132
|
<div style="margin-bottom: 20px;">
|
|
121
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${
|
|
122
|
-
<textarea id="formula-input" rows="4" style="width: 100%; padding: 10px; 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>
|
|
123
135
|
</div>
|
|
124
136
|
|
|
125
137
|
<div style="margin-bottom: 20px;">
|
|
126
|
-
<label style="display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; color: ${
|
|
127
|
-
<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>
|
|
128
140
|
</div>
|
|
129
141
|
</div>
|
|
130
142
|
|
|
131
|
-
<div style="display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid ${
|
|
132
|
-
<button class="cancel-btn" style="padding: 10px 20px; background: ${
|
|
133
|
-
<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>
|
|
134
146
|
</div>
|
|
135
|
-
`,
|
|
136
|
-
const
|
|
137
|
-
const t = C[d];
|
|
138
|
-
k.innerHTML = t.map((n) => `
|
|
139
|
-
<button type="button" data-formula="${n.formula.replace(/"/g, """)}" title="${n.description}" style="padding: 8px; border: 1px solid ${e.fieldBorder}; border-radius: 4px; background: ${e.templateBtnBg}; cursor: pointer; text-align: left;">
|
|
140
|
-
<div style="font-weight: 600; font-size: 12px; color: ${e.templateBtnText};">${n.name}</div>
|
|
141
|
-
<div style="font-size: 10px; color: ${e.templateSubText}; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${n.formula.substring(0, 20)}...</div>
|
|
142
|
-
</button>
|
|
143
|
-
`).join(""), k.querySelectorAll("button").forEach((n) => {
|
|
144
|
-
const r = n;
|
|
145
|
-
r.onmouseover = () => {
|
|
146
|
-
r.style.background = e.templateBtnHover;
|
|
147
|
-
}, r.onmouseout = () => {
|
|
148
|
-
r.style.background = e.templateBtnBg;
|
|
149
|
-
}, n.addEventListener("click", () => {
|
|
150
|
-
c.value = n.getAttribute("data-formula") || "", u = c.value, b();
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
}, b = () => {
|
|
154
|
-
const t = c.value.trim();
|
|
155
|
-
if (!t) {
|
|
156
|
-
f.innerHTML = `<span style="color: ${e.previewText};">Enter a formula to see preview</span>`, m.disabled = !0;
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
m.disabled = !1;
|
|
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) => {
|
|
160
149
|
try {
|
|
161
|
-
|
|
162
|
-
const n = window.katex;
|
|
163
|
-
f.innerHTML = n.renderToString(t, { displayMode: !1, throwOnError: !1 });
|
|
164
|
-
} else
|
|
165
|
-
t.trim().startsWith("<math") ? f.innerHTML = t : f.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${t}</math>`;
|
|
150
|
+
return decodeURIComponent(e);
|
|
166
151
|
} catch {
|
|
167
|
-
|
|
152
|
+
return e;
|
|
168
153
|
}
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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>
|
|
160
|
+
</button>
|
|
161
|
+
`).join("");
|
|
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;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
p.disabled = !1;
|
|
170
|
+
try {
|
|
171
|
+
if (m === "latex") {
|
|
172
|
+
const n = window.katex;
|
|
173
|
+
h.innerHTML = n.renderToString(e, { displayMode: !1, throwOnError: !1 });
|
|
174
|
+
} else
|
|
175
|
+
e.trim().startsWith("<math") ? h.innerHTML = e : h.innerHTML = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">${e}</math>`;
|
|
176
|
+
} catch {
|
|
177
|
+
h.innerHTML = `<span style="color: ${t.invalid};">Invalid formula</span>`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}, E = () => {
|
|
181
|
+
x !== null && cancelAnimationFrame(x), x = requestAnimationFrame(() => {
|
|
182
|
+
x = null, _();
|
|
183
|
+
});
|
|
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);
|
|
182
188
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
f.onmouseover = () => {
|
|
190
|
+
f.style.color = "#f8fafc", f.style.background = i ? "#334155" : "#e5e7eb", f.style.borderRadius = "4px";
|
|
191
|
+
}, f.onmouseout = () => {
|
|
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;
|
|
197
|
+
}, p.onmouseover = () => {
|
|
198
|
+
p.disabled || (p.style.background = t.insertHover);
|
|
199
|
+
}, p.onmouseout = () => {
|
|
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());
|
|
210
|
+
});
|
|
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;
|
|
189
217
|
try {
|
|
190
|
-
|
|
191
|
-
displayMode: !
|
|
218
|
+
n.innerHTML = g.renderToString(e, {
|
|
219
|
+
displayMode: !r.inline,
|
|
192
220
|
throwOnError: !1
|
|
193
221
|
});
|
|
194
222
|
} catch {
|
|
195
|
-
|
|
223
|
+
n.textContent = r.inline ? `$${e}$` : `$$${e}$$`;
|
|
196
224
|
}
|
|
197
|
-
} else if (
|
|
198
|
-
|
|
225
|
+
} else if (e.trim().startsWith("<math"))
|
|
226
|
+
n.innerHTML = e;
|
|
199
227
|
else {
|
|
200
|
-
const
|
|
201
|
-
|
|
228
|
+
const g = `<math xmlns="http://www.w3.org/1998/Math/MathML" display="${r.inline ? "inline" : "block"}">${e}</math>`;
|
|
229
|
+
n.innerHTML = g;
|
|
230
|
+
}
|
|
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);
|
|
202
238
|
}
|
|
203
|
-
|
|
239
|
+
(n.closest(".rte-content, .editora-content") || b)?.dispatchEvent(new Event("input", { bubbles: !0 })), y();
|
|
204
240
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
|
|
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();
|
|
210
246
|
});
|
|
211
|
-
}),
|
|
212
|
-
|
|
213
|
-
}),
|
|
214
|
-
(
|
|
215
|
-
}),
|
|
247
|
+
}), u.addEventListener("input", () => {
|
|
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();
|
|
216
252
|
};
|
|
217
253
|
if (typeof window < "u" && !window.__mathPluginDoubleClickInitialized) {
|
|
218
254
|
window.__mathPluginDoubleClickInitialized = !0;
|
|
219
255
|
const a = (o) => {
|
|
220
256
|
const i = o.target.closest(".math-formula, .math-block");
|
|
221
257
|
if (i) {
|
|
222
|
-
o.preventDefault(), o.stopPropagation(), o.stopImmediatePropagation(),
|
|
223
|
-
const
|
|
224
|
-
|
|
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 });
|
|
225
261
|
}
|
|
226
|
-
},
|
|
262
|
+
}, l = () => {
|
|
227
263
|
document.addEventListener("dblclick", a, { capture: !0 });
|
|
228
264
|
};
|
|
229
|
-
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
265
|
+
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", l) : setTimeout(l, 100);
|
|
230
266
|
}
|
|
231
|
-
const
|
|
267
|
+
const K = () => ({
|
|
232
268
|
name: "math",
|
|
233
269
|
toolbar: [
|
|
234
270
|
{
|
|
@@ -238,12 +274,15 @@ const z = () => ({
|
|
|
238
274
|
}
|
|
239
275
|
],
|
|
240
276
|
commands: {
|
|
241
|
-
insertMath: () =>
|
|
277
|
+
insertMath: (a, l) => {
|
|
278
|
+
const o = l?.contentElement instanceof HTMLElement ? l.contentElement : null;
|
|
279
|
+
return q(void 0, o), !0;
|
|
280
|
+
}
|
|
242
281
|
},
|
|
243
282
|
keymap: {
|
|
244
283
|
"Mod-Shift-m": "insertMath"
|
|
245
284
|
}
|
|
246
285
|
});
|
|
247
286
|
export {
|
|
248
|
-
|
|
287
|
+
K as MathPlugin
|
|
249
288
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./shared-config.cjs.js");let
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./shared-config.cjs.js");let A=null,s=null,l=null,R=[],D=!1,I=null,V=0,j=0,C=0,$=0,N=1,T=null;const W='[data-theme="dark"], .dark, .editora-theme-dark',B=(e,t)=>{const r=i=>{i.key!=="Escape"||!e.isConnected||(i.preventDefault(),i.stopPropagation(),t())};return document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("keydown",r,!0)}},X=()=>{if(typeof document>"u"||document.getElementById("rte-media-dialog-styles"))return;const e=document.createElement("style");e.id="rte-media-dialog-styles",e.textContent=`
|
|
2
2
|
.rte-media-overlay {
|
|
3
3
|
--rte-media-overlay-bg: rgba(15, 23, 36, 0.56);
|
|
4
4
|
--rte-media-bg: #ffffff;
|
|
@@ -376,7 +376,7 @@
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
.media-floating-toolbar.rte-ui-theme-dark,
|
|
379
|
-
${
|
|
379
|
+
${W} .media-floating-toolbar {
|
|
380
380
|
--rte-media-toolbar-bg: #24303f;
|
|
381
381
|
--rte-media-toolbar-border: #4a5a71;
|
|
382
382
|
--rte-media-toolbar-text: #d9e6fb;
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
margin: 0 2px;
|
|
425
425
|
background: var(--rte-media-toolbar-separator);
|
|
426
426
|
}
|
|
427
|
-
`,document.head.appendChild(e)},
|
|
427
|
+
`,document.head.appendChild(e)},Y=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return null;const t=e.anchorNode;return(t instanceof HTMLElement?t:t?.parentElement)?.closest(".rte-content, .editora-content")||null},Z=e=>{if(e)return e;const t=Y();if(t)return t;if(T)return T;const r=document.activeElement;return r?r.closest(".rte-content, .editora-content")||r:null},O=e=>{const t=Z(e);return t?!!t.closest(W):!1},_=e=>{X();const t=document.createElement("div");return t.className="rte-media-overlay",O(e)&&t.classList.add("rte-ui-theme-dark"),t},H=(e=!1)=>{const t=document.createElement("div");return t.className=e?"rte-media-dialog rte-media-dialog-compact":"rte-media-dialog",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t},F=(e,t)=>{const r=window.getSelection();r&&r.rangeCount>0&&(A=r.getRangeAt(0).cloneRange());const i=_(t),a=H();let o="upload",d="",c="",p="",g="";const v=()=>{a.innerHTML=`
|
|
428
428
|
<div class="rte-media-header">
|
|
429
429
|
<h2 class="rte-media-title">Insert ${e==="image"?"Image":"Video"}</h2>
|
|
430
430
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -456,12 +456,12 @@
|
|
|
456
456
|
<div id="url-section">
|
|
457
457
|
<div class="rte-media-field">
|
|
458
458
|
<label class="rte-media-label">URL</label>
|
|
459
|
-
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e==="image"?"jpg":"mp4"}" value="${
|
|
459
|
+
<input type="text" id="url-input" class="rte-media-input" placeholder="https://example.com/${e}.${e==="image"?"jpg":"mp4"}" value="${d}">
|
|
460
460
|
</div>
|
|
461
461
|
${e==="image"?`
|
|
462
462
|
<div class="rte-media-field">
|
|
463
463
|
<label class="rte-media-label">Alt Text (for accessibility)</label>
|
|
464
|
-
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${
|
|
464
|
+
<input type="text" id="alt-input" class="rte-media-input" placeholder="Describe the image" value="${g}">
|
|
465
465
|
</div>
|
|
466
466
|
`:""}
|
|
467
467
|
<div class="rte-media-grid">
|
|
@@ -471,14 +471,14 @@
|
|
|
471
471
|
</div>
|
|
472
472
|
<div class="rte-media-field">
|
|
473
473
|
<label class="rte-media-label">Height (px)</label>
|
|
474
|
-
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${
|
|
474
|
+
<input type="number" id="height-input" class="rte-media-input" placeholder="Auto" value="${p}">
|
|
475
475
|
</div>
|
|
476
476
|
</div>
|
|
477
|
-
${
|
|
477
|
+
${d?`
|
|
478
478
|
<div class="rte-media-field">
|
|
479
479
|
<label class="rte-media-label">Preview</label>
|
|
480
480
|
<div class="rte-media-preview">
|
|
481
|
-
${e==="image"?`<img src="${
|
|
481
|
+
${e==="image"?`<img src="${d}" alt="Preview">`:`<video src="${d}" controls></video>`}
|
|
482
482
|
</div>
|
|
483
483
|
</div>
|
|
484
484
|
`:""}
|
|
@@ -488,9 +488,9 @@
|
|
|
488
488
|
|
|
489
489
|
<div class="rte-media-footer">
|
|
490
490
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
491
|
-
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!
|
|
491
|
+
<button id="insert-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!d&&o==="url"?"disabled":""}>Insert</button>
|
|
492
492
|
</div>
|
|
493
|
-
`};v(),i.appendChild(a),document.body.appendChild(i);const h=()=>{i.parentNode&&i.parentNode.removeChild(i)},
|
|
493
|
+
`};v(),i.appendChild(a),document.body.appendChild(i);let k=()=>{};const h=()=>{k(),i.parentNode&&i.parentNode.removeChild(i)};k=B(i,h);const L=()=>{if(!d)return;const n=e==="image"?document.createElement("img"):document.createElement("video");n.src=d,n.setAttribute("data-media-type",e),e==="image"&&g&&(n.alt=g),c&&(n.style.width=`${c}px`,n.setAttribute("width",c)),p&&(n.style.height=`${p}px`,n.setAttribute("height",p)),e==="video"&&(n.controls=!0),!c&&!p?n.style.cssText="max-width: 100%; height: auto; display: block; margin: 1em 0; cursor: pointer;":n.style.cssText=`display: block; margin: 1em 0; cursor: pointer; ${c?`width: ${c}px;`:"max-width: 100%;"} ${p?`height: ${p}px;`:"height: auto;"}`,A&&(A.deleteContents(),A.insertNode(n)),h()},x=async n=>{const b=a.querySelector("#upload-progress"),u=a.querySelector("#progress-bar"),y=a.querySelector("#progress-text");if(b&&u&&y){b.style.display="block";let q=0;const f=setInterval(()=>{q+=Math.random()*30,q>90&&(q=90),u.style.width=`${q}%`},200);try{const w=new FileReader;w.onload=()=>{clearInterval(f),u.style.width="100%",y.textContent="Upload complete",setTimeout(()=>{d=w.result,o="url",v(),m()},500)},w.readAsDataURL(n)}catch{clearInterval(f),y.textContent="Upload failed"}}},m=()=>{const n=a.querySelector(".close-btn"),b=a.querySelector(".cancel-btn"),u=a.querySelector("#insert-btn"),y=a.querySelector(".tab-upload"),q=a.querySelector(".tab-url");if(n?.addEventListener("click",h),b?.addEventListener("click",h),u?.addEventListener("click",L),y?.addEventListener("click",()=>{o="upload",v(),m()}),q?.addEventListener("click",()=>{o="url",v(),m()}),o==="upload"){const f=a.querySelector(".dropzone"),w=a.querySelector("#file-input");f?.addEventListener("click",()=>w?.click()),f?.addEventListener("dragover",S=>{S.preventDefault(),f.classList.add("is-dragover")}),f?.addEventListener("dragleave",()=>{f.classList.remove("is-dragover")}),f?.addEventListener("drop",S=>{S.preventDefault(),f.classList.remove("is-dragover");const z=S.dataTransfer?.files[0];z&&x(z)}),w?.addEventListener("change",S=>{const z=S.target.files?.[0];z&&x(z)})}if(o==="url"){const f=a.querySelector("#url-input"),w=a.querySelector("#alt-input"),S=a.querySelector("#width-input"),z=a.querySelector("#height-input");f?.addEventListener("input",()=>{d=f.value,v(),m()}),w?.addEventListener("input",()=>{g=w.value}),S?.addEventListener("input",()=>{c=S.value}),z?.addEventListener("input",()=>{p=z.value})}};m(),i.addEventListener("click",n=>{n.target===i&&h()})},K=()=>{["nw","ne","sw","se"].forEach(t=>{const r=document.createElement("div");r.className=`media-resize-handle-${t}`,r.style.cssText=`
|
|
494
494
|
position: fixed;
|
|
495
495
|
width: 10px;
|
|
496
496
|
height: 10px;
|
|
@@ -501,7 +501,7 @@
|
|
|
501
501
|
z-index: 10001;
|
|
502
502
|
display: none;
|
|
503
503
|
box-shadow: 0 1px 3px rgba(0,0,0,0.3);
|
|
504
|
-
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!s){R.forEach(r=>r.style.display="none");return}const e=s.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const i=r.getAttribute("data-position"),a=t[i];r.style.left=`${a.x}px`,r.style.top=`${a.y}px`,r.style.display="block"})},
|
|
504
|
+
`,r.setAttribute("data-position",t),document.body.appendChild(r),R.push(r)})},M=()=>{if(!s){R.forEach(r=>r.style.display="none");return}const e=s.getBoundingClientRect(),t={nw:{x:e.left-5,y:e.top-5},ne:{x:e.right-5,y:e.top-5},sw:{x:e.left-5,y:e.bottom-5},se:{x:e.right-5,y:e.bottom-5}};R.forEach(r=>{const i=r.getAttribute("data-position"),a=t[i];r.style.left=`${a.x}px`,r.style.top=`${a.y}px`,r.style.display="block"})},J=e=>{const t=_(e),r=H(!0);r.innerHTML=`
|
|
505
505
|
<div class="rte-media-header">
|
|
506
506
|
<h2 class="rte-media-title">Edit Alt Text</h2>
|
|
507
507
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
516
516
|
<button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
|
|
517
517
|
</div>
|
|
518
|
-
`,t.appendChild(r),document.body.appendChild(t);const i=r.querySelector("#alt-text-input"),a=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),
|
|
518
|
+
`,t.appendChild(r),document.body.appendChild(t);const i=r.querySelector("#alt-text-input"),a=r.querySelector(".close-btn"),o=r.querySelector(".cancel-btn"),d=r.querySelector(".save-btn");let c=()=>{};const p=()=>{c(),t.parentNode&&t.parentNode.removeChild(t)};c=B(t,p),a.addEventListener("click",p),o.addEventListener("click",p),t.addEventListener("click",g=>{g.target===t&&p()}),d.addEventListener("click",()=>{e.alt=i.value,p()}),i.focus(),i.select()},Q=e=>{const t=e.closest("a"),r=t?.getAttribute("href")||"",i=t?.getAttribute("target")||"_self",a=t?.getAttribute("title")||"",o=_(e),d=H(!0);d.innerHTML=`
|
|
519
519
|
<div class="rte-media-header">
|
|
520
520
|
<h2 class="rte-media-title">${t?"Edit Link":"Add Link"}</h2>
|
|
521
521
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -541,7 +541,7 @@
|
|
|
541
541
|
<button class="save-btn rte-media-btn rte-media-btn-primary" type="button">Save</button>
|
|
542
542
|
</div>
|
|
543
543
|
</div>
|
|
544
|
-
`,o.appendChild(
|
|
544
|
+
`,o.appendChild(d),document.body.appendChild(o);const c=d.querySelector("#link-url"),p=d.querySelector("#link-title"),g=d.querySelector("#link-target"),v=d.querySelector(".close-btn"),k=d.querySelector(".cancel-btn"),h=d.querySelector(".save-btn"),L=d.querySelector(".remove-link-btn");let x=()=>{};const m=()=>{x(),o.parentNode&&o.parentNode.removeChild(o)};x=B(o,m),v.addEventListener("click",m),k.addEventListener("click",m),o.addEventListener("click",n=>{n.target===o&&m()}),h.addEventListener("click",()=>{const n=c.value.trim();if(n){const b=n.startsWith("http")?n:`https://${n}`;if(t)t.setAttribute("href",b),t.setAttribute("target",g.checked?"_blank":"_self"),g.checked?t.setAttribute("rel","noopener noreferrer"):t.removeAttribute("rel"),p.value.trim()?t.setAttribute("title",p.value.trim()):t.removeAttribute("title");else{const u=document.createElement("a");u.href=b,u.target=g.checked?"_blank":"_self",g.checked&&(u.rel="noopener noreferrer"),p.value.trim()&&(u.title=p.value.trim()),e.replaceWith(u),u.appendChild(e)}m(),l&&s&&U(s)}}),L?.addEventListener("click",()=>{t&&confirm("Remove link from this media?")&&(t.replaceWith(e),m(),l&&s&&U(s))}),c.focus()},ee=e=>{const t=_(e),r=H();let i="url",a=e.src;const o=()=>{r.innerHTML=`
|
|
545
545
|
<div class="rte-media-header">
|
|
546
546
|
<h2 class="rte-media-title">Replace Image</h2>
|
|
547
547
|
<button class="close-btn rte-media-close-btn" type="button" aria-label="Close">×</button>
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
<button class="cancel-btn rte-media-btn rte-media-btn-secondary" type="button">Cancel</button>
|
|
591
591
|
<button id="replace-btn" class="rte-media-btn rte-media-btn-primary" type="button" ${!a&&i==="url"?"disabled":""}>Replace</button>
|
|
592
592
|
</div>
|
|
593
|
-
`};o(),t.appendChild(r),document.body.appendChild(t);const
|
|
593
|
+
`};o(),t.appendChild(r),document.body.appendChild(t);let d=()=>{};const c=()=>{d(),t.parentNode&&t.parentNode.removeChild(t)};d=B(t,c);const p=()=>{a&&(e.src=a,c())},g=async k=>{const h=r.querySelector("#upload-progress"),L=r.querySelector("#progress-bar"),x=r.querySelector("#progress-text");if(h&&L&&x){h.style.display="block";let m=0;const n=setInterval(()=>{m+=Math.random()*30,m>90&&(m=90),L.style.width=`${m}%`},200);try{const b=new FileReader;b.onload=()=>{clearInterval(n),L.style.width="100%",x.textContent="Upload complete",setTimeout(()=>{a=b.result,i="url",o(),v()},500)},b.readAsDataURL(k)}catch{clearInterval(n),x.textContent="Upload failed"}}},v=()=>{const k=r.querySelector(".close-btn"),h=r.querySelector(".cancel-btn"),L=r.querySelector("#replace-btn"),x=r.querySelector(".tab-upload"),m=r.querySelector(".tab-url");if(k?.addEventListener("click",c),h?.addEventListener("click",c),L?.addEventListener("click",p),x?.addEventListener("click",()=>{i="upload",o(),v()}),m?.addEventListener("click",()=>{i="url",o(),v()}),i==="upload"){const n=r.querySelector(".dropzone"),b=r.querySelector("#file-input");n?.addEventListener("click",()=>b?.click()),n?.addEventListener("dragover",u=>{u.preventDefault(),n.classList.add("is-dragover")}),n?.addEventListener("dragleave",()=>{n.classList.remove("is-dragover")}),n?.addEventListener("drop",u=>{u.preventDefault(),n.classList.remove("is-dragover");const y=u.dataTransfer?.files[0];y&&g(y)}),b?.addEventListener("change",u=>{const y=u.target.files?.[0];y&&g(y)})}if(i==="url"){const n=r.querySelector("#url-input");n?.addEventListener("input",()=>{a=n.value,o(),v()})}};v(),t.addEventListener("click",k=>{k.target===t&&c()})},E=()=>{if(!l||!s)return;const e=l.offsetHeight||40,t=s.offsetTop,r=s.offsetLeft,i=s.offsetWidth,a=t-e-8,o=r+i/2-(l.offsetWidth||120)/2;l.style.top=`${a}px`,l.style.left=`${o}px`,setTimeout(()=>{l&&(l.style.display="flex")},100)},U=e=>{l&&(l._cleanup&&l._cleanup(),l.remove());const t=e.parentElement;if(t){const d=t.style.position;(!d||d==="static")&&(t.style.position="relative",t._originalPosition=d),l=document.createElement("div"),l.className="media-floating-toolbar",O(e)&&l.classList.add("rte-ui-theme-dark"),t.insertBefore(l,t.firstChild),E()}const r=e.tagName==="IMG",i=e.closest("a");l.innerHTML=`
|
|
594
594
|
<button class="media-floating-toolbar-btn btn-align-left" title="Align Left" type="button">
|
|
595
595
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="17" y1="10" x2="3" y2="10"></line><line x1="21" y1="6" x2="3" y2="6"></line><line x1="21" y1="14" x2="3" y2="14"></line><line x1="17" y1="18" x2="3" y2="18"></line></svg>
|
|
596
596
|
</button>
|
|
@@ -616,4 +616,4 @@
|
|
|
616
616
|
<button class="media-floating-toolbar-btn btn-remove" title="Remove" type="button">
|
|
617
617
|
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
|
|
618
618
|
</button>
|
|
619
|
-
`,setTimeout(()=>{
|
|
619
|
+
`,setTimeout(()=>{E()},0);const a=()=>E();let o=s.parentElement;for(;o;)o.addEventListener("scroll",a),o=o.parentElement;window.addEventListener("scroll",a),window.addEventListener("resize",a),l._cleanup=()=>{let d=s?.parentElement;for(;d;)d.removeEventListener("scroll",a),d=d.parentElement;window.removeEventListener("scroll",a),window.removeEventListener("resize",a)},l.querySelector(".btn-align-left")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="0",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-center")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="auto",E()}),l.querySelector(".btn-align-right")?.addEventListener("click",()=>{e.style.display="block",e.style.marginLeft="auto",e.style.marginRight="0",E()}),l.querySelector(".btn-alt")?.addEventListener("click",()=>{e.tagName==="IMG"&&J(e)}),l.querySelector(".btn-link")?.addEventListener("click",()=>{Q(e)}),l.querySelector(".btn-replace")?.addEventListener("click",()=>{e.tagName==="IMG"&&ee(e)}),l.querySelector(".btn-resize")?.addEventListener("click",()=>{const d=prompt("Enter width in pixels:",String(e.width||e.offsetWidth));if(d&&!isNaN(parseInt(d))){const c=parseInt(d);e.style.width=`${c}px`,e.setAttribute("width",String(c)),M(),E()}}),l.querySelector(".btn-remove")?.addEventListener("click",()=>{confirm("Remove this media?")&&(e.remove(),l&&(l._cleanup&&l._cleanup(),l.remove(),l=null),s=null,M())}),l._cleanup=()=>{window.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},G=e=>{T=e||null,K(),document.addEventListener("click",t=>{const r=t.target;if(r.tagName==="IMG"||r.tagName==="VIDEO"){const i=r;let a=!1;if(T?a=T.contains(i):a=!!i.closest('[contenteditable="true"]'),a){t.preventDefault(),t.stopPropagation(),s=i,s.style.display="block",U(i),M();return}}if(!r.closest(".btn-link, .btn-resize, .btn-remove")&&l&&!r.closest("button")){if(l._cleanup&&l._cleanup(),l.remove(),l=null,s&&s.parentElement){const i=s.parentElement;i._originalPosition!==void 0&&(i.style.position=i._originalPosition,delete i._originalPosition)}s=null,M()}}),R.forEach(t=>{t.addEventListener("mousedown",r=>{if(!s)return;r.preventDefault(),r.stopPropagation(),D=!0,I=t.getAttribute("data-position"),V=r.clientX,j=r.clientY;const i=s.getBoundingClientRect();C=i.width,$=i.height,N=C/$,document.body.style.userSelect="none",document.body.style.cursor=`${I}-resize`})}),document.addEventListener("mousemove",t=>{if(!D||!s||!I)return;const r=t.clientX-V,i=t.clientY-j;let a=C,o=$;switch(I){case"se":a=C+r,o=$+i;break;case"sw":a=C-r,o=$+i;break;case"ne":a=C+r,o=$-i;break;case"nw":a=C-r,o=$-i;break}Math.abs(r)>Math.abs(i)?o=a/N:a=o*N,a=Math.max(50,a),o=Math.max(50,o),s.style.width=`${a}px`,s.style.height=`${o}px`,s.setAttribute("width",String(Math.round(a))),s.setAttribute("height",String(Math.round(o))),M(),E()}),document.addEventListener("mouseup",()=>{D&&(D=!1,I=null,document.body.style.userSelect="",document.body.style.cursor="")}),window.addEventListener("scroll",M),window.addEventListener("resize",M)};typeof window<"u"&&!window.__mediaManagerInitialized&&(window.__mediaManagerInitialized=!0,G());const te=()=>({name:"image",initialize:e=>{const t=e?.editorElement;G(t)},toolbar:[{label:"Image",command:"insertImage",icon:'<svg width="24px" height="24px" viewBox="0 0 32 32" enable-background="new 0 0 32 32"><g><rect fill="none" height="22" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2" width="30" x="1" y="5"></rect><polygon fill="none" points="31,27 21,17 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><polygon fill="none" points="18,20 9,11 1,19 1,27 11,27" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></polygon><circle cx="19" cy="11" fill="none" r="2" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" stroke-width="2"></circle></g></svg>'},{label:"Video",command:"insertVideo",icon:'<svg width="24" height="24" focusable="false"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 0 1-1-1V4c0-.6.4-1 1-1Zm1 2v14h14V5H5Zm4.8 2.6 5.6 4a.5.5 0 0 1 0 .8l-5.6 4A.5.5 0 0 1 9 16V8a.5.5 0 0 1 .8-.4Z" fill-rule="nonzero"></path></svg>'}],commands:{insertImage:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("image",r),!0},insertVideo:(e,t)=>{const r=t?.contentElement instanceof HTMLElement?t.contentElement:void 0;return F("video",r),!0}},keymap:{"Mod-Shift-i":"insertImage"}}),re={apiEndpoints:{upload:"/media/upload",library:"/media/library",delete:"/media/library"},maxFileSize:10*1024*1024,allowedTypes:["image/jpeg","image/png","image/gif","video/mp4","video/webm"],headers:{}};let P={...re};function ae(e){P={...P,...e}}function ie(){return{...P}}exports.MediaManagerPlugin=te;exports.getMediaManagerConfig=ie;exports.setMediaManagerConfig=ae;
|