nextgen-block-editor 0.2.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 +1183 -394
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1182 -393
- package/dist/styles.css +523 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ __export(index_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
45
|
|
|
46
46
|
// src/components/BlockEditor.tsx
|
|
47
|
-
var
|
|
47
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
48
48
|
var import_editorjs2 = __toESM(require("@editorjs/editorjs"), 1);
|
|
49
49
|
var import_editorjs_drag_drop = __toESM(require("editorjs-drag-drop"), 1);
|
|
50
50
|
var import_editorjs_undo = __toESM(require("editorjs-undo"), 1);
|
|
@@ -54,7 +54,6 @@ var import_editorjs = __toESM(require("@editorjs/editorjs"), 1);
|
|
|
54
54
|
var import_header = __toESM(require("@editorjs/header"), 1);
|
|
55
55
|
var import_list = __toESM(require("@editorjs/list"), 1);
|
|
56
56
|
var import_nested_list = __toESM(require("@editorjs/nested-list"), 1);
|
|
57
|
-
var import_checklist = __toESM(require("@editorjs/checklist"), 1);
|
|
58
57
|
var import_table = __toESM(require("@editorjs/table"), 1);
|
|
59
58
|
var import_quote = __toESM(require("@editorjs/quote"), 1);
|
|
60
59
|
var import_inline_code = __toESM(require("@editorjs/inline-code"), 1);
|
|
@@ -292,7 +291,7 @@ function sanitizeInlineHtml(value) {
|
|
|
292
291
|
}
|
|
293
292
|
const template = document.createElement("template");
|
|
294
293
|
template.innerHTML = String(value == null ? "" : value);
|
|
295
|
-
const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM"];
|
|
294
|
+
const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM", "SUP", "SUB"];
|
|
296
295
|
template.content.querySelectorAll("*").forEach((element) => {
|
|
297
296
|
if (!allowed.includes(element.tagName)) {
|
|
298
297
|
element.replaceWith(document.createTextNode(element.textContent || ""));
|
|
@@ -1634,6 +1633,144 @@ var import_client = require("react-dom/client");
|
|
|
1634
1633
|
var import_excalidraw = require("@excalidraw/excalidraw");
|
|
1635
1634
|
var import_auto = __toESM(require("chart.js/auto"), 1);
|
|
1636
1635
|
var import_katex2 = __toESM(require("katex"), 1);
|
|
1636
|
+
|
|
1637
|
+
// src/utils/emojiSidePicker.ts
|
|
1638
|
+
var activeMenuCleanup = null;
|
|
1639
|
+
function openEmojiSideMenu({
|
|
1640
|
+
anchorRect,
|
|
1641
|
+
onSelect,
|
|
1642
|
+
onClose
|
|
1643
|
+
}) {
|
|
1644
|
+
if (activeMenuCleanup) {
|
|
1645
|
+
activeMenuCleanup();
|
|
1646
|
+
activeMenuCleanup = null;
|
|
1647
|
+
}
|
|
1648
|
+
const popover = document.createElement("div");
|
|
1649
|
+
popover.className = "editor-emoji-side-popover";
|
|
1650
|
+
popover.setAttribute("role", "dialog");
|
|
1651
|
+
popover.setAttribute("aria-label", "Emoji picker");
|
|
1652
|
+
const menuW = 264;
|
|
1653
|
+
const menuH = 290;
|
|
1654
|
+
const gap = 8;
|
|
1655
|
+
const fitsRight = anchorRect.right + gap + menuW <= window.innerWidth - 8;
|
|
1656
|
+
const left = fitsRight ? anchorRect.right + gap : Math.max(8, anchorRect.left - menuW - gap);
|
|
1657
|
+
const top = Math.max(
|
|
1658
|
+
8,
|
|
1659
|
+
Math.min(anchorRect.top, window.innerHeight - menuH - 8)
|
|
1660
|
+
);
|
|
1661
|
+
popover.style.left = `${left}px`;
|
|
1662
|
+
popover.style.top = `${top}px`;
|
|
1663
|
+
const searchIn = document.createElement("input");
|
|
1664
|
+
searchIn.type = "search";
|
|
1665
|
+
searchIn.className = "cdx-input editor-form-input";
|
|
1666
|
+
searchIn.placeholder = "Search emoji (fire, rocket...)";
|
|
1667
|
+
const grid = document.createElement("div");
|
|
1668
|
+
grid.className = "editor-emoji-grid";
|
|
1669
|
+
const close = () => {
|
|
1670
|
+
document.removeEventListener("mousedown", onOutside, true);
|
|
1671
|
+
document.removeEventListener("keydown", onKey, true);
|
|
1672
|
+
popover.remove();
|
|
1673
|
+
activeMenuCleanup = null;
|
|
1674
|
+
onClose?.();
|
|
1675
|
+
};
|
|
1676
|
+
const renderGrid = (query = "") => {
|
|
1677
|
+
grid.innerHTML = "";
|
|
1678
|
+
const q = query.trim().toLowerCase();
|
|
1679
|
+
const filtered = q ? EMOJI_PRESETS.filter((p) => p.name.includes(q) || p.em.includes(q)) : EMOJI_PRESETS;
|
|
1680
|
+
filtered.forEach(({ em, name }) => {
|
|
1681
|
+
const btn = document.createElement("button");
|
|
1682
|
+
btn.type = "button";
|
|
1683
|
+
btn.title = name;
|
|
1684
|
+
btn.className = "editor-emoji-btn";
|
|
1685
|
+
btn.textContent = em;
|
|
1686
|
+
btn.addEventListener("mousedown", (e) => e.preventDefault());
|
|
1687
|
+
btn.addEventListener("click", () => {
|
|
1688
|
+
const cb = onSelect;
|
|
1689
|
+
close();
|
|
1690
|
+
cb(em);
|
|
1691
|
+
});
|
|
1692
|
+
grid.appendChild(btn);
|
|
1693
|
+
});
|
|
1694
|
+
};
|
|
1695
|
+
const onOutside = (e) => {
|
|
1696
|
+
if (!popover.contains(e.target)) {
|
|
1697
|
+
close();
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
const onKey = (e) => {
|
|
1701
|
+
if (e.key === "Escape") {
|
|
1702
|
+
e.preventDefault();
|
|
1703
|
+
e.stopPropagation();
|
|
1704
|
+
close();
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
searchIn.addEventListener("input", () => renderGrid(searchIn.value));
|
|
1708
|
+
renderGrid();
|
|
1709
|
+
popover.append(searchIn, grid);
|
|
1710
|
+
document.body.appendChild(popover);
|
|
1711
|
+
document.addEventListener("mousedown", onOutside, true);
|
|
1712
|
+
document.addEventListener("keydown", onKey, true);
|
|
1713
|
+
queueMicrotask(() => searchIn.focus());
|
|
1714
|
+
activeMenuCleanup = close;
|
|
1715
|
+
return close;
|
|
1716
|
+
}
|
|
1717
|
+
function attachEmojiSidePicker(container) {
|
|
1718
|
+
const onInput = (e) => {
|
|
1719
|
+
const target = e.target;
|
|
1720
|
+
if (!target || !target.isContentEditable) return;
|
|
1721
|
+
const sel = window.getSelection();
|
|
1722
|
+
if (!sel || sel.rangeCount === 0) return;
|
|
1723
|
+
const range = sel.getRangeAt(0);
|
|
1724
|
+
if (range.startContainer.nodeType !== Node.TEXT_NODE || !range.collapsed) {
|
|
1725
|
+
return;
|
|
1726
|
+
}
|
|
1727
|
+
const textNode = range.startContainer;
|
|
1728
|
+
const offset = range.startOffset;
|
|
1729
|
+
const before = textNode.data.slice(0, offset);
|
|
1730
|
+
if (!/(^|\s)\/emoji$/i.test(before)) return;
|
|
1731
|
+
const triggerStart = offset - "/emoji".length;
|
|
1732
|
+
const triggerRange = document.createRange();
|
|
1733
|
+
triggerRange.setStart(textNode, triggerStart);
|
|
1734
|
+
triggerRange.setEnd(textNode, offset);
|
|
1735
|
+
const rawRect = triggerRange.getBoundingClientRect();
|
|
1736
|
+
const rect = rawRect.width > 0 || rawRect.height > 0 ? rawRect : target.getBoundingClientRect();
|
|
1737
|
+
openEmojiSideMenu({
|
|
1738
|
+
anchorRect: rect,
|
|
1739
|
+
onSelect: (emoji) => {
|
|
1740
|
+
if (textNode.isConnected) {
|
|
1741
|
+
const current = textNode.data;
|
|
1742
|
+
textNode.data = current.slice(0, triggerStart) + emoji + current.slice(offset);
|
|
1743
|
+
const nextCaret = triggerStart + emoji.length;
|
|
1744
|
+
const newRange = document.createRange();
|
|
1745
|
+
newRange.setStart(textNode, nextCaret);
|
|
1746
|
+
newRange.setEnd(textNode, nextCaret);
|
|
1747
|
+
const s = window.getSelection();
|
|
1748
|
+
if (s) {
|
|
1749
|
+
s.removeAllRanges();
|
|
1750
|
+
s.addRange(newRange);
|
|
1751
|
+
}
|
|
1752
|
+
} else if (target.isConnected) {
|
|
1753
|
+
target.innerHTML = target.innerHTML.replace(/\/emoji/i, emoji);
|
|
1754
|
+
}
|
|
1755
|
+
target.focus();
|
|
1756
|
+
target.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1757
|
+
},
|
|
1758
|
+
onClose: () => {
|
|
1759
|
+
target.focus();
|
|
1760
|
+
}
|
|
1761
|
+
});
|
|
1762
|
+
};
|
|
1763
|
+
container.addEventListener("input", onInput);
|
|
1764
|
+
return () => {
|
|
1765
|
+
container.removeEventListener("input", onInput);
|
|
1766
|
+
if (activeMenuCleanup) {
|
|
1767
|
+
activeMenuCleanup();
|
|
1768
|
+
activeMenuCleanup = null;
|
|
1769
|
+
}
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
// src/blocks/richBlocks.ts
|
|
1637
1774
|
var LatexTool = class {
|
|
1638
1775
|
data;
|
|
1639
1776
|
wrapper = null;
|
|
@@ -3565,34 +3702,64 @@ var FlashcardTool = class {
|
|
|
3565
3702
|
};
|
|
3566
3703
|
}
|
|
3567
3704
|
};
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
el.
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
}
|
|
3705
|
+
function createActionTriggerTool(title, icon, eventName) {
|
|
3706
|
+
return class {
|
|
3707
|
+
api;
|
|
3708
|
+
el = null;
|
|
3709
|
+
fired = false;
|
|
3710
|
+
static get toolbox() {
|
|
3711
|
+
return { title, icon };
|
|
3712
|
+
}
|
|
3713
|
+
constructor({ api }) {
|
|
3714
|
+
this.api = api;
|
|
3715
|
+
}
|
|
3716
|
+
render() {
|
|
3717
|
+
const el = document.createElement("div");
|
|
3718
|
+
el.style.height = "1px";
|
|
3719
|
+
el.style.opacity = "0";
|
|
3720
|
+
el.style.pointerEvents = "none";
|
|
3721
|
+
this.el = el;
|
|
3722
|
+
return el;
|
|
3723
|
+
}
|
|
3724
|
+
rendered() {
|
|
3725
|
+
if (this.fired || !this.el) return;
|
|
3726
|
+
this.fired = true;
|
|
3727
|
+
const contentEl = this.el.closest(".ce-block__content") || this.el.closest(".ce-block") || this.el;
|
|
3728
|
+
const blockRect = contentEl.getBoundingClientRect();
|
|
3729
|
+
this.el.dispatchEvent(
|
|
3730
|
+
new CustomEvent(eventName, {
|
|
3731
|
+
bubbles: true,
|
|
3732
|
+
detail: { rect: blockRect }
|
|
3733
|
+
})
|
|
3734
|
+
);
|
|
3735
|
+
window.setTimeout(() => {
|
|
3736
|
+
try {
|
|
3737
|
+
const idx = this.api.blocks.getCurrentBlockIndex();
|
|
3738
|
+
if (idx >= 0) this.api.blocks.delete(idx);
|
|
3739
|
+
} catch {
|
|
3740
|
+
}
|
|
3741
|
+
}, 0);
|
|
3742
|
+
}
|
|
3743
|
+
save() {
|
|
3744
|
+
return {};
|
|
3745
|
+
}
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
var SettingsTriggerTool = createActionTriggerTool(
|
|
3749
|
+
"Settings",
|
|
3750
|
+
'<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',
|
|
3751
|
+
"nextgen-open-settings"
|
|
3752
|
+
);
|
|
3753
|
+
var ContinueWritingTool = createActionTriggerTool(
|
|
3754
|
+
"Continue Writing",
|
|
3755
|
+
'<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 3l1.9 5.8L20 11l-6.1 2.2L12 19l-1.9-5.8L4 11l6.1-2.2z"/></svg>',
|
|
3756
|
+
"nextgen-ai-continue"
|
|
3757
|
+
);
|
|
3758
|
+
var AskAiTool = createActionTriggerTool(
|
|
3759
|
+
"Ask AI",
|
|
3760
|
+
'<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="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',
|
|
3761
|
+
"nextgen-ai-ask"
|
|
3762
|
+
);
|
|
3596
3763
|
var UploadTool = class {
|
|
3597
3764
|
data;
|
|
3598
3765
|
statusEl = null;
|
|
@@ -3934,94 +4101,71 @@ var EMOJI_PRESETS = [
|
|
|
3934
4101
|
];
|
|
3935
4102
|
var EmojiTool = class {
|
|
3936
4103
|
data;
|
|
4104
|
+
api;
|
|
4105
|
+
isNewInsert;
|
|
4106
|
+
anchorEl = null;
|
|
3937
4107
|
static get toolbox() {
|
|
3938
4108
|
return {
|
|
3939
4109
|
title: "Emoji",
|
|
3940
4110
|
icon: '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" y1="9" x2="9.01" y2="9"/><line x1="15" y1="9" x2="15.01" y2="9"/></svg>'
|
|
3941
4111
|
};
|
|
3942
4112
|
}
|
|
3943
|
-
constructor({
|
|
4113
|
+
constructor({
|
|
4114
|
+
data,
|
|
4115
|
+
api
|
|
4116
|
+
}) {
|
|
4117
|
+
this.isNewInsert = !data?.emoji;
|
|
4118
|
+
this.api = api;
|
|
3944
4119
|
this.data = {
|
|
3945
4120
|
emoji: data?.emoji ?? "\u2728",
|
|
3946
4121
|
label: data?.label ?? "",
|
|
3947
4122
|
size: data?.size || "md"
|
|
3948
4123
|
};
|
|
3949
4124
|
}
|
|
4125
|
+
openPickerAtAnchor() {
|
|
4126
|
+
if (!this.anchorEl) return;
|
|
4127
|
+
const rect = this.anchorEl.getBoundingClientRect();
|
|
4128
|
+
openEmojiSideMenu({
|
|
4129
|
+
anchorRect: rect,
|
|
4130
|
+
onSelect: (em) => {
|
|
4131
|
+
if (this.isNewInsert && this.api?.blocks) {
|
|
4132
|
+
const blockEl = this.anchorEl?.closest(".ce-block");
|
|
4133
|
+
const parent = blockEl?.parentElement;
|
|
4134
|
+
const domIdx = blockEl && parent ? Array.from(parent.children).indexOf(blockEl) : -1;
|
|
4135
|
+
const idx = domIdx >= 0 ? domIdx : this.api.blocks.getCurrentBlockIndex();
|
|
4136
|
+
if (idx >= 0) {
|
|
4137
|
+
this.api.blocks.insert("paragraph", { text: `${em} ` }, {}, idx + 1, true);
|
|
4138
|
+
this.api.blocks.delete(idx);
|
|
4139
|
+
window.requestAnimationFrame(() => {
|
|
4140
|
+
this.api?.caret?.setToBlock(idx, "end");
|
|
4141
|
+
});
|
|
4142
|
+
}
|
|
4143
|
+
return;
|
|
4144
|
+
}
|
|
4145
|
+
this.data.emoji = em;
|
|
4146
|
+
if (this.anchorEl) {
|
|
4147
|
+
this.anchorEl.textContent = `${em} Pick emoji`;
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
});
|
|
4151
|
+
}
|
|
3950
4152
|
render() {
|
|
3951
4153
|
const wrap = document.createElement("div");
|
|
3952
|
-
wrap.className = "editor-emoji-
|
|
3953
|
-
const
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
emojiIn.className = "cdx-input editor-callout-icon-in";
|
|
3961
|
-
emojiIn.value = this.data.emoji;
|
|
3962
|
-
emojiIn.placeholder = "\u2728";
|
|
3963
|
-
emojiIn.addEventListener("input", () => {
|
|
3964
|
-
this.data.emoji = emojiIn.value || "\u2728";
|
|
3965
|
-
previewGlyph.textContent = this.data.emoji;
|
|
3966
|
-
});
|
|
3967
|
-
const sizeSel = document.createElement("select");
|
|
3968
|
-
sizeSel.className = "cdx-input editor-form-select";
|
|
3969
|
-
["sm", "md", "lg"].forEach((s) => {
|
|
3970
|
-
const o = document.createElement("option");
|
|
3971
|
-
o.value = s;
|
|
3972
|
-
o.textContent = s.toUpperCase();
|
|
3973
|
-
if (this.data.size === s) o.selected = true;
|
|
3974
|
-
sizeSel.appendChild(o);
|
|
3975
|
-
});
|
|
3976
|
-
sizeSel.addEventListener("change", () => {
|
|
3977
|
-
this.data.size = sizeSel.value;
|
|
3978
|
-
previewGlyph.className = `editor-emoji-hero is-${this.data.size}`;
|
|
3979
|
-
});
|
|
3980
|
-
const row = document.createElement("div");
|
|
3981
|
-
row.className = "editor-emoji-controls";
|
|
3982
|
-
row.append(emojiIn, sizeSel);
|
|
3983
|
-
const labelIn = document.createElement("input");
|
|
3984
|
-
labelIn.type = "text";
|
|
3985
|
-
labelIn.className = "cdx-input editor-form-input";
|
|
3986
|
-
labelIn.placeholder = "Caption or reaction note...";
|
|
3987
|
-
labelIn.value = this.data.label || "";
|
|
3988
|
-
labelIn.addEventListener("input", () => {
|
|
3989
|
-
this.data.label = labelIn.value;
|
|
3990
|
-
});
|
|
3991
|
-
leftPane.append(previewGlyph, row, labelIn);
|
|
3992
|
-
const rightPane = document.createElement("div");
|
|
3993
|
-
rightPane.className = "editor-emoji-picker-pane";
|
|
3994
|
-
const searchIn = document.createElement("input");
|
|
3995
|
-
searchIn.type = "search";
|
|
3996
|
-
searchIn.className = "cdx-input editor-form-input";
|
|
3997
|
-
searchIn.placeholder = "Search emojis (fire, rocket, heart...)";
|
|
3998
|
-
const grid = document.createElement("div");
|
|
3999
|
-
grid.className = "editor-emoji-grid";
|
|
4000
|
-
const renderGrid = (query = "") => {
|
|
4001
|
-
grid.innerHTML = "";
|
|
4002
|
-
const q = query.trim().toLowerCase();
|
|
4003
|
-
const filtered = q ? EMOJI_PRESETS.filter((p) => p.name.includes(q) || p.em.includes(q)) : EMOJI_PRESETS;
|
|
4004
|
-
filtered.forEach(({ em, name }) => {
|
|
4005
|
-
const btn = document.createElement("button");
|
|
4006
|
-
btn.type = "button";
|
|
4007
|
-
btn.title = name;
|
|
4008
|
-
btn.className = `editor-emoji-btn${em === this.data.emoji ? " is-active" : ""}`;
|
|
4009
|
-
btn.textContent = em;
|
|
4010
|
-
btn.addEventListener("click", () => {
|
|
4011
|
-
this.data.emoji = em;
|
|
4012
|
-
emojiIn.value = em;
|
|
4013
|
-
previewGlyph.textContent = em;
|
|
4014
|
-
renderGrid(searchIn.value);
|
|
4015
|
-
});
|
|
4016
|
-
grid.appendChild(btn);
|
|
4017
|
-
});
|
|
4018
|
-
};
|
|
4019
|
-
searchIn.addEventListener("input", () => renderGrid(searchIn.value));
|
|
4020
|
-
renderGrid();
|
|
4021
|
-
rightPane.append(searchIn, grid);
|
|
4022
|
-
wrap.append(leftPane, rightPane);
|
|
4154
|
+
wrap.className = "editor-emoji-inline-wrap";
|
|
4155
|
+
const btn = document.createElement("button");
|
|
4156
|
+
btn.type = "button";
|
|
4157
|
+
btn.className = "b2 editor-emoji-inline-anchor";
|
|
4158
|
+
btn.textContent = `${this.data.emoji} Pick emoji`;
|
|
4159
|
+
btn.addEventListener("click", () => this.openPickerAtAnchor());
|
|
4160
|
+
this.anchorEl = btn;
|
|
4161
|
+
wrap.appendChild(btn);
|
|
4023
4162
|
return wrap;
|
|
4024
4163
|
}
|
|
4164
|
+
rendered() {
|
|
4165
|
+
if (this.isNewInsert) {
|
|
4166
|
+
window.requestAnimationFrame(() => this.openPickerAtAnchor());
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4025
4169
|
save() {
|
|
4026
4170
|
return {
|
|
4027
4171
|
emoji: this.data.emoji.trim() || "\u2728",
|
|
@@ -4030,83 +4174,11 @@ var EmojiTool = class {
|
|
|
4030
4174
|
};
|
|
4031
4175
|
}
|
|
4032
4176
|
};
|
|
4033
|
-
var ScratchTool =
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
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>'
|
|
4039
|
-
};
|
|
4040
|
-
}
|
|
4041
|
-
constructor({ data }) {
|
|
4042
|
-
this.data = {
|
|
4043
|
-
title: data?.title ?? "Scratchpad",
|
|
4044
|
-
text: data?.text ?? ""
|
|
4045
|
-
};
|
|
4046
|
-
}
|
|
4047
|
-
render() {
|
|
4048
|
-
const wrap = document.createElement("div");
|
|
4049
|
-
wrap.className = "editor-scratch-tool";
|
|
4050
|
-
const head = document.createElement("div");
|
|
4051
|
-
head.className = "editor-scratch-head";
|
|
4052
|
-
const titleIn = document.createElement("input");
|
|
4053
|
-
titleIn.type = "text";
|
|
4054
|
-
titleIn.className = "cdx-input editor-scratch-title";
|
|
4055
|
-
titleIn.placeholder = "Scratchpad title...";
|
|
4056
|
-
titleIn.value = this.data.title ?? "Scratchpad";
|
|
4057
|
-
titleIn.addEventListener("input", () => {
|
|
4058
|
-
this.data.title = titleIn.value;
|
|
4059
|
-
});
|
|
4060
|
-
const stats = document.createElement("span");
|
|
4061
|
-
stats.className = "editor-scratch-stats";
|
|
4062
|
-
const updateStats = () => {
|
|
4063
|
-
const len = this.data.text.length;
|
|
4064
|
-
const words = this.data.text.trim() ? this.data.text.trim().split(/\s+/).length : 0;
|
|
4065
|
-
stats.textContent = `${words}w \xB7 ${len}c`;
|
|
4066
|
-
};
|
|
4067
|
-
const copyBtn = document.createElement("button");
|
|
4068
|
-
copyBtn.type = "button";
|
|
4069
|
-
copyBtn.className = "b2";
|
|
4070
|
-
copyBtn.textContent = "Copy";
|
|
4071
|
-
copyBtn.addEventListener("click", () => {
|
|
4072
|
-
if (!this.data.text) return;
|
|
4073
|
-
void navigator.clipboard?.writeText(this.data.text);
|
|
4074
|
-
copyBtn.textContent = "Copied";
|
|
4075
|
-
window.setTimeout(() => {
|
|
4076
|
-
copyBtn.textContent = "Copy";
|
|
4077
|
-
}, 1200);
|
|
4078
|
-
});
|
|
4079
|
-
const clearBtn = document.createElement("button");
|
|
4080
|
-
clearBtn.type = "button";
|
|
4081
|
-
clearBtn.className = "b2";
|
|
4082
|
-
clearBtn.textContent = "Clear";
|
|
4083
|
-
head.append(titleIn, stats, copyBtn, clearBtn);
|
|
4084
|
-
const textarea = document.createElement("textarea");
|
|
4085
|
-
textarea.className = "cdx-input editor-scratch-textarea";
|
|
4086
|
-
textarea.rows = 4;
|
|
4087
|
-
textarea.placeholder = "Quick brain dump, rough notes, snippets...";
|
|
4088
|
-
textarea.value = this.data.text || "";
|
|
4089
|
-
textarea.addEventListener("input", () => {
|
|
4090
|
-
this.data.text = textarea.value;
|
|
4091
|
-
updateStats();
|
|
4092
|
-
});
|
|
4093
|
-
clearBtn.addEventListener("click", () => {
|
|
4094
|
-
this.data.text = "";
|
|
4095
|
-
textarea.value = "";
|
|
4096
|
-
updateStats();
|
|
4097
|
-
textarea.focus();
|
|
4098
|
-
});
|
|
4099
|
-
updateStats();
|
|
4100
|
-
wrap.append(head, textarea);
|
|
4101
|
-
return wrap;
|
|
4102
|
-
}
|
|
4103
|
-
save() {
|
|
4104
|
-
return {
|
|
4105
|
-
title: this.data.title?.trim() || "Scratchpad",
|
|
4106
|
-
text: this.data.text
|
|
4107
|
-
};
|
|
4108
|
-
}
|
|
4109
|
-
};
|
|
4177
|
+
var ScratchTool = createActionTriggerTool(
|
|
4178
|
+
"Scratchpad",
|
|
4179
|
+
'<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>',
|
|
4180
|
+
"nextgen-open-scratch"
|
|
4181
|
+
);
|
|
4110
4182
|
var DialogueTool = class {
|
|
4111
4183
|
data;
|
|
4112
4184
|
static get toolbox() {
|
|
@@ -5898,7 +5970,6 @@ function getEditorTools(includeLayout = true, enabledTools) {
|
|
|
5898
5970
|
}
|
|
5899
5971
|
},
|
|
5900
5972
|
delimiter: DelimiterTool,
|
|
5901
|
-
checklist: import_checklist.default,
|
|
5902
5973
|
table: import_table.default,
|
|
5903
5974
|
callout: CalloutTool,
|
|
5904
5975
|
hotkey: HotkeyTool,
|
|
@@ -5953,6 +6024,8 @@ function getEditorTools(includeLayout = true, enabledTools) {
|
|
|
5953
6024
|
nestedlist: import_nested_list.default,
|
|
5954
6025
|
simpleImage: import_simple_image.default,
|
|
5955
6026
|
comment: CommentTool,
|
|
6027
|
+
continueWriting: ContinueWritingTool,
|
|
6028
|
+
askAi: AskAiTool,
|
|
5956
6029
|
settings: SettingsTriggerTool,
|
|
5957
6030
|
// Inline toolbar tools
|
|
5958
6031
|
inlineCode: import_inline_code.default,
|
|
@@ -6124,6 +6197,10 @@ ${userContent}` }] }]
|
|
|
6124
6197
|
|
|
6125
6198
|
// src/utils/popoverCategories.ts
|
|
6126
6199
|
var TOOL_CATEGORIES = [
|
|
6200
|
+
{
|
|
6201
|
+
label: "AI",
|
|
6202
|
+
tools: ["continueWriting", "askAi"]
|
|
6203
|
+
},
|
|
6127
6204
|
{
|
|
6128
6205
|
label: "Text & Style",
|
|
6129
6206
|
tools: [
|
|
@@ -6133,7 +6210,6 @@ var TOOL_CATEGORIES = [
|
|
|
6133
6210
|
"paragraph",
|
|
6134
6211
|
"list",
|
|
6135
6212
|
"nestedlist",
|
|
6136
|
-
"checklist",
|
|
6137
6213
|
"quote",
|
|
6138
6214
|
"pullquote",
|
|
6139
6215
|
"delimiter",
|
|
@@ -6221,8 +6297,79 @@ var SIMPLE_MODE_TOOLS = [
|
|
|
6221
6297
|
"code",
|
|
6222
6298
|
"image",
|
|
6223
6299
|
"delimiter",
|
|
6300
|
+
"continueWriting",
|
|
6301
|
+
"askAi",
|
|
6224
6302
|
"settings"
|
|
6225
6303
|
];
|
|
6304
|
+
var ALL_TOOL_NAMES = Array.from(
|
|
6305
|
+
new Set(TOOL_CATEGORIES.flatMap((g) => g.tools))
|
|
6306
|
+
);
|
|
6307
|
+
var TOOL_LABELS = {
|
|
6308
|
+
h1: "Heading 1",
|
|
6309
|
+
h2: "Heading 2",
|
|
6310
|
+
h3: "Heading 3",
|
|
6311
|
+
paragraph: "Paragraph",
|
|
6312
|
+
list: "List (Ordered / Unordered / Checklist)",
|
|
6313
|
+
nestedlist: "Nested List",
|
|
6314
|
+
quote: "Quote",
|
|
6315
|
+
pullquote: "Pull Quote",
|
|
6316
|
+
delimiter: "Delimiter",
|
|
6317
|
+
callout: "Callout",
|
|
6318
|
+
hotkey: "Hotkey",
|
|
6319
|
+
emoji: "Emoji",
|
|
6320
|
+
scratch: "Scratchpad",
|
|
6321
|
+
alert: "Alert",
|
|
6322
|
+
badges: "Badges",
|
|
6323
|
+
tags: "Tags",
|
|
6324
|
+
cover: "Page Cover",
|
|
6325
|
+
toc: "Table of Contents",
|
|
6326
|
+
bento: "Bento Grid",
|
|
6327
|
+
layout: "Multi-Column Layout",
|
|
6328
|
+
tabs: "Tabs",
|
|
6329
|
+
accordion: "Accordion",
|
|
6330
|
+
toggleh1: "Toggle H1",
|
|
6331
|
+
toggleh2: "Toggle H2",
|
|
6332
|
+
toggleh3: "Toggle H3",
|
|
6333
|
+
collapsible: "Collapsible",
|
|
6334
|
+
spoiler: "Spoiler",
|
|
6335
|
+
cards: "Cards",
|
|
6336
|
+
timeline: "Timeline",
|
|
6337
|
+
proscons: "Pros & Cons",
|
|
6338
|
+
upload: "Upload",
|
|
6339
|
+
image: "Image",
|
|
6340
|
+
simpleImage: "Simple Image",
|
|
6341
|
+
gif: "GIF",
|
|
6342
|
+
gallery: "Lightbox Gallery",
|
|
6343
|
+
masonry: "Masonry Grid",
|
|
6344
|
+
carousel: "Carousel",
|
|
6345
|
+
compare: "Before / After",
|
|
6346
|
+
audio: "Audio Player",
|
|
6347
|
+
musicCarousel: "Music Carousel",
|
|
6348
|
+
embed: "Embed",
|
|
6349
|
+
attaches: "Attachment",
|
|
6350
|
+
excalidraw: "Excalidraw",
|
|
6351
|
+
code: "Code Block",
|
|
6352
|
+
latex: "LaTeX Math",
|
|
6353
|
+
chart: "Data Chart",
|
|
6354
|
+
table: "Table",
|
|
6355
|
+
stats: "Stats",
|
|
6356
|
+
form: "Form Builder",
|
|
6357
|
+
poll: "Poll",
|
|
6358
|
+
quiz: "Quiz",
|
|
6359
|
+
flashcards: "Flashcards",
|
|
6360
|
+
todo: "To-Do List",
|
|
6361
|
+
eisenhower: "Eisenhower Matrix",
|
|
6362
|
+
kanban: "Kanban Board",
|
|
6363
|
+
timer: "Focus Timer",
|
|
6364
|
+
faq: "FAQ",
|
|
6365
|
+
footnotes: "Footnotes",
|
|
6366
|
+
button: "Button",
|
|
6367
|
+
dialogue: "Dialogue Box",
|
|
6368
|
+
slides: "Slides",
|
|
6369
|
+
continueWriting: "Continue Writing",
|
|
6370
|
+
askAi: "Ask AI",
|
|
6371
|
+
settings: "Settings"
|
|
6372
|
+
};
|
|
6226
6373
|
function attachPopoverCategoryHeaders(container) {
|
|
6227
6374
|
const applyCategories = () => {
|
|
6228
6375
|
const popovers = container.querySelectorAll(".ce-popover__items");
|
|
@@ -6248,18 +6395,25 @@ function attachPopoverCategoryHeaders(container) {
|
|
|
6248
6395
|
titleEl.textContent = "Paragraph";
|
|
6249
6396
|
}
|
|
6250
6397
|
}
|
|
6251
|
-
if (name)
|
|
6252
|
-
|
|
6398
|
+
if (name) {
|
|
6399
|
+
const arr = byName.get(name) || [];
|
|
6400
|
+
arr.push(el);
|
|
6401
|
+
byName.set(name, arr);
|
|
6402
|
+
} else {
|
|
6403
|
+
uncategorized.push(el);
|
|
6404
|
+
}
|
|
6253
6405
|
});
|
|
6254
6406
|
const frag = document.createDocumentFragment();
|
|
6255
6407
|
const placed = /* @__PURE__ */ new Set();
|
|
6256
6408
|
for (const group of TOOL_CATEGORIES) {
|
|
6257
6409
|
const matched = [];
|
|
6258
6410
|
for (const toolName of group.tools) {
|
|
6259
|
-
const
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
|
|
6411
|
+
const els = byName.get(toolName) || [];
|
|
6412
|
+
for (const el of els) {
|
|
6413
|
+
if (!placed.has(el)) {
|
|
6414
|
+
matched.push(el);
|
|
6415
|
+
placed.add(el);
|
|
6416
|
+
}
|
|
6263
6417
|
}
|
|
6264
6418
|
}
|
|
6265
6419
|
if (matched.length > 0) {
|
|
@@ -6288,23 +6442,313 @@ function attachPopoverCategoryHeaders(container) {
|
|
|
6288
6442
|
return () => observer.disconnect();
|
|
6289
6443
|
}
|
|
6290
6444
|
|
|
6291
|
-
// src/components/
|
|
6445
|
+
// src/components/ClassicToolbar.tsx
|
|
6292
6446
|
var import_react2 = require("react");
|
|
6293
6447
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
6448
|
+
var INSERT_ITEMS = [
|
|
6449
|
+
{ tool: "bento", label: "Bento Grid", category: "Layout" },
|
|
6450
|
+
{ tool: "masonry", label: "Masonry Grid", category: "Media" },
|
|
6451
|
+
{ tool: "excalidraw", label: "Excalidraw", category: "Media" },
|
|
6452
|
+
{ tool: "chart", label: "Data Chart", category: "Data" },
|
|
6453
|
+
{ tool: "callout", label: "Callout", category: "Text" },
|
|
6454
|
+
{ tool: "spoiler", label: "Spoiler", category: "Layout" },
|
|
6455
|
+
{ tool: "dialogue", label: "Dialogue Box", category: "Interactive" },
|
|
6456
|
+
{ tool: "scratch", label: "Scratchpad", category: "Text" },
|
|
6457
|
+
{ tool: "hotkey", label: "Hotkey", category: "Text" },
|
|
6458
|
+
{ tool: "image", label: "Image", category: "Media" },
|
|
6459
|
+
{ tool: "upload", label: "File Upload", category: "Media" },
|
|
6460
|
+
{ tool: "table", label: "Table", category: "Data" },
|
|
6461
|
+
{ tool: "latex", label: "LaTeX Math", category: "Data" },
|
|
6462
|
+
{ tool: "tabs", label: "Tabs", category: "Layout" },
|
|
6463
|
+
{ tool: "accordion", label: "Accordion", category: "Layout" },
|
|
6464
|
+
{ tool: "quiz", label: "Quiz", category: "Interactive" },
|
|
6465
|
+
{ tool: "poll", label: "Poll", category: "Interactive" },
|
|
6466
|
+
{ tool: "kanban", label: "Kanban Board", category: "Interactive" },
|
|
6467
|
+
{ tool: "delimiter", label: "Delimiter", category: "Text" },
|
|
6468
|
+
{ tool: "settings", label: "Settings", category: "System" }
|
|
6469
|
+
];
|
|
6470
|
+
var ClassicToolbar = ({
|
|
6471
|
+
editorRef,
|
|
6472
|
+
onUndo,
|
|
6473
|
+
onRedo,
|
|
6474
|
+
fontFamily,
|
|
6475
|
+
onChangeFontFamily,
|
|
6476
|
+
enabledTools,
|
|
6477
|
+
onOpenSettings
|
|
6478
|
+
}) => {
|
|
6479
|
+
const allowedTools = enabledTools ? new Set(enabledTools) : null;
|
|
6480
|
+
const visibleInsertItems = allowedTools ? INSERT_ITEMS.filter((item) => item.tool === "settings" || allowedTools.has(item.tool)) : INSERT_ITEMS;
|
|
6481
|
+
const [insertOpen, setInsertOpen] = (0, import_react2.useState)(false);
|
|
6482
|
+
const [alignOpen, setAlignOpen] = (0, import_react2.useState)(false);
|
|
6483
|
+
const [blockType, setBlockType] = (0, import_react2.useState)("paragraph");
|
|
6484
|
+
const wrapRef = (0, import_react2.useRef)(null);
|
|
6485
|
+
(0, import_react2.useEffect)(() => {
|
|
6486
|
+
const onOutside = (e) => {
|
|
6487
|
+
if (wrapRef.current && !wrapRef.current.contains(e.target)) {
|
|
6488
|
+
setInsertOpen(false);
|
|
6489
|
+
setAlignOpen(false);
|
|
6490
|
+
}
|
|
6491
|
+
};
|
|
6492
|
+
document.addEventListener("mousedown", onOutside);
|
|
6493
|
+
return () => document.removeEventListener("mousedown", onOutside);
|
|
6494
|
+
}, []);
|
|
6495
|
+
const keepSelection = (e) => {
|
|
6496
|
+
e.preventDefault();
|
|
6497
|
+
};
|
|
6498
|
+
const exec = (cmd, value) => {
|
|
6499
|
+
document.execCommand(cmd, false, value);
|
|
6500
|
+
};
|
|
6501
|
+
const toggleInlineTag = (tagName) => {
|
|
6502
|
+
const sel = window.getSelection();
|
|
6503
|
+
if (!sel || sel.rangeCount === 0) return;
|
|
6504
|
+
const range = sel.getRangeAt(0);
|
|
6505
|
+
if (range.collapsed) return;
|
|
6506
|
+
const existing = (range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? range.commonAncestorContainer : range.commonAncestorContainer.parentElement)?.closest(tagName);
|
|
6507
|
+
if (existing && existing.parentNode) {
|
|
6508
|
+
const parent = existing.parentNode;
|
|
6509
|
+
while (existing.firstChild) {
|
|
6510
|
+
parent.insertBefore(existing.firstChild, existing);
|
|
6511
|
+
}
|
|
6512
|
+
parent.removeChild(existing);
|
|
6513
|
+
return;
|
|
6514
|
+
}
|
|
6515
|
+
const el = document.createElement(tagName);
|
|
6516
|
+
el.appendChild(range.extractContents());
|
|
6517
|
+
range.insertNode(el);
|
|
6518
|
+
};
|
|
6519
|
+
const insertBlock = (tool, data = {}) => {
|
|
6520
|
+
const ed = editorRef.current;
|
|
6521
|
+
if (!ed) return;
|
|
6522
|
+
if (tool === "settings") {
|
|
6523
|
+
onOpenSettings();
|
|
6524
|
+
setInsertOpen(false);
|
|
6525
|
+
return;
|
|
6526
|
+
}
|
|
6527
|
+
try {
|
|
6528
|
+
const idx = ed.blocks.getCurrentBlockIndex();
|
|
6529
|
+
const targetIdx = idx >= 0 ? idx + 1 : ed.blocks.getBlocksCount();
|
|
6530
|
+
ed.blocks.insert(tool, data, {}, targetIdx, true);
|
|
6531
|
+
} catch {
|
|
6532
|
+
ed.blocks.insert(tool, data);
|
|
6533
|
+
}
|
|
6534
|
+
setInsertOpen(false);
|
|
6535
|
+
};
|
|
6536
|
+
const handleBlockTypeChange = (next) => {
|
|
6537
|
+
setBlockType(next);
|
|
6538
|
+
if (next === "paragraph") insertBlock("paragraph", { text: "" });
|
|
6539
|
+
else if (next === "h1") insertBlock("h1", { text: "", level: 1 });
|
|
6540
|
+
else if (next === "h2") insertBlock("h2", { text: "", level: 2 });
|
|
6541
|
+
else if (next === "h3") insertBlock("h3", { text: "", level: 3 });
|
|
6542
|
+
else if (next === "quote") insertBlock("quote", { text: "", caption: "" });
|
|
6543
|
+
else if (next === "code") insertBlock("code", { code: "" });
|
|
6544
|
+
};
|
|
6545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ref: wrapRef, className: "ng-classic-toolbar", role: "toolbar", "aria-label": "Formatting toolbar", children: [
|
|
6546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: onUndo, title: "Undo", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
6547
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 7v6h6" }),
|
|
6548
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })
|
|
6549
|
+
] }) }),
|
|
6550
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: onRedo, title: "Redo", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
6551
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M21 7v6h-6" }),
|
|
6552
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })
|
|
6553
|
+
] }) }),
|
|
6554
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-sep" }),
|
|
6555
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
6556
|
+
"select",
|
|
6557
|
+
{
|
|
6558
|
+
className: "ng-ct-select",
|
|
6559
|
+
value: blockType,
|
|
6560
|
+
onChange: (e) => handleBlockTypeChange(e.target.value),
|
|
6561
|
+
"aria-label": "Block type",
|
|
6562
|
+
children: [
|
|
6563
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "paragraph", children: "Paragraph" }),
|
|
6564
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h1", children: "Heading 1" }),
|
|
6565
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h2", children: "Heading 2" }),
|
|
6566
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h3", children: "Heading 3" }),
|
|
6567
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "quote", children: "Quote" }),
|
|
6568
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "code", children: "Code" })
|
|
6569
|
+
]
|
|
6570
|
+
}
|
|
6571
|
+
),
|
|
6572
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
6573
|
+
"select",
|
|
6574
|
+
{
|
|
6575
|
+
className: "ng-ct-select",
|
|
6576
|
+
value: fontFamily,
|
|
6577
|
+
onChange: (e) => onChangeFontFamily(e.target.value),
|
|
6578
|
+
"aria-label": "Font family",
|
|
6579
|
+
children: [
|
|
6580
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "sans", children: "Sans" }),
|
|
6581
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "serif", children: "Serif" }),
|
|
6582
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "mono", children: "Mono" })
|
|
6583
|
+
]
|
|
6584
|
+
}
|
|
6585
|
+
),
|
|
6586
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-sep" }),
|
|
6587
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn ng-ct-b", onMouseDown: keepSelection, onClick: () => exec("bold"), title: "Bold", children: "B" }),
|
|
6588
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn ng-ct-i", onMouseDown: keepSelection, onClick: () => exec("italic"), title: "Italic", children: "I" }),
|
|
6589
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn ng-ct-u", onMouseDown: keepSelection, onClick: () => exec("underline"), title: "Underline", children: "U" }),
|
|
6590
|
+
/* @__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
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => toggleInlineTag("code"), title: "Inline Code", children: "<>" }),
|
|
6592
|
+
/* @__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" }),
|
|
6593
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
6594
|
+
"button",
|
|
6595
|
+
{
|
|
6596
|
+
type: "button",
|
|
6597
|
+
className: "ng-ct-btn",
|
|
6598
|
+
onMouseDown: keepSelection,
|
|
6599
|
+
onClick: () => {
|
|
6600
|
+
const url = window.prompt("Enter link URL (https://...)");
|
|
6601
|
+
if (url) exec("createLink", url.trim());
|
|
6602
|
+
},
|
|
6603
|
+
title: "Insert Link",
|
|
6604
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
6605
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
6606
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
6607
|
+
] })
|
|
6608
|
+
}
|
|
6609
|
+
),
|
|
6610
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("superscript"), title: "Superscript", children: "x\xB2" }),
|
|
6611
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("subscript"), title: "Subscript", children: "x\u2082" }),
|
|
6612
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("removeFormat"), title: "Clear Formatting", children: "T\u2093" }),
|
|
6613
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-sep" }),
|
|
6614
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "unordered", items: [] }), title: "Bullet List", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6615
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
|
|
6616
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
|
|
6617
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
|
|
6618
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "6", r: "1" }),
|
|
6619
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "12", r: "1" }),
|
|
6620
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "4", cy: "18", r: "1" })
|
|
6621
|
+
] }) }),
|
|
6622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "ordered", items: [] }), title: "Numbered List", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6623
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
|
|
6624
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
|
|
6625
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
|
|
6626
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 6h1v4" }),
|
|
6627
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 10h2" }),
|
|
6628
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
6629
|
+
] }) }),
|
|
6630
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "checklist", items: [] }), title: "Checklist", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6631
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "5", width: "6", height: "6", rx: "1" }),
|
|
6632
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3 17 2 2 4-4" }),
|
|
6633
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 6h8" }),
|
|
6634
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 12h8" }),
|
|
6635
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M13 18h8" })
|
|
6636
|
+
] }) }),
|
|
6637
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("outdent"), title: "Decrease Indent", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6638
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "7 8 3 12 7 16" }),
|
|
6639
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
|
|
6640
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
|
|
6641
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
|
|
6642
|
+
] }) }),
|
|
6643
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("indent"), title: "Increase Indent", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6644
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "3 8 7 12 3 16" }),
|
|
6645
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
|
|
6646
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
|
|
6647
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
|
|
6648
|
+
] }) }),
|
|
6649
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ng-ct-dropdown-wrap", children: [
|
|
6650
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
6651
|
+
"button",
|
|
6652
|
+
{
|
|
6653
|
+
type: "button",
|
|
6654
|
+
className: "ng-ct-btn",
|
|
6655
|
+
onMouseDown: keepSelection,
|
|
6656
|
+
onClick: () => {
|
|
6657
|
+
setAlignOpen((v) => !v);
|
|
6658
|
+
setInsertOpen(false);
|
|
6659
|
+
},
|
|
6660
|
+
title: "Alignment",
|
|
6661
|
+
children: [
|
|
6662
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
|
|
6663
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "3", y1: "6", x2: "21", y2: "6" }),
|
|
6664
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "3", y1: "12", x2: "15", y2: "12" }),
|
|
6665
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "3", y1: "18", x2: "18", y2: "18" })
|
|
6666
|
+
] }),
|
|
6667
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-caret", children: "\u25BE" })
|
|
6668
|
+
]
|
|
6669
|
+
}
|
|
6670
|
+
),
|
|
6671
|
+
alignOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ng-ct-menu", children: [
|
|
6672
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
|
|
6673
|
+
exec("justifyLeft");
|
|
6674
|
+
setAlignOpen(false);
|
|
6675
|
+
}, children: "Align Left" }),
|
|
6676
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
|
|
6677
|
+
exec("justifyCenter");
|
|
6678
|
+
setAlignOpen(false);
|
|
6679
|
+
}, children: "Align Center" }),
|
|
6680
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
|
|
6681
|
+
exec("justifyRight");
|
|
6682
|
+
setAlignOpen(false);
|
|
6683
|
+
}, children: "Align Right" }),
|
|
6684
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
|
|
6685
|
+
exec("justifyFull");
|
|
6686
|
+
setAlignOpen(false);
|
|
6687
|
+
}, children: "Justify" })
|
|
6688
|
+
] })
|
|
6689
|
+
] }),
|
|
6690
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-sep" }),
|
|
6691
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ng-ct-dropdown-wrap", children: [
|
|
6692
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
6693
|
+
"button",
|
|
6694
|
+
{
|
|
6695
|
+
type: "button",
|
|
6696
|
+
className: "ng-ct-insert-btn",
|
|
6697
|
+
onClick: () => {
|
|
6698
|
+
setInsertOpen((v) => !v);
|
|
6699
|
+
setAlignOpen(false);
|
|
6700
|
+
},
|
|
6701
|
+
children: [
|
|
6702
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "+ Insert" }),
|
|
6703
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-caret", children: "\u25BE" })
|
|
6704
|
+
]
|
|
6705
|
+
}
|
|
6706
|
+
),
|
|
6707
|
+
insertOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ng-ct-menu ng-ct-insert-menu", children: visibleInsertItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
6708
|
+
"button",
|
|
6709
|
+
{
|
|
6710
|
+
type: "button",
|
|
6711
|
+
onClick: () => insertBlock(item.tool),
|
|
6712
|
+
children: [
|
|
6713
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: item.label }),
|
|
6714
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ng-ct-cat", children: item.category })
|
|
6715
|
+
]
|
|
6716
|
+
},
|
|
6717
|
+
item.tool
|
|
6718
|
+
)) })
|
|
6719
|
+
] })
|
|
6720
|
+
] });
|
|
6721
|
+
};
|
|
6722
|
+
|
|
6723
|
+
// src/components/SettingsModal.tsx
|
|
6724
|
+
var import_react3 = require("react");
|
|
6725
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
6294
6726
|
var SettingsModal = ({
|
|
6295
6727
|
open,
|
|
6296
6728
|
theme,
|
|
6297
6729
|
mode,
|
|
6298
6730
|
showStats,
|
|
6299
6731
|
aiConfig,
|
|
6732
|
+
selectedTools,
|
|
6300
6733
|
onChangeTheme,
|
|
6301
6734
|
onChangeMode,
|
|
6302
6735
|
onChangeShowStats,
|
|
6303
6736
|
onChangeAiConfig,
|
|
6737
|
+
onChangeSelectedTools,
|
|
6304
6738
|
onClose
|
|
6305
6739
|
}) => {
|
|
6306
|
-
const [showKey, setShowKey] = (0,
|
|
6740
|
+
const [showKey, setShowKey] = (0, import_react3.useState)(false);
|
|
6741
|
+
const [toolFilter, setToolFilter] = (0, import_react3.useState)("");
|
|
6742
|
+
const [activeTab, setActiveTab] = (0, import_react3.useState)("appearance");
|
|
6307
6743
|
if (!open) return null;
|
|
6744
|
+
const selectedSet = new Set(selectedTools);
|
|
6745
|
+
const toggleTool = (tool) => {
|
|
6746
|
+
const next = new Set(selectedTools);
|
|
6747
|
+
if (next.has(tool)) next.delete(tool);
|
|
6748
|
+
else next.add(tool);
|
|
6749
|
+
next.add("settings");
|
|
6750
|
+
onChangeSelectedTools(Array.from(next));
|
|
6751
|
+
};
|
|
6308
6752
|
const handleProviderChange = (providerId) => {
|
|
6309
6753
|
const preset = AI_PROVIDER_PRESETS.find((p) => p.id === providerId);
|
|
6310
6754
|
onChangeAiConfig({
|
|
@@ -6314,169 +6758,296 @@ var SettingsModal = ({
|
|
|
6314
6758
|
endpoint: preset?.defaultEndpoint || ""
|
|
6315
6759
|
});
|
|
6316
6760
|
};
|
|
6317
|
-
return /* @__PURE__ */ (0,
|
|
6318
|
-
/* @__PURE__ */ (0,
|
|
6319
|
-
/* @__PURE__ */ (0,
|
|
6320
|
-
/* @__PURE__ */ (0,
|
|
6321
|
-
/* @__PURE__ */ (0,
|
|
6761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Editor Settings", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal ng-modal-wide", children: [
|
|
6762
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-head", children: [
|
|
6763
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
6764
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { children: "Editor Settings" }),
|
|
6765
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "Configure appearance, AI provider, and registered components." })
|
|
6322
6766
|
] }),
|
|
6323
|
-
/* @__PURE__ */ (0,
|
|
6767
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
|
|
6324
6768
|
] }),
|
|
6325
|
-
/* @__PURE__ */ (0,
|
|
6326
|
-
/* @__PURE__ */ (0,
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
}
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6769
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-layout", children: [
|
|
6770
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("aside", { className: "ng-modal-sidebar", role: "tablist", "aria-label": "Settings sections", children: [
|
|
6771
|
+
{ id: "appearance", label: "Appearance" },
|
|
6772
|
+
{ id: "ai", label: "AI Provider" },
|
|
6773
|
+
{ id: "components", label: `Components (${selectedSet.size})` }
|
|
6774
|
+
].map((t) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6775
|
+
"button",
|
|
6776
|
+
{
|
|
6777
|
+
type: "button",
|
|
6778
|
+
role: "tab",
|
|
6779
|
+
"aria-selected": activeTab === t.id,
|
|
6780
|
+
className: `ng-modal-tab${activeTab === t.id ? " is-active" : ""}`,
|
|
6781
|
+
onClick: () => setActiveTab(t.id),
|
|
6782
|
+
children: t.label
|
|
6783
|
+
},
|
|
6784
|
+
t.id
|
|
6785
|
+
)) }),
|
|
6786
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-main", children: [
|
|
6787
|
+
activeTab === "appearance" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-panel", children: [
|
|
6788
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6789
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Theme" }),
|
|
6790
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6791
|
+
"select",
|
|
6792
|
+
{
|
|
6793
|
+
className: "cdx-input editor-form-select",
|
|
6794
|
+
value: theme,
|
|
6795
|
+
onChange: (e) => onChangeTheme(e.target.value),
|
|
6796
|
+
children: [
|
|
6797
|
+
/* @__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: "shadcn Light" }),
|
|
6799
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: "dark", children: "shadcn Dark" }),
|
|
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" })
|
|
6804
|
+
]
|
|
6805
|
+
}
|
|
6806
|
+
)
|
|
6807
|
+
] }),
|
|
6808
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6809
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Editor Mode" }),
|
|
6810
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-segmented", children: [
|
|
6811
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6812
|
+
"button",
|
|
6813
|
+
{
|
|
6814
|
+
type: "button",
|
|
6815
|
+
className: `excalidraw-btn${mode === "block" ? " is-active" : ""}`,
|
|
6816
|
+
onClick: () => onChangeMode("block"),
|
|
6817
|
+
children: "Block Editor (Full)"
|
|
6818
|
+
}
|
|
6819
|
+
),
|
|
6820
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6821
|
+
"button",
|
|
6822
|
+
{
|
|
6823
|
+
type: "button",
|
|
6824
|
+
className: `excalidraw-btn${mode === "simple" ? " is-active" : ""}`,
|
|
6825
|
+
onClick: () => onChangeMode("simple"),
|
|
6826
|
+
children: "Simple Mode"
|
|
6827
|
+
}
|
|
6828
|
+
)
|
|
6829
|
+
] })
|
|
6830
|
+
] }),
|
|
6831
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field ng-field-inline", children: [
|
|
6832
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { htmlFor: "ng-stats-toggle", children: "Show word count & read time" }),
|
|
6833
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6834
|
+
"input",
|
|
6835
|
+
{
|
|
6836
|
+
id: "ng-stats-toggle",
|
|
6837
|
+
type: "checkbox",
|
|
6838
|
+
checked: showStats,
|
|
6839
|
+
onChange: (e) => onChangeShowStats(e.target.checked)
|
|
6840
|
+
}
|
|
6841
|
+
)
|
|
6842
|
+
] })
|
|
6843
|
+
] }),
|
|
6844
|
+
activeTab === "ai" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-modal-panel", children: [
|
|
6845
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6846
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "AI Provider" }),
|
|
6847
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6848
|
+
"select",
|
|
6849
|
+
{
|
|
6850
|
+
className: "cdx-input editor-form-select",
|
|
6851
|
+
value: aiConfig.provider,
|
|
6852
|
+
onChange: (e) => handleProviderChange(e.target.value),
|
|
6853
|
+
children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("option", { value: p.id, children: p.label }, p.id))
|
|
6854
|
+
}
|
|
6855
|
+
)
|
|
6856
|
+
] }),
|
|
6857
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6858
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Model" }),
|
|
6859
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6860
|
+
"input",
|
|
6861
|
+
{
|
|
6862
|
+
type: "text",
|
|
6863
|
+
className: "cdx-input editor-form-input",
|
|
6864
|
+
value: aiConfig.model,
|
|
6865
|
+
placeholder: "e.g. gpt-4o-mini",
|
|
6866
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, model: e.target.value })
|
|
6867
|
+
}
|
|
6868
|
+
)
|
|
6869
|
+
] }),
|
|
6870
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6871
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "API Key" }),
|
|
6872
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-key-row", children: [
|
|
6873
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6874
|
+
"input",
|
|
6875
|
+
{
|
|
6876
|
+
type: showKey ? "text" : "password",
|
|
6877
|
+
className: "cdx-input editor-form-input",
|
|
6878
|
+
value: aiConfig.apiKey,
|
|
6879
|
+
placeholder: "sk-...",
|
|
6880
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, apiKey: e.target.value })
|
|
6881
|
+
}
|
|
6882
|
+
),
|
|
6883
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6884
|
+
"button",
|
|
6885
|
+
{
|
|
6886
|
+
type: "button",
|
|
6887
|
+
className: "excalidraw-btn",
|
|
6888
|
+
onClick: () => setShowKey((s) => !s),
|
|
6889
|
+
children: showKey ? "Hide" : "Show"
|
|
6890
|
+
}
|
|
6891
|
+
)
|
|
6892
|
+
] })
|
|
6893
|
+
] }),
|
|
6894
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-field", children: [
|
|
6895
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("label", { children: "Endpoint URL (optional)" }),
|
|
6896
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6897
|
+
"input",
|
|
6898
|
+
{
|
|
6899
|
+
type: "url",
|
|
6900
|
+
className: "cdx-input editor-form-input",
|
|
6901
|
+
value: aiConfig.endpoint || "",
|
|
6902
|
+
placeholder: "Default provider endpoint",
|
|
6903
|
+
onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
|
|
6904
|
+
}
|
|
6905
|
+
)
|
|
6906
|
+
] })
|
|
6907
|
+
] }),
|
|
6908
|
+
activeTab === "components" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-manager", children: [
|
|
6909
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-header", children: [
|
|
6910
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { children: [
|
|
6911
|
+
"Registered Components (",
|
|
6912
|
+
selectedSet.size,
|
|
6913
|
+
"/",
|
|
6914
|
+
ALL_TOOL_NAMES.length,
|
|
6915
|
+
")"
|
|
6916
|
+
] }) }),
|
|
6917
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-actions", children: [
|
|
6918
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6919
|
+
"button",
|
|
6920
|
+
{
|
|
6921
|
+
type: "button",
|
|
6922
|
+
className: "excalidraw-btn",
|
|
6923
|
+
onClick: () => onChangeSelectedTools([...ALL_TOOL_NAMES]),
|
|
6924
|
+
children: "All"
|
|
6925
|
+
}
|
|
6926
|
+
),
|
|
6927
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6928
|
+
"button",
|
|
6929
|
+
{
|
|
6930
|
+
type: "button",
|
|
6931
|
+
className: "excalidraw-btn",
|
|
6932
|
+
onClick: () => onChangeSelectedTools([...SIMPLE_MODE_TOOLS]),
|
|
6933
|
+
children: "Minimal"
|
|
6934
|
+
}
|
|
6935
|
+
)
|
|
6936
|
+
] })
|
|
6937
|
+
] }),
|
|
6938
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6411
6939
|
"input",
|
|
6412
6940
|
{
|
|
6413
|
-
type:
|
|
6941
|
+
type: "search",
|
|
6414
6942
|
className: "cdx-input editor-form-input",
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
onChange: (e) =>
|
|
6943
|
+
placeholder: "Filter components (e.g. bento, chart, spoiler...)",
|
|
6944
|
+
value: toolFilter,
|
|
6945
|
+
onChange: (e) => setToolFilter(e.target.value)
|
|
6418
6946
|
}
|
|
6419
6947
|
),
|
|
6420
|
-
/* @__PURE__ */ (0,
|
|
6421
|
-
|
|
6422
|
-
{
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6948
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-tools-groups", children: TOOL_CATEGORIES.filter((g) => g.label !== "Settings").map((group) => {
|
|
6949
|
+
const q = toolFilter.trim().toLowerCase();
|
|
6950
|
+
const visible = group.tools.filter((t) => {
|
|
6951
|
+
const label = (TOOL_LABELS[t] || t).toLowerCase();
|
|
6952
|
+
return !q || label.includes(q) || t.toLowerCase().includes(q);
|
|
6953
|
+
});
|
|
6954
|
+
if (!visible.length) return null;
|
|
6955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ng-tools-group", children: [
|
|
6956
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-tools-group-title", children: group.label }),
|
|
6957
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ng-tools-grid", children: visible.map((tool) => {
|
|
6958
|
+
const checked = selectedSet.has(tool);
|
|
6959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
6960
|
+
"label",
|
|
6961
|
+
{
|
|
6962
|
+
className: `ng-tool-chip${checked ? " is-checked" : ""}`,
|
|
6963
|
+
children: [
|
|
6964
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
6965
|
+
"input",
|
|
6966
|
+
{
|
|
6967
|
+
type: "checkbox",
|
|
6968
|
+
checked,
|
|
6969
|
+
onChange: () => toggleTool(tool)
|
|
6970
|
+
}
|
|
6971
|
+
),
|
|
6972
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: TOOL_LABELS[tool] || tool })
|
|
6973
|
+
]
|
|
6974
|
+
},
|
|
6975
|
+
tool
|
|
6976
|
+
);
|
|
6977
|
+
}) })
|
|
6978
|
+
] }, group.label);
|
|
6979
|
+
}) })
|
|
6429
6980
|
] })
|
|
6430
|
-
] }),
|
|
6431
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ng-field", children: [
|
|
6432
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "Endpoint URL (optional)" }),
|
|
6433
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
6434
|
-
"input",
|
|
6435
|
-
{
|
|
6436
|
-
type: "url",
|
|
6437
|
-
className: "cdx-input editor-form-input",
|
|
6438
|
-
value: aiConfig.endpoint || "",
|
|
6439
|
-
placeholder: "Default provider endpoint",
|
|
6440
|
-
onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
|
|
6441
|
-
}
|
|
6442
|
-
)
|
|
6443
6981
|
] })
|
|
6444
6982
|
] })
|
|
6445
6983
|
] }) });
|
|
6446
6984
|
};
|
|
6447
6985
|
|
|
6448
6986
|
// src/components/BlockEditor.tsx
|
|
6449
|
-
var
|
|
6450
|
-
var BlockEditor =
|
|
6987
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6988
|
+
var BlockEditor = import_react4.default.forwardRef(
|
|
6451
6989
|
({
|
|
6452
6990
|
initialData,
|
|
6453
6991
|
placeholder,
|
|
6454
6992
|
enabledTools,
|
|
6455
6993
|
showStats = true,
|
|
6456
|
-
showAiBar =
|
|
6994
|
+
showAiBar = false,
|
|
6457
6995
|
onAiRequest,
|
|
6458
6996
|
className,
|
|
6459
6997
|
onReady,
|
|
6460
|
-
onChange
|
|
6998
|
+
onChange,
|
|
6999
|
+
onThemeChange
|
|
6461
7000
|
}, ref) => {
|
|
6462
|
-
const shellRef = (0,
|
|
6463
|
-
const holderRef = (0,
|
|
6464
|
-
const editorRef = (0,
|
|
6465
|
-
const undoRef = (0,
|
|
6466
|
-
const lifecycleRef = (0,
|
|
6467
|
-
const latestDocRef = (0,
|
|
6468
|
-
const onChangeRef = (0,
|
|
6469
|
-
const onReadyRef = (0,
|
|
6470
|
-
const
|
|
6471
|
-
|
|
6472
|
-
const [
|
|
6473
|
-
const [
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
7001
|
+
const shellRef = (0, import_react4.useRef)(null);
|
|
7002
|
+
const holderRef = (0, import_react4.useRef)(null);
|
|
7003
|
+
const editorRef = (0, import_react4.useRef)(null);
|
|
7004
|
+
const undoRef = (0, import_react4.useRef)(null);
|
|
7005
|
+
const lifecycleRef = (0, import_react4.useRef)(Promise.resolve());
|
|
7006
|
+
const latestDocRef = (0, import_react4.useRef)(initialData || { blocks: [] });
|
|
7007
|
+
const onChangeRef = (0, import_react4.useRef)(onChange);
|
|
7008
|
+
const onReadyRef = (0, import_react4.useRef)(onReady);
|
|
7009
|
+
const runAiRef = (0, import_react4.useRef)(async () => {
|
|
7010
|
+
});
|
|
7011
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react4.useState)(false);
|
|
7012
|
+
const [theme, setTheme] = (0, import_react4.useState)(() => {
|
|
7013
|
+
try {
|
|
7014
|
+
const saved = localStorage.getItem("ng-editor-theme");
|
|
7015
|
+
if (saved) return saved;
|
|
7016
|
+
} catch {
|
|
7017
|
+
}
|
|
7018
|
+
return "inherit";
|
|
7019
|
+
});
|
|
7020
|
+
const [editorMode, setEditorMode] = (0, import_react4.useState)("block");
|
|
7021
|
+
const [simpleFont, setSimpleFont] = (0, import_react4.useState)("sans");
|
|
7022
|
+
const [selectedTools, setSelectedTools] = (0, import_react4.useState)(() => {
|
|
7023
|
+
if (enabledTools && enabledTools.length > 0) return enabledTools;
|
|
7024
|
+
try {
|
|
7025
|
+
const raw = localStorage.getItem("ng-enabled-tools");
|
|
7026
|
+
if (raw) {
|
|
7027
|
+
const parsed = JSON.parse(raw);
|
|
7028
|
+
if (Array.isArray(parsed) && parsed.length > 0) return parsed;
|
|
7029
|
+
}
|
|
7030
|
+
} catch {
|
|
7031
|
+
}
|
|
7032
|
+
return ALL_TOOL_NAMES;
|
|
7033
|
+
});
|
|
7034
|
+
const [statsVisible, setStatsVisible] = (0, import_react4.useState)(showStats);
|
|
7035
|
+
const [aiConfig, setAiConfig] = (0, import_react4.useState)(loadAiConfig);
|
|
7036
|
+
const [aiPopover, setAiPopover] = (0, import_react4.useState)(null);
|
|
7037
|
+
const [askPrompt, setAskPrompt] = (0, import_react4.useState)("");
|
|
7038
|
+
const [aiBusy, setAiBusy] = (0, import_react4.useState)(false);
|
|
7039
|
+
const [aiError, setAiError] = (0, import_react4.useState)(null);
|
|
7040
|
+
const [scratchOpen, setScratchOpen] = (0, import_react4.useState)(false);
|
|
7041
|
+
const [scratchText, setScratchText] = (0, import_react4.useState)(() => {
|
|
7042
|
+
try {
|
|
7043
|
+
return localStorage.getItem("ng-scratchpad-note") || "";
|
|
7044
|
+
} catch {
|
|
7045
|
+
return "";
|
|
7046
|
+
}
|
|
7047
|
+
});
|
|
7048
|
+
const [scratchCopied, setScratchCopied] = (0, import_react4.useState)(false);
|
|
7049
|
+
const [scratchOffset, setScratchOffset] = (0, import_react4.useState)({ x: 0, y: 0 });
|
|
7050
|
+
const [stats, setStats] = (0, import_react4.useState)(() => {
|
|
6480
7051
|
const blocks = initialData?.blocks || [];
|
|
6481
7052
|
const text = blocks.map((b) => JSON.stringify(b.data || {})).join(" ");
|
|
6482
7053
|
const words = text.trim() ? text.trim().split(/\s+/).length : 0;
|
|
@@ -6484,39 +7055,85 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6484
7055
|
});
|
|
6485
7056
|
onChangeRef.current = onChange;
|
|
6486
7057
|
onReadyRef.current = onReady;
|
|
6487
|
-
(0,
|
|
7058
|
+
(0, import_react4.useEffect)(() => {
|
|
6488
7059
|
setStatsVisible(showStats);
|
|
6489
7060
|
}, [showStats]);
|
|
6490
|
-
(0,
|
|
7061
|
+
(0, import_react4.useEffect)(() => {
|
|
7062
|
+
try {
|
|
7063
|
+
localStorage.setItem("ng-editor-theme", theme);
|
|
7064
|
+
} catch {
|
|
7065
|
+
}
|
|
7066
|
+
if (theme === "inherit") {
|
|
7067
|
+
document.documentElement.removeAttribute("data-ng-theme");
|
|
7068
|
+
} else {
|
|
7069
|
+
document.documentElement.setAttribute("data-ng-theme", theme);
|
|
7070
|
+
}
|
|
7071
|
+
onThemeChange?.(theme);
|
|
7072
|
+
}, [theme, onThemeChange]);
|
|
7073
|
+
(0, import_react4.useEffect)(() => {
|
|
6491
7074
|
const shell = shellRef.current;
|
|
6492
7075
|
if (!shell) return;
|
|
7076
|
+
const openAiNearRect = (mode, e) => {
|
|
7077
|
+
const rect = e.detail?.rect;
|
|
7078
|
+
const shellRect = shell.getBoundingClientRect();
|
|
7079
|
+
const popW = 320;
|
|
7080
|
+
const rawLeft = rect ? rect.left - shellRect.left : 60;
|
|
7081
|
+
const rawTop = rect ? rect.top - shellRect.top + 4 : 60;
|
|
7082
|
+
const maxLeft = Math.max(12, shellRect.width - popW - 12);
|
|
7083
|
+
const left = Math.max(12, Math.min(rawLeft, maxLeft));
|
|
7084
|
+
const top = Math.max(12, rawTop);
|
|
7085
|
+
setAiError(null);
|
|
7086
|
+
setAskPrompt("");
|
|
7087
|
+
setAiPopover({ mode, top, left });
|
|
7088
|
+
};
|
|
6493
7089
|
const onOpenSettings = () => setSettingsOpen(true);
|
|
7090
|
+
const onAiContinue = (e) => openAiNearRect("continue", e);
|
|
7091
|
+
const onAiAsk = (e) => openAiNearRect("ask", e);
|
|
7092
|
+
const onOpenScratch = () => setScratchOpen(true);
|
|
6494
7093
|
shell.addEventListener("nextgen-open-settings", onOpenSettings);
|
|
6495
|
-
|
|
7094
|
+
shell.addEventListener("nextgen-ai-continue", onAiContinue);
|
|
7095
|
+
shell.addEventListener("nextgen-ai-ask", onAiAsk);
|
|
7096
|
+
shell.addEventListener("nextgen-open-scratch", onOpenScratch);
|
|
7097
|
+
return () => {
|
|
7098
|
+
shell.removeEventListener("nextgen-open-settings", onOpenSettings);
|
|
7099
|
+
shell.removeEventListener("nextgen-ai-continue", onAiContinue);
|
|
7100
|
+
shell.removeEventListener("nextgen-ai-ask", onAiAsk);
|
|
7101
|
+
shell.removeEventListener("nextgen-open-scratch", onOpenScratch);
|
|
7102
|
+
};
|
|
6496
7103
|
}, []);
|
|
6497
|
-
(0,
|
|
7104
|
+
(0, import_react4.useEffect)(() => {
|
|
6498
7105
|
const holder = holderRef.current;
|
|
6499
7106
|
if (!holder) return;
|
|
6500
7107
|
let cancelled = false;
|
|
6501
7108
|
const detachCategories = attachPopoverCategoryHeaders(holder);
|
|
6502
|
-
const
|
|
7109
|
+
const detachEmoji = attachEmojiSidePicker(holder);
|
|
7110
|
+
const effectiveTools = Array.from(/* @__PURE__ */ new Set([...selectedTools, "settings"]));
|
|
6503
7111
|
const mount = async () => {
|
|
6504
7112
|
await lifecycleRef.current;
|
|
6505
7113
|
if (cancelled) return;
|
|
7114
|
+
const sanitizedInitial = {
|
|
7115
|
+
...latestDocRef.current || { blocks: [] },
|
|
7116
|
+
blocks: (latestDocRef.current?.blocks || []).filter(
|
|
7117
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7118
|
+
)
|
|
7119
|
+
};
|
|
7120
|
+
latestDocRef.current = sanitizedInitial;
|
|
6506
7121
|
holder.innerHTML = "";
|
|
6507
7122
|
const instance = new import_editorjs2.default({
|
|
6508
7123
|
holder,
|
|
6509
|
-
data:
|
|
7124
|
+
data: sanitizedInitial,
|
|
6510
7125
|
placeholder: placeholder || "Write your story, or press / to insert blocks...",
|
|
6511
7126
|
tools: getEditorTools(true, effectiveTools),
|
|
6512
7127
|
onChange: async () => {
|
|
6513
7128
|
try {
|
|
6514
7129
|
const saved = await instance.save();
|
|
6515
|
-
const
|
|
7130
|
+
const filteredBlocks = (saved.blocks || []).filter(
|
|
7131
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7132
|
+
);
|
|
7133
|
+
const typed = { ...saved, blocks: filteredBlocks };
|
|
6516
7134
|
latestDocRef.current = typed;
|
|
6517
|
-
const blocks = saved.blocks || [];
|
|
6518
7135
|
const words = (holder.innerText || "").trim().split(/\s+/).filter(Boolean).length;
|
|
6519
|
-
setStats({ words, blocks:
|
|
7136
|
+
setStats({ words, blocks: filteredBlocks.length });
|
|
6520
7137
|
onChangeRef.current?.(typed);
|
|
6521
7138
|
} catch {
|
|
6522
7139
|
}
|
|
@@ -6545,6 +7162,7 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6545
7162
|
return () => {
|
|
6546
7163
|
cancelled = true;
|
|
6547
7164
|
detachCategories();
|
|
7165
|
+
detachEmoji();
|
|
6548
7166
|
const toDestroy = editorRef.current;
|
|
6549
7167
|
editorRef.current = null;
|
|
6550
7168
|
undoRef.current = null;
|
|
@@ -6555,13 +7173,16 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6555
7173
|
});
|
|
6556
7174
|
}
|
|
6557
7175
|
};
|
|
6558
|
-
}, [editorMode]);
|
|
6559
|
-
(0,
|
|
7176
|
+
}, [editorMode, selectedTools]);
|
|
7177
|
+
(0, import_react4.useImperativeHandle)(ref, () => ({
|
|
6560
7178
|
save: async () => {
|
|
6561
7179
|
if (!editorRef.current) return null;
|
|
6562
7180
|
await editorRef.current.isReady;
|
|
6563
7181
|
const saved = await editorRef.current.save();
|
|
6564
|
-
const
|
|
7182
|
+
const filteredBlocks = (saved.blocks || []).filter(
|
|
7183
|
+
(b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
|
|
7184
|
+
);
|
|
7185
|
+
const typed = { ...saved, blocks: filteredBlocks };
|
|
6565
7186
|
latestDocRef.current = typed;
|
|
6566
7187
|
return typed;
|
|
6567
7188
|
},
|
|
@@ -6606,7 +7227,7 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6606
7227
|
}
|
|
6607
7228
|
if (mode === "ask") {
|
|
6608
7229
|
setAskPrompt("");
|
|
6609
|
-
|
|
7230
|
+
setAiPopover(null);
|
|
6610
7231
|
}
|
|
6611
7232
|
} catch (err) {
|
|
6612
7233
|
setAiError(err instanceof Error ? err.message : "AI request failed.");
|
|
@@ -6614,6 +7235,7 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6614
7235
|
setAiBusy(false);
|
|
6615
7236
|
}
|
|
6616
7237
|
};
|
|
7238
|
+
runAiRef.current = runAi;
|
|
6617
7239
|
const handleModeSwitch = async (nextMode) => {
|
|
6618
7240
|
if (nextMode === editorMode) return;
|
|
6619
7241
|
if (editorRef.current) {
|
|
@@ -6627,16 +7249,17 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6627
7249
|
setEditorMode(nextMode);
|
|
6628
7250
|
};
|
|
6629
7251
|
const readMins = Math.max(1, Math.ceil(stats.words / 200));
|
|
6630
|
-
return /* @__PURE__ */ (0,
|
|
7252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
6631
7253
|
"div",
|
|
6632
7254
|
{
|
|
6633
7255
|
ref: shellRef,
|
|
6634
7256
|
"data-ng-theme": theme === "inherit" ? void 0 : theme,
|
|
7257
|
+
"data-ng-font": editorMode === "simple" ? simpleFont : void 0,
|
|
6635
7258
|
className: className ? `nextgen-editor-shell ${className}` : "nextgen-editor-shell",
|
|
6636
7259
|
children: [
|
|
6637
|
-
showAiBar && /* @__PURE__ */ (0,
|
|
6638
|
-
/* @__PURE__ */ (0,
|
|
6639
|
-
/* @__PURE__ */ (0,
|
|
7260
|
+
showAiBar && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-ai-bar", children: [
|
|
7261
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-ai-actions", children: [
|
|
7262
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6640
7263
|
"button",
|
|
6641
7264
|
{
|
|
6642
7265
|
type: "button",
|
|
@@ -6646,18 +7269,20 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6646
7269
|
children: aiBusy ? "Thinking\u2026" : "\u2726 Continue Writing"
|
|
6647
7270
|
}
|
|
6648
7271
|
),
|
|
6649
|
-
/* @__PURE__ */ (0,
|
|
7272
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6650
7273
|
"button",
|
|
6651
7274
|
{
|
|
6652
7275
|
type: "button",
|
|
6653
|
-
className: `excalidraw-btn${
|
|
7276
|
+
className: `excalidraw-btn${aiPopover?.mode === "ask" ? " is-active" : ""}`,
|
|
6654
7277
|
disabled: aiBusy,
|
|
6655
|
-
onClick: () =>
|
|
7278
|
+
onClick: () => setAiPopover(
|
|
7279
|
+
(p) => p ? null : { mode: "ask", top: 120, left: 120 }
|
|
7280
|
+
),
|
|
6656
7281
|
children: "Ask AI"
|
|
6657
7282
|
}
|
|
6658
7283
|
)
|
|
6659
7284
|
] }),
|
|
6660
|
-
/* @__PURE__ */ (0,
|
|
7285
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6661
7286
|
"button",
|
|
6662
7287
|
{
|
|
6663
7288
|
type: "button",
|
|
@@ -6668,49 +7293,37 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6668
7293
|
}
|
|
6669
7294
|
)
|
|
6670
7295
|
] }),
|
|
6671
|
-
|
|
6672
|
-
|
|
7296
|
+
editorMode === "simple" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7297
|
+
ClassicToolbar,
|
|
6673
7298
|
{
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
"input",
|
|
6682
|
-
{
|
|
6683
|
-
type: "text",
|
|
6684
|
-
className: "cdx-input editor-form-input",
|
|
6685
|
-
placeholder: "Ask AI to draft, summarize, or expand...",
|
|
6686
|
-
value: askPrompt,
|
|
6687
|
-
onChange: (e) => setAskPrompt(e.target.value)
|
|
6688
|
-
}
|
|
6689
|
-
),
|
|
6690
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "submit", className: "editor-form-submit", disabled: aiBusy, children: aiBusy ? "Running\u2026" : "Generate" })
|
|
6691
|
-
]
|
|
7299
|
+
editorRef,
|
|
7300
|
+
onUndo: () => undoRef.current?.undo?.(),
|
|
7301
|
+
onRedo: () => undoRef.current?.redo?.(),
|
|
7302
|
+
fontFamily: simpleFont,
|
|
7303
|
+
onChangeFontFamily: setSimpleFont,
|
|
7304
|
+
enabledTools: selectedTools,
|
|
7305
|
+
onOpenSettings: () => setSettingsOpen(true)
|
|
6692
7306
|
}
|
|
6693
7307
|
),
|
|
6694
|
-
|
|
6695
|
-
/* @__PURE__ */ (0,
|
|
6696
|
-
|
|
6697
|
-
/* @__PURE__ */ (0,
|
|
6698
|
-
/* @__PURE__ */ (0,
|
|
6699
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { children: [
|
|
7308
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { id: "editorjs", ref: holderRef }),
|
|
7309
|
+
statsVisible && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "nextgen-editor-stats", children: [
|
|
7310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: editorMode === "simple" ? "Simple Mode" : "Block Editor" }),
|
|
7311
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u2022" }),
|
|
7312
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
6700
7313
|
stats.blocks,
|
|
6701
7314
|
" blocks"
|
|
6702
7315
|
] }),
|
|
6703
|
-
/* @__PURE__ */ (0,
|
|
7316
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
6704
7317
|
stats.words,
|
|
6705
7318
|
" words"
|
|
6706
7319
|
] }),
|
|
6707
|
-
/* @__PURE__ */ (0,
|
|
7320
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { children: [
|
|
6708
7321
|
"~",
|
|
6709
7322
|
readMins,
|
|
6710
7323
|
" min read"
|
|
6711
7324
|
] })
|
|
6712
7325
|
] }),
|
|
6713
|
-
/* @__PURE__ */ (0,
|
|
7326
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6714
7327
|
SettingsModal,
|
|
6715
7328
|
{
|
|
6716
7329
|
open: settingsOpen,
|
|
@@ -6718,6 +7331,7 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6718
7331
|
mode: editorMode,
|
|
6719
7332
|
showStats: statsVisible,
|
|
6720
7333
|
aiConfig,
|
|
7334
|
+
selectedTools,
|
|
6721
7335
|
onChangeTheme: setTheme,
|
|
6722
7336
|
onChangeMode: (m) => void handleModeSwitch(m),
|
|
6723
7337
|
onChangeShowStats: setStatsVisible,
|
|
@@ -6726,8 +7340,170 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6726
7340
|
saveAiConfig(cfg);
|
|
6727
7341
|
setAiError(null);
|
|
6728
7342
|
},
|
|
7343
|
+
onChangeSelectedTools: (tools) => {
|
|
7344
|
+
setSelectedTools(tools);
|
|
7345
|
+
try {
|
|
7346
|
+
localStorage.setItem("ng-enabled-tools", JSON.stringify(tools));
|
|
7347
|
+
} catch {
|
|
7348
|
+
}
|
|
7349
|
+
},
|
|
6729
7350
|
onClose: () => setSettingsOpen(false)
|
|
6730
7351
|
}
|
|
7352
|
+
),
|
|
7353
|
+
aiPopover && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
7354
|
+
"form",
|
|
7355
|
+
{
|
|
7356
|
+
className: "ng-ai-inline-popover",
|
|
7357
|
+
style: { top: `${aiPopover.top}px`, left: `${aiPopover.left}px` },
|
|
7358
|
+
onSubmit: (e) => {
|
|
7359
|
+
e.preventDefault();
|
|
7360
|
+
if (aiPopover.mode === "continue") {
|
|
7361
|
+
void runAi("continue", askPrompt.trim());
|
|
7362
|
+
} else if (askPrompt.trim()) {
|
|
7363
|
+
void runAi("ask", askPrompt.trim());
|
|
7364
|
+
}
|
|
7365
|
+
},
|
|
7366
|
+
children: [
|
|
7367
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-ai-inline-head", children: [
|
|
7368
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: aiPopover.mode === "continue" ? "\u2726 Continue Writing" : "Ask AI" }),
|
|
7369
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7370
|
+
"button",
|
|
7371
|
+
{
|
|
7372
|
+
type: "button",
|
|
7373
|
+
className: "b2",
|
|
7374
|
+
"aria-label": "Close AI prompt",
|
|
7375
|
+
onClick: () => setAiPopover(null),
|
|
7376
|
+
children: "\xD7"
|
|
7377
|
+
}
|
|
7378
|
+
)
|
|
7379
|
+
] }),
|
|
7380
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-ai-inline-row", children: [
|
|
7381
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7382
|
+
"input",
|
|
7383
|
+
{
|
|
7384
|
+
type: "text",
|
|
7385
|
+
autoFocus: true,
|
|
7386
|
+
className: "cdx-input editor-form-input",
|
|
7387
|
+
placeholder: aiPopover.mode === "continue" ? "How should AI continue? (optional)" : "What do you want AI to write?",
|
|
7388
|
+
value: askPrompt,
|
|
7389
|
+
onChange: (e) => setAskPrompt(e.target.value),
|
|
7390
|
+
onKeyDown: (e) => {
|
|
7391
|
+
if (e.key === "Escape") setAiPopover(null);
|
|
7392
|
+
}
|
|
7393
|
+
}
|
|
7394
|
+
),
|
|
7395
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7396
|
+
"button",
|
|
7397
|
+
{
|
|
7398
|
+
type: "submit",
|
|
7399
|
+
className: "editor-form-submit",
|
|
7400
|
+
disabled: aiBusy || aiPopover.mode === "ask" && !askPrompt.trim(),
|
|
7401
|
+
children: aiBusy ? "Running\u2026" : aiPopover.mode === "continue" ? "Continue" : "Generate"
|
|
7402
|
+
}
|
|
7403
|
+
)
|
|
7404
|
+
] }),
|
|
7405
|
+
aiError && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ng-ai-error", children: aiError })
|
|
7406
|
+
]
|
|
7407
|
+
}
|
|
7408
|
+
),
|
|
7409
|
+
scratchOpen && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
7410
|
+
"div",
|
|
7411
|
+
{
|
|
7412
|
+
className: "ng-scratch-sticky",
|
|
7413
|
+
role: "dialog",
|
|
7414
|
+
"aria-label": "Scratchpad sticky note",
|
|
7415
|
+
style: {
|
|
7416
|
+
transform: `translate(${scratchOffset.x}px, ${scratchOffset.y}px)`
|
|
7417
|
+
},
|
|
7418
|
+
children: [
|
|
7419
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
7420
|
+
"div",
|
|
7421
|
+
{
|
|
7422
|
+
className: "ng-scratch-sticky-head",
|
|
7423
|
+
onMouseDown: (e) => {
|
|
7424
|
+
if (e.target.closest("button")) return;
|
|
7425
|
+
const startX = e.clientX - scratchOffset.x;
|
|
7426
|
+
const startY = e.clientY - scratchOffset.y;
|
|
7427
|
+
const onMove = (ev) => {
|
|
7428
|
+
setScratchOffset({ x: ev.clientX - startX, y: ev.clientY - startY });
|
|
7429
|
+
};
|
|
7430
|
+
const onUp = () => {
|
|
7431
|
+
window.removeEventListener("mousemove", onMove);
|
|
7432
|
+
window.removeEventListener("mouseup", onUp);
|
|
7433
|
+
};
|
|
7434
|
+
window.addEventListener("mousemove", onMove);
|
|
7435
|
+
window.addEventListener("mouseup", onUp);
|
|
7436
|
+
},
|
|
7437
|
+
children: [
|
|
7438
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "ng-scratch-sticky-title", children: "\u{1F4DD} Scratchpad" }),
|
|
7439
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "ng-scratch-sticky-count", children: [
|
|
7440
|
+
scratchText.trim() ? scratchText.trim().split(/\s+/).length : 0,
|
|
7441
|
+
"w \xB7 ",
|
|
7442
|
+
scratchText.length,
|
|
7443
|
+
"c"
|
|
7444
|
+
] }),
|
|
7445
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "ng-scratch-sticky-actions", children: [
|
|
7446
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7447
|
+
"button",
|
|
7448
|
+
{
|
|
7449
|
+
type: "button",
|
|
7450
|
+
className: "ng-scratch-sticky-btn",
|
|
7451
|
+
onClick: () => {
|
|
7452
|
+
if (!scratchText) return;
|
|
7453
|
+
void navigator.clipboard?.writeText(scratchText);
|
|
7454
|
+
setScratchCopied(true);
|
|
7455
|
+
window.setTimeout(() => setScratchCopied(false), 1200);
|
|
7456
|
+
},
|
|
7457
|
+
children: scratchCopied ? "Copied" : "Copy"
|
|
7458
|
+
}
|
|
7459
|
+
),
|
|
7460
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7461
|
+
"button",
|
|
7462
|
+
{
|
|
7463
|
+
type: "button",
|
|
7464
|
+
className: "ng-scratch-sticky-btn",
|
|
7465
|
+
onClick: () => {
|
|
7466
|
+
setScratchText("");
|
|
7467
|
+
try {
|
|
7468
|
+
localStorage.setItem("ng-scratchpad-note", "");
|
|
7469
|
+
} catch {
|
|
7470
|
+
}
|
|
7471
|
+
},
|
|
7472
|
+
children: "Clear"
|
|
7473
|
+
}
|
|
7474
|
+
),
|
|
7475
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7476
|
+
"button",
|
|
7477
|
+
{
|
|
7478
|
+
type: "button",
|
|
7479
|
+
className: "ng-scratch-sticky-btn",
|
|
7480
|
+
"aria-label": "Close scratchpad",
|
|
7481
|
+
onClick: () => setScratchOpen(false),
|
|
7482
|
+
children: "\xD7"
|
|
7483
|
+
}
|
|
7484
|
+
)
|
|
7485
|
+
] })
|
|
7486
|
+
]
|
|
7487
|
+
}
|
|
7488
|
+
),
|
|
7489
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
7490
|
+
"textarea",
|
|
7491
|
+
{
|
|
7492
|
+
className: "ng-scratch-sticky-body",
|
|
7493
|
+
placeholder: "Quick sticky note, rough ideas, snippets...",
|
|
7494
|
+
value: scratchText,
|
|
7495
|
+
onChange: (e) => {
|
|
7496
|
+
const val = e.target.value;
|
|
7497
|
+
setScratchText(val);
|
|
7498
|
+
try {
|
|
7499
|
+
localStorage.setItem("ng-scratchpad-note", val);
|
|
7500
|
+
} catch {
|
|
7501
|
+
}
|
|
7502
|
+
}
|
|
7503
|
+
}
|
|
7504
|
+
)
|
|
7505
|
+
]
|
|
7506
|
+
}
|
|
6731
7507
|
)
|
|
6732
7508
|
]
|
|
6733
7509
|
}
|
|
@@ -6737,13 +7513,13 @@ var BlockEditor = import_react3.default.forwardRef(
|
|
|
6737
7513
|
BlockEditor.displayName = "BlockEditor";
|
|
6738
7514
|
|
|
6739
7515
|
// src/components/BlockRenderer.tsx
|
|
6740
|
-
var
|
|
7516
|
+
var import_react6 = require("react");
|
|
6741
7517
|
|
|
6742
7518
|
// src/hooks/useInteractiveArticle.ts
|
|
6743
7519
|
var import_auto2 = __toESM(require("chart.js/auto"), 1);
|
|
6744
|
-
var
|
|
7520
|
+
var import_react5 = require("react");
|
|
6745
7521
|
function useInteractiveArticle(containerRef, depKey) {
|
|
6746
|
-
(0,
|
|
7522
|
+
(0, import_react5.useEffect)(() => {
|
|
6747
7523
|
const root = containerRef.current;
|
|
6748
7524
|
if (!root) return;
|
|
6749
7525
|
const cleanups = [];
|
|
@@ -7433,18 +8209,31 @@ function useInteractiveArticle(containerRef, depKey) {
|
|
|
7433
8209
|
}
|
|
7434
8210
|
|
|
7435
8211
|
// src/components/BlockRenderer.tsx
|
|
7436
|
-
var
|
|
8212
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
7437
8213
|
var BlockRenderer = ({
|
|
7438
8214
|
data,
|
|
8215
|
+
theme,
|
|
7439
8216
|
className
|
|
7440
8217
|
}) => {
|
|
7441
|
-
const bodyRef = (0,
|
|
7442
|
-
const html = (0,
|
|
8218
|
+
const bodyRef = (0, import_react6.useRef)(null);
|
|
8219
|
+
const html = (0, import_react6.useMemo)(() => blocksToHtml(data), [data]);
|
|
7443
8220
|
useInteractiveArticle(bodyRef, html);
|
|
7444
|
-
|
|
8221
|
+
let resolvedTheme = theme;
|
|
8222
|
+
if (!resolvedTheme && typeof window !== "undefined") {
|
|
8223
|
+
resolvedTheme = document.documentElement.getAttribute("data-ng-theme") || (() => {
|
|
8224
|
+
try {
|
|
8225
|
+
return localStorage.getItem("ng-editor-theme") || void 0;
|
|
8226
|
+
} catch {
|
|
8227
|
+
return void 0;
|
|
8228
|
+
}
|
|
8229
|
+
})();
|
|
8230
|
+
}
|
|
8231
|
+
const attrTheme = resolvedTheme && resolvedTheme !== "inherit" ? resolvedTheme : void 0;
|
|
8232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
7445
8233
|
"div",
|
|
7446
8234
|
{
|
|
7447
8235
|
ref: bodyRef,
|
|
8236
|
+
"data-ng-theme": attrTheme,
|
|
7448
8237
|
className: className ? `article nextgen-editor-article ${className}` : "article nextgen-editor-article",
|
|
7449
8238
|
dangerouslySetInnerHTML: { __html: html }
|
|
7450
8239
|
}
|
|
@@ -7452,7 +8241,7 @@ var BlockRenderer = ({
|
|
|
7452
8241
|
};
|
|
7453
8242
|
|
|
7454
8243
|
// src/components/DocumentHeader.tsx
|
|
7455
|
-
var
|
|
8244
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
7456
8245
|
var DocumentHeader = ({
|
|
7457
8246
|
coverUrl,
|
|
7458
8247
|
gradient = "linear-gradient(135deg, #27272a 0%, #52525b 100%)",
|
|
@@ -7462,12 +8251,12 @@ var DocumentHeader = ({
|
|
|
7462
8251
|
className
|
|
7463
8252
|
}) => {
|
|
7464
8253
|
const bannerStyle = coverUrl ? { backgroundImage: `url("${coverUrl}")`, backgroundSize: "cover", backgroundPosition: "center" } : { background: gradient };
|
|
7465
|
-
return /* @__PURE__ */ (0,
|
|
7466
|
-
/* @__PURE__ */ (0,
|
|
7467
|
-
icon ? /* @__PURE__ */ (0,
|
|
7468
|
-
/* @__PURE__ */ (0,
|
|
7469
|
-
/* @__PURE__ */ (0,
|
|
7470
|
-
subtitle ? /* @__PURE__ */ (0,
|
|
8254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("header", { className: className ? `editor-cover-card ${className}` : "editor-cover-card", children: [
|
|
8255
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "editor-cover-banner", style: bannerStyle }),
|
|
8256
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "editor-cover-icon", children: icon }) : null,
|
|
8257
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "editor-cover-meta", children: [
|
|
8258
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", { className: "editor-cover-title", children: title }),
|
|
8259
|
+
subtitle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "editor-cover-subtitle", children: subtitle }) : null
|
|
7471
8260
|
] })
|
|
7472
8261
|
] });
|
|
7473
8262
|
};
|