@editora/plugins 1.0.2 → 1.0.4
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 +30 -5
- package/dist/a11y-checker.cjs.js +109 -0
- package/dist/a11y-checker.esm.js +509 -0
- package/dist/anchor.cjs.js +176 -0
- package/dist/anchor.esm.js +400 -0
- package/dist/background-color.cjs.js +218 -0
- package/dist/background-color.esm.js +482 -0
- package/dist/blockquote.cjs.js +1 -0
- package/dist/blockquote.esm.js +47 -0
- package/dist/bold.cjs.js +1 -0
- package/dist/bold.esm.js +44 -0
- package/dist/capitalization.cjs.js +1 -0
- package/dist/capitalization.esm.js +78 -0
- package/dist/checklist.cjs.js +1 -0
- package/dist/checklist.esm.js +305 -0
- package/dist/clear-formatting.cjs.js +1 -0
- package/dist/clear-formatting.esm.js +138 -0
- package/dist/code-sample.cjs.js +161 -0
- package/dist/code-sample.esm.js +381 -0
- package/dist/code.cjs.js +598 -0
- package/dist/code.esm.js +2034 -0
- package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
- package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
- package/dist/comments.cjs.js +354 -0
- package/dist/comments.esm.js +692 -0
- package/dist/direction.cjs.js +1 -0
- package/dist/direction.esm.js +129 -0
- package/dist/document-manager.cjs.js +1 -0
- package/dist/document-manager.esm.js +6 -0
- package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
- package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
- package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
- package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
- package/dist/embed-iframe.cjs.js +361 -0
- package/dist/embed-iframe.esm.js +556 -0
- package/dist/emojis.cjs.js +284 -0
- package/dist/emojis.esm.js +1080 -0
- package/dist/font-family.cjs.js +1 -0
- package/dist/font-family.esm.js +152 -0
- package/dist/font-size.cjs.js +1 -0
- package/dist/font-size.esm.js +278 -0
- package/dist/footnote.cjs.js +85 -0
- package/dist/footnote.esm.js +397 -0
- package/dist/fullscreen.cjs.js +1 -0
- package/dist/fullscreen.esm.js +73 -0
- package/dist/heading.cjs.js +1 -0
- package/dist/heading.esm.js +63 -0
- package/dist/history.cjs.js +1 -0
- package/dist/history.esm.js +246 -0
- package/dist/indent.cjs.js +1 -0
- package/dist/indent.esm.js +146 -0
- package/dist/index-Bskk414V.mjs +145 -0
- package/dist/index-D3pJyAsj.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
- package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
- package/dist/index.esm.js +89 -49
- package/dist/italic.cjs.js +1 -0
- package/dist/italic.esm.js +40 -0
- package/dist/line-height.cjs.js +1 -0
- package/dist/line-height.esm.js +145 -0
- package/dist/link.cjs.js +138 -0
- package/dist/link.esm.js +276 -0
- package/dist/list.cjs.js +1 -0
- package/dist/list.esm.js +102 -0
- package/dist/lite.cjs.js +1 -0
- package/dist/lite.esm.js +61 -0
- package/dist/math.cjs.js +45 -0
- package/dist/math.esm.js +249 -0
- package/dist/media-manager.cjs.js +619 -0
- package/dist/media-manager.esm.js +994 -0
- package/dist/merge-tag.cjs.js +93 -0
- package/dist/merge-tag.esm.js +412 -0
- package/dist/page-break.cjs.js +72 -0
- package/dist/page-break.esm.js +295 -0
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +230 -0
- package/dist/preview.esm.js +321 -0
- package/dist/print.cjs.js +254 -0
- package/dist/print.esm.js +309 -0
- package/dist/purify.es-DHhaBdbu.mjs +470 -0
- package/dist/purify.es-T2a3nLiC.js +3 -0
- package/dist/shared-config.cjs.js +1 -0
- package/dist/shared-config.esm.js +30 -0
- package/dist/special-characters.cjs.js +257 -0
- package/dist/special-characters.esm.js +772 -0
- package/dist/spell-check.cjs.js +512 -0
- package/dist/spell-check.esm.js +1013 -0
- package/dist/strikethrough.cjs.js +1 -0
- package/dist/strikethrough.esm.js +71 -0
- package/dist/table.cjs.js +35 -0
- package/dist/table.esm.js +477 -0
- package/dist/template.cjs.js +356 -0
- package/dist/template.esm.js +560 -0
- package/dist/text-alignment.cjs.js +1 -0
- package/dist/text-alignment.esm.js +105 -0
- package/dist/text-color.cjs.js +300 -0
- package/dist/text-color.esm.js +507 -0
- package/dist/underline.cjs.js +1 -0
- package/dist/underline.esm.js +34 -0
- package/index.d.ts +62 -0
- package/package.json +218 -6
- package/LICENSE +0 -21
- package/dist/index-BbORIHoM.mjs +0 -11763
- package/dist/index-C-OCBS_6.js +0 -3753
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
const w = () => {
|
|
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 n = t;
|
|
8
|
+
if (n.getAttribute("contenteditable") === "true")
|
|
9
|
+
return n;
|
|
10
|
+
}
|
|
11
|
+
t = t.parentNode;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const a = document.activeElement;
|
|
15
|
+
if (a) {
|
|
16
|
+
if (a.getAttribute("contenteditable") === "true")
|
|
17
|
+
return a;
|
|
18
|
+
const t = a.closest('[contenteditable="true"]');
|
|
19
|
+
if (t) return t;
|
|
20
|
+
}
|
|
21
|
+
return document.querySelector('[contenteditable="true"]');
|
|
22
|
+
}, k = '[data-theme="dark"], .dark, .editora-theme-dark', N = () => {
|
|
23
|
+
if (w()?.closest(k)) return !0;
|
|
24
|
+
const a = window.getSelection();
|
|
25
|
+
if (a && a.rangeCount > 0) {
|
|
26
|
+
const n = a.getRangeAt(0).startContainer;
|
|
27
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(k)) return !0;
|
|
28
|
+
}
|
|
29
|
+
return document.activeElement?.closest(k) ? !0 : document.body.matches(k) || document.documentElement.matches(k);
|
|
30
|
+
}, A = [
|
|
31
|
+
{ value: "javascript", label: "JavaScript" },
|
|
32
|
+
{ value: "typescript", label: "TypeScript" },
|
|
33
|
+
{ value: "python", label: "Python" },
|
|
34
|
+
{ value: "java", label: "Java" },
|
|
35
|
+
{ value: "csharp", label: "C#" },
|
|
36
|
+
{ value: "cpp", label: "C++" },
|
|
37
|
+
{ value: "c", label: "C" },
|
|
38
|
+
{ value: "php", label: "PHP" },
|
|
39
|
+
{ value: "ruby", label: "Ruby" },
|
|
40
|
+
{ value: "go", label: "Go" },
|
|
41
|
+
{ value: "rust", label: "Rust" },
|
|
42
|
+
{ value: "swift", label: "Swift" },
|
|
43
|
+
{ value: "kotlin", label: "Kotlin" },
|
|
44
|
+
{ value: "html", label: "HTML" },
|
|
45
|
+
{ value: "css", label: "CSS" },
|
|
46
|
+
{ value: "scss", label: "SCSS" },
|
|
47
|
+
{ value: "json", label: "JSON" },
|
|
48
|
+
{ value: "xml", label: "XML" },
|
|
49
|
+
{ value: "yaml", label: "YAML" },
|
|
50
|
+
{ value: "markdown", label: "Markdown" },
|
|
51
|
+
{ value: "sql", label: "SQL" },
|
|
52
|
+
{ value: "bash", label: "Bash" },
|
|
53
|
+
{ value: "shell", label: "Shell" },
|
|
54
|
+
{ value: "plaintext", label: "Plain Text" }
|
|
55
|
+
], S = /* @__PURE__ */ new Map();
|
|
56
|
+
function $(d, a, t, n) {
|
|
57
|
+
const s = !!a, c = n || "javascript", g = t || "", p = N(), e = p ? {
|
|
58
|
+
overlay: "rgba(0, 0, 0, 0.62)",
|
|
59
|
+
dialogBg: "#1f2937",
|
|
60
|
+
dialogBorder: "#4b5563",
|
|
61
|
+
text: "#e2e8f0",
|
|
62
|
+
mutedText: "#a8b5c8",
|
|
63
|
+
headerFooterBg: "#222d3a",
|
|
64
|
+
border: "#3b4657",
|
|
65
|
+
fieldBg: "#111827",
|
|
66
|
+
fieldBorder: "#4b5563",
|
|
67
|
+
cancelBg: "#334155",
|
|
68
|
+
cancelHover: "#475569",
|
|
69
|
+
cancelText: "#e2e8f0",
|
|
70
|
+
primaryBg: "#3b82f6",
|
|
71
|
+
primaryHover: "#2563eb"
|
|
72
|
+
} : {
|
|
73
|
+
overlay: "rgba(0, 0, 0, 0.5)",
|
|
74
|
+
dialogBg: "#ffffff",
|
|
75
|
+
dialogBorder: "#e0e0e0",
|
|
76
|
+
text: "#333333",
|
|
77
|
+
mutedText: "#666666",
|
|
78
|
+
headerFooterBg: "#ffffff",
|
|
79
|
+
border: "#e0e0e0",
|
|
80
|
+
fieldBg: "#ffffff",
|
|
81
|
+
fieldBorder: "#dddddd",
|
|
82
|
+
cancelBg: "#e5e7eb",
|
|
83
|
+
cancelHover: "#d1d5db",
|
|
84
|
+
cancelText: "#333333",
|
|
85
|
+
primaryBg: "#2563eb",
|
|
86
|
+
primaryHover: "#1d4ed8"
|
|
87
|
+
}, l = document.createElement("div");
|
|
88
|
+
l.className = "rte-code-sample-overlay", p && l.classList.add("rte-theme-dark"), l.style.cssText = `
|
|
89
|
+
position: fixed;
|
|
90
|
+
top: 0;
|
|
91
|
+
left: 0;
|
|
92
|
+
right: 0;
|
|
93
|
+
bottom: 0;
|
|
94
|
+
background: ${e.overlay};
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
justify-content: center;
|
|
98
|
+
z-index: 10000;
|
|
99
|
+
animation: fadeIn 160ms ease-out;
|
|
100
|
+
`;
|
|
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};
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
107
|
+
max-width: 700px;
|
|
108
|
+
width: 90vw;
|
|
109
|
+
max-height: 80vh;
|
|
110
|
+
display: flex;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
animation: slideUp 200ms cubic-bezier(0.2, 0.9, 0.25, 1);
|
|
113
|
+
`;
|
|
114
|
+
const u = document.createElement("div");
|
|
115
|
+
u.style.cssText = `
|
|
116
|
+
padding: 20px;
|
|
117
|
+
border-bottom: 1px solid ${e.border};
|
|
118
|
+
background: ${e.headerFooterBg};
|
|
119
|
+
display: flex;
|
|
120
|
+
justify-content: space-between;
|
|
121
|
+
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"}
|
|
125
|
+
</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>
|
|
127
|
+
`;
|
|
128
|
+
const m = document.createElement("div");
|
|
129
|
+
m.style.cssText = `
|
|
130
|
+
flex: 1;
|
|
131
|
+
overflow-y: auto;
|
|
132
|
+
padding: 20px;
|
|
133
|
+
`;
|
|
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>
|
|
137
|
+
<select class="rte-code-language" style="
|
|
138
|
+
width: 100%;
|
|
139
|
+
padding: 10px 12px;
|
|
140
|
+
border: 1px solid ${e.fieldBorder};
|
|
141
|
+
border-radius: 4px;
|
|
142
|
+
font-size: 14px;
|
|
143
|
+
background-color: ${e.fieldBg};
|
|
144
|
+
color: ${e.text};
|
|
145
|
+
cursor: pointer;
|
|
146
|
+
">
|
|
147
|
+
${A.map((r) => `
|
|
148
|
+
<option value="${r.value}" ${r.value === c ? "selected" : ""}>
|
|
149
|
+
${r.label}
|
|
150
|
+
</option>
|
|
151
|
+
`).join("")}
|
|
152
|
+
</select>
|
|
153
|
+
`;
|
|
154
|
+
const b = document.createElement("div");
|
|
155
|
+
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>
|
|
157
|
+
<textarea class="rte-code-textarea" spellcheck="false" placeholder="Paste or type your code here..." style="
|
|
158
|
+
width: 100%;
|
|
159
|
+
padding: 12px;
|
|
160
|
+
border: 1px solid ${e.fieldBorder};
|
|
161
|
+
border-radius: 4px;
|
|
162
|
+
font-family: 'Courier New', Courier, monospace;
|
|
163
|
+
font-size: 13px;
|
|
164
|
+
line-height: 1.5;
|
|
165
|
+
resize: vertical;
|
|
166
|
+
min-height: 250px;
|
|
167
|
+
max-height: 400px;
|
|
168
|
+
background-color: ${e.fieldBg};
|
|
169
|
+
color: ${e.text};
|
|
170
|
+
box-sizing: border-box;
|
|
171
|
+
">${g}</textarea>
|
|
172
|
+
<div class="rte-code-error" style="color: #dc2626; font-size: 12px; margin-top: 6px; display: none;"></div>
|
|
173
|
+
`;
|
|
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 = `
|
|
178
|
+
padding: 20px;
|
|
179
|
+
border-top: 1px solid ${e.border};
|
|
180
|
+
background: ${e.headerFooterBg};
|
|
181
|
+
display: flex;
|
|
182
|
+
justify-content: flex-end;
|
|
183
|
+
gap: 12px;
|
|
184
|
+
`, y.innerHTML = `
|
|
185
|
+
<button class="rte-code-cancel-btn" style="
|
|
186
|
+
padding: 10px 16px;
|
|
187
|
+
border: none;
|
|
188
|
+
border-radius: 4px;
|
|
189
|
+
font-size: 14px;
|
|
190
|
+
font-weight: 500;
|
|
191
|
+
cursor: pointer;
|
|
192
|
+
background: ${e.cancelBg};
|
|
193
|
+
color: ${e.cancelText};
|
|
194
|
+
">Cancel</button>
|
|
195
|
+
<button class="rte-code-save-btn" style="
|
|
196
|
+
padding: 10px 16px;
|
|
197
|
+
border: none;
|
|
198
|
+
border-radius: 4px;
|
|
199
|
+
font-size: 14px;
|
|
200
|
+
font-weight: 500;
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
background: ${e.primaryBg};
|
|
203
|
+
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"), B = b.querySelector(".rte-code-error"), f = u.querySelector(".rte-code-close-btn"), v = y.querySelector(".rte-code-cancel-btn"), h = y.querySelector(".rte-code-save-btn");
|
|
207
|
+
f.onmouseover = () => {
|
|
208
|
+
f.style.color = "#f8fafc", f.style.background = p ? "#334155" : "#f0f0f0", f.style.borderRadius = "4px";
|
|
209
|
+
}, f.onmouseout = () => {
|
|
210
|
+
f.style.color = e.mutedText, f.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;
|
|
219
|
+
};
|
|
220
|
+
const C = () => {
|
|
221
|
+
l.remove();
|
|
222
|
+
}, T = () => {
|
|
223
|
+
const r = E.value.trim();
|
|
224
|
+
if (!r) {
|
|
225
|
+
B.textContent = "⚠ Code cannot be empty", B.style.display = "block";
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const M = L.value;
|
|
229
|
+
d(r, M), C();
|
|
230
|
+
};
|
|
231
|
+
if (f.onclick = C, v.onclick = C, h.onclick = T, E.addEventListener("keydown", (r) => {
|
|
232
|
+
(r.ctrlKey || r.metaKey) && r.key === "Enter" && (r.preventDefault(), T()), r.key === "Escape" && C();
|
|
233
|
+
}), E.addEventListener("input", () => {
|
|
234
|
+
B.style.display = "none";
|
|
235
|
+
}), l.addEventListener("click", (r) => {
|
|
236
|
+
r.target === l && C();
|
|
237
|
+
}), !document.getElementById("rte-code-sample-animations")) {
|
|
238
|
+
const r = document.createElement("style");
|
|
239
|
+
r.id = "rte-code-sample-animations", r.textContent = `
|
|
240
|
+
@keyframes fadeIn {
|
|
241
|
+
from { opacity: 0; }
|
|
242
|
+
to { opacity: 1; }
|
|
243
|
+
}
|
|
244
|
+
@keyframes slideUp {
|
|
245
|
+
from { transform: translateY(20px); opacity: 0; }
|
|
246
|
+
to { transform: translateY(0); opacity: 1; }
|
|
247
|
+
}
|
|
248
|
+
`, document.head.appendChild(r);
|
|
249
|
+
}
|
|
250
|
+
return document.body.appendChild(l), setTimeout(() => E.focus(), 100), l;
|
|
251
|
+
}
|
|
252
|
+
function R() {
|
|
253
|
+
if (!w()) return;
|
|
254
|
+
let a = null;
|
|
255
|
+
const t = window.getSelection();
|
|
256
|
+
t && t.rangeCount > 0 && (a = t.getRangeAt(0).cloneRange()), $((n, s) => {
|
|
257
|
+
const c = window.getSelection();
|
|
258
|
+
if (a && (c?.removeAllRanges(), c?.addRange(a)), !c || c.rangeCount === 0) return;
|
|
259
|
+
const g = w();
|
|
260
|
+
if (!g) return;
|
|
261
|
+
const p = c.anchorNode;
|
|
262
|
+
if (!p || !g.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 = `
|
|
292
|
+
position: absolute;
|
|
293
|
+
top: 0;
|
|
294
|
+
right: 0;
|
|
295
|
+
background: #333;
|
|
296
|
+
color: #fff;
|
|
297
|
+
padding: 2px 8px;
|
|
298
|
+
font-size: 11px;
|
|
299
|
+
font-weight: bold;
|
|
300
|
+
border-radius: 0 6px 0 4px;
|
|
301
|
+
text-transform: uppercase;
|
|
302
|
+
letter-spacing: 0.5px;
|
|
303
|
+
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;
|
|
310
|
+
background: #fff;
|
|
311
|
+
border: 1px solid #d0d0d0;
|
|
312
|
+
border-radius: 3px;
|
|
313
|
+
padding: 4px 8px;
|
|
314
|
+
font-size: 11px;
|
|
315
|
+
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);
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
function z(d) {
|
|
340
|
+
const a = w();
|
|
341
|
+
if (!a) return;
|
|
342
|
+
const t = a.querySelector(`#${d}`);
|
|
343
|
+
if (!t) return;
|
|
344
|
+
const n = S.get(d);
|
|
345
|
+
n && $(
|
|
346
|
+
(s, c) => {
|
|
347
|
+
const g = t.querySelector("code");
|
|
348
|
+
g && (g.textContent = s, g.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
|
+
});
|
|
359
|
+
},
|
|
360
|
+
d,
|
|
361
|
+
n.code,
|
|
362
|
+
n.language
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const H = () => ({
|
|
366
|
+
name: "codeSample",
|
|
367
|
+
toolbar: [
|
|
368
|
+
{
|
|
369
|
+
label: "Code Block",
|
|
370
|
+
command: "insertCodeBlock",
|
|
371
|
+
icon: '<svg width="18px" height="18px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 8L3 11.6923L7 16M17 8L21 11.6923L17 16M14 4L10 20" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
372
|
+
shortcut: "Mod-Shift-C"
|
|
373
|
+
}
|
|
374
|
+
],
|
|
375
|
+
commands: {
|
|
376
|
+
insertCodeBlock: (...d) => (R(), !0)
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
export {
|
|
380
|
+
H as CodeSamplePlugin
|
|
381
|
+
};
|