@editorcn/editor 0.5.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +651 -646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +576 -571
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -42,17 +42,16 @@ __export(index_exports, {
|
|
|
42
42
|
});
|
|
43
43
|
module.exports = __toCommonJS(index_exports);
|
|
44
44
|
|
|
45
|
-
// src/
|
|
45
|
+
// src/rich-text-editor.tsx
|
|
46
46
|
var import_react23 = require("react");
|
|
47
47
|
|
|
48
48
|
// src/bubble-menu/index.tsx
|
|
49
49
|
var import_core = require("@tiptap/core");
|
|
50
50
|
var import_menus = require("@tiptap/react/menus");
|
|
51
|
-
var
|
|
51
|
+
var import_react4 = require("react");
|
|
52
52
|
|
|
53
53
|
// src/ui/button.tsx
|
|
54
|
-
var
|
|
55
|
-
var import_class_variance_authority = require("class-variance-authority");
|
|
54
|
+
var React = __toESM(require("react"), 1);
|
|
56
55
|
|
|
57
56
|
// src/ui/utils.ts
|
|
58
57
|
var import_clsx = require("clsx");
|
|
@@ -61,238 +60,23 @@ var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)
|
|
|
61
60
|
|
|
62
61
|
// src/ui/button.tsx
|
|
63
62
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
64
|
-
var
|
|
65
|
-
"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",
|
|
66
|
-
{
|
|
67
|
-
defaultVariants: {
|
|
68
|
-
size: "default",
|
|
69
|
-
variant: "default"
|
|
70
|
-
},
|
|
71
|
-
variants: {
|
|
72
|
-
size: {
|
|
73
|
-
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
74
|
-
icon: "size-8",
|
|
75
|
-
"icon-lg": "size-9",
|
|
76
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
77
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
78
|
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
79
|
-
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",
|
|
80
|
-
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"
|
|
81
|
-
},
|
|
82
|
-
variant: {
|
|
83
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
84
|
-
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",
|
|
85
|
-
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
86
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
87
|
-
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",
|
|
88
|
-
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"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
var Button = ({
|
|
94
|
-
className,
|
|
95
|
-
variant = "default",
|
|
96
|
-
size = "default",
|
|
97
|
-
...props
|
|
98
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
99
|
-
import_button.Button,
|
|
100
|
-
{
|
|
101
|
-
"data-slot": "button",
|
|
102
|
-
className: cn(buttonVariants({ className, size, variant })),
|
|
103
|
-
...props
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
// src/ui/dialog.tsx
|
|
108
|
-
var import_dialog = require("@base-ui/react/dialog");
|
|
109
|
-
var React = require("react");
|
|
110
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
111
|
-
var Dialog = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
|
|
112
|
-
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
113
|
-
var DialogPortal = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
|
|
114
|
-
var DialogClose = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
|
|
115
|
-
var DialogOverlay = ({
|
|
116
|
-
className,
|
|
117
|
-
...props
|
|
118
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
119
|
-
import_dialog.Dialog.Backdrop,
|
|
120
|
-
{
|
|
121
|
-
"data-slot": "dialog-overlay",
|
|
122
|
-
className: cn(
|
|
123
|
-
"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",
|
|
124
|
-
className
|
|
125
|
-
),
|
|
126
|
-
...props
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
var DialogContent = ({
|
|
130
|
-
className,
|
|
131
|
-
children,
|
|
132
|
-
showCloseButton = true,
|
|
133
|
-
...props
|
|
134
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(DialogPortal, { children: [
|
|
135
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogOverlay, {}),
|
|
136
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
137
|
-
import_dialog.Dialog.Popup,
|
|
138
|
-
{
|
|
139
|
-
"data-slot": "dialog-content",
|
|
140
|
-
className: cn(
|
|
141
|
-
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-xs/relaxed text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
142
|
-
className
|
|
143
|
-
),
|
|
144
|
-
...props,
|
|
145
|
-
children: [
|
|
146
|
-
children,
|
|
147
|
-
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
148
|
-
import_dialog.Dialog.Close,
|
|
149
|
-
{
|
|
150
|
-
"data-slot": "dialog-close",
|
|
151
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
152
|
-
Button,
|
|
153
|
-
{
|
|
154
|
-
variant: "ghost",
|
|
155
|
-
className: "absolute top-2 right-2",
|
|
156
|
-
size: "icon-sm"
|
|
157
|
-
}
|
|
158
|
-
),
|
|
159
|
-
children: [
|
|
160
|
-
"X",
|
|
161
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Close" })
|
|
162
|
-
]
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
]
|
|
166
|
-
}
|
|
167
|
-
)
|
|
168
|
-
] });
|
|
169
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
170
|
-
"div",
|
|
171
|
-
{
|
|
172
|
-
"data-slot": "dialog-header",
|
|
173
|
-
className: cn("flex flex-col gap-1 text-left", className),
|
|
174
|
-
...props
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
var DialogFooter = ({
|
|
178
|
-
className,
|
|
179
|
-
showCloseButton = false,
|
|
180
|
-
children,
|
|
181
|
-
...props
|
|
182
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
183
|
-
"div",
|
|
184
|
-
{
|
|
185
|
-
"data-slot": "dialog-footer",
|
|
186
|
-
className: cn(
|
|
187
|
-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
188
|
-
className
|
|
189
|
-
),
|
|
190
|
-
...props,
|
|
191
|
-
children: [
|
|
192
|
-
children,
|
|
193
|
-
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { variant: "outline" }), children: "Close" })
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
198
|
-
import_dialog.Dialog.Title,
|
|
199
|
-
{
|
|
200
|
-
"data-slot": "dialog-title",
|
|
201
|
-
className: cn("text-sm font-medium", className),
|
|
202
|
-
...props
|
|
203
|
-
}
|
|
204
|
-
);
|
|
205
|
-
var DialogDescription = ({
|
|
206
|
-
className,
|
|
207
|
-
...props
|
|
208
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
209
|
-
import_dialog.Dialog.Description,
|
|
210
|
-
{
|
|
211
|
-
"data-slot": "dialog-description",
|
|
212
|
-
className: cn(
|
|
213
|
-
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
214
|
-
className
|
|
215
|
-
),
|
|
216
|
-
...props
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
|
|
220
|
-
// src/ui/input.tsx
|
|
221
|
-
var import_input = require("@base-ui/react/input");
|
|
222
|
-
var React2 = require("react");
|
|
223
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
224
|
-
var Input = ({
|
|
225
|
-
className,
|
|
226
|
-
type,
|
|
227
|
-
...props
|
|
228
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
229
|
-
import_input.Input,
|
|
230
|
-
{
|
|
231
|
-
type,
|
|
232
|
-
"data-slot": "input",
|
|
233
|
-
className: cn(
|
|
234
|
-
"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",
|
|
235
|
-
className
|
|
236
|
-
),
|
|
237
|
-
...props
|
|
238
|
-
}
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
// src/ui/popover.tsx
|
|
242
|
-
var import_popover = require("@base-ui/react/popover");
|
|
243
|
-
var React3 = require("react");
|
|
244
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
245
|
-
var Popover = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
246
|
-
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
247
|
-
var PopoverContent = ({
|
|
248
|
-
className,
|
|
249
|
-
align = "center",
|
|
250
|
-
alignOffset = 0,
|
|
251
|
-
side = "bottom",
|
|
252
|
-
sideOffset = 4,
|
|
253
|
-
...props
|
|
254
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
255
|
-
import_popover.Popover.Positioner,
|
|
256
|
-
{
|
|
257
|
-
align,
|
|
258
|
-
alignOffset,
|
|
259
|
-
side,
|
|
260
|
-
sideOffset,
|
|
261
|
-
className: "isolate z-50",
|
|
262
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
263
|
-
import_popover.Popover.Popup,
|
|
264
|
-
{
|
|
265
|
-
"data-slot": "popover-content",
|
|
266
|
-
className: cn(
|
|
267
|
-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
268
|
-
className
|
|
269
|
-
),
|
|
270
|
-
...props
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
}
|
|
274
|
-
) });
|
|
275
|
-
|
|
276
|
-
// src/ui/rte-button.tsx
|
|
277
|
-
var React4 = __toESM(require("react"), 1);
|
|
278
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
279
|
-
var RteButton = React4.forwardRef(
|
|
63
|
+
var Button = React.forwardRef(
|
|
280
64
|
({ className, active = false, ...props }, ref) => {
|
|
281
65
|
const cls = cn(
|
|
282
66
|
"rte-bubble-btn flex h-8 min-w-8 cursor-pointer items-center justify-center gap-1 rounded-md border-none bg-transparent px-2 text-[0.8125rem] font-medium whitespace-nowrap text-popover-foreground [transition:background-color_150ms_ease-out,color_150ms_ease-out,scale_100ms_ease-out] hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-ring/50 focus-visible:-outline-offset-2 active:scale-96",
|
|
283
67
|
active && "rte-bubble-btn--active bg-muted text-foreground",
|
|
284
68
|
className
|
|
285
69
|
);
|
|
286
|
-
return /* @__PURE__ */ (0,
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { ref, type: "button", className: cls, ...props });
|
|
287
71
|
}
|
|
288
72
|
);
|
|
289
|
-
|
|
73
|
+
Button.displayName = "Button";
|
|
290
74
|
|
|
291
|
-
// src/ui/
|
|
292
|
-
var
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
75
|
+
// src/ui/button-group.tsx
|
|
76
|
+
var React2 = __toESM(require("react"), 1);
|
|
77
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
78
|
+
var ButtonGroup = React2.forwardRef(
|
|
79
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
296
80
|
"div",
|
|
297
81
|
{
|
|
298
82
|
ref,
|
|
@@ -301,13 +85,13 @@ var RteButtonGroup = React5.forwardRef(
|
|
|
301
85
|
}
|
|
302
86
|
)
|
|
303
87
|
);
|
|
304
|
-
|
|
88
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
305
89
|
|
|
306
|
-
// src/ui/
|
|
307
|
-
var
|
|
308
|
-
var
|
|
309
|
-
var
|
|
310
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
90
|
+
// src/ui/icon.tsx
|
|
91
|
+
var React3 = __toESM(require("react"), 1);
|
|
92
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
93
|
+
var Icon = React3.forwardRef(
|
|
94
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
311
95
|
"span",
|
|
312
96
|
{
|
|
313
97
|
ref,
|
|
@@ -319,13 +103,13 @@ var RteIcon = React6.forwardRef(
|
|
|
319
103
|
}
|
|
320
104
|
)
|
|
321
105
|
);
|
|
322
|
-
|
|
106
|
+
Icon.displayName = "Icon";
|
|
323
107
|
|
|
324
|
-
// src/ui/
|
|
325
|
-
var
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
108
|
+
// src/ui/separator.tsx
|
|
109
|
+
var React4 = __toESM(require("react"), 1);
|
|
110
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
111
|
+
var Separator = React4.forwardRef(
|
|
112
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
329
113
|
"div",
|
|
330
114
|
{
|
|
331
115
|
ref,
|
|
@@ -337,13 +121,13 @@ var RteSeparator = React7.forwardRef(
|
|
|
337
121
|
}
|
|
338
122
|
)
|
|
339
123
|
);
|
|
340
|
-
|
|
124
|
+
Separator.displayName = "Separator";
|
|
341
125
|
|
|
342
|
-
// src/ui/
|
|
343
|
-
var
|
|
344
|
-
var
|
|
345
|
-
var
|
|
346
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
126
|
+
// src/ui/overlay.tsx
|
|
127
|
+
var React5 = __toESM(require("react"), 1);
|
|
128
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
129
|
+
var Overlay = React5.forwardRef(
|
|
130
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
347
131
|
"div",
|
|
348
132
|
{
|
|
349
133
|
ref,
|
|
@@ -353,18 +137,18 @@ var RteOverlay = React8.forwardRef(
|
|
|
353
137
|
}
|
|
354
138
|
)
|
|
355
139
|
);
|
|
356
|
-
|
|
140
|
+
Overlay.displayName = "Overlay";
|
|
357
141
|
|
|
358
|
-
// src/ui/
|
|
359
|
-
var
|
|
142
|
+
// src/ui/dropdown.tsx
|
|
143
|
+
var React6 = __toESM(require("react"), 1);
|
|
360
144
|
var import_react = require("react");
|
|
361
|
-
var
|
|
145
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
362
146
|
var variantClass = {
|
|
363
147
|
color: "rte-bubble-dropdown--color min-w-auto p-2 [&_.rte-bubble-dropdown-divider]:mx-[-0.5rem] [&_.rte-bubble-dropdown-divider]:mt-2.5 [&_.rte-bubble-dropdown-divider]:mb-2",
|
|
364
148
|
default: "",
|
|
365
149
|
language: "rte-bubble-dropdown--language max-h-80 min-w-40 overflow-y-auto [scrollbar-width:thin]"
|
|
366
150
|
};
|
|
367
|
-
var
|
|
151
|
+
var Dropdown = React6.forwardRef(
|
|
368
152
|
({ className, variant = "default", children, onMouseLeave, ...props }, ref) => {
|
|
369
153
|
const containerRef = (0, import_react.useRef)(null);
|
|
370
154
|
const [pill, setPill] = (0, import_react.useState)(null);
|
|
@@ -406,7 +190,7 @@ var RteDropdown = React9.forwardRef(
|
|
|
406
190
|
variantClass[variant],
|
|
407
191
|
className
|
|
408
192
|
);
|
|
409
|
-
return /* @__PURE__ */ (0,
|
|
193
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
410
194
|
"div",
|
|
411
195
|
{
|
|
412
196
|
ref: (node) => {
|
|
@@ -423,7 +207,7 @@ var RteDropdown = React9.forwardRef(
|
|
|
423
207
|
onMouseOver: handleMouseOver,
|
|
424
208
|
...props,
|
|
425
209
|
children: [
|
|
426
|
-
/* @__PURE__ */ (0,
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
427
211
|
"div",
|
|
428
212
|
{
|
|
429
213
|
"aria-hidden": "true",
|
|
@@ -445,11 +229,11 @@ var RteDropdown = React9.forwardRef(
|
|
|
445
229
|
);
|
|
446
230
|
}
|
|
447
231
|
);
|
|
448
|
-
|
|
232
|
+
Dropdown.displayName = "Dropdown";
|
|
449
233
|
|
|
450
|
-
// src/ui/
|
|
451
|
-
var
|
|
452
|
-
var
|
|
234
|
+
// src/ui/color-swatch.tsx
|
|
235
|
+
var React7 = __toESM(require("react"), 1);
|
|
236
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
453
237
|
var getCheckColor = (hex) => {
|
|
454
238
|
const value = hex.replace("#", "");
|
|
455
239
|
const r = Number.parseInt(value.slice(0, 2), 16) / 255;
|
|
@@ -458,10 +242,10 @@ var getCheckColor = (hex) => {
|
|
|
458
242
|
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
459
243
|
return luminance > 0.5 ? "#18181b" : "#ffffff";
|
|
460
244
|
};
|
|
461
|
-
var
|
|
245
|
+
var ColorSwatch = React7.forwardRef(
|
|
462
246
|
({ color, label, variant, active = false, onSelect }, ref) => {
|
|
463
247
|
const checkColor = getCheckColor(color);
|
|
464
|
-
return /* @__PURE__ */ (0,
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
465
249
|
"button",
|
|
466
250
|
{
|
|
467
251
|
ref,
|
|
@@ -483,7 +267,7 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
483
267
|
onMouseDown: (e) => e.preventDefault(),
|
|
484
268
|
onClick: () => onSelect(color),
|
|
485
269
|
children: [
|
|
486
|
-
variant === "text" && !active ? /* @__PURE__ */ (0,
|
|
270
|
+
variant === "text" && !active ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
487
271
|
"span",
|
|
488
272
|
{
|
|
489
273
|
className: "rte-bubble-color-glyph text-[0.6875rem] leading-none font-semibold",
|
|
@@ -491,12 +275,12 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
491
275
|
children: "A"
|
|
492
276
|
}
|
|
493
277
|
) : null,
|
|
494
|
-
active ? /* @__PURE__ */ (0,
|
|
278
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
495
279
|
"span",
|
|
496
280
|
{
|
|
497
281
|
className: "rte-bubble-color-check flex size-3 items-center justify-center text-(--swatch-check) [&_svg]:size-full",
|
|
498
282
|
"aria-hidden": "true",
|
|
499
|
-
children: /* @__PURE__ */ (0,
|
|
283
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
500
284
|
"svg",
|
|
501
285
|
{
|
|
502
286
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -506,7 +290,7 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
506
290
|
strokeWidth: 3,
|
|
507
291
|
strokeLinecap: "round",
|
|
508
292
|
strokeLinejoin: "round",
|
|
509
|
-
children: /* @__PURE__ */ (0,
|
|
293
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M20 6 9 17l-5-5" })
|
|
510
294
|
}
|
|
511
295
|
)
|
|
512
296
|
}
|
|
@@ -516,34 +300,36 @@ var RteColorSwatch = React10.forwardRef(
|
|
|
516
300
|
);
|
|
517
301
|
}
|
|
518
302
|
);
|
|
519
|
-
|
|
303
|
+
ColorSwatch.displayName = "ColorSwatch";
|
|
520
304
|
|
|
521
|
-
// src/ui/
|
|
522
|
-
var
|
|
523
|
-
var
|
|
524
|
-
var
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
305
|
+
// src/ui/dropdown-item.tsx
|
|
306
|
+
var React8 = __toESM(require("react"), 1);
|
|
307
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
308
|
+
var DropdownItem = React8.forwardRef(
|
|
309
|
+
({ className, active = false, ...props }, ref) => {
|
|
310
|
+
const cls = cn(
|
|
311
|
+
"rte-bubble-dropdown-item relative z-1 flex h-8 w-full cursor-pointer items-center justify-start gap-2 rounded-sm border-none bg-transparent px-2 text-left text-[0.8125rem] text-muted-foreground outline-none [transition:background-color_150ms_ease-out,color_150ms_ease-out] hover:text-foreground focus-visible:text-foreground hover:[&_.rte-bubble-dropdown-icon]:text-foreground",
|
|
312
|
+
active && "rte-bubble-dropdown-item--active bg-muted font-medium text-foreground [&_.rte-bubble-dropdown-icon]:text-foreground",
|
|
313
|
+
className
|
|
314
|
+
);
|
|
315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
316
|
+
"button",
|
|
317
|
+
{
|
|
318
|
+
ref,
|
|
319
|
+
type: "button",
|
|
320
|
+
"data-dropdown-item": true,
|
|
321
|
+
className: cls,
|
|
322
|
+
...props
|
|
323
|
+
}
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
DropdownItem.displayName = "DropdownItem";
|
|
542
328
|
|
|
543
|
-
// src/ui/
|
|
544
|
-
var
|
|
545
|
-
var
|
|
546
|
-
var
|
|
329
|
+
// src/ui/dropdown-separator.tsx
|
|
330
|
+
var React9 = __toESM(require("react"), 1);
|
|
331
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
332
|
+
var DropdownSeparator = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
547
333
|
"div",
|
|
548
334
|
{
|
|
549
335
|
ref,
|
|
@@ -554,13 +340,13 @@ var RteDropdownDivider = React12.forwardRef(({ className, ...props }, ref) => /*
|
|
|
554
340
|
...props
|
|
555
341
|
}
|
|
556
342
|
));
|
|
557
|
-
|
|
343
|
+
DropdownSeparator.displayName = "DropdownSeparator";
|
|
558
344
|
|
|
559
|
-
// src/ui/
|
|
560
|
-
var
|
|
561
|
-
var
|
|
562
|
-
var
|
|
563
|
-
({ className, ...props }, ref) => /* @__PURE__ */ (0,
|
|
345
|
+
// src/ui/dropdown-icon.tsx
|
|
346
|
+
var React10 = __toESM(require("react"), 1);
|
|
347
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
348
|
+
var DropdownIcon = React10.forwardRef(
|
|
349
|
+
({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
564
350
|
"span",
|
|
565
351
|
{
|
|
566
352
|
ref,
|
|
@@ -572,108 +358,13 @@ var RteDropdownIcon = React13.forwardRef(
|
|
|
572
358
|
}
|
|
573
359
|
)
|
|
574
360
|
);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
// src/ui/toggle.tsx
|
|
578
|
-
var import_toggle = require("@base-ui/react/toggle");
|
|
579
|
-
var import_class_variance_authority2 = require("class-variance-authority");
|
|
580
|
-
var import_react2 = require("react");
|
|
581
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
582
|
-
var toggleVariants = (0, import_class_variance_authority2.cva)(
|
|
583
|
-
"group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
584
|
-
{
|
|
585
|
-
defaultVariants: {
|
|
586
|
-
size: "default",
|
|
587
|
-
variant: "default"
|
|
588
|
-
},
|
|
589
|
-
variants: {
|
|
590
|
-
size: {
|
|
591
|
-
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
592
|
-
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
593
|
-
sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
594
|
-
},
|
|
595
|
-
variant: {
|
|
596
|
-
default: "bg-transparent",
|
|
597
|
-
outline: "border border-input bg-transparent hover:bg-muted"
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
);
|
|
602
|
-
var Toggle = (0, import_react2.forwardRef)(({ className, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
603
|
-
import_toggle.Toggle,
|
|
604
|
-
{
|
|
605
|
-
ref,
|
|
606
|
-
"data-slot": "toggle",
|
|
607
|
-
className: cn(toggleVariants({ className, size, variant })),
|
|
608
|
-
...props
|
|
609
|
-
}
|
|
610
|
-
));
|
|
611
|
-
Toggle.displayName = "Toggle";
|
|
612
|
-
|
|
613
|
-
// src/ui/tooltip.tsx
|
|
614
|
-
var import_tooltip = require("@base-ui/react/tooltip");
|
|
615
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
616
|
-
var TooltipProvider = ({
|
|
617
|
-
delay = 0,
|
|
618
|
-
...props
|
|
619
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
620
|
-
import_tooltip.Tooltip.Provider,
|
|
621
|
-
{
|
|
622
|
-
"data-slot": "tooltip-provider",
|
|
623
|
-
delay,
|
|
624
|
-
...props
|
|
625
|
-
}
|
|
626
|
-
);
|
|
627
|
-
var Tooltip = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Root, { "data-slot": "tooltip", ...props });
|
|
628
|
-
var TooltipTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
629
|
-
var TooltipContent = ({
|
|
630
|
-
className,
|
|
631
|
-
side = "top",
|
|
632
|
-
sideOffset = 4,
|
|
633
|
-
align = "center",
|
|
634
|
-
alignOffset = 0,
|
|
635
|
-
children,
|
|
636
|
-
...props
|
|
637
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
638
|
-
import_tooltip.Tooltip.Positioner,
|
|
639
|
-
{
|
|
640
|
-
align,
|
|
641
|
-
alignOffset,
|
|
642
|
-
side,
|
|
643
|
-
sideOffset,
|
|
644
|
-
className: "isolate z-50",
|
|
645
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
646
|
-
import_tooltip.Tooltip.Popup,
|
|
647
|
-
{
|
|
648
|
-
"data-slot": "tooltip-content",
|
|
649
|
-
className: cn(
|
|
650
|
-
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-2 py-1 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
651
|
-
className
|
|
652
|
-
),
|
|
653
|
-
...props,
|
|
654
|
-
children: [
|
|
655
|
-
children,
|
|
656
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
657
|
-
]
|
|
658
|
-
}
|
|
659
|
-
)
|
|
660
|
-
}
|
|
661
|
-
) });
|
|
662
|
-
var createTooltipHandle = () => import_tooltip.Tooltip.createHandle();
|
|
663
|
-
var TooltipHost = ({
|
|
664
|
-
handle,
|
|
665
|
-
children,
|
|
666
|
-
...props
|
|
667
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
668
|
-
children,
|
|
669
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Tooltip, { handle, children: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipContent, { ...props, children: payload }) })
|
|
670
|
-
] });
|
|
361
|
+
DropdownIcon.displayName = "DropdownIcon";
|
|
671
362
|
|
|
672
363
|
// src/bubble-menu/color-selector.tsx
|
|
673
|
-
var
|
|
364
|
+
var import_react3 = require("react");
|
|
674
365
|
|
|
675
366
|
// src/bubble-menu/utils.ts
|
|
676
|
-
var
|
|
367
|
+
var import_react2 = require("react");
|
|
677
368
|
var defaultEqual = (a, b) => a === b;
|
|
678
369
|
var shallowEqual = (a, b) => {
|
|
679
370
|
if (a === b) {
|
|
@@ -690,16 +381,16 @@ var shallowEqual = (a, b) => {
|
|
|
690
381
|
return ak.every((k) => a[k] === b[k]);
|
|
691
382
|
};
|
|
692
383
|
var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
693
|
-
const selectorRef = (0,
|
|
694
|
-
const isEqualRef = (0,
|
|
695
|
-
(0,
|
|
384
|
+
const selectorRef = (0, import_react2.useRef)(selector);
|
|
385
|
+
const isEqualRef = (0, import_react2.useRef)(isEqual);
|
|
386
|
+
(0, import_react2.useEffect)(() => {
|
|
696
387
|
selectorRef.current = selector;
|
|
697
388
|
isEqualRef.current = isEqual;
|
|
698
389
|
});
|
|
699
|
-
const snapshotRef = (0,
|
|
390
|
+
const snapshotRef = (0, import_react2.useRef)({
|
|
700
391
|
value: editor ? selector(editor) : void 0
|
|
701
392
|
});
|
|
702
|
-
const updateSnapshot = (0,
|
|
393
|
+
const updateSnapshot = (0, import_react2.useCallback)(() => {
|
|
703
394
|
if (!editor) {
|
|
704
395
|
return;
|
|
705
396
|
}
|
|
@@ -709,7 +400,7 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
|
709
400
|
}
|
|
710
401
|
snapshotRef.current = { value: next };
|
|
711
402
|
}, [editor]);
|
|
712
|
-
const subscribe = (0,
|
|
403
|
+
const subscribe = (0, import_react2.useCallback)(
|
|
713
404
|
(onStoreChange) => {
|
|
714
405
|
if (!editor) {
|
|
715
406
|
return () => {
|
|
@@ -728,12 +419,12 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
|
728
419
|
},
|
|
729
420
|
[editor, updateSnapshot]
|
|
730
421
|
);
|
|
731
|
-
const getSnapshot = (0,
|
|
732
|
-
return (0,
|
|
422
|
+
const getSnapshot = (0, import_react2.useCallback)(() => snapshotRef.current.value, []);
|
|
423
|
+
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
733
424
|
};
|
|
734
425
|
|
|
735
426
|
// src/bubble-menu/color-selector.tsx
|
|
736
|
-
var
|
|
427
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
737
428
|
var RECENT_KEY = "editorcn-editor-recent-colors";
|
|
738
429
|
var RECENT_LIMIT = 10;
|
|
739
430
|
var readRecentColors = () => {
|
|
@@ -782,8 +473,8 @@ var HIGHLIGHT_COLORS = [
|
|
|
782
473
|
{ color: "#bbf7d0", label: "Green" }
|
|
783
474
|
];
|
|
784
475
|
var ColorSelector = ({ editor }) => {
|
|
785
|
-
const [open, setOpen] = (0,
|
|
786
|
-
const [recent, setRecent] = (0,
|
|
476
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
477
|
+
const [recent, setRecent] = (0, import_react3.useState)(() => readRecentColors());
|
|
787
478
|
const { highlightColor, textColor } = useEditorState(
|
|
788
479
|
editor,
|
|
789
480
|
(ed) => ({
|
|
@@ -827,15 +518,15 @@ var ColorSelector = ({ editor }) => {
|
|
|
827
518
|
if (!hasColor && !hasHighlight) {
|
|
828
519
|
return null;
|
|
829
520
|
}
|
|
830
|
-
return /* @__PURE__ */ (0,
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
832
|
-
|
|
521
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { position: "relative" }, children: [
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
523
|
+
Button,
|
|
833
524
|
{
|
|
834
525
|
active: Boolean(textColor || highlightColor),
|
|
835
526
|
onMouseDown: (e) => e.preventDefault(),
|
|
836
527
|
onClick: () => setOpen(!open),
|
|
837
528
|
title: "Text color",
|
|
838
|
-
children: /* @__PURE__ */ (0,
|
|
529
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
839
530
|
"svg",
|
|
840
531
|
{
|
|
841
532
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -847,17 +538,17 @@ var ColorSelector = ({ editor }) => {
|
|
|
847
538
|
strokeLinejoin: "round",
|
|
848
539
|
className: "rte-editor-icon",
|
|
849
540
|
children: [
|
|
850
|
-
/* @__PURE__ */ (0,
|
|
851
|
-
/* @__PURE__ */ (0,
|
|
852
|
-
/* @__PURE__ */ (0,
|
|
541
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M4 20h16" }),
|
|
542
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "m6 16 6-12 6 12" }),
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M8 12h8" })
|
|
853
544
|
]
|
|
854
545
|
}
|
|
855
546
|
) })
|
|
856
547
|
}
|
|
857
548
|
),
|
|
858
|
-
open && /* @__PURE__ */ (0,
|
|
859
|
-
/* @__PURE__ */ (0,
|
|
860
|
-
|
|
549
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
550
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
551
|
+
Overlay,
|
|
861
552
|
{
|
|
862
553
|
onClick: () => setOpen(false),
|
|
863
554
|
onKeyDown: (e) => {
|
|
@@ -867,11 +558,11 @@ var ColorSelector = ({ editor }) => {
|
|
|
867
558
|
}
|
|
868
559
|
}
|
|
869
560
|
),
|
|
870
|
-
/* @__PURE__ */ (0,
|
|
871
|
-
recent.length > 0 ? /* @__PURE__ */ (0,
|
|
872
|
-
/* @__PURE__ */ (0,
|
|
873
|
-
/* @__PURE__ */ (0,
|
|
874
|
-
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Dropdown, { variant: "color", children: [
|
|
562
|
+
recent.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
563
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Recently Used" }),
|
|
564
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-bubble-color-recent flex flex-wrap justify-center gap-1.5", children: recent.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
565
|
+
ColorSwatch,
|
|
875
566
|
{
|
|
876
567
|
variant: item.type,
|
|
877
568
|
color: item.color,
|
|
@@ -882,12 +573,12 @@ var ColorSelector = ({ editor }) => {
|
|
|
882
573
|
`${item.type}-${item.color}`
|
|
883
574
|
)) })
|
|
884
575
|
] }) : null,
|
|
885
|
-
hasColor ? /* @__PURE__ */ (0,
|
|
886
|
-
recent.length > 0 && /* @__PURE__ */ (0,
|
|
887
|
-
/* @__PURE__ */ (0,
|
|
888
|
-
/* @__PURE__ */ (0,
|
|
889
|
-
/* @__PURE__ */ (0,
|
|
890
|
-
|
|
576
|
+
hasColor ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
577
|
+
recent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownSeparator, {}),
|
|
578
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
579
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Text Color" }),
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-bubble-color-grid grid grid-cols-[repeat(5,1.5rem)] justify-center gap-1.5", children: TEXT_COLORS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
581
|
+
ColorSwatch,
|
|
891
582
|
{
|
|
892
583
|
variant: "text",
|
|
893
584
|
color: item.color,
|
|
@@ -899,12 +590,12 @@ var ColorSelector = ({ editor }) => {
|
|
|
899
590
|
)) })
|
|
900
591
|
] })
|
|
901
592
|
] }) : null,
|
|
902
|
-
hasHighlight ? /* @__PURE__ */ (0,
|
|
903
|
-
(recent.length > 0 || hasColor) && /* @__PURE__ */ (0,
|
|
904
|
-
/* @__PURE__ */ (0,
|
|
905
|
-
/* @__PURE__ */ (0,
|
|
906
|
-
/* @__PURE__ */ (0,
|
|
907
|
-
|
|
593
|
+
hasHighlight ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
594
|
+
(recent.length > 0 || hasColor) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DropdownSeparator, {}),
|
|
595
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-bubble-color-section flex flex-col gap-2", children: [
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rte-bubble-color-label px-0.5 text-[0.75rem] leading-none font-medium text-muted-foreground", children: "Highlight Color" }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-bubble-color-grid grid grid-cols-[repeat(5,1.5rem)] justify-center gap-1.5", children: HIGHLIGHT_COLORS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
598
|
+
ColorSwatch,
|
|
908
599
|
{
|
|
909
600
|
variant: "highlight",
|
|
910
601
|
color: item.color,
|
|
@@ -922,11 +613,11 @@ var ColorSelector = ({ editor }) => {
|
|
|
922
613
|
};
|
|
923
614
|
|
|
924
615
|
// src/bubble-menu/text-buttons.tsx
|
|
925
|
-
var
|
|
616
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
926
617
|
var Svg = ({
|
|
927
618
|
children,
|
|
928
619
|
strokeWidth = 2
|
|
929
|
-
}) => /* @__PURE__ */ (0,
|
|
620
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
930
621
|
"svg",
|
|
931
622
|
{
|
|
932
623
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -940,51 +631,50 @@ var Svg = ({
|
|
|
940
631
|
children
|
|
941
632
|
}
|
|
942
633
|
);
|
|
943
|
-
var Icon = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RteIcon, { children });
|
|
944
634
|
var textItems = [
|
|
945
635
|
{
|
|
946
636
|
command: (e) => e.chain().focus().toggleBold().run(),
|
|
947
|
-
icon: /* @__PURE__ */ (0,
|
|
948
|
-
/* @__PURE__ */ (0,
|
|
949
|
-
/* @__PURE__ */ (0,
|
|
637
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
639
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
950
640
|
] }) }),
|
|
951
641
|
isActive: (s) => s.isBold,
|
|
952
642
|
mark: "bold"
|
|
953
643
|
},
|
|
954
644
|
{
|
|
955
645
|
command: (e) => e.chain().focus().toggleItalic().run(),
|
|
956
|
-
icon: /* @__PURE__ */ (0,
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
958
|
-
/* @__PURE__ */ (0,
|
|
959
|
-
/* @__PURE__ */ (0,
|
|
646
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
|
|
647
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
648
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
649
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
960
650
|
] }) }),
|
|
961
651
|
isActive: (s) => s.isItalic,
|
|
962
652
|
mark: "italic"
|
|
963
653
|
},
|
|
964
654
|
{
|
|
965
655
|
command: (e) => e.chain().focus().toggleUnderline().run(),
|
|
966
|
-
icon: /* @__PURE__ */ (0,
|
|
967
|
-
/* @__PURE__ */ (0,
|
|
968
|
-
/* @__PURE__ */ (0,
|
|
656
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
|
|
657
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
658
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
|
|
969
659
|
] }) }),
|
|
970
660
|
isActive: (s) => s.isUnderline,
|
|
971
661
|
mark: "underline"
|
|
972
662
|
},
|
|
973
663
|
{
|
|
974
664
|
command: (e) => e.chain().focus().toggleStrike().run(),
|
|
975
|
-
icon: /* @__PURE__ */ (0,
|
|
976
|
-
/* @__PURE__ */ (0,
|
|
977
|
-
/* @__PURE__ */ (0,
|
|
978
|
-
/* @__PURE__ */ (0,
|
|
665
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
|
|
666
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
|
|
667
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
|
|
668
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
979
669
|
] }) }),
|
|
980
670
|
isActive: (s) => s.isStrike,
|
|
981
671
|
mark: "strike"
|
|
982
672
|
},
|
|
983
673
|
{
|
|
984
674
|
command: (e) => e.chain().focus().toggleCode().run(),
|
|
985
|
-
icon: /* @__PURE__ */ (0,
|
|
986
|
-
/* @__PURE__ */ (0,
|
|
987
|
-
/* @__PURE__ */ (0,
|
|
675
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
|
|
676
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("polyline", { points: "16 18 22 12 16 6" }),
|
|
677
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("polyline", { points: "8 6 2 12 8 18" })
|
|
988
678
|
] }) }),
|
|
989
679
|
isActive: (s) => s.isCode,
|
|
990
680
|
mark: "code"
|
|
@@ -1003,8 +693,8 @@ var TextButtons = ({ editor }) => {
|
|
|
1003
693
|
}),
|
|
1004
694
|
shallowEqual
|
|
1005
695
|
);
|
|
1006
|
-
return /* @__PURE__ */ (0,
|
|
1007
|
-
|
|
696
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ButtonGroup, { children: getTextItems(editor).map((item) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
697
|
+
Button,
|
|
1008
698
|
{
|
|
1009
699
|
active: item.isActive(editorState),
|
|
1010
700
|
onMouseDown: (e) => e.preventDefault(),
|
|
@@ -1016,9 +706,9 @@ var TextButtons = ({ editor }) => {
|
|
|
1016
706
|
};
|
|
1017
707
|
|
|
1018
708
|
// src/bubble-menu/index.tsx
|
|
1019
|
-
var
|
|
709
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1020
710
|
var BubbleMenu = ({ editor }) => {
|
|
1021
|
-
const shouldShow = (0,
|
|
711
|
+
const shouldShow = (0, import_react4.useCallback)(
|
|
1022
712
|
({
|
|
1023
713
|
editor: ed,
|
|
1024
714
|
state
|
|
@@ -1047,31 +737,30 @@ var BubbleMenu = ({ editor }) => {
|
|
|
1047
737
|
if (!(hasText || hasColor)) {
|
|
1048
738
|
return null;
|
|
1049
739
|
}
|
|
1050
|
-
return /* @__PURE__ */ (0,
|
|
740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1051
741
|
import_menus.BubbleMenu,
|
|
1052
742
|
{
|
|
1053
743
|
className: "z-50",
|
|
1054
744
|
editor,
|
|
1055
745
|
options: { offset: 8, placement: "top" },
|
|
1056
746
|
shouldShow,
|
|
1057
|
-
children: /* @__PURE__ */ (0,
|
|
1058
|
-
hasText && /* @__PURE__ */ (0,
|
|
1059
|
-
hasText && hasColor && /* @__PURE__ */ (0,
|
|
1060
|
-
hasColor && /* @__PURE__ */ (0,
|
|
747
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "rte-bubble-menu flex h-10 animate-rte-bubble-pop-in items-center rounded-lg border border-[color-mix(in_srgb,var(--border)_60%,transparent)] bg-popover px-1 text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)]", children: [
|
|
748
|
+
hasText && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TextButtons, { editor }),
|
|
749
|
+
hasText && hasColor && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Separator, {}),
|
|
750
|
+
hasColor && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ColorSelector, { editor })
|
|
1061
751
|
] })
|
|
1062
752
|
}
|
|
1063
753
|
);
|
|
1064
754
|
};
|
|
1065
755
|
|
|
1066
|
-
// src/
|
|
1067
|
-
var
|
|
1068
|
-
var import_react8 = require("react");
|
|
756
|
+
// src/content.tsx
|
|
757
|
+
var import_react6 = require("@tiptap/react");
|
|
1069
758
|
|
|
1070
|
-
// src/
|
|
1071
|
-
var
|
|
1072
|
-
var RichTextEditorContext = (0,
|
|
759
|
+
// src/core/context.ts
|
|
760
|
+
var import_react5 = require("react");
|
|
761
|
+
var RichTextEditorContext = (0, import_react5.createContext)(null);
|
|
1073
762
|
var useRichTextEditorContext = () => {
|
|
1074
|
-
const context = (0,
|
|
763
|
+
const context = (0, import_react5.useContext)(RichTextEditorContext);
|
|
1075
764
|
if (!context) {
|
|
1076
765
|
throw new Error(
|
|
1077
766
|
"useRichTextEditorContext must be used within RichTextEditor"
|
|
@@ -1080,18 +769,142 @@ var useRichTextEditorContext = () => {
|
|
|
1080
769
|
return context;
|
|
1081
770
|
};
|
|
1082
771
|
|
|
1083
|
-
// src/
|
|
1084
|
-
var
|
|
772
|
+
// src/content.tsx
|
|
773
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
774
|
+
var Content = ({
|
|
775
|
+
children,
|
|
776
|
+
className
|
|
777
|
+
}) => {
|
|
778
|
+
const { editor, preset, variant } = useRichTextEditorContext();
|
|
779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "relative", children: [
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
781
|
+
import_react6.EditorContent,
|
|
782
|
+
{
|
|
783
|
+
editor,
|
|
784
|
+
className: cn(
|
|
785
|
+
"rte-content editorcn-content w-full",
|
|
786
|
+
variant === "default" && "rounded-lg border border-(--rte-hairline) bg-[var(--card,var(--background))]",
|
|
787
|
+
className
|
|
788
|
+
),
|
|
789
|
+
"data-preset": preset,
|
|
790
|
+
spellCheck: false
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
children
|
|
794
|
+
] });
|
|
795
|
+
};
|
|
796
|
+
|
|
797
|
+
// src/controls/control.tsx
|
|
798
|
+
var import_react8 = require("@tiptap/react");
|
|
799
|
+
var import_react9 = require("react");
|
|
800
|
+
|
|
801
|
+
// src/primitives/base/toggle.tsx
|
|
802
|
+
var import_toggle = require("@base-ui/react/toggle");
|
|
803
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
804
|
+
var import_react7 = require("react");
|
|
805
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
806
|
+
var toggleVariants = (0, import_class_variance_authority.cva)(
|
|
807
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
808
|
+
{
|
|
809
|
+
defaultVariants: {
|
|
810
|
+
size: "default",
|
|
811
|
+
variant: "default"
|
|
812
|
+
},
|
|
813
|
+
variants: {
|
|
814
|
+
size: {
|
|
815
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
816
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
817
|
+
sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
818
|
+
},
|
|
819
|
+
variant: {
|
|
820
|
+
default: "bg-transparent",
|
|
821
|
+
outline: "border border-input bg-transparent hover:bg-muted"
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
);
|
|
826
|
+
var Toggle = (0, import_react7.forwardRef)(({ className, variant = "default", size = "default", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
827
|
+
import_toggle.Toggle,
|
|
828
|
+
{
|
|
829
|
+
ref,
|
|
830
|
+
"data-slot": "toggle",
|
|
831
|
+
className: cn(toggleVariants({ className, size, variant })),
|
|
832
|
+
...props
|
|
833
|
+
}
|
|
834
|
+
));
|
|
835
|
+
Toggle.displayName = "Toggle";
|
|
836
|
+
|
|
837
|
+
// src/primitives/base/tooltip.tsx
|
|
838
|
+
var import_tooltip = require("@base-ui/react/tooltip");
|
|
839
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
840
|
+
var TooltipProvider = ({
|
|
841
|
+
delay = 0,
|
|
842
|
+
...props
|
|
843
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
844
|
+
import_tooltip.Tooltip.Provider,
|
|
845
|
+
{
|
|
846
|
+
"data-slot": "tooltip-provider",
|
|
847
|
+
delay,
|
|
848
|
+
...props
|
|
849
|
+
}
|
|
850
|
+
);
|
|
851
|
+
var Tooltip = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Root, { "data-slot": "tooltip", ...props });
|
|
852
|
+
var TooltipTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
853
|
+
var TooltipContent = ({
|
|
854
|
+
className,
|
|
855
|
+
side = "top",
|
|
856
|
+
sideOffset = 4,
|
|
857
|
+
align = "center",
|
|
858
|
+
alignOffset = 0,
|
|
859
|
+
children,
|
|
860
|
+
...props
|
|
861
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
862
|
+
import_tooltip.Tooltip.Positioner,
|
|
863
|
+
{
|
|
864
|
+
align,
|
|
865
|
+
alignOffset,
|
|
866
|
+
side,
|
|
867
|
+
sideOffset,
|
|
868
|
+
className: "isolate z-50",
|
|
869
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
870
|
+
import_tooltip.Tooltip.Popup,
|
|
871
|
+
{
|
|
872
|
+
"data-slot": "tooltip-content",
|
|
873
|
+
className: cn(
|
|
874
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-2 py-1 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
875
|
+
className
|
|
876
|
+
),
|
|
877
|
+
...props,
|
|
878
|
+
children: [
|
|
879
|
+
children,
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_tooltip.Tooltip.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
881
|
+
]
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
}
|
|
885
|
+
) });
|
|
886
|
+
var createTooltipHandle = () => import_tooltip.Tooltip.createHandle();
|
|
887
|
+
var TooltipHost = ({
|
|
888
|
+
handle,
|
|
889
|
+
children,
|
|
890
|
+
...props
|
|
891
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
892
|
+
children,
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Tooltip, { handle, children: ({ payload }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(TooltipContent, { ...props, children: payload }) })
|
|
894
|
+
] });
|
|
895
|
+
|
|
896
|
+
// src/controls/control.tsx
|
|
897
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1085
898
|
var RichTextEditorTooltip = ({
|
|
1086
899
|
children,
|
|
1087
900
|
id,
|
|
1088
901
|
label
|
|
1089
902
|
}) => {
|
|
1090
|
-
const tooltip = (0,
|
|
903
|
+
const tooltip = (0, import_react9.useContext)(RichTextEditorContext)?.tooltip;
|
|
1091
904
|
if (!tooltip) {
|
|
1092
|
-
return id ? (0,
|
|
905
|
+
return id ? (0, import_react9.cloneElement)(children, { id }) : children;
|
|
1093
906
|
}
|
|
1094
|
-
return /* @__PURE__ */ (0,
|
|
907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1095
908
|
TooltipTrigger,
|
|
1096
909
|
{
|
|
1097
910
|
handle: tooltip,
|
|
@@ -1111,7 +924,7 @@ var triggerProps = (props) => Object.fromEntries(
|
|
|
1111
924
|
(key) => props[key] === void 0 ? [] : [[key, props[key]]]
|
|
1112
925
|
)
|
|
1113
926
|
);
|
|
1114
|
-
var RichTextEditorControl = (0,
|
|
927
|
+
var RichTextEditorControl = (0, import_react9.forwardRef)(
|
|
1115
928
|
({
|
|
1116
929
|
active = false,
|
|
1117
930
|
interactive: _interactive = true,
|
|
@@ -1122,7 +935,7 @@ var RichTextEditorControl = (0, import_react8.forwardRef)(
|
|
|
1122
935
|
disabled,
|
|
1123
936
|
...props
|
|
1124
937
|
}, ref) => {
|
|
1125
|
-
const toggle = /* @__PURE__ */ (0,
|
|
938
|
+
const toggle = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1126
939
|
Toggle,
|
|
1127
940
|
{
|
|
1128
941
|
ref,
|
|
@@ -1144,7 +957,7 @@ var RichTextEditorControl = (0, import_react8.forwardRef)(
|
|
|
1144
957
|
children
|
|
1145
958
|
}
|
|
1146
959
|
);
|
|
1147
|
-
return props.title ? /* @__PURE__ */ (0,
|
|
960
|
+
return props.title ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RichTextEditorTooltip, { id: props.id, label: props.title, children: toggle }) : toggle;
|
|
1148
961
|
}
|
|
1149
962
|
);
|
|
1150
963
|
RichTextEditorControl.displayName = "RichTextEditorControl";
|
|
@@ -1175,9 +988,9 @@ var createControl = ({
|
|
|
1175
988
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
1176
989
|
const ariaLabel = labels[label];
|
|
1177
990
|
const selector = createSelector(isActive, isDisabled);
|
|
1178
|
-
(0,
|
|
991
|
+
(0, import_react8.useEditorState)({ editor: editor ?? null, selector });
|
|
1179
992
|
const { active, disabled } = selector({ editor: editor ?? null });
|
|
1180
|
-
return /* @__PURE__ */ (0,
|
|
993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1181
994
|
RichTextEditorControl,
|
|
1182
995
|
{
|
|
1183
996
|
active,
|
|
@@ -1200,7 +1013,7 @@ var createControl = ({
|
|
|
1200
1013
|
return Control;
|
|
1201
1014
|
};
|
|
1202
1015
|
|
|
1203
|
-
// src/controls/
|
|
1016
|
+
// src/controls/controls.tsx
|
|
1204
1017
|
var BoldControl = createControl({
|
|
1205
1018
|
iconKey: "boldControlIcon",
|
|
1206
1019
|
isActive: { name: "bold" },
|
|
@@ -1361,20 +1174,125 @@ var SuperscriptControl = createControl({
|
|
|
1361
1174
|
operation: { name: "toggleSuperscript" }
|
|
1362
1175
|
});
|
|
1363
1176
|
|
|
1364
|
-
// src/controls/
|
|
1365
|
-
var
|
|
1366
|
-
var
|
|
1367
|
-
var
|
|
1177
|
+
// src/controls/link-control.tsx
|
|
1178
|
+
var import_react10 = require("@tiptap/react");
|
|
1179
|
+
var React14 = __toESM(require("react"), 1);
|
|
1180
|
+
var import_react11 = require("react");
|
|
1181
|
+
|
|
1182
|
+
// src/primitives/base/button.tsx
|
|
1183
|
+
var import_button2 = require("@base-ui/react/button");
|
|
1184
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
1185
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1186
|
+
var buttonVariants = (0, import_class_variance_authority2.cva)(
|
|
1187
|
+
"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",
|
|
1188
|
+
{
|
|
1189
|
+
defaultVariants: {
|
|
1190
|
+
size: "default",
|
|
1191
|
+
variant: "default"
|
|
1192
|
+
},
|
|
1193
|
+
variants: {
|
|
1194
|
+
size: {
|
|
1195
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
1196
|
+
icon: "size-8",
|
|
1197
|
+
"icon-lg": "size-9",
|
|
1198
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
1199
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
1200
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
1201
|
+
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",
|
|
1202
|
+
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"
|
|
1203
|
+
},
|
|
1204
|
+
variant: {
|
|
1205
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
1206
|
+
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",
|
|
1207
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
1208
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
1209
|
+
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",
|
|
1210
|
+
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"
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
);
|
|
1215
|
+
var Button2 = ({
|
|
1216
|
+
className,
|
|
1217
|
+
variant = "default",
|
|
1218
|
+
size = "default",
|
|
1219
|
+
...props
|
|
1220
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1221
|
+
import_button2.Button,
|
|
1222
|
+
{
|
|
1223
|
+
"data-slot": "button",
|
|
1224
|
+
className: cn(buttonVariants({ className, size, variant })),
|
|
1225
|
+
...props
|
|
1226
|
+
}
|
|
1227
|
+
);
|
|
1228
|
+
|
|
1229
|
+
// src/primitives/base/input.tsx
|
|
1230
|
+
var import_input = require("@base-ui/react/input");
|
|
1231
|
+
var React12 = require("react");
|
|
1232
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1233
|
+
var Input = ({
|
|
1234
|
+
className,
|
|
1235
|
+
type,
|
|
1236
|
+
...props
|
|
1237
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1238
|
+
import_input.Input,
|
|
1239
|
+
{
|
|
1240
|
+
type,
|
|
1241
|
+
"data-slot": "input",
|
|
1242
|
+
className: cn(
|
|
1243
|
+
"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",
|
|
1244
|
+
className
|
|
1245
|
+
),
|
|
1246
|
+
...props
|
|
1247
|
+
}
|
|
1248
|
+
);
|
|
1249
|
+
|
|
1250
|
+
// src/primitives/base/popover.tsx
|
|
1251
|
+
var import_popover = require("@base-ui/react/popover");
|
|
1252
|
+
var React13 = require("react");
|
|
1253
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1254
|
+
var Popover = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
1255
|
+
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_popover.Popover.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
1256
|
+
var PopoverContent = ({
|
|
1257
|
+
className,
|
|
1258
|
+
align = "center",
|
|
1259
|
+
alignOffset = 0,
|
|
1260
|
+
side = "bottom",
|
|
1261
|
+
sideOffset = 4,
|
|
1262
|
+
...props
|
|
1263
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1264
|
+
import_popover.Popover.Positioner,
|
|
1265
|
+
{
|
|
1266
|
+
align,
|
|
1267
|
+
alignOffset,
|
|
1268
|
+
side,
|
|
1269
|
+
sideOffset,
|
|
1270
|
+
className: "isolate z-50",
|
|
1271
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1272
|
+
import_popover.Popover.Popup,
|
|
1273
|
+
{
|
|
1274
|
+
"data-slot": "popover-content",
|
|
1275
|
+
className: cn(
|
|
1276
|
+
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
1277
|
+
className
|
|
1278
|
+
),
|
|
1279
|
+
...props
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1282
|
+
}
|
|
1283
|
+
) });
|
|
1284
|
+
|
|
1285
|
+
// src/controls/link-control.tsx
|
|
1368
1286
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1369
1287
|
var LinkControl = () => {
|
|
1370
1288
|
const { editor, icons, labels, tooltip } = useRichTextEditorContext();
|
|
1371
|
-
const [url, setUrl] = (0,
|
|
1372
|
-
const [open, setOpen] = (0,
|
|
1373
|
-
const active = (0,
|
|
1289
|
+
const [url, setUrl] = (0, import_react11.useState)("");
|
|
1290
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
1291
|
+
const active = (0, import_react10.useEditorState)({
|
|
1374
1292
|
editor: editor ?? null,
|
|
1375
1293
|
selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
|
|
1376
1294
|
});
|
|
1377
|
-
const handleOpen = (0,
|
|
1295
|
+
const handleOpen = (0, import_react11.useCallback)(
|
|
1378
1296
|
(isOpen) => {
|
|
1379
1297
|
if (isOpen) {
|
|
1380
1298
|
const linkData = editor?.getAttributes("link");
|
|
@@ -1404,7 +1322,7 @@ var LinkControl = () => {
|
|
|
1404
1322
|
handleSave();
|
|
1405
1323
|
}
|
|
1406
1324
|
};
|
|
1407
|
-
|
|
1325
|
+
React14.useEffect(() => {
|
|
1408
1326
|
const handler = () => handleOpen(true);
|
|
1409
1327
|
window.addEventListener("edit-link", handler);
|
|
1410
1328
|
return () => window.removeEventListener("edit-link", handler);
|
|
@@ -1447,7 +1365,7 @@ var LinkControl = () => {
|
|
|
1447
1365
|
}
|
|
1448
1366
|
),
|
|
1449
1367
|
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1450
|
-
|
|
1368
|
+
Button2,
|
|
1451
1369
|
{
|
|
1452
1370
|
size: "sm",
|
|
1453
1371
|
variant: "default",
|
|
@@ -1460,19 +1378,19 @@ var LinkControl = () => {
|
|
|
1460
1378
|
] });
|
|
1461
1379
|
};
|
|
1462
1380
|
|
|
1463
|
-
// src/controls/
|
|
1381
|
+
// src/controls/twitter-control.tsx
|
|
1464
1382
|
var import_core2 = require("@tiptap/core");
|
|
1465
|
-
var
|
|
1466
|
-
var
|
|
1383
|
+
var import_react16 = require("@tiptap/react");
|
|
1384
|
+
var import_react17 = require("react");
|
|
1467
1385
|
|
|
1468
1386
|
// src/extensions/resizable-node-view.tsx
|
|
1469
|
-
var
|
|
1470
|
-
var
|
|
1387
|
+
var import_react14 = require("@tiptap/react");
|
|
1388
|
+
var import_react15 = require("react");
|
|
1471
1389
|
|
|
1472
|
-
// src/icons.tsx
|
|
1473
|
-
var
|
|
1390
|
+
// src/icons/icons.tsx
|
|
1391
|
+
var import_react13 = require("react");
|
|
1474
1392
|
|
|
1475
|
-
// src/icon-placeholder.tsx
|
|
1393
|
+
// src/icons/icon-placeholder.tsx
|
|
1476
1394
|
var import_lucide_react = require("lucide-react");
|
|
1477
1395
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1478
1396
|
var ICONS = {
|
|
@@ -1517,8 +1435,8 @@ var IconPlaceholder = ({
|
|
|
1517
1435
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Icon2, { ...props });
|
|
1518
1436
|
};
|
|
1519
1437
|
|
|
1520
|
-
// src/language-icons.tsx
|
|
1521
|
-
var
|
|
1438
|
+
// src/icons/language-icons.tsx
|
|
1439
|
+
var import_react12 = require("react");
|
|
1522
1440
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1523
1441
|
var LangIcon = ({
|
|
1524
1442
|
children,
|
|
@@ -1652,7 +1570,7 @@ var DEFAULT_LANGUAGE_ICONS = {
|
|
|
1652
1570
|
] })
|
|
1653
1571
|
};
|
|
1654
1572
|
|
|
1655
|
-
// src/icons.tsx
|
|
1573
|
+
// src/icons/icons.tsx
|
|
1656
1574
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1657
1575
|
var ALIGN_PATHS = {
|
|
1658
1576
|
center: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
@@ -2211,26 +2129,26 @@ var ResizableNodeView = ({
|
|
|
2211
2129
|
watchUrl,
|
|
2212
2130
|
onSrcChange
|
|
2213
2131
|
}) => {
|
|
2214
|
-
const containerRef = (0,
|
|
2215
|
-
const [isEditingUrl, setIsEditingUrl] = (0,
|
|
2216
|
-
const [urlInput, setUrlInput] = (0,
|
|
2217
|
-
const [isResizing, setIsResizing] = (0,
|
|
2218
|
-
const [currentDimensions, setCurrentDimensions] = (0,
|
|
2219
|
-
const resizingRef = (0,
|
|
2132
|
+
const containerRef = (0, import_react15.useRef)(null);
|
|
2133
|
+
const [isEditingUrl, setIsEditingUrl] = (0, import_react15.useState)(false);
|
|
2134
|
+
const [urlInput, setUrlInput] = (0, import_react15.useState)(videoSrc || "");
|
|
2135
|
+
const [isResizing, setIsResizing] = (0, import_react15.useState)(false);
|
|
2136
|
+
const [currentDimensions, setCurrentDimensions] = (0, import_react15.useState)(null);
|
|
2137
|
+
const resizingRef = (0, import_react15.useRef)(null);
|
|
2220
2138
|
const width = node.attrs.width;
|
|
2221
2139
|
const height = node.attrs.height;
|
|
2222
2140
|
const align = node.attrs.align || "center";
|
|
2223
|
-
const getEditorWidth = (0,
|
|
2141
|
+
const getEditorWidth = (0, import_react15.useCallback)(
|
|
2224
2142
|
() => view?.dom?.parentElement?.offsetWidth ?? 800,
|
|
2225
2143
|
[view]
|
|
2226
2144
|
);
|
|
2227
|
-
const inputRef = (0,
|
|
2228
|
-
(0,
|
|
2145
|
+
const inputRef = (0, import_react15.useRef)(null);
|
|
2146
|
+
(0, import_react15.useEffect)(() => {
|
|
2229
2147
|
if (isEditingUrl) {
|
|
2230
2148
|
inputRef.current?.focus();
|
|
2231
2149
|
}
|
|
2232
2150
|
}, [isEditingUrl]);
|
|
2233
|
-
const handleMouseMove = (0,
|
|
2151
|
+
const handleMouseMove = (0, import_react15.useCallback)(
|
|
2234
2152
|
(e) => {
|
|
2235
2153
|
const resize = resizingRef.current;
|
|
2236
2154
|
if (!resize) {
|
|
@@ -2280,7 +2198,7 @@ var ResizableNodeView = ({
|
|
|
2280
2198
|
},
|
|
2281
2199
|
[lockAspect, aspectRatio, minWidth, maxWidth]
|
|
2282
2200
|
);
|
|
2283
|
-
const handleMouseUp = (0,
|
|
2201
|
+
const handleMouseUp = (0, import_react15.useCallback)(
|
|
2284
2202
|
function handleMouseUp2() {
|
|
2285
2203
|
const resize = resizingRef.current;
|
|
2286
2204
|
if (!resize) {
|
|
@@ -2301,7 +2219,7 @@ var ResizableNodeView = ({
|
|
|
2301
2219
|
},
|
|
2302
2220
|
[handleMouseMove, updateAttributes]
|
|
2303
2221
|
);
|
|
2304
|
-
const handleMouseDown = (0,
|
|
2222
|
+
const handleMouseDown = (0, import_react15.useCallback)(
|
|
2305
2223
|
(e, direction) => {
|
|
2306
2224
|
e.preventDefault();
|
|
2307
2225
|
e.stopPropagation();
|
|
@@ -2332,7 +2250,7 @@ var ResizableNodeView = ({
|
|
|
2332
2250
|
},
|
|
2333
2251
|
[width, height, getEditorWidth, handleMouseMove, handleMouseUp]
|
|
2334
2252
|
);
|
|
2335
|
-
(0,
|
|
2253
|
+
(0, import_react15.useEffect)(
|
|
2336
2254
|
() => () => {
|
|
2337
2255
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
2338
2256
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -2361,7 +2279,7 @@ var ResizableNodeView = ({
|
|
|
2361
2279
|
};
|
|
2362
2280
|
const isEditable = editor ? editor.isEditable : true;
|
|
2363
2281
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2364
|
-
|
|
2282
|
+
import_react14.NodeViewWrapper,
|
|
2365
2283
|
{
|
|
2366
2284
|
className: "rte-embed-wrapper group/embed",
|
|
2367
2285
|
"data-selected": selected || void 0,
|
|
@@ -2459,8 +2377,121 @@ var ResizableNodeView = ({
|
|
|
2459
2377
|
);
|
|
2460
2378
|
};
|
|
2461
2379
|
|
|
2462
|
-
// src/
|
|
2380
|
+
// src/primitives/base/dialog.tsx
|
|
2381
|
+
var import_dialog = require("@base-ui/react/dialog");
|
|
2382
|
+
var React17 = require("react");
|
|
2463
2383
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2384
|
+
var Dialog = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
|
|
2385
|
+
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
2386
|
+
var DialogPortal = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
|
|
2387
|
+
var DialogClose = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
|
|
2388
|
+
var DialogOverlay = ({
|
|
2389
|
+
className,
|
|
2390
|
+
...props
|
|
2391
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2392
|
+
import_dialog.Dialog.Backdrop,
|
|
2393
|
+
{
|
|
2394
|
+
"data-slot": "dialog-overlay",
|
|
2395
|
+
className: cn(
|
|
2396
|
+
"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",
|
|
2397
|
+
className
|
|
2398
|
+
),
|
|
2399
|
+
...props
|
|
2400
|
+
}
|
|
2401
|
+
);
|
|
2402
|
+
var DialogContent = ({
|
|
2403
|
+
className,
|
|
2404
|
+
children,
|
|
2405
|
+
showCloseButton = true,
|
|
2406
|
+
...props
|
|
2407
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(DialogPortal, { children: [
|
|
2408
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DialogOverlay, {}),
|
|
2409
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2410
|
+
import_dialog.Dialog.Popup,
|
|
2411
|
+
{
|
|
2412
|
+
"data-slot": "dialog-content",
|
|
2413
|
+
className: cn(
|
|
2414
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-xs/relaxed text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
2415
|
+
className
|
|
2416
|
+
),
|
|
2417
|
+
...props,
|
|
2418
|
+
children: [
|
|
2419
|
+
children,
|
|
2420
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2421
|
+
import_dialog.Dialog.Close,
|
|
2422
|
+
{
|
|
2423
|
+
"data-slot": "dialog-close",
|
|
2424
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2425
|
+
Button2,
|
|
2426
|
+
{
|
|
2427
|
+
variant: "ghost",
|
|
2428
|
+
className: "absolute top-2 right-2",
|
|
2429
|
+
size: "icon-sm"
|
|
2430
|
+
}
|
|
2431
|
+
),
|
|
2432
|
+
children: [
|
|
2433
|
+
"X",
|
|
2434
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "sr-only", children: "Close" })
|
|
2435
|
+
]
|
|
2436
|
+
}
|
|
2437
|
+
)
|
|
2438
|
+
]
|
|
2439
|
+
}
|
|
2440
|
+
)
|
|
2441
|
+
] });
|
|
2442
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2443
|
+
"div",
|
|
2444
|
+
{
|
|
2445
|
+
"data-slot": "dialog-header",
|
|
2446
|
+
className: cn("flex flex-col gap-1 text-left", className),
|
|
2447
|
+
...props
|
|
2448
|
+
}
|
|
2449
|
+
);
|
|
2450
|
+
var DialogFooter = ({
|
|
2451
|
+
className,
|
|
2452
|
+
showCloseButton = false,
|
|
2453
|
+
children,
|
|
2454
|
+
...props
|
|
2455
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2456
|
+
"div",
|
|
2457
|
+
{
|
|
2458
|
+
"data-slot": "dialog-footer",
|
|
2459
|
+
className: cn(
|
|
2460
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
2461
|
+
className
|
|
2462
|
+
),
|
|
2463
|
+
...props,
|
|
2464
|
+
children: [
|
|
2465
|
+
children,
|
|
2466
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Button2, { variant: "outline" }), children: "Close" })
|
|
2467
|
+
]
|
|
2468
|
+
}
|
|
2469
|
+
);
|
|
2470
|
+
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2471
|
+
import_dialog.Dialog.Title,
|
|
2472
|
+
{
|
|
2473
|
+
"data-slot": "dialog-title",
|
|
2474
|
+
className: cn("text-sm font-medium", className),
|
|
2475
|
+
...props
|
|
2476
|
+
}
|
|
2477
|
+
);
|
|
2478
|
+
var DialogDescription = ({
|
|
2479
|
+
className,
|
|
2480
|
+
...props
|
|
2481
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2482
|
+
import_dialog.Dialog.Description,
|
|
2483
|
+
{
|
|
2484
|
+
"data-slot": "dialog-description",
|
|
2485
|
+
className: cn(
|
|
2486
|
+
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
2487
|
+
className
|
|
2488
|
+
),
|
|
2489
|
+
...props
|
|
2490
|
+
}
|
|
2491
|
+
);
|
|
2492
|
+
|
|
2493
|
+
// src/controls/twitter-control.tsx
|
|
2494
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2464
2495
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
2465
2496
|
var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
|
|
2466
2497
|
var READY_POLL_INTERVAL_MS = 50;
|
|
@@ -2536,15 +2567,15 @@ var loadTwitterScript = () => {
|
|
|
2536
2567
|
};
|
|
2537
2568
|
var TwitterNodeView = (props) => {
|
|
2538
2569
|
const { node } = props;
|
|
2539
|
-
const containerRef = (0,
|
|
2540
|
-
const [loading, setLoading] = (0,
|
|
2541
|
-
const [failed, setFailed] = (0,
|
|
2570
|
+
const containerRef = (0, import_react17.useRef)(null);
|
|
2571
|
+
const [loading, setLoading] = (0, import_react17.useState)(true);
|
|
2572
|
+
const [failed, setFailed] = (0, import_react17.useState)(false);
|
|
2542
2573
|
const { tweetId } = node.attrs;
|
|
2543
|
-
const renderedTweetIdRef = (0,
|
|
2544
|
-
const activeRenderIdRef = (0,
|
|
2545
|
-
const retryToken = (0,
|
|
2546
|
-
const [retryCount, setRetryCount] = (0,
|
|
2547
|
-
(0,
|
|
2574
|
+
const renderedTweetIdRef = (0, import_react17.useRef)(null);
|
|
2575
|
+
const activeRenderIdRef = (0, import_react17.useRef)(0);
|
|
2576
|
+
const retryToken = (0, import_react17.useRef)(0);
|
|
2577
|
+
const [retryCount, setRetryCount] = (0, import_react17.useState)(0);
|
|
2578
|
+
(0, import_react17.useEffect)(() => {
|
|
2548
2579
|
if (!containerRef.current || !tweetId) {
|
|
2549
2580
|
return;
|
|
2550
2581
|
}
|
|
@@ -2603,11 +2634,11 @@ var TwitterNodeView = (props) => {
|
|
|
2603
2634
|
isCancelled = true;
|
|
2604
2635
|
};
|
|
2605
2636
|
}, [tweetId, retryCount, failed]);
|
|
2606
|
-
const handleRetry = (0,
|
|
2637
|
+
const handleRetry = (0, import_react17.useCallback)(() => {
|
|
2607
2638
|
retryToken.current += 1;
|
|
2608
2639
|
setRetryCount(retryToken.current);
|
|
2609
2640
|
}, []);
|
|
2610
|
-
return /* @__PURE__ */ (0,
|
|
2641
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2611
2642
|
ResizableNodeView,
|
|
2612
2643
|
{
|
|
2613
2644
|
...props,
|
|
@@ -2615,12 +2646,12 @@ var TwitterNodeView = (props) => {
|
|
|
2615
2646
|
minWidth: 300,
|
|
2616
2647
|
maxWidth: 1200,
|
|
2617
2648
|
children: [
|
|
2618
|
-
loading && /* @__PURE__ */ (0,
|
|
2619
|
-
!loading && failed && /* @__PURE__ */ (0,
|
|
2620
|
-
/* @__PURE__ */ (0,
|
|
2621
|
-
/* @__PURE__ */ (0,
|
|
2649
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "rte-embed-loading animate-pulse", children: "Loading tweet..." }),
|
|
2650
|
+
!loading && failed && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "rte-embed-error", children: [
|
|
2651
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: "Couldn't load this tweet." }),
|
|
2652
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", onClick: handleRetry, children: "Retry" })
|
|
2622
2653
|
] }),
|
|
2623
|
-
/* @__PURE__ */ (0,
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { ref: containerRef })
|
|
2624
2655
|
]
|
|
2625
2656
|
}
|
|
2626
2657
|
);
|
|
@@ -2690,7 +2721,7 @@ var TwitterEmbed = import_core2.Node.create({
|
|
|
2690
2721
|
];
|
|
2691
2722
|
},
|
|
2692
2723
|
addNodeView() {
|
|
2693
|
-
return (0,
|
|
2724
|
+
return (0, import_react16.ReactNodeViewRenderer)(TwitterNodeView);
|
|
2694
2725
|
},
|
|
2695
2726
|
atom: true,
|
|
2696
2727
|
draggable: true,
|
|
@@ -2724,10 +2755,10 @@ var extractTweetId = (input) => {
|
|
|
2724
2755
|
};
|
|
2725
2756
|
var TwitterEmbedControl = ({ className }) => {
|
|
2726
2757
|
const { editor } = useRichTextEditorContext();
|
|
2727
|
-
const [open, setOpen] = (0,
|
|
2728
|
-
const [url, setUrl] = (0,
|
|
2729
|
-
const [touched, setTouched] = (0,
|
|
2730
|
-
const { active } = (0,
|
|
2758
|
+
const [open, setOpen] = (0, import_react17.useState)(false);
|
|
2759
|
+
const [url, setUrl] = (0, import_react17.useState)("");
|
|
2760
|
+
const [touched, setTouched] = (0, import_react17.useState)(false);
|
|
2761
|
+
const { active } = (0, import_react16.useEditorState)({
|
|
2731
2762
|
editor: editor ?? null,
|
|
2732
2763
|
selector: (ctx) => ({
|
|
2733
2764
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
|
|
@@ -2735,11 +2766,11 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2735
2766
|
}) ?? { active: false };
|
|
2736
2767
|
const tweetId = url ? extractTweetId(url) : null;
|
|
2737
2768
|
const showError = touched && url.length > 0 && !tweetId;
|
|
2738
|
-
const resetState = (0,
|
|
2769
|
+
const resetState = (0, import_react17.useCallback)(() => {
|
|
2739
2770
|
setUrl("");
|
|
2740
2771
|
setTouched(false);
|
|
2741
2772
|
}, []);
|
|
2742
|
-
const handleInsert = (0,
|
|
2773
|
+
const handleInsert = (0, import_react17.useCallback)(() => {
|
|
2743
2774
|
setTouched(true);
|
|
2744
2775
|
if (!tweetId || !editor) {
|
|
2745
2776
|
return false;
|
|
@@ -2748,7 +2779,7 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2748
2779
|
resetState();
|
|
2749
2780
|
return true;
|
|
2750
2781
|
}, [tweetId, editor, resetState]);
|
|
2751
|
-
return /* @__PURE__ */ (0,
|
|
2782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2752
2783
|
Dialog,
|
|
2753
2784
|
{
|
|
2754
2785
|
open,
|
|
@@ -2759,36 +2790,36 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2759
2790
|
}
|
|
2760
2791
|
},
|
|
2761
2792
|
children: [
|
|
2762
|
-
/* @__PURE__ */ (0,
|
|
2793
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2763
2794
|
DialogTrigger,
|
|
2764
2795
|
{
|
|
2765
|
-
render: /* @__PURE__ */ (0,
|
|
2796
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2766
2797
|
RichTextEditorControl,
|
|
2767
2798
|
{
|
|
2768
2799
|
active,
|
|
2769
2800
|
className,
|
|
2770
2801
|
title: "Embed Tweet",
|
|
2771
2802
|
"aria-label": "Embed Tweet",
|
|
2772
|
-
children: /* @__PURE__ */ (0,
|
|
2803
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2773
2804
|
"svg",
|
|
2774
2805
|
{
|
|
2775
2806
|
xmlns: "http://www.w3.org/2000/svg",
|
|
2776
2807
|
viewBox: "0 0 24 24",
|
|
2777
2808
|
fill: "currentColor",
|
|
2778
2809
|
className: "rte-editor-icon",
|
|
2779
|
-
children: /* @__PURE__ */ (0,
|
|
2810
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("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" })
|
|
2780
2811
|
}
|
|
2781
2812
|
)
|
|
2782
2813
|
}
|
|
2783
2814
|
)
|
|
2784
2815
|
}
|
|
2785
2816
|
),
|
|
2786
|
-
/* @__PURE__ */ (0,
|
|
2787
|
-
/* @__PURE__ */ (0,
|
|
2788
|
-
/* @__PURE__ */ (0,
|
|
2789
|
-
/* @__PURE__ */ (0,
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(DialogContent, { children: [
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(DialogHeader, { children: [
|
|
2819
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DialogTitle, { children: "Embed Tweet" }),
|
|
2820
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
2790
2821
|
] }),
|
|
2791
|
-
/* @__PURE__ */ (0,
|
|
2822
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2792
2823
|
Input,
|
|
2793
2824
|
{
|
|
2794
2825
|
value: url,
|
|
@@ -2808,10 +2839,10 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2808
2839
|
}
|
|
2809
2840
|
}
|
|
2810
2841
|
),
|
|
2811
|
-
showError && /* @__PURE__ */ (0,
|
|
2812
|
-
/* @__PURE__ */ (0,
|
|
2813
|
-
/* @__PURE__ */ (0,
|
|
2814
|
-
/* @__PURE__ */ (0,
|
|
2842
|
+
showError && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
|
|
2843
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(DialogFooter, { children: [
|
|
2844
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DialogClose, { children: "Cancel" }),
|
|
2845
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2815
2846
|
"button",
|
|
2816
2847
|
{
|
|
2817
2848
|
type: "button",
|
|
@@ -2832,11 +2863,11 @@ var TwitterEmbedControl = ({ className }) => {
|
|
|
2832
2863
|
);
|
|
2833
2864
|
};
|
|
2834
2865
|
|
|
2835
|
-
// src/controls/
|
|
2866
|
+
// src/controls/youtube-control.tsx
|
|
2836
2867
|
var import_core3 = require("@tiptap/core");
|
|
2837
|
-
var
|
|
2838
|
-
var
|
|
2839
|
-
var
|
|
2868
|
+
var import_react18 = require("@tiptap/react");
|
|
2869
|
+
var import_react19 = require("react");
|
|
2870
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2840
2871
|
var getYouTubeId = (url) => {
|
|
2841
2872
|
const clean = url.trim();
|
|
2842
2873
|
const patterns = [
|
|
@@ -2864,7 +2895,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2864
2895
|
if (videoId) {
|
|
2865
2896
|
watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
|
|
2866
2897
|
}
|
|
2867
|
-
return /* @__PURE__ */ (0,
|
|
2898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2868
2899
|
ResizableNodeView,
|
|
2869
2900
|
{
|
|
2870
2901
|
...props,
|
|
@@ -2875,7 +2906,7 @@ var YouTubeNodeView = (props) => {
|
|
|
2875
2906
|
videoSrc: rawSrc,
|
|
2876
2907
|
watchUrl,
|
|
2877
2908
|
onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
|
|
2878
|
-
children: /* @__PURE__ */ (0,
|
|
2909
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2879
2910
|
"iframe",
|
|
2880
2911
|
{
|
|
2881
2912
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -2953,7 +2984,7 @@ var YouTubeEmbed = import_core3.Node.create({
|
|
|
2953
2984
|
];
|
|
2954
2985
|
},
|
|
2955
2986
|
addNodeView() {
|
|
2956
|
-
return (0,
|
|
2987
|
+
return (0, import_react18.ReactNodeViewRenderer)(YouTubeNodeView);
|
|
2957
2988
|
},
|
|
2958
2989
|
atom: true,
|
|
2959
2990
|
draggable: true,
|
|
@@ -2977,32 +3008,32 @@ var YouTubeEmbed = import_core3.Node.create({
|
|
|
2977
3008
|
});
|
|
2978
3009
|
var YouTubeEmbedControl = ({ className }) => {
|
|
2979
3010
|
const { editor } = useRichTextEditorContext();
|
|
2980
|
-
const [open, setOpen] = (0,
|
|
2981
|
-
const [url, setUrl] = (0,
|
|
2982
|
-
const { active } = (0,
|
|
3011
|
+
const [open, setOpen] = (0, import_react19.useState)(false);
|
|
3012
|
+
const [url, setUrl] = (0, import_react19.useState)("");
|
|
3013
|
+
const { active } = (0, import_react18.useEditorState)({
|
|
2983
3014
|
editor: editor ?? null,
|
|
2984
3015
|
selector: (ctx) => ({
|
|
2985
3016
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
|
|
2986
3017
|
})
|
|
2987
3018
|
}) ?? { active: false };
|
|
2988
|
-
const handleInsert = (0,
|
|
3019
|
+
const handleInsert = (0, import_react19.useCallback)(() => {
|
|
2989
3020
|
if (url && editor) {
|
|
2990
3021
|
editor.chain().focus().setYouTubeEmbed(url).run();
|
|
2991
3022
|
setUrl("");
|
|
2992
3023
|
}
|
|
2993
3024
|
}, [url, editor]);
|
|
2994
|
-
return /* @__PURE__ */ (0,
|
|
2995
|
-
/* @__PURE__ */ (0,
|
|
3025
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
|
|
3026
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2996
3027
|
DialogTrigger,
|
|
2997
3028
|
{
|
|
2998
|
-
render: /* @__PURE__ */ (0,
|
|
3029
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2999
3030
|
RichTextEditorControl,
|
|
3000
3031
|
{
|
|
3001
3032
|
active,
|
|
3002
3033
|
className,
|
|
3003
3034
|
title: "Embed YouTube video",
|
|
3004
3035
|
"aria-label": "Embed YouTube video",
|
|
3005
|
-
children: /* @__PURE__ */ (0,
|
|
3036
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3006
3037
|
"svg",
|
|
3007
3038
|
{
|
|
3008
3039
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -3014,8 +3045,8 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3014
3045
|
strokeLinejoin: "round",
|
|
3015
3046
|
className: "rte-editor-icon",
|
|
3016
3047
|
children: [
|
|
3017
|
-
/* @__PURE__ */ (0,
|
|
3018
|
-
/* @__PURE__ */ (0,
|
|
3048
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("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" }),
|
|
3049
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
3019
3050
|
]
|
|
3020
3051
|
}
|
|
3021
3052
|
)
|
|
@@ -3023,12 +3054,12 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3023
3054
|
)
|
|
3024
3055
|
}
|
|
3025
3056
|
),
|
|
3026
|
-
/* @__PURE__ */ (0,
|
|
3027
|
-
/* @__PURE__ */ (0,
|
|
3028
|
-
/* @__PURE__ */ (0,
|
|
3029
|
-
/* @__PURE__ */ (0,
|
|
3057
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(DialogContent, { showCloseButton: false, children: [
|
|
3058
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(DialogHeader, { children: [
|
|
3059
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DialogTitle, { children: "Embed YouTube video" }),
|
|
3060
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
3030
3061
|
] }),
|
|
3031
|
-
/* @__PURE__ */ (0,
|
|
3062
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3032
3063
|
Input,
|
|
3033
3064
|
{
|
|
3034
3065
|
value: url,
|
|
@@ -3042,9 +3073,9 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3042
3073
|
}
|
|
3043
3074
|
}
|
|
3044
3075
|
),
|
|
3045
|
-
/* @__PURE__ */ (0,
|
|
3046
|
-
/* @__PURE__ */ (0,
|
|
3047
|
-
/* @__PURE__ */ (0,
|
|
3076
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(DialogFooter, { children: [
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(DialogClose, { children: "Cancel" }),
|
|
3078
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3048
3079
|
DialogClose,
|
|
3049
3080
|
{
|
|
3050
3081
|
disabled: !url,
|
|
@@ -3058,7 +3089,7 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
3058
3089
|
] });
|
|
3059
3090
|
};
|
|
3060
3091
|
|
|
3061
|
-
// src/labels.ts
|
|
3092
|
+
// src/core/labels.ts
|
|
3062
3093
|
var DEFAULT_LABELS = {
|
|
3063
3094
|
alignCenterControlLabel: "Align center",
|
|
3064
3095
|
alignJustifyControlLabel: "Align justify",
|
|
@@ -3099,63 +3130,9 @@ var DEFAULT_LABELS = {
|
|
|
3099
3130
|
unlinkControlLabel: "Remove link"
|
|
3100
3131
|
};
|
|
3101
3132
|
|
|
3102
|
-
// src/
|
|
3103
|
-
var import_react19 = require("@tiptap/react");
|
|
3104
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3105
|
-
var Content = ({
|
|
3106
|
-
children,
|
|
3107
|
-
className
|
|
3108
|
-
}) => {
|
|
3109
|
-
const { editor, preset, variant } = useRichTextEditorContext();
|
|
3110
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "relative", children: [
|
|
3111
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3112
|
-
import_react19.EditorContent,
|
|
3113
|
-
{
|
|
3114
|
-
editor,
|
|
3115
|
-
className: cn(
|
|
3116
|
-
"rte-content editorcn-content w-full",
|
|
3117
|
-
variant === "default" && "rounded-lg border border-(--rte-hairline) bg-[var(--card,var(--background))]",
|
|
3118
|
-
className
|
|
3119
|
-
),
|
|
3120
|
-
"data-preset": preset,
|
|
3121
|
-
spellCheck: false
|
|
3122
|
-
}
|
|
3123
|
-
),
|
|
3124
|
-
children
|
|
3125
|
-
] });
|
|
3126
|
-
};
|
|
3127
|
-
|
|
3128
|
-
// src/rte-controls-group.tsx
|
|
3133
|
+
// src/footer.tsx
|
|
3129
3134
|
var import_react20 = require("react");
|
|
3130
3135
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
3131
|
-
var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-[''] [.rte-controls-group+&]:data-line-start:before:invisible";
|
|
3132
|
-
var BUTTON = "[&>button]:border-none [&>button]:bg-transparent [&>button]:transition-[background-color,color] [&>button]:duration-150 [&>button]:ease-[ease-out] [&>button:focus-visible]:outline-2 [&>button:focus-visible]:outline-offset-1 [&>button:focus-visible]:outline-ring/50 [&>button:focus-visible]:outline-solid";
|
|
3133
|
-
var variantClasses = {
|
|
3134
|
-
compact: `${SEPARATOR} [.rte-controls-group+&]:before:mx-0.5 [.rte-controls-group+&]:before:h-3.5 ${BUTTON} [&>button]:h-7 [&>button]:min-w-7 [&>button]:rounded-sm [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`,
|
|
3135
|
-
default: `gap-0.5 ${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-foreground [&>button:disabled]:cursor-not-allowed [&>button:disabled]:opacity-40 [&>button:hover:not(:disabled)]:bg-foreground/5 [&>button:hover:not(:disabled)]:text-foreground [&>button[aria-pressed=true]]:bg-foreground/8 [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-foreground/8 [&>button[data-state=on]]:text-foreground`,
|
|
3136
|
-
subtle: `${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`
|
|
3137
|
-
};
|
|
3138
|
-
var ControlsGroup = ({
|
|
3139
|
-
children,
|
|
3140
|
-
className
|
|
3141
|
-
}) => {
|
|
3142
|
-
const variant = (0, import_react20.useContext)(RichTextEditorContext)?.variant;
|
|
3143
|
-
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3144
|
-
"div",
|
|
3145
|
-
{
|
|
3146
|
-
className: cn(
|
|
3147
|
-
"rte-controls-group flex items-center empty:hidden",
|
|
3148
|
-
variant && variantClasses[variant],
|
|
3149
|
-
className
|
|
3150
|
-
),
|
|
3151
|
-
children
|
|
3152
|
-
}
|
|
3153
|
-
);
|
|
3154
|
-
};
|
|
3155
|
-
|
|
3156
|
-
// src/rte-footer.tsx
|
|
3157
|
-
var import_react21 = require("react");
|
|
3158
|
-
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3159
3136
|
var Footer = ({
|
|
3160
3137
|
children,
|
|
3161
3138
|
className,
|
|
@@ -3166,9 +3143,9 @@ var Footer = ({
|
|
|
3166
3143
|
wordCountFormatter
|
|
3167
3144
|
}) => {
|
|
3168
3145
|
const { editor, variant } = useRichTextEditorContext();
|
|
3169
|
-
const [, forceUpdate] = (0,
|
|
3170
|
-
const rafRef = (0,
|
|
3171
|
-
(0,
|
|
3146
|
+
const [, forceUpdate] = (0, import_react20.useState)(0);
|
|
3147
|
+
const rafRef = (0, import_react20.useRef)(null);
|
|
3148
|
+
(0, import_react20.useEffect)(() => {
|
|
3172
3149
|
if (!editor || !showWordCount) {
|
|
3173
3150
|
return;
|
|
3174
3151
|
}
|
|
@@ -3197,7 +3174,7 @@ var Footer = ({
|
|
|
3197
3174
|
}
|
|
3198
3175
|
};
|
|
3199
3176
|
}, [editor, showWordCount]);
|
|
3200
|
-
const wordCount = (0,
|
|
3177
|
+
const wordCount = (0, import_react20.useMemo)(() => {
|
|
3201
3178
|
if (!editor || !showWordCount) {
|
|
3202
3179
|
return null;
|
|
3203
3180
|
}
|
|
@@ -3214,7 +3191,7 @@ var Footer = ({
|
|
|
3214
3191
|
if (!showWordCount && !children) {
|
|
3215
3192
|
return null;
|
|
3216
3193
|
}
|
|
3217
|
-
return /* @__PURE__ */ (0,
|
|
3194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
3218
3195
|
"div",
|
|
3219
3196
|
{
|
|
3220
3197
|
className: cn(
|
|
@@ -3228,28 +3205,28 @@ var Footer = ({
|
|
|
3228
3205
|
"data-sticky": sticky ? "" : void 0,
|
|
3229
3206
|
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
3230
3207
|
children: [
|
|
3231
|
-
showWordCount && wordCount && /* @__PURE__ */ (0,
|
|
3208
|
+
showWordCount && wordCount && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3232
3209
|
"span",
|
|
3233
3210
|
{
|
|
3234
3211
|
className: cn(
|
|
3235
3212
|
"rte-footer-word-count inline-flex items-center gap-1.5 text-[0.75rem] whitespace-nowrap",
|
|
3236
3213
|
wordCountClassName
|
|
3237
3214
|
),
|
|
3238
|
-
children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ (0,
|
|
3239
|
-
/* @__PURE__ */ (0,
|
|
3240
|
-
/* @__PURE__ */ (0,
|
|
3241
|
-
/* @__PURE__ */ (0,
|
|
3215
|
+
children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_jsx_runtime29.Fragment, { children: [
|
|
3216
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "rte-footer-word-count-stat inline-flex items-baseline gap-1", children: [
|
|
3217
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "rte-footer-word-count-number font-medium text-foreground tabular-nums", children: wordCount.words }),
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "rte-footer-word-count-unit text-muted-foreground", children: "words" })
|
|
3242
3219
|
] }),
|
|
3243
|
-
/* @__PURE__ */ (0,
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
3244
3221
|
"span",
|
|
3245
3222
|
{
|
|
3246
3223
|
className: "rte-footer-word-count-separator size-[3px] shrink-0 rounded-full bg-[color-mix(in_srgb,var(--muted-foreground)_45%,transparent)]",
|
|
3247
3224
|
"aria-hidden": "true"
|
|
3248
3225
|
}
|
|
3249
3226
|
),
|
|
3250
|
-
/* @__PURE__ */ (0,
|
|
3251
|
-
/* @__PURE__ */ (0,
|
|
3252
|
-
/* @__PURE__ */ (0,
|
|
3227
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "rte-footer-word-count-stat inline-flex items-baseline gap-1", children: [
|
|
3228
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "rte-footer-word-count-number font-medium text-foreground tabular-nums", children: wordCount.characters }),
|
|
3229
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "rte-footer-word-count-unit text-muted-foreground", children: "characters" })
|
|
3253
3230
|
] })
|
|
3254
3231
|
] })
|
|
3255
3232
|
}
|
|
@@ -3260,7 +3237,35 @@ var Footer = ({
|
|
|
3260
3237
|
);
|
|
3261
3238
|
};
|
|
3262
3239
|
|
|
3263
|
-
// src/
|
|
3240
|
+
// src/toolbar/controls-group.tsx
|
|
3241
|
+
var import_react21 = require("react");
|
|
3242
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3243
|
+
var SEPARATOR = "[.rte-controls-group+&]:before:w-px [.rte-controls-group+&]:before:shrink-0 [.rte-controls-group+&]:before:bg-border [.rte-controls-group+&]:before:content-[''] [.rte-controls-group+&]:data-line-start:before:invisible";
|
|
3244
|
+
var BUTTON = "[&>button]:border-none [&>button]:bg-transparent [&>button]:transition-[background-color,color] [&>button]:duration-150 [&>button]:ease-[ease-out] [&>button:focus-visible]:outline-2 [&>button:focus-visible]:outline-offset-1 [&>button:focus-visible]:outline-ring/50 [&>button:focus-visible]:outline-solid";
|
|
3245
|
+
var variantClasses = {
|
|
3246
|
+
compact: `${SEPARATOR} [.rte-controls-group+&]:before:mx-0.5 [.rte-controls-group+&]:before:h-3.5 ${BUTTON} [&>button]:h-7 [&>button]:min-w-7 [&>button]:rounded-sm [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`,
|
|
3247
|
+
default: `gap-0.5 ${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-foreground [&>button:disabled]:cursor-not-allowed [&>button:disabled]:opacity-40 [&>button:hover:not(:disabled)]:bg-foreground/5 [&>button:hover:not(:disabled)]:text-foreground [&>button[aria-pressed=true]]:bg-foreground/8 [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-foreground/8 [&>button[data-state=on]]:text-foreground`,
|
|
3248
|
+
subtle: `${SEPARATOR} [.rte-controls-group+&]:before:mx-1 [.rte-controls-group+&]:before:h-4 ${BUTTON} [&>button]:h-8 [&>button]:min-w-8 [&>button]:rounded-md [&>button]:text-muted-foreground [&>button:hover]:bg-muted [&>button:hover]:text-foreground [&>button[aria-pressed=true]]:bg-muted [&>button[aria-pressed=true]]:text-foreground [&>button[data-state=on]]:bg-muted [&>button[data-state=on]]:text-foreground`
|
|
3249
|
+
};
|
|
3250
|
+
var ControlsGroup = ({
|
|
3251
|
+
children,
|
|
3252
|
+
className
|
|
3253
|
+
}) => {
|
|
3254
|
+
const variant = (0, import_react21.useContext)(RichTextEditorContext)?.variant;
|
|
3255
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3256
|
+
"div",
|
|
3257
|
+
{
|
|
3258
|
+
className: cn(
|
|
3259
|
+
"rte-controls-group flex items-center empty:hidden",
|
|
3260
|
+
variant && variantClasses[variant],
|
|
3261
|
+
className
|
|
3262
|
+
),
|
|
3263
|
+
children
|
|
3264
|
+
}
|
|
3265
|
+
);
|
|
3266
|
+
};
|
|
3267
|
+
|
|
3268
|
+
// src/toolbar/toolbar.tsx
|
|
3264
3269
|
var import_react22 = require("react");
|
|
3265
3270
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3266
3271
|
var GROUPS = ":scope > .rte-controls-group";
|
|
@@ -3338,7 +3343,7 @@ var Toolbar = ({
|
|
|
3338
3343
|
);
|
|
3339
3344
|
};
|
|
3340
3345
|
|
|
3341
|
-
// src/
|
|
3346
|
+
// src/rich-text-editor.tsx
|
|
3342
3347
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3343
3348
|
var RichTextEditorRoot = ({
|
|
3344
3349
|
editor,
|