raydit-editor 0.0.10 → 0.0.11

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,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
3
+ var React2 = require('react');
4
4
  var react = require('@tiptap/react');
5
+ var menus = require('@tiptap/react/menus');
5
6
  var StarterKit = require('@tiptap/starter-kit');
6
7
  var Placeholder = require('@tiptap/extension-placeholder');
7
- var Underline = require('@tiptap/extension-underline');
8
+ var Underline2 = require('@tiptap/extension-underline');
8
9
  var extensionColor = require('@tiptap/extension-color');
9
10
  var Highlight = require('@tiptap/extension-highlight');
10
- var Link2 = require('@tiptap/extension-link');
11
+ var Link3 = require('@tiptap/extension-link');
11
12
  var extensionTable = require('@tiptap/extension-table');
12
13
  var extensionTextStyle = require('@tiptap/extension-text-style');
13
14
  var Superscript = require('@tiptap/extension-superscript');
@@ -23,12 +24,12 @@ var lucideReact = require('lucide-react');
23
24
 
24
25
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
25
26
 
26
- var React__default = /*#__PURE__*/_interopDefault(React);
27
+ var React2__default = /*#__PURE__*/_interopDefault(React2);
27
28
  var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
28
29
  var Placeholder__default = /*#__PURE__*/_interopDefault(Placeholder);
29
- var Underline__default = /*#__PURE__*/_interopDefault(Underline);
30
+ var Underline2__default = /*#__PURE__*/_interopDefault(Underline2);
30
31
  var Highlight__default = /*#__PURE__*/_interopDefault(Highlight);
31
- var Link2__default = /*#__PURE__*/_interopDefault(Link2);
32
+ var Link3__default = /*#__PURE__*/_interopDefault(Link3);
32
33
  var Superscript__default = /*#__PURE__*/_interopDefault(Superscript);
33
34
  var Subscript__default = /*#__PURE__*/_interopDefault(Subscript);
34
35
  var TextAlign__default = /*#__PURE__*/_interopDefault(TextAlign);
@@ -4435,10 +4436,10 @@ tippy.setDefaultProps({
4435
4436
  });
4436
4437
  var tippy_esm_default = tippy;
4437
4438
  function SlashMenu({ items, command }) {
4438
- const [query, setQuery] = React.useState("");
4439
- const [activeIndex, setActiveIndex] = React.useState(0);
4440
- const containerRef = React.useRef(null);
4441
- const filtered = React.useMemo(() => {
4439
+ const [query, setQuery] = React2.useState("");
4440
+ const [activeIndex, setActiveIndex] = React2.useState(0);
4441
+ const containerRef = React2.useRef(null);
4442
+ const filtered = React2.useMemo(() => {
4442
4443
  return items.filter(
4443
4444
  (item) => {
4444
4445
  var _a;
@@ -4446,7 +4447,7 @@ function SlashMenu({ items, command }) {
4446
4447
  }
4447
4448
  );
4448
4449
  }, [items, query]);
4449
- const grouped = React.useMemo(() => {
4450
+ const grouped = React2.useMemo(() => {
4450
4451
  return filtered.reduce((acc, item) => {
4451
4452
  var _a, _b;
4452
4453
  (_b = acc[_a = item.category]) != null ? _b : acc[_a] = [];
@@ -4455,14 +4456,14 @@ function SlashMenu({ items, command }) {
4455
4456
  }, {});
4456
4457
  }, [filtered]);
4457
4458
  const flatItems = Object.values(grouped).flat();
4458
- React.useEffect(() => {
4459
+ React2.useEffect(() => {
4459
4460
  var _a;
4460
4461
  const el = (_a = containerRef.current) == null ? void 0 : _a.querySelector(
4461
4462
  `[data-index="${activeIndex}"]`
4462
4463
  );
4463
4464
  el == null ? void 0 : el.scrollIntoView({ block: "nearest" });
4464
4465
  }, [activeIndex]);
4465
- React.useEffect(() => {
4466
+ React2.useEffect(() => {
4466
4467
  const handler = (e) => {
4467
4468
  if (e.key === "ArrowDown") {
4468
4469
  e.preventDefault();
@@ -4791,9 +4792,414 @@ var SlashExtension = core.Extension.create({
4791
4792
  ];
4792
4793
  }
4793
4794
  });
4795
+ function SelectionToolbar({ editor }) {
4796
+ const [showColors, setShowColors] = React2.useState(false);
4797
+ const [showHighlights, setShowHighlights] = React2.useState(false);
4798
+ const [showTurnInto, setShowTurnInto] = React2.useState(false);
4799
+ const [showMore, setShowMore] = React2.useState(false);
4800
+ React2.useEffect(() => {
4801
+ if (!editor) return;
4802
+ const closeMenu = () => {
4803
+ setShowTurnInto(false);
4804
+ setShowColors(false);
4805
+ setShowHighlights(false);
4806
+ setShowMore(false);
4807
+ };
4808
+ editor.on("selectionUpdate", closeMenu);
4809
+ editor.on("blur", closeMenu);
4810
+ return () => {
4811
+ editor.off("selectionUpdate", closeMenu);
4812
+ editor.off("blur", closeMenu);
4813
+ };
4814
+ }, [editor]);
4815
+ const colors = [
4816
+ { name: "Default", value: "#000000" },
4817
+ { name: "Gray", value: "#6B7280" },
4818
+ { name: "Red", value: "#EF4444" },
4819
+ { name: "Orange", value: "#F97316" },
4820
+ { name: "Yellow", value: "#EAB308" },
4821
+ { name: "Green", value: "#10B981" },
4822
+ { name: "Blue", value: "#3B82F6" },
4823
+ { name: "Purple", value: "#8B5CF6" }
4824
+ ];
4825
+ const highlights = [
4826
+ { name: "None", value: "transparent" },
4827
+ { name: "Gray", value: "#F3F4F6" },
4828
+ { name: "Red", value: "#FEE2E2" },
4829
+ { name: "Orange", value: "#FFEDD5" },
4830
+ { name: "Yellow", value: "#FEF3C7" },
4831
+ { name: "Green", value: "#D1FAE5" },
4832
+ { name: "Blue", value: "#DBEAFE" },
4833
+ { name: "Purple", value: "#EDE9FE" }
4834
+ ];
4835
+ const setLink = () => {
4836
+ const previousUrl = editor.getAttributes("link").href;
4837
+ const url = window.prompt("Enter URL:", previousUrl);
4838
+ if (url === null) {
4839
+ return;
4840
+ }
4841
+ if (url === "") {
4842
+ editor.chain().focus().extendMarkRange("link").unsetLink().run();
4843
+ return;
4844
+ }
4845
+ editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
4846
+ };
4847
+ const currentBlockLabel = () => {
4848
+ if (editor.isActive("heading", { level: 1 })) return "Heading 1";
4849
+ if (editor.isActive("heading", { level: 2 })) return "Heading 2";
4850
+ if (editor.isActive("heading", { level: 3 })) return "Heading 3";
4851
+ if (editor.isActive("bulletList")) return "Bulleted list";
4852
+ if (editor.isActive("orderedList")) return "Numbered list";
4853
+ if (editor.isActive("taskList")) return "To-do list";
4854
+ if (editor.isActive("blockquote")) return "Blockquote";
4855
+ if (editor.isActive("codeBlock")) return "Code block";
4856
+ return "Text";
4857
+ };
4858
+ const turnIntoItems = [
4859
+ {
4860
+ label: "Text",
4861
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Type, { size: 16 }),
4862
+ isActive: () => editor.isActive("paragraph") && !editor.isActive("bulletList") && !editor.isActive("orderedList") && !editor.isActive("taskList"),
4863
+ action: () => {
4864
+ editor.chain().focus().clearNodes().setParagraph().run();
4865
+ }
4866
+ },
4867
+ {
4868
+ label: "Heading 1",
4869
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading1, { size: 16 }),
4870
+ isActive: () => editor.isActive("heading", { level: 1 }),
4871
+ action: () => editor.chain().focus().toggleHeading({ level: 1 }).run()
4872
+ },
4873
+ {
4874
+ label: "Heading 2",
4875
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading2, { size: 16 }),
4876
+ isActive: () => editor.isActive("heading", { level: 2 }),
4877
+ action: () => editor.chain().focus().toggleHeading({ level: 2 }).run()
4878
+ },
4879
+ {
4880
+ label: "Heading 3",
4881
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Heading3, { size: 16 }),
4882
+ isActive: () => editor.isActive("heading", { level: 3 }),
4883
+ action: () => editor.chain().focus().toggleHeading({ level: 3 }).run()
4884
+ },
4885
+ {
4886
+ label: "To-do list",
4887
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckSquare, { size: 16 }),
4888
+ isActive: () => editor.isActive("taskList"),
4889
+ action: () => {
4890
+ if (editor.isActive("taskList")) {
4891
+ editor.chain().focus().liftListItem("taskItem").run();
4892
+ } else {
4893
+ editor.chain().focus().toggleTaskList().run();
4894
+ }
4895
+ }
4896
+ },
4897
+ {
4898
+ label: "Blockquote",
4899
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Quote, { size: 16 }),
4900
+ isActive: () => editor.isActive("blockquote"),
4901
+ action: () => editor.chain().focus().toggleBlockquote().run()
4902
+ },
4903
+ {
4904
+ label: "Code block",
4905
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code2, { size: 16 }),
4906
+ isActive: () => editor.isActive("codeBlock"),
4907
+ action: () => editor.chain().focus().toggleCodeBlock().run()
4908
+ }
4909
+ ];
4910
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 rounded-lg border border-gray-200 bg-white p-1 shadow-xl", children: [
4911
+ /* @__PURE__ */ jsxRuntime.jsx(
4912
+ "button",
4913
+ {
4914
+ onClick: () => {
4915
+ if (editor.isActive("bulletList")) {
4916
+ editor.chain().focus().liftListItem("listItem").run();
4917
+ } else {
4918
+ editor.chain().focus().toggleBulletList().run();
4919
+ }
4920
+ },
4921
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("bulletList") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
4922
+ title: "Bullet List",
4923
+ type: "button",
4924
+ onMouseDown: (e) => e.preventDefault(),
4925
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.List, { size: 16 })
4926
+ }
4927
+ ),
4928
+ /* @__PURE__ */ jsxRuntime.jsx(
4929
+ "button",
4930
+ {
4931
+ onClick: () => {
4932
+ if (editor.isActive("orderedList")) {
4933
+ editor.chain().focus().liftListItem("listItem").run();
4934
+ } else {
4935
+ editor.chain().focus().toggleOrderedList().run();
4936
+ }
4937
+ },
4938
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("orderedList") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
4939
+ title: "Numbered List",
4940
+ type: "button",
4941
+ onMouseDown: (e) => e.preventDefault(),
4942
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ListOrdered, { size: 16 })
4943
+ }
4944
+ ),
4945
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
4946
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
4947
+ /* @__PURE__ */ jsxRuntime.jsxs(
4948
+ "button",
4949
+ {
4950
+ onMouseDown: (e) => e.preventDefault(),
4951
+ onClick: () => setShowTurnInto((v) => !v),
4952
+ className: "rounded-md px-2 py-1 text-sm text-gray-700 hover:bg-gray-100",
4953
+ children: [
4954
+ currentBlockLabel(),
4955
+ " \u25BE"
4956
+ ]
4957
+ }
4958
+ ),
4959
+ showTurnInto && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute left-0 top-full z-50 mt-2 w-52 rounded-lg border bg-white shadow-xl", children: [
4960
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "Turn into" }),
4961
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-1", children: turnIntoItems.map((item) => {
4962
+ const active = item.isActive();
4963
+ return /* @__PURE__ */ jsxRuntime.jsxs(
4964
+ "button",
4965
+ {
4966
+ onMouseDown: (e) => e.preventDefault(),
4967
+ onClick: () => {
4968
+ item.action();
4969
+ setShowTurnInto(false);
4970
+ },
4971
+ className: `flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors ${active ? "bg-gray-100 text-blue-600" : "text-gray-700 hover:bg-gray-100"}`,
4972
+ children: [
4973
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
4974
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
4975
+ ]
4976
+ },
4977
+ item.label
4978
+ );
4979
+ }) })
4980
+ ] })
4981
+ ] }),
4982
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
4983
+ /* @__PURE__ */ jsxRuntime.jsx(
4984
+ "button",
4985
+ {
4986
+ onClick: () => editor.chain().focus().toggleBold().run(),
4987
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("bold") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
4988
+ title: "Bold (Ctrl+B)",
4989
+ type: "button",
4990
+ onMouseDown: (e) => e.preventDefault(),
4991
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bold, { size: 16 })
4992
+ }
4993
+ ),
4994
+ /* @__PURE__ */ jsxRuntime.jsx(
4995
+ "button",
4996
+ {
4997
+ onClick: () => editor.chain().focus().toggleItalic().run(),
4998
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("italic") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
4999
+ title: "Italic (Ctrl+I)",
5000
+ type: "button",
5001
+ onMouseDown: (e) => e.preventDefault(),
5002
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Italic, { size: 16 })
5003
+ }
5004
+ ),
5005
+ /* @__PURE__ */ jsxRuntime.jsx(
5006
+ "button",
5007
+ {
5008
+ onClick: () => editor.chain().focus().toggleUnderline().run(),
5009
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("underline") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
5010
+ title: "Underline (Ctrl+U)",
5011
+ type: "button",
5012
+ onMouseDown: (e) => e.preventDefault(),
5013
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Underline, { size: 16 })
5014
+ }
5015
+ ),
5016
+ /* @__PURE__ */ jsxRuntime.jsx(
5017
+ "button",
5018
+ {
5019
+ onClick: () => editor.chain().focus().toggleStrike().run(),
5020
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("strike") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
5021
+ title: "Strikethrough",
5022
+ type: "button",
5023
+ onMouseDown: (e) => e.preventDefault(),
5024
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Strikethrough, { size: 16 })
5025
+ }
5026
+ ),
5027
+ /* @__PURE__ */ jsxRuntime.jsx(
5028
+ "button",
5029
+ {
5030
+ onClick: () => editor.chain().focus().toggleCode().run(),
5031
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("code") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
5032
+ title: "Code",
5033
+ type: "button",
5034
+ onMouseDown: (e) => e.preventDefault(),
5035
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Code, { size: 16 })
5036
+ }
5037
+ ),
5038
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
5039
+ /* @__PURE__ */ jsxRuntime.jsx(
5040
+ "button",
5041
+ {
5042
+ onClick: setLink,
5043
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("link") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
5044
+ title: "Add Link",
5045
+ type: "button",
5046
+ onMouseDown: (e) => e.preventDefault(),
5047
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Link2, { size: 16 })
5048
+ }
5049
+ ),
5050
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5051
+ /* @__PURE__ */ jsxRuntime.jsx(
5052
+ "button",
5053
+ {
5054
+ onClick: () => {
5055
+ setShowColors(!showColors);
5056
+ setShowHighlights(false);
5057
+ },
5058
+ className: "rounded p-1.5 text-gray-700 transition-colors hover:bg-gray-100",
5059
+ title: "Text Color",
5060
+ type: "button",
5061
+ onMouseDown: (e) => e.preventDefault(),
5062
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Type, { size: 16 })
5063
+ }
5064
+ ),
5065
+ showColors && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-0 top-full z-50 mt-2 flex gap-1 rounded-lg border bg-white p-2 shadow-xl", children: colors.map((color) => /* @__PURE__ */ jsxRuntime.jsx(
5066
+ "button",
5067
+ {
5068
+ onClick: () => {
5069
+ editor.chain().focus().setMark("textStyle", { color: color.value }).run();
5070
+ setShowColors(false);
5071
+ },
5072
+ className: "h-6 w-6 rounded border border-gray-300 transition-transform hover:scale-110",
5073
+ style: { backgroundColor: color.value },
5074
+ title: color.name,
5075
+ type: "button",
5076
+ onMouseDown: (e) => e.preventDefault()
5077
+ },
5078
+ color.value
5079
+ )) })
5080
+ ] }),
5081
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5082
+ /* @__PURE__ */ jsxRuntime.jsx(
5083
+ "button",
5084
+ {
5085
+ onClick: () => {
5086
+ setShowHighlights(!showHighlights);
5087
+ setShowColors(false);
5088
+ },
5089
+ className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("highlight") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
5090
+ title: "Highlight",
5091
+ type: "button",
5092
+ onMouseDown: (e) => e.preventDefault(),
5093
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Highlighter, { size: 16 })
5094
+ }
5095
+ ),
5096
+ showHighlights && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-0 top-full z-50 mt-2 flex gap-1 rounded-lg border bg-white p-2 shadow-xl", children: highlights.map((highlight) => /* @__PURE__ */ jsxRuntime.jsx(
5097
+ "button",
5098
+ {
5099
+ onClick: () => {
5100
+ if (highlight.value === "transparent") {
5101
+ editor.chain().focus().unsetMark("highlight").run();
5102
+ } else {
5103
+ editor.chain().focus().setMark("highlight", { color: highlight.value }).run();
5104
+ }
5105
+ setShowHighlights(false);
5106
+ },
5107
+ className: "h-6 w-6 rounded border border-gray-300 transition-transform hover:scale-110",
5108
+ style: { backgroundColor: highlight.value },
5109
+ title: highlight.name,
5110
+ type: "button",
5111
+ onMouseDown: (e) => e.preventDefault()
5112
+ },
5113
+ highlight.value
5114
+ )) })
5115
+ ] }),
5116
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
5117
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
5118
+ /* @__PURE__ */ jsxRuntime.jsx(
5119
+ "button",
5120
+ {
5121
+ onMouseDown: (e) => e.preventDefault(),
5122
+ onClick: () => setShowMore((v) => !v),
5123
+ className: "rounded p-1.5 hover:bg-gray-100",
5124
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreVertical, { size: 16 })
5125
+ }
5126
+ ),
5127
+ showMore && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute right-0 top-full z-50 mt-2 w-56 rounded-lg border bg-white shadow-xl", children: [
5128
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "More" }),
5129
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-1", children: [
5130
+ {
5131
+ label: "Align left",
5132
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignLeft, { size: 16 }),
5133
+ isActive: () => editor.isActive({ textAlign: "left" }),
5134
+ action: () => editor.chain().focus().setTextAlign("left").run()
5135
+ },
5136
+ {
5137
+ label: "Align center",
5138
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignCenter, { size: 16 }),
5139
+ isActive: () => editor.isActive({ textAlign: "center" }),
5140
+ action: () => editor.chain().focus().setTextAlign("center").run()
5141
+ },
5142
+ {
5143
+ label: "Align right",
5144
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignRight, { size: 16 }),
5145
+ isActive: () => editor.isActive({ textAlign: "right" }),
5146
+ action: () => editor.chain().focus().setTextAlign("right").run()
5147
+ },
5148
+ {
5149
+ label: "Justify",
5150
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignJustify, { size: 16 }),
5151
+ isActive: () => editor.isActive({ textAlign: "justify" }),
5152
+ action: () => editor.chain().focus().setTextAlign("justify").run()
5153
+ },
5154
+ { divider: true },
5155
+ {
5156
+ label: "Superscript",
5157
+ icon: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "x\xB2" }),
5158
+ isActive: () => editor.isActive("superscript"),
5159
+ action: () => editor.chain().focus().toggleSuperscript().run()
5160
+ },
5161
+ {
5162
+ label: "Subscript",
5163
+ icon: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "x\u2082" }),
5164
+ isActive: () => editor.isActive("subscript"),
5165
+ action: () => editor.chain().focus().toggleSubscript().run()
5166
+ }
5167
+ ].map((item, index) => {
5168
+ if ("divider" in item) {
5169
+ return /* @__PURE__ */ jsxRuntime.jsx(
5170
+ "div",
5171
+ {
5172
+ className: "my-1 h-px bg-gray-200"
5173
+ },
5174
+ `divider-${index}`
5175
+ );
5176
+ }
5177
+ const active = item.isActive();
5178
+ return /* @__PURE__ */ jsxRuntime.jsxs(
5179
+ "button",
5180
+ {
5181
+ onMouseDown: (e) => e.preventDefault(),
5182
+ onClick: () => {
5183
+ item.action();
5184
+ setShowMore(false);
5185
+ },
5186
+ className: `flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors ${active ? "bg-gray-100 text-blue-600" : "text-gray-700 hover:bg-gray-100"}`,
5187
+ children: [
5188
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
5189
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
5190
+ ]
5191
+ },
5192
+ item.label
5193
+ );
5194
+ }) })
5195
+ ] })
5196
+ ] })
5197
+ ] });
5198
+ }
5199
+ var SelectionToolbar_default = SelectionToolbar;
4794
5200
  function useRowHover(editor) {
4795
- const [rowEl, setRowEl] = React.useState(null);
4796
- React.useEffect(() => {
5201
+ const [rowEl, setRowEl] = React2.useState(null);
5202
+ React2.useEffect(() => {
4797
5203
  if (!editor) return;
4798
5204
  const root = editor.view.dom;
4799
5205
  const onMouseMove = (e) => {
@@ -4871,7 +5277,7 @@ function MenuItem({
4871
5277
  );
4872
5278
  }
4873
5279
  function RowAddButton({ editor, row }) {
4874
- const [showRowMenu, setShowRowMenu] = React__default.default.useState(false);
5280
+ const [showRowMenu, setShowRowMenu] = React2__default.default.useState(false);
4875
5281
  const firstCell = row.querySelector("td, th");
4876
5282
  if (!firstCell) return null;
4877
5283
  const rect = row.getBoundingClientRect();
@@ -4915,8 +5321,8 @@ function RowAddButton({ editor, row }) {
4915
5321
  ] });
4916
5322
  }
4917
5323
  function useColumnHover(editor) {
4918
- const [hovered, setHovered] = React.useState(null);
4919
- React.useEffect(() => {
5324
+ const [hovered, setHovered] = React2.useState(null);
5325
+ React2.useEffect(() => {
4920
5326
  if (!editor) return;
4921
5327
  const root = editor.view.dom;
4922
5328
  const onMouseMove = (e) => {
@@ -5000,7 +5406,7 @@ function MenuItem2({
5000
5406
  );
5001
5407
  }
5002
5408
  function ColumnAddButton({ editor, table, columnIndex }) {
5003
- const [showColumnMenu, setShowColumnMenu] = React__default.default.useState(false);
5409
+ const [showColumnMenu, setShowColumnMenu] = React2__default.default.useState(false);
5004
5410
  const firstRow = table.querySelector("tr");
5005
5411
  if (!firstRow) return null;
5006
5412
  const cells = Array.from(firstRow.children);
@@ -5084,8 +5490,8 @@ var NotionEditor = ({
5084
5490
  showToolbar = true,
5085
5491
  showTableControls = true
5086
5492
  }) => {
5087
- const lastSavedRef = React.useRef("");
5088
- const isDirtyRef = React.useRef(false);
5493
+ const lastSavedRef = React2.useRef("");
5494
+ const isDirtyRef = React2.useRef(false);
5089
5495
  console.log("demo", 233232362);
5090
5496
  const editor = react.useEditor({
5091
5497
  autofocus: autoFocus,
@@ -5103,7 +5509,7 @@ var NotionEditor = ({
5103
5509
  includeChildren: false
5104
5510
  }),
5105
5511
  SlashExtension,
5106
- Underline__default.default,
5512
+ Underline2__default.default,
5107
5513
  extensionTextStyle.TextStyle,
5108
5514
  extensionColor.Color,
5109
5515
  Superscript__default.default,
@@ -5114,7 +5520,7 @@ var NotionEditor = ({
5114
5520
  Highlight__default.default.configure({
5115
5521
  multicolor: true
5116
5522
  }),
5117
- Link2__default.default.configure({
5523
+ Link3__default.default.configure({
5118
5524
  openOnClick: false,
5119
5525
  HTMLAttributes: {
5120
5526
  class: "text-blue-600 underline cursor-pointer hover:text-blue-800"
@@ -5162,20 +5568,21 @@ var NotionEditor = ({
5162
5568
  });
5163
5569
  }
5164
5570
  });
5165
- React.useEffect(() => {
5571
+ React2.useEffect(() => {
5166
5572
  if (!editor) return;
5167
5573
  const currentHTML = editor.getHTML();
5168
5574
  if (content !== void 0 && content !== currentHTML) {
5169
5575
  editor.commands.setContent(content || "");
5170
5576
  }
5171
5577
  }, [content, editor]);
5172
- React.useEffect(() => {
5578
+ React2.useEffect(() => {
5173
5579
  editor == null ? void 0 : editor.setEditable(!disabled);
5174
5580
  }, [disabled, editor]);
5175
5581
  const hoveredRow = useRowHover(editor);
5176
5582
  const hoveredColumn = useColumnHover(editor);
5177
5583
  if (!editor) return null;
5178
5584
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: clsx__default.default("relative rounded-lg border bg-white", className), children: [
5585
+ showToolbar && /* @__PURE__ */ jsxRuntime.jsx(menus.BubbleMenu, { editor, children: /* @__PURE__ */ jsxRuntime.jsx(SelectionToolbar_default, { editor }) }),
5179
5586
  showTableControls && editor && hoveredRow && /* @__PURE__ */ jsxRuntime.jsx(RowAddButton, { editor, row: hoveredRow }),
5180
5587
  showTableControls && editor && hoveredColumn && /* @__PURE__ */ jsxRuntime.jsx(
5181
5588
  ColumnAddButton,