@editora/plugins 1.0.17 → 1.0.18

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 (100) hide show
  1. package/dist/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
  2. package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
  3. package/dist/a11y-checker.cjs.js +16 -16
  4. package/dist/a11y-checker.esm.js +79 -75
  5. package/dist/anchor.cjs.js +9 -9
  6. package/dist/anchor.esm.js +61 -60
  7. package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
  8. package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
  9. package/dist/approval-workflow.cjs.js +5 -5
  10. package/dist/approval-workflow.esm.js +105 -104
  11. package/dist/background-color.cjs.js +1 -1
  12. package/dist/background-color.esm.js +1 -1
  13. package/dist/blocks-library.cjs.js +6 -6
  14. package/dist/blocks-library.esm.js +226 -202
  15. package/dist/capitalization.cjs.js +1 -1
  16. package/dist/capitalization.esm.js +9 -4
  17. package/dist/checklist.cjs.js +1 -1
  18. package/dist/checklist.esm.js +154 -116
  19. package/dist/citations.cjs.js +43 -18
  20. package/dist/citations.esm.js +465 -446
  21. package/dist/clear-formatting.cjs.js +1 -1
  22. package/dist/clear-formatting.esm.js +21 -20
  23. package/dist/code-sample.cjs.js +85 -66
  24. package/dist/code-sample.esm.js +301 -190
  25. package/dist/code.cjs.js +1 -1
  26. package/dist/code.esm.js +1 -1
  27. package/dist/collaboration.cjs.js +68 -0
  28. package/dist/collaboration.esm.js +7428 -0
  29. package/dist/comments.cjs.js +11 -11
  30. package/dist/comments.esm.js +284 -237
  31. package/dist/conditional-content.cjs.js +67 -60
  32. package/dist/conditional-content.esm.js +270 -220
  33. package/dist/data-binding.cjs.js +3 -3
  34. package/dist/data-binding.esm.js +28 -27
  35. package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
  36. package/dist/dialogHelpers-zU6zpMIA.js +12 -0
  37. package/dist/document-manager.cjs.js +1 -1
  38. package/dist/document-manager.esm.js +1 -1
  39. package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
  40. package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
  41. package/dist/embed-iframe.cjs.js +37 -17
  42. package/dist/embed-iframe.esm.js +188 -143
  43. package/dist/emojis.cjs.js +13 -10
  44. package/dist/emojis.esm.js +288 -76
  45. package/dist/enterprise.cjs.js +1 -1
  46. package/dist/enterprise.esm.js +9 -7
  47. package/dist/escapeHtml-D2Zh82pD.js +1 -0
  48. package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
  49. package/dist/font-family.cjs.js +1 -1
  50. package/dist/font-family.esm.js +48 -41
  51. package/dist/font-size.cjs.js +1 -1
  52. package/dist/font-size.esm.js +67 -60
  53. package/dist/format-painter.cjs.js +1 -1
  54. package/dist/format-painter.esm.js +2 -1
  55. package/dist/history.cjs.js +1 -1
  56. package/dist/history.esm.js +40 -36
  57. package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
  58. package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
  59. package/dist/index-Bm1eqYHh.mjs +194 -0
  60. package/dist/index-CoflqYuK.js +30 -0
  61. package/dist/index.cjs.js +1 -1
  62. package/dist/index.esm.js +17 -15
  63. package/dist/link.cjs.js +17 -13
  64. package/dist/link.esm.js +138 -69
  65. package/dist/list.cjs.js +1 -1
  66. package/dist/list.esm.js +66 -33
  67. package/dist/math.cjs.js +22 -22
  68. package/dist/math.esm.js +221 -126
  69. package/dist/media-manager.cjs.js +12 -12
  70. package/dist/media-manager.esm.js +55 -50
  71. package/dist/mentions.cjs.js +2 -2
  72. package/dist/mentions.esm.js +17 -12
  73. package/dist/merge-tag.cjs.js +2 -2
  74. package/dist/merge-tag.esm.js +43 -42
  75. package/dist/plugins.css +1 -1
  76. package/dist/preview.cjs.js +3 -3
  77. package/dist/preview.esm.js +30 -27
  78. package/dist/slash-commands.cjs.js +13 -7
  79. package/dist/slash-commands.esm.js +90 -79
  80. package/dist/smart-paste.cjs.js +5 -5
  81. package/dist/smart-paste.esm.js +85 -81
  82. package/dist/special-characters.cjs.js +6 -3
  83. package/dist/special-characters.esm.js +72 -25
  84. package/dist/spell-check.cjs.js +8 -8
  85. package/dist/spell-check.esm.js +10189 -295
  86. package/dist/table.cjs.js +166 -13
  87. package/dist/table.esm.js +543 -266
  88. package/dist/template.cjs.js +11 -11
  89. package/dist/template.esm.js +290 -264
  90. package/dist/text-color.cjs.js +1 -1
  91. package/dist/text-color.esm.js +1 -1
  92. package/dist/translation-workflow.cjs.js +4 -4
  93. package/dist/translation-workflow.esm.js +33 -31
  94. package/dist/version-diff.cjs.js +6 -6
  95. package/dist/version-diff.esm.js +40 -40
  96. package/package.json +11 -5
  97. package/dist/anchoredPopover-BzqGPOAE.js +0 -1
  98. package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
  99. package/dist/index-CJ90EVWy.mjs +0 -145
  100. package/dist/index-DTkvH8gX.js +0 -1
@@ -1,33 +1,60 @@
1
- const T = () => {
2
- const d = window.getSelection();
3
- if (d && d.rangeCount > 0) {
4
- let t = d.getRangeAt(0).startContainer;
1
+ import { e as U } from "./escapeHtml-DyksyvcZ.mjs";
2
+ import { i as F } from "./dialogHelpers-5d5BuOCW.mjs";
3
+ import { r as P } from "./historyHelpers-BEKwNOtA.mjs";
4
+ const G = /* @__PURE__ */ new Set([
5
+ "DIV",
6
+ "P",
7
+ "BLOCKQUOTE",
8
+ "PRE",
9
+ "H1",
10
+ "H2",
11
+ "H3",
12
+ "H4",
13
+ "H5",
14
+ "H6",
15
+ "LI",
16
+ "TD",
17
+ "TH"
18
+ ]);
19
+ function N(e, o) {
20
+ let t = e;
21
+ for (; t && t !== o; ) {
22
+ if (t.nodeType === Node.ELEMENT_NODE && G.has(t.tagName))
23
+ return t;
24
+ t = t.parentNode;
25
+ }
26
+ return null;
27
+ }
28
+ const I = () => {
29
+ const e = window.getSelection();
30
+ if (e && e.rangeCount > 0) {
31
+ let t = e.getRangeAt(0).startContainer;
5
32
  for (; t && t !== document.body; ) {
6
33
  if (t.nodeType === Node.ELEMENT_NODE) {
7
- const n = t;
8
- if (n.getAttribute("contenteditable") === "true")
9
- return n;
34
+ const a = t;
35
+ if (a.getAttribute("contenteditable") === "true")
36
+ return a;
10
37
  }
11
38
  t = t.parentNode;
12
39
  }
13
40
  }
14
- const r = document.activeElement;
15
- if (r) {
16
- if (r.getAttribute("contenteditable") === "true")
17
- return r;
18
- const t = r.closest('[contenteditable="true"]');
41
+ const o = document.activeElement;
42
+ if (o) {
43
+ if (o.getAttribute("contenteditable") === "true")
44
+ return o;
45
+ const t = o.closest('[contenteditable="true"]');
19
46
  if (t) return t;
20
47
  }
21
48
  return document.querySelector('[contenteditable="true"]');
22
- }, k = '[data-theme="dark"], .dark, .editora-theme-dark', A = () => {
23
- if (T()?.closest(k)) return !0;
24
- const r = window.getSelection();
25
- if (r && r.rangeCount > 0) {
26
- const n = r.getRangeAt(0).startContainer;
27
- if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(k)) return !0;
49
+ }, h = '[data-theme="dark"], .dark, .editora-theme-dark', Z = () => {
50
+ if (I()?.closest(h)) return !0;
51
+ const o = window.getSelection();
52
+ if (o && o.rangeCount > 0) {
53
+ const a = o.getRangeAt(0).startContainer;
54
+ if ((a.nodeType === Node.ELEMENT_NODE ? a : a.parentElement)?.closest(h)) return !0;
28
55
  }
29
- return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
30
- }, M = [
56
+ return document.activeElement?.closest(h) ? !0 : document.body.matches(h) || document.documentElement.matches(h);
57
+ }, J = [
31
58
  { value: "javascript", label: "JavaScript" },
32
59
  { value: "typescript", label: "TypeScript" },
33
60
  { value: "python", label: "Python" },
@@ -52,9 +79,11 @@ const T = () => {
52
79
  { value: "bash", label: "Bash" },
53
80
  { value: "shell", label: "Shell" },
54
81
  { value: "plaintext", label: "Plain Text" }
55
- ], S = /* @__PURE__ */ new Map();
56
- function $(d, r, t, n) {
57
- const s = !!r, c = n || "javascript", f = t || "", p = A(), e = p ? {
82
+ ];
83
+ let C = null;
84
+ function O(e, o, t, a) {
85
+ C && (C.remove(), C = null);
86
+ const i = !!o, B = a || "javascript", s = t || "", c = Z(), n = c ? {
58
87
  overlay: "rgba(0, 0, 0, 0.62)",
59
88
  dialogBg: "#1f2937",
60
89
  dialogBorder: "#4b5563",
@@ -85,23 +114,23 @@ function $(d, r, t, n) {
85
114
  primaryBg: "#2563eb",
86
115
  primaryHover: "#1d4ed8"
87
116
  }, l = document.createElement("div");
88
- l.className = "rte-code-sample-overlay", p && l.classList.add("rte-theme-dark"), l.style.cssText = `
117
+ F(l), l.className = "rte-code-sample-overlay", c && l.classList.add("rte-theme-dark"), l.style.cssText = `
89
118
  position: fixed;
90
119
  top: 0;
91
120
  left: 0;
92
121
  right: 0;
93
122
  bottom: 0;
94
- background: ${e.overlay};
123
+ background: ${n.overlay};
95
124
  display: flex;
96
125
  align-items: center;
97
126
  justify-content: center;
98
127
  z-index: 10000;
99
128
  animation: fadeIn 160ms ease-out;
100
129
  `;
101
- const o = document.createElement("div");
102
- o.className = "rte-code-sample-dialog", o.style.cssText = `
103
- background: ${e.dialogBg};
104
- border: 1px solid ${e.dialogBorder};
130
+ const d = document.createElement("div");
131
+ d.className = "rte-code-sample-dialog", d.style.cssText = `
132
+ background: ${n.dialogBg};
133
+ border: 1px solid ${n.dialogBorder};
105
134
  border-radius: 8px;
106
135
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
107
136
  max-width: 700px;
@@ -111,53 +140,53 @@ function $(d, r, t, n) {
111
140
  flex-direction: column;
112
141
  animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
113
142
  `;
114
- const u = document.createElement("div");
115
- u.style.cssText = `
143
+ const p = document.createElement("div");
144
+ p.style.cssText = `
116
145
  padding: 20px;
117
- border-bottom: 1px solid ${e.border};
118
- background: ${e.headerFooterBg};
146
+ border-bottom: 1px solid ${n.border};
147
+ background: ${n.headerFooterBg};
119
148
  display: flex;
120
149
  justify-content: space-between;
121
150
  align-items: center;
122
- `, u.innerHTML = `
123
- <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${e.text};">
124
- ${s ? "Edit Code Sample" : "Insert Code Sample"}
151
+ `, p.innerHTML = `
152
+ <h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${n.text};">
153
+ ${i ? "Edit Code Sample" : "Insert Code Sample"}
125
154
  </h2>
126
- <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>
155
+ <button class="rte-code-close-btn" style="background: none; border: none; font-size: 28px; color: ${n.mutedText}; cursor: pointer; padding: 0; width: 32px; height: 32px;">×</button>
127
156
  `;
128
- const m = document.createElement("div");
129
- m.style.cssText = `
157
+ const f = document.createElement("div");
158
+ f.style.cssText = `
130
159
  flex: 1;
131
160
  overflow-y: auto;
132
161
  padding: 20px;
133
162
  `;
134
- const i = document.createElement("div");
135
- i.style.marginBottom = "20px", i.innerHTML = `
136
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Language</label>
163
+ const E = document.createElement("div");
164
+ E.style.marginBottom = "20px", E.innerHTML = `
165
+ <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${n.text}; font-size: 14px;">Language</label>
137
166
  <select class="rte-code-language" style="
138
167
  width: 100%;
139
168
  padding: 10px 12px;
140
- border: 1px solid ${e.fieldBorder};
169
+ border: 1px solid ${n.fieldBorder};
141
170
  border-radius: 4px;
142
171
  font-size: 14px;
143
- background-color: ${e.fieldBg};
144
- color: ${e.text};
172
+ background-color: ${n.fieldBg};
173
+ color: ${n.text};
145
174
  cursor: pointer;
146
175
  ">
147
- ${M.map((a) => `
148
- <option value="${a.value}" ${a.value === c ? "selected" : ""}>
149
- ${a.label}
176
+ ${J.map((r) => `
177
+ <option value="${r.value}" ${r.value === B ? "selected" : ""}>
178
+ ${r.label}
150
179
  </option>
151
180
  `).join("")}
152
181
  </select>
153
182
  `;
154
183
  const b = document.createElement("div");
155
184
  b.style.marginBottom = "20px", b.innerHTML = `
156
- <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${e.text}; font-size: 14px;">Code</label>
185
+ <label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${n.text}; font-size: 14px;">Code</label>
157
186
  <textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
158
187
  width: 100%;
159
188
  padding: 12px;
160
- border: 1px solid ${e.fieldBorder};
189
+ border: 1px solid ${n.fieldBorder};
161
190
  border-radius: 4px;
162
191
  font-family: 'Courier New', Courier, monospace;
163
192
  font-size: 13px;
@@ -165,23 +194,23 @@ function $(d, r, t, n) {
165
194
  resize: vertical;
166
195
  min-height: 250px;
167
196
  max-height: 400px;
168
- background-color: ${e.fieldBg};
169
- color: ${e.text};
197
+ background-color: ${n.fieldBg};
198
+ color: ${n.text};
170
199
  box-sizing: border-box;
171
- ">${f}</textarea>
200
+ ">${U(s)}</textarea>
172
201
  <div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
173
202
  `;
174
- const x = document.createElement("div");
175
- 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(i), m.appendChild(b), m.appendChild(x);
176
- const y = document.createElement("div");
177
- y.style.cssText = `
203
+ const L = document.createElement("div");
204
+ L.style.cssText = `color: ${n.mutedText}; font-size: 12px; margin-top: 10px;`, L.innerHTML = "💡 Tip: Press Ctrl+Enter (or Cmd+Enter on Mac) to save, or Escape to cancel", f.appendChild(E), f.appendChild(b), f.appendChild(L);
205
+ const g = document.createElement("div");
206
+ g.style.cssText = `
178
207
  padding: 20px;
179
- border-top: 1px solid ${e.border};
180
- background: ${e.headerFooterBg};
208
+ border-top: 1px solid ${n.border};
209
+ background: ${n.headerFooterBg};
181
210
  display: flex;
182
211
  justify-content: flex-end;
183
212
  gap: 12px;
184
- `, y.innerHTML = `
213
+ `, g.innerHTML = `
185
214
  <button class="rte-code-cancel-btn" style="
186
215
  padding: 10px 16px;
187
216
  border: none;
@@ -189,8 +218,8 @@ function $(d, r, t, n) {
189
218
  font-size: 14px;
190
219
  font-weight: 500;
191
220
  cursor: pointer;
192
- background: ${e.cancelBg};
193
- color: ${e.cancelText};
221
+ background: ${n.cancelBg};
222
+ color: ${n.cancelText};
194
223
  ">Cancel</button>
195
224
  <button class="rte-code-save-btn" style="
196
225
  padding: 10px 16px;
@@ -199,44 +228,44 @@ function $(d, r, t, n) {
199
228
  font-size: 14px;
200
229
  font-weight: 500;
201
230
  cursor: pointer;
202
- background: ${e.primaryBg};
231
+ background: ${n.primaryBg};
203
232
  color: #fff;
204
- ">${s ? "Update Code Sample" : "Insert Code Sample"}</button>
205
- `, o.appendChild(u), o.appendChild(m), o.appendChild(y), l.appendChild(o);
206
- const L = i.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");
207
- g.onmouseover = () => {
208
- g.style.color = "#f8fafc", g.style.background = p ? "#334155" : "#f0f0f0", g.style.borderRadius = "4px";
209
- }, g.onmouseout = () => {
210
- g.style.color = e.mutedText, g.style.background = "none";
211
- }, v.onmouseover = () => {
212
- v.style.background = e.cancelHover;
213
- }, v.onmouseout = () => {
214
- v.style.background = e.cancelBg;
215
- }, h.onmouseover = () => {
216
- h.style.background = e.primaryHover;
217
- }, h.onmouseout = () => {
218
- h.style.background = e.primaryBg;
233
+ ">${i ? "Update Code Sample" : "Insert Code Sample"}</button>
234
+ `, d.appendChild(p), d.appendChild(f), d.appendChild(g), l.appendChild(d);
235
+ const V = E.querySelector(".rte-code-language"), k = b.querySelector(".rte-code-textarea"), $ = b.querySelector(".rte-code-error"), u = p.querySelector(".rte-code-close-btn"), y = g.querySelector(".rte-code-cancel-btn"), x = g.querySelector(".rte-code-save-btn");
236
+ u.onmouseover = () => {
237
+ u.style.color = "#f8fafc", u.style.background = c ? "#334155" : "#f0f0f0", u.style.borderRadius = "4px";
238
+ }, u.onmouseout = () => {
239
+ u.style.color = n.mutedText, u.style.background = "none";
240
+ }, y.onmouseover = () => {
241
+ y.style.background = n.cancelHover;
242
+ }, y.onmouseout = () => {
243
+ y.style.background = n.cancelBg;
244
+ }, x.onmouseover = () => {
245
+ x.style.background = n.primaryHover;
246
+ }, x.onmouseout = () => {
247
+ x.style.background = n.primaryBg;
219
248
  };
220
- const C = () => {
221
- l.remove();
222
- }, B = () => {
223
- const a = E.value.trim();
224
- if (!a) {
225
- w.textContent = "⚠ Code cannot be empty", w.style.display = "block";
249
+ const v = () => {
250
+ l.remove(), C = null;
251
+ }, R = () => {
252
+ const r = k.value.replace(/^(?:[ \t]*\r?\n)+/, "").replace(/\s+$/, "");
253
+ if (!r.trim()) {
254
+ $.textContent = "⚠ Code cannot be empty", $.style.display = "block";
226
255
  return;
227
256
  }
228
- const N = L.value;
229
- d(a, N), C();
257
+ const K = V.value;
258
+ e(r, K), v();
230
259
  };
231
- if (g.onclick = C, v.onclick = C, h.onclick = B, E.addEventListener("keydown", (a) => {
232
- (a.ctrlKey || a.metaKey) && a.key === "Enter" && (a.preventDefault(), B()), a.key === "Escape" && C();
233
- }), E.addEventListener("input", () => {
234
- w.style.display = "none";
235
- }), l.addEventListener("click", (a) => {
236
- a.target === l && C();
260
+ if (u.onclick = v, y.onclick = v, x.onclick = R, k.addEventListener("keydown", (r) => {
261
+ (r.ctrlKey || r.metaKey) && r.key === "Enter" && (r.preventDefault(), R()), r.key === "Escape" && v();
262
+ }), k.addEventListener("input", () => {
263
+ $.style.display = "none";
264
+ }), l.addEventListener("click", (r) => {
265
+ r.target === l && v();
237
266
  }), !document.getElementById("rte-code-sample-animations")) {
238
- const a = document.createElement("style");
239
- a.id = "rte-code-sample-animations", a.textContent = `
267
+ const r = document.createElement("style");
268
+ r.id = "rte-code-sample-animations", r.textContent = `
240
269
  @keyframes fadeIn {
241
270
  from { opacity: 0; }
242
271
  to { opacity: 1; }
@@ -245,50 +274,17 @@ function $(d, r, t, n) {
245
274
  from { transform: translateY(20px); opacity: 0; }
246
275
  to { transform: translateY(0); opacity: 1; }
247
276
  }
248
- `, document.head.appendChild(a);
277
+ `, document.head.appendChild(r);
249
278
  }
250
- return document.body.appendChild(l), setTimeout(() => E.focus(), 100), l;
279
+ return C = l, document.body.appendChild(l), setTimeout(() => k.focus(), 100), l;
251
280
  }
252
- function R() {
253
- if (!T()) return;
254
- let r = null;
255
- const t = window.getSelection();
256
- t && t.rangeCount > 0 && (r = t.getRangeAt(0).cloneRange()), $((n, s) => {
257
- const c = window.getSelection();
258
- if (r && (c?.removeAllRanges(), c?.addRange(r)), !c || c.rangeCount === 0) return;
259
- const f = T();
260
- if (!f) return;
261
- const p = c.anchorNode;
262
- if (!p || !f.contains(p)) return;
263
- const e = c.getRangeAt(0), l = `code-block-${Date.now()}`, o = document.createElement("pre");
264
- o.className = "rte-code-block", o.id = l, o.setAttribute("data-type", "code-block"), o.setAttribute("data-lang", s), o.setAttribute("data-code-id", l), o.setAttribute("contenteditable", "false"), o.style.cssText = `
265
- display: block;
266
- position: relative;
267
- background: #f5f5f5;
268
- border: 1px solid #e0e0e0;
269
- border-radius: 6px;
270
- padding: 12px;
271
- margin: 12px 0;
272
- overflow-x: auto;
273
- font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
274
- font-size: 13px;
275
- line-height: 1.5;
276
- color: #333;
277
- user-select: text;
278
- cursor: default;
279
- `;
280
- const u = document.createElement("code");
281
- u.className = `language-${s}`, u.style.cssText = `
282
- font-family: inherit;
283
- font-size: inherit;
284
- line-height: inherit;
285
- color: inherit;
286
- white-space: pre;
287
- word-break: normal;
288
- display: block;
289
- `, u.textContent = n;
290
- const m = document.createElement("span");
291
- m.style.cssText = `
281
+ const M = 'pre.rte-code-block, pre[data-type="code-block"]';
282
+ function _() {
283
+ if (document.getElementById("rte-code-sample-block-styles")) return;
284
+ const e = document.createElement("style");
285
+ e.id = "rte-code-sample-block-styles", e.textContent = `
286
+ pre.rte-code-block[data-lang]::after {
287
+ content: attr(data-lang);
292
288
  position: absolute;
293
289
  top: 0;
294
290
  right: 0;
@@ -301,68 +297,183 @@ function R() {
301
297
  text-transform: uppercase;
302
298
  letter-spacing: 0.5px;
303
299
  pointer-events: none;
304
- `, m.textContent = s;
305
- const i = document.createElement("button");
306
- i.className = "rte-code-copy", i.textContent = "Copy", i.style.cssText = `
307
- position: absolute;
308
- top: 8px;
309
- left: 8px;
300
+ }
301
+
302
+ pre.rte-code-block:focus-visible {
303
+ outline: 2px solid #2563eb;
304
+ outline-offset: 2px;
305
+ }
306
+
307
+ .rte-code-copy-floating {
308
+ position: fixed;
309
+ z-index: 9999;
310
+ display: none;
310
311
  background: #fff;
312
+ color: #333;
311
313
  border: 1px solid #d0d0d0;
312
314
  border-radius: 3px;
313
315
  padding: 4px 8px;
314
- font-size: 11px;
316
+ font: 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
315
317
  cursor: pointer;
316
- opacity: 0;
317
- transition: opacity 0.2s ease;
318
- `, i.onclick = (x) => {
319
- x.stopPropagation(), navigator.clipboard.writeText(n).then(() => {
320
- i.textContent = "✓ Copied!", setTimeout(() => {
321
- i.textContent = "Copy";
322
- }, 2e3);
323
- });
324
- }, o.appendChild(m), o.appendChild(i), o.appendChild(u), o.addEventListener("mouseenter", () => {
325
- i.style.opacity = "1";
326
- }), o.addEventListener("mouseleave", () => {
327
- i.style.opacity = "0";
328
- }), o.addEventListener("dblclick", () => {
329
- z(l);
330
- }), S.set(l, {
331
- id: l,
332
- language: s,
333
- code: n
334
- }), e.insertNode(o);
335
- const b = document.createRange();
336
- b.setStartAfter(o), b.collapse(!0), c.removeAllRanges(), c.addRange(b);
318
+ }
319
+
320
+ .rte-code-copy-floating:hover {
321
+ background: #f3f4f6;
322
+ }
323
+
324
+ @media print {
325
+ .rte-code-copy-floating {
326
+ display: none !important;
327
+ }
328
+ }
329
+ `, document.head.appendChild(e);
330
+ }
331
+ function q(e) {
332
+ return e.querySelector("code")?.textContent ?? "";
333
+ }
334
+ function Y(e) {
335
+ return e.getAttribute("data-lang") || "plaintext";
336
+ }
337
+ function Q(e, o) {
338
+ const t = document.createElement("pre");
339
+ t.className = "rte-code-block", t.setAttribute("data-type", "code-block"), t.setAttribute("data-lang", o), t.setAttribute("contenteditable", "false"), t.setAttribute("tabindex", "0"), t.setAttribute("role", "group"), t.setAttribute("aria-label", `Code sample (${o}). Press Enter to edit.`), t.style.cssText = `
340
+ display: block;
341
+ position: relative;
342
+ background: #f5f5f5;
343
+ border: 1px solid #e0e0e0;
344
+ border-radius: 6px;
345
+ padding: 30px 12px 12px;
346
+ margin: 12px 0;
347
+ overflow-x: auto;
348
+ font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
349
+ font-size: 13px;
350
+ line-height: 1.5;
351
+ color: #333;
352
+ user-select: text;
353
+ cursor: default;
354
+ `;
355
+ const a = document.createElement("code");
356
+ return a.className = `language-${o}`, a.style.cssText = `
357
+ font-family: inherit;
358
+ font-size: inherit;
359
+ line-height: inherit;
360
+ color: inherit;
361
+ white-space: pre;
362
+ word-break: normal;
363
+ display: block;
364
+ `, a.textContent = e, t.appendChild(a), t;
365
+ }
366
+ function X(e, o, t) {
367
+ let a = e.querySelector("code");
368
+ a || (a = document.createElement("code")), a.textContent = o, a.className = `language-${t}`, Array.from(e.childNodes).forEach((i) => {
369
+ i !== a && e.removeChild(i);
370
+ }), e.appendChild(a), e.setAttribute("data-lang", t), e.setAttribute("aria-label", `Code sample (${t}). Press Enter to edit.`), e.style.paddingTop = "30px";
371
+ }
372
+ let m = null, A = null, T = null, w = null;
373
+ function S() {
374
+ T !== null && (window.clearTimeout(T), T = null);
375
+ }
376
+ function H() {
377
+ S(), m && (m.style.display = "none"), A = null;
378
+ }
379
+ function j() {
380
+ S(), T = window.setTimeout(H, 120);
381
+ }
382
+ async function W(e) {
383
+ try {
384
+ if (navigator.clipboard && window.isSecureContext)
385
+ return await navigator.clipboard.writeText(e), !0;
386
+ } catch {
387
+ }
388
+ const o = document.createElement("textarea");
389
+ o.value = e, o.setAttribute("readonly", ""), o.style.cssText = "position: fixed; top: 0; left: 0; opacity: 0; pointer-events: none;", document.body.appendChild(o);
390
+ const t = window.getSelection(), a = t && t.rangeCount > 0 ? t.getRangeAt(0).cloneRange() : null;
391
+ o.select();
392
+ let i = !1;
393
+ try {
394
+ i = document.execCommand("copy");
395
+ } catch {
396
+ i = !1;
397
+ }
398
+ return o.remove(), a && t && (t.removeAllRanges(), t.addRange(a)), i;
399
+ }
400
+ function ee() {
401
+ if (m && m.isConnected) return m;
402
+ const e = document.createElement("button");
403
+ return e.type = "button", e.className = "rte-code-copy-floating", e.textContent = "Copy", e.setAttribute("aria-label", "Copy code"), e.addEventListener("mousedown", (o) => o.preventDefault()), e.addEventListener("mouseenter", S), e.addEventListener("mouseleave", j), e.addEventListener("click", async (o) => {
404
+ o.stopPropagation();
405
+ const t = A;
406
+ if (!t) return;
407
+ const a = await W(q(t));
408
+ e.textContent = a ? "✓ Copied!" : "Copy failed", w !== null && window.clearTimeout(w), w = window.setTimeout(() => {
409
+ e.textContent = "Copy", w = null;
410
+ }, 2e3);
411
+ }), document.body.appendChild(e), m = e, e;
412
+ }
413
+ function te(e) {
414
+ _();
415
+ const o = ee();
416
+ S(), A = e;
417
+ const t = e.getBoundingClientRect();
418
+ o.style.left = `${Math.max(0, t.left + 8)}px`, o.style.top = `${Math.max(0, t.top + 5)}px`, o.style.display = "block";
419
+ }
420
+ function z(e) {
421
+ return !!e.parentElement?.closest('[contenteditable="true"]');
422
+ }
423
+ function oe() {
424
+ if (typeof document > "u" || window.__codeSampleInteractionsReady) return;
425
+ window.__codeSampleInteractionsReady = !0;
426
+ const e = (o) => (o instanceof Element ? o : o instanceof Node ? o.parentElement : null)?.closest(M) ?? null;
427
+ document.addEventListener("mouseover", (o) => {
428
+ const t = e(o.target);
429
+ t && te(t);
430
+ }), document.addEventListener("mouseout", (o) => {
431
+ e(o.target) && !(o.relatedTarget instanceof Node && m?.contains(o.relatedTarget)) && j();
432
+ }), document.addEventListener("scroll", H, !0), window.addEventListener("resize", H), document.addEventListener("dblclick", (o) => {
433
+ const t = e(o.target);
434
+ t && z(t) && D(t);
435
+ }), document.addEventListener("keydown", (o) => {
436
+ if (o.key !== "Enter" || o.target !== document.activeElement) return;
437
+ const t = o.target instanceof HTMLElement && o.target.matches(M) ? o.target : null;
438
+ t && z(t) && (o.preventDefault(), D(t));
439
+ });
440
+ }
441
+ typeof window < "u" && oe();
442
+ function ne() {
443
+ const e = I();
444
+ if (!e || e.getAttribute("contenteditable") !== "true") return;
445
+ let o = null;
446
+ const t = window.getSelection();
447
+ t && t.rangeCount > 0 && e.contains(t.getRangeAt(0).commonAncestorContainer) && (o = t.getRangeAt(0).cloneRange()), O((a, i) => {
448
+ if (!e.isConnected) return;
449
+ _();
450
+ const B = e.innerHTML, s = Q(a, i), c = o ? o.cloneRange() : document.createRange();
451
+ o || (c.selectNodeContents(e), c.collapse(!1));
452
+ const n = N(c.endContainer, e) || N(c.startContainer, e);
453
+ if (n && n.parentNode ? n.parentNode.insertBefore(s, n.nextSibling) : o ? c.insertNode(s) : e.appendChild(s), !s.nextSibling) {
454
+ const p = document.createElement("p");
455
+ p.appendChild(document.createElement("br")), s.after(p);
456
+ }
457
+ const l = document.createRange();
458
+ l.setStartAfter(s), l.collapse(!0);
459
+ const d = window.getSelection();
460
+ d?.removeAllRanges(), d?.addRange(l), P(e, B), e.dispatchEvent(new Event("input", { bubbles: !0 }));
337
461
  });
338
462
  }
339
- function z(d) {
340
- const r = T();
341
- if (!r) return;
342
- const t = r.querySelector(`#${d}`);
343
- if (!t) return;
344
- const n = S.get(d);
345
- n && $(
346
- (s, c) => {
347
- const f = t.querySelector("code");
348
- f && (f.textContent = s, f.className = `language-${c}`);
349
- const p = t.querySelector("span");
350
- p && (p.textContent = c), t.setAttribute("data-lang", c), n.language = c, n.code = s;
351
- const e = t.querySelector(".rte-code-copy");
352
- e && (e.onclick = (l) => {
353
- l.stopPropagation(), navigator.clipboard.writeText(s).then(() => {
354
- e.textContent = "✓ Copied!", setTimeout(() => {
355
- e.textContent = "Copy";
356
- }, 2e3);
357
- });
358
- });
463
+ function D(e) {
464
+ const o = e.closest('[contenteditable="true"]');
465
+ o && O(
466
+ (t, a) => {
467
+ if (!e.isConnected) return;
468
+ const i = o.innerHTML;
469
+ X(e, t, a), P(o, i), o.dispatchEvent(new Event("input", { bubbles: !0 }));
359
470
  },
360
- d,
361
- n.code,
362
- n.language
471
+ "editing",
472
+ q(e),
473
+ Y(e)
363
474
  );
364
475
  }
365
- const H = () => ({
476
+ const ie = () => ({
366
477
  name: "codeSample",
367
478
  toolbar: [
368
479
  {
@@ -373,9 +484,9 @@ const H = () => ({
373
484
  }
374
485
  ],
375
486
  commands: {
376
- insertCodeBlock: (...d) => (R(), !0)
487
+ insertCodeBlock: () => (ne(), !0)
377
488
  }
378
489
  });
379
490
  export {
380
- H as CodeSamplePlugin
491
+ ie as CodeSamplePlugin
381
492
  };
package/dist/code.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./CodePlugin.native-Cqi46sxh.js");exports.CodePlugin=e.CodePlugin;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./CodePlugin.native-Bwf25lLX.js");exports.CodePlugin=e.CodePlugin;
package/dist/code.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as r } from "./CodePlugin.native-CmnEFfJi.mjs";
1
+ import { C as r } from "./CodePlugin.native-Cpp4u3Jl.mjs";
2
2
  export {
3
3
  r as CodePlugin
4
4
  };