@editora/core 1.0.24 → 1.0.25

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.
@@ -0,0 +1,92 @@
1
+ import { e as s } from "./escapeHtml-CX8RelZ1.mjs";
2
+ import { i as x } from "./dialogHelpers-Dzn8DHoF.mjs";
3
+ const g = "rte-confirm-styles", v = '[data-theme="dark"], .dark, .editora-theme-dark';
4
+ let y = 0;
5
+ function h() {
6
+ if (document.getElementById(g)) return;
7
+ const t = document.createElement("style");
8
+ t.id = g, t.textContent = `
9
+ .rte-confirm-overlay {
10
+ position: fixed; inset: 0; z-index: 100002; display: flex; align-items: center; justify-content: center;
11
+ padding: 16px; background: rgba(15, 23, 36, 0.56);
12
+ --rte-confirm-bg: #ffffff; --rte-confirm-text: #101828; --rte-confirm-muted: #5f6b7d; --rte-confirm-border: #d6dbe4;
13
+ --rte-confirm-accent: #1f75fe; --rte-confirm-danger: #c62828;
14
+ }
15
+ .rte-confirm-overlay.rte-confirm-dark {
16
+ --rte-confirm-bg: #1f2937; --rte-confirm-text: #e5e7eb; --rte-confirm-muted: #9ca3af; --rte-confirm-border: #3b4657;
17
+ --rte-confirm-accent: #3b82f6; --rte-confirm-danger: #ef4444;
18
+ }
19
+ .rte-confirm-dialog {
20
+ box-sizing: border-box; width: min(100%, 420px); padding: 20px; border-radius: 10px;
21
+ background: var(--rte-confirm-bg); color: var(--rte-confirm-text); border: 1px solid var(--rte-confirm-border);
22
+ box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35); font-size: 14px; line-height: 1.45;
23
+ }
24
+ .rte-confirm-title { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
25
+ .rte-confirm-message { margin: 0 0 14px; color: var(--rte-confirm-muted); }
26
+ .rte-confirm-field { display: block; margin: 0 0 6px; }
27
+ .rte-confirm-input {
28
+ box-sizing: border-box; width: 100%; padding: 8px 10px; border-radius: 6px; font: inherit;
29
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
30
+ }
31
+ .rte-confirm-input[aria-invalid="true"] { border-color: var(--rte-confirm-danger); }
32
+ .rte-confirm-error { margin: 6px 0 0; color: var(--rte-confirm-danger); font-size: 13px; }
33
+ .rte-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
34
+ .rte-confirm-button {
35
+ padding: 8px 14px; border-radius: 6px; font: inherit; cursor: pointer;
36
+ border: 1px solid var(--rte-confirm-border); background: transparent; color: inherit;
37
+ }
38
+ .rte-confirm-button.primary { background: var(--rte-confirm-accent); border-color: var(--rte-confirm-accent); color: #fff; }
39
+ .rte-confirm-button.danger { background: var(--rte-confirm-danger); border-color: var(--rte-confirm-danger); color: #fff; }
40
+ .rte-confirm-button:focus-visible, .rte-confirm-input:focus-visible { outline: 2px solid var(--rte-confirm-accent); outline-offset: 2px; }
41
+ `, document.head.appendChild(t);
42
+ }
43
+ function k(t, n, d) {
44
+ var a, u, p, b;
45
+ h();
46
+ const r = `rte-confirm-${++y}`, o = document.createElement("div");
47
+ x(o), o.className = "rte-confirm-overlay";
48
+ const c = (a = n.context) != null ? a : document.activeElement instanceof Element ? document.activeElement : null;
49
+ c != null && c.closest(v) && o.classList.add("rte-confirm-dark");
50
+ const f = (u = n.title) != null ? u : "Please confirm", i = (p = n.confirmText) != null ? p : "Confirm", m = (b = n.cancelText) != null ? b : "Cancel", l = n.danger === !0, e = document.createElement("div");
51
+ return e.className = "rte-confirm-dialog", e.setAttribute("role", "alertdialog"), e.setAttribute("aria-modal", "true"), e.setAttribute("aria-labelledby", `${r}-title`), e.setAttribute("aria-describedby", `${r}-message`), e.innerHTML = `
52
+ <h2 class="rte-confirm-title" id="${r}-title">${s(f)}</h2>
53
+ <p class="rte-confirm-message" id="${r}-message">${s(t)}</p>
54
+
55
+ <div class="rte-confirm-actions">
56
+ <button type="button" class="rte-confirm-button" data-action="cancel">${s(m)}</button>
57
+ <button type="button" class="rte-confirm-button ${l ? "danger" : "primary"}" data-action="confirm">${s(i)}</button>
58
+ </div>
59
+ `, o.appendChild(e), {
60
+ overlay: o,
61
+ confirmButton: e.querySelector('[data-action="confirm"]'),
62
+ cancelButton: e.querySelector('[data-action="cancel"]'),
63
+ input: e.querySelector("input"),
64
+ error: e.querySelector(".rte-confirm-error")
65
+ };
66
+ }
67
+ function E(t, n) {
68
+ return new Promise((d) => {
69
+ var l;
70
+ const { overlay: r, confirmButton: o, cancelButton: c } = t;
71
+ let f = !1;
72
+ const i = (e) => {
73
+ const a = n(e);
74
+ a !== void 0 && (f || (f = !0, window.removeEventListener("keydown", m, !0), r.remove(), d(a)));
75
+ }, m = (e) => {
76
+ e.key !== "Escape" || !r.isConnected || (e.preventDefault(), e.stopPropagation(), i(!1));
77
+ };
78
+ window.addEventListener("keydown", m, !0), c.addEventListener("click", () => i(!1)), o.addEventListener("click", () => i(!0)), r.addEventListener("click", (e) => {
79
+ e.target === r && i(!1);
80
+ }), (l = t.input) == null || l.addEventListener("keydown", (e) => {
81
+ e.key === "Enter" && (e.preventDefault(), i(!0));
82
+ }), document.body.appendChild(r);
83
+ });
84
+ }
85
+ function L(t, n = {}) {
86
+ const d = k(t, n);
87
+ return E(d, (r) => r);
88
+ }
89
+ export {
90
+ L as c
91
+ };
92
+ //# sourceMappingURL=confirmDialog-CNqPHT5x.mjs.map