raydit-editor 0.0.1 → 0.0.3
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 +227 -229
- package/dist/index.js.map +1 -1
- package/dist/{index.cjs → index.mjs} +230 -228
- package/dist/index.mjs.map +1 -0
- package/package.json +20 -22
- package/dist/index.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
NotionEditor: () => NotionEditor_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
|
|
1
37
|
// src/NotionEditor.tsx
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import TaskList from "@tiptap/extension-task-list";
|
|
20
|
-
import TaskItem from "@tiptap/extension-task-item";
|
|
21
|
-
import { BubbleMenu } from "@tiptap/react/menus";
|
|
22
|
-
import { useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
23
|
-
import clsx from "clsx";
|
|
38
|
+
var import_react8 = require("@tiptap/react");
|
|
39
|
+
var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
|
|
40
|
+
var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
|
|
41
|
+
var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
|
|
42
|
+
var import_extension_color = require("@tiptap/extension-color");
|
|
43
|
+
var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
|
|
44
|
+
var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
|
|
45
|
+
var import_extension_table = require("@tiptap/extension-table");
|
|
46
|
+
var import_extension_text_style = require("@tiptap/extension-text-style");
|
|
47
|
+
var import_extension_superscript = __toESM(require("@tiptap/extension-superscript"), 1);
|
|
48
|
+
var import_extension_subscript = __toESM(require("@tiptap/extension-subscript"), 1);
|
|
49
|
+
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"), 1);
|
|
50
|
+
var import_extension_task_list = __toESM(require("@tiptap/extension-task-list"), 1);
|
|
51
|
+
var import_extension_task_item = __toESM(require("@tiptap/extension-task-item"), 1);
|
|
52
|
+
var import_menus = require("@tiptap/react/menus");
|
|
53
|
+
var import_react9 = require("react");
|
|
54
|
+
var import_clsx = __toESM(require("clsx"), 1);
|
|
24
55
|
|
|
25
56
|
// src/slash/SlashExtension.ts
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
57
|
+
var import_core2 = require("@tiptap/core");
|
|
58
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"), 1);
|
|
59
|
+
var import_react2 = require("@tiptap/react");
|
|
29
60
|
|
|
30
61
|
// node_modules/prosemirror-model/dist/index.js
|
|
31
62
|
function findDiffStart(a, b, pos) {
|
|
@@ -5803,13 +5834,13 @@ tippy.setDefaultProps({
|
|
|
5803
5834
|
var tippy_esm_default = tippy;
|
|
5804
5835
|
|
|
5805
5836
|
// src/slash/SlashMenu.tsx
|
|
5806
|
-
|
|
5807
|
-
|
|
5837
|
+
var import_react = require("react");
|
|
5838
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
5808
5839
|
function SlashMenu({ items, command }) {
|
|
5809
|
-
const [query, setQuery] = useState("");
|
|
5810
|
-
const [activeIndex, setActiveIndex] = useState(0);
|
|
5811
|
-
const containerRef = useRef(null);
|
|
5812
|
-
const filtered = useMemo(() => {
|
|
5840
|
+
const [query, setQuery] = (0, import_react.useState)("");
|
|
5841
|
+
const [activeIndex, setActiveIndex] = (0, import_react.useState)(0);
|
|
5842
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
5843
|
+
const filtered = (0, import_react.useMemo)(() => {
|
|
5813
5844
|
return items.filter(
|
|
5814
5845
|
(item) => {
|
|
5815
5846
|
var _a;
|
|
@@ -5817,7 +5848,7 @@ function SlashMenu({ items, command }) {
|
|
|
5817
5848
|
}
|
|
5818
5849
|
);
|
|
5819
5850
|
}, [items, query]);
|
|
5820
|
-
const grouped = useMemo(() => {
|
|
5851
|
+
const grouped = (0, import_react.useMemo)(() => {
|
|
5821
5852
|
return filtered.reduce((acc, item) => {
|
|
5822
5853
|
var _a, _b;
|
|
5823
5854
|
(_b = acc[_a = item.category]) != null ? _b : acc[_a] = [];
|
|
@@ -5826,14 +5857,14 @@ function SlashMenu({ items, command }) {
|
|
|
5826
5857
|
}, {});
|
|
5827
5858
|
}, [filtered]);
|
|
5828
5859
|
const flatItems = Object.values(grouped).flat();
|
|
5829
|
-
useEffect(() => {
|
|
5860
|
+
(0, import_react.useEffect)(() => {
|
|
5830
5861
|
var _a;
|
|
5831
5862
|
const el = (_a = containerRef.current) == null ? void 0 : _a.querySelector(
|
|
5832
5863
|
`[data-index="${activeIndex}"]`
|
|
5833
5864
|
);
|
|
5834
5865
|
el == null ? void 0 : el.scrollIntoView({ block: "nearest" });
|
|
5835
5866
|
}, [activeIndex]);
|
|
5836
|
-
useEffect(() => {
|
|
5867
|
+
(0, import_react.useEffect)(() => {
|
|
5837
5868
|
const handler = (e) => {
|
|
5838
5869
|
if (e.key === "ArrowDown") {
|
|
5839
5870
|
e.preventDefault();
|
|
@@ -5853,27 +5884,27 @@ function SlashMenu({ items, command }) {
|
|
|
5853
5884
|
return () => window.removeEventListener("keydown", handler);
|
|
5854
5885
|
}, [flatItems, activeIndex, command]);
|
|
5855
5886
|
let globalIndex = -1;
|
|
5856
|
-
return /* @__PURE__ */ jsx("div", { className: "w-80 rounded-xl border bg-white shadow-2xl dark:bg-black", children: /* @__PURE__ */ jsx(
|
|
5887
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "w-80 rounded-xl border bg-white shadow-2xl dark:bg-black", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
5857
5888
|
"div",
|
|
5858
5889
|
{
|
|
5859
5890
|
ref: containerRef,
|
|
5860
5891
|
className: "max-h-[360px] overflow-y-auto p-2",
|
|
5861
|
-
children: Object.entries(grouped).map(([category, commands]) => /* @__PURE__ */ jsxs("div", { children: [
|
|
5862
|
-
/* @__PURE__ */ jsx("div", { className: "px-2 py-1 text-xs font-semibold text-gray-500 dark:text-gray-800", children: category }),
|
|
5892
|
+
children: Object.entries(grouped).map(([category, commands]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
5893
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-2 py-1 text-xs font-semibold text-gray-500 dark:text-gray-800", children: category }),
|
|
5863
5894
|
commands.map((item) => {
|
|
5864
5895
|
globalIndex += 1;
|
|
5865
5896
|
const isActive = globalIndex === activeIndex;
|
|
5866
|
-
return /* @__PURE__ */ jsxs(
|
|
5897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
5867
5898
|
"button",
|
|
5868
5899
|
{
|
|
5869
5900
|
"data-index": globalIndex,
|
|
5870
5901
|
onClick: () => command(item),
|
|
5871
5902
|
className: `flex w-full items-center gap-3 rounded-md px-3 py-2 text-left ${isActive ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
5872
5903
|
children: [
|
|
5873
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-500", children: item.icon }),
|
|
5874
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
5875
|
-
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: item.title }),
|
|
5876
|
-
item.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: item.description })
|
|
5904
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-gray-500", children: item.icon }),
|
|
5905
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
5906
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-sm font-medium", children: item.title }),
|
|
5907
|
+
item.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-xs text-gray-500", children: item.description })
|
|
5877
5908
|
] })
|
|
5878
5909
|
]
|
|
5879
5910
|
},
|
|
@@ -5886,20 +5917,8 @@ function SlashMenu({ items, command }) {
|
|
|
5886
5917
|
}
|
|
5887
5918
|
|
|
5888
5919
|
// src/commands/slash-commands.tsx
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
Heading1,
|
|
5892
|
-
Heading2,
|
|
5893
|
-
Heading3,
|
|
5894
|
-
List,
|
|
5895
|
-
ListOrdered,
|
|
5896
|
-
Quote,
|
|
5897
|
-
Code,
|
|
5898
|
-
Minus,
|
|
5899
|
-
Table,
|
|
5900
|
-
Link
|
|
5901
|
-
} from "lucide-react";
|
|
5902
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
5920
|
+
var import_lucide_react = require("lucide-react");
|
|
5921
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
5903
5922
|
var slashCommands = [
|
|
5904
5923
|
/* ================= AI ================= */
|
|
5905
5924
|
// {
|
|
@@ -5942,7 +5961,7 @@ var slashCommands = [
|
|
|
5942
5961
|
title: "Text",
|
|
5943
5962
|
description: "Normal paragraph",
|
|
5944
5963
|
category: "Style",
|
|
5945
|
-
icon: /* @__PURE__ */
|
|
5964
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Type, { size: 16 }),
|
|
5946
5965
|
keywords: ["paragraph", "text"],
|
|
5947
5966
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setParagraph().run()
|
|
5948
5967
|
},
|
|
@@ -5951,7 +5970,7 @@ var slashCommands = [
|
|
|
5951
5970
|
title: "Heading 1",
|
|
5952
5971
|
description: "Big section heading",
|
|
5953
5972
|
category: "Style",
|
|
5954
|
-
icon: /* @__PURE__ */
|
|
5973
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Heading1, { size: 16 }),
|
|
5955
5974
|
keywords: ["h1", "title"],
|
|
5956
5975
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setHeading({ level: 1 }).run()
|
|
5957
5976
|
},
|
|
@@ -5960,7 +5979,7 @@ var slashCommands = [
|
|
|
5960
5979
|
title: "Heading 2",
|
|
5961
5980
|
description: "Medium section heading",
|
|
5962
5981
|
category: "Style",
|
|
5963
|
-
icon: /* @__PURE__ */
|
|
5982
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Heading2, { size: 16 }),
|
|
5964
5983
|
keywords: ["h2"],
|
|
5965
5984
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setHeading({ level: 2 }).run()
|
|
5966
5985
|
},
|
|
@@ -5969,7 +5988,7 @@ var slashCommands = [
|
|
|
5969
5988
|
title: "Heading 3",
|
|
5970
5989
|
description: "Small section heading",
|
|
5971
5990
|
category: "Style",
|
|
5972
|
-
icon: /* @__PURE__ */
|
|
5991
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Heading3, { size: 16 }),
|
|
5973
5992
|
keywords: ["h3"],
|
|
5974
5993
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setHeading({ level: 3 }).run()
|
|
5975
5994
|
},
|
|
@@ -5977,7 +5996,7 @@ var slashCommands = [
|
|
|
5977
5996
|
id: "bullet-list",
|
|
5978
5997
|
title: "Bullet List",
|
|
5979
5998
|
category: "Style",
|
|
5980
|
-
icon: /* @__PURE__ */
|
|
5999
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.List, { size: 16 }),
|
|
5981
6000
|
keywords: ["ul", "bullet"],
|
|
5982
6001
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).toggleBulletList().run()
|
|
5983
6002
|
},
|
|
@@ -5985,7 +6004,7 @@ var slashCommands = [
|
|
|
5985
6004
|
id: "ordered-list",
|
|
5986
6005
|
title: "Numbered List",
|
|
5987
6006
|
category: "Style",
|
|
5988
|
-
icon: /* @__PURE__ */
|
|
6007
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.ListOrdered, { size: 16 }),
|
|
5989
6008
|
keywords: ["ol", "number"],
|
|
5990
6009
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).toggleOrderedList().run()
|
|
5991
6010
|
},
|
|
@@ -6001,7 +6020,7 @@ var slashCommands = [
|
|
|
6001
6020
|
id: "blockquote",
|
|
6002
6021
|
title: "Quote",
|
|
6003
6022
|
category: "Style",
|
|
6004
|
-
icon: /* @__PURE__ */
|
|
6023
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Quote, { size: 16 }),
|
|
6005
6024
|
keywords: ["quote"],
|
|
6006
6025
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).toggleBlockquote().run()
|
|
6007
6026
|
},
|
|
@@ -6009,7 +6028,7 @@ var slashCommands = [
|
|
|
6009
6028
|
id: "code-block",
|
|
6010
6029
|
title: "Code Block",
|
|
6011
6030
|
category: "Style",
|
|
6012
|
-
icon: /* @__PURE__ */
|
|
6031
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Code, { size: 16 }),
|
|
6013
6032
|
keywords: ["code", "pre"],
|
|
6014
6033
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).toggleCodeBlock().run()
|
|
6015
6034
|
},
|
|
@@ -6018,7 +6037,7 @@ var slashCommands = [
|
|
|
6018
6037
|
id: "divider",
|
|
6019
6038
|
title: "Divider",
|
|
6020
6039
|
category: "Insert",
|
|
6021
|
-
icon: /* @__PURE__ */
|
|
6040
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Minus, { size: 16 }),
|
|
6022
6041
|
keywords: ["hr", "separator"],
|
|
6023
6042
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setHorizontalRule().run()
|
|
6024
6043
|
},
|
|
@@ -6026,7 +6045,7 @@ var slashCommands = [
|
|
|
6026
6045
|
id: "table",
|
|
6027
6046
|
title: "Table",
|
|
6028
6047
|
category: "Insert",
|
|
6029
|
-
icon: /* @__PURE__ */
|
|
6048
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Table, { size: 16 }),
|
|
6030
6049
|
keywords: ["table", "grid"],
|
|
6031
6050
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run()
|
|
6032
6051
|
},
|
|
@@ -6052,7 +6071,7 @@ var slashCommands = [
|
|
|
6052
6071
|
id: "link",
|
|
6053
6072
|
title: "Link",
|
|
6054
6073
|
category: "Media",
|
|
6055
|
-
icon: /* @__PURE__ */
|
|
6074
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_lucide_react.Link, { size: 16 }),
|
|
6056
6075
|
keywords: ["url"],
|
|
6057
6076
|
command: ({ editor, range }) => editor.chain().focus().deleteRange(range).setLink({ href: "https://example.com" }).run()
|
|
6058
6077
|
}
|
|
@@ -6080,12 +6099,12 @@ function getSafeClientRect(clientRect) {
|
|
|
6080
6099
|
};
|
|
6081
6100
|
}
|
|
6082
6101
|
var SlashPluginKey = new PluginKey("slash-command");
|
|
6083
|
-
var SlashExtension = Extension.create({
|
|
6102
|
+
var SlashExtension = import_core2.Extension.create({
|
|
6084
6103
|
name: "slash-command",
|
|
6085
6104
|
addProseMirrorPlugins() {
|
|
6086
6105
|
const editor = this.editor;
|
|
6087
6106
|
return [
|
|
6088
|
-
|
|
6107
|
+
(0, import_suggestion.default)({
|
|
6089
6108
|
pluginKey: SlashPluginKey,
|
|
6090
6109
|
editor,
|
|
6091
6110
|
char: "/",
|
|
@@ -6119,7 +6138,7 @@ var SlashExtension = Extension.create({
|
|
|
6119
6138
|
items = props.items;
|
|
6120
6139
|
selectCommand = props.command;
|
|
6121
6140
|
if (!editor) return;
|
|
6122
|
-
component = new ReactRenderer(SlashMenu, {
|
|
6141
|
+
component = new import_react2.ReactRenderer(SlashMenu, {
|
|
6123
6142
|
props: {
|
|
6124
6143
|
...props,
|
|
6125
6144
|
selectedIndex
|
|
@@ -6180,37 +6199,15 @@ var SlashExtension = Extension.create({
|
|
|
6180
6199
|
});
|
|
6181
6200
|
|
|
6182
6201
|
// src/SelectionToolbar.tsx
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
Italic,
|
|
6187
|
-
Underline,
|
|
6188
|
-
Strikethrough,
|
|
6189
|
-
Code as Code2,
|
|
6190
|
-
Link2,
|
|
6191
|
-
Highlighter,
|
|
6192
|
-
Type as Type2,
|
|
6193
|
-
Heading1 as Heading12,
|
|
6194
|
-
Heading2 as Heading22,
|
|
6195
|
-
Heading3 as Heading32,
|
|
6196
|
-
List as List2,
|
|
6197
|
-
ListOrdered as ListOrdered2,
|
|
6198
|
-
CheckSquare as CheckSquare2,
|
|
6199
|
-
Quote as Quote2,
|
|
6200
|
-
Code2 as Code22,
|
|
6201
|
-
AlignLeft,
|
|
6202
|
-
AlignCenter,
|
|
6203
|
-
AlignRight,
|
|
6204
|
-
AlignJustify,
|
|
6205
|
-
MoreVertical
|
|
6206
|
-
} from "lucide-react";
|
|
6207
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
6202
|
+
var import_react3 = require("react");
|
|
6203
|
+
var import_lucide_react2 = require("lucide-react");
|
|
6204
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
6208
6205
|
function SelectionToolbar({ editor }) {
|
|
6209
|
-
const [showColors, setShowColors] =
|
|
6210
|
-
const [showHighlights, setShowHighlights] =
|
|
6211
|
-
const [showTurnInto, setShowTurnInto] =
|
|
6212
|
-
const [showMore, setShowMore] =
|
|
6213
|
-
|
|
6206
|
+
const [showColors, setShowColors] = (0, import_react3.useState)(false);
|
|
6207
|
+
const [showHighlights, setShowHighlights] = (0, import_react3.useState)(false);
|
|
6208
|
+
const [showTurnInto, setShowTurnInto] = (0, import_react3.useState)(false);
|
|
6209
|
+
const [showMore, setShowMore] = (0, import_react3.useState)(false);
|
|
6210
|
+
(0, import_react3.useEffect)(() => {
|
|
6214
6211
|
if (!editor) return;
|
|
6215
6212
|
const closeMenu = () => {
|
|
6216
6213
|
setShowTurnInto(false);
|
|
@@ -6271,7 +6268,7 @@ function SelectionToolbar({ editor }) {
|
|
|
6271
6268
|
const turnIntoItems = [
|
|
6272
6269
|
{
|
|
6273
6270
|
label: "Text",
|
|
6274
|
-
icon: /* @__PURE__ */
|
|
6271
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Type, { size: 16 }),
|
|
6275
6272
|
isActive: () => editor.isActive("paragraph") && !editor.isActive("bulletList") && !editor.isActive("orderedList") && !editor.isActive("taskList"),
|
|
6276
6273
|
action: () => {
|
|
6277
6274
|
editor.chain().focus().clearNodes().setParagraph().run();
|
|
@@ -6279,25 +6276,25 @@ function SelectionToolbar({ editor }) {
|
|
|
6279
6276
|
},
|
|
6280
6277
|
{
|
|
6281
6278
|
label: "Heading 1",
|
|
6282
|
-
icon: /* @__PURE__ */
|
|
6279
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Heading1, { size: 16 }),
|
|
6283
6280
|
isActive: () => editor.isActive("heading", { level: 1 }),
|
|
6284
6281
|
action: () => editor.chain().focus().toggleHeading({ level: 1 }).run()
|
|
6285
6282
|
},
|
|
6286
6283
|
{
|
|
6287
6284
|
label: "Heading 2",
|
|
6288
|
-
icon: /* @__PURE__ */
|
|
6285
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Heading2, { size: 16 }),
|
|
6289
6286
|
isActive: () => editor.isActive("heading", { level: 2 }),
|
|
6290
6287
|
action: () => editor.chain().focus().toggleHeading({ level: 2 }).run()
|
|
6291
6288
|
},
|
|
6292
6289
|
{
|
|
6293
6290
|
label: "Heading 3",
|
|
6294
|
-
icon: /* @__PURE__ */
|
|
6291
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Heading3, { size: 16 }),
|
|
6295
6292
|
isActive: () => editor.isActive("heading", { level: 3 }),
|
|
6296
6293
|
action: () => editor.chain().focus().toggleHeading({ level: 3 }).run()
|
|
6297
6294
|
},
|
|
6298
6295
|
{
|
|
6299
6296
|
label: "To-do list",
|
|
6300
|
-
icon: /* @__PURE__ */
|
|
6297
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.CheckSquare, { size: 16 }),
|
|
6301
6298
|
isActive: () => editor.isActive("taskList"),
|
|
6302
6299
|
action: () => {
|
|
6303
6300
|
if (editor.isActive("taskList")) {
|
|
@@ -6309,19 +6306,19 @@ function SelectionToolbar({ editor }) {
|
|
|
6309
6306
|
},
|
|
6310
6307
|
{
|
|
6311
6308
|
label: "Blockquote",
|
|
6312
|
-
icon: /* @__PURE__ */
|
|
6309
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Quote, { size: 16 }),
|
|
6313
6310
|
isActive: () => editor.isActive("blockquote"),
|
|
6314
6311
|
action: () => editor.chain().focus().toggleBlockquote().run()
|
|
6315
6312
|
},
|
|
6316
6313
|
{
|
|
6317
6314
|
label: "Code block",
|
|
6318
|
-
icon: /* @__PURE__ */
|
|
6315
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Code2, { size: 16 }),
|
|
6319
6316
|
isActive: () => editor.isActive("codeBlock"),
|
|
6320
6317
|
action: () => editor.chain().focus().toggleCodeBlock().run()
|
|
6321
6318
|
}
|
|
6322
6319
|
];
|
|
6323
|
-
return /* @__PURE__ */
|
|
6324
|
-
/* @__PURE__ */
|
|
6320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex items-center gap-1 rounded-lg border border-gray-200 bg-white p-1 shadow-xl", children: [
|
|
6321
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6325
6322
|
"button",
|
|
6326
6323
|
{
|
|
6327
6324
|
onClick: () => {
|
|
@@ -6335,10 +6332,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6335
6332
|
title: "Bullet List",
|
|
6336
6333
|
type: "button",
|
|
6337
6334
|
onMouseDown: (e) => e.preventDefault(),
|
|
6338
|
-
children: /* @__PURE__ */
|
|
6335
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.List, { size: 16 })
|
|
6339
6336
|
}
|
|
6340
6337
|
),
|
|
6341
|
-
/* @__PURE__ */
|
|
6338
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6342
6339
|
"button",
|
|
6343
6340
|
{
|
|
6344
6341
|
onClick: () => {
|
|
@@ -6352,12 +6349,12 @@ function SelectionToolbar({ editor }) {
|
|
|
6352
6349
|
title: "Numbered List",
|
|
6353
6350
|
type: "button",
|
|
6354
6351
|
onMouseDown: (e) => e.preventDefault(),
|
|
6355
|
-
children: /* @__PURE__ */
|
|
6352
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.ListOrdered, { size: 16 })
|
|
6356
6353
|
}
|
|
6357
6354
|
),
|
|
6358
|
-
/* @__PURE__ */
|
|
6359
|
-
/* @__PURE__ */
|
|
6360
|
-
/* @__PURE__ */
|
|
6355
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
6356
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
|
|
6357
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
6361
6358
|
"button",
|
|
6362
6359
|
{
|
|
6363
6360
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -6369,11 +6366,11 @@ function SelectionToolbar({ editor }) {
|
|
|
6369
6366
|
]
|
|
6370
6367
|
}
|
|
6371
6368
|
),
|
|
6372
|
-
showTurnInto && /* @__PURE__ */
|
|
6373
|
-
/* @__PURE__ */
|
|
6374
|
-
/* @__PURE__ */
|
|
6369
|
+
showTurnInto && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "absolute left-0 top-full z-50 mt-2 w-52 rounded-lg border bg-white shadow-xl", children: [
|
|
6370
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "Turn into" }),
|
|
6371
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "p-1", children: turnIntoItems.map((item) => {
|
|
6375
6372
|
const active = item.isActive();
|
|
6376
|
-
return /* @__PURE__ */
|
|
6373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
6377
6374
|
"button",
|
|
6378
6375
|
{
|
|
6379
6376
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -6383,8 +6380,8 @@ function SelectionToolbar({ editor }) {
|
|
|
6383
6380
|
},
|
|
6384
6381
|
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"}`,
|
|
6385
6382
|
children: [
|
|
6386
|
-
/* @__PURE__ */
|
|
6387
|
-
/* @__PURE__ */
|
|
6383
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
|
|
6384
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: item.label })
|
|
6388
6385
|
]
|
|
6389
6386
|
},
|
|
6390
6387
|
item.label
|
|
@@ -6392,8 +6389,8 @@ function SelectionToolbar({ editor }) {
|
|
|
6392
6389
|
}) })
|
|
6393
6390
|
] })
|
|
6394
6391
|
] }),
|
|
6395
|
-
/* @__PURE__ */
|
|
6396
|
-
/* @__PURE__ */
|
|
6392
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
6393
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6397
6394
|
"button",
|
|
6398
6395
|
{
|
|
6399
6396
|
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
@@ -6401,10 +6398,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6401
6398
|
title: "Bold (Ctrl+B)",
|
|
6402
6399
|
type: "button",
|
|
6403
6400
|
onMouseDown: (e) => e.preventDefault(),
|
|
6404
|
-
children: /* @__PURE__ */
|
|
6401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Bold, { size: 16 })
|
|
6405
6402
|
}
|
|
6406
6403
|
),
|
|
6407
|
-
/* @__PURE__ */
|
|
6404
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6408
6405
|
"button",
|
|
6409
6406
|
{
|
|
6410
6407
|
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
@@ -6412,10 +6409,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6412
6409
|
title: "Italic (Ctrl+I)",
|
|
6413
6410
|
type: "button",
|
|
6414
6411
|
onMouseDown: (e) => e.preventDefault(),
|
|
6415
|
-
children: /* @__PURE__ */
|
|
6412
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Italic, { size: 16 })
|
|
6416
6413
|
}
|
|
6417
6414
|
),
|
|
6418
|
-
/* @__PURE__ */
|
|
6415
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6419
6416
|
"button",
|
|
6420
6417
|
{
|
|
6421
6418
|
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
@@ -6423,10 +6420,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6423
6420
|
title: "Underline (Ctrl+U)",
|
|
6424
6421
|
type: "button",
|
|
6425
6422
|
onMouseDown: (e) => e.preventDefault(),
|
|
6426
|
-
children: /* @__PURE__ */
|
|
6423
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Underline, { size: 16 })
|
|
6427
6424
|
}
|
|
6428
6425
|
),
|
|
6429
|
-
/* @__PURE__ */
|
|
6426
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6430
6427
|
"button",
|
|
6431
6428
|
{
|
|
6432
6429
|
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
@@ -6434,10 +6431,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6434
6431
|
title: "Strikethrough",
|
|
6435
6432
|
type: "button",
|
|
6436
6433
|
onMouseDown: (e) => e.preventDefault(),
|
|
6437
|
-
children: /* @__PURE__ */
|
|
6434
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Strikethrough, { size: 16 })
|
|
6438
6435
|
}
|
|
6439
6436
|
),
|
|
6440
|
-
/* @__PURE__ */
|
|
6437
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6441
6438
|
"button",
|
|
6442
6439
|
{
|
|
6443
6440
|
onClick: () => editor.chain().focus().toggleCode().run(),
|
|
@@ -6445,11 +6442,11 @@ function SelectionToolbar({ editor }) {
|
|
|
6445
6442
|
title: "Code",
|
|
6446
6443
|
type: "button",
|
|
6447
6444
|
onMouseDown: (e) => e.preventDefault(),
|
|
6448
|
-
children: /* @__PURE__ */
|
|
6445
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Code, { size: 16 })
|
|
6449
6446
|
}
|
|
6450
6447
|
),
|
|
6451
|
-
/* @__PURE__ */
|
|
6452
|
-
/* @__PURE__ */
|
|
6448
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
6449
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6453
6450
|
"button",
|
|
6454
6451
|
{
|
|
6455
6452
|
onClick: setLink,
|
|
@@ -6457,11 +6454,11 @@ function SelectionToolbar({ editor }) {
|
|
|
6457
6454
|
title: "Add Link",
|
|
6458
6455
|
type: "button",
|
|
6459
6456
|
onMouseDown: (e) => e.preventDefault(),
|
|
6460
|
-
children: /* @__PURE__ */
|
|
6457
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Link2, { size: 16 })
|
|
6461
6458
|
}
|
|
6462
6459
|
),
|
|
6463
|
-
/* @__PURE__ */
|
|
6464
|
-
/* @__PURE__ */
|
|
6460
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
|
|
6461
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6465
6462
|
"button",
|
|
6466
6463
|
{
|
|
6467
6464
|
onClick: () => {
|
|
@@ -6472,10 +6469,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6472
6469
|
title: "Text Color",
|
|
6473
6470
|
type: "button",
|
|
6474
6471
|
onMouseDown: (e) => e.preventDefault(),
|
|
6475
|
-
children: /* @__PURE__ */
|
|
6472
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Type, { size: 16 })
|
|
6476
6473
|
}
|
|
6477
6474
|
),
|
|
6478
|
-
showColors && /* @__PURE__ */
|
|
6475
|
+
showColors && /* @__PURE__ */ (0, import_jsx_runtime3.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__ */ (0, import_jsx_runtime3.jsx)(
|
|
6479
6476
|
"button",
|
|
6480
6477
|
{
|
|
6481
6478
|
onClick: () => {
|
|
@@ -6491,8 +6488,8 @@ function SelectionToolbar({ editor }) {
|
|
|
6491
6488
|
color.value
|
|
6492
6489
|
)) })
|
|
6493
6490
|
] }),
|
|
6494
|
-
/* @__PURE__ */
|
|
6495
|
-
/* @__PURE__ */
|
|
6491
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
|
|
6492
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6496
6493
|
"button",
|
|
6497
6494
|
{
|
|
6498
6495
|
onClick: () => {
|
|
@@ -6503,10 +6500,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6503
6500
|
title: "Highlight",
|
|
6504
6501
|
type: "button",
|
|
6505
6502
|
onMouseDown: (e) => e.preventDefault(),
|
|
6506
|
-
children: /* @__PURE__ */
|
|
6503
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.Highlighter, { size: 16 })
|
|
6507
6504
|
}
|
|
6508
6505
|
),
|
|
6509
|
-
showHighlights && /* @__PURE__ */
|
|
6506
|
+
showHighlights && /* @__PURE__ */ (0, import_jsx_runtime3.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__ */ (0, import_jsx_runtime3.jsx)(
|
|
6510
6507
|
"button",
|
|
6511
6508
|
{
|
|
6512
6509
|
onClick: () => {
|
|
@@ -6526,60 +6523,60 @@ function SelectionToolbar({ editor }) {
|
|
|
6526
6523
|
highlight.value
|
|
6527
6524
|
)) })
|
|
6528
6525
|
] }),
|
|
6529
|
-
/* @__PURE__ */
|
|
6530
|
-
/* @__PURE__ */
|
|
6531
|
-
/* @__PURE__ */
|
|
6526
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mx-1 h-6 w-px bg-gray-300" }),
|
|
6527
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "relative", children: [
|
|
6528
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6532
6529
|
"button",
|
|
6533
6530
|
{
|
|
6534
6531
|
onMouseDown: (e) => e.preventDefault(),
|
|
6535
6532
|
onClick: () => setShowMore((v) => !v),
|
|
6536
6533
|
className: "rounded p-1.5 hover:bg-gray-100",
|
|
6537
|
-
children: /* @__PURE__ */
|
|
6534
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.MoreVertical, { size: 16 })
|
|
6538
6535
|
}
|
|
6539
6536
|
),
|
|
6540
|
-
showMore && /* @__PURE__ */
|
|
6541
|
-
/* @__PURE__ */
|
|
6542
|
-
/* @__PURE__ */
|
|
6537
|
+
showMore && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "absolute right-0 top-full z-50 mt-2 w-56 rounded-lg border bg-white shadow-xl", children: [
|
|
6538
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "px-3 py-2 text-xs font-semibold text-gray-500", children: "More" }),
|
|
6539
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "p-1", children: [
|
|
6543
6540
|
{
|
|
6544
6541
|
label: "Align left",
|
|
6545
|
-
icon: /* @__PURE__ */
|
|
6542
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlignLeft, { size: 16 }),
|
|
6546
6543
|
isActive: () => editor.isActive({ textAlign: "left" }),
|
|
6547
6544
|
action: () => editor.chain().focus().setTextAlign("left").run()
|
|
6548
6545
|
},
|
|
6549
6546
|
{
|
|
6550
6547
|
label: "Align center",
|
|
6551
|
-
icon: /* @__PURE__ */
|
|
6548
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlignCenter, { size: 16 }),
|
|
6552
6549
|
isActive: () => editor.isActive({ textAlign: "center" }),
|
|
6553
6550
|
action: () => editor.chain().focus().setTextAlign("center").run()
|
|
6554
6551
|
},
|
|
6555
6552
|
{
|
|
6556
6553
|
label: "Align right",
|
|
6557
|
-
icon: /* @__PURE__ */
|
|
6554
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlignRight, { size: 16 }),
|
|
6558
6555
|
isActive: () => editor.isActive({ textAlign: "right" }),
|
|
6559
6556
|
action: () => editor.chain().focus().setTextAlign("right").run()
|
|
6560
6557
|
},
|
|
6561
6558
|
{
|
|
6562
6559
|
label: "Justify",
|
|
6563
|
-
icon: /* @__PURE__ */
|
|
6560
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.AlignJustify, { size: 16 }),
|
|
6564
6561
|
isActive: () => editor.isActive({ textAlign: "justify" }),
|
|
6565
6562
|
action: () => editor.chain().focus().setTextAlign("justify").run()
|
|
6566
6563
|
},
|
|
6567
6564
|
{ divider: true },
|
|
6568
6565
|
{
|
|
6569
6566
|
label: "Superscript",
|
|
6570
|
-
icon: /* @__PURE__ */
|
|
6567
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-sm font-semibold", children: "x\xB2" }),
|
|
6571
6568
|
isActive: () => editor.isActive("superscript"),
|
|
6572
6569
|
action: () => editor.chain().focus().toggleSuperscript().run()
|
|
6573
6570
|
},
|
|
6574
6571
|
{
|
|
6575
6572
|
label: "Subscript",
|
|
6576
|
-
icon: /* @__PURE__ */
|
|
6573
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "text-sm font-semibold", children: "x\u2082" }),
|
|
6577
6574
|
isActive: () => editor.isActive("subscript"),
|
|
6578
6575
|
action: () => editor.chain().focus().toggleSubscript().run()
|
|
6579
6576
|
}
|
|
6580
6577
|
].map((item, index) => {
|
|
6581
6578
|
if ("divider" in item) {
|
|
6582
|
-
return /* @__PURE__ */
|
|
6579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
6583
6580
|
"div",
|
|
6584
6581
|
{
|
|
6585
6582
|
className: "my-1 h-px bg-gray-200"
|
|
@@ -6588,7 +6585,7 @@ function SelectionToolbar({ editor }) {
|
|
|
6588
6585
|
);
|
|
6589
6586
|
}
|
|
6590
6587
|
const active = item.isActive();
|
|
6591
|
-
return /* @__PURE__ */
|
|
6588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
6592
6589
|
"button",
|
|
6593
6590
|
{
|
|
6594
6591
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -6598,8 +6595,8 @@ function SelectionToolbar({ editor }) {
|
|
|
6598
6595
|
},
|
|
6599
6596
|
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"}`,
|
|
6600
6597
|
children: [
|
|
6601
|
-
/* @__PURE__ */
|
|
6602
|
-
/* @__PURE__ */
|
|
6598
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "flex h-5 w-5 items-center justify-center", children: item.icon }),
|
|
6599
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: item.label })
|
|
6603
6600
|
]
|
|
6604
6601
|
},
|
|
6605
6602
|
item.label
|
|
@@ -6612,10 +6609,10 @@ function SelectionToolbar({ editor }) {
|
|
|
6612
6609
|
var SelectionToolbar_default = SelectionToolbar;
|
|
6613
6610
|
|
|
6614
6611
|
// src/table/useRowHover.ts
|
|
6615
|
-
|
|
6612
|
+
var import_react4 = require("react");
|
|
6616
6613
|
function useRowHover(editor) {
|
|
6617
|
-
const [rowEl, setRowEl] =
|
|
6618
|
-
|
|
6614
|
+
const [rowEl, setRowEl] = (0, import_react4.useState)(null);
|
|
6615
|
+
(0, import_react4.useEffect)(() => {
|
|
6619
6616
|
if (!editor) return;
|
|
6620
6617
|
const root = editor.view.dom;
|
|
6621
6618
|
const onMouseMove = (e) => {
|
|
@@ -6636,7 +6633,7 @@ function useRowHover(editor) {
|
|
|
6636
6633
|
}
|
|
6637
6634
|
|
|
6638
6635
|
// src/table/RowAddButton.tsx
|
|
6639
|
-
|
|
6636
|
+
var import_lucide_react3 = require("lucide-react");
|
|
6640
6637
|
|
|
6641
6638
|
// src/table/selectTableCell.ts
|
|
6642
6639
|
function selectCellByDom(editor, cell) {
|
|
@@ -6646,33 +6643,33 @@ function selectCellByDom(editor, cell) {
|
|
|
6646
6643
|
}
|
|
6647
6644
|
|
|
6648
6645
|
// src/table/RowAddButton.tsx
|
|
6649
|
-
|
|
6650
|
-
|
|
6646
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
6647
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
6651
6648
|
function RowTableMenu(editor, onClose) {
|
|
6652
|
-
return /* @__PURE__ */
|
|
6653
|
-
/* @__PURE__ */
|
|
6649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "w-56 rounded-lg border bg-white p-1 shadow-xl", children: [
|
|
6650
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6654
6651
|
MenuItem,
|
|
6655
6652
|
{
|
|
6656
6653
|
label: "Add row above",
|
|
6657
6654
|
onClick: () => editor.commands.addRowBefore()
|
|
6658
6655
|
}
|
|
6659
6656
|
),
|
|
6660
|
-
/* @__PURE__ */
|
|
6657
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6661
6658
|
MenuItem,
|
|
6662
6659
|
{
|
|
6663
6660
|
label: "Add row below",
|
|
6664
6661
|
onClick: () => editor.commands.addRowAfter()
|
|
6665
6662
|
}
|
|
6666
6663
|
),
|
|
6667
|
-
/* @__PURE__ */
|
|
6664
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6668
6665
|
MenuItem,
|
|
6669
6666
|
{
|
|
6670
6667
|
label: "Delete row",
|
|
6671
6668
|
onClick: () => editor.commands.deleteRow()
|
|
6672
6669
|
}
|
|
6673
6670
|
),
|
|
6674
|
-
/* @__PURE__ */
|
|
6675
|
-
/* @__PURE__ */
|
|
6671
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "my-1 border-t" }),
|
|
6672
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6676
6673
|
MenuItem,
|
|
6677
6674
|
{
|
|
6678
6675
|
label: "Delete table",
|
|
@@ -6690,7 +6687,7 @@ function MenuItem({
|
|
|
6690
6687
|
onClick,
|
|
6691
6688
|
danger
|
|
6692
6689
|
}) {
|
|
6693
|
-
return /* @__PURE__ */
|
|
6690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6694
6691
|
"button",
|
|
6695
6692
|
{
|
|
6696
6693
|
onClick,
|
|
@@ -6700,12 +6697,12 @@ function MenuItem({
|
|
|
6700
6697
|
);
|
|
6701
6698
|
}
|
|
6702
6699
|
function RowAddButton({ editor, row }) {
|
|
6703
|
-
const [showRowMenu, setShowRowMenu] =
|
|
6700
|
+
const [showRowMenu, setShowRowMenu] = import_react5.default.useState(false);
|
|
6704
6701
|
const firstCell = row.querySelector("td, th");
|
|
6705
6702
|
if (!firstCell) return null;
|
|
6706
6703
|
const rect = row.getBoundingClientRect();
|
|
6707
|
-
return /* @__PURE__ */
|
|
6708
|
-
/* @__PURE__ */
|
|
6704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "relative", children: [
|
|
6705
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6709
6706
|
"button",
|
|
6710
6707
|
{
|
|
6711
6708
|
style: {
|
|
@@ -6722,10 +6719,10 @@ function RowAddButton({ editor, row }) {
|
|
|
6722
6719
|
setShowRowMenu((v) => !v);
|
|
6723
6720
|
selectCellByDom(editor, firstCell);
|
|
6724
6721
|
},
|
|
6725
|
-
children: /* @__PURE__ */
|
|
6722
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react3.MoreHorizontal, { size: 14 })
|
|
6726
6723
|
}
|
|
6727
6724
|
),
|
|
6728
|
-
showRowMenu && /* @__PURE__ */
|
|
6725
|
+
showRowMenu && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
6729
6726
|
"div",
|
|
6730
6727
|
{
|
|
6731
6728
|
className: "z-[1000]",
|
|
@@ -6745,10 +6742,10 @@ function RowAddButton({ editor, row }) {
|
|
|
6745
6742
|
}
|
|
6746
6743
|
|
|
6747
6744
|
// src/table/useColumnHover.ts
|
|
6748
|
-
|
|
6745
|
+
var import_react6 = require("react");
|
|
6749
6746
|
function useColumnHover(editor) {
|
|
6750
|
-
const [hovered, setHovered] =
|
|
6751
|
-
|
|
6747
|
+
const [hovered, setHovered] = (0, import_react6.useState)(null);
|
|
6748
|
+
(0, import_react6.useEffect)(() => {
|
|
6752
6749
|
if (!editor) return;
|
|
6753
6750
|
const root = editor.view.dom;
|
|
6754
6751
|
const onMouseMove = (e) => {
|
|
@@ -6778,34 +6775,34 @@ function useColumnHover(editor) {
|
|
|
6778
6775
|
}
|
|
6779
6776
|
|
|
6780
6777
|
// src/table/ColumnAddButton.tsx
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6778
|
+
var import_lucide_react4 = require("lucide-react");
|
|
6779
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
6780
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
6784
6781
|
function ColumnTableMenu(editor, onClose) {
|
|
6785
|
-
return /* @__PURE__ */
|
|
6786
|
-
/* @__PURE__ */
|
|
6782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "w-56 rounded-lg border bg-white p-1 shadow-xl", children: [
|
|
6783
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6787
6784
|
MenuItem2,
|
|
6788
6785
|
{
|
|
6789
6786
|
label: "Add column left",
|
|
6790
6787
|
onClick: () => editor.commands.addColumnBefore()
|
|
6791
6788
|
}
|
|
6792
6789
|
),
|
|
6793
|
-
/* @__PURE__ */
|
|
6790
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6794
6791
|
MenuItem2,
|
|
6795
6792
|
{
|
|
6796
6793
|
label: "Add column right",
|
|
6797
6794
|
onClick: () => editor.commands.addColumnAfter()
|
|
6798
6795
|
}
|
|
6799
6796
|
),
|
|
6800
|
-
/* @__PURE__ */
|
|
6797
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6801
6798
|
MenuItem2,
|
|
6802
6799
|
{
|
|
6803
6800
|
label: "Delete column",
|
|
6804
6801
|
onClick: () => editor.commands.deleteColumn()
|
|
6805
6802
|
}
|
|
6806
6803
|
),
|
|
6807
|
-
/* @__PURE__ */
|
|
6808
|
-
/* @__PURE__ */
|
|
6804
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "my-1 border-t" }),
|
|
6805
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6809
6806
|
MenuItem2,
|
|
6810
6807
|
{
|
|
6811
6808
|
label: "Delete table",
|
|
@@ -6823,7 +6820,7 @@ function MenuItem2({
|
|
|
6823
6820
|
onClick,
|
|
6824
6821
|
danger
|
|
6825
6822
|
}) {
|
|
6826
|
-
return /* @__PURE__ */
|
|
6823
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6827
6824
|
"button",
|
|
6828
6825
|
{
|
|
6829
6826
|
onClick,
|
|
@@ -6837,15 +6834,15 @@ function MenuItem2({
|
|
|
6837
6834
|
);
|
|
6838
6835
|
}
|
|
6839
6836
|
function ColumnAddButton({ editor, table, columnIndex }) {
|
|
6840
|
-
const [showColumnMenu, setShowColumnMenu] =
|
|
6837
|
+
const [showColumnMenu, setShowColumnMenu] = import_react7.default.useState(false);
|
|
6841
6838
|
const firstRow = table.querySelector("tr");
|
|
6842
6839
|
if (!firstRow) return null;
|
|
6843
6840
|
const cells = Array.from(firstRow.children);
|
|
6844
6841
|
const cell = cells[columnIndex];
|
|
6845
6842
|
if (!cell) return null;
|
|
6846
6843
|
const rect = cell.getBoundingClientRect();
|
|
6847
|
-
return /* @__PURE__ */
|
|
6848
|
-
/* @__PURE__ */
|
|
6844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
6845
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6849
6846
|
"button",
|
|
6850
6847
|
{
|
|
6851
6848
|
style: {
|
|
@@ -6862,10 +6859,10 @@ function ColumnAddButton({ editor, table, columnIndex }) {
|
|
|
6862
6859
|
setShowColumnMenu((v) => !v);
|
|
6863
6860
|
selectCellByDom(editor, cell);
|
|
6864
6861
|
},
|
|
6865
|
-
children: /* @__PURE__ */
|
|
6862
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.MoreHorizontal, { size: 14 })
|
|
6866
6863
|
}
|
|
6867
6864
|
),
|
|
6868
|
-
showColumnMenu && /* @__PURE__ */
|
|
6865
|
+
showColumnMenu && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
6869
6866
|
"div",
|
|
6870
6867
|
{
|
|
6871
6868
|
className: "fixed z-[1000]",
|
|
@@ -6881,8 +6878,8 @@ function ColumnAddButton({ editor, table, columnIndex }) {
|
|
|
6881
6878
|
}
|
|
6882
6879
|
|
|
6883
6880
|
// src/NotionEditor.tsx
|
|
6884
|
-
|
|
6885
|
-
var DynamicPlaceholder =
|
|
6881
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
6882
|
+
var DynamicPlaceholder = import_extension_placeholder.default.configure({
|
|
6886
6883
|
placeholder: ({ node }) => {
|
|
6887
6884
|
var _a;
|
|
6888
6885
|
const type = node.type.name;
|
|
@@ -6924,51 +6921,51 @@ var NotionEditor = ({
|
|
|
6924
6921
|
showToolbar = true,
|
|
6925
6922
|
showTableControls = true
|
|
6926
6923
|
}) => {
|
|
6927
|
-
const lastSavedRef =
|
|
6928
|
-
const isDirtyRef =
|
|
6929
|
-
const editor = useEditor({
|
|
6924
|
+
const lastSavedRef = (0, import_react9.useRef)("");
|
|
6925
|
+
const isDirtyRef = (0, import_react9.useRef)(false);
|
|
6926
|
+
const editor = (0, import_react8.useEditor)({
|
|
6930
6927
|
autofocus: autoFocus,
|
|
6931
6928
|
editable: !disabled,
|
|
6932
6929
|
extensions: [
|
|
6933
|
-
|
|
6930
|
+
import_starter_kit.default.configure({
|
|
6934
6931
|
heading: {
|
|
6935
6932
|
levels: [1, 2, 3]
|
|
6936
6933
|
}
|
|
6937
6934
|
}),
|
|
6938
6935
|
DynamicPlaceholder,
|
|
6939
|
-
|
|
6936
|
+
import_extension_placeholder.default.configure({
|
|
6940
6937
|
placeholder,
|
|
6941
6938
|
showOnlyWhenEditable: true,
|
|
6942
6939
|
includeChildren: false
|
|
6943
6940
|
}),
|
|
6944
6941
|
SlashExtension,
|
|
6945
|
-
|
|
6946
|
-
TextStyle,
|
|
6947
|
-
Color,
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6942
|
+
import_extension_underline.default,
|
|
6943
|
+
import_extension_text_style.TextStyle,
|
|
6944
|
+
import_extension_color.Color,
|
|
6945
|
+
import_extension_superscript.default,
|
|
6946
|
+
import_extension_subscript.default,
|
|
6947
|
+
import_extension_text_align.default.configure({
|
|
6951
6948
|
types: ["heading", "paragraph"]
|
|
6952
6949
|
}),
|
|
6953
|
-
|
|
6950
|
+
import_extension_highlight.default.configure({
|
|
6954
6951
|
multicolor: true
|
|
6955
6952
|
}),
|
|
6956
|
-
|
|
6953
|
+
import_extension_link.default.configure({
|
|
6957
6954
|
openOnClick: false,
|
|
6958
6955
|
HTMLAttributes: {
|
|
6959
6956
|
class: "text-blue-600 underline cursor-pointer hover:text-blue-800"
|
|
6960
6957
|
}
|
|
6961
6958
|
}),
|
|
6962
|
-
|
|
6959
|
+
import_extension_table.Table.configure({
|
|
6963
6960
|
resizable: true,
|
|
6964
6961
|
lastColumnResizable: true,
|
|
6965
6962
|
allowTableNodeSelection: true
|
|
6966
6963
|
}),
|
|
6967
|
-
TableRow,
|
|
6968
|
-
TableHeader,
|
|
6969
|
-
TableCell,
|
|
6970
|
-
|
|
6971
|
-
|
|
6964
|
+
import_extension_table.TableRow,
|
|
6965
|
+
import_extension_table.TableHeader,
|
|
6966
|
+
import_extension_table.TableCell,
|
|
6967
|
+
import_extension_task_list.default,
|
|
6968
|
+
import_extension_task_item.default.configure({
|
|
6972
6969
|
nested: true,
|
|
6973
6970
|
HTMLAttributes: {
|
|
6974
6971
|
class: "task-item"
|
|
@@ -7001,23 +6998,23 @@ var NotionEditor = ({
|
|
|
7001
6998
|
});
|
|
7002
6999
|
}
|
|
7003
7000
|
});
|
|
7004
|
-
|
|
7001
|
+
(0, import_react9.useEffect)(() => {
|
|
7005
7002
|
if (!editor) return;
|
|
7006
7003
|
const currentHTML = editor.getHTML();
|
|
7007
7004
|
if (content !== void 0 && content !== currentHTML) {
|
|
7008
7005
|
editor.commands.setContent(content || "");
|
|
7009
7006
|
}
|
|
7010
7007
|
}, [content, editor]);
|
|
7011
|
-
|
|
7008
|
+
(0, import_react9.useEffect)(() => {
|
|
7012
7009
|
editor == null ? void 0 : editor.setEditable(!disabled);
|
|
7013
7010
|
}, [disabled, editor]);
|
|
7014
7011
|
const hoveredRow = useRowHover(editor);
|
|
7015
7012
|
const hoveredColumn = useColumnHover(editor);
|
|
7016
7013
|
if (!editor) return null;
|
|
7017
|
-
return /* @__PURE__ */
|
|
7018
|
-
showToolbar && /* @__PURE__ */
|
|
7019
|
-
showTableControls && editor && hoveredRow && /* @__PURE__ */
|
|
7020
|
-
showTableControls && editor && hoveredColumn && /* @__PURE__ */
|
|
7014
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: (0, import_clsx.default)("relative rounded-lg border bg-white", className), children: [
|
|
7015
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_menus.BubbleMenu, { editor, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectionToolbar_default, { editor }) }),
|
|
7016
|
+
showTableControls && editor && hoveredRow && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RowAddButton, { editor, row: hoveredRow }),
|
|
7017
|
+
showTableControls && editor && hoveredColumn && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7021
7018
|
ColumnAddButton,
|
|
7022
7019
|
{
|
|
7023
7020
|
editor,
|
|
@@ -7025,11 +7022,11 @@ var NotionEditor = ({
|
|
|
7025
7022
|
columnIndex: hoveredColumn.columnIndex
|
|
7026
7023
|
}
|
|
7027
7024
|
),
|
|
7028
|
-
/* @__PURE__ */
|
|
7029
|
-
EditorContent,
|
|
7025
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
7026
|
+
import_react8.EditorContent,
|
|
7030
7027
|
{
|
|
7031
7028
|
editor,
|
|
7032
|
-
className:
|
|
7029
|
+
className: (0, import_clsx.default)(
|
|
7033
7030
|
"prose max-w-none border border-gray-300 p-6",
|
|
7034
7031
|
disabled && "cursor-not-allowed opacity-60",
|
|
7035
7032
|
editorClassName
|
|
@@ -7039,7 +7036,8 @@ var NotionEditor = ({
|
|
|
7039
7036
|
] });
|
|
7040
7037
|
};
|
|
7041
7038
|
var NotionEditor_default = NotionEditor;
|
|
7042
|
-
export
|
|
7043
|
-
|
|
7044
|
-
|
|
7039
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
7040
|
+
0 && (module.exports = {
|
|
7041
|
+
NotionEditor
|
|
7042
|
+
});
|
|
7045
7043
|
//# sourceMappingURL=index.js.map
|