@editorcn/editor 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1128 -722
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1119 -713
- package/dist/index.js.map +1 -1
- package/dist/style.css +1362 -1249
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,24 +6,541 @@ import { isTextSelection } from "@tiptap/core";
|
|
|
6
6
|
import { BubbleMenu as TiptapBubbleMenu } from "@tiptap/react/menus";
|
|
7
7
|
import { useCallback as useCallback3 } from "react";
|
|
8
8
|
|
|
9
|
-
// src/
|
|
10
|
-
import {
|
|
9
|
+
// src/ui/button.tsx
|
|
10
|
+
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
11
|
+
import { cva } from "class-variance-authority";
|
|
11
12
|
|
|
12
|
-
// src/
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// src/ui/utils.ts
|
|
14
|
+
import { clsx } from "clsx";
|
|
15
|
+
import { twMerge } from "tailwind-merge";
|
|
16
|
+
var cn = (...inputs) => twMerge(clsx(inputs));
|
|
17
|
+
|
|
18
|
+
// src/ui/button.tsx
|
|
19
|
+
import { jsx } from "react/jsx-runtime";
|
|
20
|
+
var buttonVariants = cva(
|
|
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-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 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-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 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(
|
|
236
|
+
({ className = "", active = false, ...props }, ref) => {
|
|
237
|
+
const cls = [
|
|
238
|
+
"rte-bubble-btn",
|
|
239
|
+
active ? "rte-bubble-btn--active" : "",
|
|
240
|
+
className
|
|
241
|
+
].filter(Boolean).join(" ");
|
|
242
|
+
return /* @__PURE__ */ jsx5("button", { ref, type: "button", className: cls, ...props });
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
RteButton.displayName = "RteButton";
|
|
246
|
+
|
|
247
|
+
// src/ui/rte-button-group.tsx
|
|
248
|
+
import * as React5 from "react";
|
|
249
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
250
|
+
var RteButtonGroup = React5.forwardRef(
|
|
251
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ jsx6(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
ref,
|
|
255
|
+
className: `rte-bubble-group ${className}`.trim(),
|
|
256
|
+
...props
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
RteButtonGroup.displayName = "RteButtonGroup";
|
|
261
|
+
|
|
262
|
+
// src/ui/rte-icon.tsx
|
|
263
|
+
import * as React6 from "react";
|
|
264
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
265
|
+
var RteIcon = React6.forwardRef(
|
|
266
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ jsx7(
|
|
267
|
+
"span",
|
|
268
|
+
{
|
|
269
|
+
ref,
|
|
270
|
+
className: `rte-bubble-btn-icon ${className}`.trim(),
|
|
271
|
+
...props
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
);
|
|
275
|
+
RteIcon.displayName = "RteIcon";
|
|
276
|
+
|
|
277
|
+
// src/ui/rte-separator.tsx
|
|
278
|
+
import * as React7 from "react";
|
|
279
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
280
|
+
var RteSeparator = React7.forwardRef(
|
|
281
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ jsx8(
|
|
282
|
+
"div",
|
|
283
|
+
{
|
|
284
|
+
ref,
|
|
285
|
+
className: `rte-bubble-separator ${className}`.trim(),
|
|
286
|
+
...props
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
);
|
|
290
|
+
RteSeparator.displayName = "RteSeparator";
|
|
291
|
+
|
|
292
|
+
// src/ui/rte-overlay.tsx
|
|
293
|
+
import * as React8 from "react";
|
|
294
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
295
|
+
var RteOverlay = React8.forwardRef(
|
|
296
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ jsx9(
|
|
297
|
+
"div",
|
|
298
|
+
{
|
|
299
|
+
ref,
|
|
300
|
+
role: "presentation",
|
|
301
|
+
className: `rte-bubble-overlay ${className}`.trim(),
|
|
302
|
+
...props
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
);
|
|
306
|
+
RteOverlay.displayName = "RteOverlay";
|
|
307
|
+
|
|
308
|
+
// src/ui/rte-dropdown.tsx
|
|
309
|
+
import * as React9 from "react";
|
|
310
|
+
import { useCallback, useRef, useState } from "react";
|
|
311
|
+
import { jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
312
|
+
var variantClass = {
|
|
313
|
+
color: "rte-bubble-dropdown--color",
|
|
314
|
+
default: "",
|
|
315
|
+
language: "rte-bubble-dropdown--language"
|
|
316
|
+
};
|
|
317
|
+
var RteDropdown = React9.forwardRef(
|
|
318
|
+
({ className = "", variant = "default", children, onMouseLeave, ...props }, ref) => {
|
|
319
|
+
const containerRef = useRef(null);
|
|
320
|
+
const [pill, setPill] = useState(null);
|
|
321
|
+
const handleItemEnter = useCallback((target) => {
|
|
322
|
+
const item = target.closest(
|
|
323
|
+
"[data-dropdown-item]"
|
|
324
|
+
);
|
|
325
|
+
if (!item) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
setPill({
|
|
329
|
+
height: item.offsetHeight,
|
|
330
|
+
left: item.offsetLeft,
|
|
331
|
+
top: item.offsetTop,
|
|
332
|
+
width: item.offsetWidth
|
|
333
|
+
});
|
|
334
|
+
}, []);
|
|
335
|
+
const handleMouseOver = useCallback(
|
|
336
|
+
(event) => {
|
|
337
|
+
handleItemEnter(event.target);
|
|
338
|
+
},
|
|
339
|
+
[handleItemEnter]
|
|
340
|
+
);
|
|
341
|
+
const handleFocus = useCallback(
|
|
342
|
+
(event) => {
|
|
343
|
+
handleItemEnter(event.target);
|
|
344
|
+
},
|
|
345
|
+
[handleItemEnter]
|
|
346
|
+
);
|
|
347
|
+
const handleMouseLeaveFn = useCallback(
|
|
348
|
+
(event) => {
|
|
349
|
+
setPill(null);
|
|
350
|
+
onMouseLeave?.(event);
|
|
351
|
+
},
|
|
352
|
+
[onMouseLeave]
|
|
353
|
+
);
|
|
354
|
+
const cls = ["rte-bubble-dropdown", variantClass[variant], className].filter(Boolean).join(" ");
|
|
355
|
+
return /* @__PURE__ */ jsxs2(
|
|
356
|
+
"div",
|
|
357
|
+
{
|
|
358
|
+
ref: (node) => {
|
|
359
|
+
containerRef.current = node;
|
|
360
|
+
if (typeof ref === "function") {
|
|
361
|
+
ref(node);
|
|
362
|
+
} else if (ref) {
|
|
363
|
+
ref.current = node;
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
className: cls,
|
|
367
|
+
onFocus: handleFocus,
|
|
368
|
+
onMouseLeave: handleMouseLeaveFn,
|
|
369
|
+
onMouseOver: handleMouseOver,
|
|
370
|
+
...props,
|
|
371
|
+
children: [
|
|
372
|
+
/* @__PURE__ */ jsx10(
|
|
373
|
+
"div",
|
|
374
|
+
{
|
|
375
|
+
"aria-hidden": "true",
|
|
376
|
+
className: [
|
|
377
|
+
"rte-bubble-dropdown-pill",
|
|
378
|
+
pill ? "rte-bubble-dropdown-pill--visible" : ""
|
|
379
|
+
].filter(Boolean).join(" "),
|
|
380
|
+
style: pill ? {
|
|
381
|
+
height: pill.height,
|
|
382
|
+
left: pill.left,
|
|
383
|
+
top: pill.top,
|
|
384
|
+
width: pill.width
|
|
385
|
+
} : void 0
|
|
386
|
+
}
|
|
387
|
+
),
|
|
388
|
+
children
|
|
389
|
+
]
|
|
390
|
+
}
|
|
20
391
|
);
|
|
21
392
|
}
|
|
22
|
-
|
|
393
|
+
);
|
|
394
|
+
RteDropdown.displayName = "RteDropdown";
|
|
395
|
+
|
|
396
|
+
// src/ui/rte-color-swatch.tsx
|
|
397
|
+
import * as React10 from "react";
|
|
398
|
+
import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
399
|
+
var getCheckColor = (hex) => {
|
|
400
|
+
const value = hex.replace("#", "");
|
|
401
|
+
const r = Number.parseInt(value.slice(0, 2), 16) / 255;
|
|
402
|
+
const g = Number.parseInt(value.slice(2, 4), 16) / 255;
|
|
403
|
+
const b = Number.parseInt(value.slice(4, 6), 16) / 255;
|
|
404
|
+
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
405
|
+
return luminance > 0.5 ? "#18181b" : "#ffffff";
|
|
23
406
|
};
|
|
407
|
+
var RteColorSwatch = React10.forwardRef(
|
|
408
|
+
({ color, label, variant, active = false, onSelect }, ref) => {
|
|
409
|
+
const checkColor = getCheckColor(color);
|
|
410
|
+
return /* @__PURE__ */ jsxs3(
|
|
411
|
+
"button",
|
|
412
|
+
{
|
|
413
|
+
ref,
|
|
414
|
+
type: "button",
|
|
415
|
+
"aria-pressed": active,
|
|
416
|
+
"aria-label": label,
|
|
417
|
+
title: label,
|
|
418
|
+
className: [
|
|
419
|
+
"rte-bubble-color-swatch",
|
|
420
|
+
variant === "text" ? "rte-bubble-color-swatch--text" : "rte-bubble-color-swatch--highlight",
|
|
421
|
+
active ? "rte-bubble-color-swatch--active" : ""
|
|
422
|
+
].filter(Boolean).join(" "),
|
|
423
|
+
style: {
|
|
424
|
+
"--swatch-check": checkColor,
|
|
425
|
+
"--swatch-color": color
|
|
426
|
+
},
|
|
427
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
428
|
+
onClick: () => onSelect(color),
|
|
429
|
+
children: [
|
|
430
|
+
variant === "text" && !active ? /* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-glyph", "aria-hidden": "true", children: "A" }) : null,
|
|
431
|
+
active ? /* @__PURE__ */ jsx11("span", { className: "rte-bubble-color-check", "aria-hidden": "true", children: /* @__PURE__ */ jsx11(
|
|
432
|
+
"svg",
|
|
433
|
+
{
|
|
434
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
435
|
+
viewBox: "0 0 24 24",
|
|
436
|
+
fill: "none",
|
|
437
|
+
stroke: "currentColor",
|
|
438
|
+
strokeWidth: 3,
|
|
439
|
+
strokeLinecap: "round",
|
|
440
|
+
strokeLinejoin: "round",
|
|
441
|
+
children: /* @__PURE__ */ jsx11("path", { d: "M20 6 9 17l-5-5" })
|
|
442
|
+
}
|
|
443
|
+
) }) : null
|
|
444
|
+
]
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
RteColorSwatch.displayName = "RteColorSwatch";
|
|
450
|
+
|
|
451
|
+
// src/ui/rte-dropdown-item.tsx
|
|
452
|
+
import * as React11 from "react";
|
|
453
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
454
|
+
var RteDropdownItem = React11.forwardRef(({ className = "", active = false, ...props }, ref) => {
|
|
455
|
+
const cls = [
|
|
456
|
+
"rte-bubble-dropdown-item",
|
|
457
|
+
active ? "rte-bubble-dropdown-item--active" : "",
|
|
458
|
+
className
|
|
459
|
+
].filter(Boolean).join(" ");
|
|
460
|
+
return /* @__PURE__ */ jsx12(
|
|
461
|
+
"button",
|
|
462
|
+
{
|
|
463
|
+
ref,
|
|
464
|
+
type: "button",
|
|
465
|
+
"data-dropdown-item": true,
|
|
466
|
+
className: cls,
|
|
467
|
+
...props
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
});
|
|
471
|
+
RteDropdownItem.displayName = "RteDropdownItem";
|
|
472
|
+
|
|
473
|
+
// src/ui/rte-dropdown-divider.tsx
|
|
474
|
+
import * as React12 from "react";
|
|
475
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
476
|
+
var RteDropdownDivider = React12.forwardRef(({ className = "", ...props }, ref) => /* @__PURE__ */ jsx13(
|
|
477
|
+
"div",
|
|
478
|
+
{
|
|
479
|
+
ref,
|
|
480
|
+
className: `rte-bubble-dropdown-divider ${className}`.trim(),
|
|
481
|
+
...props
|
|
482
|
+
}
|
|
483
|
+
));
|
|
484
|
+
RteDropdownDivider.displayName = "RteDropdownDivider";
|
|
485
|
+
|
|
486
|
+
// src/ui/rte-dropdown-icon.tsx
|
|
487
|
+
import * as React13 from "react";
|
|
488
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
489
|
+
var RteDropdownIcon = React13.forwardRef(
|
|
490
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ jsx14(
|
|
491
|
+
"span",
|
|
492
|
+
{
|
|
493
|
+
ref,
|
|
494
|
+
className: `rte-bubble-dropdown-icon ${className}`.trim(),
|
|
495
|
+
...props
|
|
496
|
+
}
|
|
497
|
+
)
|
|
498
|
+
);
|
|
499
|
+
RteDropdownIcon.displayName = "RteDropdownIcon";
|
|
500
|
+
|
|
501
|
+
// src/ui/toggle.tsx
|
|
502
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
503
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
504
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
505
|
+
var toggleVariants = cva2(
|
|
506
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] 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",
|
|
507
|
+
{
|
|
508
|
+
defaultVariants: {
|
|
509
|
+
size: "default",
|
|
510
|
+
variant: "default"
|
|
511
|
+
},
|
|
512
|
+
variants: {
|
|
513
|
+
size: {
|
|
514
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
515
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
516
|
+
sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
517
|
+
},
|
|
518
|
+
variant: {
|
|
519
|
+
default: "bg-transparent",
|
|
520
|
+
outline: "border border-input bg-transparent hover:bg-muted"
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
var Toggle = ({
|
|
526
|
+
className,
|
|
527
|
+
variant = "default",
|
|
528
|
+
size = "default",
|
|
529
|
+
...props
|
|
530
|
+
}) => /* @__PURE__ */ jsx15(
|
|
531
|
+
TogglePrimitive,
|
|
532
|
+
{
|
|
533
|
+
"data-slot": "toggle",
|
|
534
|
+
className: cn(toggleVariants({ className, size, variant })),
|
|
535
|
+
...props
|
|
536
|
+
}
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
// src/bubble-menu/color-selector.tsx
|
|
540
|
+
import { useState as useState2 } from "react";
|
|
24
541
|
|
|
25
542
|
// src/bubble-menu/utils.ts
|
|
26
|
-
import { useCallback, useEffect, useRef, useSyncExternalStore } from "react";
|
|
543
|
+
import { useCallback as useCallback2, useEffect, useRef as useRef2, useSyncExternalStore } from "react";
|
|
27
544
|
var defaultEqual = (a, b) => a === b;
|
|
28
545
|
var shallowEqual = (a, b) => {
|
|
29
546
|
if (a === b) {
|
|
@@ -40,16 +557,16 @@ var shallowEqual = (a, b) => {
|
|
|
40
557
|
return ak.every((k) => a[k] === b[k]);
|
|
41
558
|
};
|
|
42
559
|
var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
43
|
-
const selectorRef =
|
|
44
|
-
const isEqualRef =
|
|
560
|
+
const selectorRef = useRef2(selector);
|
|
561
|
+
const isEqualRef = useRef2(isEqual);
|
|
45
562
|
useEffect(() => {
|
|
46
563
|
selectorRef.current = selector;
|
|
47
564
|
isEqualRef.current = isEqual;
|
|
48
565
|
});
|
|
49
|
-
const snapshotRef =
|
|
566
|
+
const snapshotRef = useRef2({
|
|
50
567
|
value: editor ? selector(editor) : void 0
|
|
51
568
|
});
|
|
52
|
-
const updateSnapshot =
|
|
569
|
+
const updateSnapshot = useCallback2(() => {
|
|
53
570
|
if (!editor) {
|
|
54
571
|
return;
|
|
55
572
|
}
|
|
@@ -59,7 +576,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
|
59
576
|
}
|
|
60
577
|
snapshotRef.current = { value: next };
|
|
61
578
|
}, [editor]);
|
|
62
|
-
const subscribe =
|
|
579
|
+
const subscribe = useCallback2(
|
|
63
580
|
(onStoreChange) => {
|
|
64
581
|
if (!editor) {
|
|
65
582
|
return () => {
|
|
@@ -78,7 +595,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
|
78
595
|
},
|
|
79
596
|
[editor, updateSnapshot]
|
|
80
597
|
);
|
|
81
|
-
const getSnapshot =
|
|
598
|
+
const getSnapshot = useCallback2(() => snapshotRef.current.value, []);
|
|
82
599
|
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
83
600
|
};
|
|
84
601
|
var CODE_BLOCK_LANGUAGES = [
|
|
@@ -129,9 +646,214 @@ var CODE_BLOCK_LANGUAGE_LABELS = {
|
|
|
129
646
|
};
|
|
130
647
|
var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
|
|
131
648
|
|
|
649
|
+
// src/bubble-menu/color-selector.tsx
|
|
650
|
+
import { Fragment, jsx as jsx16, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
651
|
+
var RECENT_KEY = "editorcn-editor-recent-colors";
|
|
652
|
+
var RECENT_LIMIT = 10;
|
|
653
|
+
var readRecentColors = () => {
|
|
654
|
+
if (typeof window === "undefined") {
|
|
655
|
+
return [];
|
|
656
|
+
}
|
|
657
|
+
try {
|
|
658
|
+
const raw = window.localStorage.getItem(RECENT_KEY);
|
|
659
|
+
if (!raw) {
|
|
660
|
+
return [];
|
|
661
|
+
}
|
|
662
|
+
const parsed = JSON.parse(raw);
|
|
663
|
+
return Array.isArray(parsed) ? parsed.slice(0, RECENT_LIMIT) : [];
|
|
664
|
+
} catch {
|
|
665
|
+
return [];
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
var persistRecentColors = (recent) => {
|
|
669
|
+
try {
|
|
670
|
+
window.localStorage.setItem(RECENT_KEY, JSON.stringify(recent));
|
|
671
|
+
} catch {
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var TEXT_COLORS = [
|
|
675
|
+
{ color: "#0f172a", label: "Foreground" },
|
|
676
|
+
{ color: "#ef4444", label: "Red" },
|
|
677
|
+
{ color: "#f97316", label: "Orange" },
|
|
678
|
+
{ color: "#f59e0b", label: "Amber" },
|
|
679
|
+
{ color: "#22c55e", label: "Green" },
|
|
680
|
+
{ color: "#0ea5e9", label: "Sky" },
|
|
681
|
+
{ color: "#3b82f6", label: "Blue" },
|
|
682
|
+
{ color: "#6366f1", label: "Indigo" },
|
|
683
|
+
{ color: "#a855f7", label: "Purple" },
|
|
684
|
+
{ color: "#ec4899", label: "Pink" }
|
|
685
|
+
];
|
|
686
|
+
var HIGHLIGHT_COLORS = [
|
|
687
|
+
{ color: "#fef08a", label: "Yellow" },
|
|
688
|
+
{ color: "#fed7aa", label: "Orange" },
|
|
689
|
+
{ color: "#fecaca", label: "Red" },
|
|
690
|
+
{ color: "#fbcfe8", label: "Pink" },
|
|
691
|
+
{ color: "#e9d5ff", label: "Purple" },
|
|
692
|
+
{ color: "#ddd6fe", label: "Violet" },
|
|
693
|
+
{ color: "#bfdbfe", label: "Blue" },
|
|
694
|
+
{ color: "#a5f3fc", label: "Cyan" },
|
|
695
|
+
{ color: "#99f6e4", label: "Teal" },
|
|
696
|
+
{ color: "#bbf7d0", label: "Green" }
|
|
697
|
+
];
|
|
698
|
+
var ColorSelector = ({ editor }) => {
|
|
699
|
+
const [open, setOpen] = useState2(false);
|
|
700
|
+
const [recent, setRecent] = useState2(() => readRecentColors());
|
|
701
|
+
const { highlightColor, textColor } = useEditorState(
|
|
702
|
+
editor,
|
|
703
|
+
(ed) => ({
|
|
704
|
+
highlightColor: ed.isActive("highlight") ? ed.getAttributes("highlight").color : void 0,
|
|
705
|
+
textColor: ed.isActive("textStyle") ? ed.getAttributes("textStyle").color : void 0
|
|
706
|
+
}),
|
|
707
|
+
shallowEqual
|
|
708
|
+
);
|
|
709
|
+
const hasColor = editor.extensionManager.extensions.some(
|
|
710
|
+
(ext) => ext.name === "color"
|
|
711
|
+
);
|
|
712
|
+
const hasHighlight = editor.extensionManager.extensions.some(
|
|
713
|
+
(ext) => ext.name === "highlight"
|
|
714
|
+
);
|
|
715
|
+
const remember = (type, color, label) => {
|
|
716
|
+
setRecent((prev) => {
|
|
717
|
+
const next = [
|
|
718
|
+
{ color, label, type },
|
|
719
|
+
...prev.filter((item) => !(item.type === type && item.color === color))
|
|
720
|
+
].slice(0, RECENT_LIMIT);
|
|
721
|
+
persistRecentColors(next);
|
|
722
|
+
return next;
|
|
723
|
+
});
|
|
724
|
+
};
|
|
725
|
+
const selectText = (color, label) => {
|
|
726
|
+
remember("text", color, label);
|
|
727
|
+
if (textColor === color) {
|
|
728
|
+
editor.chain().focus().unsetColor().run();
|
|
729
|
+
} else {
|
|
730
|
+
editor.chain().focus().setColor(color).run();
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
const selectHighlight = (color, label) => {
|
|
734
|
+
remember("highlight", color, label);
|
|
735
|
+
if (highlightColor === color) {
|
|
736
|
+
editor.chain().focus().unsetHighlight().run();
|
|
737
|
+
} else {
|
|
738
|
+
editor.chain().focus().setHighlight({ color }).run();
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
if (!hasColor && !hasHighlight) {
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
return /* @__PURE__ */ jsxs4("div", { style: { position: "relative" }, children: [
|
|
745
|
+
/* @__PURE__ */ jsx16(
|
|
746
|
+
RteButton,
|
|
747
|
+
{
|
|
748
|
+
active: Boolean(textColor || highlightColor),
|
|
749
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
750
|
+
onClick: () => setOpen(!open),
|
|
751
|
+
title: "Text color",
|
|
752
|
+
children: /* @__PURE__ */ jsx16(RteIcon, { children: /* @__PURE__ */ jsxs4(
|
|
753
|
+
"svg",
|
|
754
|
+
{
|
|
755
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
756
|
+
viewBox: "0 0 24 24",
|
|
757
|
+
fill: "none",
|
|
758
|
+
stroke: "currentColor",
|
|
759
|
+
strokeWidth: 2,
|
|
760
|
+
strokeLinecap: "round",
|
|
761
|
+
strokeLinejoin: "round",
|
|
762
|
+
className: "rte-editor-icon",
|
|
763
|
+
children: [
|
|
764
|
+
/* @__PURE__ */ jsx16("path", { d: "M4 20h16" }),
|
|
765
|
+
/* @__PURE__ */ jsx16("path", { d: "m6 16 6-12 6 12" }),
|
|
766
|
+
/* @__PURE__ */ jsx16("path", { d: "M8 12h8" })
|
|
767
|
+
]
|
|
768
|
+
}
|
|
769
|
+
) })
|
|
770
|
+
}
|
|
771
|
+
),
|
|
772
|
+
open && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
773
|
+
/* @__PURE__ */ jsx16(
|
|
774
|
+
RteOverlay,
|
|
775
|
+
{
|
|
776
|
+
onClick: () => setOpen(false),
|
|
777
|
+
onKeyDown: (e) => {
|
|
778
|
+
if (e.key === "Escape") {
|
|
779
|
+
setOpen(false);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
),
|
|
784
|
+
/* @__PURE__ */ jsxs4(RteDropdown, { variant: "color", children: [
|
|
785
|
+
recent.length > 0 ? /* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
|
|
786
|
+
/* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Recently Used" }),
|
|
787
|
+
/* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-recent", children: recent.map((item) => /* @__PURE__ */ jsx16(
|
|
788
|
+
RteColorSwatch,
|
|
789
|
+
{
|
|
790
|
+
variant: item.type,
|
|
791
|
+
color: item.color,
|
|
792
|
+
label: item.label,
|
|
793
|
+
active: item.type === "text" ? textColor === item.color : highlightColor === item.color,
|
|
794
|
+
onSelect: () => item.type === "text" ? selectText(item.color, item.label) : selectHighlight(item.color, item.label)
|
|
795
|
+
},
|
|
796
|
+
`${item.type}-${item.color}`
|
|
797
|
+
)) })
|
|
798
|
+
] }) : null,
|
|
799
|
+
hasColor ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
800
|
+
recent.length > 0 && /* @__PURE__ */ jsx16(RteDropdownDivider, {}),
|
|
801
|
+
/* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
|
|
802
|
+
/* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Text Color" }),
|
|
803
|
+
/* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-grid", children: TEXT_COLORS.map((item) => /* @__PURE__ */ jsx16(
|
|
804
|
+
RteColorSwatch,
|
|
805
|
+
{
|
|
806
|
+
variant: "text",
|
|
807
|
+
color: item.color,
|
|
808
|
+
label: item.label,
|
|
809
|
+
active: textColor === item.color,
|
|
810
|
+
onSelect: () => selectText(item.color, item.label)
|
|
811
|
+
},
|
|
812
|
+
item.color
|
|
813
|
+
)) })
|
|
814
|
+
] })
|
|
815
|
+
] }) : null,
|
|
816
|
+
hasHighlight ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
817
|
+
(recent.length > 0 || hasColor) && /* @__PURE__ */ jsx16(RteDropdownDivider, {}),
|
|
818
|
+
/* @__PURE__ */ jsxs4("div", { className: "rte-bubble-color-section", children: [
|
|
819
|
+
/* @__PURE__ */ jsx16("span", { className: "rte-bubble-color-label", children: "Highlight Color" }),
|
|
820
|
+
/* @__PURE__ */ jsx16("div", { className: "rte-bubble-color-grid", children: HIGHLIGHT_COLORS.map((item) => /* @__PURE__ */ jsx16(
|
|
821
|
+
RteColorSwatch,
|
|
822
|
+
{
|
|
823
|
+
variant: "highlight",
|
|
824
|
+
color: item.color,
|
|
825
|
+
label: item.label,
|
|
826
|
+
active: highlightColor === item.color,
|
|
827
|
+
onSelect: () => selectHighlight(item.color, item.label)
|
|
828
|
+
},
|
|
829
|
+
item.color
|
|
830
|
+
)) })
|
|
831
|
+
] })
|
|
832
|
+
] }) : null
|
|
833
|
+
] })
|
|
834
|
+
] })
|
|
835
|
+
] });
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/bubble-menu/language-selector.tsx
|
|
839
|
+
import { useState as useState3 } from "react";
|
|
840
|
+
|
|
841
|
+
// src/rte-context.ts
|
|
842
|
+
import { createContext, useContext } from "react";
|
|
843
|
+
var RichTextEditorContext = createContext(null);
|
|
844
|
+
var useRichTextEditorContext = () => {
|
|
845
|
+
const context = useContext(RichTextEditorContext);
|
|
846
|
+
if (!context) {
|
|
847
|
+
throw new Error(
|
|
848
|
+
"useRichTextEditorContext must be used within RichTextEditor"
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
return context;
|
|
852
|
+
};
|
|
853
|
+
|
|
132
854
|
// src/bubble-menu/language-selector.tsx
|
|
133
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
134
|
-
var FallbackIcon = () => /* @__PURE__ */
|
|
855
|
+
import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
856
|
+
var FallbackIcon = () => /* @__PURE__ */ jsxs5(
|
|
135
857
|
"svg",
|
|
136
858
|
{
|
|
137
859
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -143,14 +865,13 @@ var FallbackIcon = () => /* @__PURE__ */ jsxs(
|
|
|
143
865
|
strokeLinejoin: "round",
|
|
144
866
|
className: "rte-editor-icon",
|
|
145
867
|
children: [
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
868
|
+
/* @__PURE__ */ jsx17("polyline", { points: "16 18 22 12 16 6" }),
|
|
869
|
+
/* @__PURE__ */ jsx17("polyline", { points: "8 6 2 12 8 18" })
|
|
148
870
|
]
|
|
149
871
|
}
|
|
150
872
|
);
|
|
151
873
|
var LanguageSelector = ({ editor }) => {
|
|
152
|
-
const [open, setOpen] =
|
|
153
|
-
const [pill, setPill] = useState(null);
|
|
874
|
+
const [open, setOpen] = useState3(false);
|
|
154
875
|
const { icons } = useRichTextEditorContext();
|
|
155
876
|
const { currentLanguage } = useEditorState(
|
|
156
877
|
editor,
|
|
@@ -159,45 +880,17 @@ var LanguageSelector = ({ editor }) => {
|
|
|
159
880
|
}),
|
|
160
881
|
shallowEqual
|
|
161
882
|
);
|
|
162
|
-
const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
);
|
|
167
|
-
if (!item) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
setPill({
|
|
171
|
-
height: item.offsetHeight,
|
|
172
|
-
left: item.offsetLeft,
|
|
173
|
-
top: item.offsetTop,
|
|
174
|
-
width: item.offsetWidth
|
|
175
|
-
});
|
|
176
|
-
}, []);
|
|
177
|
-
const handleMouseOver = useCallback2(
|
|
178
|
-
(event) => {
|
|
179
|
-
handleItemEnter(event.target);
|
|
180
|
-
},
|
|
181
|
-
[handleItemEnter]
|
|
182
|
-
);
|
|
183
|
-
const handleFocus = useCallback2(
|
|
184
|
-
(event) => {
|
|
185
|
-
handleItemEnter(event.target);
|
|
186
|
-
},
|
|
187
|
-
[handleItemEnter]
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
|
|
190
|
-
/* @__PURE__ */ jsxs(
|
|
191
|
-
"button",
|
|
883
|
+
const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ jsx17(FallbackIcon, {});
|
|
884
|
+
return /* @__PURE__ */ jsxs5("div", { style: { position: "relative" }, children: [
|
|
885
|
+
/* @__PURE__ */ jsxs5(
|
|
886
|
+
RteButton,
|
|
192
887
|
{
|
|
193
|
-
type: "button",
|
|
194
|
-
className: "rte-bubble-btn",
|
|
195
888
|
onMouseDown: (e) => e.preventDefault(),
|
|
196
889
|
onClick: () => setOpen(!open),
|
|
197
890
|
children: [
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
/* @__PURE__ */
|
|
891
|
+
/* @__PURE__ */ jsx17(RteIcon, { children: langIcon }),
|
|
892
|
+
/* @__PURE__ */ jsx17("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
|
|
893
|
+
/* @__PURE__ */ jsx17(RteIcon, { style: { height: 12, width: 12 }, children: /* @__PURE__ */ jsx17(
|
|
201
894
|
"svg",
|
|
202
895
|
{
|
|
203
896
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -207,18 +900,16 @@ var LanguageSelector = ({ editor }) => {
|
|
|
207
900
|
strokeWidth: 2,
|
|
208
901
|
strokeLinecap: "round",
|
|
209
902
|
strokeLinejoin: "round",
|
|
210
|
-
children: /* @__PURE__ */
|
|
903
|
+
children: /* @__PURE__ */ jsx17("path", { d: "m6 9 6 6 6-6" })
|
|
211
904
|
}
|
|
212
905
|
) })
|
|
213
906
|
]
|
|
214
907
|
}
|
|
215
908
|
),
|
|
216
|
-
open && /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
909
|
+
open && /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
910
|
+
/* @__PURE__ */ jsx17(
|
|
911
|
+
RteOverlay,
|
|
219
912
|
{
|
|
220
|
-
className: "rte-bubble-overlay",
|
|
221
|
-
role: "presentation",
|
|
222
913
|
onClick: () => setOpen(false),
|
|
223
914
|
onKeyDown: (e) => {
|
|
224
915
|
if (e.key === "Escape") {
|
|
@@ -227,61 +918,32 @@ var LanguageSelector = ({ editor }) => {
|
|
|
227
918
|
}
|
|
228
919
|
}
|
|
229
920
|
),
|
|
230
|
-
/* @__PURE__ */
|
|
231
|
-
|
|
921
|
+
/* @__PURE__ */ jsx17(RteDropdown, { variant: "language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs5(
|
|
922
|
+
RteDropdownItem,
|
|
232
923
|
{
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
924
|
+
active: currentLanguage === lang,
|
|
925
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
926
|
+
onClick: () => {
|
|
927
|
+
editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
|
|
928
|
+
setOpen(false);
|
|
929
|
+
},
|
|
237
930
|
children: [
|
|
238
|
-
/* @__PURE__ */
|
|
239
|
-
|
|
240
|
-
{
|
|
241
|
-
"aria-hidden": "true",
|
|
242
|
-
className: [
|
|
243
|
-
"rte-bubble-dropdown-pill",
|
|
244
|
-
pill ? "rte-bubble-dropdown-pill--visible" : ""
|
|
245
|
-
].filter(Boolean).join(" "),
|
|
246
|
-
style: pill ? {
|
|
247
|
-
height: pill.height,
|
|
248
|
-
left: pill.left,
|
|
249
|
-
top: pill.top,
|
|
250
|
-
width: pill.width
|
|
251
|
-
} : void 0
|
|
252
|
-
}
|
|
253
|
-
),
|
|
254
|
-
CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
|
|
255
|
-
"button",
|
|
256
|
-
{
|
|
257
|
-
type: "button",
|
|
258
|
-
"data-dropdown-item": true,
|
|
259
|
-
className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
|
|
260
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
261
|
-
onClick: () => {
|
|
262
|
-
editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
|
|
263
|
-
setOpen(false);
|
|
264
|
-
},
|
|
265
|
-
children: [
|
|
266
|
-
/* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
|
|
267
|
-
/* @__PURE__ */ jsx("span", { children: getLanguageLabel(lang) })
|
|
268
|
-
]
|
|
269
|
-
},
|
|
270
|
-
lang
|
|
271
|
-
))
|
|
931
|
+
/* @__PURE__ */ jsx17(RteDropdownIcon, { children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx17(FallbackIcon, {}) }),
|
|
932
|
+
/* @__PURE__ */ jsx17("span", { children: getLanguageLabel(lang) })
|
|
272
933
|
]
|
|
273
|
-
}
|
|
274
|
-
|
|
934
|
+
},
|
|
935
|
+
lang
|
|
936
|
+
)) })
|
|
275
937
|
] })
|
|
276
938
|
] });
|
|
277
939
|
};
|
|
278
940
|
|
|
279
941
|
// src/bubble-menu/text-buttons.tsx
|
|
280
|
-
import { jsx as
|
|
942
|
+
import { jsx as jsx18, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
281
943
|
var Svg = ({
|
|
282
944
|
children,
|
|
283
945
|
strokeWidth = 2
|
|
284
|
-
}) => /* @__PURE__ */
|
|
946
|
+
}) => /* @__PURE__ */ jsx18(
|
|
285
947
|
"svg",
|
|
286
948
|
{
|
|
287
949
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -295,47 +957,48 @@ var Svg = ({
|
|
|
295
957
|
children
|
|
296
958
|
}
|
|
297
959
|
);
|
|
960
|
+
var Icon = ({ children }) => /* @__PURE__ */ jsx18(RteIcon, { children });
|
|
298
961
|
var textItems = [
|
|
299
962
|
{
|
|
300
963
|
command: (e) => e.chain().focus().toggleBold().run(),
|
|
301
|
-
icon: /* @__PURE__ */
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
/* @__PURE__ */
|
|
304
|
-
] }),
|
|
964
|
+
icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
|
|
965
|
+
/* @__PURE__ */ jsx18("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
966
|
+
/* @__PURE__ */ jsx18("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
967
|
+
] }) }),
|
|
305
968
|
isActive: (s) => s.isBold
|
|
306
969
|
},
|
|
307
970
|
{
|
|
308
971
|
command: (e) => e.chain().focus().toggleItalic().run(),
|
|
309
|
-
icon: /* @__PURE__ */
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
] }),
|
|
972
|
+
icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
|
|
973
|
+
/* @__PURE__ */ jsx18("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
974
|
+
/* @__PURE__ */ jsx18("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
975
|
+
/* @__PURE__ */ jsx18("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
976
|
+
] }) }),
|
|
314
977
|
isActive: (s) => s.isItalic
|
|
315
978
|
},
|
|
316
979
|
{
|
|
317
980
|
command: (e) => e.chain().focus().toggleUnderline().run(),
|
|
318
|
-
icon: /* @__PURE__ */
|
|
319
|
-
/* @__PURE__ */
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
] }),
|
|
981
|
+
icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
|
|
982
|
+
/* @__PURE__ */ jsx18("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
983
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
|
|
984
|
+
] }) }),
|
|
322
985
|
isActive: (s) => s.isUnderline
|
|
323
986
|
},
|
|
324
987
|
{
|
|
325
988
|
command: (e) => e.chain().focus().toggleStrike().run(),
|
|
326
|
-
icon: /* @__PURE__ */
|
|
327
|
-
/* @__PURE__ */
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
/* @__PURE__ */
|
|
330
|
-
] }),
|
|
989
|
+
icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
|
|
990
|
+
/* @__PURE__ */ jsx18("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
|
|
991
|
+
/* @__PURE__ */ jsx18("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
|
|
992
|
+
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
993
|
+
] }) }),
|
|
331
994
|
isActive: (s) => s.isStrike
|
|
332
995
|
},
|
|
333
996
|
{
|
|
334
997
|
command: (e) => e.chain().focus().toggleCode().run(),
|
|
335
|
-
icon: /* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
] }),
|
|
998
|
+
icon: /* @__PURE__ */ jsx18(Icon, { children: /* @__PURE__ */ jsxs6(Svg, { children: [
|
|
999
|
+
/* @__PURE__ */ jsx18("polyline", { points: "16 18 22 12 16 6" }),
|
|
1000
|
+
/* @__PURE__ */ jsx18("polyline", { points: "8 6 2 12 8 18" })
|
|
1001
|
+
] }) }),
|
|
339
1002
|
isActive: (s) => s.isCode
|
|
340
1003
|
}
|
|
341
1004
|
];
|
|
@@ -351,11 +1014,10 @@ var TextButtons = ({ editor }) => {
|
|
|
351
1014
|
}),
|
|
352
1015
|
shallowEqual
|
|
353
1016
|
);
|
|
354
|
-
return /* @__PURE__ */
|
|
355
|
-
|
|
1017
|
+
return /* @__PURE__ */ jsx18(RteButtonGroup, { children: textItems.map((item, i) => /* @__PURE__ */ jsx18(
|
|
1018
|
+
RteButton,
|
|
356
1019
|
{
|
|
357
|
-
|
|
358
|
-
className: `rte-bubble-btn${item.isActive(editorState) ? " rte-bubble-btn--active" : ""}`,
|
|
1020
|
+
active: item.isActive(editorState),
|
|
359
1021
|
onMouseDown: (e) => e.preventDefault(),
|
|
360
1022
|
onClick: () => item.command(editor),
|
|
361
1023
|
children: item.icon
|
|
@@ -365,7 +1027,7 @@ var TextButtons = ({ editor }) => {
|
|
|
365
1027
|
};
|
|
366
1028
|
|
|
367
1029
|
// src/bubble-menu/index.tsx
|
|
368
|
-
import { jsx as
|
|
1030
|
+
import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
369
1031
|
var BubbleMenu = ({ editor }) => {
|
|
370
1032
|
const editorState = useEditorState(
|
|
371
1033
|
editor,
|
|
@@ -377,88 +1039,45 @@ var BubbleMenu = ({ editor }) => {
|
|
|
377
1039
|
const shouldShow = useCallback3(
|
|
378
1040
|
({
|
|
379
1041
|
editor: ed,
|
|
380
|
-
state
|
|
381
|
-
}) => {
|
|
382
|
-
const { selection } = state;
|
|
383
|
-
if (!ed.isEditable) {
|
|
384
|
-
return false;
|
|
385
|
-
}
|
|
386
|
-
if (selection.empty && !ed.isActive("codeBlock")) {
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
if (!selection.empty && !isTextSelection(selection)) {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
return true;
|
|
393
|
-
},
|
|
394
|
-
[]
|
|
395
|
-
);
|
|
396
|
-
if (!editor) {
|
|
397
|
-
return null;
|
|
398
|
-
}
|
|
399
|
-
const isCodeBlockActive = editorState?.isCodeBlock ?? false;
|
|
400
|
-
return /* @__PURE__ */ jsx3(
|
|
401
|
-
TiptapBubbleMenu,
|
|
402
|
-
{
|
|
403
|
-
editor,
|
|
404
|
-
options: { offset: 8, placement: "top" },
|
|
405
|
-
shouldShow,
|
|
406
|
-
children: /* @__PURE__ */ jsx3("div", { className: "rte-bubble-menu", children: isCodeBlockActive ? /* @__PURE__ */ jsx3(LanguageSelector, { editor }) : /* @__PURE__ */ jsx3(TextButtons, { editor }) })
|
|
407
|
-
}
|
|
408
|
-
);
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
// src/controls/rte-control.tsx
|
|
412
|
-
import { useEditorState as useEditorState2 } from "@tiptap/react";
|
|
413
|
-
import "react";
|
|
414
|
-
|
|
415
|
-
// src/ui/toggle.tsx
|
|
416
|
-
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
417
|
-
import { cva } from "class-variance-authority";
|
|
418
|
-
|
|
419
|
-
// src/ui/utils.ts
|
|
420
|
-
import { clsx } from "clsx";
|
|
421
|
-
import { twMerge } from "tailwind-merge";
|
|
422
|
-
var cn = (...inputs) => twMerge(clsx(inputs));
|
|
423
|
-
|
|
424
|
-
// src/ui/toggle.tsx
|
|
425
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
426
|
-
var toggleVariants = cva(
|
|
427
|
-
"group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] 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",
|
|
428
|
-
{
|
|
429
|
-
defaultVariants: {
|
|
430
|
-
size: "default",
|
|
431
|
-
variant: "default"
|
|
432
|
-
},
|
|
433
|
-
variants: {
|
|
434
|
-
size: {
|
|
435
|
-
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
436
|
-
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
437
|
-
sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
438
|
-
},
|
|
439
|
-
variant: {
|
|
440
|
-
default: "bg-transparent",
|
|
441
|
-
outline: "border border-input bg-transparent hover:bg-muted"
|
|
1042
|
+
state
|
|
1043
|
+
}) => {
|
|
1044
|
+
const { selection } = state;
|
|
1045
|
+
if (!ed.isEditable) {
|
|
1046
|
+
return false;
|
|
442
1047
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
{
|
|
454
|
-
|
|
455
|
-
className: cn(toggleVariants({ className, size, variant })),
|
|
456
|
-
...props
|
|
1048
|
+
if (selection.empty && !ed.isActive("codeBlock")) {
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1051
|
+
if (!selection.empty && !isTextSelection(selection)) {
|
|
1052
|
+
return false;
|
|
1053
|
+
}
|
|
1054
|
+
return true;
|
|
1055
|
+
},
|
|
1056
|
+
[]
|
|
1057
|
+
);
|
|
1058
|
+
if (!editor) {
|
|
1059
|
+
return null;
|
|
457
1060
|
}
|
|
458
|
-
|
|
1061
|
+
const isCodeBlockActive = editorState?.isCodeBlock ?? false;
|
|
1062
|
+
return /* @__PURE__ */ jsx19(
|
|
1063
|
+
TiptapBubbleMenu,
|
|
1064
|
+
{
|
|
1065
|
+
editor,
|
|
1066
|
+
options: { offset: 8, placement: "top" },
|
|
1067
|
+
shouldShow,
|
|
1068
|
+
children: /* @__PURE__ */ jsx19("div", { className: "rte-bubble-menu", children: isCodeBlockActive ? /* @__PURE__ */ jsx19(LanguageSelector, { editor }) : /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
1069
|
+
/* @__PURE__ */ jsx19(TextButtons, { editor }),
|
|
1070
|
+
/* @__PURE__ */ jsx19(RteSeparator, {}),
|
|
1071
|
+
/* @__PURE__ */ jsx19(ColorSelector, { editor })
|
|
1072
|
+
] }) })
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
};
|
|
459
1076
|
|
|
460
1077
|
// src/controls/rte-control.tsx
|
|
461
|
-
import {
|
|
1078
|
+
import { useEditorState as useEditorState2 } from "@tiptap/react";
|
|
1079
|
+
import "react";
|
|
1080
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
462
1081
|
var RichTextEditorControl = ({
|
|
463
1082
|
active,
|
|
464
1083
|
interactive: _interactive = true,
|
|
@@ -468,7 +1087,7 @@ var RichTextEditorControl = ({
|
|
|
468
1087
|
onClick,
|
|
469
1088
|
disabled,
|
|
470
1089
|
...props
|
|
471
|
-
}) => /* @__PURE__ */
|
|
1090
|
+
}) => /* @__PURE__ */ jsx20(
|
|
472
1091
|
Toggle,
|
|
473
1092
|
{
|
|
474
1093
|
size: "sm",
|
|
@@ -517,7 +1136,7 @@ var createControl = ({
|
|
|
517
1136
|
});
|
|
518
1137
|
const active = editorState?.active ?? false;
|
|
519
1138
|
const disabled = editorState?.disabled ?? true;
|
|
520
|
-
return /* @__PURE__ */
|
|
1139
|
+
return /* @__PURE__ */ jsx20(
|
|
521
1140
|
RichTextEditorControl,
|
|
522
1141
|
{
|
|
523
1142
|
active,
|
|
@@ -703,118 +1322,13 @@ var SuperscriptControl = createControl({
|
|
|
703
1322
|
|
|
704
1323
|
// src/controls/rte-link-control.tsx
|
|
705
1324
|
import { useEditorState as useEditorState3 } from "@tiptap/react";
|
|
706
|
-
import * as
|
|
707
|
-
import { useCallback as useCallback4, useState as
|
|
708
|
-
|
|
709
|
-
// src/ui/button.tsx
|
|
710
|
-
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
711
|
-
import { cva as cva2 } from "class-variance-authority";
|
|
712
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
713
|
-
var buttonVariants = cva2(
|
|
714
|
-
"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",
|
|
715
|
-
{
|
|
716
|
-
defaultVariants: {
|
|
717
|
-
size: "default",
|
|
718
|
-
variant: "default"
|
|
719
|
-
},
|
|
720
|
-
variants: {
|
|
721
|
-
size: {
|
|
722
|
-
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
723
|
-
icon: "size-8",
|
|
724
|
-
"icon-lg": "size-9",
|
|
725
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
726
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
727
|
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
728
|
-
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",
|
|
729
|
-
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"
|
|
730
|
-
},
|
|
731
|
-
variant: {
|
|
732
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
733
|
-
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",
|
|
734
|
-
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
735
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
736
|
-
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",
|
|
737
|
-
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"
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
);
|
|
742
|
-
var Button = ({
|
|
743
|
-
className,
|
|
744
|
-
variant = "default",
|
|
745
|
-
size = "default",
|
|
746
|
-
...props
|
|
747
|
-
}) => /* @__PURE__ */ jsx6(
|
|
748
|
-
ButtonPrimitive,
|
|
749
|
-
{
|
|
750
|
-
"data-slot": "button",
|
|
751
|
-
className: cn(buttonVariants({ className, size, variant })),
|
|
752
|
-
...props
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
|
|
756
|
-
// src/ui/input.tsx
|
|
757
|
-
import { Input as InputPrimitive } from "@base-ui/react/input";
|
|
758
|
-
import "react";
|
|
759
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
760
|
-
var Input = ({
|
|
761
|
-
className,
|
|
762
|
-
type,
|
|
763
|
-
...props
|
|
764
|
-
}) => /* @__PURE__ */ jsx7(
|
|
765
|
-
InputPrimitive,
|
|
766
|
-
{
|
|
767
|
-
type,
|
|
768
|
-
"data-slot": "input",
|
|
769
|
-
className: cn(
|
|
770
|
-
"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",
|
|
771
|
-
className
|
|
772
|
-
),
|
|
773
|
-
...props
|
|
774
|
-
}
|
|
775
|
-
);
|
|
776
|
-
|
|
777
|
-
// src/ui/popover.tsx
|
|
778
|
-
import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
|
|
779
|
-
import "react";
|
|
780
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
781
|
-
var Popover = ({ ...props }) => /* @__PURE__ */ jsx8(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
782
|
-
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ jsx8(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
783
|
-
var PopoverContent = ({
|
|
784
|
-
className,
|
|
785
|
-
align = "center",
|
|
786
|
-
alignOffset = 0,
|
|
787
|
-
side = "bottom",
|
|
788
|
-
sideOffset = 4,
|
|
789
|
-
...props
|
|
790
|
-
}) => /* @__PURE__ */ jsx8(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx8(
|
|
791
|
-
PopoverPrimitive.Positioner,
|
|
792
|
-
{
|
|
793
|
-
align,
|
|
794
|
-
alignOffset,
|
|
795
|
-
side,
|
|
796
|
-
sideOffset,
|
|
797
|
-
className: "isolate z-50",
|
|
798
|
-
children: /* @__PURE__ */ jsx8(
|
|
799
|
-
PopoverPrimitive.Popup,
|
|
800
|
-
{
|
|
801
|
-
"data-slot": "popover-content",
|
|
802
|
-
className: cn(
|
|
803
|
-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 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",
|
|
804
|
-
className
|
|
805
|
-
),
|
|
806
|
-
...props
|
|
807
|
-
}
|
|
808
|
-
)
|
|
809
|
-
}
|
|
810
|
-
) });
|
|
811
|
-
|
|
812
|
-
// src/controls/rte-link-control.tsx
|
|
813
|
-
import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1325
|
+
import * as React15 from "react";
|
|
1326
|
+
import { useCallback as useCallback4, useState as useState4 } from "react";
|
|
1327
|
+
import { jsx as jsx21, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
814
1328
|
var LinkControl = () => {
|
|
815
1329
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
816
|
-
const [url, setUrl] =
|
|
817
|
-
const [open, setOpen] =
|
|
1330
|
+
const [url, setUrl] = useState4("");
|
|
1331
|
+
const [open, setOpen] = useState4(false);
|
|
818
1332
|
const active = useEditorState3({
|
|
819
1333
|
editor: editor ?? null,
|
|
820
1334
|
selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
|
|
@@ -849,16 +1363,16 @@ var LinkControl = () => {
|
|
|
849
1363
|
handleSave();
|
|
850
1364
|
}
|
|
851
1365
|
};
|
|
852
|
-
|
|
1366
|
+
React15.useEffect(() => {
|
|
853
1367
|
const handler = () => handleOpen(true);
|
|
854
1368
|
window.addEventListener("edit-link", handler);
|
|
855
1369
|
return () => window.removeEventListener("edit-link", handler);
|
|
856
1370
|
}, [handleOpen]);
|
|
857
|
-
return /* @__PURE__ */
|
|
858
|
-
/* @__PURE__ */
|
|
1371
|
+
return /* @__PURE__ */ jsxs8(Popover, { open, onOpenChange: handleOpen, children: [
|
|
1372
|
+
/* @__PURE__ */ jsx21(
|
|
859
1373
|
PopoverTrigger,
|
|
860
1374
|
{
|
|
861
|
-
render: /* @__PURE__ */
|
|
1375
|
+
render: /* @__PURE__ */ jsx21(
|
|
862
1376
|
Toggle,
|
|
863
1377
|
{
|
|
864
1378
|
size: "sm",
|
|
@@ -872,8 +1386,8 @@ var LinkControl = () => {
|
|
|
872
1386
|
children: icons.linkControlIcon
|
|
873
1387
|
}
|
|
874
1388
|
),
|
|
875
|
-
/* @__PURE__ */
|
|
876
|
-
/* @__PURE__ */
|
|
1389
|
+
/* @__PURE__ */ jsx21(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs8("div", { className: "rte-link-editor", children: [
|
|
1390
|
+
/* @__PURE__ */ jsx21(
|
|
877
1391
|
Input,
|
|
878
1392
|
{
|
|
879
1393
|
type: "url",
|
|
@@ -885,7 +1399,7 @@ var LinkControl = () => {
|
|
|
885
1399
|
className: "rte-link-editor-input h-8 text-sm"
|
|
886
1400
|
}
|
|
887
1401
|
),
|
|
888
|
-
/* @__PURE__ */
|
|
1402
|
+
/* @__PURE__ */ jsx21(
|
|
889
1403
|
Button,
|
|
890
1404
|
{
|
|
891
1405
|
size: "sm",
|
|
@@ -902,11 +1416,11 @@ var LinkControl = () => {
|
|
|
902
1416
|
// src/controls/rte-twitter-control.tsx
|
|
903
1417
|
import { Node, nodeInputRule } from "@tiptap/core";
|
|
904
1418
|
import { ReactNodeViewRenderer, useEditorState as useEditorState4 } from "@tiptap/react";
|
|
905
|
-
import { useState as
|
|
1419
|
+
import { useState as useState6, useCallback as useCallback6, useEffect as useEffect4, useRef as useRef4 } from "react";
|
|
906
1420
|
|
|
907
1421
|
// src/extensions/resizable-node-view.tsx
|
|
908
1422
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
909
|
-
import { useCallback as useCallback5, useEffect as useEffect3, useRef as
|
|
1423
|
+
import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef3, useState as useState5 } from "react";
|
|
910
1424
|
|
|
911
1425
|
// src/icons.tsx
|
|
912
1426
|
import {
|
|
@@ -940,25 +1454,25 @@ import {
|
|
|
940
1454
|
Undo2
|
|
941
1455
|
} from "lucide-react";
|
|
942
1456
|
import "react";
|
|
943
|
-
import { Fragment as
|
|
1457
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
944
1458
|
var ALIGN_PATHS = {
|
|
945
|
-
center: /* @__PURE__ */
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
/* @__PURE__ */
|
|
948
|
-
/* @__PURE__ */
|
|
1459
|
+
center: /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
1460
|
+
/* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1461
|
+
/* @__PURE__ */ jsx22("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
|
|
1462
|
+
/* @__PURE__ */ jsx22("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
|
|
949
1463
|
] }),
|
|
950
|
-
left: /* @__PURE__ */
|
|
951
|
-
/* @__PURE__ */
|
|
952
|
-
/* @__PURE__ */
|
|
953
|
-
/* @__PURE__ */
|
|
1464
|
+
left: /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
1465
|
+
/* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1466
|
+
/* @__PURE__ */ jsx22("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
|
|
1467
|
+
/* @__PURE__ */ jsx22("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
|
|
954
1468
|
] }),
|
|
955
|
-
right: /* @__PURE__ */
|
|
956
|
-
/* @__PURE__ */
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
/* @__PURE__ */
|
|
1469
|
+
right: /* @__PURE__ */ jsxs9(Fragment4, { children: [
|
|
1470
|
+
/* @__PURE__ */ jsx22("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1471
|
+
/* @__PURE__ */ jsx22("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
|
|
1472
|
+
/* @__PURE__ */ jsx22("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
|
|
959
1473
|
] })
|
|
960
1474
|
};
|
|
961
|
-
var AlignIcon = ({ dir }) => /* @__PURE__ */
|
|
1475
|
+
var AlignIcon = ({ dir }) => /* @__PURE__ */ jsx22(
|
|
962
1476
|
"svg",
|
|
963
1477
|
{
|
|
964
1478
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -972,7 +1486,7 @@ var AlignIcon = ({ dir }) => /* @__PURE__ */ jsx10(
|
|
|
972
1486
|
children: ALIGN_PATHS[dir]
|
|
973
1487
|
}
|
|
974
1488
|
);
|
|
975
|
-
var EditUrlIcon = () => /* @__PURE__ */
|
|
1489
|
+
var EditUrlIcon = () => /* @__PURE__ */ jsxs9(
|
|
976
1490
|
"svg",
|
|
977
1491
|
{
|
|
978
1492
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -984,12 +1498,12 @@ var EditUrlIcon = () => /* @__PURE__ */ jsxs4(
|
|
|
984
1498
|
strokeLinejoin: "round",
|
|
985
1499
|
className: "rte-editor-icon",
|
|
986
1500
|
children: [
|
|
987
|
-
/* @__PURE__ */
|
|
988
|
-
/* @__PURE__ */
|
|
1501
|
+
/* @__PURE__ */ jsx22("path", { d: "M12 20h9" }),
|
|
1502
|
+
/* @__PURE__ */ jsx22("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
|
|
989
1503
|
]
|
|
990
1504
|
}
|
|
991
1505
|
);
|
|
992
|
-
var OpenInYouTubeIcon = () => /* @__PURE__ */
|
|
1506
|
+
var OpenInYouTubeIcon = () => /* @__PURE__ */ jsxs9(
|
|
993
1507
|
"svg",
|
|
994
1508
|
{
|
|
995
1509
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1001,13 +1515,13 @@ var OpenInYouTubeIcon = () => /* @__PURE__ */ jsxs4(
|
|
|
1001
1515
|
strokeLinejoin: "round",
|
|
1002
1516
|
className: "rte-editor-icon",
|
|
1003
1517
|
children: [
|
|
1004
|
-
/* @__PURE__ */
|
|
1005
|
-
/* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1518
|
+
/* @__PURE__ */ jsx22("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
1519
|
+
/* @__PURE__ */ jsx22("polyline", { points: "15 3 21 3 21 9" }),
|
|
1520
|
+
/* @__PURE__ */ jsx22("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
1007
1521
|
]
|
|
1008
1522
|
}
|
|
1009
1523
|
);
|
|
1010
|
-
var DeleteEmbedIcon = () => /* @__PURE__ */
|
|
1524
|
+
var DeleteEmbedIcon = () => /* @__PURE__ */ jsxs9(
|
|
1011
1525
|
"svg",
|
|
1012
1526
|
{
|
|
1013
1527
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1019,8 +1533,8 @@ var DeleteEmbedIcon = () => /* @__PURE__ */ jsxs4(
|
|
|
1019
1533
|
strokeLinejoin: "round",
|
|
1020
1534
|
className: "rte-editor-icon",
|
|
1021
1535
|
children: [
|
|
1022
|
-
/* @__PURE__ */
|
|
1023
|
-
/* @__PURE__ */
|
|
1536
|
+
/* @__PURE__ */ jsx22("polyline", { points: "3 6 5 6 21 6" }),
|
|
1537
|
+
/* @__PURE__ */ jsx22("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
1024
1538
|
]
|
|
1025
1539
|
}
|
|
1026
1540
|
);
|
|
@@ -1028,7 +1542,7 @@ var iconProps = { className: "rte-editor-icon" };
|
|
|
1028
1542
|
var LangIcon = ({
|
|
1029
1543
|
children,
|
|
1030
1544
|
className
|
|
1031
|
-
}) => /* @__PURE__ */
|
|
1545
|
+
}) => /* @__PURE__ */ jsx22(
|
|
1032
1546
|
"svg",
|
|
1033
1547
|
{
|
|
1034
1548
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1043,153 +1557,153 @@ var LangIcon = ({
|
|
|
1043
1557
|
}
|
|
1044
1558
|
);
|
|
1045
1559
|
var DEFAULT_LANGUAGE_ICONS = {
|
|
1046
|
-
bash: /* @__PURE__ */
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1560
|
+
bash: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1561
|
+
/* @__PURE__ */ jsx22("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
|
|
1562
|
+
/* @__PURE__ */ jsx22("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
|
|
1563
|
+
/* @__PURE__ */ jsx22("path", { d: "M12 15.5h5.5" })
|
|
1050
1564
|
] }),
|
|
1051
|
-
c: /* @__PURE__ */
|
|
1052
|
-
/* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */
|
|
1565
|
+
c: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1566
|
+
/* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "8.5" }),
|
|
1567
|
+
/* @__PURE__ */ jsx22("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
|
|
1054
1568
|
] }),
|
|
1055
|
-
cpp: /* @__PURE__ */
|
|
1056
|
-
/* @__PURE__ */
|
|
1057
|
-
/* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1569
|
+
cpp: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1570
|
+
/* @__PURE__ */ jsx22("circle", { cx: "9.5", cy: "12", r: "6.5" }),
|
|
1571
|
+
/* @__PURE__ */ jsx22("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
|
|
1572
|
+
/* @__PURE__ */ jsx22("path", { d: "M15.7 10.5v3M14.2 12h3" }),
|
|
1573
|
+
/* @__PURE__ */ jsx22("path", { d: "M19.3 10.5v3M17.8 12h3" })
|
|
1060
1574
|
] }),
|
|
1061
|
-
css: /* @__PURE__ */
|
|
1062
|
-
/* @__PURE__ */
|
|
1063
|
-
/* @__PURE__ */
|
|
1064
|
-
/* @__PURE__ */
|
|
1065
|
-
/* @__PURE__ */
|
|
1066
|
-
/* @__PURE__ */
|
|
1575
|
+
css: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1576
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1577
|
+
/* @__PURE__ */ jsx22("path", { d: "M9.7 7.5l-1 9" }),
|
|
1578
|
+
/* @__PURE__ */ jsx22("path", { d: "M15.3 7.5l-1 9" }),
|
|
1579
|
+
/* @__PURE__ */ jsx22("path", { d: "M7 10.3h11" }),
|
|
1580
|
+
/* @__PURE__ */ jsx22("path", { d: "M6.5 14.3h11" })
|
|
1067
1581
|
] }),
|
|
1068
|
-
go: /* @__PURE__ */
|
|
1069
|
-
/* @__PURE__ */
|
|
1070
|
-
/* @__PURE__ */
|
|
1071
|
-
/* @__PURE__ */
|
|
1072
|
-
/* @__PURE__ */
|
|
1582
|
+
go: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1583
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1584
|
+
/* @__PURE__ */ jsx22("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
|
|
1585
|
+
/* @__PURE__ */ jsx22("path", { d: "M12.6 12h-1.9" }),
|
|
1586
|
+
/* @__PURE__ */ jsx22("circle", { cx: "17", cy: "12", r: "2.9" })
|
|
1073
1587
|
] }),
|
|
1074
|
-
html: /* @__PURE__ */
|
|
1075
|
-
/* @__PURE__ */
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
/* @__PURE__ */
|
|
1588
|
+
html: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1589
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1590
|
+
/* @__PURE__ */ jsx22("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
|
|
1591
|
+
/* @__PURE__ */ jsx22("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
|
|
1592
|
+
/* @__PURE__ */ jsx22("path", { d: "M13 7.3l-2 9.4" })
|
|
1079
1593
|
] }),
|
|
1080
|
-
java: /* @__PURE__ */
|
|
1081
|
-
/* @__PURE__ */
|
|
1082
|
-
/* @__PURE__ */
|
|
1083
|
-
/* @__PURE__ */
|
|
1084
|
-
/* @__PURE__ */
|
|
1594
|
+
java: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1595
|
+
/* @__PURE__ */ jsx22("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
|
|
1596
|
+
/* @__PURE__ */ jsx22("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
|
|
1597
|
+
/* @__PURE__ */ jsx22("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
|
|
1598
|
+
/* @__PURE__ */ jsx22("path", { d: "M6 19.3h10" })
|
|
1085
1599
|
] }),
|
|
1086
|
-
javascript: /* @__PURE__ */
|
|
1087
|
-
/* @__PURE__ */
|
|
1088
|
-
/* @__PURE__ */
|
|
1089
|
-
/* @__PURE__ */
|
|
1600
|
+
javascript: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1601
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1602
|
+
/* @__PURE__ */ jsx22("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
|
|
1603
|
+
/* @__PURE__ */ jsx22("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1090
1604
|
] }),
|
|
1091
|
-
json: /* @__PURE__ */
|
|
1092
|
-
/* @__PURE__ */
|
|
1093
|
-
/* @__PURE__ */
|
|
1605
|
+
json: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1606
|
+
/* @__PURE__ */ jsx22("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
|
|
1607
|
+
/* @__PURE__ */ jsx22("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
|
|
1094
1608
|
] }),
|
|
1095
|
-
kotlin: /* @__PURE__ */
|
|
1096
|
-
/* @__PURE__ */
|
|
1097
|
-
/* @__PURE__ */
|
|
1098
|
-
/* @__PURE__ */
|
|
1099
|
-
/* @__PURE__ */
|
|
1609
|
+
kotlin: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1610
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1611
|
+
/* @__PURE__ */ jsx22("path", { d: "M9 7.5v9" }),
|
|
1612
|
+
/* @__PURE__ */ jsx22("path", { d: "M9 12l6-4.5" }),
|
|
1613
|
+
/* @__PURE__ */ jsx22("path", { d: "M9 12l6 4.5" })
|
|
1100
1614
|
] }),
|
|
1101
|
-
markdown: /* @__PURE__ */
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */
|
|
1104
|
-
/* @__PURE__ */
|
|
1105
|
-
/* @__PURE__ */
|
|
1615
|
+
markdown: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1616
|
+
/* @__PURE__ */ jsx22("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
|
|
1617
|
+
/* @__PURE__ */ jsx22("path", { d: "M6 15V9l3 4 3-4v6" }),
|
|
1618
|
+
/* @__PURE__ */ jsx22("path", { d: "M16.5 9v6" }),
|
|
1619
|
+
/* @__PURE__ */ jsx22("path", { d: "M14.5 13l2 2 2-2" })
|
|
1106
1620
|
] }),
|
|
1107
|
-
php: /* @__PURE__ */
|
|
1108
|
-
/* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */
|
|
1110
|
-
/* @__PURE__ */
|
|
1111
|
-
/* @__PURE__ */
|
|
1621
|
+
php: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1622
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1623
|
+
/* @__PURE__ */ jsx22("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
|
|
1624
|
+
/* @__PURE__ */ jsx22("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
|
|
1625
|
+
/* @__PURE__ */ jsx22("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
|
|
1112
1626
|
] }),
|
|
1113
|
-
plaintext: /* @__PURE__ */
|
|
1114
|
-
/* @__PURE__ */
|
|
1115
|
-
/* @__PURE__ */
|
|
1116
|
-
/* @__PURE__ */
|
|
1117
|
-
/* @__PURE__ */
|
|
1627
|
+
plaintext: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1628
|
+
/* @__PURE__ */ jsx22("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
|
|
1629
|
+
/* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
|
|
1630
|
+
/* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
|
|
1631
|
+
/* @__PURE__ */ jsx22("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
|
|
1118
1632
|
] }),
|
|
1119
|
-
python: /* @__PURE__ */
|
|
1120
|
-
/* @__PURE__ */
|
|
1121
|
-
/* @__PURE__ */
|
|
1122
|
-
/* @__PURE__ */
|
|
1123
|
-
/* @__PURE__ */
|
|
1633
|
+
python: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1634
|
+
/* @__PURE__ */ jsx22("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
|
|
1635
|
+
/* @__PURE__ */ jsx22("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
|
|
1636
|
+
/* @__PURE__ */ jsx22("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
|
|
1637
|
+
/* @__PURE__ */ jsx22("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
|
|
1124
1638
|
] }),
|
|
1125
|
-
ruby: /* @__PURE__ */
|
|
1126
|
-
/* @__PURE__ */
|
|
1127
|
-
/* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */
|
|
1639
|
+
ruby: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1640
|
+
/* @__PURE__ */ jsx22("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
|
|
1641
|
+
/* @__PURE__ */ jsx22("path", { d: "M4.5 8h15" }),
|
|
1642
|
+
/* @__PURE__ */ jsx22("path", { d: "M12 2.5v19" })
|
|
1129
1643
|
] }),
|
|
1130
|
-
rust: /* @__PURE__ */
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1133
|
-
/* @__PURE__ */
|
|
1134
|
-
/* @__PURE__ */
|
|
1644
|
+
rust: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1645
|
+
/* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "7" }),
|
|
1646
|
+
/* @__PURE__ */ jsx22("circle", { cx: "12", cy: "12", r: "2.3" }),
|
|
1647
|
+
/* @__PURE__ */ jsx22("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
|
|
1648
|
+
/* @__PURE__ */ jsx22("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
|
|
1135
1649
|
] }),
|
|
1136
|
-
sql: /* @__PURE__ */
|
|
1137
|
-
/* @__PURE__ */
|
|
1138
|
-
/* @__PURE__ */
|
|
1139
|
-
/* @__PURE__ */
|
|
1650
|
+
sql: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1651
|
+
/* @__PURE__ */ jsx22("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
|
|
1652
|
+
/* @__PURE__ */ jsx22("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
|
|
1653
|
+
/* @__PURE__ */ jsx22("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
|
|
1140
1654
|
] }),
|
|
1141
|
-
swift: /* @__PURE__ */
|
|
1142
|
-
typescript: /* @__PURE__ */
|
|
1143
|
-
/* @__PURE__ */
|
|
1144
|
-
/* @__PURE__ */
|
|
1145
|
-
/* @__PURE__ */
|
|
1655
|
+
swift: /* @__PURE__ */ jsx22(LangIcon, { children: /* @__PURE__ */ jsx22("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
|
|
1656
|
+
typescript: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1657
|
+
/* @__PURE__ */ jsx22("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1658
|
+
/* @__PURE__ */ jsx22("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
|
|
1659
|
+
/* @__PURE__ */ jsx22("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1146
1660
|
] }),
|
|
1147
|
-
xml: /* @__PURE__ */
|
|
1148
|
-
/* @__PURE__ */
|
|
1149
|
-
/* @__PURE__ */
|
|
1150
|
-
/* @__PURE__ */
|
|
1661
|
+
xml: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1662
|
+
/* @__PURE__ */ jsx22("path", { d: "M8 7l-4.5 5 4.5 5" }),
|
|
1663
|
+
/* @__PURE__ */ jsx22("path", { d: "M16 7l4.5 5-4.5 5" }),
|
|
1664
|
+
/* @__PURE__ */ jsx22("path", { d: "M12 8v8" })
|
|
1151
1665
|
] }),
|
|
1152
|
-
yaml: /* @__PURE__ */
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
/* @__PURE__ */
|
|
1155
|
-
/* @__PURE__ */
|
|
1156
|
-
/* @__PURE__ */
|
|
1666
|
+
yaml: /* @__PURE__ */ jsxs9(LangIcon, { children: [
|
|
1667
|
+
/* @__PURE__ */ jsx22("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
|
|
1668
|
+
/* @__PURE__ */ jsx22("path", { d: "M6.5 8h2M9.5 8h8" }),
|
|
1669
|
+
/* @__PURE__ */ jsx22("path", { d: "M6.5 12h2M9.5 12h6" }),
|
|
1670
|
+
/* @__PURE__ */ jsx22("path", { d: "M6.5 16h2M9.5 16h7" })
|
|
1157
1671
|
] })
|
|
1158
1672
|
};
|
|
1159
1673
|
var DEFAULT_ICONS = {
|
|
1160
|
-
alignCenterControlIcon: /* @__PURE__ */
|
|
1161
|
-
alignJustifyControlIcon: /* @__PURE__ */
|
|
1162
|
-
alignLeftControlIcon: /* @__PURE__ */
|
|
1163
|
-
alignRightControlIcon: /* @__PURE__ */
|
|
1164
|
-
blockquoteControlIcon: /* @__PURE__ */
|
|
1165
|
-
boldControlIcon: /* @__PURE__ */
|
|
1166
|
-
bulletListControlIcon: /* @__PURE__ */
|
|
1167
|
-
clearFormattingControlIcon: /* @__PURE__ */
|
|
1168
|
-
codeBlockControlIcon: /* @__PURE__ */
|
|
1169
|
-
codeControlIcon: /* @__PURE__ */
|
|
1170
|
-
h1ControlIcon: /* @__PURE__ */
|
|
1171
|
-
h2ControlIcon: /* @__PURE__ */
|
|
1172
|
-
h3ControlIcon: /* @__PURE__ */
|
|
1173
|
-
h4ControlIcon: /* @__PURE__ */
|
|
1174
|
-
h5ControlIcon: /* @__PURE__ */
|
|
1175
|
-
h6ControlIcon: /* @__PURE__ */
|
|
1176
|
-
highlightControlIcon: /* @__PURE__ */
|
|
1177
|
-
hrControlIcon: /* @__PURE__ */
|
|
1178
|
-
italicControlIcon: /* @__PURE__ */
|
|
1674
|
+
alignCenterControlIcon: /* @__PURE__ */ jsx22(TextAlignCenter, { ...iconProps }),
|
|
1675
|
+
alignJustifyControlIcon: /* @__PURE__ */ jsx22(TextAlignJustify, { ...iconProps }),
|
|
1676
|
+
alignLeftControlIcon: /* @__PURE__ */ jsx22(TextAlignStart, { ...iconProps }),
|
|
1677
|
+
alignRightControlIcon: /* @__PURE__ */ jsx22(TextAlignEnd, { ...iconProps }),
|
|
1678
|
+
blockquoteControlIcon: /* @__PURE__ */ jsx22(TextQuote, { ...iconProps }),
|
|
1679
|
+
boldControlIcon: /* @__PURE__ */ jsx22(Bold, { ...iconProps }),
|
|
1680
|
+
bulletListControlIcon: /* @__PURE__ */ jsx22(List, { ...iconProps }),
|
|
1681
|
+
clearFormattingControlIcon: /* @__PURE__ */ jsx22(RemoveFormatting, { ...iconProps }),
|
|
1682
|
+
codeBlockControlIcon: /* @__PURE__ */ jsx22(SquareCode, { ...iconProps }),
|
|
1683
|
+
codeControlIcon: /* @__PURE__ */ jsx22(Code, { ...iconProps }),
|
|
1684
|
+
h1ControlIcon: /* @__PURE__ */ jsx22(Heading1, { ...iconProps }),
|
|
1685
|
+
h2ControlIcon: /* @__PURE__ */ jsx22(Heading2, { ...iconProps }),
|
|
1686
|
+
h3ControlIcon: /* @__PURE__ */ jsx22(Heading3, { ...iconProps }),
|
|
1687
|
+
h4ControlIcon: /* @__PURE__ */ jsx22(Heading4, { ...iconProps }),
|
|
1688
|
+
h5ControlIcon: /* @__PURE__ */ jsx22(Heading5, { ...iconProps }),
|
|
1689
|
+
h6ControlIcon: /* @__PURE__ */ jsx22(Heading6, { ...iconProps }),
|
|
1690
|
+
highlightControlIcon: /* @__PURE__ */ jsx22(Highlighter, { ...iconProps }),
|
|
1691
|
+
hrControlIcon: /* @__PURE__ */ jsx22(Minus, { ...iconProps }),
|
|
1692
|
+
italicControlIcon: /* @__PURE__ */ jsx22(Italic, { ...iconProps }),
|
|
1179
1693
|
languageIcons: DEFAULT_LANGUAGE_ICONS,
|
|
1180
|
-
linkControlIcon: /* @__PURE__ */
|
|
1181
|
-
orderedListControlIcon: /* @__PURE__ */
|
|
1182
|
-
redoControlIcon: /* @__PURE__ */
|
|
1183
|
-
strikeControlIcon: /* @__PURE__ */
|
|
1184
|
-
subscriptControlIcon: /* @__PURE__ */
|
|
1185
|
-
superscriptControlIcon: /* @__PURE__ */
|
|
1186
|
-
underlineControlIcon: /* @__PURE__ */
|
|
1187
|
-
undoControlIcon: /* @__PURE__ */
|
|
1188
|
-
unlinkControlIcon: /* @__PURE__ */
|
|
1694
|
+
linkControlIcon: /* @__PURE__ */ jsx22(Link, { ...iconProps }),
|
|
1695
|
+
orderedListControlIcon: /* @__PURE__ */ jsx22(ListOrdered, { ...iconProps }),
|
|
1696
|
+
redoControlIcon: /* @__PURE__ */ jsx22(Redo2, { ...iconProps }),
|
|
1697
|
+
strikeControlIcon: /* @__PURE__ */ jsx22(Strikethrough, { ...iconProps }),
|
|
1698
|
+
subscriptControlIcon: /* @__PURE__ */ jsx22(Subscript, { ...iconProps }),
|
|
1699
|
+
superscriptControlIcon: /* @__PURE__ */ jsx22(Superscript, { ...iconProps }),
|
|
1700
|
+
underlineControlIcon: /* @__PURE__ */ jsx22(Underline, { ...iconProps }),
|
|
1701
|
+
undoControlIcon: /* @__PURE__ */ jsx22(Undo2, { ...iconProps }),
|
|
1702
|
+
unlinkControlIcon: /* @__PURE__ */ jsx22(Link2Off, { ...iconProps })
|
|
1189
1703
|
};
|
|
1190
1704
|
|
|
1191
1705
|
// src/extensions/resizable-node-view.tsx
|
|
1192
|
-
import { Fragment as
|
|
1706
|
+
import { Fragment as Fragment5, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1193
1707
|
var EmbedToolbar = ({
|
|
1194
1708
|
align,
|
|
1195
1709
|
videoSrc,
|
|
@@ -1206,8 +1720,8 @@ var EmbedToolbar = ({
|
|
|
1206
1720
|
nodeSrc
|
|
1207
1721
|
}) => {
|
|
1208
1722
|
if (isEditingUrl) {
|
|
1209
|
-
return /* @__PURE__ */
|
|
1210
|
-
/* @__PURE__ */
|
|
1723
|
+
return /* @__PURE__ */ jsxs10("div", { className: "rte-embed-selector-edit-form", children: [
|
|
1724
|
+
/* @__PURE__ */ jsx23(
|
|
1211
1725
|
"input",
|
|
1212
1726
|
{
|
|
1213
1727
|
ref: inputRef,
|
|
@@ -1225,7 +1739,7 @@ var EmbedToolbar = ({
|
|
|
1225
1739
|
}
|
|
1226
1740
|
}
|
|
1227
1741
|
),
|
|
1228
|
-
/* @__PURE__ */
|
|
1742
|
+
/* @__PURE__ */ jsx23(
|
|
1229
1743
|
"button",
|
|
1230
1744
|
{
|
|
1231
1745
|
type: "button",
|
|
@@ -1234,7 +1748,7 @@ var EmbedToolbar = ({
|
|
|
1234
1748
|
children: "Save"
|
|
1235
1749
|
}
|
|
1236
1750
|
),
|
|
1237
|
-
/* @__PURE__ */
|
|
1751
|
+
/* @__PURE__ */ jsx23(
|
|
1238
1752
|
"button",
|
|
1239
1753
|
{
|
|
1240
1754
|
type: "button",
|
|
@@ -1245,8 +1759,8 @@ var EmbedToolbar = ({
|
|
|
1245
1759
|
)
|
|
1246
1760
|
] });
|
|
1247
1761
|
}
|
|
1248
|
-
return /* @__PURE__ */
|
|
1249
|
-
/* @__PURE__ */
|
|
1762
|
+
return /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
1763
|
+
/* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ jsx23(
|
|
1250
1764
|
"button",
|
|
1251
1765
|
{
|
|
1252
1766
|
type: "button",
|
|
@@ -1254,12 +1768,12 @@ var EmbedToolbar = ({
|
|
|
1254
1768
|
"aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
|
|
1255
1769
|
className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
|
|
1256
1770
|
onClick: () => updateAttributes({ align: dir }),
|
|
1257
|
-
children: /* @__PURE__ */
|
|
1771
|
+
children: /* @__PURE__ */ jsx23(AlignIcon, { dir })
|
|
1258
1772
|
},
|
|
1259
1773
|
dir
|
|
1260
1774
|
)) }),
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
/* @__PURE__ */
|
|
1775
|
+
/* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-divider" }),
|
|
1776
|
+
/* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ jsxs10(
|
|
1263
1777
|
"button",
|
|
1264
1778
|
{
|
|
1265
1779
|
type: "button",
|
|
@@ -1273,9 +1787,9 @@ var EmbedToolbar = ({
|
|
|
1273
1787
|
},
|
|
1274
1788
|
pct
|
|
1275
1789
|
)) }),
|
|
1276
|
-
/* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
1278
|
-
(videoSrc || nodeSrc) && /* @__PURE__ */
|
|
1790
|
+
/* @__PURE__ */ jsx23("div", { className: "rte-embed-selector-divider" }),
|
|
1791
|
+
/* @__PURE__ */ jsxs10("div", { className: "rte-embed-selector-group", children: [
|
|
1792
|
+
(videoSrc || nodeSrc) && /* @__PURE__ */ jsx23(
|
|
1279
1793
|
"button",
|
|
1280
1794
|
{
|
|
1281
1795
|
type: "button",
|
|
@@ -1286,10 +1800,10 @@ var EmbedToolbar = ({
|
|
|
1286
1800
|
setUrlInput(videoSrc || nodeSrc || "");
|
|
1287
1801
|
setIsEditingUrl(true);
|
|
1288
1802
|
},
|
|
1289
|
-
children: /* @__PURE__ */
|
|
1803
|
+
children: /* @__PURE__ */ jsx23(EditUrlIcon, {})
|
|
1290
1804
|
}
|
|
1291
1805
|
),
|
|
1292
|
-
watchUrl && /* @__PURE__ */
|
|
1806
|
+
watchUrl && /* @__PURE__ */ jsx23(
|
|
1293
1807
|
"button",
|
|
1294
1808
|
{
|
|
1295
1809
|
type: "button",
|
|
@@ -1297,10 +1811,10 @@ var EmbedToolbar = ({
|
|
|
1297
1811
|
"aria-label": "Open video in YouTube",
|
|
1298
1812
|
className: "rte-embed-selector-btn",
|
|
1299
1813
|
onClick: () => window.open(watchUrl, "_blank"),
|
|
1300
|
-
children: /* @__PURE__ */
|
|
1814
|
+
children: /* @__PURE__ */ jsx23(OpenInYouTubeIcon, {})
|
|
1301
1815
|
}
|
|
1302
1816
|
),
|
|
1303
|
-
deleteNode && /* @__PURE__ */
|
|
1817
|
+
deleteNode && /* @__PURE__ */ jsx23(
|
|
1304
1818
|
"button",
|
|
1305
1819
|
{
|
|
1306
1820
|
type: "button",
|
|
@@ -1308,7 +1822,7 @@ var EmbedToolbar = ({
|
|
|
1308
1822
|
"aria-label": "Delete Embed",
|
|
1309
1823
|
className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
|
|
1310
1824
|
onClick: () => deleteNode(),
|
|
1311
|
-
children: /* @__PURE__ */
|
|
1825
|
+
children: /* @__PURE__ */ jsx23(DeleteEmbedIcon, {})
|
|
1312
1826
|
}
|
|
1313
1827
|
)
|
|
1314
1828
|
] })
|
|
@@ -1330,12 +1844,12 @@ var ResizableNodeView = ({
|
|
|
1330
1844
|
watchUrl,
|
|
1331
1845
|
onSrcChange
|
|
1332
1846
|
}) => {
|
|
1333
|
-
const containerRef =
|
|
1334
|
-
const [isEditingUrl, setIsEditingUrl] =
|
|
1335
|
-
const [urlInput, setUrlInput] =
|
|
1336
|
-
const [isResizing, setIsResizing] =
|
|
1337
|
-
const [currentDimensions, setCurrentDimensions] =
|
|
1338
|
-
const resizingRef =
|
|
1847
|
+
const containerRef = useRef3(null);
|
|
1848
|
+
const [isEditingUrl, setIsEditingUrl] = useState5(false);
|
|
1849
|
+
const [urlInput, setUrlInput] = useState5(videoSrc || "");
|
|
1850
|
+
const [isResizing, setIsResizing] = useState5(false);
|
|
1851
|
+
const [currentDimensions, setCurrentDimensions] = useState5(null);
|
|
1852
|
+
const resizingRef = useRef3(null);
|
|
1339
1853
|
const width = node.attrs.width;
|
|
1340
1854
|
const height = node.attrs.height;
|
|
1341
1855
|
const align = node.attrs.align || "center";
|
|
@@ -1343,7 +1857,7 @@ var ResizableNodeView = ({
|
|
|
1343
1857
|
() => view?.dom?.parentElement?.offsetWidth ?? 800,
|
|
1344
1858
|
[view]
|
|
1345
1859
|
);
|
|
1346
|
-
const inputRef =
|
|
1860
|
+
const inputRef = useRef3(null);
|
|
1347
1861
|
useEffect3(() => {
|
|
1348
1862
|
if (isEditingUrl) {
|
|
1349
1863
|
inputRef.current?.focus();
|
|
@@ -1479,13 +1993,13 @@ var ResizableNodeView = ({
|
|
|
1479
1993
|
setIsEditingUrl(false);
|
|
1480
1994
|
};
|
|
1481
1995
|
const isEditable = editor ? editor.isEditable : true;
|
|
1482
|
-
return /* @__PURE__ */
|
|
1996
|
+
return /* @__PURE__ */ jsx23(
|
|
1483
1997
|
NodeViewWrapper,
|
|
1484
1998
|
{
|
|
1485
1999
|
className: "rte-embed-wrapper",
|
|
1486
2000
|
"data-selected": selected || void 0,
|
|
1487
2001
|
"data-align": align,
|
|
1488
|
-
children: /* @__PURE__ */
|
|
2002
|
+
children: /* @__PURE__ */ jsxs10(
|
|
1489
2003
|
"div",
|
|
1490
2004
|
{
|
|
1491
2005
|
ref: containerRef,
|
|
@@ -1498,7 +2012,7 @@ var ResizableNodeView = ({
|
|
|
1498
2012
|
},
|
|
1499
2013
|
children: [
|
|
1500
2014
|
children,
|
|
1501
|
-
selected && isEditable && /* @__PURE__ */
|
|
2015
|
+
selected && isEditable && /* @__PURE__ */ jsx23("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ jsx23(
|
|
1502
2016
|
EmbedToolbar,
|
|
1503
2017
|
{
|
|
1504
2018
|
align,
|
|
@@ -1516,14 +2030,14 @@ var ResizableNodeView = ({
|
|
|
1516
2030
|
nodeSrc: node.attrs.src
|
|
1517
2031
|
}
|
|
1518
2032
|
) }),
|
|
1519
|
-
isResizing && currentDimensions && /* @__PURE__ */
|
|
2033
|
+
isResizing && currentDimensions && /* @__PURE__ */ jsxs10("div", { className: "rte-embed-resize-badge", children: [
|
|
1520
2034
|
currentDimensions.w,
|
|
1521
2035
|
" \xD7 ",
|
|
1522
2036
|
currentDimensions.h,
|
|
1523
2037
|
" px"
|
|
1524
2038
|
] }),
|
|
1525
|
-
selected && isEditable && /* @__PURE__ */
|
|
1526
|
-
/* @__PURE__ */
|
|
2039
|
+
selected && isEditable && /* @__PURE__ */ jsxs10(Fragment5, { children: [
|
|
2040
|
+
/* @__PURE__ */ jsx23(
|
|
1527
2041
|
"div",
|
|
1528
2042
|
{
|
|
1529
2043
|
className: "rte-resize-handle rte-resize-handle--left",
|
|
@@ -1531,7 +2045,7 @@ var ResizableNodeView = ({
|
|
|
1531
2045
|
role: "presentation"
|
|
1532
2046
|
}
|
|
1533
2047
|
),
|
|
1534
|
-
/* @__PURE__ */
|
|
2048
|
+
/* @__PURE__ */ jsx23(
|
|
1535
2049
|
"div",
|
|
1536
2050
|
{
|
|
1537
2051
|
className: "rte-resize-handle rte-resize-handle--right",
|
|
@@ -1539,7 +2053,7 @@ var ResizableNodeView = ({
|
|
|
1539
2053
|
role: "presentation"
|
|
1540
2054
|
}
|
|
1541
2055
|
),
|
|
1542
|
-
/* @__PURE__ */
|
|
2056
|
+
/* @__PURE__ */ jsx23(
|
|
1543
2057
|
"div",
|
|
1544
2058
|
{
|
|
1545
2059
|
className: "rte-resize-handle rte-resize-handle--bottom",
|
|
@@ -1547,7 +2061,7 @@ var ResizableNodeView = ({
|
|
|
1547
2061
|
role: "presentation"
|
|
1548
2062
|
}
|
|
1549
2063
|
),
|
|
1550
|
-
/* @__PURE__ */
|
|
2064
|
+
/* @__PURE__ */ jsx23(
|
|
1551
2065
|
"div",
|
|
1552
2066
|
{
|
|
1553
2067
|
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
|
|
@@ -1555,7 +2069,7 @@ var ResizableNodeView = ({
|
|
|
1555
2069
|
role: "presentation"
|
|
1556
2070
|
}
|
|
1557
2071
|
),
|
|
1558
|
-
/* @__PURE__ */
|
|
2072
|
+
/* @__PURE__ */ jsx23(
|
|
1559
2073
|
"div",
|
|
1560
2074
|
{
|
|
1561
2075
|
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
|
|
@@ -1571,121 +2085,8 @@ var ResizableNodeView = ({
|
|
|
1571
2085
|
);
|
|
1572
2086
|
};
|
|
1573
2087
|
|
|
1574
|
-
// src/ui/dialog.tsx
|
|
1575
|
-
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
1576
|
-
import "react";
|
|
1577
|
-
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1578
|
-
var Dialog = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
1579
|
-
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
1580
|
-
var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
1581
|
-
var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
1582
|
-
var DialogOverlay = ({
|
|
1583
|
-
className,
|
|
1584
|
-
...props
|
|
1585
|
-
}) => /* @__PURE__ */ jsx12(
|
|
1586
|
-
DialogPrimitive.Backdrop,
|
|
1587
|
-
{
|
|
1588
|
-
"data-slot": "dialog-overlay",
|
|
1589
|
-
className: cn(
|
|
1590
|
-
"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",
|
|
1591
|
-
className
|
|
1592
|
-
),
|
|
1593
|
-
...props
|
|
1594
|
-
}
|
|
1595
|
-
);
|
|
1596
|
-
var DialogContent = ({
|
|
1597
|
-
className,
|
|
1598
|
-
children,
|
|
1599
|
-
showCloseButton = true,
|
|
1600
|
-
...props
|
|
1601
|
-
}) => /* @__PURE__ */ jsxs6(DialogPortal, { children: [
|
|
1602
|
-
/* @__PURE__ */ jsx12(DialogOverlay, {}),
|
|
1603
|
-
/* @__PURE__ */ jsxs6(
|
|
1604
|
-
DialogPrimitive.Popup,
|
|
1605
|
-
{
|
|
1606
|
-
"data-slot": "dialog-content",
|
|
1607
|
-
className: cn(
|
|
1608
|
-
"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-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 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",
|
|
1609
|
-
className
|
|
1610
|
-
),
|
|
1611
|
-
...props,
|
|
1612
|
-
children: [
|
|
1613
|
-
children,
|
|
1614
|
-
showCloseButton && /* @__PURE__ */ jsxs6(
|
|
1615
|
-
DialogPrimitive.Close,
|
|
1616
|
-
{
|
|
1617
|
-
"data-slot": "dialog-close",
|
|
1618
|
-
render: /* @__PURE__ */ jsx12(
|
|
1619
|
-
Button,
|
|
1620
|
-
{
|
|
1621
|
-
variant: "ghost",
|
|
1622
|
-
className: "absolute top-2 right-2",
|
|
1623
|
-
size: "icon-sm"
|
|
1624
|
-
}
|
|
1625
|
-
),
|
|
1626
|
-
children: [
|
|
1627
|
-
"X",
|
|
1628
|
-
/* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Close" })
|
|
1629
|
-
]
|
|
1630
|
-
}
|
|
1631
|
-
)
|
|
1632
|
-
]
|
|
1633
|
-
}
|
|
1634
|
-
)
|
|
1635
|
-
] });
|
|
1636
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx12(
|
|
1637
|
-
"div",
|
|
1638
|
-
{
|
|
1639
|
-
"data-slot": "dialog-header",
|
|
1640
|
-
className: cn("flex flex-col gap-1 text-left", className),
|
|
1641
|
-
...props
|
|
1642
|
-
}
|
|
1643
|
-
);
|
|
1644
|
-
var DialogFooter = ({
|
|
1645
|
-
className,
|
|
1646
|
-
showCloseButton = false,
|
|
1647
|
-
children,
|
|
1648
|
-
...props
|
|
1649
|
-
}) => /* @__PURE__ */ jsxs6(
|
|
1650
|
-
"div",
|
|
1651
|
-
{
|
|
1652
|
-
"data-slot": "dialog-footer",
|
|
1653
|
-
className: cn(
|
|
1654
|
-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
1655
|
-
className
|
|
1656
|
-
),
|
|
1657
|
-
...props,
|
|
1658
|
-
children: [
|
|
1659
|
-
children,
|
|
1660
|
-
showCloseButton && /* @__PURE__ */ jsx12(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx12(Button, { variant: "outline" }), children: "Close" })
|
|
1661
|
-
]
|
|
1662
|
-
}
|
|
1663
|
-
);
|
|
1664
|
-
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx12(
|
|
1665
|
-
DialogPrimitive.Title,
|
|
1666
|
-
{
|
|
1667
|
-
"data-slot": "dialog-title",
|
|
1668
|
-
className: cn("text-sm font-medium", className),
|
|
1669
|
-
...props
|
|
1670
|
-
}
|
|
1671
|
-
);
|
|
1672
|
-
var DialogDescription = ({
|
|
1673
|
-
className,
|
|
1674
|
-
...props
|
|
1675
|
-
}) => /* @__PURE__ */ jsx12(
|
|
1676
|
-
DialogPrimitive.Description,
|
|
1677
|
-
{
|
|
1678
|
-
"data-slot": "dialog-description",
|
|
1679
|
-
className: cn(
|
|
1680
|
-
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
1681
|
-
className
|
|
1682
|
-
),
|
|
1683
|
-
...props
|
|
1684
|
-
}
|
|
1685
|
-
);
|
|
1686
|
-
|
|
1687
2088
|
// src/controls/rte-twitter-control.tsx
|
|
1688
|
-
import { jsx as
|
|
2089
|
+
import { jsx as jsx24, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1689
2090
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
1690
2091
|
var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
|
|
1691
2092
|
var READY_POLL_INTERVAL_MS = 50;
|
|
@@ -1712,18 +2113,23 @@ var loadTwitterScript = () => {
|
|
|
1712
2113
|
document.body.append(script);
|
|
1713
2114
|
}
|
|
1714
2115
|
let settled = false;
|
|
2116
|
+
const timers = {};
|
|
1715
2117
|
const cleanup = () => {
|
|
1716
|
-
clearInterval(
|
|
1717
|
-
clearTimeout(
|
|
2118
|
+
clearInterval(timers.poll);
|
|
2119
|
+
clearTimeout(timers.timeout);
|
|
1718
2120
|
};
|
|
1719
2121
|
const succeed = () => {
|
|
1720
|
-
if (settled)
|
|
2122
|
+
if (settled) {
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
1721
2125
|
settled = true;
|
|
1722
2126
|
cleanup();
|
|
1723
2127
|
resolve();
|
|
1724
2128
|
};
|
|
1725
2129
|
const fail = () => {
|
|
1726
|
-
if (settled)
|
|
2130
|
+
if (settled) {
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
1727
2133
|
settled = true;
|
|
1728
2134
|
cleanup();
|
|
1729
2135
|
twitterScriptPromise = null;
|
|
@@ -1733,12 +2139,12 @@ var loadTwitterScript = () => {
|
|
|
1733
2139
|
succeed();
|
|
1734
2140
|
return;
|
|
1735
2141
|
}
|
|
1736
|
-
|
|
2142
|
+
timers.poll = setInterval(() => {
|
|
1737
2143
|
if (window.twttr?.widgets) {
|
|
1738
2144
|
succeed();
|
|
1739
2145
|
}
|
|
1740
2146
|
}, READY_POLL_INTERVAL_MS);
|
|
1741
|
-
|
|
2147
|
+
timers.timeout = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
|
|
1742
2148
|
if (isNewScript) {
|
|
1743
2149
|
script.addEventListener(
|
|
1744
2150
|
"load",
|
|
@@ -1756,14 +2162,14 @@ var loadTwitterScript = () => {
|
|
|
1756
2162
|
};
|
|
1757
2163
|
var TwitterNodeView = (props) => {
|
|
1758
2164
|
const { node } = props;
|
|
1759
|
-
const containerRef =
|
|
1760
|
-
const [loading, setLoading] =
|
|
1761
|
-
const [failed, setFailed] =
|
|
2165
|
+
const containerRef = useRef4(null);
|
|
2166
|
+
const [loading, setLoading] = useState6(true);
|
|
2167
|
+
const [failed, setFailed] = useState6(false);
|
|
1762
2168
|
const { tweetId } = node.attrs;
|
|
1763
|
-
const renderedTweetIdRef =
|
|
1764
|
-
const activeRenderIdRef =
|
|
1765
|
-
const retryToken =
|
|
1766
|
-
const [retryCount, setRetryCount] =
|
|
2169
|
+
const renderedTweetIdRef = useRef4(null);
|
|
2170
|
+
const activeRenderIdRef = useRef4(0);
|
|
2171
|
+
const retryToken = useRef4(0);
|
|
2172
|
+
const [retryCount, setRetryCount] = useState6(0);
|
|
1767
2173
|
useEffect4(() => {
|
|
1768
2174
|
if (!containerRef.current || !tweetId) {
|
|
1769
2175
|
return;
|
|
@@ -1827,7 +2233,7 @@ var TwitterNodeView = (props) => {
|
|
|
1827
2233
|
retryToken.current += 1;
|
|
1828
2234
|
setRetryCount(retryToken.current);
|
|
1829
2235
|
}, []);
|
|
1830
|
-
return /* @__PURE__ */
|
|
2236
|
+
return /* @__PURE__ */ jsxs11(
|
|
1831
2237
|
ResizableNodeView,
|
|
1832
2238
|
{
|
|
1833
2239
|
...props,
|
|
@@ -1835,12 +2241,12 @@ var TwitterNodeView = (props) => {
|
|
|
1835
2241
|
minWidth: 300,
|
|
1836
2242
|
maxWidth: 1200,
|
|
1837
2243
|
children: [
|
|
1838
|
-
loading && /* @__PURE__ */
|
|
1839
|
-
!loading && failed && /* @__PURE__ */
|
|
1840
|
-
/* @__PURE__ */
|
|
1841
|
-
/* @__PURE__ */
|
|
2244
|
+
loading && /* @__PURE__ */ jsx24("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
|
|
2245
|
+
!loading && failed && /* @__PURE__ */ jsxs11("div", { className: "rte-embed-error", children: [
|
|
2246
|
+
/* @__PURE__ */ jsx24("p", { children: "Couldn't load this tweet." }),
|
|
2247
|
+
/* @__PURE__ */ jsx24("button", { type: "button", onClick: handleRetry, children: "Retry" })
|
|
1842
2248
|
] }),
|
|
1843
|
-
/* @__PURE__ */
|
|
2249
|
+
/* @__PURE__ */ jsx24("div", { ref: containerRef })
|
|
1844
2250
|
]
|
|
1845
2251
|
}
|
|
1846
2252
|
);
|
|
@@ -1930,9 +2336,9 @@ var extractTweetId = (input) => {
|
|
|
1930
2336
|
};
|
|
1931
2337
|
var TwitterEmbedControl = ({ className }) => {
|
|
1932
2338
|
const { editor } = useRichTextEditorContext();
|
|
1933
|
-
const [open, setOpen] =
|
|
1934
|
-
const [url, setUrl] =
|
|
1935
|
-
const [touched, setTouched] =
|
|
2339
|
+
const [open, setOpen] = useState6(false);
|
|
2340
|
+
const [url, setUrl] = useState6("");
|
|
2341
|
+
const [touched, setTouched] = useState6(false);
|
|
1936
2342
|
const { active } = useEditorState4({
|
|
1937
2343
|
editor: editor ?? null,
|
|
1938
2344
|
selector: (ctx) => ({
|
|
@@ -1954,7 +2360,7 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
1954
2360
|
resetState();
|
|
1955
2361
|
return true;
|
|
1956
2362
|
}, [tweetId, editor, resetState]);
|
|
1957
|
-
return /* @__PURE__ */
|
|
2363
|
+
return /* @__PURE__ */ jsxs11(
|
|
1958
2364
|
Dialog,
|
|
1959
2365
|
{
|
|
1960
2366
|
open,
|
|
@@ -1965,59 +2371,59 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
1965
2371
|
}
|
|
1966
2372
|
},
|
|
1967
2373
|
children: [
|
|
1968
|
-
/* @__PURE__ */
|
|
2374
|
+
/* @__PURE__ */ jsx24(
|
|
1969
2375
|
DialogTrigger,
|
|
1970
2376
|
{
|
|
1971
|
-
render: /* @__PURE__ */
|
|
2377
|
+
render: /* @__PURE__ */ jsx24(
|
|
1972
2378
|
RichTextEditorControl,
|
|
1973
2379
|
{
|
|
1974
2380
|
active,
|
|
1975
2381
|
className,
|
|
1976
2382
|
title: "Embed Tweet",
|
|
1977
2383
|
"aria-label": "Embed Tweet",
|
|
1978
|
-
children: /* @__PURE__ */
|
|
2384
|
+
children: /* @__PURE__ */ jsx24(
|
|
1979
2385
|
"svg",
|
|
1980
2386
|
{
|
|
1981
2387
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1982
2388
|
viewBox: "0 0 24 24",
|
|
1983
2389
|
fill: "currentColor",
|
|
1984
2390
|
className: "rte-editor-icon",
|
|
1985
|
-
children: /* @__PURE__ */
|
|
2391
|
+
children: /* @__PURE__ */ jsx24("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" })
|
|
1986
2392
|
}
|
|
1987
2393
|
)
|
|
1988
2394
|
}
|
|
1989
2395
|
)
|
|
1990
2396
|
}
|
|
1991
2397
|
),
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
/* @__PURE__ */
|
|
1994
|
-
/* @__PURE__ */
|
|
1995
|
-
/* @__PURE__ */
|
|
2398
|
+
/* @__PURE__ */ jsxs11(DialogContent, { children: [
|
|
2399
|
+
/* @__PURE__ */ jsxs11(DialogHeader, { children: [
|
|
2400
|
+
/* @__PURE__ */ jsx24(DialogTitle, { children: "Embed Tweet" }),
|
|
2401
|
+
/* @__PURE__ */ jsx24(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
1996
2402
|
] }),
|
|
1997
|
-
/* @__PURE__ */
|
|
2403
|
+
/* @__PURE__ */ jsx24(
|
|
1998
2404
|
Input,
|
|
1999
2405
|
{
|
|
2000
2406
|
value: url,
|
|
2001
2407
|
onChange: (e) => {
|
|
2002
2408
|
setUrl(e.target.value);
|
|
2003
|
-
if (touched)
|
|
2409
|
+
if (touched) {
|
|
2410
|
+
setTouched(false);
|
|
2411
|
+
}
|
|
2004
2412
|
},
|
|
2005
2413
|
onBlur: () => setTouched(true),
|
|
2006
2414
|
placeholder: "https://x.com/user/status/...",
|
|
2007
2415
|
"aria-invalid": showError,
|
|
2008
2416
|
onKeyDown: (e) => {
|
|
2009
|
-
if (e.key === "Enter" && url) {
|
|
2010
|
-
|
|
2011
|
-
setOpen(false);
|
|
2012
|
-
}
|
|
2417
|
+
if (e.key === "Enter" && url && handleInsert()) {
|
|
2418
|
+
setOpen(false);
|
|
2013
2419
|
}
|
|
2014
2420
|
}
|
|
2015
2421
|
}
|
|
2016
2422
|
),
|
|
2017
|
-
showError && /* @__PURE__ */
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2423
|
+
showError && /* @__PURE__ */ jsx24("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
|
|
2424
|
+
/* @__PURE__ */ jsxs11(DialogFooter, { children: [
|
|
2425
|
+
/* @__PURE__ */ jsx24(DialogClose, { children: "Cancel" }),
|
|
2426
|
+
/* @__PURE__ */ jsx24(
|
|
2021
2427
|
"button",
|
|
2022
2428
|
{
|
|
2023
2429
|
type: "button",
|
|
@@ -2041,8 +2447,8 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2041
2447
|
// src/controls/rte-youtube-control.tsx
|
|
2042
2448
|
import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
|
|
2043
2449
|
import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
|
|
2044
|
-
import { useState as
|
|
2045
|
-
import { jsx as
|
|
2450
|
+
import { useState as useState7, useCallback as useCallback7 } from "react";
|
|
2451
|
+
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2046
2452
|
var getYouTubeId = (url) => {
|
|
2047
2453
|
const clean = url.trim();
|
|
2048
2454
|
const patterns = [
|
|
@@ -2070,7 +2476,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2070
2476
|
if (videoId) {
|
|
2071
2477
|
watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
|
|
2072
2478
|
}
|
|
2073
|
-
return /* @__PURE__ */
|
|
2479
|
+
return /* @__PURE__ */ jsx25(
|
|
2074
2480
|
ResizableNodeView,
|
|
2075
2481
|
{
|
|
2076
2482
|
...props,
|
|
@@ -2081,7 +2487,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2081
2487
|
videoSrc: rawSrc,
|
|
2082
2488
|
watchUrl,
|
|
2083
2489
|
onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
|
|
2084
|
-
children: /* @__PURE__ */
|
|
2490
|
+
children: /* @__PURE__ */ jsx25(
|
|
2085
2491
|
"iframe",
|
|
2086
2492
|
{
|
|
2087
2493
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -2169,8 +2575,8 @@ var YouTubeEmbed = Node2.create({
|
|
|
2169
2575
|
});
|
|
2170
2576
|
var YouTubeEmbedControl = ({ className }) => {
|
|
2171
2577
|
const { editor } = useRichTextEditorContext();
|
|
2172
|
-
const [open, setOpen] =
|
|
2173
|
-
const [url, setUrl] =
|
|
2578
|
+
const [open, setOpen] = useState7(false);
|
|
2579
|
+
const [url, setUrl] = useState7("");
|
|
2174
2580
|
const { active } = useEditorState5({
|
|
2175
2581
|
editor: editor ?? null,
|
|
2176
2582
|
selector: (ctx) => ({
|
|
@@ -2183,18 +2589,18 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
2183
2589
|
setUrl("");
|
|
2184
2590
|
}
|
|
2185
2591
|
}, [url, editor]);
|
|
2186
|
-
return /* @__PURE__ */
|
|
2187
|
-
/* @__PURE__ */
|
|
2592
|
+
return /* @__PURE__ */ jsxs12(Dialog, { open, onOpenChange: setOpen, children: [
|
|
2593
|
+
/* @__PURE__ */ jsx25(
|
|
2188
2594
|
DialogTrigger,
|
|
2189
2595
|
{
|
|
2190
|
-
render: /* @__PURE__ */
|
|
2596
|
+
render: /* @__PURE__ */ jsx25(
|
|
2191
2597
|
RichTextEditorControl,
|
|
2192
2598
|
{
|
|
2193
2599
|
active,
|
|
2194
2600
|
className,
|
|
2195
2601
|
title: "Embed YouTube video",
|
|
2196
2602
|
"aria-label": "Embed YouTube video",
|
|
2197
|
-
children: /* @__PURE__ */
|
|
2603
|
+
children: /* @__PURE__ */ jsxs12(
|
|
2198
2604
|
"svg",
|
|
2199
2605
|
{
|
|
2200
2606
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -2206,8 +2612,8 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
2206
2612
|
strokeLinejoin: "round",
|
|
2207
2613
|
className: "rte-editor-icon",
|
|
2208
2614
|
children: [
|
|
2209
|
-
/* @__PURE__ */
|
|
2210
|
-
/* @__PURE__ */
|
|
2615
|
+
/* @__PURE__ */ jsx25("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" }),
|
|
2616
|
+
/* @__PURE__ */ jsx25("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
2211
2617
|
]
|
|
2212
2618
|
}
|
|
2213
2619
|
)
|
|
@@ -2215,12 +2621,12 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
2215
2621
|
)
|
|
2216
2622
|
}
|
|
2217
2623
|
),
|
|
2218
|
-
/* @__PURE__ */
|
|
2219
|
-
/* @__PURE__ */
|
|
2220
|
-
/* @__PURE__ */
|
|
2221
|
-
/* @__PURE__ */
|
|
2624
|
+
/* @__PURE__ */ jsxs12(DialogContent, { showCloseButton: false, children: [
|
|
2625
|
+
/* @__PURE__ */ jsxs12(DialogHeader, { children: [
|
|
2626
|
+
/* @__PURE__ */ jsx25(DialogTitle, { children: "Embed YouTube video" }),
|
|
2627
|
+
/* @__PURE__ */ jsx25(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
2222
2628
|
] }),
|
|
2223
|
-
/* @__PURE__ */
|
|
2629
|
+
/* @__PURE__ */ jsx25(
|
|
2224
2630
|
Input,
|
|
2225
2631
|
{
|
|
2226
2632
|
value: url,
|
|
@@ -2234,9 +2640,9 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
2234
2640
|
}
|
|
2235
2641
|
}
|
|
2236
2642
|
),
|
|
2237
|
-
/* @__PURE__ */
|
|
2238
|
-
/* @__PURE__ */
|
|
2239
|
-
/* @__PURE__ */
|
|
2643
|
+
/* @__PURE__ */ jsxs12(DialogFooter, { children: [
|
|
2644
|
+
/* @__PURE__ */ jsx25(DialogClose, { children: "Cancel" }),
|
|
2645
|
+
/* @__PURE__ */ jsx25(
|
|
2240
2646
|
DialogClose,
|
|
2241
2647
|
{
|
|
2242
2648
|
disabled: !url,
|
|
@@ -2293,14 +2699,14 @@ var DEFAULT_LABELS = {
|
|
|
2293
2699
|
|
|
2294
2700
|
// src/rte-content.tsx
|
|
2295
2701
|
import { EditorContent } from "@tiptap/react";
|
|
2296
|
-
import { jsx as
|
|
2702
|
+
import { jsx as jsx26, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2297
2703
|
var Content = ({
|
|
2298
2704
|
children,
|
|
2299
2705
|
className
|
|
2300
2706
|
}) => {
|
|
2301
2707
|
const { editor } = useRichTextEditorContext();
|
|
2302
|
-
return /* @__PURE__ */
|
|
2303
|
-
/* @__PURE__ */
|
|
2708
|
+
return /* @__PURE__ */ jsxs13("div", { className: "relative", children: [
|
|
2709
|
+
/* @__PURE__ */ jsx26(
|
|
2304
2710
|
EditorContent,
|
|
2305
2711
|
{
|
|
2306
2712
|
editor,
|
|
@@ -2312,15 +2718,15 @@ var Content = ({
|
|
|
2312
2718
|
};
|
|
2313
2719
|
|
|
2314
2720
|
// src/rte-controls-group.tsx
|
|
2315
|
-
import { jsx as
|
|
2721
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2316
2722
|
var ControlsGroup = ({
|
|
2317
2723
|
children,
|
|
2318
2724
|
className
|
|
2319
|
-
}) => /* @__PURE__ */
|
|
2725
|
+
}) => /* @__PURE__ */ jsx27("div", { className: cn("rte-controls-group", className), children });
|
|
2320
2726
|
|
|
2321
2727
|
// src/rte-footer.tsx
|
|
2322
|
-
import { useEffect as useEffect5, useMemo, useRef as
|
|
2323
|
-
import { Fragment as
|
|
2728
|
+
import { useEffect as useEffect5, useMemo, useRef as useRef5, useState as useState8 } from "react";
|
|
2729
|
+
import { Fragment as Fragment6, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2324
2730
|
var Footer = ({
|
|
2325
2731
|
children,
|
|
2326
2732
|
className,
|
|
@@ -2331,8 +2737,8 @@ var Footer = ({
|
|
|
2331
2737
|
wordCountFormatter
|
|
2332
2738
|
}) => {
|
|
2333
2739
|
const { editor, variant } = useRichTextEditorContext();
|
|
2334
|
-
const [, forceUpdate] =
|
|
2335
|
-
const rafRef =
|
|
2740
|
+
const [, forceUpdate] = useState8(0);
|
|
2741
|
+
const rafRef = useRef5(null);
|
|
2336
2742
|
useEffect5(() => {
|
|
2337
2743
|
if (!editor || !showWordCount) {
|
|
2338
2744
|
return;
|
|
@@ -2379,7 +2785,7 @@ var Footer = ({
|
|
|
2379
2785
|
if (!showWordCount && !children) {
|
|
2380
2786
|
return null;
|
|
2381
2787
|
}
|
|
2382
|
-
return /* @__PURE__ */
|
|
2788
|
+
return /* @__PURE__ */ jsxs14(
|
|
2383
2789
|
"div",
|
|
2384
2790
|
{
|
|
2385
2791
|
className: cn(
|
|
@@ -2391,21 +2797,21 @@ var Footer = ({
|
|
|
2391
2797
|
"data-sticky": sticky ? "" : void 0,
|
|
2392
2798
|
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
2393
2799
|
children: [
|
|
2394
|
-
showWordCount && wordCount && /* @__PURE__ */
|
|
2395
|
-
/* @__PURE__ */
|
|
2396
|
-
/* @__PURE__ */
|
|
2397
|
-
/* @__PURE__ */
|
|
2800
|
+
showWordCount && wordCount && /* @__PURE__ */ jsx28("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs14(Fragment6, { children: [
|
|
2801
|
+
/* @__PURE__ */ jsxs14("span", { className: "rte-footer-word-count-stat", children: [
|
|
2802
|
+
/* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
|
|
2803
|
+
/* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-unit", children: "words" })
|
|
2398
2804
|
] }),
|
|
2399
|
-
/* @__PURE__ */
|
|
2805
|
+
/* @__PURE__ */ jsx28(
|
|
2400
2806
|
"span",
|
|
2401
2807
|
{
|
|
2402
2808
|
className: "rte-footer-word-count-separator",
|
|
2403
2809
|
"aria-hidden": "true"
|
|
2404
2810
|
}
|
|
2405
2811
|
),
|
|
2406
|
-
/* @__PURE__ */
|
|
2407
|
-
/* @__PURE__ */
|
|
2408
|
-
/* @__PURE__ */
|
|
2812
|
+
/* @__PURE__ */ jsxs14("span", { className: "rte-footer-word-count-stat", children: [
|
|
2813
|
+
/* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
|
|
2814
|
+
/* @__PURE__ */ jsx28("span", { className: "rte-footer-word-count-unit", children: "characters" })
|
|
2409
2815
|
] })
|
|
2410
2816
|
] }) }),
|
|
2411
2817
|
children
|
|
@@ -2415,7 +2821,7 @@ var Footer = ({
|
|
|
2415
2821
|
};
|
|
2416
2822
|
|
|
2417
2823
|
// src/rte-toolbar.tsx
|
|
2418
|
-
import { jsx as
|
|
2824
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
2419
2825
|
var Toolbar = ({
|
|
2420
2826
|
children,
|
|
2421
2827
|
className,
|
|
@@ -2426,7 +2832,7 @@ var Toolbar = ({
|
|
|
2426
2832
|
if (!editable) {
|
|
2427
2833
|
return null;
|
|
2428
2834
|
}
|
|
2429
|
-
return /* @__PURE__ */
|
|
2835
|
+
return /* @__PURE__ */ jsx29(
|
|
2430
2836
|
"div",
|
|
2431
2837
|
{
|
|
2432
2838
|
className: cn(
|
|
@@ -2443,7 +2849,7 @@ var Toolbar = ({
|
|
|
2443
2849
|
};
|
|
2444
2850
|
|
|
2445
2851
|
// src/rte-text-editor.tsx
|
|
2446
|
-
import { jsx as
|
|
2852
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
2447
2853
|
var RichTextEditorRoot = ({
|
|
2448
2854
|
editor,
|
|
2449
2855
|
children,
|
|
@@ -2463,7 +2869,7 @@ var RichTextEditorRoot = ({
|
|
|
2463
2869
|
editor.setEditable(editable);
|
|
2464
2870
|
}
|
|
2465
2871
|
}, [editor, editable]);
|
|
2466
|
-
return /* @__PURE__ */
|
|
2872
|
+
return /* @__PURE__ */ jsx30(
|
|
2467
2873
|
RichTextEditorContext.Provider,
|
|
2468
2874
|
{
|
|
2469
2875
|
value: {
|
|
@@ -2473,7 +2879,7 @@ var RichTextEditorRoot = ({
|
|
|
2473
2879
|
labels: mergedLabels,
|
|
2474
2880
|
variant
|
|
2475
2881
|
},
|
|
2476
|
-
children: /* @__PURE__ */
|
|
2882
|
+
children: /* @__PURE__ */ jsx30(
|
|
2477
2883
|
"div",
|
|
2478
2884
|
{
|
|
2479
2885
|
className: cn(
|