nextgen-block-editor 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2114 -545
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +2101 -534
- package/dist/styles.css +550 -78
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -34,8 +34,10 @@ __export(index_exports, {
|
|
|
34
34
|
BlockRenderer: () => BlockRenderer,
|
|
35
35
|
DocumentHeader: () => DocumentHeader,
|
|
36
36
|
blocksToHtml: () => blocksToHtml,
|
|
37
|
+
blocksToMarkdown: () => blocksToMarkdown,
|
|
37
38
|
escHtml: () => escHtml,
|
|
38
39
|
getEditorTools: () => getEditorTools,
|
|
40
|
+
markdownToBlocks: () => markdownToBlocks,
|
|
39
41
|
sanitizeInlineHtml: () => sanitizeInlineHtml,
|
|
40
42
|
slugify: () => slugify,
|
|
41
43
|
uploadFileToBucket: () => uploadFileToBucket,
|
|
@@ -44,7 +46,7 @@ __export(index_exports, {
|
|
|
44
46
|
module.exports = __toCommonJS(index_exports);
|
|
45
47
|
|
|
46
48
|
// src/components/BlockEditor.tsx
|
|
47
|
-
var
|
|
49
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
48
50
|
var import_editorjs2 = __toESM(require("@editorjs/editorjs"), 1);
|
|
49
51
|
var import_editorjs_drag_drop = __toESM(require("editorjs-drag-drop"), 1);
|
|
50
52
|
var import_editorjs_undo = __toESM(require("editorjs-undo"), 1);
|
|
@@ -297,7 +299,7 @@ function sanitizeInlineHtml(value) {
|
|
|
297
299
|
element.replaceWith(document.createTextNode(element.textContent || ""));
|
|
298
300
|
return;
|
|
299
301
|
}
|
|
300
|
-
if (element.tagName === "SPAN" && !element.classList.contains("editor-inline-spoiler")) {
|
|
302
|
+
if (element.tagName === "SPAN" && !element.classList.contains("editor-inline-spoiler") && !element.classList.contains("ng-inline-color")) {
|
|
301
303
|
element.replaceWith(document.createTextNode(element.textContent || ""));
|
|
302
304
|
return;
|
|
303
305
|
}
|
|
@@ -306,7 +308,10 @@ function sanitizeInlineHtml(value) {
|
|
|
306
308
|
if (element.tagName === "A" && attribute.name === "class" && attribute.value === "editor-mention") {
|
|
307
309
|
return;
|
|
308
310
|
}
|
|
309
|
-
if (element.tagName === "SPAN" && attribute.name === "class" && attribute.value === "editor-inline-spoiler") {
|
|
311
|
+
if (element.tagName === "SPAN" && attribute.name === "class" && (attribute.value === "editor-inline-spoiler" || attribute.value === "ng-inline-color")) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
if (element.tagName === "SPAN" && element.classList.contains("ng-inline-color") && attribute.name === "style") {
|
|
310
315
|
return;
|
|
311
316
|
}
|
|
312
317
|
if (["target", "rel"].includes(attribute.name) && element.tagName === "A") return;
|
|
@@ -590,9 +595,12 @@ function blocksToHtml(data) {
|
|
|
590
595
|
}).join("") + "</div>";
|
|
591
596
|
}
|
|
592
597
|
if (block.type === "embed") {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
598
|
+
if (!d.embed) return "";
|
|
599
|
+
const align = ["left", "center", "right"].includes(d.align) ? d.align : "center";
|
|
600
|
+
const size = ["small", "medium", "large", "full"].includes(d.size) ? d.size : "medium";
|
|
601
|
+
return `<div class="editor-embed-wrap" data-align="${align}" data-size="${size}"><iframe src="${escHtml(
|
|
602
|
+
d.embed
|
|
603
|
+
)}" title="${escHtml(d.caption)}" loading="lazy" allowfullscreen></iframe></div>`;
|
|
596
604
|
}
|
|
597
605
|
if (block.type === "attaches") {
|
|
598
606
|
const attachmentUrl = d.file && d.file.url ? d.file.url : d.dataUrl || "";
|
|
@@ -642,6 +650,85 @@ function blocksToHtml(data) {
|
|
|
642
650
|
d.text || ""
|
|
643
651
|
)}</div></div>${overlay}</div>`;
|
|
644
652
|
}
|
|
653
|
+
if (block.type === "mermaid") {
|
|
654
|
+
const code = String(d.code || "");
|
|
655
|
+
const caption = d.caption ? `<figcaption>${escHtml(d.caption)}</figcaption>` : "";
|
|
656
|
+
return `<figure class="editor-mermaid-block"><div class="editor-mermaid-diagram" data-mermaid="${escHtml(
|
|
657
|
+
code
|
|
658
|
+
)}"><pre class="editor-mermaid-fallback">${escHtml(code)}</pre></div>${caption}</figure>`;
|
|
659
|
+
}
|
|
660
|
+
if (block.type === "bookmark") {
|
|
661
|
+
const url = String(d.url || "#");
|
|
662
|
+
let host = url;
|
|
663
|
+
try {
|
|
664
|
+
host = new URL(url).hostname;
|
|
665
|
+
} catch {
|
|
666
|
+
}
|
|
667
|
+
return `<a class="editor-bookmark-card" href="${escHtml(
|
|
668
|
+
url
|
|
669
|
+
)}" target="_blank" rel="noopener noreferrer"><div class="editor-bookmark-body"><div class="editor-bookmark-title">${escHtml(
|
|
670
|
+
d.title || host
|
|
671
|
+
)}</div>${d.description ? `<div class="editor-bookmark-desc">${escHtml(d.description)}</div>` : ""}<div class="editor-bookmark-url">${escHtml(host)}</div></div>${d.image ? `<img class="editor-bookmark-thumb" src="${escHtml(d.image)}" alt="" loading="lazy">` : ""}</a>`;
|
|
672
|
+
}
|
|
673
|
+
if (block.type === "steps") {
|
|
674
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
675
|
+
return `<ol class="editor-steps-list">${items.map(
|
|
676
|
+
(item, idx) => `<li class="editor-step-item"><div class="editor-step-badge">${idx + 1}</div><div class="editor-step-content"><h4>${escHtml(
|
|
677
|
+
item.title || `Step ${idx + 1}`
|
|
678
|
+
)}</h4><p>${escHtml(item.body || "")}</p></div></li>`
|
|
679
|
+
).join("")}</ol>`;
|
|
680
|
+
}
|
|
681
|
+
if (block.type === "diff") {
|
|
682
|
+
const before = String(d.before || "").split("\n");
|
|
683
|
+
const after = String(d.after || "").split("\n");
|
|
684
|
+
const max = Math.max(before.length, after.length);
|
|
685
|
+
const rows = [];
|
|
686
|
+
for (let i = 0; i < max; i += 1) {
|
|
687
|
+
if (before[i] === after[i]) {
|
|
688
|
+
if (before[i] !== void 0) {
|
|
689
|
+
rows.push(`<span class="editor-diff-line is-same"> ${escHtml(before[i])}</span>`);
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
if (before[i] !== void 0) {
|
|
693
|
+
rows.push(`<span class="editor-diff-line is-del">- ${escHtml(before[i])}</span>`);
|
|
694
|
+
}
|
|
695
|
+
if (after[i] !== void 0) {
|
|
696
|
+
rows.push(`<span class="editor-diff-line is-add">+ ${escHtml(after[i])}</span>`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
return `<div class="editor-diff-block">${d.filename ? `<div class="editor-diff-filename">${escHtml(d.filename)}</div>` : ""}<pre class="editor-diff-preview">${rows.join("\n")}</pre></div>`;
|
|
701
|
+
}
|
|
702
|
+
if (block.type === "video") {
|
|
703
|
+
if (!d.url) return "";
|
|
704
|
+
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
|
+
}
|
|
706
|
+
if (block.type === "changelog") {
|
|
707
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
708
|
+
return `<section class="editor-changelog-block"><div class="editor-changelog-head"><span class="editor-changelog-version">${escHtml(
|
|
709
|
+
d.version || "v1.0.0"
|
|
710
|
+
)}</span><span class="editor-changelog-date">${escHtml(
|
|
711
|
+
d.date || ""
|
|
712
|
+
)}</span></div><ul class="editor-changelog-list">${items.map(
|
|
713
|
+
(i) => `<li><span class="editor-changelog-badge is-${escHtml(
|
|
714
|
+
i.kind || "added"
|
|
715
|
+
)}">${escHtml((i.kind || "added").toUpperCase())}</span><span>${escHtml(
|
|
716
|
+
i.text || ""
|
|
717
|
+
)}</span></li>`
|
|
718
|
+
).join("")}</ul></section>`;
|
|
719
|
+
}
|
|
720
|
+
if (block.type === "today") {
|
|
721
|
+
return `<div class="editor-today-pill"><span class="editor-today-badge">\u{1F4C5} ${escHtml(
|
|
722
|
+
d.date || ""
|
|
723
|
+
)}</span></div>`;
|
|
724
|
+
}
|
|
725
|
+
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>`;
|
|
731
|
+
}
|
|
645
732
|
if (block.type === "alert") {
|
|
646
733
|
const variant = ["info", "tip", "warning", "danger"].includes(d.variant) ? d.variant : "info";
|
|
647
734
|
const icons = {
|
|
@@ -4888,203 +4975,1221 @@ var TagsTool = class {
|
|
|
4888
4975
|
}
|
|
4889
4976
|
};
|
|
4890
4977
|
|
|
4891
|
-
// src/
|
|
4892
|
-
var
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
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, "<")}</pre>`;
|
|
4897
5024
|
}
|
|
5025
|
+
}
|
|
5026
|
+
var MermaidTool = class {
|
|
5027
|
+
data;
|
|
5028
|
+
renderSeq = 0;
|
|
4898
5029
|
static get toolbox() {
|
|
4899
5030
|
return {
|
|
4900
|
-
title: "
|
|
4901
|
-
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="
|
|
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>'
|
|
5033
|
+
};
|
|
5034
|
+
}
|
|
5035
|
+
constructor({ data }) {
|
|
5036
|
+
this.data = {
|
|
5037
|
+
code: data?.code ?? MERMAID_PRESETS.Flowchart,
|
|
5038
|
+
caption: data?.caption ?? ""
|
|
4902
5039
|
};
|
|
4903
5040
|
}
|
|
4904
5041
|
render() {
|
|
4905
|
-
const
|
|
4906
|
-
|
|
4907
|
-
const
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
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;
|
|
4918
5069
|
const preview = document.createElement("div");
|
|
4919
|
-
preview.className = "
|
|
4920
|
-
const
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
const
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
if (bucketUrl) {
|
|
4930
|
-
input.value = bucketUrl;
|
|
4931
|
-
paint(bucketUrl);
|
|
4932
|
-
return;
|
|
4933
|
-
}
|
|
4934
|
-
const reader = new FileReader();
|
|
4935
|
-
reader.onload = () => {
|
|
4936
|
-
const res = String(reader.result || "");
|
|
4937
|
-
input.value = res;
|
|
4938
|
-
paint(res);
|
|
4939
|
-
};
|
|
4940
|
-
reader.readAsDataURL(selected);
|
|
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;
|
|
4941
5080
|
};
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
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;
|
|
4945
5091
|
}
|
|
4946
5092
|
save() {
|
|
4947
5093
|
return {
|
|
4948
|
-
|
|
4949
|
-
caption: this.
|
|
5094
|
+
code: this.data.code,
|
|
5095
|
+
caption: this.data.caption?.trim() || void 0
|
|
4950
5096
|
};
|
|
4951
5097
|
}
|
|
4952
5098
|
};
|
|
4953
|
-
|
|
5099
|
+
|
|
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 {
|
|
4954
5120
|
data;
|
|
4955
|
-
elements;
|
|
4956
|
-
constructor(options) {
|
|
4957
|
-
this.data = options.data || {};
|
|
4958
|
-
}
|
|
4959
5121
|
static get toolbox() {
|
|
4960
5122
|
return {
|
|
4961
|
-
title: "
|
|
4962
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
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 ?? ""
|
|
4963
5133
|
};
|
|
4964
5134
|
}
|
|
4965
5135
|
render() {
|
|
4966
|
-
const
|
|
4967
|
-
|
|
4968
|
-
const
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
searchInput.type = "search";
|
|
4972
|
-
searchInput.placeholder = "Search free GIFs (trending or keyword)...";
|
|
4973
|
-
const searchBtn = document.createElement("button");
|
|
4974
|
-
searchBtn.type = "button";
|
|
4975
|
-
searchBtn.className = "b2";
|
|
4976
|
-
searchBtn.textContent = "Search";
|
|
4977
|
-
searchRow.append(searchInput, searchBtn);
|
|
4978
|
-
const resultsGrid = document.createElement("div");
|
|
4979
|
-
resultsGrid.className = "gif-picker-grid";
|
|
4980
|
-
const url = document.createElement("input");
|
|
4981
|
-
url.type = "url";
|
|
4982
|
-
url.placeholder = "Or paste GIF / image URL";
|
|
4983
|
-
url.value = this.data.url || "";
|
|
4984
|
-
const caption = document.createElement("input");
|
|
4985
|
-
caption.type = "text";
|
|
4986
|
-
caption.placeholder = "Caption";
|
|
4987
|
-
caption.value = this.data.caption || "";
|
|
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";
|
|
4988
5141
|
const preview = document.createElement("div");
|
|
4989
|
-
preview.className = "
|
|
4990
|
-
const
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
resultsGrid.innerHTML = '<span class="gif-picker-status">Loading GIFs\u2026</span>';
|
|
4997
|
-
try {
|
|
4998
|
-
const res = await fetch(
|
|
4999
|
-
`/api/gifs?q=${encodeURIComponent(query)}&limit=12`
|
|
5000
|
-
);
|
|
5001
|
-
const json = await res.json();
|
|
5002
|
-
const items = json.results || [];
|
|
5003
|
-
if (!items.length) {
|
|
5004
|
-
resultsGrid.innerHTML = '<span class="gif-picker-status">No GIFs found. Try another keyword or paste a URL below.</span>';
|
|
5005
|
-
return;
|
|
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";
|
|
5006
5149
|
}
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
paint();
|
|
5018
|
-
};
|
|
5019
|
-
resultsGrid.appendChild(btn);
|
|
5020
|
-
});
|
|
5021
|
-
} catch {
|
|
5022
|
-
resultsGrid.innerHTML = '<span class="gif-picker-status">Could not load GIFs. Paste a GIF URL below.</span>';
|
|
5023
|
-
}
|
|
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>`;
|
|
5024
5160
|
};
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
}
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
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;
|
|
5039
5184
|
}
|
|
5040
5185
|
save() {
|
|
5041
5186
|
return {
|
|
5042
|
-
url: this.
|
|
5043
|
-
|
|
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
|
|
5044
5191
|
};
|
|
5045
5192
|
}
|
|
5046
5193
|
};
|
|
5047
|
-
var
|
|
5194
|
+
var StepsTool = class {
|
|
5048
5195
|
data;
|
|
5049
|
-
elements;
|
|
5050
|
-
constructor(options) {
|
|
5051
|
-
this.data = options.data || {};
|
|
5052
|
-
}
|
|
5053
5196
|
static get toolbox() {
|
|
5054
5197
|
return {
|
|
5055
|
-
title: "
|
|
5056
|
-
icon: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><
|
|
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>'
|
|
5057
5200
|
};
|
|
5058
5201
|
}
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
name.type = "text";
|
|
5066
|
-
name.placeholder = "Attachment label";
|
|
5067
|
-
name.value = this.data.name || "";
|
|
5068
|
-
root.append(file, name);
|
|
5069
|
-
const elements = {
|
|
5070
|
-
file,
|
|
5071
|
-
name,
|
|
5072
|
-
dataUrl: this.data.dataUrl || "",
|
|
5073
|
-
dataName: this.data.name || ""
|
|
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
|
+
]
|
|
5074
5208
|
};
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5209
|
+
}
|
|
5210
|
+
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";
|
|
5216
|
+
const list = document.createElement("div");
|
|
5217
|
+
list.className = "editor-steps-editor-list";
|
|
5218
|
+
const renderList = () => {
|
|
5219
|
+
list.innerHTML = "";
|
|
5220
|
+
this.data.items.forEach((item, idx) => {
|
|
5221
|
+
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);
|
|
5247
|
+
list.appendChild(row);
|
|
5248
|
+
});
|
|
5086
5249
|
};
|
|
5087
|
-
|
|
5250
|
+
const addBtn = document.createElement("button");
|
|
5251
|
+
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;
|
|
5261
|
+
}
|
|
5262
|
+
save() {
|
|
5263
|
+
return {
|
|
5264
|
+
items: this.data.items.filter((i) => i.title.trim() || i.body.trim())
|
|
5265
|
+
};
|
|
5266
|
+
}
|
|
5267
|
+
};
|
|
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 {
|
|
5286
|
+
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>'
|
|
5291
|
+
};
|
|
5292
|
+
}
|
|
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";'
|
|
5298
|
+
};
|
|
5299
|
+
}
|
|
5300
|
+
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");
|
|
5314
|
+
};
|
|
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;
|
|
5333
|
+
}
|
|
5334
|
+
save() {
|
|
5335
|
+
return {
|
|
5336
|
+
filename: this.data.filename?.trim() || void 0,
|
|
5337
|
+
before: this.data.before,
|
|
5338
|
+
after: this.data.after
|
|
5339
|
+
};
|
|
5340
|
+
}
|
|
5341
|
+
};
|
|
5342
|
+
var VideoTool = class {
|
|
5343
|
+
data;
|
|
5344
|
+
static get toolbox() {
|
|
5345
|
+
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>'
|
|
5348
|
+
};
|
|
5349
|
+
}
|
|
5350
|
+
constructor({ data }) {
|
|
5351
|
+
this.data = {
|
|
5352
|
+
url: data?.url ?? "",
|
|
5353
|
+
poster: data?.poster ?? "",
|
|
5354
|
+
caption: data?.caption ?? ""
|
|
5355
|
+
};
|
|
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>`;
|
|
5371
|
+
};
|
|
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;
|
|
5400
|
+
}
|
|
5401
|
+
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
|
+
};
|
|
5407
|
+
}
|
|
5408
|
+
};
|
|
5409
|
+
var ChangelogTool = class {
|
|
5410
|
+
data;
|
|
5411
|
+
static get toolbox() {
|
|
5412
|
+
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" }]
|
|
5422
|
+
};
|
|
5423
|
+
}
|
|
5424
|
+
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
|
+
);
|
|
5440
|
+
const list = document.createElement("div");
|
|
5441
|
+
list.className = "editor-steps-editor-list";
|
|
5442
|
+
const renderItems = () => {
|
|
5443
|
+
list.innerHTML = "";
|
|
5444
|
+
this.data.items.forEach((item, idx) => {
|
|
5445
|
+
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) => {
|
|
5450
|
+
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();
|
|
5470
|
+
});
|
|
5471
|
+
row.append(select, text, del);
|
|
5472
|
+
list.appendChild(row);
|
|
5473
|
+
});
|
|
5474
|
+
};
|
|
5475
|
+
const addBtn = document.createElement("button");
|
|
5476
|
+
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;
|
|
5486
|
+
}
|
|
5487
|
+
save() {
|
|
5488
|
+
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())
|
|
5492
|
+
};
|
|
5493
|
+
}
|
|
5494
|
+
};
|
|
5495
|
+
var SocialTool = class {
|
|
5496
|
+
data;
|
|
5497
|
+
static get toolbox() {
|
|
5498
|
+
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>'
|
|
5501
|
+
};
|
|
5502
|
+
}
|
|
5503
|
+
constructor({ data }) {
|
|
5504
|
+
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 ?? ""
|
|
5510
|
+
};
|
|
5511
|
+
}
|
|
5512
|
+
render() {
|
|
5513
|
+
const wrap = document.createElement("div");
|
|
5514
|
+
wrap.className = "editor-extra-card";
|
|
5515
|
+
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;
|
|
5530
|
+
});
|
|
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);
|
|
5542
|
+
return wrap;
|
|
5543
|
+
}
|
|
5544
|
+
save() {
|
|
5545
|
+
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
|
|
5551
|
+
};
|
|
5552
|
+
}
|
|
5553
|
+
};
|
|
5554
|
+
|
|
5555
|
+
// src/utils/aiClient.ts
|
|
5556
|
+
var AI_PROVIDER_PRESETS = [
|
|
5557
|
+
{
|
|
5558
|
+
id: "openai",
|
|
5559
|
+
label: "OpenAI (ChatGPT)",
|
|
5560
|
+
defaultModel: "gpt-4o-mini",
|
|
5561
|
+
defaultEndpoint: "https://api.openai.com/v1/chat/completions"
|
|
5562
|
+
},
|
|
5563
|
+
{
|
|
5564
|
+
id: "codex",
|
|
5565
|
+
label: "OpenAI Codex",
|
|
5566
|
+
defaultModel: "codex-mini-latest",
|
|
5567
|
+
defaultEndpoint: "https://api.openai.com/v1/chat/completions"
|
|
5568
|
+
},
|
|
5569
|
+
{
|
|
5570
|
+
id: "openrouter",
|
|
5571
|
+
label: "OpenRouter",
|
|
5572
|
+
defaultModel: "openai/gpt-4o-mini",
|
|
5573
|
+
defaultEndpoint: "https://openrouter.ai/api/v1/chat/completions"
|
|
5574
|
+
},
|
|
5575
|
+
{
|
|
5576
|
+
id: "opencode",
|
|
5577
|
+
label: "OpenCode",
|
|
5578
|
+
defaultModel: "opencode/default",
|
|
5579
|
+
defaultEndpoint: "https://api.opencode.ai/v1/chat/completions"
|
|
5580
|
+
},
|
|
5581
|
+
{
|
|
5582
|
+
id: "anthropic",
|
|
5583
|
+
label: "Anthropic (Claude)",
|
|
5584
|
+
defaultModel: "claude-3-5-sonnet-latest",
|
|
5585
|
+
defaultEndpoint: "https://api.anthropic.com/v1/messages"
|
|
5586
|
+
},
|
|
5587
|
+
{
|
|
5588
|
+
id: "gemini",
|
|
5589
|
+
label: "Google Gemini",
|
|
5590
|
+
defaultModel: "gemini-2.5-flash",
|
|
5591
|
+
defaultEndpoint: "https://generativelanguage.googleapis.com/v1beta/models"
|
|
5592
|
+
},
|
|
5593
|
+
{
|
|
5594
|
+
id: "custom",
|
|
5595
|
+
label: "Custom OpenAI-Compatible",
|
|
5596
|
+
defaultModel: "gpt-4o-mini",
|
|
5597
|
+
defaultEndpoint: "http://localhost:11434/v1/chat/completions"
|
|
5598
|
+
}
|
|
5599
|
+
];
|
|
5600
|
+
var AI_STORAGE_KEY = "nextgen-editor-ai-config";
|
|
5601
|
+
function loadAiConfig() {
|
|
5602
|
+
try {
|
|
5603
|
+
const raw = localStorage.getItem(AI_STORAGE_KEY);
|
|
5604
|
+
if (raw) {
|
|
5605
|
+
const parsed = JSON.parse(raw);
|
|
5606
|
+
if (parsed.provider) {
|
|
5607
|
+
return {
|
|
5608
|
+
provider: parsed.provider,
|
|
5609
|
+
model: parsed.model || "gpt-4o-mini",
|
|
5610
|
+
apiKey: parsed.apiKey || "",
|
|
5611
|
+
endpoint: parsed.endpoint || ""
|
|
5612
|
+
};
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
} catch {
|
|
5616
|
+
}
|
|
5617
|
+
return {
|
|
5618
|
+
provider: "openai",
|
|
5619
|
+
model: "gpt-4o-mini",
|
|
5620
|
+
apiKey: "",
|
|
5621
|
+
endpoint: ""
|
|
5622
|
+
};
|
|
5623
|
+
}
|
|
5624
|
+
function saveAiConfig(cfg) {
|
|
5625
|
+
try {
|
|
5626
|
+
localStorage.setItem(AI_STORAGE_KEY, JSON.stringify(cfg));
|
|
5627
|
+
} catch {
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
async function generateAiText(params) {
|
|
5631
|
+
const { config, mode, prompt, context } = params;
|
|
5632
|
+
const preset = AI_PROVIDER_PRESETS.find((p) => p.id === config.provider) || AI_PROVIDER_PRESETS[0];
|
|
5633
|
+
const endpoint = (config.endpoint || preset.defaultEndpoint).trim();
|
|
5634
|
+
const model = (config.model || preset.defaultModel).trim();
|
|
5635
|
+
const apiKey = config.apiKey.trim();
|
|
5636
|
+
if (!apiKey && config.provider !== "custom") {
|
|
5637
|
+
throw new Error("Please add an API key in Settings first.");
|
|
5638
|
+
}
|
|
5639
|
+
const systemPrompt = mode === "continue" ? "You are a concise writing assistant inside a block editor. Continue the document naturally from the provided context in 1-3 clear paragraphs. Return only the continuation text." : "You are a helpful writing and editing assistant inside a block editor. Fulfill the user request concisely using the provided document context.";
|
|
5640
|
+
const userContent = mode === "continue" ? `Document context:
|
|
5641
|
+
${context || "(Empty document)"}
|
|
5642
|
+
|
|
5643
|
+
Continue writing naturally:` : `Document context:
|
|
5644
|
+
${context || "(Empty document)"}
|
|
5645
|
+
|
|
5646
|
+
User request: ${prompt}`;
|
|
5647
|
+
if (config.provider === "gemini") {
|
|
5648
|
+
const url = `${endpoint.replace(/\/$/, "")}/${encodeURIComponent(
|
|
5649
|
+
model
|
|
5650
|
+
)}:generateContent?key=${encodeURIComponent(apiKey)}`;
|
|
5651
|
+
const res2 = await fetch(url, {
|
|
5652
|
+
method: "POST",
|
|
5653
|
+
headers: { "Content-Type": "application/json" },
|
|
5654
|
+
body: JSON.stringify({
|
|
5655
|
+
contents: [{ parts: [{ text: `${systemPrompt}
|
|
5656
|
+
|
|
5657
|
+
${userContent}` }] }]
|
|
5658
|
+
})
|
|
5659
|
+
});
|
|
5660
|
+
if (!res2.ok) throw new Error(`Gemini API error (${res2.status})`);
|
|
5661
|
+
const json2 = await res2.json();
|
|
5662
|
+
return json2.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || "";
|
|
5663
|
+
}
|
|
5664
|
+
if (config.provider === "anthropic") {
|
|
5665
|
+
const res2 = await fetch(endpoint, {
|
|
5666
|
+
method: "POST",
|
|
5667
|
+
headers: {
|
|
5668
|
+
"Content-Type": "application/json",
|
|
5669
|
+
"x-api-key": apiKey,
|
|
5670
|
+
"anthropic-version": "2023-06-01"
|
|
5671
|
+
},
|
|
5672
|
+
body: JSON.stringify({
|
|
5673
|
+
model,
|
|
5674
|
+
max_tokens: 1024,
|
|
5675
|
+
system: systemPrompt,
|
|
5676
|
+
messages: [{ role: "user", content: userContent }]
|
|
5677
|
+
})
|
|
5678
|
+
});
|
|
5679
|
+
if (!res2.ok) throw new Error(`Anthropic API error (${res2.status})`);
|
|
5680
|
+
const json2 = await res2.json();
|
|
5681
|
+
return json2.content?.[0]?.text?.trim() || "";
|
|
5682
|
+
}
|
|
5683
|
+
const headers = {
|
|
5684
|
+
"Content-Type": "application/json"
|
|
5685
|
+
};
|
|
5686
|
+
if (apiKey) {
|
|
5687
|
+
headers.Authorization = `Bearer ${apiKey}`;
|
|
5688
|
+
}
|
|
5689
|
+
const res = await fetch(endpoint, {
|
|
5690
|
+
method: "POST",
|
|
5691
|
+
headers,
|
|
5692
|
+
body: JSON.stringify({
|
|
5693
|
+
model,
|
|
5694
|
+
messages: [
|
|
5695
|
+
{ role: "system", content: systemPrompt },
|
|
5696
|
+
{ role: "user", content: userContent }
|
|
5697
|
+
]
|
|
5698
|
+
})
|
|
5699
|
+
});
|
|
5700
|
+
if (!res.ok) throw new Error(`AI API error (${res.status})`);
|
|
5701
|
+
const json = await res.json();
|
|
5702
|
+
return json.choices?.[0]?.message?.content?.trim() || "";
|
|
5703
|
+
}
|
|
5704
|
+
|
|
5705
|
+
// src/blocks/inlineExtensions.ts
|
|
5706
|
+
var TEXT_COLOR_SWATCHES = [
|
|
5707
|
+
{ label: "Default", value: "" },
|
|
5708
|
+
{ label: "Gray", value: "#71717a" },
|
|
5709
|
+
{ label: "Red", value: "#dc2626" },
|
|
5710
|
+
{ label: "Amber", value: "#d97706" },
|
|
5711
|
+
{ label: "Green", value: "#16a34a" },
|
|
5712
|
+
{ label: "Blue", value: "#2563eb" },
|
|
5713
|
+
{ label: "Purple", value: "#9333ea" }
|
|
5714
|
+
];
|
|
5715
|
+
var HIGHLIGHT_SWATCHES = [
|
|
5716
|
+
{ label: "None", value: "" },
|
|
5717
|
+
{ label: "Yellow", value: "rgba(250, 204, 21, 0.35)" },
|
|
5718
|
+
{ label: "Green", value: "rgba(74, 222, 128, 0.3)" },
|
|
5719
|
+
{ label: "Blue", value: "rgba(96, 165, 250, 0.3)" },
|
|
5720
|
+
{ label: "Pink", value: "rgba(244, 114, 182, 0.3)" },
|
|
5721
|
+
{ label: "Gray", value: "rgba(161, 161, 170, 0.28)" }
|
|
5722
|
+
];
|
|
5723
|
+
var REWRITE_ACTIONS = [
|
|
5724
|
+
{
|
|
5725
|
+
id: "improve",
|
|
5726
|
+
label: "Improve",
|
|
5727
|
+
prompt: "Rewrite the following text to be clearer, smoother, and more engaging. Return only the rewritten text."
|
|
5728
|
+
},
|
|
5729
|
+
{
|
|
5730
|
+
id: "shorten",
|
|
5731
|
+
label: "Shorten",
|
|
5732
|
+
prompt: "Make the following text more concise while preserving its core meaning. Return only the shortened text."
|
|
5733
|
+
},
|
|
5734
|
+
{
|
|
5735
|
+
id: "grammar",
|
|
5736
|
+
label: "Fix Grammar",
|
|
5737
|
+
prompt: "Fix any spelling, punctuation, or grammar mistakes in the following text. Return only the corrected text."
|
|
5738
|
+
},
|
|
5739
|
+
{
|
|
5740
|
+
id: "professional",
|
|
5741
|
+
label: "Professional",
|
|
5742
|
+
prompt: "Rewrite the following text in a polished, professional tone. Return only the rewritten text."
|
|
5743
|
+
},
|
|
5744
|
+
{
|
|
5745
|
+
id: "translate",
|
|
5746
|
+
label: "Translate (ES)",
|
|
5747
|
+
prompt: "Translate the following text into natural Spanish. Return only the translated text."
|
|
5748
|
+
}
|
|
5749
|
+
];
|
|
5750
|
+
var AiRewriteInline = class {
|
|
5751
|
+
savedRange = null;
|
|
5752
|
+
actionsEl = null;
|
|
5753
|
+
static get isInline() {
|
|
5754
|
+
return true;
|
|
5755
|
+
}
|
|
5756
|
+
static get title() {
|
|
5757
|
+
return "AI Rewrite";
|
|
5758
|
+
}
|
|
5759
|
+
static get sanitize() {
|
|
5760
|
+
return {};
|
|
5761
|
+
}
|
|
5762
|
+
render() {
|
|
5763
|
+
const btn = document.createElement("button");
|
|
5764
|
+
btn.type = "button";
|
|
5765
|
+
btn.className = "ce-inline-tool";
|
|
5766
|
+
btn.title = "AI Rewrite selection";
|
|
5767
|
+
btn.innerHTML = '<span style="font-size:12px;font-weight:700;">\u2726 AI</span>';
|
|
5768
|
+
return btn;
|
|
5769
|
+
}
|
|
5770
|
+
surround(range) {
|
|
5771
|
+
this.savedRange = range.cloneRange();
|
|
5772
|
+
if (this.actionsEl) {
|
|
5773
|
+
this.actionsEl.hidden = false;
|
|
5774
|
+
}
|
|
5775
|
+
}
|
|
5776
|
+
renderActions() {
|
|
5777
|
+
const wrap = document.createElement("div");
|
|
5778
|
+
wrap.className = "ng-inline-ai-actions";
|
|
5779
|
+
wrap.hidden = true;
|
|
5780
|
+
const status = document.createElement("span");
|
|
5781
|
+
status.className = "ng-inline-ai-status";
|
|
5782
|
+
const row = document.createElement("div");
|
|
5783
|
+
row.className = "ng-inline-ai-row";
|
|
5784
|
+
REWRITE_ACTIONS.forEach((act) => {
|
|
5785
|
+
const b = document.createElement("button");
|
|
5786
|
+
b.type = "button";
|
|
5787
|
+
b.className = "ng-inline-action-btn";
|
|
5788
|
+
b.textContent = act.label;
|
|
5789
|
+
b.addEventListener("click", async () => {
|
|
5790
|
+
const range = this.savedRange;
|
|
5791
|
+
const selected = range?.toString().trim() || "";
|
|
5792
|
+
if (!range || !selected) {
|
|
5793
|
+
status.textContent = "Select text first.";
|
|
5794
|
+
return;
|
|
5795
|
+
}
|
|
5796
|
+
status.textContent = "Rewriting\u2026";
|
|
5797
|
+
try {
|
|
5798
|
+
const rewritten = await generateAiText({
|
|
5799
|
+
config: loadAiConfig(),
|
|
5800
|
+
mode: "ask",
|
|
5801
|
+
prompt: `${act.prompt}
|
|
5802
|
+
|
|
5803
|
+
Text:
|
|
5804
|
+
"${selected}"`,
|
|
5805
|
+
context: selected
|
|
5806
|
+
});
|
|
5807
|
+
if (rewritten) {
|
|
5808
|
+
range.deleteContents();
|
|
5809
|
+
range.insertNode(document.createTextNode(rewritten));
|
|
5810
|
+
status.textContent = "Done";
|
|
5811
|
+
} else {
|
|
5812
|
+
status.textContent = "Empty response";
|
|
5813
|
+
}
|
|
5814
|
+
} catch (err) {
|
|
5815
|
+
status.textContent = err instanceof Error ? err.message : "AI error";
|
|
5816
|
+
}
|
|
5817
|
+
});
|
|
5818
|
+
row.appendChild(b);
|
|
5819
|
+
});
|
|
5820
|
+
wrap.append(row, status);
|
|
5821
|
+
this.actionsEl = wrap;
|
|
5822
|
+
return wrap;
|
|
5823
|
+
}
|
|
5824
|
+
checkState() {
|
|
5825
|
+
const sel = window.getSelection();
|
|
5826
|
+
if (sel && sel.rangeCount > 0 && !sel.getRangeAt(0).collapsed) {
|
|
5827
|
+
this.savedRange = sel.getRangeAt(0).cloneRange();
|
|
5828
|
+
}
|
|
5829
|
+
return false;
|
|
5830
|
+
}
|
|
5831
|
+
};
|
|
5832
|
+
var ColorInline = class {
|
|
5833
|
+
savedRange = null;
|
|
5834
|
+
actionsEl = null;
|
|
5835
|
+
static get isInline() {
|
|
5836
|
+
return true;
|
|
5837
|
+
}
|
|
5838
|
+
static get title() {
|
|
5839
|
+
return "Color & Highlight";
|
|
5840
|
+
}
|
|
5841
|
+
static get sanitize() {
|
|
5842
|
+
return {
|
|
5843
|
+
span: {
|
|
5844
|
+
class: "ng-inline-color",
|
|
5845
|
+
style: true
|
|
5846
|
+
}
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5849
|
+
render() {
|
|
5850
|
+
const btn = document.createElement("button");
|
|
5851
|
+
btn.type = "button";
|
|
5852
|
+
btn.className = "ce-inline-tool";
|
|
5853
|
+
btn.title = "Text & Highlight Color";
|
|
5854
|
+
btn.innerHTML = '<span style="font-weight:700;font-size:12px;border-bottom:2px solid currentColor;">A</span>';
|
|
5855
|
+
return btn;
|
|
5856
|
+
}
|
|
5857
|
+
surround(range) {
|
|
5858
|
+
this.savedRange = range.cloneRange();
|
|
5859
|
+
if (this.actionsEl) {
|
|
5860
|
+
this.actionsEl.hidden = false;
|
|
5861
|
+
}
|
|
5862
|
+
}
|
|
5863
|
+
applyStyle(prop, value) {
|
|
5864
|
+
const range = this.savedRange;
|
|
5865
|
+
if (!range || range.collapsed) return;
|
|
5866
|
+
if (!value) {
|
|
5867
|
+
const span2 = document.createElement("span");
|
|
5868
|
+
span2.appendChild(range.extractContents());
|
|
5869
|
+
span2.querySelectorAll(".ng-inline-color").forEach((el) => {
|
|
5870
|
+
el.style[prop] = "";
|
|
5871
|
+
});
|
|
5872
|
+
range.insertNode(span2);
|
|
5873
|
+
return;
|
|
5874
|
+
}
|
|
5875
|
+
const span = document.createElement("span");
|
|
5876
|
+
span.className = "ng-inline-color";
|
|
5877
|
+
span.style[prop] = value;
|
|
5878
|
+
try {
|
|
5879
|
+
range.surroundContents(span);
|
|
5880
|
+
} catch {
|
|
5881
|
+
const frag = range.extractContents();
|
|
5882
|
+
span.appendChild(frag);
|
|
5883
|
+
range.insertNode(span);
|
|
5884
|
+
}
|
|
5885
|
+
}
|
|
5886
|
+
renderActions() {
|
|
5887
|
+
const wrap = document.createElement("div");
|
|
5888
|
+
wrap.className = "ng-inline-color-actions";
|
|
5889
|
+
wrap.hidden = true;
|
|
5890
|
+
const makeRow = (title, swatches, prop) => {
|
|
5891
|
+
const row = document.createElement("div");
|
|
5892
|
+
row.className = "ng-inline-swatch-row";
|
|
5893
|
+
const lbl = document.createElement("span");
|
|
5894
|
+
lbl.className = "ng-inline-swatch-label";
|
|
5895
|
+
lbl.textContent = title;
|
|
5896
|
+
row.appendChild(lbl);
|
|
5897
|
+
swatches.forEach((sw) => {
|
|
5898
|
+
const dot = document.createElement("button");
|
|
5899
|
+
dot.type = "button";
|
|
5900
|
+
dot.className = "ng-inline-swatch";
|
|
5901
|
+
dot.title = sw.label;
|
|
5902
|
+
dot.style.background = sw.value || "transparent";
|
|
5903
|
+
if (!sw.value) dot.textContent = "\xD7";
|
|
5904
|
+
dot.addEventListener("click", () => this.applyStyle(prop, sw.value));
|
|
5905
|
+
row.appendChild(dot);
|
|
5906
|
+
});
|
|
5907
|
+
return row;
|
|
5908
|
+
};
|
|
5909
|
+
wrap.append(
|
|
5910
|
+
makeRow("Text", TEXT_COLOR_SWATCHES, "color"),
|
|
5911
|
+
makeRow("Bg", HIGHLIGHT_SWATCHES, "backgroundColor")
|
|
5912
|
+
);
|
|
5913
|
+
this.actionsEl = wrap;
|
|
5914
|
+
return wrap;
|
|
5915
|
+
}
|
|
5916
|
+
checkState() {
|
|
5917
|
+
const sel = window.getSelection();
|
|
5918
|
+
if (sel && sel.rangeCount > 0 && !sel.getRangeAt(0).collapsed) {
|
|
5919
|
+
this.savedRange = sel.getRangeAt(0).cloneRange();
|
|
5920
|
+
}
|
|
5921
|
+
return false;
|
|
5922
|
+
}
|
|
5923
|
+
};
|
|
5924
|
+
var TodayTool = class {
|
|
5925
|
+
data;
|
|
5926
|
+
static get toolbox() {
|
|
5927
|
+
return {
|
|
5928
|
+
title: "Today Date",
|
|
5929
|
+
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="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>'
|
|
5930
|
+
};
|
|
5931
|
+
}
|
|
5932
|
+
constructor({ data }) {
|
|
5933
|
+
const now = /* @__PURE__ */ new Date();
|
|
5934
|
+
this.data = {
|
|
5935
|
+
date: data?.date ?? now.toLocaleDateString(void 0, {
|
|
5936
|
+
year: "numeric",
|
|
5937
|
+
month: "long",
|
|
5938
|
+
day: "numeric"
|
|
5939
|
+
}),
|
|
5940
|
+
label: data?.label ?? "Date"
|
|
5941
|
+
};
|
|
5942
|
+
}
|
|
5943
|
+
render() {
|
|
5944
|
+
const wrap = document.createElement("div");
|
|
5945
|
+
wrap.className = "editor-today-pill";
|
|
5946
|
+
const badge = document.createElement("span");
|
|
5947
|
+
badge.className = "editor-today-badge";
|
|
5948
|
+
badge.textContent = `\u{1F4C5} ${this.data.date}`;
|
|
5949
|
+
const toggle = document.createElement("button");
|
|
5950
|
+
toggle.type = "button";
|
|
5951
|
+
toggle.className = "editor-mermaid-preset-btn";
|
|
5952
|
+
toggle.textContent = "ISO";
|
|
5953
|
+
toggle.addEventListener("click", () => {
|
|
5954
|
+
const now = /* @__PURE__ */ new Date();
|
|
5955
|
+
const iso = now.toISOString().slice(0, 10);
|
|
5956
|
+
const long = now.toLocaleDateString(void 0, {
|
|
5957
|
+
year: "numeric",
|
|
5958
|
+
month: "long",
|
|
5959
|
+
day: "numeric"
|
|
5960
|
+
});
|
|
5961
|
+
this.data.date = this.data.date === iso ? long : iso;
|
|
5962
|
+
badge.textContent = `\u{1F4C5} ${this.data.date}`;
|
|
5963
|
+
toggle.textContent = this.data.date === iso ? "Long" : "ISO";
|
|
5964
|
+
});
|
|
5965
|
+
wrap.append(badge, toggle);
|
|
5966
|
+
return wrap;
|
|
5967
|
+
}
|
|
5968
|
+
save() {
|
|
5969
|
+
return {
|
|
5970
|
+
date: this.data.date,
|
|
5971
|
+
label: this.data.label
|
|
5972
|
+
};
|
|
5973
|
+
}
|
|
5974
|
+
};
|
|
5975
|
+
var ExportTriggerTool = class {
|
|
5976
|
+
static get toolbox() {
|
|
5977
|
+
return {
|
|
5978
|
+
title: "Export / Import",
|
|
5979
|
+
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 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>'
|
|
5980
|
+
};
|
|
5981
|
+
}
|
|
5982
|
+
render() {
|
|
5983
|
+
const el = document.createElement("div");
|
|
5984
|
+
el.className = "editor-export-trigger";
|
|
5985
|
+
el.textContent = "Opening Export & Markdown modal\u2026";
|
|
5986
|
+
queueMicrotask(() => {
|
|
5987
|
+
el.dispatchEvent(new CustomEvent("nextgen-open-export", { bubbles: true }));
|
|
5988
|
+
});
|
|
5989
|
+
return el;
|
|
5990
|
+
}
|
|
5991
|
+
save() {
|
|
5992
|
+
return {};
|
|
5993
|
+
}
|
|
5994
|
+
};
|
|
5995
|
+
|
|
5996
|
+
// src/editorTools.ts
|
|
5997
|
+
var CustomMediaTool = class {
|
|
5998
|
+
data;
|
|
5999
|
+
elements;
|
|
6000
|
+
constructor(options) {
|
|
6001
|
+
this.data = options.data || {};
|
|
6002
|
+
}
|
|
6003
|
+
static get toolbox() {
|
|
6004
|
+
return {
|
|
6005
|
+
title: "Image",
|
|
6006
|
+
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"/><circle cx="8.5" cy="8.5" r="1.5"/><path d="m21 15-5-5L5 21"/></svg>'
|
|
6007
|
+
};
|
|
6008
|
+
}
|
|
6009
|
+
render() {
|
|
6010
|
+
const root = document.createElement("div");
|
|
6011
|
+
root.className = "custom-media-fields";
|
|
6012
|
+
const input = document.createElement("input");
|
|
6013
|
+
input.type = "text";
|
|
6014
|
+
input.placeholder = "Paste image URL";
|
|
6015
|
+
input.value = this.data.url || "";
|
|
6016
|
+
const file = document.createElement("input");
|
|
6017
|
+
file.type = "file";
|
|
6018
|
+
file.accept = "image/*";
|
|
6019
|
+
const caption = document.createElement("input");
|
|
6020
|
+
caption.type = "text";
|
|
6021
|
+
caption.placeholder = "Caption";
|
|
6022
|
+
caption.value = this.data.caption || "";
|
|
6023
|
+
const preview = document.createElement("div");
|
|
6024
|
+
preview.className = "custom-media-preview";
|
|
6025
|
+
const paint = (url) => {
|
|
6026
|
+
preview.innerHTML = url ? `<img src="${escHtml(url)}" alt="">` : "";
|
|
6027
|
+
};
|
|
6028
|
+
paint(input.value);
|
|
6029
|
+
input.oninput = () => paint(input.value);
|
|
6030
|
+
file.onchange = async () => {
|
|
6031
|
+
const selected = file.files?.[0];
|
|
6032
|
+
if (!selected) return;
|
|
6033
|
+
const bucketUrl = await uploadFileToBucket(selected, "writing");
|
|
6034
|
+
if (bucketUrl) {
|
|
6035
|
+
input.value = bucketUrl;
|
|
6036
|
+
paint(bucketUrl);
|
|
6037
|
+
return;
|
|
6038
|
+
}
|
|
6039
|
+
const reader = new FileReader();
|
|
6040
|
+
reader.onload = () => {
|
|
6041
|
+
const res = String(reader.result || "");
|
|
6042
|
+
input.value = res;
|
|
6043
|
+
paint(res);
|
|
6044
|
+
};
|
|
6045
|
+
reader.readAsDataURL(selected);
|
|
6046
|
+
};
|
|
6047
|
+
root.append(input, file, caption, preview);
|
|
6048
|
+
this.elements = { root, input, caption };
|
|
6049
|
+
return root;
|
|
6050
|
+
}
|
|
6051
|
+
save() {
|
|
6052
|
+
return {
|
|
6053
|
+
url: this.elements?.input.value.trim() || "",
|
|
6054
|
+
caption: this.elements?.caption.value.trim() || ""
|
|
6055
|
+
};
|
|
6056
|
+
}
|
|
6057
|
+
};
|
|
6058
|
+
var GifTool = class {
|
|
6059
|
+
data;
|
|
6060
|
+
elements;
|
|
6061
|
+
constructor(options) {
|
|
6062
|
+
this.data = options.data || {};
|
|
6063
|
+
}
|
|
6064
|
+
static get toolbox() {
|
|
6065
|
+
return {
|
|
6066
|
+
title: "GIF",
|
|
6067
|
+
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="4" width="20" height="16" rx="2"/><path d="M10 9H7a1 1 0 0 0-1 1v4a1 1 0 0 0 1 1h2v-3H8"/><path d="M13 9v6"/><path d="M16 15V9h3"/><path d="M16 12h2"/></svg>'
|
|
6068
|
+
};
|
|
6069
|
+
}
|
|
6070
|
+
render() {
|
|
6071
|
+
const root = document.createElement("div");
|
|
6072
|
+
root.className = "custom-media-fields";
|
|
6073
|
+
const searchRow = document.createElement("div");
|
|
6074
|
+
searchRow.className = "gif-search-row";
|
|
6075
|
+
const searchInput = document.createElement("input");
|
|
6076
|
+
searchInput.type = "search";
|
|
6077
|
+
searchInput.placeholder = "Search free GIFs (trending or keyword)...";
|
|
6078
|
+
const searchBtn = document.createElement("button");
|
|
6079
|
+
searchBtn.type = "button";
|
|
6080
|
+
searchBtn.className = "b2";
|
|
6081
|
+
searchBtn.textContent = "Search";
|
|
6082
|
+
searchRow.append(searchInput, searchBtn);
|
|
6083
|
+
const resultsGrid = document.createElement("div");
|
|
6084
|
+
resultsGrid.className = "gif-picker-grid";
|
|
6085
|
+
const url = document.createElement("input");
|
|
6086
|
+
url.type = "url";
|
|
6087
|
+
url.placeholder = "Or paste GIF / image URL";
|
|
6088
|
+
url.value = this.data.url || "";
|
|
6089
|
+
const caption = document.createElement("input");
|
|
6090
|
+
caption.type = "text";
|
|
6091
|
+
caption.placeholder = "Caption";
|
|
6092
|
+
caption.value = this.data.caption || "";
|
|
6093
|
+
const preview = document.createElement("div");
|
|
6094
|
+
preview.className = "custom-media-preview";
|
|
6095
|
+
const paint = () => {
|
|
6096
|
+
preview.innerHTML = url.value ? `<img src="${escHtml(url.value)}" alt="${escHtml(caption.value || "GIF")}">` : "";
|
|
6097
|
+
};
|
|
6098
|
+
paint();
|
|
6099
|
+
url.oninput = paint;
|
|
6100
|
+
const runSearch = async (query) => {
|
|
6101
|
+
resultsGrid.innerHTML = '<span class="gif-picker-status">Loading GIFs\u2026</span>';
|
|
6102
|
+
try {
|
|
6103
|
+
const res = await fetch(
|
|
6104
|
+
`/api/gifs?q=${encodeURIComponent(query)}&limit=12`
|
|
6105
|
+
);
|
|
6106
|
+
const json = await res.json();
|
|
6107
|
+
const items = json.results || [];
|
|
6108
|
+
if (!items.length) {
|
|
6109
|
+
resultsGrid.innerHTML = '<span class="gif-picker-status">No GIFs found. Try another keyword or paste a URL below.</span>';
|
|
6110
|
+
return;
|
|
6111
|
+
}
|
|
6112
|
+
resultsGrid.innerHTML = "";
|
|
6113
|
+
items.forEach((item) => {
|
|
6114
|
+
const btn = document.createElement("button");
|
|
6115
|
+
btn.type = "button";
|
|
6116
|
+
btn.className = "gif-picker-item";
|
|
6117
|
+
btn.title = item.title;
|
|
6118
|
+
btn.innerHTML = `<img src="${escHtml(item.previewUrl)}" alt="${escHtml(item.title)}" loading="lazy">`;
|
|
6119
|
+
btn.onclick = () => {
|
|
6120
|
+
url.value = item.url;
|
|
6121
|
+
if (!caption.value) caption.value = item.title;
|
|
6122
|
+
paint();
|
|
6123
|
+
};
|
|
6124
|
+
resultsGrid.appendChild(btn);
|
|
6125
|
+
});
|
|
6126
|
+
} catch {
|
|
6127
|
+
resultsGrid.innerHTML = '<span class="gif-picker-status">Could not load GIFs. Paste a GIF URL below.</span>';
|
|
6128
|
+
}
|
|
6129
|
+
};
|
|
6130
|
+
searchBtn.onclick = () => void runSearch(searchInput.value);
|
|
6131
|
+
searchInput.addEventListener("keydown", (e) => {
|
|
6132
|
+
if (e.key === "Enter") {
|
|
6133
|
+
e.preventDefault();
|
|
6134
|
+
e.stopPropagation();
|
|
6135
|
+
void runSearch(searchInput.value);
|
|
6136
|
+
}
|
|
6137
|
+
});
|
|
6138
|
+
if (!this.data.url) {
|
|
6139
|
+
void runSearch("");
|
|
6140
|
+
}
|
|
6141
|
+
root.append(searchRow, resultsGrid, url, caption, preview);
|
|
6142
|
+
this.elements = { url, caption };
|
|
6143
|
+
return root;
|
|
6144
|
+
}
|
|
6145
|
+
save() {
|
|
6146
|
+
return {
|
|
6147
|
+
url: this.elements?.url.value.trim() || "",
|
|
6148
|
+
caption: this.elements?.caption.value.trim() || ""
|
|
6149
|
+
};
|
|
6150
|
+
}
|
|
6151
|
+
};
|
|
6152
|
+
var AttachTool = class {
|
|
6153
|
+
data;
|
|
6154
|
+
elements;
|
|
6155
|
+
constructor(options) {
|
|
6156
|
+
this.data = options.data || {};
|
|
6157
|
+
}
|
|
6158
|
+
static get toolbox() {
|
|
6159
|
+
return {
|
|
6160
|
+
title: "Attachment",
|
|
6161
|
+
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.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>'
|
|
6162
|
+
};
|
|
6163
|
+
}
|
|
6164
|
+
render() {
|
|
6165
|
+
const root = document.createElement("div");
|
|
6166
|
+
root.className = "custom-media-fields";
|
|
6167
|
+
const file = document.createElement("input");
|
|
6168
|
+
file.type = "file";
|
|
6169
|
+
const name = document.createElement("input");
|
|
6170
|
+
name.type = "text";
|
|
6171
|
+
name.placeholder = "Attachment label";
|
|
6172
|
+
name.value = this.data.name || "";
|
|
6173
|
+
root.append(file, name);
|
|
6174
|
+
const elements = {
|
|
6175
|
+
file,
|
|
6176
|
+
name,
|
|
6177
|
+
dataUrl: this.data.dataUrl || "",
|
|
6178
|
+
dataName: this.data.name || ""
|
|
6179
|
+
};
|
|
6180
|
+
this.elements = elements;
|
|
6181
|
+
file.onchange = () => {
|
|
6182
|
+
const selected = file.files?.[0];
|
|
6183
|
+
if (!selected) return;
|
|
6184
|
+
const reader = new FileReader();
|
|
6185
|
+
reader.onload = () => {
|
|
6186
|
+
elements.dataUrl = String(reader.result || "");
|
|
6187
|
+
elements.dataName = selected.name;
|
|
6188
|
+
if (!name.value) name.value = selected.name;
|
|
6189
|
+
};
|
|
6190
|
+
reader.readAsDataURL(selected);
|
|
6191
|
+
};
|
|
6192
|
+
return root;
|
|
5088
6193
|
}
|
|
5089
6194
|
save() {
|
|
5090
6195
|
return {
|
|
@@ -5301,7 +6406,11 @@ var CustomEmbedTool = class {
|
|
|
5301
6406
|
data;
|
|
5302
6407
|
elements;
|
|
5303
6408
|
constructor(options) {
|
|
5304
|
-
this.data =
|
|
6409
|
+
this.data = {
|
|
6410
|
+
align: "center",
|
|
6411
|
+
size: "medium",
|
|
6412
|
+
...options.data || {}
|
|
6413
|
+
};
|
|
5305
6414
|
}
|
|
5306
6415
|
static get toolbox() {
|
|
5307
6416
|
return {
|
|
@@ -5362,15 +6471,20 @@ var CustomEmbedTool = class {
|
|
|
5362
6471
|
caption.value = this.data.caption || "";
|
|
5363
6472
|
const preview = document.createElement("div");
|
|
5364
6473
|
preview.className = "custom-embed-preview";
|
|
6474
|
+
preview.dataset.align = this.data.align || "center";
|
|
6475
|
+
preview.dataset.size = this.data.size || "medium";
|
|
5365
6476
|
const elements = {
|
|
5366
6477
|
url,
|
|
5367
6478
|
caption,
|
|
6479
|
+
preview,
|
|
5368
6480
|
embedUrl: this.data.embed || this.toEmbedUrl(url.value)
|
|
5369
6481
|
};
|
|
5370
6482
|
this.elements = elements;
|
|
5371
6483
|
const paint = () => {
|
|
5372
6484
|
const embedUrl = this.toEmbedUrl(url.value);
|
|
5373
6485
|
elements.embedUrl = embedUrl;
|
|
6486
|
+
preview.dataset.align = this.data.align || "center";
|
|
6487
|
+
preview.dataset.size = this.data.size || "medium";
|
|
5374
6488
|
preview.innerHTML = embedUrl ? `<iframe src="${escHtml(embedUrl)}" title="${escHtml(
|
|
5375
6489
|
caption.value || "Embedded content"
|
|
5376
6490
|
)}" loading="lazy" allowfullscreen></iframe>` : "";
|
|
@@ -5384,13 +6498,96 @@ var CustomEmbedTool = class {
|
|
|
5384
6498
|
root.append(url, caption, preview);
|
|
5385
6499
|
return root;
|
|
5386
6500
|
}
|
|
6501
|
+
renderSettings() {
|
|
6502
|
+
const tunes = [
|
|
6503
|
+
{
|
|
6504
|
+
name: "align-left",
|
|
6505
|
+
label: "Align Left",
|
|
6506
|
+
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>',
|
|
6507
|
+
isActive: (this.data.align || "center") === "left",
|
|
6508
|
+
onActivate: () => {
|
|
6509
|
+
this.data.align = "left";
|
|
6510
|
+
if (this.elements?.preview) this.elements.preview.dataset.align = "left";
|
|
6511
|
+
}
|
|
6512
|
+
},
|
|
6513
|
+
{
|
|
6514
|
+
name: "align-center",
|
|
6515
|
+
label: "Align Center",
|
|
6516
|
+
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>',
|
|
6517
|
+
isActive: (this.data.align || "center") === "center",
|
|
6518
|
+
onActivate: () => {
|
|
6519
|
+
this.data.align = "center";
|
|
6520
|
+
if (this.elements?.preview) this.elements.preview.dataset.align = "center";
|
|
6521
|
+
}
|
|
6522
|
+
},
|
|
6523
|
+
{
|
|
6524
|
+
name: "align-right",
|
|
6525
|
+
label: "Align Right",
|
|
6526
|
+
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>',
|
|
6527
|
+
isActive: (this.data.align || "center") === "right",
|
|
6528
|
+
onActivate: () => {
|
|
6529
|
+
this.data.align = "right";
|
|
6530
|
+
if (this.elements?.preview) this.elements.preview.dataset.align = "right";
|
|
6531
|
+
}
|
|
6532
|
+
},
|
|
6533
|
+
{
|
|
6534
|
+
name: "size-small",
|
|
6535
|
+
label: "Small",
|
|
6536
|
+
icon: '<span style="font-size:11px;font-weight:700;">S</span>',
|
|
6537
|
+
isActive: (this.data.size || "medium") === "small",
|
|
6538
|
+
onActivate: () => {
|
|
6539
|
+
this.data.size = "small";
|
|
6540
|
+
if (this.elements?.preview) this.elements.preview.dataset.size = "small";
|
|
6541
|
+
}
|
|
6542
|
+
},
|
|
6543
|
+
{
|
|
6544
|
+
name: "size-medium",
|
|
6545
|
+
label: "Medium",
|
|
6546
|
+
icon: '<span style="font-size:11px;font-weight:700;">M</span>',
|
|
6547
|
+
isActive: (this.data.size || "medium") === "medium",
|
|
6548
|
+
onActivate: () => {
|
|
6549
|
+
this.data.size = "medium";
|
|
6550
|
+
if (this.elements?.preview) this.elements.preview.dataset.size = "medium";
|
|
6551
|
+
}
|
|
6552
|
+
},
|
|
6553
|
+
{
|
|
6554
|
+
name: "size-large",
|
|
6555
|
+
label: "Large",
|
|
6556
|
+
icon: '<span style="font-size:11px;font-weight:700;">L</span>',
|
|
6557
|
+
isActive: (this.data.size || "medium") === "large",
|
|
6558
|
+
onActivate: () => {
|
|
6559
|
+
this.data.size = "large";
|
|
6560
|
+
if (this.elements?.preview) this.elements.preview.dataset.size = "large";
|
|
6561
|
+
}
|
|
6562
|
+
},
|
|
6563
|
+
{
|
|
6564
|
+
name: "size-full",
|
|
6565
|
+
label: "Full Page",
|
|
6566
|
+
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>',
|
|
6567
|
+
isActive: (this.data.size || "medium") === "full",
|
|
6568
|
+
onActivate: () => {
|
|
6569
|
+
this.data.size = "full";
|
|
6570
|
+
if (this.elements?.preview) this.elements.preview.dataset.size = "full";
|
|
6571
|
+
}
|
|
6572
|
+
}
|
|
6573
|
+
];
|
|
6574
|
+
return tunes.map((t) => ({
|
|
6575
|
+
icon: t.icon,
|
|
6576
|
+
label: t.label,
|
|
6577
|
+
isActive: t.isActive,
|
|
6578
|
+
closeOnActivate: true,
|
|
6579
|
+
onActivate: t.onActivate
|
|
6580
|
+
}));
|
|
6581
|
+
}
|
|
5387
6582
|
save() {
|
|
5388
6583
|
const source = this.elements?.url.value.trim() || "";
|
|
5389
6584
|
const embed = this.toEmbedUrl(source);
|
|
5390
6585
|
return {
|
|
5391
6586
|
source,
|
|
5392
6587
|
embed,
|
|
5393
|
-
caption: this.elements?.caption.value.trim() || ""
|
|
6588
|
+
caption: this.elements?.caption.value.trim() || "",
|
|
6589
|
+
align: this.data.align || "center",
|
|
6590
|
+
size: this.data.size || "medium"
|
|
5394
6591
|
};
|
|
5395
6592
|
}
|
|
5396
6593
|
};
|
|
@@ -5840,6 +7037,8 @@ var SpoilerInline = class {
|
|
|
5840
7037
|
}
|
|
5841
7038
|
};
|
|
5842
7039
|
var MentionInline = class {
|
|
7040
|
+
savedRange = null;
|
|
7041
|
+
actionsEl = null;
|
|
5843
7042
|
static get isInline() {
|
|
5844
7043
|
return true;
|
|
5845
7044
|
}
|
|
@@ -5855,23 +7054,59 @@ var MentionInline = class {
|
|
|
5855
7054
|
return button;
|
|
5856
7055
|
}
|
|
5857
7056
|
surround(range) {
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
7057
|
+
this.savedRange = range.cloneRange();
|
|
7058
|
+
if (this.actionsEl) {
|
|
7059
|
+
this.actionsEl.hidden = false;
|
|
7060
|
+
const input = this.actionsEl.querySelector("input");
|
|
7061
|
+
input?.focus();
|
|
7062
|
+
}
|
|
7063
|
+
}
|
|
7064
|
+
renderActions() {
|
|
7065
|
+
const wrap = document.createElement("div");
|
|
7066
|
+
wrap.className = "ng-mention-popover";
|
|
7067
|
+
wrap.hidden = true;
|
|
7068
|
+
const input = document.createElement("input");
|
|
7069
|
+
input.type = "url";
|
|
7070
|
+
input.className = "cdx-input";
|
|
7071
|
+
input.placeholder = "https://github.com/username";
|
|
7072
|
+
const applyBtn = document.createElement("button");
|
|
7073
|
+
applyBtn.type = "button";
|
|
7074
|
+
applyBtn.className = "ng-inline-action-btn";
|
|
7075
|
+
applyBtn.textContent = "Apply";
|
|
7076
|
+
const applyMention = (url) => {
|
|
7077
|
+
const range = this.savedRange;
|
|
7078
|
+
if (!range || !url.trim()) return;
|
|
7079
|
+
const selectedText = range.toString().trim();
|
|
7080
|
+
const anchor = document.createElement("a");
|
|
7081
|
+
anchor.className = "editor-mention";
|
|
7082
|
+
anchor.href = url.trim();
|
|
7083
|
+
anchor.target = "_blank";
|
|
7084
|
+
anchor.rel = "noopener noreferrer";
|
|
7085
|
+
try {
|
|
7086
|
+
range.surroundContents(anchor);
|
|
7087
|
+
if (selectedText && !selectedText.startsWith("@")) {
|
|
7088
|
+
anchor.textContent = `@${selectedText}`;
|
|
7089
|
+
}
|
|
7090
|
+
} catch {
|
|
5870
7091
|
}
|
|
5871
|
-
|
|
5872
|
-
}
|
|
7092
|
+
wrap.hidden = true;
|
|
7093
|
+
};
|
|
7094
|
+
applyBtn.addEventListener("click", () => applyMention(input.value));
|
|
7095
|
+
input.addEventListener("keydown", (e) => {
|
|
7096
|
+
if (e.key === "Enter") {
|
|
7097
|
+
e.preventDefault();
|
|
7098
|
+
applyMention(input.value);
|
|
7099
|
+
}
|
|
7100
|
+
});
|
|
7101
|
+
wrap.append(input, applyBtn);
|
|
7102
|
+
this.actionsEl = wrap;
|
|
7103
|
+
return wrap;
|
|
5873
7104
|
}
|
|
5874
7105
|
checkState() {
|
|
7106
|
+
const sel = window.getSelection();
|
|
7107
|
+
if (sel && sel.rangeCount > 0 && !sel.getRangeAt(0).collapsed) {
|
|
7108
|
+
this.savedRange = sel.getRangeAt(0).cloneRange();
|
|
7109
|
+
}
|
|
5875
7110
|
return false;
|
|
5876
7111
|
}
|
|
5877
7112
|
};
|
|
@@ -5929,270 +7164,131 @@ function makeHeadingTool(level) {
|
|
|
5929
7164
|
}
|
|
5930
7165
|
var Heading1Tool = makeHeadingTool(1);
|
|
5931
7166
|
var Heading2Tool = makeHeadingTool(2);
|
|
5932
|
-
var Heading3Tool = makeHeadingTool(3);
|
|
5933
|
-
function getEditorTools(includeLayout = true, enabledTools) {
|
|
5934
|
-
const tools = {
|
|
5935
|
-
// 1. Most frequently used core blocks
|
|
5936
|
-
cover: PageCoverTool,
|
|
5937
|
-
h1: {
|
|
5938
|
-
class: Heading1Tool,
|
|
5939
|
-
inlineToolbar: true
|
|
5940
|
-
},
|
|
5941
|
-
h2: {
|
|
5942
|
-
class: Heading2Tool,
|
|
5943
|
-
inlineToolbar: true
|
|
5944
|
-
},
|
|
5945
|
-
h3: {
|
|
5946
|
-
class: Heading3Tool,
|
|
5947
|
-
inlineToolbar: true
|
|
5948
|
-
},
|
|
5949
|
-
header: {
|
|
5950
|
-
class: import_header.default,
|
|
5951
|
-
toolbox: false,
|
|
5952
|
-
config: { placeholder: "Heading", levels: [1, 2, 3], defaultLevel: 2 }
|
|
5953
|
-
},
|
|
5954
|
-
list: import_list.default,
|
|
5955
|
-
image: CustomMediaTool,
|
|
5956
|
-
quote: {
|
|
5957
|
-
class: import_quote.default,
|
|
5958
|
-
inlineToolbar: true,
|
|
5959
|
-
config: {
|
|
5960
|
-
quotePlaceholder: "Enter a quote",
|
|
5961
|
-
captionPlaceholder: "Quote author"
|
|
5962
|
-
}
|
|
5963
|
-
},
|
|
5964
|
-
code: SmartCodeTool,
|
|
5965
|
-
toc: TableOfContentsTool,
|
|
5966
|
-
linkTool: {
|
|
5967
|
-
class: import_link.default,
|
|
5968
|
-
config: {
|
|
5969
|
-
endpoint: "/api/fetchUrl"
|
|
5970
|
-
}
|
|
5971
|
-
},
|
|
5972
|
-
delimiter: DelimiterTool,
|
|
5973
|
-
table: import_table.default,
|
|
5974
|
-
callout: CalloutTool,
|
|
5975
|
-
hotkey: HotkeyTool,
|
|
5976
|
-
emoji: EmojiTool,
|
|
5977
|
-
scratch: ScratchTool,
|
|
5978
|
-
alert: AlertTool,
|
|
5979
|
-
// 2. Common rich media & layout
|
|
5980
|
-
upload: UploadTool,
|
|
5981
|
-
audio: AudioPlayerTool,
|
|
5982
|
-
musicCarousel: MusicCarouselTool,
|
|
5983
|
-
embed: CustomEmbedTool,
|
|
5984
|
-
gallery: LightboxGalleryTool,
|
|
5985
|
-
masonry: MasonryTool,
|
|
5986
|
-
carousel: CarouselTool,
|
|
5987
|
-
bento: BentoTool,
|
|
5988
|
-
...includeLayout ? { layout: LayoutTool } : {},
|
|
5989
|
-
tabs: TabsTool,
|
|
5990
|
-
accordion: AccordionTool,
|
|
5991
|
-
toggleh1: ToggleH1Tool,
|
|
5992
|
-
toggleh2: ToggleH2Tool,
|
|
5993
|
-
toggleh3: ToggleH3Tool,
|
|
5994
|
-
// 3. Structured & editorial blocks
|
|
5995
|
-
flashcards: FlashcardTool,
|
|
5996
|
-
chart: ChartTool,
|
|
5997
|
-
footnotes: FootnotesTool,
|
|
5998
|
-
quiz: QuizTool,
|
|
5999
|
-
kanban: KanbanTool,
|
|
6000
|
-
timer: FocusTimerTool,
|
|
6001
|
-
poll: PollTool,
|
|
6002
|
-
faq: FaqTool,
|
|
6003
|
-
todo: TaskChecklistTool,
|
|
6004
|
-
eisenhower: EisenhowerMatrixTool,
|
|
6005
|
-
form: FormBuilderTool,
|
|
6006
|
-
latex: LatexTool,
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
var AI_PROVIDER_PRESETS = [
|
|
6050
|
-
{
|
|
6051
|
-
id: "openai",
|
|
6052
|
-
label: "OpenAI (ChatGPT)",
|
|
6053
|
-
defaultModel: "gpt-4o-mini",
|
|
6054
|
-
defaultEndpoint: "https://api.openai.com/v1/chat/completions"
|
|
6055
|
-
},
|
|
6056
|
-
{
|
|
6057
|
-
id: "codex",
|
|
6058
|
-
label: "OpenAI Codex",
|
|
6059
|
-
defaultModel: "codex-mini-latest",
|
|
6060
|
-
defaultEndpoint: "https://api.openai.com/v1/chat/completions"
|
|
6061
|
-
},
|
|
6062
|
-
{
|
|
6063
|
-
id: "openrouter",
|
|
6064
|
-
label: "OpenRouter",
|
|
6065
|
-
defaultModel: "openai/gpt-4o-mini",
|
|
6066
|
-
defaultEndpoint: "https://openrouter.ai/api/v1/chat/completions"
|
|
6067
|
-
},
|
|
6068
|
-
{
|
|
6069
|
-
id: "opencode",
|
|
6070
|
-
label: "OpenCode",
|
|
6071
|
-
defaultModel: "opencode/default",
|
|
6072
|
-
defaultEndpoint: "https://api.opencode.ai/v1/chat/completions"
|
|
6073
|
-
},
|
|
6074
|
-
{
|
|
6075
|
-
id: "anthropic",
|
|
6076
|
-
label: "Anthropic (Claude)",
|
|
6077
|
-
defaultModel: "claude-3-5-sonnet-latest",
|
|
6078
|
-
defaultEndpoint: "https://api.anthropic.com/v1/messages"
|
|
6079
|
-
},
|
|
6080
|
-
{
|
|
6081
|
-
id: "gemini",
|
|
6082
|
-
label: "Google Gemini",
|
|
6083
|
-
defaultModel: "gemini-2.5-flash",
|
|
6084
|
-
defaultEndpoint: "https://generativelanguage.googleapis.com/v1beta/models"
|
|
6085
|
-
},
|
|
6086
|
-
{
|
|
6087
|
-
id: "custom",
|
|
6088
|
-
label: "Custom OpenAI-Compatible",
|
|
6089
|
-
defaultModel: "gpt-4o-mini",
|
|
6090
|
-
defaultEndpoint: "http://localhost:11434/v1/chat/completions"
|
|
6091
|
-
}
|
|
6092
|
-
];
|
|
6093
|
-
var AI_STORAGE_KEY = "nextgen-editor-ai-config";
|
|
6094
|
-
function loadAiConfig() {
|
|
6095
|
-
try {
|
|
6096
|
-
const raw = localStorage.getItem(AI_STORAGE_KEY);
|
|
6097
|
-
if (raw) {
|
|
6098
|
-
const parsed = JSON.parse(raw);
|
|
6099
|
-
if (parsed.provider) {
|
|
6100
|
-
return {
|
|
6101
|
-
provider: parsed.provider,
|
|
6102
|
-
model: parsed.model || "gpt-4o-mini",
|
|
6103
|
-
apiKey: parsed.apiKey || "",
|
|
6104
|
-
endpoint: parsed.endpoint || ""
|
|
6105
|
-
};
|
|
6106
|
-
}
|
|
6107
|
-
}
|
|
6108
|
-
} catch {
|
|
6109
|
-
}
|
|
6110
|
-
return {
|
|
6111
|
-
provider: "openai",
|
|
6112
|
-
model: "gpt-4o-mini",
|
|
6113
|
-
apiKey: "",
|
|
6114
|
-
endpoint: ""
|
|
6115
|
-
};
|
|
6116
|
-
}
|
|
6117
|
-
function saveAiConfig(cfg) {
|
|
6118
|
-
try {
|
|
6119
|
-
localStorage.setItem(AI_STORAGE_KEY, JSON.stringify(cfg));
|
|
6120
|
-
} catch {
|
|
6121
|
-
}
|
|
6122
|
-
}
|
|
6123
|
-
async function generateAiText(params) {
|
|
6124
|
-
const { config, mode, prompt, context } = params;
|
|
6125
|
-
const preset = AI_PROVIDER_PRESETS.find((p) => p.id === config.provider) || AI_PROVIDER_PRESETS[0];
|
|
6126
|
-
const endpoint = (config.endpoint || preset.defaultEndpoint).trim();
|
|
6127
|
-
const model = (config.model || preset.defaultModel).trim();
|
|
6128
|
-
const apiKey = config.apiKey.trim();
|
|
6129
|
-
if (!apiKey && config.provider !== "custom") {
|
|
6130
|
-
throw new Error("Please add an API key in Settings first.");
|
|
6131
|
-
}
|
|
6132
|
-
const systemPrompt = mode === "continue" ? "You are a concise writing assistant inside a block editor. Continue the document naturally from the provided context in 1-3 clear paragraphs. Return only the continuation text." : "You are a helpful writing and editing assistant inside a block editor. Fulfill the user request concisely using the provided document context.";
|
|
6133
|
-
const userContent = mode === "continue" ? `Document context:
|
|
6134
|
-
${context || "(Empty document)"}
|
|
6135
|
-
|
|
6136
|
-
Continue writing naturally:` : `Document context:
|
|
6137
|
-
${context || "(Empty document)"}
|
|
6138
|
-
|
|
6139
|
-
User request: ${prompt}`;
|
|
6140
|
-
if (config.provider === "gemini") {
|
|
6141
|
-
const url = `${endpoint.replace(/\/$/, "")}/${encodeURIComponent(
|
|
6142
|
-
model
|
|
6143
|
-
)}:generateContent?key=${encodeURIComponent(apiKey)}`;
|
|
6144
|
-
const res2 = await fetch(url, {
|
|
6145
|
-
method: "POST",
|
|
6146
|
-
headers: { "Content-Type": "application/json" },
|
|
6147
|
-
body: JSON.stringify({
|
|
6148
|
-
contents: [{ parts: [{ text: `${systemPrompt}
|
|
6149
|
-
|
|
6150
|
-
${userContent}` }] }]
|
|
6151
|
-
})
|
|
6152
|
-
});
|
|
6153
|
-
if (!res2.ok) throw new Error(`Gemini API error (${res2.status})`);
|
|
6154
|
-
const json2 = await res2.json();
|
|
6155
|
-
return json2.candidates?.[0]?.content?.parts?.[0]?.text?.trim() || "";
|
|
6156
|
-
}
|
|
6157
|
-
if (config.provider === "anthropic") {
|
|
6158
|
-
const res2 = await fetch(endpoint, {
|
|
6159
|
-
method: "POST",
|
|
6160
|
-
headers: {
|
|
6161
|
-
"Content-Type": "application/json",
|
|
6162
|
-
"x-api-key": apiKey,
|
|
6163
|
-
"anthropic-version": "2023-06-01"
|
|
6164
|
-
},
|
|
6165
|
-
body: JSON.stringify({
|
|
6166
|
-
model,
|
|
6167
|
-
max_tokens: 1024,
|
|
6168
|
-
system: systemPrompt,
|
|
6169
|
-
messages: [{ role: "user", content: userContent }]
|
|
6170
|
-
})
|
|
6171
|
-
});
|
|
6172
|
-
if (!res2.ok) throw new Error(`Anthropic API error (${res2.status})`);
|
|
6173
|
-
const json2 = await res2.json();
|
|
6174
|
-
return json2.content?.[0]?.text?.trim() || "";
|
|
6175
|
-
}
|
|
6176
|
-
const headers = {
|
|
6177
|
-
"Content-Type": "application/json"
|
|
7167
|
+
var Heading3Tool = makeHeadingTool(3);
|
|
7168
|
+
function getEditorTools(includeLayout = true, enabledTools) {
|
|
7169
|
+
const tools = {
|
|
7170
|
+
// 1. Most frequently used core blocks
|
|
7171
|
+
cover: PageCoverTool,
|
|
7172
|
+
h1: {
|
|
7173
|
+
class: Heading1Tool,
|
|
7174
|
+
inlineToolbar: true
|
|
7175
|
+
},
|
|
7176
|
+
h2: {
|
|
7177
|
+
class: Heading2Tool,
|
|
7178
|
+
inlineToolbar: true
|
|
7179
|
+
},
|
|
7180
|
+
h3: {
|
|
7181
|
+
class: Heading3Tool,
|
|
7182
|
+
inlineToolbar: true
|
|
7183
|
+
},
|
|
7184
|
+
header: {
|
|
7185
|
+
class: import_header.default,
|
|
7186
|
+
toolbox: false,
|
|
7187
|
+
config: { placeholder: "Heading", levels: [1, 2, 3], defaultLevel: 2 }
|
|
7188
|
+
},
|
|
7189
|
+
list: import_list.default,
|
|
7190
|
+
image: CustomMediaTool,
|
|
7191
|
+
quote: {
|
|
7192
|
+
class: import_quote.default,
|
|
7193
|
+
inlineToolbar: true,
|
|
7194
|
+
config: {
|
|
7195
|
+
quotePlaceholder: "Enter a quote",
|
|
7196
|
+
captionPlaceholder: "Quote author"
|
|
7197
|
+
}
|
|
7198
|
+
},
|
|
7199
|
+
code: SmartCodeTool,
|
|
7200
|
+
toc: TableOfContentsTool,
|
|
7201
|
+
linkTool: {
|
|
7202
|
+
class: import_link.default,
|
|
7203
|
+
config: {
|
|
7204
|
+
endpoint: "/api/fetchUrl"
|
|
7205
|
+
}
|
|
7206
|
+
},
|
|
7207
|
+
delimiter: DelimiterTool,
|
|
7208
|
+
table: import_table.default,
|
|
7209
|
+
callout: CalloutTool,
|
|
7210
|
+
hotkey: HotkeyTool,
|
|
7211
|
+
emoji: EmojiTool,
|
|
7212
|
+
scratch: ScratchTool,
|
|
7213
|
+
alert: AlertTool,
|
|
7214
|
+
// 2. Common rich media & layout
|
|
7215
|
+
upload: UploadTool,
|
|
7216
|
+
audio: AudioPlayerTool,
|
|
7217
|
+
musicCarousel: MusicCarouselTool,
|
|
7218
|
+
embed: CustomEmbedTool,
|
|
7219
|
+
gallery: LightboxGalleryTool,
|
|
7220
|
+
masonry: MasonryTool,
|
|
7221
|
+
carousel: CarouselTool,
|
|
7222
|
+
bento: BentoTool,
|
|
7223
|
+
...includeLayout ? { layout: LayoutTool } : {},
|
|
7224
|
+
tabs: TabsTool,
|
|
7225
|
+
accordion: AccordionTool,
|
|
7226
|
+
toggleh1: ToggleH1Tool,
|
|
7227
|
+
toggleh2: ToggleH2Tool,
|
|
7228
|
+
toggleh3: ToggleH3Tool,
|
|
7229
|
+
// 3. Structured & editorial blocks
|
|
7230
|
+
flashcards: FlashcardTool,
|
|
7231
|
+
chart: ChartTool,
|
|
7232
|
+
footnotes: FootnotesTool,
|
|
7233
|
+
quiz: QuizTool,
|
|
7234
|
+
kanban: KanbanTool,
|
|
7235
|
+
timer: FocusTimerTool,
|
|
7236
|
+
poll: PollTool,
|
|
7237
|
+
faq: FaqTool,
|
|
7238
|
+
todo: TaskChecklistTool,
|
|
7239
|
+
eisenhower: EisenhowerMatrixTool,
|
|
7240
|
+
form: FormBuilderTool,
|
|
7241
|
+
latex: LatexTool,
|
|
7242
|
+
mermaid: MermaidTool,
|
|
7243
|
+
bookmark: BookmarkTool,
|
|
7244
|
+
steps: StepsTool,
|
|
7245
|
+
diff: DiffTool,
|
|
7246
|
+
video: VideoTool,
|
|
7247
|
+
changelog: ChangelogTool,
|
|
7248
|
+
social: SocialTool,
|
|
7249
|
+
excalidraw: ExcalidrawTool,
|
|
7250
|
+
pullquote: PullQuoteTool,
|
|
7251
|
+
timeline: TimelineTool,
|
|
7252
|
+
stats: StatsTool,
|
|
7253
|
+
proscons: ProsConsTool,
|
|
7254
|
+
cards: CardsTool,
|
|
7255
|
+
badges: BadgesTool,
|
|
7256
|
+
tags: TagsTool,
|
|
7257
|
+
button: ButtonTool,
|
|
7258
|
+
dialogue: DialogueTool,
|
|
7259
|
+
// 4. Specialized / least frequent blocks
|
|
7260
|
+
gif: GifTool,
|
|
7261
|
+
compare: CompareTool,
|
|
7262
|
+
slides: SlidesTool,
|
|
7263
|
+
spoiler: SpoilerTool,
|
|
7264
|
+
collapsible: CollapsibleTool,
|
|
7265
|
+
attaches: AttachTool,
|
|
7266
|
+
nestedlist: import_nested_list.default,
|
|
7267
|
+
simpleImage: import_simple_image.default,
|
|
7268
|
+
comment: CommentTool,
|
|
7269
|
+
continueWriting: ContinueWritingTool,
|
|
7270
|
+
askAi: AskAiTool,
|
|
7271
|
+
today: TodayTool,
|
|
7272
|
+
export: ExportTriggerTool,
|
|
7273
|
+
settings: SettingsTriggerTool,
|
|
7274
|
+
// Inline toolbar tools
|
|
7275
|
+
inlineCode: import_inline_code.default,
|
|
7276
|
+
marker: MarkerInline,
|
|
7277
|
+
textColor: ColorInline,
|
|
7278
|
+
aiRewrite: AiRewriteInline,
|
|
7279
|
+
spoilerInline: SpoilerInline,
|
|
7280
|
+
underline: import_underline.default,
|
|
7281
|
+
strikethrough: import_strikethrough.default,
|
|
7282
|
+
hyperlink: HyperlinkInline,
|
|
7283
|
+
mention: MentionInline
|
|
6178
7284
|
};
|
|
6179
|
-
if (
|
|
6180
|
-
|
|
7285
|
+
if (enabledTools && enabledTools.length > 0) {
|
|
7286
|
+
const allowed = new Set(enabledTools);
|
|
7287
|
+
return Object.fromEntries(
|
|
7288
|
+
Object.entries(tools).filter(([key]) => allowed.has(key))
|
|
7289
|
+
);
|
|
6181
7290
|
}
|
|
6182
|
-
|
|
6183
|
-
method: "POST",
|
|
6184
|
-
headers,
|
|
6185
|
-
body: JSON.stringify({
|
|
6186
|
-
model,
|
|
6187
|
-
messages: [
|
|
6188
|
-
{ role: "system", content: systemPrompt },
|
|
6189
|
-
{ role: "user", content: userContent }
|
|
6190
|
-
]
|
|
6191
|
-
})
|
|
6192
|
-
});
|
|
6193
|
-
if (!res.ok) throw new Error(`AI API error (${res.status})`);
|
|
6194
|
-
const json = await res.json();
|
|
6195
|
-
return json.choices?.[0]?.message?.content?.trim() || "";
|
|
7291
|
+
return tools;
|
|
6196
7292
|
}
|
|
6197
7293
|
|
|
6198
7294
|
// src/utils/popoverCategories.ts
|
|
@@ -6216,6 +7312,7 @@ var TOOL_CATEGORIES = [
|
|
|
6216
7312
|
"callout",
|
|
6217
7313
|
"hotkey",
|
|
6218
7314
|
"emoji",
|
|
7315
|
+
"today",
|
|
6219
7316
|
"scratch",
|
|
6220
7317
|
"alert",
|
|
6221
7318
|
"badges",
|
|
@@ -6255,6 +7352,8 @@ var TOOL_CATEGORIES = [
|
|
|
6255
7352
|
"audio",
|
|
6256
7353
|
"musicCarousel",
|
|
6257
7354
|
"embed",
|
|
7355
|
+
"bookmark",
|
|
7356
|
+
"video",
|
|
6258
7357
|
"attaches",
|
|
6259
7358
|
"excalidraw"
|
|
6260
7359
|
]
|
|
@@ -6264,6 +7363,11 @@ var TOOL_CATEGORIES = [
|
|
|
6264
7363
|
tools: [
|
|
6265
7364
|
"code",
|
|
6266
7365
|
"latex",
|
|
7366
|
+
"mermaid",
|
|
7367
|
+
"diff",
|
|
7368
|
+
"steps",
|
|
7369
|
+
"changelog",
|
|
7370
|
+
"social",
|
|
6267
7371
|
"chart",
|
|
6268
7372
|
"table",
|
|
6269
7373
|
"stats",
|
|
@@ -6284,7 +7388,7 @@ var TOOL_CATEGORIES = [
|
|
|
6284
7388
|
},
|
|
6285
7389
|
{
|
|
6286
7390
|
label: "Settings",
|
|
6287
|
-
tools: ["settings"]
|
|
7391
|
+
tools: ["export", "settings"]
|
|
6288
7392
|
}
|
|
6289
7393
|
];
|
|
6290
7394
|
var SIMPLE_MODE_TOOLS = [
|
|
@@ -6350,6 +7454,14 @@ var TOOL_LABELS = {
|
|
|
6350
7454
|
excalidraw: "Excalidraw",
|
|
6351
7455
|
code: "Code Block",
|
|
6352
7456
|
latex: "LaTeX Math",
|
|
7457
|
+
mermaid: "Mermaid Diagram",
|
|
7458
|
+
bookmark: "Bookmark Card",
|
|
7459
|
+
steps: "Steps Walkthrough",
|
|
7460
|
+
diff: "Code Diff",
|
|
7461
|
+
video: "Video Player",
|
|
7462
|
+
changelog: "Changelog",
|
|
7463
|
+
social: "Social Quote",
|
|
7464
|
+
today: "Today Date",
|
|
6353
7465
|
chart: "Data Chart",
|
|
6354
7466
|
table: "Table",
|
|
6355
7467
|
stats: "Stats",
|
|
@@ -6368,6 +7480,7 @@ var TOOL_LABELS = {
|
|
|
6368
7480
|
slides: "Slides",
|
|
6369
7481
|
continueWriting: "Continue Writing",
|
|
6370
7482
|
askAi: "Ask AI",
|
|
7483
|
+
export: "Export / Import",
|
|
6371
7484
|
settings: "Settings"
|
|
6372
7485
|
};
|
|
6373
7486
|
function attachPopoverCategoryHeaders(container) {
|
|
@@ -6590,6 +7703,28 @@ var ClassicToolbar = ({
|
|
|
6590
7703
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn ng-ct-s", onMouseDown: keepSelection, onClick: () => exec("strikeThrough"), title: "Strikethrough", children: "S" }),
|
|
6591
7704
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => toggleInlineTag("code"), title: "Inline Code", children: "<>" }),
|
|
6592
7705
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn ng-ct-highlight", onMouseDown: keepSelection, onClick: () => toggleInlineTag("mark"), title: "Highlight", children: "A" }),
|
|
7706
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
7707
|
+
"input",
|
|
7708
|
+
{
|
|
7709
|
+
type: "color",
|
|
7710
|
+
className: "ng-ct-color",
|
|
7711
|
+
title: "Text Color",
|
|
7712
|
+
"aria-label": "Text Color",
|
|
7713
|
+
defaultValue: "#18181b",
|
|
7714
|
+
onChange: (e) => exec("foreColor", e.target.value)
|
|
7715
|
+
}
|
|
7716
|
+
),
|
|
7717
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
7718
|
+
"input",
|
|
7719
|
+
{
|
|
7720
|
+
type: "color",
|
|
7721
|
+
className: "ng-ct-color",
|
|
7722
|
+
title: "Highlight Color",
|
|
7723
|
+
"aria-label": "Highlight Color",
|
|
7724
|
+
defaultValue: "#fef08a",
|
|
7725
|
+
onChange: (e) => exec("hiliteColor", e.target.value)
|
|
7726
|
+
}
|
|
7727
|
+
),
|
|
6593
7728
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
6594
7729
|
"button",
|
|
6595
7730
|
{
|
|
@@ -6726,11 +7861,17 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
|
6726
7861
|
var SettingsModal = ({
|
|
6727
7862
|
open,
|
|
6728
7863
|
theme,
|
|
7864
|
+
docWidth,
|
|
6729
7865
|
mode,
|
|
6730
7866
|
showStats,
|
|
6731
7867
|
aiConfig,
|
|
6732
7868
|
selectedTools,
|
|
7869
|
+
allowedTools,
|
|
7870
|
+
canConfigureTools,
|
|
7871
|
+
developerRestricted,
|
|
7872
|
+
accessNoticeText,
|
|
6733
7873
|
onChangeTheme,
|
|
7874
|
+
onChangeDocWidth,
|
|
6734
7875
|
onChangeMode,
|
|
6735
7876
|
onChangeShowStats,
|
|
6736
7877
|
onChangeAiConfig,
|
|
@@ -6786,7 +7927,7 @@ var SettingsModal = ({
|
|
|
6786
7927
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-main", children: [
|
|
6787
7928
|
activeTab === "appearance" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-panel", children: [
|
|
6788
7929
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6789
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "
|
|
7930
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Appearance" }),
|
|
6790
7931
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6791
7932
|
"select",
|
|
6792
7933
|
{
|
|
@@ -6795,16 +7936,29 @@ var SettingsModal = ({
|
|
|
6795
7936
|
onChange: (e) => onChangeTheme(e.target.value),
|
|
6796
7937
|
children: [
|
|
6797
7938
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "inherit", children: "Inherit from Host App" }),
|
|
6798
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "light", children: "
|
|
6799
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "dark", children: "
|
|
6800
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "catppuccin-mocha", children: "Catppuccin Mocha" }),
|
|
6801
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "catppuccin-macchiato", children: "Catppuccin Macchiato" }),
|
|
6802
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "catppuccin-frappe", children: "Catppuccin Frapp\xE9" }),
|
|
6803
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "catppuccin-latte", children: "Catppuccin Latte" })
|
|
7939
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "light", children: "Light (White)" }),
|
|
7940
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "dark", children: "Dark (Black)" })
|
|
6804
7941
|
]
|
|
6805
7942
|
}
|
|
6806
7943
|
)
|
|
6807
7944
|
] }),
|
|
7945
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
7946
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Document Width" }),
|
|
7947
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-segmented", children: [
|
|
7948
|
+
{ id: "narrow", label: "Narrow" },
|
|
7949
|
+
{ id: "standard", label: "Standard" },
|
|
7950
|
+
{ id: "full", label: "Full-Width" }
|
|
7951
|
+
].map((w) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
7952
|
+
"button",
|
|
7953
|
+
{
|
|
7954
|
+
type: "button",
|
|
7955
|
+
className: `excalidraw-btn${docWidth === w.id ? " is-active" : ""}`,
|
|
7956
|
+
onClick: () => onChangeDocWidth(w.id),
|
|
7957
|
+
children: w.label
|
|
7958
|
+
},
|
|
7959
|
+
w.id
|
|
7960
|
+
)) })
|
|
7961
|
+
] }),
|
|
6808
7962
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6809
7963
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Editor Mode" }),
|
|
6810
7964
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-segmented", children: [
|
|
@@ -6906,21 +8060,28 @@ var SettingsModal = ({
|
|
|
6906
8060
|
] })
|
|
6907
8061
|
] }),
|
|
6908
8062
|
activeTab === "components" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-manager", children: [
|
|
8063
|
+
(developerRestricted || !canConfigureTools) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-dev-access-bar", role: "status", children: [
|
|
8064
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: "Access Managed by Developer:" }),
|
|
8065
|
+
" ",
|
|
8066
|
+
accessNoticeText || "Some commands are not enabled for this workspace and are hidden."
|
|
8067
|
+
] }),
|
|
6909
8068
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-header", children: [
|
|
6910
8069
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
6911
8070
|
"Registered Components (",
|
|
6912
8071
|
selectedSet.size,
|
|
6913
8072
|
"/",
|
|
6914
|
-
ALL_TOOL_NAMES.length,
|
|
8073
|
+
developerRestricted && allowedTools ? allowedTools.length : ALL_TOOL_NAMES.length,
|
|
6915
8074
|
")"
|
|
6916
8075
|
] }) }),
|
|
6917
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-actions", children: [
|
|
8076
|
+
canConfigureTools && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-actions", children: [
|
|
6918
8077
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6919
8078
|
"button",
|
|
6920
8079
|
{
|
|
6921
8080
|
type: "button",
|
|
6922
8081
|
className: "excalidraw-btn",
|
|
6923
|
-
onClick: () => onChangeSelectedTools(
|
|
8082
|
+
onClick: () => onChangeSelectedTools(
|
|
8083
|
+
developerRestricted && allowedTools ? [...allowedTools] : [...ALL_TOOL_NAMES]
|
|
8084
|
+
),
|
|
6924
8085
|
children: "All"
|
|
6925
8086
|
}
|
|
6926
8087
|
),
|
|
@@ -6929,7 +8090,11 @@ var SettingsModal = ({
|
|
|
6929
8090
|
{
|
|
6930
8091
|
type: "button",
|
|
6931
8092
|
className: "excalidraw-btn",
|
|
6932
|
-
onClick: () =>
|
|
8093
|
+
onClick: () => {
|
|
8094
|
+
const base = new Set(SIMPLE_MODE_TOOLS);
|
|
8095
|
+
const minimal = developerRestricted && allowedTools ? allowedTools.filter((t) => base.has(t)) : [...SIMPLE_MODE_TOOLS];
|
|
8096
|
+
onChangeSelectedTools(minimal);
|
|
8097
|
+
},
|
|
6933
8098
|
children: "Minimal"
|
|
6934
8099
|
}
|
|
6935
8100
|
)
|
|
@@ -6947,7 +8112,9 @@ var SettingsModal = ({
|
|
|
6947
8112
|
),
|
|
6948
8113
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-tools-groups", children: TOOL_CATEGORIES.filter((g) => g.label !== "Settings").map((group) => {
|
|
6949
8114
|
const q = toolFilter.trim().toLowerCase();
|
|
8115
|
+
const allowedSet = developerRestricted && allowedTools ? new Set(allowedTools) : null;
|
|
6950
8116
|
const visible = group.tools.filter((t) => {
|
|
8117
|
+
if (allowedSet && !allowedSet.has(t)) return false;
|
|
6951
8118
|
const label = (TOOL_LABELS[t] || t).toLowerCase();
|
|
6952
8119
|
return !q || label.includes(q) || t.toLowerCase().includes(q);
|
|
6953
8120
|
});
|
|
@@ -6959,14 +8126,17 @@ var SettingsModal = ({
|
|
|
6959
8126
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6960
8127
|
"label",
|
|
6961
8128
|
{
|
|
6962
|
-
className: `ng-tool-chip${checked ? " is-checked" : ""}`,
|
|
8129
|
+
className: `ng-tool-chip${checked ? " is-checked" : ""}${!canConfigureTools ? " is-locked" : ""}`,
|
|
6963
8130
|
children: [
|
|
6964
8131
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6965
8132
|
"input",
|
|
6966
8133
|
{
|
|
6967
8134
|
type: "checkbox",
|
|
6968
8135
|
checked,
|
|
6969
|
-
|
|
8136
|
+
disabled: !canConfigureTools,
|
|
8137
|
+
onChange: () => {
|
|
8138
|
+
if (canConfigureTools) toggleTool(tool);
|
|
8139
|
+
}
|
|
6970
8140
|
}
|
|
6971
8141
|
),
|
|
6972
8142
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: TOOL_LABELS[tool] || tool })
|
|
@@ -6983,13 +8153,320 @@ var SettingsModal = ({
|
|
|
6983
8153
|
] }) });
|
|
6984
8154
|
};
|
|
6985
8155
|
|
|
6986
|
-
// src/components/
|
|
8156
|
+
// src/components/ExportModal.tsx
|
|
8157
|
+
var import_react4 = require("react");
|
|
8158
|
+
|
|
8159
|
+
// src/utils/markdown.ts
|
|
8160
|
+
function stripHtmlTags(html) {
|
|
8161
|
+
return String(html == null ? "" : html).replace(/<br\s*\/?>/gi, "\n").replace(/<\/(p|div|li)>/gi, "\n").replace(/<[^>]+>/g, "").replace(/ /g, " ").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").trim();
|
|
8162
|
+
}
|
|
8163
|
+
function blocksToMarkdown(data) {
|
|
8164
|
+
if (!data || !Array.isArray(data.blocks)) return "";
|
|
8165
|
+
const parts = [];
|
|
8166
|
+
for (const block of data.blocks) {
|
|
8167
|
+
const d = block.data || {};
|
|
8168
|
+
switch (block.type) {
|
|
8169
|
+
case "header":
|
|
8170
|
+
case "h1":
|
|
8171
|
+
case "h2":
|
|
8172
|
+
case "h3": {
|
|
8173
|
+
const lvl = block.type === "h1" ? 1 : block.type === "h2" ? 2 : block.type === "h3" ? 3 : Number(d.level) || 2;
|
|
8174
|
+
parts.push(`${"#".repeat(Math.min(6, Math.max(1, lvl)))} ${stripHtmlTags(d.text)}`);
|
|
8175
|
+
break;
|
|
8176
|
+
}
|
|
8177
|
+
case "paragraph":
|
|
8178
|
+
parts.push(stripHtmlTags(d.text));
|
|
8179
|
+
break;
|
|
8180
|
+
case "quote":
|
|
8181
|
+
case "pullquote": {
|
|
8182
|
+
const quote = stripHtmlTags(d.text).split("\n").map((l) => `> ${l}`).join("\n");
|
|
8183
|
+
const cap = d.caption ? `
|
|
8184
|
+
> \u2014 ${stripHtmlTags(d.caption)}` : "";
|
|
8185
|
+
parts.push(`${quote}${cap}`);
|
|
8186
|
+
break;
|
|
8187
|
+
}
|
|
8188
|
+
case "list":
|
|
8189
|
+
case "nestedlist": {
|
|
8190
|
+
const ordered = d.style === "ordered";
|
|
8191
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
8192
|
+
const lines = items.map((item, idx) => {
|
|
8193
|
+
const txt = typeof item === "string" ? item : item?.content || item?.text || "";
|
|
8194
|
+
return `${ordered ? `${idx + 1}.` : "-"} ${stripHtmlTags(txt)}`;
|
|
8195
|
+
});
|
|
8196
|
+
parts.push(lines.join("\n"));
|
|
8197
|
+
break;
|
|
8198
|
+
}
|
|
8199
|
+
case "checklist":
|
|
8200
|
+
case "todo": {
|
|
8201
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
8202
|
+
parts.push(
|
|
8203
|
+
items.map((item) => `- [${item.checked || item.done ? "x" : " "}] ${stripHtmlTags(item.text || item.title)}`).join("\n")
|
|
8204
|
+
);
|
|
8205
|
+
break;
|
|
8206
|
+
}
|
|
8207
|
+
case "code":
|
|
8208
|
+
parts.push(`\`\`\`${d.language || ""}
|
|
8209
|
+
${d.code || ""}
|
|
8210
|
+
\`\`\``);
|
|
8211
|
+
break;
|
|
8212
|
+
case "mermaid":
|
|
8213
|
+
parts.push(`\`\`\`mermaid
|
|
8214
|
+
${d.code || ""}
|
|
8215
|
+
\`\`\``);
|
|
8216
|
+
break;
|
|
8217
|
+
case "latex":
|
|
8218
|
+
parts.push(`$$
|
|
8219
|
+
${d.tex || ""}
|
|
8220
|
+
$$`);
|
|
8221
|
+
break;
|
|
8222
|
+
case "delimiter":
|
|
8223
|
+
parts.push("---");
|
|
8224
|
+
break;
|
|
8225
|
+
case "image":
|
|
8226
|
+
case "simpleImage": {
|
|
8227
|
+
const url = d.file?.url || d.url || "";
|
|
8228
|
+
if (url) parts.push(``);
|
|
8229
|
+
break;
|
|
8230
|
+
}
|
|
8231
|
+
case "bookmark":
|
|
8232
|
+
parts.push(`[${d.title || d.url || "Link"}](${d.url || "#"})`);
|
|
8233
|
+
break;
|
|
8234
|
+
case "steps": {
|
|
8235
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
8236
|
+
parts.push(
|
|
8237
|
+
items.map((s, i) => `${i + 1}. **${s.title || ""}** \u2014 ${s.body || ""}`).join("\n")
|
|
8238
|
+
);
|
|
8239
|
+
break;
|
|
8240
|
+
}
|
|
8241
|
+
case "diff":
|
|
8242
|
+
parts.push(`\`\`\`diff
|
|
8243
|
+
- ${String(d.before || "").replace(/\n/g, "\n- ")}
|
|
8244
|
+
+ ${String(d.after || "").replace(/\n/g, "\n+ ")}
|
|
8245
|
+
\`\`\``);
|
|
8246
|
+
break;
|
|
8247
|
+
case "changelog": {
|
|
8248
|
+
const items = Array.isArray(d.items) ? d.items : [];
|
|
8249
|
+
parts.push(
|
|
8250
|
+
`### ${d.version || "Release"} (${d.date || ""})
|
|
8251
|
+
` + items.map((i) => `- **${(i.kind || "added").toUpperCase()}**: ${i.text || ""}`).join("\n")
|
|
8252
|
+
);
|
|
8253
|
+
break;
|
|
8254
|
+
}
|
|
8255
|
+
case "social":
|
|
8256
|
+
parts.push(`> ${d.text || ""}
|
|
8257
|
+
> \u2014 ${d.author || ""} (${d.handle || ""})`);
|
|
8258
|
+
break;
|
|
8259
|
+
case "today":
|
|
8260
|
+
parts.push(`\u{1F4C5} ${d.date || ""}`);
|
|
8261
|
+
break;
|
|
8262
|
+
default:
|
|
8263
|
+
if (d.text) parts.push(stripHtmlTags(d.text));
|
|
8264
|
+
break;
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
return parts.filter(Boolean).join("\n\n");
|
|
8268
|
+
}
|
|
8269
|
+
function markdownToBlocks(markdown) {
|
|
8270
|
+
const lines = markdown.replace(/\r\n/g, "\n").split("\n");
|
|
8271
|
+
const blocks = [];
|
|
8272
|
+
let i = 0;
|
|
8273
|
+
while (i < lines.length) {
|
|
8274
|
+
const line = lines[i];
|
|
8275
|
+
const trimmed = line.trim();
|
|
8276
|
+
if (!trimmed) {
|
|
8277
|
+
i += 1;
|
|
8278
|
+
continue;
|
|
8279
|
+
}
|
|
8280
|
+
if (trimmed.startsWith("```")) {
|
|
8281
|
+
const lang = trimmed.slice(3).trim();
|
|
8282
|
+
const codeLines = [];
|
|
8283
|
+
i += 1;
|
|
8284
|
+
while (i < lines.length && !lines[i].trim().startsWith("```")) {
|
|
8285
|
+
codeLines.push(lines[i]);
|
|
8286
|
+
i += 1;
|
|
8287
|
+
}
|
|
8288
|
+
i += 1;
|
|
8289
|
+
if (lang === "mermaid") {
|
|
8290
|
+
blocks.push({ type: "mermaid", data: { code: codeLines.join("\n") } });
|
|
8291
|
+
} else {
|
|
8292
|
+
blocks.push({ type: "code", data: { code: codeLines.join("\n"), language: lang || void 0 } });
|
|
8293
|
+
}
|
|
8294
|
+
continue;
|
|
8295
|
+
}
|
|
8296
|
+
const headingMatch = trimmed.match(/^(#{1,3})\s+(.+)$/);
|
|
8297
|
+
if (headingMatch) {
|
|
8298
|
+
const level = headingMatch[1].length;
|
|
8299
|
+
const type = level === 1 ? "h1" : level === 2 ? "h2" : "h3";
|
|
8300
|
+
blocks.push({ type, data: { text: headingMatch[2], level } });
|
|
8301
|
+
i += 1;
|
|
8302
|
+
continue;
|
|
8303
|
+
}
|
|
8304
|
+
if (/^[-*_]{3,}$/.test(trimmed)) {
|
|
8305
|
+
blocks.push({ type: "delimiter", data: {} });
|
|
8306
|
+
i += 1;
|
|
8307
|
+
continue;
|
|
8308
|
+
}
|
|
8309
|
+
if (trimmed.startsWith("> ")) {
|
|
8310
|
+
const quoteLines = [];
|
|
8311
|
+
while (i < lines.length && lines[i].trim().startsWith("> ")) {
|
|
8312
|
+
quoteLines.push(lines[i].trim().slice(2));
|
|
8313
|
+
i += 1;
|
|
8314
|
+
}
|
|
8315
|
+
blocks.push({ type: "quote", data: { text: quoteLines.join("\n"), caption: "" } });
|
|
8316
|
+
continue;
|
|
8317
|
+
}
|
|
8318
|
+
if (/^[-*]\s+/.test(trimmed) || /^\d+\.\s+/.test(trimmed)) {
|
|
8319
|
+
const ordered = /^\d+\.\s+/.test(trimmed);
|
|
8320
|
+
const items = [];
|
|
8321
|
+
while (i < lines.length && (ordered ? /^\d+\.\s+/.test(lines[i].trim()) : /^[-*]\s+/.test(lines[i].trim()))) {
|
|
8322
|
+
items.push(lines[i].trim().replace(ordered ? /^\d+\.\s+/ : /^[-*]\s+/, ""));
|
|
8323
|
+
i += 1;
|
|
8324
|
+
}
|
|
8325
|
+
blocks.push({ type: "list", data: { style: ordered ? "ordered" : "unordered", items } });
|
|
8326
|
+
continue;
|
|
8327
|
+
}
|
|
8328
|
+
blocks.push({ type: "paragraph", data: { text: trimmed } });
|
|
8329
|
+
i += 1;
|
|
8330
|
+
}
|
|
8331
|
+
return blocks;
|
|
8332
|
+
}
|
|
8333
|
+
|
|
8334
|
+
// src/components/ExportModal.tsx
|
|
6987
8335
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6988
|
-
var
|
|
8336
|
+
var ExportModal = ({
|
|
8337
|
+
open,
|
|
8338
|
+
data,
|
|
8339
|
+
onImportBlocks,
|
|
8340
|
+
onClose
|
|
8341
|
+
}) => {
|
|
8342
|
+
const [importText, setImportText] = (0, import_react4.useState)("");
|
|
8343
|
+
const [copiedKind, setCopiedKind] = (0, import_react4.useState)(null);
|
|
8344
|
+
const markdown = (0, import_react4.useMemo)(() => open ? blocksToMarkdown(data) : "", [open, data]);
|
|
8345
|
+
const html = (0, import_react4.useMemo)(() => open ? blocksToHtml(data) : "", [open, data]);
|
|
8346
|
+
if (!open) return null;
|
|
8347
|
+
const copyText = async (text, kind) => {
|
|
8348
|
+
try {
|
|
8349
|
+
await navigator.clipboard.writeText(text);
|
|
8350
|
+
setCopiedKind(kind);
|
|
8351
|
+
window.setTimeout(() => setCopiedKind(null), 1500);
|
|
8352
|
+
} catch {
|
|
8353
|
+
}
|
|
8354
|
+
};
|
|
8355
|
+
const downloadFile = (content, filename, mime) => {
|
|
8356
|
+
const blob = new Blob([content], { type: mime });
|
|
8357
|
+
const url = URL.createObjectURL(blob);
|
|
8358
|
+
const a = document.createElement("a");
|
|
8359
|
+
a.href = url;
|
|
8360
|
+
a.download = filename;
|
|
8361
|
+
a.click();
|
|
8362
|
+
URL.revokeObjectURL(url);
|
|
8363
|
+
};
|
|
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: [
|
|
8365
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-modal-head", children: [
|
|
8366
|
+
/* @__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." })
|
|
8369
|
+
] }),
|
|
8370
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
|
|
8371
|
+
] }),
|
|
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();
|
|
8451
|
+
}
|
|
8452
|
+
},
|
|
8453
|
+
children: "Append Markdown as Blocks"
|
|
8454
|
+
}
|
|
8455
|
+
) })
|
|
8456
|
+
] })
|
|
8457
|
+
] })
|
|
8458
|
+
] }) });
|
|
8459
|
+
};
|
|
8460
|
+
|
|
8461
|
+
// src/components/BlockEditor.tsx
|
|
8462
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
8463
|
+
var BlockEditor = import_react5.default.forwardRef(
|
|
6989
8464
|
({
|
|
6990
8465
|
initialData,
|
|
6991
8466
|
placeholder,
|
|
6992
8467
|
enabledTools,
|
|
8468
|
+
allowToolConfiguration,
|
|
8469
|
+
accessNoticeText,
|
|
6993
8470
|
showStats = true,
|
|
6994
8471
|
showAiBar = false,
|
|
6995
8472
|
onAiRequest,
|
|
@@ -6998,28 +8475,37 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
6998
8475
|
onChange,
|
|
6999
8476
|
onThemeChange
|
|
7000
8477
|
}, ref) => {
|
|
7001
|
-
const shellRef = (0,
|
|
7002
|
-
const holderRef = (0,
|
|
7003
|
-
const editorRef = (0,
|
|
7004
|
-
const undoRef = (0,
|
|
7005
|
-
const lifecycleRef = (0,
|
|
7006
|
-
const latestDocRef = (0,
|
|
7007
|
-
const onChangeRef = (0,
|
|
7008
|
-
const onReadyRef = (0,
|
|
7009
|
-
const runAiRef = (0,
|
|
7010
|
-
});
|
|
7011
|
-
const [settingsOpen, setSettingsOpen] = (0,
|
|
7012
|
-
const [
|
|
8478
|
+
const shellRef = (0, import_react5.useRef)(null);
|
|
8479
|
+
const holderRef = (0, import_react5.useRef)(null);
|
|
8480
|
+
const editorRef = (0, import_react5.useRef)(null);
|
|
8481
|
+
const undoRef = (0, import_react5.useRef)(null);
|
|
8482
|
+
const lifecycleRef = (0, import_react5.useRef)(Promise.resolve());
|
|
8483
|
+
const latestDocRef = (0, import_react5.useRef)(initialData || { blocks: [] });
|
|
8484
|
+
const onChangeRef = (0, import_react5.useRef)(onChange);
|
|
8485
|
+
const onReadyRef = (0, import_react5.useRef)(onReady);
|
|
8486
|
+
const runAiRef = (0, import_react5.useRef)(async () => {
|
|
8487
|
+
});
|
|
8488
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react5.useState)(false);
|
|
8489
|
+
const [exportOpen, setExportOpen] = (0, import_react5.useState)(false);
|
|
8490
|
+
const [theme, setTheme] = (0, import_react5.useState)(() => {
|
|
7013
8491
|
try {
|
|
7014
8492
|
const saved = localStorage.getItem("ng-editor-theme");
|
|
7015
|
-
if (saved) return saved;
|
|
8493
|
+
if (saved === "light" || saved === "dark" || saved === "inherit") return saved;
|
|
7016
8494
|
} catch {
|
|
7017
8495
|
}
|
|
7018
8496
|
return "inherit";
|
|
7019
8497
|
});
|
|
7020
|
-
const [
|
|
7021
|
-
|
|
7022
|
-
|
|
8498
|
+
const [docWidth, setDocWidth] = (0, import_react5.useState)(() => {
|
|
8499
|
+
try {
|
|
8500
|
+
const saved = localStorage.getItem("ng-editor-width");
|
|
8501
|
+
if (saved === "narrow" || saved === "standard" || saved === "full") return saved;
|
|
8502
|
+
} catch {
|
|
8503
|
+
}
|
|
8504
|
+
return "full";
|
|
8505
|
+
});
|
|
8506
|
+
const [editorMode, setEditorMode] = (0, import_react5.useState)("block");
|
|
8507
|
+
const [simpleFont, setSimpleFont] = (0, import_react5.useState)("sans");
|
|
8508
|
+
const [selectedTools, setSelectedTools] = (0, import_react5.useState)(() => {
|
|
7023
8509
|
if (enabledTools && enabledTools.length > 0) return enabledTools;
|
|
7024
8510
|
try {
|
|
7025
8511
|
const raw = localStorage.getItem("ng-enabled-tools");
|
|
@@ -7031,23 +8517,28 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7031
8517
|
}
|
|
7032
8518
|
return ALL_TOOL_NAMES;
|
|
7033
8519
|
});
|
|
7034
|
-
const [statsVisible, setStatsVisible] = (0,
|
|
7035
|
-
const
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
const
|
|
7039
|
-
const
|
|
7040
|
-
const [
|
|
7041
|
-
const [
|
|
8520
|
+
const [statsVisible, setStatsVisible] = (0, import_react5.useState)(showStats);
|
|
8521
|
+
const developerRestricted = Boolean(
|
|
8522
|
+
enabledTools && enabledTools.length > 0 && allowToolConfiguration !== true
|
|
8523
|
+
);
|
|
8524
|
+
const canConfigureTools = allowToolConfiguration ?? !developerRestricted;
|
|
8525
|
+
const effectiveSelectedTools = developerRestricted && enabledTools ? enabledTools : selectedTools;
|
|
8526
|
+
const [aiConfig, setAiConfig] = (0, import_react5.useState)(loadAiConfig);
|
|
8527
|
+
const [aiPopover, setAiPopover] = (0, import_react5.useState)(null);
|
|
8528
|
+
const [askPrompt, setAskPrompt] = (0, import_react5.useState)("");
|
|
8529
|
+
const [aiBusy, setAiBusy] = (0, import_react5.useState)(false);
|
|
8530
|
+
const [aiError, setAiError] = (0, import_react5.useState)(null);
|
|
8531
|
+
const [scratchOpen, setScratchOpen] = (0, import_react5.useState)(false);
|
|
8532
|
+
const [scratchText, setScratchText] = (0, import_react5.useState)(() => {
|
|
7042
8533
|
try {
|
|
7043
8534
|
return localStorage.getItem("ng-scratchpad-note") || "";
|
|
7044
8535
|
} catch {
|
|
7045
8536
|
return "";
|
|
7046
8537
|
}
|
|
7047
8538
|
});
|
|
7048
|
-
const [scratchCopied, setScratchCopied] = (0,
|
|
7049
|
-
const [scratchOffset, setScratchOffset] = (0,
|
|
7050
|
-
const [stats, setStats] = (0,
|
|
8539
|
+
const [scratchCopied, setScratchCopied] = (0, import_react5.useState)(false);
|
|
8540
|
+
const [scratchOffset, setScratchOffset] = (0, import_react5.useState)({ x: 0, y: 0 });
|
|
8541
|
+
const [stats, setStats] = (0, import_react5.useState)(() => {
|
|
7051
8542
|
const blocks = initialData?.blocks || [];
|
|
7052
8543
|
const text = blocks.map((b) => JSON.stringify(b.data || {})).join(" ");
|
|
7053
8544
|
const words = text.trim() ? text.trim().split(/\s+/).length : 0;
|
|
@@ -7055,10 +8546,10 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7055
8546
|
});
|
|
7056
8547
|
onChangeRef.current = onChange;
|
|
7057
8548
|
onReadyRef.current = onReady;
|
|
7058
|
-
(0,
|
|
8549
|
+
(0, import_react5.useEffect)(() => {
|
|
7059
8550
|
setStatsVisible(showStats);
|
|
7060
8551
|
}, [showStats]);
|
|
7061
|
-
(0,
|
|
8552
|
+
(0, import_react5.useEffect)(() => {
|
|
7062
8553
|
try {
|
|
7063
8554
|
localStorage.setItem("ng-editor-theme", theme);
|
|
7064
8555
|
} catch {
|
|
@@ -7070,7 +8561,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7070
8561
|
}
|
|
7071
8562
|
onThemeChange?.(theme);
|
|
7072
8563
|
}, [theme, onThemeChange]);
|
|
7073
|
-
(0,
|
|
8564
|
+
(0, import_react5.useEffect)(() => {
|
|
7074
8565
|
const shell = shellRef.current;
|
|
7075
8566
|
if (!shell) return;
|
|
7076
8567
|
const openAiNearRect = (mode, e) => {
|
|
@@ -7087,27 +8578,48 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7087
8578
|
setAiPopover({ mode, top, left });
|
|
7088
8579
|
};
|
|
7089
8580
|
const onOpenSettings = () => setSettingsOpen(true);
|
|
8581
|
+
const onOpenExport = () => setExportOpen(true);
|
|
7090
8582
|
const onAiContinue = (e) => openAiNearRect("continue", e);
|
|
7091
8583
|
const onAiAsk = (e) => openAiNearRect("ask", e);
|
|
7092
8584
|
const onOpenScratch = () => setScratchOpen(true);
|
|
8585
|
+
const onKeyDown = async (e) => {
|
|
8586
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "d") {
|
|
8587
|
+
e.preventDefault();
|
|
8588
|
+
const ed = editorRef.current;
|
|
8589
|
+
if (!ed) return;
|
|
8590
|
+
try {
|
|
8591
|
+
const idx = ed.blocks.getCurrentBlockIndex();
|
|
8592
|
+
const saved = await ed.save();
|
|
8593
|
+
const blk = saved.blocks?.[idx];
|
|
8594
|
+
if (blk) {
|
|
8595
|
+
ed.blocks.insert(blk.type, blk.data, {}, idx + 1, true);
|
|
8596
|
+
}
|
|
8597
|
+
} catch {
|
|
8598
|
+
}
|
|
8599
|
+
}
|
|
8600
|
+
};
|
|
7093
8601
|
shell.addEventListener("nextgen-open-settings", onOpenSettings);
|
|
8602
|
+
shell.addEventListener("nextgen-open-export", onOpenExport);
|
|
7094
8603
|
shell.addEventListener("nextgen-ai-continue", onAiContinue);
|
|
7095
8604
|
shell.addEventListener("nextgen-ai-ask", onAiAsk);
|
|
7096
8605
|
shell.addEventListener("nextgen-open-scratch", onOpenScratch);
|
|
8606
|
+
shell.addEventListener("keydown", onKeyDown);
|
|
7097
8607
|
return () => {
|
|
7098
8608
|
shell.removeEventListener("nextgen-open-settings", onOpenSettings);
|
|
8609
|
+
shell.removeEventListener("nextgen-open-export", onOpenExport);
|
|
7099
8610
|
shell.removeEventListener("nextgen-ai-continue", onAiContinue);
|
|
7100
8611
|
shell.removeEventListener("nextgen-ai-ask", onAiAsk);
|
|
7101
8612
|
shell.removeEventListener("nextgen-open-scratch", onOpenScratch);
|
|
8613
|
+
shell.removeEventListener("keydown", onKeyDown);
|
|
7102
8614
|
};
|
|
7103
8615
|
}, []);
|
|
7104
|
-
(0,
|
|
8616
|
+
(0, import_react5.useEffect)(() => {
|
|
7105
8617
|
const holder = holderRef.current;
|
|
7106
8618
|
if (!holder) return;
|
|
7107
8619
|
let cancelled = false;
|
|
7108
8620
|
const detachCategories = attachPopoverCategoryHeaders(holder);
|
|
7109
8621
|
const detachEmoji = attachEmojiSidePicker(holder);
|
|
7110
|
-
const effectiveTools = Array.from(/* @__PURE__ */ new Set([...
|
|
8622
|
+
const effectiveTools = Array.from(/* @__PURE__ */ new Set([...effectiveSelectedTools, "settings"]));
|
|
7111
8623
|
const mount = async () => {
|
|
7112
8624
|
await lifecycleRef.current;
|
|
7113
8625
|
if (cancelled) return;
|
|
@@ -7173,8 +8685,8 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7173
8685
|
});
|
|
7174
8686
|
}
|
|
7175
8687
|
};
|
|
7176
|
-
}, [editorMode,
|
|
7177
|
-
(0,
|
|
8688
|
+
}, [editorMode, effectiveSelectedTools]);
|
|
8689
|
+
(0, import_react5.useImperativeHandle)(ref, () => ({
|
|
7178
8690
|
save: async () => {
|
|
7179
8691
|
if (!editorRef.current) return null;
|
|
7180
8692
|
await editorRef.current.isReady;
|
|
@@ -7249,17 +8761,18 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7249
8761
|
setEditorMode(nextMode);
|
|
7250
8762
|
};
|
|
7251
8763
|
const readMins = Math.max(1, Math.ceil(stats.words / 200));
|
|
7252
|
-
return /* @__PURE__ */ (0,
|
|
8764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
7253
8765
|
"div",
|
|
7254
8766
|
{
|
|
7255
8767
|
ref: shellRef,
|
|
7256
8768
|
"data-ng-theme": theme === "inherit" ? void 0 : theme,
|
|
8769
|
+
"data-ng-width": docWidth,
|
|
7257
8770
|
"data-ng-font": editorMode === "simple" ? simpleFont : void 0,
|
|
7258
8771
|
className: className ? `nextgen-editor-shell ${className}` : "nextgen-editor-shell",
|
|
7259
8772
|
children: [
|
|
7260
|
-
showAiBar && /* @__PURE__ */ (0,
|
|
7261
|
-
/* @__PURE__ */ (0,
|
|
7262
|
-
/* @__PURE__ */ (0,
|
|
8773
|
+
showAiBar && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ng-ai-bar", children: [
|
|
8774
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ng-ai-actions", children: [
|
|
8775
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7263
8776
|
"button",
|
|
7264
8777
|
{
|
|
7265
8778
|
type: "button",
|
|
@@ -7269,7 +8782,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7269
8782
|
children: aiBusy ? "Thinking\u2026" : "\u2726 Continue Writing"
|
|
7270
8783
|
}
|
|
7271
8784
|
),
|
|
7272
|
-
/* @__PURE__ */ (0,
|
|
8785
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7273
8786
|
"button",
|
|
7274
8787
|
{
|
|
7275
8788
|
type: "button",
|
|
@@ -7282,7 +8795,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7282
8795
|
}
|
|
7283
8796
|
)
|
|
7284
8797
|
] }),
|
|
7285
|
-
/* @__PURE__ */ (0,
|
|
8798
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7286
8799
|
"button",
|
|
7287
8800
|
{
|
|
7288
8801
|
type: "button",
|
|
@@ -7293,7 +8806,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7293
8806
|
}
|
|
7294
8807
|
)
|
|
7295
8808
|
] }),
|
|
7296
|
-
editorMode === "simple" && /* @__PURE__ */ (0,
|
|
8809
|
+
editorMode === "simple" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7297
8810
|
ClassicToolbar,
|
|
7298
8811
|
{
|
|
7299
8812
|
editorRef,
|
|
@@ -7301,38 +8814,50 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7301
8814
|
onRedo: () => undoRef.current?.redo?.(),
|
|
7302
8815
|
fontFamily: simpleFont,
|
|
7303
8816
|
onChangeFontFamily: setSimpleFont,
|
|
7304
|
-
enabledTools:
|
|
8817
|
+
enabledTools: effectiveSelectedTools,
|
|
7305
8818
|
onOpenSettings: () => setSettingsOpen(true)
|
|
7306
8819
|
}
|
|
7307
8820
|
),
|
|
7308
|
-
/* @__PURE__ */ (0,
|
|
7309
|
-
statsVisible && /* @__PURE__ */ (0,
|
|
7310
|
-
/* @__PURE__ */ (0,
|
|
7311
|
-
/* @__PURE__ */ (0,
|
|
7312
|
-
/* @__PURE__ */ (0,
|
|
8821
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: "editorjs", ref: holderRef }),
|
|
8822
|
+
statsVisible && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "nextgen-editor-stats", children: [
|
|
8823
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: editorMode === "simple" ? "Simple Mode" : "Block Editor" }),
|
|
8824
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u2022" }),
|
|
8825
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
7313
8826
|
stats.blocks,
|
|
7314
8827
|
" blocks"
|
|
7315
8828
|
] }),
|
|
7316
|
-
/* @__PURE__ */ (0,
|
|
8829
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
7317
8830
|
stats.words,
|
|
7318
8831
|
" words"
|
|
7319
8832
|
] }),
|
|
7320
|
-
/* @__PURE__ */ (0,
|
|
8833
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
|
|
7321
8834
|
"~",
|
|
7322
8835
|
readMins,
|
|
7323
8836
|
" min read"
|
|
7324
8837
|
] })
|
|
7325
8838
|
] }),
|
|
7326
|
-
/* @__PURE__ */ (0,
|
|
8839
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7327
8840
|
SettingsModal,
|
|
7328
8841
|
{
|
|
7329
8842
|
open: settingsOpen,
|
|
7330
8843
|
theme,
|
|
8844
|
+
docWidth,
|
|
7331
8845
|
mode: editorMode,
|
|
7332
8846
|
showStats: statsVisible,
|
|
7333
8847
|
aiConfig,
|
|
7334
|
-
selectedTools,
|
|
8848
|
+
selectedTools: effectiveSelectedTools,
|
|
8849
|
+
allowedTools: enabledTools,
|
|
8850
|
+
canConfigureTools,
|
|
8851
|
+
developerRestricted,
|
|
8852
|
+
accessNoticeText,
|
|
7335
8853
|
onChangeTheme: setTheme,
|
|
8854
|
+
onChangeDocWidth: (w) => {
|
|
8855
|
+
setDocWidth(w);
|
|
8856
|
+
try {
|
|
8857
|
+
localStorage.setItem("ng-editor-width", w);
|
|
8858
|
+
} catch {
|
|
8859
|
+
}
|
|
8860
|
+
},
|
|
7336
8861
|
onChangeMode: (m) => void handleModeSwitch(m),
|
|
7337
8862
|
onChangeShowStats: setStatsVisible,
|
|
7338
8863
|
onChangeAiConfig: (cfg) => {
|
|
@@ -7350,7 +8875,22 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7350
8875
|
onClose: () => setSettingsOpen(false)
|
|
7351
8876
|
}
|
|
7352
8877
|
),
|
|
7353
|
-
|
|
8878
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
8879
|
+
ExportModal,
|
|
8880
|
+
{
|
|
8881
|
+
open: exportOpen,
|
|
8882
|
+
data: latestDocRef.current,
|
|
8883
|
+
onImportBlocks: (blocks) => {
|
|
8884
|
+
const ed = editorRef.current;
|
|
8885
|
+
if (!ed) return;
|
|
8886
|
+
blocks.forEach((b) => {
|
|
8887
|
+
ed.blocks.insert(b.type, b.data);
|
|
8888
|
+
});
|
|
8889
|
+
},
|
|
8890
|
+
onClose: () => setExportOpen(false)
|
|
8891
|
+
}
|
|
8892
|
+
),
|
|
8893
|
+
aiPopover && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
7354
8894
|
"form",
|
|
7355
8895
|
{
|
|
7356
8896
|
className: "ng-ai-inline-popover",
|
|
@@ -7364,9 +8904,9 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7364
8904
|
}
|
|
7365
8905
|
},
|
|
7366
8906
|
children: [
|
|
7367
|
-
/* @__PURE__ */ (0,
|
|
7368
|
-
/* @__PURE__ */ (0,
|
|
7369
|
-
/* @__PURE__ */ (0,
|
|
8907
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ng-ai-inline-head", children: [
|
|
8908
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: aiPopover.mode === "continue" ? "\u2726 Continue Writing" : "Ask AI" }),
|
|
8909
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7370
8910
|
"button",
|
|
7371
8911
|
{
|
|
7372
8912
|
type: "button",
|
|
@@ -7377,8 +8917,8 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7377
8917
|
}
|
|
7378
8918
|
)
|
|
7379
8919
|
] }),
|
|
7380
|
-
/* @__PURE__ */ (0,
|
|
7381
|
-
/* @__PURE__ */ (0,
|
|
8920
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ng-ai-inline-row", children: [
|
|
8921
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7382
8922
|
"input",
|
|
7383
8923
|
{
|
|
7384
8924
|
type: "text",
|
|
@@ -7392,7 +8932,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7392
8932
|
}
|
|
7393
8933
|
}
|
|
7394
8934
|
),
|
|
7395
|
-
/* @__PURE__ */ (0,
|
|
8935
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7396
8936
|
"button",
|
|
7397
8937
|
{
|
|
7398
8938
|
type: "submit",
|
|
@@ -7402,11 +8942,11 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7402
8942
|
}
|
|
7403
8943
|
)
|
|
7404
8944
|
] }),
|
|
7405
|
-
aiError && /* @__PURE__ */ (0,
|
|
8945
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "ng-ai-error", children: aiError })
|
|
7406
8946
|
]
|
|
7407
8947
|
}
|
|
7408
8948
|
),
|
|
7409
|
-
scratchOpen && /* @__PURE__ */ (0,
|
|
8949
|
+
scratchOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
7410
8950
|
"div",
|
|
7411
8951
|
{
|
|
7412
8952
|
className: "ng-scratch-sticky",
|
|
@@ -7416,7 +8956,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7416
8956
|
transform: `translate(${scratchOffset.x}px, ${scratchOffset.y}px)`
|
|
7417
8957
|
},
|
|
7418
8958
|
children: [
|
|
7419
|
-
/* @__PURE__ */ (0,
|
|
8959
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
7420
8960
|
"div",
|
|
7421
8961
|
{
|
|
7422
8962
|
className: "ng-scratch-sticky-head",
|
|
@@ -7435,15 +8975,15 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7435
8975
|
window.addEventListener("mouseup", onUp);
|
|
7436
8976
|
},
|
|
7437
8977
|
children: [
|
|
7438
|
-
/* @__PURE__ */ (0,
|
|
7439
|
-
/* @__PURE__ */ (0,
|
|
8978
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "ng-scratch-sticky-title", children: "\u{1F4DD} Scratchpad" }),
|
|
8979
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "ng-scratch-sticky-count", children: [
|
|
7440
8980
|
scratchText.trim() ? scratchText.trim().split(/\s+/).length : 0,
|
|
7441
8981
|
"w \xB7 ",
|
|
7442
8982
|
scratchText.length,
|
|
7443
8983
|
"c"
|
|
7444
8984
|
] }),
|
|
7445
|
-
/* @__PURE__ */ (0,
|
|
7446
|
-
/* @__PURE__ */ (0,
|
|
8985
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "ng-scratch-sticky-actions", children: [
|
|
8986
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7447
8987
|
"button",
|
|
7448
8988
|
{
|
|
7449
8989
|
type: "button",
|
|
@@ -7457,7 +8997,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7457
8997
|
children: scratchCopied ? "Copied" : "Copy"
|
|
7458
8998
|
}
|
|
7459
8999
|
),
|
|
7460
|
-
/* @__PURE__ */ (0,
|
|
9000
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7461
9001
|
"button",
|
|
7462
9002
|
{
|
|
7463
9003
|
type: "button",
|
|
@@ -7472,7 +9012,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7472
9012
|
children: "Clear"
|
|
7473
9013
|
}
|
|
7474
9014
|
),
|
|
7475
|
-
/* @__PURE__ */ (0,
|
|
9015
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7476
9016
|
"button",
|
|
7477
9017
|
{
|
|
7478
9018
|
type: "button",
|
|
@@ -7486,7 +9026,7 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7486
9026
|
]
|
|
7487
9027
|
}
|
|
7488
9028
|
),
|
|
7489
|
-
/* @__PURE__ */ (0,
|
|
9029
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7490
9030
|
"textarea",
|
|
7491
9031
|
{
|
|
7492
9032
|
className: "ng-scratch-sticky-body",
|
|
@@ -7513,13 +9053,13 @@ var BlockEditor = import_react4.default.forwardRef(
|
|
|
7513
9053
|
BlockEditor.displayName = "BlockEditor";
|
|
7514
9054
|
|
|
7515
9055
|
// src/components/BlockRenderer.tsx
|
|
7516
|
-
var
|
|
9056
|
+
var import_react7 = require("react");
|
|
7517
9057
|
|
|
7518
9058
|
// src/hooks/useInteractiveArticle.ts
|
|
7519
9059
|
var import_auto2 = __toESM(require("chart.js/auto"), 1);
|
|
7520
|
-
var
|
|
9060
|
+
var import_react6 = require("react");
|
|
7521
9061
|
function useInteractiveArticle(containerRef, depKey) {
|
|
7522
|
-
(0,
|
|
9062
|
+
(0, import_react6.useEffect)(() => {
|
|
7523
9063
|
const root = containerRef.current;
|
|
7524
9064
|
if (!root) return;
|
|
7525
9065
|
const cleanups = [];
|
|
@@ -8202,6 +9742,12 @@ function useInteractiveArticle(containerRef, depKey) {
|
|
|
8202
9742
|
btn.addEventListener("click", onOpen);
|
|
8203
9743
|
cleanups.push(() => btn.removeEventListener("click", onOpen));
|
|
8204
9744
|
});
|
|
9745
|
+
root.querySelectorAll("[data-mermaid]").forEach((el) => {
|
|
9746
|
+
const code = el.getAttribute("data-mermaid") || "";
|
|
9747
|
+
if (code.trim()) {
|
|
9748
|
+
void renderMermaidInto(el, code);
|
|
9749
|
+
}
|
|
9750
|
+
});
|
|
8205
9751
|
return () => {
|
|
8206
9752
|
cleanups.forEach((fn) => fn());
|
|
8207
9753
|
};
|
|
@@ -8209,15 +9755,33 @@ function useInteractiveArticle(containerRef, depKey) {
|
|
|
8209
9755
|
}
|
|
8210
9756
|
|
|
8211
9757
|
// src/components/BlockRenderer.tsx
|
|
8212
|
-
var
|
|
9758
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
8213
9759
|
var BlockRenderer = ({
|
|
8214
9760
|
data,
|
|
8215
9761
|
theme,
|
|
8216
9762
|
className
|
|
8217
9763
|
}) => {
|
|
8218
|
-
const bodyRef = (0,
|
|
8219
|
-
const
|
|
9764
|
+
const bodyRef = (0, import_react7.useRef)(null);
|
|
9765
|
+
const [progress, setProgress] = (0, import_react7.useState)(0);
|
|
9766
|
+
const html = (0, import_react7.useMemo)(() => blocksToHtml(data), [data]);
|
|
8220
9767
|
useInteractiveArticle(bodyRef, html);
|
|
9768
|
+
(0, import_react7.useEffect)(() => {
|
|
9769
|
+
const updateProgress = () => {
|
|
9770
|
+
const el = bodyRef.current;
|
|
9771
|
+
if (!el) return;
|
|
9772
|
+
const rect = el.getBoundingClientRect();
|
|
9773
|
+
const total = Math.max(1, el.scrollHeight - window.innerHeight);
|
|
9774
|
+
const scrolled = Math.min(total, Math.max(0, -rect.top));
|
|
9775
|
+
setProgress(Math.round(scrolled / total * 100));
|
|
9776
|
+
};
|
|
9777
|
+
updateProgress();
|
|
9778
|
+
window.addEventListener("scroll", updateProgress, { passive: true });
|
|
9779
|
+
window.addEventListener("resize", updateProgress);
|
|
9780
|
+
return () => {
|
|
9781
|
+
window.removeEventListener("scroll", updateProgress);
|
|
9782
|
+
window.removeEventListener("resize", updateProgress);
|
|
9783
|
+
};
|
|
9784
|
+
}, [html]);
|
|
8221
9785
|
let resolvedTheme = theme;
|
|
8222
9786
|
if (!resolvedTheme && typeof window !== "undefined") {
|
|
8223
9787
|
resolvedTheme = document.documentElement.getAttribute("data-ng-theme") || (() => {
|
|
@@ -8228,20 +9792,23 @@ var BlockRenderer = ({
|
|
|
8228
9792
|
}
|
|
8229
9793
|
})();
|
|
8230
9794
|
}
|
|
8231
|
-
const attrTheme = resolvedTheme
|
|
8232
|
-
return /* @__PURE__ */ (0,
|
|
9795
|
+
const attrTheme = resolvedTheme === "light" || resolvedTheme === "dark" ? resolvedTheme : void 0;
|
|
9796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
8233
9797
|
"div",
|
|
8234
9798
|
{
|
|
8235
9799
|
ref: bodyRef,
|
|
8236
9800
|
"data-ng-theme": attrTheme,
|
|
8237
9801
|
className: className ? `article nextgen-editor-article ${className}` : "article nextgen-editor-article",
|
|
8238
|
-
|
|
9802
|
+
children: [
|
|
9803
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ng-reading-progress", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "ng-reading-progress-fill", style: { width: `${progress}%` } }) }),
|
|
9804
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { dangerouslySetInnerHTML: { __html: html } })
|
|
9805
|
+
]
|
|
8239
9806
|
}
|
|
8240
9807
|
);
|
|
8241
9808
|
};
|
|
8242
9809
|
|
|
8243
9810
|
// src/components/DocumentHeader.tsx
|
|
8244
|
-
var
|
|
9811
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
8245
9812
|
var DocumentHeader = ({
|
|
8246
9813
|
coverUrl,
|
|
8247
9814
|
gradient = "linear-gradient(135deg, #27272a 0%, #52525b 100%)",
|
|
@@ -8251,12 +9818,12 @@ var DocumentHeader = ({
|
|
|
8251
9818
|
className
|
|
8252
9819
|
}) => {
|
|
8253
9820
|
const bannerStyle = coverUrl ? { backgroundImage: `url("${coverUrl}")`, backgroundSize: "cover", backgroundPosition: "center" } : { background: gradient };
|
|
8254
|
-
return /* @__PURE__ */ (0,
|
|
8255
|
-
/* @__PURE__ */ (0,
|
|
8256
|
-
icon ? /* @__PURE__ */ (0,
|
|
8257
|
-
/* @__PURE__ */ (0,
|
|
8258
|
-
/* @__PURE__ */ (0,
|
|
8259
|
-
subtitle ? /* @__PURE__ */ (0,
|
|
9821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { className: className ? `editor-cover-card ${className}` : "editor-cover-card", children: [
|
|
9822
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "editor-cover-banner", style: bannerStyle }),
|
|
9823
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "editor-cover-icon", children: icon }) : null,
|
|
9824
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "editor-cover-meta", children: [
|
|
9825
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { className: "editor-cover-title", children: title }),
|
|
9826
|
+
subtitle ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "editor-cover-subtitle", children: subtitle }) : null
|
|
8260
9827
|
] })
|
|
8261
9828
|
] });
|
|
8262
9829
|
};
|
|
@@ -8266,8 +9833,10 @@ var DocumentHeader = ({
|
|
|
8266
9833
|
BlockRenderer,
|
|
8267
9834
|
DocumentHeader,
|
|
8268
9835
|
blocksToHtml,
|
|
9836
|
+
blocksToMarkdown,
|
|
8269
9837
|
escHtml,
|
|
8270
9838
|
getEditorTools,
|
|
9839
|
+
markdownToBlocks,
|
|
8271
9840
|
sanitizeInlineHtml,
|
|
8272
9841
|
slugify,
|
|
8273
9842
|
uploadFileToBucket,
|