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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/components/BlockEditor.tsx
2
- import React3, { useEffect, useImperativeHandle, useRef, useState as useState2 } from "react";
2
+ import React4, { useEffect as useEffect2, useImperativeHandle, useRef as useRef2, useState as useState3 } from "react";
3
3
  import EditorJS2 from "@editorjs/editorjs";
4
4
  import DragDrop from "editorjs-drag-drop";
5
5
  import Undo from "editorjs-undo";
@@ -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";
@@ -247,7 +246,7 @@ function sanitizeInlineHtml(value) {
247
246
  }
248
247
  const template = document.createElement("template");
249
248
  template.innerHTML = String(value == null ? "" : value);
250
- const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM"];
249
+ const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM", "SUP", "SUB"];
251
250
  template.content.querySelectorAll("*").forEach((element) => {
252
251
  if (!allowed.includes(element.tagName)) {
253
252
  element.replaceWith(document.createTextNode(element.textContent || ""));
@@ -1589,6 +1588,144 @@ import { createRoot } from "react-dom/client";
1589
1588
  import { Excalidraw, exportToCanvas } from "@excalidraw/excalidraw";
1590
1589
  import Chart from "chart.js/auto";
1591
1590
  import katex2 from "katex";
1591
+
1592
+ // src/utils/emojiSidePicker.ts
1593
+ var activeMenuCleanup = null;
1594
+ function openEmojiSideMenu({
1595
+ anchorRect,
1596
+ onSelect,
1597
+ onClose
1598
+ }) {
1599
+ if (activeMenuCleanup) {
1600
+ activeMenuCleanup();
1601
+ activeMenuCleanup = null;
1602
+ }
1603
+ const popover = document.createElement("div");
1604
+ popover.className = "editor-emoji-side-popover";
1605
+ popover.setAttribute("role", "dialog");
1606
+ popover.setAttribute("aria-label", "Emoji picker");
1607
+ const menuW = 264;
1608
+ const menuH = 290;
1609
+ const gap = 8;
1610
+ const fitsRight = anchorRect.right + gap + menuW <= window.innerWidth - 8;
1611
+ const left = fitsRight ? anchorRect.right + gap : Math.max(8, anchorRect.left - menuW - gap);
1612
+ const top = Math.max(
1613
+ 8,
1614
+ Math.min(anchorRect.top, window.innerHeight - menuH - 8)
1615
+ );
1616
+ popover.style.left = `${left}px`;
1617
+ popover.style.top = `${top}px`;
1618
+ const searchIn = document.createElement("input");
1619
+ searchIn.type = "search";
1620
+ searchIn.className = "cdx-input editor-form-input";
1621
+ searchIn.placeholder = "Search emoji (fire, rocket...)";
1622
+ const grid = document.createElement("div");
1623
+ grid.className = "editor-emoji-grid";
1624
+ const close = () => {
1625
+ document.removeEventListener("mousedown", onOutside, true);
1626
+ document.removeEventListener("keydown", onKey, true);
1627
+ popover.remove();
1628
+ activeMenuCleanup = null;
1629
+ onClose?.();
1630
+ };
1631
+ const renderGrid = (query = "") => {
1632
+ grid.innerHTML = "";
1633
+ const q = query.trim().toLowerCase();
1634
+ const filtered = q ? EMOJI_PRESETS.filter((p) => p.name.includes(q) || p.em.includes(q)) : EMOJI_PRESETS;
1635
+ filtered.forEach(({ em, name }) => {
1636
+ const btn = document.createElement("button");
1637
+ btn.type = "button";
1638
+ btn.title = name;
1639
+ btn.className = "editor-emoji-btn";
1640
+ btn.textContent = em;
1641
+ btn.addEventListener("mousedown", (e) => e.preventDefault());
1642
+ btn.addEventListener("click", () => {
1643
+ const cb = onSelect;
1644
+ close();
1645
+ cb(em);
1646
+ });
1647
+ grid.appendChild(btn);
1648
+ });
1649
+ };
1650
+ const onOutside = (e) => {
1651
+ if (!popover.contains(e.target)) {
1652
+ close();
1653
+ }
1654
+ };
1655
+ const onKey = (e) => {
1656
+ if (e.key === "Escape") {
1657
+ e.preventDefault();
1658
+ e.stopPropagation();
1659
+ close();
1660
+ }
1661
+ };
1662
+ searchIn.addEventListener("input", () => renderGrid(searchIn.value));
1663
+ renderGrid();
1664
+ popover.append(searchIn, grid);
1665
+ document.body.appendChild(popover);
1666
+ document.addEventListener("mousedown", onOutside, true);
1667
+ document.addEventListener("keydown", onKey, true);
1668
+ queueMicrotask(() => searchIn.focus());
1669
+ activeMenuCleanup = close;
1670
+ return close;
1671
+ }
1672
+ function attachEmojiSidePicker(container) {
1673
+ const onInput = (e) => {
1674
+ const target = e.target;
1675
+ if (!target || !target.isContentEditable) return;
1676
+ const sel = window.getSelection();
1677
+ if (!sel || sel.rangeCount === 0) return;
1678
+ const range = sel.getRangeAt(0);
1679
+ if (range.startContainer.nodeType !== Node.TEXT_NODE || !range.collapsed) {
1680
+ return;
1681
+ }
1682
+ const textNode = range.startContainer;
1683
+ const offset = range.startOffset;
1684
+ const before = textNode.data.slice(0, offset);
1685
+ if (!/(^|\s)\/emoji$/i.test(before)) return;
1686
+ const triggerStart = offset - "/emoji".length;
1687
+ const triggerRange = document.createRange();
1688
+ triggerRange.setStart(textNode, triggerStart);
1689
+ triggerRange.setEnd(textNode, offset);
1690
+ const rawRect = triggerRange.getBoundingClientRect();
1691
+ const rect = rawRect.width > 0 || rawRect.height > 0 ? rawRect : target.getBoundingClientRect();
1692
+ openEmojiSideMenu({
1693
+ anchorRect: rect,
1694
+ onSelect: (emoji) => {
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);
1709
+ }
1710
+ target.focus();
1711
+ target.dispatchEvent(new Event("input", { bubbles: true }));
1712
+ },
1713
+ onClose: () => {
1714
+ target.focus();
1715
+ }
1716
+ });
1717
+ };
1718
+ container.addEventListener("input", onInput);
1719
+ return () => {
1720
+ container.removeEventListener("input", onInput);
1721
+ if (activeMenuCleanup) {
1722
+ activeMenuCleanup();
1723
+ activeMenuCleanup = null;
1724
+ }
1725
+ };
1726
+ }
1727
+
1728
+ // src/blocks/richBlocks.ts
1592
1729
  var LatexTool = class {
1593
1730
  data;
1594
1731
  wrapper = null;
@@ -3520,34 +3657,64 @@ var FlashcardTool = class {
3520
3657
  };
3521
3658
  }
3522
3659
  };
3523
- var SettingsTriggerTool = class {
3524
- api;
3525
- static get toolbox() {
3526
- return {
3527
- title: "Settings",
3528
- icon: '<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>'
3529
- };
3530
- }
3531
- constructor({ api }) {
3532
- this.api = api;
3533
- }
3534
- render() {
3535
- const el = document.createElement("div");
3536
- el.style.display = "none";
3537
- queueMicrotask(() => {
3538
- el.dispatchEvent(new CustomEvent("nextgen-open-settings", { bubbles: true }));
3539
- try {
3540
- const idx = this.api.blocks.getCurrentBlockIndex();
3541
- if (idx >= 0) this.api.blocks.delete(idx);
3542
- } catch {
3543
- }
3544
- });
3545
- return el;
3546
- }
3547
- save() {
3548
- return {};
3549
- }
3550
- };
3660
+ function createActionTriggerTool(title, icon, eventName) {
3661
+ return class {
3662
+ api;
3663
+ el = null;
3664
+ fired = false;
3665
+ static get toolbox() {
3666
+ return { title, icon };
3667
+ }
3668
+ constructor({ api }) {
3669
+ this.api = api;
3670
+ }
3671
+ render() {
3672
+ const el = document.createElement("div");
3673
+ el.style.height = "1px";
3674
+ el.style.opacity = "0";
3675
+ el.style.pointerEvents = "none";
3676
+ this.el = el;
3677
+ return el;
3678
+ }
3679
+ rendered() {
3680
+ if (this.fired || !this.el) return;
3681
+ this.fired = true;
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
+ );
3690
+ window.setTimeout(() => {
3691
+ try {
3692
+ const idx = this.api.blocks.getCurrentBlockIndex();
3693
+ if (idx >= 0) this.api.blocks.delete(idx);
3694
+ } catch {
3695
+ }
3696
+ }, 0);
3697
+ }
3698
+ save() {
3699
+ return {};
3700
+ }
3701
+ };
3702
+ }
3703
+ var SettingsTriggerTool = createActionTriggerTool(
3704
+ "Settings",
3705
+ '<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>',
3706
+ "nextgen-open-settings"
3707
+ );
3708
+ var ContinueWritingTool = createActionTriggerTool(
3709
+ "Continue Writing",
3710
+ '<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>',
3711
+ "nextgen-ai-continue"
3712
+ );
3713
+ var AskAiTool = createActionTriggerTool(
3714
+ "Ask AI",
3715
+ '<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>',
3716
+ "nextgen-ai-ask"
3717
+ );
3551
3718
  var UploadTool = class {
3552
3719
  data;
3553
3720
  statusEl = null;
@@ -3889,94 +4056,71 @@ var EMOJI_PRESETS = [
3889
4056
  ];
3890
4057
  var EmojiTool = class {
3891
4058
  data;
4059
+ api;
4060
+ isNewInsert;
4061
+ anchorEl = null;
3892
4062
  static get toolbox() {
3893
4063
  return {
3894
4064
  title: "Emoji",
3895
4065
  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>'
3896
4066
  };
3897
4067
  }
3898
- constructor({ data }) {
4068
+ constructor({
4069
+ data,
4070
+ api
4071
+ }) {
4072
+ this.isNewInsert = !data?.emoji;
4073
+ this.api = api;
3899
4074
  this.data = {
3900
4075
  emoji: data?.emoji ?? "\u2728",
3901
4076
  label: data?.label ?? "",
3902
4077
  size: data?.size || "md"
3903
4078
  };
3904
4079
  }
4080
+ openPickerAtAnchor() {
4081
+ if (!this.anchorEl) return;
4082
+ const rect = this.anchorEl.getBoundingClientRect();
4083
+ openEmojiSideMenu({
4084
+ anchorRect: rect,
4085
+ onSelect: (em) => {
4086
+ if (this.isNewInsert && this.api?.blocks) {
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
+ }
4098
+ return;
4099
+ }
4100
+ this.data.emoji = em;
4101
+ if (this.anchorEl) {
4102
+ this.anchorEl.textContent = `${em} Pick emoji`;
4103
+ }
4104
+ }
4105
+ });
4106
+ }
3905
4107
  render() {
3906
4108
  const wrap = document.createElement("div");
3907
- wrap.className = "editor-emoji-split";
3908
- const leftPane = document.createElement("div");
3909
- leftPane.className = "editor-emoji-left";
3910
- const previewGlyph = document.createElement("div");
3911
- previewGlyph.className = `editor-emoji-hero is-${this.data.size}`;
3912
- previewGlyph.textContent = this.data.emoji;
3913
- const emojiIn = document.createElement("input");
3914
- emojiIn.type = "text";
3915
- emojiIn.className = "cdx-input editor-callout-icon-in";
3916
- emojiIn.value = this.data.emoji;
3917
- emojiIn.placeholder = "\u2728";
3918
- emojiIn.addEventListener("input", () => {
3919
- this.data.emoji = emojiIn.value || "\u2728";
3920
- previewGlyph.textContent = this.data.emoji;
3921
- });
3922
- const sizeSel = document.createElement("select");
3923
- sizeSel.className = "cdx-input editor-form-select";
3924
- ["sm", "md", "lg"].forEach((s) => {
3925
- const o = document.createElement("option");
3926
- o.value = s;
3927
- o.textContent = s.toUpperCase();
3928
- if (this.data.size === s) o.selected = true;
3929
- sizeSel.appendChild(o);
3930
- });
3931
- sizeSel.addEventListener("change", () => {
3932
- this.data.size = sizeSel.value;
3933
- previewGlyph.className = `editor-emoji-hero is-${this.data.size}`;
3934
- });
3935
- const row = document.createElement("div");
3936
- row.className = "editor-emoji-controls";
3937
- row.append(emojiIn, sizeSel);
3938
- const labelIn = document.createElement("input");
3939
- labelIn.type = "text";
3940
- labelIn.className = "cdx-input editor-form-input";
3941
- labelIn.placeholder = "Caption or reaction note...";
3942
- labelIn.value = this.data.label || "";
3943
- labelIn.addEventListener("input", () => {
3944
- this.data.label = labelIn.value;
3945
- });
3946
- leftPane.append(previewGlyph, row, labelIn);
3947
- const rightPane = document.createElement("div");
3948
- rightPane.className = "editor-emoji-picker-pane";
3949
- const searchIn = document.createElement("input");
3950
- searchIn.type = "search";
3951
- searchIn.className = "cdx-input editor-form-input";
3952
- searchIn.placeholder = "Search emojis (fire, rocket, heart...)";
3953
- const grid = document.createElement("div");
3954
- grid.className = "editor-emoji-grid";
3955
- const renderGrid = (query = "") => {
3956
- grid.innerHTML = "";
3957
- const q = query.trim().toLowerCase();
3958
- const filtered = q ? EMOJI_PRESETS.filter((p) => p.name.includes(q) || p.em.includes(q)) : EMOJI_PRESETS;
3959
- filtered.forEach(({ em, name }) => {
3960
- const btn = document.createElement("button");
3961
- btn.type = "button";
3962
- btn.title = name;
3963
- btn.className = `editor-emoji-btn${em === this.data.emoji ? " is-active" : ""}`;
3964
- btn.textContent = em;
3965
- btn.addEventListener("click", () => {
3966
- this.data.emoji = em;
3967
- emojiIn.value = em;
3968
- previewGlyph.textContent = em;
3969
- renderGrid(searchIn.value);
3970
- });
3971
- grid.appendChild(btn);
3972
- });
3973
- };
3974
- searchIn.addEventListener("input", () => renderGrid(searchIn.value));
3975
- renderGrid();
3976
- rightPane.append(searchIn, grid);
3977
- wrap.append(leftPane, rightPane);
4109
+ wrap.className = "editor-emoji-inline-wrap";
4110
+ const btn = document.createElement("button");
4111
+ btn.type = "button";
4112
+ btn.className = "b2 editor-emoji-inline-anchor";
4113
+ btn.textContent = `${this.data.emoji} Pick emoji`;
4114
+ btn.addEventListener("click", () => this.openPickerAtAnchor());
4115
+ this.anchorEl = btn;
4116
+ wrap.appendChild(btn);
3978
4117
  return wrap;
3979
4118
  }
4119
+ rendered() {
4120
+ if (this.isNewInsert) {
4121
+ window.requestAnimationFrame(() => this.openPickerAtAnchor());
4122
+ }
4123
+ }
3980
4124
  save() {
3981
4125
  return {
3982
4126
  emoji: this.data.emoji.trim() || "\u2728",
@@ -3985,83 +4129,11 @@ var EmojiTool = class {
3985
4129
  };
3986
4130
  }
3987
4131
  };
3988
- var ScratchTool = class {
3989
- data;
3990
- static get toolbox() {
3991
- return {
3992
- title: "Scratchpad",
3993
- 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>'
3994
- };
3995
- }
3996
- constructor({ data }) {
3997
- this.data = {
3998
- title: data?.title ?? "Scratchpad",
3999
- text: data?.text ?? ""
4000
- };
4001
- }
4002
- render() {
4003
- const wrap = document.createElement("div");
4004
- wrap.className = "editor-scratch-tool";
4005
- const head = document.createElement("div");
4006
- head.className = "editor-scratch-head";
4007
- const titleIn = document.createElement("input");
4008
- titleIn.type = "text";
4009
- titleIn.className = "cdx-input editor-scratch-title";
4010
- titleIn.placeholder = "Scratchpad title...";
4011
- titleIn.value = this.data.title ?? "Scratchpad";
4012
- titleIn.addEventListener("input", () => {
4013
- this.data.title = titleIn.value;
4014
- });
4015
- const stats = document.createElement("span");
4016
- stats.className = "editor-scratch-stats";
4017
- const updateStats = () => {
4018
- const len = this.data.text.length;
4019
- const words = this.data.text.trim() ? this.data.text.trim().split(/\s+/).length : 0;
4020
- stats.textContent = `${words}w \xB7 ${len}c`;
4021
- };
4022
- const copyBtn = document.createElement("button");
4023
- copyBtn.type = "button";
4024
- copyBtn.className = "b2";
4025
- copyBtn.textContent = "Copy";
4026
- copyBtn.addEventListener("click", () => {
4027
- if (!this.data.text) return;
4028
- void navigator.clipboard?.writeText(this.data.text);
4029
- copyBtn.textContent = "Copied";
4030
- window.setTimeout(() => {
4031
- copyBtn.textContent = "Copy";
4032
- }, 1200);
4033
- });
4034
- const clearBtn = document.createElement("button");
4035
- clearBtn.type = "button";
4036
- clearBtn.className = "b2";
4037
- clearBtn.textContent = "Clear";
4038
- head.append(titleIn, stats, copyBtn, clearBtn);
4039
- const textarea = document.createElement("textarea");
4040
- textarea.className = "cdx-input editor-scratch-textarea";
4041
- textarea.rows = 4;
4042
- textarea.placeholder = "Quick brain dump, rough notes, snippets...";
4043
- textarea.value = this.data.text || "";
4044
- textarea.addEventListener("input", () => {
4045
- this.data.text = textarea.value;
4046
- updateStats();
4047
- });
4048
- clearBtn.addEventListener("click", () => {
4049
- this.data.text = "";
4050
- textarea.value = "";
4051
- updateStats();
4052
- textarea.focus();
4053
- });
4054
- updateStats();
4055
- wrap.append(head, textarea);
4056
- return wrap;
4057
- }
4058
- save() {
4059
- return {
4060
- title: this.data.title?.trim() || "Scratchpad",
4061
- text: this.data.text
4062
- };
4063
- }
4064
- };
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
+ );
4065
4137
  var DialogueTool = class {
4066
4138
  data;
4067
4139
  static get toolbox() {
@@ -5853,7 +5925,6 @@ function getEditorTools(includeLayout = true, enabledTools) {
5853
5925
  }
5854
5926
  },
5855
5927
  delimiter: DelimiterTool,
5856
- checklist: Checklist,
5857
5928
  table: Table,
5858
5929
  callout: CalloutTool,
5859
5930
  hotkey: HotkeyTool,
@@ -5908,6 +5979,8 @@ function getEditorTools(includeLayout = true, enabledTools) {
5908
5979
  nestedlist: NestedList,
5909
5980
  simpleImage: SimpleImage,
5910
5981
  comment: CommentTool,
5982
+ continueWriting: ContinueWritingTool,
5983
+ askAi: AskAiTool,
5911
5984
  settings: SettingsTriggerTool,
5912
5985
  // Inline toolbar tools
5913
5986
  inlineCode: InlineCode,
@@ -6079,6 +6152,10 @@ ${userContent}` }] }]
6079
6152
 
6080
6153
  // src/utils/popoverCategories.ts
6081
6154
  var TOOL_CATEGORIES = [
6155
+ {
6156
+ label: "AI",
6157
+ tools: ["continueWriting", "askAi"]
6158
+ },
6082
6159
  {
6083
6160
  label: "Text & Style",
6084
6161
  tools: [
@@ -6088,7 +6165,6 @@ var TOOL_CATEGORIES = [
6088
6165
  "paragraph",
6089
6166
  "list",
6090
6167
  "nestedlist",
6091
- "checklist",
6092
6168
  "quote",
6093
6169
  "pullquote",
6094
6170
  "delimiter",
@@ -6176,8 +6252,79 @@ var SIMPLE_MODE_TOOLS = [
6176
6252
  "code",
6177
6253
  "image",
6178
6254
  "delimiter",
6255
+ "continueWriting",
6256
+ "askAi",
6179
6257
  "settings"
6180
6258
  ];
6259
+ var ALL_TOOL_NAMES = Array.from(
6260
+ new Set(TOOL_CATEGORIES.flatMap((g) => g.tools))
6261
+ );
6262
+ var TOOL_LABELS = {
6263
+ h1: "Heading 1",
6264
+ h2: "Heading 2",
6265
+ h3: "Heading 3",
6266
+ paragraph: "Paragraph",
6267
+ list: "List (Ordered / Unordered / Checklist)",
6268
+ nestedlist: "Nested List",
6269
+ quote: "Quote",
6270
+ pullquote: "Pull Quote",
6271
+ delimiter: "Delimiter",
6272
+ callout: "Callout",
6273
+ hotkey: "Hotkey",
6274
+ emoji: "Emoji",
6275
+ scratch: "Scratchpad",
6276
+ alert: "Alert",
6277
+ badges: "Badges",
6278
+ tags: "Tags",
6279
+ cover: "Page Cover",
6280
+ toc: "Table of Contents",
6281
+ bento: "Bento Grid",
6282
+ layout: "Multi-Column Layout",
6283
+ tabs: "Tabs",
6284
+ accordion: "Accordion",
6285
+ toggleh1: "Toggle H1",
6286
+ toggleh2: "Toggle H2",
6287
+ toggleh3: "Toggle H3",
6288
+ collapsible: "Collapsible",
6289
+ spoiler: "Spoiler",
6290
+ cards: "Cards",
6291
+ timeline: "Timeline",
6292
+ proscons: "Pros & Cons",
6293
+ upload: "Upload",
6294
+ image: "Image",
6295
+ simpleImage: "Simple Image",
6296
+ gif: "GIF",
6297
+ gallery: "Lightbox Gallery",
6298
+ masonry: "Masonry Grid",
6299
+ carousel: "Carousel",
6300
+ compare: "Before / After",
6301
+ audio: "Audio Player",
6302
+ musicCarousel: "Music Carousel",
6303
+ embed: "Embed",
6304
+ attaches: "Attachment",
6305
+ excalidraw: "Excalidraw",
6306
+ code: "Code Block",
6307
+ latex: "LaTeX Math",
6308
+ chart: "Data Chart",
6309
+ table: "Table",
6310
+ stats: "Stats",
6311
+ form: "Form Builder",
6312
+ poll: "Poll",
6313
+ quiz: "Quiz",
6314
+ flashcards: "Flashcards",
6315
+ todo: "To-Do List",
6316
+ eisenhower: "Eisenhower Matrix",
6317
+ kanban: "Kanban Board",
6318
+ timer: "Focus Timer",
6319
+ faq: "FAQ",
6320
+ footnotes: "Footnotes",
6321
+ button: "Button",
6322
+ dialogue: "Dialogue Box",
6323
+ slides: "Slides",
6324
+ continueWriting: "Continue Writing",
6325
+ askAi: "Ask AI",
6326
+ settings: "Settings"
6327
+ };
6181
6328
  function attachPopoverCategoryHeaders(container) {
6182
6329
  const applyCategories = () => {
6183
6330
  const popovers = container.querySelectorAll(".ce-popover__items");
@@ -6203,18 +6350,25 @@ function attachPopoverCategoryHeaders(container) {
6203
6350
  titleEl.textContent = "Paragraph";
6204
6351
  }
6205
6352
  }
6206
- if (name) byName.set(name, el);
6207
- else uncategorized.push(el);
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
+ }
6208
6360
  });
6209
6361
  const frag = document.createDocumentFragment();
6210
6362
  const placed = /* @__PURE__ */ new Set();
6211
6363
  for (const group of TOOL_CATEGORIES) {
6212
6364
  const matched = [];
6213
6365
  for (const toolName of group.tools) {
6214
- const el = byName.get(toolName);
6215
- if (el && !placed.has(el)) {
6216
- matched.push(el);
6217
- placed.add(el);
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
+ }
6218
6372
  }
6219
6373
  }
6220
6374
  if (matched.length > 0) {
@@ -6243,23 +6397,313 @@ function attachPopoverCategoryHeaders(container) {
6243
6397
  return () => observer.disconnect();
6244
6398
  }
6245
6399
 
6246
- // src/components/SettingsModal.tsx
6247
- import { useState } from "react";
6400
+ // src/components/ClassicToolbar.tsx
6401
+ import { useEffect, useRef, useState } from "react";
6248
6402
  import { jsx, jsxs } from "react/jsx-runtime";
6403
+ var INSERT_ITEMS = [
6404
+ { tool: "bento", label: "Bento Grid", category: "Layout" },
6405
+ { tool: "masonry", label: "Masonry Grid", category: "Media" },
6406
+ { tool: "excalidraw", label: "Excalidraw", category: "Media" },
6407
+ { tool: "chart", label: "Data Chart", category: "Data" },
6408
+ { tool: "callout", label: "Callout", category: "Text" },
6409
+ { tool: "spoiler", label: "Spoiler", category: "Layout" },
6410
+ { tool: "dialogue", label: "Dialogue Box", category: "Interactive" },
6411
+ { tool: "scratch", label: "Scratchpad", category: "Text" },
6412
+ { tool: "hotkey", label: "Hotkey", category: "Text" },
6413
+ { tool: "image", label: "Image", category: "Media" },
6414
+ { tool: "upload", label: "File Upload", category: "Media" },
6415
+ { tool: "table", label: "Table", category: "Data" },
6416
+ { tool: "latex", label: "LaTeX Math", category: "Data" },
6417
+ { tool: "tabs", label: "Tabs", category: "Layout" },
6418
+ { tool: "accordion", label: "Accordion", category: "Layout" },
6419
+ { tool: "quiz", label: "Quiz", category: "Interactive" },
6420
+ { tool: "poll", label: "Poll", category: "Interactive" },
6421
+ { tool: "kanban", label: "Kanban Board", category: "Interactive" },
6422
+ { tool: "delimiter", label: "Delimiter", category: "Text" },
6423
+ { tool: "settings", label: "Settings", category: "System" }
6424
+ ];
6425
+ var ClassicToolbar = ({
6426
+ editorRef,
6427
+ onUndo,
6428
+ onRedo,
6429
+ fontFamily,
6430
+ onChangeFontFamily,
6431
+ enabledTools,
6432
+ onOpenSettings
6433
+ }) => {
6434
+ const allowedTools = enabledTools ? new Set(enabledTools) : null;
6435
+ const visibleInsertItems = allowedTools ? INSERT_ITEMS.filter((item) => item.tool === "settings" || allowedTools.has(item.tool)) : INSERT_ITEMS;
6436
+ const [insertOpen, setInsertOpen] = useState(false);
6437
+ const [alignOpen, setAlignOpen] = useState(false);
6438
+ const [blockType, setBlockType] = useState("paragraph");
6439
+ const wrapRef = useRef(null);
6440
+ useEffect(() => {
6441
+ const onOutside = (e) => {
6442
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) {
6443
+ setInsertOpen(false);
6444
+ setAlignOpen(false);
6445
+ }
6446
+ };
6447
+ document.addEventListener("mousedown", onOutside);
6448
+ return () => document.removeEventListener("mousedown", onOutside);
6449
+ }, []);
6450
+ const keepSelection = (e) => {
6451
+ e.preventDefault();
6452
+ };
6453
+ const exec = (cmd, value) => {
6454
+ document.execCommand(cmd, false, value);
6455
+ };
6456
+ const toggleInlineTag = (tagName) => {
6457
+ const sel = window.getSelection();
6458
+ if (!sel || sel.rangeCount === 0) return;
6459
+ const range = sel.getRangeAt(0);
6460
+ if (range.collapsed) return;
6461
+ const existing = (range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? range.commonAncestorContainer : range.commonAncestorContainer.parentElement)?.closest(tagName);
6462
+ if (existing && existing.parentNode) {
6463
+ const parent = existing.parentNode;
6464
+ while (existing.firstChild) {
6465
+ parent.insertBefore(existing.firstChild, existing);
6466
+ }
6467
+ parent.removeChild(existing);
6468
+ return;
6469
+ }
6470
+ const el = document.createElement(tagName);
6471
+ el.appendChild(range.extractContents());
6472
+ range.insertNode(el);
6473
+ };
6474
+ const insertBlock = (tool, data = {}) => {
6475
+ const ed = editorRef.current;
6476
+ if (!ed) return;
6477
+ if (tool === "settings") {
6478
+ onOpenSettings();
6479
+ setInsertOpen(false);
6480
+ return;
6481
+ }
6482
+ try {
6483
+ const idx = ed.blocks.getCurrentBlockIndex();
6484
+ const targetIdx = idx >= 0 ? idx + 1 : ed.blocks.getBlocksCount();
6485
+ ed.blocks.insert(tool, data, {}, targetIdx, true);
6486
+ } catch {
6487
+ ed.blocks.insert(tool, data);
6488
+ }
6489
+ setInsertOpen(false);
6490
+ };
6491
+ const handleBlockTypeChange = (next) => {
6492
+ setBlockType(next);
6493
+ if (next === "paragraph") insertBlock("paragraph", { text: "" });
6494
+ else if (next === "h1") insertBlock("h1", { text: "", level: 1 });
6495
+ else if (next === "h2") insertBlock("h2", { text: "", level: 2 });
6496
+ else if (next === "h3") insertBlock("h3", { text: "", level: 3 });
6497
+ else if (next === "quote") insertBlock("quote", { text: "", caption: "" });
6498
+ else if (next === "code") insertBlock("code", { code: "" });
6499
+ };
6500
+ return /* @__PURE__ */ jsxs("div", { ref: wrapRef, className: "ng-classic-toolbar", role: "toolbar", "aria-label": "Formatting toolbar", children: [
6501
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: onUndo, title: "Undo", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
6502
+ /* @__PURE__ */ jsx("path", { d: "M3 7v6h6" }),
6503
+ /* @__PURE__ */ jsx("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })
6504
+ ] }) }),
6505
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: onRedo, title: "Redo", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
6506
+ /* @__PURE__ */ jsx("path", { d: "M21 7v6h-6" }),
6507
+ /* @__PURE__ */ jsx("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })
6508
+ ] }) }),
6509
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6510
+ /* @__PURE__ */ jsxs(
6511
+ "select",
6512
+ {
6513
+ className: "ng-ct-select",
6514
+ value: blockType,
6515
+ onChange: (e) => handleBlockTypeChange(e.target.value),
6516
+ "aria-label": "Block type",
6517
+ children: [
6518
+ /* @__PURE__ */ jsx("option", { value: "paragraph", children: "Paragraph" }),
6519
+ /* @__PURE__ */ jsx("option", { value: "h1", children: "Heading 1" }),
6520
+ /* @__PURE__ */ jsx("option", { value: "h2", children: "Heading 2" }),
6521
+ /* @__PURE__ */ jsx("option", { value: "h3", children: "Heading 3" }),
6522
+ /* @__PURE__ */ jsx("option", { value: "quote", children: "Quote" }),
6523
+ /* @__PURE__ */ jsx("option", { value: "code", children: "Code" })
6524
+ ]
6525
+ }
6526
+ ),
6527
+ /* @__PURE__ */ jsxs(
6528
+ "select",
6529
+ {
6530
+ className: "ng-ct-select",
6531
+ value: fontFamily,
6532
+ onChange: (e) => onChangeFontFamily(e.target.value),
6533
+ "aria-label": "Font family",
6534
+ children: [
6535
+ /* @__PURE__ */ jsx("option", { value: "sans", children: "Sans" }),
6536
+ /* @__PURE__ */ jsx("option", { value: "serif", children: "Serif" }),
6537
+ /* @__PURE__ */ jsx("option", { value: "mono", children: "Mono" })
6538
+ ]
6539
+ }
6540
+ ),
6541
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6542
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-b", onMouseDown: keepSelection, onClick: () => exec("bold"), title: "Bold", children: "B" }),
6543
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-i", onMouseDown: keepSelection, onClick: () => exec("italic"), title: "Italic", children: "I" }),
6544
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-u", onMouseDown: keepSelection, onClick: () => exec("underline"), title: "Underline", children: "U" }),
6545
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-s", onMouseDown: keepSelection, onClick: () => exec("strikeThrough"), title: "Strikethrough", children: "S" }),
6546
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => toggleInlineTag("code"), title: "Inline Code", children: "<>" }),
6547
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-highlight", onMouseDown: keepSelection, onClick: () => toggleInlineTag("mark"), title: "Highlight", children: "A" }),
6548
+ /* @__PURE__ */ jsx(
6549
+ "button",
6550
+ {
6551
+ type: "button",
6552
+ className: "ng-ct-btn",
6553
+ onMouseDown: keepSelection,
6554
+ onClick: () => {
6555
+ const url = window.prompt("Enter link URL (https://...)");
6556
+ if (url) exec("createLink", url.trim());
6557
+ },
6558
+ title: "Insert Link",
6559
+ children: /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
6560
+ /* @__PURE__ */ 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" }),
6561
+ /* @__PURE__ */ 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" })
6562
+ ] })
6563
+ }
6564
+ ),
6565
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("superscript"), title: "Superscript", children: "x\xB2" }),
6566
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("subscript"), title: "Subscript", children: "x\u2082" }),
6567
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("removeFormat"), title: "Clear Formatting", children: "T\u2093" }),
6568
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6569
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "unordered", items: [] }), title: "Bullet List", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6570
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
6571
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
6572
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
6573
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "6", r: "1" }),
6574
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "12", r: "1" }),
6575
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "18", r: "1" })
6576
+ ] }) }),
6577
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("list", { style: "ordered", items: [] }), title: "Numbered List", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6578
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
6579
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
6580
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
6581
+ /* @__PURE__ */ jsx("path", { d: "M4 6h1v4" }),
6582
+ /* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
6583
+ /* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
6584
+ ] }) }),
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: [
6586
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "6", height: "6", rx: "1" }),
6587
+ /* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
6588
+ /* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
6589
+ /* @__PURE__ */ jsx("path", { d: "M13 12h8" }),
6590
+ /* @__PURE__ */ jsx("path", { d: "M13 18h8" })
6591
+ ] }) }),
6592
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("outdent"), title: "Decrease Indent", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6593
+ /* @__PURE__ */ jsx("polyline", { points: "7 8 3 12 7 16" }),
6594
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
6595
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
6596
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
6597
+ ] }) }),
6598
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("indent"), title: "Increase Indent", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6599
+ /* @__PURE__ */ jsx("polyline", { points: "3 8 7 12 3 16" }),
6600
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
6601
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
6602
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
6603
+ ] }) }),
6604
+ /* @__PURE__ */ jsxs("div", { className: "ng-ct-dropdown-wrap", children: [
6605
+ /* @__PURE__ */ jsxs(
6606
+ "button",
6607
+ {
6608
+ type: "button",
6609
+ className: "ng-ct-btn",
6610
+ onMouseDown: keepSelection,
6611
+ onClick: () => {
6612
+ setAlignOpen((v) => !v);
6613
+ setInsertOpen(false);
6614
+ },
6615
+ title: "Alignment",
6616
+ children: [
6617
+ /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6618
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "6", x2: "21", y2: "6" }),
6619
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "12", x2: "15", y2: "12" }),
6620
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "18", x2: "18", y2: "18" })
6621
+ ] }),
6622
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-caret", children: "\u25BE" })
6623
+ ]
6624
+ }
6625
+ ),
6626
+ alignOpen && /* @__PURE__ */ jsxs("div", { className: "ng-ct-menu", children: [
6627
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6628
+ exec("justifyLeft");
6629
+ setAlignOpen(false);
6630
+ }, children: "Align Left" }),
6631
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6632
+ exec("justifyCenter");
6633
+ setAlignOpen(false);
6634
+ }, children: "Align Center" }),
6635
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6636
+ exec("justifyRight");
6637
+ setAlignOpen(false);
6638
+ }, children: "Align Right" }),
6639
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6640
+ exec("justifyFull");
6641
+ setAlignOpen(false);
6642
+ }, children: "Justify" })
6643
+ ] })
6644
+ ] }),
6645
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6646
+ /* @__PURE__ */ jsxs("div", { className: "ng-ct-dropdown-wrap", children: [
6647
+ /* @__PURE__ */ jsxs(
6648
+ "button",
6649
+ {
6650
+ type: "button",
6651
+ className: "ng-ct-insert-btn",
6652
+ onClick: () => {
6653
+ setInsertOpen((v) => !v);
6654
+ setAlignOpen(false);
6655
+ },
6656
+ children: [
6657
+ /* @__PURE__ */ jsx("span", { children: "+ Insert" }),
6658
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-caret", children: "\u25BE" })
6659
+ ]
6660
+ }
6661
+ ),
6662
+ insertOpen && /* @__PURE__ */ jsx("div", { className: "ng-ct-menu ng-ct-insert-menu", children: visibleInsertItems.map((item) => /* @__PURE__ */ jsxs(
6663
+ "button",
6664
+ {
6665
+ type: "button",
6666
+ onClick: () => insertBlock(item.tool),
6667
+ children: [
6668
+ /* @__PURE__ */ jsx("span", { children: item.label }),
6669
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-cat", children: item.category })
6670
+ ]
6671
+ },
6672
+ item.tool
6673
+ )) })
6674
+ ] })
6675
+ ] });
6676
+ };
6677
+
6678
+ // src/components/SettingsModal.tsx
6679
+ import { useState as useState2 } from "react";
6680
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
6249
6681
  var SettingsModal = ({
6250
6682
  open,
6251
6683
  theme,
6252
6684
  mode,
6253
6685
  showStats,
6254
6686
  aiConfig,
6687
+ selectedTools,
6255
6688
  onChangeTheme,
6256
6689
  onChangeMode,
6257
6690
  onChangeShowStats,
6258
6691
  onChangeAiConfig,
6692
+ onChangeSelectedTools,
6259
6693
  onClose
6260
6694
  }) => {
6261
- const [showKey, setShowKey] = useState(false);
6695
+ const [showKey, setShowKey] = useState2(false);
6696
+ const [toolFilter, setToolFilter] = useState2("");
6697
+ const [activeTab, setActiveTab] = useState2("appearance");
6262
6698
  if (!open) return null;
6699
+ const selectedSet = new Set(selectedTools);
6700
+ const toggleTool = (tool) => {
6701
+ const next = new Set(selectedTools);
6702
+ if (next.has(tool)) next.delete(tool);
6703
+ else next.add(tool);
6704
+ next.add("settings");
6705
+ onChangeSelectedTools(Array.from(next));
6706
+ };
6263
6707
  const handleProviderChange = (providerId) => {
6264
6708
  const preset = AI_PROVIDER_PRESETS.find((p) => p.id === providerId);
6265
6709
  onChangeAiConfig({
@@ -6269,169 +6713,296 @@ var SettingsModal = ({
6269
6713
  endpoint: preset?.defaultEndpoint || ""
6270
6714
  });
6271
6715
  };
6272
- return /* @__PURE__ */ jsx("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Editor Settings", children: /* @__PURE__ */ jsxs("div", { className: "ng-modal", children: [
6273
- /* @__PURE__ */ jsxs("div", { className: "ng-modal-head", children: [
6274
- /* @__PURE__ */ jsxs("div", { children: [
6275
- /* @__PURE__ */ jsx("h3", { children: "Editor Settings" }),
6276
- /* @__PURE__ */ jsx("p", { children: "Configure appearance, editor mode, and AI provider." })
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: [
6717
+ /* @__PURE__ */ jsxs2("div", { className: "ng-modal-head", children: [
6718
+ /* @__PURE__ */ jsxs2("div", { children: [
6719
+ /* @__PURE__ */ jsx2("h3", { children: "Editor Settings" }),
6720
+ /* @__PURE__ */ jsx2("p", { children: "Configure appearance, AI provider, and registered components." })
6277
6721
  ] }),
6278
- /* @__PURE__ */ jsx("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
6722
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
6279
6723
  ] }),
6280
- /* @__PURE__ */ jsxs("div", { className: "ng-modal-body", children: [
6281
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6282
- /* @__PURE__ */ jsx("label", { children: "Theme" }),
6283
- /* @__PURE__ */ jsxs(
6284
- "select",
6285
- {
6286
- className: "cdx-input editor-form-select",
6287
- value: theme,
6288
- onChange: (e) => onChangeTheme(e.target.value),
6289
- children: [
6290
- /* @__PURE__ */ jsx("option", { value: "inherit", children: "Inherit from Host App" }),
6291
- /* @__PURE__ */ jsx("option", { value: "light", children: "shadcn Light" }),
6292
- /* @__PURE__ */ jsx("option", { value: "dark", children: "shadcn Dark" }),
6293
- /* @__PURE__ */ jsx("option", { value: "catppuccin-mocha", children: "Catppuccin Mocha" }),
6294
- /* @__PURE__ */ jsx("option", { value: "catppuccin-macchiato", children: "Catppuccin Macchiato" }),
6295
- /* @__PURE__ */ jsx("option", { value: "catppuccin-frappe", children: "Catppuccin Frapp\xE9" }),
6296
- /* @__PURE__ */ jsx("option", { value: "catppuccin-latte", children: "Catppuccin Latte" })
6297
- ]
6298
- }
6299
- )
6300
- ] }),
6301
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6302
- /* @__PURE__ */ jsx("label", { children: "Editor Mode" }),
6303
- /* @__PURE__ */ jsxs("div", { className: "ng-segmented", children: [
6304
- /* @__PURE__ */ jsx(
6305
- "button",
6306
- {
6307
- type: "button",
6308
- className: `excalidraw-btn${mode === "block" ? " is-active" : ""}`,
6309
- onClick: () => onChangeMode("block"),
6310
- children: "Block Editor (Full)"
6311
- }
6312
- ),
6313
- /* @__PURE__ */ jsx(
6314
- "button",
6315
- {
6316
- type: "button",
6317
- className: `excalidraw-btn${mode === "simple" ? " is-active" : ""}`,
6318
- onClick: () => onChangeMode("simple"),
6319
- children: "Simple Mode"
6320
- }
6321
- )
6322
- ] })
6323
- ] }),
6324
- /* @__PURE__ */ jsxs("div", { className: "ng-field ng-field-inline", children: [
6325
- /* @__PURE__ */ jsx("label", { htmlFor: "ng-stats-toggle", children: "Show word count & read time" }),
6326
- /* @__PURE__ */ jsx(
6327
- "input",
6328
- {
6329
- id: "ng-stats-toggle",
6330
- type: "checkbox",
6331
- checked: showStats,
6332
- onChange: (e) => onChangeShowStats(e.target.checked)
6333
- }
6334
- )
6335
- ] }),
6336
- /* @__PURE__ */ jsx("hr", { className: "ng-divider" }),
6337
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6338
- /* @__PURE__ */ jsx("label", { children: "AI Provider" }),
6339
- /* @__PURE__ */ jsx(
6340
- "select",
6341
- {
6342
- className: "cdx-input editor-form-select",
6343
- value: aiConfig.provider,
6344
- onChange: (e) => handleProviderChange(e.target.value),
6345
- children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ jsx("option", { value: p.id, children: p.label }, p.id))
6346
- }
6347
- )
6348
- ] }),
6349
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6350
- /* @__PURE__ */ jsx("label", { children: "Model" }),
6351
- /* @__PURE__ */ jsx(
6352
- "input",
6353
- {
6354
- type: "text",
6355
- className: "cdx-input editor-form-input",
6356
- value: aiConfig.model,
6357
- placeholder: "e.g. gpt-4o-mini",
6358
- onChange: (e) => onChangeAiConfig({ ...aiConfig, model: e.target.value })
6359
- }
6360
- )
6361
- ] }),
6362
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6363
- /* @__PURE__ */ jsx("label", { children: "API Key" }),
6364
- /* @__PURE__ */ jsxs("div", { className: "ng-key-row", children: [
6365
- /* @__PURE__ */ jsx(
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" }),
6788
+ /* @__PURE__ */ jsx2(
6789
+ "input",
6790
+ {
6791
+ id: "ng-stats-toggle",
6792
+ type: "checkbox",
6793
+ checked: showStats,
6794
+ onChange: (e) => onChangeShowStats(e.target.checked)
6795
+ }
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" }),
6802
+ /* @__PURE__ */ jsx2(
6803
+ "select",
6804
+ {
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 })
6859
+ }
6860
+ )
6861
+ ] })
6862
+ ] }),
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",
6875
+ {
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(
6366
6894
  "input",
6367
6895
  {
6368
- type: showKey ? "text" : "password",
6896
+ type: "search",
6369
6897
  className: "cdx-input editor-form-input",
6370
- value: aiConfig.apiKey,
6371
- placeholder: "sk-...",
6372
- onChange: (e) => onChangeAiConfig({ ...aiConfig, apiKey: e.target.value })
6898
+ placeholder: "Filter components (e.g. bento, chart, spoiler...)",
6899
+ value: toolFilter,
6900
+ onChange: (e) => setToolFilter(e.target.value)
6373
6901
  }
6374
6902
  ),
6375
- /* @__PURE__ */ jsx(
6376
- "button",
6377
- {
6378
- type: "button",
6379
- className: "excalidraw-btn",
6380
- onClick: () => setShowKey((s) => !s),
6381
- children: showKey ? "Hide" : "Show"
6382
- }
6383
- )
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
+ }) })
6384
6935
  ] })
6385
- ] }),
6386
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6387
- /* @__PURE__ */ jsx("label", { children: "Endpoint URL (optional)" }),
6388
- /* @__PURE__ */ jsx(
6389
- "input",
6390
- {
6391
- type: "url",
6392
- className: "cdx-input editor-form-input",
6393
- value: aiConfig.endpoint || "",
6394
- placeholder: "Default provider endpoint",
6395
- onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
6396
- }
6397
- )
6398
6936
  ] })
6399
6937
  ] })
6400
6938
  ] }) });
6401
6939
  };
6402
6940
 
6403
6941
  // src/components/BlockEditor.tsx
6404
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
6405
- var BlockEditor = React3.forwardRef(
6942
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
6943
+ var BlockEditor = React4.forwardRef(
6406
6944
  ({
6407
6945
  initialData,
6408
6946
  placeholder,
6409
6947
  enabledTools,
6410
6948
  showStats = true,
6411
- showAiBar = true,
6949
+ showAiBar = false,
6412
6950
  onAiRequest,
6413
6951
  className,
6414
6952
  onReady,
6415
- onChange
6953
+ onChange,
6954
+ onThemeChange
6416
6955
  }, ref) => {
6417
- const shellRef = useRef(null);
6418
- const holderRef = useRef(null);
6419
- const editorRef = useRef(null);
6420
- const undoRef = useRef(null);
6421
- const lifecycleRef = useRef(Promise.resolve());
6422
- const latestDocRef = useRef(initialData || { blocks: [] });
6423
- const onChangeRef = useRef(onChange);
6424
- const onReadyRef = useRef(onReady);
6425
- const [settingsOpen, setSettingsOpen] = useState2(false);
6426
- const [theme, setTheme] = useState2("inherit");
6427
- const [editorMode, setEditorMode] = useState2("block");
6428
- const [statsVisible, setStatsVisible] = useState2(showStats);
6429
- const [aiConfig, setAiConfig] = useState2(loadAiConfig);
6430
- const [askOpen, setAskOpen] = useState2(false);
6431
- const [askPrompt, setAskPrompt] = useState2("");
6432
- const [aiBusy, setAiBusy] = useState2(false);
6433
- const [aiError, setAiError] = useState2(null);
6434
- const [stats, setStats] = useState2(() => {
6956
+ const shellRef = useRef2(null);
6957
+ const holderRef = useRef2(null);
6958
+ const editorRef = useRef2(null);
6959
+ const undoRef = useRef2(null);
6960
+ const lifecycleRef = useRef2(Promise.resolve());
6961
+ const latestDocRef = useRef2(initialData || { blocks: [] });
6962
+ const onChangeRef = useRef2(onChange);
6963
+ const onReadyRef = useRef2(onReady);
6964
+ const runAiRef = useRef2(async () => {
6965
+ });
6966
+ const [settingsOpen, setSettingsOpen] = useState3(false);
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
+ });
6975
+ const [editorMode, setEditorMode] = useState3("block");
6976
+ const [simpleFont, setSimpleFont] = useState3("sans");
6977
+ const [selectedTools, setSelectedTools] = useState3(() => {
6978
+ if (enabledTools && enabledTools.length > 0) return enabledTools;
6979
+ try {
6980
+ const raw = localStorage.getItem("ng-enabled-tools");
6981
+ if (raw) {
6982
+ const parsed = JSON.parse(raw);
6983
+ if (Array.isArray(parsed) && parsed.length > 0) return parsed;
6984
+ }
6985
+ } catch {
6986
+ }
6987
+ return ALL_TOOL_NAMES;
6988
+ });
6989
+ const [statsVisible, setStatsVisible] = useState3(showStats);
6990
+ const [aiConfig, setAiConfig] = useState3(loadAiConfig);
6991
+ const [aiPopover, setAiPopover] = useState3(null);
6992
+ const [askPrompt, setAskPrompt] = useState3("");
6993
+ const [aiBusy, setAiBusy] = useState3(false);
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 });
7005
+ const [stats, setStats] = useState3(() => {
6435
7006
  const blocks = initialData?.blocks || [];
6436
7007
  const text = blocks.map((b) => JSON.stringify(b.data || {})).join(" ");
6437
7008
  const words = text.trim() ? text.trim().split(/\s+/).length : 0;
@@ -6439,39 +7010,85 @@ var BlockEditor = React3.forwardRef(
6439
7010
  });
6440
7011
  onChangeRef.current = onChange;
6441
7012
  onReadyRef.current = onReady;
6442
- useEffect(() => {
7013
+ useEffect2(() => {
6443
7014
  setStatsVisible(showStats);
6444
7015
  }, [showStats]);
6445
- useEffect(() => {
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]);
7028
+ useEffect2(() => {
6446
7029
  const shell = shellRef.current;
6447
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
+ };
6448
7044
  const onOpenSettings = () => setSettingsOpen(true);
7045
+ const onAiContinue = (e) => openAiNearRect("continue", e);
7046
+ const onAiAsk = (e) => openAiNearRect("ask", e);
7047
+ const onOpenScratch = () => setScratchOpen(true);
6449
7048
  shell.addEventListener("nextgen-open-settings", onOpenSettings);
6450
- return () => shell.removeEventListener("nextgen-open-settings", onOpenSettings);
7049
+ shell.addEventListener("nextgen-ai-continue", onAiContinue);
7050
+ shell.addEventListener("nextgen-ai-ask", onAiAsk);
7051
+ shell.addEventListener("nextgen-open-scratch", onOpenScratch);
7052
+ return () => {
7053
+ shell.removeEventListener("nextgen-open-settings", onOpenSettings);
7054
+ shell.removeEventListener("nextgen-ai-continue", onAiContinue);
7055
+ shell.removeEventListener("nextgen-ai-ask", onAiAsk);
7056
+ shell.removeEventListener("nextgen-open-scratch", onOpenScratch);
7057
+ };
6451
7058
  }, []);
6452
- useEffect(() => {
7059
+ useEffect2(() => {
6453
7060
  const holder = holderRef.current;
6454
7061
  if (!holder) return;
6455
7062
  let cancelled = false;
6456
7063
  const detachCategories = attachPopoverCategoryHeaders(holder);
6457
- const effectiveTools = editorMode === "simple" ? enabledTools && enabledTools.length > 0 ? enabledTools.filter((t) => SIMPLE_MODE_TOOLS.includes(t)) : SIMPLE_MODE_TOOLS : enabledTools;
7064
+ const detachEmoji = attachEmojiSidePicker(holder);
7065
+ const effectiveTools = Array.from(/* @__PURE__ */ new Set([...selectedTools, "settings"]));
6458
7066
  const mount = async () => {
6459
7067
  await lifecycleRef.current;
6460
7068
  if (cancelled) return;
7069
+ const sanitizedInitial = {
7070
+ ...latestDocRef.current || { blocks: [] },
7071
+ blocks: (latestDocRef.current?.blocks || []).filter(
7072
+ (b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
7073
+ )
7074
+ };
7075
+ latestDocRef.current = sanitizedInitial;
6461
7076
  holder.innerHTML = "";
6462
7077
  const instance = new EditorJS2({
6463
7078
  holder,
6464
- data: latestDocRef.current || { blocks: [] },
7079
+ data: sanitizedInitial,
6465
7080
  placeholder: placeholder || "Write your story, or press / to insert blocks...",
6466
7081
  tools: getEditorTools(true, effectiveTools),
6467
7082
  onChange: async () => {
6468
7083
  try {
6469
7084
  const saved = await instance.save();
6470
- const typed = saved;
7085
+ const filteredBlocks = (saved.blocks || []).filter(
7086
+ (b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
7087
+ );
7088
+ const typed = { ...saved, blocks: filteredBlocks };
6471
7089
  latestDocRef.current = typed;
6472
- const blocks = saved.blocks || [];
6473
7090
  const words = (holder.innerText || "").trim().split(/\s+/).filter(Boolean).length;
6474
- setStats({ words, blocks: blocks.length });
7091
+ setStats({ words, blocks: filteredBlocks.length });
6475
7092
  onChangeRef.current?.(typed);
6476
7093
  } catch {
6477
7094
  }
@@ -6500,6 +7117,7 @@ var BlockEditor = React3.forwardRef(
6500
7117
  return () => {
6501
7118
  cancelled = true;
6502
7119
  detachCategories();
7120
+ detachEmoji();
6503
7121
  const toDestroy = editorRef.current;
6504
7122
  editorRef.current = null;
6505
7123
  undoRef.current = null;
@@ -6510,13 +7128,16 @@ var BlockEditor = React3.forwardRef(
6510
7128
  });
6511
7129
  }
6512
7130
  };
6513
- }, [editorMode]);
7131
+ }, [editorMode, selectedTools]);
6514
7132
  useImperativeHandle(ref, () => ({
6515
7133
  save: async () => {
6516
7134
  if (!editorRef.current) return null;
6517
7135
  await editorRef.current.isReady;
6518
7136
  const saved = await editorRef.current.save();
6519
- const typed = saved;
7137
+ const filteredBlocks = (saved.blocks || []).filter(
7138
+ (b) => !["settings", "continueWriting", "askAi", "scratch"].includes(b.type)
7139
+ );
7140
+ const typed = { ...saved, blocks: filteredBlocks };
6520
7141
  latestDocRef.current = typed;
6521
7142
  return typed;
6522
7143
  },
@@ -6561,7 +7182,7 @@ var BlockEditor = React3.forwardRef(
6561
7182
  }
6562
7183
  if (mode === "ask") {
6563
7184
  setAskPrompt("");
6564
- setAskOpen(false);
7185
+ setAiPopover(null);
6565
7186
  }
6566
7187
  } catch (err) {
6567
7188
  setAiError(err instanceof Error ? err.message : "AI request failed.");
@@ -6569,6 +7190,7 @@ var BlockEditor = React3.forwardRef(
6569
7190
  setAiBusy(false);
6570
7191
  }
6571
7192
  };
7193
+ runAiRef.current = runAi;
6572
7194
  const handleModeSwitch = async (nextMode) => {
6573
7195
  if (nextMode === editorMode) return;
6574
7196
  if (editorRef.current) {
@@ -6582,16 +7204,17 @@ var BlockEditor = React3.forwardRef(
6582
7204
  setEditorMode(nextMode);
6583
7205
  };
6584
7206
  const readMins = Math.max(1, Math.ceil(stats.words / 200));
6585
- return /* @__PURE__ */ jsxs2(
7207
+ return /* @__PURE__ */ jsxs3(
6586
7208
  "div",
6587
7209
  {
6588
7210
  ref: shellRef,
6589
7211
  "data-ng-theme": theme === "inherit" ? void 0 : theme,
7212
+ "data-ng-font": editorMode === "simple" ? simpleFont : void 0,
6590
7213
  className: className ? `nextgen-editor-shell ${className}` : "nextgen-editor-shell",
6591
7214
  children: [
6592
- showAiBar && /* @__PURE__ */ jsxs2("div", { className: "ng-ai-bar", children: [
6593
- /* @__PURE__ */ jsxs2("div", { className: "ng-ai-actions", children: [
6594
- /* @__PURE__ */ jsx2(
7215
+ showAiBar && /* @__PURE__ */ jsxs3("div", { className: "ng-ai-bar", children: [
7216
+ /* @__PURE__ */ jsxs3("div", { className: "ng-ai-actions", children: [
7217
+ /* @__PURE__ */ jsx3(
6595
7218
  "button",
6596
7219
  {
6597
7220
  type: "button",
@@ -6601,18 +7224,20 @@ var BlockEditor = React3.forwardRef(
6601
7224
  children: aiBusy ? "Thinking\u2026" : "\u2726 Continue Writing"
6602
7225
  }
6603
7226
  ),
6604
- /* @__PURE__ */ jsx2(
7227
+ /* @__PURE__ */ jsx3(
6605
7228
  "button",
6606
7229
  {
6607
7230
  type: "button",
6608
- className: `excalidraw-btn${askOpen ? " is-active" : ""}`,
7231
+ className: `excalidraw-btn${aiPopover?.mode === "ask" ? " is-active" : ""}`,
6609
7232
  disabled: aiBusy,
6610
- onClick: () => setAskOpen((o) => !o),
7233
+ onClick: () => setAiPopover(
7234
+ (p) => p ? null : { mode: "ask", top: 120, left: 120 }
7235
+ ),
6611
7236
  children: "Ask AI"
6612
7237
  }
6613
7238
  )
6614
7239
  ] }),
6615
- /* @__PURE__ */ jsx2(
7240
+ /* @__PURE__ */ jsx3(
6616
7241
  "button",
6617
7242
  {
6618
7243
  type: "button",
@@ -6623,49 +7248,37 @@ var BlockEditor = React3.forwardRef(
6623
7248
  }
6624
7249
  )
6625
7250
  ] }),
6626
- askOpen && /* @__PURE__ */ jsxs2(
6627
- "form",
7251
+ editorMode === "simple" && /* @__PURE__ */ jsx3(
7252
+ ClassicToolbar,
6628
7253
  {
6629
- className: "ng-ask-form",
6630
- onSubmit: (e) => {
6631
- e.preventDefault();
6632
- if (askPrompt.trim()) void runAi("ask", askPrompt.trim());
6633
- },
6634
- children: [
6635
- /* @__PURE__ */ jsx2(
6636
- "input",
6637
- {
6638
- type: "text",
6639
- className: "cdx-input editor-form-input",
6640
- placeholder: "Ask AI to draft, summarize, or expand...",
6641
- value: askPrompt,
6642
- onChange: (e) => setAskPrompt(e.target.value)
6643
- }
6644
- ),
6645
- /* @__PURE__ */ jsx2("button", { type: "submit", className: "editor-form-submit", disabled: aiBusy, children: aiBusy ? "Running\u2026" : "Generate" })
6646
- ]
7254
+ editorRef,
7255
+ onUndo: () => undoRef.current?.undo?.(),
7256
+ onRedo: () => undoRef.current?.redo?.(),
7257
+ fontFamily: simpleFont,
7258
+ onChangeFontFamily: setSimpleFont,
7259
+ enabledTools: selectedTools,
7260
+ onOpenSettings: () => setSettingsOpen(true)
6647
7261
  }
6648
7262
  ),
6649
- aiError && /* @__PURE__ */ jsx2("div", { className: "ng-ai-error", children: aiError }),
6650
- /* @__PURE__ */ jsx2("div", { id: "editorjs", ref: holderRef }),
6651
- statsVisible && /* @__PURE__ */ jsxs2("div", { className: "nextgen-editor-stats", children: [
6652
- /* @__PURE__ */ jsx2("span", { children: editorMode === "simple" ? "Simple Mode" : "Block Editor" }),
6653
- /* @__PURE__ */ jsx2("span", { children: "\u2022" }),
6654
- /* @__PURE__ */ jsxs2("span", { children: [
7263
+ /* @__PURE__ */ jsx3("div", { id: "editorjs", ref: holderRef }),
7264
+ statsVisible && /* @__PURE__ */ jsxs3("div", { className: "nextgen-editor-stats", children: [
7265
+ /* @__PURE__ */ jsx3("span", { children: editorMode === "simple" ? "Simple Mode" : "Block Editor" }),
7266
+ /* @__PURE__ */ jsx3("span", { children: "\u2022" }),
7267
+ /* @__PURE__ */ jsxs3("span", { children: [
6655
7268
  stats.blocks,
6656
7269
  " blocks"
6657
7270
  ] }),
6658
- /* @__PURE__ */ jsxs2("span", { children: [
7271
+ /* @__PURE__ */ jsxs3("span", { children: [
6659
7272
  stats.words,
6660
7273
  " words"
6661
7274
  ] }),
6662
- /* @__PURE__ */ jsxs2("span", { children: [
7275
+ /* @__PURE__ */ jsxs3("span", { children: [
6663
7276
  "~",
6664
7277
  readMins,
6665
7278
  " min read"
6666
7279
  ] })
6667
7280
  ] }),
6668
- /* @__PURE__ */ jsx2(
7281
+ /* @__PURE__ */ jsx3(
6669
7282
  SettingsModal,
6670
7283
  {
6671
7284
  open: settingsOpen,
@@ -6673,6 +7286,7 @@ var BlockEditor = React3.forwardRef(
6673
7286
  mode: editorMode,
6674
7287
  showStats: statsVisible,
6675
7288
  aiConfig,
7289
+ selectedTools,
6676
7290
  onChangeTheme: setTheme,
6677
7291
  onChangeMode: (m) => void handleModeSwitch(m),
6678
7292
  onChangeShowStats: setStatsVisible,
@@ -6681,8 +7295,170 @@ var BlockEditor = React3.forwardRef(
6681
7295
  saveAiConfig(cfg);
6682
7296
  setAiError(null);
6683
7297
  },
7298
+ onChangeSelectedTools: (tools) => {
7299
+ setSelectedTools(tools);
7300
+ try {
7301
+ localStorage.setItem("ng-enabled-tools", JSON.stringify(tools));
7302
+ } catch {
7303
+ }
7304
+ },
6684
7305
  onClose: () => setSettingsOpen(false)
6685
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
+ }
6686
7462
  )
6687
7463
  ]
6688
7464
  }
@@ -6692,13 +7468,13 @@ var BlockEditor = React3.forwardRef(
6692
7468
  BlockEditor.displayName = "BlockEditor";
6693
7469
 
6694
7470
  // src/components/BlockRenderer.tsx
6695
- import { useMemo, useRef as useRef2 } from "react";
7471
+ import { useMemo, useRef as useRef3 } from "react";
6696
7472
 
6697
7473
  // src/hooks/useInteractiveArticle.ts
6698
7474
  import Chart2 from "chart.js/auto";
6699
- import { useEffect as useEffect2 } from "react";
7475
+ import { useEffect as useEffect3 } from "react";
6700
7476
  function useInteractiveArticle(containerRef, depKey) {
6701
- useEffect2(() => {
7477
+ useEffect3(() => {
6702
7478
  const root = containerRef.current;
6703
7479
  if (!root) return;
6704
7480
  const cleanups = [];
@@ -7388,18 +8164,31 @@ function useInteractiveArticle(containerRef, depKey) {
7388
8164
  }
7389
8165
 
7390
8166
  // src/components/BlockRenderer.tsx
7391
- import { jsx as jsx3 } from "react/jsx-runtime";
8167
+ import { jsx as jsx4 } from "react/jsx-runtime";
7392
8168
  var BlockRenderer = ({
7393
8169
  data,
8170
+ theme,
7394
8171
  className
7395
8172
  }) => {
7396
- const bodyRef = useRef2(null);
8173
+ const bodyRef = useRef3(null);
7397
8174
  const html = useMemo(() => blocksToHtml(data), [data]);
7398
8175
  useInteractiveArticle(bodyRef, html);
7399
- return /* @__PURE__ */ jsx3(
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;
8187
+ return /* @__PURE__ */ jsx4(
7400
8188
  "div",
7401
8189
  {
7402
8190
  ref: bodyRef,
8191
+ "data-ng-theme": attrTheme,
7403
8192
  className: className ? `article nextgen-editor-article ${className}` : "article nextgen-editor-article",
7404
8193
  dangerouslySetInnerHTML: { __html: html }
7405
8194
  }
@@ -7407,7 +8196,7 @@ var BlockRenderer = ({
7407
8196
  };
7408
8197
 
7409
8198
  // src/components/DocumentHeader.tsx
7410
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
8199
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
7411
8200
  var DocumentHeader = ({
7412
8201
  coverUrl,
7413
8202
  gradient = "linear-gradient(135deg, #27272a 0%, #52525b 100%)",
@@ -7417,12 +8206,12 @@ var DocumentHeader = ({
7417
8206
  className
7418
8207
  }) => {
7419
8208
  const bannerStyle = coverUrl ? { backgroundImage: `url("${coverUrl}")`, backgroundSize: "cover", backgroundPosition: "center" } : { background: gradient };
7420
- return /* @__PURE__ */ jsxs3("header", { className: className ? `editor-cover-card ${className}` : "editor-cover-card", children: [
7421
- /* @__PURE__ */ jsx4("div", { className: "editor-cover-banner", style: bannerStyle }),
7422
- icon ? /* @__PURE__ */ jsx4("div", { className: "editor-cover-icon", children: icon }) : null,
7423
- /* @__PURE__ */ jsxs3("div", { className: "editor-cover-meta", children: [
7424
- /* @__PURE__ */ jsx4("h1", { className: "editor-cover-title", children: title }),
7425
- subtitle ? /* @__PURE__ */ jsx4("p", { className: "editor-cover-subtitle", children: subtitle }) : null
8209
+ return /* @__PURE__ */ jsxs4("header", { className: className ? `editor-cover-card ${className}` : "editor-cover-card", children: [
8210
+ /* @__PURE__ */ jsx5("div", { className: "editor-cover-banner", style: bannerStyle }),
8211
+ icon ? /* @__PURE__ */ jsx5("div", { className: "editor-cover-icon", children: icon }) : null,
8212
+ /* @__PURE__ */ jsxs4("div", { className: "editor-cover-meta", children: [
8213
+ /* @__PURE__ */ jsx5("h1", { className: "editor-cover-title", children: title }),
8214
+ subtitle ? /* @__PURE__ */ jsx5("p", { className: "editor-cover-subtitle", children: subtitle }) : null
7426
8215
  ] })
7427
8216
  ] });
7428
8217
  };