@editora/core 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CodePlugin.native-0Zari_zp.mjs → CodePlugin.native-B263UI8O.mjs} +502 -370
- package/dist/{CodeSamplePlugin.native-B-KS1pOl.mjs → CodeSamplePlugin.native-CgGoH-X4.mjs} +52 -52
- package/dist/{HistoryPlugin.native-DCrPdeSW.mjs → HistoryPlugin.native-TDnVMsEO.mjs} +21 -21
- package/dist/{MergeTagPlugin.native-CU9LtsfD.mjs → MergeTagPlugin.native-DIGWhdnF.mjs} +8 -5
- package/dist/index.cjs.js +1 -1
- package/dist/plugin-loader.js +2 -2
- package/dist/webcomponent-core.js +2 -2
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +33 -25
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.js +4 -4
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +154 -146
- package/index.d.ts +6 -6
- package/package.json +18 -11
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const T = () => {
|
|
2
2
|
const d = window.getSelection();
|
|
3
3
|
if (d && d.rangeCount > 0) {
|
|
4
4
|
let t = d.getRangeAt(0).startContainer;
|
|
5
5
|
for (; t && t !== document.body; ) {
|
|
6
6
|
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
7
|
+
const a = t;
|
|
8
|
+
if (a.getAttribute("contenteditable") === "true")
|
|
9
|
+
return a;
|
|
10
10
|
}
|
|
11
11
|
t = t.parentNode;
|
|
12
12
|
}
|
|
@@ -19,17 +19,17 @@ const w = () => {
|
|
|
19
19
|
if (t) return t;
|
|
20
20
|
}
|
|
21
21
|
return document.querySelector('[contenteditable="true"]');
|
|
22
|
-
}, k = '[data-theme="dark"], .dark, .editora-theme-dark',
|
|
23
|
-
const d =
|
|
22
|
+
}, k = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => {
|
|
23
|
+
const d = T();
|
|
24
24
|
if (d != null && d.closest(k)) return !0;
|
|
25
25
|
const l = window.getSelection();
|
|
26
26
|
if (l && l.rangeCount > 0) {
|
|
27
|
-
const
|
|
27
|
+
const a = l.getRangeAt(0).startContainer, i = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
|
|
28
28
|
if (i != null && i.closest(k)) return !0;
|
|
29
29
|
}
|
|
30
30
|
const t = document.activeElement;
|
|
31
31
|
return t != null && t.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
|
|
32
|
-
},
|
|
32
|
+
}, M = [
|
|
33
33
|
{ value: "javascript", label: "JavaScript" },
|
|
34
34
|
{ value: "typescript", label: "TypeScript" },
|
|
35
35
|
{ value: "python", label: "Python" },
|
|
@@ -55,8 +55,8 @@ const w = () => {
|
|
|
55
55
|
{ value: "shell", label: "Shell" },
|
|
56
56
|
{ value: "plaintext", label: "Plain Text" }
|
|
57
57
|
], S = /* @__PURE__ */ new Map();
|
|
58
|
-
function $(d, l, t,
|
|
59
|
-
const i = !!l, n =
|
|
58
|
+
function $(d, l, t, a) {
|
|
59
|
+
const i = !!l, n = a || "javascript", f = t || "", p = A(), e = p ? {
|
|
60
60
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
61
61
|
dialogBg: "#1f2937",
|
|
62
62
|
dialogBorder: "#4b5563",
|
|
@@ -146,9 +146,9 @@ function $(d, l, t, r) {
|
|
|
146
146
|
color: ${e.text};
|
|
147
147
|
cursor: pointer;
|
|
148
148
|
">
|
|
149
|
-
${
|
|
150
|
-
<option value="${
|
|
151
|
-
${
|
|
149
|
+
${M.map((r) => `
|
|
150
|
+
<option value="${r.value}" ${r.value === n ? "selected" : ""}>
|
|
151
|
+
${r.label}
|
|
152
152
|
</option>
|
|
153
153
|
`).join("")}
|
|
154
154
|
</select>
|
|
@@ -170,7 +170,7 @@ function $(d, l, t, r) {
|
|
|
170
170
|
background-color: ${e.fieldBg};
|
|
171
171
|
color: ${e.text};
|
|
172
172
|
box-sizing: border-box;
|
|
173
|
-
">${
|
|
173
|
+
">${f}</textarea>
|
|
174
174
|
<div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
|
|
175
175
|
`;
|
|
176
176
|
const x = document.createElement("div");
|
|
@@ -205,11 +205,11 @@ function $(d, l, t, r) {
|
|
|
205
205
|
color: #fff;
|
|
206
206
|
">${i ? "Update Code Sample" : "Insert Code Sample"}</button>
|
|
207
207
|
`, o.appendChild(u), o.appendChild(m), o.appendChild(y), c.appendChild(o);
|
|
208
|
-
const L = s.querySelector(".rte-code-language"), E = b.querySelector(".rte-code-textarea"),
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
|
|
208
|
+
const L = s.querySelector(".rte-code-language"), E = b.querySelector(".rte-code-textarea"), w = b.querySelector(".rte-code-error"), g = u.querySelector(".rte-code-close-btn"), v = y.querySelector(".rte-code-cancel-btn"), h = y.querySelector(".rte-code-save-btn");
|
|
209
|
+
g.onmouseover = () => {
|
|
210
|
+
g.style.color = "#f8fafc", g.style.background = p ? "#334155" : "#f0f0f0", g.style.borderRadius = "4px";
|
|
211
|
+
}, g.onmouseout = () => {
|
|
212
|
+
g.style.color = e.mutedText, g.style.background = "none";
|
|
213
213
|
}, v.onmouseover = () => {
|
|
214
214
|
v.style.background = e.cancelHover;
|
|
215
215
|
}, v.onmouseout = () => {
|
|
@@ -221,24 +221,24 @@ function $(d, l, t, r) {
|
|
|
221
221
|
};
|
|
222
222
|
const C = () => {
|
|
223
223
|
c.remove();
|
|
224
|
-
},
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
227
|
-
|
|
224
|
+
}, B = () => {
|
|
225
|
+
const r = E.value.trim();
|
|
226
|
+
if (!r) {
|
|
227
|
+
w.textContent = "⚠ Code cannot be empty", w.style.display = "block";
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
d(
|
|
230
|
+
const N = L.value;
|
|
231
|
+
d(r, N), C();
|
|
232
232
|
};
|
|
233
|
-
if (
|
|
234
|
-
(
|
|
233
|
+
if (g.onclick = C, v.onclick = C, h.onclick = B, E.addEventListener("keydown", (r) => {
|
|
234
|
+
(r.ctrlKey || r.metaKey) && r.key === "Enter" && (r.preventDefault(), B()), r.key === "Escape" && C();
|
|
235
235
|
}), E.addEventListener("input", () => {
|
|
236
|
-
|
|
237
|
-
}), c.addEventListener("click", (
|
|
238
|
-
|
|
236
|
+
w.style.display = "none";
|
|
237
|
+
}), c.addEventListener("click", (r) => {
|
|
238
|
+
r.target === c && C();
|
|
239
239
|
}), !document.getElementById("rte-code-sample-animations")) {
|
|
240
|
-
const
|
|
241
|
-
|
|
240
|
+
const r = document.createElement("style");
|
|
241
|
+
r.id = "rte-code-sample-animations", r.textContent = `
|
|
242
242
|
@keyframes fadeIn {
|
|
243
243
|
from { opacity: 0; }
|
|
244
244
|
to { opacity: 1; }
|
|
@@ -247,21 +247,21 @@ function $(d, l, t, r) {
|
|
|
247
247
|
from { transform: translateY(20px); opacity: 0; }
|
|
248
248
|
to { transform: translateY(0); opacity: 1; }
|
|
249
249
|
}
|
|
250
|
-
`, document.head.appendChild(
|
|
250
|
+
`, document.head.appendChild(r);
|
|
251
251
|
}
|
|
252
252
|
return document.body.appendChild(c), setTimeout(() => E.focus(), 100), c;
|
|
253
253
|
}
|
|
254
254
|
function R() {
|
|
255
|
-
if (!
|
|
255
|
+
if (!T()) return;
|
|
256
256
|
let l = null;
|
|
257
257
|
const t = window.getSelection();
|
|
258
|
-
t && t.rangeCount > 0 && (l = t.getRangeAt(0).cloneRange()), $((
|
|
258
|
+
t && t.rangeCount > 0 && (l = t.getRangeAt(0).cloneRange()), $((a, i) => {
|
|
259
259
|
const n = window.getSelection();
|
|
260
260
|
if (l && (n == null || n.removeAllRanges(), n == null || n.addRange(l)), !n || n.rangeCount === 0) return;
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
261
|
+
const f = T();
|
|
262
|
+
if (!f) return;
|
|
263
263
|
const p = n.anchorNode;
|
|
264
|
-
if (!p || !
|
|
264
|
+
if (!p || !f.contains(p)) return;
|
|
265
265
|
const e = n.getRangeAt(0), c = `code-block-${Date.now()}`, o = document.createElement("pre");
|
|
266
266
|
o.className = "rte-code-block", o.id = c, o.setAttribute("data-type", "code-block"), o.setAttribute("data-lang", i), o.setAttribute("data-code-id", c), o.setAttribute("contenteditable", "false"), o.style.cssText = `
|
|
267
267
|
display: block;
|
|
@@ -288,7 +288,7 @@ function R() {
|
|
|
288
288
|
white-space: pre;
|
|
289
289
|
word-break: normal;
|
|
290
290
|
display: block;
|
|
291
|
-
`, u.textContent =
|
|
291
|
+
`, u.textContent = a;
|
|
292
292
|
const m = document.createElement("span");
|
|
293
293
|
m.style.cssText = `
|
|
294
294
|
position: absolute;
|
|
@@ -318,7 +318,7 @@ function R() {
|
|
|
318
318
|
opacity: 0;
|
|
319
319
|
transition: opacity 0.2s ease;
|
|
320
320
|
`, s.onclick = (x) => {
|
|
321
|
-
x.stopPropagation(), navigator.clipboard.writeText(
|
|
321
|
+
x.stopPropagation(), navigator.clipboard.writeText(a).then(() => {
|
|
322
322
|
s.textContent = "✓ Copied!", setTimeout(() => {
|
|
323
323
|
s.textContent = "Copy";
|
|
324
324
|
}, 2e3);
|
|
@@ -332,24 +332,24 @@ function R() {
|
|
|
332
332
|
}), S.set(c, {
|
|
333
333
|
id: c,
|
|
334
334
|
language: i,
|
|
335
|
-
code:
|
|
335
|
+
code: a
|
|
336
336
|
}), e.insertNode(o);
|
|
337
337
|
const b = document.createRange();
|
|
338
338
|
b.setStartAfter(o), b.collapse(!0), n.removeAllRanges(), n.addRange(b);
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
function z(d) {
|
|
342
|
-
const l =
|
|
342
|
+
const l = T();
|
|
343
343
|
if (!l) return;
|
|
344
344
|
const t = l.querySelector(`#${d}`);
|
|
345
345
|
if (!t) return;
|
|
346
|
-
const
|
|
347
|
-
|
|
346
|
+
const a = S.get(d);
|
|
347
|
+
a && $(
|
|
348
348
|
(i, n) => {
|
|
349
|
-
const
|
|
350
|
-
|
|
349
|
+
const f = t.querySelector("code");
|
|
350
|
+
f && (f.textContent = i, f.className = `language-${n}`);
|
|
351
351
|
const p = t.querySelector("span");
|
|
352
|
-
p && (p.textContent = n), t.setAttribute("data-lang", n),
|
|
352
|
+
p && (p.textContent = n), t.setAttribute("data-lang", n), a.language = n, a.code = i;
|
|
353
353
|
const e = t.querySelector(".rte-code-copy");
|
|
354
354
|
e && (e.onclick = (c) => {
|
|
355
355
|
c.stopPropagation(), navigator.clipboard.writeText(i).then(() => {
|
|
@@ -360,17 +360,17 @@ function z(d) {
|
|
|
360
360
|
});
|
|
361
361
|
},
|
|
362
362
|
d,
|
|
363
|
-
|
|
364
|
-
|
|
363
|
+
a.code,
|
|
364
|
+
a.language
|
|
365
365
|
);
|
|
366
366
|
}
|
|
367
367
|
const H = () => ({
|
|
368
368
|
name: "codeSample",
|
|
369
369
|
toolbar: [
|
|
370
370
|
{
|
|
371
|
-
label: "Code
|
|
371
|
+
label: "Insert Code",
|
|
372
372
|
command: "insertCodeBlock",
|
|
373
|
-
icon: '<svg width="
|
|
373
|
+
icon: '<svg width="24" height="26" focusable="false"><path d="M7.1 11a2.8 2.8 0 0 1-.8 2 2.8 2.8 0 0 1 .8 2v1.7c0 .3.1.6.4.8.2.3.5.4.8.4.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.7 0-1.4-.3-2-.8-.5-.6-.8-1.3-.8-2V15c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4v-.8c0-.2.2-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V9.3c0-.7.3-1.4.8-2 .6-.5 1.3-.8 2-.8.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8V11Zm9.8 0V9.3c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 0 1-.4-.4V7c0-.2.1-.4.4-.4.7 0 1.4.3 2 .8.5.6.8 1.3.8 2V11c0 .3.1.6.4.8.2.3.5.4.8.4.2 0 .4.2.4.4v.8c0 .2-.2.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8v1.7c0 .7-.3 1.4-.8 2-.6.5-1.3.8-2 .8a.4.4 0 0 1-.4-.4v-.8c0-.2.1-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V15a2.8 2.8 0 0 1 .8-2 2.8 2.8 0 0 1-.8-2Zm-3.3-.4c0 .4-.1.8-.5 1.1-.3.3-.7.5-1.1.5-.4 0-.8-.2-1.1-.5-.4-.3-.5-.7-.5-1.1 0-.5.1-.9.5-1.2.3-.3.7-.4 1.1-.4.4 0 .8.1 1.1.4.4.3.5.7.5 1.2ZM12 13c.4 0 .8.1 1.1.5.4.3.5.7.5 1.1 0 1-.1 1.6-.5 2a3 3 0 0 1-1.1 1c-.4.3-.8.4-1.1.4a.5.5 0 0 1-.5-.5V17a3 3 0 0 0 1-.2l.6-.6c-.6 0-1-.2-1.3-.5-.2-.3-.3-.7-.3-1 0-.5.1-1 .5-1.2.3-.4.7-.5 1.1-.5Z" fill-rule="evenodd"></path></svg>',
|
|
374
374
|
shortcut: "Mod-Shift-C"
|
|
375
375
|
}
|
|
376
376
|
],
|
|
@@ -381,4 +381,4 @@ const H = () => ({
|
|
|
381
381
|
export {
|
|
382
382
|
H as CodeSamplePlugin
|
|
383
383
|
};
|
|
384
|
-
//# sourceMappingURL=CodeSamplePlugin.native-
|
|
384
|
+
//# sourceMappingURL=CodeSamplePlugin.native-CgGoH-X4.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const A = ".rte-content, .editora-content";
|
|
2
|
-
const y = "__editoraCommandEditorRoot",
|
|
2
|
+
const y = "__editoraCommandEditorRoot", s = /* @__PURE__ */ new Map(), E = {};
|
|
3
3
|
let T = !1, c = null;
|
|
4
4
|
function N(t) {
|
|
5
5
|
if (!t) return null;
|
|
@@ -52,21 +52,21 @@ function l() {
|
|
|
52
52
|
if (i) return i;
|
|
53
53
|
}
|
|
54
54
|
if (c != null && c.isConnected) return c;
|
|
55
|
-
const o = Array.from(
|
|
55
|
+
const o = Array.from(s.keys()).find((i) => i.isConnected);
|
|
56
56
|
if (o) return o;
|
|
57
57
|
const r = document.querySelector(A);
|
|
58
58
|
return r || document.querySelector('[contenteditable="true"]');
|
|
59
59
|
}
|
|
60
60
|
function L() {
|
|
61
|
-
for (const t of
|
|
62
|
-
t.isConnected || (
|
|
61
|
+
for (const t of s.keys())
|
|
62
|
+
t.isConnected || (s.delete(t), c === t && (c = null));
|
|
63
63
|
}
|
|
64
64
|
function M(t) {
|
|
65
65
|
L();
|
|
66
|
-
let e =
|
|
67
|
-
return e || (e = { undoStack: [], redoStack: [] },
|
|
66
|
+
let e = s.get(t);
|
|
67
|
+
return e || (e = { undoStack: [], redoStack: [] }, s.set(t, e)), e;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function d(t) {
|
|
70
70
|
t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
71
71
|
}
|
|
72
72
|
function h(t) {
|
|
@@ -77,7 +77,7 @@ function m(t, e) {
|
|
|
77
77
|
const n = M(t);
|
|
78
78
|
n.undoStack.push(e), n.redoStack.length = 0, n.undoStack.length > 100 && n.undoStack.splice(0, n.undoStack.length - 100), c = t;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
80
|
+
function v(t, e = "undo") {
|
|
81
81
|
if (L(), t != null && t.isConnected)
|
|
82
82
|
return t;
|
|
83
83
|
const n = l();
|
|
@@ -86,7 +86,7 @@ function x(t, e = "undo") {
|
|
|
86
86
|
if (c != null && c.isConnected)
|
|
87
87
|
return c;
|
|
88
88
|
const o = (r) => e === "undo" ? r.undoStack.length > 0 : r.redoStack.length > 0;
|
|
89
|
-
for (const [r, i] of
|
|
89
|
+
for (const [r, i] of s.entries())
|
|
90
90
|
if (r.isConnected && o(i))
|
|
91
91
|
return r;
|
|
92
92
|
return null;
|
|
@@ -125,7 +125,7 @@ const S = (t, ...e) => {
|
|
|
125
125
|
function C() {
|
|
126
126
|
T || typeof window == "undefined" || (T = !0, window.execEditorCommand || (window.execEditorCommand = S), window.executeEditorCommand || (window.executeEditorCommand = S), u("undo", k), u("redo", O), u("setAttribute", D), u("setText", _), u("autoFixA11y", R), u("recordDomTransaction", I), u("undoDom", b), u("redoDom", p));
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function x(t, e) {
|
|
129
129
|
const n = e || l(), o = h(n);
|
|
130
130
|
n == null || n.focus({ preventScroll: !0 });
|
|
131
131
|
let r = !1;
|
|
@@ -135,14 +135,14 @@ function v(t, e) {
|
|
|
135
135
|
r = !1;
|
|
136
136
|
}
|
|
137
137
|
const i = h(n), a = o !== i;
|
|
138
|
-
return a &&
|
|
138
|
+
return a && d(n), { executed: r, changed: a };
|
|
139
139
|
}
|
|
140
140
|
const k = () => {
|
|
141
141
|
const t = l();
|
|
142
|
-
return
|
|
142
|
+
return x("undo", t).changed ? !0 : b(t != null ? t : void 0);
|
|
143
143
|
}, O = () => {
|
|
144
144
|
const t = l();
|
|
145
|
-
return
|
|
145
|
+
return x("redo", t).changed ? !0 : p(t != null ? t : void 0);
|
|
146
146
|
}, D = (t, e, n) => {
|
|
147
147
|
if (!(t instanceof HTMLElement)) return;
|
|
148
148
|
const o = f(t), r = t.hasAttribute(e), i = t.getAttribute(e);
|
|
@@ -153,7 +153,7 @@ const k = () => {
|
|
|
153
153
|
redo: () => {
|
|
154
154
|
t.isConnected && t.setAttribute(e, n);
|
|
155
155
|
}
|
|
156
|
-
}),
|
|
156
|
+
}), d(o);
|
|
157
157
|
}, _ = (t, e) => {
|
|
158
158
|
var r;
|
|
159
159
|
if (!(t instanceof HTMLElement)) return;
|
|
@@ -165,7 +165,7 @@ const k = () => {
|
|
|
165
165
|
redo: () => {
|
|
166
166
|
t.isConnected && (t.textContent = e);
|
|
167
167
|
}
|
|
168
|
-
}),
|
|
168
|
+
}), d(n);
|
|
169
169
|
}, R = (t) => {
|
|
170
170
|
var a;
|
|
171
171
|
const e = t == null ? void 0 : t.element;
|
|
@@ -182,7 +182,7 @@ const k = () => {
|
|
|
182
182
|
redo: () => {
|
|
183
183
|
e.isConnected && w(e, i);
|
|
184
184
|
}
|
|
185
|
-
}),
|
|
185
|
+
}), d(n);
|
|
186
186
|
}, I = (t, e, n) => {
|
|
187
187
|
if (!(t instanceof HTMLElement)) return !1;
|
|
188
188
|
const o = typeof n == "string" ? n : t.innerHTML;
|
|
@@ -195,15 +195,15 @@ const k = () => {
|
|
|
195
195
|
}
|
|
196
196
|
}), !0);
|
|
197
197
|
}, b = (t) => {
|
|
198
|
-
const e =
|
|
198
|
+
const e = v(t, "undo");
|
|
199
199
|
if (!e) return !1;
|
|
200
200
|
const n = M(e), o = n.undoStack.pop();
|
|
201
|
-
return o ? (o.undo(), n.redoStack.push(o), c = e,
|
|
201
|
+
return o ? (o.undo(), n.redoStack.push(o), c = e, d(e), !0) : !1;
|
|
202
202
|
}, p = (t) => {
|
|
203
|
-
const e =
|
|
203
|
+
const e = v(t, "redo");
|
|
204
204
|
if (!e) return !1;
|
|
205
205
|
const n = M(e), o = n.redoStack.pop();
|
|
206
|
-
return o ? (o.redo(), n.undoStack.push(o), c = e,
|
|
206
|
+
return o ? (o.redo(), n.undoStack.push(o), c = e, d(e), !0) : !1;
|
|
207
207
|
};
|
|
208
208
|
typeof window != "undefined" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", C, { once: !0 }) : C());
|
|
209
209
|
const Y = () => (C(), {
|
|
@@ -254,4 +254,4 @@ export {
|
|
|
254
254
|
k as undo,
|
|
255
255
|
b as undoDom
|
|
256
256
|
};
|
|
257
|
-
//# sourceMappingURL=HistoryPlugin.native-
|
|
257
|
+
//# sourceMappingURL=HistoryPlugin.native-TDnVMsEO.mjs.map
|
|
@@ -32,10 +32,13 @@ const D = {
|
|
|
32
32
|
tags: []
|
|
33
33
|
}
|
|
34
34
|
}, v = ".rte-content, .editora-content", K = '[data-theme="dark"], .dark, .editora-theme-dark', A = Object.keys(D), Y = A.reduce(
|
|
35
|
-
(t, e) => (t[e] = D[e].tags.map((r) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
(t, e) => (t[e] = D[e].tags.map((r) => {
|
|
36
|
+
var n;
|
|
37
|
+
return {
|
|
38
|
+
...r,
|
|
39
|
+
searchIndex: `${r.label} ${r.key} ${r.category} ${"description" in r && (n = r.description) != null ? n : ""}`.toLowerCase()
|
|
40
|
+
};
|
|
41
|
+
}), t),
|
|
39
42
|
{}
|
|
40
43
|
);
|
|
41
44
|
let j = !1, H = !1, E = null, w = null, k = null, P = !1;
|
|
@@ -413,4 +416,4 @@ const ce = () => ({
|
|
|
413
416
|
export {
|
|
414
417
|
ce as MergeTagPlugin
|
|
415
418
|
};
|
|
416
|
-
//# sourceMappingURL=MergeTagPlugin.native-
|
|
419
|
+
//# sourceMappingURL=MergeTagPlugin.native-DIGWhdnF.mjs.map
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./index-CqWQFb3D.js");class v{constructor(e){if(this.listeners=[],e instanceof l.PluginManager)this.pluginManager=e;else{const i=e;this.pluginManager=new l.PluginManager,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(n=>{this.pluginManager.register(n)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const t=this.pluginManager.buildSchema();this.state=l.EditorState.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(i=>{i.shortcut&&(t[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(i.ctrlKey||i.metaKey)&&n.push("ctrl"),i.shiftKey&&n.push("shift"),i.altKey&&n.push("alt");const o=i.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${o}`:o,a=t[s];a&&(i.preventDefault(),this.execCommand(a))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(o=>o.id&&o.id===e||o.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const i=this.commands[e];if(!i)return console.warn(`Command not found: ${e}`),!1;let n;return t!==void 0?n=i(this.state,t):n=i(this.state),n instanceof Promise?(n.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&this.setState(o)}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=null}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class b{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const n=(i=this.plugin.commands)==null?void 0:i[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function E(r){return new b(r)}function x(r={}){const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:n={},language:o="en",customDictionary:s=[],ignoreAllCaps:a=!0,ignoreNumbers:c=!0}=r;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:o}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:h=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:h=>(console.log("[Spellcheck] Add to dictionary:",h),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function w(r={}){const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:o={},withCredentials:s=!1,chunkSize:a=1024*1024,enableChunking:c=!0,onProgress:h,onError:u,onSuccess:$}=r;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:d=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async d=>{if(console.log("[Media] Insert image command (not implemented)",d),!d)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(d.type)){const g=new Error(`File type ${d.type} not allowed`);return u==null||u(g),null}if(d.size>i){const g=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(g),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async d=>(console.log("[Media] Upload media (not implemented)",{name:d.name,size:d.size,type:d.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class p{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new p(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new p(this.doc,e)}update(e,t){return new p(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class m{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((i,n)=>`<button type="button" class="editora-btn ${i.type==="danger"?"editora-btn-danger":i.type==="primary"||i.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${i.label}</button>`).join(""):`
|
|
2
2
|
<button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
|
|
3
3
|
<button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
|
|
4
4
|
`;if(e.innerHTML=`
|
package/dist/plugin-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const r = {
|
|
2
|
-
codeSample: () => import("./CodeSamplePlugin.native-
|
|
2
|
+
codeSample: () => import("./CodeSamplePlugin.native-CgGoH-X4.mjs").then((e) => e.CodeSamplePlugin()),
|
|
3
3
|
checklist: () => import("./ChecklistPlugin.native-nuSSEFNI.mjs").then((e) => e.ChecklistPlugin()),
|
|
4
4
|
textAlignment: () => import("./TextAlignmentPlugin.native-sM_1s00t.mjs").then((e) => e.TextAlignmentPlugin()),
|
|
5
5
|
indent: () => import("./IndentPlugin.native-BHixp8sP.mjs").then((e) => e.IndentPlugin()),
|
|
@@ -16,7 +16,7 @@ const r = {
|
|
|
16
16
|
embedIframe: () => import("./EmbedIframePlugin.native-CSWIB1jm.mjs").then((e) => e.EmbedIframePlugin()),
|
|
17
17
|
math: () => import("./MathPlugin.native-KUxz0o8C.mjs").then((e) => e.MathPlugin()),
|
|
18
18
|
image: () => import("./MediaManagerPlugin.native-CgP5iInD.mjs").then((e) => e.MediaManagerPlugin()),
|
|
19
|
-
mergeTag: () => import("./MergeTagPlugin.native-
|
|
19
|
+
mergeTag: () => import("./MergeTagPlugin.native-DIGWhdnF.mjs").then((e) => e.MergeTagPlugin()),
|
|
20
20
|
pageBreak: () => import("./PageBreakPlugin.native-CGiQxXqR.mjs").then((e) => e.PageBreakPlugin()),
|
|
21
21
|
print: () => import("./PrintPlugin.native-7qt5v7L5.mjs").then((e) => e.PrintPlugin()),
|
|
22
22
|
preview: () => import("./PreviewPlugin.native-DBvfpmIv.mjs").then((e) => e.PreviewPlugin()),
|
|
@@ -2209,9 +2209,9 @@ const _ = {
|
|
|
2209
2209
|
clearFormatting: () => import("./ClearFormattingPlugin.native-Bq_XcTh2.mjs").then((s) => s.ClearFormattingPlugin()),
|
|
2210
2210
|
heading: () => import("./HeadingPlugin.native-DrLYwQnQ.mjs").then((s) => s.HeadingPlugin()),
|
|
2211
2211
|
blockquote: () => import("./BlockquotePlugin.native-JFmOLsxN.mjs").then((s) => s.BlockquotePlugin()),
|
|
2212
|
-
code: () => import("./CodePlugin.native-
|
|
2212
|
+
code: () => import("./CodePlugin.native-B263UI8O.mjs").then((s) => s.CodePlugin()),
|
|
2213
2213
|
list: () => import("./ListPlugin.native-V7EZC1lM.mjs").then((s) => s.ListPlugin()),
|
|
2214
|
-
history: () => import("./HistoryPlugin.native-
|
|
2214
|
+
history: () => import("./HistoryPlugin.native-TDnVMsEO.mjs").then((s) => s.HistoryPlugin())
|
|
2215
2215
|
};
|
|
2216
2216
|
async function q() {
|
|
2217
2217
|
return Object.entries(_).forEach(([s, t]) => {
|