@editora/core 1.0.6 → 1.0.7
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/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
- package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
- package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
- package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
- package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
- package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
- package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
- package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
- package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
- package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
- package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
- package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
- package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
- package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
- package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
- package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
- package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
- package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
- package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
- package/dist/editora.min.js +10 -10
- package/dist/editora.umd.js +10 -10
- package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
- package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
- package/dist/index-BslAFzmv.mjs +16544 -0
- package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
- package/dist/index.esm.js +2 -2
- package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
- package/dist/plugin-loader.js +15 -15
- package/dist/webcomponent-core.js +241 -224
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +86 -106
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +205 -188
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +477 -402
- package/package.json +1 -1
- package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
- package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
- package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
- package/dist/documentManager-irzj9n3V.mjs +0 -37627
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
1
|
+
import { a as v, b as w } from "./anchoredPopover-Bxds0VoB.mjs";
|
|
2
|
+
let l = null, d = null, x = null, i = "#000000";
|
|
3
|
+
const u = '[data-theme="dark"], .dark, .editora-theme-dark', C = [
|
|
4
4
|
"#000000",
|
|
5
5
|
"#ffffff",
|
|
6
6
|
"#808080",
|
|
@@ -14,80 +14,96 @@ const s = '[data-theme="dark"], .dark, .editora-theme-dark', k = [
|
|
|
14
14
|
"#800080",
|
|
15
15
|
"#ffc0cb"
|
|
16
16
|
];
|
|
17
|
-
function
|
|
17
|
+
function y() {
|
|
18
18
|
const e = window.getSelection();
|
|
19
19
|
if (e && e.rangeCount > 0) {
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
20
|
+
const c = e.getRangeAt(0).startContainer, n = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
|
|
21
|
+
if (n) {
|
|
22
|
+
const r = n.closest(
|
|
23
23
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
24
24
|
);
|
|
25
|
-
if (
|
|
25
|
+
if (r) return r;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const o = document.activeElement;
|
|
29
|
+
return o ? o.closest(
|
|
30
30
|
'[data-editora-editor="true"], .rte-editor, .editora-editor'
|
|
31
31
|
) : null;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const t =
|
|
35
|
-
if (t) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
function E(e) {
|
|
34
|
+
const o = window.__editoraLastCommand, t = window.__editoraLastCommandButton;
|
|
35
|
+
if (o === e && t && t.isConnected) {
|
|
36
|
+
const a = window.getComputedStyle(t), s = t.getBoundingClientRect();
|
|
37
|
+
if (a.display !== "none" && a.visibility !== "hidden" && a.pointerEvents !== "none" && !(s.width === 0 && s.height === 0))
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
const c = (a) => {
|
|
41
|
+
for (const s of a) {
|
|
42
|
+
const b = window.getComputedStyle(s), m = s.getBoundingClientRect();
|
|
43
|
+
if (!(b.display === "none" || b.visibility === "hidden" || b.pointerEvents === "none") && !(m.width === 0 && m.height === 0))
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}, n = y();
|
|
48
|
+
if (n) {
|
|
49
|
+
const a = Array.from(
|
|
50
|
+
n.querySelectorAll(`[data-command="${e}"]`)
|
|
51
|
+
), s = c(a);
|
|
52
|
+
if (s) return s;
|
|
40
53
|
}
|
|
41
|
-
|
|
54
|
+
const r = Array.from(
|
|
55
|
+
document.querySelectorAll(`[data-command="${e}"]`)
|
|
56
|
+
);
|
|
57
|
+
return c(r);
|
|
42
58
|
}
|
|
43
|
-
function
|
|
44
|
-
if (e != null && e.closest(
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
59
|
+
function S(e) {
|
|
60
|
+
if (e != null && e.closest(u)) return !0;
|
|
61
|
+
const o = window.getSelection();
|
|
62
|
+
if (o && o.rangeCount > 0) {
|
|
63
|
+
const c = o.getRangeAt(0).startContainer, n = c.nodeType === Node.ELEMENT_NODE ? c : c.parentElement;
|
|
64
|
+
if (n != null && n.closest(u)) return !0;
|
|
49
65
|
}
|
|
50
|
-
const
|
|
51
|
-
return
|
|
66
|
+
const t = document.activeElement;
|
|
67
|
+
return t != null && t.closest(u) ? !0 : document.body.matches(u) || document.documentElement.matches(u);
|
|
52
68
|
}
|
|
53
|
-
function
|
|
54
|
-
return
|
|
69
|
+
function f(e) {
|
|
70
|
+
return v({
|
|
55
71
|
color: e,
|
|
56
72
|
className: "rte-text-color",
|
|
57
73
|
styleProperty: "color",
|
|
58
74
|
commands: ["foreColor"],
|
|
59
|
-
savedRange:
|
|
60
|
-
getActiveEditorRoot:
|
|
75
|
+
savedRange: x,
|
|
76
|
+
getActiveEditorRoot: y,
|
|
61
77
|
warnMessage: "[TextColor] Could not apply color for current selection"
|
|
62
78
|
});
|
|
63
79
|
}
|
|
64
|
-
function
|
|
80
|
+
function T() {
|
|
65
81
|
const e = window.getSelection();
|
|
66
82
|
if (!e || e.rangeCount === 0) return "#000000";
|
|
67
|
-
let
|
|
68
|
-
for (;
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
72
|
-
return
|
|
83
|
+
let t = e.getRangeAt(0).startContainer;
|
|
84
|
+
for (; t && t !== document.body; ) {
|
|
85
|
+
if (t.nodeType === Node.ELEMENT_NODE) {
|
|
86
|
+
const c = t, n = c.style.color || window.getComputedStyle(c).color;
|
|
87
|
+
if (n && n !== "rgb(0, 0, 0)")
|
|
88
|
+
return A(n);
|
|
73
89
|
}
|
|
74
|
-
|
|
90
|
+
t = t.parentNode;
|
|
75
91
|
}
|
|
76
92
|
return "#000000";
|
|
77
93
|
}
|
|
78
|
-
function
|
|
94
|
+
function A(e) {
|
|
79
95
|
if (e.startsWith("#")) return e;
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
const
|
|
83
|
-
return "#" + [
|
|
84
|
-
const
|
|
85
|
-
return
|
|
96
|
+
const o = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
97
|
+
if (!o) return "#000000";
|
|
98
|
+
const t = parseInt(o[1]), c = parseInt(o[2]), n = parseInt(o[3]);
|
|
99
|
+
return "#" + [t, c, n].map((r) => {
|
|
100
|
+
const a = r.toString(16);
|
|
101
|
+
return a.length === 1 ? "0" + a : a;
|
|
86
102
|
}).join("");
|
|
87
103
|
}
|
|
88
|
-
function
|
|
89
|
-
const
|
|
90
|
-
|
|
104
|
+
function L(e) {
|
|
105
|
+
const o = window.getSelection();
|
|
106
|
+
o && o.rangeCount > 0 && (x = o.getRangeAt(0).cloneRange()), i = T(), l = document.createElement("div"), l.className = "rte-inline-color-picker", S(e) && l.classList.add("rte-theme-dark"), l.addEventListener("click", (t) => t.stopPropagation()), l.innerHTML = `
|
|
91
107
|
<div class="rte-color-picker-header">
|
|
92
108
|
<span class="rte-color-picker-title">Text Color</span>
|
|
93
109
|
<button class="rte-color-picker-close" aria-label="Close">×</button>
|
|
@@ -104,13 +120,13 @@ function E(e) {
|
|
|
104
120
|
<div class="rte-color-section">
|
|
105
121
|
<label class="rte-color-section-label">Colors</label>
|
|
106
122
|
<div class="rte-color-palette">
|
|
107
|
-
${
|
|
123
|
+
${C.map((t) => `
|
|
108
124
|
<button
|
|
109
|
-
class="rte-color-swatch ${i ===
|
|
110
|
-
style="background-color: ${
|
|
111
|
-
data-color="${
|
|
112
|
-
title="${
|
|
113
|
-
aria-label="${
|
|
125
|
+
class="rte-color-swatch ${i === t ? "selected" : ""}"
|
|
126
|
+
style="background-color: ${t}; ${t === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
|
|
127
|
+
data-color="${t}"
|
|
128
|
+
title="${t.toUpperCase()}"
|
|
129
|
+
aria-label="${t.toUpperCase()}"
|
|
114
130
|
></button>
|
|
115
131
|
`).join("")}
|
|
116
132
|
</div>
|
|
@@ -137,73 +153,73 @@ function E(e) {
|
|
|
137
153
|
</div>
|
|
138
154
|
</div>
|
|
139
155
|
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
`, document.body.appendChild(l), d && (d.destroy(), d = null), d = w({
|
|
157
|
+
popover: l,
|
|
158
|
+
anchor: e,
|
|
159
|
+
onClose: p,
|
|
160
|
+
gap: 4,
|
|
161
|
+
margin: 8,
|
|
162
|
+
zIndex: 1e4
|
|
163
|
+
}), P();
|
|
143
164
|
}
|
|
144
|
-
function
|
|
145
|
-
if (!
|
|
146
|
-
const e =
|
|
147
|
-
e == null || e.addEventListener("click", () =>
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
165
|
+
function P() {
|
|
166
|
+
if (!l) return;
|
|
167
|
+
const e = l.querySelector(".rte-color-picker-close");
|
|
168
|
+
e == null || e.addEventListener("click", () => p()), l.querySelectorAll(".rte-color-swatch").forEach((n) => {
|
|
169
|
+
n.addEventListener("click", () => {
|
|
170
|
+
const r = n.getAttribute("data-color");
|
|
171
|
+
r && (i = r, f(r), p());
|
|
151
172
|
});
|
|
152
173
|
});
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
i =
|
|
174
|
+
const t = l.querySelector(".rte-color-input-native");
|
|
175
|
+
t == null || t.addEventListener("change", (n) => {
|
|
176
|
+
const r = n.target.value;
|
|
177
|
+
i = r, f(r), p();
|
|
157
178
|
});
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
162
|
-
}),
|
|
163
|
-
const
|
|
164
|
-
i =
|
|
165
|
-
}),
|
|
166
|
-
const
|
|
167
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
179
|
+
const c = l.querySelector(".rte-color-input-text");
|
|
180
|
+
c == null || c.addEventListener("change", (n) => {
|
|
181
|
+
const r = n.target.value;
|
|
182
|
+
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, f(r), p());
|
|
183
|
+
}), t == null || t.addEventListener("input", (n) => {
|
|
184
|
+
const r = n.target.value;
|
|
185
|
+
i = r, h(r), k(r), _(r);
|
|
186
|
+
}), c == null || c.addEventListener("input", (n) => {
|
|
187
|
+
const r = n.target.value;
|
|
188
|
+
/^#[0-9A-Fa-f]{6}$/.test(r) && (i = r, h(r), k(r), $(r));
|
|
168
189
|
});
|
|
169
190
|
}
|
|
170
|
-
function
|
|
171
|
-
if (!
|
|
172
|
-
const
|
|
173
|
-
|
|
191
|
+
function h(e) {
|
|
192
|
+
if (!l) return;
|
|
193
|
+
const o = l.querySelector(".rte-color-preview-box"), t = l.querySelector(".rte-color-preview-label");
|
|
194
|
+
o && (o.style.backgroundColor = e, o.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), t && (t.textContent = e.toUpperCase());
|
|
174
195
|
}
|
|
175
|
-
function
|
|
176
|
-
if (!
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
function k(e) {
|
|
197
|
+
if (!l) return;
|
|
198
|
+
l.querySelectorAll(".rte-color-swatch").forEach((t) => {
|
|
199
|
+
t.getAttribute("data-color") === e ? t.classList.add("selected") : t.classList.remove("selected");
|
|
179
200
|
});
|
|
180
201
|
}
|
|
181
|
-
function
|
|
182
|
-
if (!
|
|
183
|
-
const
|
|
184
|
-
|
|
202
|
+
function $(e) {
|
|
203
|
+
if (!l) return;
|
|
204
|
+
const o = l.querySelector(".rte-color-input-native");
|
|
205
|
+
o && (o.value = e);
|
|
185
206
|
}
|
|
186
|
-
function
|
|
187
|
-
if (!
|
|
188
|
-
const
|
|
189
|
-
|
|
207
|
+
function _(e) {
|
|
208
|
+
if (!l) return;
|
|
209
|
+
const o = l.querySelector(".rte-color-input-text");
|
|
210
|
+
o && (o.value = e);
|
|
190
211
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
212
|
+
function p() {
|
|
213
|
+
d && (d.destroy(), d = null), l && (l.remove(), l = null), x = null;
|
|
193
214
|
}
|
|
194
|
-
function
|
|
195
|
-
if (
|
|
196
|
-
return
|
|
197
|
-
const e =
|
|
198
|
-
return e ? (
|
|
215
|
+
function R() {
|
|
216
|
+
if (g(), l)
|
|
217
|
+
return p(), !0;
|
|
218
|
+
const e = E("openTextColorPicker");
|
|
219
|
+
return e ? (L(e), !0) : !1;
|
|
199
220
|
}
|
|
200
221
|
function g() {
|
|
201
|
-
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, document.
|
|
202
|
-
if (r && p) {
|
|
203
|
-
const t = e.target;
|
|
204
|
-
!r.contains(t) && !p.contains(t) && a();
|
|
205
|
-
}
|
|
206
|
-
}), !document.getElementById("text-color-plugin-styles"))) {
|
|
222
|
+
if (!window.__textColorPluginInitialized && (window.__textColorPluginInitialized = !0, !document.getElementById("text-color-plugin-styles"))) {
|
|
207
223
|
const e = document.createElement("style");
|
|
208
224
|
e.id = "text-color-plugin-styles", e.textContent = `
|
|
209
225
|
.rte-inline-color-picker {
|
|
@@ -458,7 +474,7 @@ function g() {
|
|
|
458
474
|
}
|
|
459
475
|
}
|
|
460
476
|
document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", g) : setTimeout(g, 100);
|
|
461
|
-
const
|
|
477
|
+
const M = () => ({
|
|
462
478
|
name: "textColor",
|
|
463
479
|
marks: {
|
|
464
480
|
textColor: {
|
|
@@ -469,24 +485,24 @@ const A = () => ({
|
|
|
469
485
|
{
|
|
470
486
|
tag: "span[style*=color]",
|
|
471
487
|
getAttrs: (e) => {
|
|
472
|
-
const
|
|
473
|
-
return
|
|
488
|
+
const t = (e.getAttribute("style") || "").match(/color:\s*([^;]+)/);
|
|
489
|
+
return t ? { color: t[1] } : null;
|
|
474
490
|
}
|
|
475
491
|
},
|
|
476
492
|
{
|
|
477
493
|
tag: "font[color]",
|
|
478
494
|
getAttrs: (e) => {
|
|
479
|
-
const
|
|
480
|
-
return
|
|
495
|
+
const o = e.getAttribute("color");
|
|
496
|
+
return o ? { color: o } : null;
|
|
481
497
|
}
|
|
482
498
|
}
|
|
483
499
|
],
|
|
484
500
|
toDOM: (e) => {
|
|
485
|
-
var
|
|
501
|
+
var o;
|
|
486
502
|
return [
|
|
487
503
|
"span",
|
|
488
504
|
{
|
|
489
|
-
style: `color: ${((
|
|
505
|
+
style: `color: ${((o = e.attrs) == null ? void 0 : o.color) || "#000000"}`,
|
|
490
506
|
class: "rte-text-color"
|
|
491
507
|
},
|
|
492
508
|
0
|
|
@@ -502,12 +518,12 @@ const A = () => ({
|
|
|
502
518
|
}
|
|
503
519
|
],
|
|
504
520
|
commands: {
|
|
505
|
-
openTextColorPicker: () =>
|
|
506
|
-
setTextColor: (e) => e ?
|
|
521
|
+
openTextColorPicker: () => R(),
|
|
522
|
+
setTextColor: (e) => e ? f(e) : !1
|
|
507
523
|
},
|
|
508
524
|
keymap: {}
|
|
509
525
|
});
|
|
510
526
|
export {
|
|
511
|
-
|
|
527
|
+
M as TextColorPlugin
|
|
512
528
|
};
|
|
513
|
-
//# sourceMappingURL=TextColorPlugin.native-
|
|
529
|
+
//# sourceMappingURL=TextColorPlugin.native-Bwl_bSmc.mjs.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function c(e) {
|
|
2
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
3
|
+
}
|
|
4
|
+
function a(e) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(e, "__esModule")) return e;
|
|
6
|
+
var n = e.default;
|
|
7
|
+
if (typeof n == "function") {
|
|
8
|
+
var t = function r() {
|
|
9
|
+
var o = !1;
|
|
10
|
+
try {
|
|
11
|
+
o = this instanceof r;
|
|
12
|
+
} catch (u) {
|
|
13
|
+
}
|
|
14
|
+
return o ? Reflect.construct(n, arguments, this.constructor) : n.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
t.prototype = n.prototype;
|
|
17
|
+
} else t = {};
|
|
18
|
+
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(e).forEach(function(r) {
|
|
19
|
+
var o = Object.getOwnPropertyDescriptor(e, r);
|
|
20
|
+
Object.defineProperty(t, r, o.get ? o : {
|
|
21
|
+
enumerable: !0,
|
|
22
|
+
get: function() {
|
|
23
|
+
return e[r];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}), t;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
c as a,
|
|
30
|
+
a as g
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=_commonjsHelpers-DOllISpa.mjs.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const b = "p,div,li,ul,ol,table,thead,tbody,tfoot,tr,td,th,h1,h2,h3,h4,h5,h6,blockquote,pre";
|
|
2
|
+
function p(e) {
|
|
3
|
+
return !!e.cloneContents().querySelector(b);
|
|
4
|
+
}
|
|
5
|
+
function v(e, n) {
|
|
6
|
+
var r, o;
|
|
7
|
+
const t = (e == null ? void 0 : e.nodeType) === Node.ELEMENT_NODE ? e : (r = e == null ? void 0 : e.parentElement) != null ? r : null;
|
|
8
|
+
return (t == null ? void 0 : t.closest('[contenteditable="true"]')) || ((o = n()) == null ? void 0 : o.querySelector('[contenteditable="true"]')) || document.querySelector('[contenteditable="true"]');
|
|
9
|
+
}
|
|
10
|
+
function C(e, n) {
|
|
11
|
+
const t = v(e, n);
|
|
12
|
+
t && t.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
13
|
+
}
|
|
14
|
+
function A(e, n) {
|
|
15
|
+
let r = e.startContainer.nodeType === Node.TEXT_NODE ? e.startContainer.parentElement : e.startContainer;
|
|
16
|
+
for (; r && r !== document.body; ) {
|
|
17
|
+
if (r.classList.contains(n)) {
|
|
18
|
+
const o = document.createRange();
|
|
19
|
+
if (o.selectNodeContents(r), o.compareBoundaryPoints(Range.START_TO_START, e) <= 0 && o.compareBoundaryPoints(Range.END_TO_END, e) >= 0)
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
r = r.parentElement;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
function N(e) {
|
|
27
|
+
try {
|
|
28
|
+
if (e.savedRange) {
|
|
29
|
+
const c = window.getSelection();
|
|
30
|
+
c && (c.removeAllRanges(), c.addRange(e.savedRange.cloneRange()));
|
|
31
|
+
}
|
|
32
|
+
const n = window.getSelection();
|
|
33
|
+
if (!n || n.rangeCount === 0 || n.isCollapsed)
|
|
34
|
+
return !1;
|
|
35
|
+
const t = n.getRangeAt(0);
|
|
36
|
+
if (t.collapsed)
|
|
37
|
+
return !1;
|
|
38
|
+
const r = A(t, e.className);
|
|
39
|
+
if (r)
|
|
40
|
+
return e.styleProperty === "backgroundColor" ? r.style.backgroundColor = e.color : r.style.color = e.color, C(r, e.getActiveEditorRoot), !0;
|
|
41
|
+
const o = v(
|
|
42
|
+
t.commonAncestorContainer,
|
|
43
|
+
e.getActiveEditorRoot
|
|
44
|
+
);
|
|
45
|
+
o == null || o.focus({ preventScroll: !0 });
|
|
46
|
+
try {
|
|
47
|
+
document.execCommand("styleWithCSS", !1, "true");
|
|
48
|
+
} catch (c) {
|
|
49
|
+
}
|
|
50
|
+
let l = !1;
|
|
51
|
+
if (e.commands.forEach((c) => {
|
|
52
|
+
l || (l = document.execCommand(c, !1, e.color));
|
|
53
|
+
}), !l && !p(t)) {
|
|
54
|
+
const c = document.createElement("span");
|
|
55
|
+
e.styleProperty === "backgroundColor" ? c.style.backgroundColor = e.color : c.style.color = e.color, c.className = e.className;
|
|
56
|
+
const a = t.extractContents();
|
|
57
|
+
c.appendChild(a), t.insertNode(c), t.setStartAfter(c), t.collapse(!0), n.removeAllRanges(), n.addRange(t), l = !0;
|
|
58
|
+
}
|
|
59
|
+
return l ? (C(t.commonAncestorContainer, e.getActiveEditorRoot), !0) : (e.warnMessage && console.warn(e.warnMessage), !1);
|
|
60
|
+
} catch (n) {
|
|
61
|
+
return e.warnMessage ? console.error(e.warnMessage, n) : console.error("[ColorApply] Failed to apply color", n), !1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function T({
|
|
65
|
+
popover: e,
|
|
66
|
+
anchor: n,
|
|
67
|
+
onClose: t,
|
|
68
|
+
gap: r = 6,
|
|
69
|
+
margin: o = 8,
|
|
70
|
+
zIndex: l = 1e4
|
|
71
|
+
}) {
|
|
72
|
+
e.style.position = "fixed", e.style.zIndex = `${l}`, e.style.visibility = "hidden";
|
|
73
|
+
const c = () => {
|
|
74
|
+
if (!e.isConnected || !n.isConnected) {
|
|
75
|
+
t();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const s = n.getBoundingClientRect();
|
|
79
|
+
if (s.width === 0 && s.height === 0) {
|
|
80
|
+
t();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const i = e.getBoundingClientRect(), w = i.width || e.offsetWidth || 220, f = i.height || e.offsetHeight || 260, y = window.innerWidth, E = window.innerHeight;
|
|
84
|
+
let u = s.left, d = s.bottom + r;
|
|
85
|
+
if (u + w > y - o && (u = y - w - o), u = Math.max(o, u), d + f > E - o) {
|
|
86
|
+
const g = s.top - f - r;
|
|
87
|
+
g >= o ? d = g : d = Math.max(o, E - f - o);
|
|
88
|
+
}
|
|
89
|
+
d < o && (d = o), e.style.left = `${Math.round(u)}px`, e.style.top = `${Math.round(d)}px`, e.style.visibility = "visible";
|
|
90
|
+
}, a = () => {
|
|
91
|
+
c();
|
|
92
|
+
}, h = (s) => {
|
|
93
|
+
const i = s.target;
|
|
94
|
+
i && (e.contains(i) || n.contains(i) || t());
|
|
95
|
+
}, m = (s) => {
|
|
96
|
+
s.key === "Escape" && t();
|
|
97
|
+
};
|
|
98
|
+
window.addEventListener("resize", a), window.addEventListener("scroll", a, !0), document.addEventListener("keydown", m);
|
|
99
|
+
const R = window.requestAnimationFrame(() => {
|
|
100
|
+
document.addEventListener("mousedown", h, !0);
|
|
101
|
+
});
|
|
102
|
+
return c(), { reposition: c, destroy: () => {
|
|
103
|
+
window.cancelAnimationFrame(R), window.removeEventListener("resize", a), window.removeEventListener("scroll", a, !0), document.removeEventListener("keydown", m), document.removeEventListener("mousedown", h, !0);
|
|
104
|
+
} };
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
N as a,
|
|
108
|
+
T as b
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=anchoredPopover-Bxds0VoB.mjs.map
|