@editora/core 1.0.15 → 1.0.17

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 (68) hide show
  1. package/dist/{A11yCheckerPlugin.native-BRdGYMju.mjs → A11yCheckerPlugin.native-DIKuCeFw.mjs} +82 -79
  2. package/dist/{AnchorPlugin.native-BcYGEtd9.mjs → AnchorPlugin.native-DXZdK3zr.mjs} +72 -71
  3. package/dist/{ApprovalWorkflowPlugin.native-BZ6jO-Wj.mjs → ApprovalWorkflowPlugin.native-ZsS_2xmn.mjs} +239 -238
  4. package/dist/{BackgroundColorPlugin.native-50iAT9xU.mjs → BackgroundColorPlugin.native-H3XyYD7_.mjs} +2 -2
  5. package/dist/{BlocksLibraryPlugin.native-5sdsXsiE.mjs → BlocksLibraryPlugin.native-CownM6Rk.mjs} +140 -116
  6. package/dist/{CapitalizationPlugin.native-DLV4oPmB.mjs → CapitalizationPlugin.native-C-HRbXGh.mjs} +10 -5
  7. package/dist/{ChecklistPlugin.native-BS-kMz9O.mjs → ChecklistPlugin.native-NVrBUkaL.mjs} +141 -103
  8. package/dist/{CitationsPlugin.native-DQgoCd1B.mjs → CitationsPlugin.native-C_7wWQ-k.mjs} +441 -422
  9. package/dist/{ClearFormattingPlugin.native-B6ro3a1h.mjs → ClearFormattingPlugin.native-Pp0O-SBf.mjs} +24 -23
  10. package/dist/{CodePlugin.native-knhM8NNo.mjs → CodePlugin.native-BH-K4xmW.mjs} +474 -342
  11. package/dist/CodePlugin.native-hNgfXlfS.mjs +4767 -0
  12. package/dist/CodeSamplePlugin.native-svbAFWh_.mjs +501 -0
  13. package/dist/CollaborationPlugin.native-oSybCGPW.mjs +7468 -0
  14. package/dist/{CommentsPlugin.native-DPSqTkiv.mjs → CommentsPlugin.native-CLip9wAO.mjs} +233 -185
  15. package/dist/{ConditionalContentPlugin.native-CfhY46rU.mjs → ConditionalContentPlugin.native-Bf7XgRSW.mjs} +401 -351
  16. package/dist/{DataBindingPlugin.native-BoXwghTz.mjs → DataBindingPlugin.native-B7lpI_0c.mjs} +29 -28
  17. package/dist/{DocumentManagerPlugin.native-D1YHQ2NN.mjs → DocumentManagerPlugin.native-iFip6s4Q.mjs} +94 -45
  18. package/dist/{EmbedIframePlugin.native-BF_-LjTq.mjs → EmbedIframePlugin.native-BfZ_HGlV.mjs} +231 -186
  19. package/dist/{EmojisPlugin.native-CitxxlWX.mjs → EmojisPlugin.native-D92aaOKi.mjs} +288 -76
  20. package/dist/{FontFamilyPlugin.native-j8hMTbg4.mjs → FontFamilyPlugin.native-M3cNQ0KA.mjs} +57 -50
  21. package/dist/{FontSizePlugin.native-B_jCh7dY.mjs → FontSizePlugin.native-DsLrH8eq.mjs} +41 -34
  22. package/dist/{FormatPainterPlugin.native-CsMrKfFU.mjs → FormatPainterPlugin.native-BhjzsiVq.mjs} +3 -2
  23. package/dist/{HistoryPlugin.native-D2wl32jV.mjs → HistoryPlugin.native-DPvhks6h.mjs} +36 -32
  24. package/dist/LinkPlugin.native-BsQXYsK6.mjs +352 -0
  25. package/dist/{ListPlugin.native-V7EZC1lM.mjs → ListPlugin.native-Bt0LANbO.mjs} +68 -35
  26. package/dist/{MathPlugin.native-NwWPHVmj.mjs → MathPlugin.native-Byo3WL0f.mjs} +211 -115
  27. package/dist/{MediaManagerPlugin.native-eOsTJFpw.mjs → MediaManagerPlugin.native-BT1NZIJS.mjs} +139 -134
  28. package/dist/{MentionPlugin.native-BMDlOqur.mjs → MentionPlugin.native-S_lwGZQO.mjs} +23 -18
  29. package/dist/{MergeTagPlugin.native-BzRVoD9-.mjs → MergeTagPlugin.native-7-6F3S1Y.mjs} +44 -43
  30. package/dist/{PreviewPlugin.native-WuIwOAOR.mjs → PreviewPlugin.native-CiR51jql.mjs} +31 -28
  31. package/dist/{SlashCommandsPlugin.native-BiN6ODw5.mjs → SlashCommandsPlugin.native-BDIIwGNs.mjs} +90 -79
  32. package/dist/{SmartPastePlugin.native-CZAEHkyt.mjs → SmartPastePlugin.native-BATLCds5.mjs} +89 -85
  33. package/dist/{SpecialCharactersPlugin.native-DaG4b19I.mjs → SpecialCharactersPlugin.native-CdZoc1GB.mjs} +73 -26
  34. package/dist/SpellCheckPlugin.native-Bef2oTLB.mjs +10935 -0
  35. package/dist/TablePlugin.native-BjIxYZ2X.mjs +772 -0
  36. package/dist/{TemplatePlugin.native-DLjFUaPW.mjs → TemplatePlugin.native-D6n5RUnC.mjs} +288 -262
  37. package/dist/{TextColorPlugin.native-Bwl_bSmc.mjs → TextColorPlugin.native-KMZ2uzlq.mjs} +2 -2
  38. package/dist/{TranslationWorkflowPlugin.native-DdF16tgT.mjs → TranslationWorkflowPlugin.native-CZtG--06.mjs} +67 -65
  39. package/dist/{VersionDiffPlugin.native-Bvxgy--t.mjs → VersionDiffPlugin.native-Ca1fMWUJ.mjs} +42 -42
  40. package/dist/anchoredPopover-DJFD2oAP.mjs +116 -0
  41. package/dist/core.css +1 -1
  42. package/dist/dialogHelpers-DBf7WqYH.mjs +40 -0
  43. package/dist/editora.min.js +26 -24
  44. package/dist/editora.umd.js +26 -24
  45. package/dist/escapeHtml-CX8RelZ1.mjs +7 -0
  46. package/dist/historyHelpers-B0-4mq1E.mjs +15 -0
  47. package/dist/index-XsYC_KdJ.mjs +3923 -0
  48. package/dist/index-_eKRBZPq.js +12 -0
  49. package/dist/index.cjs.js +3 -3
  50. package/dist/index.esm.js +17 -14
  51. package/dist/plugin-loader.js +53 -52
  52. package/dist/webcomponent-core.js +2055 -476
  53. package/dist/webcomponent-core.min.css +1 -1
  54. package/dist/webcomponent-core.min.js +96 -66
  55. package/dist/webcomponent.cjs.js +1 -1
  56. package/dist/webcomponent.esm.js +1 -1
  57. package/dist/webcomponent.js +2223 -643
  58. package/dist/webcomponent.min.css +1 -1
  59. package/dist/webcomponent.min.js +1564 -1198
  60. package/index.d.ts +32 -0
  61. package/package.json +10 -3
  62. package/dist/CodeSamplePlugin.native-CgGoH-X4.mjs +0 -384
  63. package/dist/LinkPlugin.native-DYCIcdTm.mjs +0 -283
  64. package/dist/SpellCheckPlugin.native-BZB9AewP.mjs +0 -1039
  65. package/dist/TablePlugin.native-DrHX-efe.mjs +0 -495
  66. package/dist/anchoredPopover-Bxds0VoB.mjs +0 -110
  67. package/dist/index-BLm1MtzH.js +0 -10
  68. package/dist/index-Cd9jEuZP.mjs +0 -2341
package/index.d.ts CHANGED
@@ -353,3 +353,35 @@ export function getSelectionInfo(
353
353
  selectedChars: number;
354
354
  selectedWords: number;
355
355
  };
356
+
357
+ export interface SanitizationConfig {
358
+ allowedTags?: string[];
359
+ allowedAttributes?: Record<string, string[]>;
360
+ sanitize?: boolean;
361
+ }
362
+
363
+ export interface SecurityConfig {
364
+ sanitizeOnPaste?: boolean;
365
+ sanitizeOnInput?: boolean;
366
+ }
367
+
368
+ export function sanitizeHTML(
369
+ html: string,
370
+ contentConfig?: SanitizationConfig,
371
+ securityConfig?: SecurityConfig,
372
+ ): string;
373
+ export function sanitizePastedHTML(
374
+ html: string,
375
+ contentConfig?: SanitizationConfig,
376
+ securityConfig?: SecurityConfig,
377
+ ): string;
378
+ export function sanitizeInputHTML(
379
+ html: string,
380
+ contentConfig?: SanitizationConfig,
381
+ securityConfig?: SecurityConfig,
382
+ /**
383
+ * Tags a specific, already-trusted mutation (e.g. the embed-iframe dialog) may keep
384
+ * even though the default allowlist excludes them. Never applied to pasted content.
385
+ */
386
+ additionalAllowedTags?: string[],
387
+ ): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/core",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Framework-agnostic rich text editor core for React and web apps, built for enterprise editing workflows.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",
@@ -124,14 +124,21 @@
124
124
  "typecheck:build": "tsc -p tsconfig.build.json --noEmit",
125
125
  "dev": "vite build --watch",
126
126
  "clean": "rm -rf dist",
127
+ "test": "vitest run",
127
128
  "prepublishOnly": "npm run typecheck:build && npm run build"
128
129
  },
129
130
  "devDependencies": {
131
+ "@types/dompurify": "^3.0.5",
132
+ "jsdom": "^22.1.0",
130
133
  "typescript": "^5.0.0",
131
- "vite": "^4.5.14"
134
+ "vite": "^7.3.1",
135
+ "vitest": "^1.0.0"
132
136
  },
133
137
  "publishConfig": {
134
138
  "access": "public"
135
139
  },
136
- "gitHead": "e19160591d822f5ecf242658d6db63959371838e"
140
+ "gitHead": "7883627e823aa99dd5ecb66a5201116df972f88b",
141
+ "dependencies": {
142
+ "dompurify": "^3.4.16"
143
+ }
137
144
  }
@@ -1,384 +0,0 @@
1
- const T = () => {
2
- const d = window.getSelection();
3
- if (d && d.rangeCount > 0) {
4
- let t = d.getRangeAt(0).startContainer;
5
- for (; t && t !== document.body; ) {
6
- if (t.nodeType === Node.ELEMENT_NODE) {
7
- const a = t;
8
- if (a.getAttribute("contenteditable") === "true")
9
- return a;
10
- }
11
- t = t.parentNode;
12
- }
13
- }
14
- const l = document.activeElement;
15
- if (l) {
16
- if (l.getAttribute("contenteditable") === "true")
17
- return l;
18
- const t = l.closest('[contenteditable="true"]');
19
- if (t) return t;
20
- }
21
- return document.querySelector('[contenteditable="true"]');
22
- }, k = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => {
23
- const d = T();
24
- if (d != null && d.closest(k)) return !0;
25
- const l = window.getSelection();
26
- if (l && l.rangeCount > 0) {
27
- const a = l.getRangeAt(0).startContainer, i = a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement;
28
- if (i != null && i.closest(k)) return !0;
29
- }
30
- const t = document.activeElement;
31
- return t != null && t.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
32
- }, M = [
33
- { value: "javascript", label: "JavaScript" },
34
- { value: "typescript", label: "TypeScript" },
35
- { value: "python", label: "Python" },
36
- { value: "java", label: "Java" },
37
- { value: "csharp", label: "C#" },
38
- { value: "cpp", label: "C++" },
39
- { value: "c", label: "C" },
40
- { value: "php", label: "PHP" },
41
- { value: "ruby", label: "Ruby" },
42
- { value: "go", label: "Go" },
43
- { value: "rust", label: "Rust" },
44
- { value: "swift", label: "Swift" },
45
- { value: "kotlin", label: "Kotlin" },
46
- { value: "html", label: "HTML" },
47
- { value: "css", label: "CSS" },
48
- { value: "scss", label: "SCSS" },
49
- { value: "json", label: "JSON" },
50
- { value: "xml", label: "XML" },
51
- { value: "yaml", label: "YAML" },
52
- { value: "markdown", label: "Markdown" },
53
- { value: "sql", label: "SQL" },
54
- { value: "bash", label: "Bash" },
55
- { value: "shell", label: "Shell" },
56
- { value: "plaintext", label: "Plain Text" }
57
- ], S = /* @__PURE__ */ new Map();
58
- function $(d, l, t, a) {
59
- const i = !!l, n = a || "javascript", f = t || "", p = A(), e = p ? {
60
- overlay: "rgba(0, 0, 0, 0.62)",
61
- dialogBg: "#1f2937",
62
- dialogBorder: "#4b5563",
63
- text: "#e2e8f0",
64
- mutedText: "#a8b5c8",
65
- headerFooterBg: "#222d3a",
66
- border: "#3b4657",
67
- fieldBg: "#111827",
68
- fieldBorder: "#4b5563",
69
- cancelBg: "#334155",
70
- cancelHover: "#475569",
71
- cancelText: "#e2e8f0",
72
- primaryBg: "#3b82f6",
73
- primaryHover: "#2563eb"
74
- } : {
75
- overlay: "rgba(0, 0, 0, 0.5)",
76
- dialogBg: "#ffffff",
77
- dialogBorder: "#e0e0e0",
78
- text: "#333333",
79
- mutedText: "#666666",
80
- headerFooterBg: "#ffffff",
81
- border: "#e0e0e0",
82
- fieldBg: "#ffffff",
83
- fieldBorder: "#dddddd",
84
- cancelBg: "#e5e7eb",
85
- cancelHover: "#d1d5db",
86
- cancelText: "#333333",
87
- primaryBg: "#2563eb",
88
- primaryHover: "#1d4ed8"
89
- }, c = document.createElement("div");
90
- c.className = "rte-code-sample-overlay", p && c.classList.add("rte-theme-dark"), c.style.cssText = `
91
- position: fixed;
92
- top: 0;
93
- left: 0;
94
- right: 0;
95
- bottom: 0;
96
- background: ${e.overlay};
97
- display: flex;
98
- align-items: center;
99
- justify-content: center;
100
- z-index: 10000;
101
- animation: fadeIn 160ms ease-out;
102
- `;
103
- const o = document.createElement("div");
104
- o.className = "rte-code-sample-dialog", o.style.cssText = `
105
- background: ${e.dialogBg};
106
- border: 1px solid ${e.dialogBorder};
107
- border-radius: 8px;
108
- box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
109
- max-width: 700px;
110
- width: 90vw;
111
- max-height: 80vh;
112
- display: flex;
113
- flex-direction: column;
114
- animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
115
- `;
116
- const u = document.createElement("div");
117
- u.style.cssText = `
118
- padding: 20px;
119
- border-bottom: 1px solid ${e.border};
120
- background: ${e.headerFooterBg};
121
- display: flex;
122
- justify-content: space-between;
123
- align-items: center;
124
- `, u.innerHTML = `
125
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">
126
- ${i ? "Edit Code Sample" : "Insert Code Sample"}
127
- </h2>
128
- <button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: ${e.mutedText}; cursor: pointer; padding: 0; width: 32px; height: 32px;">×</button>
129
- `;
130
- const m = document.createElement("div");
131
- m.style.cssText = `
132
- flex: 1;
133
- overflow-y: auto;
134
- padding: 20px;
135
- `;
136
- const s = document.createElement("div");
137
- s.style.marginBottom = "20px", s.innerHTML = `
138
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Language</label>
139
- <select class="rte-code-language" style="
140
- width: 100%;
141
- padding: 10px 12px;
142
- border: 1px solid ${e.fieldBorder};
143
- border-radius: 4px;
144
- font-size: 14px;
145
- background-color: ${e.fieldBg};
146
- color: ${e.text};
147
- cursor: pointer;
148
- ">
149
- ${M.map((r) => `
150
- <option value="${r.value}" ${r.value === n ? "selected" : ""}>
151
- ${r.label}
152
- </option>
153
- `).join("")}
154
- </select>
155
- `;
156
- const b = document.createElement("div");
157
- b.style.marginBottom = "20px", b.innerHTML = `
158
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Code</label>
159
- <textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
160
- width: 100%;
161
- padding: 12px;
162
- border: 1px solid ${e.fieldBorder};
163
- border-radius: 4px;
164
- font-family: 'Courier New', Courier, monospace;
165
- font-size: 13px;
166
- line-height: 1.5;
167
- resize: vertical;
168
- min-height: 250px;
169
- max-height: 400px;
170
- background-color: ${e.fieldBg};
171
- color: ${e.text};
172
- box-sizing: border-box;
173
- ">${f}</textarea>
174
- <div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
175
- `;
176
- const x = document.createElement("div");
177
- x.style.cssText = `color: ${e.mutedText}; font-size: 12px; margin-top: 10px;`, x.innerHTML = "💡 Tip: Press Ctrl+Enter (or Cmd+Enter on Mac) to save, or Escape to cancel", m.appendChild(s), m.appendChild(b), m.appendChild(x);
178
- const y = document.createElement("div");
179
- y.style.cssText = `
180
- padding: 20px;
181
- border-top: 1px solid ${e.border};
182
- background: ${e.headerFooterBg};
183
- display: flex;
184
- justify-content: flex-end;
185
- gap: 12px;
186
- `, y.innerHTML = `
187
- <button class="rte-code-cancel-btn" style="
188
- padding: 10px 16px;
189
- border: none;
190
- border-radius: 4px;
191
- font-size: 14px;
192
- font-weight: 500;
193
- cursor: pointer;
194
- background: ${e.cancelBg};
195
- color: ${e.cancelText};
196
- ">Cancel</button>
197
- <button class="rte-code-save-btn" style="
198
- padding: 10px 16px;
199
- border: none;
200
- border-radius: 4px;
201
- font-size: 14px;
202
- font-weight: 500;
203
- cursor: pointer;
204
- background: ${e.primaryBg};
205
- color: #fff;
206
- ">${i ? "Update Code Sample" : "Insert Code Sample"}</button>
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"), 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
- }, v.onmouseover = () => {
214
- v.style.background = e.cancelHover;
215
- }, v.onmouseout = () => {
216
- v.style.background = e.cancelBg;
217
- }, h.onmouseover = () => {
218
- h.style.background = e.primaryHover;
219
- }, h.onmouseout = () => {
220
- h.style.background = e.primaryBg;
221
- };
222
- const C = () => {
223
- c.remove();
224
- }, B = () => {
225
- const r = E.value.trim();
226
- if (!r) {
227
- w.textContent = "⚠ Code cannot be empty", w.style.display = "block";
228
- return;
229
- }
230
- const N = L.value;
231
- d(r, N), C();
232
- };
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
- }), E.addEventListener("input", () => {
236
- w.style.display = "none";
237
- }), c.addEventListener("click", (r) => {
238
- r.target === c && C();
239
- }), !document.getElementById("rte-code-sample-animations")) {
240
- const r = document.createElement("style");
241
- r.id = "rte-code-sample-animations", r.textContent = `
242
- @keyframes fadeIn {
243
- from { opacity: 0; }
244
- to { opacity: 1; }
245
- }
246
- @keyframes slideUp {
247
- from { transform: translateY(20px); opacity: 0; }
248
- to { transform: translateY(0); opacity: 1; }
249
- }
250
- `, document.head.appendChild(r);
251
- }
252
- return document.body.appendChild(c), setTimeout(() => E.focus(), 100), c;
253
- }
254
- function R() {
255
- if (!T()) return;
256
- let l = null;
257
- const t = window.getSelection();
258
- t && t.rangeCount > 0 && (l = t.getRangeAt(0).cloneRange()), $((a, i) => {
259
- const n = window.getSelection();
260
- if (l && (n == null || n.removeAllRanges(), n == null || n.addRange(l)), !n || n.rangeCount === 0) return;
261
- const f = T();
262
- if (!f) return;
263
- const p = n.anchorNode;
264
- if (!p || !f.contains(p)) return;
265
- const e = n.getRangeAt(0), c = `code-block-${Date.now()}`, o = document.createElement("pre");
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
- display: block;
268
- position: relative;
269
- background: #f5f5f5;
270
- border: 1px solid #e0e0e0;
271
- border-radius: 6px;
272
- padding: 12px;
273
- margin: 12px 0;
274
- overflow-x: auto;
275
- font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
276
- font-size: 13px;
277
- line-height: 1.5;
278
- color: #333;
279
- user-select: text;
280
- cursor: default;
281
- `;
282
- const u = document.createElement("code");
283
- u.className = `language-${i}`, u.style.cssText = `
284
- font-family: inherit;
285
- font-size: inherit;
286
- line-height: inherit;
287
- color: inherit;
288
- white-space: pre;
289
- word-break: normal;
290
- display: block;
291
- `, u.textContent = a;
292
- const m = document.createElement("span");
293
- m.style.cssText = `
294
- position: absolute;
295
- top: 0;
296
- right: 0;
297
- background: #333;
298
- color: #fff;
299
- padding: 2px 8px;
300
- font-size: 11px;
301
- font-weight: bold;
302
- border-radius: 0 6px 0 4px;
303
- text-transform: uppercase;
304
- letter-spacing: 0.5px;
305
- pointer-events: none;
306
- `, m.textContent = i;
307
- const s = document.createElement("button");
308
- s.className = "rte-code-copy", s.textContent = "Copy", s.style.cssText = `
309
- position: absolute;
310
- top: 8px;
311
- left: 8px;
312
- background: #fff;
313
- border: 1px solid #d0d0d0;
314
- border-radius: 3px;
315
- padding: 4px 8px;
316
- font-size: 11px;
317
- cursor: pointer;
318
- opacity: 0;
319
- transition: opacity 0.2s ease;
320
- `, s.onclick = (x) => {
321
- x.stopPropagation(), navigator.clipboard.writeText(a).then(() => {
322
- s.textContent = "✓ Copied!", setTimeout(() => {
323
- s.textContent = "Copy";
324
- }, 2e3);
325
- });
326
- }, o.appendChild(m), o.appendChild(s), o.appendChild(u), o.addEventListener("mouseenter", () => {
327
- s.style.opacity = "1";
328
- }), o.addEventListener("mouseleave", () => {
329
- s.style.opacity = "0";
330
- }), o.addEventListener("dblclick", () => {
331
- z(c);
332
- }), S.set(c, {
333
- id: c,
334
- language: i,
335
- code: a
336
- }), e.insertNode(o);
337
- const b = document.createRange();
338
- b.setStartAfter(o), b.collapse(!0), n.removeAllRanges(), n.addRange(b);
339
- });
340
- }
341
- function z(d) {
342
- const l = T();
343
- if (!l) return;
344
- const t = l.querySelector(`#${d}`);
345
- if (!t) return;
346
- const a = S.get(d);
347
- a && $(
348
- (i, n) => {
349
- const f = t.querySelector("code");
350
- f && (f.textContent = i, f.className = `language-${n}`);
351
- const p = t.querySelector("span");
352
- p && (p.textContent = n), t.setAttribute("data-lang", n), a.language = n, a.code = i;
353
- const e = t.querySelector(".rte-code-copy");
354
- e && (e.onclick = (c) => {
355
- c.stopPropagation(), navigator.clipboard.writeText(i).then(() => {
356
- e.textContent = "✓ Copied!", setTimeout(() => {
357
- e.textContent = "Copy";
358
- }, 2e3);
359
- });
360
- });
361
- },
362
- d,
363
- a.code,
364
- a.language
365
- );
366
- }
367
- const H = () => ({
368
- name: "codeSample",
369
- toolbar: [
370
- {
371
- label: "Insert Code",
372
- command: "insertCodeBlock",
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
- shortcut: "Mod-Shift-C"
375
- }
376
- ],
377
- commands: {
378
- insertCodeBlock: (...d) => (R(), !0)
379
- }
380
- });
381
- export {
382
- H as CodeSamplePlugin
383
- };
384
- //# sourceMappingURL=CodeSamplePlugin.native-CgGoH-X4.mjs.map