@editora/plugins 1.0.16 → 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.
- package/dist/CodePlugin.native-Bwf25lLX.js +460 -0
- package/dist/CodePlugin.native-Cpp4u3Jl.mjs +648 -0
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -669
- package/dist/code.esm.js +2 -4560
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-Jf0RbSks.js → documentManager-BDz6tovy.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-yjRBab4v.mjs} +3 -3
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index-CxhJLMPS.js +221 -0
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +17 -15
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +10 -4
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-BFsKNTTj.mjs +0 -145
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-tqLTHcO6.js +0 -1
package/dist/code-sample.esm.js
CHANGED
|
@@ -1,33 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
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
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
18
|
-
const t =
|
|
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
|
-
},
|
|
23
|
-
if (
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
if ((
|
|
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(
|
|
30
|
-
},
|
|
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
|
-
]
|
|
56
|
-
|
|
57
|
-
|
|
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",
|
|
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: ${
|
|
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
|
|
102
|
-
|
|
103
|
-
background: ${
|
|
104
|
-
border: 1px solid ${
|
|
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
|
|
115
|
-
|
|
143
|
+
const p = document.createElement("div");
|
|
144
|
+
p.style.cssText = `
|
|
116
145
|
padding: 20px;
|
|
117
|
-
border-bottom: 1px solid ${
|
|
118
|
-
background: ${
|
|
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
|
-
`,
|
|
123
|
-
<h2 style="margin: 0; font-size: 18px; font-weight: 600; color: ${
|
|
124
|
-
${
|
|
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: ${
|
|
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
|
|
129
|
-
|
|
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
|
|
135
|
-
|
|
136
|
-
<label style="display: block; margin-bottom: 8px; font-weight: 500; color: ${
|
|
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 ${
|
|
169
|
+
border: 1px solid ${n.fieldBorder};
|
|
141
170
|
border-radius: 4px;
|
|
142
171
|
font-size: 14px;
|
|
143
|
-
background-color: ${
|
|
144
|
-
color: ${
|
|
172
|
+
background-color: ${n.fieldBg};
|
|
173
|
+
color: ${n.text};
|
|
145
174
|
cursor: pointer;
|
|
146
175
|
">
|
|
147
|
-
${
|
|
148
|
-
<option value="${
|
|
149
|
-
${
|
|
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: ${
|
|
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 ${
|
|
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: ${
|
|
169
|
-
color: ${
|
|
197
|
+
background-color: ${n.fieldBg};
|
|
198
|
+
color: ${n.text};
|
|
170
199
|
box-sizing: border-box;
|
|
171
|
-
">${
|
|
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
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
|
|
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 ${
|
|
180
|
-
background: ${
|
|
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
|
-
`,
|
|
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: ${
|
|
193
|
-
color: ${
|
|
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: ${
|
|
231
|
+
background: ${n.primaryBg};
|
|
203
232
|
color: #fff;
|
|
204
|
-
">${
|
|
205
|
-
`,
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
|
|
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
|
|
221
|
-
l.remove();
|
|
222
|
-
},
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
|
|
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
|
|
229
|
-
|
|
257
|
+
const K = V.value;
|
|
258
|
+
e(r, K), v();
|
|
230
259
|
};
|
|
231
|
-
if (
|
|
232
|
-
(
|
|
233
|
-
}),
|
|
234
|
-
|
|
235
|
-
}), l.addEventListener("click", (
|
|
236
|
-
|
|
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
|
|
239
|
-
|
|
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(
|
|
277
|
+
`, document.head.appendChild(r);
|
|
249
278
|
}
|
|
250
|
-
return document.body.appendChild(l), setTimeout(() =>
|
|
279
|
+
return C = l, document.body.appendChild(l), setTimeout(() => k.focus(), 100), l;
|
|
251
280
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
|
316
|
+
font: 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
315
317
|
cursor: pointer;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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
|
-
|
|
361
|
-
|
|
362
|
-
|
|
471
|
+
"editing",
|
|
472
|
+
q(e),
|
|
473
|
+
Y(e)
|
|
363
474
|
);
|
|
364
475
|
}
|
|
365
|
-
const
|
|
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: (
|
|
487
|
+
insertCodeBlock: () => (ne(), !0)
|
|
377
488
|
}
|
|
378
489
|
});
|
|
379
490
|
export {
|
|
380
|
-
|
|
491
|
+
ie as CodeSamplePlugin
|
|
381
492
|
};
|