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.
Files changed (4) hide show
  1. package/dist/index.cjs +1820 -1119
  2. package/dist/index.js +1820 -1119
  3. package/dist/styles.css +746 -14
  4. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -67,6 +67,824 @@ var import_strikethrough = __toESM(require("@sotaproject/strikethrough"), 1);
67
67
  // src/utils/blocksToHtml.ts
68
68
  var import_katex = __toESM(require("katex"), 1);
69
69
 
70
+ // src/blocks/frameBlock.ts
71
+ var DEVICE_OPTIONS = [
72
+ { id: "iphone", label: "iPhone" },
73
+ { id: "samsung", label: "Samsung" },
74
+ { id: "macbook", label: "MacBook" },
75
+ { id: "laptop", label: "Laptop" },
76
+ { id: "browser", label: "Browser" }
77
+ ];
78
+ function renderFrameMarkup(data) {
79
+ const device = data.device && ["iphone", "samsung", "macbook", "laptop", "browser"].includes(data.device) ? data.device : "iphone";
80
+ const src = String(data.src || "").trim();
81
+ const isIframe = data.contentType === "url";
82
+ const inner = !src ? `<div class="editor-frame-empty">
83
+ <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>
84
+ <span>Add an image or URL to preview</span>
85
+ </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" />`;
86
+ let chromeTop = "";
87
+ let chromeBottom = "";
88
+ if (device === "iphone") {
89
+ 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>';
90
+ chromeBottom = '<div class="editor-frame-homebar" aria-hidden="true"></div>';
91
+ } else if (device === "samsung") {
92
+ chromeTop = '<div class="editor-frame-statusbar"><span>12:45</span><div class="editor-frame-punch" aria-hidden="true"></div><span>5G 100%</span></div>';
93
+ chromeBottom = '<div class="editor-frame-homebar is-pill" aria-hidden="true"></div>';
94
+ } else if (device === "browser") {
95
+ chromeTop = `<div class="editor-frame-browser-bar">
96
+ <span class="editor-frame-dots"><i></i><i></i><i></i></span>
97
+ <span class="editor-frame-nav-icons">\u2190 \u2192 \u21BB</span>
98
+ <span class="editor-frame-addr">\u{1F512} ${escHtml(data.address || src || "https://nextgen-editor.dev")}</span>
99
+ </div>`;
100
+ } else if (device === "macbook") {
101
+ chromeTop = '<div class="editor-frame-notch" aria-hidden="true"><span></span></div>';
102
+ } else {
103
+ chromeTop = '<div class="editor-frame-cam" aria-hidden="true"></div>';
104
+ }
105
+ const base = device === "macbook" || device === "laptop" ? `<div class="editor-frame-base is-${device}" aria-hidden="true"><div class="editor-frame-hinge"></div></div>` : "";
106
+ const caption = data.caption ? `<figcaption class="editor-frame-caption">${escHtml(data.caption)}</figcaption>` : "";
107
+ return `<figure class="editor-frame-block" data-device="${device}">
108
+ <div class="editor-frame-shell is-${device}">
109
+ ${chromeTop}
110
+ <div class="editor-frame-screen">${inner}</div>
111
+ ${chromeBottom}
112
+ </div>
113
+ ${base}
114
+ ${caption}
115
+ </figure>`;
116
+ }
117
+ var FrameTool = class {
118
+ data;
119
+ static get toolbox() {
120
+ return {
121
+ title: "Device Frame",
122
+ 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>'
123
+ };
124
+ }
125
+ constructor({ data }) {
126
+ this.data = {
127
+ device: data?.device ?? "iphone",
128
+ contentType: data?.contentType ?? "image",
129
+ src: data?.src ?? "",
130
+ address: data?.address ?? "https://nextgen-editor.dev",
131
+ caption: data?.caption ?? ""
132
+ };
133
+ }
134
+ render() {
135
+ const wrap = document.createElement("div");
136
+ wrap.className = "editor-extra-card";
137
+ const head = document.createElement("div");
138
+ head.className = "editor-extra-head";
139
+ head.textContent = "Device Mockup Frame";
140
+ const controls = document.createElement("div");
141
+ controls.className = "editor-frame-controls";
142
+ const deviceSelect = document.createElement("select");
143
+ deviceSelect.className = "cdx-input editor-form-select";
144
+ DEVICE_OPTIONS.forEach((opt) => {
145
+ const o = document.createElement("option");
146
+ o.value = opt.id;
147
+ o.textContent = opt.label;
148
+ if (this.data.device === opt.id) o.selected = true;
149
+ deviceSelect.appendChild(o);
150
+ });
151
+ const typeSelect = document.createElement("select");
152
+ typeSelect.className = "cdx-input editor-form-select";
153
+ [
154
+ { id: "image", label: "Image / Screenshot" },
155
+ { id: "url", label: "Live URL (iframe)" }
156
+ ].forEach((opt) => {
157
+ const o = document.createElement("option");
158
+ o.value = opt.id;
159
+ o.textContent = opt.label;
160
+ if (this.data.contentType === opt.id) o.selected = true;
161
+ typeSelect.appendChild(o);
162
+ });
163
+ const srcInput = document.createElement("input");
164
+ srcInput.type = "url";
165
+ srcInput.className = "cdx-input";
166
+ srcInput.placeholder = "Image URL or Website URL (https://...)";
167
+ srcInput.value = this.data.src;
168
+ const uploadInput = document.createElement("input");
169
+ uploadInput.type = "file";
170
+ uploadInput.accept = "image/*";
171
+ uploadInput.className = "cdx-input";
172
+ const addrInput = document.createElement("input");
173
+ addrInput.type = "text";
174
+ addrInput.className = "cdx-input";
175
+ addrInput.placeholder = "Browser address bar text (optional)";
176
+ addrInput.value = this.data.address || "";
177
+ const capInput = document.createElement("input");
178
+ capInput.type = "text";
179
+ capInput.className = "cdx-input";
180
+ capInput.placeholder = "Optional caption";
181
+ capInput.value = this.data.caption || "";
182
+ const preview = document.createElement("div");
183
+ const refresh = () => {
184
+ preview.innerHTML = renderFrameMarkup(this.data);
185
+ };
186
+ deviceSelect.addEventListener("change", () => {
187
+ this.data.device = deviceSelect.value;
188
+ refresh();
189
+ });
190
+ typeSelect.addEventListener("change", () => {
191
+ this.data.contentType = typeSelect.value;
192
+ refresh();
193
+ });
194
+ srcInput.addEventListener("input", () => {
195
+ this.data.src = srcInput.value;
196
+ refresh();
197
+ });
198
+ addrInput.addEventListener("input", () => {
199
+ this.data.address = addrInput.value;
200
+ refresh();
201
+ });
202
+ capInput.addEventListener("input", () => {
203
+ this.data.caption = capInput.value;
204
+ refresh();
205
+ });
206
+ uploadInput.addEventListener("change", async () => {
207
+ const file = uploadInput.files?.[0];
208
+ if (!file) return;
209
+ const uploaded = await uploadFileToBucket(file, "frames");
210
+ if (uploaded) {
211
+ this.data.contentType = "image";
212
+ typeSelect.value = "image";
213
+ this.data.src = uploaded;
214
+ srcInput.value = uploaded;
215
+ refresh();
216
+ }
217
+ });
218
+ controls.append(deviceSelect, typeSelect);
219
+ refresh();
220
+ wrap.append(head, controls, srcInput, uploadInput, addrInput, capInput, preview);
221
+ return wrap;
222
+ }
223
+ save() {
224
+ return {
225
+ device: this.data.device,
226
+ contentType: this.data.contentType,
227
+ src: this.data.src.trim(),
228
+ address: this.data.address?.trim() || void 0,
229
+ caption: this.data.caption?.trim() || void 0
230
+ };
231
+ }
232
+ };
233
+
234
+ // src/blocks/extraBlocks.ts
235
+ function createInput(type, className, placeholder, value, onInput) {
236
+ const input = document.createElement("input");
237
+ input.type = type;
238
+ input.className = className;
239
+ input.placeholder = placeholder;
240
+ input.value = value;
241
+ input.addEventListener("input", () => onInput(input.value));
242
+ return input;
243
+ }
244
+ function createTextarea(className, rows, placeholder, value, onInput) {
245
+ const ta = document.createElement("textarea");
246
+ ta.className = className;
247
+ ta.rows = rows;
248
+ ta.placeholder = placeholder;
249
+ ta.value = value;
250
+ ta.addEventListener("input", () => onInput(ta.value));
251
+ return ta;
252
+ }
253
+ var BookmarkTool = class {
254
+ data;
255
+ static get toolbox() {
256
+ return {
257
+ title: "Bookmark",
258
+ 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>'
259
+ };
260
+ }
261
+ constructor({ data }) {
262
+ this.data = {
263
+ url: data?.url ?? "",
264
+ title: data?.title ?? "",
265
+ description: data?.description ?? "",
266
+ image: data?.image ?? ""
267
+ };
268
+ }
269
+ render() {
270
+ const wrap = document.createElement("div");
271
+ wrap.className = "editor-extra-card";
272
+ const head = document.createElement("div");
273
+ head.className = "editor-extra-head";
274
+ head.textContent = "URL Bookmark Card";
275
+ const preview = document.createElement("div");
276
+ preview.className = "editor-bookmark-preview";
277
+ const refreshPreview = () => {
278
+ const host = (() => {
279
+ try {
280
+ return this.data.url ? new URL(this.data.url).hostname : "example.com";
281
+ } catch {
282
+ return this.data.url || "example.com";
283
+ }
284
+ })();
285
+ preview.innerHTML = `
286
+ <div class="editor-bookmark-card">
287
+ <div class="editor-bookmark-body">
288
+ <div class="editor-bookmark-title">${escHtml(this.data.title || host)}</div>
289
+ ${this.data.description ? `<div class="editor-bookmark-desc">${escHtml(this.data.description)}</div>` : ""}
290
+ <div class="editor-bookmark-url">${escHtml(host)}</div>
291
+ </div>
292
+ ${this.data.image ? `<img class="editor-bookmark-thumb" src="${escHtml(this.data.image)}" alt="" />` : ""}
293
+ </div>`;
294
+ };
295
+ const grid = document.createElement("div");
296
+ grid.className = "editor-extra-grid";
297
+ grid.append(
298
+ createInput("url", "cdx-input", "https://example.com/article", this.data.url, (v) => {
299
+ this.data.url = v;
300
+ refreshPreview();
301
+ }),
302
+ createInput("text", "cdx-input", "Link title", this.data.title, (v) => {
303
+ this.data.title = v;
304
+ refreshPreview();
305
+ }),
306
+ createInput("text", "cdx-input", "Short description", this.data.description, (v) => {
307
+ this.data.description = v;
308
+ refreshPreview();
309
+ }),
310
+ createInput("url", "cdx-input", "Optional thumbnail URL", this.data.image || "", (v) => {
311
+ this.data.image = v;
312
+ refreshPreview();
313
+ })
314
+ );
315
+ refreshPreview();
316
+ wrap.append(head, grid, preview);
317
+ return wrap;
318
+ }
319
+ save() {
320
+ return {
321
+ url: this.data.url.trim(),
322
+ title: this.data.title.trim(),
323
+ description: this.data.description.trim(),
324
+ image: this.data.image?.trim() || void 0
325
+ };
326
+ }
327
+ };
328
+ var StepsTool = class {
329
+ data;
330
+ static get toolbox() {
331
+ return {
332
+ title: "Steps",
333
+ 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>'
334
+ };
335
+ }
336
+ constructor({ data }) {
337
+ this.data = {
338
+ items: Array.isArray(data?.items) && data.items.length > 0 ? data.items.map((item) => ({ title: item.title || "", body: item.body || "" })) : [
339
+ { title: "Install dependencies", body: "Run npm install to set up the package." },
340
+ { title: "Configure & render", body: "Pass initialData and onChange to BlockEditor." }
341
+ ]
342
+ };
343
+ }
344
+ render() {
345
+ const wrap = document.createElement("div");
346
+ wrap.className = "editor-extra-card";
347
+ const head = document.createElement("div");
348
+ head.className = "editor-extra-head";
349
+ head.textContent = "Step-by-Step Walkthrough";
350
+ const list = document.createElement("div");
351
+ list.className = "editor-steps-editor-list";
352
+ const renderList = () => {
353
+ list.innerHTML = "";
354
+ this.data.items.forEach((item, idx) => {
355
+ const row = document.createElement("div");
356
+ row.className = "editor-step-editor-row";
357
+ const badge = document.createElement("span");
358
+ badge.className = "editor-step-badge";
359
+ badge.textContent = String(idx + 1);
360
+ const fields = document.createElement("div");
361
+ fields.className = "editor-step-editor-fields";
362
+ fields.append(
363
+ createInput("text", "cdx-input", `Step ${idx + 1} title`, item.title, (v) => {
364
+ item.title = v;
365
+ }),
366
+ createTextarea("cdx-input", 2, "Step details", item.body, (v) => {
367
+ item.body = v;
368
+ })
369
+ );
370
+ const removeBtn = document.createElement("button");
371
+ removeBtn.type = "button";
372
+ removeBtn.className = "excalidraw-btn";
373
+ removeBtn.textContent = "\xD7";
374
+ removeBtn.title = "Remove step";
375
+ removeBtn.addEventListener("click", () => {
376
+ if (this.data.items.length <= 1) return;
377
+ this.data.items.splice(idx, 1);
378
+ renderList();
379
+ });
380
+ row.append(badge, fields, removeBtn);
381
+ list.appendChild(row);
382
+ });
383
+ };
384
+ const addBtn = document.createElement("button");
385
+ addBtn.type = "button";
386
+ addBtn.className = "excalidraw-btn";
387
+ addBtn.textContent = "+ Add Step";
388
+ addBtn.addEventListener("click", () => {
389
+ this.data.items.push({ title: "", body: "" });
390
+ renderList();
391
+ });
392
+ renderList();
393
+ wrap.append(head, list, addBtn);
394
+ return wrap;
395
+ }
396
+ save() {
397
+ return {
398
+ items: this.data.items.filter((i) => i.title.trim() || i.body.trim())
399
+ };
400
+ }
401
+ };
402
+ function computeSimpleDiff(before, after) {
403
+ const a = before.split("\n");
404
+ const b = after.split("\n");
405
+ const lines = [];
406
+ const max = Math.max(a.length, b.length);
407
+ for (let i = 0; i < max; i += 1) {
408
+ const left = a[i];
409
+ const right = b[i];
410
+ if (left === right) {
411
+ if (left !== void 0) lines.push({ kind: "same", text: left });
412
+ } else {
413
+ if (left !== void 0) lines.push({ kind: "del", text: left });
414
+ if (right !== void 0) lines.push({ kind: "add", text: right });
415
+ }
416
+ }
417
+ return lines;
418
+ }
419
+ var DiffTool = class {
420
+ data;
421
+ static get toolbox() {
422
+ return {
423
+ title: "Code Diff",
424
+ 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>'
425
+ };
426
+ }
427
+ constructor({ data }) {
428
+ this.data = {
429
+ filename: data?.filename ?? "example.ts",
430
+ before: data?.before ?? 'const theme = "catppuccin";',
431
+ after: data?.after ?? 'const theme = "dark";'
432
+ };
433
+ }
434
+ render() {
435
+ const wrap = document.createElement("div");
436
+ wrap.className = "editor-extra-card";
437
+ const head = document.createElement("div");
438
+ head.className = "editor-extra-head";
439
+ head.textContent = "Code Diff Viewer";
440
+ const preview = document.createElement("pre");
441
+ preview.className = "editor-diff-preview";
442
+ const refreshPreview = () => {
443
+ const diffLines = computeSimpleDiff(this.data.before, this.data.after);
444
+ preview.innerHTML = diffLines.map((line) => {
445
+ const prefix = line.kind === "del" ? "-" : line.kind === "add" ? "+" : " ";
446
+ return `<span class="editor-diff-line is-${line.kind}">${prefix} ${escHtml(line.text)}</span>`;
447
+ }).join("\n");
448
+ };
449
+ const cols = document.createElement("div");
450
+ cols.className = "editor-diff-inputs";
451
+ cols.append(
452
+ createTextarea("editor-mermaid-input", 4, "Before code...", this.data.before, (v) => {
453
+ this.data.before = v;
454
+ refreshPreview();
455
+ }),
456
+ createTextarea("editor-mermaid-input", 4, "After code...", this.data.after, (v) => {
457
+ this.data.after = v;
458
+ refreshPreview();
459
+ })
460
+ );
461
+ const fileInput = createInput("text", "cdx-input", "Filename (optional)", this.data.filename || "", (v) => {
462
+ this.data.filename = v;
463
+ });
464
+ refreshPreview();
465
+ wrap.append(head, fileInput, cols, preview);
466
+ return wrap;
467
+ }
468
+ save() {
469
+ return {
470
+ filename: this.data.filename?.trim() || void 0,
471
+ before: this.data.before,
472
+ after: this.data.after
473
+ };
474
+ }
475
+ };
476
+ var VideoTool = class {
477
+ data;
478
+ static get toolbox() {
479
+ return {
480
+ title: "Video Player",
481
+ 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>'
482
+ };
483
+ }
484
+ constructor({ data }) {
485
+ this.data = {
486
+ url: data?.url ?? "",
487
+ poster: data?.poster ?? "",
488
+ caption: data?.caption ?? ""
489
+ };
490
+ }
491
+ render() {
492
+ const wrap = document.createElement("div");
493
+ wrap.className = "editor-extra-card";
494
+ const head = document.createElement("div");
495
+ head.className = "editor-extra-head";
496
+ head.textContent = "Video Player (MP4 / WebM)";
497
+ const preview = document.createElement("div");
498
+ preview.className = "editor-video-preview";
499
+ const refreshPreview = () => {
500
+ if (!this.data.url.trim()) {
501
+ preview.innerHTML = '<div class="editor-mermaid-empty">Paste a video URL or upload a file</div>';
502
+ return;
503
+ }
504
+ 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>`;
505
+ };
506
+ const urlInput = createInput("url", "cdx-input", "https://.../video.mp4", this.data.url, (v) => {
507
+ this.data.url = v;
508
+ refreshPreview();
509
+ });
510
+ const uploadInput = document.createElement("input");
511
+ uploadInput.type = "file";
512
+ uploadInput.accept = "video/mp4,video/webm,video/ogg";
513
+ uploadInput.className = "cdx-input";
514
+ uploadInput.addEventListener("change", async () => {
515
+ const file = uploadInput.files?.[0];
516
+ if (!file) return;
517
+ const uploaded = await uploadFileToBucket(file, "videos");
518
+ if (uploaded) {
519
+ this.data.url = uploaded;
520
+ urlInput.value = uploaded;
521
+ refreshPreview();
522
+ }
523
+ });
524
+ const posterInput = createInput("url", "cdx-input", "Optional poster image URL", this.data.poster || "", (v) => {
525
+ this.data.poster = v;
526
+ refreshPreview();
527
+ });
528
+ const captionInput = createInput("text", "cdx-input", "Optional video caption", this.data.caption || "", (v) => {
529
+ this.data.caption = v;
530
+ });
531
+ refreshPreview();
532
+ wrap.append(head, urlInput, uploadInput, posterInput, captionInput, preview);
533
+ return wrap;
534
+ }
535
+ save() {
536
+ return {
537
+ url: this.data.url.trim(),
538
+ poster: this.data.poster?.trim() || void 0,
539
+ caption: this.data.caption?.trim() || void 0
540
+ };
541
+ }
542
+ };
543
+ var ChangelogTool = class {
544
+ data;
545
+ static get toolbox() {
546
+ return {
547
+ title: "Changelog",
548
+ 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>'
549
+ };
550
+ }
551
+ constructor({ data }) {
552
+ this.data = {
553
+ version: data?.version ?? "v1.0.0",
554
+ date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
555
+ 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" }]
556
+ };
557
+ }
558
+ render() {
559
+ const wrap = document.createElement("div");
560
+ wrap.className = "editor-extra-card";
561
+ const head = document.createElement("div");
562
+ head.className = "editor-extra-head";
563
+ head.textContent = "Release Changelog";
564
+ const meta = document.createElement("div");
565
+ meta.className = "editor-diff-inputs";
566
+ meta.append(
567
+ createInput("text", "cdx-input", "Version (e.g. v1.2.0)", this.data.version, (v) => {
568
+ this.data.version = v;
569
+ }),
570
+ createInput("date", "cdx-input", "Release date", this.data.date, (v) => {
571
+ this.data.date = v;
572
+ })
573
+ );
574
+ const list = document.createElement("div");
575
+ list.className = "editor-steps-editor-list";
576
+ const renderItems = () => {
577
+ list.innerHTML = "";
578
+ this.data.items.forEach((item, idx) => {
579
+ const row = document.createElement("div");
580
+ row.className = "editor-changelog-row";
581
+ const select = document.createElement("select");
582
+ select.className = `cdx-input editor-form-select editor-changelog-select is-${item.kind}`;
583
+ ["added", "changed", "fixed"].forEach((k) => {
584
+ const opt = document.createElement("option");
585
+ opt.value = k;
586
+ opt.textContent = k.toUpperCase();
587
+ if (item.kind === k) opt.selected = true;
588
+ select.appendChild(opt);
589
+ });
590
+ select.addEventListener("change", () => {
591
+ item.kind = select.value;
592
+ select.className = `cdx-input editor-form-select editor-changelog-select is-${item.kind}`;
593
+ });
594
+ const text = createInput("text", "cdx-input", "Change description", item.text, (v) => {
595
+ item.text = v;
596
+ });
597
+ const del = document.createElement("button");
598
+ del.type = "button";
599
+ del.className = "excalidraw-btn";
600
+ del.textContent = "\xD7";
601
+ del.addEventListener("click", () => {
602
+ if (this.data.items.length <= 1) return;
603
+ this.data.items.splice(idx, 1);
604
+ renderItems();
605
+ });
606
+ row.append(select, text, del);
607
+ list.appendChild(row);
608
+ });
609
+ };
610
+ const addBtn = document.createElement("button");
611
+ addBtn.type = "button";
612
+ addBtn.className = "excalidraw-btn";
613
+ addBtn.textContent = "+ Add Entry";
614
+ addBtn.addEventListener("click", () => {
615
+ this.data.items.push({ kind: "added", text: "" });
616
+ renderItems();
617
+ });
618
+ renderItems();
619
+ wrap.append(head, meta, list, addBtn);
620
+ return wrap;
621
+ }
622
+ save() {
623
+ return {
624
+ version: this.data.version.trim() || "v1.0.0",
625
+ date: this.data.date,
626
+ items: this.data.items.filter((i) => i.text.trim())
627
+ };
628
+ }
629
+ };
630
+ function renderSocialMarkup(d) {
631
+ const platform = d.platform && ["x", "linkedin", "instagram"].includes(d.platform) ? d.platform : "x";
632
+ const align = d.align && ["left", "center", "right"].includes(d.align) ? d.align : "center";
633
+ const author = escHtml(d.author || "Alex Rivera");
634
+ const handle = escHtml(d.handle || "@alexrivera");
635
+ const role = escHtml(d.role || d.handle || "Staff Engineer at NextGen");
636
+ const date = escHtml(d.date || "2h");
637
+ const text = escHtml(d.text || "");
638
+ const initials = String(d.author || "A").trim().slice(0, 2).toUpperCase();
639
+ const postLink = d.url ? `<a class="editor-social-link" href="${escHtml(
640
+ d.url
641
+ )}" target="_blank" rel="noopener noreferrer">Open \u2197</a>` : "";
642
+ if (platform === "linkedin") {
643
+ return `<div class="editor-social-wrap" data-align="${align}">
644
+ <blockquote class="editor-social-card is-linkedin">
645
+ <div class="editor-social-top">
646
+ <div class="editor-social-avatar is-linkedin" aria-hidden="true">${escHtml(initials)}</div>
647
+ <div class="editor-social-meta">
648
+ <div class="editor-social-name-row"><strong>${author}</strong><span class="editor-social-conn">\u2022 1st</span></div>
649
+ <span class="editor-social-sub">${role}</span>
650
+ <span class="editor-social-sub">${date} \xB7 \u{1F310}</span>
651
+ </div>
652
+ <span class="editor-social-li-logo" aria-label="LinkedIn">in</span>
653
+ </div>
654
+ <p class="editor-social-text">${text}</p>
655
+ ${d.imageUrl ? `<img class="editor-social-media" src="${escHtml(d.imageUrl)}" alt="" loading="lazy" />` : ""}
656
+ <div class="editor-social-li-stats"><span>\u{1F44D} \u{1F44F} \u{1F4A1} 148</span><span>18 comments \xB7 9 reposts</span></div>
657
+ <div class="editor-social-foot is-linkedin">
658
+ <span>\u{1F44D} Like</span><span>\u{1F4AC} Comment</span><span>\u21BB Repost</span><span>\u27A4 Send</span>${postLink}
659
+ </div>
660
+ </blockquote>
661
+ </div>`;
662
+ }
663
+ if (platform === "instagram") {
664
+ 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>`;
665
+ return `<div class="editor-social-wrap" data-align="${align}">
666
+ <blockquote class="editor-social-card is-instagram">
667
+ <div class="editor-social-top is-instagram">
668
+ <div class="editor-social-ig-ring"><div class="editor-social-avatar is-instagram" aria-hidden="true">${escHtml(initials)}</div></div>
669
+ <div class="editor-social-meta">
670
+ <strong>${handle.replace(/^@/, "")}</strong>
671
+ <span class="editor-social-sub">${date}</span>
672
+ </div>
673
+ <span class="editor-social-more">\u2022\u2022\u2022</span>
674
+ </div>
675
+ ${mediaHtml}
676
+ <div class="editor-social-ig-actions">
677
+ <span>\u2661 &nbsp; \u{1F4AC} &nbsp; \u2197</span>
678
+ <span>\u{1F516}</span>
679
+ </div>
680
+ <div class="editor-social-ig-likes">Liked by <strong>1,284 others</strong></div>
681
+ <p class="editor-social-ig-caption"><strong>${handle.replace(/^@/, "")}</strong> ${text} ${postLink}</p>
682
+ </blockquote>
683
+ </div>`;
684
+ }
685
+ 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>';
686
+ return `<div class="editor-social-wrap" data-align="${align}">
687
+ <blockquote class="editor-social-card is-x">
688
+ <div class="editor-social-top">
689
+ <div class="editor-social-avatar" aria-hidden="true">${escHtml(initials)}</div>
690
+ <div class="editor-social-meta">
691
+ <div class="editor-social-name-row"><strong>${author}</strong>${verifiedSvg}</div>
692
+ <span class="editor-social-sub">${handle} \xB7 ${date}</span>
693
+ </div>
694
+ <span class="editor-social-x-logo" aria-label="X">\u{1D54F}</span>
695
+ </div>
696
+ <p class="editor-social-text">${text}</p>
697
+ ${d.imageUrl ? `<img class="editor-social-media" src="${escHtml(d.imageUrl)}" alt="" loading="lazy" />` : ""}
698
+ <div class="editor-social-foot is-x">
699
+ <span>\u{1F4AC} 24</span><span>\u21BB 86</span><span>\u2661 612</span><span>\u{1F4CA} 14.2K</span>${postLink}
700
+ </div>
701
+ </blockquote>
702
+ </div>`;
703
+ }
704
+ var SocialTool = class {
705
+ data;
706
+ previewEl;
707
+ static get toolbox() {
708
+ return {
709
+ title: "Social Media Post",
710
+ 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>'
711
+ };
712
+ }
713
+ constructor({ data }) {
714
+ this.data = {
715
+ platform: data?.platform ?? "x",
716
+ align: data?.align ?? "center",
717
+ author: data?.author ?? "Alex Rivera",
718
+ handle: data?.handle ?? "@alexrivera",
719
+ role: data?.role ?? "Staff Engineer",
720
+ date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
721
+ text: data?.text ?? "Shipping clean, modular blocks with nextgen-block-editor.",
722
+ imageUrl: data?.imageUrl ?? "",
723
+ url: data?.url ?? ""
724
+ };
725
+ }
726
+ refreshPreview() {
727
+ if (this.previewEl) {
728
+ this.previewEl.innerHTML = renderSocialMarkup(this.data);
729
+ }
730
+ }
731
+ render() {
732
+ const wrap = document.createElement("div");
733
+ wrap.className = "editor-extra-card";
734
+ const head = document.createElement("div");
735
+ head.className = "editor-extra-head";
736
+ head.textContent = "Social Media Post Card";
737
+ const topControls = document.createElement("div");
738
+ topControls.className = "editor-diff-inputs";
739
+ const platformSelect = document.createElement("select");
740
+ platformSelect.className = "cdx-input editor-form-select";
741
+ [
742
+ { id: "x", label: "Twitter / X Format" },
743
+ { id: "linkedin", label: "LinkedIn Format" },
744
+ { id: "instagram", label: "Instagram Format" }
745
+ ].forEach((p) => {
746
+ const opt = document.createElement("option");
747
+ opt.value = p.id;
748
+ opt.textContent = p.label;
749
+ if (this.data.platform === p.id) opt.selected = true;
750
+ platformSelect.appendChild(opt);
751
+ });
752
+ platformSelect.addEventListener("change", () => {
753
+ this.data.platform = platformSelect.value;
754
+ this.refreshPreview();
755
+ });
756
+ const alignSelect = document.createElement("select");
757
+ alignSelect.className = "cdx-input editor-form-select";
758
+ [
759
+ { id: "left", label: "Align Left" },
760
+ { id: "center", label: "Align Center" },
761
+ { id: "right", label: "Align Right" }
762
+ ].forEach((a) => {
763
+ const opt = document.createElement("option");
764
+ opt.value = a.id;
765
+ opt.textContent = a.label;
766
+ if (this.data.align === a.id) opt.selected = true;
767
+ alignSelect.appendChild(opt);
768
+ });
769
+ alignSelect.addEventListener("change", () => {
770
+ this.data.align = alignSelect.value;
771
+ this.refreshPreview();
772
+ });
773
+ topControls.append(platformSelect, alignSelect);
774
+ const meta = document.createElement("div");
775
+ meta.className = "editor-diff-inputs";
776
+ meta.append(
777
+ createInput("text", "cdx-input", "Author name", this.data.author, (v) => {
778
+ this.data.author = v;
779
+ this.refreshPreview();
780
+ }),
781
+ createInput("text", "cdx-input", "@handle or Role", this.data.handle, (v) => {
782
+ this.data.handle = v;
783
+ this.data.role = v;
784
+ this.refreshPreview();
785
+ })
786
+ );
787
+ const text = createTextarea("cdx-input", 3, "Post content...", this.data.text, (v) => {
788
+ this.data.text = v;
789
+ this.refreshPreview();
790
+ });
791
+ const extra = document.createElement("div");
792
+ extra.className = "editor-diff-inputs";
793
+ extra.append(
794
+ createInput("url", "cdx-input", "Optional image URL (Instagram)", this.data.imageUrl || "", (v) => {
795
+ this.data.imageUrl = v;
796
+ this.refreshPreview();
797
+ }),
798
+ createInput("url", "cdx-input", "Original post URL (optional)", this.data.url || "", (v) => {
799
+ this.data.url = v;
800
+ this.refreshPreview();
801
+ })
802
+ );
803
+ const preview = document.createElement("div");
804
+ this.previewEl = preview;
805
+ this.refreshPreview();
806
+ wrap.append(head, topControls, meta, text, extra, preview);
807
+ return wrap;
808
+ }
809
+ renderSettings() {
810
+ return [
811
+ {
812
+ icon: '<span style="font-size:11px;font-weight:700;">\u{1D54F}</span>',
813
+ label: "Twitter / X Format",
814
+ isActive: this.data.platform === "x",
815
+ closeOnActivate: true,
816
+ onActivate: () => {
817
+ this.data.platform = "x";
818
+ this.refreshPreview();
819
+ }
820
+ },
821
+ {
822
+ icon: '<span style="font-size:11px;font-weight:700;">in</span>',
823
+ label: "LinkedIn Format",
824
+ isActive: this.data.platform === "linkedin",
825
+ closeOnActivate: true,
826
+ onActivate: () => {
827
+ this.data.platform = "linkedin";
828
+ this.refreshPreview();
829
+ }
830
+ },
831
+ {
832
+ icon: '<span style="font-size:11px;font-weight:700;">\u25CE</span>',
833
+ label: "Instagram Format",
834
+ isActive: this.data.platform === "instagram",
835
+ closeOnActivate: true,
836
+ onActivate: () => {
837
+ this.data.platform = "instagram";
838
+ this.refreshPreview();
839
+ }
840
+ },
841
+ {
842
+ 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>',
843
+ label: "Align Left",
844
+ isActive: this.data.align === "left",
845
+ closeOnActivate: true,
846
+ onActivate: () => {
847
+ this.data.align = "left";
848
+ this.refreshPreview();
849
+ }
850
+ },
851
+ {
852
+ 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>',
853
+ label: "Align Center",
854
+ isActive: this.data.align === "center",
855
+ closeOnActivate: true,
856
+ onActivate: () => {
857
+ this.data.align = "center";
858
+ this.refreshPreview();
859
+ }
860
+ },
861
+ {
862
+ 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>',
863
+ label: "Align Right",
864
+ isActive: this.data.align === "right",
865
+ closeOnActivate: true,
866
+ onActivate: () => {
867
+ this.data.align = "right";
868
+ this.refreshPreview();
869
+ }
870
+ }
871
+ ];
872
+ }
873
+ save() {
874
+ return {
875
+ platform: this.data.platform,
876
+ align: this.data.align,
877
+ author: this.data.author.trim(),
878
+ handle: this.data.handle.trim(),
879
+ role: this.data.role?.trim() || void 0,
880
+ date: this.data.date?.trim() || void 0,
881
+ text: this.data.text.trim(),
882
+ imageUrl: this.data.imageUrl?.trim() || void 0,
883
+ url: this.data.url?.trim() || void 0
884
+ };
885
+ }
886
+ };
887
+
70
888
  // src/utils/syntaxHighlight.ts
71
889
  var SUPPORTED_LANGUAGES = [
72
890
  { id: "typescript", label: "TypeScript" },
@@ -359,6 +1177,17 @@ function pickLinkTint(seed) {
359
1177
  function renderAudioCard(track, compact = false) {
360
1178
  const url = String(track.url || "").trim();
361
1179
  if (!url) return "";
1180
+ try {
1181
+ const parsed = new URL(url);
1182
+ const host = parsed.hostname.replace(/^www\./, "").toLowerCase();
1183
+ if (host === "open.spotify.com") {
1184
+ const embedUrl = parsed.pathname.startsWith("/embed/") ? url : `https://open.spotify.com/embed${parsed.pathname}`;
1185
+ return `<div class="editor-audio-card editor-spotify-card${compact ? " is-compact" : ""}"><iframe src="${escHtml(
1186
+ embedUrl
1187
+ )}" title="${escHtml(track.title || "Spotify track")}" loading="lazy" allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"></iframe></div>`;
1188
+ }
1189
+ } catch {
1190
+ }
362
1191
  const cover = track.coverUrl ? `<img class="editor-audio-cover" src="${escHtml(track.coverUrl)}" alt="${escHtml(
363
1192
  track.title || "Audio cover"
364
1193
  )}">` : `<div class="editor-audio-cover editor-audio-cover-placeholder" aria-hidden="true">\u266A</div>`;
@@ -524,7 +1353,10 @@ function blocksToHtml(data) {
524
1353
  if (t.startsWith("## ")) return `<h4>${escHtml(t.slice(3))}</h4>`;
525
1354
  return `<p>${escHtml(t)}</p>`;
526
1355
  }).join("");
527
- return `<div class="editor-slides" data-slides><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(
1356
+ const slideBg = ["default", "white", "zinc", "dark", "gradient"].includes(d.background) ? d.background : "default";
1357
+ const slideAlign = ["left", "center", "right"].includes(d.align) ? d.align : "left";
1358
+ const slideText = ["auto", "light", "dark"].includes(d.textTone) ? d.textTone : "auto";
1359
+ 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(
528
1360
  (s, idx) => `<div class="editor-slide-panel${idx === 0 ? " active" : ""}" data-slide-idx="${idx}">${formatSlide(s)}</div>`
529
1361
  ).join("") + "</div></div>";
530
1362
  }
@@ -652,8 +1484,10 @@ function blocksToHtml(data) {
652
1484
  }
653
1485
  if (block.type === "mermaid") {
654
1486
  const code = String(d.code || "");
1487
+ const align = ["left", "center", "right"].includes(d.align) ? d.align : "center";
1488
+ const size = ["small", "medium", "large", "full"].includes(d.size) ? d.size : "small";
655
1489
  const caption = d.caption ? `<figcaption>${escHtml(d.caption)}</figcaption>` : "";
656
- return `<figure class="editor-mermaid-block"><div class="editor-mermaid-diagram" data-mermaid="${escHtml(
1490
+ return `<figure class="editor-mermaid-block" data-align="${align}" data-size="${size}"><div class="editor-mermaid-diagram" data-mermaid="${escHtml(
657
1491
  code
658
1492
  )}"><pre class="editor-mermaid-fallback">${escHtml(code)}</pre></div>${caption}</figure>`;
659
1493
  }
@@ -703,6 +1537,9 @@ function blocksToHtml(data) {
703
1537
  if (!d.url) return "";
704
1538
  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>`;
705
1539
  }
1540
+ if (block.type === "frame") {
1541
+ return renderFrameMarkup(d);
1542
+ }
706
1543
  if (block.type === "changelog") {
707
1544
  const items = Array.isArray(d.items) ? d.items : [];
708
1545
  return `<section class="editor-changelog-block"><div class="editor-changelog-head"><span class="editor-changelog-version">${escHtml(
@@ -723,11 +1560,7 @@ function blocksToHtml(data) {
723
1560
  )}</span></div>`;
724
1561
  }
725
1562
  if (block.type === "social") {
726
- return `<blockquote class="editor-social-card"><div class="editor-social-head"><strong>${escHtml(
727
- d.author || ""
728
- )}</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(
729
- d.url
730
- )}" target="_blank" rel="noopener noreferrer">View original post \u2192</a>` : ""}</blockquote>`;
1563
+ return renderSocialMarkup(d);
731
1564
  }
732
1565
  if (block.type === "alert") {
733
1566
  const variant = ["info", "tip", "warning", "danger"].includes(d.variant) ? d.variant : "info";
@@ -2871,13 +3704,15 @@ var QuizTool = class {
2871
3704
  q.options.forEach((opt, oIdx) => {
2872
3705
  const row = document.createElement("div");
2873
3706
  row.className = "editor-eisenhower-item-row";
2874
- const radio = document.createElement("input");
2875
- radio.type = "radio";
2876
- radio.name = `quiz_correct_${qIdx}_${Math.random().toString(36).slice(2, 6)}`;
2877
- radio.checked = q.correctIndex === oIdx;
2878
- radio.title = "Mark as correct answer";
2879
- radio.addEventListener("change", () => {
2880
- if (radio.checked) q.correctIndex = oIdx;
3707
+ const tickBtn = document.createElement("button");
3708
+ tickBtn.type = "button";
3709
+ tickBtn.className = `editor-quiz-tick-btn${q.correctIndex === oIdx ? " is-selected" : ""}`;
3710
+ tickBtn.title = q.correctIndex === oIdx ? "Unmark as correct answer" : "Mark as correct answer";
3711
+ tickBtn.setAttribute("aria-pressed", String(q.correctIndex === oIdx));
3712
+ 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>' : "";
3713
+ tickBtn.addEventListener("click", () => {
3714
+ q.correctIndex = q.correctIndex === oIdx ? -1 : oIdx;
3715
+ renderOpts();
2881
3716
  });
2882
3717
  const optIn = document.createElement("input");
2883
3718
  optIn.type = "text";
@@ -2898,7 +3733,7 @@ var QuizTool = class {
2898
3733
  }
2899
3734
  renderOpts();
2900
3735
  });
2901
- row.append(radio, optIn, rmOpt);
3736
+ row.append(tickBtn, optIn, rmOpt);
2902
3737
  optsWrap.appendChild(row);
2903
3738
  });
2904
3739
  };
@@ -4340,451 +5175,221 @@ var DialogueTool = class {
4340
5175
  this.data.triggerLabel = triggerIn.value;
4341
5176
  previewBtn.textContent = triggerIn.value || "Open Dialog";
4342
5177
  };
4343
- const previewBtn = document.createElement("button");
4344
- previewBtn.type = "button";
4345
- previewBtn.className = "b2 p";
4346
- previewBtn.textContent = this.data.triggerLabel || "Open Dialog";
4347
- previewBtn.onclick = () => this.openPreviewModal();
4348
- top.append(triggerIn, previewBtn);
4349
- const titleIn = document.createElement("input");
4350
- titleIn.type = "text";
4351
- titleIn.className = "cdx-input editor-form-input";
4352
- titleIn.placeholder = "Dialog title...";
4353
- titleIn.value = this.data.title;
4354
- titleIn.oninput = () => {
4355
- this.data.title = titleIn.value;
4356
- };
4357
- const bodyIn = document.createElement("textarea");
4358
- bodyIn.rows = 3;
4359
- bodyIn.className = "cdx-input editor-form-input";
4360
- bodyIn.placeholder = "Dialog message / content...";
4361
- bodyIn.value = this.data.body;
4362
- bodyIn.oninput = () => {
4363
- this.data.body = bodyIn.value;
4364
- };
4365
- const confirmIn = document.createElement("input");
4366
- confirmIn.type = "text";
4367
- confirmIn.className = "cdx-input editor-form-input";
4368
- confirmIn.placeholder = "Confirm button text (e.g. Got it)";
4369
- confirmIn.value = this.data.confirmLabel || "Got it";
4370
- confirmIn.oninput = () => {
4371
- this.data.confirmLabel = confirmIn.value;
4372
- };
4373
- wrap.append(top, titleIn, bodyIn, confirmIn);
4374
- return wrap;
4375
- }
4376
- save() {
4377
- return {
4378
- triggerLabel: this.data.triggerLabel?.trim() || "Open Dialog",
4379
- title: this.data.title?.trim() || "Dialog",
4380
- body: this.data.body || "",
4381
- confirmLabel: this.data.confirmLabel?.trim() || "Got it"
4382
- };
4383
- }
4384
- };
4385
-
4386
- // src/blocks/layoutTextBlocks.ts
4387
- var SlidesTool = class {
4388
- content;
4389
- textarea;
4390
- constructor(options) {
4391
- this.content = options.data?.content || "# Slide 1\nIntroduce the big idea.\n\n---\n\n# Slide 2\nKey takeaways or code.";
4392
- }
4393
- static get toolbox() {
4394
- return {
4395
- title: "Slides",
4396
- 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>'
4397
- };
4398
- }
4399
- render() {
4400
- const root = document.createElement("div");
4401
- root.className = "block-card";
4402
- const hint = document.createElement("div");
4403
- hint.className = "block-hint";
4404
- hint.textContent = "Separate slides with --- on its own line. Readers get arrow controls + Present mode.";
4405
- const ta = document.createElement("textarea");
4406
- ta.rows = 7;
4407
- ta.value = this.content;
4408
- ta.placeholder = "# Slide 1\n...\n\n---\n\n# Slide 2\n...";
4409
- ta.oninput = () => {
4410
- this.content = ta.value;
4411
- };
4412
- root.append(hint, ta);
4413
- this.textarea = ta;
4414
- return root;
4415
- }
4416
- save() {
4417
- return {
4418
- content: this.textarea?.value ?? this.content
4419
- };
4420
- }
4421
- };
4422
- var TabsTool = class {
4423
- tabs;
4424
- constructor(options) {
4425
- this.tabs = Array.isArray(options.data?.tabs) && options.data.tabs.length ? options.data.tabs.map((t) => ({ ...t })) : [
4426
- { label: "Overview", content: "" },
4427
- { label: "Specs", content: "" },
4428
- { label: "Notes", content: "" }
4429
- ];
4430
- }
4431
- static get toolbox() {
4432
- return {
4433
- title: "Tabs",
4434
- 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>'
4435
- };
4436
- }
4437
- render() {
4438
- const root = document.createElement("div");
4439
- root.className = "block-card";
4440
- const list = document.createElement("div");
4441
- list.className = "block-rows";
4442
- const draw = () => {
4443
- list.innerHTML = "";
4444
- this.tabs.forEach((tab, idx) => {
4445
- const row = document.createElement("div");
4446
- row.className = "block-subrow";
4447
- const top = document.createElement("div");
4448
- top.className = "block-subrow-head";
4449
- const lbl = document.createElement("input");
4450
- lbl.type = "text";
4451
- lbl.placeholder = `Tab ${idx + 1} label`;
4452
- lbl.value = tab.label;
4453
- lbl.oninput = () => {
4454
- tab.label = lbl.value;
4455
- };
4456
- const rmBtn = document.createElement("button");
4457
- rmBtn.type = "button";
4458
- rmBtn.className = "b2";
4459
- rmBtn.textContent = "\xD7";
4460
- rmBtn.onclick = () => {
4461
- this.tabs.splice(idx, 1);
4462
- draw();
4463
- };
4464
- top.append(lbl, rmBtn);
4465
- const body = document.createElement("textarea");
4466
- body.rows = 3;
4467
- body.placeholder = "Tab panel content...";
4468
- body.value = tab.content;
4469
- body.oninput = () => {
4470
- tab.content = body.value;
4471
- };
4472
- row.append(top, body);
4473
- list.appendChild(row);
4474
- });
4475
- };
4476
- const addBtn = document.createElement("button");
4477
- addBtn.type = "button";
4478
- addBtn.className = "b2";
4479
- addBtn.textContent = "+ Add tab";
4480
- addBtn.onclick = () => {
4481
- this.tabs.push({ label: `Tab ${this.tabs.length + 1}`, content: "" });
4482
- draw();
4483
- };
4484
- draw();
4485
- root.append(list, addBtn);
4486
- return root;
4487
- }
4488
- save() {
4489
- return { tabs: this.tabs };
4490
- }
4491
- };
4492
- var AccordionTool = class {
4493
- items;
4494
- constructor(options) {
4495
- this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((i) => ({ ...i })) : [
4496
- { title: "Question or section 1", body: "" },
4497
- { title: "Question or section 2", body: "" }
4498
- ];
4499
- }
4500
- static get toolbox() {
4501
- return {
4502
- title: "Accordion",
4503
- 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>'
4504
- };
4505
- }
4506
- render() {
4507
- const root = document.createElement("div");
4508
- root.className = "block-card";
4509
- const list = document.createElement("div");
4510
- list.className = "block-rows";
4511
- const draw = () => {
4512
- list.innerHTML = "";
4513
- this.items.forEach((item, idx) => {
4514
- const row = document.createElement("div");
4515
- row.className = "block-subrow";
4516
- const top = document.createElement("div");
4517
- top.className = "block-subrow-head";
4518
- const titleIn = document.createElement("input");
4519
- titleIn.type = "text";
4520
- titleIn.placeholder = `Row ${idx + 1} title`;
4521
- titleIn.value = item.title;
4522
- titleIn.oninput = () => {
4523
- item.title = titleIn.value;
4524
- };
4525
- const rmBtn = document.createElement("button");
4526
- rmBtn.type = "button";
4527
- rmBtn.className = "b2";
4528
- rmBtn.textContent = "\xD7";
4529
- rmBtn.onclick = () => {
4530
- this.items.splice(idx, 1);
4531
- draw();
4532
- };
4533
- top.append(titleIn, rmBtn);
4534
- const bodyIn = document.createElement("textarea");
4535
- bodyIn.rows = 2;
4536
- bodyIn.placeholder = "Answer / details...";
4537
- bodyIn.value = item.body;
4538
- bodyIn.oninput = () => {
4539
- item.body = bodyIn.value;
4540
- };
4541
- row.append(top, bodyIn);
4542
- list.appendChild(row);
4543
- });
4544
- };
4545
- const addBtn = document.createElement("button");
4546
- addBtn.type = "button";
4547
- addBtn.className = "b2";
4548
- addBtn.textContent = "+ Add row";
4549
- addBtn.onclick = () => {
4550
- this.items.push({ title: "", body: "" });
4551
- draw();
4552
- };
4553
- draw();
4554
- root.append(list, addBtn);
4555
- return root;
4556
- }
4557
- save() {
4558
- return { items: this.items };
4559
- }
4560
- };
4561
- var PullQuoteTool = class {
4562
- data;
4563
- constructor(options) {
4564
- this.data = {
4565
- text: options.data?.text || "",
4566
- attribution: options.data?.attribution || ""
4567
- };
4568
- }
4569
- static get toolbox() {
4570
- return {
4571
- title: "Pull quote",
4572
- 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>'
5178
+ const previewBtn = document.createElement("button");
5179
+ previewBtn.type = "button";
5180
+ previewBtn.className = "b2 p";
5181
+ previewBtn.textContent = this.data.triggerLabel || "Open Dialog";
5182
+ previewBtn.onclick = () => this.openPreviewModal();
5183
+ top.append(triggerIn, previewBtn);
5184
+ const titleIn = document.createElement("input");
5185
+ titleIn.type = "text";
5186
+ titleIn.className = "cdx-input editor-form-input";
5187
+ titleIn.placeholder = "Dialog title...";
5188
+ titleIn.value = this.data.title;
5189
+ titleIn.oninput = () => {
5190
+ this.data.title = titleIn.value;
4573
5191
  };
4574
- }
4575
- render() {
4576
- const root = document.createElement("div");
4577
- root.className = "block-card";
4578
- const text = document.createElement("textarea");
4579
- text.rows = 3;
4580
- text.placeholder = "Oversized editorial pull-quote...";
4581
- text.value = this.data.text;
4582
- text.oninput = () => {
4583
- this.data.text = text.value;
5192
+ const bodyIn = document.createElement("textarea");
5193
+ bodyIn.rows = 3;
5194
+ bodyIn.className = "cdx-input editor-form-input";
5195
+ bodyIn.placeholder = "Dialog message / content...";
5196
+ bodyIn.value = this.data.body;
5197
+ bodyIn.oninput = () => {
5198
+ this.data.body = bodyIn.value;
4584
5199
  };
4585
- const attr = document.createElement("input");
4586
- attr.type = "text";
4587
- attr.placeholder = "Attribution (optional)";
4588
- attr.value = this.data.attribution;
4589
- attr.oninput = () => {
4590
- this.data.attribution = attr.value;
5200
+ const confirmIn = document.createElement("input");
5201
+ confirmIn.type = "text";
5202
+ confirmIn.className = "cdx-input editor-form-input";
5203
+ confirmIn.placeholder = "Confirm button text (e.g. Got it)";
5204
+ confirmIn.value = this.data.confirmLabel || "Got it";
5205
+ confirmIn.oninput = () => {
5206
+ this.data.confirmLabel = confirmIn.value;
4591
5207
  };
4592
- root.append(text, attr);
4593
- return root;
5208
+ wrap.append(top, titleIn, bodyIn, confirmIn);
5209
+ return wrap;
4594
5210
  }
4595
5211
  save() {
4596
- return this.data;
4597
- }
4598
- };
4599
-
4600
- // src/blocks/structuredBlocks.ts
4601
- var TimelineTool = class {
4602
- steps;
4603
- constructor(options) {
4604
- this.steps = Array.isArray(options.data?.steps) && options.data.steps.length ? options.data.steps.map((s) => ({ ...s })) : [
4605
- { title: "Step 1", detail: "" },
4606
- { title: "Step 2", detail: "" }
4607
- ];
4608
- }
4609
- static get toolbox() {
4610
5212
  return {
4611
- title: "Timeline",
4612
- 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>'
4613
- };
4614
- }
4615
- render() {
4616
- const root = document.createElement("div");
4617
- root.className = "block-card";
4618
- const list = document.createElement("div");
4619
- list.className = "block-rows";
4620
- const draw = () => {
4621
- list.innerHTML = "";
4622
- this.steps.forEach((step, idx) => {
4623
- const row = document.createElement("div");
4624
- row.className = "block-subrow";
4625
- const top = document.createElement("div");
4626
- top.className = "block-subrow-head";
4627
- const titleIn = document.createElement("input");
4628
- titleIn.type = "text";
4629
- titleIn.placeholder = `Step ${idx + 1} title`;
4630
- titleIn.value = step.title;
4631
- titleIn.oninput = () => {
4632
- step.title = titleIn.value;
4633
- };
4634
- const rmBtn = document.createElement("button");
4635
- rmBtn.type = "button";
4636
- rmBtn.className = "b2";
4637
- rmBtn.textContent = "\xD7";
4638
- rmBtn.onclick = () => {
4639
- this.steps.splice(idx, 1);
4640
- draw();
4641
- };
4642
- top.append(titleIn, rmBtn);
4643
- const detailIn = document.createElement("textarea");
4644
- detailIn.rows = 2;
4645
- detailIn.placeholder = "Short step description...";
4646
- detailIn.value = step.detail;
4647
- detailIn.oninput = () => {
4648
- step.detail = detailIn.value;
4649
- };
4650
- row.append(top, detailIn);
4651
- list.appendChild(row);
4652
- });
4653
- };
4654
- const addBtn = document.createElement("button");
4655
- addBtn.type = "button";
4656
- addBtn.className = "b2";
4657
- addBtn.textContent = "+ Add step";
4658
- addBtn.onclick = () => {
4659
- this.steps.push({ title: `Step ${this.steps.length + 1}`, detail: "" });
4660
- draw();
5213
+ triggerLabel: this.data.triggerLabel?.trim() || "Open Dialog",
5214
+ title: this.data.title?.trim() || "Dialog",
5215
+ body: this.data.body || "",
5216
+ confirmLabel: this.data.confirmLabel?.trim() || "Got it"
4661
5217
  };
4662
- draw();
4663
- root.append(list, addBtn);
4664
- return root;
4665
- }
4666
- save() {
4667
- return { steps: this.steps };
4668
5218
  }
4669
5219
  };
4670
- var StatsTool = class {
4671
- stats;
5220
+
5221
+ // src/blocks/layoutTextBlocks.ts
5222
+ var SlidesTool = class {
5223
+ content;
5224
+ background;
5225
+ align;
5226
+ textTone;
5227
+ textarea;
5228
+ rootEl;
4672
5229
  constructor(options) {
4673
- this.stats = Array.isArray(options.data?.stats) && options.data.stats.length ? options.data.stats.map((s) => ({ ...s })) : [
4674
- { value: "99.9%", label: "Uptime" },
4675
- { value: "42ms", label: "Latency" }
4676
- ];
5230
+ this.content = options.data?.content || "# Slide 1\nIntroduce the big idea.\n\n---\n\n# Slide 2\nKey takeaways or code.";
5231
+ this.background = options.data?.background ?? "default";
5232
+ this.align = options.data?.align ?? "left";
5233
+ this.textTone = options.data?.textTone ?? "auto";
4677
5234
  }
4678
5235
  static get toolbox() {
4679
5236
  return {
4680
- title: "Stats row",
4681
- 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>'
5237
+ title: "Slides",
5238
+ 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>'
4682
5239
  };
4683
5240
  }
5241
+ applyVisualAttrs() {
5242
+ if (!this.rootEl) return;
5243
+ this.rootEl.dataset.slideBg = this.background;
5244
+ this.rootEl.dataset.slideAlign = this.align;
5245
+ this.rootEl.dataset.slideText = this.textTone;
5246
+ }
4684
5247
  render() {
4685
5248
  const root = document.createElement("div");
4686
- root.className = "block-card";
4687
- const list = document.createElement("div");
4688
- list.className = "block-rows";
4689
- const draw = () => {
4690
- list.innerHTML = "";
4691
- this.stats.forEach((stat, idx) => {
4692
- const row = document.createElement("div");
4693
- row.className = "block-subrow-head";
4694
- const valIn = document.createElement("input");
4695
- valIn.type = "text";
4696
- valIn.placeholder = "Value (e.g. 99.9%)";
4697
- valIn.value = stat.value;
4698
- valIn.oninput = () => {
4699
- stat.value = valIn.value;
4700
- };
4701
- const lblIn = document.createElement("input");
4702
- lblIn.type = "text";
4703
- lblIn.placeholder = "Label (e.g. Uptime)";
4704
- lblIn.value = stat.label;
4705
- lblIn.oninput = () => {
4706
- stat.label = lblIn.value;
4707
- };
4708
- const rmBtn = document.createElement("button");
4709
- rmBtn.type = "button";
4710
- rmBtn.className = "b2";
4711
- rmBtn.textContent = "\xD7";
4712
- rmBtn.onclick = () => {
4713
- this.stats.splice(idx, 1);
4714
- draw();
4715
- };
4716
- row.append(valIn, lblIn, rmBtn);
4717
- list.appendChild(row);
4718
- });
4719
- };
4720
- const addBtn = document.createElement("button");
4721
- addBtn.type = "button";
4722
- addBtn.className = "b2";
4723
- addBtn.textContent = "+ Add metric";
4724
- addBtn.onclick = () => {
4725
- this.stats.push({ value: "", label: "" });
4726
- draw();
5249
+ root.className = "block-card editor-slides-tool-card";
5250
+ this.rootEl = root;
5251
+ this.applyVisualAttrs();
5252
+ const hint = document.createElement("div");
5253
+ hint.className = "block-hint";
5254
+ hint.textContent = "Separate slides with --- on its own line. Use the block menu (\u22EE) to customize background, text tone & alignment.";
5255
+ const ta = document.createElement("textarea");
5256
+ ta.rows = 7;
5257
+ ta.value = this.content;
5258
+ ta.placeholder = "# Slide 1\n...\n\n---\n\n# Slide 2\n...";
5259
+ ta.oninput = () => {
5260
+ this.content = ta.value;
4727
5261
  };
4728
- draw();
4729
- root.append(list, addBtn);
5262
+ root.append(hint, ta);
5263
+ this.textarea = ta;
4730
5264
  return root;
4731
5265
  }
4732
- save() {
4733
- return { stats: this.stats };
4734
- }
4735
- };
4736
- var ProsConsTool = class {
4737
- data;
4738
- constructor(options) {
4739
- this.data = {
4740
- pros: options.data?.pros || [""],
4741
- cons: options.data?.cons || [""]
4742
- };
5266
+ renderSettings() {
5267
+ const tunes = [
5268
+ {
5269
+ label: "Align Left",
5270
+ 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>',
5271
+ isActive: this.align === "left",
5272
+ onActivate: () => {
5273
+ this.align = "left";
5274
+ this.applyVisualAttrs();
5275
+ }
5276
+ },
5277
+ {
5278
+ label: "Align Center",
5279
+ 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>',
5280
+ isActive: this.align === "center",
5281
+ onActivate: () => {
5282
+ this.align = "center";
5283
+ this.applyVisualAttrs();
5284
+ }
5285
+ },
5286
+ {
5287
+ label: "Align Right",
5288
+ 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>',
5289
+ isActive: this.align === "right",
5290
+ onActivate: () => {
5291
+ this.align = "right";
5292
+ this.applyVisualAttrs();
5293
+ }
5294
+ },
5295
+ {
5296
+ label: "BG: Default",
5297
+ icon: '<span style="font-size:11px;font-weight:700;">D</span>',
5298
+ isActive: this.background === "default",
5299
+ onActivate: () => {
5300
+ this.background = "default";
5301
+ this.applyVisualAttrs();
5302
+ }
5303
+ },
5304
+ {
5305
+ label: "BG: White",
5306
+ icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#fff;border:1px solid #999;"></span>',
5307
+ isActive: this.background === "white",
5308
+ onActivate: () => {
5309
+ this.background = "white";
5310
+ this.textTone = "dark";
5311
+ this.applyVisualAttrs();
5312
+ }
5313
+ },
5314
+ {
5315
+ label: "BG: Soft Zinc",
5316
+ icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#e4e4e7;border:1px solid #999;"></span>',
5317
+ isActive: this.background === "zinc",
5318
+ onActivate: () => {
5319
+ this.background = "zinc";
5320
+ this.textTone = "dark";
5321
+ this.applyVisualAttrs();
5322
+ }
5323
+ },
5324
+ {
5325
+ label: "BG: Dark",
5326
+ icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:#09090b;border:1px solid #666;"></span>',
5327
+ isActive: this.background === "dark",
5328
+ onActivate: () => {
5329
+ this.background = "dark";
5330
+ this.textTone = "light";
5331
+ this.applyVisualAttrs();
5332
+ }
5333
+ },
5334
+ {
5335
+ label: "BG: Gradient",
5336
+ icon: '<span style="display:inline-block;width:12px;height:12px;border-radius:99px;background:linear-gradient(135deg,#18181b,#52525b);"></span>',
5337
+ isActive: this.background === "gradient",
5338
+ onActivate: () => {
5339
+ this.background = "gradient";
5340
+ this.textTone = "light";
5341
+ this.applyVisualAttrs();
5342
+ }
5343
+ },
5344
+ {
5345
+ label: "Text: Dark",
5346
+ icon: '<span style="font-size:11px;font-weight:700;">T</span>',
5347
+ isActive: this.textTone === "dark",
5348
+ onActivate: () => {
5349
+ this.textTone = "dark";
5350
+ this.applyVisualAttrs();
5351
+ }
5352
+ },
5353
+ {
5354
+ label: "Text: Light",
5355
+ icon: '<span style="font-size:11px;font-weight:700;opacity:0.65;">T</span>',
5356
+ isActive: this.textTone === "light",
5357
+ onActivate: () => {
5358
+ this.textTone = "light";
5359
+ this.applyVisualAttrs();
5360
+ }
5361
+ }
5362
+ ];
5363
+ return tunes.map((t) => ({
5364
+ icon: t.icon,
5365
+ label: t.label,
5366
+ isActive: t.isActive,
5367
+ closeOnActivate: true,
5368
+ onActivate: t.onActivate
5369
+ }));
4743
5370
  }
4744
- static get toolbox() {
5371
+ save() {
4745
5372
  return {
4746
- title: "Pros & Cons",
4747
- 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>'
4748
- };
4749
- }
4750
- render() {
4751
- const root = document.createElement("div");
4752
- root.className = "block-card";
4753
- const grid = document.createElement("div");
4754
- grid.className = "block-two-col";
4755
- const makeCol = (title, key) => {
4756
- const box = document.createElement("div");
4757
- box.className = "block-subrow";
4758
- const heading = document.createElement("div");
4759
- heading.className = "block-hint";
4760
- heading.textContent = title;
4761
- const ta = document.createElement("textarea");
4762
- ta.rows = 4;
4763
- ta.placeholder = `${title}, one per line...`;
4764
- ta.value = this.data[key].join("\n");
4765
- ta.oninput = () => {
4766
- this.data[key] = ta.value.split(/\n/).map((s) => s.trim()).filter(Boolean);
4767
- };
4768
- box.append(heading, ta);
4769
- return box;
5373
+ content: this.textarea?.value ?? this.content,
5374
+ background: this.background,
5375
+ align: this.align,
5376
+ textTone: this.textTone
4770
5377
  };
4771
- grid.append(makeCol("Pros", "pros"), makeCol("Cons", "cons"));
4772
- root.appendChild(grid);
4773
- return root;
4774
- }
4775
- save() {
4776
- return this.data;
4777
5378
  }
4778
5379
  };
4779
- var CardsTool = class {
4780
- cards;
5380
+ var TabsTool = class {
5381
+ tabs;
4781
5382
  constructor(options) {
4782
- this.cards = Array.isArray(options.data?.cards) && options.data.cards.length ? options.data.cards.map((c) => ({ ...c })) : [{ title: "", subtitle: "", url: "", badge: "Link" }];
5383
+ this.tabs = Array.isArray(options.data?.tabs) && options.data.tabs.length ? options.data.tabs.map((t) => ({ ...t })) : [
5384
+ { label: "Overview", content: "" },
5385
+ { label: "Specs", content: "" },
5386
+ { label: "Notes", content: "" }
5387
+ ];
4783
5388
  }
4784
5389
  static get toolbox() {
4785
5390
  return {
4786
- title: "Card grid",
4787
- 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>'
5391
+ title: "Tabs",
5392
+ 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>'
4788
5393
  };
4789
5394
  }
4790
5395
  render() {
@@ -4794,78 +5399,44 @@ var CardsTool = class {
4794
5399
  list.className = "block-rows";
4795
5400
  const draw = () => {
4796
5401
  list.innerHTML = "";
4797
- this.cards.forEach((card, idx) => {
5402
+ this.tabs.forEach((tab, idx) => {
4798
5403
  const row = document.createElement("div");
4799
5404
  row.className = "block-subrow";
4800
5405
  const top = document.createElement("div");
4801
5406
  top.className = "block-subrow-head";
4802
- const titleIn = document.createElement("input");
4803
- titleIn.type = "text";
4804
- titleIn.placeholder = "Card title";
4805
- titleIn.value = card.title;
4806
- titleIn.oninput = () => {
4807
- card.title = titleIn.value;
4808
- };
4809
- const badgeIn = document.createElement("input");
4810
- badgeIn.type = "text";
4811
- badgeIn.placeholder = "Badge (PDF / Link)";
4812
- badgeIn.value = card.badge || "";
4813
- badgeIn.oninput = () => {
4814
- card.badge = badgeIn.value;
5407
+ const lbl = document.createElement("input");
5408
+ lbl.type = "text";
5409
+ lbl.placeholder = `Tab ${idx + 1} label`;
5410
+ lbl.value = tab.label;
5411
+ lbl.oninput = () => {
5412
+ tab.label = lbl.value;
4815
5413
  };
4816
5414
  const rmBtn = document.createElement("button");
4817
5415
  rmBtn.type = "button";
4818
5416
  rmBtn.className = "b2";
4819
5417
  rmBtn.textContent = "\xD7";
4820
5418
  rmBtn.onclick = () => {
4821
- this.cards.splice(idx, 1);
5419
+ this.tabs.splice(idx, 1);
4822
5420
  draw();
4823
5421
  };
4824
- top.append(titleIn, badgeIn, rmBtn);
4825
- const subIn = document.createElement("input");
4826
- subIn.type = "text";
4827
- subIn.placeholder = "Short description";
4828
- subIn.value = card.subtitle || "";
4829
- subIn.oninput = () => {
4830
- card.subtitle = subIn.value;
4831
- };
4832
- const urlIn = document.createElement("input");
4833
- urlIn.type = "url";
4834
- urlIn.placeholder = "URL or upload a file below";
4835
- urlIn.value = card.url;
4836
- urlIn.oninput = () => {
4837
- card.url = urlIn.value.trim();
4838
- };
4839
- const fileIn = document.createElement("input");
4840
- fileIn.type = "file";
4841
- fileIn.onchange = async () => {
4842
- const file = fileIn.files?.[0];
4843
- if (!file) return;
4844
- if (!card.title) card.title = file.name;
4845
- titleIn.value = card.title;
4846
- const bucketUrl = await uploadFileToBucket(file, "attachments");
4847
- if (bucketUrl) {
4848
- card.url = bucketUrl;
4849
- urlIn.value = bucketUrl;
4850
- return;
4851
- }
4852
- const reader = new FileReader();
4853
- reader.onload = () => {
4854
- card.url = String(reader.result || "");
4855
- urlIn.value = card.url;
4856
- };
4857
- reader.readAsDataURL(file);
5422
+ top.append(lbl, rmBtn);
5423
+ const body = document.createElement("textarea");
5424
+ body.rows = 3;
5425
+ body.placeholder = "Tab panel content...";
5426
+ body.value = tab.content;
5427
+ body.oninput = () => {
5428
+ tab.content = body.value;
4858
5429
  };
4859
- row.append(top, subIn, urlIn, fileIn);
5430
+ row.append(top, body);
4860
5431
  list.appendChild(row);
4861
5432
  });
4862
5433
  };
4863
5434
  const addBtn = document.createElement("button");
4864
5435
  addBtn.type = "button";
4865
5436
  addBtn.className = "b2";
4866
- addBtn.textContent = "+ Add card";
5437
+ addBtn.textContent = "+ Add tab";
4867
5438
  addBtn.onclick = () => {
4868
- this.cards.push({ title: "", subtitle: "", url: "", badge: "Link" });
5439
+ this.tabs.push({ label: `Tab ${this.tabs.length + 1}`, content: "" });
4869
5440
  draw();
4870
5441
  };
4871
5442
  draw();
@@ -4873,18 +5444,21 @@ var CardsTool = class {
4873
5444
  return root;
4874
5445
  }
4875
5446
  save() {
4876
- return { cards: this.cards };
5447
+ return { tabs: this.tabs };
4877
5448
  }
4878
5449
  };
4879
- var BadgesTool = class {
5450
+ var AccordionTool = class {
4880
5451
  items;
4881
5452
  constructor(options) {
4882
- this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((b) => ({ ...b })) : [{ label: "New", tone: "accent" }];
5453
+ this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((i) => ({ ...i })) : [
5454
+ { title: "Question or section 1", body: "" },
5455
+ { title: "Question or section 2", body: "" }
5456
+ ];
4883
5457
  }
4884
5458
  static get toolbox() {
4885
5459
  return {
4886
- title: "Badges",
4887
- 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>'
5460
+ title: "Accordion",
5461
+ 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>'
4888
5462
  };
4889
5463
  }
4890
5464
  render() {
@@ -4892,29 +5466,19 @@ var BadgesTool = class {
4892
5466
  root.className = "block-card";
4893
5467
  const list = document.createElement("div");
4894
5468
  list.className = "block-rows";
4895
- const tones = ["neutral", "accent", "green", "blue", "amber", "red"];
4896
5469
  const draw = () => {
4897
5470
  list.innerHTML = "";
4898
5471
  this.items.forEach((item, idx) => {
4899
5472
  const row = document.createElement("div");
4900
- row.className = "block-subrow-head";
4901
- const labelIn = document.createElement("input");
4902
- labelIn.type = "text";
4903
- labelIn.placeholder = "Badge label (e.g. Beta, v2.0)";
4904
- labelIn.value = item.label;
4905
- labelIn.oninput = () => {
4906
- item.label = labelIn.value;
4907
- };
4908
- const toneSel = document.createElement("select");
4909
- tones.forEach((t) => {
4910
- const opt = document.createElement("option");
4911
- opt.value = t;
4912
- opt.textContent = t.charAt(0).toUpperCase() + t.slice(1);
4913
- toneSel.appendChild(opt);
4914
- });
4915
- toneSel.value = item.tone || "neutral";
4916
- toneSel.onchange = () => {
4917
- item.tone = toneSel.value;
5473
+ row.className = "block-subrow";
5474
+ const top = document.createElement("div");
5475
+ top.className = "block-subrow-head";
5476
+ const titleIn = document.createElement("input");
5477
+ titleIn.type = "text";
5478
+ titleIn.placeholder = `Row ${idx + 1} title`;
5479
+ titleIn.value = item.title;
5480
+ titleIn.oninput = () => {
5481
+ item.title = titleIn.value;
4918
5482
  };
4919
5483
  const rmBtn = document.createElement("button");
4920
5484
  rmBtn.type = "button";
@@ -4924,16 +5488,24 @@ var BadgesTool = class {
4924
5488
  this.items.splice(idx, 1);
4925
5489
  draw();
4926
5490
  };
4927
- row.append(labelIn, toneSel, rmBtn);
5491
+ top.append(titleIn, rmBtn);
5492
+ const bodyIn = document.createElement("textarea");
5493
+ bodyIn.rows = 2;
5494
+ bodyIn.placeholder = "Answer / details...";
5495
+ bodyIn.value = item.body;
5496
+ bodyIn.oninput = () => {
5497
+ item.body = bodyIn.value;
5498
+ };
5499
+ row.append(top, bodyIn);
4928
5500
  list.appendChild(row);
4929
5501
  });
4930
5502
  };
4931
5503
  const addBtn = document.createElement("button");
4932
5504
  addBtn.type = "button";
4933
5505
  addBtn.className = "b2";
4934
- addBtn.textContent = "+ Add badge";
5506
+ addBtn.textContent = "+ Add row";
4935
5507
  addBtn.onclick = () => {
4936
- this.items.push({ label: "", tone: "neutral" });
5508
+ this.items.push({ title: "", body: "" });
4937
5509
  draw();
4938
5510
  };
4939
5511
  draw();
@@ -4941,613 +5513,626 @@ var BadgesTool = class {
4941
5513
  return root;
4942
5514
  }
4943
5515
  save() {
4944
- return { items: this.items.filter((i) => i.label.trim()) };
4945
- }
4946
- };
4947
- var TagsTool = class {
4948
- raw;
4949
- input;
4950
- constructor(options) {
4951
- this.raw = Array.isArray(options.data?.tags) ? options.data.tags.join(", ") : "";
4952
- }
4953
- static get toolbox() {
4954
- return {
4955
- title: "Tags",
4956
- 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>'
4957
- };
4958
- }
4959
- render() {
4960
- const root = document.createElement("div");
4961
- root.className = "block-card";
4962
- const input = document.createElement("input");
4963
- input.type = "text";
4964
- input.placeholder = "Comma-separated tags (e.g. react, typescript, design)";
4965
- input.value = this.raw;
4966
- root.appendChild(input);
4967
- this.input = input;
4968
- return root;
4969
- }
4970
- save() {
4971
- const val = this.input?.value ?? this.raw;
4972
- return {
4973
- tags: val.split(",").map((t) => t.trim().replace(/^#/, "")).filter(Boolean)
4974
- };
4975
- }
4976
- };
4977
-
4978
- // src/blocks/mermaidBlock.ts
4979
- var import_mermaid = __toESM(require("mermaid"), 1);
4980
- var MERMAID_PRESETS = {
4981
- Flowchart: `graph TD
4982
- A[Start] --> B{Condition?}
4983
- B -->|Yes| C[Proceed]
4984
- B -->|No| D[Retry]`,
4985
- Sequence: `sequenceDiagram
4986
- User->>Editor: Type /mermaid
4987
- Editor->>Mermaid: Render SVG
4988
- Mermaid-->>User: Interactive Diagram`,
4989
- Mindmap: `mindmap
4990
- root((NextGen Editor))
4991
- Blocks
4992
- Mermaid
4993
- Charts
4994
- Code
4995
- AI
4996
- Rewrite
4997
- Continue`
4998
- };
4999
- var mermaidInitialized = false;
5000
- var mermaidCounter = 0;
5001
- function ensureMermaidInit() {
5002
- if (mermaidInitialized) return;
5003
- mermaidInitialized = true;
5004
- import_mermaid.default.initialize({
5005
- startOnLoad: false,
5006
- securityLevel: "strict",
5007
- theme: "neutral"
5008
- });
5009
- }
5010
- async function renderMermaidInto(container, code) {
5011
- const trimmed = code.trim();
5012
- if (!trimmed) {
5013
- container.innerHTML = '<span class="editor-mermaid-empty">Enter Mermaid syntax to preview</span>';
5014
- return;
5015
- }
5016
- ensureMermaidInit();
5017
- const id = `ng-mermaid-${++mermaidCounter}`;
5018
- try {
5019
- const { svg } = await import_mermaid.default.render(id, trimmed);
5020
- container.innerHTML = svg;
5021
- } catch (err) {
5022
- const message = err instanceof Error ? err.message : "Invalid Mermaid syntax";
5023
- container.innerHTML = `<pre class="editor-mermaid-error">${message.replace(/</g, "&lt;")}</pre>`;
5516
+ return { items: this.items };
5024
5517
  }
5025
- }
5026
- var MermaidTool = class {
5518
+ };
5519
+ var PullQuoteTool = class {
5027
5520
  data;
5028
- renderSeq = 0;
5029
- static get toolbox() {
5030
- return {
5031
- title: "Mermaid Diagram",
5032
- 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>'
5521
+ constructor(options) {
5522
+ this.data = {
5523
+ text: options.data?.text || "",
5524
+ attribution: options.data?.attribution || ""
5033
5525
  };
5034
5526
  }
5035
- constructor({ data }) {
5036
- this.data = {
5037
- code: data?.code ?? MERMAID_PRESETS.Flowchart,
5038
- caption: data?.caption ?? ""
5527
+ static get toolbox() {
5528
+ return {
5529
+ title: "Pull quote",
5530
+ 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>'
5039
5531
  };
5040
5532
  }
5041
5533
  render() {
5042
- const wrap = document.createElement("div");
5043
- wrap.className = "editor-mermaid-tool";
5044
- const head = document.createElement("div");
5045
- head.className = "editor-mermaid-head";
5046
- const title = document.createElement("span");
5047
- title.className = "editor-mermaid-label";
5048
- title.textContent = "Mermaid Diagram";
5049
- const presets = document.createElement("div");
5050
- presets.className = "editor-mermaid-presets";
5051
- Object.entries(MERMAID_PRESETS).forEach(([label, snippet]) => {
5052
- const btn = document.createElement("button");
5053
- btn.type = "button";
5054
- btn.className = "editor-mermaid-preset-btn";
5055
- btn.textContent = label;
5056
- btn.addEventListener("click", () => {
5057
- this.data.code = snippet;
5058
- textarea.value = snippet;
5059
- void updatePreview();
5060
- });
5061
- presets.appendChild(btn);
5062
- });
5063
- head.append(title, presets);
5064
- const textarea = document.createElement("textarea");
5065
- textarea.className = "editor-mermaid-input";
5066
- textarea.rows = 5;
5067
- textarea.placeholder = "graph TD\n A --> B";
5068
- textarea.value = this.data.code;
5069
- const preview = document.createElement("div");
5070
- preview.className = "editor-mermaid-preview";
5071
- const captionInput = document.createElement("input");
5072
- captionInput.type = "text";
5073
- captionInput.className = "editor-mermaid-caption cdx-input";
5074
- captionInput.placeholder = "Optional diagram caption";
5075
- captionInput.value = this.data.caption || "";
5076
- const updatePreview = async () => {
5077
- const seq = ++this.renderSeq;
5078
- await renderMermaidInto(preview, this.data.code);
5079
- if (seq !== this.renderSeq) return;
5534
+ const root = document.createElement("div");
5535
+ root.className = "block-card";
5536
+ const text = document.createElement("textarea");
5537
+ text.rows = 3;
5538
+ text.placeholder = "Oversized editorial pull-quote...";
5539
+ text.value = this.data.text;
5540
+ text.oninput = () => {
5541
+ this.data.text = text.value;
5080
5542
  };
5081
- textarea.addEventListener("input", () => {
5082
- this.data.code = textarea.value;
5083
- void updatePreview();
5084
- });
5085
- captionInput.addEventListener("input", () => {
5086
- this.data.caption = captionInput.value;
5087
- });
5088
- void updatePreview();
5089
- wrap.append(head, textarea, preview, captionInput);
5090
- return wrap;
5543
+ const attr = document.createElement("input");
5544
+ attr.type = "text";
5545
+ attr.placeholder = "Attribution (optional)";
5546
+ attr.value = this.data.attribution;
5547
+ attr.oninput = () => {
5548
+ this.data.attribution = attr.value;
5549
+ };
5550
+ root.append(text, attr);
5551
+ return root;
5091
5552
  }
5092
5553
  save() {
5093
- return {
5094
- code: this.data.code,
5095
- caption: this.data.caption?.trim() || void 0
5096
- };
5554
+ return this.data;
5097
5555
  }
5098
5556
  };
5099
5557
 
5100
- // src/blocks/extraBlocks.ts
5101
- function createInput(type, className, placeholder, value, onInput) {
5102
- const input = document.createElement("input");
5103
- input.type = type;
5104
- input.className = className;
5105
- input.placeholder = placeholder;
5106
- input.value = value;
5107
- input.addEventListener("input", () => onInput(input.value));
5108
- return input;
5109
- }
5110
- function createTextarea(className, rows, placeholder, value, onInput) {
5111
- const ta = document.createElement("textarea");
5112
- ta.className = className;
5113
- ta.rows = rows;
5114
- ta.placeholder = placeholder;
5115
- ta.value = value;
5116
- ta.addEventListener("input", () => onInput(ta.value));
5117
- return ta;
5118
- }
5119
- var BookmarkTool = class {
5120
- data;
5558
+ // src/blocks/structuredBlocks.ts
5559
+ var TimelineTool = class {
5560
+ steps;
5561
+ constructor(options) {
5562
+ this.steps = Array.isArray(options.data?.steps) && options.data.steps.length ? options.data.steps.map((s) => ({ ...s })) : [
5563
+ { title: "Step 1", detail: "" },
5564
+ { title: "Step 2", detail: "" }
5565
+ ];
5566
+ }
5121
5567
  static get toolbox() {
5122
5568
  return {
5123
- title: "Bookmark",
5124
- 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>'
5125
- };
5126
- }
5127
- constructor({ data }) {
5128
- this.data = {
5129
- url: data?.url ?? "",
5130
- title: data?.title ?? "",
5131
- description: data?.description ?? "",
5132
- image: data?.image ?? ""
5569
+ title: "Timeline",
5570
+ 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>'
5133
5571
  };
5134
5572
  }
5135
5573
  render() {
5136
- const wrap = document.createElement("div");
5137
- wrap.className = "editor-extra-card";
5138
- const head = document.createElement("div");
5139
- head.className = "editor-extra-head";
5140
- head.textContent = "URL Bookmark Card";
5141
- const preview = document.createElement("div");
5142
- preview.className = "editor-bookmark-preview";
5143
- const refreshPreview = () => {
5144
- const host = (() => {
5145
- try {
5146
- return this.data.url ? new URL(this.data.url).hostname : "example.com";
5147
- } catch {
5148
- return this.data.url || "example.com";
5149
- }
5150
- })();
5151
- preview.innerHTML = `
5152
- <div class="editor-bookmark-card">
5153
- <div class="editor-bookmark-body">
5154
- <div class="editor-bookmark-title">${escHtml(this.data.title || host)}</div>
5155
- ${this.data.description ? `<div class="editor-bookmark-desc">${escHtml(this.data.description)}</div>` : ""}
5156
- <div class="editor-bookmark-url">${escHtml(host)}</div>
5157
- </div>
5158
- ${this.data.image ? `<img class="editor-bookmark-thumb" src="${escHtml(this.data.image)}" alt="" />` : ""}
5159
- </div>`;
5574
+ const root = document.createElement("div");
5575
+ root.className = "block-card";
5576
+ const list = document.createElement("div");
5577
+ list.className = "block-rows";
5578
+ const draw = () => {
5579
+ list.innerHTML = "";
5580
+ this.steps.forEach((step, idx) => {
5581
+ const row = document.createElement("div");
5582
+ row.className = "block-subrow";
5583
+ const top = document.createElement("div");
5584
+ top.className = "block-subrow-head";
5585
+ const titleIn = document.createElement("input");
5586
+ titleIn.type = "text";
5587
+ titleIn.placeholder = `Step ${idx + 1} title`;
5588
+ titleIn.value = step.title;
5589
+ titleIn.oninput = () => {
5590
+ step.title = titleIn.value;
5591
+ };
5592
+ const rmBtn = document.createElement("button");
5593
+ rmBtn.type = "button";
5594
+ rmBtn.className = "b2";
5595
+ rmBtn.textContent = "\xD7";
5596
+ rmBtn.onclick = () => {
5597
+ this.steps.splice(idx, 1);
5598
+ draw();
5599
+ };
5600
+ top.append(titleIn, rmBtn);
5601
+ const detailIn = document.createElement("textarea");
5602
+ detailIn.rows = 2;
5603
+ detailIn.placeholder = "Short step description...";
5604
+ detailIn.value = step.detail;
5605
+ detailIn.oninput = () => {
5606
+ step.detail = detailIn.value;
5607
+ };
5608
+ row.append(top, detailIn);
5609
+ list.appendChild(row);
5610
+ });
5160
5611
  };
5161
- const grid = document.createElement("div");
5162
- grid.className = "editor-extra-grid";
5163
- grid.append(
5164
- createInput("url", "cdx-input", "https://example.com/article", this.data.url, (v) => {
5165
- this.data.url = v;
5166
- refreshPreview();
5167
- }),
5168
- createInput("text", "cdx-input", "Link title", this.data.title, (v) => {
5169
- this.data.title = v;
5170
- refreshPreview();
5171
- }),
5172
- createInput("text", "cdx-input", "Short description", this.data.description, (v) => {
5173
- this.data.description = v;
5174
- refreshPreview();
5175
- }),
5176
- createInput("url", "cdx-input", "Optional thumbnail URL", this.data.image || "", (v) => {
5177
- this.data.image = v;
5178
- refreshPreview();
5179
- })
5180
- );
5181
- refreshPreview();
5182
- wrap.append(head, grid, preview);
5183
- return wrap;
5612
+ const addBtn = document.createElement("button");
5613
+ addBtn.type = "button";
5614
+ addBtn.className = "b2";
5615
+ addBtn.textContent = "+ Add step";
5616
+ addBtn.onclick = () => {
5617
+ this.steps.push({ title: `Step ${this.steps.length + 1}`, detail: "" });
5618
+ draw();
5619
+ };
5620
+ draw();
5621
+ root.append(list, addBtn);
5622
+ return root;
5184
5623
  }
5185
5624
  save() {
5186
- return {
5187
- url: this.data.url.trim(),
5188
- title: this.data.title.trim(),
5189
- description: this.data.description.trim(),
5190
- image: this.data.image?.trim() || void 0
5191
- };
5625
+ return { steps: this.steps };
5192
5626
  }
5193
5627
  };
5194
- var StepsTool = class {
5195
- data;
5196
- static get toolbox() {
5197
- return {
5198
- title: "Steps",
5199
- 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>'
5200
- };
5201
- }
5202
- constructor({ data }) {
5203
- this.data = {
5204
- items: Array.isArray(data?.items) && data.items.length > 0 ? data.items.map((item) => ({ title: item.title || "", body: item.body || "" })) : [
5205
- { title: "Install dependencies", body: "Run npm install to set up the package." },
5206
- { title: "Configure & render", body: "Pass initialData and onChange to BlockEditor." }
5207
- ]
5628
+ var StatsTool = class {
5629
+ stats;
5630
+ constructor(options) {
5631
+ this.stats = Array.isArray(options.data?.stats) && options.data.stats.length ? options.data.stats.map((s) => ({ ...s })) : [
5632
+ { value: "99.9%", label: "Uptime" },
5633
+ { value: "42ms", label: "Latency" }
5634
+ ];
5635
+ }
5636
+ static get toolbox() {
5637
+ return {
5638
+ title: "Stats row",
5639
+ 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>'
5208
5640
  };
5209
5641
  }
5210
5642
  render() {
5211
- const wrap = document.createElement("div");
5212
- wrap.className = "editor-extra-card";
5213
- const head = document.createElement("div");
5214
- head.className = "editor-extra-head";
5215
- head.textContent = "Step-by-Step Walkthrough";
5643
+ const root = document.createElement("div");
5644
+ root.className = "block-card";
5216
5645
  const list = document.createElement("div");
5217
- list.className = "editor-steps-editor-list";
5218
- const renderList = () => {
5646
+ list.className = "block-rows";
5647
+ const draw = () => {
5219
5648
  list.innerHTML = "";
5220
- this.data.items.forEach((item, idx) => {
5649
+ this.stats.forEach((stat, idx) => {
5221
5650
  const row = document.createElement("div");
5222
- row.className = "editor-step-editor-row";
5223
- const badge = document.createElement("span");
5224
- badge.className = "editor-step-badge";
5225
- badge.textContent = String(idx + 1);
5226
- const fields = document.createElement("div");
5227
- fields.className = "editor-step-editor-fields";
5228
- fields.append(
5229
- createInput("text", "cdx-input", `Step ${idx + 1} title`, item.title, (v) => {
5230
- item.title = v;
5231
- }),
5232
- createTextarea("cdx-input", 2, "Step details", item.body, (v) => {
5233
- item.body = v;
5234
- })
5235
- );
5236
- const removeBtn = document.createElement("button");
5237
- removeBtn.type = "button";
5238
- removeBtn.className = "excalidraw-btn";
5239
- removeBtn.textContent = "\xD7";
5240
- removeBtn.title = "Remove step";
5241
- removeBtn.addEventListener("click", () => {
5242
- if (this.data.items.length <= 1) return;
5243
- this.data.items.splice(idx, 1);
5244
- renderList();
5245
- });
5246
- row.append(badge, fields, removeBtn);
5651
+ row.className = "block-subrow-head";
5652
+ const valIn = document.createElement("input");
5653
+ valIn.type = "text";
5654
+ valIn.placeholder = "Value (e.g. 99.9%)";
5655
+ valIn.value = stat.value;
5656
+ valIn.oninput = () => {
5657
+ stat.value = valIn.value;
5658
+ };
5659
+ const lblIn = document.createElement("input");
5660
+ lblIn.type = "text";
5661
+ lblIn.placeholder = "Label (e.g. Uptime)";
5662
+ lblIn.value = stat.label;
5663
+ lblIn.oninput = () => {
5664
+ stat.label = lblIn.value;
5665
+ };
5666
+ const rmBtn = document.createElement("button");
5667
+ rmBtn.type = "button";
5668
+ rmBtn.className = "b2";
5669
+ rmBtn.textContent = "\xD7";
5670
+ rmBtn.onclick = () => {
5671
+ this.stats.splice(idx, 1);
5672
+ draw();
5673
+ };
5674
+ row.append(valIn, lblIn, rmBtn);
5247
5675
  list.appendChild(row);
5248
5676
  });
5249
5677
  };
5250
5678
  const addBtn = document.createElement("button");
5251
5679
  addBtn.type = "button";
5252
- addBtn.className = "excalidraw-btn";
5253
- addBtn.textContent = "+ Add Step";
5254
- addBtn.addEventListener("click", () => {
5255
- this.data.items.push({ title: "", body: "" });
5256
- renderList();
5257
- });
5258
- renderList();
5259
- wrap.append(head, list, addBtn);
5260
- return wrap;
5680
+ addBtn.className = "b2";
5681
+ addBtn.textContent = "+ Add metric";
5682
+ addBtn.onclick = () => {
5683
+ this.stats.push({ value: "", label: "" });
5684
+ draw();
5685
+ };
5686
+ draw();
5687
+ root.append(list, addBtn);
5688
+ return root;
5261
5689
  }
5262
5690
  save() {
5263
- return {
5264
- items: this.data.items.filter((i) => i.title.trim() || i.body.trim())
5265
- };
5691
+ return { stats: this.stats };
5266
5692
  }
5267
5693
  };
5268
- function computeSimpleDiff(before, after) {
5269
- const a = before.split("\n");
5270
- const b = after.split("\n");
5271
- const lines = [];
5272
- const max = Math.max(a.length, b.length);
5273
- for (let i = 0; i < max; i += 1) {
5274
- const left = a[i];
5275
- const right = b[i];
5276
- if (left === right) {
5277
- if (left !== void 0) lines.push({ kind: "same", text: left });
5278
- } else {
5279
- if (left !== void 0) lines.push({ kind: "del", text: left });
5280
- if (right !== void 0) lines.push({ kind: "add", text: right });
5281
- }
5282
- }
5283
- return lines;
5284
- }
5285
- var DiffTool = class {
5694
+ var ProsConsTool = class {
5286
5695
  data;
5287
- static get toolbox() {
5288
- return {
5289
- title: "Code Diff",
5290
- 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>'
5696
+ constructor(options) {
5697
+ this.data = {
5698
+ pros: options.data?.pros || [""],
5699
+ cons: options.data?.cons || [""]
5291
5700
  };
5292
5701
  }
5293
- constructor({ data }) {
5294
- this.data = {
5295
- filename: data?.filename ?? "example.ts",
5296
- before: data?.before ?? 'const theme = "catppuccin";',
5297
- after: data?.after ?? 'const theme = "dark";'
5702
+ static get toolbox() {
5703
+ return {
5704
+ title: "Pros & Cons",
5705
+ 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>'
5298
5706
  };
5299
5707
  }
5300
5708
  render() {
5301
- const wrap = document.createElement("div");
5302
- wrap.className = "editor-extra-card";
5303
- const head = document.createElement("div");
5304
- head.className = "editor-extra-head";
5305
- head.textContent = "Code Diff Viewer";
5306
- const preview = document.createElement("pre");
5307
- preview.className = "editor-diff-preview";
5308
- const refreshPreview = () => {
5309
- const diffLines = computeSimpleDiff(this.data.before, this.data.after);
5310
- preview.innerHTML = diffLines.map((line) => {
5311
- const prefix = line.kind === "del" ? "-" : line.kind === "add" ? "+" : " ";
5312
- return `<span class="editor-diff-line is-${line.kind}">${prefix} ${escHtml(line.text)}</span>`;
5313
- }).join("\n");
5709
+ const root = document.createElement("div");
5710
+ root.className = "block-card";
5711
+ const grid = document.createElement("div");
5712
+ grid.className = "block-two-col";
5713
+ const makeCol = (title, key) => {
5714
+ const box = document.createElement("div");
5715
+ box.className = "block-subrow";
5716
+ const heading = document.createElement("div");
5717
+ heading.className = "block-hint";
5718
+ heading.textContent = title;
5719
+ const ta = document.createElement("textarea");
5720
+ ta.rows = 4;
5721
+ ta.placeholder = `${title}, one per line...`;
5722
+ ta.value = this.data[key].join("\n");
5723
+ ta.oninput = () => {
5724
+ this.data[key] = ta.value.split(/\n/).map((s) => s.trim()).filter(Boolean);
5725
+ };
5726
+ box.append(heading, ta);
5727
+ return box;
5314
5728
  };
5315
- const cols = document.createElement("div");
5316
- cols.className = "editor-diff-inputs";
5317
- cols.append(
5318
- createTextarea("editor-mermaid-input", 4, "Before code...", this.data.before, (v) => {
5319
- this.data.before = v;
5320
- refreshPreview();
5321
- }),
5322
- createTextarea("editor-mermaid-input", 4, "After code...", this.data.after, (v) => {
5323
- this.data.after = v;
5324
- refreshPreview();
5325
- })
5326
- );
5327
- const fileInput = createInput("text", "cdx-input", "Filename (optional)", this.data.filename || "", (v) => {
5328
- this.data.filename = v;
5329
- });
5330
- refreshPreview();
5331
- wrap.append(head, fileInput, cols, preview);
5332
- return wrap;
5729
+ grid.append(makeCol("Pros", "pros"), makeCol("Cons", "cons"));
5730
+ root.appendChild(grid);
5731
+ return root;
5333
5732
  }
5334
5733
  save() {
5335
- return {
5336
- filename: this.data.filename?.trim() || void 0,
5337
- before: this.data.before,
5338
- after: this.data.after
5339
- };
5734
+ return this.data;
5340
5735
  }
5341
5736
  };
5342
- var VideoTool = class {
5343
- data;
5737
+ var CardsTool = class {
5738
+ cards;
5739
+ constructor(options) {
5740
+ this.cards = Array.isArray(options.data?.cards) && options.data.cards.length ? options.data.cards.map((c) => ({ ...c })) : [{ title: "", subtitle: "", url: "", badge: "Link" }];
5741
+ }
5344
5742
  static get toolbox() {
5345
5743
  return {
5346
- title: "Video Player",
5347
- 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>'
5744
+ title: "Card grid",
5745
+ 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>'
5348
5746
  };
5349
5747
  }
5350
- constructor({ data }) {
5351
- this.data = {
5352
- url: data?.url ?? "",
5353
- poster: data?.poster ?? "",
5354
- caption: data?.caption ?? ""
5748
+ render() {
5749
+ const root = document.createElement("div");
5750
+ root.className = "block-card";
5751
+ const list = document.createElement("div");
5752
+ list.className = "block-rows";
5753
+ const draw = () => {
5754
+ list.innerHTML = "";
5755
+ this.cards.forEach((card, idx) => {
5756
+ const row = document.createElement("div");
5757
+ row.className = "block-subrow";
5758
+ const top = document.createElement("div");
5759
+ top.className = "block-subrow-head";
5760
+ const titleIn = document.createElement("input");
5761
+ titleIn.type = "text";
5762
+ titleIn.placeholder = "Card title";
5763
+ titleIn.value = card.title;
5764
+ titleIn.oninput = () => {
5765
+ card.title = titleIn.value;
5766
+ };
5767
+ const badgeIn = document.createElement("input");
5768
+ badgeIn.type = "text";
5769
+ badgeIn.placeholder = "Badge (PDF / Link)";
5770
+ badgeIn.value = card.badge || "";
5771
+ badgeIn.oninput = () => {
5772
+ card.badge = badgeIn.value;
5773
+ };
5774
+ const rmBtn = document.createElement("button");
5775
+ rmBtn.type = "button";
5776
+ rmBtn.className = "b2";
5777
+ rmBtn.textContent = "\xD7";
5778
+ rmBtn.onclick = () => {
5779
+ this.cards.splice(idx, 1);
5780
+ draw();
5781
+ };
5782
+ top.append(titleIn, badgeIn, rmBtn);
5783
+ const subIn = document.createElement("input");
5784
+ subIn.type = "text";
5785
+ subIn.placeholder = "Short description";
5786
+ subIn.value = card.subtitle || "";
5787
+ subIn.oninput = () => {
5788
+ card.subtitle = subIn.value;
5789
+ };
5790
+ const urlIn = document.createElement("input");
5791
+ urlIn.type = "url";
5792
+ urlIn.placeholder = "URL or upload a file below";
5793
+ urlIn.value = card.url;
5794
+ urlIn.oninput = () => {
5795
+ card.url = urlIn.value.trim();
5796
+ };
5797
+ const fileIn = document.createElement("input");
5798
+ fileIn.type = "file";
5799
+ fileIn.onchange = async () => {
5800
+ const file = fileIn.files?.[0];
5801
+ if (!file) return;
5802
+ if (!card.title) card.title = file.name;
5803
+ titleIn.value = card.title;
5804
+ const bucketUrl = await uploadFileToBucket(file, "attachments");
5805
+ if (bucketUrl) {
5806
+ card.url = bucketUrl;
5807
+ urlIn.value = bucketUrl;
5808
+ return;
5809
+ }
5810
+ const reader = new FileReader();
5811
+ reader.onload = () => {
5812
+ card.url = String(reader.result || "");
5813
+ urlIn.value = card.url;
5814
+ };
5815
+ reader.readAsDataURL(file);
5816
+ };
5817
+ row.append(top, subIn, urlIn, fileIn);
5818
+ list.appendChild(row);
5819
+ });
5355
5820
  };
5356
- }
5357
- render() {
5358
- const wrap = document.createElement("div");
5359
- wrap.className = "editor-extra-card";
5360
- const head = document.createElement("div");
5361
- head.className = "editor-extra-head";
5362
- head.textContent = "Video Player (MP4 / WebM)";
5363
- const preview = document.createElement("div");
5364
- preview.className = "editor-video-preview";
5365
- const refreshPreview = () => {
5366
- if (!this.data.url.trim()) {
5367
- preview.innerHTML = '<div class="editor-mermaid-empty">Paste a video URL or upload a file</div>';
5368
- return;
5369
- }
5370
- 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>`;
5821
+ const addBtn = document.createElement("button");
5822
+ addBtn.type = "button";
5823
+ addBtn.className = "b2";
5824
+ addBtn.textContent = "+ Add card";
5825
+ addBtn.onclick = () => {
5826
+ this.cards.push({ title: "", subtitle: "", url: "", badge: "Link" });
5827
+ draw();
5371
5828
  };
5372
- const urlInput = createInput("url", "cdx-input", "https://.../video.mp4", this.data.url, (v) => {
5373
- this.data.url = v;
5374
- refreshPreview();
5375
- });
5376
- const uploadInput = document.createElement("input");
5377
- uploadInput.type = "file";
5378
- uploadInput.accept = "video/mp4,video/webm,video/ogg";
5379
- uploadInput.className = "cdx-input";
5380
- uploadInput.addEventListener("change", async () => {
5381
- const file = uploadInput.files?.[0];
5382
- if (!file) return;
5383
- const uploaded = await uploadFileToBucket(file, "videos");
5384
- if (uploaded) {
5385
- this.data.url = uploaded;
5386
- urlInput.value = uploaded;
5387
- refreshPreview();
5388
- }
5389
- });
5390
- const posterInput = createInput("url", "cdx-input", "Optional poster image URL", this.data.poster || "", (v) => {
5391
- this.data.poster = v;
5392
- refreshPreview();
5393
- });
5394
- const captionInput = createInput("text", "cdx-input", "Optional video caption", this.data.caption || "", (v) => {
5395
- this.data.caption = v;
5396
- });
5397
- refreshPreview();
5398
- wrap.append(head, urlInput, uploadInput, posterInput, captionInput, preview);
5399
- return wrap;
5829
+ draw();
5830
+ root.append(list, addBtn);
5831
+ return root;
5400
5832
  }
5401
5833
  save() {
5402
- return {
5403
- url: this.data.url.trim(),
5404
- poster: this.data.poster?.trim() || void 0,
5405
- caption: this.data.caption?.trim() || void 0
5406
- };
5834
+ return { cards: this.cards };
5407
5835
  }
5408
5836
  };
5409
- var ChangelogTool = class {
5410
- data;
5837
+ var BadgesTool = class {
5838
+ items;
5839
+ constructor(options) {
5840
+ this.items = Array.isArray(options.data?.items) && options.data.items.length ? options.data.items.map((b) => ({ ...b })) : [{ label: "New", tone: "accent" }];
5841
+ }
5411
5842
  static get toolbox() {
5412
5843
  return {
5413
- title: "Changelog",
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"><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>'
5415
- };
5416
- }
5417
- constructor({ data }) {
5418
- this.data = {
5419
- version: data?.version ?? "v1.0.0",
5420
- date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
5421
- 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" }]
5844
+ title: "Badges",
5845
+ 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>'
5422
5846
  };
5423
5847
  }
5424
5848
  render() {
5425
- const wrap = document.createElement("div");
5426
- wrap.className = "editor-extra-card";
5427
- const head = document.createElement("div");
5428
- head.className = "editor-extra-head";
5429
- head.textContent = "Release Changelog";
5430
- const meta = document.createElement("div");
5431
- meta.className = "editor-diff-inputs";
5432
- meta.append(
5433
- createInput("text", "cdx-input", "Version (e.g. v1.2.0)", this.data.version, (v) => {
5434
- this.data.version = v;
5435
- }),
5436
- createInput("date", "cdx-input", "Release date", this.data.date, (v) => {
5437
- this.data.date = v;
5438
- })
5439
- );
5849
+ const root = document.createElement("div");
5850
+ root.className = "block-card";
5440
5851
  const list = document.createElement("div");
5441
- list.className = "editor-steps-editor-list";
5442
- const renderItems = () => {
5852
+ list.className = "block-rows";
5853
+ const tones = ["neutral", "accent", "green", "blue", "amber", "red"];
5854
+ const draw = () => {
5443
5855
  list.innerHTML = "";
5444
- this.data.items.forEach((item, idx) => {
5856
+ this.items.forEach((item, idx) => {
5445
5857
  const row = document.createElement("div");
5446
- row.className = "editor-changelog-row";
5447
- const select = document.createElement("select");
5448
- select.className = "cdx-input editor-form-select";
5449
- ["added", "changed", "fixed"].forEach((k) => {
5858
+ row.className = "block-subrow-head";
5859
+ const labelIn = document.createElement("input");
5860
+ labelIn.type = "text";
5861
+ labelIn.placeholder = "Badge label (e.g. Beta, v2.0)";
5862
+ labelIn.value = item.label;
5863
+ labelIn.oninput = () => {
5864
+ item.label = labelIn.value;
5865
+ };
5866
+ const toneSel = document.createElement("select");
5867
+ tones.forEach((t) => {
5450
5868
  const opt = document.createElement("option");
5451
- opt.value = k;
5452
- opt.textContent = k.toUpperCase();
5453
- if (item.kind === k) opt.selected = true;
5454
- select.appendChild(opt);
5455
- });
5456
- select.addEventListener("change", () => {
5457
- item.kind = select.value;
5458
- });
5459
- const text = createInput("text", "cdx-input", "Change description", item.text, (v) => {
5460
- item.text = v;
5461
- });
5462
- const del = document.createElement("button");
5463
- del.type = "button";
5464
- del.className = "excalidraw-btn";
5465
- del.textContent = "\xD7";
5466
- del.addEventListener("click", () => {
5467
- if (this.data.items.length <= 1) return;
5468
- this.data.items.splice(idx, 1);
5469
- renderItems();
5869
+ opt.value = t;
5870
+ opt.textContent = t.charAt(0).toUpperCase() + t.slice(1);
5871
+ toneSel.appendChild(opt);
5470
5872
  });
5471
- row.append(select, text, del);
5873
+ toneSel.value = item.tone || "neutral";
5874
+ toneSel.onchange = () => {
5875
+ item.tone = toneSel.value;
5876
+ };
5877
+ const rmBtn = document.createElement("button");
5878
+ rmBtn.type = "button";
5879
+ rmBtn.className = "b2";
5880
+ rmBtn.textContent = "\xD7";
5881
+ rmBtn.onclick = () => {
5882
+ this.items.splice(idx, 1);
5883
+ draw();
5884
+ };
5885
+ row.append(labelIn, toneSel, rmBtn);
5472
5886
  list.appendChild(row);
5473
5887
  });
5474
5888
  };
5475
5889
  const addBtn = document.createElement("button");
5476
5890
  addBtn.type = "button";
5477
- addBtn.className = "excalidraw-btn";
5478
- addBtn.textContent = "+ Add Entry";
5479
- addBtn.addEventListener("click", () => {
5480
- this.data.items.push({ kind: "added", text: "" });
5481
- renderItems();
5482
- });
5483
- renderItems();
5484
- wrap.append(head, meta, list, addBtn);
5485
- return wrap;
5891
+ addBtn.className = "b2";
5892
+ addBtn.textContent = "+ Add badge";
5893
+ addBtn.onclick = () => {
5894
+ this.items.push({ label: "", tone: "neutral" });
5895
+ draw();
5896
+ };
5897
+ draw();
5898
+ root.append(list, addBtn);
5899
+ return root;
5900
+ }
5901
+ save() {
5902
+ return { items: this.items.filter((i) => i.label.trim()) };
5903
+ }
5904
+ };
5905
+ var TagsTool = class {
5906
+ raw;
5907
+ input;
5908
+ constructor(options) {
5909
+ this.raw = Array.isArray(options.data?.tags) ? options.data.tags.join(", ") : "";
5910
+ }
5911
+ static get toolbox() {
5912
+ return {
5913
+ title: "Tags",
5914
+ 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>'
5915
+ };
5916
+ }
5917
+ render() {
5918
+ const root = document.createElement("div");
5919
+ root.className = "block-card";
5920
+ const input = document.createElement("input");
5921
+ input.type = "text";
5922
+ input.placeholder = "Comma-separated tags (e.g. react, typescript, design)";
5923
+ input.value = this.raw;
5924
+ root.appendChild(input);
5925
+ this.input = input;
5926
+ return root;
5486
5927
  }
5487
5928
  save() {
5929
+ const val = this.input?.value ?? this.raw;
5488
5930
  return {
5489
- version: this.data.version.trim() || "v1.0.0",
5490
- date: this.data.date,
5491
- items: this.data.items.filter((i) => i.text.trim())
5931
+ tags: val.split(",").map((t) => t.trim().replace(/^#/, "")).filter(Boolean)
5492
5932
  };
5493
5933
  }
5494
- };
5495
- var SocialTool = class {
5934
+ };
5935
+
5936
+ // src/blocks/mermaidBlock.ts
5937
+ var import_mermaid = __toESM(require("mermaid"), 1);
5938
+ var MERMAID_PRESETS = {
5939
+ Flowchart: `graph TD
5940
+ A[Start] --> B{Condition?}
5941
+ B -->|Yes| C[Proceed]
5942
+ B -->|No| D[Retry]`,
5943
+ Sequence: `sequenceDiagram
5944
+ User->>Editor: Type /mermaid
5945
+ Editor->>Mermaid: Render SVG
5946
+ Mermaid-->>User: Interactive Diagram`,
5947
+ Mindmap: `mindmap
5948
+ root((NextGen Editor))
5949
+ Blocks
5950
+ Mermaid
5951
+ Charts
5952
+ Code
5953
+ AI
5954
+ Rewrite
5955
+ Continue`
5956
+ };
5957
+ var mermaidInitialized = false;
5958
+ var mermaidCounter = 0;
5959
+ function ensureMermaidInit() {
5960
+ if (mermaidInitialized) return;
5961
+ mermaidInitialized = true;
5962
+ import_mermaid.default.initialize({
5963
+ startOnLoad: false,
5964
+ securityLevel: "strict",
5965
+ theme: "neutral"
5966
+ });
5967
+ }
5968
+ async function renderMermaidInto(container, code) {
5969
+ const trimmed = code.trim();
5970
+ if (!trimmed) {
5971
+ container.innerHTML = '<span class="editor-mermaid-empty">Enter Mermaid syntax to preview</span>';
5972
+ return;
5973
+ }
5974
+ ensureMermaidInit();
5975
+ const id = `ng-mermaid-${++mermaidCounter}`;
5976
+ try {
5977
+ const { svg } = await import_mermaid.default.render(id, trimmed);
5978
+ container.innerHTML = svg;
5979
+ } catch (err) {
5980
+ const message = err instanceof Error ? err.message : "Invalid Mermaid syntax";
5981
+ container.innerHTML = `<pre class="editor-mermaid-error">${message.replace(/</g, "&lt;")}</pre>`;
5982
+ }
5983
+ }
5984
+ var MermaidTool = class {
5496
5985
  data;
5986
+ renderSeq = 0;
5987
+ previewEl = null;
5497
5988
  static get toolbox() {
5498
5989
  return {
5499
- title: "Social Post",
5500
- 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>'
5990
+ title: "Mermaid Diagram",
5991
+ 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>'
5501
5992
  };
5502
5993
  }
5503
5994
  constructor({ data }) {
5504
5995
  this.data = {
5505
- author: data?.author ?? "Alex Rivera",
5506
- handle: data?.handle ?? "@alexrivera",
5507
- date: data?.date ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
5508
- text: data?.text ?? "",
5509
- url: data?.url ?? ""
5996
+ code: data?.code ?? MERMAID_PRESETS.Flowchart,
5997
+ caption: data?.caption ?? "",
5998
+ align: data?.align ?? "center",
5999
+ size: data?.size ?? "small"
5510
6000
  };
5511
6001
  }
5512
6002
  render() {
5513
6003
  const wrap = document.createElement("div");
5514
- wrap.className = "editor-extra-card";
6004
+ wrap.className = "editor-mermaid-tool";
5515
6005
  const head = document.createElement("div");
5516
- head.className = "editor-extra-head";
5517
- head.textContent = "Social Post Quote Card";
5518
- const meta = document.createElement("div");
5519
- meta.className = "editor-diff-inputs";
5520
- meta.append(
5521
- createInput("text", "cdx-input", "Author name", this.data.author, (v) => {
5522
- this.data.author = v;
5523
- }),
5524
- createInput("text", "cdx-input", "@handle", this.data.handle, (v) => {
5525
- this.data.handle = v;
5526
- })
5527
- );
5528
- const text = createTextarea("cdx-input", 3, "Quoted post content...", this.data.text, (v) => {
5529
- this.data.text = v;
6006
+ head.className = "editor-mermaid-head";
6007
+ const title = document.createElement("span");
6008
+ title.className = "editor-mermaid-label";
6009
+ title.textContent = "Mermaid Diagram";
6010
+ const presets = document.createElement("div");
6011
+ presets.className = "editor-mermaid-presets";
6012
+ Object.entries(MERMAID_PRESETS).forEach(([label, snippet]) => {
6013
+ const btn = document.createElement("button");
6014
+ btn.type = "button";
6015
+ btn.className = "editor-mermaid-preset-btn";
6016
+ btn.textContent = label;
6017
+ btn.addEventListener("click", () => {
6018
+ this.data.code = snippet;
6019
+ textarea.value = snippet;
6020
+ void updatePreview();
6021
+ });
6022
+ presets.appendChild(btn);
5530
6023
  });
5531
- const extra = document.createElement("div");
5532
- extra.className = "editor-diff-inputs";
5533
- extra.append(
5534
- createInput("text", "cdx-input", "Date (optional)", this.data.date || "", (v) => {
5535
- this.data.date = v;
5536
- }),
5537
- createInput("url", "cdx-input", "Original post URL (optional)", this.data.url || "", (v) => {
5538
- this.data.url = v;
5539
- })
5540
- );
5541
- wrap.append(head, meta, text, extra);
6024
+ head.append(title, presets);
6025
+ const textarea = document.createElement("textarea");
6026
+ textarea.className = "editor-mermaid-input";
6027
+ textarea.rows = 5;
6028
+ textarea.placeholder = "graph TD\n A --> B";
6029
+ textarea.value = this.data.code;
6030
+ const preview = document.createElement("div");
6031
+ preview.className = "editor-mermaid-preview";
6032
+ preview.dataset.align = this.data.align || "center";
6033
+ preview.dataset.size = this.data.size || "small";
6034
+ this.previewEl = preview;
6035
+ const captionInput = document.createElement("input");
6036
+ captionInput.type = "text";
6037
+ captionInput.className = "editor-mermaid-caption cdx-input";
6038
+ captionInput.placeholder = "Optional diagram caption";
6039
+ captionInput.value = this.data.caption || "";
6040
+ const updatePreview = async () => {
6041
+ const seq = ++this.renderSeq;
6042
+ await renderMermaidInto(preview, this.data.code);
6043
+ if (seq !== this.renderSeq) return;
6044
+ };
6045
+ textarea.addEventListener("input", () => {
6046
+ this.data.code = textarea.value;
6047
+ void updatePreview();
6048
+ });
6049
+ captionInput.addEventListener("input", () => {
6050
+ this.data.caption = captionInput.value;
6051
+ });
6052
+ void updatePreview();
6053
+ wrap.append(head, textarea, preview, captionInput);
5542
6054
  return wrap;
5543
6055
  }
6056
+ renderSettings() {
6057
+ const tunes = [
6058
+ {
6059
+ label: "Align Left",
6060
+ 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>',
6061
+ isActive: (this.data.align || "center") === "left",
6062
+ onActivate: () => {
6063
+ this.data.align = "left";
6064
+ if (this.previewEl) this.previewEl.dataset.align = "left";
6065
+ }
6066
+ },
6067
+ {
6068
+ label: "Align Center",
6069
+ 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>',
6070
+ isActive: (this.data.align || "center") === "center",
6071
+ onActivate: () => {
6072
+ this.data.align = "center";
6073
+ if (this.previewEl) this.previewEl.dataset.align = "center";
6074
+ }
6075
+ },
6076
+ {
6077
+ label: "Align Right",
6078
+ 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>',
6079
+ isActive: (this.data.align || "center") === "right",
6080
+ onActivate: () => {
6081
+ this.data.align = "right";
6082
+ if (this.previewEl) this.previewEl.dataset.align = "right";
6083
+ }
6084
+ },
6085
+ {
6086
+ label: "Small",
6087
+ icon: '<span style="font-size:11px;font-weight:700;">S</span>',
6088
+ isActive: (this.data.size || "small") === "small",
6089
+ onActivate: () => {
6090
+ this.data.size = "small";
6091
+ if (this.previewEl) this.previewEl.dataset.size = "small";
6092
+ }
6093
+ },
6094
+ {
6095
+ label: "Medium",
6096
+ icon: '<span style="font-size:11px;font-weight:700;">M</span>',
6097
+ isActive: (this.data.size || "small") === "medium",
6098
+ onActivate: () => {
6099
+ this.data.size = "medium";
6100
+ if (this.previewEl) this.previewEl.dataset.size = "medium";
6101
+ }
6102
+ },
6103
+ {
6104
+ label: "Large",
6105
+ icon: '<span style="font-size:11px;font-weight:700;">L</span>',
6106
+ isActive: (this.data.size || "small") === "large",
6107
+ onActivate: () => {
6108
+ this.data.size = "large";
6109
+ if (this.previewEl) this.previewEl.dataset.size = "large";
6110
+ }
6111
+ },
6112
+ {
6113
+ label: "Full Page",
6114
+ 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>',
6115
+ isActive: (this.data.size || "small") === "full",
6116
+ onActivate: () => {
6117
+ this.data.size = "full";
6118
+ if (this.previewEl) this.previewEl.dataset.size = "full";
6119
+ }
6120
+ }
6121
+ ];
6122
+ return tunes.map((t) => ({
6123
+ icon: t.icon,
6124
+ label: t.label,
6125
+ isActive: t.isActive,
6126
+ closeOnActivate: true,
6127
+ onActivate: t.onActivate
6128
+ }));
6129
+ }
5544
6130
  save() {
5545
6131
  return {
5546
- author: this.data.author.trim(),
5547
- handle: this.data.handle.trim(),
5548
- date: this.data.date?.trim() || void 0,
5549
- text: this.data.text.trim(),
5550
- url: this.data.url?.trim() || void 0
6132
+ code: this.data.code,
6133
+ caption: this.data.caption?.trim() || void 0,
6134
+ align: this.data.align || "center",
6135
+ size: this.data.size || "small"
5551
6136
  };
5552
6137
  }
5553
6138
  };
@@ -5764,19 +6349,15 @@ var AiRewriteInline = class {
5764
6349
  btn.type = "button";
5765
6350
  btn.className = "ce-inline-tool";
5766
6351
  btn.title = "AI Rewrite selection";
5767
- btn.innerHTML = '<span style="font-size:12px;font-weight:700;">\u2726 AI</span>';
6352
+ 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>';
5768
6353
  return btn;
5769
6354
  }
5770
6355
  surround(range) {
5771
6356
  this.savedRange = range.cloneRange();
5772
- if (this.actionsEl) {
5773
- this.actionsEl.hidden = false;
5774
- }
5775
6357
  }
5776
6358
  renderActions() {
5777
6359
  const wrap = document.createElement("div");
5778
6360
  wrap.className = "ng-inline-ai-actions";
5779
- wrap.hidden = true;
5780
6361
  const status = document.createElement("span");
5781
6362
  status.className = "ng-inline-ai-status";
5782
6363
  const row = document.createElement("div");
@@ -5786,6 +6367,7 @@ var AiRewriteInline = class {
5786
6367
  b.type = "button";
5787
6368
  b.className = "ng-inline-action-btn";
5788
6369
  b.textContent = act.label;
6370
+ b.addEventListener("mousedown", (e) => e.preventDefault());
5789
6371
  b.addEventListener("click", async () => {
5790
6372
  const range = this.savedRange;
5791
6373
  const selected = range?.toString().trim() || "";
@@ -5851,14 +6433,11 @@ var ColorInline = class {
5851
6433
  btn.type = "button";
5852
6434
  btn.className = "ce-inline-tool";
5853
6435
  btn.title = "Text & Highlight Color";
5854
- btn.innerHTML = '<span style="font-weight:700;font-size:12px;border-bottom:2px solid currentColor;">A</span>';
6436
+ 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>';
5855
6437
  return btn;
5856
6438
  }
5857
6439
  surround(range) {
5858
6440
  this.savedRange = range.cloneRange();
5859
- if (this.actionsEl) {
5860
- this.actionsEl.hidden = false;
5861
- }
5862
6441
  }
5863
6442
  applyStyle(prop, value) {
5864
6443
  const range = this.savedRange;
@@ -5886,7 +6465,6 @@ var ColorInline = class {
5886
6465
  renderActions() {
5887
6466
  const wrap = document.createElement("div");
5888
6467
  wrap.className = "ng-inline-color-actions";
5889
- wrap.hidden = true;
5890
6468
  const makeRow = (title, swatches, prop) => {
5891
6469
  const row = document.createElement("div");
5892
6470
  row.className = "ng-inline-swatch-row";
@@ -5901,7 +6479,11 @@ var ColorInline = class {
5901
6479
  dot.title = sw.label;
5902
6480
  dot.style.background = sw.value || "transparent";
5903
6481
  if (!sw.value) dot.textContent = "\xD7";
5904
- dot.addEventListener("click", () => this.applyStyle(prop, sw.value));
6482
+ dot.addEventListener("mousedown", (e) => e.preventDefault());
6483
+ dot.addEventListener("click", (e) => {
6484
+ e.preventDefault();
6485
+ this.applyStyle(prop, sw.value);
6486
+ });
5905
6487
  row.appendChild(dot);
5906
6488
  });
5907
6489
  return row;
@@ -7244,6 +7826,7 @@ function getEditorTools(includeLayout = true, enabledTools) {
7244
7826
  steps: StepsTool,
7245
7827
  diff: DiffTool,
7246
7828
  video: VideoTool,
7829
+ frame: FrameTool,
7247
7830
  changelog: ChangelogTool,
7248
7831
  social: SocialTool,
7249
7832
  excalidraw: ExcalidrawTool,
@@ -7284,8 +7867,21 @@ function getEditorTools(includeLayout = true, enabledTools) {
7284
7867
  };
7285
7868
  if (enabledTools && enabledTools.length > 0) {
7286
7869
  const allowed = new Set(enabledTools);
7870
+ const alwaysKeep = /* @__PURE__ */ new Set([
7871
+ "header",
7872
+ "paragraph",
7873
+ "inlineCode",
7874
+ "marker",
7875
+ "textColor",
7876
+ "aiRewrite",
7877
+ "spoilerInline",
7878
+ "underline",
7879
+ "strikethrough",
7880
+ "hyperlink",
7881
+ "mention"
7882
+ ]);
7287
7883
  return Object.fromEntries(
7288
- Object.entries(tools).filter(([key]) => allowed.has(key))
7884
+ Object.entries(tools).filter(([key]) => allowed.has(key) || alwaysKeep.has(key))
7289
7885
  );
7290
7886
  }
7291
7887
  return tools;
@@ -7354,6 +7950,7 @@ var TOOL_CATEGORIES = [
7354
7950
  "embed",
7355
7951
  "bookmark",
7356
7952
  "video",
7953
+ "frame",
7357
7954
  "attaches",
7358
7955
  "excalidraw"
7359
7956
  ]
@@ -7459,6 +8056,7 @@ var TOOL_LABELS = {
7459
8056
  steps: "Steps Walkthrough",
7460
8057
  diff: "Code Diff",
7461
8058
  video: "Video Player",
8059
+ frame: "Device Frame",
7462
8060
  changelog: "Changelog",
7463
8061
  social: "Social Quote",
7464
8062
  today: "Today Date",
@@ -8339,10 +8937,15 @@ var ExportModal = ({
8339
8937
  onImportBlocks,
8340
8938
  onClose
8341
8939
  }) => {
8940
+ const [activeTab, setActiveTab] = (0, import_react4.useState)("export");
8342
8941
  const [importText, setImportText] = (0, import_react4.useState)("");
8343
8942
  const [copiedKind, setCopiedKind] = (0, import_react4.useState)(null);
8344
8943
  const markdown = (0, import_react4.useMemo)(() => open ? blocksToMarkdown(data) : "", [open, data]);
8345
8944
  const html = (0, import_react4.useMemo)(() => open ? blocksToHtml(data) : "", [open, data]);
8945
+ const parsedCount = (0, import_react4.useMemo)(
8946
+ () => importText.trim() ? markdownToBlocks(importText).length : 0,
8947
+ [importText]
8948
+ );
8346
8949
  if (!open) return null;
8347
8950
  const copyText = async (text, kind) => {
8348
8951
  try {
@@ -8361,98 +8964,156 @@ var ExportModal = ({
8361
8964
  a.click();
8362
8965
  URL.revokeObjectURL(url);
8363
8966
  };
8364
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Export & Import", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal", children: [
8967
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Import & Export", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal ng-modal-wide", children: [
8365
8968
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-head", children: [
8366
8969
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
8367
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { children: "Export & Markdown" }),
8368
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: "Export to Markdown, HTML, PDF, or import Markdown into blocks." })
8970
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { children: "Import & Export" }),
8971
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: "Export your document as Markdown, HTML, or PDF, or import Markdown into blocks." })
8369
8972
  ] }),
8370
8973
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
8371
8974
  ] }),
8372
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-panel", children: [
8373
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-field", children: [
8374
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { children: "Quick Export" }),
8375
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-inline-ai-row", children: [
8376
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8377
- "button",
8378
- {
8379
- type: "button",
8380
- className: "excalidraw-btn",
8381
- onClick: () => void copyText(markdown, "md"),
8382
- children: copiedKind === "md" ? "Copied MD!" : "Copy Markdown"
8383
- }
8384
- ),
8385
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8386
- "button",
8387
- {
8388
- type: "button",
8389
- className: "excalidraw-btn",
8390
- onClick: () => downloadFile(markdown, "document.md", "text/markdown"),
8391
- children: "Download .md"
8392
- }
8393
- ),
8394
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8395
- "button",
8396
- {
8397
- type: "button",
8398
- className: "excalidraw-btn",
8399
- onClick: () => void copyText(html, "html"),
8400
- children: copiedKind === "html" ? "Copied HTML!" : "Copy HTML"
8401
- }
8402
- ),
8403
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8404
- "button",
8405
- {
8406
- type: "button",
8407
- className: "excalidraw-btn",
8408
- onClick: () => downloadFile(
8409
- `<!doctype html><html><head><meta charset="utf-8"><title>Document</title></head><body>${html}</body></html>`,
8410
- "document.html",
8411
- "text/html"
8412
- ),
8413
- children: "Download .html"
8414
- }
8415
- ),
8416
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8417
- "button",
8418
- {
8419
- type: "button",
8420
- className: "excalidraw-btn",
8421
- onClick: () => window.print(),
8422
- children: "Print / PDF"
8423
- }
8424
- )
8425
- ] })
8426
- ] }),
8427
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-field", children: [
8428
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { children: "Import Markdown" }),
8429
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8430
- "textarea",
8431
- {
8432
- className: "editor-mermaid-input",
8433
- rows: 5,
8434
- placeholder: "Paste Markdown here (# Heading, - list, ```mermaid ...```)...",
8435
- value: importText,
8436
- onChange: (e) => setImportText(e.target.value)
8437
- }
8438
- ),
8439
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8440
- "button",
8441
- {
8442
- type: "button",
8443
- className: "excalidraw-btn is-active",
8444
- disabled: !importText.trim(),
8445
- onClick: () => {
8446
- const blocks = markdownToBlocks(importText);
8447
- if (blocks.length > 0) {
8448
- onImportBlocks(blocks);
8449
- setImportText("");
8450
- onClose();
8975
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-layout", children: [
8976
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("aside", { className: "ng-modal-sidebar", role: "tablist", "aria-label": "Import and export sections", children: [
8977
+ { id: "export", label: "Export Document" },
8978
+ { id: "import", label: "Import Markdown" }
8979
+ ].map((t) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8980
+ "button",
8981
+ {
8982
+ type: "button",
8983
+ role: "tab",
8984
+ "aria-selected": activeTab === t.id,
8985
+ className: `ng-modal-tab${activeTab === t.id ? " is-active" : ""}`,
8986
+ onClick: () => setActiveTab(t.id),
8987
+ children: t.label
8988
+ },
8989
+ t.id
8990
+ )) }),
8991
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-main", children: [
8992
+ activeTab === "export" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-panel", children: [
8993
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-export-grid", children: [
8994
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-export-card", children: [
8995
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-export-card-title", children: "Markdown (.md)" }),
8996
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "ng-export-card-desc", children: "Clean GitHub-Flavored Markdown including headings, code, and Mermaid blocks." }),
8997
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-inline-ai-row", children: [
8998
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
8999
+ "button",
9000
+ {
9001
+ type: "button",
9002
+ className: "excalidraw-btn",
9003
+ onClick: () => void copyText(markdown, "md"),
9004
+ children: copiedKind === "md" ? "Copied!" : "Copy MD"
9005
+ }
9006
+ ),
9007
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9008
+ "button",
9009
+ {
9010
+ type: "button",
9011
+ className: "excalidraw-btn is-active",
9012
+ onClick: () => downloadFile(markdown, "document.md", "text/markdown"),
9013
+ children: "Download .md"
9014
+ }
9015
+ )
9016
+ ] })
9017
+ ] }),
9018
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-export-card", children: [
9019
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-export-card-title", children: "HTML (.html)" }),
9020
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "ng-export-card-desc", children: "Sanitized semantic HTML ready for blogs, emails, or static sites." }),
9021
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-inline-ai-row", children: [
9022
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9023
+ "button",
9024
+ {
9025
+ type: "button",
9026
+ className: "excalidraw-btn",
9027
+ onClick: () => void copyText(html, "html"),
9028
+ children: copiedKind === "html" ? "Copied!" : "Copy HTML"
9029
+ }
9030
+ ),
9031
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9032
+ "button",
9033
+ {
9034
+ type: "button",
9035
+ className: "excalidraw-btn is-active",
9036
+ onClick: () => downloadFile(
9037
+ `<!doctype html><html><head><meta charset="utf-8"><title>Document</title></head><body>${html}</body></html>`,
9038
+ "document.html",
9039
+ "text/html"
9040
+ ),
9041
+ children: "Download .html"
9042
+ }
9043
+ )
9044
+ ] })
9045
+ ] }),
9046
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-export-card", children: [
9047
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-export-card-title", children: "Print / Save as PDF" }),
9048
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "ng-export-card-desc", children: "Open the browser print dialog to save a formatted PDF copy." }),
9049
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-inline-ai-row", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9050
+ "button",
9051
+ {
9052
+ type: "button",
9053
+ className: "excalidraw-btn",
9054
+ onClick: () => window.print(),
9055
+ children: "Print / PDF"
9056
+ }
9057
+ ) })
9058
+ ] })
9059
+ ] }),
9060
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-field", children: [
9061
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { children: "Markdown Preview" }),
9062
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "ng-export-preview", children: markdown || "(Empty document)" })
9063
+ ] })
9064
+ ] }),
9065
+ activeTab === "import" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-panel", children: [
9066
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-field", children: [
9067
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
9068
+ "Paste Markdown (",
9069
+ parsedCount,
9070
+ " blocks detected)"
9071
+ ] }),
9072
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9073
+ "textarea",
9074
+ {
9075
+ className: "editor-mermaid-input",
9076
+ rows: 10,
9077
+ placeholder: "Paste Markdown here (# Heading, - list, > quote, ```mermaid ...```)...",
9078
+ value: importText,
9079
+ onChange: (e) => setImportText(e.target.value)
8451
9080
  }
8452
- },
8453
- children: "Append Markdown as Blocks"
8454
- }
8455
- ) })
9081
+ )
9082
+ ] }),
9083
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-inline-ai-row", children: [
9084
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
9085
+ "button",
9086
+ {
9087
+ type: "button",
9088
+ className: "excalidraw-btn is-active",
9089
+ disabled: parsedCount === 0,
9090
+ onClick: () => {
9091
+ const blocks = markdownToBlocks(importText);
9092
+ if (blocks.length > 0) {
9093
+ onImportBlocks(blocks);
9094
+ setImportText("");
9095
+ onClose();
9096
+ }
9097
+ },
9098
+ children: [
9099
+ "Append ",
9100
+ parsedCount || "",
9101
+ " Blocks to Editor"
9102
+ ]
9103
+ }
9104
+ ),
9105
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
9106
+ "button",
9107
+ {
9108
+ type: "button",
9109
+ className: "excalidraw-btn",
9110
+ disabled: !importText,
9111
+ onClick: () => setImportText(""),
9112
+ children: "Clear"
9113
+ }
9114
+ )
9115
+ ] })
9116
+ ] })
8456
9117
  ] })
8457
9118
  ] })
8458
9119
  ] }) });
@@ -9748,6 +10409,46 @@ function useInteractiveArticle(containerRef, depKey) {
9748
10409
  void renderMermaidInto(el, code);
9749
10410
  }
9750
10411
  });
10412
+ const pinnableSelectors = [
10413
+ ".editor-video-block",
10414
+ ".editor-embed-wrap",
10415
+ ".editor-chart-block",
10416
+ ".editor-mermaid-block",
10417
+ ".editor-audio-card",
10418
+ ".editor-code-block",
10419
+ ".editor-diff-block",
10420
+ ".editor-frame-block"
10421
+ ].join(",");
10422
+ root.querySelectorAll(pinnableSelectors).forEach((blockEl) => {
10423
+ if (blockEl.querySelector(".ng-pin-btn")) return;
10424
+ blockEl.classList.add("ng-pinnable");
10425
+ const pinBtn = document.createElement("button");
10426
+ pinBtn.type = "button";
10427
+ pinBtn.className = "ng-pin-btn";
10428
+ pinBtn.textContent = "\u{1F4CC} Pin";
10429
+ pinBtn.title = "Pin as floating window while scrolling";
10430
+ const onPin = (e) => {
10431
+ e.preventDefault();
10432
+ e.stopPropagation();
10433
+ const isPinned = blockEl.classList.contains("is-pinned-floating");
10434
+ root.querySelectorAll(".is-pinned-floating").forEach((other) => {
10435
+ other.classList.remove("is-pinned-floating");
10436
+ const b = other.querySelector(".ng-pin-btn");
10437
+ if (b) b.textContent = "\u{1F4CC} Pin";
10438
+ });
10439
+ if (!isPinned) {
10440
+ blockEl.classList.add("is-pinned-floating");
10441
+ pinBtn.textContent = "\u2715 Unpin";
10442
+ }
10443
+ };
10444
+ pinBtn.addEventListener("click", onPin);
10445
+ blockEl.appendChild(pinBtn);
10446
+ cleanups.push(() => {
10447
+ pinBtn.removeEventListener("click", onPin);
10448
+ pinBtn.remove();
10449
+ blockEl.classList.remove("ng-pinnable", "is-pinned-floating");
10450
+ });
10451
+ });
9751
10452
  return () => {
9752
10453
  cleanups.forEach((fn) => fn());
9753
10454
  };