raydit-editor 0.0.10 → 0.0.12
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 +432 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +415 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -17
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React2, { useState, useRef, useMemo, useEffect } from 'react';
|
|
2
2
|
import { ReactRenderer, useEditor, EditorContent } from '@tiptap/react';
|
|
3
|
+
import { BubbleMenu } from '@tiptap/react/menus';
|
|
3
4
|
import StarterKit from '@tiptap/starter-kit';
|
|
4
5
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
5
|
-
import
|
|
6
|
+
import Underline2 from '@tiptap/extension-underline';
|
|
6
7
|
import { Color } from '@tiptap/extension-color';
|
|
7
8
|
import Highlight from '@tiptap/extension-highlight';
|
|
8
|
-
import
|
|
9
|
+
import Link3 from '@tiptap/extension-link';
|
|
9
10
|
import { TableRow, TableHeader, TableCell, Table as Table$1 } from '@tiptap/extension-table';
|
|
10
11
|
import { TextStyle } from '@tiptap/extension-text-style';
|
|
11
12
|
import Superscript from '@tiptap/extension-superscript';
|
|
@@ -17,7 +18,7 @@ import clsx from 'clsx';
|
|
|
17
18
|
import { Extension } from '@tiptap/core';
|
|
18
19
|
import Suggestion from '@tiptap/suggestion';
|
|
19
20
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
20
|
-
import { Type, Heading1, Heading2, Heading3, List, ListOrdered, Quote, Code, Minus, Table, Link, MoreHorizontal } from 'lucide-react';
|
|
21
|
+
import { Type, Heading1, Heading2, Heading3, List, ListOrdered, Quote, Code, Minus, Table, Link, Bold, Italic, Underline, Strikethrough, Link2, Highlighter, MoreVertical, AlignLeft, AlignCenter, AlignRight, AlignJustify, MoreHorizontal, CheckSquare, Code2 } from 'lucide-react';
|
|
21
22
|
|
|
22
23
|
// src/NotionEditor.tsx
|
|
23
24
|
|
|
@@ -4773,6 +4774,411 @@ var SlashExtension = Extension.create({
|
|
|
4773
4774
|
];
|
|
4774
4775
|
}
|
|
4775
4776
|
});
|
|
4777
|
+
function SelectionToolbar({ editor }) {
|
|
4778
|
+
const [showColors, setShowColors] = useState(false);
|
|
4779
|
+
const [showHighlights, setShowHighlights] = useState(false);
|
|
4780
|
+
const [showTurnInto, setShowTurnInto] = useState(false);
|
|
4781
|
+
const [showMore, setShowMore] = useState(false);
|
|
4782
|
+
useEffect(() => {
|
|
4783
|
+
if (!editor) return;
|
|
4784
|
+
const closeMenu = () => {
|
|
4785
|
+
setShowTurnInto(false);
|
|
4786
|
+
setShowColors(false);
|
|
4787
|
+
setShowHighlights(false);
|
|
4788
|
+
setShowMore(false);
|
|
4789
|
+
};
|
|
4790
|
+
editor.on("selectionUpdate", closeMenu);
|
|
4791
|
+
editor.on("blur", closeMenu);
|
|
4792
|
+
return () => {
|
|
4793
|
+
editor.off("selectionUpdate", closeMenu);
|
|
4794
|
+
editor.off("blur", closeMenu);
|
|
4795
|
+
};
|
|
4796
|
+
}, [editor]);
|
|
4797
|
+
const colors = [
|
|
4798
|
+
{ name: "Default", value: "#000000" },
|
|
4799
|
+
{ name: "Gray", value: "#6B7280" },
|
|
4800
|
+
{ name: "Red", value: "#EF4444" },
|
|
4801
|
+
{ name: "Orange", value: "#F97316" },
|
|
4802
|
+
{ name: "Yellow", value: "#EAB308" },
|
|
4803
|
+
{ name: "Green", value: "#10B981" },
|
|
4804
|
+
{ name: "Blue", value: "#3B82F6" },
|
|
4805
|
+
{ name: "Purple", value: "#8B5CF6" }
|
|
4806
|
+
];
|
|
4807
|
+
const highlights = [
|
|
4808
|
+
{ name: "None", value: "transparent" },
|
|
4809
|
+
{ name: "Gray", value: "#F3F4F6" },
|
|
4810
|
+
{ name: "Red", value: "#FEE2E2" },
|
|
4811
|
+
{ name: "Orange", value: "#FFEDD5" },
|
|
4812
|
+
{ name: "Yellow", value: "#FEF3C7" },
|
|
4813
|
+
{ name: "Green", value: "#D1FAE5" },
|
|
4814
|
+
{ name: "Blue", value: "#DBEAFE" },
|
|
4815
|
+
{ name: "Purple", value: "#EDE9FE" }
|
|
4816
|
+
];
|
|
4817
|
+
const setLink = () => {
|
|
4818
|
+
const previousUrl = editor.getAttributes("link").href;
|
|
4819
|
+
const url = window.prompt("Enter URL:", previousUrl);
|
|
4820
|
+
if (url === null) {
|
|
4821
|
+
return;
|
|
4822
|
+
}
|
|
4823
|
+
if (url === "") {
|
|
4824
|
+
editor.chain().focus().extendMarkRange("link").unsetLink().run();
|
|
4825
|
+
return;
|
|
4826
|
+
}
|
|
4827
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
4828
|
+
};
|
|
4829
|
+
const currentBlockLabel = () => {
|
|
4830
|
+
if (editor.isActive("heading", { level: 1 })) return "Heading 1";
|
|
4831
|
+
if (editor.isActive("heading", { level: 2 })) return "Heading 2";
|
|
4832
|
+
if (editor.isActive("heading", { level: 3 })) return "Heading 3";
|
|
4833
|
+
if (editor.isActive("bulletList")) return "Bulleted list";
|
|
4834
|
+
if (editor.isActive("orderedList")) return "Numbered list";
|
|
4835
|
+
if (editor.isActive("taskList")) return "To-do list";
|
|
4836
|
+
if (editor.isActive("blockquote")) return "Blockquote";
|
|
4837
|
+
if (editor.isActive("codeBlock")) return "Code block";
|
|
4838
|
+
return "Text";
|
|
4839
|
+
};
|
|
4840
|
+
const turnIntoItems = [
|
|
4841
|
+
{
|
|
4842
|
+
label: "Text",
|
|
4843
|
+
icon: /* @__PURE__ */ jsx(Type, { size: 16 }),
|
|
4844
|
+
isActive: () => editor.isActive("paragraph") && !editor.isActive("bulletList") && !editor.isActive("orderedList") && !editor.isActive("taskList"),
|
|
4845
|
+
action: () => {
|
|
4846
|
+
editor.chain().focus().clearNodes().setParagraph().run();
|
|
4847
|
+
}
|
|
4848
|
+
},
|
|
4849
|
+
{
|
|
4850
|
+
label: "Heading 1",
|
|
4851
|
+
icon: /* @__PURE__ */ jsx(Heading1, { size: 16 }),
|
|
4852
|
+
isActive: () => editor.isActive("heading", { level: 1 }),
|
|
4853
|
+
action: () => editor.chain().focus().toggleHeading({ level: 1 }).run()
|
|
4854
|
+
},
|
|
4855
|
+
{
|
|
4856
|
+
label: "Heading 2",
|
|
4857
|
+
icon: /* @__PURE__ */ jsx(Heading2, { size: 16 }),
|
|
4858
|
+
isActive: () => editor.isActive("heading", { level: 2 }),
|
|
4859
|
+
action: () => editor.chain().focus().toggleHeading({ level: 2 }).run()
|
|
4860
|
+
},
|
|
4861
|
+
{
|
|
4862
|
+
label: "Heading 3",
|
|
4863
|
+
icon: /* @__PURE__ */ jsx(Heading3, { size: 16 }),
|
|
4864
|
+
isActive: () => editor.isActive("heading", { level: 3 }),
|
|
4865
|
+
action: () => editor.chain().focus().toggleHeading({ level: 3 }).run()
|
|
4866
|
+
},
|
|
4867
|
+
{
|
|
4868
|
+
label: "To-do list",
|
|
4869
|
+
icon: /* @__PURE__ */ jsx(CheckSquare, { size: 16 }),
|
|
4870
|
+
isActive: () => editor.isActive("taskList"),
|
|
4871
|
+
action: () => {
|
|
4872
|
+
if (editor.isActive("taskList")) {
|
|
4873
|
+
editor.chain().focus().liftListItem("taskItem").run();
|
|
4874
|
+
} else {
|
|
4875
|
+
editor.chain().focus().toggleTaskList().run();
|
|
4876
|
+
}
|
|
4877
|
+
}
|
|
4878
|
+
},
|
|
4879
|
+
{
|
|
4880
|
+
label: "Blockquote",
|
|
4881
|
+
icon: /* @__PURE__ */ jsx(Quote, { size: 16 }),
|
|
4882
|
+
isActive: () => editor.isActive("blockquote"),
|
|
4883
|
+
action: () => editor.chain().focus().toggleBlockquote().run()
|
|
4884
|
+
},
|
|
4885
|
+
{
|
|
4886
|
+
label: "Code block",
|
|
4887
|
+
icon: /* @__PURE__ */ jsx(Code2, { size: 16 }),
|
|
4888
|
+
isActive: () => editor.isActive("codeBlock"),
|
|
4889
|
+
action: () => editor.chain().focus().toggleCodeBlock().run()
|
|
4890
|
+
}
|
|
4891
|
+
];
|
|
4892
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 rounded-lg border border-gray-200 bg-white p-1 shadow-xl", children: [
|
|
4893
|
+
/* @__PURE__ */ jsx(
|
|
4894
|
+
"button",
|
|
4895
|
+
{
|
|
4896
|
+
onClick: () => {
|
|
4897
|
+
if (editor.isActive("bulletList")) {
|
|
4898
|
+
editor.chain().focus().liftListItem("listItem").run();
|
|
4899
|
+
} else {
|
|
4900
|
+
editor.chain().focus().toggleBulletList().run();
|
|
4901
|
+
}
|
|
4902
|
+
},
|
|
4903
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("bulletList") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
4904
|
+
title: "Bullet List",
|
|
4905
|
+
type: "button",
|
|
4906
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4907
|
+
children: /* @__PURE__ */ jsx(List, { size: 16 })
|
|
4908
|
+
}
|
|
4909
|
+
),
|
|
4910
|
+
/* @__PURE__ */ jsx(
|
|
4911
|
+
"button",
|
|
4912
|
+
{
|
|
4913
|
+
onClick: () => {
|
|
4914
|
+
if (editor.isActive("orderedList")) {
|
|
4915
|
+
editor.chain().focus().liftListItem("listItem").run();
|
|
4916
|
+
} else {
|
|
4917
|
+
editor.chain().focus().toggleOrderedList().run();
|
|
4918
|
+
}
|
|
4919
|
+
},
|
|
4920
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("orderedList") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
4921
|
+
title: "Numbered List",
|
|
4922
|
+
type: "button",
|
|
4923
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4924
|
+
children: /* @__PURE__ */ jsx(ListOrdered, { size: 16 })
|
|
4925
|
+
}
|
|
4926
|
+
),
|
|
4927
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
4928
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4929
|
+
/* @__PURE__ */ jsxs(
|
|
4930
|
+
"button",
|
|
4931
|
+
{
|
|
4932
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4933
|
+
onClick: () => setShowTurnInto((v) => !v),
|
|
4934
|
+
className: "rounded-md px-2 py-1 text-sm text-gray-700 hover:bg-gray-100",
|
|
4935
|
+
children: [
|
|
4936
|
+
currentBlockLabel(),
|
|
4937
|
+
" \u25BE"
|
|
4938
|
+
]
|
|
4939
|
+
}
|
|
4940
|
+
),
|
|
4941
|
+
showTurnInto && /* @__PURE__ */ jsxs("div", { className: "absolute left-0 top-full z-50 mt-2 w-52 rounded-lg border bg-white shadow-xl", children: [
|
|
4942
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "Turn into" }),
|
|
4943
|
+
/* @__PURE__ */ jsx("div", { className: "p-1", children: turnIntoItems.map((item) => {
|
|
4944
|
+
const active = item.isActive();
|
|
4945
|
+
return /* @__PURE__ */ jsxs(
|
|
4946
|
+
"button",
|
|
4947
|
+
{
|
|
4948
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4949
|
+
onClick: () => {
|
|
4950
|
+
item.action();
|
|
4951
|
+
setShowTurnInto(false);
|
|
4952
|
+
},
|
|
4953
|
+
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"}`,
|
|
4954
|
+
children: [
|
|
4955
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
|
|
4956
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
4957
|
+
]
|
|
4958
|
+
},
|
|
4959
|
+
item.label
|
|
4960
|
+
);
|
|
4961
|
+
}) })
|
|
4962
|
+
] })
|
|
4963
|
+
] }),
|
|
4964
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
4965
|
+
/* @__PURE__ */ jsx(
|
|
4966
|
+
"button",
|
|
4967
|
+
{
|
|
4968
|
+
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
4969
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("bold") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
4970
|
+
title: "Bold (Ctrl+B)",
|
|
4971
|
+
type: "button",
|
|
4972
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4973
|
+
children: /* @__PURE__ */ jsx(Bold, { size: 16 })
|
|
4974
|
+
}
|
|
4975
|
+
),
|
|
4976
|
+
/* @__PURE__ */ jsx(
|
|
4977
|
+
"button",
|
|
4978
|
+
{
|
|
4979
|
+
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
4980
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("italic") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
4981
|
+
title: "Italic (Ctrl+I)",
|
|
4982
|
+
type: "button",
|
|
4983
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4984
|
+
children: /* @__PURE__ */ jsx(Italic, { size: 16 })
|
|
4985
|
+
}
|
|
4986
|
+
),
|
|
4987
|
+
/* @__PURE__ */ jsx(
|
|
4988
|
+
"button",
|
|
4989
|
+
{
|
|
4990
|
+
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
4991
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("underline") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
4992
|
+
title: "Underline (Ctrl+U)",
|
|
4993
|
+
type: "button",
|
|
4994
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
4995
|
+
children: /* @__PURE__ */ jsx(Underline, { size: 16 })
|
|
4996
|
+
}
|
|
4997
|
+
),
|
|
4998
|
+
/* @__PURE__ */ jsx(
|
|
4999
|
+
"button",
|
|
5000
|
+
{
|
|
5001
|
+
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
5002
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("strike") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
5003
|
+
title: "Strikethrough",
|
|
5004
|
+
type: "button",
|
|
5005
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5006
|
+
children: /* @__PURE__ */ jsx(Strikethrough, { size: 16 })
|
|
5007
|
+
}
|
|
5008
|
+
),
|
|
5009
|
+
/* @__PURE__ */ jsx(
|
|
5010
|
+
"button",
|
|
5011
|
+
{
|
|
5012
|
+
onClick: () => editor.chain().focus().toggleCode().run(),
|
|
5013
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("code") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
5014
|
+
title: "Code",
|
|
5015
|
+
type: "button",
|
|
5016
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5017
|
+
children: /* @__PURE__ */ jsx(Code, { size: 16 })
|
|
5018
|
+
}
|
|
5019
|
+
),
|
|
5020
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
5021
|
+
/* @__PURE__ */ jsx(
|
|
5022
|
+
"button",
|
|
5023
|
+
{
|
|
5024
|
+
onClick: setLink,
|
|
5025
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("link") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
5026
|
+
title: "Add Link",
|
|
5027
|
+
type: "button",
|
|
5028
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5029
|
+
children: /* @__PURE__ */ jsx(Link2, { size: 16 })
|
|
5030
|
+
}
|
|
5031
|
+
),
|
|
5032
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5033
|
+
/* @__PURE__ */ jsx(
|
|
5034
|
+
"button",
|
|
5035
|
+
{
|
|
5036
|
+
onClick: () => {
|
|
5037
|
+
setShowColors(!showColors);
|
|
5038
|
+
setShowHighlights(false);
|
|
5039
|
+
},
|
|
5040
|
+
className: "rounded p-1.5 text-gray-700 transition-colors hover:bg-gray-100",
|
|
5041
|
+
title: "Text Color",
|
|
5042
|
+
type: "button",
|
|
5043
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5044
|
+
children: /* @__PURE__ */ jsx(Type, { size: 16 })
|
|
5045
|
+
}
|
|
5046
|
+
),
|
|
5047
|
+
showColors && /* @__PURE__ */ 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__ */ jsx(
|
|
5048
|
+
"button",
|
|
5049
|
+
{
|
|
5050
|
+
onClick: () => {
|
|
5051
|
+
editor.chain().focus().setMark("textStyle", { color: color.value }).run();
|
|
5052
|
+
setShowColors(false);
|
|
5053
|
+
},
|
|
5054
|
+
className: "h-6 w-6 rounded border border-gray-300 transition-transform hover:scale-110",
|
|
5055
|
+
style: { backgroundColor: color.value },
|
|
5056
|
+
title: color.name,
|
|
5057
|
+
type: "button",
|
|
5058
|
+
onMouseDown: (e) => e.preventDefault()
|
|
5059
|
+
},
|
|
5060
|
+
color.value
|
|
5061
|
+
)) })
|
|
5062
|
+
] }),
|
|
5063
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5064
|
+
/* @__PURE__ */ jsx(
|
|
5065
|
+
"button",
|
|
5066
|
+
{
|
|
5067
|
+
onClick: () => {
|
|
5068
|
+
setShowHighlights(!showHighlights);
|
|
5069
|
+
setShowColors(false);
|
|
5070
|
+
},
|
|
5071
|
+
className: `rounded p-1.5 transition-colors hover:bg-gray-100 ${editor.isActive("highlight") ? "bg-gray-100 text-blue-600" : "text-gray-700"}`,
|
|
5072
|
+
title: "Highlight",
|
|
5073
|
+
type: "button",
|
|
5074
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5075
|
+
children: /* @__PURE__ */ jsx(Highlighter, { size: 16 })
|
|
5076
|
+
}
|
|
5077
|
+
),
|
|
5078
|
+
showHighlights && /* @__PURE__ */ 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__ */ jsx(
|
|
5079
|
+
"button",
|
|
5080
|
+
{
|
|
5081
|
+
onClick: () => {
|
|
5082
|
+
if (highlight.value === "transparent") {
|
|
5083
|
+
editor.chain().focus().unsetMark("highlight").run();
|
|
5084
|
+
} else {
|
|
5085
|
+
editor.chain().focus().setMark("highlight", { color: highlight.value }).run();
|
|
5086
|
+
}
|
|
5087
|
+
setShowHighlights(false);
|
|
5088
|
+
},
|
|
5089
|
+
className: "h-6 w-6 rounded border border-gray-300 transition-transform hover:scale-110",
|
|
5090
|
+
style: { backgroundColor: highlight.value },
|
|
5091
|
+
title: highlight.name,
|
|
5092
|
+
type: "button",
|
|
5093
|
+
onMouseDown: (e) => e.preventDefault()
|
|
5094
|
+
},
|
|
5095
|
+
highlight.value
|
|
5096
|
+
)) })
|
|
5097
|
+
] }),
|
|
5098
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
5099
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
5100
|
+
/* @__PURE__ */ jsx(
|
|
5101
|
+
"button",
|
|
5102
|
+
{
|
|
5103
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5104
|
+
onClick: () => setShowMore((v) => !v),
|
|
5105
|
+
className: "rounded p-1.5 hover:bg-gray-100",
|
|
5106
|
+
children: /* @__PURE__ */ jsx(MoreVertical, { size: 16 })
|
|
5107
|
+
}
|
|
5108
|
+
),
|
|
5109
|
+
showMore && /* @__PURE__ */ jsxs("div", { className: "absolute right-0 top-full z-50 mt-2 w-56 rounded-lg border bg-white shadow-xl", children: [
|
|
5110
|
+
/* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "More" }),
|
|
5111
|
+
/* @__PURE__ */ jsx("div", { className: "p-1", children: [
|
|
5112
|
+
{
|
|
5113
|
+
label: "Align left",
|
|
5114
|
+
icon: /* @__PURE__ */ jsx(AlignLeft, { size: 16 }),
|
|
5115
|
+
isActive: () => editor.isActive({ textAlign: "left" }),
|
|
5116
|
+
action: () => editor.chain().focus().setTextAlign("left").run()
|
|
5117
|
+
},
|
|
5118
|
+
{
|
|
5119
|
+
label: "Align center",
|
|
5120
|
+
icon: /* @__PURE__ */ jsx(AlignCenter, { size: 16 }),
|
|
5121
|
+
isActive: () => editor.isActive({ textAlign: "center" }),
|
|
5122
|
+
action: () => editor.chain().focus().setTextAlign("center").run()
|
|
5123
|
+
},
|
|
5124
|
+
{
|
|
5125
|
+
label: "Align right",
|
|
5126
|
+
icon: /* @__PURE__ */ jsx(AlignRight, { size: 16 }),
|
|
5127
|
+
isActive: () => editor.isActive({ textAlign: "right" }),
|
|
5128
|
+
action: () => editor.chain().focus().setTextAlign("right").run()
|
|
5129
|
+
},
|
|
5130
|
+
{
|
|
5131
|
+
label: "Justify",
|
|
5132
|
+
icon: /* @__PURE__ */ jsx(AlignJustify, { size: 16 }),
|
|
5133
|
+
isActive: () => editor.isActive({ textAlign: "justify" }),
|
|
5134
|
+
action: () => editor.chain().focus().setTextAlign("justify").run()
|
|
5135
|
+
},
|
|
5136
|
+
{ divider: true },
|
|
5137
|
+
{
|
|
5138
|
+
label: "Superscript",
|
|
5139
|
+
icon: /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: "x\xB2" }),
|
|
5140
|
+
isActive: () => editor.isActive("superscript"),
|
|
5141
|
+
action: () => editor.chain().focus().toggleSuperscript().run()
|
|
5142
|
+
},
|
|
5143
|
+
{
|
|
5144
|
+
label: "Subscript",
|
|
5145
|
+
icon: /* @__PURE__ */ jsx("span", { className: "text-sm font-semibold", children: "x\u2082" }),
|
|
5146
|
+
isActive: () => editor.isActive("subscript"),
|
|
5147
|
+
action: () => editor.chain().focus().toggleSubscript().run()
|
|
5148
|
+
}
|
|
5149
|
+
].map((item, index) => {
|
|
5150
|
+
if ("divider" in item) {
|
|
5151
|
+
return /* @__PURE__ */ jsx(
|
|
5152
|
+
"div",
|
|
5153
|
+
{
|
|
5154
|
+
className: "my-1 h-px bg-gray-200"
|
|
5155
|
+
},
|
|
5156
|
+
`divider-${index}`
|
|
5157
|
+
);
|
|
5158
|
+
}
|
|
5159
|
+
const active = item.isActive();
|
|
5160
|
+
return /* @__PURE__ */ jsxs(
|
|
5161
|
+
"button",
|
|
5162
|
+
{
|
|
5163
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
5164
|
+
onClick: () => {
|
|
5165
|
+
item.action();
|
|
5166
|
+
setShowMore(false);
|
|
5167
|
+
},
|
|
5168
|
+
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"}`,
|
|
5169
|
+
children: [
|
|
5170
|
+
/* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
|
|
5171
|
+
/* @__PURE__ */ jsx("span", { children: item.label })
|
|
5172
|
+
]
|
|
5173
|
+
},
|
|
5174
|
+
item.label
|
|
5175
|
+
);
|
|
5176
|
+
}) })
|
|
5177
|
+
] })
|
|
5178
|
+
] })
|
|
5179
|
+
] });
|
|
5180
|
+
}
|
|
5181
|
+
var SelectionToolbar_default = SelectionToolbar;
|
|
4776
5182
|
function useRowHover(editor) {
|
|
4777
5183
|
const [rowEl, setRowEl] = useState(null);
|
|
4778
5184
|
useEffect(() => {
|
|
@@ -4853,7 +5259,7 @@ function MenuItem({
|
|
|
4853
5259
|
);
|
|
4854
5260
|
}
|
|
4855
5261
|
function RowAddButton({ editor, row }) {
|
|
4856
|
-
const [showRowMenu, setShowRowMenu] =
|
|
5262
|
+
const [showRowMenu, setShowRowMenu] = React2.useState(false);
|
|
4857
5263
|
const firstCell = row.querySelector("td, th");
|
|
4858
5264
|
if (!firstCell) return null;
|
|
4859
5265
|
const rect = row.getBoundingClientRect();
|
|
@@ -4982,7 +5388,7 @@ function MenuItem2({
|
|
|
4982
5388
|
);
|
|
4983
5389
|
}
|
|
4984
5390
|
function ColumnAddButton({ editor, table, columnIndex }) {
|
|
4985
|
-
const [showColumnMenu, setShowColumnMenu] =
|
|
5391
|
+
const [showColumnMenu, setShowColumnMenu] = React2.useState(false);
|
|
4986
5392
|
const firstRow = table.querySelector("tr");
|
|
4987
5393
|
if (!firstRow) return null;
|
|
4988
5394
|
const cells = Array.from(firstRow.children);
|
|
@@ -5085,7 +5491,7 @@ var NotionEditor = ({
|
|
|
5085
5491
|
includeChildren: false
|
|
5086
5492
|
}),
|
|
5087
5493
|
SlashExtension,
|
|
5088
|
-
|
|
5494
|
+
Underline2,
|
|
5089
5495
|
TextStyle,
|
|
5090
5496
|
Color,
|
|
5091
5497
|
Superscript,
|
|
@@ -5096,7 +5502,7 @@ var NotionEditor = ({
|
|
|
5096
5502
|
Highlight.configure({
|
|
5097
5503
|
multicolor: true
|
|
5098
5504
|
}),
|
|
5099
|
-
|
|
5505
|
+
Link3.configure({
|
|
5100
5506
|
openOnClick: false,
|
|
5101
5507
|
HTMLAttributes: {
|
|
5102
5508
|
class: "text-blue-600 underline cursor-pointer hover:text-blue-800"
|
|
@@ -5158,6 +5564,7 @@ var NotionEditor = ({
|
|
|
5158
5564
|
const hoveredColumn = useColumnHover(editor);
|
|
5159
5565
|
if (!editor) return null;
|
|
5160
5566
|
return /* @__PURE__ */ jsxs("div", { className: clsx("relative rounded-lg border bg-white", className), children: [
|
|
5567
|
+
showToolbar && /* @__PURE__ */ jsx(BubbleMenu, { editor, children: /* @__PURE__ */ jsx(SelectionToolbar_default, { editor }) }),
|
|
5161
5568
|
showTableControls && editor && hoveredRow && /* @__PURE__ */ jsx(RowAddButton, { editor, row: hoveredRow }),
|
|
5162
5569
|
showTableControls && editor && hoveredColumn && /* @__PURE__ */ jsx(
|
|
5163
5570
|
ColumnAddButton,
|