@editora/core 1.0.3 → 1.0.5
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 +34 -0
- package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
- package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
- package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
- package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-B263UI8O.mjs} +624 -473
- package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +384 -0
- package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
- package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
- package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
- package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
- package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
- package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
- package/dist/HistoryPlugin.native-TDnVMsEO.mjs +257 -0
- package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
- package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
- package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
- package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
- package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
- package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
- package/dist/MergeTagPlugin.native-DIGWhdnF.mjs +419 -0
- package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
- package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
- package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
- package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
- package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
- package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
- package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
- package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
- package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
- package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
- package/dist/core.css +1 -1
- package/dist/editora.min.js +31 -29
- package/dist/editora.umd.js +31 -29
- package/dist/index-CqWQFb3D.js +10 -0
- package/dist/index-OwnkG39N.mjs +2227 -0
- package/dist/index.cjs.js +14 -18
- package/dist/index.esm.js +204 -521
- package/dist/plugin-loader.js +26 -26
- package/dist/webcomponent-core.js +1286 -295
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +111 -78
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +1252 -261
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +3552 -2037
- package/index.d.ts +355 -0
- package/package.json +21 -18
- package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
- package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
- package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
- package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
- package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
- package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
- package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
- package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
- package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
- package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
- package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
- package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
- package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
- package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
- package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
- package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
- package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
- package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
- package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
- package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
- package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
- package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
- package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
- package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
- package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
- package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
- package/dist/documentManager-irzj9n3V.mjs.map +0 -1
- package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
- package/dist/editora.min.js.map +0 -1
- package/dist/editora.umd.js.map +0 -1
- package/dist/index-BF5RBhL9.js +0 -4
- package/dist/index-BF5RBhL9.js.map +0 -1
- package/dist/index-BPsf460l.mjs +0 -1243
- package/dist/index-BPsf460l.mjs.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es-CuicffkQ.mjs.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/plugin-loader.js.map +0 -1
- package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
- package/dist/webcomponent-core.js.map +0 -1
- package/dist/webcomponent-core.min.js.map +0 -1
- package/dist/webcomponent.cjs.js.map +0 -1
- package/dist/webcomponent.esm.js.map +0 -1
- package/dist/webcomponent.js.map +0 -1
- package/dist/webcomponent.min.js.map +0 -1
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import { f as S, g as D } from "./editorContainerHelpers-C7kdWnS0.mjs";
|
|
2
|
+
const b = /* @__PURE__ */ new Set(), m = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
3
|
+
function R() {
|
|
4
|
+
if (typeof window == "undefined" || window.__anchorObserverInitialized) return;
|
|
5
|
+
window.__anchorObserverInitialized = !0, new MutationObserver((l) => {
|
|
6
|
+
l.forEach((d) => {
|
|
7
|
+
d.removedNodes.forEach((r) => {
|
|
8
|
+
var n, e;
|
|
9
|
+
if (r.nodeType === Node.ELEMENT_NODE) {
|
|
10
|
+
const a = r;
|
|
11
|
+
if ((n = a.classList) != null && n.contains("rte-anchor")) {
|
|
12
|
+
const c = a.id;
|
|
13
|
+
c && b.delete(c);
|
|
14
|
+
}
|
|
15
|
+
const u = (e = a.querySelectorAll) == null ? void 0 : e.call(a, ".rte-anchor");
|
|
16
|
+
u == null || u.forEach((c) => {
|
|
17
|
+
const h = c.id;
|
|
18
|
+
h && b.delete(h);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}).observe(document.body, {
|
|
24
|
+
childList: !0,
|
|
25
|
+
subtree: !0
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function A(o) {
|
|
29
|
+
return !o || o.trim().length === 0 ? { valid: !1, error: "Anchor ID cannot be empty" } : o.length > 256 ? { valid: !1, error: "Anchor ID must be less than 256 characters" } : /^[a-z_]/.test(o) ? /^[a-z0-9\-_]+$/.test(o) ? { valid: !0, error: "" } : { valid: !1, error: "Anchor ID can only contain letters, numbers, hyphens, and underscores" } : { valid: !1, error: "Anchor ID must start with a letter or underscore" };
|
|
30
|
+
}
|
|
31
|
+
function N() {
|
|
32
|
+
const o = S();
|
|
33
|
+
if (!o) return;
|
|
34
|
+
const l = D(o);
|
|
35
|
+
if (!l) return;
|
|
36
|
+
const d = l.querySelectorAll(".rte-anchor"), r = /* @__PURE__ */ new Set();
|
|
37
|
+
d.forEach((n) => {
|
|
38
|
+
const e = n.id;
|
|
39
|
+
e && r.add(e);
|
|
40
|
+
}), b.clear(), r.forEach((n) => b.add(n));
|
|
41
|
+
}
|
|
42
|
+
function M(o) {
|
|
43
|
+
if (o) {
|
|
44
|
+
const r = o.startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
|
|
45
|
+
if (n != null && n.closest(m)) return !0;
|
|
46
|
+
}
|
|
47
|
+
const l = window.getSelection();
|
|
48
|
+
if (l && l.rangeCount > 0) {
|
|
49
|
+
const r = l.getRangeAt(0).startContainer, n = r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement;
|
|
50
|
+
if (n != null && n.closest(m)) return !0;
|
|
51
|
+
}
|
|
52
|
+
const d = document.activeElement;
|
|
53
|
+
return d != null && d.closest(m) ? !0 : document.body.matches(m) || document.documentElement.matches(m);
|
|
54
|
+
}
|
|
55
|
+
function _(o, l, d, r) {
|
|
56
|
+
N();
|
|
57
|
+
const n = M(r), e = n ? {
|
|
58
|
+
overlay: "rgba(0, 0, 0, 0.62)",
|
|
59
|
+
dialogBg: "#1f2937",
|
|
60
|
+
panelBg: "#222d3a",
|
|
61
|
+
border: "#3b4657",
|
|
62
|
+
text: "#e2e8f0",
|
|
63
|
+
muted: "#94a3b8",
|
|
64
|
+
closeHoverBg: "#334155",
|
|
65
|
+
fieldBg: "#111827",
|
|
66
|
+
fieldFocusBg: "#111827",
|
|
67
|
+
fieldBorder: "#4b5563",
|
|
68
|
+
fieldText: "#e2e8f0",
|
|
69
|
+
fieldErrorBg: "#3f2124",
|
|
70
|
+
fieldErrorBorder: "#ef4444",
|
|
71
|
+
cancelBg: "#334155",
|
|
72
|
+
cancelHover: "#475569",
|
|
73
|
+
cancelText: "#e2e8f0",
|
|
74
|
+
saveBg: "#3b82f6",
|
|
75
|
+
saveHover: "#2563eb",
|
|
76
|
+
saveDisabledBg: "#374151",
|
|
77
|
+
saveDisabledText: "#7f8ca1",
|
|
78
|
+
help: "#9fb0c6",
|
|
79
|
+
focusRing: "rgba(88, 166, 255, 0.25)",
|
|
80
|
+
errorRing: "rgba(239, 68, 68, 0.25)"
|
|
81
|
+
} : {
|
|
82
|
+
overlay: "rgba(0, 0, 0, 0.5)",
|
|
83
|
+
dialogBg: "#ffffff",
|
|
84
|
+
panelBg: "#f9f9f9",
|
|
85
|
+
border: "#e0e0e0",
|
|
86
|
+
text: "#333333",
|
|
87
|
+
muted: "#999999",
|
|
88
|
+
closeHoverBg: "#e0e0e0",
|
|
89
|
+
fieldBg: "#ffffff",
|
|
90
|
+
fieldFocusBg: "#f9f9ff",
|
|
91
|
+
fieldBorder: "#d0d0d0",
|
|
92
|
+
fieldText: "#333333",
|
|
93
|
+
fieldErrorBg: "#ffebee",
|
|
94
|
+
fieldErrorBorder: "#d32f2f",
|
|
95
|
+
cancelBg: "#f0f0f0",
|
|
96
|
+
cancelHover: "#e0e0e0",
|
|
97
|
+
cancelText: "#333333",
|
|
98
|
+
saveBg: "#0066cc",
|
|
99
|
+
saveHover: "#0052a3",
|
|
100
|
+
saveDisabledBg: "#d0d0d0",
|
|
101
|
+
saveDisabledText: "#999999",
|
|
102
|
+
help: "#999999",
|
|
103
|
+
focusRing: "rgba(0, 102, 204, 0.1)",
|
|
104
|
+
errorRing: "rgba(211, 47, 47, 0.1)"
|
|
105
|
+
}, a = document.createElement("div");
|
|
106
|
+
a.className = "rte-anchor-dialog-overlay", a.style.cssText = `
|
|
107
|
+
position: fixed;
|
|
108
|
+
top: 0;
|
|
109
|
+
left: 0;
|
|
110
|
+
right: 0;
|
|
111
|
+
bottom: 0;
|
|
112
|
+
background: ${e.overlay};
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
z-index: 10000;
|
|
117
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
|
118
|
+
`;
|
|
119
|
+
const u = document.createElement("div");
|
|
120
|
+
if (u.className = "rte-anchor-dialog", u.style.cssText = `
|
|
121
|
+
background: ${e.dialogBg};
|
|
122
|
+
border: 1px solid ${e.border};
|
|
123
|
+
border-radius: 8px;
|
|
124
|
+
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
|
125
|
+
width: 90%;
|
|
126
|
+
max-width: 450px;
|
|
127
|
+
overflow: hidden;
|
|
128
|
+
animation: rte-anchor-dialog-appear 0.2s ease;
|
|
129
|
+
`, !document.getElementById("rte-anchor-dialog-styles")) {
|
|
130
|
+
const s = document.createElement("style");
|
|
131
|
+
s.id = "rte-anchor-dialog-styles", s.textContent = `
|
|
132
|
+
@keyframes rte-anchor-dialog-appear {
|
|
133
|
+
from { opacity: 0; transform: scale(0.95); }
|
|
134
|
+
to { opacity: 1; transform: scale(1); }
|
|
135
|
+
}
|
|
136
|
+
.rte-anchor-dialog input:focus {
|
|
137
|
+
outline: none !important;
|
|
138
|
+
}
|
|
139
|
+
`, document.head.appendChild(s);
|
|
140
|
+
}
|
|
141
|
+
let c = "";
|
|
142
|
+
const h = document.createElement("div");
|
|
143
|
+
h.style.cssText = `
|
|
144
|
+
display: flex;
|
|
145
|
+
align-items: center;
|
|
146
|
+
justify-content: space-between;
|
|
147
|
+
padding: 16px 20px;
|
|
148
|
+
border-bottom: 1px solid ${e.border};
|
|
149
|
+
background: ${e.panelBg};
|
|
150
|
+
`;
|
|
151
|
+
const E = document.createElement("h3");
|
|
152
|
+
E.style.cssText = `margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};`, E.textContent = "Add Anchor";
|
|
153
|
+
const p = document.createElement("button");
|
|
154
|
+
p.textContent = "✕", p.style.cssText = `
|
|
155
|
+
background: none;
|
|
156
|
+
border: none;
|
|
157
|
+
font-size: 24px;
|
|
158
|
+
color: ${e.muted};
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
padding: 0;
|
|
161
|
+
width: 32px;
|
|
162
|
+
height: 32px;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
justify-content: center;
|
|
166
|
+
border-radius: 4px;
|
|
167
|
+
transition: all 0.2s ease;
|
|
168
|
+
`, p.onmouseover = () => {
|
|
169
|
+
p.style.background = e.closeHoverBg, p.style.color = "#f8fafc";
|
|
170
|
+
}, p.onmouseout = () => {
|
|
171
|
+
p.style.background = "none", p.style.color = e.muted;
|
|
172
|
+
}, h.appendChild(E), h.appendChild(p);
|
|
173
|
+
const C = document.createElement("div");
|
|
174
|
+
C.style.cssText = "padding: 20px;";
|
|
175
|
+
const x = document.createElement("div");
|
|
176
|
+
x.style.cssText = "margin-bottom: 0;";
|
|
177
|
+
const y = document.createElement("label");
|
|
178
|
+
y.textContent = "Anchor ID", y.style.cssText = `display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`, y.setAttribute("for", "anchor-id-input");
|
|
179
|
+
const t = document.createElement("input");
|
|
180
|
+
t.id = "anchor-id-input", t.type = "text", t.placeholder = "e.g., section-introduction", t.value = "", t.style.cssText = `
|
|
181
|
+
width: 100%;
|
|
182
|
+
padding: 10px 12px;
|
|
183
|
+
font-size: 14px;
|
|
184
|
+
border: 1px solid ${e.fieldBorder};
|
|
185
|
+
border-radius: 4px;
|
|
186
|
+
font-family: 'Courier New', monospace;
|
|
187
|
+
color: ${e.fieldText};
|
|
188
|
+
background: ${e.fieldBg};
|
|
189
|
+
transition: all 0.2s ease;
|
|
190
|
+
box-sizing: border-box;
|
|
191
|
+
`, t.style.setProperty("caret-color", e.fieldText);
|
|
192
|
+
const f = document.createElement("div");
|
|
193
|
+
f.style.cssText = `
|
|
194
|
+
color: #d32f2f;
|
|
195
|
+
font-size: 12px;
|
|
196
|
+
margin-top: 6px;
|
|
197
|
+
display: none;
|
|
198
|
+
`;
|
|
199
|
+
const B = document.createElement("div");
|
|
200
|
+
B.textContent = "URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.", B.style.cssText = `color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`, x.appendChild(y), x.appendChild(t), x.appendChild(f), x.appendChild(B), C.appendChild(x);
|
|
201
|
+
const v = document.createElement("div");
|
|
202
|
+
v.style.cssText = `
|
|
203
|
+
display: flex;
|
|
204
|
+
gap: 12px;
|
|
205
|
+
padding: 16px 20px;
|
|
206
|
+
border-top: 1px solid ${e.border};
|
|
207
|
+
background: ${e.panelBg};
|
|
208
|
+
justify-content: flex-end;
|
|
209
|
+
`;
|
|
210
|
+
const g = document.createElement("button");
|
|
211
|
+
g.textContent = "Cancel", g.style.cssText = `
|
|
212
|
+
padding: 8px 16px;
|
|
213
|
+
font-size: 14px;
|
|
214
|
+
font-weight: 500;
|
|
215
|
+
border: none;
|
|
216
|
+
border-radius: 4px;
|
|
217
|
+
cursor: pointer;
|
|
218
|
+
transition: all 0.2s ease;
|
|
219
|
+
background: ${e.cancelBg};
|
|
220
|
+
color: ${e.cancelText};
|
|
221
|
+
`, g.onmouseover = () => g.style.background = e.cancelHover, g.onmouseout = () => g.style.background = e.cancelBg;
|
|
222
|
+
const i = document.createElement("button");
|
|
223
|
+
i.textContent = "Add Anchor", i.style.cssText = `
|
|
224
|
+
padding: 8px 16px;
|
|
225
|
+
font-size: 14px;
|
|
226
|
+
font-weight: 500;
|
|
227
|
+
border: none;
|
|
228
|
+
border-radius: 4px;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
transition: all 0.2s ease;
|
|
231
|
+
background: ${e.saveBg};
|
|
232
|
+
color: white;
|
|
233
|
+
`, i.disabled = !t.value.trim();
|
|
234
|
+
const z = () => {
|
|
235
|
+
t.value.trim() ? (i.disabled = !1, i.style.background = e.saveBg, i.style.color = "white", i.style.cursor = "pointer") : (i.disabled = !0, i.style.background = e.saveDisabledBg, i.style.color = e.saveDisabledText, i.style.cursor = "not-allowed");
|
|
236
|
+
};
|
|
237
|
+
i.onmouseover = () => {
|
|
238
|
+
i.disabled || (i.style.background = e.saveHover, i.style.boxShadow = n ? "0 2px 8px rgba(59, 130, 246, 0.35)" : "0 2px 8px rgba(0, 102, 204, 0.3)");
|
|
239
|
+
}, i.onmouseout = () => {
|
|
240
|
+
i.disabled || (i.style.background = e.saveBg, i.style.boxShadow = "none");
|
|
241
|
+
}, v.appendChild(g), v.appendChild(i), t.oninput = () => {
|
|
242
|
+
const s = t.value;
|
|
243
|
+
if (z(), s.trim()) {
|
|
244
|
+
const k = A(s);
|
|
245
|
+
k.valid ? b.has(s) ? (c = `Anchor ID already exists: ${s}`, f.textContent = "⚠ " + c, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg) : (c = "", f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg) : (c = k.error, f.textContent = "⚠ " + c, f.style.display = "block", t.style.borderColor = e.fieldErrorBorder, t.style.background = e.fieldErrorBg);
|
|
246
|
+
} else
|
|
247
|
+
f.style.display = "none", t.style.borderColor = e.fieldBorder, t.style.background = e.fieldBg;
|
|
248
|
+
}, t.onfocus = () => {
|
|
249
|
+
t.style.borderColor = c ? e.fieldErrorBorder : e.saveBg, t.style.boxShadow = c ? `0 0 0 3px ${e.errorRing}` : `0 0 0 3px ${e.focusRing}`, t.style.background = c ? e.fieldErrorBg : e.fieldFocusBg;
|
|
250
|
+
}, t.onblur = () => {
|
|
251
|
+
t.style.boxShadow = "none", c || (t.style.background = e.fieldBg);
|
|
252
|
+
};
|
|
253
|
+
const T = () => {
|
|
254
|
+
const s = t.value.trim();
|
|
255
|
+
!s || !A(s).valid || b.has(s) || (d && d(s), a.remove());
|
|
256
|
+
}, w = () => {
|
|
257
|
+
a.remove();
|
|
258
|
+
};
|
|
259
|
+
i.onclick = T, g.onclick = w, p.onclick = w, t.onkeydown = (s) => {
|
|
260
|
+
s.key === "Enter" ? (s.preventDefault(), T()) : s.key === "Escape" && (s.preventDefault(), w());
|
|
261
|
+
}, a.onclick = (s) => {
|
|
262
|
+
s.target === a && w();
|
|
263
|
+
}, u.appendChild(h), u.appendChild(C), u.appendChild(v), a.appendChild(u), document.body.appendChild(a), setTimeout(() => t.focus(), 100);
|
|
264
|
+
}
|
|
265
|
+
function H(o, l) {
|
|
266
|
+
let d;
|
|
267
|
+
if (l)
|
|
268
|
+
d = l;
|
|
269
|
+
else {
|
|
270
|
+
const a = window.getSelection();
|
|
271
|
+
if (!a || a.rangeCount === 0) return;
|
|
272
|
+
d = a.getRangeAt(0);
|
|
273
|
+
}
|
|
274
|
+
const r = document.createElement("span");
|
|
275
|
+
r.id = o, r.className = "rte-anchor", r.setAttribute("data-type", "anchor"), r.setAttribute("data-anchor-id", o), r.setAttribute("title", `Anchor: ${o}`), r.style.cssText = `
|
|
276
|
+
display: inline;
|
|
277
|
+
position: relative;
|
|
278
|
+
cursor: pointer;
|
|
279
|
+
`, d.insertNode(r), b.add(o), d.setStart(r.nextSibling || r.parentNode, 0), d.collapse(!0);
|
|
280
|
+
const n = window.getSelection();
|
|
281
|
+
n && (n.removeAllRanges(), n.addRange(d));
|
|
282
|
+
const e = S();
|
|
283
|
+
if (e) {
|
|
284
|
+
const a = D(e);
|
|
285
|
+
a && a.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
286
|
+
}
|
|
287
|
+
$();
|
|
288
|
+
}
|
|
289
|
+
function $() {
|
|
290
|
+
if (document.getElementById("rte-anchor-styles")) return;
|
|
291
|
+
const o = document.createElement("style");
|
|
292
|
+
o.id = "rte-anchor-styles", o.textContent = `
|
|
293
|
+
.rte-anchor {
|
|
294
|
+
display: inline;
|
|
295
|
+
position: relative;
|
|
296
|
+
cursor: pointer;
|
|
297
|
+
transition: all 0.2s ease;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.rte-anchor:hover::before {
|
|
301
|
+
content: '⚓';
|
|
302
|
+
position: absolute;
|
|
303
|
+
top: -1.2em;
|
|
304
|
+
left: 0;
|
|
305
|
+
background: #333;
|
|
306
|
+
color: #fff;
|
|
307
|
+
padding: 2px 6px;
|
|
308
|
+
border-radius: 3px;
|
|
309
|
+
font-size: 0.8em;
|
|
310
|
+
white-space: nowrap;
|
|
311
|
+
z-index: 100;
|
|
312
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.rte-anchor:hover::after {
|
|
316
|
+
content: attr(data-anchor-id);
|
|
317
|
+
position: absolute;
|
|
318
|
+
top: -1.2em;
|
|
319
|
+
left: 1.4em;
|
|
320
|
+
background: #333;
|
|
321
|
+
color: #fff;
|
|
322
|
+
padding: 2px 6px;
|
|
323
|
+
border-radius: 3px;
|
|
324
|
+
font-size: 0.75em;
|
|
325
|
+
font-family: 'Courier New', monospace;
|
|
326
|
+
white-space: nowrap;
|
|
327
|
+
z-index: 100;
|
|
328
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
[contenteditable='true'] .rte-anchor::before {
|
|
332
|
+
content: '';
|
|
333
|
+
position: absolute;
|
|
334
|
+
width: 8px;
|
|
335
|
+
height: 8px;
|
|
336
|
+
background: #0066cc;
|
|
337
|
+
border-radius: 50%;
|
|
338
|
+
top: -3px;
|
|
339
|
+
left: 0;
|
|
340
|
+
opacity: 0.5;
|
|
341
|
+
transition: opacity 0.2s ease;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
[contenteditable='true'] .rte-anchor:hover::before {
|
|
345
|
+
opacity: 1;
|
|
346
|
+
width: auto;
|
|
347
|
+
height: auto;
|
|
348
|
+
background: #333;
|
|
349
|
+
border-radius: 3px;
|
|
350
|
+
top: -1.2em;
|
|
351
|
+
padding: 2px 6px;
|
|
352
|
+
font-size: 0.8em;
|
|
353
|
+
content: '⚓';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
@media print {
|
|
357
|
+
.rte-anchor::before,
|
|
358
|
+
.rte-anchor::after {
|
|
359
|
+
display: none;
|
|
360
|
+
}
|
|
361
|
+
.rte-anchor {
|
|
362
|
+
cursor: auto;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.rte-anchor:focus {
|
|
367
|
+
outline: 2px solid #0066cc;
|
|
368
|
+
outline-offset: 2px;
|
|
369
|
+
}
|
|
370
|
+
`, document.head.appendChild(o);
|
|
371
|
+
}
|
|
372
|
+
const O = () => (typeof window != "undefined" && (R(), $()), {
|
|
373
|
+
name: "anchor",
|
|
374
|
+
toolbar: [
|
|
375
|
+
{
|
|
376
|
+
label: "Anchor",
|
|
377
|
+
command: "insertAnchor",
|
|
378
|
+
icon: '<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',
|
|
379
|
+
shortcut: "Mod-Shift-k"
|
|
380
|
+
}
|
|
381
|
+
],
|
|
382
|
+
commands: {
|
|
383
|
+
insertAnchor: () => {
|
|
384
|
+
try {
|
|
385
|
+
const o = window.getSelection();
|
|
386
|
+
if (!o || o.rangeCount === 0)
|
|
387
|
+
return alert("Please place your cursor where you want to insert the anchor."), !1;
|
|
388
|
+
const l = o.getRangeAt(0).cloneRange();
|
|
389
|
+
return _("add", "", (d) => {
|
|
390
|
+
H(d, l);
|
|
391
|
+
}, l), !0;
|
|
392
|
+
} catch (o) {
|
|
393
|
+
return console.error("Failed to insert anchor:", o), !1;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
keymap: {
|
|
398
|
+
"Mod-Shift-k": "insertAnchor"
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
export {
|
|
402
|
+
O as AnchorPlugin
|
|
403
|
+
};
|
|
404
|
+
//# sourceMappingURL=AnchorPlugin.native-C1Rw5m04.mjs.map
|