nextgen-block-editor 0.4.0 → 0.5.1
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/index.cjs +1820 -1119
- package/dist/index.js +1820 -1119
- package/dist/styles.css +746 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,6 +20,824 @@ import Strikethrough from "@sotaproject/strikethrough";
|
|
|
20
20
|
// src/utils/blocksToHtml.ts
|
|
21
21
|
import katex from "katex";
|
|
22
22
|
|
|
23
|
+
// src/blocks/frameBlock.ts
|
|
24
|
+
var DEVICE_OPTIONS = [
|
|
25
|
+
{ id: "iphone", label: "iPhone" },
|
|
26
|
+
{ id: "samsung", label: "Samsung" },
|
|
27
|
+
{ id: "macbook", label: "MacBook" },
|
|
28
|
+
{ id: "laptop", label: "Laptop" },
|
|
29
|
+
{ id: "browser", label: "Browser" }
|
|
30
|
+
];
|
|
31
|
+
function renderFrameMarkup(data) {
|
|
32
|
+
const device = data.device && ["iphone", "samsung", "macbook", "laptop", "browser"].includes(data.device) ? data.device : "iphone";
|
|
33
|
+
const src = String(data.src || "").trim();
|
|
34
|
+
const isIframe = data.contentType === "url";
|
|
35
|
+
const inner = !src ? `<div class="editor-frame-empty">
|
|
36
|
+
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" style="opacity:0.45"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>
|
|
37
|
+
<span>Add an image or URL to preview</span>
|
|
38
|
+
</div>` : isIframe ? `<iframe src="${escHtml(src)}" title="${escHtml(data.caption || device)}" loading="lazy"></iframe>` : `<img src="${escHtml(src)}" alt="${escHtml(data.caption || device)}" loading="lazy" />`;
|
|
39
|
+
let chromeTop = "";
|
|
40
|
+
let chromeBottom = "";
|
|
41
|
+
if (device === "iphone") {
|
|
42
|
+
chromeTop = '<div class="editor-frame-statusbar"><span>9:41</span><div class="editor-frame-island" aria-hidden="true"><span></span></div><span>5G \u25AE\u25AE\u25AE</span></div>';
|
|
43
|
+
chromeBottom = '<div class="editor-frame-homebar" aria-hidden="true"></div>';
|
|
44
|
+
} else if (device === "samsung") {
|
|
45
|
+
chromeTop = '<div class="editor-frame-statusbar"><span>12:45</span><div class="editor-frame-punch" aria-hidden="true"></div><span>5G 100%</span></div>';
|
|
46
|
+
chromeBottom = '<div class="editor-frame-homebar is-pill" aria-hidden="true"></div>';
|
|
47
|
+
} else if (device === "browser") {
|
|
48
|
+
chromeTop = `<div class="editor-frame-browser-bar">
|
|
49
|
+
<span class="editor-frame-dots"><i></i><i></i><i></i></span>
|
|
50
|
+
<span class="editor-frame-nav-icons">\u2190 \u2192 \u21BB</span>
|
|
51
|
+
<span class="editor-frame-addr">\u{1F512} ${escHtml(data.address || src || "https://nextgen-editor.dev")}</span>
|
|
52
|
+
</div>`;
|
|
53
|
+
} else if (device === "macbook") {
|
|
54
|
+
chromeTop = '<div class="editor-frame-notch" aria-hidden="true"><span></span></div>';
|
|
55
|
+
} else {
|
|
56
|
+
chromeTop = '<div class="editor-frame-cam" aria-hidden="true"></div>';
|
|
57
|
+
}
|
|
58
|
+
const base = device === "macbook" || device === "laptop" ? `<div class="editor-frame-base is-${device}" aria-hidden="true"><div class="editor-frame-hinge"></div></div>` : "";
|
|
59
|
+
const caption = data.caption ? `<figcaption class="editor-frame-caption">${escHtml(data.caption)}</figcaption>` : "";
|
|
60
|
+
return `<figure class="editor-frame-block" data-device="${device}">
|
|
61
|
+
<div class="editor-frame-shell is-${device}">
|
|
62
|
+
${chromeTop}
|
|
63
|
+
<div class="editor-frame-screen">${inner}</div>
|
|
64
|
+
${chromeBottom}
|
|
65
|
+
</div>
|
|
66
|
+
${base}
|
|
67
|
+
${caption}
|
|
68
|
+
</figure>`;
|
|
69
|
+
}
|
|
70
|
+
var FrameTool = class {
|
|
71
|
+
data;
|
|
72
|
+
static get toolbox() {
|
|
73
|
+
return {
|
|
74
|
+
title: "Device Frame",
|
|
75
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="2" width="14" height="20" rx="2"/><line x1="12" y1="18" x2="12.01" y2="18"/></svg>'
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
constructor({ data }) {
|
|
79
|
+
this.data = {
|
|
80
|
+
device: data?.device ?? "iphone",
|
|
81
|
+
contentType: data?.contentType ?? "image",
|
|
82
|
+
src: data?.src ?? "",
|
|
83
|
+
address: data?.address ?? "https://nextgen-editor.dev",
|
|
84
|
+
caption: data?.caption ?? ""
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
const wrap = document.createElement("div");
|
|
89
|
+
wrap.className = "editor-extra-card";
|
|
90
|
+
const head = document.createElement("div");
|
|
91
|
+
head.className = "editor-extra-head";
|
|
92
|
+
head.textContent = "Device Mockup Frame";
|
|
93
|
+
const controls = document.createElement("div");
|
|
94
|
+
controls.className = "editor-frame-controls";
|
|
95
|
+
const deviceSelect = document.createElement("select");
|
|
96
|
+
deviceSelect.className = "cdx-input editor-form-select";
|
|
97
|
+
DEVICE_OPTIONS.forEach((opt) => {
|
|
98
|
+
const o = document.createElement("option");
|
|
99
|
+
o.value = opt.id;
|
|
100
|
+
o.textContent = opt.label;
|
|
101
|
+
if (this.data.device === opt.id) o.selected = true;
|
|
102
|
+
deviceSelect.appendChild(o);
|
|
103
|
+
});
|
|
104
|
+
const typeSelect = document.createElement("select");
|
|
105
|
+
typeSelect.className = "cdx-input editor-form-select";
|
|
106
|
+
[
|
|
107
|
+
{ id: "image", label: "Image / Screenshot" },
|
|
108
|
+
{ id: "url", label: "Live URL (iframe)" }
|
|
109
|
+
].forEach((opt) => {
|
|
110
|
+
const o = document.createElement("option");
|
|
111
|
+
o.value = opt.id;
|
|
112
|
+
o.textContent = opt.label;
|
|
113
|
+
if (this.data.contentType === opt.id) o.selected = true;
|
|
114
|
+
typeSelect.appendChild(o);
|
|
115
|
+
});
|
|
116
|
+
const srcInput = document.createElement("input");
|
|
117
|
+
srcInput.type = "url";
|
|
118
|
+
srcInput.className = "cdx-input";
|
|
119
|
+
srcInput.placeholder = "Image URL or Website URL (https://...)";
|
|
120
|
+
srcInput.value = this.data.src;
|
|
121
|
+
const uploadInput = document.createElement("input");
|
|
122
|
+
uploadInput.type = "file";
|
|
123
|
+
uploadInput.accept = "image/*";
|
|
124
|
+
uploadInput.className = "cdx-input";
|
|
125
|
+
const addrInput = document.createElement("input");
|
|
126
|
+
addrInput.type = "text";
|
|
127
|
+
addrInput.className = "cdx-input";
|
|
128
|
+
addrInput.placeholder = "Browser address bar text (optional)";
|
|
129
|
+
addrInput.value = this.data.address || "";
|
|
130
|
+
const capInput = document.createElement("input");
|
|
131
|
+
capInput.type = "text";
|
|
132
|
+
capInput.className = "cdx-input";
|
|
133
|
+
capInput.placeholder = "Optional caption";
|
|
134
|
+
capInput.value = this.data.caption || "";
|
|
135
|
+
const preview = document.createElement("div");
|
|
136
|
+
const refresh = () => {
|
|
137
|
+
preview.innerHTML = renderFrameMarkup(this.data);
|
|
138
|
+
};
|
|
139
|
+
deviceSelect.addEventListener("change", () => {
|
|
140
|
+
this.data.device = deviceSelect.value;
|
|
141
|
+
refresh();
|
|
142
|
+
});
|
|
143
|
+
typeSelect.addEventListener("change", () => {
|
|
144
|
+
this.data.contentType = typeSelect.value;
|
|
145
|
+
refresh();
|
|
146
|
+
});
|
|
147
|
+
srcInput.addEventListener("input", () => {
|
|
148
|
+
this.data.src = srcInput.value;
|
|
149
|
+
refresh();
|
|
150
|
+
});
|
|
151
|
+
addrInput.addEventListener("input", () => {
|
|
152
|
+
this.data.address = addrInput.value;
|
|
153
|
+
refresh();
|
|
154
|
+
});
|
|
155
|
+
capInput.addEventListener("input", () => {
|
|
156
|
+
this.data.caption = capInput.value;
|
|
157
|
+
refresh();
|
|
158
|
+
});
|
|
159
|
+
uploadInput.addEventListener("change", async () => {
|
|
160
|
+
const file = uploadInput.files?.[0];
|
|
161
|
+
if (!file) return;
|
|
162
|
+
const uploaded = await uploadFileToBucket(file, "frames");
|
|
163
|
+
if (uploaded) {
|
|
164
|
+
this.data.contentType = "image";
|
|
165
|
+
typeSelect.value = "image";
|
|
166
|
+
this.data.src = uploaded;
|
|
167
|
+
srcInput.value = uploaded;
|
|
168
|
+
refresh();
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
controls.append(deviceSelect, typeSelect);
|
|
172
|
+
refresh();
|
|
173
|
+
wrap.append(head, controls, srcInput, uploadInput, addrInput, capInput, preview);
|
|
174
|
+
return wrap;
|
|
175
|
+
}
|
|
176
|
+
save() {
|
|
177
|
+
return {
|
|
178
|
+
device: this.data.device,
|
|
179
|
+
contentType: this.data.contentType,
|
|
180
|
+
src: this.data.src.trim(),
|
|
181
|
+
address: this.data.address?.trim() || void 0,
|
|
182
|
+
caption: this.data.caption?.trim() || void 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// src/blocks/extraBlocks.ts
|
|
188
|
+
function createInput(type, className, placeholder, value, onInput) {
|
|
189
|
+
const input = document.createElement("input");
|
|
190
|
+
input.type = type;
|
|
191
|
+
input.className = className;
|
|
192
|
+
input.placeholder = placeholder;
|
|
193
|
+
input.value = value;
|
|
194
|
+
input.addEventListener("input", () => onInput(input.value));
|
|
195
|
+
return input;
|
|
196
|
+
}
|
|
197
|
+
function createTextarea(className, rows, placeholder, value, onInput) {
|
|
198
|
+
const ta = document.createElement("textarea");
|
|
199
|
+
ta.className = className;
|
|
200
|
+
ta.rows = rows;
|
|
201
|
+
ta.placeholder = placeholder;
|
|
202
|
+
ta.value = value;
|
|
203
|
+
ta.addEventListener("input", () => onInput(ta.value));
|
|
204
|
+
return ta;
|
|
205
|
+
}
|
|
206
|
+
var BookmarkTool = class {
|
|
207
|
+
data;
|
|
208
|
+
static get toolbox() {
|
|
209
|
+
return {
|
|
210
|
+
title: "Bookmark",
|
|
211
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z"/></svg>'
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
constructor({ data }) {
|
|
215
|
+
this.data = {
|
|
216
|
+
url: data?.url ?? "",
|
|
217
|
+
title: data?.title ?? "",
|
|
218
|
+
description: data?.description ?? "",
|
|
219
|
+
image: data?.image ?? ""
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
render() {
|
|
223
|
+
const wrap = document.createElement("div");
|
|
224
|
+
wrap.className = "editor-extra-card";
|
|
225
|
+
const head = document.createElement("div");
|
|
226
|
+
head.className = "editor-extra-head";
|
|
227
|
+
head.textContent = "URL Bookmark Card";
|
|
228
|
+
const preview = document.createElement("div");
|
|
229
|
+
preview.className = "editor-bookmark-preview";
|
|
230
|
+
const refreshPreview = () => {
|
|
231
|
+
const host = (() => {
|
|
232
|
+
try {
|
|
233
|
+
return this.data.url ? new URL(this.data.url).hostname : "example.com";
|
|
234
|
+
} catch {
|
|
235
|
+
return this.data.url || "example.com";
|
|
236
|
+
}
|
|
237
|
+
})();
|
|
238
|
+
preview.innerHTML = `
|
|
239
|
+
<div class="editor-bookmark-card">
|
|
240
|
+
<div class="editor-bookmark-body">
|
|
241
|
+
<div class="editor-bookmark-title">${escHtml(this.data.title || host)}</div>
|
|
242
|
+
${this.data.description ? `<div class="editor-bookmark-desc">${escHtml(this.data.description)}</div>` : ""}
|
|
243
|
+
<div class="editor-bookmark-url">${escHtml(host)}</div>
|
|
244
|
+
</div>
|
|
245
|
+
${this.data.image ? `<img class="editor-bookmark-thumb" src="${escHtml(this.data.image)}" alt="" />` : ""}
|
|
246
|
+
</div>`;
|
|
247
|
+
};
|
|
248
|
+
const grid = document.createElement("div");
|
|
249
|
+
grid.className = "editor-extra-grid";
|
|
250
|
+
grid.append(
|
|
251
|
+
createInput("url", "cdx-input", "https://example.com/article", this.data.url, (v) => {
|
|
252
|
+
this.data.url = v;
|
|
253
|
+
refreshPreview();
|
|
254
|
+
}),
|
|
255
|
+
createInput("text", "cdx-input", "Link title", this.data.title, (v) => {
|
|
256
|
+
this.data.title = v;
|
|
257
|
+
refreshPreview();
|
|
258
|
+
}),
|
|
259
|
+
createInput("text", "cdx-input", "Short description", this.data.description, (v) => {
|
|
260
|
+
this.data.description = v;
|
|
261
|
+
refreshPreview();
|
|
262
|
+
}),
|
|
263
|
+
createInput("url", "cdx-input", "Optional thumbnail URL", this.data.image || "", (v) => {
|
|
264
|
+
this.data.image = v;
|
|
265
|
+
refreshPreview();
|
|
266
|
+
})
|
|
267
|
+
);
|
|
268
|
+
refreshPreview();
|
|
269
|
+
wrap.append(head, grid, preview);
|
|
270
|
+
return wrap;
|
|
271
|
+
}
|
|
272
|
+
save() {
|
|
273
|
+
return {
|
|
274
|
+
url: this.data.url.trim(),
|
|
275
|
+
title: this.data.title.trim(),
|
|
276
|
+
description: this.data.description.trim(),
|
|
277
|
+
image: this.data.image?.trim() || void 0
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var StepsTool = class {
|
|
282
|
+
data;
|
|
283
|
+
static get toolbox() {
|
|
284
|
+
return {
|
|
285
|
+
title: "Steps",
|
|
286
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/></svg>'
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
constructor({ data }) {
|
|
290
|
+
this.data = {
|
|
291
|
+
items: Array.isArray(data?.items) && data.items.length > 0 ? data.items.map((item) => ({ title: item.title || "", body: item.body || "" })) : [
|
|
292
|
+
{ title: "Install dependencies", body: "Run npm install to set up the package." },
|
|
293
|
+
{ title: "Configure & render", body: "Pass initialData and onChange to BlockEditor." }
|
|
294
|
+
]
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
render() {
|
|
298
|
+
const wrap = document.createElement("div");
|
|
299
|
+
wrap.className = "editor-extra-card";
|
|
300
|
+
const head = document.createElement("div");
|
|
301
|
+
head.className = "editor-extra-head";
|
|
302
|
+
head.textContent = "Step-by-Step Walkthrough";
|
|
303
|
+
const list = document.createElement("div");
|
|
304
|
+
list.className = "editor-steps-editor-list";
|
|
305
|
+
const renderList = () => {
|
|
306
|
+
list.innerHTML = "";
|
|
307
|
+
this.data.items.forEach((item, idx) => {
|
|
308
|
+
const row = document.createElement("div");
|
|
309
|
+
row.className = "editor-step-editor-row";
|
|
310
|
+
const badge = document.createElement("span");
|
|
311
|
+
badge.className = "editor-step-badge";
|
|
312
|
+
badge.textContent = String(idx + 1);
|
|
313
|
+
const fields = document.createElement("div");
|
|
314
|
+
fields.className = "editor-step-editor-fields";
|
|
315
|
+
fields.append(
|
|
316
|
+
createInput("text", "cdx-input", `Step ${idx + 1} title`, item.title, (v) => {
|
|
317
|
+
item.title = v;
|
|
318
|
+
}),
|
|
319
|
+
createTextarea("cdx-input", 2, "Step details", item.body, (v) => {
|
|
320
|
+
item.body = v;
|
|
321
|
+
})
|
|
322
|
+
);
|
|
323
|
+
const removeBtn = document.createElement("button");
|
|
324
|
+
removeBtn.type = "button";
|
|
325
|
+
removeBtn.className = "excalidraw-btn";
|
|
326
|
+
removeBtn.textContent = "\xD7";
|
|
327
|
+
removeBtn.title = "Remove step";
|
|
328
|
+
removeBtn.addEventListener("click", () => {
|
|
329
|
+
if (this.data.items.length <= 1) return;
|
|
330
|
+
this.data.items.splice(idx, 1);
|
|
331
|
+
renderList();
|
|
332
|
+
});
|
|
333
|
+
row.append(badge, fields, removeBtn);
|
|
334
|
+
list.appendChild(row);
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const addBtn = document.createElement("button");
|
|
338
|
+
addBtn.type = "button";
|
|
339
|
+
addBtn.className = "excalidraw-btn";
|
|
340
|
+
addBtn.textContent = "+ Add Step";
|
|
341
|
+
addBtn.addEventListener("click", () => {
|
|
342
|
+
this.data.items.push({ title: "", body: "" });
|
|
343
|
+
renderList();
|
|
344
|
+
});
|
|
345
|
+
renderList();
|
|
346
|
+
wrap.append(head, list, addBtn);
|
|
347
|
+
return wrap;
|
|
348
|
+
}
|
|
349
|
+
save() {
|
|
350
|
+
return {
|
|
351
|
+
items: this.data.items.filter((i) => i.title.trim() || i.body.trim())
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
function computeSimpleDiff(before, after) {
|
|
356
|
+
const a = before.split("\n");
|
|
357
|
+
const b = after.split("\n");
|
|
358
|
+
const lines = [];
|
|
359
|
+
const max = Math.max(a.length, b.length);
|
|
360
|
+
for (let i = 0; i < max; i += 1) {
|
|
361
|
+
const left = a[i];
|
|
362
|
+
const right = b[i];
|
|
363
|
+
if (left === right) {
|
|
364
|
+
if (left !== void 0) lines.push({ kind: "same", text: left });
|
|
365
|
+
} else {
|
|
366
|
+
if (left !== void 0) lines.push({ kind: "del", text: left });
|
|
367
|
+
if (right !== void 0) lines.push({ kind: "add", text: right });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return lines;
|
|
371
|
+
}
|
|
372
|
+
var DiffTool = class {
|
|
373
|
+
data;
|
|
374
|
+
static get toolbox() {
|
|
375
|
+
return {
|
|
376
|
+
title: "Code Diff",
|
|
377
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v14"/><path d="M5 10h14"/><path d="M5 21h14"/></svg>'
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
constructor({ data }) {
|
|
381
|
+
this.data = {
|
|
382
|
+
filename: data?.filename ?? "example.ts",
|
|
383
|
+
before: data?.before ?? 'const theme = "catppuccin";',
|
|
384
|
+
after: data?.after ?? 'const theme = "dark";'
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
render() {
|
|
388
|
+
const wrap = document.createElement("div");
|
|
389
|
+
wrap.className = "editor-extra-card";
|
|
390
|
+
const head = document.createElement("div");
|
|
391
|
+
head.className = "editor-extra-head";
|
|
392
|
+
head.textContent = "Code Diff Viewer";
|
|
393
|
+
const preview = document.createElement("pre");
|
|
394
|
+
preview.className = "editor-diff-preview";
|
|
395
|
+
const refreshPreview = () => {
|
|
396
|
+
const diffLines = computeSimpleDiff(this.data.before, this.data.after);
|
|
397
|
+
preview.innerHTML = diffLines.map((line) => {
|
|
398
|
+
const prefix = line.kind === "del" ? "-" : line.kind === "add" ? "+" : " ";
|
|
399
|
+
return `<span class="editor-diff-line is-${line.kind}">${prefix} ${escHtml(line.text)}</span>`;
|
|
400
|
+
}).join("\n");
|
|
401
|
+
};
|
|
402
|
+
const cols = document.createElement("div");
|
|
403
|
+
cols.className = "editor-diff-inputs";
|
|
404
|
+
cols.append(
|
|
405
|
+
createTextarea("editor-mermaid-input", 4, "Before code...", this.data.before, (v) => {
|
|
406
|
+
this.data.before = v;
|
|
407
|
+
refreshPreview();
|
|
408
|
+
}),
|
|
409
|
+
createTextarea("editor-mermaid-input", 4, "After code...", this.data.after, (v) => {
|
|
410
|
+
this.data.after = v;
|
|
411
|
+
refreshPreview();
|
|
412
|
+
})
|
|
413
|
+
);
|
|
414
|
+
const fileInput = createInput("text", "cdx-input", "Filename (optional)", this.data.filename || "", (v) => {
|
|
415
|
+
this.data.filename = v;
|
|
416
|
+
});
|
|
417
|
+
refreshPreview();
|
|
418
|
+
wrap.append(head, fileInput, cols, preview);
|
|
419
|
+
return wrap;
|
|
420
|
+
}
|
|
421
|
+
save() {
|
|
422
|
+
return {
|
|
423
|
+
filename: this.data.filename?.trim() || void 0,
|
|
424
|
+
before: this.data.before,
|
|
425
|
+
after: this.data.after
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
var VideoTool = class {
|
|
430
|
+
data;
|
|
431
|
+
static get toolbox() {
|
|
432
|
+
return {
|
|
433
|
+
title: "Video Player",
|
|
434
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="6 3 20 12 6 21 6 3"/></svg>'
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
constructor({ data }) {
|
|
438
|
+
this.data = {
|
|
439
|
+
url: data?.url ?? "",
|
|
440
|
+
poster: data?.poster ?? "",
|
|
441
|
+
caption: data?.caption ?? ""
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
render() {
|
|
445
|
+
const wrap = document.createElement("div");
|
|
446
|
+
wrap.className = "editor-extra-card";
|
|
447
|
+
const head = document.createElement("div");
|
|
448
|
+
head.className = "editor-extra-head";
|
|
449
|
+
head.textContent = "Video Player (MP4 / WebM)";
|
|
450
|
+
const preview = document.createElement("div");
|
|
451
|
+
preview.className = "editor-video-preview";
|
|
452
|
+
const refreshPreview = () => {
|
|
453
|
+
if (!this.data.url.trim()) {
|
|
454
|
+
preview.innerHTML = '<div class="editor-mermaid-empty">Paste a video URL or upload a file</div>';
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
preview.innerHTML = `<video controls preload="metadata" class="editor-video-el"${this.data.poster ? ` poster="${escHtml(this.data.poster)}"` : ""}><source src="${escHtml(this.data.url)}" /></video>`;
|
|
458
|
+
};
|
|
459
|
+
const urlInput = createInput("url", "cdx-input", "https://.../video.mp4", this.data.url, (v) => {
|
|
460
|
+
this.data.url = v;
|
|
461
|
+
refreshPreview();
|
|
462
|
+
});
|
|
463
|
+
const uploadInput = document.createElement("input");
|
|
464
|
+
uploadInput.type = "file";
|
|
465
|
+
uploadInput.accept = "video/mp4,video/webm,video/ogg";
|
|
466
|
+
uploadInput.className = "cdx-input";
|
|
467
|
+
uploadInput.addEventListener("change", async () => {
|
|
468
|
+
const file = uploadInput.files?.[0];
|
|
469
|
+
if (!file) return;
|
|
470
|
+
const uploaded = await uploadFileToBucket(file, "videos");
|
|
471
|
+
if (uploaded) {
|
|
472
|
+
this.data.url = uploaded;
|
|
473
|
+
urlInput.value = uploaded;
|
|
474
|
+
refreshPreview();
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
const posterInput = createInput("url", "cdx-input", "Optional poster image URL", this.data.poster || "", (v) => {
|
|
478
|
+
this.data.poster = v;
|
|
479
|
+
refreshPreview();
|
|
480
|
+
});
|
|
481
|
+
const captionInput = createInput("text", "cdx-input", "Optional video caption", this.data.caption || "", (v) => {
|
|
482
|
+
this.data.caption = v;
|
|
483
|
+
});
|
|
484
|
+
refreshPreview();
|
|
485
|
+
wrap.append(head, urlInput, uploadInput, posterInput, captionInput, preview);
|
|
486
|
+
return wrap;
|
|
487
|
+
}
|
|
488
|
+
save() {
|
|
489
|
+
return {
|
|
490
|
+
url: this.data.url.trim(),
|
|
491
|
+
poster: this.data.poster?.trim() || void 0,
|
|
492
|
+
caption: this.data.caption?.trim() || void 0
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
var ChangelogTool = class {
|
|
497
|
+
data;
|
|
498
|
+
static get toolbox() {
|
|
499
|
+
return {
|
|
500
|
+
title: "Changelog",
|
|
501
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M16 13H8"/><path d="M16 17H8"/></svg>'
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
constructor({ data }) {
|
|
505
|
+
this.data = {
|
|
506
|
+
version: data?.version ?? "v1.0.0",
|
|
507
|
+
date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
508
|
+
items: Array.isArray(data?.items) && data.items.length > 0 ? data.items.map((i) => ({ kind: i.kind || "added", text: i.text || "" })) : [{ kind: "added", text: "Initial release notes" }]
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
render() {
|
|
512
|
+
const wrap = document.createElement("div");
|
|
513
|
+
wrap.className = "editor-extra-card";
|
|
514
|
+
const head = document.createElement("div");
|
|
515
|
+
head.className = "editor-extra-head";
|
|
516
|
+
head.textContent = "Release Changelog";
|
|
517
|
+
const meta = document.createElement("div");
|
|
518
|
+
meta.className = "editor-diff-inputs";
|
|
519
|
+
meta.append(
|
|
520
|
+
createInput("text", "cdx-input", "Version (e.g. v1.2.0)", this.data.version, (v) => {
|
|
521
|
+
this.data.version = v;
|
|
522
|
+
}),
|
|
523
|
+
createInput("date", "cdx-input", "Release date", this.data.date, (v) => {
|
|
524
|
+
this.data.date = v;
|
|
525
|
+
})
|
|
526
|
+
);
|
|
527
|
+
const list = document.createElement("div");
|
|
528
|
+
list.className = "editor-steps-editor-list";
|
|
529
|
+
const renderItems = () => {
|
|
530
|
+
list.innerHTML = "";
|
|
531
|
+
this.data.items.forEach((item, idx) => {
|
|
532
|
+
const row = document.createElement("div");
|
|
533
|
+
row.className = "editor-changelog-row";
|
|
534
|
+
const select = document.createElement("select");
|
|
535
|
+
select.className = `cdx-input editor-form-select editor-changelog-select is-${item.kind}`;
|
|
536
|
+
["added", "changed", "fixed"].forEach((k) => {
|
|
537
|
+
const opt = document.createElement("option");
|
|
538
|
+
opt.value = k;
|
|
539
|
+
opt.textContent = k.toUpperCase();
|
|
540
|
+
if (item.kind === k) opt.selected = true;
|
|
541
|
+
select.appendChild(opt);
|
|
542
|
+
});
|
|
543
|
+
select.addEventListener("change", () => {
|
|
544
|
+
item.kind = select.value;
|
|
545
|
+
select.className = `cdx-input editor-form-select editor-changelog-select is-${item.kind}`;
|
|
546
|
+
});
|
|
547
|
+
const text = createInput("text", "cdx-input", "Change description", item.text, (v) => {
|
|
548
|
+
item.text = v;
|
|
549
|
+
});
|
|
550
|
+
const del = document.createElement("button");
|
|
551
|
+
del.type = "button";
|
|
552
|
+
del.className = "excalidraw-btn";
|
|
553
|
+
del.textContent = "\xD7";
|
|
554
|
+
del.addEventListener("click", () => {
|
|
555
|
+
if (this.data.items.length <= 1) return;
|
|
556
|
+
this.data.items.splice(idx, 1);
|
|
557
|
+
renderItems();
|
|
558
|
+
});
|
|
559
|
+
row.append(select, text, del);
|
|
560
|
+
list.appendChild(row);
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
const addBtn = document.createElement("button");
|
|
564
|
+
addBtn.type = "button";
|
|
565
|
+
addBtn.className = "excalidraw-btn";
|
|
566
|
+
addBtn.textContent = "+ Add Entry";
|
|
567
|
+
addBtn.addEventListener("click", () => {
|
|
568
|
+
this.data.items.push({ kind: "added", text: "" });
|
|
569
|
+
renderItems();
|
|
570
|
+
});
|
|
571
|
+
renderItems();
|
|
572
|
+
wrap.append(head, meta, list, addBtn);
|
|
573
|
+
return wrap;
|
|
574
|
+
}
|
|
575
|
+
save() {
|
|
576
|
+
return {
|
|
577
|
+
version: this.data.version.trim() || "v1.0.0",
|
|
578
|
+
date: this.data.date,
|
|
579
|
+
items: this.data.items.filter((i) => i.text.trim())
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
function renderSocialMarkup(d) {
|
|
584
|
+
const platform = d.platform && ["x", "linkedin", "instagram"].includes(d.platform) ? d.platform : "x";
|
|
585
|
+
const align = d.align && ["left", "center", "right"].includes(d.align) ? d.align : "center";
|
|
586
|
+
const author = escHtml(d.author || "Alex Rivera");
|
|
587
|
+
const handle = escHtml(d.handle || "@alexrivera");
|
|
588
|
+
const role = escHtml(d.role || d.handle || "Staff Engineer at NextGen");
|
|
589
|
+
const date = escHtml(d.date || "2h");
|
|
590
|
+
const text = escHtml(d.text || "");
|
|
591
|
+
const initials = String(d.author || "A").trim().slice(0, 2).toUpperCase();
|
|
592
|
+
const postLink = d.url ? `<a class="editor-social-link" href="${escHtml(
|
|
593
|
+
d.url
|
|
594
|
+
)}" target="_blank" rel="noopener noreferrer">Open \u2197</a>` : "";
|
|
595
|
+
if (platform === "linkedin") {
|
|
596
|
+
return `<div class="editor-social-wrap" data-align="${align}">
|
|
597
|
+
<blockquote class="editor-social-card is-linkedin">
|
|
598
|
+
<div class="editor-social-top">
|
|
599
|
+
<div class="editor-social-avatar is-linkedin" aria-hidden="true">${escHtml(initials)}</div>
|
|
600
|
+
<div class="editor-social-meta">
|
|
601
|
+
<div class="editor-social-name-row"><strong>${author}</strong><span class="editor-social-conn">\u2022 1st</span></div>
|
|
602
|
+
<span class="editor-social-sub">${role}</span>
|
|
603
|
+
<span class="editor-social-sub">${date} \xB7 \u{1F310}</span>
|
|
604
|
+
</div>
|
|
605
|
+
<span class="editor-social-li-logo" aria-label="LinkedIn">in</span>
|
|
606
|
+
</div>
|
|
607
|
+
<p class="editor-social-text">${text}</p>
|
|
608
|
+
${d.imageUrl ? `<img class="editor-social-media" src="${escHtml(d.imageUrl)}" alt="" loading="lazy" />` : ""}
|
|
609
|
+
<div class="editor-social-li-stats"><span>\u{1F44D} \u{1F44F} \u{1F4A1} 148</span><span>18 comments \xB7 9 reposts</span></div>
|
|
610
|
+
<div class="editor-social-foot is-linkedin">
|
|
611
|
+
<span>\u{1F44D} Like</span><span>\u{1F4AC} Comment</span><span>\u21BB Repost</span><span>\u27A4 Send</span>${postLink}
|
|
612
|
+
</div>
|
|
613
|
+
</blockquote>
|
|
614
|
+
</div>`;
|
|
615
|
+
}
|
|
616
|
+
if (platform === "instagram") {
|
|
617
|
+
const mediaHtml = d.imageUrl ? `<img class="editor-social-ig-media" src="${escHtml(d.imageUrl)}" alt="" loading="lazy" />` : `<div class="editor-social-ig-placeholder"><span>\u25CE</span><p>${text}</p></div>`;
|
|
618
|
+
return `<div class="editor-social-wrap" data-align="${align}">
|
|
619
|
+
<blockquote class="editor-social-card is-instagram">
|
|
620
|
+
<div class="editor-social-top is-instagram">
|
|
621
|
+
<div class="editor-social-ig-ring"><div class="editor-social-avatar is-instagram" aria-hidden="true">${escHtml(initials)}</div></div>
|
|
622
|
+
<div class="editor-social-meta">
|
|
623
|
+
<strong>${handle.replace(/^@/, "")}</strong>
|
|
624
|
+
<span class="editor-social-sub">${date}</span>
|
|
625
|
+
</div>
|
|
626
|
+
<span class="editor-social-more">\u2022\u2022\u2022</span>
|
|
627
|
+
</div>
|
|
628
|
+
${mediaHtml}
|
|
629
|
+
<div class="editor-social-ig-actions">
|
|
630
|
+
<span>\u2661 \u{1F4AC} \u2197</span>
|
|
631
|
+
<span>\u{1F516}</span>
|
|
632
|
+
</div>
|
|
633
|
+
<div class="editor-social-ig-likes">Liked by <strong>1,284 others</strong></div>
|
|
634
|
+
<p class="editor-social-ig-caption"><strong>${handle.replace(/^@/, "")}</strong> ${text} ${postLink}</p>
|
|
635
|
+
</blockquote>
|
|
636
|
+
</div>`;
|
|
637
|
+
}
|
|
638
|
+
const verifiedSvg = '<svg class="editor-social-verified" width="15" height="15" viewBox="0 0 24 24" fill="#1d9bf0" aria-label="Verified"><path d="M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .494.083.964.237 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z"/></svg>';
|
|
639
|
+
return `<div class="editor-social-wrap" data-align="${align}">
|
|
640
|
+
<blockquote class="editor-social-card is-x">
|
|
641
|
+
<div class="editor-social-top">
|
|
642
|
+
<div class="editor-social-avatar" aria-hidden="true">${escHtml(initials)}</div>
|
|
643
|
+
<div class="editor-social-meta">
|
|
644
|
+
<div class="editor-social-name-row"><strong>${author}</strong>${verifiedSvg}</div>
|
|
645
|
+
<span class="editor-social-sub">${handle} \xB7 ${date}</span>
|
|
646
|
+
</div>
|
|
647
|
+
<span class="editor-social-x-logo" aria-label="X">\u{1D54F}</span>
|
|
648
|
+
</div>
|
|
649
|
+
<p class="editor-social-text">${text}</p>
|
|
650
|
+
${d.imageUrl ? `<img class="editor-social-media" src="${escHtml(d.imageUrl)}" alt="" loading="lazy" />` : ""}
|
|
651
|
+
<div class="editor-social-foot is-x">
|
|
652
|
+
<span>\u{1F4AC} 24</span><span>\u21BB 86</span><span>\u2661 612</span><span>\u{1F4CA} 14.2K</span>${postLink}
|
|
653
|
+
</div>
|
|
654
|
+
</blockquote>
|
|
655
|
+
</div>`;
|
|
656
|
+
}
|
|
657
|
+
var SocialTool = class {
|
|
658
|
+
data;
|
|
659
|
+
previewEl;
|
|
660
|
+
static get toolbox() {
|
|
661
|
+
return {
|
|
662
|
+
title: "Social Media Post",
|
|
663
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>'
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
constructor({ data }) {
|
|
667
|
+
this.data = {
|
|
668
|
+
platform: data?.platform ?? "x",
|
|
669
|
+
align: data?.align ?? "center",
|
|
670
|
+
author: data?.author ?? "Alex Rivera",
|
|
671
|
+
handle: data?.handle ?? "@alexrivera",
|
|
672
|
+
role: data?.role ?? "Staff Engineer",
|
|
673
|
+
date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
674
|
+
text: data?.text ?? "Shipping clean, modular blocks with nextgen-block-editor.",
|
|
675
|
+
imageUrl: data?.imageUrl ?? "",
|
|
676
|
+
url: data?.url ?? ""
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
refreshPreview() {
|
|
680
|
+
if (this.previewEl) {
|
|
681
|
+
this.previewEl.innerHTML = renderSocialMarkup(this.data);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
render() {
|
|
685
|
+
const wrap = document.createElement("div");
|
|
686
|
+
wrap.className = "editor-extra-card";
|
|
687
|
+
const head = document.createElement("div");
|
|
688
|
+
head.className = "editor-extra-head";
|
|
689
|
+
head.textContent = "Social Media Post Card";
|
|
690
|
+
const topControls = document.createElement("div");
|
|
691
|
+
topControls.className = "editor-diff-inputs";
|
|
692
|
+
const platformSelect = document.createElement("select");
|
|
693
|
+
platformSelect.className = "cdx-input editor-form-select";
|
|
694
|
+
[
|
|
695
|
+
{ id: "x", label: "Twitter / X Format" },
|
|
696
|
+
{ id: "linkedin", label: "LinkedIn Format" },
|
|
697
|
+
{ id: "instagram", label: "Instagram Format" }
|
|
698
|
+
].forEach((p) => {
|
|
699
|
+
const opt = document.createElement("option");
|
|
700
|
+
opt.value = p.id;
|
|
701
|
+
opt.textContent = p.label;
|
|
702
|
+
if (this.data.platform === p.id) opt.selected = true;
|
|
703
|
+
platformSelect.appendChild(opt);
|
|
704
|
+
});
|
|
705
|
+
platformSelect.addEventListener("change", () => {
|
|
706
|
+
this.data.platform = platformSelect.value;
|
|
707
|
+
this.refreshPreview();
|
|
708
|
+
});
|
|
709
|
+
const alignSelect = document.createElement("select");
|
|
710
|
+
alignSelect.className = "cdx-input editor-form-select";
|
|
711
|
+
[
|
|
712
|
+
{ id: "left", label: "Align Left" },
|
|
713
|
+
{ id: "center", label: "Align Center" },
|
|
714
|
+
{ id: "right", label: "Align Right" }
|
|
715
|
+
].forEach((a) => {
|
|
716
|
+
const opt = document.createElement("option");
|
|
717
|
+
opt.value = a.id;
|
|
718
|
+
opt.textContent = a.label;
|
|
719
|
+
if (this.data.align === a.id) opt.selected = true;
|
|
720
|
+
alignSelect.appendChild(opt);
|
|
721
|
+
});
|
|
722
|
+
alignSelect.addEventListener("change", () => {
|
|
723
|
+
this.data.align = alignSelect.value;
|
|
724
|
+
this.refreshPreview();
|
|
725
|
+
});
|
|
726
|
+
topControls.append(platformSelect, alignSelect);
|
|
727
|
+
const meta = document.createElement("div");
|
|
728
|
+
meta.className = "editor-diff-inputs";
|
|
729
|
+
meta.append(
|
|
730
|
+
createInput("text", "cdx-input", "Author name", this.data.author, (v) => {
|
|
731
|
+
this.data.author = v;
|
|
732
|
+
this.refreshPreview();
|
|
733
|
+
}),
|
|
734
|
+
createInput("text", "cdx-input", "@handle or Role", this.data.handle, (v) => {
|
|
735
|
+
this.data.handle = v;
|
|
736
|
+
this.data.role = v;
|
|
737
|
+
this.refreshPreview();
|
|
738
|
+
})
|
|
739
|
+
);
|
|
740
|
+
const text = createTextarea("cdx-input", 3, "Post content...", this.data.text, (v) => {
|
|
741
|
+
this.data.text = v;
|
|
742
|
+
this.refreshPreview();
|
|
743
|
+
});
|
|
744
|
+
const extra = document.createElement("div");
|
|
745
|
+
extra.className = "editor-diff-inputs";
|
|
746
|
+
extra.append(
|
|
747
|
+
createInput("url", "cdx-input", "Optional image URL (Instagram)", this.data.imageUrl || "", (v) => {
|
|
748
|
+
this.data.imageUrl = v;
|
|
749
|
+
this.refreshPreview();
|
|
750
|
+
}),
|
|
751
|
+
createInput("url", "cdx-input", "Original post URL (optional)", this.data.url || "", (v) => {
|
|
752
|
+
this.data.url = v;
|
|
753
|
+
this.refreshPreview();
|
|
754
|
+
})
|
|
755
|
+
);
|
|
756
|
+
const preview = document.createElement("div");
|
|
757
|
+
this.previewEl = preview;
|
|
758
|
+
this.refreshPreview();
|
|
759
|
+
wrap.append(head, topControls, meta, text, extra, preview);
|
|
760
|
+
return wrap;
|
|
761
|
+
}
|
|
762
|
+
renderSettings() {
|
|
763
|
+
return [
|
|
764
|
+
{
|
|
765
|
+
icon: '<span style="font-size:11px;font-weight:700;">\u{1D54F}</span>',
|
|
766
|
+
label: "Twitter / X Format",
|
|
767
|
+
isActive: this.data.platform === "x",
|
|
768
|
+
closeOnActivate: true,
|
|
769
|
+
onActivate: () => {
|
|
770
|
+
this.data.platform = "x";
|
|
771
|
+
this.refreshPreview();
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
icon: '<span style="font-size:11px;font-weight:700;">in</span>',
|
|
776
|
+
label: "LinkedIn Format",
|
|
777
|
+
isActive: this.data.platform === "linkedin",
|
|
778
|
+
closeOnActivate: true,
|
|
779
|
+
onActivate: () => {
|
|
780
|
+
this.data.platform = "linkedin";
|
|
781
|
+
this.refreshPreview();
|
|
782
|
+
}
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
icon: '<span style="font-size:11px;font-weight:700;">\u25CE</span>',
|
|
786
|
+
label: "Instagram Format",
|
|
787
|
+
isActive: this.data.platform === "instagram",
|
|
788
|
+
closeOnActivate: true,
|
|
789
|
+
onActivate: () => {
|
|
790
|
+
this.data.platform = "instagram";
|
|
791
|
+
this.refreshPreview();
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>',
|
|
796
|
+
label: "Align Left",
|
|
797
|
+
isActive: this.data.align === "left",
|
|
798
|
+
closeOnActivate: true,
|
|
799
|
+
onActivate: () => {
|
|
800
|
+
this.data.align = "left";
|
|
801
|
+
this.refreshPreview();
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>',
|
|
806
|
+
label: "Align Center",
|
|
807
|
+
isActive: this.data.align === "center",
|
|
808
|
+
closeOnActivate: true,
|
|
809
|
+
onActivate: () => {
|
|
810
|
+
this.data.align = "center";
|
|
811
|
+
this.refreshPreview();
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>',
|
|
816
|
+
label: "Align Right",
|
|
817
|
+
isActive: this.data.align === "right",
|
|
818
|
+
closeOnActivate: true,
|
|
819
|
+
onActivate: () => {
|
|
820
|
+
this.data.align = "right";
|
|
821
|
+
this.refreshPreview();
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
];
|
|
825
|
+
}
|
|
826
|
+
save() {
|
|
827
|
+
return {
|
|
828
|
+
platform: this.data.platform,
|
|
829
|
+
align: this.data.align,
|
|
830
|
+
author: this.data.author.trim(),
|
|
831
|
+
handle: this.data.handle.trim(),
|
|
832
|
+
role: this.data.role?.trim() || void 0,
|
|
833
|
+
date: this.data.date?.trim() || void 0,
|
|
834
|
+
text: this.data.text.trim(),
|
|
835
|
+
imageUrl: this.data.imageUrl?.trim() || void 0,
|
|
836
|
+
url: this.data.url?.trim() || void 0
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
|
|
23
841
|
// src/utils/syntaxHighlight.ts
|
|
24
842
|
var SUPPORTED_LANGUAGES = [
|
|
25
843
|
{ id: "typescript", label: "TypeScript" },
|
|
@@ -312,6 +1130,17 @@ function pickLinkTint(seed) {
|
|
|
312
1130
|
function renderAudioCard(track, compact = false) {
|
|
313
1131
|
const url = String(track.url || "").trim();
|
|
314
1132
|
if (!url) return "";
|
|
1133
|
+
try {
|
|
1134
|
+
const parsed = new URL(url);
|
|
1135
|
+
const host = parsed.hostname.replace(/^www\./, "").toLowerCase();
|
|
1136
|
+
if (host === "open.spotify.com") {
|
|
1137
|
+
const embedUrl = parsed.pathname.startsWith("/embed/") ? url : `https://open.spotify.com/embed${parsed.pathname}`;
|
|
1138
|
+
return `<div class="editor-audio-card editor-spotify-card${compact ? " is-compact" : ""}"><iframe src="${escHtml(
|
|
1139
|
+
embedUrl
|
|
1140
|
+
)}" title="${escHtml(track.title || "Spotify track")}" loading="lazy" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"></iframe></div>`;
|
|
1141
|
+
}
|
|
1142
|
+
} catch {
|
|
1143
|
+
}
|
|
315
1144
|
const cover = track.coverUrl ? `<img class="editor-audio-cover" src="${escHtml(track.coverUrl)}" alt="${escHtml(
|
|
316
1145
|
track.title || "Audio cover"
|
|
317
1146
|
)}">` : `<div class="editor-audio-cover editor-audio-cover-placeholder" aria-hidden="true">\u266A</div>`;
|
|
@@ -477,7 +1306,10 @@ function blocksToHtml(data) {
|
|
|
477
1306
|
if (t.startsWith("## ")) return `<h4>${escHtml(t.slice(3))}</h4>`;
|
|
478
1307
|
return `<p>${escHtml(t)}</p>`;
|
|
479
1308
|
}).join("");
|
|
480
|
-
|
|
1309
|
+
const slideBg = ["default", "white", "zinc", "dark", "gradient"].includes(d.background) ? d.background : "default";
|
|
1310
|
+
const slideAlign = ["left", "center", "right"].includes(d.align) ? d.align : "left";
|
|
1311
|
+
const slideText = ["auto", "light", "dark"].includes(d.textTone) ? d.textTone : "auto";
|
|
1312
|
+
return `<div class="editor-slides" data-slides data-slide-bg="${slideBg}" data-slide-align="${slideAlign}" data-slide-text="${slideText}"><div class="editor-slides-bar"><span class="editor-slides-count">1 / ${rawSlides.length}</span><div class="editor-slides-controls"><button type="button" class="editor-slides-prev" aria-label="Previous slide">\u2190</button><button type="button" class="editor-slides-next" aria-label="Next slide">\u2192</button><button type="button" class="editor-slides-present">Present</button></div></div><div class="editor-slides-stage">` + rawSlides.map(
|
|
481
1313
|
(s, idx) => `<div class="editor-slide-panel${idx === 0 ? " active" : ""}" data-slide-idx="${idx}">${formatSlide(s)}</div>`
|
|
482
1314
|
).join("") + "</div></div>";
|
|
483
1315
|
}
|
|
@@ -605,8 +1437,10 @@ function blocksToHtml(data) {
|
|
|
605
1437
|
}
|
|
606
1438
|
if (block.type === "mermaid") {
|
|
607
1439
|
const code = String(d.code || "");
|
|
1440
|
+
const align = ["left", "center", "right"].includes(d.align) ? d.align : "center";
|
|
1441
|
+
const size = ["small", "medium", "large", "full"].includes(d.size) ? d.size : "small";
|
|
608
1442
|
const caption = d.caption ? `<figcaption>${escHtml(d.caption)}</figcaption>` : "";
|
|
609
|
-
return `<figure class="editor-mermaid-block"><div class="editor-mermaid-diagram" data-mermaid="${escHtml(
|
|
1443
|
+
return `<figure class="editor-mermaid-block" data-align="${align}" data-size="${size}"><div class="editor-mermaid-diagram" data-mermaid="${escHtml(
|
|
610
1444
|
code
|
|
611
1445
|
)}"><pre class="editor-mermaid-fallback">${escHtml(code)}</pre></div>${caption}</figure>`;
|
|
612
1446
|
}
|
|
@@ -656,6 +1490,9 @@ function blocksToHtml(data) {
|
|
|
656
1490
|
if (!d.url) return "";
|
|
657
1491
|
return `<figure class="editor-video-block"><video controls preload="metadata" class="editor-video-el"${d.poster ? ` poster="${escHtml(d.poster)}"` : ""}><source src="${escHtml(d.url)}"></video>${d.caption ? `<figcaption>${escHtml(d.caption)}</figcaption>` : ""}</figure>`;
|
|
658
1492
|
}
|
|
1493
|
+
if (block.type === "frame") {
|
|
1494
|
+
return renderFrameMarkup(d);
|
|
1495
|
+
}
|
|
659
1496
|
if (block.type === "changelog") {
|
|
660
1497
|
const items = Array.isArray(d.items) ? d.items : [];
|
|
661
1498
|
return `<section class="editor-changelog-block"><div class="editor-changelog-head"><span class="editor-changelog-version">${escHtml(
|
|
@@ -676,11 +1513,7 @@ function blocksToHtml(data) {
|
|
|
676
1513
|
)}</span></div>`;
|
|
677
1514
|
}
|
|
678
1515
|
if (block.type === "social") {
|
|
679
|
-
return
|
|
680
|
-
d.author || ""
|
|
681
|
-
)}</strong><span>${escHtml(d.handle || "")}</span>${d.date ? `<span>\xB7 ${escHtml(d.date)}</span>` : ""}</div><p class="editor-social-text">${escHtml(d.text || "")}</p>${d.url ? `<a class="editor-social-link" href="${escHtml(
|
|
682
|
-
d.url
|
|
683
|
-
)}" target="_blank" rel="noopener noreferrer">View original post \u2192</a>` : ""}</blockquote>`;
|
|
1516
|
+
return renderSocialMarkup(d);
|
|
684
1517
|
}
|
|
685
1518
|
if (block.type === "alert") {
|
|
686
1519
|
const variant = ["info", "tip", "warning", "danger"].includes(d.variant) ? d.variant : "info";
|
|
@@ -2824,13 +3657,15 @@ var QuizTool = class {
|
|
|
2824
3657
|
q.options.forEach((opt, oIdx) => {
|
|
2825
3658
|
const row = document.createElement("div");
|
|
2826
3659
|
row.className = "editor-eisenhower-item-row";
|
|
2827
|
-
const
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
3660
|
+
const tickBtn = document.createElement("button");
|
|
3661
|
+
tickBtn.type = "button";
|
|
3662
|
+
tickBtn.className = `editor-quiz-tick-btn${q.correctIndex === oIdx ? " is-selected" : ""}`;
|
|
3663
|
+
tickBtn.title = q.correctIndex === oIdx ? "Unmark as correct answer" : "Mark as correct answer";
|
|
3664
|
+
tickBtn.setAttribute("aria-pressed", String(q.correctIndex === oIdx));
|
|
3665
|
+
tickBtn.innerHTML = q.correctIndex === oIdx ? '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>' : "";
|
|
3666
|
+
tickBtn.addEventListener("click", () => {
|
|
3667
|
+
q.correctIndex = q.correctIndex === oIdx ? -1 : oIdx;
|
|
3668
|
+
renderOpts();
|
|
2834
3669
|
});
|
|
2835
3670
|
const optIn = document.createElement("input");
|
|
2836
3671
|
optIn.type = "text";
|
|
@@ -2851,7 +3686,7 @@ var QuizTool = class {
|
|
|
2851
3686
|
}
|
|
2852
3687
|
renderOpts();
|
|
2853
3688
|
});
|
|
2854
|
-
row.append(
|
|
3689
|
+
row.append(tickBtn, optIn, rmOpt);
|
|
2855
3690
|
optsWrap.appendChild(row);
|
|
2856
3691
|
});
|
|
2857
3692
|
};
|
|
@@ -4293,451 +5128,221 @@ var DialogueTool = class {
|
|
|
4293
5128
|
this.data.triggerLabel = triggerIn.value;
|
|
4294
5129
|
previewBtn.textContent = triggerIn.value || "Open Dialog";
|
|
4295
5130
|
};
|
|
4296
|
-
const previewBtn = document.createElement("button");
|
|
4297
|
-
previewBtn.type = "button";
|
|
4298
|
-
previewBtn.className = "b2 p";
|
|
4299
|
-
previewBtn.textContent = this.data.triggerLabel || "Open Dialog";
|
|
4300
|
-
previewBtn.onclick = () => this.openPreviewModal();
|
|
4301
|
-
top.append(triggerIn, previewBtn);
|
|
4302
|
-
const titleIn = document.createElement("input");
|
|
4303
|
-
titleIn.type = "text";
|
|
4304
|
-
titleIn.className = "cdx-input editor-form-input";
|
|
4305
|
-
titleIn.placeholder = "Dialog title...";
|
|
4306
|
-
titleIn.value = this.data.title;
|
|
4307
|
-
titleIn.oninput = () => {
|
|
4308
|
-
this.data.title = titleIn.value;
|
|
4309
|
-
};
|
|
4310
|
-
const bodyIn = document.createElement("textarea");
|
|
4311
|
-
bodyIn.rows = 3;
|
|
4312
|
-
bodyIn.className = "cdx-input editor-form-input";
|
|
4313
|
-
bodyIn.placeholder = "Dialog message / content...";
|
|
4314
|
-
bodyIn.value = this.data.body;
|
|
4315
|
-
bodyIn.oninput = () => {
|
|
4316
|
-
this.data.body = bodyIn.value;
|
|
4317
|
-
};
|
|
4318
|
-
const confirmIn = document.createElement("input");
|
|
4319
|
-
confirmIn.type = "text";
|
|
4320
|
-
confirmIn.className = "cdx-input editor-form-input";
|
|
4321
|
-
confirmIn.placeholder = "Confirm button text (e.g. Got it)";
|
|
4322
|
-
confirmIn.value = this.data.confirmLabel || "Got it";
|
|
4323
|
-
confirmIn.oninput = () => {
|
|
4324
|
-
this.data.confirmLabel = confirmIn.value;
|
|
4325
|
-
};
|
|
4326
|
-
wrap.append(top, titleIn, bodyIn, confirmIn);
|
|
4327
|
-
return wrap;
|
|
4328
|
-
}
|
|
4329
|
-
save() {
|
|
4330
|
-
return {
|
|
4331
|
-
triggerLabel: this.data.triggerLabel?.trim() || "Open Dialog",
|
|
4332
|
-
title: this.data.title?.trim() || "Dialog",
|
|
4333
|
-
body: this.data.body || "",
|
|
4334
|
-
confirmLabel: this.data.confirmLabel?.trim() || "Got it"
|
|
4335
|
-
};
|
|
4336
|
-
}
|
|
4337
|
-
};
|
|
4338
|
-
|
|
4339
|
-
// src/blocks/layoutTextBlocks.ts
|
|
4340
|
-
var SlidesTool = class {
|
|
4341
|
-
content;
|
|
4342
|
-
textarea;
|
|
4343
|
-
constructor(options) {
|
|
4344
|
-
this.content = options.data?.content || "# Slide 1\nIntroduce the big idea.\n\n---\n\n# Slide 2\nKey takeaways or code.";
|
|
4345
|
-
}
|
|
4346
|
-
static get toolbox() {
|
|
4347
|
-
return {
|
|
4348
|
-
title: "Slides",
|
|
4349
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>'
|
|
4350
|
-
};
|
|
4351
|
-
}
|
|
4352
|
-
render() {
|
|
4353
|
-
const root = document.createElement("div");
|
|
4354
|
-
root.className = "block-card";
|
|
4355
|
-
const hint = document.createElement("div");
|
|
4356
|
-
hint.className = "block-hint";
|
|
4357
|
-
hint.textContent = "Separate slides with --- on its own line. Readers get arrow controls + Present mode.";
|
|
4358
|
-
const ta = document.createElement("textarea");
|
|
4359
|
-
ta.rows = 7;
|
|
4360
|
-
ta.value = this.content;
|
|
4361
|
-
ta.placeholder = "# Slide 1\n...\n\n---\n\n# Slide 2\n...";
|
|
4362
|
-
ta.oninput = () => {
|
|
4363
|
-
this.content = ta.value;
|
|
4364
|
-
};
|
|
4365
|
-
root.append(hint, ta);
|
|
4366
|
-
this.textarea = ta;
|
|
4367
|
-
return root;
|
|
4368
|
-
}
|
|
4369
|
-
save() {
|
|
4370
|
-
return {
|
|
4371
|
-
content: this.textarea?.value ?? this.content
|
|
4372
|
-
};
|
|
4373
|
-
}
|
|
4374
|
-
};
|
|
4375
|
-
var TabsTool = class {
|
|
4376
|
-
tabs;
|
|
4377
|
-
constructor(options) {
|
|
4378
|
-
this.tabs = Array.isArray(options.data?.tabs) && options.data.tabs.length ? options.data.tabs.map((t) => ({ ...t })) : [
|
|
4379
|
-
{ label: "Overview", content: "" },
|
|
4380
|
-
{ label: "Specs", content: "" },
|
|
4381
|
-
{ label: "Notes", content: "" }
|
|
4382
|
-
];
|
|
4383
|
-
}
|
|
4384
|
-
static get toolbox() {
|
|
4385
|
-
return {
|
|
4386
|
-
title: "Tabs",
|
|
4387
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18"/><path d="M9 4v6"/><path d="M15 4v6"/></svg>'
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
|
-
render() {
|
|
4391
|
-
const root = document.createElement("div");
|
|
4392
|
-
root.className = "block-card";
|
|
4393
|
-
const list = document.createElement("div");
|
|
4394
|
-
list.className = "block-rows";
|
|
4395
|
-
const draw = () => {
|
|
4396
|
-
list.innerHTML = "";
|
|
4397
|
-
this.tabs.forEach((tab, idx) => {
|
|
4398
|
-
const row = document.createElement("div");
|
|
4399
|
-
row.className = "block-subrow";
|
|
4400
|
-
const top = document.createElement("div");
|
|
4401
|
-
top.className = "block-subrow-head";
|
|
4402
|
-
const lbl = document.createElement("input");
|
|
4403
|
-
lbl.type = "text";
|
|
4404
|
-
lbl.placeholder = `Tab ${idx + 1} label`;
|
|
4405
|
-
lbl.value = tab.label;
|
|
4406
|
-
lbl.oninput = () => {
|
|
4407
|
-
tab.label = lbl.value;
|
|
4408
|
-
};
|
|
4409
|
-
const rmBtn = document.createElement("button");
|
|
4410
|
-
rmBtn.type = "button";
|
|
4411
|
-
rmBtn.className = "b2";
|
|
4412
|
-
rmBtn.textContent = "\xD7";
|
|
4413
|
-
rmBtn.onclick = () => {
|
|
4414
|
-
this.tabs.splice(idx, 1);
|
|
4415
|
-
draw();
|
|
4416
|
-
};
|
|
4417
|
-
top.append(lbl, rmBtn);
|
|
4418
|
-
const body = document.createElement("textarea");
|
|
4419
|
-
body.rows = 3;
|
|
4420
|
-
body.placeholder = "Tab panel content...";
|
|
4421
|
-
body.value = tab.content;
|
|
4422
|
-
body.oninput = () => {
|
|
4423
|
-
tab.content = body.value;
|
|
4424
|
-
};
|
|
4425
|
-
row.append(top, body);
|
|
4426
|
-
list.appendChild(row);
|
|
4427
|
-
});
|
|
4428
|
-
};
|
|
4429
|
-
const addBtn = document.createElement("button");
|
|
4430
|
-
addBtn.type = "button";
|
|
4431
|
-
addBtn.className = "b2";
|
|
4432
|
-
addBtn.textContent = "+ Add tab";
|
|
4433
|
-
addBtn.onclick = () => {
|
|
4434
|
-
this.tabs.push({ label: `Tab ${this.tabs.length + 1}`, content: "" });
|
|
4435
|
-
draw();
|
|
4436
|
-
};
|
|
4437
|
-
draw();
|
|
4438
|
-
root.append(list, addBtn);
|
|
4439
|
-
return root;
|
|
4440
|
-
}
|
|
4441
|
-
save() {
|
|
4442
|
-
return { tabs: this.tabs };
|
|
4443
|
-
}
|
|
4444
|
-
};
|
|
4445
|
-
var AccordionTool = class {
|
|
4446
|
-
items;
|
|
4447
|
-
constructor(options) {
|
|
4448
|
-
this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((i) => ({ ...i })) : [
|
|
4449
|
-
{ title: "Question or section 1", body: "" },
|
|
4450
|
-
{ title: "Question or section 2", body: "" }
|
|
4451
|
-
];
|
|
4452
|
-
}
|
|
4453
|
-
static get toolbox() {
|
|
4454
|
-
return {
|
|
4455
|
-
title: "Accordion",
|
|
4456
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="5" rx="1"/><rect x="3" y="11" width="18" height="5" rx="1"/><line x1="3" y1="19" x2="21" y2="19"/></svg>'
|
|
4457
|
-
};
|
|
4458
|
-
}
|
|
4459
|
-
render() {
|
|
4460
|
-
const root = document.createElement("div");
|
|
4461
|
-
root.className = "block-card";
|
|
4462
|
-
const list = document.createElement("div");
|
|
4463
|
-
list.className = "block-rows";
|
|
4464
|
-
const draw = () => {
|
|
4465
|
-
list.innerHTML = "";
|
|
4466
|
-
this.items.forEach((item, idx) => {
|
|
4467
|
-
const row = document.createElement("div");
|
|
4468
|
-
row.className = "block-subrow";
|
|
4469
|
-
const top = document.createElement("div");
|
|
4470
|
-
top.className = "block-subrow-head";
|
|
4471
|
-
const titleIn = document.createElement("input");
|
|
4472
|
-
titleIn.type = "text";
|
|
4473
|
-
titleIn.placeholder = `Row ${idx + 1} title`;
|
|
4474
|
-
titleIn.value = item.title;
|
|
4475
|
-
titleIn.oninput = () => {
|
|
4476
|
-
item.title = titleIn.value;
|
|
4477
|
-
};
|
|
4478
|
-
const rmBtn = document.createElement("button");
|
|
4479
|
-
rmBtn.type = "button";
|
|
4480
|
-
rmBtn.className = "b2";
|
|
4481
|
-
rmBtn.textContent = "\xD7";
|
|
4482
|
-
rmBtn.onclick = () => {
|
|
4483
|
-
this.items.splice(idx, 1);
|
|
4484
|
-
draw();
|
|
4485
|
-
};
|
|
4486
|
-
top.append(titleIn, rmBtn);
|
|
4487
|
-
const bodyIn = document.createElement("textarea");
|
|
4488
|
-
bodyIn.rows = 2;
|
|
4489
|
-
bodyIn.placeholder = "Answer / details...";
|
|
4490
|
-
bodyIn.value = item.body;
|
|
4491
|
-
bodyIn.oninput = () => {
|
|
4492
|
-
item.body = bodyIn.value;
|
|
4493
|
-
};
|
|
4494
|
-
row.append(top, bodyIn);
|
|
4495
|
-
list.appendChild(row);
|
|
4496
|
-
});
|
|
4497
|
-
};
|
|
4498
|
-
const addBtn = document.createElement("button");
|
|
4499
|
-
addBtn.type = "button";
|
|
4500
|
-
addBtn.className = "b2";
|
|
4501
|
-
addBtn.textContent = "+ Add row";
|
|
4502
|
-
addBtn.onclick = () => {
|
|
4503
|
-
this.items.push({ title: "", body: "" });
|
|
4504
|
-
draw();
|
|
4505
|
-
};
|
|
4506
|
-
draw();
|
|
4507
|
-
root.append(list, addBtn);
|
|
4508
|
-
return root;
|
|
4509
|
-
}
|
|
4510
|
-
save() {
|
|
4511
|
-
return { items: this.items };
|
|
4512
|
-
}
|
|
4513
|
-
};
|
|
4514
|
-
var PullQuoteTool = class {
|
|
4515
|
-
data;
|
|
4516
|
-
constructor(options) {
|
|
4517
|
-
this.data = {
|
|
4518
|
-
text: options.data?.text || "",
|
|
4519
|
-
attribution: options.data?.attribution || ""
|
|
4520
|
-
};
|
|
4521
|
-
}
|
|
4522
|
-
static get toolbox() {
|
|
4523
|
-
return {
|
|
4524
|
-
title: "Pull quote",
|
|
4525
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="5" x2="20" y2="5"/><path d="M7 10h4v4H7z"/><path d="M13 10h4v4h-4z"/><line x1="4" y1="19" x2="20" y2="19"/></svg>'
|
|
5131
|
+
const previewBtn = document.createElement("button");
|
|
5132
|
+
previewBtn.type = "button";
|
|
5133
|
+
previewBtn.className = "b2 p";
|
|
5134
|
+
previewBtn.textContent = this.data.triggerLabel || "Open Dialog";
|
|
5135
|
+
previewBtn.onclick = () => this.openPreviewModal();
|
|
5136
|
+
top.append(triggerIn, previewBtn);
|
|
5137
|
+
const titleIn = document.createElement("input");
|
|
5138
|
+
titleIn.type = "text";
|
|
5139
|
+
titleIn.className = "cdx-input editor-form-input";
|
|
5140
|
+
titleIn.placeholder = "Dialog title...";
|
|
5141
|
+
titleIn.value = this.data.title;
|
|
5142
|
+
titleIn.oninput = () => {
|
|
5143
|
+
this.data.title = titleIn.value;
|
|
4526
5144
|
};
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
text.value = this.data.text;
|
|
4535
|
-
text.oninput = () => {
|
|
4536
|
-
this.data.text = text.value;
|
|
5145
|
+
const bodyIn = document.createElement("textarea");
|
|
5146
|
+
bodyIn.rows = 3;
|
|
5147
|
+
bodyIn.className = "cdx-input editor-form-input";
|
|
5148
|
+
bodyIn.placeholder = "Dialog message / content...";
|
|
5149
|
+
bodyIn.value = this.data.body;
|
|
5150
|
+
bodyIn.oninput = () => {
|
|
5151
|
+
this.data.body = bodyIn.value;
|
|
4537
5152
|
};
|
|
4538
|
-
const
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
5153
|
+
const confirmIn = document.createElement("input");
|
|
5154
|
+
confirmIn.type = "text";
|
|
5155
|
+
confirmIn.className = "cdx-input editor-form-input";
|
|
5156
|
+
confirmIn.placeholder = "Confirm button text (e.g. Got it)";
|
|
5157
|
+
confirmIn.value = this.data.confirmLabel || "Got it";
|
|
5158
|
+
confirmIn.oninput = () => {
|
|
5159
|
+
this.data.confirmLabel = confirmIn.value;
|
|
4544
5160
|
};
|
|
4545
|
-
|
|
4546
|
-
return
|
|
5161
|
+
wrap.append(top, titleIn, bodyIn, confirmIn);
|
|
5162
|
+
return wrap;
|
|
4547
5163
|
}
|
|
4548
5164
|
save() {
|
|
4549
|
-
return this.data;
|
|
4550
|
-
}
|
|
4551
|
-
};
|
|
4552
|
-
|
|
4553
|
-
// src/blocks/structuredBlocks.ts
|
|
4554
|
-
var TimelineTool = class {
|
|
4555
|
-
steps;
|
|
4556
|
-
constructor(options) {
|
|
4557
|
-
this.steps = Array.isArray(options.data?.steps) && options.data.steps.length ? options.data.steps.map((s) => ({ ...s })) : [
|
|
4558
|
-
{ title: "Step 1", detail: "" },
|
|
4559
|
-
{ title: "Step 2", detail: "" }
|
|
4560
|
-
];
|
|
4561
|
-
}
|
|
4562
|
-
static get toolbox() {
|
|
4563
5165
|
return {
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
render() {
|
|
4569
|
-
const root = document.createElement("div");
|
|
4570
|
-
root.className = "block-card";
|
|
4571
|
-
const list = document.createElement("div");
|
|
4572
|
-
list.className = "block-rows";
|
|
4573
|
-
const draw = () => {
|
|
4574
|
-
list.innerHTML = "";
|
|
4575
|
-
this.steps.forEach((step, idx) => {
|
|
4576
|
-
const row = document.createElement("div");
|
|
4577
|
-
row.className = "block-subrow";
|
|
4578
|
-
const top = document.createElement("div");
|
|
4579
|
-
top.className = "block-subrow-head";
|
|
4580
|
-
const titleIn = document.createElement("input");
|
|
4581
|
-
titleIn.type = "text";
|
|
4582
|
-
titleIn.placeholder = `Step ${idx + 1} title`;
|
|
4583
|
-
titleIn.value = step.title;
|
|
4584
|
-
titleIn.oninput = () => {
|
|
4585
|
-
step.title = titleIn.value;
|
|
4586
|
-
};
|
|
4587
|
-
const rmBtn = document.createElement("button");
|
|
4588
|
-
rmBtn.type = "button";
|
|
4589
|
-
rmBtn.className = "b2";
|
|
4590
|
-
rmBtn.textContent = "\xD7";
|
|
4591
|
-
rmBtn.onclick = () => {
|
|
4592
|
-
this.steps.splice(idx, 1);
|
|
4593
|
-
draw();
|
|
4594
|
-
};
|
|
4595
|
-
top.append(titleIn, rmBtn);
|
|
4596
|
-
const detailIn = document.createElement("textarea");
|
|
4597
|
-
detailIn.rows = 2;
|
|
4598
|
-
detailIn.placeholder = "Short step description...";
|
|
4599
|
-
detailIn.value = step.detail;
|
|
4600
|
-
detailIn.oninput = () => {
|
|
4601
|
-
step.detail = detailIn.value;
|
|
4602
|
-
};
|
|
4603
|
-
row.append(top, detailIn);
|
|
4604
|
-
list.appendChild(row);
|
|
4605
|
-
});
|
|
4606
|
-
};
|
|
4607
|
-
const addBtn = document.createElement("button");
|
|
4608
|
-
addBtn.type = "button";
|
|
4609
|
-
addBtn.className = "b2";
|
|
4610
|
-
addBtn.textContent = "+ Add step";
|
|
4611
|
-
addBtn.onclick = () => {
|
|
4612
|
-
this.steps.push({ title: `Step ${this.steps.length + 1}`, detail: "" });
|
|
4613
|
-
draw();
|
|
5166
|
+
triggerLabel: this.data.triggerLabel?.trim() || "Open Dialog",
|
|
5167
|
+
title: this.data.title?.trim() || "Dialog",
|
|
5168
|
+
body: this.data.body || "",
|
|
5169
|
+
confirmLabel: this.data.confirmLabel?.trim() || "Got it"
|
|
4614
5170
|
};
|
|
4615
|
-
draw();
|
|
4616
|
-
root.append(list, addBtn);
|
|
4617
|
-
return root;
|
|
4618
|
-
}
|
|
4619
|
-
save() {
|
|
4620
|
-
return { steps: this.steps };
|
|
4621
5171
|
}
|
|
4622
5172
|
};
|
|
4623
|
-
|
|
4624
|
-
|
|
5173
|
+
|
|
5174
|
+
// src/blocks/layoutTextBlocks.ts
|
|
5175
|
+
var SlidesTool = class {
|
|
5176
|
+
content;
|
|
5177
|
+
background;
|
|
5178
|
+
align;
|
|
5179
|
+
textTone;
|
|
5180
|
+
textarea;
|
|
5181
|
+
rootEl;
|
|
4625
5182
|
constructor(options) {
|
|
4626
|
-
this.
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
5183
|
+
this.content = options.data?.content || "# Slide 1\nIntroduce the big idea.\n\n---\n\n# Slide 2\nKey takeaways or code.";
|
|
5184
|
+
this.background = options.data?.background ?? "default";
|
|
5185
|
+
this.align = options.data?.align ?? "left";
|
|
5186
|
+
this.textTone = options.data?.textTone ?? "auto";
|
|
4630
5187
|
}
|
|
4631
5188
|
static get toolbox() {
|
|
4632
5189
|
return {
|
|
4633
|
-
title: "
|
|
4634
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
5190
|
+
title: "Slides",
|
|
5191
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/></svg>'
|
|
4635
5192
|
};
|
|
4636
5193
|
}
|
|
5194
|
+
applyVisualAttrs() {
|
|
5195
|
+
if (!this.rootEl) return;
|
|
5196
|
+
this.rootEl.dataset.slideBg = this.background;
|
|
5197
|
+
this.rootEl.dataset.slideAlign = this.align;
|
|
5198
|
+
this.rootEl.dataset.slideText = this.textTone;
|
|
5199
|
+
}
|
|
4637
5200
|
render() {
|
|
4638
5201
|
const root = document.createElement("div");
|
|
4639
|
-
root.className = "block-card";
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
const
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
valIn.oninput = () => {
|
|
4652
|
-
stat.value = valIn.value;
|
|
4653
|
-
};
|
|
4654
|
-
const lblIn = document.createElement("input");
|
|
4655
|
-
lblIn.type = "text";
|
|
4656
|
-
lblIn.placeholder = "Label (e.g. Uptime)";
|
|
4657
|
-
lblIn.value = stat.label;
|
|
4658
|
-
lblIn.oninput = () => {
|
|
4659
|
-
stat.label = lblIn.value;
|
|
4660
|
-
};
|
|
4661
|
-
const rmBtn = document.createElement("button");
|
|
4662
|
-
rmBtn.type = "button";
|
|
4663
|
-
rmBtn.className = "b2";
|
|
4664
|
-
rmBtn.textContent = "\xD7";
|
|
4665
|
-
rmBtn.onclick = () => {
|
|
4666
|
-
this.stats.splice(idx, 1);
|
|
4667
|
-
draw();
|
|
4668
|
-
};
|
|
4669
|
-
row.append(valIn, lblIn, rmBtn);
|
|
4670
|
-
list.appendChild(row);
|
|
4671
|
-
});
|
|
4672
|
-
};
|
|
4673
|
-
const addBtn = document.createElement("button");
|
|
4674
|
-
addBtn.type = "button";
|
|
4675
|
-
addBtn.className = "b2";
|
|
4676
|
-
addBtn.textContent = "+ Add metric";
|
|
4677
|
-
addBtn.onclick = () => {
|
|
4678
|
-
this.stats.push({ value: "", label: "" });
|
|
4679
|
-
draw();
|
|
5202
|
+
root.className = "block-card editor-slides-tool-card";
|
|
5203
|
+
this.rootEl = root;
|
|
5204
|
+
this.applyVisualAttrs();
|
|
5205
|
+
const hint = document.createElement("div");
|
|
5206
|
+
hint.className = "block-hint";
|
|
5207
|
+
hint.textContent = "Separate slides with --- on its own line. Use the block menu (\u22EE) to customize background, text tone & alignment.";
|
|
5208
|
+
const ta = document.createElement("textarea");
|
|
5209
|
+
ta.rows = 7;
|
|
5210
|
+
ta.value = this.content;
|
|
5211
|
+
ta.placeholder = "# Slide 1\n...\n\n---\n\n# Slide 2\n...";
|
|
5212
|
+
ta.oninput = () => {
|
|
5213
|
+
this.content = ta.value;
|
|
4680
5214
|
};
|
|
4681
|
-
|
|
4682
|
-
|
|
5215
|
+
root.append(hint, ta);
|
|
5216
|
+
this.textarea = ta;
|
|
4683
5217
|
return root;
|
|
4684
5218
|
}
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
5219
|
+
renderSettings() {
|
|
5220
|
+
const tunes = [
|
|
5221
|
+
{
|
|
5222
|
+
label: "Align Left",
|
|
5223
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>',
|
|
5224
|
+
isActive: this.align === "left",
|
|
5225
|
+
onActivate: () => {
|
|
5226
|
+
this.align = "left";
|
|
5227
|
+
this.applyVisualAttrs();
|
|
5228
|
+
}
|
|
5229
|
+
},
|
|
5230
|
+
{
|
|
5231
|
+
label: "Align Center",
|
|
5232
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>',
|
|
5233
|
+
isActive: this.align === "center",
|
|
5234
|
+
onActivate: () => {
|
|
5235
|
+
this.align = "center";
|
|
5236
|
+
this.applyVisualAttrs();
|
|
5237
|
+
}
|
|
5238
|
+
},
|
|
5239
|
+
{
|
|
5240
|
+
label: "Align Right",
|
|
5241
|
+
icon: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>',
|
|
5242
|
+
isActive: this.align === "right",
|
|
5243
|
+
onActivate: () => {
|
|
5244
|
+
this.align = "right";
|
|
5245
|
+
this.applyVisualAttrs();
|
|
5246
|
+
}
|
|
5247
|
+
},
|
|
5248
|
+
{
|
|
5249
|
+
label: "BG: Default",
|
|
5250
|
+
icon: '<span style="font-size:11px;font-weight:700;">D</span>',
|
|
5251
|
+
isActive: this.background === "default",
|
|
5252
|
+
onActivate: () => {
|
|
5253
|
+
this.background = "default";
|
|
5254
|
+
this.applyVisualAttrs();
|
|
5255
|
+
}
|
|
5256
|
+
},
|
|
5257
|
+
{
|
|
5258
|
+
label: "BG: White",
|
|
5259
|
+
icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#fff;border:1px solid #999;"></span>',
|
|
5260
|
+
isActive: this.background === "white",
|
|
5261
|
+
onActivate: () => {
|
|
5262
|
+
this.background = "white";
|
|
5263
|
+
this.textTone = "dark";
|
|
5264
|
+
this.applyVisualAttrs();
|
|
5265
|
+
}
|
|
5266
|
+
},
|
|
5267
|
+
{
|
|
5268
|
+
label: "BG: Soft Zinc",
|
|
5269
|
+
icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#e4e4e7;border:1px solid #999;"></span>',
|
|
5270
|
+
isActive: this.background === "zinc",
|
|
5271
|
+
onActivate: () => {
|
|
5272
|
+
this.background = "zinc";
|
|
5273
|
+
this.textTone = "dark";
|
|
5274
|
+
this.applyVisualAttrs();
|
|
5275
|
+
}
|
|
5276
|
+
},
|
|
5277
|
+
{
|
|
5278
|
+
label: "BG: Dark",
|
|
5279
|
+
icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#09090b;border:1px solid #666;"></span>',
|
|
5280
|
+
isActive: this.background === "dark",
|
|
5281
|
+
onActivate: () => {
|
|
5282
|
+
this.background = "dark";
|
|
5283
|
+
this.textTone = "light";
|
|
5284
|
+
this.applyVisualAttrs();
|
|
5285
|
+
}
|
|
5286
|
+
},
|
|
5287
|
+
{
|
|
5288
|
+
label: "BG: Gradient",
|
|
5289
|
+
icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:linear-gradient(135deg,#18181b,#52525b);"></span>',
|
|
5290
|
+
isActive: this.background === "gradient",
|
|
5291
|
+
onActivate: () => {
|
|
5292
|
+
this.background = "gradient";
|
|
5293
|
+
this.textTone = "light";
|
|
5294
|
+
this.applyVisualAttrs();
|
|
5295
|
+
}
|
|
5296
|
+
},
|
|
5297
|
+
{
|
|
5298
|
+
label: "Text: Dark",
|
|
5299
|
+
icon: '<span style="font-size:11px;font-weight:700;">T</span>',
|
|
5300
|
+
isActive: this.textTone === "dark",
|
|
5301
|
+
onActivate: () => {
|
|
5302
|
+
this.textTone = "dark";
|
|
5303
|
+
this.applyVisualAttrs();
|
|
5304
|
+
}
|
|
5305
|
+
},
|
|
5306
|
+
{
|
|
5307
|
+
label: "Text: Light",
|
|
5308
|
+
icon: '<span style="font-size:11px;font-weight:700;opacity:0.65;">T</span>',
|
|
5309
|
+
isActive: this.textTone === "light",
|
|
5310
|
+
onActivate: () => {
|
|
5311
|
+
this.textTone = "light";
|
|
5312
|
+
this.applyVisualAttrs();
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
];
|
|
5316
|
+
return tunes.map((t) => ({
|
|
5317
|
+
icon: t.icon,
|
|
5318
|
+
label: t.label,
|
|
5319
|
+
isActive: t.isActive,
|
|
5320
|
+
closeOnActivate: true,
|
|
5321
|
+
onActivate: t.onActivate
|
|
5322
|
+
}));
|
|
4696
5323
|
}
|
|
4697
|
-
|
|
5324
|
+
save() {
|
|
4698
5325
|
return {
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
render() {
|
|
4704
|
-
const root = document.createElement("div");
|
|
4705
|
-
root.className = "block-card";
|
|
4706
|
-
const grid = document.createElement("div");
|
|
4707
|
-
grid.className = "block-two-col";
|
|
4708
|
-
const makeCol = (title, key) => {
|
|
4709
|
-
const box = document.createElement("div");
|
|
4710
|
-
box.className = "block-subrow";
|
|
4711
|
-
const heading = document.createElement("div");
|
|
4712
|
-
heading.className = "block-hint";
|
|
4713
|
-
heading.textContent = title;
|
|
4714
|
-
const ta = document.createElement("textarea");
|
|
4715
|
-
ta.rows = 4;
|
|
4716
|
-
ta.placeholder = `${title}, one per line...`;
|
|
4717
|
-
ta.value = this.data[key].join("\n");
|
|
4718
|
-
ta.oninput = () => {
|
|
4719
|
-
this.data[key] = ta.value.split(/\n/).map((s) => s.trim()).filter(Boolean);
|
|
4720
|
-
};
|
|
4721
|
-
box.append(heading, ta);
|
|
4722
|
-
return box;
|
|
5326
|
+
content: this.textarea?.value ?? this.content,
|
|
5327
|
+
background: this.background,
|
|
5328
|
+
align: this.align,
|
|
5329
|
+
textTone: this.textTone
|
|
4723
5330
|
};
|
|
4724
|
-
grid.append(makeCol("Pros", "pros"), makeCol("Cons", "cons"));
|
|
4725
|
-
root.appendChild(grid);
|
|
4726
|
-
return root;
|
|
4727
|
-
}
|
|
4728
|
-
save() {
|
|
4729
|
-
return this.data;
|
|
4730
5331
|
}
|
|
4731
5332
|
};
|
|
4732
|
-
var
|
|
4733
|
-
|
|
5333
|
+
var TabsTool = class {
|
|
5334
|
+
tabs;
|
|
4734
5335
|
constructor(options) {
|
|
4735
|
-
this.
|
|
5336
|
+
this.tabs = Array.isArray(options.data?.tabs) && options.data.tabs.length ? options.data.tabs.map((t) => ({ ...t })) : [
|
|
5337
|
+
{ label: "Overview", content: "" },
|
|
5338
|
+
{ label: "Specs", content: "" },
|
|
5339
|
+
{ label: "Notes", content: "" }
|
|
5340
|
+
];
|
|
4736
5341
|
}
|
|
4737
5342
|
static get toolbox() {
|
|
4738
5343
|
return {
|
|
4739
|
-
title: "
|
|
4740
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="
|
|
5344
|
+
title: "Tabs",
|
|
5345
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18"/><path d="M9 4v6"/><path d="M15 4v6"/></svg>'
|
|
4741
5346
|
};
|
|
4742
5347
|
}
|
|
4743
5348
|
render() {
|
|
@@ -4747,78 +5352,44 @@ var CardsTool = class {
|
|
|
4747
5352
|
list.className = "block-rows";
|
|
4748
5353
|
const draw = () => {
|
|
4749
5354
|
list.innerHTML = "";
|
|
4750
|
-
this.
|
|
5355
|
+
this.tabs.forEach((tab, idx) => {
|
|
4751
5356
|
const row = document.createElement("div");
|
|
4752
5357
|
row.className = "block-subrow";
|
|
4753
5358
|
const top = document.createElement("div");
|
|
4754
5359
|
top.className = "block-subrow-head";
|
|
4755
|
-
const
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
};
|
|
4762
|
-
const badgeIn = document.createElement("input");
|
|
4763
|
-
badgeIn.type = "text";
|
|
4764
|
-
badgeIn.placeholder = "Badge (PDF / Link)";
|
|
4765
|
-
badgeIn.value = card.badge || "";
|
|
4766
|
-
badgeIn.oninput = () => {
|
|
4767
|
-
card.badge = badgeIn.value;
|
|
5360
|
+
const lbl = document.createElement("input");
|
|
5361
|
+
lbl.type = "text";
|
|
5362
|
+
lbl.placeholder = `Tab ${idx + 1} label`;
|
|
5363
|
+
lbl.value = tab.label;
|
|
5364
|
+
lbl.oninput = () => {
|
|
5365
|
+
tab.label = lbl.value;
|
|
4768
5366
|
};
|
|
4769
5367
|
const rmBtn = document.createElement("button");
|
|
4770
5368
|
rmBtn.type = "button";
|
|
4771
5369
|
rmBtn.className = "b2";
|
|
4772
5370
|
rmBtn.textContent = "\xD7";
|
|
4773
5371
|
rmBtn.onclick = () => {
|
|
4774
|
-
this.
|
|
5372
|
+
this.tabs.splice(idx, 1);
|
|
4775
5373
|
draw();
|
|
4776
5374
|
};
|
|
4777
|
-
top.append(
|
|
4778
|
-
const
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
};
|
|
4785
|
-
const urlIn = document.createElement("input");
|
|
4786
|
-
urlIn.type = "url";
|
|
4787
|
-
urlIn.placeholder = "URL or upload a file below";
|
|
4788
|
-
urlIn.value = card.url;
|
|
4789
|
-
urlIn.oninput = () => {
|
|
4790
|
-
card.url = urlIn.value.trim();
|
|
4791
|
-
};
|
|
4792
|
-
const fileIn = document.createElement("input");
|
|
4793
|
-
fileIn.type = "file";
|
|
4794
|
-
fileIn.onchange = async () => {
|
|
4795
|
-
const file = fileIn.files?.[0];
|
|
4796
|
-
if (!file) return;
|
|
4797
|
-
if (!card.title) card.title = file.name;
|
|
4798
|
-
titleIn.value = card.title;
|
|
4799
|
-
const bucketUrl = await uploadFileToBucket(file, "attachments");
|
|
4800
|
-
if (bucketUrl) {
|
|
4801
|
-
card.url = bucketUrl;
|
|
4802
|
-
urlIn.value = bucketUrl;
|
|
4803
|
-
return;
|
|
4804
|
-
}
|
|
4805
|
-
const reader = new FileReader();
|
|
4806
|
-
reader.onload = () => {
|
|
4807
|
-
card.url = String(reader.result || "");
|
|
4808
|
-
urlIn.value = card.url;
|
|
4809
|
-
};
|
|
4810
|
-
reader.readAsDataURL(file);
|
|
5375
|
+
top.append(lbl, rmBtn);
|
|
5376
|
+
const body = document.createElement("textarea");
|
|
5377
|
+
body.rows = 3;
|
|
5378
|
+
body.placeholder = "Tab panel content...";
|
|
5379
|
+
body.value = tab.content;
|
|
5380
|
+
body.oninput = () => {
|
|
5381
|
+
tab.content = body.value;
|
|
4811
5382
|
};
|
|
4812
|
-
row.append(top,
|
|
5383
|
+
row.append(top, body);
|
|
4813
5384
|
list.appendChild(row);
|
|
4814
5385
|
});
|
|
4815
5386
|
};
|
|
4816
5387
|
const addBtn = document.createElement("button");
|
|
4817
5388
|
addBtn.type = "button";
|
|
4818
5389
|
addBtn.className = "b2";
|
|
4819
|
-
addBtn.textContent = "+ Add
|
|
5390
|
+
addBtn.textContent = "+ Add tab";
|
|
4820
5391
|
addBtn.onclick = () => {
|
|
4821
|
-
this.
|
|
5392
|
+
this.tabs.push({ label: `Tab ${this.tabs.length + 1}`, content: "" });
|
|
4822
5393
|
draw();
|
|
4823
5394
|
};
|
|
4824
5395
|
draw();
|
|
@@ -4826,18 +5397,21 @@ var CardsTool = class {
|
|
|
4826
5397
|
return root;
|
|
4827
5398
|
}
|
|
4828
5399
|
save() {
|
|
4829
|
-
return {
|
|
5400
|
+
return { tabs: this.tabs };
|
|
4830
5401
|
}
|
|
4831
5402
|
};
|
|
4832
|
-
var
|
|
5403
|
+
var AccordionTool = class {
|
|
4833
5404
|
items;
|
|
4834
5405
|
constructor(options) {
|
|
4835
|
-
this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((
|
|
5406
|
+
this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((i) => ({ ...i })) : [
|
|
5407
|
+
{ title: "Question or section 1", body: "" },
|
|
5408
|
+
{ title: "Question or section 2", body: "" }
|
|
5409
|
+
];
|
|
4836
5410
|
}
|
|
4837
5411
|
static get toolbox() {
|
|
4838
5412
|
return {
|
|
4839
|
-
title: "
|
|
4840
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
5413
|
+
title: "Accordion",
|
|
5414
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="5" rx="1"/><rect x="3" y="11" width="18" height="5" rx="1"/><line x1="3" y1="19" x2="21" y2="19"/></svg>'
|
|
4841
5415
|
};
|
|
4842
5416
|
}
|
|
4843
5417
|
render() {
|
|
@@ -4845,29 +5419,19 @@ var BadgesTool = class {
|
|
|
4845
5419
|
root.className = "block-card";
|
|
4846
5420
|
const list = document.createElement("div");
|
|
4847
5421
|
list.className = "block-rows";
|
|
4848
|
-
const tones = ["neutral", "accent", "green", "blue", "amber", "red"];
|
|
4849
5422
|
const draw = () => {
|
|
4850
5423
|
list.innerHTML = "";
|
|
4851
5424
|
this.items.forEach((item, idx) => {
|
|
4852
5425
|
const row = document.createElement("div");
|
|
4853
|
-
row.className = "block-subrow
|
|
4854
|
-
const
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
tones.forEach((t) => {
|
|
4863
|
-
const opt = document.createElement("option");
|
|
4864
|
-
opt.value = t;
|
|
4865
|
-
opt.textContent = t.charAt(0).toUpperCase() + t.slice(1);
|
|
4866
|
-
toneSel.appendChild(opt);
|
|
4867
|
-
});
|
|
4868
|
-
toneSel.value = item.tone || "neutral";
|
|
4869
|
-
toneSel.onchange = () => {
|
|
4870
|
-
item.tone = toneSel.value;
|
|
5426
|
+
row.className = "block-subrow";
|
|
5427
|
+
const top = document.createElement("div");
|
|
5428
|
+
top.className = "block-subrow-head";
|
|
5429
|
+
const titleIn = document.createElement("input");
|
|
5430
|
+
titleIn.type = "text";
|
|
5431
|
+
titleIn.placeholder = `Row ${idx + 1} title`;
|
|
5432
|
+
titleIn.value = item.title;
|
|
5433
|
+
titleIn.oninput = () => {
|
|
5434
|
+
item.title = titleIn.value;
|
|
4871
5435
|
};
|
|
4872
5436
|
const rmBtn = document.createElement("button");
|
|
4873
5437
|
rmBtn.type = "button";
|
|
@@ -4877,16 +5441,24 @@ var BadgesTool = class {
|
|
|
4877
5441
|
this.items.splice(idx, 1);
|
|
4878
5442
|
draw();
|
|
4879
5443
|
};
|
|
4880
|
-
|
|
5444
|
+
top.append(titleIn, rmBtn);
|
|
5445
|
+
const bodyIn = document.createElement("textarea");
|
|
5446
|
+
bodyIn.rows = 2;
|
|
5447
|
+
bodyIn.placeholder = "Answer / details...";
|
|
5448
|
+
bodyIn.value = item.body;
|
|
5449
|
+
bodyIn.oninput = () => {
|
|
5450
|
+
item.body = bodyIn.value;
|
|
5451
|
+
};
|
|
5452
|
+
row.append(top, bodyIn);
|
|
4881
5453
|
list.appendChild(row);
|
|
4882
5454
|
});
|
|
4883
5455
|
};
|
|
4884
5456
|
const addBtn = document.createElement("button");
|
|
4885
5457
|
addBtn.type = "button";
|
|
4886
5458
|
addBtn.className = "b2";
|
|
4887
|
-
addBtn.textContent = "+ Add
|
|
5459
|
+
addBtn.textContent = "+ Add row";
|
|
4888
5460
|
addBtn.onclick = () => {
|
|
4889
|
-
this.items.push({
|
|
5461
|
+
this.items.push({ title: "", body: "" });
|
|
4890
5462
|
draw();
|
|
4891
5463
|
};
|
|
4892
5464
|
draw();
|
|
@@ -4894,613 +5466,626 @@ var BadgesTool = class {
|
|
|
4894
5466
|
return root;
|
|
4895
5467
|
}
|
|
4896
5468
|
save() {
|
|
4897
|
-
return { items: this.items
|
|
4898
|
-
}
|
|
4899
|
-
};
|
|
4900
|
-
var TagsTool = class {
|
|
4901
|
-
raw;
|
|
4902
|
-
input;
|
|
4903
|
-
constructor(options) {
|
|
4904
|
-
this.raw = Array.isArray(options.data?.tags) ? options.data.tags.join(", ") : "";
|
|
4905
|
-
}
|
|
4906
|
-
static get toolbox() {
|
|
4907
|
-
return {
|
|
4908
|
-
title: "Tags",
|
|
4909
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/></svg>'
|
|
4910
|
-
};
|
|
4911
|
-
}
|
|
4912
|
-
render() {
|
|
4913
|
-
const root = document.createElement("div");
|
|
4914
|
-
root.className = "block-card";
|
|
4915
|
-
const input = document.createElement("input");
|
|
4916
|
-
input.type = "text";
|
|
4917
|
-
input.placeholder = "Comma-separated tags (e.g. react, typescript, design)";
|
|
4918
|
-
input.value = this.raw;
|
|
4919
|
-
root.appendChild(input);
|
|
4920
|
-
this.input = input;
|
|
4921
|
-
return root;
|
|
4922
|
-
}
|
|
4923
|
-
save() {
|
|
4924
|
-
const val = this.input?.value ?? this.raw;
|
|
4925
|
-
return {
|
|
4926
|
-
tags: val.split(",").map((t) => t.trim().replace(/^#/, "")).filter(Boolean)
|
|
4927
|
-
};
|
|
4928
|
-
}
|
|
4929
|
-
};
|
|
4930
|
-
|
|
4931
|
-
// src/blocks/mermaidBlock.ts
|
|
4932
|
-
import mermaid from "mermaid";
|
|
4933
|
-
var MERMAID_PRESETS = {
|
|
4934
|
-
Flowchart: `graph TD
|
|
4935
|
-
A[Start] --> B{Condition?}
|
|
4936
|
-
B -->|Yes| C[Proceed]
|
|
4937
|
-
B -->|No| D[Retry]`,
|
|
4938
|
-
Sequence: `sequenceDiagram
|
|
4939
|
-
User->>Editor: Type /mermaid
|
|
4940
|
-
Editor->>Mermaid: Render SVG
|
|
4941
|
-
Mermaid-->>User: Interactive Diagram`,
|
|
4942
|
-
Mindmap: `mindmap
|
|
4943
|
-
root((NextGen Editor))
|
|
4944
|
-
Blocks
|
|
4945
|
-
Mermaid
|
|
4946
|
-
Charts
|
|
4947
|
-
Code
|
|
4948
|
-
AI
|
|
4949
|
-
Rewrite
|
|
4950
|
-
Continue`
|
|
4951
|
-
};
|
|
4952
|
-
var mermaidInitialized = false;
|
|
4953
|
-
var mermaidCounter = 0;
|
|
4954
|
-
function ensureMermaidInit() {
|
|
4955
|
-
if (mermaidInitialized) return;
|
|
4956
|
-
mermaidInitialized = true;
|
|
4957
|
-
mermaid.initialize({
|
|
4958
|
-
startOnLoad: false,
|
|
4959
|
-
securityLevel: "strict",
|
|
4960
|
-
theme: "neutral"
|
|
4961
|
-
});
|
|
4962
|
-
}
|
|
4963
|
-
async function renderMermaidInto(container, code) {
|
|
4964
|
-
const trimmed = code.trim();
|
|
4965
|
-
if (!trimmed) {
|
|
4966
|
-
container.innerHTML = '<span class="editor-mermaid-empty">Enter Mermaid syntax to preview</span>';
|
|
4967
|
-
return;
|
|
4968
|
-
}
|
|
4969
|
-
ensureMermaidInit();
|
|
4970
|
-
const id = `ng-mermaid-${++mermaidCounter}`;
|
|
4971
|
-
try {
|
|
4972
|
-
const { svg } = await mermaid.render(id, trimmed);
|
|
4973
|
-
container.innerHTML = svg;
|
|
4974
|
-
} catch (err) {
|
|
4975
|
-
const message = err instanceof Error ? err.message : "Invalid Mermaid syntax";
|
|
4976
|
-
container.innerHTML = `<pre class="editor-mermaid-error">${message.replace(/</g, "<")}</pre>`;
|
|
5469
|
+
return { items: this.items };
|
|
4977
5470
|
}
|
|
4978
|
-
}
|
|
4979
|
-
var
|
|
5471
|
+
};
|
|
5472
|
+
var PullQuoteTool = class {
|
|
4980
5473
|
data;
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="6" height="6" rx="1"/><rect x="15" y="3" width="6" height="6" rx="1"/><rect x="9" y="15" width="6" height="6" rx="1"/><path d="M6 9v3a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9"/><path d="M12 12v3"/></svg>'
|
|
5474
|
+
constructor(options) {
|
|
5475
|
+
this.data = {
|
|
5476
|
+
text: options.data?.text || "",
|
|
5477
|
+
attribution: options.data?.attribution || ""
|
|
4986
5478
|
};
|
|
4987
5479
|
}
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
5480
|
+
static get toolbox() {
|
|
5481
|
+
return {
|
|
5482
|
+
title: "Pull quote",
|
|
5483
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="5" x2="20" y2="5"/><path d="M7 10h4v4H7z"/><path d="M13 10h4v4h-4z"/><line x1="4" y1="19" x2="20" y2="19"/></svg>'
|
|
4992
5484
|
};
|
|
4993
5485
|
}
|
|
4994
5486
|
render() {
|
|
4995
|
-
const
|
|
4996
|
-
|
|
4997
|
-
const
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
presets.className = "editor-mermaid-presets";
|
|
5004
|
-
Object.entries(MERMAID_PRESETS).forEach(([label, snippet]) => {
|
|
5005
|
-
const btn = document.createElement("button");
|
|
5006
|
-
btn.type = "button";
|
|
5007
|
-
btn.className = "editor-mermaid-preset-btn";
|
|
5008
|
-
btn.textContent = label;
|
|
5009
|
-
btn.addEventListener("click", () => {
|
|
5010
|
-
this.data.code = snippet;
|
|
5011
|
-
textarea.value = snippet;
|
|
5012
|
-
void updatePreview();
|
|
5013
|
-
});
|
|
5014
|
-
presets.appendChild(btn);
|
|
5015
|
-
});
|
|
5016
|
-
head.append(title, presets);
|
|
5017
|
-
const textarea = document.createElement("textarea");
|
|
5018
|
-
textarea.className = "editor-mermaid-input";
|
|
5019
|
-
textarea.rows = 5;
|
|
5020
|
-
textarea.placeholder = "graph TD\n A --> B";
|
|
5021
|
-
textarea.value = this.data.code;
|
|
5022
|
-
const preview = document.createElement("div");
|
|
5023
|
-
preview.className = "editor-mermaid-preview";
|
|
5024
|
-
const captionInput = document.createElement("input");
|
|
5025
|
-
captionInput.type = "text";
|
|
5026
|
-
captionInput.className = "editor-mermaid-caption cdx-input";
|
|
5027
|
-
captionInput.placeholder = "Optional diagram caption";
|
|
5028
|
-
captionInput.value = this.data.caption || "";
|
|
5029
|
-
const updatePreview = async () => {
|
|
5030
|
-
const seq = ++this.renderSeq;
|
|
5031
|
-
await renderMermaidInto(preview, this.data.code);
|
|
5032
|
-
if (seq !== this.renderSeq) return;
|
|
5487
|
+
const root = document.createElement("div");
|
|
5488
|
+
root.className = "block-card";
|
|
5489
|
+
const text = document.createElement("textarea");
|
|
5490
|
+
text.rows = 3;
|
|
5491
|
+
text.placeholder = "Oversized editorial pull-quote...";
|
|
5492
|
+
text.value = this.data.text;
|
|
5493
|
+
text.oninput = () => {
|
|
5494
|
+
this.data.text = text.value;
|
|
5033
5495
|
};
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
this.data.
|
|
5040
|
-
}
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
return wrap;
|
|
5496
|
+
const attr = document.createElement("input");
|
|
5497
|
+
attr.type = "text";
|
|
5498
|
+
attr.placeholder = "Attribution (optional)";
|
|
5499
|
+
attr.value = this.data.attribution;
|
|
5500
|
+
attr.oninput = () => {
|
|
5501
|
+
this.data.attribution = attr.value;
|
|
5502
|
+
};
|
|
5503
|
+
root.append(text, attr);
|
|
5504
|
+
return root;
|
|
5044
5505
|
}
|
|
5045
5506
|
save() {
|
|
5046
|
-
return
|
|
5047
|
-
code: this.data.code,
|
|
5048
|
-
caption: this.data.caption?.trim() || void 0
|
|
5049
|
-
};
|
|
5507
|
+
return this.data;
|
|
5050
5508
|
}
|
|
5051
5509
|
};
|
|
5052
5510
|
|
|
5053
|
-
// src/blocks/
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
}
|
|
5063
|
-
function createTextarea(className, rows, placeholder, value, onInput) {
|
|
5064
|
-
const ta = document.createElement("textarea");
|
|
5065
|
-
ta.className = className;
|
|
5066
|
-
ta.rows = rows;
|
|
5067
|
-
ta.placeholder = placeholder;
|
|
5068
|
-
ta.value = value;
|
|
5069
|
-
ta.addEventListener("input", () => onInput(ta.value));
|
|
5070
|
-
return ta;
|
|
5071
|
-
}
|
|
5072
|
-
var BookmarkTool = class {
|
|
5073
|
-
data;
|
|
5511
|
+
// src/blocks/structuredBlocks.ts
|
|
5512
|
+
var TimelineTool = class {
|
|
5513
|
+
steps;
|
|
5514
|
+
constructor(options) {
|
|
5515
|
+
this.steps = Array.isArray(options.data?.steps) && options.data.steps.length ? options.data.steps.map((s) => ({ ...s })) : [
|
|
5516
|
+
{ title: "Step 1", detail: "" },
|
|
5517
|
+
{ title: "Step 2", detail: "" }
|
|
5518
|
+
];
|
|
5519
|
+
}
|
|
5074
5520
|
static get toolbox() {
|
|
5075
5521
|
return {
|
|
5076
|
-
title: "
|
|
5077
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
5078
|
-
};
|
|
5079
|
-
}
|
|
5080
|
-
constructor({ data }) {
|
|
5081
|
-
this.data = {
|
|
5082
|
-
url: data?.url ?? "",
|
|
5083
|
-
title: data?.title ?? "",
|
|
5084
|
-
description: data?.description ?? "",
|
|
5085
|
-
image: data?.image ?? ""
|
|
5522
|
+
title: "Timeline",
|
|
5523
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="6" y1="4" x2="6" y2="20"/><circle cx="6" cy="6" r="2"/><circle cx="6" cy="12" r="2"/><circle cx="6" cy="18" r="2"/><line x1="11" y1="6" x2="20" y2="6"/><line x1="11" y1="12" x2="20" y2="12"/><line x1="11" y1="18" x2="20" y2="18"/></svg>'
|
|
5086
5524
|
};
|
|
5087
5525
|
}
|
|
5088
5526
|
render() {
|
|
5089
|
-
const
|
|
5090
|
-
|
|
5091
|
-
const
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
}
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5527
|
+
const root = document.createElement("div");
|
|
5528
|
+
root.className = "block-card";
|
|
5529
|
+
const list = document.createElement("div");
|
|
5530
|
+
list.className = "block-rows";
|
|
5531
|
+
const draw = () => {
|
|
5532
|
+
list.innerHTML = "";
|
|
5533
|
+
this.steps.forEach((step, idx) => {
|
|
5534
|
+
const row = document.createElement("div");
|
|
5535
|
+
row.className = "block-subrow";
|
|
5536
|
+
const top = document.createElement("div");
|
|
5537
|
+
top.className = "block-subrow-head";
|
|
5538
|
+
const titleIn = document.createElement("input");
|
|
5539
|
+
titleIn.type = "text";
|
|
5540
|
+
titleIn.placeholder = `Step ${idx + 1} title`;
|
|
5541
|
+
titleIn.value = step.title;
|
|
5542
|
+
titleIn.oninput = () => {
|
|
5543
|
+
step.title = titleIn.value;
|
|
5544
|
+
};
|
|
5545
|
+
const rmBtn = document.createElement("button");
|
|
5546
|
+
rmBtn.type = "button";
|
|
5547
|
+
rmBtn.className = "b2";
|
|
5548
|
+
rmBtn.textContent = "\xD7";
|
|
5549
|
+
rmBtn.onclick = () => {
|
|
5550
|
+
this.steps.splice(idx, 1);
|
|
5551
|
+
draw();
|
|
5552
|
+
};
|
|
5553
|
+
top.append(titleIn, rmBtn);
|
|
5554
|
+
const detailIn = document.createElement("textarea");
|
|
5555
|
+
detailIn.rows = 2;
|
|
5556
|
+
detailIn.placeholder = "Short step description...";
|
|
5557
|
+
detailIn.value = step.detail;
|
|
5558
|
+
detailIn.oninput = () => {
|
|
5559
|
+
step.detail = detailIn.value;
|
|
5560
|
+
};
|
|
5561
|
+
row.append(top, detailIn);
|
|
5562
|
+
list.appendChild(row);
|
|
5563
|
+
});
|
|
5113
5564
|
};
|
|
5114
|
-
const
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
createInput("text", "cdx-input", "Short description", this.data.description, (v) => {
|
|
5126
|
-
this.data.description = v;
|
|
5127
|
-
refreshPreview();
|
|
5128
|
-
}),
|
|
5129
|
-
createInput("url", "cdx-input", "Optional thumbnail URL", this.data.image || "", (v) => {
|
|
5130
|
-
this.data.image = v;
|
|
5131
|
-
refreshPreview();
|
|
5132
|
-
})
|
|
5133
|
-
);
|
|
5134
|
-
refreshPreview();
|
|
5135
|
-
wrap.append(head, grid, preview);
|
|
5136
|
-
return wrap;
|
|
5565
|
+
const addBtn = document.createElement("button");
|
|
5566
|
+
addBtn.type = "button";
|
|
5567
|
+
addBtn.className = "b2";
|
|
5568
|
+
addBtn.textContent = "+ Add step";
|
|
5569
|
+
addBtn.onclick = () => {
|
|
5570
|
+
this.steps.push({ title: `Step ${this.steps.length + 1}`, detail: "" });
|
|
5571
|
+
draw();
|
|
5572
|
+
};
|
|
5573
|
+
draw();
|
|
5574
|
+
root.append(list, addBtn);
|
|
5575
|
+
return root;
|
|
5137
5576
|
}
|
|
5138
5577
|
save() {
|
|
5139
|
-
return {
|
|
5140
|
-
url: this.data.url.trim(),
|
|
5141
|
-
title: this.data.title.trim(),
|
|
5142
|
-
description: this.data.description.trim(),
|
|
5143
|
-
image: this.data.image?.trim() || void 0
|
|
5144
|
-
};
|
|
5578
|
+
return { steps: this.steps };
|
|
5145
5579
|
}
|
|
5146
5580
|
};
|
|
5147
|
-
var
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
}
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
{ title: "Configure & render", body: "Pass initialData and onChange to BlockEditor." }
|
|
5160
|
-
]
|
|
5581
|
+
var StatsTool = class {
|
|
5582
|
+
stats;
|
|
5583
|
+
constructor(options) {
|
|
5584
|
+
this.stats = Array.isArray(options.data?.stats) && options.data.stats.length ? options.data.stats.map((s) => ({ ...s })) : [
|
|
5585
|
+
{ value: "99.9%", label: "Uptime" },
|
|
5586
|
+
{ value: "42ms", label: "Latency" }
|
|
5587
|
+
];
|
|
5588
|
+
}
|
|
5589
|
+
static get toolbox() {
|
|
5590
|
+
return {
|
|
5591
|
+
title: "Stats row",
|
|
5592
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>'
|
|
5161
5593
|
};
|
|
5162
5594
|
}
|
|
5163
5595
|
render() {
|
|
5164
|
-
const
|
|
5165
|
-
|
|
5166
|
-
const head = document.createElement("div");
|
|
5167
|
-
head.className = "editor-extra-head";
|
|
5168
|
-
head.textContent = "Step-by-Step Walkthrough";
|
|
5596
|
+
const root = document.createElement("div");
|
|
5597
|
+
root.className = "block-card";
|
|
5169
5598
|
const list = document.createElement("div");
|
|
5170
|
-
list.className = "
|
|
5171
|
-
const
|
|
5599
|
+
list.className = "block-rows";
|
|
5600
|
+
const draw = () => {
|
|
5172
5601
|
list.innerHTML = "";
|
|
5173
|
-
this.
|
|
5602
|
+
this.stats.forEach((stat, idx) => {
|
|
5174
5603
|
const row = document.createElement("div");
|
|
5175
|
-
row.className = "
|
|
5176
|
-
const
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
row.append(badge, fields, removeBtn);
|
|
5604
|
+
row.className = "block-subrow-head";
|
|
5605
|
+
const valIn = document.createElement("input");
|
|
5606
|
+
valIn.type = "text";
|
|
5607
|
+
valIn.placeholder = "Value (e.g. 99.9%)";
|
|
5608
|
+
valIn.value = stat.value;
|
|
5609
|
+
valIn.oninput = () => {
|
|
5610
|
+
stat.value = valIn.value;
|
|
5611
|
+
};
|
|
5612
|
+
const lblIn = document.createElement("input");
|
|
5613
|
+
lblIn.type = "text";
|
|
5614
|
+
lblIn.placeholder = "Label (e.g. Uptime)";
|
|
5615
|
+
lblIn.value = stat.label;
|
|
5616
|
+
lblIn.oninput = () => {
|
|
5617
|
+
stat.label = lblIn.value;
|
|
5618
|
+
};
|
|
5619
|
+
const rmBtn = document.createElement("button");
|
|
5620
|
+
rmBtn.type = "button";
|
|
5621
|
+
rmBtn.className = "b2";
|
|
5622
|
+
rmBtn.textContent = "\xD7";
|
|
5623
|
+
rmBtn.onclick = () => {
|
|
5624
|
+
this.stats.splice(idx, 1);
|
|
5625
|
+
draw();
|
|
5626
|
+
};
|
|
5627
|
+
row.append(valIn, lblIn, rmBtn);
|
|
5200
5628
|
list.appendChild(row);
|
|
5201
5629
|
});
|
|
5202
5630
|
};
|
|
5203
5631
|
const addBtn = document.createElement("button");
|
|
5204
5632
|
addBtn.type = "button";
|
|
5205
|
-
addBtn.className = "
|
|
5206
|
-
addBtn.textContent = "+ Add
|
|
5207
|
-
addBtn.
|
|
5208
|
-
this.
|
|
5209
|
-
|
|
5210
|
-
}
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
return
|
|
5633
|
+
addBtn.className = "b2";
|
|
5634
|
+
addBtn.textContent = "+ Add metric";
|
|
5635
|
+
addBtn.onclick = () => {
|
|
5636
|
+
this.stats.push({ value: "", label: "" });
|
|
5637
|
+
draw();
|
|
5638
|
+
};
|
|
5639
|
+
draw();
|
|
5640
|
+
root.append(list, addBtn);
|
|
5641
|
+
return root;
|
|
5214
5642
|
}
|
|
5215
5643
|
save() {
|
|
5216
|
-
return {
|
|
5217
|
-
items: this.data.items.filter((i) => i.title.trim() || i.body.trim())
|
|
5218
|
-
};
|
|
5644
|
+
return { stats: this.stats };
|
|
5219
5645
|
}
|
|
5220
5646
|
};
|
|
5221
|
-
|
|
5222
|
-
const a = before.split("\n");
|
|
5223
|
-
const b = after.split("\n");
|
|
5224
|
-
const lines = [];
|
|
5225
|
-
const max = Math.max(a.length, b.length);
|
|
5226
|
-
for (let i = 0; i < max; i += 1) {
|
|
5227
|
-
const left = a[i];
|
|
5228
|
-
const right = b[i];
|
|
5229
|
-
if (left === right) {
|
|
5230
|
-
if (left !== void 0) lines.push({ kind: "same", text: left });
|
|
5231
|
-
} else {
|
|
5232
|
-
if (left !== void 0) lines.push({ kind: "del", text: left });
|
|
5233
|
-
if (right !== void 0) lines.push({ kind: "add", text: right });
|
|
5234
|
-
}
|
|
5235
|
-
}
|
|
5236
|
-
return lines;
|
|
5237
|
-
}
|
|
5238
|
-
var DiffTool = class {
|
|
5647
|
+
var ProsConsTool = class {
|
|
5239
5648
|
data;
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5649
|
+
constructor(options) {
|
|
5650
|
+
this.data = {
|
|
5651
|
+
pros: options.data?.pros || [""],
|
|
5652
|
+
cons: options.data?.cons || [""]
|
|
5244
5653
|
};
|
|
5245
5654
|
}
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
after: data?.after ?? 'const theme = "dark";'
|
|
5655
|
+
static get toolbox() {
|
|
5656
|
+
return {
|
|
5657
|
+
title: "Pros & Cons",
|
|
5658
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="3" x2="12" y2="21"/><path d="M6 12h3"/><path d="M7.5 10.5v3"/><path d="M15 12h3"/></svg>'
|
|
5251
5659
|
};
|
|
5252
5660
|
}
|
|
5253
5661
|
render() {
|
|
5254
|
-
const
|
|
5255
|
-
|
|
5256
|
-
const
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
}
|
|
5662
|
+
const root = document.createElement("div");
|
|
5663
|
+
root.className = "block-card";
|
|
5664
|
+
const grid = document.createElement("div");
|
|
5665
|
+
grid.className = "block-two-col";
|
|
5666
|
+
const makeCol = (title, key) => {
|
|
5667
|
+
const box = document.createElement("div");
|
|
5668
|
+
box.className = "block-subrow";
|
|
5669
|
+
const heading = document.createElement("div");
|
|
5670
|
+
heading.className = "block-hint";
|
|
5671
|
+
heading.textContent = title;
|
|
5672
|
+
const ta = document.createElement("textarea");
|
|
5673
|
+
ta.rows = 4;
|
|
5674
|
+
ta.placeholder = `${title}, one per line...`;
|
|
5675
|
+
ta.value = this.data[key].join("\n");
|
|
5676
|
+
ta.oninput = () => {
|
|
5677
|
+
this.data[key] = ta.value.split(/\n/).map((s) => s.trim()).filter(Boolean);
|
|
5678
|
+
};
|
|
5679
|
+
box.append(heading, ta);
|
|
5680
|
+
return box;
|
|
5267
5681
|
};
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
createTextarea("editor-mermaid-input", 4, "Before code...", this.data.before, (v) => {
|
|
5272
|
-
this.data.before = v;
|
|
5273
|
-
refreshPreview();
|
|
5274
|
-
}),
|
|
5275
|
-
createTextarea("editor-mermaid-input", 4, "After code...", this.data.after, (v) => {
|
|
5276
|
-
this.data.after = v;
|
|
5277
|
-
refreshPreview();
|
|
5278
|
-
})
|
|
5279
|
-
);
|
|
5280
|
-
const fileInput = createInput("text", "cdx-input", "Filename (optional)", this.data.filename || "", (v) => {
|
|
5281
|
-
this.data.filename = v;
|
|
5282
|
-
});
|
|
5283
|
-
refreshPreview();
|
|
5284
|
-
wrap.append(head, fileInput, cols, preview);
|
|
5285
|
-
return wrap;
|
|
5682
|
+
grid.append(makeCol("Pros", "pros"), makeCol("Cons", "cons"));
|
|
5683
|
+
root.appendChild(grid);
|
|
5684
|
+
return root;
|
|
5286
5685
|
}
|
|
5287
5686
|
save() {
|
|
5288
|
-
return
|
|
5289
|
-
filename: this.data.filename?.trim() || void 0,
|
|
5290
|
-
before: this.data.before,
|
|
5291
|
-
after: this.data.after
|
|
5292
|
-
};
|
|
5687
|
+
return this.data;
|
|
5293
5688
|
}
|
|
5294
5689
|
};
|
|
5295
|
-
var
|
|
5296
|
-
|
|
5690
|
+
var CardsTool = class {
|
|
5691
|
+
cards;
|
|
5692
|
+
constructor(options) {
|
|
5693
|
+
this.cards = Array.isArray(options.data?.cards) && options.data.cards.length ? options.data.cards.map((c) => ({ ...c })) : [{ title: "", subtitle: "", url: "", badge: "Link" }];
|
|
5694
|
+
}
|
|
5297
5695
|
static get toolbox() {
|
|
5298
5696
|
return {
|
|
5299
|
-
title: "
|
|
5300
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
5697
|
+
title: "Card grid",
|
|
5698
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="8" height="7" rx="1.5"/><rect x="13" y="4" width="8" height="7" rx="1.5"/><rect x="3" y="13" width="8" height="7" rx="1.5"/><rect x="13" y="13" width="8" height="7" rx="1.5"/></svg>'
|
|
5301
5699
|
};
|
|
5302
5700
|
}
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5701
|
+
render() {
|
|
5702
|
+
const root = document.createElement("div");
|
|
5703
|
+
root.className = "block-card";
|
|
5704
|
+
const list = document.createElement("div");
|
|
5705
|
+
list.className = "block-rows";
|
|
5706
|
+
const draw = () => {
|
|
5707
|
+
list.innerHTML = "";
|
|
5708
|
+
this.cards.forEach((card, idx) => {
|
|
5709
|
+
const row = document.createElement("div");
|
|
5710
|
+
row.className = "block-subrow";
|
|
5711
|
+
const top = document.createElement("div");
|
|
5712
|
+
top.className = "block-subrow-head";
|
|
5713
|
+
const titleIn = document.createElement("input");
|
|
5714
|
+
titleIn.type = "text";
|
|
5715
|
+
titleIn.placeholder = "Card title";
|
|
5716
|
+
titleIn.value = card.title;
|
|
5717
|
+
titleIn.oninput = () => {
|
|
5718
|
+
card.title = titleIn.value;
|
|
5719
|
+
};
|
|
5720
|
+
const badgeIn = document.createElement("input");
|
|
5721
|
+
badgeIn.type = "text";
|
|
5722
|
+
badgeIn.placeholder = "Badge (PDF / Link)";
|
|
5723
|
+
badgeIn.value = card.badge || "";
|
|
5724
|
+
badgeIn.oninput = () => {
|
|
5725
|
+
card.badge = badgeIn.value;
|
|
5726
|
+
};
|
|
5727
|
+
const rmBtn = document.createElement("button");
|
|
5728
|
+
rmBtn.type = "button";
|
|
5729
|
+
rmBtn.className = "b2";
|
|
5730
|
+
rmBtn.textContent = "\xD7";
|
|
5731
|
+
rmBtn.onclick = () => {
|
|
5732
|
+
this.cards.splice(idx, 1);
|
|
5733
|
+
draw();
|
|
5734
|
+
};
|
|
5735
|
+
top.append(titleIn, badgeIn, rmBtn);
|
|
5736
|
+
const subIn = document.createElement("input");
|
|
5737
|
+
subIn.type = "text";
|
|
5738
|
+
subIn.placeholder = "Short description";
|
|
5739
|
+
subIn.value = card.subtitle || "";
|
|
5740
|
+
subIn.oninput = () => {
|
|
5741
|
+
card.subtitle = subIn.value;
|
|
5742
|
+
};
|
|
5743
|
+
const urlIn = document.createElement("input");
|
|
5744
|
+
urlIn.type = "url";
|
|
5745
|
+
urlIn.placeholder = "URL or upload a file below";
|
|
5746
|
+
urlIn.value = card.url;
|
|
5747
|
+
urlIn.oninput = () => {
|
|
5748
|
+
card.url = urlIn.value.trim();
|
|
5749
|
+
};
|
|
5750
|
+
const fileIn = document.createElement("input");
|
|
5751
|
+
fileIn.type = "file";
|
|
5752
|
+
fileIn.onchange = async () => {
|
|
5753
|
+
const file = fileIn.files?.[0];
|
|
5754
|
+
if (!file) return;
|
|
5755
|
+
if (!card.title) card.title = file.name;
|
|
5756
|
+
titleIn.value = card.title;
|
|
5757
|
+
const bucketUrl = await uploadFileToBucket(file, "attachments");
|
|
5758
|
+
if (bucketUrl) {
|
|
5759
|
+
card.url = bucketUrl;
|
|
5760
|
+
urlIn.value = bucketUrl;
|
|
5761
|
+
return;
|
|
5762
|
+
}
|
|
5763
|
+
const reader = new FileReader();
|
|
5764
|
+
reader.onload = () => {
|
|
5765
|
+
card.url = String(reader.result || "");
|
|
5766
|
+
urlIn.value = card.url;
|
|
5767
|
+
};
|
|
5768
|
+
reader.readAsDataURL(file);
|
|
5769
|
+
};
|
|
5770
|
+
row.append(top, subIn, urlIn, fileIn);
|
|
5771
|
+
list.appendChild(row);
|
|
5772
|
+
});
|
|
5308
5773
|
};
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
const preview = document.createElement("div");
|
|
5317
|
-
preview.className = "editor-video-preview";
|
|
5318
|
-
const refreshPreview = () => {
|
|
5319
|
-
if (!this.data.url.trim()) {
|
|
5320
|
-
preview.innerHTML = '<div class="editor-mermaid-empty">Paste a video URL or upload a file</div>';
|
|
5321
|
-
return;
|
|
5322
|
-
}
|
|
5323
|
-
preview.innerHTML = `<video controls preload="metadata" class="editor-video-el"${this.data.poster ? ` poster="${escHtml(this.data.poster)}"` : ""}><source src="${escHtml(this.data.url)}" /></video>`;
|
|
5774
|
+
const addBtn = document.createElement("button");
|
|
5775
|
+
addBtn.type = "button";
|
|
5776
|
+
addBtn.className = "b2";
|
|
5777
|
+
addBtn.textContent = "+ Add card";
|
|
5778
|
+
addBtn.onclick = () => {
|
|
5779
|
+
this.cards.push({ title: "", subtitle: "", url: "", badge: "Link" });
|
|
5780
|
+
draw();
|
|
5324
5781
|
};
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
});
|
|
5329
|
-
const uploadInput = document.createElement("input");
|
|
5330
|
-
uploadInput.type = "file";
|
|
5331
|
-
uploadInput.accept = "video/mp4,video/webm,video/ogg";
|
|
5332
|
-
uploadInput.className = "cdx-input";
|
|
5333
|
-
uploadInput.addEventListener("change", async () => {
|
|
5334
|
-
const file = uploadInput.files?.[0];
|
|
5335
|
-
if (!file) return;
|
|
5336
|
-
const uploaded = await uploadFileToBucket(file, "videos");
|
|
5337
|
-
if (uploaded) {
|
|
5338
|
-
this.data.url = uploaded;
|
|
5339
|
-
urlInput.value = uploaded;
|
|
5340
|
-
refreshPreview();
|
|
5341
|
-
}
|
|
5342
|
-
});
|
|
5343
|
-
const posterInput = createInput("url", "cdx-input", "Optional poster image URL", this.data.poster || "", (v) => {
|
|
5344
|
-
this.data.poster = v;
|
|
5345
|
-
refreshPreview();
|
|
5346
|
-
});
|
|
5347
|
-
const captionInput = createInput("text", "cdx-input", "Optional video caption", this.data.caption || "", (v) => {
|
|
5348
|
-
this.data.caption = v;
|
|
5349
|
-
});
|
|
5350
|
-
refreshPreview();
|
|
5351
|
-
wrap.append(head, urlInput, uploadInput, posterInput, captionInput, preview);
|
|
5352
|
-
return wrap;
|
|
5782
|
+
draw();
|
|
5783
|
+
root.append(list, addBtn);
|
|
5784
|
+
return root;
|
|
5353
5785
|
}
|
|
5354
5786
|
save() {
|
|
5355
|
-
return {
|
|
5356
|
-
url: this.data.url.trim(),
|
|
5357
|
-
poster: this.data.poster?.trim() || void 0,
|
|
5358
|
-
caption: this.data.caption?.trim() || void 0
|
|
5359
|
-
};
|
|
5787
|
+
return { cards: this.cards };
|
|
5360
5788
|
}
|
|
5361
5789
|
};
|
|
5362
|
-
var
|
|
5363
|
-
|
|
5790
|
+
var BadgesTool = class {
|
|
5791
|
+
items;
|
|
5792
|
+
constructor(options) {
|
|
5793
|
+
this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((b) => ({ ...b })) : [{ label: "New", tone: "accent" }];
|
|
5794
|
+
}
|
|
5364
5795
|
static get toolbox() {
|
|
5365
5796
|
return {
|
|
5366
|
-
title: "
|
|
5367
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="
|
|
5368
|
-
};
|
|
5369
|
-
}
|
|
5370
|
-
constructor({ data }) {
|
|
5371
|
-
this.data = {
|
|
5372
|
-
version: data?.version ?? "v1.0.0",
|
|
5373
|
-
date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
5374
|
-
items: Array.isArray(data?.items) && data.items.length > 0 ? data.items.map((i) => ({ kind: i.kind || "added", text: i.text || "" })) : [{ kind: "added", text: "Initial release notes" }]
|
|
5797
|
+
title: "Badges",
|
|
5798
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2l2.9 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l7.1-1.01L12 2z"/></svg>'
|
|
5375
5799
|
};
|
|
5376
5800
|
}
|
|
5377
5801
|
render() {
|
|
5378
|
-
const
|
|
5379
|
-
|
|
5380
|
-
const head = document.createElement("div");
|
|
5381
|
-
head.className = "editor-extra-head";
|
|
5382
|
-
head.textContent = "Release Changelog";
|
|
5383
|
-
const meta = document.createElement("div");
|
|
5384
|
-
meta.className = "editor-diff-inputs";
|
|
5385
|
-
meta.append(
|
|
5386
|
-
createInput("text", "cdx-input", "Version (e.g. v1.2.0)", this.data.version, (v) => {
|
|
5387
|
-
this.data.version = v;
|
|
5388
|
-
}),
|
|
5389
|
-
createInput("date", "cdx-input", "Release date", this.data.date, (v) => {
|
|
5390
|
-
this.data.date = v;
|
|
5391
|
-
})
|
|
5392
|
-
);
|
|
5802
|
+
const root = document.createElement("div");
|
|
5803
|
+
root.className = "block-card";
|
|
5393
5804
|
const list = document.createElement("div");
|
|
5394
|
-
list.className = "
|
|
5395
|
-
const
|
|
5805
|
+
list.className = "block-rows";
|
|
5806
|
+
const tones = ["neutral", "accent", "green", "blue", "amber", "red"];
|
|
5807
|
+
const draw = () => {
|
|
5396
5808
|
list.innerHTML = "";
|
|
5397
|
-
this.
|
|
5809
|
+
this.items.forEach((item, idx) => {
|
|
5398
5810
|
const row = document.createElement("div");
|
|
5399
|
-
row.className = "
|
|
5400
|
-
const
|
|
5401
|
-
|
|
5402
|
-
|
|
5811
|
+
row.className = "block-subrow-head";
|
|
5812
|
+
const labelIn = document.createElement("input");
|
|
5813
|
+
labelIn.type = "text";
|
|
5814
|
+
labelIn.placeholder = "Badge label (e.g. Beta, v2.0)";
|
|
5815
|
+
labelIn.value = item.label;
|
|
5816
|
+
labelIn.oninput = () => {
|
|
5817
|
+
item.label = labelIn.value;
|
|
5818
|
+
};
|
|
5819
|
+
const toneSel = document.createElement("select");
|
|
5820
|
+
tones.forEach((t) => {
|
|
5403
5821
|
const opt = document.createElement("option");
|
|
5404
|
-
opt.value =
|
|
5405
|
-
opt.textContent =
|
|
5406
|
-
|
|
5407
|
-
select.appendChild(opt);
|
|
5408
|
-
});
|
|
5409
|
-
select.addEventListener("change", () => {
|
|
5410
|
-
item.kind = select.value;
|
|
5411
|
-
});
|
|
5412
|
-
const text = createInput("text", "cdx-input", "Change description", item.text, (v) => {
|
|
5413
|
-
item.text = v;
|
|
5414
|
-
});
|
|
5415
|
-
const del = document.createElement("button");
|
|
5416
|
-
del.type = "button";
|
|
5417
|
-
del.className = "excalidraw-btn";
|
|
5418
|
-
del.textContent = "\xD7";
|
|
5419
|
-
del.addEventListener("click", () => {
|
|
5420
|
-
if (this.data.items.length <= 1) return;
|
|
5421
|
-
this.data.items.splice(idx, 1);
|
|
5422
|
-
renderItems();
|
|
5822
|
+
opt.value = t;
|
|
5823
|
+
opt.textContent = t.charAt(0).toUpperCase() + t.slice(1);
|
|
5824
|
+
toneSel.appendChild(opt);
|
|
5423
5825
|
});
|
|
5424
|
-
|
|
5826
|
+
toneSel.value = item.tone || "neutral";
|
|
5827
|
+
toneSel.onchange = () => {
|
|
5828
|
+
item.tone = toneSel.value;
|
|
5829
|
+
};
|
|
5830
|
+
const rmBtn = document.createElement("button");
|
|
5831
|
+
rmBtn.type = "button";
|
|
5832
|
+
rmBtn.className = "b2";
|
|
5833
|
+
rmBtn.textContent = "\xD7";
|
|
5834
|
+
rmBtn.onclick = () => {
|
|
5835
|
+
this.items.splice(idx, 1);
|
|
5836
|
+
draw();
|
|
5837
|
+
};
|
|
5838
|
+
row.append(labelIn, toneSel, rmBtn);
|
|
5425
5839
|
list.appendChild(row);
|
|
5426
5840
|
});
|
|
5427
5841
|
};
|
|
5428
5842
|
const addBtn = document.createElement("button");
|
|
5429
5843
|
addBtn.type = "button";
|
|
5430
|
-
addBtn.className = "
|
|
5431
|
-
addBtn.textContent = "+ Add
|
|
5432
|
-
addBtn.
|
|
5433
|
-
this.
|
|
5434
|
-
|
|
5435
|
-
}
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
return
|
|
5844
|
+
addBtn.className = "b2";
|
|
5845
|
+
addBtn.textContent = "+ Add badge";
|
|
5846
|
+
addBtn.onclick = () => {
|
|
5847
|
+
this.items.push({ label: "", tone: "neutral" });
|
|
5848
|
+
draw();
|
|
5849
|
+
};
|
|
5850
|
+
draw();
|
|
5851
|
+
root.append(list, addBtn);
|
|
5852
|
+
return root;
|
|
5853
|
+
}
|
|
5854
|
+
save() {
|
|
5855
|
+
return { items: this.items.filter((i) => i.label.trim()) };
|
|
5856
|
+
}
|
|
5857
|
+
};
|
|
5858
|
+
var TagsTool = class {
|
|
5859
|
+
raw;
|
|
5860
|
+
input;
|
|
5861
|
+
constructor(options) {
|
|
5862
|
+
this.raw = Array.isArray(options.data?.tags) ? options.data.tags.join(", ") : "";
|
|
5863
|
+
}
|
|
5864
|
+
static get toolbox() {
|
|
5865
|
+
return {
|
|
5866
|
+
title: "Tags",
|
|
5867
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"/><line x1="7" y1="7" x2="7.01" y2="7"/></svg>'
|
|
5868
|
+
};
|
|
5869
|
+
}
|
|
5870
|
+
render() {
|
|
5871
|
+
const root = document.createElement("div");
|
|
5872
|
+
root.className = "block-card";
|
|
5873
|
+
const input = document.createElement("input");
|
|
5874
|
+
input.type = "text";
|
|
5875
|
+
input.placeholder = "Comma-separated tags (e.g. react, typescript, design)";
|
|
5876
|
+
input.value = this.raw;
|
|
5877
|
+
root.appendChild(input);
|
|
5878
|
+
this.input = input;
|
|
5879
|
+
return root;
|
|
5439
5880
|
}
|
|
5440
5881
|
save() {
|
|
5882
|
+
const val = this.input?.value ?? this.raw;
|
|
5441
5883
|
return {
|
|
5442
|
-
|
|
5443
|
-
date: this.data.date,
|
|
5444
|
-
items: this.data.items.filter((i) => i.text.trim())
|
|
5884
|
+
tags: val.split(",").map((t) => t.trim().replace(/^#/, "")).filter(Boolean)
|
|
5445
5885
|
};
|
|
5446
5886
|
}
|
|
5447
|
-
};
|
|
5448
|
-
|
|
5887
|
+
};
|
|
5888
|
+
|
|
5889
|
+
// src/blocks/mermaidBlock.ts
|
|
5890
|
+
import mermaid from "mermaid";
|
|
5891
|
+
var MERMAID_PRESETS = {
|
|
5892
|
+
Flowchart: `graph TD
|
|
5893
|
+
A[Start] --> B{Condition?}
|
|
5894
|
+
B -->|Yes| C[Proceed]
|
|
5895
|
+
B -->|No| D[Retry]`,
|
|
5896
|
+
Sequence: `sequenceDiagram
|
|
5897
|
+
User->>Editor: Type /mermaid
|
|
5898
|
+
Editor->>Mermaid: Render SVG
|
|
5899
|
+
Mermaid-->>User: Interactive Diagram`,
|
|
5900
|
+
Mindmap: `mindmap
|
|
5901
|
+
root((NextGen Editor))
|
|
5902
|
+
Blocks
|
|
5903
|
+
Mermaid
|
|
5904
|
+
Charts
|
|
5905
|
+
Code
|
|
5906
|
+
AI
|
|
5907
|
+
Rewrite
|
|
5908
|
+
Continue`
|
|
5909
|
+
};
|
|
5910
|
+
var mermaidInitialized = false;
|
|
5911
|
+
var mermaidCounter = 0;
|
|
5912
|
+
function ensureMermaidInit() {
|
|
5913
|
+
if (mermaidInitialized) return;
|
|
5914
|
+
mermaidInitialized = true;
|
|
5915
|
+
mermaid.initialize({
|
|
5916
|
+
startOnLoad: false,
|
|
5917
|
+
securityLevel: "strict",
|
|
5918
|
+
theme: "neutral"
|
|
5919
|
+
});
|
|
5920
|
+
}
|
|
5921
|
+
async function renderMermaidInto(container, code) {
|
|
5922
|
+
const trimmed = code.trim();
|
|
5923
|
+
if (!trimmed) {
|
|
5924
|
+
container.innerHTML = '<span class="editor-mermaid-empty">Enter Mermaid syntax to preview</span>';
|
|
5925
|
+
return;
|
|
5926
|
+
}
|
|
5927
|
+
ensureMermaidInit();
|
|
5928
|
+
const id = `ng-mermaid-${++mermaidCounter}`;
|
|
5929
|
+
try {
|
|
5930
|
+
const { svg } = await mermaid.render(id, trimmed);
|
|
5931
|
+
container.innerHTML = svg;
|
|
5932
|
+
} catch (err) {
|
|
5933
|
+
const message = err instanceof Error ? err.message : "Invalid Mermaid syntax";
|
|
5934
|
+
container.innerHTML = `<pre class="editor-mermaid-error">${message.replace(/</g, "<")}</pre>`;
|
|
5935
|
+
}
|
|
5936
|
+
}
|
|
5937
|
+
var MermaidTool = class {
|
|
5449
5938
|
data;
|
|
5939
|
+
renderSeq = 0;
|
|
5940
|
+
previewEl = null;
|
|
5450
5941
|
static get toolbox() {
|
|
5451
5942
|
return {
|
|
5452
|
-
title: "
|
|
5453
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
5943
|
+
title: "Mermaid Diagram",
|
|
5944
|
+
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="6" height="6" rx="1"/><rect x="15" y="3" width="6" height="6" rx="1"/><rect x="9" y="15" width="6" height="6" rx="1"/><path d="M6 9v3a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V9"/><path d="M12 12v3"/></svg>'
|
|
5454
5945
|
};
|
|
5455
5946
|
}
|
|
5456
5947
|
constructor({ data }) {
|
|
5457
5948
|
this.data = {
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
url: data?.url ?? ""
|
|
5949
|
+
code: data?.code ?? MERMAID_PRESETS.Flowchart,
|
|
5950
|
+
caption: data?.caption ?? "",
|
|
5951
|
+
align: data?.align ?? "center",
|
|
5952
|
+
size: data?.size ?? "small"
|
|
5463
5953
|
};
|
|
5464
5954
|
}
|
|
5465
5955
|
render() {
|
|
5466
5956
|
const wrap = document.createElement("div");
|
|
5467
|
-
wrap.className = "editor-
|
|
5957
|
+
wrap.className = "editor-mermaid-tool";
|
|
5468
5958
|
const head = document.createElement("div");
|
|
5469
|
-
head.className = "editor-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5959
|
+
head.className = "editor-mermaid-head";
|
|
5960
|
+
const title = document.createElement("span");
|
|
5961
|
+
title.className = "editor-mermaid-label";
|
|
5962
|
+
title.textContent = "Mermaid Diagram";
|
|
5963
|
+
const presets = document.createElement("div");
|
|
5964
|
+
presets.className = "editor-mermaid-presets";
|
|
5965
|
+
Object.entries(MERMAID_PRESETS).forEach(([label, snippet]) => {
|
|
5966
|
+
const btn = document.createElement("button");
|
|
5967
|
+
btn.type = "button";
|
|
5968
|
+
btn.className = "editor-mermaid-preset-btn";
|
|
5969
|
+
btn.textContent = label;
|
|
5970
|
+
btn.addEventListener("click", () => {
|
|
5971
|
+
this.data.code = snippet;
|
|
5972
|
+
textarea.value = snippet;
|
|
5973
|
+
void updatePreview();
|
|
5974
|
+
});
|
|
5975
|
+
presets.appendChild(btn);
|
|
5483
5976
|
});
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5977
|
+
head.append(title, presets);
|
|
5978
|
+
const textarea = document.createElement("textarea");
|
|
5979
|
+
textarea.className = "editor-mermaid-input";
|
|
5980
|
+
textarea.rows = 5;
|
|
5981
|
+
textarea.placeholder = "graph TD\n A --> B";
|
|
5982
|
+
textarea.value = this.data.code;
|
|
5983
|
+
const preview = document.createElement("div");
|
|
5984
|
+
preview.className = "editor-mermaid-preview";
|
|
5985
|
+
preview.dataset.align = this.data.align || "center";
|
|
5986
|
+
preview.dataset.size = this.data.size || "small";
|
|
5987
|
+
this.previewEl = preview;
|
|
5988
|
+
const captionInput = document.createElement("input");
|
|
5989
|
+
captionInput.type = "text";
|
|
5990
|
+
captionInput.className = "editor-mermaid-caption cdx-input";
|
|
5991
|
+
captionInput.placeholder = "Optional diagram caption";
|
|
5992
|
+
captionInput.value = this.data.caption || "";
|
|
5993
|
+
const updatePreview = async () => {
|
|
5994
|
+
const seq = ++this.renderSeq;
|
|
5995
|
+
await renderMermaidInto(preview, this.data.code);
|
|
5996
|
+
if (seq !== this.renderSeq) return;
|
|
5997
|
+
};
|
|
5998
|
+
textarea.addEventListener("input", () => {
|
|
5999
|
+
this.data.code = textarea.value;
|
|
6000
|
+
void updatePreview();
|
|
6001
|
+
});
|
|
6002
|
+
captionInput.addEventListener("input", () => {
|
|
6003
|
+
this.data.caption = captionInput.value;
|
|
6004
|
+
});
|
|
6005
|
+
void updatePreview();
|
|
6006
|
+
wrap.append(head, textarea, preview, captionInput);
|
|
5495
6007
|
return wrap;
|
|
5496
6008
|
}
|
|
6009
|
+
renderSettings() {
|
|
6010
|
+
const tunes = [
|
|
6011
|
+
{
|
|
6012
|
+
label: "Align Left",
|
|
6013
|
+
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="18" y2="18"/></svg>',
|
|
6014
|
+
isActive: (this.data.align || "center") === "left",
|
|
6015
|
+
onActivate: () => {
|
|
6016
|
+
this.data.align = "left";
|
|
6017
|
+
if (this.previewEl) this.previewEl.dataset.align = "left";
|
|
6018
|
+
}
|
|
6019
|
+
},
|
|
6020
|
+
{
|
|
6021
|
+
label: "Align Center",
|
|
6022
|
+
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="4" y1="18" x2="20" y2="18"/></svg>',
|
|
6023
|
+
isActive: (this.data.align || "center") === "center",
|
|
6024
|
+
onActivate: () => {
|
|
6025
|
+
this.data.align = "center";
|
|
6026
|
+
if (this.previewEl) this.previewEl.dataset.align = "center";
|
|
6027
|
+
}
|
|
6028
|
+
},
|
|
6029
|
+
{
|
|
6030
|
+
label: "Align Right",
|
|
6031
|
+
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="6" y1="18" x2="21" y2="18"/></svg>',
|
|
6032
|
+
isActive: (this.data.align || "center") === "right",
|
|
6033
|
+
onActivate: () => {
|
|
6034
|
+
this.data.align = "right";
|
|
6035
|
+
if (this.previewEl) this.previewEl.dataset.align = "right";
|
|
6036
|
+
}
|
|
6037
|
+
},
|
|
6038
|
+
{
|
|
6039
|
+
label: "Small",
|
|
6040
|
+
icon: '<span style="font-size:11px;font-weight:700;">S</span>',
|
|
6041
|
+
isActive: (this.data.size || "small") === "small",
|
|
6042
|
+
onActivate: () => {
|
|
6043
|
+
this.data.size = "small";
|
|
6044
|
+
if (this.previewEl) this.previewEl.dataset.size = "small";
|
|
6045
|
+
}
|
|
6046
|
+
},
|
|
6047
|
+
{
|
|
6048
|
+
label: "Medium",
|
|
6049
|
+
icon: '<span style="font-size:11px;font-weight:700;">M</span>',
|
|
6050
|
+
isActive: (this.data.size || "small") === "medium",
|
|
6051
|
+
onActivate: () => {
|
|
6052
|
+
this.data.size = "medium";
|
|
6053
|
+
if (this.previewEl) this.previewEl.dataset.size = "medium";
|
|
6054
|
+
}
|
|
6055
|
+
},
|
|
6056
|
+
{
|
|
6057
|
+
label: "Large",
|
|
6058
|
+
icon: '<span style="font-size:11px;font-weight:700;">L</span>',
|
|
6059
|
+
isActive: (this.data.size || "small") === "large",
|
|
6060
|
+
onActivate: () => {
|
|
6061
|
+
this.data.size = "large";
|
|
6062
|
+
if (this.previewEl) this.previewEl.dataset.size = "large";
|
|
6063
|
+
}
|
|
6064
|
+
},
|
|
6065
|
+
{
|
|
6066
|
+
label: "Full Page",
|
|
6067
|
+
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><line x1="21" y1="3" x2="14" y2="10"/><line x1="3" y1="21" x2="10" y2="14"/></svg>',
|
|
6068
|
+
isActive: (this.data.size || "small") === "full",
|
|
6069
|
+
onActivate: () => {
|
|
6070
|
+
this.data.size = "full";
|
|
6071
|
+
if (this.previewEl) this.previewEl.dataset.size = "full";
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
];
|
|
6075
|
+
return tunes.map((t) => ({
|
|
6076
|
+
icon: t.icon,
|
|
6077
|
+
label: t.label,
|
|
6078
|
+
isActive: t.isActive,
|
|
6079
|
+
closeOnActivate: true,
|
|
6080
|
+
onActivate: t.onActivate
|
|
6081
|
+
}));
|
|
6082
|
+
}
|
|
5497
6083
|
save() {
|
|
5498
6084
|
return {
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
url: this.data.url?.trim() || void 0
|
|
6085
|
+
code: this.data.code,
|
|
6086
|
+
caption: this.data.caption?.trim() || void 0,
|
|
6087
|
+
align: this.data.align || "center",
|
|
6088
|
+
size: this.data.size || "small"
|
|
5504
6089
|
};
|
|
5505
6090
|
}
|
|
5506
6091
|
};
|
|
@@ -5717,19 +6302,15 @@ var AiRewriteInline = class {
|
|
|
5717
6302
|
btn.type = "button";
|
|
5718
6303
|
btn.className = "ce-inline-tool";
|
|
5719
6304
|
btn.title = "AI Rewrite selection";
|
|
5720
|
-
btn.innerHTML = '<
|
|
6305
|
+
btn.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3l1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2z"/></svg>';
|
|
5721
6306
|
return btn;
|
|
5722
6307
|
}
|
|
5723
6308
|
surround(range) {
|
|
5724
6309
|
this.savedRange = range.cloneRange();
|
|
5725
|
-
if (this.actionsEl) {
|
|
5726
|
-
this.actionsEl.hidden = false;
|
|
5727
|
-
}
|
|
5728
6310
|
}
|
|
5729
6311
|
renderActions() {
|
|
5730
6312
|
const wrap = document.createElement("div");
|
|
5731
6313
|
wrap.className = "ng-inline-ai-actions";
|
|
5732
|
-
wrap.hidden = true;
|
|
5733
6314
|
const status = document.createElement("span");
|
|
5734
6315
|
status.className = "ng-inline-ai-status";
|
|
5735
6316
|
const row = document.createElement("div");
|
|
@@ -5739,6 +6320,7 @@ var AiRewriteInline = class {
|
|
|
5739
6320
|
b.type = "button";
|
|
5740
6321
|
b.className = "ng-inline-action-btn";
|
|
5741
6322
|
b.textContent = act.label;
|
|
6323
|
+
b.addEventListener("mousedown", (e) => e.preventDefault());
|
|
5742
6324
|
b.addEventListener("click", async () => {
|
|
5743
6325
|
const range = this.savedRange;
|
|
5744
6326
|
const selected = range?.toString().trim() || "";
|
|
@@ -5804,14 +6386,11 @@ var ColorInline = class {
|
|
|
5804
6386
|
btn.type = "button";
|
|
5805
6387
|
btn.className = "ce-inline-tool";
|
|
5806
6388
|
btn.title = "Text & Highlight Color";
|
|
5807
|
-
btn.innerHTML = '<
|
|
6389
|
+
btn.innerHTML = '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16"/><path d="m6 16 6-12 6 12"/><path d="M8 12h8"/></svg>';
|
|
5808
6390
|
return btn;
|
|
5809
6391
|
}
|
|
5810
6392
|
surround(range) {
|
|
5811
6393
|
this.savedRange = range.cloneRange();
|
|
5812
|
-
if (this.actionsEl) {
|
|
5813
|
-
this.actionsEl.hidden = false;
|
|
5814
|
-
}
|
|
5815
6394
|
}
|
|
5816
6395
|
applyStyle(prop, value) {
|
|
5817
6396
|
const range = this.savedRange;
|
|
@@ -5839,7 +6418,6 @@ var ColorInline = class {
|
|
|
5839
6418
|
renderActions() {
|
|
5840
6419
|
const wrap = document.createElement("div");
|
|
5841
6420
|
wrap.className = "ng-inline-color-actions";
|
|
5842
|
-
wrap.hidden = true;
|
|
5843
6421
|
const makeRow = (title, swatches, prop) => {
|
|
5844
6422
|
const row = document.createElement("div");
|
|
5845
6423
|
row.className = "ng-inline-swatch-row";
|
|
@@ -5854,7 +6432,11 @@ var ColorInline = class {
|
|
|
5854
6432
|
dot.title = sw.label;
|
|
5855
6433
|
dot.style.background = sw.value || "transparent";
|
|
5856
6434
|
if (!sw.value) dot.textContent = "\xD7";
|
|
5857
|
-
dot.addEventListener("
|
|
6435
|
+
dot.addEventListener("mousedown", (e) => e.preventDefault());
|
|
6436
|
+
dot.addEventListener("click", (e) => {
|
|
6437
|
+
e.preventDefault();
|
|
6438
|
+
this.applyStyle(prop, sw.value);
|
|
6439
|
+
});
|
|
5858
6440
|
row.appendChild(dot);
|
|
5859
6441
|
});
|
|
5860
6442
|
return row;
|
|
@@ -7197,6 +7779,7 @@ function getEditorTools(includeLayout = true, enabledTools) {
|
|
|
7197
7779
|
steps: StepsTool,
|
|
7198
7780
|
diff: DiffTool,
|
|
7199
7781
|
video: VideoTool,
|
|
7782
|
+
frame: FrameTool,
|
|
7200
7783
|
changelog: ChangelogTool,
|
|
7201
7784
|
social: SocialTool,
|
|
7202
7785
|
excalidraw: ExcalidrawTool,
|
|
@@ -7237,8 +7820,21 @@ function getEditorTools(includeLayout = true, enabledTools) {
|
|
|
7237
7820
|
};
|
|
7238
7821
|
if (enabledTools && enabledTools.length > 0) {
|
|
7239
7822
|
const allowed = new Set(enabledTools);
|
|
7823
|
+
const alwaysKeep = /* @__PURE__ */ new Set([
|
|
7824
|
+
"header",
|
|
7825
|
+
"paragraph",
|
|
7826
|
+
"inlineCode",
|
|
7827
|
+
"marker",
|
|
7828
|
+
"textColor",
|
|
7829
|
+
"aiRewrite",
|
|
7830
|
+
"spoilerInline",
|
|
7831
|
+
"underline",
|
|
7832
|
+
"strikethrough",
|
|
7833
|
+
"hyperlink",
|
|
7834
|
+
"mention"
|
|
7835
|
+
]);
|
|
7240
7836
|
return Object.fromEntries(
|
|
7241
|
-
Object.entries(tools).filter(([key]) => allowed.has(key))
|
|
7837
|
+
Object.entries(tools).filter(([key]) => allowed.has(key) || alwaysKeep.has(key))
|
|
7242
7838
|
);
|
|
7243
7839
|
}
|
|
7244
7840
|
return tools;
|
|
@@ -7307,6 +7903,7 @@ var TOOL_CATEGORIES = [
|
|
|
7307
7903
|
"embed",
|
|
7308
7904
|
"bookmark",
|
|
7309
7905
|
"video",
|
|
7906
|
+
"frame",
|
|
7310
7907
|
"attaches",
|
|
7311
7908
|
"excalidraw"
|
|
7312
7909
|
]
|
|
@@ -7412,6 +8009,7 @@ var TOOL_LABELS = {
|
|
|
7412
8009
|
steps: "Steps Walkthrough",
|
|
7413
8010
|
diff: "Code Diff",
|
|
7414
8011
|
video: "Video Player",
|
|
8012
|
+
frame: "Device Frame",
|
|
7415
8013
|
changelog: "Changelog",
|
|
7416
8014
|
social: "Social Quote",
|
|
7417
8015
|
today: "Today Date",
|
|
@@ -8292,10 +8890,15 @@ var ExportModal = ({
|
|
|
8292
8890
|
onImportBlocks,
|
|
8293
8891
|
onClose
|
|
8294
8892
|
}) => {
|
|
8893
|
+
const [activeTab, setActiveTab] = useState3("export");
|
|
8295
8894
|
const [importText, setImportText] = useState3("");
|
|
8296
8895
|
const [copiedKind, setCopiedKind] = useState3(null);
|
|
8297
8896
|
const markdown = useMemo(() => open ? blocksToMarkdown(data) : "", [open, data]);
|
|
8298
8897
|
const html = useMemo(() => open ? blocksToHtml(data) : "", [open, data]);
|
|
8898
|
+
const parsedCount = useMemo(
|
|
8899
|
+
() => importText.trim() ? markdownToBlocks(importText).length : 0,
|
|
8900
|
+
[importText]
|
|
8901
|
+
);
|
|
8299
8902
|
if (!open) return null;
|
|
8300
8903
|
const copyText = async (text, kind) => {
|
|
8301
8904
|
try {
|
|
@@ -8314,98 +8917,156 @@ var ExportModal = ({
|
|
|
8314
8917
|
a.click();
|
|
8315
8918
|
URL.revokeObjectURL(url);
|
|
8316
8919
|
};
|
|
8317
|
-
return /* @__PURE__ */ jsx3("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "
|
|
8920
|
+
return /* @__PURE__ */ jsx3("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Import & Export", children: /* @__PURE__ */ jsxs3("div", { className: "ng-modal ng-modal-wide", children: [
|
|
8318
8921
|
/* @__PURE__ */ jsxs3("div", { className: "ng-modal-head", children: [
|
|
8319
8922
|
/* @__PURE__ */ jsxs3("div", { children: [
|
|
8320
|
-
/* @__PURE__ */ jsx3("h3", { children: "
|
|
8321
|
-
/* @__PURE__ */ jsx3("p", { children: "Export
|
|
8923
|
+
/* @__PURE__ */ jsx3("h3", { children: "Import & Export" }),
|
|
8924
|
+
/* @__PURE__ */ jsx3("p", { children: "Export your document as Markdown, HTML, or PDF, or import Markdown into blocks." })
|
|
8322
8925
|
] }),
|
|
8323
8926
|
/* @__PURE__ */ jsx3("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
|
|
8324
8927
|
] }),
|
|
8325
|
-
/* @__PURE__ */ jsxs3("div", { className: "ng-modal-
|
|
8326
|
-
/* @__PURE__ */
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8336
|
-
|
|
8337
|
-
|
|
8338
|
-
|
|
8339
|
-
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
}
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
|
|
8396
|
-
className: "
|
|
8397
|
-
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8401
|
-
|
|
8402
|
-
|
|
8403
|
-
|
|
8928
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-modal-layout", children: [
|
|
8929
|
+
/* @__PURE__ */ jsx3("aside", { className: "ng-modal-sidebar", role: "tablist", "aria-label": "Import and export sections", children: [
|
|
8930
|
+
{ id: "export", label: "Export Document" },
|
|
8931
|
+
{ id: "import", label: "Import Markdown" }
|
|
8932
|
+
].map((t) => /* @__PURE__ */ jsx3(
|
|
8933
|
+
"button",
|
|
8934
|
+
{
|
|
8935
|
+
type: "button",
|
|
8936
|
+
role: "tab",
|
|
8937
|
+
"aria-selected": activeTab === t.id,
|
|
8938
|
+
className: `ng-modal-tab${activeTab === t.id ? " is-active" : ""}`,
|
|
8939
|
+
onClick: () => setActiveTab(t.id),
|
|
8940
|
+
children: t.label
|
|
8941
|
+
},
|
|
8942
|
+
t.id
|
|
8943
|
+
)) }),
|
|
8944
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-modal-main", children: [
|
|
8945
|
+
activeTab === "export" && /* @__PURE__ */ jsxs3("div", { className: "ng-modal-panel", children: [
|
|
8946
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-export-grid", children: [
|
|
8947
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-export-card", children: [
|
|
8948
|
+
/* @__PURE__ */ jsx3("div", { className: "ng-export-card-title", children: "Markdown (.md)" }),
|
|
8949
|
+
/* @__PURE__ */ jsx3("p", { className: "ng-export-card-desc", children: "Clean GitHub-Flavored Markdown including headings, code, and Mermaid blocks." }),
|
|
8950
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-inline-ai-row", children: [
|
|
8951
|
+
/* @__PURE__ */ jsx3(
|
|
8952
|
+
"button",
|
|
8953
|
+
{
|
|
8954
|
+
type: "button",
|
|
8955
|
+
className: "excalidraw-btn",
|
|
8956
|
+
onClick: () => void copyText(markdown, "md"),
|
|
8957
|
+
children: copiedKind === "md" ? "Copied!" : "Copy MD"
|
|
8958
|
+
}
|
|
8959
|
+
),
|
|
8960
|
+
/* @__PURE__ */ jsx3(
|
|
8961
|
+
"button",
|
|
8962
|
+
{
|
|
8963
|
+
type: "button",
|
|
8964
|
+
className: "excalidraw-btn is-active",
|
|
8965
|
+
onClick: () => downloadFile(markdown, "document.md", "text/markdown"),
|
|
8966
|
+
children: "Download .md"
|
|
8967
|
+
}
|
|
8968
|
+
)
|
|
8969
|
+
] })
|
|
8970
|
+
] }),
|
|
8971
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-export-card", children: [
|
|
8972
|
+
/* @__PURE__ */ jsx3("div", { className: "ng-export-card-title", children: "HTML (.html)" }),
|
|
8973
|
+
/* @__PURE__ */ jsx3("p", { className: "ng-export-card-desc", children: "Sanitized semantic HTML ready for blogs, emails, or static sites." }),
|
|
8974
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-inline-ai-row", children: [
|
|
8975
|
+
/* @__PURE__ */ jsx3(
|
|
8976
|
+
"button",
|
|
8977
|
+
{
|
|
8978
|
+
type: "button",
|
|
8979
|
+
className: "excalidraw-btn",
|
|
8980
|
+
onClick: () => void copyText(html, "html"),
|
|
8981
|
+
children: copiedKind === "html" ? "Copied!" : "Copy HTML"
|
|
8982
|
+
}
|
|
8983
|
+
),
|
|
8984
|
+
/* @__PURE__ */ jsx3(
|
|
8985
|
+
"button",
|
|
8986
|
+
{
|
|
8987
|
+
type: "button",
|
|
8988
|
+
className: "excalidraw-btn is-active",
|
|
8989
|
+
onClick: () => downloadFile(
|
|
8990
|
+
`<!doctype html><html><head><meta charset="utf-8"><title>Document</title></head><body>${html}</body></html>`,
|
|
8991
|
+
"document.html",
|
|
8992
|
+
"text/html"
|
|
8993
|
+
),
|
|
8994
|
+
children: "Download .html"
|
|
8995
|
+
}
|
|
8996
|
+
)
|
|
8997
|
+
] })
|
|
8998
|
+
] }),
|
|
8999
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-export-card", children: [
|
|
9000
|
+
/* @__PURE__ */ jsx3("div", { className: "ng-export-card-title", children: "Print / Save as PDF" }),
|
|
9001
|
+
/* @__PURE__ */ jsx3("p", { className: "ng-export-card-desc", children: "Open the browser print dialog to save a formatted PDF copy." }),
|
|
9002
|
+
/* @__PURE__ */ jsx3("div", { className: "ng-inline-ai-row", children: /* @__PURE__ */ jsx3(
|
|
9003
|
+
"button",
|
|
9004
|
+
{
|
|
9005
|
+
type: "button",
|
|
9006
|
+
className: "excalidraw-btn",
|
|
9007
|
+
onClick: () => window.print(),
|
|
9008
|
+
children: "Print / PDF"
|
|
9009
|
+
}
|
|
9010
|
+
) })
|
|
9011
|
+
] })
|
|
9012
|
+
] }),
|
|
9013
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-field", children: [
|
|
9014
|
+
/* @__PURE__ */ jsx3("label", { children: "Markdown Preview" }),
|
|
9015
|
+
/* @__PURE__ */ jsx3("pre", { className: "ng-export-preview", children: markdown || "(Empty document)" })
|
|
9016
|
+
] })
|
|
9017
|
+
] }),
|
|
9018
|
+
activeTab === "import" && /* @__PURE__ */ jsxs3("div", { className: "ng-modal-panel", children: [
|
|
9019
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-field", children: [
|
|
9020
|
+
/* @__PURE__ */ jsxs3("label", { children: [
|
|
9021
|
+
"Paste Markdown (",
|
|
9022
|
+
parsedCount,
|
|
9023
|
+
" blocks detected)"
|
|
9024
|
+
] }),
|
|
9025
|
+
/* @__PURE__ */ jsx3(
|
|
9026
|
+
"textarea",
|
|
9027
|
+
{
|
|
9028
|
+
className: "editor-mermaid-input",
|
|
9029
|
+
rows: 10,
|
|
9030
|
+
placeholder: "Paste Markdown here (# Heading, - list, > quote, ```mermaid ...```)...",
|
|
9031
|
+
value: importText,
|
|
9032
|
+
onChange: (e) => setImportText(e.target.value)
|
|
8404
9033
|
}
|
|
8405
|
-
|
|
8406
|
-
|
|
8407
|
-
|
|
8408
|
-
|
|
9034
|
+
)
|
|
9035
|
+
] }),
|
|
9036
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-inline-ai-row", children: [
|
|
9037
|
+
/* @__PURE__ */ jsxs3(
|
|
9038
|
+
"button",
|
|
9039
|
+
{
|
|
9040
|
+
type: "button",
|
|
9041
|
+
className: "excalidraw-btn is-active",
|
|
9042
|
+
disabled: parsedCount === 0,
|
|
9043
|
+
onClick: () => {
|
|
9044
|
+
const blocks = markdownToBlocks(importText);
|
|
9045
|
+
if (blocks.length > 0) {
|
|
9046
|
+
onImportBlocks(blocks);
|
|
9047
|
+
setImportText("");
|
|
9048
|
+
onClose();
|
|
9049
|
+
}
|
|
9050
|
+
},
|
|
9051
|
+
children: [
|
|
9052
|
+
"Append ",
|
|
9053
|
+
parsedCount || "",
|
|
9054
|
+
" Blocks to Editor"
|
|
9055
|
+
]
|
|
9056
|
+
}
|
|
9057
|
+
),
|
|
9058
|
+
/* @__PURE__ */ jsx3(
|
|
9059
|
+
"button",
|
|
9060
|
+
{
|
|
9061
|
+
type: "button",
|
|
9062
|
+
className: "excalidraw-btn",
|
|
9063
|
+
disabled: !importText,
|
|
9064
|
+
onClick: () => setImportText(""),
|
|
9065
|
+
children: "Clear"
|
|
9066
|
+
}
|
|
9067
|
+
)
|
|
9068
|
+
] })
|
|
9069
|
+
] })
|
|
8409
9070
|
] })
|
|
8410
9071
|
] })
|
|
8411
9072
|
] }) });
|
|
@@ -9701,6 +10362,46 @@ function useInteractiveArticle(containerRef, depKey) {
|
|
|
9701
10362
|
void renderMermaidInto(el, code);
|
|
9702
10363
|
}
|
|
9703
10364
|
});
|
|
10365
|
+
const pinnableSelectors = [
|
|
10366
|
+
".editor-video-block",
|
|
10367
|
+
".editor-embed-wrap",
|
|
10368
|
+
".editor-chart-block",
|
|
10369
|
+
".editor-mermaid-block",
|
|
10370
|
+
".editor-audio-card",
|
|
10371
|
+
".editor-code-block",
|
|
10372
|
+
".editor-diff-block",
|
|
10373
|
+
".editor-frame-block"
|
|
10374
|
+
].join(",");
|
|
10375
|
+
root.querySelectorAll(pinnableSelectors).forEach((blockEl) => {
|
|
10376
|
+
if (blockEl.querySelector(".ng-pin-btn")) return;
|
|
10377
|
+
blockEl.classList.add("ng-pinnable");
|
|
10378
|
+
const pinBtn = document.createElement("button");
|
|
10379
|
+
pinBtn.type = "button";
|
|
10380
|
+
pinBtn.className = "ng-pin-btn";
|
|
10381
|
+
pinBtn.textContent = "\u{1F4CC} Pin";
|
|
10382
|
+
pinBtn.title = "Pin as floating window while scrolling";
|
|
10383
|
+
const onPin = (e) => {
|
|
10384
|
+
e.preventDefault();
|
|
10385
|
+
e.stopPropagation();
|
|
10386
|
+
const isPinned = blockEl.classList.contains("is-pinned-floating");
|
|
10387
|
+
root.querySelectorAll(".is-pinned-floating").forEach((other) => {
|
|
10388
|
+
other.classList.remove("is-pinned-floating");
|
|
10389
|
+
const b = other.querySelector(".ng-pin-btn");
|
|
10390
|
+
if (b) b.textContent = "\u{1F4CC} Pin";
|
|
10391
|
+
});
|
|
10392
|
+
if (!isPinned) {
|
|
10393
|
+
blockEl.classList.add("is-pinned-floating");
|
|
10394
|
+
pinBtn.textContent = "\u2715 Unpin";
|
|
10395
|
+
}
|
|
10396
|
+
};
|
|
10397
|
+
pinBtn.addEventListener("click", onPin);
|
|
10398
|
+
blockEl.appendChild(pinBtn);
|
|
10399
|
+
cleanups.push(() => {
|
|
10400
|
+
pinBtn.removeEventListener("click", onPin);
|
|
10401
|
+
pinBtn.remove();
|
|
10402
|
+
blockEl.classList.remove("ng-pinnable", "is-pinned-floating");
|
|
10403
|
+
});
|
|
10404
|
+
});
|
|
9704
10405
|
return () => {
|
|
9705
10406
|
cleanups.forEach((fn) => fn());
|
|
9706
10407
|
};
|