@editorcn/editor 0.5.3 → 0.6.0
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +651 -646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +576 -571
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/rich-text-editor.tsx
|
|
2
2
|
import { useEffect as useEffect6, useMemo as useMemo2, useState as useState8 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/bubble-menu/index.tsx
|
|
@@ -7,8 +7,7 @@ import { BubbleMenu as TiptapBubbleMenu } from "@tiptap/react/menus";
|
|
|
7
7
|
import { useCallback as useCallback3 } from "react";
|
|
8
8
|
|
|
9
9
|
// src/ui/button.tsx
|
|
10
|
-
import
|
|
11
|
-
import { cva } from "class-variance-authority";
|
|
10
|
+
import * as React from "react";
|
|
12
11
|
|
|
13
12
|
// src/ui/utils.ts
|
|
14
13
|
import { clsx } from "clsx";
|
|
@@ -17,238 +16,23 @@ var cn = (...inputs) => twMerge(clsx(inputs));
|
|
|
17
16
|
|
|
18
17
|
// src/ui/button.tsx
|
|
19
18
|
import { jsx } from "react/jsx-runtime";
|
|
20
|
-
var
|
|
21
|
-
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
22
|
-
{
|
|
23
|
-
defaultVariants: {
|
|
24
|
-
size: "default",
|
|
25
|
-
variant: "default"
|
|
26
|
-
},
|
|
27
|
-
variants: {
|
|
28
|
-
size: {
|
|
29
|
-
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
30
|
-
icon: "size-8",
|
|
31
|
-
"icon-lg": "size-9",
|
|
32
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
33
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
34
|
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
35
|
-
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
36
|
-
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3"
|
|
37
|
-
},
|
|
38
|
-
variant: {
|
|
39
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
40
|
-
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
41
|
-
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
42
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
43
|
-
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
44
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
var Button = ({
|
|
50
|
-
className,
|
|
51
|
-
variant = "default",
|
|
52
|
-
size = "default",
|
|
53
|
-
...props
|
|
54
|
-
}) => /* @__PURE__ */ jsx(
|
|
55
|
-
ButtonPrimitive,
|
|
56
|
-
{
|
|
57
|
-
"data-slot": "button",
|
|
58
|
-
className: cn(buttonVariants({ className, size, variant })),
|
|
59
|
-
...props
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
// src/ui/dialog.tsx
|
|
64
|
-
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
65
|
-
import "react";
|
|
66
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
67
|
-
var Dialog = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
68
|
-
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
69
|
-
var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
70
|
-
var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx2(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
71
|
-
var DialogOverlay = ({
|
|
72
|
-
className,
|
|
73
|
-
...props
|
|
74
|
-
}) => /* @__PURE__ */ jsx2(
|
|
75
|
-
DialogPrimitive.Backdrop,
|
|
76
|
-
{
|
|
77
|
-
"data-slot": "dialog-overlay",
|
|
78
|
-
className: cn(
|
|
79
|
-
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
80
|
-
className
|
|
81
|
-
),
|
|
82
|
-
...props
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
var DialogContent = ({
|
|
86
|
-
className,
|
|
87
|
-
children,
|
|
88
|
-
showCloseButton = true,
|
|
89
|
-
...props
|
|
90
|
-
}) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
|
|
91
|
-
/* @__PURE__ */ jsx2(DialogOverlay, {}),
|
|
92
|
-
/* @__PURE__ */ jsxs(
|
|
93
|
-
DialogPrimitive.Popup,
|
|
94
|
-
{
|
|
95
|
-
"data-slot": "dialog-content",
|
|
96
|
-
className: cn(
|
|
97
|
-
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-xs/relaxed text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
98
|
-
className
|
|
99
|
-
),
|
|
100
|
-
...props,
|
|
101
|
-
children: [
|
|
102
|
-
children,
|
|
103
|
-
showCloseButton && /* @__PURE__ */ jsxs(
|
|
104
|
-
DialogPrimitive.Close,
|
|
105
|
-
{
|
|
106
|
-
"data-slot": "dialog-close",
|
|
107
|
-
render: /* @__PURE__ */ jsx2(
|
|
108
|
-
Button,
|
|
109
|
-
{
|
|
110
|
-
variant: "ghost",
|
|
111
|
-
className: "absolute top-2 right-2",
|
|
112
|
-
size: "icon-sm"
|
|
113
|
-
}
|
|
114
|
-
),
|
|
115
|
-
children: [
|
|
116
|
-
"X",
|
|
117
|
-
/* @__PURE__ */ jsx2("span", { className: "sr-only", children: "Close" })
|
|
118
|
-
]
|
|
119
|
-
}
|
|
120
|
-
)
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
)
|
|
124
|
-
] });
|
|
125
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx2(
|
|
126
|
-
"div",
|
|
127
|
-
{
|
|
128
|
-
"data-slot": "dialog-header",
|
|
129
|
-
className: cn("flex flex-col gap-1 text-left", className),
|
|
130
|
-
...props
|
|
131
|
-
}
|
|
132
|
-
);
|
|
133
|
-
var DialogFooter = ({
|
|
134
|
-
className,
|
|
135
|
-
showCloseButton = false,
|
|
136
|
-
children,
|
|
137
|
-
...props
|
|
138
|
-
}) => /* @__PURE__ */ jsxs(
|
|
139
|
-
"div",
|
|
140
|
-
{
|
|
141
|
-
"data-slot": "dialog-footer",
|
|
142
|
-
className: cn(
|
|
143
|
-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
144
|
-
className
|
|
145
|
-
),
|
|
146
|
-
...props,
|
|
147
|
-
children: [
|
|
148
|
-
children,
|
|
149
|
-
showCloseButton && /* @__PURE__ */ jsx2(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx2(Button, { variant: "outline" }), children: "Close" })
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
);
|
|
153
|
-
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx2(
|
|
154
|
-
DialogPrimitive.Title,
|
|
155
|
-
{
|
|
156
|
-
"data-slot": "dialog-title",
|
|
157
|
-
className: cn("text-sm font-medium", className),
|
|
158
|
-
...props
|
|
159
|
-
}
|
|
160
|
-
);
|
|
161
|
-
var DialogDescription = ({
|
|
162
|
-
className,
|
|
163
|
-
...props
|
|
164
|
-
}) => /* @__PURE__ */ jsx2(
|
|
165
|
-
DialogPrimitive.Description,
|
|
166
|
-
{
|
|
167
|
-
"data-slot": "dialog-description",
|
|
168
|
-
className: cn(
|
|
169
|
-
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
170
|
-
className
|
|
171
|
-
),
|
|
172
|
-
...props
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
// src/ui/input.tsx
|
|
177
|
-
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
178
|
-
import "react";
|
|
179
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
180
|
-
var Input = ({
|
|
181
|
-
className,
|
|
182
|
-
type,
|
|
183
|
-
...props
|
|
184
|
-
}) => /* @__PURE__ */ jsx3(
|
|
185
|
-
InputPrimitive,
|
|
186
|
-
{
|
|
187
|
-
type,
|
|
188
|
-
"data-slot": "input",
|
|
189
|
-
className: cn(
|
|
190
|
-
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
191
|
-
className
|
|
192
|
-
),
|
|
193
|
-
...props
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
// src/ui/popover.tsx
|
|
198
|
-
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
199
|
-
import "react";
|
|
200
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
201
|
-
var Popover = ({ ...props }) => /* @__PURE__ */ jsx4(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
202
|
-
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ jsx4(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
203
|
-
var PopoverContent = ({
|
|
204
|
-
className,
|
|
205
|
-
align = "center",
|
|
206
|
-
alignOffset = 0,
|
|
207
|
-
side = "bottom",
|
|
208
|
-
sideOffset = 4,
|
|
209
|
-
...props
|
|
210
|
-
}) => /* @__PURE__ */ jsx4(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx4(
|
|
211
|
-
PopoverPrimitive.Positioner,
|
|
212
|
-
{
|
|
213
|
-
align,
|
|
214
|
-
alignOffset,
|
|
215
|
-
side,
|
|
216
|
-
sideOffset,
|
|
217
|
-
className: "isolate z-50",
|
|
218
|
-
children: /* @__PURE__ */ jsx4(
|
|
219
|
-
PopoverPrimitive.Popup,
|
|
220
|
-
{
|
|
221
|
-
"data-slot": "popover-content",
|
|
222
|
-
className: cn(
|
|
223
|
-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
224
|
-
className
|
|
225
|
-
),
|
|
226
|
-
...props
|
|
227
|
-
}
|
|
228
|
-
)
|
|
229
|
-
}
|
|
230
|
-
) });
|
|
231
|
-
|
|
232
|
-
// src/ui/rte-button.tsx
|
|
233
|
-
import * as React4 from "react";
|
|
234
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
235
|
-
var RteButton = React4.forwardRef(
|
|
19
|
+
var Button = React.forwardRef(
|
|
236
20
|
({ className, active = false, ...props }, ref) => {
|
|
237
21
|
const cls = cn(
|
|
238
22
|
"rte-bubble-btn flex h-8 min-w-8 cursor-pointer items-center justify-center gap-1 rounded-md border-none bg-transparent px-2 text-[0.8125rem] font-medium whitespace-nowrap text-popover-foreground [transition:background-color_150ms_ease-out,color_150ms_ease-out,scale_100ms_ease-out] hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-ring/50 focus-visible:-outline-offset-2 active:scale-96",
|
|
239
23
|
active && "rte-bubble-btn--active bg-muted text-foreground",
|
|
240
24
|
className
|
|
241
25
|
);
|
|
242
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ jsx("button", { ref, type: "button", className: cls, ...props });
|
|
243
27
|
}
|
|
244
28
|
);
|
|
245
|
-
|
|
29
|
+
Button.displayName = "Button";
|
|
246
30
|
|
|
247
|
-
// src/ui/
|
|
248
|
-
import * as
|
|
249
|
-
import { jsx as
|
|
250
|
-
var
|
|
251
|
-
({ className, ...props }, ref) => /* @__PURE__ */
|
|
31
|
+
// src/ui/button-group.tsx
|
|
32
|
+
import * as React2 from "react";
|
|
33
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
34
|
+
var ButtonGroup = React2.forwardRef(
|
|
35
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx2(
|
|
252
36
|
"div",
|
|
253
37
|
{
|
|
254
38
|
ref,
|
|
@@ -257,13 +41,13 @@ var RteButtonGroup = React5.forwardRef(
|
|
|
257
41
|
}
|
|
258
42
|
)
|
|
259
43
|
);
|
|
260
|
-
|
|
44
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
261
45
|
|
|
262
|
-
// src/ui/
|
|
263
|
-
import * as
|
|
264
|
-
import { jsx as
|
|
265
|
-
var
|
|
266
|
-
({ className, ...props }, ref) => /* @__PURE__ */
|
|
46
|
+
// src/ui/icon.tsx
|
|
47
|
+
import * as React3 from "react";
|
|
48
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
49
|
+
var Icon = React3.forwardRef(
|
|
50
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
267
51
|
"span",
|
|
268
52
|
{
|
|
269
53
|
ref,
|
|
@@ -275,13 +59,13 @@ var RteIcon = React6.forwardRef(
|
|
|
275
59
|
}
|
|
276
60
|
)
|
|
277
61
|
);
|
|
278
|
-
|
|
62
|
+
Icon.displayName = "Icon";
|
|
279
63
|
|
|
280
|
-
// src/ui/
|
|
281
|
-
import * as
|
|
282
|
-
import { jsx as
|
|
283
|
-
var
|
|
284
|
-
({ className, ...props }, ref) => /* @__PURE__ */
|
|
64
|
+
// src/ui/separator.tsx
|
|
65
|
+
import * as React4 from "react";
|
|
66
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
67
|
+
var Separator = React4.forwardRef(
|
|
68
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx4(
|
|
285
69
|
"div",
|
|
286
70
|
{
|
|
287
71
|
ref,
|
|
@@ -293,13 +77,13 @@ var RteSeparator = React7.forwardRef(
|
|
|
293
77
|
}
|
|
294
78
|
)
|
|
295
79
|
);
|
|
296
|
-
|
|
80
|
+
Separator.displayName = "Separator";
|
|
297
81
|
|
|
298
|
-
// src/ui/
|
|
299
|
-
import * as
|
|
300
|
-
import { jsx as
|
|
301
|
-
var
|
|
302
|
-
({ className, ...props }, ref) => /* @__PURE__ */
|
|
82
|
+
// src/ui/overlay.tsx
|
|
83
|
+
import * as React5 from "react";
|
|
84
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
85
|
+
var Overlay = React5.forwardRef(
|
|
86
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx5(
|
|
303
87
|
"div",
|
|
304
88
|
{
|
|
305
89
|
ref,
|
|
@@ -309,18 +93,18 @@ var RteOverlay = React8.forwardRef(
|
|
|
309
93
|
}
|
|
310
94
|
)
|
|
311
95
|
);
|
|
312
|
-
|
|
96
|
+
Overlay.displayName = "Overlay";
|
|
313
97
|
|
|
314
|
-
// src/ui/
|
|
315
|
-
import * as
|
|
98
|
+
// src/ui/dropdown.tsx
|
|
99
|
+
import * as React6 from "react";
|
|
316
100
|
import { useCallback, useRef, useState } from "react";
|
|
317
|
-
import { jsx as
|
|
101
|
+
import { jsx as jsx6, jsxs } from "react/jsx-runtime";
|
|
318
102
|
var variantClass = {
|
|
319
103
|
color: "rte-bubble-dropdown--color min-w-auto p-2 [&_.rte-bubble-dropdown-divider]:mx-[-0.5rem] [&_.rte-bubble-dropdown-divider]:mt-2.5 [&_.rte-bubble-dropdown-divider]:mb-2",
|
|
320
104
|
default: "",
|
|
321
105
|
language: "rte-bubble-dropdown--language max-h-80 min-w-40 overflow-y-auto [scrollbar-width:thin]"
|
|
322
106
|
};
|
|
323
|
-
var
|
|
107
|
+
var Dropdown = React6.forwardRef(
|
|
324
108
|
({ className, variant = "default", children, onMouseLeave, ...props }, ref) => {
|
|
325
109
|
const containerRef = useRef(null);
|
|
326
110
|
const [pill, setPill] = useState(null);
|
|
@@ -362,7 +146,7 @@ var RteDropdown = React9.forwardRef(
|
|
|
362
146
|
variantClass[variant],
|
|
363
147
|
className
|
|
364
148
|
);
|
|
365
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ jsxs(
|
|
366
150
|
"div",
|
|
367
151
|
{
|
|
368
152
|
ref: (node) => {
|
|
@@ -379,7 +163,7 @@ var RteDropdown = React9.forwardRef(
|
|
|
379
163
|
onMouseOver: handleMouseOver,
|
|
380
164
|
...props,
|
|
381
165
|
children: [
|
|
382
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ jsx6(
|
|
383
167
|
"div",
|
|
384
168
|
{
|
|
385
169
|
"aria-hidden": "true",
|
|
@@ -401,11 +185,11 @@ var RteDropdown = React9.forwardRef(
|
|
|
401
185
|
);
|
|
402
186
|
}
|
|
403
187
|
);
|
|
404
|
-
|
|
188
|
+
Dropdown.displayName = "Dropdown";
|
|
405
189
|
|
|
406
|
-
// src/ui/
|
|
407
|
-
import * as
|
|
408
|
-
import { jsx as
|
|
190
|
+
// src/ui/color-swatch.tsx
|
|
191
|
+
import * as React7 from "react";
|
|
192
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
409
193
|
var getCheckColor = (hex) => {
|
|
410
194
|
const value = hex.replace("#", "");
|
|
411
195
|
const r = Number.parseInt(value.slice(0, 2), 16) / 255;
|
|
@@ -414,10 +198,10 @@ var getCheckColor = (hex) => {
|
|
|
414
198
|
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
415
199
|
return luminance > 0.5 ? "#18181b" : "#ffffff";
|
|
416
200
|
};
|
|
417
|
-
var
|
|
201
|
+
var ColorSwatch = React7.forwardRef(
|
|
418
202
|
({ color, label, variant, active = false, onSelect }, ref) => {
|
|
419
203
|
const checkColor = getCheckColor(color);
|
|
420
|
-
return /* @__PURE__ */
|
|
204
|
+
return /* @__PURE__ */ jsxs2(
|
|
421
205
|
"button",
|
|
422
206
|
{
|
|
423
207
|
ref,
|
|
@@ -439,7 +223,7 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
439
223
|
onMouseDown: (e) => e.preventDefault(),
|
|
440
224
|
onClick: () => onSelect(color),
|
|
441
225
|
children: [
|
|
442
|
-
variant === "text" && !active ? /* @__PURE__ */
|
|
226
|
+
variant === "text" && !active ? /* @__PURE__ */ jsx7(
|
|
443
227
|
"span",
|
|
444
228
|
{
|
|
445
229
|
className: "rte-bubble-color-glyph text-[0.6875rem] leading-none font-semibold",
|
|
@@ -447,12 +231,12 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
447
231
|
children: "A"
|
|
448
232
|
}
|
|
449
233
|
) : null,
|
|
450
|
-
active ? /* @__PURE__ */
|
|
234
|
+
active ? /* @__PURE__ */ jsx7(
|
|
451
235
|
"span",
|
|
452
236
|
{
|
|
453
237
|
className: "rte-bubble-color-check flex size-3 items-center justify-center text-(--swatch-check) [&_svg]:size-full",
|
|
454
238
|
"aria-hidden": "true",
|
|
455
|
-
children: /* @__PURE__ */
|
|
239
|
+
children: /* @__PURE__ */ jsx7(
|
|
456
240
|
"svg",
|
|
457
241
|
{
|
|
458
242
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -462,7 +246,7 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
462
246
|
strokeWidth: 3,
|
|
463
247
|
strokeLinecap: "round",
|
|
464
248
|
strokeLinejoin: "round",
|
|
465
|
-
children: /* @__PURE__ */
|
|
249
|
+
children: /* @__PURE__ */ jsx7("path", { d: "M20 6 9 17l-5-5" })
|
|
466
250
|
}
|
|
467
251
|
)
|
|
468
252
|
}
|
|
@@ -472,34 +256,36 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
472
256
|
);
|
|
473
257
|
}
|
|
474
258
|
);
|
|
475
|
-
|
|
259
|
+
ColorSwatch.displayName = "ColorSwatch";
|
|
476
260
|
|
|
477
|
-
// src/ui/
|
|
478
|
-
import * as
|
|
479
|
-
import { jsx as
|
|
480
|
-
var
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
261
|
+
// src/ui/dropdown-item.tsx
|
|
262
|
+
import * as React8 from "react";
|
|
263
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
264
|
+
var DropdownItem = React8.forwardRef(
|
|
265
|
+
({ className, active = false, ...props }, ref) => {
|
|
266
|
+
const cls = cn(
|
|
267
|
+
"rte-bubble-dropdown-item relative z-1 flex h-8 w-full cursor-pointer items-center justify-start gap-2 rounded-sm border-none bg-transparent px-2 text-left text-[0.8125rem] text-muted-foreground outline-none [transition:background-color_150ms_ease-out,color_150ms_ease-out] hover:text-foreground focus-visible:text-foreground hover:[&_.rte-bubble-dropdown-icon]:text-foreground",
|
|
268
|
+
active && "rte-bubble-dropdown-item--active bg-muted font-medium text-foreground [&_.rte-bubble-dropdown-icon]:text-foreground",
|
|
269
|
+
className
|
|
270
|
+
);
|
|
271
|
+
return /* @__PURE__ */ jsx8(
|
|
272
|
+
"button",
|
|
273
|
+
{
|
|
274
|
+
ref,
|
|
275
|
+
type: "button",
|
|
276
|
+
"data-dropdown-item": true,
|
|
277
|
+
className: cls,
|
|
278
|
+
...props
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
DropdownItem.displayName = "DropdownItem";
|
|
498
284
|
|
|
499
|
-
// src/ui/
|
|
500
|
-
import * as
|
|
501
|
-
import { jsx as
|
|
502
|
-
var
|
|
285
|
+
// src/ui/dropdown-separator.tsx
|
|
286
|
+
import * as React9 from "react";
|
|
287
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
288
|
+
var DropdownSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
503
289
|
"div",
|
|
504
290
|
{
|
|
505
291
|
ref,
|
|
@@ -510,13 +296,13 @@ var RteDropdownDivider = React12.forwardRef(({ className, ...props }, ref) => /*
|
|
|
510
296
|
...props
|
|
511
297
|
}
|
|
512
298
|
));
|
|
513
|
-
|
|
299
|
+
DropdownSeparator.displayName = "DropdownSeparator";
|
|
514
300
|
|
|
515
|
-
// src/ui/
|
|
516
|
-
import * as
|
|
517
|
-
import { jsx as
|
|
518
|
-
var
|
|
519
|
-
({ className, ...props }, ref) => /* @__PURE__ */
|
|
301
|
+
// src/ui/dropdown-icon.tsx
|
|
302
|
+
import * as React10 from "react";
|
|
303
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
304
|
+
var DropdownIcon = React10.forwardRef(
|
|
305
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx10(
|
|
520
306
|
"span",
|
|
521
307
|
{
|
|
522
308
|
ref,
|
|
@@ -528,102 +314,7 @@ var RteDropdownIcon = React13.forwardRef(
|
|
|
528
314
|
}
|
|
529
315
|
)
|
|
530
316
|
);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
// src/ui/toggle.tsx
|
|
534
|
-
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
535
|
-
import { cva as cva2 } from "class-variance-authority";
|
|
536
|
-
import { forwardRef as forwardRef11 } from "react";
|
|
537
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
538
|
-
var toggleVariants = cva2(
|
|
539
|
-
"group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
540
|
-
{
|
|
541
|
-
defaultVariants: {
|
|
542
|
-
size: "default",
|
|
543
|
-
variant: "default"
|
|
544
|
-
},
|
|
545
|
-
variants: {
|
|
546
|
-
size: {
|
|
547
|
-
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
548
|
-
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
549
|
-
sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
550
|
-
},
|
|
551
|
-
variant: {
|
|
552
|
-
default: "bg-transparent",
|
|
553
|
-
outline: "border border-input bg-transparent hover:bg-muted"
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
);
|
|
558
|
-
var Toggle = forwardRef11(({ className, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsx15(
|
|
559
|
-
TogglePrimitive,
|
|
560
|
-
{
|
|
561
|
-
ref,
|
|
562
|
-
"data-slot": "toggle",
|
|
563
|
-
className: cn(toggleVariants({ className, size, variant })),
|
|
564
|
-
...props
|
|
565
|
-
}
|
|
566
|
-
));
|
|
567
|
-
Toggle.displayName = "Toggle";
|
|
568
|
-
|
|
569
|
-
// src/ui/tooltip.tsx
|
|
570
|
-
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
571
|
-
import { Fragment, jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
572
|
-
var TooltipProvider = ({
|
|
573
|
-
delay = 0,
|
|
574
|
-
...props
|
|
575
|
-
}) => /* @__PURE__ */ jsx16(
|
|
576
|
-
TooltipPrimitive.Provider,
|
|
577
|
-
{
|
|
578
|
-
"data-slot": "tooltip-provider",
|
|
579
|
-
delay,
|
|
580
|
-
...props
|
|
581
|
-
}
|
|
582
|
-
);
|
|
583
|
-
var Tooltip = ({ ...props }) => /* @__PURE__ */ jsx16(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
584
|
-
var TooltipTrigger = ({ ...props }) => /* @__PURE__ */ jsx16(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
585
|
-
var TooltipContent = ({
|
|
586
|
-
className,
|
|
587
|
-
side = "top",
|
|
588
|
-
sideOffset = 4,
|
|
589
|
-
align = "center",
|
|
590
|
-
alignOffset = 0,
|
|
591
|
-
children,
|
|
592
|
-
...props
|
|
593
|
-
}) => /* @__PURE__ */ jsx16(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx16(
|
|
594
|
-
TooltipPrimitive.Positioner,
|
|
595
|
-
{
|
|
596
|
-
align,
|
|
597
|
-
alignOffset,
|
|
598
|
-
side,
|
|
599
|
-
sideOffset,
|
|
600
|
-
className: "isolate z-50",
|
|
601
|
-
children: /* @__PURE__ */ jsxs4(
|
|
602
|
-
TooltipPrimitive.Popup,
|
|
603
|
-
{
|
|
604
|
-
"data-slot": "tooltip-content",
|
|
605
|
-
className: cn(
|
|
606
|
-
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-2 py-1 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
607
|
-
className
|
|
608
|
-
),
|
|
609
|
-
...props,
|
|
610
|
-
children: [
|
|
611
|
-
children,
|
|
612
|
-
/* @__PURE__ */ jsx16(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
613
|
-
]
|
|
614
|
-
}
|
|
615
|
-
)
|
|
616
|
-
}
|
|
617
|
-
) });
|
|
618
|
-
var createTooltipHandle = () => TooltipPrimitive.createHandle();
|
|
619
|
-
var TooltipHost = ({
|
|
620
|
-
handle,
|
|
621
|
-
children,
|
|
622
|
-
...props
|
|
623
|
-
}) => /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
624
|
-
children,
|
|
625
|
-
/* @__PURE__ */ jsx16(Tooltip, { handle, children: ({ payload }) => /* @__PURE__ */ jsx16(TooltipContent, { ...props, children: payload }) })
|
|
626
|
-
] });
|
|
317
|
+
DropdownIcon.displayName = "DropdownIcon";
|
|
627
318
|
|
|
628
319
|
// src/bubble-menu/color-selector.tsx
|
|
629
320
|
import { useState as useState2 } from "react";
|
|
@@ -689,7 +380,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
|
689
380
|
};
|
|
690
381
|
|
|
691
382
|
// src/bubble-menu/color-selector.tsx
|
|
692
|
-
import { Fragment
|
|
383
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
693
384
|
var RECENT_KEY = "editorcn-editor-recent-colors";
|
|
694
385
|
var RECENT_LIMIT = 10;
|
|
695
386
|
var readRecentColors = () => {
|
|
@@ -783,15 +474,15 @@ var ColorSelector = ({ editor }) => {
|
|
|
783
474
|
if (!hasColor && !hasHighlight) {
|
|
784
475
|
return null;
|
|
785
476
|
}
|
|
786
|
-
return /* @__PURE__ */
|
|
787
|
-
/* @__PURE__ */
|
|
788
|
-
|
|
477
|
+
return /* @__PURE__ */ jsxs3("div", { style: { position: "relative" }, children: [
|
|
478
|
+
/* @__PURE__ */ jsx11(
|
|
479
|
+
Button,
|
|
789
480
|
{
|
|
790
481
|
active: Boolean(textColor || highlightColor),
|
|
791
482
|
onMouseDown: (e) => e.preventDefault(),
|
|
792
483
|
onClick: () => setOpen(!open),
|
|
793
484
|
title: "Text color",
|
|
794
|
-
children: /* @__PURE__ */
|
|
485
|
+
children: /* @__PURE__ */ jsx11(Icon, { children: /* @__PURE__ */ jsxs3(
|
|
795
486
|
"svg",
|
|
796
487
|
{
|
|
797
488
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -803,17 +494,17 @@ var ColorSelector = ({ editor }) => {
|
|
|
803
494
|
strokeLinejoin: "round",
|
|
804
495
|
className: "rte-editor-icon",
|
|
805
496
|
children: [
|
|
806
|
-
/* @__PURE__ */
|
|
807
|
-
/* @__PURE__ */
|
|
808
|
-
/* @__PURE__ */
|
|
497
|
+
/* @__PURE__ */ jsx11("path", { d: "M4 20h16" }),
|
|
498
|
+
/* @__PURE__ */ jsx11("path", { d: "m6 16 6-12 6 12" }),
|
|
499
|
+
/* @__PURE__ */ jsx11("path", { d: "M8 12h8" })
|
|
809
500
|
]
|
|
810
501
|
}
|
|
811
502
|
) })
|
|
812
503
|
}
|
|
813
504
|
),
|
|
814
|
-
open && /* @__PURE__ */
|
|
815
|
-
/* @__PURE__ */
|
|
816
|
-
|
|
505
|
+
open && /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
506
|
+
/* @__PURE__ */ jsx11(
|
|
507
|
+
Overlay,
|
|
817
508
|
{
|
|
818
509
|
onClick: () => setOpen(false),
|
|
819
510
|
onKeyDown: (e) => {
|
|
@@ -823,11 +514,11 @@ var ColorSelector = ({ editor }) => {
|
|
|
823
514
|
}
|
|
824
515
|
}
|
|
825
516
|
),
|
|
826
|
-
/* @__PURE__ */
|
|
827
|
-
recent.length > 0 ? /* @__PURE__ */
|
|
828
|
-
/* @__PURE__ */
|
|
829
|
-
/* @__PURE__ */
|
|
830
|
-
|
|
517
|
+
/* @__PURE__ */ jsxs3(Dropdown, { variant: "color", children: [
|
|
518
|
+
recent.length > 0 ? /* @__PURE__ */ jsxs3("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
519
|
+
/* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Recently Used" }),
|
|
520
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-bubble-color-recent flex flex-wrap justify-center gap-1.5", children: recent.map((item) => /* @__PURE__ */ jsx11(
|
|
521
|
+
ColorSwatch,
|
|
831
522
|
{
|
|
832
523
|
variant: item.type,
|
|
833
524
|
color: item.color,
|
|
@@ -838,12 +529,12 @@ var ColorSelector = ({ editor }) => {
|
|
|
838
529
|
`${item.type}-${item.color}`
|
|
839
530
|
)) })
|
|
840
531
|
] }) : null,
|
|
841
|
-
hasColor ? /* @__PURE__ */
|
|
842
|
-
recent.length > 0 && /* @__PURE__ */
|
|
843
|
-
/* @__PURE__ */
|
|
844
|
-
/* @__PURE__ */
|
|
845
|
-
/* @__PURE__ */
|
|
846
|
-
|
|
532
|
+
hasColor ? /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
533
|
+
recent.length > 0 && /* @__PURE__ */ jsx11(DropdownSeparator, {}),
|
|
534
|
+
/* @__PURE__ */ jsxs3("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
535
|
+
/* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Text Color" }),
|
|
536
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-bubble-color-grid grid grid-cols-[repeat(5,1.5rem)] justify-center gap-1.5", children: TEXT_COLORS.map((item) => /* @__PURE__ */ jsx11(
|
|
537
|
+
ColorSwatch,
|
|
847
538
|
{
|
|
848
539
|
variant: "text",
|
|
849
540
|
color: item.color,
|
|
@@ -855,12 +546,12 @@ var ColorSelector = ({ editor }) => {
|
|
|
855
546
|
)) })
|
|
856
547
|
] })
|
|
857
548
|
] }) : null,
|
|
858
|
-
hasHighlight ? /* @__PURE__ */
|
|
859
|
-
(recent.length > 0 || hasColor) && /* @__PURE__ */
|
|
860
|
-
/* @__PURE__ */
|
|
861
|
-
/* @__PURE__ */
|
|
862
|
-
/* @__PURE__ */
|
|
863
|
-
|
|
549
|
+
hasHighlight ? /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
550
|
+
(recent.length > 0 || hasColor) && /* @__PURE__ */ jsx11(DropdownSeparator, {}),
|
|
551
|
+
/* @__PURE__ */ jsxs3("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
552
|
+
/* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Highlight Color" }),
|
|
553
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-bubble-color-grid grid grid-cols-[repeat(5,1.5rem)] justify-center gap-1.5", children: HIGHLIGHT_COLORS.map((item) => /* @__PURE__ */ jsx11(
|
|
554
|
+
ColorSwatch,
|
|
864
555
|
{
|
|
865
556
|
variant: "highlight",
|
|
866
557
|
color: item.color,
|
|
@@ -878,11 +569,11 @@ var ColorSelector = ({ editor }) => {
|
|
|
878
569
|
};
|
|
879
570
|
|
|
880
571
|
// src/bubble-menu/text-buttons.tsx
|
|
881
|
-
import { jsx as
|
|
572
|
+
import { jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
882
573
|
var Svg = ({
|
|
883
574
|
children,
|
|
884
575
|
strokeWidth = 2
|
|
885
|
-
}) => /* @__PURE__ */
|
|
576
|
+
}) => /* @__PURE__ */ jsx12(
|
|
886
577
|
"svg",
|
|
887
578
|
{
|
|
888
579
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -896,51 +587,50 @@ var Svg = ({
|
|
|
896
587
|
children
|
|
897
588
|
}
|
|
898
589
|
);
|
|
899
|
-
var Icon = ({ children }) => /* @__PURE__ */ jsx18(RteIcon, { children });
|
|
900
590
|
var textItems = [
|
|
901
591
|
{
|
|
902
592
|
command: (e) => e.chain().focus().toggleBold().run(),
|
|
903
|
-
icon: /* @__PURE__ */
|
|
904
|
-
/* @__PURE__ */
|
|
905
|
-
/* @__PURE__ */
|
|
593
|
+
icon: /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsxs4(Svg, { children: [
|
|
594
|
+
/* @__PURE__ */ jsx12("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
595
|
+
/* @__PURE__ */ jsx12("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
906
596
|
] }) }),
|
|
907
597
|
isActive: (s) => s.isBold,
|
|
908
598
|
mark: "bold"
|
|
909
599
|
},
|
|
910
600
|
{
|
|
911
601
|
command: (e) => e.chain().focus().toggleItalic().run(),
|
|
912
|
-
icon: /* @__PURE__ */
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
/* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
602
|
+
icon: /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsxs4(Svg, { children: [
|
|
603
|
+
/* @__PURE__ */ jsx12("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
604
|
+
/* @__PURE__ */ jsx12("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
605
|
+
/* @__PURE__ */ jsx12("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
916
606
|
] }) }),
|
|
917
607
|
isActive: (s) => s.isItalic,
|
|
918
608
|
mark: "italic"
|
|
919
609
|
},
|
|
920
610
|
{
|
|
921
611
|
command: (e) => e.chain().focus().toggleUnderline().run(),
|
|
922
|
-
icon: /* @__PURE__ */
|
|
923
|
-
/* @__PURE__ */
|
|
924
|
-
/* @__PURE__ */
|
|
612
|
+
icon: /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsxs4(Svg, { children: [
|
|
613
|
+
/* @__PURE__ */ jsx12("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
614
|
+
/* @__PURE__ */ jsx12("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
|
|
925
615
|
] }) }),
|
|
926
616
|
isActive: (s) => s.isUnderline,
|
|
927
617
|
mark: "underline"
|
|
928
618
|
},
|
|
929
619
|
{
|
|
930
620
|
command: (e) => e.chain().focus().toggleStrike().run(),
|
|
931
|
-
icon: /* @__PURE__ */
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
621
|
+
icon: /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsxs4(Svg, { children: [
|
|
622
|
+
/* @__PURE__ */ jsx12("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
|
|
623
|
+
/* @__PURE__ */ jsx12("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
|
|
624
|
+
/* @__PURE__ */ jsx12("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
935
625
|
] }) }),
|
|
936
626
|
isActive: (s) => s.isStrike,
|
|
937
627
|
mark: "strike"
|
|
938
628
|
},
|
|
939
629
|
{
|
|
940
630
|
command: (e) => e.chain().focus().toggleCode().run(),
|
|
941
|
-
icon: /* @__PURE__ */
|
|
942
|
-
/* @__PURE__ */
|
|
943
|
-
/* @__PURE__ */
|
|
631
|
+
icon: /* @__PURE__ */ jsx12(Icon, { children: /* @__PURE__ */ jsxs4(Svg, { children: [
|
|
632
|
+
/* @__PURE__ */ jsx12("polyline", { points: "16 18 22 12 16 6" }),
|
|
633
|
+
/* @__PURE__ */ jsx12("polyline", { points: "8 6 2 12 8 18" })
|
|
944
634
|
] }) }),
|
|
945
635
|
isActive: (s) => s.isCode,
|
|
946
636
|
mark: "code"
|
|
@@ -959,8 +649,8 @@ var TextButtons = ({ editor }) => {
|
|
|
959
649
|
}),
|
|
960
650
|
shallowEqual
|
|
961
651
|
);
|
|
962
|
-
return /* @__PURE__ */
|
|
963
|
-
|
|
652
|
+
return /* @__PURE__ */ jsx12(ButtonGroup, { children: getTextItems(editor).map((item) => /* @__PURE__ */ jsx12(
|
|
653
|
+
Button,
|
|
964
654
|
{
|
|
965
655
|
active: item.isActive(editorState),
|
|
966
656
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -972,7 +662,7 @@ var TextButtons = ({ editor }) => {
|
|
|
972
662
|
};
|
|
973
663
|
|
|
974
664
|
// src/bubble-menu/index.tsx
|
|
975
|
-
import { jsx as
|
|
665
|
+
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
976
666
|
var BubbleMenu = ({ editor }) => {
|
|
977
667
|
const shouldShow = useCallback3(
|
|
978
668
|
({
|
|
@@ -1003,27 +693,26 @@ var BubbleMenu = ({ editor }) => {
|
|
|
1003
693
|
if (!(hasText || hasColor)) {
|
|
1004
694
|
return null;
|
|
1005
695
|
}
|
|
1006
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx13(
|
|
1007
697
|
TiptapBubbleMenu,
|
|
1008
698
|
{
|
|
1009
699
|
className: "z-50",
|
|
1010
700
|
editor,
|
|
1011
701
|
options: { offset: 8, placement: "top" },
|
|
1012
702
|
shouldShow,
|
|
1013
|
-
children: /* @__PURE__ */
|
|
1014
|
-
hasText && /* @__PURE__ */
|
|
1015
|
-
hasText && hasColor && /* @__PURE__ */
|
|
1016
|
-
hasColor && /* @__PURE__ */
|
|
703
|
+
children: /* @__PURE__ */ jsxs5("div", { className: "rte-bubble-menu flex h-10 animate-rte-bubble-pop-in items-center rounded-lg border border-[color-mix(in_srgb,var(--border)_60%,transparent)] bg-popover px-1 text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)]", children: [
|
|
704
|
+
hasText && /* @__PURE__ */ jsx13(TextButtons, { editor }),
|
|
705
|
+
hasText && hasColor && /* @__PURE__ */ jsx13(Separator, {}),
|
|
706
|
+
hasColor && /* @__PURE__ */ jsx13(ColorSelector, { editor })
|
|
1017
707
|
] })
|
|
1018
708
|
}
|
|
1019
709
|
);
|
|
1020
710
|
};
|
|
1021
711
|
|
|
1022
|
-
// src/
|
|
1023
|
-
import {
|
|
1024
|
-
import { cloneElement, forwardRef as forwardRef12, useContext as useContext2 } from "react";
|
|
712
|
+
// src/content.tsx
|
|
713
|
+
import { EditorContent } from "@tiptap/react";
|
|
1025
714
|
|
|
1026
|
-
// src/
|
|
715
|
+
// src/core/context.ts
|
|
1027
716
|
import { createContext, useContext } from "react";
|
|
1028
717
|
var RichTextEditorContext = createContext(null);
|
|
1029
718
|
var useRichTextEditorContext = () => {
|
|
@@ -1036,8 +725,132 @@ var useRichTextEditorContext = () => {
|
|
|
1036
725
|
return context;
|
|
1037
726
|
};
|
|
1038
727
|
|
|
1039
|
-
// src/
|
|
1040
|
-
import { jsx as
|
|
728
|
+
// src/content.tsx
|
|
729
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
730
|
+
var Content = ({
|
|
731
|
+
children,
|
|
732
|
+
className
|
|
733
|
+
}) => {
|
|
734
|
+
const { editor, preset, variant } = useRichTextEditorContext();
|
|
735
|
+
return /* @__PURE__ */ jsxs6("div", { className: "relative", children: [
|
|
736
|
+
/* @__PURE__ */ jsx14(
|
|
737
|
+
EditorContent,
|
|
738
|
+
{
|
|
739
|
+
editor,
|
|
740
|
+
className: cn(
|
|
741
|
+
"rte-content editorcn-content w-full",
|
|
742
|
+
variant === "default" && "rounded-lg border border-(--rte-hairline) bg-[var(--card,var(--background))]",
|
|
743
|
+
className
|
|
744
|
+
),
|
|
745
|
+
"data-preset": preset,
|
|
746
|
+
spellCheck: false
|
|
747
|
+
}
|
|
748
|
+
),
|
|
749
|
+
children
|
|
750
|
+
] });
|
|
751
|
+
};
|
|
752
|
+
|
|
753
|
+
// src/controls/control.tsx
|
|
754
|
+
import { useEditorState as useEditorState2 } from "@tiptap/react";
|
|
755
|
+
import { cloneElement, forwardRef as forwardRef12, useContext as useContext2 } from "react";
|
|
756
|
+
|
|
757
|
+
// src/primitives/base/toggle.tsx
|
|
758
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
759
|
+
import { cva } from "class-variance-authority";
|
|
760
|
+
import { forwardRef as forwardRef11 } from "react";
|
|
761
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
762
|
+
var toggleVariants = cva(
|
|
763
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
764
|
+
{
|
|
765
|
+
defaultVariants: {
|
|
766
|
+
size: "default",
|
|
767
|
+
variant: "default"
|
|
768
|
+
},
|
|
769
|
+
variants: {
|
|
770
|
+
size: {
|
|
771
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
772
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
773
|
+
sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
774
|
+
},
|
|
775
|
+
variant: {
|
|
776
|
+
default: "bg-transparent",
|
|
777
|
+
outline: "border border-input bg-transparent hover:bg-muted"
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
);
|
|
782
|
+
var Toggle = forwardRef11(({ className, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ jsx15(
|
|
783
|
+
TogglePrimitive,
|
|
784
|
+
{
|
|
785
|
+
ref,
|
|
786
|
+
"data-slot": "toggle",
|
|
787
|
+
className: cn(toggleVariants({ className, size, variant })),
|
|
788
|
+
...props
|
|
789
|
+
}
|
|
790
|
+
));
|
|
791
|
+
Toggle.displayName = "Toggle";
|
|
792
|
+
|
|
793
|
+
// src/primitives/base/tooltip.tsx
|
|
794
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
795
|
+
import { Fragment as Fragment2, jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
796
|
+
var TooltipProvider = ({
|
|
797
|
+
delay = 0,
|
|
798
|
+
...props
|
|
799
|
+
}) => /* @__PURE__ */ jsx16(
|
|
800
|
+
TooltipPrimitive.Provider,
|
|
801
|
+
{
|
|
802
|
+
"data-slot": "tooltip-provider",
|
|
803
|
+
delay,
|
|
804
|
+
...props
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
var Tooltip = ({ ...props }) => /* @__PURE__ */ jsx16(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
|
|
808
|
+
var TooltipTrigger = ({ ...props }) => /* @__PURE__ */ jsx16(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
809
|
+
var TooltipContent = ({
|
|
810
|
+
className,
|
|
811
|
+
side = "top",
|
|
812
|
+
sideOffset = 4,
|
|
813
|
+
align = "center",
|
|
814
|
+
alignOffset = 0,
|
|
815
|
+
children,
|
|
816
|
+
...props
|
|
817
|
+
}) => /* @__PURE__ */ jsx16(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx16(
|
|
818
|
+
TooltipPrimitive.Positioner,
|
|
819
|
+
{
|
|
820
|
+
align,
|
|
821
|
+
alignOffset,
|
|
822
|
+
side,
|
|
823
|
+
sideOffset,
|
|
824
|
+
className: "isolate z-50",
|
|
825
|
+
children: /* @__PURE__ */ jsxs7(
|
|
826
|
+
TooltipPrimitive.Popup,
|
|
827
|
+
{
|
|
828
|
+
"data-slot": "tooltip-content",
|
|
829
|
+
className: cn(
|
|
830
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-2 py-1 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
831
|
+
className
|
|
832
|
+
),
|
|
833
|
+
...props,
|
|
834
|
+
children: [
|
|
835
|
+
children,
|
|
836
|
+
/* @__PURE__ */ jsx16(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
837
|
+
]
|
|
838
|
+
}
|
|
839
|
+
)
|
|
840
|
+
}
|
|
841
|
+
) });
|
|
842
|
+
var createTooltipHandle = () => TooltipPrimitive.createHandle();
|
|
843
|
+
var TooltipHost = ({
|
|
844
|
+
handle,
|
|
845
|
+
children,
|
|
846
|
+
...props
|
|
847
|
+
}) => /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
848
|
+
children,
|
|
849
|
+
/* @__PURE__ */ jsx16(Tooltip, { handle, children: ({ payload }) => /* @__PURE__ */ jsx16(TooltipContent, { ...props, children: payload }) })
|
|
850
|
+
] });
|
|
851
|
+
|
|
852
|
+
// src/controls/control.tsx
|
|
853
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1041
854
|
var RichTextEditorTooltip = ({
|
|
1042
855
|
children,
|
|
1043
856
|
id,
|
|
@@ -1047,7 +860,7 @@ var RichTextEditorTooltip = ({
|
|
|
1047
860
|
if (!tooltip) {
|
|
1048
861
|
return id ? cloneElement(children, { id }) : children;
|
|
1049
862
|
}
|
|
1050
|
-
return /* @__PURE__ */
|
|
863
|
+
return /* @__PURE__ */ jsx17(
|
|
1051
864
|
TooltipTrigger,
|
|
1052
865
|
{
|
|
1053
866
|
handle: tooltip,
|
|
@@ -1078,7 +891,7 @@ var RichTextEditorControl = forwardRef12(
|
|
|
1078
891
|
disabled,
|
|
1079
892
|
...props
|
|
1080
893
|
}, ref) => {
|
|
1081
|
-
const toggle = /* @__PURE__ */
|
|
894
|
+
const toggle = /* @__PURE__ */ jsx17(
|
|
1082
895
|
Toggle,
|
|
1083
896
|
{
|
|
1084
897
|
ref,
|
|
@@ -1100,7 +913,7 @@ var RichTextEditorControl = forwardRef12(
|
|
|
1100
913
|
children
|
|
1101
914
|
}
|
|
1102
915
|
);
|
|
1103
|
-
return props.title ? /* @__PURE__ */
|
|
916
|
+
return props.title ? /* @__PURE__ */ jsx17(RichTextEditorTooltip, { id: props.id, label: props.title, children: toggle }) : toggle;
|
|
1104
917
|
}
|
|
1105
918
|
);
|
|
1106
919
|
RichTextEditorControl.displayName = "RichTextEditorControl";
|
|
@@ -1133,7 +946,7 @@ var createControl = ({
|
|
|
1133
946
|
const selector = createSelector(isActive, isDisabled);
|
|
1134
947
|
useEditorState2({ editor: editor ?? null, selector });
|
|
1135
948
|
const { active, disabled } = selector({ editor: editor ?? null });
|
|
1136
|
-
return /* @__PURE__ */
|
|
949
|
+
return /* @__PURE__ */ jsx17(
|
|
1137
950
|
RichTextEditorControl,
|
|
1138
951
|
{
|
|
1139
952
|
active,
|
|
@@ -1156,7 +969,7 @@ var createControl = ({
|
|
|
1156
969
|
return Control;
|
|
1157
970
|
};
|
|
1158
971
|
|
|
1159
|
-
// src/controls/
|
|
972
|
+
// src/controls/controls.tsx
|
|
1160
973
|
var BoldControl = createControl({
|
|
1161
974
|
iconKey: "boldControlIcon",
|
|
1162
975
|
isActive: { name: "bold" },
|
|
@@ -1317,10 +1130,115 @@ var SuperscriptControl = createControl({
|
|
|
1317
1130
|
operation: { name: "toggleSuperscript" }
|
|
1318
1131
|
});
|
|
1319
1132
|
|
|
1320
|
-
// src/controls/
|
|
1321
|
-
import { useEditorState as useEditorState3 } from "@tiptap/react";
|
|
1322
|
-
import * as
|
|
1323
|
-
import { useCallback as useCallback4, useState as useState3 } from "react";
|
|
1133
|
+
// src/controls/link-control.tsx
|
|
1134
|
+
import { useEditorState as useEditorState3 } from "@tiptap/react";
|
|
1135
|
+
import * as React14 from "react";
|
|
1136
|
+
import { useCallback as useCallback4, useState as useState3 } from "react";
|
|
1137
|
+
|
|
1138
|
+
// src/primitives/base/button.tsx
|
|
1139
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
1140
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
1141
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1142
|
+
var buttonVariants = cva2(
|
|
1143
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1144
|
+
{
|
|
1145
|
+
defaultVariants: {
|
|
1146
|
+
size: "default",
|
|
1147
|
+
variant: "default"
|
|
1148
|
+
},
|
|
1149
|
+
variants: {
|
|
1150
|
+
size: {
|
|
1151
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
1152
|
+
icon: "size-8",
|
|
1153
|
+
"icon-lg": "size-9",
|
|
1154
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
1155
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
1156
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
1157
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
1158
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3"
|
|
1159
|
+
},
|
|
1160
|
+
variant: {
|
|
1161
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
1162
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
1163
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
1164
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
1165
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
1166
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground"
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
);
|
|
1171
|
+
var Button2 = ({
|
|
1172
|
+
className,
|
|
1173
|
+
variant = "default",
|
|
1174
|
+
size = "default",
|
|
1175
|
+
...props
|
|
1176
|
+
}) => /* @__PURE__ */ jsx18(
|
|
1177
|
+
ButtonPrimitive,
|
|
1178
|
+
{
|
|
1179
|
+
"data-slot": "button",
|
|
1180
|
+
className: cn(buttonVariants({ className, size, variant })),
|
|
1181
|
+
...props
|
|
1182
|
+
}
|
|
1183
|
+
);
|
|
1184
|
+
|
|
1185
|
+
// src/primitives/base/input.tsx
|
|
1186
|
+
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
1187
|
+
import "react";
|
|
1188
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1189
|
+
var Input = ({
|
|
1190
|
+
className,
|
|
1191
|
+
type,
|
|
1192
|
+
...props
|
|
1193
|
+
}) => /* @__PURE__ */ jsx19(
|
|
1194
|
+
InputPrimitive,
|
|
1195
|
+
{
|
|
1196
|
+
type,
|
|
1197
|
+
"data-slot": "input",
|
|
1198
|
+
className: cn(
|
|
1199
|
+
"h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
|
|
1200
|
+
className
|
|
1201
|
+
),
|
|
1202
|
+
...props
|
|
1203
|
+
}
|
|
1204
|
+
);
|
|
1205
|
+
|
|
1206
|
+
// src/primitives/base/popover.tsx
|
|
1207
|
+
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
1208
|
+
import "react";
|
|
1209
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
1210
|
+
var Popover = ({ ...props }) => /* @__PURE__ */ jsx20(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
1211
|
+
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ jsx20(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
1212
|
+
var PopoverContent = ({
|
|
1213
|
+
className,
|
|
1214
|
+
align = "center",
|
|
1215
|
+
alignOffset = 0,
|
|
1216
|
+
side = "bottom",
|
|
1217
|
+
sideOffset = 4,
|
|
1218
|
+
...props
|
|
1219
|
+
}) => /* @__PURE__ */ jsx20(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx20(
|
|
1220
|
+
PopoverPrimitive.Positioner,
|
|
1221
|
+
{
|
|
1222
|
+
align,
|
|
1223
|
+
alignOffset,
|
|
1224
|
+
side,
|
|
1225
|
+
sideOffset,
|
|
1226
|
+
className: "isolate z-50",
|
|
1227
|
+
children: /* @__PURE__ */ jsx20(
|
|
1228
|
+
PopoverPrimitive.Popup,
|
|
1229
|
+
{
|
|
1230
|
+
"data-slot": "popover-content",
|
|
1231
|
+
className: cn(
|
|
1232
|
+
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
1233
|
+
className
|
|
1234
|
+
),
|
|
1235
|
+
...props
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
}
|
|
1239
|
+
) });
|
|
1240
|
+
|
|
1241
|
+
// src/controls/link-control.tsx
|
|
1324
1242
|
import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1325
1243
|
var LinkControl = () => {
|
|
1326
1244
|
const { editor, icons, labels, tooltip } = useRichTextEditorContext();
|
|
@@ -1360,7 +1278,7 @@ var LinkControl = () => {
|
|
|
1360
1278
|
handleSave();
|
|
1361
1279
|
}
|
|
1362
1280
|
};
|
|
1363
|
-
|
|
1281
|
+
React14.useEffect(() => {
|
|
1364
1282
|
const handler = () => handleOpen(true);
|
|
1365
1283
|
window.addEventListener("edit-link", handler);
|
|
1366
1284
|
return () => window.removeEventListener("edit-link", handler);
|
|
@@ -1403,7 +1321,7 @@ var LinkControl = () => {
|
|
|
1403
1321
|
}
|
|
1404
1322
|
),
|
|
1405
1323
|
/* @__PURE__ */ jsx21(
|
|
1406
|
-
|
|
1324
|
+
Button2,
|
|
1407
1325
|
{
|
|
1408
1326
|
size: "sm",
|
|
1409
1327
|
variant: "default",
|
|
@@ -1416,7 +1334,7 @@ var LinkControl = () => {
|
|
|
1416
1334
|
] });
|
|
1417
1335
|
};
|
|
1418
1336
|
|
|
1419
|
-
// src/controls/
|
|
1337
|
+
// src/controls/twitter-control.tsx
|
|
1420
1338
|
import {
|
|
1421
1339
|
createAtomBlockMarkdownSpec,
|
|
1422
1340
|
Node,
|
|
@@ -1430,10 +1348,10 @@ import { useState as useState5, useCallback as useCallback6, useEffect as useEff
|
|
|
1430
1348
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
1431
1349
|
import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef3, useState as useState4 } from "react";
|
|
1432
1350
|
|
|
1433
|
-
// src/icons.tsx
|
|
1351
|
+
// src/icons/icons.tsx
|
|
1434
1352
|
import "react";
|
|
1435
1353
|
|
|
1436
|
-
// src/icon-placeholder.tsx
|
|
1354
|
+
// src/icons/icon-placeholder.tsx
|
|
1437
1355
|
import {
|
|
1438
1356
|
AlignCenter,
|
|
1439
1357
|
AlignJustify,
|
|
@@ -1507,7 +1425,7 @@ var IconPlaceholder = ({
|
|
|
1507
1425
|
return /* @__PURE__ */ jsx22(Icon2, { ...props });
|
|
1508
1426
|
};
|
|
1509
1427
|
|
|
1510
|
-
// src/language-icons.tsx
|
|
1428
|
+
// src/icons/language-icons.tsx
|
|
1511
1429
|
import "react";
|
|
1512
1430
|
import { jsx as jsx23, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1513
1431
|
var LangIcon = ({
|
|
@@ -1642,7 +1560,7 @@ var DEFAULT_LANGUAGE_ICONS = {
|
|
|
1642
1560
|
] })
|
|
1643
1561
|
};
|
|
1644
1562
|
|
|
1645
|
-
// src/icons.tsx
|
|
1563
|
+
// src/icons/icons.tsx
|
|
1646
1564
|
import { Fragment as Fragment3, jsx as jsx24, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1647
1565
|
var ALIGN_PATHS = {
|
|
1648
1566
|
center: /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
@@ -2449,8 +2367,121 @@ var ResizableNodeView = ({
|
|
|
2449
2367
|
);
|
|
2450
2368
|
};
|
|
2451
2369
|
|
|
2452
|
-
// src/
|
|
2370
|
+
// src/primitives/base/dialog.tsx
|
|
2371
|
+
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
2372
|
+
import "react";
|
|
2453
2373
|
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2374
|
+
var Dialog = ({ ...props }) => /* @__PURE__ */ jsx26(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
2375
|
+
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx26(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
2376
|
+
var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx26(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
2377
|
+
var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx26(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
2378
|
+
var DialogOverlay = ({
|
|
2379
|
+
className,
|
|
2380
|
+
...props
|
|
2381
|
+
}) => /* @__PURE__ */ jsx26(
|
|
2382
|
+
DialogPrimitive.Backdrop,
|
|
2383
|
+
{
|
|
2384
|
+
"data-slot": "dialog-overlay",
|
|
2385
|
+
className: cn(
|
|
2386
|
+
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
|
2387
|
+
className
|
|
2388
|
+
),
|
|
2389
|
+
...props
|
|
2390
|
+
}
|
|
2391
|
+
);
|
|
2392
|
+
var DialogContent = ({
|
|
2393
|
+
className,
|
|
2394
|
+
children,
|
|
2395
|
+
showCloseButton = true,
|
|
2396
|
+
...props
|
|
2397
|
+
}) => /* @__PURE__ */ jsxs12(DialogPortal, { children: [
|
|
2398
|
+
/* @__PURE__ */ jsx26(DialogOverlay, {}),
|
|
2399
|
+
/* @__PURE__ */ jsxs12(
|
|
2400
|
+
DialogPrimitive.Popup,
|
|
2401
|
+
{
|
|
2402
|
+
"data-slot": "dialog-content",
|
|
2403
|
+
className: cn(
|
|
2404
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-xs/relaxed text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
2405
|
+
className
|
|
2406
|
+
),
|
|
2407
|
+
...props,
|
|
2408
|
+
children: [
|
|
2409
|
+
children,
|
|
2410
|
+
showCloseButton && /* @__PURE__ */ jsxs12(
|
|
2411
|
+
DialogPrimitive.Close,
|
|
2412
|
+
{
|
|
2413
|
+
"data-slot": "dialog-close",
|
|
2414
|
+
render: /* @__PURE__ */ jsx26(
|
|
2415
|
+
Button2,
|
|
2416
|
+
{
|
|
2417
|
+
variant: "ghost",
|
|
2418
|
+
className: "absolute top-2 right-2",
|
|
2419
|
+
size: "icon-sm"
|
|
2420
|
+
}
|
|
2421
|
+
),
|
|
2422
|
+
children: [
|
|
2423
|
+
"X",
|
|
2424
|
+
/* @__PURE__ */ jsx26("span", { className: "sr-only", children: "Close" })
|
|
2425
|
+
]
|
|
2426
|
+
}
|
|
2427
|
+
)
|
|
2428
|
+
]
|
|
2429
|
+
}
|
|
2430
|
+
)
|
|
2431
|
+
] });
|
|
2432
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx26(
|
|
2433
|
+
"div",
|
|
2434
|
+
{
|
|
2435
|
+
"data-slot": "dialog-header",
|
|
2436
|
+
className: cn("flex flex-col gap-1 text-left", className),
|
|
2437
|
+
...props
|
|
2438
|
+
}
|
|
2439
|
+
);
|
|
2440
|
+
var DialogFooter = ({
|
|
2441
|
+
className,
|
|
2442
|
+
showCloseButton = false,
|
|
2443
|
+
children,
|
|
2444
|
+
...props
|
|
2445
|
+
}) => /* @__PURE__ */ jsxs12(
|
|
2446
|
+
"div",
|
|
2447
|
+
{
|
|
2448
|
+
"data-slot": "dialog-footer",
|
|
2449
|
+
className: cn(
|
|
2450
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
2451
|
+
className
|
|
2452
|
+
),
|
|
2453
|
+
...props,
|
|
2454
|
+
children: [
|
|
2455
|
+
children,
|
|
2456
|
+
showCloseButton && /* @__PURE__ */ jsx26(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx26(Button2, { variant: "outline" }), children: "Close" })
|
|
2457
|
+
]
|
|
2458
|
+
}
|
|
2459
|
+
);
|
|
2460
|
+
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx26(
|
|
2461
|
+
DialogPrimitive.Title,
|
|
2462
|
+
{
|
|
2463
|
+
"data-slot": "dialog-title",
|
|
2464
|
+
className: cn("text-sm font-medium", className),
|
|
2465
|
+
...props
|
|
2466
|
+
}
|
|
2467
|
+
);
|
|
2468
|
+
var DialogDescription = ({
|
|
2469
|
+
className,
|
|
2470
|
+
...props
|
|
2471
|
+
}) => /* @__PURE__ */ jsx26(
|
|
2472
|
+
DialogPrimitive.Description,
|
|
2473
|
+
{
|
|
2474
|
+
"data-slot": "dialog-description",
|
|
2475
|
+
className: cn(
|
|
2476
|
+
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
2477
|
+
className
|
|
2478
|
+
),
|
|
2479
|
+
...props
|
|
2480
|
+
}
|
|
2481
|
+
);
|
|
2482
|
+
|
|
2483
|
+
// src/controls/twitter-control.tsx
|
|
2484
|
+
import { jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2454
2485
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
2455
2486
|
var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
|
|
2456
2487
|
var READY_POLL_INTERVAL_MS = 50;
|
|
@@ -2597,7 +2628,7 @@ var TwitterNodeView = (props) => {
|
|
|
2597
2628
|
retryToken.current += 1;
|
|
2598
2629
|
setRetryCount(retryToken.current);
|
|
2599
2630
|
}, []);
|
|
2600
|
-
return /* @__PURE__ */
|
|
2631
|
+
return /* @__PURE__ */ jsxs13(
|
|
2601
2632
|
ResizableNodeView,
|
|
2602
2633
|
{
|
|
2603
2634
|
...props,
|
|
@@ -2605,12 +2636,12 @@ var TwitterNodeView = (props) => {
|
|
|
2605
2636
|
minWidth: 300,
|
|
2606
2637
|
maxWidth: 1200,
|
|
2607
2638
|
children: [
|
|
2608
|
-
loading && /* @__PURE__ */
|
|
2609
|
-
!loading && failed && /* @__PURE__ */
|
|
2610
|
-
/* @__PURE__ */
|
|
2611
|
-
/* @__PURE__ */
|
|
2639
|
+
loading && /* @__PURE__ */ jsx27("div", { className: "rte-embed-loading animate-pulse", children: "Loading tweet..." }),
|
|
2640
|
+
!loading && failed && /* @__PURE__ */ jsxs13("div", { className: "rte-embed-error", children: [
|
|
2641
|
+
/* @__PURE__ */ jsx27("p", { children: "Couldn't load this tweet." }),
|
|
2642
|
+
/* @__PURE__ */ jsx27("button", { type: "button", onClick: handleRetry, children: "Retry" })
|
|
2612
2643
|
] }),
|
|
2613
|
-
/* @__PURE__ */
|
|
2644
|
+
/* @__PURE__ */ jsx27("div", { ref: containerRef })
|
|
2614
2645
|
]
|
|
2615
2646
|
}
|
|
2616
2647
|
);
|
|
@@ -2738,7 +2769,7 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2738
2769
|
resetState();
|
|
2739
2770
|
return true;
|
|
2740
2771
|
}, [tweetId, editor, resetState]);
|
|
2741
|
-
return /* @__PURE__ */
|
|
2772
|
+
return /* @__PURE__ */ jsxs13(
|
|
2742
2773
|
Dialog,
|
|
2743
2774
|
{
|
|
2744
2775
|
open,
|
|
@@ -2749,36 +2780,36 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2749
2780
|
}
|
|
2750
2781
|
},
|
|
2751
2782
|
children: [
|
|
2752
|
-
/* @__PURE__ */
|
|
2783
|
+
/* @__PURE__ */ jsx27(
|
|
2753
2784
|
DialogTrigger,
|
|
2754
2785
|
{
|
|
2755
|
-
render: /* @__PURE__ */
|
|
2786
|
+
render: /* @__PURE__ */ jsx27(
|
|
2756
2787
|
RichTextEditorControl,
|
|
2757
2788
|
{
|
|
2758
2789
|
active,
|
|
2759
2790
|
className,
|
|
2760
2791
|
title: "Embed Tweet",
|
|
2761
2792
|
"aria-label": "Embed Tweet",
|
|
2762
|
-
children: /* @__PURE__ */
|
|
2793
|
+
children: /* @__PURE__ */ jsx27(
|
|
2763
2794
|
"svg",
|
|
2764
2795
|
{
|
|
2765
2796
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2766
2797
|
viewBox: "0 0 24 24",
|
|
2767
2798
|
fill: "currentColor",
|
|
2768
2799
|
className: "rte-editor-icon",
|
|
2769
|
-
children: /* @__PURE__ */
|
|
2800
|
+
children: /* @__PURE__ */ jsx27("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
|
|
2770
2801
|
}
|
|
2771
2802
|
)
|
|
2772
2803
|
}
|
|
2773
2804
|
)
|
|
2774
2805
|
}
|
|
2775
2806
|
),
|
|
2776
|
-
/* @__PURE__ */
|
|
2777
|
-
/* @__PURE__ */
|
|
2778
|
-
/* @__PURE__ */
|
|
2779
|
-
/* @__PURE__ */
|
|
2807
|
+
/* @__PURE__ */ jsxs13(DialogContent, { children: [
|
|
2808
|
+
/* @__PURE__ */ jsxs13(DialogHeader, { children: [
|
|
2809
|
+
/* @__PURE__ */ jsx27(DialogTitle, { children: "Embed Tweet" }),
|
|
2810
|
+
/* @__PURE__ */ jsx27(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
2780
2811
|
] }),
|
|
2781
|
-
/* @__PURE__ */
|
|
2812
|
+
/* @__PURE__ */ jsx27(
|
|
2782
2813
|
Input,
|
|
2783
2814
|
{
|
|
2784
2815
|
value: url,
|
|
@@ -2798,10 +2829,10 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2798
2829
|
}
|
|
2799
2830
|
}
|
|
2800
2831
|
),
|
|
2801
|
-
showError && /* @__PURE__ */
|
|
2802
|
-
/* @__PURE__ */
|
|
2803
|
-
/* @__PURE__ */
|
|
2804
|
-
/* @__PURE__ */
|
|
2832
|
+
showError && /* @__PURE__ */ jsx27("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
|
|
2833
|
+
/* @__PURE__ */ jsxs13(DialogFooter, { children: [
|
|
2834
|
+
/* @__PURE__ */ jsx27(DialogClose, { children: "Cancel" }),
|
|
2835
|
+
/* @__PURE__ */ jsx27(
|
|
2805
2836
|
"button",
|
|
2806
2837
|
{
|
|
2807
2838
|
type: "button",
|
|
@@ -2822,7 +2853,7 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2822
2853
|
);
|
|
2823
2854
|
};
|
|
2824
2855
|
|
|
2825
|
-
// src/controls/
|
|
2856
|
+
// src/controls/youtube-control.tsx
|
|
2826
2857
|
import {
|
|
2827
2858
|
createAtomBlockMarkdownSpec as createAtomBlockMarkdownSpec2,
|
|
2828
2859
|
Node as Node2,
|
|
@@ -2831,7 +2862,7 @@ import {
|
|
|
2831
2862
|
} from "@tiptap/core";
|
|
2832
2863
|
import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
|
|
2833
2864
|
import { useState as useState6, useCallback as useCallback7 } from "react";
|
|
2834
|
-
import { jsx as
|
|
2865
|
+
import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2835
2866
|
var getYouTubeId = (url) => {
|
|
2836
2867
|
const clean = url.trim();
|
|
2837
2868
|
const patterns = [
|
|
@@ -2859,7 +2890,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2859
2890
|
if (videoId) {
|
|
2860
2891
|
watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
|
|
2861
2892
|
}
|
|
2862
|
-
return /* @__PURE__ */
|
|
2893
|
+
return /* @__PURE__ */ jsx28(
|
|
2863
2894
|
ResizableNodeView,
|
|
2864
2895
|
{
|
|
2865
2896
|
...props,
|
|
@@ -2870,7 +2901,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2870
2901
|
videoSrc: rawSrc,
|
|
2871
2902
|
watchUrl,
|
|
2872
2903
|
onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
|
|
2873
|
-
children: /* @__PURE__ */
|
|
2904
|
+
children: /* @__PURE__ */ jsx28(
|
|
2874
2905
|
"iframe",
|
|
2875
2906
|
{
|
|
2876
2907
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -2986,18 +3017,18 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
2986
3017
|
setUrl("");
|
|
2987
3018
|
}
|
|
2988
3019
|
}, [url, editor]);
|
|
2989
|
-
return /* @__PURE__ */
|
|
2990
|
-
/* @__PURE__ */
|
|
3020
|
+
return /* @__PURE__ */ jsxs14(Dialog, { open, onOpenChange: setOpen, children: [
|
|
3021
|
+
/* @__PURE__ */ jsx28(
|
|
2991
3022
|
DialogTrigger,
|
|
2992
3023
|
{
|
|
2993
|
-
render: /* @__PURE__ */
|
|
3024
|
+
render: /* @__PURE__ */ jsx28(
|
|
2994
3025
|
RichTextEditorControl,
|
|
2995
3026
|
{
|
|
2996
3027
|
active,
|
|
2997
3028
|
className,
|
|
2998
3029
|
title: "Embed YouTube video",
|
|
2999
3030
|
"aria-label": "Embed YouTube video",
|
|
3000
|
-
children: /* @__PURE__ */
|
|
3031
|
+
children: /* @__PURE__ */ jsxs14(
|
|
3001
3032
|
"svg",
|
|
3002
3033
|
{
|
|
3003
3034
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3009,8 +3040,8 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3009
3040
|
strokeLinejoin: "round",
|
|
3010
3041
|
className: "rte-editor-icon",
|
|
3011
3042
|
children: [
|
|
3012
|
-
/* @__PURE__ */
|
|
3013
|
-
/* @__PURE__ */
|
|
3043
|
+
/* @__PURE__ */ jsx28("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
|
|
3044
|
+
/* @__PURE__ */ jsx28("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
3014
3045
|
]
|
|
3015
3046
|
}
|
|
3016
3047
|
)
|
|
@@ -3018,12 +3049,12 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3018
3049
|
)
|
|
3019
3050
|
}
|
|
3020
3051
|
),
|
|
3021
|
-
/* @__PURE__ */
|
|
3022
|
-
/* @__PURE__ */
|
|
3023
|
-
/* @__PURE__ */
|
|
3024
|
-
/* @__PURE__ */
|
|
3052
|
+
/* @__PURE__ */ jsxs14(DialogContent, { showCloseButton: false, children: [
|
|
3053
|
+
/* @__PURE__ */ jsxs14(DialogHeader, { children: [
|
|
3054
|
+
/* @__PURE__ */ jsx28(DialogTitle, { children: "Embed YouTube video" }),
|
|
3055
|
+
/* @__PURE__ */ jsx28(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
3025
3056
|
] }),
|
|
3026
|
-
/* @__PURE__ */
|
|
3057
|
+
/* @__PURE__ */ jsx28(
|
|
3027
3058
|
Input,
|
|
3028
3059
|
{
|
|
3029
3060
|
value: url,
|
|
@@ -3037,9 +3068,9 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3037
3068
|
}
|
|
3038
3069
|
}
|
|
3039
3070
|
),
|
|
3040
|
-
/* @__PURE__ */
|
|
3041
|
-
/* @__PURE__ */
|
|
3042
|
-
/* @__PURE__ */
|
|
3071
|
+
/* @__PURE__ */ jsxs14(DialogFooter, { children: [
|
|
3072
|
+
/* @__PURE__ */ jsx28(DialogClose, { children: "Cancel" }),
|
|
3073
|
+
/* @__PURE__ */ jsx28(
|
|
3043
3074
|
DialogClose,
|
|
3044
3075
|
{
|
|
3045
3076
|
disabled: !url,
|
|
@@ -3053,7 +3084,7 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3053
3084
|
] });
|
|
3054
3085
|
};
|
|
3055
3086
|
|
|
3056
|
-
// src/labels.ts
|
|
3087
|
+
// src/core/labels.ts
|
|
3057
3088
|
var DEFAULT_LABELS = {
|
|
3058
3089
|
alignCenterControlLabel: "Align center",
|
|
3059
3090
|
alignJustifyControlLabel: "Align justify",
|
|
@@ -3094,63 +3125,9 @@ var DEFAULT_LABELS = {
|
|
|
3094
3125
|
unlinkControlLabel: "Remove link"
|
|
3095
3126
|
};
|
|
3096
3127
|
|
|
3097
|
-
// src/
|
|
3098
|
-
import { EditorContent } from "@tiptap/react";
|
|
3099
|
-
import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3100
|
-
var Content = ({
|
|
3101
|
-
children,
|
|
3102
|
-
className
|
|
3103
|
-
}) => {
|
|
3104
|
-
const { editor, preset, variant } = useRichTextEditorContext();
|
|
3105
|
-
return /* @__PURE__ */ jsxs14("div", { className: "relative", children: [
|
|
3106
|
-
/* @__PURE__ */ jsx28(
|
|
3107
|
-
EditorContent,
|
|
3108
|
-
{
|
|
3109
|
-
editor,
|
|
3110
|
-
className: cn(
|
|
3111
|
-
"rte-content editorcn-content w-full",
|
|
3112
|
-
variant === "default" && "rounded-lg border border-(--rte-hairline) bg-[var(--card,var(--background))]",
|
|
3113
|
-
className
|
|
3114
|
-
),
|
|
3115
|
-
"data-preset": preset,
|
|
3116
|
-
spellCheck: false
|
|
3117
|
-
}
|
|
3118
|
-
),
|
|
3119
|
-
children
|
|
3120
|
-
] });
|
|
3121
|
-
};
|
|
3122
|
-
|
|
3123
|
-
// src/rte-controls-group.tsx
|
|
3124
|
-
import { useContext as useContext3 } from "react";
|
|
3125
|
-
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
3126
|
-
var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-[''] [.rte-controls-group+&]:data-line-start:before:invisible";
|
|
3127
|
-
var BUTTON = "[&>button]:border-none [&>button]:bg-transparent [&>button]:transition-[background-color,color] [&>button]:duration-150 [&>button]:ease-[ease-out] [&>button:focus-visible]:outline-2 [&>button:focus-visible]:outline-offset-1 [&>button:focus-visible]:outline-ring/50 [&>button:focus-visible]:outline-solid";
|
|
3128
|
-
var variantClasses = {
|
|
3129
|
-
compact: `${SEPARATOR} [.rte-controls-group+&]:before:mx-0.5 [.rte-controls-group+&]:before:h-3.5 ${BUTTON} [&>button]:h-7 [&>button]:min-w-7 [&>button]:rounded-sm [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`,
|
|
3130
|
-
default: `gap-0.5 ${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-foreground [&>button:disabled]:cursor-not-allowed [&>button:disabled]:opacity-40 [&>button:hover:not(:disabled)]:bg-foreground/5 [&>button:hover:not(:disabled)]:text-foreground [&>button[aria-pressed=true]]:bg-foreground/8 [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-foreground/8 [&>button[data-state=on]]:text-foreground`,
|
|
3131
|
-
subtle: `${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`
|
|
3132
|
-
};
|
|
3133
|
-
var ControlsGroup = ({
|
|
3134
|
-
children,
|
|
3135
|
-
className
|
|
3136
|
-
}) => {
|
|
3137
|
-
const variant = useContext3(RichTextEditorContext)?.variant;
|
|
3138
|
-
return /* @__PURE__ */ jsx29(
|
|
3139
|
-
"div",
|
|
3140
|
-
{
|
|
3141
|
-
className: cn(
|
|
3142
|
-
"rte-controls-group flex items-center empty:hidden",
|
|
3143
|
-
variant && variantClasses[variant],
|
|
3144
|
-
className
|
|
3145
|
-
),
|
|
3146
|
-
children
|
|
3147
|
-
}
|
|
3148
|
-
);
|
|
3149
|
-
};
|
|
3150
|
-
|
|
3151
|
-
// src/rte-footer.tsx
|
|
3128
|
+
// src/footer.tsx
|
|
3152
3129
|
import { useEffect as useEffect5, useMemo, useRef as useRef5, useState as useState7 } from "react";
|
|
3153
|
-
import { Fragment as Fragment5, jsx as
|
|
3130
|
+
import { Fragment as Fragment5, jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3154
3131
|
var Footer = ({
|
|
3155
3132
|
children,
|
|
3156
3133
|
className,
|
|
@@ -3223,7 +3200,7 @@ var Footer = ({
|
|
|
3223
3200
|
"data-sticky": sticky ? "" : void 0,
|
|
3224
3201
|
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
3225
3202
|
children: [
|
|
3226
|
-
showWordCount && wordCount && /* @__PURE__ */
|
|
3203
|
+
showWordCount && wordCount && /* @__PURE__ */ jsx29(
|
|
3227
3204
|
"span",
|
|
3228
3205
|
{
|
|
3229
3206
|
className: cn(
|
|
@@ -3232,10 +3209,10 @@ var Footer = ({
|
|
|
3232
3209
|
),
|
|
3233
3210
|
children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
3234
3211
|
/* @__PURE__ */ jsxs15("span", { className: "rte-footer-word-count-stat inline-flex items-baseline gap-1", children: [
|
|
3235
|
-
/* @__PURE__ */
|
|
3236
|
-
/* @__PURE__ */
|
|
3212
|
+
/* @__PURE__ */ jsx29("span", { className: "rte-footer-word-count-number font-medium text-foreground tabular-nums", children: wordCount.words }),
|
|
3213
|
+
/* @__PURE__ */ jsx29("span", { className: "rte-footer-word-count-unit text-muted-foreground", children: "words" })
|
|
3237
3214
|
] }),
|
|
3238
|
-
/* @__PURE__ */
|
|
3215
|
+
/* @__PURE__ */ jsx29(
|
|
3239
3216
|
"span",
|
|
3240
3217
|
{
|
|
3241
3218
|
className: "rte-footer-word-count-separator size-[3px] shrink-0 rounded-full bg-[color-mix(in_srgb,var(--muted-foreground)_45%,transparent)]",
|
|
@@ -3243,8 +3220,8 @@ var Footer = ({
|
|
|
3243
3220
|
}
|
|
3244
3221
|
),
|
|
3245
3222
|
/* @__PURE__ */ jsxs15("span", { className: "rte-footer-word-count-stat inline-flex items-baseline gap-1", children: [
|
|
3246
|
-
/* @__PURE__ */
|
|
3247
|
-
/* @__PURE__ */
|
|
3223
|
+
/* @__PURE__ */ jsx29("span", { className: "rte-footer-word-count-number font-medium text-foreground tabular-nums", children: wordCount.characters }),
|
|
3224
|
+
/* @__PURE__ */ jsx29("span", { className: "rte-footer-word-count-unit text-muted-foreground", children: "characters" })
|
|
3248
3225
|
] })
|
|
3249
3226
|
] })
|
|
3250
3227
|
}
|
|
@@ -3255,7 +3232,35 @@ var Footer = ({
|
|
|
3255
3232
|
);
|
|
3256
3233
|
};
|
|
3257
3234
|
|
|
3258
|
-
// src/
|
|
3235
|
+
// src/toolbar/controls-group.tsx
|
|
3236
|
+
import { useContext as useContext3 } from "react";
|
|
3237
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
3238
|
+
var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-[''] [.rte-controls-group+&]:data-line-start:before:invisible";
|
|
3239
|
+
var BUTTON = "[&>button]:border-none [&>button]:bg-transparent [&>button]:transition-[background-color,color] [&>button]:duration-150 [&>button]:ease-[ease-out] [&>button:focus-visible]:outline-2 [&>button:focus-visible]:outline-offset-1 [&>button:focus-visible]:outline-ring/50 [&>button:focus-visible]:outline-solid";
|
|
3240
|
+
var variantClasses = {
|
|
3241
|
+
compact: `${SEPARATOR} [.rte-controls-group+&]:before:mx-0.5 [.rte-controls-group+&]:before:h-3.5 ${BUTTON} [&>button]:h-7 [&>button]:min-w-7 [&>button]:rounded-sm [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`,
|
|
3242
|
+
default: `gap-0.5 ${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-foreground [&>button:disabled]:cursor-not-allowed [&>button:disabled]:opacity-40 [&>button:hover:not(:disabled)]:bg-foreground/5 [&>button:hover:not(:disabled)]:text-foreground [&>button[aria-pressed=true]]:bg-foreground/8 [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-foreground/8 [&>button[data-state=on]]:text-foreground`,
|
|
3243
|
+
subtle: `${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`
|
|
3244
|
+
};
|
|
3245
|
+
var ControlsGroup = ({
|
|
3246
|
+
children,
|
|
3247
|
+
className
|
|
3248
|
+
}) => {
|
|
3249
|
+
const variant = useContext3(RichTextEditorContext)?.variant;
|
|
3250
|
+
return /* @__PURE__ */ jsx30(
|
|
3251
|
+
"div",
|
|
3252
|
+
{
|
|
3253
|
+
className: cn(
|
|
3254
|
+
"rte-controls-group flex items-center empty:hidden",
|
|
3255
|
+
variant && variantClasses[variant],
|
|
3256
|
+
className
|
|
3257
|
+
),
|
|
3258
|
+
children
|
|
3259
|
+
}
|
|
3260
|
+
);
|
|
3261
|
+
};
|
|
3262
|
+
|
|
3263
|
+
// src/toolbar/toolbar.tsx
|
|
3259
3264
|
import { useLayoutEffect, useRef as useRef6 } from "react";
|
|
3260
3265
|
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
3261
3266
|
var GROUPS = ":scope > .rte-controls-group";
|
|
@@ -3333,7 +3338,7 @@ var Toolbar = ({
|
|
|
3333
3338
|
);
|
|
3334
3339
|
};
|
|
3335
3340
|
|
|
3336
|
-
// src/
|
|
3341
|
+
// src/rich-text-editor.tsx
|
|
3337
3342
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
3338
3343
|
var RichTextEditorRoot = ({
|
|
3339
3344
|
editor,
|