nextgen-block-editor 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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";
@@ -247,7 +247,7 @@ function sanitizeInlineHtml(value) {
247
247
  }
248
248
  const template = document.createElement("template");
249
249
  template.innerHTML = String(value == null ? "" : value);
250
- const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM"];
250
+ const allowed = ["A", "MARK", "SPAN", "U", "S", "STRIKE", "CODE", "B", "STRONG", "I", "EM", "SUP", "SUB"];
251
251
  template.content.querySelectorAll("*").forEach((element) => {
252
252
  if (!allowed.includes(element.tagName)) {
253
253
  element.replaceWith(document.createTextNode(element.textContent || ""));
@@ -1589,6 +1589,141 @@ import { createRoot } from "react-dom/client";
1589
1589
  import { Excalidraw, exportToCanvas } from "@excalidraw/excalidraw";
1590
1590
  import Chart from "chart.js/auto";
1591
1591
  import katex2 from "katex";
1592
+
1593
+ // src/utils/emojiSidePicker.ts
1594
+ var activeMenuCleanup = null;
1595
+ function openEmojiSideMenu({
1596
+ anchorRect,
1597
+ onSelect,
1598
+ onClose
1599
+ }) {
1600
+ if (activeMenuCleanup) {
1601
+ activeMenuCleanup();
1602
+ activeMenuCleanup = null;
1603
+ }
1604
+ const popover = document.createElement("div");
1605
+ popover.className = "editor-emoji-side-popover";
1606
+ popover.setAttribute("role", "dialog");
1607
+ popover.setAttribute("aria-label", "Emoji picker");
1608
+ const menuW = 264;
1609
+ const menuH = 290;
1610
+ const gap = 8;
1611
+ const fitsRight = anchorRect.right + gap + menuW <= window.innerWidth - 8;
1612
+ const left = fitsRight ? anchorRect.right + gap : Math.max(8, anchorRect.left - menuW - gap);
1613
+ const top = Math.max(
1614
+ 8,
1615
+ Math.min(anchorRect.top, window.innerHeight - menuH - 8)
1616
+ );
1617
+ popover.style.left = `${left}px`;
1618
+ popover.style.top = `${top}px`;
1619
+ const searchIn = document.createElement("input");
1620
+ searchIn.type = "search";
1621
+ searchIn.className = "cdx-input editor-form-input";
1622
+ searchIn.placeholder = "Search emoji (fire, rocket...)";
1623
+ const grid = document.createElement("div");
1624
+ grid.className = "editor-emoji-grid";
1625
+ const close = () => {
1626
+ document.removeEventListener("mousedown", onOutside, true);
1627
+ document.removeEventListener("keydown", onKey, true);
1628
+ popover.remove();
1629
+ activeMenuCleanup = null;
1630
+ onClose?.();
1631
+ };
1632
+ const renderGrid = (query = "") => {
1633
+ grid.innerHTML = "";
1634
+ const q = query.trim().toLowerCase();
1635
+ const filtered = q ? EMOJI_PRESETS.filter((p) => p.name.includes(q) || p.em.includes(q)) : EMOJI_PRESETS;
1636
+ filtered.forEach(({ em, name }) => {
1637
+ const btn = document.createElement("button");
1638
+ btn.type = "button";
1639
+ btn.title = name;
1640
+ btn.className = "editor-emoji-btn";
1641
+ btn.textContent = em;
1642
+ btn.addEventListener("mousedown", (e) => e.preventDefault());
1643
+ btn.addEventListener("click", () => {
1644
+ const cb = onSelect;
1645
+ close();
1646
+ cb(em);
1647
+ });
1648
+ grid.appendChild(btn);
1649
+ });
1650
+ };
1651
+ const onOutside = (e) => {
1652
+ if (!popover.contains(e.target)) {
1653
+ close();
1654
+ }
1655
+ };
1656
+ const onKey = (e) => {
1657
+ if (e.key === "Escape") {
1658
+ e.preventDefault();
1659
+ e.stopPropagation();
1660
+ close();
1661
+ }
1662
+ };
1663
+ searchIn.addEventListener("input", () => renderGrid(searchIn.value));
1664
+ renderGrid();
1665
+ popover.append(searchIn, grid);
1666
+ document.body.appendChild(popover);
1667
+ document.addEventListener("mousedown", onOutside, true);
1668
+ document.addEventListener("keydown", onKey, true);
1669
+ queueMicrotask(() => searchIn.focus());
1670
+ activeMenuCleanup = close;
1671
+ return close;
1672
+ }
1673
+ function attachEmojiSidePicker(container) {
1674
+ const onInput = (e) => {
1675
+ const target = e.target;
1676
+ if (!target || !target.isContentEditable) return;
1677
+ const sel = window.getSelection();
1678
+ if (!sel || sel.rangeCount === 0) return;
1679
+ const range = sel.getRangeAt(0);
1680
+ if (range.startContainer.nodeType !== Node.TEXT_NODE || !range.collapsed) {
1681
+ return;
1682
+ }
1683
+ const textNode = range.startContainer;
1684
+ const offset = range.startOffset;
1685
+ const before = textNode.data.slice(0, offset);
1686
+ if (!/(^|\s)\/emoji$/i.test(before)) return;
1687
+ const triggerStart = offset - "/emoji".length;
1688
+ const triggerRange = document.createRange();
1689
+ triggerRange.setStart(textNode, triggerStart);
1690
+ triggerRange.setEnd(textNode, offset);
1691
+ const rect = triggerRange.getBoundingClientRect();
1692
+ openEmojiSideMenu({
1693
+ anchorRect: rect,
1694
+ onSelect: (emoji) => {
1695
+ if (!textNode.isConnected) return;
1696
+ const current = textNode.data;
1697
+ const nextText = current.slice(0, triggerStart) + emoji + current.slice(offset);
1698
+ textNode.data = nextText;
1699
+ const nextCaret = triggerStart + emoji.length;
1700
+ const newRange = document.createRange();
1701
+ newRange.setStart(textNode, nextCaret);
1702
+ newRange.setEnd(textNode, nextCaret);
1703
+ const s = window.getSelection();
1704
+ if (s) {
1705
+ s.removeAllRanges();
1706
+ s.addRange(newRange);
1707
+ }
1708
+ target.focus();
1709
+ target.dispatchEvent(new Event("input", { bubbles: true }));
1710
+ },
1711
+ onClose: () => {
1712
+ target.focus();
1713
+ }
1714
+ });
1715
+ };
1716
+ container.addEventListener("input", onInput);
1717
+ return () => {
1718
+ container.removeEventListener("input", onInput);
1719
+ if (activeMenuCleanup) {
1720
+ activeMenuCleanup();
1721
+ activeMenuCleanup = null;
1722
+ }
1723
+ };
1724
+ }
1725
+
1726
+ // src/blocks/richBlocks.ts
1592
1727
  var LatexTool = class {
1593
1728
  data;
1594
1729
  wrapper = null;
@@ -3520,34 +3655,55 @@ var FlashcardTool = class {
3520
3655
  };
3521
3656
  }
3522
3657
  };
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
- };
3658
+ function createActionTriggerTool(title, icon, eventName) {
3659
+ return class {
3660
+ api;
3661
+ el = null;
3662
+ fired = false;
3663
+ static get toolbox() {
3664
+ return { title, icon };
3665
+ }
3666
+ constructor({ api }) {
3667
+ this.api = api;
3668
+ }
3669
+ render() {
3670
+ const el = document.createElement("div");
3671
+ el.style.display = "none";
3672
+ this.el = el;
3673
+ return el;
3674
+ }
3675
+ rendered() {
3676
+ if (this.fired || !this.el) return;
3677
+ this.fired = true;
3678
+ this.el.dispatchEvent(new CustomEvent(eventName, { bubbles: true }));
3679
+ window.setTimeout(() => {
3680
+ try {
3681
+ const idx = this.api.blocks.getCurrentBlockIndex();
3682
+ if (idx >= 0) this.api.blocks.delete(idx);
3683
+ } catch {
3684
+ }
3685
+ }, 0);
3686
+ }
3687
+ save() {
3688
+ return {};
3689
+ }
3690
+ };
3691
+ }
3692
+ var SettingsTriggerTool = createActionTriggerTool(
3693
+ "Settings",
3694
+ '<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>',
3695
+ "nextgen-open-settings"
3696
+ );
3697
+ var ContinueWritingTool = createActionTriggerTool(
3698
+ "Continue Writing",
3699
+ '<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>',
3700
+ "nextgen-ai-continue"
3701
+ );
3702
+ var AskAiTool = createActionTriggerTool(
3703
+ "Ask AI",
3704
+ '<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>',
3705
+ "nextgen-ai-ask"
3706
+ );
3551
3707
  var UploadTool = class {
3552
3708
  data;
3553
3709
  statusEl = null;
@@ -3889,94 +4045,66 @@ var EMOJI_PRESETS = [
3889
4045
  ];
3890
4046
  var EmojiTool = class {
3891
4047
  data;
4048
+ api;
4049
+ isNewInsert;
4050
+ anchorEl = null;
3892
4051
  static get toolbox() {
3893
4052
  return {
3894
4053
  title: "Emoji",
3895
4054
  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
4055
  };
3897
4056
  }
3898
- constructor({ data }) {
4057
+ constructor({
4058
+ data,
4059
+ api
4060
+ }) {
4061
+ this.isNewInsert = !data?.emoji;
4062
+ this.api = api;
3899
4063
  this.data = {
3900
4064
  emoji: data?.emoji ?? "\u2728",
3901
4065
  label: data?.label ?? "",
3902
4066
  size: data?.size || "md"
3903
4067
  };
3904
4068
  }
4069
+ openPickerAtAnchor() {
4070
+ if (!this.anchorEl) return;
4071
+ const rect = this.anchorEl.getBoundingClientRect();
4072
+ openEmojiSideMenu({
4073
+ anchorRect: rect,
4074
+ onSelect: (em) => {
4075
+ if (this.isNewInsert && this.api?.blocks) {
4076
+ const idx = this.api.blocks.getCurrentBlockIndex();
4077
+ this.api.blocks.delete(idx);
4078
+ this.api.blocks.insert("paragraph", { text: `${em} ` }, {}, idx, true);
4079
+ queueMicrotask(() => {
4080
+ this.api?.caret?.setToBlock(idx, "end");
4081
+ });
4082
+ return;
4083
+ }
4084
+ this.data.emoji = em;
4085
+ if (this.anchorEl) {
4086
+ this.anchorEl.textContent = `${em} Pick emoji`;
4087
+ }
4088
+ }
4089
+ });
4090
+ }
3905
4091
  render() {
3906
4092
  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);
4093
+ wrap.className = "editor-emoji-inline-wrap";
4094
+ const btn = document.createElement("button");
4095
+ btn.type = "button";
4096
+ btn.className = "b2 editor-emoji-inline-anchor";
4097
+ btn.textContent = `${this.data.emoji} Pick emoji`;
4098
+ btn.addEventListener("click", () => this.openPickerAtAnchor());
4099
+ this.anchorEl = btn;
4100
+ wrap.appendChild(btn);
3978
4101
  return wrap;
3979
4102
  }
4103
+ rendered() {
4104
+ if (this.isNewInsert) {
4105
+ queueMicrotask(() => this.openPickerAtAnchor());
4106
+ }
4107
+ }
3980
4108
  save() {
3981
4109
  return {
3982
4110
  emoji: this.data.emoji.trim() || "\u2728",
@@ -5908,6 +6036,8 @@ function getEditorTools(includeLayout = true, enabledTools) {
5908
6036
  nestedlist: NestedList,
5909
6037
  simpleImage: SimpleImage,
5910
6038
  comment: CommentTool,
6039
+ continueWriting: ContinueWritingTool,
6040
+ askAi: AskAiTool,
5911
6041
  settings: SettingsTriggerTool,
5912
6042
  // Inline toolbar tools
5913
6043
  inlineCode: InlineCode,
@@ -6161,6 +6291,10 @@ var TOOL_CATEGORIES = [
6161
6291
  "slides"
6162
6292
  ]
6163
6293
  },
6294
+ {
6295
+ label: "AI",
6296
+ tools: ["continueWriting", "askAi"]
6297
+ },
6164
6298
  {
6165
6299
  label: "Settings",
6166
6300
  tools: ["settings"]
@@ -6176,8 +6310,80 @@ var SIMPLE_MODE_TOOLS = [
6176
6310
  "code",
6177
6311
  "image",
6178
6312
  "delimiter",
6313
+ "continueWriting",
6314
+ "askAi",
6179
6315
  "settings"
6180
6316
  ];
6317
+ var ALL_TOOL_NAMES = Array.from(
6318
+ new Set(TOOL_CATEGORIES.flatMap((g) => g.tools))
6319
+ );
6320
+ var TOOL_LABELS = {
6321
+ h1: "Heading 1",
6322
+ h2: "Heading 2",
6323
+ h3: "Heading 3",
6324
+ paragraph: "Paragraph",
6325
+ list: "List",
6326
+ nestedlist: "Nested List",
6327
+ checklist: "Checklist",
6328
+ quote: "Quote",
6329
+ pullquote: "Pull Quote",
6330
+ delimiter: "Delimiter",
6331
+ callout: "Callout",
6332
+ hotkey: "Hotkey",
6333
+ emoji: "Emoji",
6334
+ scratch: "Scratchpad",
6335
+ alert: "Alert",
6336
+ badges: "Badges",
6337
+ tags: "Tags",
6338
+ cover: "Page Cover",
6339
+ toc: "Table of Contents",
6340
+ bento: "Bento Grid",
6341
+ layout: "Multi-Column Layout",
6342
+ tabs: "Tabs",
6343
+ accordion: "Accordion",
6344
+ toggleh1: "Toggle H1",
6345
+ toggleh2: "Toggle H2",
6346
+ toggleh3: "Toggle H3",
6347
+ collapsible: "Collapsible",
6348
+ spoiler: "Spoiler",
6349
+ cards: "Cards",
6350
+ timeline: "Timeline",
6351
+ proscons: "Pros & Cons",
6352
+ upload: "Upload",
6353
+ image: "Image",
6354
+ simpleImage: "Simple Image",
6355
+ gif: "GIF",
6356
+ gallery: "Lightbox Gallery",
6357
+ masonry: "Masonry Grid",
6358
+ carousel: "Carousel",
6359
+ compare: "Before / After",
6360
+ audio: "Audio Player",
6361
+ musicCarousel: "Music Carousel",
6362
+ embed: "Embed",
6363
+ attaches: "Attachment",
6364
+ excalidraw: "Excalidraw",
6365
+ code: "Code Block",
6366
+ latex: "LaTeX Math",
6367
+ chart: "Data Chart",
6368
+ table: "Table",
6369
+ stats: "Stats",
6370
+ form: "Form Builder",
6371
+ poll: "Poll",
6372
+ quiz: "Quiz",
6373
+ flashcards: "Flashcards",
6374
+ todo: "To-Do List",
6375
+ eisenhower: "Eisenhower Matrix",
6376
+ kanban: "Kanban Board",
6377
+ timer: "Focus Timer",
6378
+ faq: "FAQ",
6379
+ footnotes: "Footnotes",
6380
+ button: "Button",
6381
+ dialogue: "Dialogue Box",
6382
+ slides: "Slides",
6383
+ continueWriting: "Continue Writing",
6384
+ askAi: "Ask AI",
6385
+ settings: "Settings"
6386
+ };
6181
6387
  function attachPopoverCategoryHeaders(container) {
6182
6388
  const applyCategories = () => {
6183
6389
  const popovers = container.querySelectorAll(".ce-popover__items");
@@ -6243,23 +6449,312 @@ function attachPopoverCategoryHeaders(container) {
6243
6449
  return () => observer.disconnect();
6244
6450
  }
6245
6451
 
6246
- // src/components/SettingsModal.tsx
6247
- import { useState } from "react";
6452
+ // src/components/ClassicToolbar.tsx
6453
+ import { useEffect, useRef, useState } from "react";
6248
6454
  import { jsx, jsxs } from "react/jsx-runtime";
6455
+ var INSERT_ITEMS = [
6456
+ { tool: "bento", label: "Bento Grid", category: "Layout" },
6457
+ { tool: "masonry", label: "Masonry Grid", category: "Media" },
6458
+ { tool: "excalidraw", label: "Excalidraw", category: "Media" },
6459
+ { tool: "chart", label: "Data Chart", category: "Data" },
6460
+ { tool: "callout", label: "Callout", category: "Text" },
6461
+ { tool: "spoiler", label: "Spoiler", category: "Layout" },
6462
+ { tool: "dialogue", label: "Dialogue Box", category: "Interactive" },
6463
+ { tool: "scratch", label: "Scratchpad", category: "Text" },
6464
+ { tool: "hotkey", label: "Hotkey", category: "Text" },
6465
+ { tool: "image", label: "Image", category: "Media" },
6466
+ { tool: "upload", label: "File Upload", category: "Media" },
6467
+ { tool: "table", label: "Table", category: "Data" },
6468
+ { tool: "latex", label: "LaTeX Math", category: "Data" },
6469
+ { tool: "tabs", label: "Tabs", category: "Layout" },
6470
+ { tool: "accordion", label: "Accordion", category: "Layout" },
6471
+ { tool: "quiz", label: "Quiz", category: "Interactive" },
6472
+ { tool: "poll", label: "Poll", category: "Interactive" },
6473
+ { tool: "kanban", label: "Kanban Board", category: "Interactive" },
6474
+ { tool: "delimiter", label: "Delimiter", category: "Text" },
6475
+ { tool: "settings", label: "Settings", category: "System" }
6476
+ ];
6477
+ var ClassicToolbar = ({
6478
+ editorRef,
6479
+ onUndo,
6480
+ onRedo,
6481
+ fontFamily,
6482
+ onChangeFontFamily,
6483
+ enabledTools,
6484
+ onOpenSettings
6485
+ }) => {
6486
+ const allowedTools = enabledTools ? new Set(enabledTools) : null;
6487
+ const visibleInsertItems = allowedTools ? INSERT_ITEMS.filter((item) => item.tool === "settings" || allowedTools.has(item.tool)) : INSERT_ITEMS;
6488
+ const [insertOpen, setInsertOpen] = useState(false);
6489
+ const [alignOpen, setAlignOpen] = useState(false);
6490
+ const [blockType, setBlockType] = useState("paragraph");
6491
+ const wrapRef = useRef(null);
6492
+ useEffect(() => {
6493
+ const onOutside = (e) => {
6494
+ if (wrapRef.current && !wrapRef.current.contains(e.target)) {
6495
+ setInsertOpen(false);
6496
+ setAlignOpen(false);
6497
+ }
6498
+ };
6499
+ document.addEventListener("mousedown", onOutside);
6500
+ return () => document.removeEventListener("mousedown", onOutside);
6501
+ }, []);
6502
+ const keepSelection = (e) => {
6503
+ e.preventDefault();
6504
+ };
6505
+ const exec = (cmd, value) => {
6506
+ document.execCommand(cmd, false, value);
6507
+ };
6508
+ const toggleInlineTag = (tagName) => {
6509
+ const sel = window.getSelection();
6510
+ if (!sel || sel.rangeCount === 0) return;
6511
+ const range = sel.getRangeAt(0);
6512
+ if (range.collapsed) return;
6513
+ const existing = (range.commonAncestorContainer.nodeType === Node.ELEMENT_NODE ? range.commonAncestorContainer : range.commonAncestorContainer.parentElement)?.closest(tagName);
6514
+ if (existing && existing.parentNode) {
6515
+ const parent = existing.parentNode;
6516
+ while (existing.firstChild) {
6517
+ parent.insertBefore(existing.firstChild, existing);
6518
+ }
6519
+ parent.removeChild(existing);
6520
+ return;
6521
+ }
6522
+ const el = document.createElement(tagName);
6523
+ el.appendChild(range.extractContents());
6524
+ range.insertNode(el);
6525
+ };
6526
+ const insertBlock = (tool, data = {}) => {
6527
+ const ed = editorRef.current;
6528
+ if (!ed) return;
6529
+ if (tool === "settings") {
6530
+ onOpenSettings();
6531
+ setInsertOpen(false);
6532
+ return;
6533
+ }
6534
+ try {
6535
+ const idx = ed.blocks.getCurrentBlockIndex();
6536
+ const targetIdx = idx >= 0 ? idx + 1 : ed.blocks.getBlocksCount();
6537
+ ed.blocks.insert(tool, data, {}, targetIdx, true);
6538
+ } catch {
6539
+ ed.blocks.insert(tool, data);
6540
+ }
6541
+ setInsertOpen(false);
6542
+ };
6543
+ const handleBlockTypeChange = (next) => {
6544
+ setBlockType(next);
6545
+ if (next === "paragraph") insertBlock("paragraph", { text: "" });
6546
+ else if (next === "h1") insertBlock("h1", { text: "", level: 1 });
6547
+ else if (next === "h2") insertBlock("h2", { text: "", level: 2 });
6548
+ else if (next === "h3") insertBlock("h3", { text: "", level: 3 });
6549
+ else if (next === "quote") insertBlock("quote", { text: "", caption: "" });
6550
+ else if (next === "code") insertBlock("code", { code: "" });
6551
+ };
6552
+ return /* @__PURE__ */ jsxs("div", { ref: wrapRef, className: "ng-classic-toolbar", role: "toolbar", "aria-label": "Formatting toolbar", children: [
6553
+ /* @__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: [
6554
+ /* @__PURE__ */ jsx("path", { d: "M3 7v6h6" }),
6555
+ /* @__PURE__ */ jsx("path", { d: "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13" })
6556
+ ] }) }),
6557
+ /* @__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: [
6558
+ /* @__PURE__ */ jsx("path", { d: "M21 7v6h-6" }),
6559
+ /* @__PURE__ */ jsx("path", { d: "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7" })
6560
+ ] }) }),
6561
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6562
+ /* @__PURE__ */ jsxs(
6563
+ "select",
6564
+ {
6565
+ className: "ng-ct-select",
6566
+ value: blockType,
6567
+ onChange: (e) => handleBlockTypeChange(e.target.value),
6568
+ "aria-label": "Block type",
6569
+ children: [
6570
+ /* @__PURE__ */ jsx("option", { value: "paragraph", children: "Paragraph" }),
6571
+ /* @__PURE__ */ jsx("option", { value: "h1", children: "Heading 1" }),
6572
+ /* @__PURE__ */ jsx("option", { value: "h2", children: "Heading 2" }),
6573
+ /* @__PURE__ */ jsx("option", { value: "h3", children: "Heading 3" }),
6574
+ /* @__PURE__ */ jsx("option", { value: "quote", children: "Quote" }),
6575
+ /* @__PURE__ */ jsx("option", { value: "code", children: "Code" })
6576
+ ]
6577
+ }
6578
+ ),
6579
+ /* @__PURE__ */ jsxs(
6580
+ "select",
6581
+ {
6582
+ className: "ng-ct-select",
6583
+ value: fontFamily,
6584
+ onChange: (e) => onChangeFontFamily(e.target.value),
6585
+ "aria-label": "Font family",
6586
+ children: [
6587
+ /* @__PURE__ */ jsx("option", { value: "sans", children: "Sans" }),
6588
+ /* @__PURE__ */ jsx("option", { value: "serif", children: "Serif" }),
6589
+ /* @__PURE__ */ jsx("option", { value: "mono", children: "Mono" })
6590
+ ]
6591
+ }
6592
+ ),
6593
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6594
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-b", onMouseDown: keepSelection, onClick: () => exec("bold"), title: "Bold", children: "B" }),
6595
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-i", onMouseDown: keepSelection, onClick: () => exec("italic"), title: "Italic", children: "I" }),
6596
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-u", onMouseDown: keepSelection, onClick: () => exec("underline"), title: "Underline", children: "U" }),
6597
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-s", onMouseDown: keepSelection, onClick: () => exec("strikeThrough"), title: "Strikethrough", children: "S" }),
6598
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => toggleInlineTag("code"), title: "Inline Code", children: "<>" }),
6599
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn ng-ct-highlight", onMouseDown: keepSelection, onClick: () => toggleInlineTag("mark"), title: "Highlight", children: "A" }),
6600
+ /* @__PURE__ */ jsx(
6601
+ "button",
6602
+ {
6603
+ type: "button",
6604
+ className: "ng-ct-btn",
6605
+ onMouseDown: keepSelection,
6606
+ onClick: () => {
6607
+ const url = window.prompt("Enter link URL (https://...)");
6608
+ if (url) exec("createLink", url.trim());
6609
+ },
6610
+ title: "Insert Link",
6611
+ children: /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
6612
+ /* @__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" }),
6613
+ /* @__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" })
6614
+ ] })
6615
+ }
6616
+ ),
6617
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("superscript"), title: "Superscript", children: "x\xB2" }),
6618
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("subscript"), title: "Subscript", children: "x\u2082" }),
6619
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => exec("removeFormat"), title: "Clear Formatting", children: "T\u2093" }),
6620
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6621
+ /* @__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: [
6622
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "6", x2: "21", y2: "6" }),
6623
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "12", x2: "21", y2: "12" }),
6624
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "18", x2: "21", y2: "18" }),
6625
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "6", r: "1" }),
6626
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "12", r: "1" }),
6627
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "18", r: "1" })
6628
+ ] }) }),
6629
+ /* @__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: [
6630
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
6631
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
6632
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
6633
+ /* @__PURE__ */ jsx("path", { d: "M4 6h1v4" }),
6634
+ /* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
6635
+ /* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
6636
+ ] }) }),
6637
+ /* @__PURE__ */ jsx("button", { type: "button", className: "ng-ct-btn", onMouseDown: keepSelection, onClick: () => insertBlock("checklist", { items: [] }), title: "Checklist", children: /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6638
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "6", height: "6", rx: "1" }),
6639
+ /* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
6640
+ /* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
6641
+ /* @__PURE__ */ jsx("path", { d: "M13 12h8" }),
6642
+ /* @__PURE__ */ jsx("path", { d: "M13 18h8" })
6643
+ ] }) }),
6644
+ /* @__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: [
6645
+ /* @__PURE__ */ jsx("polyline", { points: "7 8 3 12 7 16" }),
6646
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
6647
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
6648
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
6649
+ ] }) }),
6650
+ /* @__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: [
6651
+ /* @__PURE__ */ jsx("polyline", { points: "3 8 7 12 3 16" }),
6652
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "11", y2: "12" }),
6653
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "6", x2: "11", y2: "6" }),
6654
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "18", x2: "11", y2: "18" })
6655
+ ] }) }),
6656
+ /* @__PURE__ */ jsxs("div", { className: "ng-ct-dropdown-wrap", children: [
6657
+ /* @__PURE__ */ jsxs(
6658
+ "button",
6659
+ {
6660
+ type: "button",
6661
+ className: "ng-ct-btn",
6662
+ onMouseDown: keepSelection,
6663
+ onClick: () => {
6664
+ setAlignOpen((v) => !v);
6665
+ setInsertOpen(false);
6666
+ },
6667
+ title: "Alignment",
6668
+ children: [
6669
+ /* @__PURE__ */ jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6670
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "6", x2: "21", y2: "6" }),
6671
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "12", x2: "15", y2: "12" }),
6672
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "18", x2: "18", y2: "18" })
6673
+ ] }),
6674
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-caret", children: "\u25BE" })
6675
+ ]
6676
+ }
6677
+ ),
6678
+ alignOpen && /* @__PURE__ */ jsxs("div", { className: "ng-ct-menu", children: [
6679
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6680
+ exec("justifyLeft");
6681
+ setAlignOpen(false);
6682
+ }, children: "Align Left" }),
6683
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6684
+ exec("justifyCenter");
6685
+ setAlignOpen(false);
6686
+ }, children: "Align Center" }),
6687
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6688
+ exec("justifyRight");
6689
+ setAlignOpen(false);
6690
+ }, children: "Align Right" }),
6691
+ /* @__PURE__ */ jsx("button", { type: "button", onMouseDown: keepSelection, onClick: () => {
6692
+ exec("justifyFull");
6693
+ setAlignOpen(false);
6694
+ }, children: "Justify" })
6695
+ ] })
6696
+ ] }),
6697
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-sep" }),
6698
+ /* @__PURE__ */ jsxs("div", { className: "ng-ct-dropdown-wrap", children: [
6699
+ /* @__PURE__ */ jsxs(
6700
+ "button",
6701
+ {
6702
+ type: "button",
6703
+ className: "ng-ct-insert-btn",
6704
+ onClick: () => {
6705
+ setInsertOpen((v) => !v);
6706
+ setAlignOpen(false);
6707
+ },
6708
+ children: [
6709
+ /* @__PURE__ */ jsx("span", { children: "+ Insert" }),
6710
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-caret", children: "\u25BE" })
6711
+ ]
6712
+ }
6713
+ ),
6714
+ insertOpen && /* @__PURE__ */ jsx("div", { className: "ng-ct-menu ng-ct-insert-menu", children: visibleInsertItems.map((item) => /* @__PURE__ */ jsxs(
6715
+ "button",
6716
+ {
6717
+ type: "button",
6718
+ onClick: () => insertBlock(item.tool),
6719
+ children: [
6720
+ /* @__PURE__ */ jsx("span", { children: item.label }),
6721
+ /* @__PURE__ */ jsx("span", { className: "ng-ct-cat", children: item.category })
6722
+ ]
6723
+ },
6724
+ item.tool
6725
+ )) })
6726
+ ] })
6727
+ ] });
6728
+ };
6729
+
6730
+ // src/components/SettingsModal.tsx
6731
+ import { useState as useState2 } from "react";
6732
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
6249
6733
  var SettingsModal = ({
6250
6734
  open,
6251
6735
  theme,
6252
6736
  mode,
6253
6737
  showStats,
6254
6738
  aiConfig,
6739
+ selectedTools,
6255
6740
  onChangeTheme,
6256
6741
  onChangeMode,
6257
6742
  onChangeShowStats,
6258
6743
  onChangeAiConfig,
6744
+ onChangeSelectedTools,
6259
6745
  onClose
6260
6746
  }) => {
6261
- const [showKey, setShowKey] = useState(false);
6747
+ const [showKey, setShowKey] = useState2(false);
6748
+ const [toolFilter, setToolFilter] = useState2("");
6262
6749
  if (!open) return null;
6750
+ const selectedSet = new Set(selectedTools);
6751
+ const toggleTool = (tool) => {
6752
+ const next = new Set(selectedTools);
6753
+ if (next.has(tool)) next.delete(tool);
6754
+ else next.add(tool);
6755
+ next.add("settings");
6756
+ onChangeSelectedTools(Array.from(next));
6757
+ };
6263
6758
  const handleProviderChange = (providerId) => {
6264
6759
  const preset = AI_PROVIDER_PRESETS.find((p) => p.id === providerId);
6265
6760
  onChangeAiConfig({
@@ -6269,39 +6764,39 @@ var SettingsModal = ({
6269
6764
  endpoint: preset?.defaultEndpoint || ""
6270
6765
  });
6271
6766
  };
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." })
6767
+ return /* @__PURE__ */ jsx2("div", { className: "ng-modal-backdrop", role: "dialog", "aria-modal": "true", "aria-label": "Editor Settings", children: /* @__PURE__ */ jsxs2("div", { className: "ng-modal", children: [
6768
+ /* @__PURE__ */ jsxs2("div", { className: "ng-modal-head", children: [
6769
+ /* @__PURE__ */ jsxs2("div", { children: [
6770
+ /* @__PURE__ */ jsx2("h3", { children: "Editor Settings" }),
6771
+ /* @__PURE__ */ jsx2("p", { children: "Configure appearance, editor mode, and AI provider." })
6277
6772
  ] }),
6278
- /* @__PURE__ */ jsx("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
6773
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "excalidraw-btn", onClick: onClose, children: "Done" })
6279
6774
  ] }),
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(
6775
+ /* @__PURE__ */ jsxs2("div", { className: "ng-modal-body", children: [
6776
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6777
+ /* @__PURE__ */ jsx2("label", { children: "Theme" }),
6778
+ /* @__PURE__ */ jsxs2(
6284
6779
  "select",
6285
6780
  {
6286
6781
  className: "cdx-input editor-form-select",
6287
6782
  value: theme,
6288
6783
  onChange: (e) => onChangeTheme(e.target.value),
6289
6784
  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" })
6785
+ /* @__PURE__ */ jsx2("option", { value: "inherit", children: "Inherit from Host App" }),
6786
+ /* @__PURE__ */ jsx2("option", { value: "light", children: "shadcn Light" }),
6787
+ /* @__PURE__ */ jsx2("option", { value: "dark", children: "shadcn Dark" }),
6788
+ /* @__PURE__ */ jsx2("option", { value: "catppuccin-mocha", children: "Catppuccin Mocha" }),
6789
+ /* @__PURE__ */ jsx2("option", { value: "catppuccin-macchiato", children: "Catppuccin Macchiato" }),
6790
+ /* @__PURE__ */ jsx2("option", { value: "catppuccin-frappe", children: "Catppuccin Frapp\xE9" }),
6791
+ /* @__PURE__ */ jsx2("option", { value: "catppuccin-latte", children: "Catppuccin Latte" })
6297
6792
  ]
6298
6793
  }
6299
6794
  )
6300
6795
  ] }),
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(
6796
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6797
+ /* @__PURE__ */ jsx2("label", { children: "Editor Mode" }),
6798
+ /* @__PURE__ */ jsxs2("div", { className: "ng-segmented", children: [
6799
+ /* @__PURE__ */ jsx2(
6305
6800
  "button",
6306
6801
  {
6307
6802
  type: "button",
@@ -6310,7 +6805,7 @@ var SettingsModal = ({
6310
6805
  children: "Block Editor (Full)"
6311
6806
  }
6312
6807
  ),
6313
- /* @__PURE__ */ jsx(
6808
+ /* @__PURE__ */ jsx2(
6314
6809
  "button",
6315
6810
  {
6316
6811
  type: "button",
@@ -6321,9 +6816,9 @@ var SettingsModal = ({
6321
6816
  )
6322
6817
  ] })
6323
6818
  ] }),
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(
6819
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field ng-field-inline", children: [
6820
+ /* @__PURE__ */ jsx2("label", { htmlFor: "ng-stats-toggle", children: "Show word count & read time" }),
6821
+ /* @__PURE__ */ jsx2(
6327
6822
  "input",
6328
6823
  {
6329
6824
  id: "ng-stats-toggle",
@@ -6333,22 +6828,22 @@ var SettingsModal = ({
6333
6828
  }
6334
6829
  )
6335
6830
  ] }),
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(
6831
+ /* @__PURE__ */ jsx2("hr", { className: "ng-divider" }),
6832
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6833
+ /* @__PURE__ */ jsx2("label", { children: "AI Provider" }),
6834
+ /* @__PURE__ */ jsx2(
6340
6835
  "select",
6341
6836
  {
6342
6837
  className: "cdx-input editor-form-select",
6343
6838
  value: aiConfig.provider,
6344
6839
  onChange: (e) => handleProviderChange(e.target.value),
6345
- children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ jsx("option", { value: p.id, children: p.label }, p.id))
6840
+ children: AI_PROVIDER_PRESETS.map((p) => /* @__PURE__ */ jsx2("option", { value: p.id, children: p.label }, p.id))
6346
6841
  }
6347
6842
  )
6348
6843
  ] }),
6349
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6350
- /* @__PURE__ */ jsx("label", { children: "Model" }),
6351
- /* @__PURE__ */ jsx(
6844
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6845
+ /* @__PURE__ */ jsx2("label", { children: "Model" }),
6846
+ /* @__PURE__ */ jsx2(
6352
6847
  "input",
6353
6848
  {
6354
6849
  type: "text",
@@ -6359,10 +6854,10 @@ var SettingsModal = ({
6359
6854
  }
6360
6855
  )
6361
6856
  ] }),
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(
6857
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6858
+ /* @__PURE__ */ jsx2("label", { children: "API Key" }),
6859
+ /* @__PURE__ */ jsxs2("div", { className: "ng-key-row", children: [
6860
+ /* @__PURE__ */ jsx2(
6366
6861
  "input",
6367
6862
  {
6368
6863
  type: showKey ? "text" : "password",
@@ -6372,7 +6867,7 @@ var SettingsModal = ({
6372
6867
  onChange: (e) => onChangeAiConfig({ ...aiConfig, apiKey: e.target.value })
6373
6868
  }
6374
6869
  ),
6375
- /* @__PURE__ */ jsx(
6870
+ /* @__PURE__ */ jsx2(
6376
6871
  "button",
6377
6872
  {
6378
6873
  type: "button",
@@ -6383,9 +6878,9 @@ var SettingsModal = ({
6383
6878
  )
6384
6879
  ] })
6385
6880
  ] }),
6386
- /* @__PURE__ */ jsxs("div", { className: "ng-field", children: [
6387
- /* @__PURE__ */ jsx("label", { children: "Endpoint URL (optional)" }),
6388
- /* @__PURE__ */ jsx(
6881
+ /* @__PURE__ */ jsxs2("div", { className: "ng-field", children: [
6882
+ /* @__PURE__ */ jsx2("label", { children: "Endpoint URL (optional)" }),
6883
+ /* @__PURE__ */ jsx2(
6389
6884
  "input",
6390
6885
  {
6391
6886
  type: "url",
@@ -6395,43 +6890,132 @@ var SettingsModal = ({
6395
6890
  onChange: (e) => onChangeAiConfig({ ...aiConfig, endpoint: e.target.value })
6396
6891
  }
6397
6892
  )
6893
+ ] }),
6894
+ /* @__PURE__ */ jsx2("hr", { className: "ng-divider" }),
6895
+ /* @__PURE__ */ jsxs2("div", { className: "ng-tools-manager", children: [
6896
+ /* @__PURE__ */ jsxs2("div", { className: "ng-tools-header", children: [
6897
+ /* @__PURE__ */ jsx2("div", { children: /* @__PURE__ */ jsxs2("label", { children: [
6898
+ "Registered Components (",
6899
+ selectedSet.size,
6900
+ "/",
6901
+ ALL_TOOL_NAMES.length,
6902
+ ")"
6903
+ ] }) }),
6904
+ /* @__PURE__ */ jsxs2("div", { className: "ng-tools-actions", children: [
6905
+ /* @__PURE__ */ jsx2(
6906
+ "button",
6907
+ {
6908
+ type: "button",
6909
+ className: "excalidraw-btn",
6910
+ onClick: () => onChangeSelectedTools([...ALL_TOOL_NAMES]),
6911
+ children: "All"
6912
+ }
6913
+ ),
6914
+ /* @__PURE__ */ jsx2(
6915
+ "button",
6916
+ {
6917
+ type: "button",
6918
+ className: "excalidraw-btn",
6919
+ onClick: () => onChangeSelectedTools([...SIMPLE_MODE_TOOLS]),
6920
+ children: "Minimal"
6921
+ }
6922
+ )
6923
+ ] })
6924
+ ] }),
6925
+ /* @__PURE__ */ jsx2(
6926
+ "input",
6927
+ {
6928
+ type: "search",
6929
+ className: "cdx-input editor-form-input",
6930
+ placeholder: "Filter components (e.g. bento, chart, spoiler...)",
6931
+ value: toolFilter,
6932
+ onChange: (e) => setToolFilter(e.target.value)
6933
+ }
6934
+ ),
6935
+ /* @__PURE__ */ jsx2("div", { className: "ng-tools-groups", children: TOOL_CATEGORIES.filter((g) => g.label !== "Settings").map((group) => {
6936
+ const q = toolFilter.trim().toLowerCase();
6937
+ const visible = group.tools.filter((t) => {
6938
+ const label = (TOOL_LABELS[t] || t).toLowerCase();
6939
+ return !q || label.includes(q) || t.toLowerCase().includes(q);
6940
+ });
6941
+ if (!visible.length) return null;
6942
+ return /* @__PURE__ */ jsxs2("div", { className: "ng-tools-group", children: [
6943
+ /* @__PURE__ */ jsx2("div", { className: "ng-tools-group-title", children: group.label }),
6944
+ /* @__PURE__ */ jsx2("div", { className: "ng-tools-grid", children: visible.map((tool) => {
6945
+ const checked = selectedSet.has(tool);
6946
+ return /* @__PURE__ */ jsxs2(
6947
+ "label",
6948
+ {
6949
+ className: `ng-tool-chip${checked ? " is-checked" : ""}`,
6950
+ children: [
6951
+ /* @__PURE__ */ jsx2(
6952
+ "input",
6953
+ {
6954
+ type: "checkbox",
6955
+ checked,
6956
+ onChange: () => toggleTool(tool)
6957
+ }
6958
+ ),
6959
+ /* @__PURE__ */ jsx2("span", { children: TOOL_LABELS[tool] || tool })
6960
+ ]
6961
+ },
6962
+ tool
6963
+ );
6964
+ }) })
6965
+ ] }, group.label);
6966
+ }) })
6398
6967
  ] })
6399
6968
  ] })
6400
6969
  ] }) });
6401
6970
  };
6402
6971
 
6403
6972
  // src/components/BlockEditor.tsx
6404
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
6405
- var BlockEditor = React3.forwardRef(
6973
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
6974
+ var BlockEditor = React4.forwardRef(
6406
6975
  ({
6407
6976
  initialData,
6408
6977
  placeholder,
6409
6978
  enabledTools,
6410
6979
  showStats = true,
6411
- showAiBar = true,
6980
+ showAiBar = false,
6412
6981
  onAiRequest,
6413
6982
  className,
6414
6983
  onReady,
6415
6984
  onChange
6416
6985
  }, 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(() => {
6986
+ const shellRef = useRef2(null);
6987
+ const holderRef = useRef2(null);
6988
+ const editorRef = useRef2(null);
6989
+ const undoRef = useRef2(null);
6990
+ const lifecycleRef = useRef2(Promise.resolve());
6991
+ const latestDocRef = useRef2(initialData || { blocks: [] });
6992
+ const onChangeRef = useRef2(onChange);
6993
+ const onReadyRef = useRef2(onReady);
6994
+ const runAiRef = useRef2(async () => {
6995
+ });
6996
+ const [settingsOpen, setSettingsOpen] = useState3(false);
6997
+ const [theme, setTheme] = useState3("inherit");
6998
+ const [editorMode, setEditorMode] = useState3("block");
6999
+ const [simpleFont, setSimpleFont] = useState3("sans");
7000
+ const [selectedTools, setSelectedTools] = useState3(() => {
7001
+ if (enabledTools && enabledTools.length > 0) return enabledTools;
7002
+ try {
7003
+ const raw = localStorage.getItem("ng-enabled-tools");
7004
+ if (raw) {
7005
+ const parsed = JSON.parse(raw);
7006
+ if (Array.isArray(parsed) && parsed.length > 0) return parsed;
7007
+ }
7008
+ } catch {
7009
+ }
7010
+ return ALL_TOOL_NAMES;
7011
+ });
7012
+ const [statsVisible, setStatsVisible] = useState3(showStats);
7013
+ const [aiConfig, setAiConfig] = useState3(loadAiConfig);
7014
+ const [askOpen, setAskOpen] = useState3(false);
7015
+ const [askPrompt, setAskPrompt] = useState3("");
7016
+ const [aiBusy, setAiBusy] = useState3(false);
7017
+ const [aiError, setAiError] = useState3(null);
7018
+ const [stats, setStats] = useState3(() => {
6435
7019
  const blocks = initialData?.blocks || [];
6436
7020
  const text = blocks.map((b) => JSON.stringify(b.data || {})).join(" ");
6437
7021
  const words = text.trim() ? text.trim().split(/\s+/).length : 0;
@@ -6439,39 +7023,57 @@ var BlockEditor = React3.forwardRef(
6439
7023
  });
6440
7024
  onChangeRef.current = onChange;
6441
7025
  onReadyRef.current = onReady;
6442
- useEffect(() => {
7026
+ useEffect2(() => {
6443
7027
  setStatsVisible(showStats);
6444
7028
  }, [showStats]);
6445
- useEffect(() => {
7029
+ useEffect2(() => {
6446
7030
  const shell = shellRef.current;
6447
7031
  if (!shell) return;
6448
7032
  const onOpenSettings = () => setSettingsOpen(true);
7033
+ const onAiContinue = () => void runAiRef.current?.("continue");
7034
+ const onAiAsk = () => setAskOpen(true);
6449
7035
  shell.addEventListener("nextgen-open-settings", onOpenSettings);
6450
- return () => shell.removeEventListener("nextgen-open-settings", onOpenSettings);
7036
+ shell.addEventListener("nextgen-ai-continue", onAiContinue);
7037
+ shell.addEventListener("nextgen-ai-ask", onAiAsk);
7038
+ return () => {
7039
+ shell.removeEventListener("nextgen-open-settings", onOpenSettings);
7040
+ shell.removeEventListener("nextgen-ai-continue", onAiContinue);
7041
+ shell.removeEventListener("nextgen-ai-ask", onAiAsk);
7042
+ };
6451
7043
  }, []);
6452
- useEffect(() => {
7044
+ useEffect2(() => {
6453
7045
  const holder = holderRef.current;
6454
7046
  if (!holder) return;
6455
7047
  let cancelled = false;
6456
7048
  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;
7049
+ const detachEmoji = attachEmojiSidePicker(holder);
7050
+ const effectiveTools = Array.from(/* @__PURE__ */ new Set([...selectedTools, "settings"]));
6458
7051
  const mount = async () => {
6459
7052
  await lifecycleRef.current;
6460
7053
  if (cancelled) return;
7054
+ const sanitizedInitial = {
7055
+ ...latestDocRef.current || { blocks: [] },
7056
+ blocks: (latestDocRef.current?.blocks || []).filter(
7057
+ (b) => !["settings", "continueWriting", "askAi"].includes(b.type)
7058
+ )
7059
+ };
7060
+ latestDocRef.current = sanitizedInitial;
6461
7061
  holder.innerHTML = "";
6462
7062
  const instance = new EditorJS2({
6463
7063
  holder,
6464
- data: latestDocRef.current || { blocks: [] },
7064
+ data: sanitizedInitial,
6465
7065
  placeholder: placeholder || "Write your story, or press / to insert blocks...",
6466
7066
  tools: getEditorTools(true, effectiveTools),
6467
7067
  onChange: async () => {
6468
7068
  try {
6469
7069
  const saved = await instance.save();
6470
- const typed = saved;
7070
+ const filteredBlocks = (saved.blocks || []).filter(
7071
+ (b) => !["settings", "continueWriting", "askAi"].includes(b.type)
7072
+ );
7073
+ const typed = { ...saved, blocks: filteredBlocks };
6471
7074
  latestDocRef.current = typed;
6472
- const blocks = saved.blocks || [];
6473
7075
  const words = (holder.innerText || "").trim().split(/\s+/).filter(Boolean).length;
6474
- setStats({ words, blocks: blocks.length });
7076
+ setStats({ words, blocks: filteredBlocks.length });
6475
7077
  onChangeRef.current?.(typed);
6476
7078
  } catch {
6477
7079
  }
@@ -6500,6 +7102,7 @@ var BlockEditor = React3.forwardRef(
6500
7102
  return () => {
6501
7103
  cancelled = true;
6502
7104
  detachCategories();
7105
+ detachEmoji();
6503
7106
  const toDestroy = editorRef.current;
6504
7107
  editorRef.current = null;
6505
7108
  undoRef.current = null;
@@ -6510,13 +7113,16 @@ var BlockEditor = React3.forwardRef(
6510
7113
  });
6511
7114
  }
6512
7115
  };
6513
- }, [editorMode]);
7116
+ }, [editorMode, selectedTools]);
6514
7117
  useImperativeHandle(ref, () => ({
6515
7118
  save: async () => {
6516
7119
  if (!editorRef.current) return null;
6517
7120
  await editorRef.current.isReady;
6518
7121
  const saved = await editorRef.current.save();
6519
- const typed = saved;
7122
+ const filteredBlocks = (saved.blocks || []).filter(
7123
+ (b) => !["settings", "continueWriting", "askAi"].includes(b.type)
7124
+ );
7125
+ const typed = { ...saved, blocks: filteredBlocks };
6520
7126
  latestDocRef.current = typed;
6521
7127
  return typed;
6522
7128
  },
@@ -6569,6 +7175,7 @@ var BlockEditor = React3.forwardRef(
6569
7175
  setAiBusy(false);
6570
7176
  }
6571
7177
  };
7178
+ runAiRef.current = runAi;
6572
7179
  const handleModeSwitch = async (nextMode) => {
6573
7180
  if (nextMode === editorMode) return;
6574
7181
  if (editorRef.current) {
@@ -6582,16 +7189,17 @@ var BlockEditor = React3.forwardRef(
6582
7189
  setEditorMode(nextMode);
6583
7190
  };
6584
7191
  const readMins = Math.max(1, Math.ceil(stats.words / 200));
6585
- return /* @__PURE__ */ jsxs2(
7192
+ return /* @__PURE__ */ jsxs3(
6586
7193
  "div",
6587
7194
  {
6588
7195
  ref: shellRef,
6589
7196
  "data-ng-theme": theme === "inherit" ? void 0 : theme,
7197
+ "data-ng-font": editorMode === "simple" ? simpleFont : void 0,
6590
7198
  className: className ? `nextgen-editor-shell ${className}` : "nextgen-editor-shell",
6591
7199
  children: [
6592
- showAiBar && /* @__PURE__ */ jsxs2("div", { className: "ng-ai-bar", children: [
6593
- /* @__PURE__ */ jsxs2("div", { className: "ng-ai-actions", children: [
6594
- /* @__PURE__ */ jsx2(
7200
+ showAiBar && /* @__PURE__ */ jsxs3("div", { className: "ng-ai-bar", children: [
7201
+ /* @__PURE__ */ jsxs3("div", { className: "ng-ai-actions", children: [
7202
+ /* @__PURE__ */ jsx3(
6595
7203
  "button",
6596
7204
  {
6597
7205
  type: "button",
@@ -6601,7 +7209,7 @@ var BlockEditor = React3.forwardRef(
6601
7209
  children: aiBusy ? "Thinking\u2026" : "\u2726 Continue Writing"
6602
7210
  }
6603
7211
  ),
6604
- /* @__PURE__ */ jsx2(
7212
+ /* @__PURE__ */ jsx3(
6605
7213
  "button",
6606
7214
  {
6607
7215
  type: "button",
@@ -6612,7 +7220,7 @@ var BlockEditor = React3.forwardRef(
6612
7220
  }
6613
7221
  )
6614
7222
  ] }),
6615
- /* @__PURE__ */ jsx2(
7223
+ /* @__PURE__ */ jsx3(
6616
7224
  "button",
6617
7225
  {
6618
7226
  type: "button",
@@ -6623,7 +7231,7 @@ var BlockEditor = React3.forwardRef(
6623
7231
  }
6624
7232
  )
6625
7233
  ] }),
6626
- askOpen && /* @__PURE__ */ jsxs2(
7234
+ askOpen && /* @__PURE__ */ jsxs3(
6627
7235
  "form",
6628
7236
  {
6629
7237
  className: "ng-ask-form",
@@ -6632,7 +7240,7 @@ var BlockEditor = React3.forwardRef(
6632
7240
  if (askPrompt.trim()) void runAi("ask", askPrompt.trim());
6633
7241
  },
6634
7242
  children: [
6635
- /* @__PURE__ */ jsx2(
7243
+ /* @__PURE__ */ jsx3(
6636
7244
  "input",
6637
7245
  {
6638
7246
  type: "text",
@@ -6642,30 +7250,42 @@ var BlockEditor = React3.forwardRef(
6642
7250
  onChange: (e) => setAskPrompt(e.target.value)
6643
7251
  }
6644
7252
  ),
6645
- /* @__PURE__ */ jsx2("button", { type: "submit", className: "editor-form-submit", disabled: aiBusy, children: aiBusy ? "Running\u2026" : "Generate" })
7253
+ /* @__PURE__ */ jsx3("button", { type: "submit", className: "editor-form-submit", disabled: aiBusy, children: aiBusy ? "Running\u2026" : "Generate" })
6646
7254
  ]
6647
7255
  }
6648
7256
  ),
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: [
7257
+ aiError && /* @__PURE__ */ jsx3("div", { className: "ng-ai-error", children: aiError }),
7258
+ editorMode === "simple" && /* @__PURE__ */ jsx3(
7259
+ ClassicToolbar,
7260
+ {
7261
+ editorRef,
7262
+ onUndo: () => undoRef.current?.undo?.(),
7263
+ onRedo: () => undoRef.current?.redo?.(),
7264
+ fontFamily: simpleFont,
7265
+ onChangeFontFamily: setSimpleFont,
7266
+ enabledTools: selectedTools,
7267
+ onOpenSettings: () => setSettingsOpen(true)
7268
+ }
7269
+ ),
7270
+ /* @__PURE__ */ jsx3("div", { id: "editorjs", ref: holderRef }),
7271
+ statsVisible && /* @__PURE__ */ jsxs3("div", { className: "nextgen-editor-stats", children: [
7272
+ /* @__PURE__ */ jsx3("span", { children: editorMode === "simple" ? "Simple Mode" : "Block Editor" }),
7273
+ /* @__PURE__ */ jsx3("span", { children: "\u2022" }),
7274
+ /* @__PURE__ */ jsxs3("span", { children: [
6655
7275
  stats.blocks,
6656
7276
  " blocks"
6657
7277
  ] }),
6658
- /* @__PURE__ */ jsxs2("span", { children: [
7278
+ /* @__PURE__ */ jsxs3("span", { children: [
6659
7279
  stats.words,
6660
7280
  " words"
6661
7281
  ] }),
6662
- /* @__PURE__ */ jsxs2("span", { children: [
7282
+ /* @__PURE__ */ jsxs3("span", { children: [
6663
7283
  "~",
6664
7284
  readMins,
6665
7285
  " min read"
6666
7286
  ] })
6667
7287
  ] }),
6668
- /* @__PURE__ */ jsx2(
7288
+ /* @__PURE__ */ jsx3(
6669
7289
  SettingsModal,
6670
7290
  {
6671
7291
  open: settingsOpen,
@@ -6673,6 +7293,7 @@ var BlockEditor = React3.forwardRef(
6673
7293
  mode: editorMode,
6674
7294
  showStats: statsVisible,
6675
7295
  aiConfig,
7296
+ selectedTools,
6676
7297
  onChangeTheme: setTheme,
6677
7298
  onChangeMode: (m) => void handleModeSwitch(m),
6678
7299
  onChangeShowStats: setStatsVisible,
@@ -6681,6 +7302,13 @@ var BlockEditor = React3.forwardRef(
6681
7302
  saveAiConfig(cfg);
6682
7303
  setAiError(null);
6683
7304
  },
7305
+ onChangeSelectedTools: (tools) => {
7306
+ setSelectedTools(tools);
7307
+ try {
7308
+ localStorage.setItem("ng-enabled-tools", JSON.stringify(tools));
7309
+ } catch {
7310
+ }
7311
+ },
6684
7312
  onClose: () => setSettingsOpen(false)
6685
7313
  }
6686
7314
  )
@@ -6692,13 +7320,13 @@ var BlockEditor = React3.forwardRef(
6692
7320
  BlockEditor.displayName = "BlockEditor";
6693
7321
 
6694
7322
  // src/components/BlockRenderer.tsx
6695
- import { useMemo, useRef as useRef2 } from "react";
7323
+ import { useMemo, useRef as useRef3 } from "react";
6696
7324
 
6697
7325
  // src/hooks/useInteractiveArticle.ts
6698
7326
  import Chart2 from "chart.js/auto";
6699
- import { useEffect as useEffect2 } from "react";
7327
+ import { useEffect as useEffect3 } from "react";
6700
7328
  function useInteractiveArticle(containerRef, depKey) {
6701
- useEffect2(() => {
7329
+ useEffect3(() => {
6702
7330
  const root = containerRef.current;
6703
7331
  if (!root) return;
6704
7332
  const cleanups = [];
@@ -7388,15 +8016,15 @@ function useInteractiveArticle(containerRef, depKey) {
7388
8016
  }
7389
8017
 
7390
8018
  // src/components/BlockRenderer.tsx
7391
- import { jsx as jsx3 } from "react/jsx-runtime";
8019
+ import { jsx as jsx4 } from "react/jsx-runtime";
7392
8020
  var BlockRenderer = ({
7393
8021
  data,
7394
8022
  className
7395
8023
  }) => {
7396
- const bodyRef = useRef2(null);
8024
+ const bodyRef = useRef3(null);
7397
8025
  const html = useMemo(() => blocksToHtml(data), [data]);
7398
8026
  useInteractiveArticle(bodyRef, html);
7399
- return /* @__PURE__ */ jsx3(
8027
+ return /* @__PURE__ */ jsx4(
7400
8028
  "div",
7401
8029
  {
7402
8030
  ref: bodyRef,
@@ -7407,7 +8035,7 @@ var BlockRenderer = ({
7407
8035
  };
7408
8036
 
7409
8037
  // src/components/DocumentHeader.tsx
7410
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
8038
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
7411
8039
  var DocumentHeader = ({
7412
8040
  coverUrl,
7413
8041
  gradient = "linear-gradient(135deg, #27272a 0%, #52525b 100%)",
@@ -7417,12 +8045,12 @@ var DocumentHeader = ({
7417
8045
  className
7418
8046
  }) => {
7419
8047
  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
8048
+ return /* @__PURE__ */ jsxs4("header", { className: className ? `editor-cover-card ${className}` : "editor-cover-card", children: [
8049
+ /* @__PURE__ */ jsx5("div", { className: "editor-cover-banner", style: bannerStyle }),
8050
+ icon ? /* @__PURE__ */ jsx5("div", { className: "editor-cover-icon", children: icon }) : null,
8051
+ /* @__PURE__ */ jsxs4("div", { className: "editor-cover-meta", children: [
8052
+ /* @__PURE__ */ jsx5("h1", { className: "editor-cover-title", children: title }),
8053
+ subtitle ? /* @__PURE__ */ jsx5("p", { className: "editor-cover-subtitle", children: subtitle }) : null
7426
8054
  ] })
7427
8055
  ] });
7428
8056
  };