@dooherceg/tiptap-controlled-editor-with-table 0.0.9 → 0.0.10
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/components/tiptap-templates/simple/simple-editor.d.ts +3 -1
- package/dist/components/tiptap-templates/simple/simple-editor.js +192 -185
- package/dist/components/tiptap-ui/color-highlight-popover/color-highlight-popover.js +12 -12
- package/dist/components/tiptap-ui/list-dropdown-menu/use-list-dropdown-menu.js +3 -3
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Editor, EditorOptions } from '@tiptap/react';
|
|
2
|
+
import { Ref } from 'react';
|
|
2
3
|
export interface SimpleEditorProps extends Omit<Partial<EditorOptions>, "content"> {
|
|
3
4
|
themeMode: "dark" | "light";
|
|
4
5
|
content?: string;
|
|
5
6
|
onContentChange?: (content: string) => void;
|
|
6
7
|
placeholder?: string;
|
|
8
|
+
ref?: Ref<SimpleEditorRef>;
|
|
7
9
|
}
|
|
8
10
|
export interface SimpleEditorRef {
|
|
9
11
|
getEditor: () => Editor | null;
|
|
10
12
|
}
|
|
11
|
-
export declare
|
|
13
|
+
export declare function SimpleEditor({ themeMode, content, onContentChange, placeholder, ref, }: SimpleEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,220 +1,227 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useEditor as
|
|
3
|
-
import {
|
|
1
|
+
import { jsx as t, jsxs as e, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useEditor as H, EditorContext as v, EditorContent as E } from "@tiptap/react";
|
|
3
|
+
import { useState as S, useRef as C, useEffect as h, useImperativeHandle as x } from "react";
|
|
4
4
|
import '../../../assets/components/tiptap-templates/simple/simple-editor.css';import '../../../assets/components/tiptap-node/paragraph-node/paragraph-node.css';import '../../../assets/components/tiptap-node/list-node/list-node.css';import '../../../assets/components/tiptap-node/image-node/image-node.css';import '../../../assets/components/tiptap-node/horizontal-rule-node/horizontal-rule-node.css';import '../../../assets/components/tiptap-node/heading-node/heading-node.css';import '../../../assets/components/tiptap-node/code-block-node/code-block-node.css';import '../../../assets/components/tiptap-node/blockquote-node/blockquote-node.css';import '../../../assets/styles/_variables.css';import '../../../assets/styles/_keyframe-animations.css';/* empty css */
|
|
5
5
|
/* empty css */
|
|
6
|
-
import { Highlight as
|
|
6
|
+
import { Highlight as w } from "../../../node_modules/@tiptap/extension-highlight/dist/index.js";
|
|
7
7
|
import { Image as P } from "../../../node_modules/@tiptap/extension-image/dist/index.js";
|
|
8
|
-
import { TaskList as
|
|
9
|
-
import { Subscript as
|
|
10
|
-
import { Superscript as
|
|
11
|
-
import { TextAlign as
|
|
12
|
-
import { Typography as
|
|
13
|
-
import { Selection as
|
|
14
|
-
import { StarterKit as
|
|
8
|
+
import { TaskList as R, TaskItem as M } from "../../../node_modules/@tiptap/extension-list/dist/index.js";
|
|
9
|
+
import { Subscript as U } from "../../../node_modules/@tiptap/extension-subscript/dist/index.js";
|
|
10
|
+
import { Superscript as z } from "../../../node_modules/@tiptap/extension-superscript/dist/index.js";
|
|
11
|
+
import { TextAlign as N } from "../../../node_modules/@tiptap/extension-text-align/dist/index.js";
|
|
12
|
+
import { Typography as A } from "../../../node_modules/@tiptap/extension-typography/dist/index.js";
|
|
13
|
+
import { Selection as j, Placeholder as F } from "../../../node_modules/@tiptap/extensions/dist/index.js";
|
|
14
|
+
import { StarterKit as V } from "@tiptap/starter-kit";
|
|
15
15
|
/* empty css */
|
|
16
16
|
/* empty css */
|
|
17
17
|
/* empty css */
|
|
18
|
-
import { HorizontalRule as
|
|
18
|
+
import { HorizontalRule as D } from "../../tiptap-node/horizontal-rule-node/horizontal-rule-node-extension.js";
|
|
19
19
|
/* empty css */
|
|
20
20
|
/* empty css */
|
|
21
|
-
import { ImageUploadNode as
|
|
21
|
+
import { ImageUploadNode as K } from "../../tiptap-node/image-upload-node/image-upload-node-extension.js";
|
|
22
22
|
/* empty css */
|
|
23
23
|
/* empty css */
|
|
24
|
-
import { ArrowLeftIcon as
|
|
25
|
-
import { HighlighterIcon as
|
|
26
|
-
import { LinkIcon as
|
|
27
|
-
import { useCursorVisibility as
|
|
28
|
-
import { useIsMobile as
|
|
29
|
-
import { useWindowSize as
|
|
30
|
-
import { handleImageUpload as
|
|
24
|
+
import { ArrowLeftIcon as O } from "../../tiptap-icons/arrow-left-icon.js";
|
|
25
|
+
import { HighlighterIcon as _ } from "../../tiptap-icons/highlighter-icon.js";
|
|
26
|
+
import { LinkIcon as q } from "../../tiptap-icons/link-icon.js";
|
|
27
|
+
import { useCursorVisibility as G } from "../../../hooks/use-cursor-visibility.js";
|
|
28
|
+
import { useIsMobile as W } from "../../../hooks/use-mobile.js";
|
|
29
|
+
import { useWindowSize as X } from "../../../hooks/use-window-size.js";
|
|
30
|
+
import { handleImageUpload as Z, MAX_FILE_SIZE as $ } from "../../../lib/tiptap-utils.js";
|
|
31
31
|
/* empty css */
|
|
32
|
-
import { InsertTableButton as
|
|
33
|
-
import
|
|
34
|
-
import { useTiptapEditor as
|
|
35
|
-
import { TableKit as
|
|
36
|
-
import { Toolbar as
|
|
32
|
+
import { InsertTableButton as J } from "../../tiptap-ui/insert-table-button/insert-table-button.js";
|
|
33
|
+
import Q from "../../tiptap-ui/table-actions-toolbar/table-actions-toolbar.js";
|
|
34
|
+
import { useTiptapEditor as Y } from "../../../hooks/use-tiptap-editor.js";
|
|
35
|
+
import { TableKit as tt } from "../../../node_modules/@tiptap/extension-table/dist/index.js";
|
|
36
|
+
import { Toolbar as ot, ToolbarGroup as m, ToolbarSeparator as a } from "../../tiptap-ui-primitive/toolbar/toolbar.js";
|
|
37
37
|
import { UndoRedoButton as T } from "../../tiptap-ui/undo-redo-button/undo-redo-button.js";
|
|
38
|
-
import { HeadingDropdownMenu as
|
|
39
|
-
import { ListDropdownMenu as
|
|
40
|
-
import { BlockquoteButton as
|
|
41
|
-
import { CodeBlockButton as
|
|
42
|
-
import { MarkButton as
|
|
43
|
-
import { ColorHighlightPopover as
|
|
44
|
-
import { LinkPopover as
|
|
38
|
+
import { HeadingDropdownMenu as rt } from "../../tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js";
|
|
39
|
+
import { ListDropdownMenu as et } from "../../tiptap-ui/list-dropdown-menu/list-dropdown-menu.js";
|
|
40
|
+
import { BlockquoteButton as it } from "../../tiptap-ui/blockquote-button/blockquote-button.js";
|
|
41
|
+
import { CodeBlockButton as nt } from "../../tiptap-ui/code-block-button/code-block-button.js";
|
|
42
|
+
import { MarkButton as l } from "../../tiptap-ui/mark-button/mark-button.js";
|
|
43
|
+
import { ColorHighlightPopover as lt, ColorHighlightPopoverButton as mt, ColorHighlightPopoverContent as at } from "../../tiptap-ui/color-highlight-popover/color-highlight-popover.js";
|
|
44
|
+
import { LinkPopover as pt, LinkButton as ct, LinkContent as st } from "../../tiptap-ui/link-popover/link-popover.js";
|
|
45
45
|
import { TextAlignButton as d } from "../../tiptap-ui/text-align-button/text-align-button.js";
|
|
46
|
-
import { Button as
|
|
47
|
-
const
|
|
48
|
-
onHighlighterClick:
|
|
49
|
-
onLinkClick:
|
|
50
|
-
isMobile:
|
|
46
|
+
import { Button as ut } from "../../tiptap-ui-primitive/button/button.js";
|
|
47
|
+
const ft = ({
|
|
48
|
+
onHighlighterClick: n,
|
|
49
|
+
onLinkClick: r,
|
|
50
|
+
isMobile: i
|
|
51
51
|
}) => {
|
|
52
|
-
const { editor: p } =
|
|
52
|
+
const { editor: p } = Y();
|
|
53
53
|
return /* @__PURE__ */ e(y, { children: [
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ e(m, { children: [
|
|
55
|
+
/* @__PURE__ */ t(T, { action: "undo" }),
|
|
56
|
+
/* @__PURE__ */ t(T, { action: "redo" })
|
|
57
57
|
] }),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */ e(
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
|
|
58
|
+
/* @__PURE__ */ t(a, {}),
|
|
59
|
+
/* @__PURE__ */ e(m, { children: [
|
|
60
|
+
/* @__PURE__ */ t(rt, { levels: [1, 2, 3, 4], portal: i }),
|
|
61
|
+
/* @__PURE__ */ t(
|
|
62
|
+
et,
|
|
63
63
|
{
|
|
64
64
|
types: ["bulletList", "orderedList", "taskList"],
|
|
65
|
-
portal:
|
|
65
|
+
portal: i
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ t(it, {}),
|
|
69
|
+
/* @__PURE__ */ t(nt, {})
|
|
70
70
|
] }),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */ e(
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
/* @__PURE__ */ t(a, {}),
|
|
72
|
+
/* @__PURE__ */ e(m, { children: [
|
|
73
|
+
/* @__PURE__ */ t(l, { type: "bold" }),
|
|
74
|
+
/* @__PURE__ */ t(l, { type: "italic" }),
|
|
75
|
+
/* @__PURE__ */ t(l, { type: "strike" }),
|
|
76
|
+
/* @__PURE__ */ t(l, { type: "code" }),
|
|
77
|
+
/* @__PURE__ */ t(l, { type: "underline" }),
|
|
78
|
+
i ? /* @__PURE__ */ t(mt, { onClick: n }) : /* @__PURE__ */ t(lt, {}),
|
|
79
|
+
i ? /* @__PURE__ */ t(ct, { onClick: r }) : /* @__PURE__ */ t(pt, {})
|
|
80
80
|
] }),
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ e(
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ t(a, {}),
|
|
82
|
+
/* @__PURE__ */ e(m, { children: [
|
|
83
|
+
/* @__PURE__ */ t(l, { type: "superscript" }),
|
|
84
|
+
/* @__PURE__ */ t(l, { type: "subscript" })
|
|
85
85
|
] }),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */ e(
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ t(a, {}),
|
|
87
|
+
/* @__PURE__ */ e(m, { children: [
|
|
88
|
+
/* @__PURE__ */ t(d, { align: "left" }),
|
|
89
|
+
/* @__PURE__ */ t(d, { align: "center" }),
|
|
90
|
+
/* @__PURE__ */ t(d, { align: "right" }),
|
|
91
|
+
/* @__PURE__ */ t(d, { align: "justify" })
|
|
92
92
|
] }),
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ t(a, {}),
|
|
94
|
+
/* @__PURE__ */ t(m, { children: /* @__PURE__ */ t(J, { onClick: () => {
|
|
95
95
|
p && p.chain().focus().insertTable({ rows: 3, cols: 3 }).run();
|
|
96
96
|
} }) }),
|
|
97
|
-
|
|
97
|
+
i && /* @__PURE__ */ t(a, {})
|
|
98
98
|
] });
|
|
99
|
-
},
|
|
100
|
-
type:
|
|
101
|
-
onBack:
|
|
99
|
+
}, dt = ({
|
|
100
|
+
type: n,
|
|
101
|
+
onBack: r
|
|
102
102
|
}) => /* @__PURE__ */ e(y, { children: [
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
|
|
103
|
+
/* @__PURE__ */ t(m, { children: /* @__PURE__ */ e(ut, { "data-style": "ghost", onClick: r, children: [
|
|
104
|
+
/* @__PURE__ */ t(O, { className: "tiptap-button-icon" }),
|
|
105
|
+
n === "highlighter" ? /* @__PURE__ */ t(_, { className: "tiptap-button-icon" }) : /* @__PURE__ */ t(q, { className: "tiptap-button-icon" })
|
|
106
106
|
] }) }),
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
109
|
-
] })
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
107
|
+
/* @__PURE__ */ t(a, {}),
|
|
108
|
+
n === "highlighter" ? /* @__PURE__ */ t(at, {}) : /* @__PURE__ */ t(st, {})
|
|
109
|
+
] });
|
|
110
|
+
function mo({
|
|
111
|
+
themeMode: n,
|
|
112
|
+
content: r,
|
|
113
|
+
onContentChange: i,
|
|
114
|
+
placeholder: p = "",
|
|
115
|
+
ref: b
|
|
116
|
+
}) {
|
|
117
|
+
const c = W(), { height: L } = X(), [s, u] = S(
|
|
118
|
+
"main"
|
|
119
|
+
), k = C(null), g = C(!1), o = H({
|
|
120
|
+
immediatelyRender: !0,
|
|
121
|
+
shouldRerenderOnTransaction: !1,
|
|
122
|
+
editorProps: {
|
|
123
|
+
attributes: {
|
|
124
|
+
autocomplete: "off",
|
|
125
|
+
autocorrect: "off",
|
|
126
|
+
autocapitalize: "off",
|
|
127
|
+
"aria-label": "Main content area, start typing to enter text.",
|
|
128
|
+
class: "simple-editor"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
extensions: [
|
|
132
|
+
V.configure({
|
|
133
|
+
horizontalRule: !1,
|
|
134
|
+
link: {
|
|
135
|
+
openOnClick: !1,
|
|
136
|
+
enableClickSelection: !0
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
D,
|
|
140
|
+
N.configure({ types: ["heading", "paragraph"] }),
|
|
141
|
+
R,
|
|
142
|
+
M.configure({ nested: !0 }),
|
|
143
|
+
w.configure({ multicolor: !0 }),
|
|
144
|
+
P,
|
|
145
|
+
A,
|
|
146
|
+
z,
|
|
147
|
+
U,
|
|
148
|
+
j,
|
|
149
|
+
K.configure({
|
|
150
|
+
accept: "image/*",
|
|
151
|
+
maxSize: $,
|
|
152
|
+
limit: 3,
|
|
153
|
+
upload: Z,
|
|
154
|
+
onError: (f) => console.error("Upload failed:", f)
|
|
155
|
+
}),
|
|
156
|
+
tt.configure({
|
|
157
|
+
table: {
|
|
158
|
+
resizable: !0
|
|
126
159
|
}
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
160
|
+
}),
|
|
161
|
+
F.configure({
|
|
162
|
+
placeholder: p
|
|
163
|
+
})
|
|
164
|
+
],
|
|
165
|
+
content: r,
|
|
166
|
+
onUpdate: ({ editor: f }) => {
|
|
167
|
+
if (!g.current && i) {
|
|
168
|
+
const B = f.getHTML();
|
|
169
|
+
i(B);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}), I = G({
|
|
173
|
+
editor: o,
|
|
174
|
+
overlayHeight: k.current?.getBoundingClientRect().height ?? 0
|
|
175
|
+
});
|
|
176
|
+
return h(() => {
|
|
177
|
+
!c && s !== "main" && u("main");
|
|
178
|
+
}, [c, s]), h(() => {
|
|
179
|
+
o && r !== void 0 && o.getHTML() !== r && (g.current = !0, o.commands.setContent(r, { emitUpdate: !1 }), g.current = !1);
|
|
180
|
+
}, [r, o]), h(() => {
|
|
181
|
+
document.documentElement.classList.toggle("dark", n === "dark");
|
|
182
|
+
}, [n]), x(
|
|
183
|
+
b,
|
|
184
|
+
() => ({
|
|
185
|
+
getEditor: () => o
|
|
186
|
+
}),
|
|
187
|
+
[o]
|
|
188
|
+
), o ? /* @__PURE__ */ t("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ e(v.Provider, { value: { editor: o }, children: [
|
|
189
|
+
/* @__PURE__ */ t(
|
|
190
|
+
ot,
|
|
191
|
+
{
|
|
192
|
+
ref: k,
|
|
193
|
+
style: {
|
|
194
|
+
...c ? {
|
|
195
|
+
bottom: `calc(100% - ${L - I.y}px)`
|
|
196
|
+
} : {}
|
|
197
|
+
},
|
|
198
|
+
children: s === "main" ? /* @__PURE__ */ t(
|
|
199
|
+
ft,
|
|
200
|
+
{
|
|
201
|
+
onHighlighterClick: () => u("highlighter"),
|
|
202
|
+
onLinkClick: () => u("link"),
|
|
203
|
+
isMobile: c
|
|
134
204
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
R.configure({ multicolor: !0 }),
|
|
141
|
-
P,
|
|
142
|
-
j,
|
|
143
|
-
N,
|
|
144
|
-
z,
|
|
145
|
-
F,
|
|
146
|
-
O.configure({
|
|
147
|
-
accept: "image/*",
|
|
148
|
-
maxSize: J,
|
|
149
|
-
limit: 3,
|
|
150
|
-
upload: $,
|
|
151
|
-
onError: (f) => console.error("Upload failed:", f)
|
|
152
|
-
}),
|
|
153
|
-
to.configure({
|
|
154
|
-
table: {
|
|
155
|
-
resizable: !0
|
|
205
|
+
) : /* @__PURE__ */ t(
|
|
206
|
+
dt,
|
|
207
|
+
{
|
|
208
|
+
type: s === "highlighter" ? "highlighter" : "link",
|
|
209
|
+
onBack: () => u("main")
|
|
156
210
|
}
|
|
157
|
-
|
|
158
|
-
V.configure({
|
|
159
|
-
placeholder: b
|
|
160
|
-
})
|
|
161
|
-
],
|
|
162
|
-
content: t,
|
|
163
|
-
onUpdate: ({ editor: f }) => {
|
|
164
|
-
!g.current && p && p(f.getHTML());
|
|
211
|
+
)
|
|
165
212
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
() => ({
|
|
179
|
-
getEditor: () => r
|
|
180
|
-
}),
|
|
181
|
-
[r]
|
|
182
|
-
), r ? /* @__PURE__ */ o("div", { className: "simple-editor-wrapper", children: /* @__PURE__ */ e(H.Provider, { value: { editor: r }, children: [
|
|
183
|
-
/* @__PURE__ */ o(
|
|
184
|
-
ro,
|
|
185
|
-
{
|
|
186
|
-
ref: k,
|
|
187
|
-
style: {
|
|
188
|
-
...c ? { bottom: `calc(100% - ${I - B.y}px)` } : {}
|
|
189
|
-
},
|
|
190
|
-
children: s === "main" ? /* @__PURE__ */ o(
|
|
191
|
-
go,
|
|
192
|
-
{
|
|
193
|
-
onHighlighterClick: () => u("highlighter"),
|
|
194
|
-
onLinkClick: () => u("link"),
|
|
195
|
-
isMobile: c
|
|
196
|
-
}
|
|
197
|
-
) : /* @__PURE__ */ o(
|
|
198
|
-
ho,
|
|
199
|
-
{
|
|
200
|
-
type: s === "highlighter" ? "highlighter" : "link",
|
|
201
|
-
onBack: () => u("main")
|
|
202
|
-
}
|
|
203
|
-
)
|
|
204
|
-
}
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ o(Y, {}),
|
|
207
|
-
/* @__PURE__ */ o(
|
|
208
|
-
S,
|
|
209
|
-
{
|
|
210
|
-
editor: r,
|
|
211
|
-
role: "presentation",
|
|
212
|
-
className: "simple-editor-content"
|
|
213
|
-
}
|
|
214
|
-
)
|
|
215
|
-
] }) }) : null;
|
|
216
|
-
}
|
|
217
|
-
);
|
|
213
|
+
),
|
|
214
|
+
/* @__PURE__ */ t(Q, {}),
|
|
215
|
+
/* @__PURE__ */ t(
|
|
216
|
+
E,
|
|
217
|
+
{
|
|
218
|
+
editor: o,
|
|
219
|
+
role: "presentation",
|
|
220
|
+
className: "simple-editor-content"
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] }) }) : null;
|
|
224
|
+
}
|
|
218
225
|
export {
|
|
219
|
-
|
|
226
|
+
mo as SimpleEditor
|
|
220
227
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jsx as t, jsxs as u } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as H,
|
|
2
|
+
import { forwardRef as H, useRef as I, useMemo as y, useState as x } from "react";
|
|
3
3
|
import "@tiptap/react";
|
|
4
4
|
import { useMenuNavigation as B } from "../../../hooks/use-menu-navigation.js";
|
|
5
5
|
import { useIsMobile as P } from "../../../hooks/use-mobile.js";
|
|
6
6
|
import { useTiptapEditor as R } from "../../../hooks/use-tiptap-editor.js";
|
|
7
7
|
import { BanIcon as S } from "../../tiptap-icons/ban-icon.js";
|
|
8
8
|
import { HighlighterIcon as N } from "../../tiptap-icons/highlighter-icon.js";
|
|
9
|
-
import { Popover as w, PopoverTrigger as M, PopoverContent as k } from "../../tiptap-ui-primitive/popover/popover.js";
|
|
10
9
|
import { useColorHighlight as m, pickHighlightColorsByValue as f } from "../color-highlight-button/use-color-highlight.js";
|
|
11
|
-
import { Card as
|
|
10
|
+
import { Card as w, CardBody as M, CardItemGroup as k } from "../../tiptap-ui-primitive/card/card.js";
|
|
12
11
|
import { Button as b, ButtonGroup as d } from "../../tiptap-ui-primitive/button/button.js";
|
|
13
|
-
import { ColorHighlightButton as
|
|
12
|
+
import { ColorHighlightButton as z } from "../color-highlight-button/color-highlight-button.js";
|
|
13
|
+
import { Popover as O, PopoverTrigger as j, PopoverContent as E } from "../../tiptap-ui-primitive/popover/popover.js";
|
|
14
14
|
import { Separator as G } from "../../tiptap-ui-primitive/separator/separator.js";
|
|
15
15
|
const v = H(({ className: l, children: o, ...r }, a) => /* @__PURE__ */ t(
|
|
16
16
|
b,
|
|
@@ -39,7 +39,7 @@ function T({
|
|
|
39
39
|
"var(--tt-color-highlight-yellow)"
|
|
40
40
|
])
|
|
41
41
|
}) {
|
|
42
|
-
const { handleRemoveHighlight: r } = m({ editor: l }), a = P(), h =
|
|
42
|
+
const { handleRemoveHighlight: r } = m({ editor: l }), a = P(), h = I(null), g = y(
|
|
43
43
|
() => [...o, { label: "Remove highlight", value: "none" }],
|
|
44
44
|
[o]
|
|
45
45
|
), { selectedIndex: n } = B({
|
|
@@ -56,14 +56,14 @@ function T({
|
|
|
56
56
|
autoSelectFirstItem: !1
|
|
57
57
|
});
|
|
58
58
|
return /* @__PURE__ */ t(
|
|
59
|
-
|
|
59
|
+
w,
|
|
60
60
|
{
|
|
61
61
|
ref: h,
|
|
62
62
|
tabIndex: 0,
|
|
63
63
|
style: a ? { boxShadow: "none", border: 0 } : {},
|
|
64
|
-
children: /* @__PURE__ */ t(
|
|
64
|
+
children: /* @__PURE__ */ t(M, { style: a ? { padding: 0 } : {}, children: /* @__PURE__ */ u(k, { orientation: "horizontal", children: [
|
|
65
65
|
/* @__PURE__ */ t(d, { orientation: "horizontal", children: o.map((e, i) => /* @__PURE__ */ t(
|
|
66
|
-
|
|
66
|
+
z,
|
|
67
67
|
{
|
|
68
68
|
editor: l,
|
|
69
69
|
highlightColor: e.value,
|
|
@@ -106,13 +106,13 @@ function Z({
|
|
|
106
106
|
onApplied: a,
|
|
107
107
|
...h
|
|
108
108
|
}) {
|
|
109
|
-
const { editor: g } = R(l), [n, e] =
|
|
109
|
+
const { editor: g } = R(l), [n, e] = x(!1), { isVisible: i, canColorHighlight: p, isActive: s, label: c, Icon: C } = m({
|
|
110
110
|
editor: g,
|
|
111
111
|
hideWhenUnavailable: r,
|
|
112
112
|
onApplied: a
|
|
113
113
|
});
|
|
114
|
-
return i ? /* @__PURE__ */ u(
|
|
115
|
-
/* @__PURE__ */ t(
|
|
114
|
+
return i ? /* @__PURE__ */ u(O, { open: n, onOpenChange: e, children: [
|
|
115
|
+
/* @__PURE__ */ t(j, { asChild: !0, children: /* @__PURE__ */ t(
|
|
116
116
|
v,
|
|
117
117
|
{
|
|
118
118
|
disabled: !p,
|
|
@@ -125,7 +125,7 @@ function Z({
|
|
|
125
125
|
children: /* @__PURE__ */ t(C, { className: "tiptap-button-icon" })
|
|
126
126
|
}
|
|
127
127
|
) }),
|
|
128
|
-
/* @__PURE__ */ t(
|
|
128
|
+
/* @__PURE__ */ t(E, { "aria-label": "Highlight colors", children: /* @__PURE__ */ t(T, { editor: g, colors: o }) })
|
|
129
129
|
] }) : null;
|
|
130
130
|
}
|
|
131
131
|
export {
|
|
@@ -4,7 +4,7 @@ import { ListIcon as u } from "../../tiptap-icons/list-icon.js";
|
|
|
4
4
|
import { ListOrderedIcon as A } from "../../tiptap-icons/list-ordered-icon.js";
|
|
5
5
|
import { ListTodoIcon as h } from "../../tiptap-icons/list-todo-icon.js";
|
|
6
6
|
import { isNodeInSchema as T } from "../../../lib/tiptap-utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { canToggleList as I, isListActive as d, listIcons as E } from "../list-button/use-list.js";
|
|
8
8
|
const S = [
|
|
9
9
|
{
|
|
10
10
|
label: "Bullet List",
|
|
@@ -23,7 +23,7 @@ const S = [
|
|
|
23
23
|
}
|
|
24
24
|
];
|
|
25
25
|
function U(t, i) {
|
|
26
|
-
return !t || !t.isEditable ? !1 : i.some((e) =>
|
|
26
|
+
return !t || !t.isEditable ? !1 : i.some((e) => I(t, e));
|
|
27
27
|
}
|
|
28
28
|
function O(t, i) {
|
|
29
29
|
return !t || !t.isEditable ? !1 : i.some((e) => d(t, e));
|
|
@@ -70,7 +70,7 @@ function j(t) {
|
|
|
70
70
|
types: e,
|
|
71
71
|
filteredLists: l,
|
|
72
72
|
label: "List",
|
|
73
|
-
Icon: f ?
|
|
73
|
+
Icon: f ? E[f.type] : u
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
export {
|