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