@editora/core 1.0.5 → 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.
Files changed (43) hide show
  1. package/dist/{AnchorPlugin.native-C1Rw5m04.mjs → AnchorPlugin.native-BcYGEtd9.mjs} +129 -105
  2. package/dist/{BackgroundColorPlugin.native-BE-p9DRd.mjs → BackgroundColorPlugin.native-50iAT9xU.mjs} +119 -122
  3. package/dist/CodePlugin.native-DlpTPdkd.mjs +2691 -0
  4. package/dist/{CommentsPlugin.native-tMnWn8a2.mjs → CommentsPlugin.native-DPSqTkiv.mjs} +153 -135
  5. package/dist/{DocumentManagerPlugin.native-BvZL5CSG.mjs → DocumentManagerPlugin.native-C2cs_1w4.mjs} +43 -43
  6. package/dist/{EmbedIframePlugin.native-CSWIB1jm.mjs → EmbedIframePlugin.native-DKJx2OS7.mjs} +61 -58
  7. package/dist/{EmojisPlugin.native-DxTm_DL-.mjs → EmojisPlugin.native-CitxxlWX.mjs} +135 -104
  8. package/dist/{LinkPlugin.native-CS2g-G18.mjs → LinkPlugin.native-DYCIcdTm.mjs} +47 -45
  9. package/dist/{MathPlugin.native-KUxz0o8C.mjs → MathPlugin.native-f_mDp8VL.mjs} +149 -108
  10. package/dist/{MediaManagerPlugin.native-CgP5iInD.mjs → MediaManagerPlugin.native-BiXiK8FC.mjs} +238 -217
  11. package/dist/MergeTagPlugin.native-C3eOfEgw.mjs +559 -0
  12. package/dist/{PageBreakPlugin.native-CGiQxXqR.mjs → PageBreakPlugin.native-CXdX5fAv.mjs} +77 -68
  13. package/dist/{SpecialCharactersPlugin.native-DANrbExJ.mjs → SpecialCharactersPlugin.native-CZDato89.mjs} +143 -98
  14. package/dist/{SpellCheckPlugin.native-C8bPvRHy.mjs → SpellCheckPlugin.native-BZB9AewP.mjs} +239 -219
  15. package/dist/{TemplatePlugin.native-4lKEm-WY.mjs → TemplatePlugin.native-CrpfKRJ8.mjs} +167 -143
  16. package/dist/{TextColorPlugin.native-Clgtb50j.mjs → TextColorPlugin.native-Bwl_bSmc.mjs} +134 -118
  17. package/dist/_commonjsHelpers-DOllISpa.mjs +32 -0
  18. package/dist/anchoredPopover-Bxds0VoB.mjs +110 -0
  19. package/dist/documentManager-vQ1VkbUY.mjs +8418 -0
  20. package/dist/editora.min.js +10 -10
  21. package/dist/editora.umd.js +10 -10
  22. package/dist/html2canvas.esm-AYkPY5LS.mjs +4803 -0
  23. package/dist/{index-CqWQFb3D.js → index-BpE6GFbz.js} +4 -4
  24. package/dist/index-BslAFzmv.mjs +16544 -0
  25. package/dist/{index-OwnkG39N.mjs → index-yzU4NdPT.mjs} +200 -183
  26. package/dist/index.cjs.js +1 -1
  27. package/dist/{index.es-CuicffkQ.mjs → index.es-BYD2KEo6.mjs} +5 -4
  28. package/dist/index.esm.js +2 -2
  29. package/dist/jspdf.es.min-BJGtOnRT.mjs +7890 -0
  30. package/dist/plugin-loader.js +15 -15
  31. package/dist/webcomponent-core.js +241 -224
  32. package/dist/webcomponent-core.min.css +1 -1
  33. package/dist/webcomponent-core.min.js +86 -106
  34. package/dist/webcomponent.cjs.js +1 -1
  35. package/dist/webcomponent.esm.js +1 -1
  36. package/dist/webcomponent.js +205 -188
  37. package/dist/webcomponent.min.css +1 -1
  38. package/dist/webcomponent.min.js +477 -402
  39. package/package.json +16 -10
  40. package/dist/CodePlugin.native-B263UI8O.mjs +0 -2173
  41. package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +0 -419
  42. package/dist/colorSelectionApply-CK1My9N2.mjs +0 -67
  43. package/dist/documentManager-irzj9n3V.mjs +0 -37627
@@ -1,6 +1,6 @@
1
- import { a as h } from "./colorSelectionApply-CK1My9N2.mjs";
2
- let r = null, p = null, f = null, i = "#000000";
3
- const s = '[data-theme="dark"], .dark, .editora-theme-dark', k = [
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 m() {
17
+ function y() {
18
18
  const e = window.getSelection();
19
19
  if (e && e.rangeCount > 0) {
20
- const l = e.getRangeAt(0).startContainer, c = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
21
- if (c) {
22
- const n = c.closest(
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 (n) return n;
25
+ if (r) return r;
26
26
  }
27
27
  }
28
- const t = document.activeElement;
29
- return t ? t.closest(
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 y(e) {
34
- const t = m();
35
- if (t) {
36
- const o = t.querySelector(
37
- `[data-command="${e}"]`
38
- );
39
- if (o) return o;
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
- return document.querySelector(`[data-command="${e}"]`);
54
+ const r = Array.from(
55
+ document.querySelectorAll(`[data-command="${e}"]`)
56
+ );
57
+ return c(r);
42
58
  }
43
- function v(e) {
44
- if (e != null && e.closest(s)) return !0;
45
- const t = window.getSelection();
46
- if (t && t.rangeCount > 0) {
47
- const l = t.getRangeAt(0).startContainer, c = l.nodeType === Node.ELEMENT_NODE ? l : l.parentElement;
48
- if (c != null && c.closest(s)) return !0;
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 o = document.activeElement;
51
- return o != null && o.closest(s) ? !0 : document.body.matches(s) || document.documentElement.matches(s);
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 d(e) {
54
- return h({
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: f,
60
- getActiveEditorRoot: m,
75
+ savedRange: x,
76
+ getActiveEditorRoot: y,
61
77
  warnMessage: "[TextColor] Could not apply color for current selection"
62
78
  });
63
79
  }
64
- function w() {
80
+ function T() {
65
81
  const e = window.getSelection();
66
82
  if (!e || e.rangeCount === 0) return "#000000";
67
- let o = e.getRangeAt(0).startContainer;
68
- for (; o && o !== document.body; ) {
69
- if (o.nodeType === Node.ELEMENT_NODE) {
70
- const l = o, c = l.style.color || window.getComputedStyle(l).color;
71
- if (c && c !== "rgb(0, 0, 0)")
72
- return C(c);
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
- o = o.parentNode;
90
+ t = t.parentNode;
75
91
  }
76
92
  return "#000000";
77
93
  }
78
- function C(e) {
94
+ function A(e) {
79
95
  if (e.startsWith("#")) return e;
80
- const t = e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
81
- if (!t) return "#000000";
82
- const o = parseInt(t[1]), l = parseInt(t[2]), c = parseInt(t[3]);
83
- return "#" + [o, l, c].map((n) => {
84
- const u = n.toString(16);
85
- return u.length === 1 ? "0" + u : u;
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 E(e) {
89
- const t = window.getSelection();
90
- t && t.rangeCount > 0 && (f = t.getRangeAt(0).cloneRange()), i = w(), r = document.createElement("div"), r.className = "rte-inline-color-picker", v(e) && r.classList.add("rte-theme-dark"), r.addEventListener("click", (l) => l.stopPropagation()), r.innerHTML = `
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
- ${k.map((l) => `
123
+ ${C.map((t) => `
108
124
  <button
109
- class="rte-color-swatch ${i === l ? "selected" : ""}"
110
- style="background-color: ${l}; ${l === "#ffffff" ? "border: 1px solid #ccc;" : ""}"
111
- data-color="${l}"
112
- title="${l.toUpperCase()}"
113
- aria-label="${l.toUpperCase()}"
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
- const o = e.getBoundingClientRect();
142
- r.style.position = "absolute", r.style.top = `${o.bottom + window.scrollY + 4}px`, r.style.left = `${o.left + window.scrollX}px`, r.style.zIndex = "10000", document.body.appendChild(r), p = e, T();
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 T() {
145
- if (!r) return;
146
- const e = r.querySelector(".rte-color-picker-close");
147
- e == null || e.addEventListener("click", () => a()), r.querySelectorAll(".rte-color-swatch").forEach((c) => {
148
- c.addEventListener("click", () => {
149
- const n = c.getAttribute("data-color");
150
- n && (i = n, d(n), a());
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 o = r.querySelector(".rte-color-input-native");
154
- o == null || o.addEventListener("change", (c) => {
155
- const n = c.target.value;
156
- i = n, d(n), a();
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 l = r.querySelector(".rte-color-input-text");
159
- l == null || l.addEventListener("change", (c) => {
160
- const n = c.target.value;
161
- /^#[0-9A-Fa-f]{6}$/.test(n) && (i = n, d(n), a());
162
- }), o == null || o.addEventListener("input", (c) => {
163
- const n = c.target.value;
164
- i = n, x(n), b(n), L(n);
165
- }), l == null || l.addEventListener("input", (c) => {
166
- const n = c.target.value;
167
- /^#[0-9A-Fa-f]{6}$/.test(n) && (i = n, x(n), b(n), S(n));
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 x(e) {
171
- if (!r) return;
172
- const t = r.querySelector(".rte-color-preview-box"), o = r.querySelector(".rte-color-preview-label");
173
- t && (t.style.backgroundColor = e, t.style.border = e === "#ffffff" ? "1px solid #ccc" : "none"), o && (o.textContent = e.toUpperCase());
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 b(e) {
176
- if (!r) return;
177
- r.querySelectorAll(".rte-color-swatch").forEach((o) => {
178
- o.getAttribute("data-color") === e ? o.classList.add("selected") : o.classList.remove("selected");
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 S(e) {
182
- if (!r) return;
183
- const t = r.querySelector(".rte-color-input-native");
184
- t && (t.value = e);
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 L(e) {
187
- if (!r) return;
188
- const t = r.querySelector(".rte-color-input-text");
189
- t && (t.value = e);
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 a() {
192
- r && (r.remove(), r = null), p = null, f = null;
212
+ function p() {
213
+ d && (d.destroy(), d = null), l && (l.remove(), l = null), x = null;
193
214
  }
194
- function $() {
195
- if (r)
196
- return a(), !0;
197
- const e = y("openTextColorPicker");
198
- return e ? (E(e), !0) : !1;
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.addEventListener("click", (e) => {
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 A = () => ({
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 o = (e.getAttribute("style") || "").match(/color:\s*([^;]+)/);
473
- return o ? { color: o[1] } : null;
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 t = e.getAttribute("color");
480
- return t ? { color: t } : null;
495
+ const o = e.getAttribute("color");
496
+ return o ? { color: o } : null;
481
497
  }
482
498
  }
483
499
  ],
484
500
  toDOM: (e) => {
485
- var t;
501
+ var o;
486
502
  return [
487
503
  "span",
488
504
  {
489
- style: `color: ${((t = e.attrs) == null ? void 0 : t.color) || "#000000"}`,
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 ? d(e) : !1
521
+ openTextColorPicker: () => R(),
522
+ setTextColor: (e) => e ? f(e) : !1
507
523
  },
508
524
  keymap: {}
509
525
  });
510
526
  export {
511
- A as TextColorPlugin
527
+ M as TextColorPlugin
512
528
  };
513
- //# sourceMappingURL=TextColorPlugin.native-Clgtb50j.mjs.map
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