@dooherceg/tiptap-controlled-editor-with-table 0.0.8 → 0.0.9
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 +1 -3
- package/dist/components/tiptap-templates/simple/simple-editor.js +185 -192
- 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,13 +1,11 @@
|
|
|
1
1
|
import { Editor, EditorOptions } from '@tiptap/react';
|
|
2
|
-
import { Ref } from 'react';
|
|
3
2
|
export interface SimpleEditorProps extends Omit<Partial<EditorOptions>, "content"> {
|
|
4
3
|
themeMode: "dark" | "light";
|
|
5
4
|
content?: string;
|
|
6
5
|
onContentChange?: (content: string) => void;
|
|
7
6
|
placeholder?: string;
|
|
8
|
-
ref?: Ref<SimpleEditorRef>;
|
|
9
7
|
}
|
|
10
8
|
export interface SimpleEditorRef {
|
|
11
9
|
getEditor: () => Editor | null;
|
|
12
10
|
}
|
|
13
|
-
export declare
|
|
11
|
+
export declare const SimpleEditor: import('react').ForwardRefExoticComponent<SimpleEditorProps & import('react').RefAttributes<SimpleEditorRef>>;
|
|
@@ -1,227 +1,220 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useEditor as
|
|
3
|
-
import { useState as
|
|
1
|
+
import { jsx as o, jsxs as e, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useEditor as E, EditorContext as H, EditorContent as S } from "@tiptap/react";
|
|
3
|
+
import { forwardRef as v, useState as x, useRef as C, useEffect as h, useImperativeHandle as w } 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 R } 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 M, TaskItem as U } from "../../../node_modules/@tiptap/extension-list/dist/index.js";
|
|
9
|
+
import { Subscript as z } from "../../../node_modules/@tiptap/extension-subscript/dist/index.js";
|
|
10
|
+
import { Superscript as N } from "../../../node_modules/@tiptap/extension-superscript/dist/index.js";
|
|
11
|
+
import { TextAlign as A } from "../../../node_modules/@tiptap/extension-text-align/dist/index.js";
|
|
12
|
+
import { Typography as j } from "../../../node_modules/@tiptap/extension-typography/dist/index.js";
|
|
13
|
+
import { Selection as F, Placeholder as V } from "../../../node_modules/@tiptap/extensions/dist/index.js";
|
|
14
|
+
import { StarterKit as D } from "@tiptap/starter-kit";
|
|
15
15
|
/* empty css */
|
|
16
16
|
/* empty css */
|
|
17
17
|
/* empty css */
|
|
18
|
-
import { HorizontalRule as
|
|
18
|
+
import { HorizontalRule as K } 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 O } 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 _ } from "../../tiptap-icons/arrow-left-icon.js";
|
|
25
|
+
import { HighlighterIcon as q } from "../../tiptap-icons/highlighter-icon.js";
|
|
26
|
+
import { LinkIcon as G } from "../../tiptap-icons/link-icon.js";
|
|
27
|
+
import { useCursorVisibility as W } from "../../../hooks/use-cursor-visibility.js";
|
|
28
|
+
import { useIsMobile as X } from "../../../hooks/use-mobile.js";
|
|
29
|
+
import { useWindowSize as Z } from "../../../hooks/use-window-size.js";
|
|
30
|
+
import { handleImageUpload as $, MAX_FILE_SIZE as J } 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 Q } from "../../tiptap-ui/insert-table-button/insert-table-button.js";
|
|
33
|
+
import Y from "../../tiptap-ui/table-actions-toolbar/table-actions-toolbar.js";
|
|
34
|
+
import { useTiptapEditor as oo } from "../../../hooks/use-tiptap-editor.js";
|
|
35
|
+
import { TableKit as to } from "../../../node_modules/@tiptap/extension-table/dist/index.js";
|
|
36
|
+
import { Toolbar as ro, ToolbarGroup as n, ToolbarSeparator as l } 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 eo } from "../../tiptap-ui/heading-dropdown-menu/heading-dropdown-menu.js";
|
|
39
|
+
import { ListDropdownMenu as io } from "../../tiptap-ui/list-dropdown-menu/list-dropdown-menu.js";
|
|
40
|
+
import { BlockquoteButton as no } from "../../tiptap-ui/blockquote-button/blockquote-button.js";
|
|
41
|
+
import { CodeBlockButton as lo } from "../../tiptap-ui/code-block-button/code-block-button.js";
|
|
42
|
+
import { MarkButton as i } from "../../tiptap-ui/mark-button/mark-button.js";
|
|
43
|
+
import { ColorHighlightPopover as mo, ColorHighlightPopoverButton as ao, ColorHighlightPopoverContent as po } from "../../tiptap-ui/color-highlight-popover/color-highlight-popover.js";
|
|
44
|
+
import { LinkPopover as co, LinkButton as so, LinkContent as uo } 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 fo } from "../../tiptap-ui-primitive/button/button.js";
|
|
47
|
+
const go = ({
|
|
48
|
+
onHighlighterClick: a,
|
|
49
|
+
onLinkClick: m,
|
|
50
|
+
isMobile: t
|
|
51
51
|
}) => {
|
|
52
|
-
const { editor: p } =
|
|
52
|
+
const { editor: p } = oo();
|
|
53
53
|
return /* @__PURE__ */ e(y, { children: [
|
|
54
|
-
/* @__PURE__ */ e(
|
|
55
|
-
/* @__PURE__ */
|
|
56
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ e(n, { children: [
|
|
55
|
+
/* @__PURE__ */ o(T, { action: "undo" }),
|
|
56
|
+
/* @__PURE__ */ o(T, { action: "redo" })
|
|
57
57
|
] }),
|
|
58
|
-
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */ e(
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
|
|
58
|
+
/* @__PURE__ */ o(l, {}),
|
|
59
|
+
/* @__PURE__ */ e(n, { children: [
|
|
60
|
+
/* @__PURE__ */ o(eo, { levels: [1, 2, 3, 4], portal: t }),
|
|
61
|
+
/* @__PURE__ */ o(
|
|
62
|
+
io,
|
|
63
63
|
{
|
|
64
64
|
types: ["bulletList", "orderedList", "taskList"],
|
|
65
|
-
portal:
|
|
65
|
+
portal: t
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ o(no, {}),
|
|
69
|
+
/* @__PURE__ */ o(lo, {})
|
|
70
70
|
] }),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
/* @__PURE__ */ e(
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
/* @__PURE__ */ o(l, {}),
|
|
72
|
+
/* @__PURE__ */ e(n, { children: [
|
|
73
|
+
/* @__PURE__ */ o(i, { type: "bold" }),
|
|
74
|
+
/* @__PURE__ */ o(i, { type: "italic" }),
|
|
75
|
+
/* @__PURE__ */ o(i, { type: "strike" }),
|
|
76
|
+
/* @__PURE__ */ o(i, { type: "code" }),
|
|
77
|
+
/* @__PURE__ */ o(i, { type: "underline" }),
|
|
78
|
+
t ? /* @__PURE__ */ o(ao, { onClick: a }) : /* @__PURE__ */ o(mo, {}),
|
|
79
|
+
t ? /* @__PURE__ */ o(so, { onClick: m }) : /* @__PURE__ */ o(co, {})
|
|
80
80
|
] }),
|
|
81
|
-
/* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ e(
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ o(l, {}),
|
|
82
|
+
/* @__PURE__ */ e(n, { children: [
|
|
83
|
+
/* @__PURE__ */ o(i, { type: "superscript" }),
|
|
84
|
+
/* @__PURE__ */ o(i, { type: "subscript" })
|
|
85
85
|
] }),
|
|
86
|
-
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */ e(
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ o(l, {}),
|
|
87
|
+
/* @__PURE__ */ e(n, { children: [
|
|
88
|
+
/* @__PURE__ */ o(d, { align: "left" }),
|
|
89
|
+
/* @__PURE__ */ o(d, { align: "center" }),
|
|
90
|
+
/* @__PURE__ */ o(d, { align: "right" }),
|
|
91
|
+
/* @__PURE__ */ o(d, { align: "justify" })
|
|
92
92
|
] }),
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ o(l, {}),
|
|
94
|
+
/* @__PURE__ */ o(n, { children: /* @__PURE__ */ o(Q, { onClick: () => {
|
|
95
95
|
p && p.chain().focus().insertTable({ rows: 3, cols: 3 }).run();
|
|
96
96
|
} }) }),
|
|
97
|
-
|
|
97
|
+
t && /* @__PURE__ */ o(l, {})
|
|
98
98
|
] });
|
|
99
|
-
},
|
|
100
|
-
type:
|
|
101
|
-
onBack:
|
|
99
|
+
}, ho = ({
|
|
100
|
+
type: a,
|
|
101
|
+
onBack: m
|
|
102
102
|
}) => /* @__PURE__ */ e(y, { children: [
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
|
|
103
|
+
/* @__PURE__ */ o(n, { children: /* @__PURE__ */ e(fo, { "data-style": "ghost", onClick: m, children: [
|
|
104
|
+
/* @__PURE__ */ o(_, { className: "tiptap-button-icon" }),
|
|
105
|
+
a === "highlighter" ? /* @__PURE__ */ o(q, { className: "tiptap-button-icon" }) : /* @__PURE__ */ o(G, { className: "tiptap-button-icon" })
|
|
106
106
|
] }) }),
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
109
|
-
] })
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
|
107
|
+
/* @__PURE__ */ o(l, {}),
|
|
108
|
+
a === "highlighter" ? /* @__PURE__ */ o(po, {}) : /* @__PURE__ */ o(uo, {})
|
|
109
|
+
] }), pt = v(
|
|
110
|
+
function({
|
|
111
|
+
themeMode: m,
|
|
112
|
+
content: t,
|
|
113
|
+
onContentChange: p,
|
|
114
|
+
placeholder: b = ""
|
|
115
|
+
}, L) {
|
|
116
|
+
const c = X(), { height: I } = Z(), [s, u] = x("main"), k = C(null), g = C(!1), r = E({
|
|
117
|
+
immediatelyRender: !0,
|
|
118
|
+
shouldRerenderOnTransaction: !1,
|
|
119
|
+
editorProps: {
|
|
120
|
+
attributes: {
|
|
121
|
+
autocomplete: "off",
|
|
122
|
+
autocorrect: "off",
|
|
123
|
+
autocapitalize: "off",
|
|
124
|
+
"aria-label": "Main content area, start typing to enter text.",
|
|
125
|
+
class: "simple-editor"
|
|
159
126
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
|
127
|
+
},
|
|
128
|
+
extensions: [
|
|
129
|
+
D.configure({
|
|
130
|
+
horizontalRule: !1,
|
|
131
|
+
link: {
|
|
132
|
+
openOnClick: !1,
|
|
133
|
+
enableClickSelection: !0
|
|
204
134
|
}
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
135
|
+
}),
|
|
136
|
+
K,
|
|
137
|
+
A.configure({ types: ["heading", "paragraph"] }),
|
|
138
|
+
M,
|
|
139
|
+
U.configure({ nested: !0 }),
|
|
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
|
|
210
156
|
}
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{
|
|
218
|
-
|
|
219
|
-
role: "presentation",
|
|
220
|
-
className: "simple-editor-content"
|
|
157
|
+
}),
|
|
158
|
+
V.configure({
|
|
159
|
+
placeholder: b
|
|
160
|
+
})
|
|
161
|
+
],
|
|
162
|
+
content: t,
|
|
163
|
+
onUpdate: ({ editor: f }) => {
|
|
164
|
+
!g.current && p && p(f.getHTML());
|
|
221
165
|
}
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
|
|
166
|
+
}), B = W({
|
|
167
|
+
editor: r,
|
|
168
|
+
overlayHeight: k.current?.getBoundingClientRect().height ?? 0
|
|
169
|
+
});
|
|
170
|
+
return h(() => {
|
|
171
|
+
!c && s !== "main" && u("main");
|
|
172
|
+
}, [c, s]), h(() => {
|
|
173
|
+
r && t !== void 0 && r.getHTML() !== t && (g.current = !0, r.commands.setContent(t, { emitUpdate: !1 }), g.current = !1);
|
|
174
|
+
}, [t, r]), h(() => {
|
|
175
|
+
document.documentElement.classList.toggle("dark", m === "dark");
|
|
176
|
+
}, [m]), w(
|
|
177
|
+
L,
|
|
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
|
+
);
|
|
225
218
|
export {
|
|
226
|
-
|
|
219
|
+
pt as SimpleEditor
|
|
227
220
|
};
|
|
@@ -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, useState as I, useRef as y, useMemo 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";
|
|
9
10
|
import { useColorHighlight as m, pickHighlightColorsByValue as f } from "../color-highlight-button/use-color-highlight.js";
|
|
10
|
-
import { Card as
|
|
11
|
+
import { Card as z, CardBody as O, CardItemGroup as j } from "../../tiptap-ui-primitive/card/card.js";
|
|
11
12
|
import { Button as b, ButtonGroup as d } from "../../tiptap-ui-primitive/button/button.js";
|
|
12
|
-
import { ColorHighlightButton as
|
|
13
|
-
import { Popover as O, PopoverTrigger as j, PopoverContent as E } from "../../tiptap-ui-primitive/popover/popover.js";
|
|
13
|
+
import { ColorHighlightButton as E } from "../color-highlight-button/color-highlight-button.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 = y(null), g = x(
|
|
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
|
+
z,
|
|
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(O, { style: a ? { padding: 0 } : {}, children: /* @__PURE__ */ u(j, { orientation: "horizontal", children: [
|
|
65
65
|
/* @__PURE__ */ t(d, { orientation: "horizontal", children: o.map((e, i) => /* @__PURE__ */ t(
|
|
66
|
-
|
|
66
|
+
E,
|
|
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] = I(!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(w, { open: n, onOpenChange: e, children: [
|
|
115
|
+
/* @__PURE__ */ t(M, { 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(k, { "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 { listIcons as I, canToggleList as E, isListActive as d } 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) => E(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 ? I[f.type] : u
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
export {
|