nextgen-block-editor 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +495 -334
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +495 -334
- package/dist/styles.css +251 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,6 @@ import EditorJS from "@editorjs/editorjs";
|
|
|
9
9
|
import Header from "@editorjs/header";
|
|
10
10
|
import List from "@editorjs/list";
|
|
11
11
|
import NestedList from "@editorjs/nested-list";
|
|
12
|
-
import Checklist from "@editorjs/checklist";
|
|
13
12
|
import Table from "@editorjs/table";
|
|
14
13
|
import Quote from "@editorjs/quote";
|
|
15
14
|
import InlineCode from "@editorjs/inline-code";
|
|
@@ -1688,22 +1687,25 @@ function attachEmojiSidePicker(container) {
|
|
|
1688
1687
|
const triggerRange = document.createRange();
|
|
1689
1688
|
triggerRange.setStart(textNode, triggerStart);
|
|
1690
1689
|
triggerRange.setEnd(textNode, offset);
|
|
1691
|
-
const
|
|
1690
|
+
const rawRect = triggerRange.getBoundingClientRect();
|
|
1691
|
+
const rect = rawRect.width > 0 || rawRect.height > 0 ? rawRect : target.getBoundingClientRect();
|
|
1692
1692
|
openEmojiSideMenu({
|
|
1693
1693
|
anchorRect: rect,
|
|
1694
1694
|
onSelect: (emoji) => {
|
|
1695
|
-
if (
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1695
|
+
if (textNode.isConnected) {
|
|
1696
|
+
const current = textNode.data;
|
|
1697
|
+
textNode.data = current.slice(0, triggerStart) + emoji + current.slice(offset);
|
|
1698
|
+
const nextCaret = triggerStart + emoji.length;
|
|
1699
|
+
const newRange = document.createRange();
|
|
1700
|
+
newRange.setStart(textNode, nextCaret);
|
|
1701
|
+
newRange.setEnd(textNode, nextCaret);
|
|
1702
|
+
const s = window.getSelection();
|
|
1703
|
+
if (s) {
|
|
1704
|
+
s.removeAllRanges();
|
|
1705
|
+
s.addRange(newRange);
|
|
1706
|
+
}
|
|
1707
|
+
} else if (target.isConnected) {
|
|
1708
|
+
target.innerHTML = target.innerHTML.replace(/\/emoji/i, emoji);
|
|
1707
1709
|
}
|
|
1708
1710
|
target.focus();
|
|
1709
1711
|
target.dispatchEvent(new Event("input", { bubbles: true }));
|
|
@@ -3668,14 +3670,23 @@ function createActionTriggerTool(title, icon, eventName) {
|
|
|
3668
3670
|
}
|
|
3669
3671
|
render() {
|
|
3670
3672
|
const el = document.createElement("div");
|
|
3671
|
-
el.style.
|
|
3673
|
+
el.style.height = "1px";
|
|
3674
|
+
el.style.opacity = "0";
|
|
3675
|
+
el.style.pointerEvents = "none";
|
|
3672
3676
|
this.el = el;
|
|
3673
3677
|
return el;
|
|
3674
3678
|
}
|
|
3675
3679
|
rendered() {
|
|
3676
3680
|
if (this.fired || !this.el) return;
|
|
3677
3681
|
this.fired = true;
|
|
3678
|
-
this.el.
|
|
3682
|
+
const contentEl = this.el.closest(".ce-block__content") || this.el.closest(".ce-block") || this.el;
|
|
3683
|
+
const blockRect = contentEl.getBoundingClientRect();
|
|
3684
|
+
this.el.dispatchEvent(
|
|
3685
|
+
new CustomEvent(eventName, {
|
|
3686
|
+
bubbles: true,
|
|
3687
|
+
detail: { rect: blockRect }
|
|
3688
|
+
})
|
|
3689
|
+
);
|
|
3679
3690
|
window.setTimeout(() => {
|
|
3680
3691
|
try {
|
|
3681
3692
|
const idx = this.api.blocks.getCurrentBlockIndex();
|
|
@@ -4073,12 +4084,17 @@ var EmojiTool = class {
|
|
|
4073
4084
|
anchorRect: rect,
|
|
4074
4085
|
onSelect: (em) => {
|
|
4075
4086
|
if (this.isNewInsert && this.api?.blocks) {
|
|
4076
|
-
const
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4087
|
+
const blockEl = this.anchorEl?.closest(".ce-block");
|
|
4088
|
+
const parent = blockEl?.parentElement;
|
|
4089
|
+
const domIdx = blockEl && parent ? Array.from(parent.children).indexOf(blockEl) : -1;
|
|
4090
|
+
const idx = domIdx >= 0 ? domIdx : this.api.blocks.getCurrentBlockIndex();
|
|
4091
|
+
if (idx >= 0) {
|
|
4092
|
+
this.api.blocks.insert("paragraph", { text: `${em} ` }, {}, idx + 1, true);
|
|
4093
|
+
this.api.blocks.delete(idx);
|
|
4094
|
+
window.requestAnimationFrame(() => {
|
|
4095
|
+
this.api?.caret?.setToBlock(idx, "end");
|
|
4096
|
+
});
|
|
4097
|
+
}
|
|
4082
4098
|
return;
|
|
4083
4099
|
}
|
|
4084
4100
|
this.data.emoji = em;
|
|
@@ -4102,7 +4118,7 @@ var EmojiTool = class {
|
|
|
4102
4118
|
}
|
|
4103
4119
|
rendered() {
|
|
4104
4120
|
if (this.isNewInsert) {
|
|
4105
|
-
|
|
4121
|
+
window.requestAnimationFrame(() => this.openPickerAtAnchor());
|
|
4106
4122
|
}
|
|
4107
4123
|
}
|
|
4108
4124
|
save() {
|
|
@@ -4113,83 +4129,11 @@ var EmojiTool = class {
|
|
|
4113
4129
|
};
|
|
4114
4130
|
}
|
|
4115
4131
|
};
|
|
4116
|
-
var ScratchTool =
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 1 1 3 3L7 19l-4 1 1-4Z"/></svg>'
|
|
4122
|
-
};
|
|
4123
|
-
}
|
|
4124
|
-
constructor({ data }) {
|
|
4125
|
-
this.data = {
|
|
4126
|
-
title: data?.title ?? "Scratchpad",
|
|
4127
|
-
text: data?.text ?? ""
|
|
4128
|
-
};
|
|
4129
|
-
}
|
|
4130
|
-
render() {
|
|
4131
|
-
const wrap = document.createElement("div");
|
|
4132
|
-
wrap.className = "editor-scratch-tool";
|
|
4133
|
-
const head = document.createElement("div");
|
|
4134
|
-
head.className = "editor-scratch-head";
|
|
4135
|
-
const titleIn = document.createElement("input");
|
|
4136
|
-
titleIn.type = "text";
|
|
4137
|
-
titleIn.className = "cdx-input editor-scratch-title";
|
|
4138
|
-
titleIn.placeholder = "Scratchpad title...";
|
|
4139
|
-
titleIn.value = this.data.title ?? "Scratchpad";
|
|
4140
|
-
titleIn.addEventListener("input", () => {
|
|
4141
|
-
this.data.title = titleIn.value;
|
|
4142
|
-
});
|
|
4143
|
-
const stats = document.createElement("span");
|
|
4144
|
-
stats.className = "editor-scratch-stats";
|
|
4145
|
-
const updateStats = () => {
|
|
4146
|
-
const len = this.data.text.length;
|
|
4147
|
-
const words = this.data.text.trim() ? this.data.text.trim().split(/\s+/).length : 0;
|
|
4148
|
-
stats.textContent = `${words}w \xB7 ${len}c`;
|
|
4149
|
-
};
|
|
4150
|
-
const copyBtn = document.createElement("button");
|
|
4151
|
-
copyBtn.type = "button";
|
|
4152
|
-
copyBtn.className = "b2";
|
|
4153
|
-
copyBtn.textContent = "Copy";
|
|
4154
|
-
copyBtn.addEventListener("click", () => {
|
|
4155
|
-
if (!this.data.text) return;
|
|
4156
|
-
void navigator.clipboard?.writeText(this.data.text);
|
|
4157
|
-
copyBtn.textContent = "Copied";
|
|
4158
|
-
window.setTimeout(() => {
|
|
4159
|
-
copyBtn.textContent = "Copy";
|
|
4160
|
-
}, 1200);
|
|
4161
|
-
});
|
|
4162
|
-
const clearBtn = document.createElement("button");
|
|
4163
|
-
clearBtn.type = "button";
|
|
4164
|
-
clearBtn.className = "b2";
|
|
4165
|
-
clearBtn.textContent = "Clear";
|
|
4166
|
-
head.append(titleIn, stats, copyBtn, clearBtn);
|
|
4167
|
-
const textarea = document.createElement("textarea");
|
|
4168
|
-
textarea.className = "cdx-input editor-scratch-textarea";
|
|
4169
|
-
textarea.rows = 4;
|
|
4170
|
-
textarea.placeholder = "Quick brain dump, rough notes, snippets...";
|
|
4171
|
-
textarea.value = this.data.text || "";
|
|
4172
|
-
textarea.addEventListener("input", () => {
|
|
4173
|
-
this.data.text = textarea.value;
|
|
4174
|
-
updateStats();
|
|
4175
|
-
});
|
|
4176
|
-
clearBtn.addEventListener("click", () => {
|
|
4177
|
-
this.data.text = "";
|
|
4178
|
-
textarea.value = "";
|
|
4179
|
-
updateStats();
|
|
4180
|
-
textarea.focus();
|
|
4181
|
-
});
|
|
4182
|
-
updateStats();
|
|
4183
|
-
wrap.append(head, textarea);
|
|
4184
|
-
return wrap;
|
|
4185
|
-
}
|
|
4186
|
-
save() {
|
|
4187
|
-
return {
|
|
4188
|
-
title: this.data.title?.trim() || "Scratchpad",
|
|
4189
|
-
text: this.data.text
|
|
4190
|
-
};
|
|
4191
|
-
}
|
|
4192
|
-
};
|
|
4132
|
+
var ScratchTool = createActionTriggerTool(
|
|
4133
|
+
"Scratchpad",
|
|
4134
|
+
'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 1 1 3 3L7 19l-4 1 1-4Z"/></svg>',
|
|
4135
|
+
"nextgen-open-scratch"
|
|
4136
|
+
);
|
|
4193
4137
|
var DialogueTool = class {
|
|
4194
4138
|
data;
|
|
4195
4139
|
static get toolbox() {
|
|
@@ -5981,7 +5925,6 @@ function getEditorTools(includeLayout = true, enabledTools) {
|
|
|
5981
5925
|
}
|
|
5982
5926
|
},
|
|
5983
5927
|
delimiter: DelimiterTool,
|
|
5984
|
-
checklist: Checklist,
|
|
5985
5928
|
table: Table,
|
|
5986
5929
|
callout: CalloutTool,
|
|
5987
5930
|
hotkey: HotkeyTool,
|
|
@@ -6209,6 +6152,10 @@ ${userContent}` }] }]
|
|
|
6209
6152
|
|
|
6210
6153
|
// src/utils/popoverCategories.ts
|
|
6211
6154
|
var TOOL_CATEGORIES = [
|
|
6155
|
+
{
|
|
6156
|
+
label: "AI",
|
|
6157
|
+
tools: ["continueWriting", "askAi"]
|
|
6158
|
+
},
|
|
6212
6159
|
{
|
|
6213
6160
|
label: "Text & Style",
|
|
6214
6161
|
tools: [
|
|
@@ -6218,7 +6165,6 @@ var TOOL_CATEGORIES = [
|
|
|
6218
6165
|
"paragraph",
|
|
6219
6166
|
"list",
|
|
6220
6167
|
"nestedlist",
|
|
6221
|
-
"checklist",
|
|
6222
6168
|
"quote",
|
|
6223
6169
|
"pullquote",
|
|
6224
6170
|
"delimiter",
|
|
@@ -6291,10 +6237,6 @@ var TOOL_CATEGORIES = [
|
|
|
6291
6237
|
"slides"
|
|
6292
6238
|
]
|
|
6293
6239
|
},
|
|
6294
|
-
{
|
|
6295
|
-
label: "AI",
|
|
6296
|
-
tools: ["continueWriting", "askAi"]
|
|
6297
|
-
},
|
|
6298
6240
|
{
|
|
6299
6241
|
label: "Settings",
|
|
6300
6242
|
tools: ["settings"]
|
|
@@ -6322,9 +6264,8 @@ var TOOL_LABELS = {
|
|
|
6322
6264
|
h2: "Heading 2",
|
|
6323
6265
|
h3: "Heading 3",
|
|
6324
6266
|
paragraph: "Paragraph",
|
|
6325
|
-
list: "List",
|
|
6267
|
+
list: "List (Ordered / Unordered / Checklist)",
|
|
6326
6268
|
nestedlist: "Nested List",
|
|
6327
|
-
checklist: "Checklist",
|
|
6328
6269
|
quote: "Quote",
|
|
6329
6270
|
pullquote: "Pull Quote",
|
|
6330
6271
|
delimiter: "Delimiter",
|
|
@@ -6409,18 +6350,25 @@ function attachPopoverCategoryHeaders(container) {
|
|
|
6409
6350
|
titleEl.textContent = "Paragraph";
|
|
6410
6351
|
}
|
|
6411
6352
|
}
|
|
6412
|
-
if (name)
|
|
6413
|
-
|
|
6353
|
+
if (name) {
|
|
6354
|
+
const arr = byName.get(name) || [];
|
|
6355
|
+
arr.push(el);
|
|
6356
|
+
byName.set(name, arr);
|
|
6357
|
+
} else {
|
|
6358
|
+
uncategorized.push(el);
|
|
6359
|
+
}
|
|
6414
6360
|
});
|
|
6415
6361
|
const frag = document.createDocumentFragment();
|
|
6416
6362
|
const placed = /* @__PURE__ */ new Set();
|
|
6417
6363
|
for (const group of TOOL_CATEGORIES) {
|
|
6418
6364
|
const matched = [];
|
|
6419
6365
|
for (const toolName of group.tools) {
|
|
6420
|
-
const
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6366
|
+
const els = byName.get(toolName) || [];
|
|
6367
|
+
for (const el of els) {
|
|
6368
|
+
if (!placed.has(el)) {
|
|
6369
|
+
matched.push(el);
|
|
6370
|
+
placed.add(el);
|
|
6371
|
+
}
|
|
6424
6372
|
}
|
|
6425
6373
|
}
|
|
6426
6374
|
if (matched.length > 0) {
|
|
@@ -6634,7 +6582,7 @@ var ClassicToolbar = ({
|
|
|
6634
6582
|
/* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
|
|
6635
6583
|
/* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
6636
6584
|
] }) }),
|
|
6637
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("
|
|
6585
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "checklist", items: [] }), title: "Checklist", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6638
6586
|
/* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "6", height: "6", rx: "1" }),
|
|
6639
6587
|
/* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
|
|
6640
6588
|
/* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
|
|
@@ -6746,6 +6694,7 @@ var SettingsModal = ({
|
|
|
6746
6694
|
}) => {
|
|
6747
6695
|
const [showKey, setShowKey] = useState2(false);
|
|
6748
6696
|
const [toolFilter, setToolFilter] = useState2("");
|
|
6697
|
+
const [activeTab, setActiveTab] = useState2("appearance");
|
|
6749
6698
|
if (!open) return null;
|
|
6750
6699
|
const selectedSet = new Set(selectedTools);
|
|
6751
6700
|
const toggleTool = (tool) => {
|
|
@@ -6764,206 +6713,226 @@ var SettingsModal = ({
|
|
|
6764
6713
|
endpoint: preset?.defaultEndpoint || ""
|
|
6765
6714
|
});
|
|
6766
6715
|
};
|
|
6767
|
-
return /* @__PURE__ */ jsx2("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Editor Settings", children: /* @__PURE__ */ jsxs2("div", { className: "ng-modal", children: [
|
|
6716
|
+
return /* @__PURE__ */ jsx2("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Editor Settings", children: /* @__PURE__ */ jsxs2("div", { className: "ng-modal ng-modal-wide", children: [
|
|
6768
6717
|
/* @__PURE__ */ jsxs2("div", { className: "ng-modal-head", children: [
|
|
6769
6718
|
/* @__PURE__ */ jsxs2("div", { children: [
|
|
6770
6719
|
/* @__PURE__ */ jsx2("h3", { children: "Editor Settings" }),
|
|
6771
|
-
/* @__PURE__ */ jsx2("p", { children: "Configure appearance,
|
|
6720
|
+
/* @__PURE__ */ jsx2("p", { children: "Configure appearance, AI provider, and registered components." })
|
|
6772
6721
|
] }),
|
|
6773
6722
|
/* @__PURE__ */ jsx2("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
|
|
6774
6723
|
] }),
|
|
6775
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-modal-
|
|
6776
|
-
/* @__PURE__ */
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
}
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
onChange: (e) => handleProviderChange(e.target.value),
|
|
6840
|
-
children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ jsx2("option", { value: p.id, children: p.label }, p.id))
|
|
6841
|
-
}
|
|
6842
|
-
)
|
|
6843
|
-
] }),
|
|
6844
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6845
|
-
/* @__PURE__ */ jsx2("label", { children: "Model" }),
|
|
6846
|
-
/* @__PURE__ */ jsx2(
|
|
6847
|
-
"input",
|
|
6848
|
-
{
|
|
6849
|
-
type: "text",
|
|
6850
|
-
className: "cdx-input editor-form-input",
|
|
6851
|
-
value: aiConfig.model,
|
|
6852
|
-
placeholder: "e.g. gpt-4o-mini",
|
|
6853
|
-
onChange: (e) => onChangeAiConfig({ ...aiConfig, model: e.target.value })
|
|
6854
|
-
}
|
|
6855
|
-
)
|
|
6856
|
-
] }),
|
|
6857
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6858
|
-
/* @__PURE__ */ jsx2("label", { children: "API Key" }),
|
|
6859
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-key-row", children: [
|
|
6860
|
-
/* @__PURE__ */ jsx2(
|
|
6861
|
-
"input",
|
|
6862
|
-
{
|
|
6863
|
-
type: showKey ? "text" : "password",
|
|
6864
|
-
className: "cdx-input editor-form-input",
|
|
6865
|
-
value: aiConfig.apiKey,
|
|
6866
|
-
placeholder: "sk-...",
|
|
6867
|
-
onChange: (e) => onChangeAiConfig({ ...aiConfig, apiKey: e.target.value })
|
|
6868
|
-
}
|
|
6869
|
-
),
|
|
6870
|
-
/* @__PURE__ */ jsx2(
|
|
6871
|
-
"button",
|
|
6872
|
-
{
|
|
6873
|
-
type: "button",
|
|
6874
|
-
className: "excalidraw-btn",
|
|
6875
|
-
onClick: () => setShowKey((s) => !s),
|
|
6876
|
-
children: showKey ? "Hide" : "Show"
|
|
6877
|
-
}
|
|
6878
|
-
)
|
|
6879
|
-
] })
|
|
6880
|
-
] }),
|
|
6881
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6882
|
-
/* @__PURE__ */ jsx2("label", { children: "Endpoint URL (optional)" }),
|
|
6883
|
-
/* @__PURE__ */ jsx2(
|
|
6884
|
-
"input",
|
|
6885
|
-
{
|
|
6886
|
-
type: "url",
|
|
6887
|
-
className: "cdx-input editor-form-input",
|
|
6888
|
-
value: aiConfig.endpoint || "",
|
|
6889
|
-
placeholder: "Default provider endpoint",
|
|
6890
|
-
onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
|
|
6891
|
-
}
|
|
6892
|
-
)
|
|
6893
|
-
] }),
|
|
6894
|
-
/* @__PURE__ */ jsx2("hr", { className: "ng-divider" }),
|
|
6895
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-tools-manager", children: [
|
|
6896
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-tools-header", children: [
|
|
6897
|
-
/* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsxs2("label", { children: [
|
|
6898
|
-
"Registered Components (",
|
|
6899
|
-
selectedSet.size,
|
|
6900
|
-
"/",
|
|
6901
|
-
ALL_TOOL_NAMES.length,
|
|
6902
|
-
")"
|
|
6903
|
-
] }) }),
|
|
6904
|
-
/* @__PURE__ */ jsxs2("div", { className: "ng-tools-actions", children: [
|
|
6724
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-modal-layout", children: [
|
|
6725
|
+
/* @__PURE__ */ jsx2("aside", { className: "ng-modal-sidebar", role: "tablist", "aria-label": "Settings sections", children: [
|
|
6726
|
+
{ id: "appearance", label: "Appearance" },
|
|
6727
|
+
{ id: "ai", label: "AI Provider" },
|
|
6728
|
+
{ id: "components", label: `Components (${selectedSet.size})` }
|
|
6729
|
+
].map((t) => /* @__PURE__ */ jsx2(
|
|
6730
|
+
"button",
|
|
6731
|
+
{
|
|
6732
|
+
type: "button",
|
|
6733
|
+
role: "tab",
|
|
6734
|
+
"aria-selected": activeTab === t.id,
|
|
6735
|
+
className: `ng-modal-tab${activeTab === t.id ? " is-active" : ""}`,
|
|
6736
|
+
onClick: () => setActiveTab(t.id),
|
|
6737
|
+
children: t.label
|
|
6738
|
+
},
|
|
6739
|
+
t.id
|
|
6740
|
+
)) }),
|
|
6741
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-modal-main", children: [
|
|
6742
|
+
activeTab === "appearance" && /* @__PURE__ */ jsxs2("div", { className: "ng-modal-panel", children: [
|
|
6743
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6744
|
+
/* @__PURE__ */ jsx2("label", { children: "Theme" }),
|
|
6745
|
+
/* @__PURE__ */ jsxs2(
|
|
6746
|
+
"select",
|
|
6747
|
+
{
|
|
6748
|
+
className: "cdx-input editor-form-select",
|
|
6749
|
+
value: theme,
|
|
6750
|
+
onChange: (e) => onChangeTheme(e.target.value),
|
|
6751
|
+
children: [
|
|
6752
|
+
/* @__PURE__ */ jsx2("option", { value: "inherit", children: "Inherit from Host App" }),
|
|
6753
|
+
/* @__PURE__ */ jsx2("option", { value: "light", children: "shadcn Light" }),
|
|
6754
|
+
/* @__PURE__ */ jsx2("option", { value: "dark", children: "shadcn Dark" }),
|
|
6755
|
+
/* @__PURE__ */ jsx2("option", { value: "catppuccin-mocha", children: "Catppuccin Mocha" }),
|
|
6756
|
+
/* @__PURE__ */ jsx2("option", { value: "catppuccin-macchiato", children: "Catppuccin Macchiato" }),
|
|
6757
|
+
/* @__PURE__ */ jsx2("option", { value: "catppuccin-frappe", children: "Catppuccin Frapp\xE9" }),
|
|
6758
|
+
/* @__PURE__ */ jsx2("option", { value: "catppuccin-latte", children: "Catppuccin Latte" })
|
|
6759
|
+
]
|
|
6760
|
+
}
|
|
6761
|
+
)
|
|
6762
|
+
] }),
|
|
6763
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6764
|
+
/* @__PURE__ */ jsx2("label", { children: "Editor Mode" }),
|
|
6765
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-segmented", children: [
|
|
6766
|
+
/* @__PURE__ */ jsx2(
|
|
6767
|
+
"button",
|
|
6768
|
+
{
|
|
6769
|
+
type: "button",
|
|
6770
|
+
className: `excalidraw-btn${mode === "block" ? " is-active" : ""}`,
|
|
6771
|
+
onClick: () => onChangeMode("block"),
|
|
6772
|
+
children: "Block Editor (Full)"
|
|
6773
|
+
}
|
|
6774
|
+
),
|
|
6775
|
+
/* @__PURE__ */ jsx2(
|
|
6776
|
+
"button",
|
|
6777
|
+
{
|
|
6778
|
+
type: "button",
|
|
6779
|
+
className: `excalidraw-btn${mode === "simple" ? " is-active" : ""}`,
|
|
6780
|
+
onClick: () => onChangeMode("simple"),
|
|
6781
|
+
children: "Simple Mode"
|
|
6782
|
+
}
|
|
6783
|
+
)
|
|
6784
|
+
] })
|
|
6785
|
+
] }),
|
|
6786
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field ng-field-inline", children: [
|
|
6787
|
+
/* @__PURE__ */ jsx2("label", { htmlFor: "ng-stats-toggle", children: "Show word count & read time" }),
|
|
6905
6788
|
/* @__PURE__ */ jsx2(
|
|
6906
|
-
"
|
|
6789
|
+
"input",
|
|
6907
6790
|
{
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6791
|
+
id: "ng-stats-toggle",
|
|
6792
|
+
type: "checkbox",
|
|
6793
|
+
checked: showStats,
|
|
6794
|
+
onChange: (e) => onChangeShowStats(e.target.checked)
|
|
6912
6795
|
}
|
|
6913
|
-
)
|
|
6796
|
+
)
|
|
6797
|
+
] })
|
|
6798
|
+
] }),
|
|
6799
|
+
activeTab === "ai" && /* @__PURE__ */ jsxs2("div", { className: "ng-modal-panel", children: [
|
|
6800
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6801
|
+
/* @__PURE__ */ jsx2("label", { children: "AI Provider" }),
|
|
6914
6802
|
/* @__PURE__ */ jsx2(
|
|
6915
|
-
"
|
|
6803
|
+
"select",
|
|
6916
6804
|
{
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
children: "
|
|
6805
|
+
className: "cdx-input editor-form-select",
|
|
6806
|
+
value: aiConfig.provider,
|
|
6807
|
+
onChange: (e) => handleProviderChange(e.target.value),
|
|
6808
|
+
children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ jsx2("option", { value: p.id, children: p.label }, p.id))
|
|
6809
|
+
}
|
|
6810
|
+
)
|
|
6811
|
+
] }),
|
|
6812
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6813
|
+
/* @__PURE__ */ jsx2("label", { children: "Model" }),
|
|
6814
|
+
/* @__PURE__ */ jsx2(
|
|
6815
|
+
"input",
|
|
6816
|
+
{
|
|
6817
|
+
type: "text",
|
|
6818
|
+
className: "cdx-input editor-form-input",
|
|
6819
|
+
value: aiConfig.model,
|
|
6820
|
+
placeholder: "e.g. gpt-4o-mini",
|
|
6821
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, model: e.target.value })
|
|
6822
|
+
}
|
|
6823
|
+
)
|
|
6824
|
+
] }),
|
|
6825
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6826
|
+
/* @__PURE__ */ jsx2("label", { children: "API Key" }),
|
|
6827
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-key-row", children: [
|
|
6828
|
+
/* @__PURE__ */ jsx2(
|
|
6829
|
+
"input",
|
|
6830
|
+
{
|
|
6831
|
+
type: showKey ? "text" : "password",
|
|
6832
|
+
className: "cdx-input editor-form-input",
|
|
6833
|
+
value: aiConfig.apiKey,
|
|
6834
|
+
placeholder: "sk-...",
|
|
6835
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, apiKey: e.target.value })
|
|
6836
|
+
}
|
|
6837
|
+
),
|
|
6838
|
+
/* @__PURE__ */ jsx2(
|
|
6839
|
+
"button",
|
|
6840
|
+
{
|
|
6841
|
+
type: "button",
|
|
6842
|
+
className: "excalidraw-btn",
|
|
6843
|
+
onClick: () => setShowKey((s) => !s),
|
|
6844
|
+
children: showKey ? "Hide" : "Show"
|
|
6845
|
+
}
|
|
6846
|
+
)
|
|
6847
|
+
] })
|
|
6848
|
+
] }),
|
|
6849
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
|
|
6850
|
+
/* @__PURE__ */ jsx2("label", { children: "Endpoint URL (optional)" }),
|
|
6851
|
+
/* @__PURE__ */ jsx2(
|
|
6852
|
+
"input",
|
|
6853
|
+
{
|
|
6854
|
+
type: "url",
|
|
6855
|
+
className: "cdx-input editor-form-input",
|
|
6856
|
+
value: aiConfig.endpoint || "",
|
|
6857
|
+
placeholder: "Default provider endpoint",
|
|
6858
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
|
|
6921
6859
|
}
|
|
6922
6860
|
)
|
|
6923
6861
|
] })
|
|
6924
6862
|
] }),
|
|
6925
|
-
/* @__PURE__ */
|
|
6926
|
-
"
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
const visible = group.tools.filter((t) => {
|
|
6938
|
-
const label = (TOOL_LABELS[t] || t).toLowerCase();
|
|
6939
|
-
return !q || label.includes(q) || t.toLowerCase().includes(q);
|
|
6940
|
-
});
|
|
6941
|
-
if (!visible.length) return null;
|
|
6942
|
-
return /* @__PURE__ */ jsxs2("div", { className: "ng-tools-group", children: [
|
|
6943
|
-
/* @__PURE__ */ jsx2("div", { className: "ng-tools-group-title", children: group.label }),
|
|
6944
|
-
/* @__PURE__ */ jsx2("div", { className: "ng-tools-grid", children: visible.map((tool) => {
|
|
6945
|
-
const checked = selectedSet.has(tool);
|
|
6946
|
-
return /* @__PURE__ */ jsxs2(
|
|
6947
|
-
"label",
|
|
6863
|
+
activeTab === "components" && /* @__PURE__ */ jsxs2("div", { className: "ng-tools-manager", children: [
|
|
6864
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-tools-header", children: [
|
|
6865
|
+
/* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsxs2("label", { children: [
|
|
6866
|
+
"Registered Components (",
|
|
6867
|
+
selectedSet.size,
|
|
6868
|
+
"/",
|
|
6869
|
+
ALL_TOOL_NAMES.length,
|
|
6870
|
+
")"
|
|
6871
|
+
] }) }),
|
|
6872
|
+
/* @__PURE__ */ jsxs2("div", { className: "ng-tools-actions", children: [
|
|
6873
|
+
/* @__PURE__ */ jsx2(
|
|
6874
|
+
"button",
|
|
6948
6875
|
{
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
]
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
)
|
|
6964
|
-
|
|
6965
|
-
] },
|
|
6966
|
-
|
|
6876
|
+
type: "button",
|
|
6877
|
+
className: "excalidraw-btn",
|
|
6878
|
+
onClick: () => onChangeSelectedTools([...ALL_TOOL_NAMES]),
|
|
6879
|
+
children: "All"
|
|
6880
|
+
}
|
|
6881
|
+
),
|
|
6882
|
+
/* @__PURE__ */ jsx2(
|
|
6883
|
+
"button",
|
|
6884
|
+
{
|
|
6885
|
+
type: "button",
|
|
6886
|
+
className: "excalidraw-btn",
|
|
6887
|
+
onClick: () => onChangeSelectedTools([...SIMPLE_MODE_TOOLS]),
|
|
6888
|
+
children: "Minimal"
|
|
6889
|
+
}
|
|
6890
|
+
)
|
|
6891
|
+
] })
|
|
6892
|
+
] }),
|
|
6893
|
+
/* @__PURE__ */ jsx2(
|
|
6894
|
+
"input",
|
|
6895
|
+
{
|
|
6896
|
+
type: "search",
|
|
6897
|
+
className: "cdx-input editor-form-input",
|
|
6898
|
+
placeholder: "Filter components (e.g. bento, chart, spoiler...)",
|
|
6899
|
+
value: toolFilter,
|
|
6900
|
+
onChange: (e) => setToolFilter(e.target.value)
|
|
6901
|
+
}
|
|
6902
|
+
),
|
|
6903
|
+
/* @__PURE__ */ jsx2("div", { className: "ng-tools-groups", children: TOOL_CATEGORIES.filter((g) => g.label !== "Settings").map((group) => {
|
|
6904
|
+
const q = toolFilter.trim().toLowerCase();
|
|
6905
|
+
const visible = group.tools.filter((t) => {
|
|
6906
|
+
const label = (TOOL_LABELS[t] || t).toLowerCase();
|
|
6907
|
+
return !q || label.includes(q) || t.toLowerCase().includes(q);
|
|
6908
|
+
});
|
|
6909
|
+
if (!visible.length) return null;
|
|
6910
|
+
return /* @__PURE__ */ jsxs2("div", { className: "ng-tools-group", children: [
|
|
6911
|
+
/* @__PURE__ */ jsx2("div", { className: "ng-tools-group-title", children: group.label }),
|
|
6912
|
+
/* @__PURE__ */ jsx2("div", { className: "ng-tools-grid", children: visible.map((tool) => {
|
|
6913
|
+
const checked = selectedSet.has(tool);
|
|
6914
|
+
return /* @__PURE__ */ jsxs2(
|
|
6915
|
+
"label",
|
|
6916
|
+
{
|
|
6917
|
+
className: `ng-tool-chip${checked ? " is-checked" : ""}`,
|
|
6918
|
+
children: [
|
|
6919
|
+
/* @__PURE__ */ jsx2(
|
|
6920
|
+
"input",
|
|
6921
|
+
{
|
|
6922
|
+
type: "checkbox",
|
|
6923
|
+
checked,
|
|
6924
|
+
onChange: () => toggleTool(tool)
|
|
6925
|
+
}
|
|
6926
|
+
),
|
|
6927
|
+
/* @__PURE__ */ jsx2("span", { children: TOOL_LABELS[tool] || tool })
|
|
6928
|
+
]
|
|
6929
|
+
},
|
|
6930
|
+
tool
|
|
6931
|
+
);
|
|
6932
|
+
}) })
|
|
6933
|
+
] }, group.label);
|
|
6934
|
+
}) })
|
|
6935
|
+
] })
|
|
6967
6936
|
] })
|
|
6968
6937
|
] })
|
|
6969
6938
|
] }) });
|
|
@@ -6981,7 +6950,8 @@ var BlockEditor = React4.forwardRef(
|
|
|
6981
6950
|
onAiRequest,
|
|
6982
6951
|
className,
|
|
6983
6952
|
onReady,
|
|
6984
|
-
onChange
|
|
6953
|
+
onChange,
|
|
6954
|
+
onThemeChange
|
|
6985
6955
|
}, ref) => {
|
|
6986
6956
|
const shellRef = useRef2(null);
|
|
6987
6957
|
const holderRef = useRef2(null);
|
|
@@ -6994,7 +6964,14 @@ var BlockEditor = React4.forwardRef(
|
|
|
6994
6964
|
const runAiRef = useRef2(async () => {
|
|
6995
6965
|
});
|
|
6996
6966
|
const [settingsOpen, setSettingsOpen] = useState3(false);
|
|
6997
|
-
const [theme, setTheme] = useState3(
|
|
6967
|
+
const [theme, setTheme] = useState3(() => {
|
|
6968
|
+
try {
|
|
6969
|
+
const saved = localStorage.getItem("ng-editor-theme");
|
|
6970
|
+
if (saved) return saved;
|
|
6971
|
+
} catch {
|
|
6972
|
+
}
|
|
6973
|
+
return "inherit";
|
|
6974
|
+
});
|
|
6998
6975
|
const [editorMode, setEditorMode] = useState3("block");
|
|
6999
6976
|
const [simpleFont, setSimpleFont] = useState3("sans");
|
|
7000
6977
|
const [selectedTools, setSelectedTools] = useState3(() => {
|
|
@@ -7011,10 +6988,20 @@ var BlockEditor = React4.forwardRef(
|
|
|
7011
6988
|
});
|
|
7012
6989
|
const [statsVisible, setStatsVisible] = useState3(showStats);
|
|
7013
6990
|
const [aiConfig, setAiConfig] = useState3(loadAiConfig);
|
|
7014
|
-
const [
|
|
6991
|
+
const [aiPopover, setAiPopover] = useState3(null);
|
|
7015
6992
|
const [askPrompt, setAskPrompt] = useState3("");
|
|
7016
6993
|
const [aiBusy, setAiBusy] = useState3(false);
|
|
7017
6994
|
const [aiError, setAiError] = useState3(null);
|
|
6995
|
+
const [scratchOpen, setScratchOpen] = useState3(false);
|
|
6996
|
+
const [scratchText, setScratchText] = useState3(() => {
|
|
6997
|
+
try {
|
|
6998
|
+
return localStorage.getItem("ng-scratchpad-note") || "";
|
|
6999
|
+
} catch {
|
|
7000
|
+
return "";
|
|
7001
|
+
}
|
|
7002
|
+
});
|
|
7003
|
+
const [scratchCopied, setScratchCopied] = useState3(false);
|
|
7004
|
+
const [scratchOffset, setScratchOffset] = useState3({ x: 0, y: 0 });
|
|
7018
7005
|
const [stats, setStats] = useState3(() => {
|
|
7019
7006
|
const blocks = initialData?.blocks || [];
|
|
7020
7007
|
const text = blocks.map((b) => JSON.stringify(b.data || {})).join(" ");
|
|
@@ -7026,19 +7013,47 @@ var BlockEditor = React4.forwardRef(
|
|
|
7026
7013
|
useEffect2(() => {
|
|
7027
7014
|
setStatsVisible(showStats);
|
|
7028
7015
|
}, [showStats]);
|
|
7016
|
+
useEffect2(() => {
|
|
7017
|
+
try {
|
|
7018
|
+
localStorage.setItem("ng-editor-theme", theme);
|
|
7019
|
+
} catch {
|
|
7020
|
+
}
|
|
7021
|
+
if (theme === "inherit") {
|
|
7022
|
+
document.documentElement.removeAttribute("data-ng-theme");
|
|
7023
|
+
} else {
|
|
7024
|
+
document.documentElement.setAttribute("data-ng-theme", theme);
|
|
7025
|
+
}
|
|
7026
|
+
onThemeChange?.(theme);
|
|
7027
|
+
}, [theme, onThemeChange]);
|
|
7029
7028
|
useEffect2(() => {
|
|
7030
7029
|
const shell = shellRef.current;
|
|
7031
7030
|
if (!shell) return;
|
|
7031
|
+
const openAiNearRect = (mode, e) => {
|
|
7032
|
+
const rect = e.detail?.rect;
|
|
7033
|
+
const shellRect = shell.getBoundingClientRect();
|
|
7034
|
+
const popW = 320;
|
|
7035
|
+
const rawLeft = rect ? rect.left - shellRect.left : 60;
|
|
7036
|
+
const rawTop = rect ? rect.top - shellRect.top + 4 : 60;
|
|
7037
|
+
const maxLeft = Math.max(12, shellRect.width - popW - 12);
|
|
7038
|
+
const left = Math.max(12, Math.min(rawLeft, maxLeft));
|
|
7039
|
+
const top = Math.max(12, rawTop);
|
|
7040
|
+
setAiError(null);
|
|
7041
|
+
setAskPrompt("");
|
|
7042
|
+
setAiPopover({ mode, top, left });
|
|
7043
|
+
};
|
|
7032
7044
|
const onOpenSettings = () => setSettingsOpen(true);
|
|
7033
|
-
const onAiContinue = () =>
|
|
7034
|
-
const onAiAsk = () =>
|
|
7045
|
+
const onAiContinue = (e) => openAiNearRect("continue", e);
|
|
7046
|
+
const onAiAsk = (e) => openAiNearRect("ask", e);
|
|
7047
|
+
const onOpenScratch = () => setScratchOpen(true);
|
|
7035
7048
|
shell.addEventListener("nextgen-open-settings", onOpenSettings);
|
|
7036
7049
|
shell.addEventListener("nextgen-ai-continue", onAiContinue);
|
|
7037
7050
|
shell.addEventListener("nextgen-ai-ask", onAiAsk);
|
|
7051
|
+
shell.addEventListener("nextgen-open-scratch", onOpenScratch);
|
|
7038
7052
|
return () => {
|
|
7039
7053
|
shell.removeEventListener("nextgen-open-settings", onOpenSettings);
|
|
7040
7054
|
shell.removeEventListener("nextgen-ai-continue", onAiContinue);
|
|
7041
7055
|
shell.removeEventListener("nextgen-ai-ask", onAiAsk);
|
|
7056
|
+
shell.removeEventListener("nextgen-open-scratch", onOpenScratch);
|
|
7042
7057
|
};
|
|
7043
7058
|
}, []);
|
|
7044
7059
|
useEffect2(() => {
|
|
@@ -7054,7 +7069,7 @@ var BlockEditor = React4.forwardRef(
|
|
|
7054
7069
|
const sanitizedInitial = {
|
|
7055
7070
|
...latestDocRef.current || { blocks: [] },
|
|
7056
7071
|
blocks: (latestDocRef.current?.blocks || []).filter(
|
|
7057
|
-
(b) => !["settings", "continueWriting", "askAi"].includes(b.type)
|
|
7072
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7058
7073
|
)
|
|
7059
7074
|
};
|
|
7060
7075
|
latestDocRef.current = sanitizedInitial;
|
|
@@ -7068,7 +7083,7 @@ var BlockEditor = React4.forwardRef(
|
|
|
7068
7083
|
try {
|
|
7069
7084
|
const saved = await instance.save();
|
|
7070
7085
|
const filteredBlocks = (saved.blocks || []).filter(
|
|
7071
|
-
(b) => !["settings", "continueWriting", "askAi"].includes(b.type)
|
|
7086
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7072
7087
|
);
|
|
7073
7088
|
const typed = { ...saved, blocks: filteredBlocks };
|
|
7074
7089
|
latestDocRef.current = typed;
|
|
@@ -7120,7 +7135,7 @@ var BlockEditor = React4.forwardRef(
|
|
|
7120
7135
|
await editorRef.current.isReady;
|
|
7121
7136
|
const saved = await editorRef.current.save();
|
|
7122
7137
|
const filteredBlocks = (saved.blocks || []).filter(
|
|
7123
|
-
(b) => !["settings", "continueWriting", "askAi"].includes(b.type)
|
|
7138
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7124
7139
|
);
|
|
7125
7140
|
const typed = { ...saved, blocks: filteredBlocks };
|
|
7126
7141
|
latestDocRef.current = typed;
|
|
@@ -7167,7 +7182,7 @@ var BlockEditor = React4.forwardRef(
|
|
|
7167
7182
|
}
|
|
7168
7183
|
if (mode === "ask") {
|
|
7169
7184
|
setAskPrompt("");
|
|
7170
|
-
|
|
7185
|
+
setAiPopover(null);
|
|
7171
7186
|
}
|
|
7172
7187
|
} catch (err) {
|
|
7173
7188
|
setAiError(err instanceof Error ? err.message : "AI request failed.");
|
|
@@ -7213,9 +7228,11 @@ var BlockEditor = React4.forwardRef(
|
|
|
7213
7228
|
"button",
|
|
7214
7229
|
{
|
|
7215
7230
|
type: "button",
|
|
7216
|
-
className: `excalidraw-btn${
|
|
7231
|
+
className: `excalidraw-btn${aiPopover?.mode === "ask" ? " is-active" : ""}`,
|
|
7217
7232
|
disabled: aiBusy,
|
|
7218
|
-
onClick: () =>
|
|
7233
|
+
onClick: () => setAiPopover(
|
|
7234
|
+
(p) => p ? null : { mode: "ask", top: 120, left: 120 }
|
|
7235
|
+
),
|
|
7219
7236
|
children: "Ask AI"
|
|
7220
7237
|
}
|
|
7221
7238
|
)
|
|
@@ -7231,30 +7248,6 @@ var BlockEditor = React4.forwardRef(
|
|
|
7231
7248
|
}
|
|
7232
7249
|
)
|
|
7233
7250
|
] }),
|
|
7234
|
-
askOpen && /* @__PURE__ */ jsxs3(
|
|
7235
|
-
"form",
|
|
7236
|
-
{
|
|
7237
|
-
className: "ng-ask-form",
|
|
7238
|
-
onSubmit: (e) => {
|
|
7239
|
-
e.preventDefault();
|
|
7240
|
-
if (askPrompt.trim()) void runAi("ask", askPrompt.trim());
|
|
7241
|
-
},
|
|
7242
|
-
children: [
|
|
7243
|
-
/* @__PURE__ */ jsx3(
|
|
7244
|
-
"input",
|
|
7245
|
-
{
|
|
7246
|
-
type: "text",
|
|
7247
|
-
className: "cdx-input editor-form-input",
|
|
7248
|
-
placeholder: "Ask AI to draft, summarize, or expand...",
|
|
7249
|
-
value: askPrompt,
|
|
7250
|
-
onChange: (e) => setAskPrompt(e.target.value)
|
|
7251
|
-
}
|
|
7252
|
-
),
|
|
7253
|
-
/* @__PURE__ */ jsx3("button", { type: "submit", className: "editor-form-submit", disabled: aiBusy, children: aiBusy ? "Running\u2026" : "Generate" })
|
|
7254
|
-
]
|
|
7255
|
-
}
|
|
7256
|
-
),
|
|
7257
|
-
aiError && /* @__PURE__ */ jsx3("div", { className: "ng-ai-error", children: aiError }),
|
|
7258
7251
|
editorMode === "simple" && /* @__PURE__ */ jsx3(
|
|
7259
7252
|
ClassicToolbar,
|
|
7260
7253
|
{
|
|
@@ -7311,6 +7304,161 @@ var BlockEditor = React4.forwardRef(
|
|
|
7311
7304
|
},
|
|
7312
7305
|
onClose: () => setSettingsOpen(false)
|
|
7313
7306
|
}
|
|
7307
|
+
),
|
|
7308
|
+
aiPopover && /* @__PURE__ */ jsxs3(
|
|
7309
|
+
"form",
|
|
7310
|
+
{
|
|
7311
|
+
className: "ng-ai-inline-popover",
|
|
7312
|
+
style: { top: `${aiPopover.top}px`, left: `${aiPopover.left}px` },
|
|
7313
|
+
onSubmit: (e) => {
|
|
7314
|
+
e.preventDefault();
|
|
7315
|
+
if (aiPopover.mode === "continue") {
|
|
7316
|
+
void runAi("continue", askPrompt.trim());
|
|
7317
|
+
} else if (askPrompt.trim()) {
|
|
7318
|
+
void runAi("ask", askPrompt.trim());
|
|
7319
|
+
}
|
|
7320
|
+
},
|
|
7321
|
+
children: [
|
|
7322
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-ai-inline-head", children: [
|
|
7323
|
+
/* @__PURE__ */ jsx3("span", { children: aiPopover.mode === "continue" ? "\u2726 Continue Writing" : "Ask AI" }),
|
|
7324
|
+
/* @__PURE__ */ jsx3(
|
|
7325
|
+
"button",
|
|
7326
|
+
{
|
|
7327
|
+
type: "button",
|
|
7328
|
+
className: "b2",
|
|
7329
|
+
"aria-label": "Close AI prompt",
|
|
7330
|
+
onClick: () => setAiPopover(null),
|
|
7331
|
+
children: "\xD7"
|
|
7332
|
+
}
|
|
7333
|
+
)
|
|
7334
|
+
] }),
|
|
7335
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-ai-inline-row", children: [
|
|
7336
|
+
/* @__PURE__ */ jsx3(
|
|
7337
|
+
"input",
|
|
7338
|
+
{
|
|
7339
|
+
type: "text",
|
|
7340
|
+
autoFocus: true,
|
|
7341
|
+
className: "cdx-input editor-form-input",
|
|
7342
|
+
placeholder: aiPopover.mode === "continue" ? "How should AI continue? (optional)" : "What do you want AI to write?",
|
|
7343
|
+
value: askPrompt,
|
|
7344
|
+
onChange: (e) => setAskPrompt(e.target.value),
|
|
7345
|
+
onKeyDown: (e) => {
|
|
7346
|
+
if (e.key === "Escape") setAiPopover(null);
|
|
7347
|
+
}
|
|
7348
|
+
}
|
|
7349
|
+
),
|
|
7350
|
+
/* @__PURE__ */ jsx3(
|
|
7351
|
+
"button",
|
|
7352
|
+
{
|
|
7353
|
+
type: "submit",
|
|
7354
|
+
className: "editor-form-submit",
|
|
7355
|
+
disabled: aiBusy || aiPopover.mode === "ask" && !askPrompt.trim(),
|
|
7356
|
+
children: aiBusy ? "Running\u2026" : aiPopover.mode === "continue" ? "Continue" : "Generate"
|
|
7357
|
+
}
|
|
7358
|
+
)
|
|
7359
|
+
] }),
|
|
7360
|
+
aiError && /* @__PURE__ */ jsx3("div", { className: "ng-ai-error", children: aiError })
|
|
7361
|
+
]
|
|
7362
|
+
}
|
|
7363
|
+
),
|
|
7364
|
+
scratchOpen && /* @__PURE__ */ jsxs3(
|
|
7365
|
+
"div",
|
|
7366
|
+
{
|
|
7367
|
+
className: "ng-scratch-sticky",
|
|
7368
|
+
role: "dialog",
|
|
7369
|
+
"aria-label": "Scratchpad sticky note",
|
|
7370
|
+
style: {
|
|
7371
|
+
transform: `translate(${scratchOffset.x}px, ${scratchOffset.y}px)`
|
|
7372
|
+
},
|
|
7373
|
+
children: [
|
|
7374
|
+
/* @__PURE__ */ jsxs3(
|
|
7375
|
+
"div",
|
|
7376
|
+
{
|
|
7377
|
+
className: "ng-scratch-sticky-head",
|
|
7378
|
+
onMouseDown: (e) => {
|
|
7379
|
+
if (e.target.closest("button")) return;
|
|
7380
|
+
const startX = e.clientX - scratchOffset.x;
|
|
7381
|
+
const startY = e.clientY - scratchOffset.y;
|
|
7382
|
+
const onMove = (ev) => {
|
|
7383
|
+
setScratchOffset({ x: ev.clientX - startX, y: ev.clientY - startY });
|
|
7384
|
+
};
|
|
7385
|
+
const onUp = () => {
|
|
7386
|
+
window.removeEventListener("mousemove", onMove);
|
|
7387
|
+
window.removeEventListener("mouseup", onUp);
|
|
7388
|
+
};
|
|
7389
|
+
window.addEventListener("mousemove", onMove);
|
|
7390
|
+
window.addEventListener("mouseup", onUp);
|
|
7391
|
+
},
|
|
7392
|
+
children: [
|
|
7393
|
+
/* @__PURE__ */ jsx3("span", { className: "ng-scratch-sticky-title", children: "\u{1F4DD} Scratchpad" }),
|
|
7394
|
+
/* @__PURE__ */ jsxs3("span", { className: "ng-scratch-sticky-count", children: [
|
|
7395
|
+
scratchText.trim() ? scratchText.trim().split(/\s+/).length : 0,
|
|
7396
|
+
"w \xB7 ",
|
|
7397
|
+
scratchText.length,
|
|
7398
|
+
"c"
|
|
7399
|
+
] }),
|
|
7400
|
+
/* @__PURE__ */ jsxs3("div", { className: "ng-scratch-sticky-actions", children: [
|
|
7401
|
+
/* @__PURE__ */ jsx3(
|
|
7402
|
+
"button",
|
|
7403
|
+
{
|
|
7404
|
+
type: "button",
|
|
7405
|
+
className: "ng-scratch-sticky-btn",
|
|
7406
|
+
onClick: () => {
|
|
7407
|
+
if (!scratchText) return;
|
|
7408
|
+
void navigator.clipboard?.writeText(scratchText);
|
|
7409
|
+
setScratchCopied(true);
|
|
7410
|
+
window.setTimeout(() => setScratchCopied(false), 1200);
|
|
7411
|
+
},
|
|
7412
|
+
children: scratchCopied ? "Copied" : "Copy"
|
|
7413
|
+
}
|
|
7414
|
+
),
|
|
7415
|
+
/* @__PURE__ */ jsx3(
|
|
7416
|
+
"button",
|
|
7417
|
+
{
|
|
7418
|
+
type: "button",
|
|
7419
|
+
className: "ng-scratch-sticky-btn",
|
|
7420
|
+
onClick: () => {
|
|
7421
|
+
setScratchText("");
|
|
7422
|
+
try {
|
|
7423
|
+
localStorage.setItem("ng-scratchpad-note", "");
|
|
7424
|
+
} catch {
|
|
7425
|
+
}
|
|
7426
|
+
},
|
|
7427
|
+
children: "Clear"
|
|
7428
|
+
}
|
|
7429
|
+
),
|
|
7430
|
+
/* @__PURE__ */ jsx3(
|
|
7431
|
+
"button",
|
|
7432
|
+
{
|
|
7433
|
+
type: "button",
|
|
7434
|
+
className: "ng-scratch-sticky-btn",
|
|
7435
|
+
"aria-label": "Close scratchpad",
|
|
7436
|
+
onClick: () => setScratchOpen(false),
|
|
7437
|
+
children: "\xD7"
|
|
7438
|
+
}
|
|
7439
|
+
)
|
|
7440
|
+
] })
|
|
7441
|
+
]
|
|
7442
|
+
}
|
|
7443
|
+
),
|
|
7444
|
+
/* @__PURE__ */ jsx3(
|
|
7445
|
+
"textarea",
|
|
7446
|
+
{
|
|
7447
|
+
className: "ng-scratch-sticky-body",
|
|
7448
|
+
placeholder: "Quick sticky note, rough ideas, snippets...",
|
|
7449
|
+
value: scratchText,
|
|
7450
|
+
onChange: (e) => {
|
|
7451
|
+
const val = e.target.value;
|
|
7452
|
+
setScratchText(val);
|
|
7453
|
+
try {
|
|
7454
|
+
localStorage.setItem("ng-scratchpad-note", val);
|
|
7455
|
+
} catch {
|
|
7456
|
+
}
|
|
7457
|
+
}
|
|
7458
|
+
}
|
|
7459
|
+
)
|
|
7460
|
+
]
|
|
7461
|
+
}
|
|
7314
7462
|
)
|
|
7315
7463
|
]
|
|
7316
7464
|
}
|
|
@@ -8019,15 +8167,28 @@ function useInteractiveArticle(containerRef, depKey) {
|
|
|
8019
8167
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
8020
8168
|
var BlockRenderer = ({
|
|
8021
8169
|
data,
|
|
8170
|
+
theme,
|
|
8022
8171
|
className
|
|
8023
8172
|
}) => {
|
|
8024
8173
|
const bodyRef = useRef3(null);
|
|
8025
8174
|
const html = useMemo(() => blocksToHtml(data), [data]);
|
|
8026
8175
|
useInteractiveArticle(bodyRef, html);
|
|
8176
|
+
let resolvedTheme = theme;
|
|
8177
|
+
if (!resolvedTheme && typeof window !== "undefined") {
|
|
8178
|
+
resolvedTheme = document.documentElement.getAttribute("data-ng-theme") || (() => {
|
|
8179
|
+
try {
|
|
8180
|
+
return localStorage.getItem("ng-editor-theme") || void 0;
|
|
8181
|
+
} catch {
|
|
8182
|
+
return void 0;
|
|
8183
|
+
}
|
|
8184
|
+
})();
|
|
8185
|
+
}
|
|
8186
|
+
const attrTheme = resolvedTheme && resolvedTheme !== "inherit" ? resolvedTheme : void 0;
|
|
8027
8187
|
return /* @__PURE__ */ jsx4(
|
|
8028
8188
|
"div",
|
|
8029
8189
|
{
|
|
8030
8190
|
ref: bodyRef,
|
|
8191
|
+
"data-ng-theme": attrTheme,
|
|
8031
8192
|
className: className ? `article nextgen-editor-article ${className}` : "article nextgen-editor-article",
|
|
8032
8193
|
dangerouslySetInnerHTML: { __html: html }
|
|
8033
8194
|
}
|