@editorcn/editor 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1669 -827
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1643 -801
- package/dist/index.js.map +1 -1
- package/dist/style.css +291 -8
- package/package.json +65 -65
package/dist/index.cjs
CHANGED
|
@@ -44,28 +44,545 @@ __export(index_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(index_exports);
|
|
45
45
|
|
|
46
46
|
// src/rte-text-editor.tsx
|
|
47
|
-
var
|
|
47
|
+
var import_react20 = require("react");
|
|
48
48
|
|
|
49
49
|
// src/bubble-menu/index.tsx
|
|
50
50
|
var import_core = require("@tiptap/core");
|
|
51
51
|
var import_menus = require("@tiptap/react/menus");
|
|
52
|
-
var
|
|
52
|
+
var import_react6 = require("react");
|
|
53
53
|
|
|
54
|
-
// src/
|
|
55
|
-
var
|
|
54
|
+
// src/ui/button.tsx
|
|
55
|
+
var import_button = require("@base-ui/react/button");
|
|
56
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
56
57
|
|
|
57
|
-
// src/
|
|
58
|
+
// src/ui/utils.ts
|
|
59
|
+
var import_clsx = require("clsx");
|
|
60
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
61
|
+
var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
62
|
+
|
|
63
|
+
// src/ui/button.tsx
|
|
64
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
|
+
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
66
|
+
"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",
|
|
67
|
+
{
|
|
68
|
+
defaultVariants: {
|
|
69
|
+
size: "default",
|
|
70
|
+
variant: "default"
|
|
71
|
+
},
|
|
72
|
+
variants: {
|
|
73
|
+
size: {
|
|
74
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
75
|
+
icon: "size-8",
|
|
76
|
+
"icon-lg": "size-9",
|
|
77
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
78
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
79
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
80
|
+
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",
|
|
81
|
+
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"
|
|
82
|
+
},
|
|
83
|
+
variant: {
|
|
84
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
85
|
+
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",
|
|
86
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
87
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
88
|
+
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",
|
|
89
|
+
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"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
var Button = ({
|
|
95
|
+
className,
|
|
96
|
+
variant = "default",
|
|
97
|
+
size = "default",
|
|
98
|
+
...props
|
|
99
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
100
|
+
import_button.Button,
|
|
101
|
+
{
|
|
102
|
+
"data-slot": "button",
|
|
103
|
+
className: cn(buttonVariants({ className, size, variant })),
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
// src/ui/dialog.tsx
|
|
109
|
+
var import_dialog = require("@base-ui/react/dialog");
|
|
110
|
+
var React = require("react");
|
|
111
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
112
|
+
var Dialog = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
|
|
113
|
+
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
114
|
+
var DialogPortal = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
|
|
115
|
+
var DialogClose = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
|
|
116
|
+
var DialogOverlay = ({
|
|
117
|
+
className,
|
|
118
|
+
...props
|
|
119
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
120
|
+
import_dialog.Dialog.Backdrop,
|
|
121
|
+
{
|
|
122
|
+
"data-slot": "dialog-overlay",
|
|
123
|
+
className: cn(
|
|
124
|
+
"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",
|
|
125
|
+
className
|
|
126
|
+
),
|
|
127
|
+
...props
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
var DialogContent = ({
|
|
131
|
+
className,
|
|
132
|
+
children,
|
|
133
|
+
showCloseButton = true,
|
|
134
|
+
...props
|
|
135
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(DialogPortal, { children: [
|
|
136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogOverlay, {}),
|
|
137
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
138
|
+
import_dialog.Dialog.Popup,
|
|
139
|
+
{
|
|
140
|
+
"data-slot": "dialog-content",
|
|
141
|
+
className: cn(
|
|
142
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-none bg-popover p-4 text-xs/relaxed text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
143
|
+
className
|
|
144
|
+
),
|
|
145
|
+
...props,
|
|
146
|
+
children: [
|
|
147
|
+
children,
|
|
148
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
149
|
+
import_dialog.Dialog.Close,
|
|
150
|
+
{
|
|
151
|
+
"data-slot": "dialog-close",
|
|
152
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
153
|
+
Button,
|
|
154
|
+
{
|
|
155
|
+
variant: "ghost",
|
|
156
|
+
className: "absolute top-2 right-2",
|
|
157
|
+
size: "icon-sm"
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
children: [
|
|
161
|
+
"X",
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Close" })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] });
|
|
170
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
171
|
+
"div",
|
|
172
|
+
{
|
|
173
|
+
"data-slot": "dialog-header",
|
|
174
|
+
className: cn("flex flex-col gap-1 text-left", className),
|
|
175
|
+
...props
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
var DialogFooter = ({
|
|
179
|
+
className,
|
|
180
|
+
showCloseButton = false,
|
|
181
|
+
children,
|
|
182
|
+
...props
|
|
183
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
"data-slot": "dialog-footer",
|
|
187
|
+
className: cn(
|
|
188
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
189
|
+
className
|
|
190
|
+
),
|
|
191
|
+
...props,
|
|
192
|
+
children: [
|
|
193
|
+
children,
|
|
194
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Button, { variant: "outline" }), children: "Close" })
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
199
|
+
import_dialog.Dialog.Title,
|
|
200
|
+
{
|
|
201
|
+
"data-slot": "dialog-title",
|
|
202
|
+
className: cn("text-sm font-medium", className),
|
|
203
|
+
...props
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
var DialogDescription = ({
|
|
207
|
+
className,
|
|
208
|
+
...props
|
|
209
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
210
|
+
import_dialog.Dialog.Description,
|
|
211
|
+
{
|
|
212
|
+
"data-slot": "dialog-description",
|
|
213
|
+
className: cn(
|
|
214
|
+
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
215
|
+
className
|
|
216
|
+
),
|
|
217
|
+
...props
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
// src/ui/input.tsx
|
|
222
|
+
var import_input = require("@base-ui/react/input");
|
|
223
|
+
var React2 = require("react");
|
|
224
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
225
|
+
var Input = ({
|
|
226
|
+
className,
|
|
227
|
+
type,
|
|
228
|
+
...props
|
|
229
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
230
|
+
import_input.Input,
|
|
231
|
+
{
|
|
232
|
+
type,
|
|
233
|
+
"data-slot": "input",
|
|
234
|
+
className: cn(
|
|
235
|
+
"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",
|
|
236
|
+
className
|
|
237
|
+
),
|
|
238
|
+
...props
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
// src/ui/popover.tsx
|
|
243
|
+
var import_popover = require("@base-ui/react/popover");
|
|
244
|
+
var React3 = require("react");
|
|
245
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
246
|
+
var Popover = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
247
|
+
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
248
|
+
var PopoverContent = ({
|
|
249
|
+
className,
|
|
250
|
+
align = "center",
|
|
251
|
+
alignOffset = 0,
|
|
252
|
+
side = "bottom",
|
|
253
|
+
sideOffset = 4,
|
|
254
|
+
...props
|
|
255
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
256
|
+
import_popover.Popover.Positioner,
|
|
257
|
+
{
|
|
258
|
+
align,
|
|
259
|
+
alignOffset,
|
|
260
|
+
side,
|
|
261
|
+
sideOffset,
|
|
262
|
+
className: "isolate z-50",
|
|
263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
264
|
+
import_popover.Popover.Popup,
|
|
265
|
+
{
|
|
266
|
+
"data-slot": "popover-content",
|
|
267
|
+
className: cn(
|
|
268
|
+
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
269
|
+
className
|
|
270
|
+
),
|
|
271
|
+
...props
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
) });
|
|
276
|
+
|
|
277
|
+
// src/ui/rte-button.tsx
|
|
278
|
+
var React4 = __toESM(require("react"), 1);
|
|
279
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
280
|
+
var RteButton = React4.forwardRef(
|
|
281
|
+
({ className = "", active = false, ...props }, ref) => {
|
|
282
|
+
const cls = [
|
|
283
|
+
"rte-bubble-btn",
|
|
284
|
+
active ? "rte-bubble-btn--active" : "",
|
|
285
|
+
className
|
|
286
|
+
].filter(Boolean).join(" ");
|
|
287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { ref, type: "button", className: cls, ...props });
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
RteButton.displayName = "RteButton";
|
|
291
|
+
|
|
292
|
+
// src/ui/rte-button-group.tsx
|
|
293
|
+
var React5 = __toESM(require("react"), 1);
|
|
294
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
295
|
+
var RteButtonGroup = React5.forwardRef(
|
|
296
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
297
|
+
"div",
|
|
298
|
+
{
|
|
299
|
+
ref,
|
|
300
|
+
className: `rte-bubble-group ${className}`.trim(),
|
|
301
|
+
...props
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
RteButtonGroup.displayName = "RteButtonGroup";
|
|
306
|
+
|
|
307
|
+
// src/ui/rte-icon.tsx
|
|
308
|
+
var React6 = __toESM(require("react"), 1);
|
|
309
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
310
|
+
var RteIcon = React6.forwardRef(
|
|
311
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
312
|
+
"span",
|
|
313
|
+
{
|
|
314
|
+
ref,
|
|
315
|
+
className: `rte-bubble-btn-icon ${className}`.trim(),
|
|
316
|
+
...props
|
|
317
|
+
}
|
|
318
|
+
)
|
|
319
|
+
);
|
|
320
|
+
RteIcon.displayName = "RteIcon";
|
|
321
|
+
|
|
322
|
+
// src/ui/rte-separator.tsx
|
|
323
|
+
var React7 = __toESM(require("react"), 1);
|
|
324
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
325
|
+
var RteSeparator = React7.forwardRef(
|
|
326
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
ref,
|
|
330
|
+
className: `rte-bubble-separator ${className}`.trim(),
|
|
331
|
+
...props
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
);
|
|
335
|
+
RteSeparator.displayName = "RteSeparator";
|
|
336
|
+
|
|
337
|
+
// src/ui/rte-overlay.tsx
|
|
338
|
+
var React8 = __toESM(require("react"), 1);
|
|
339
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
340
|
+
var RteOverlay = React8.forwardRef(
|
|
341
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
342
|
+
"div",
|
|
343
|
+
{
|
|
344
|
+
ref,
|
|
345
|
+
role: "presentation",
|
|
346
|
+
className: `rte-bubble-overlay ${className}`.trim(),
|
|
347
|
+
...props
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
);
|
|
351
|
+
RteOverlay.displayName = "RteOverlay";
|
|
352
|
+
|
|
353
|
+
// src/ui/rte-dropdown.tsx
|
|
354
|
+
var React9 = __toESM(require("react"), 1);
|
|
58
355
|
var import_react = require("react");
|
|
59
|
-
var
|
|
60
|
-
var
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
356
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
357
|
+
var variantClass = {
|
|
358
|
+
color: "rte-bubble-dropdown--color",
|
|
359
|
+
default: "",
|
|
360
|
+
language: "rte-bubble-dropdown--language"
|
|
361
|
+
};
|
|
362
|
+
var RteDropdown = React9.forwardRef(
|
|
363
|
+
({ className = "", variant = "default", children, onMouseLeave, ...props }, ref) => {
|
|
364
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
365
|
+
const [pill, setPill] = (0, import_react.useState)(null);
|
|
366
|
+
const handleItemEnter = (0, import_react.useCallback)((target) => {
|
|
367
|
+
const item = target.closest(
|
|
368
|
+
"[data-dropdown-item]"
|
|
369
|
+
);
|
|
370
|
+
if (!item) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
setPill({
|
|
374
|
+
height: item.offsetHeight,
|
|
375
|
+
left: item.offsetLeft,
|
|
376
|
+
top: item.offsetTop,
|
|
377
|
+
width: item.offsetWidth
|
|
378
|
+
});
|
|
379
|
+
}, []);
|
|
380
|
+
const handleMouseOver = (0, import_react.useCallback)(
|
|
381
|
+
(event) => {
|
|
382
|
+
handleItemEnter(event.target);
|
|
383
|
+
},
|
|
384
|
+
[handleItemEnter]
|
|
385
|
+
);
|
|
386
|
+
const handleFocus = (0, import_react.useCallback)(
|
|
387
|
+
(event) => {
|
|
388
|
+
handleItemEnter(event.target);
|
|
389
|
+
},
|
|
390
|
+
[handleItemEnter]
|
|
391
|
+
);
|
|
392
|
+
const handleMouseLeaveFn = (0, import_react.useCallback)(
|
|
393
|
+
(event) => {
|
|
394
|
+
setPill(null);
|
|
395
|
+
onMouseLeave?.(event);
|
|
396
|
+
},
|
|
397
|
+
[onMouseLeave]
|
|
398
|
+
);
|
|
399
|
+
const cls = ["rte-bubble-dropdown", variantClass[variant], className].filter(Boolean).join(" ");
|
|
400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
401
|
+
"div",
|
|
402
|
+
{
|
|
403
|
+
ref: (node) => {
|
|
404
|
+
containerRef.current = node;
|
|
405
|
+
if (typeof ref === "function") {
|
|
406
|
+
ref(node);
|
|
407
|
+
} else if (ref) {
|
|
408
|
+
ref.current = node;
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
className: cls,
|
|
412
|
+
onFocus: handleFocus,
|
|
413
|
+
onMouseLeave: handleMouseLeaveFn,
|
|
414
|
+
onMouseOver: handleMouseOver,
|
|
415
|
+
...props,
|
|
416
|
+
children: [
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
418
|
+
"div",
|
|
419
|
+
{
|
|
420
|
+
"aria-hidden": "true",
|
|
421
|
+
className: [
|
|
422
|
+
"rte-bubble-dropdown-pill",
|
|
423
|
+
pill ? "rte-bubble-dropdown-pill--visible" : ""
|
|
424
|
+
].filter(Boolean).join(" "),
|
|
425
|
+
style: pill ? {
|
|
426
|
+
height: pill.height,
|
|
427
|
+
left: pill.left,
|
|
428
|
+
top: pill.top,
|
|
429
|
+
width: pill.width
|
|
430
|
+
} : void 0
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
children
|
|
434
|
+
]
|
|
435
|
+
}
|
|
65
436
|
);
|
|
66
437
|
}
|
|
67
|
-
|
|
438
|
+
);
|
|
439
|
+
RteDropdown.displayName = "RteDropdown";
|
|
440
|
+
|
|
441
|
+
// src/ui/rte-color-swatch.tsx
|
|
442
|
+
var React10 = __toESM(require("react"), 1);
|
|
443
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
444
|
+
var getCheckColor = (hex) => {
|
|
445
|
+
const value = hex.replace("#", "");
|
|
446
|
+
const r = Number.parseInt(value.slice(0, 2), 16) / 255;
|
|
447
|
+
const g = Number.parseInt(value.slice(2, 4), 16) / 255;
|
|
448
|
+
const b = Number.parseInt(value.slice(4, 6), 16) / 255;
|
|
449
|
+
const luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
450
|
+
return luminance > 0.5 ? "#18181b" : "#ffffff";
|
|
68
451
|
};
|
|
452
|
+
var RteColorSwatch = React10.forwardRef(
|
|
453
|
+
({ color, label, variant, active = false, onSelect }, ref) => {
|
|
454
|
+
const checkColor = getCheckColor(color);
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
456
|
+
"button",
|
|
457
|
+
{
|
|
458
|
+
ref,
|
|
459
|
+
type: "button",
|
|
460
|
+
"aria-pressed": active,
|
|
461
|
+
"aria-label": label,
|
|
462
|
+
title: label,
|
|
463
|
+
className: [
|
|
464
|
+
"rte-bubble-color-swatch",
|
|
465
|
+
variant === "text" ? "rte-bubble-color-swatch--text" : "rte-bubble-color-swatch--highlight",
|
|
466
|
+
active ? "rte-bubble-color-swatch--active" : ""
|
|
467
|
+
].filter(Boolean).join(" "),
|
|
468
|
+
style: {
|
|
469
|
+
"--swatch-check": checkColor,
|
|
470
|
+
"--swatch-color": color
|
|
471
|
+
},
|
|
472
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
473
|
+
onClick: () => onSelect(color),
|
|
474
|
+
children: [
|
|
475
|
+
variant === "text" && !active ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rte-bubble-color-glyph", "aria-hidden": "true", children: "A" }) : null,
|
|
476
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "rte-bubble-color-check", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
477
|
+
"svg",
|
|
478
|
+
{
|
|
479
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
480
|
+
viewBox: "0 0 24 24",
|
|
481
|
+
fill: "none",
|
|
482
|
+
stroke: "currentColor",
|
|
483
|
+
strokeWidth: 3,
|
|
484
|
+
strokeLinecap: "round",
|
|
485
|
+
strokeLinejoin: "round",
|
|
486
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("path", { d: "M20 6 9 17l-5-5" })
|
|
487
|
+
}
|
|
488
|
+
) }) : null
|
|
489
|
+
]
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
);
|
|
494
|
+
RteColorSwatch.displayName = "RteColorSwatch";
|
|
495
|
+
|
|
496
|
+
// src/ui/rte-dropdown-item.tsx
|
|
497
|
+
var React11 = __toESM(require("react"), 1);
|
|
498
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
499
|
+
var RteDropdownItem = React11.forwardRef(({ className = "", active = false, ...props }, ref) => {
|
|
500
|
+
const cls = [
|
|
501
|
+
"rte-bubble-dropdown-item",
|
|
502
|
+
active ? "rte-bubble-dropdown-item--active" : "",
|
|
503
|
+
className
|
|
504
|
+
].filter(Boolean).join(" ");
|
|
505
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
506
|
+
"button",
|
|
507
|
+
{
|
|
508
|
+
ref,
|
|
509
|
+
type: "button",
|
|
510
|
+
"data-dropdown-item": true,
|
|
511
|
+
className: cls,
|
|
512
|
+
...props
|
|
513
|
+
}
|
|
514
|
+
);
|
|
515
|
+
});
|
|
516
|
+
RteDropdownItem.displayName = "RteDropdownItem";
|
|
517
|
+
|
|
518
|
+
// src/ui/rte-dropdown-divider.tsx
|
|
519
|
+
var React12 = __toESM(require("react"), 1);
|
|
520
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
521
|
+
var RteDropdownDivider = React12.forwardRef(({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
522
|
+
"div",
|
|
523
|
+
{
|
|
524
|
+
ref,
|
|
525
|
+
className: `rte-bubble-dropdown-divider ${className}`.trim(),
|
|
526
|
+
...props
|
|
527
|
+
}
|
|
528
|
+
));
|
|
529
|
+
RteDropdownDivider.displayName = "RteDropdownDivider";
|
|
530
|
+
|
|
531
|
+
// src/ui/rte-dropdown-icon.tsx
|
|
532
|
+
var React13 = __toESM(require("react"), 1);
|
|
533
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
534
|
+
var RteDropdownIcon = React13.forwardRef(
|
|
535
|
+
({ className = "", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
536
|
+
"span",
|
|
537
|
+
{
|
|
538
|
+
ref,
|
|
539
|
+
className: `rte-bubble-dropdown-icon ${className}`.trim(),
|
|
540
|
+
...props
|
|
541
|
+
}
|
|
542
|
+
)
|
|
543
|
+
);
|
|
544
|
+
RteDropdownIcon.displayName = "RteDropdownIcon";
|
|
545
|
+
|
|
546
|
+
// src/ui/toggle.tsx
|
|
547
|
+
var import_toggle = require("@base-ui/react/toggle");
|
|
548
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
549
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
550
|
+
var toggleVariants = (0, import_class_variance_authority2.cva)(
|
|
551
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
552
|
+
{
|
|
553
|
+
defaultVariants: {
|
|
554
|
+
size: "default",
|
|
555
|
+
variant: "default"
|
|
556
|
+
},
|
|
557
|
+
variants: {
|
|
558
|
+
size: {
|
|
559
|
+
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
560
|
+
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
561
|
+
sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
562
|
+
},
|
|
563
|
+
variant: {
|
|
564
|
+
default: "bg-transparent",
|
|
565
|
+
outline: "border border-input bg-transparent hover:bg-muted"
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
var Toggle = ({
|
|
571
|
+
className,
|
|
572
|
+
variant = "default",
|
|
573
|
+
size = "default",
|
|
574
|
+
...props
|
|
575
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
576
|
+
import_toggle.Toggle,
|
|
577
|
+
{
|
|
578
|
+
"data-slot": "toggle",
|
|
579
|
+
className: cn(toggleVariants({ className, size, variant })),
|
|
580
|
+
...props
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
|
|
584
|
+
// src/bubble-menu/color-selector.tsx
|
|
585
|
+
var import_react3 = require("react");
|
|
69
586
|
|
|
70
587
|
// src/bubble-menu/utils.ts
|
|
71
588
|
var import_react2 = require("react");
|
|
@@ -86,9 +603,11 @@ var shallowEqual = (a, b) => {
|
|
|
86
603
|
};
|
|
87
604
|
var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
88
605
|
const selectorRef = (0, import_react2.useRef)(selector);
|
|
89
|
-
selectorRef.current = selector;
|
|
90
606
|
const isEqualRef = (0, import_react2.useRef)(isEqual);
|
|
91
|
-
|
|
607
|
+
(0, import_react2.useEffect)(() => {
|
|
608
|
+
selectorRef.current = selector;
|
|
609
|
+
isEqualRef.current = isEqual;
|
|
610
|
+
});
|
|
92
611
|
const snapshotRef = (0, import_react2.useRef)({
|
|
93
612
|
value: editor ? selector(editor) : void 0
|
|
94
613
|
});
|
|
@@ -170,11 +689,216 @@ var CODE_BLOCK_LANGUAGE_LABELS = {
|
|
|
170
689
|
xml: "XML",
|
|
171
690
|
yaml: "YAML"
|
|
172
691
|
};
|
|
173
|
-
var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
|
|
692
|
+
var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
|
|
693
|
+
|
|
694
|
+
// src/bubble-menu/color-selector.tsx
|
|
695
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
696
|
+
var RECENT_KEY = "editorcn-editor-recent-colors";
|
|
697
|
+
var RECENT_LIMIT = 10;
|
|
698
|
+
var readRecentColors = () => {
|
|
699
|
+
if (typeof window === "undefined") {
|
|
700
|
+
return [];
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
const raw = window.localStorage.getItem(RECENT_KEY);
|
|
704
|
+
if (!raw) {
|
|
705
|
+
return [];
|
|
706
|
+
}
|
|
707
|
+
const parsed = JSON.parse(raw);
|
|
708
|
+
return Array.isArray(parsed) ? parsed.slice(0, RECENT_LIMIT) : [];
|
|
709
|
+
} catch {
|
|
710
|
+
return [];
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
var persistRecentColors = (recent) => {
|
|
714
|
+
try {
|
|
715
|
+
window.localStorage.setItem(RECENT_KEY, JSON.stringify(recent));
|
|
716
|
+
} catch {
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
var TEXT_COLORS = [
|
|
720
|
+
{ color: "#0f172a", label: "Foreground" },
|
|
721
|
+
{ color: "#ef4444", label: "Red" },
|
|
722
|
+
{ color: "#f97316", label: "Orange" },
|
|
723
|
+
{ color: "#f59e0b", label: "Amber" },
|
|
724
|
+
{ color: "#22c55e", label: "Green" },
|
|
725
|
+
{ color: "#0ea5e9", label: "Sky" },
|
|
726
|
+
{ color: "#3b82f6", label: "Blue" },
|
|
727
|
+
{ color: "#6366f1", label: "Indigo" },
|
|
728
|
+
{ color: "#a855f7", label: "Purple" },
|
|
729
|
+
{ color: "#ec4899", label: "Pink" }
|
|
730
|
+
];
|
|
731
|
+
var HIGHLIGHT_COLORS = [
|
|
732
|
+
{ color: "#fef08a", label: "Yellow" },
|
|
733
|
+
{ color: "#fed7aa", label: "Orange" },
|
|
734
|
+
{ color: "#fecaca", label: "Red" },
|
|
735
|
+
{ color: "#fbcfe8", label: "Pink" },
|
|
736
|
+
{ color: "#e9d5ff", label: "Purple" },
|
|
737
|
+
{ color: "#ddd6fe", label: "Violet" },
|
|
738
|
+
{ color: "#bfdbfe", label: "Blue" },
|
|
739
|
+
{ color: "#a5f3fc", label: "Cyan" },
|
|
740
|
+
{ color: "#99f6e4", label: "Teal" },
|
|
741
|
+
{ color: "#bbf7d0", label: "Green" }
|
|
742
|
+
];
|
|
743
|
+
var ColorSelector = ({ editor }) => {
|
|
744
|
+
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
745
|
+
const [recent, setRecent] = (0, import_react3.useState)(() => readRecentColors());
|
|
746
|
+
const { highlightColor, textColor } = useEditorState(
|
|
747
|
+
editor,
|
|
748
|
+
(ed) => ({
|
|
749
|
+
highlightColor: ed.isActive("highlight") ? ed.getAttributes("highlight").color : void 0,
|
|
750
|
+
textColor: ed.isActive("textStyle") ? ed.getAttributes("textStyle").color : void 0
|
|
751
|
+
}),
|
|
752
|
+
shallowEqual
|
|
753
|
+
);
|
|
754
|
+
const hasColor = editor.extensionManager.extensions.some(
|
|
755
|
+
(ext) => ext.name === "color"
|
|
756
|
+
);
|
|
757
|
+
const hasHighlight = editor.extensionManager.extensions.some(
|
|
758
|
+
(ext) => ext.name === "highlight"
|
|
759
|
+
);
|
|
760
|
+
const remember = (type, color, label) => {
|
|
761
|
+
setRecent((prev) => {
|
|
762
|
+
const next = [
|
|
763
|
+
{ color, label, type },
|
|
764
|
+
...prev.filter((item) => !(item.type === type && item.color === color))
|
|
765
|
+
].slice(0, RECENT_LIMIT);
|
|
766
|
+
persistRecentColors(next);
|
|
767
|
+
return next;
|
|
768
|
+
});
|
|
769
|
+
};
|
|
770
|
+
const selectText = (color, label) => {
|
|
771
|
+
remember("text", color, label);
|
|
772
|
+
if (textColor === color) {
|
|
773
|
+
editor.chain().focus().unsetColor().run();
|
|
774
|
+
} else {
|
|
775
|
+
editor.chain().focus().setColor(color).run();
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
const selectHighlight = (color, label) => {
|
|
779
|
+
remember("highlight", color, label);
|
|
780
|
+
if (highlightColor === color) {
|
|
781
|
+
editor.chain().focus().unsetHighlight().run();
|
|
782
|
+
} else {
|
|
783
|
+
editor.chain().focus().setHighlight({ color }).run();
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
if (!hasColor && !hasHighlight) {
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { style: { position: "relative" }, children: [
|
|
790
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
791
|
+
RteButton,
|
|
792
|
+
{
|
|
793
|
+
active: Boolean(textColor || highlightColor),
|
|
794
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
795
|
+
onClick: () => setOpen(!open),
|
|
796
|
+
title: "Text color",
|
|
797
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RteIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
798
|
+
"svg",
|
|
799
|
+
{
|
|
800
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
801
|
+
viewBox: "0 0 24 24",
|
|
802
|
+
fill: "none",
|
|
803
|
+
stroke: "currentColor",
|
|
804
|
+
strokeWidth: 2,
|
|
805
|
+
strokeLinecap: "round",
|
|
806
|
+
strokeLinejoin: "round",
|
|
807
|
+
className: "rte-editor-icon",
|
|
808
|
+
children: [
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M4 20h16" }),
|
|
810
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "m6 16 6-12 6 12" }),
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("path", { d: "M8 12h8" })
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
) })
|
|
815
|
+
}
|
|
816
|
+
),
|
|
817
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
818
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
819
|
+
RteOverlay,
|
|
820
|
+
{
|
|
821
|
+
onClick: () => setOpen(false),
|
|
822
|
+
onKeyDown: (e) => {
|
|
823
|
+
if (e.key === "Escape") {
|
|
824
|
+
setOpen(false);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
),
|
|
829
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(RteDropdown, { variant: "color", children: [
|
|
830
|
+
recent.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "rte-bubble-color-section", children: [
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "rte-bubble-color-label", children: "Recently Used" }),
|
|
832
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "rte-bubble-color-recent", children: recent.map((item) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
833
|
+
RteColorSwatch,
|
|
834
|
+
{
|
|
835
|
+
variant: item.type,
|
|
836
|
+
color: item.color,
|
|
837
|
+
label: item.label,
|
|
838
|
+
active: item.type === "text" ? textColor === item.color : highlightColor === item.color,
|
|
839
|
+
onSelect: () => item.type === "text" ? selectText(item.color, item.label) : selectHighlight(item.color, item.label)
|
|
840
|
+
},
|
|
841
|
+
`${item.type}-${item.color}`
|
|
842
|
+
)) })
|
|
843
|
+
] }) : null,
|
|
844
|
+
hasColor ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
845
|
+
recent.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RteDropdownDivider, {}),
|
|
846
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "rte-bubble-color-section", children: [
|
|
847
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "rte-bubble-color-label", children: "Text Color" }),
|
|
848
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "rte-bubble-color-grid", children: TEXT_COLORS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
849
|
+
RteColorSwatch,
|
|
850
|
+
{
|
|
851
|
+
variant: "text",
|
|
852
|
+
color: item.color,
|
|
853
|
+
label: item.label,
|
|
854
|
+
active: textColor === item.color,
|
|
855
|
+
onSelect: () => selectText(item.color, item.label)
|
|
856
|
+
},
|
|
857
|
+
item.color
|
|
858
|
+
)) })
|
|
859
|
+
] })
|
|
860
|
+
] }) : null,
|
|
861
|
+
hasHighlight ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
862
|
+
(recent.length > 0 || hasColor) && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RteDropdownDivider, {}),
|
|
863
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "rte-bubble-color-section", children: [
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "rte-bubble-color-label", children: "Highlight Color" }),
|
|
865
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "rte-bubble-color-grid", children: HIGHLIGHT_COLORS.map((item) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
866
|
+
RteColorSwatch,
|
|
867
|
+
{
|
|
868
|
+
variant: "highlight",
|
|
869
|
+
color: item.color,
|
|
870
|
+
label: item.label,
|
|
871
|
+
active: highlightColor === item.color,
|
|
872
|
+
onSelect: () => selectHighlight(item.color, item.label)
|
|
873
|
+
},
|
|
874
|
+
item.color
|
|
875
|
+
)) })
|
|
876
|
+
] })
|
|
877
|
+
] }) : null
|
|
878
|
+
] })
|
|
879
|
+
] })
|
|
880
|
+
] });
|
|
881
|
+
};
|
|
174
882
|
|
|
175
883
|
// src/bubble-menu/language-selector.tsx
|
|
176
|
-
var
|
|
177
|
-
|
|
884
|
+
var import_react5 = require("react");
|
|
885
|
+
|
|
886
|
+
// src/rte-context.ts
|
|
887
|
+
var import_react4 = require("react");
|
|
888
|
+
var RichTextEditorContext = (0, import_react4.createContext)(null);
|
|
889
|
+
var useRichTextEditorContext = () => {
|
|
890
|
+
const context = (0, import_react4.useContext)(RichTextEditorContext);
|
|
891
|
+
if (!context) {
|
|
892
|
+
throw new Error(
|
|
893
|
+
"useRichTextEditorContext must be used within RichTextEditor"
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
return context;
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
// src/bubble-menu/language-selector.tsx
|
|
900
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
901
|
+
var FallbackIcon = () => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
178
902
|
"svg",
|
|
179
903
|
{
|
|
180
904
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -186,14 +910,13 @@ var FallbackIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
|
186
910
|
strokeLinejoin: "round",
|
|
187
911
|
className: "rte-editor-icon",
|
|
188
912
|
children: [
|
|
189
|
-
/* @__PURE__ */ (0,
|
|
190
|
-
/* @__PURE__ */ (0,
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("polyline", { points: "16 18 22 12 16 6" }),
|
|
914
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("polyline", { points: "8 6 2 12 8 18" })
|
|
191
915
|
]
|
|
192
916
|
}
|
|
193
917
|
);
|
|
194
918
|
var LanguageSelector = ({ editor }) => {
|
|
195
|
-
const [open, setOpen] = (0,
|
|
196
|
-
const [pill, setPill] = (0, import_react3.useState)(null);
|
|
919
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
197
920
|
const { icons } = useRichTextEditorContext();
|
|
198
921
|
const { currentLanguage } = useEditorState(
|
|
199
922
|
editor,
|
|
@@ -202,45 +925,17 @@ var LanguageSelector = ({ editor }) => {
|
|
|
202
925
|
}),
|
|
203
926
|
shallowEqual
|
|
204
927
|
);
|
|
205
|
-
const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ (0,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
);
|
|
210
|
-
if (!item) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
setPill({
|
|
214
|
-
height: item.offsetHeight,
|
|
215
|
-
left: item.offsetLeft,
|
|
216
|
-
top: item.offsetTop,
|
|
217
|
-
width: item.offsetWidth
|
|
218
|
-
});
|
|
219
|
-
}, []);
|
|
220
|
-
const handleMouseOver = (0, import_react3.useCallback)(
|
|
221
|
-
(event) => {
|
|
222
|
-
handleItemEnter(event.target);
|
|
223
|
-
},
|
|
224
|
-
[handleItemEnter]
|
|
225
|
-
);
|
|
226
|
-
const handleFocus = (0, import_react3.useCallback)(
|
|
227
|
-
(event) => {
|
|
228
|
-
handleItemEnter(event.target);
|
|
229
|
-
},
|
|
230
|
-
[handleItemEnter]
|
|
231
|
-
);
|
|
232
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { position: "relative" }, children: [
|
|
233
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
234
|
-
"button",
|
|
928
|
+
const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FallbackIcon, {});
|
|
929
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { style: { position: "relative" }, children: [
|
|
930
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
931
|
+
RteButton,
|
|
235
932
|
{
|
|
236
|
-
type: "button",
|
|
237
|
-
className: "rte-bubble-btn",
|
|
238
933
|
onMouseDown: (e) => e.preventDefault(),
|
|
239
934
|
onClick: () => setOpen(!open),
|
|
240
935
|
children: [
|
|
241
|
-
/* @__PURE__ */ (0,
|
|
242
|
-
/* @__PURE__ */ (0,
|
|
243
|
-
/* @__PURE__ */ (0,
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RteIcon, { children: langIcon }),
|
|
937
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
|
|
938
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RteIcon, { style: { height: 12, width: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
244
939
|
"svg",
|
|
245
940
|
{
|
|
246
941
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -250,18 +945,16 @@ var LanguageSelector = ({ editor }) => {
|
|
|
250
945
|
strokeWidth: 2,
|
|
251
946
|
strokeLinecap: "round",
|
|
252
947
|
strokeLinejoin: "round",
|
|
253
|
-
children: /* @__PURE__ */ (0,
|
|
948
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "m6 9 6 6 6-6" })
|
|
254
949
|
}
|
|
255
950
|
) })
|
|
256
951
|
]
|
|
257
952
|
}
|
|
258
953
|
),
|
|
259
|
-
open && /* @__PURE__ */ (0,
|
|
260
|
-
/* @__PURE__ */ (0,
|
|
261
|
-
|
|
954
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
955
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
956
|
+
RteOverlay,
|
|
262
957
|
{
|
|
263
|
-
className: "rte-bubble-overlay",
|
|
264
|
-
role: "presentation",
|
|
265
958
|
onClick: () => setOpen(false),
|
|
266
959
|
onKeyDown: (e) => {
|
|
267
960
|
if (e.key === "Escape") {
|
|
@@ -270,61 +963,32 @@ var LanguageSelector = ({ editor }) => {
|
|
|
270
963
|
}
|
|
271
964
|
}
|
|
272
965
|
),
|
|
273
|
-
/* @__PURE__ */ (0,
|
|
274
|
-
|
|
966
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RteDropdown, { variant: "language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
967
|
+
RteDropdownItem,
|
|
275
968
|
{
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
969
|
+
active: currentLanguage === lang,
|
|
970
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
971
|
+
onClick: () => {
|
|
972
|
+
editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
|
|
973
|
+
setOpen(false);
|
|
974
|
+
},
|
|
280
975
|
children: [
|
|
281
|
-
/* @__PURE__ */ (0,
|
|
282
|
-
|
|
283
|
-
{
|
|
284
|
-
"aria-hidden": "true",
|
|
285
|
-
className: [
|
|
286
|
-
"rte-bubble-dropdown-pill",
|
|
287
|
-
pill ? "rte-bubble-dropdown-pill--visible" : ""
|
|
288
|
-
].filter(Boolean).join(" "),
|
|
289
|
-
style: pill ? {
|
|
290
|
-
height: pill.height,
|
|
291
|
-
left: pill.left,
|
|
292
|
-
top: pill.top,
|
|
293
|
-
width: pill.width
|
|
294
|
-
} : void 0
|
|
295
|
-
}
|
|
296
|
-
),
|
|
297
|
-
CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
298
|
-
"button",
|
|
299
|
-
{
|
|
300
|
-
type: "button",
|
|
301
|
-
"data-dropdown-item": true,
|
|
302
|
-
className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
|
|
303
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
304
|
-
onClick: () => {
|
|
305
|
-
editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
|
|
306
|
-
setOpen(false);
|
|
307
|
-
},
|
|
308
|
-
children: [
|
|
309
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackIcon, {}) }),
|
|
310
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: getLanguageLabel(lang) })
|
|
311
|
-
]
|
|
312
|
-
},
|
|
313
|
-
lang
|
|
314
|
-
))
|
|
976
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RteDropdownIcon, { children: icons.languageIcons[lang] ?? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(FallbackIcon, {}) }),
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: getLanguageLabel(lang) })
|
|
315
978
|
]
|
|
316
|
-
}
|
|
317
|
-
|
|
979
|
+
},
|
|
980
|
+
lang
|
|
981
|
+
)) })
|
|
318
982
|
] })
|
|
319
983
|
] });
|
|
320
984
|
};
|
|
321
985
|
|
|
322
986
|
// src/bubble-menu/text-buttons.tsx
|
|
323
|
-
var
|
|
987
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
324
988
|
var Svg = ({
|
|
325
989
|
children,
|
|
326
990
|
strokeWidth = 2
|
|
327
|
-
}) => /* @__PURE__ */ (0,
|
|
991
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
328
992
|
"svg",
|
|
329
993
|
{
|
|
330
994
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -338,47 +1002,48 @@ var Svg = ({
|
|
|
338
1002
|
children
|
|
339
1003
|
}
|
|
340
1004
|
);
|
|
1005
|
+
var Icon = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RteIcon, { children });
|
|
341
1006
|
var textItems = [
|
|
342
1007
|
{
|
|
343
1008
|
command: (e) => e.chain().focus().toggleBold().run(),
|
|
344
|
-
icon: /* @__PURE__ */ (0,
|
|
345
|
-
/* @__PURE__ */ (0,
|
|
346
|
-
/* @__PURE__ */ (0,
|
|
347
|
-
] }),
|
|
1009
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Svg, { children: [
|
|
1010
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
1012
|
+
] }) }),
|
|
348
1013
|
isActive: (s) => s.isBold
|
|
349
1014
|
},
|
|
350
1015
|
{
|
|
351
1016
|
command: (e) => e.chain().focus().toggleItalic().run(),
|
|
352
|
-
icon: /* @__PURE__ */ (0,
|
|
353
|
-
/* @__PURE__ */ (0,
|
|
354
|
-
/* @__PURE__ */ (0,
|
|
355
|
-
/* @__PURE__ */ (0,
|
|
356
|
-
] }),
|
|
1017
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Svg, { children: [
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
1020
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
1021
|
+
] }) }),
|
|
357
1022
|
isActive: (s) => s.isItalic
|
|
358
1023
|
},
|
|
359
1024
|
{
|
|
360
1025
|
command: (e) => e.chain().focus().toggleUnderline().run(),
|
|
361
|
-
icon: /* @__PURE__ */ (0,
|
|
362
|
-
/* @__PURE__ */ (0,
|
|
363
|
-
/* @__PURE__ */ (0,
|
|
364
|
-
] }),
|
|
1026
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Svg, { children: [
|
|
1027
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
1028
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
|
|
1029
|
+
] }) }),
|
|
365
1030
|
isActive: (s) => s.isUnderline
|
|
366
1031
|
},
|
|
367
1032
|
{
|
|
368
1033
|
command: (e) => e.chain().focus().toggleStrike().run(),
|
|
369
|
-
icon: /* @__PURE__ */ (0,
|
|
370
|
-
/* @__PURE__ */ (0,
|
|
371
|
-
/* @__PURE__ */ (0,
|
|
372
|
-
/* @__PURE__ */ (0,
|
|
373
|
-
] }),
|
|
1034
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Svg, { children: [
|
|
1035
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
|
|
1037
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
1038
|
+
] }) }),
|
|
374
1039
|
isActive: (s) => s.isStrike
|
|
375
1040
|
},
|
|
376
1041
|
{
|
|
377
1042
|
command: (e) => e.chain().focus().toggleCode().run(),
|
|
378
|
-
icon: /* @__PURE__ */ (0,
|
|
379
|
-
/* @__PURE__ */ (0,
|
|
380
|
-
/* @__PURE__ */ (0,
|
|
381
|
-
] }),
|
|
1043
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Svg, { children: [
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("polyline", { points: "16 18 22 12 16 6" }),
|
|
1045
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("polyline", { points: "8 6 2 12 8 18" })
|
|
1046
|
+
] }) }),
|
|
382
1047
|
isActive: (s) => s.isCode
|
|
383
1048
|
}
|
|
384
1049
|
];
|
|
@@ -394,11 +1059,10 @@ var TextButtons = ({ editor }) => {
|
|
|
394
1059
|
}),
|
|
395
1060
|
shallowEqual
|
|
396
1061
|
);
|
|
397
|
-
return /* @__PURE__ */ (0,
|
|
398
|
-
|
|
1062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RteButtonGroup, { children: textItems.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1063
|
+
RteButton,
|
|
399
1064
|
{
|
|
400
|
-
|
|
401
|
-
className: `rte-bubble-btn${item.isActive(editorState) ? " rte-bubble-btn--active" : ""}`,
|
|
1065
|
+
active: item.isActive(editorState),
|
|
402
1066
|
onMouseDown: (e) => e.preventDefault(),
|
|
403
1067
|
onClick: () => item.command(editor),
|
|
404
1068
|
children: item.icon
|
|
@@ -408,7 +1072,7 @@ var TextButtons = ({ editor }) => {
|
|
|
408
1072
|
};
|
|
409
1073
|
|
|
410
1074
|
// src/bubble-menu/index.tsx
|
|
411
|
-
var
|
|
1075
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
412
1076
|
var BubbleMenu = ({ editor }) => {
|
|
413
1077
|
const editorState = useEditorState(
|
|
414
1078
|
editor,
|
|
@@ -417,7 +1081,7 @@ var BubbleMenu = ({ editor }) => {
|
|
|
417
1081
|
}),
|
|
418
1082
|
shallowEqual
|
|
419
1083
|
);
|
|
420
|
-
const shouldShow = (0,
|
|
1084
|
+
const shouldShow = (0, import_react6.useCallback)(
|
|
421
1085
|
({
|
|
422
1086
|
editor: ed,
|
|
423
1087
|
state
|
|
@@ -440,68 +1104,25 @@ var BubbleMenu = ({ editor }) => {
|
|
|
440
1104
|
return null;
|
|
441
1105
|
}
|
|
442
1106
|
const isCodeBlockActive = editorState?.isCodeBlock ?? false;
|
|
443
|
-
return /* @__PURE__ */ (0,
|
|
1107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
444
1108
|
import_menus.BubbleMenu,
|
|
445
1109
|
{
|
|
446
1110
|
editor,
|
|
447
1111
|
options: { offset: 8, placement: "top" },
|
|
448
1112
|
shouldShow,
|
|
449
|
-
children: /* @__PURE__ */ (0,
|
|
1113
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "rte-bubble-menu", children: isCodeBlockActive ? /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LanguageSelector, { editor }) : /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
|
|
1114
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(TextButtons, { editor }),
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(RteSeparator, {}),
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ColorSelector, { editor })
|
|
1117
|
+
] }) })
|
|
450
1118
|
}
|
|
451
1119
|
);
|
|
452
1120
|
};
|
|
453
1121
|
|
|
454
1122
|
// src/controls/rte-control.tsx
|
|
455
|
-
var
|
|
456
|
-
var
|
|
457
|
-
|
|
458
|
-
// src/ui/toggle.tsx
|
|
459
|
-
var import_toggle = require("@base-ui/react/toggle");
|
|
460
|
-
var import_class_variance_authority = require("class-variance-authority");
|
|
461
|
-
|
|
462
|
-
// src/ui/utils.ts
|
|
463
|
-
var import_clsx = require("clsx");
|
|
464
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
465
|
-
var cn = (...inputs) => (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
466
|
-
|
|
467
|
-
// src/ui/toggle.tsx
|
|
468
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
469
|
-
var toggleVariants = (0, import_class_variance_authority.cva)(
|
|
470
|
-
"group/toggle inline-flex items-center justify-center gap-1 rounded-none text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
471
|
-
{
|
|
472
|
-
defaultVariants: {
|
|
473
|
-
size: "default",
|
|
474
|
-
variant: "default"
|
|
475
|
-
},
|
|
476
|
-
variants: {
|
|
477
|
-
size: {
|
|
478
|
-
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
479
|
-
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
480
|
-
sm: "h-7 min-w-7 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
481
|
-
},
|
|
482
|
-
variant: {
|
|
483
|
-
default: "bg-transparent",
|
|
484
|
-
outline: "border border-input bg-transparent hover:bg-muted"
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
);
|
|
489
|
-
var Toggle = ({
|
|
490
|
-
className,
|
|
491
|
-
variant = "default",
|
|
492
|
-
size = "default",
|
|
493
|
-
...props
|
|
494
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
495
|
-
import_toggle.Toggle,
|
|
496
|
-
{
|
|
497
|
-
"data-slot": "toggle",
|
|
498
|
-
className: cn(toggleVariants({ className, size, variant })),
|
|
499
|
-
...props
|
|
500
|
-
}
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
// src/controls/rte-control.tsx
|
|
504
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1123
|
+
var import_react7 = require("@tiptap/react");
|
|
1124
|
+
var import_react8 = require("react");
|
|
1125
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
505
1126
|
var RichTextEditorControl = ({
|
|
506
1127
|
active,
|
|
507
1128
|
interactive: _interactive = true,
|
|
@@ -511,7 +1132,7 @@ var RichTextEditorControl = ({
|
|
|
511
1132
|
onClick,
|
|
512
1133
|
disabled,
|
|
513
1134
|
...props
|
|
514
|
-
}) => /* @__PURE__ */ (0,
|
|
1135
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
515
1136
|
Toggle,
|
|
516
1137
|
{
|
|
517
1138
|
size: "sm",
|
|
@@ -554,13 +1175,13 @@ var createControl = ({
|
|
|
554
1175
|
const Control = ({ className }) => {
|
|
555
1176
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
556
1177
|
const ariaLabel = labels[label];
|
|
557
|
-
const editorState = (0,
|
|
1178
|
+
const editorState = (0, import_react7.useEditorState)({
|
|
558
1179
|
editor: editor ?? null,
|
|
559
1180
|
selector: createSelector(isActive, isDisabled)
|
|
560
1181
|
});
|
|
561
1182
|
const active = editorState?.active ?? false;
|
|
562
1183
|
const disabled = editorState?.disabled ?? true;
|
|
563
|
-
return /* @__PURE__ */ (0,
|
|
1184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
564
1185
|
RichTextEditorControl,
|
|
565
1186
|
{
|
|
566
1187
|
active,
|
|
@@ -703,6 +1324,7 @@ var H6Control = createControl({
|
|
|
703
1324
|
});
|
|
704
1325
|
var AlignLeftControl = createControl({
|
|
705
1326
|
iconKey: "alignLeftControlIcon",
|
|
1327
|
+
isActive: { attrs: { textAlign: "left" } },
|
|
706
1328
|
label: "alignLeftControlLabel",
|
|
707
1329
|
operation: { attributes: "left", name: "setTextAlign" }
|
|
708
1330
|
});
|
|
@@ -725,143 +1347,38 @@ var AlignJustifyControl = createControl({
|
|
|
725
1347
|
operation: { attributes: "justify", name: "setTextAlign" }
|
|
726
1348
|
});
|
|
727
1349
|
var HighlightControl = createControl({
|
|
728
|
-
iconKey: "highlightControlIcon",
|
|
729
|
-
isActive: { name: "highlight" },
|
|
730
|
-
label: "highlightControlLabel",
|
|
731
|
-
operation: { name: "toggleHighlight" }
|
|
732
|
-
});
|
|
733
|
-
var SubscriptControl = createControl({
|
|
734
|
-
iconKey: "subscriptControlIcon",
|
|
735
|
-
isActive: { name: "subscript" },
|
|
736
|
-
label: "subscriptControlLabel",
|
|
737
|
-
operation: { name: "toggleSubscript" }
|
|
738
|
-
});
|
|
739
|
-
var SuperscriptControl = createControl({
|
|
740
|
-
iconKey: "superscriptControlIcon",
|
|
741
|
-
isActive: { name: "superscript" },
|
|
742
|
-
label: "superscriptControlLabel",
|
|
743
|
-
operation: { name: "toggleSuperscript" }
|
|
744
|
-
});
|
|
745
|
-
|
|
746
|
-
// src/controls/rte-link-control.tsx
|
|
747
|
-
var import_react7 = require("@tiptap/react");
|
|
748
|
-
var React4 = __toESM(require("react"), 1);
|
|
749
|
-
var import_react8 = require("react");
|
|
750
|
-
|
|
751
|
-
// src/ui/button.tsx
|
|
752
|
-
var import_button = require("@base-ui/react/button");
|
|
753
|
-
var import_class_variance_authority2 = require("class-variance-authority");
|
|
754
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
755
|
-
var buttonVariants = (0, import_class_variance_authority2.cva)(
|
|
756
|
-
"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",
|
|
757
|
-
{
|
|
758
|
-
defaultVariants: {
|
|
759
|
-
size: "default",
|
|
760
|
-
variant: "default"
|
|
761
|
-
},
|
|
762
|
-
variants: {
|
|
763
|
-
size: {
|
|
764
|
-
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
765
|
-
icon: "size-8",
|
|
766
|
-
"icon-lg": "size-9",
|
|
767
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
768
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
769
|
-
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
770
|
-
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",
|
|
771
|
-
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"
|
|
772
|
-
},
|
|
773
|
-
variant: {
|
|
774
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/80",
|
|
775
|
-
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",
|
|
776
|
-
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
777
|
-
link: "text-primary underline-offset-4 hover:underline",
|
|
778
|
-
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",
|
|
779
|
-
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"
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
);
|
|
784
|
-
var Button = ({
|
|
785
|
-
className,
|
|
786
|
-
variant = "default",
|
|
787
|
-
size = "default",
|
|
788
|
-
...props
|
|
789
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
790
|
-
import_button.Button,
|
|
791
|
-
{
|
|
792
|
-
"data-slot": "button",
|
|
793
|
-
className: cn(buttonVariants({ className, size, variant })),
|
|
794
|
-
...props
|
|
795
|
-
}
|
|
796
|
-
);
|
|
797
|
-
|
|
798
|
-
// src/ui/input.tsx
|
|
799
|
-
var import_input = require("@base-ui/react/input");
|
|
800
|
-
var React2 = require("react");
|
|
801
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
802
|
-
var Input = ({
|
|
803
|
-
className,
|
|
804
|
-
type,
|
|
805
|
-
...props
|
|
806
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
807
|
-
import_input.Input,
|
|
808
|
-
{
|
|
809
|
-
type,
|
|
810
|
-
"data-slot": "input",
|
|
811
|
-
className: cn(
|
|
812
|
-
"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",
|
|
813
|
-
className
|
|
814
|
-
),
|
|
815
|
-
...props
|
|
816
|
-
}
|
|
817
|
-
);
|
|
818
|
-
|
|
819
|
-
// src/ui/popover.tsx
|
|
820
|
-
var import_popover = require("@base-ui/react/popover");
|
|
821
|
-
var React3 = require("react");
|
|
822
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
823
|
-
var Popover = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Root, { "data-slot": "popover", ...props });
|
|
824
|
-
var PopoverTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
825
|
-
var PopoverContent = ({
|
|
826
|
-
className,
|
|
827
|
-
align = "center",
|
|
828
|
-
alignOffset = 0,
|
|
829
|
-
side = "bottom",
|
|
830
|
-
sideOffset = 4,
|
|
831
|
-
...props
|
|
832
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
833
|
-
import_popover.Popover.Positioner,
|
|
834
|
-
{
|
|
835
|
-
align,
|
|
836
|
-
alignOffset,
|
|
837
|
-
side,
|
|
838
|
-
sideOffset,
|
|
839
|
-
className: "isolate z-50",
|
|
840
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
841
|
-
import_popover.Popover.Popup,
|
|
842
|
-
{
|
|
843
|
-
"data-slot": "popover-content",
|
|
844
|
-
className: cn(
|
|
845
|
-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-none bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
846
|
-
className
|
|
847
|
-
),
|
|
848
|
-
...props
|
|
849
|
-
}
|
|
850
|
-
)
|
|
851
|
-
}
|
|
852
|
-
) });
|
|
1350
|
+
iconKey: "highlightControlIcon",
|
|
1351
|
+
isActive: { name: "highlight" },
|
|
1352
|
+
label: "highlightControlLabel",
|
|
1353
|
+
operation: { name: "toggleHighlight" }
|
|
1354
|
+
});
|
|
1355
|
+
var SubscriptControl = createControl({
|
|
1356
|
+
iconKey: "subscriptControlIcon",
|
|
1357
|
+
isActive: { name: "subscript" },
|
|
1358
|
+
label: "subscriptControlLabel",
|
|
1359
|
+
operation: { name: "toggleSubscript" }
|
|
1360
|
+
});
|
|
1361
|
+
var SuperscriptControl = createControl({
|
|
1362
|
+
iconKey: "superscriptControlIcon",
|
|
1363
|
+
isActive: { name: "superscript" },
|
|
1364
|
+
label: "superscriptControlLabel",
|
|
1365
|
+
operation: { name: "toggleSuperscript" }
|
|
1366
|
+
});
|
|
853
1367
|
|
|
854
1368
|
// src/controls/rte-link-control.tsx
|
|
855
|
-
var
|
|
1369
|
+
var import_react9 = require("@tiptap/react");
|
|
1370
|
+
var React15 = __toESM(require("react"), 1);
|
|
1371
|
+
var import_react10 = require("react");
|
|
1372
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
856
1373
|
var LinkControl = () => {
|
|
857
1374
|
const { editor, labels, icons } = useRichTextEditorContext();
|
|
858
|
-
const [url, setUrl] = (0,
|
|
859
|
-
const [open, setOpen] = (0,
|
|
860
|
-
const active = (0,
|
|
1375
|
+
const [url, setUrl] = (0, import_react10.useState)("");
|
|
1376
|
+
const [open, setOpen] = (0, import_react10.useState)(false);
|
|
1377
|
+
const active = (0, import_react9.useEditorState)({
|
|
861
1378
|
editor: editor ?? null,
|
|
862
1379
|
selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
|
|
863
1380
|
});
|
|
864
|
-
const handleOpen = (0,
|
|
1381
|
+
const handleOpen = (0, import_react10.useCallback)(
|
|
865
1382
|
(isOpen) => {
|
|
866
1383
|
if (isOpen) {
|
|
867
1384
|
const linkData = editor?.getAttributes("link");
|
|
@@ -891,16 +1408,16 @@ var LinkControl = () => {
|
|
|
891
1408
|
handleSave();
|
|
892
1409
|
}
|
|
893
1410
|
};
|
|
894
|
-
|
|
1411
|
+
React15.useEffect(() => {
|
|
895
1412
|
const handler = () => handleOpen(true);
|
|
896
1413
|
window.addEventListener("edit-link", handler);
|
|
897
1414
|
return () => window.removeEventListener("edit-link", handler);
|
|
898
1415
|
}, [handleOpen]);
|
|
899
|
-
return /* @__PURE__ */ (0,
|
|
900
|
-
/* @__PURE__ */ (0,
|
|
1416
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Popover, { open, onOpenChange: handleOpen, children: [
|
|
1417
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
901
1418
|
PopoverTrigger,
|
|
902
1419
|
{
|
|
903
|
-
render: /* @__PURE__ */ (0,
|
|
1420
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
904
1421
|
Toggle,
|
|
905
1422
|
{
|
|
906
1423
|
size: "sm",
|
|
@@ -914,8 +1431,8 @@ var LinkControl = () => {
|
|
|
914
1431
|
children: icons.linkControlIcon
|
|
915
1432
|
}
|
|
916
1433
|
),
|
|
917
|
-
/* @__PURE__ */ (0,
|
|
918
|
-
/* @__PURE__ */ (0,
|
|
1434
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "rte-link-editor", children: [
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
919
1436
|
Input,
|
|
920
1437
|
{
|
|
921
1438
|
type: "url",
|
|
@@ -927,7 +1444,7 @@ var LinkControl = () => {
|
|
|
927
1444
|
className: "rte-link-editor-input h-8 text-sm"
|
|
928
1445
|
}
|
|
929
1446
|
),
|
|
930
|
-
/* @__PURE__ */ (0,
|
|
1447
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
931
1448
|
Button,
|
|
932
1449
|
{
|
|
933
1450
|
size: "sm",
|
|
@@ -943,34 +1460,426 @@ var LinkControl = () => {
|
|
|
943
1460
|
|
|
944
1461
|
// src/controls/rte-twitter-control.tsx
|
|
945
1462
|
var import_core2 = require("@tiptap/core");
|
|
946
|
-
var
|
|
947
|
-
var
|
|
1463
|
+
var import_react14 = require("@tiptap/react");
|
|
1464
|
+
var import_react15 = require("react");
|
|
948
1465
|
|
|
949
1466
|
// src/extensions/resizable-node-view.tsx
|
|
950
|
-
var
|
|
951
|
-
var
|
|
952
|
-
|
|
1467
|
+
var import_react12 = require("@tiptap/react");
|
|
1468
|
+
var import_react13 = require("react");
|
|
1469
|
+
|
|
1470
|
+
// src/icons.tsx
|
|
1471
|
+
var import_lucide_react = require("lucide-react");
|
|
1472
|
+
var import_react11 = require("react");
|
|
1473
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1474
|
+
var ALIGN_PATHS = {
|
|
1475
|
+
center: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
1476
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1477
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
|
|
1478
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
|
|
1479
|
+
] }),
|
|
1480
|
+
left: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
1481
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
|
|
1484
|
+
] }),
|
|
1485
|
+
right: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
|
|
1489
|
+
] })
|
|
1490
|
+
};
|
|
1491
|
+
var AlignIcon = ({ dir }) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1492
|
+
"svg",
|
|
1493
|
+
{
|
|
1494
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1495
|
+
viewBox: "0 0 24 24",
|
|
1496
|
+
fill: "none",
|
|
1497
|
+
stroke: "currentColor",
|
|
1498
|
+
strokeWidth: "2",
|
|
1499
|
+
strokeLinecap: "round",
|
|
1500
|
+
strokeLinejoin: "round",
|
|
1501
|
+
className: "rte-editor-icon",
|
|
1502
|
+
children: ALIGN_PATHS[dir]
|
|
1503
|
+
}
|
|
1504
|
+
);
|
|
1505
|
+
var EditUrlIcon = () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1506
|
+
"svg",
|
|
1507
|
+
{
|
|
1508
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1509
|
+
viewBox: "0 0 24 24",
|
|
1510
|
+
fill: "none",
|
|
1511
|
+
stroke: "currentColor",
|
|
1512
|
+
strokeWidth: "2",
|
|
1513
|
+
strokeLinecap: "round",
|
|
1514
|
+
strokeLinejoin: "round",
|
|
1515
|
+
className: "rte-editor-icon",
|
|
1516
|
+
children: [
|
|
1517
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 20h9" }),
|
|
1518
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
|
|
1519
|
+
]
|
|
1520
|
+
}
|
|
1521
|
+
);
|
|
1522
|
+
var OpenInYouTubeIcon = () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1523
|
+
"svg",
|
|
1524
|
+
{
|
|
1525
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1526
|
+
viewBox: "0 0 24 24",
|
|
1527
|
+
fill: "none",
|
|
1528
|
+
stroke: "currentColor",
|
|
1529
|
+
strokeWidth: "2",
|
|
1530
|
+
strokeLinecap: "round",
|
|
1531
|
+
strokeLinejoin: "round",
|
|
1532
|
+
className: "rte-editor-icon",
|
|
1533
|
+
children: [
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("polyline", { points: "15 3 21 3 21 9" }),
|
|
1536
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
1537
|
+
]
|
|
1538
|
+
}
|
|
1539
|
+
);
|
|
1540
|
+
var DeleteEmbedIcon = () => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1541
|
+
"svg",
|
|
1542
|
+
{
|
|
1543
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1544
|
+
viewBox: "0 0 24 24",
|
|
1545
|
+
fill: "none",
|
|
1546
|
+
stroke: "currentColor",
|
|
1547
|
+
strokeWidth: "2",
|
|
1548
|
+
strokeLinecap: "round",
|
|
1549
|
+
strokeLinejoin: "round",
|
|
1550
|
+
className: "rte-editor-icon",
|
|
1551
|
+
children: [
|
|
1552
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("polyline", { points: "3 6 5 6 21 6" }),
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
1554
|
+
]
|
|
1555
|
+
}
|
|
1556
|
+
);
|
|
1557
|
+
var iconProps = { className: "rte-editor-icon" };
|
|
1558
|
+
var LangIcon = ({
|
|
1559
|
+
children,
|
|
1560
|
+
className
|
|
1561
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1562
|
+
"svg",
|
|
1563
|
+
{
|
|
1564
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1565
|
+
viewBox: "0 0 24 24",
|
|
1566
|
+
fill: "none",
|
|
1567
|
+
stroke: "currentColor",
|
|
1568
|
+
strokeWidth: 1.5,
|
|
1569
|
+
strokeLinecap: "round",
|
|
1570
|
+
strokeLinejoin: "round",
|
|
1571
|
+
className,
|
|
1572
|
+
children
|
|
1573
|
+
}
|
|
1574
|
+
);
|
|
1575
|
+
var DEFAULT_LANGUAGE_ICONS = {
|
|
1576
|
+
bash: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1577
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
|
|
1578
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
|
|
1579
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 15.5h5.5" })
|
|
1580
|
+
] }),
|
|
1581
|
+
c: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1582
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "12", cy: "12", r: "8.5" }),
|
|
1583
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
|
|
1584
|
+
] }),
|
|
1585
|
+
cpp: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "9.5", cy: "12", r: "6.5" }),
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M15.7 10.5v3M14.2 12h3" }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M19.3 10.5v3M17.8 12h3" })
|
|
1590
|
+
] }),
|
|
1591
|
+
css: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9.7 7.5l-1 9" }),
|
|
1594
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M15.3 7.5l-1 9" }),
|
|
1595
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M7 10.3h11" }),
|
|
1596
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6.5 14.3h11" })
|
|
1597
|
+
] }),
|
|
1598
|
+
go: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12.6 12h-1.9" }),
|
|
1602
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "17", cy: "12", r: "2.9" })
|
|
1603
|
+
] }),
|
|
1604
|
+
html: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
|
|
1607
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
|
|
1608
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M13 7.3l-2 9.4" })
|
|
1609
|
+
] }),
|
|
1610
|
+
java: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1611
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
|
|
1612
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
|
|
1614
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6 19.3h10" })
|
|
1615
|
+
] }),
|
|
1616
|
+
javascript: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1617
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1618
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
|
|
1619
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1620
|
+
] }),
|
|
1621
|
+
json: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
|
|
1624
|
+
] }),
|
|
1625
|
+
kotlin: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1627
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9 7.5v9" }),
|
|
1628
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9 12l6-4.5" }),
|
|
1629
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9 12l6 4.5" })
|
|
1630
|
+
] }),
|
|
1631
|
+
markdown: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1632
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
|
|
1633
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6 15V9l3 4 3-4v6" }),
|
|
1634
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16.5 9v6" }),
|
|
1635
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M14.5 13l2 2 2-2" })
|
|
1636
|
+
] }),
|
|
1637
|
+
php: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1638
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1639
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
|
|
1640
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
|
|
1641
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
|
|
1642
|
+
] }),
|
|
1643
|
+
plaintext: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1644
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
|
|
1645
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
|
|
1646
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
|
|
1648
|
+
] }),
|
|
1649
|
+
python: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1650
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
|
|
1651
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
|
|
1652
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
|
|
1654
|
+
] }),
|
|
1655
|
+
ruby: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M4.5 8h15" }),
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 2.5v19" })
|
|
1659
|
+
] }),
|
|
1660
|
+
rust: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "12", cy: "12", r: "7" }),
|
|
1662
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("circle", { cx: "12", cy: "12", r: "2.3" }),
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
|
|
1664
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
|
|
1665
|
+
] }),
|
|
1666
|
+
sql: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
|
|
1670
|
+
] }),
|
|
1671
|
+
swift: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LangIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
|
|
1672
|
+
typescript: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1674
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1676
|
+
] }),
|
|
1677
|
+
xml: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1678
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M8 7l-4.5 5 4.5 5" }),
|
|
1679
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M16 7l4.5 5-4.5 5" }),
|
|
1680
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M12 8v8" })
|
|
1681
|
+
] }),
|
|
1682
|
+
yaml: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(LangIcon, { children: [
|
|
1683
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
|
|
1684
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6.5 8h2M9.5 8h8" }),
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6.5 12h2M9.5 12h6" }),
|
|
1686
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("path", { d: "M6.5 16h2M9.5 16h7" })
|
|
1687
|
+
] })
|
|
1688
|
+
};
|
|
1689
|
+
var DEFAULT_ICONS = {
|
|
1690
|
+
alignCenterControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.TextAlignCenter, { ...iconProps }),
|
|
1691
|
+
alignJustifyControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.TextAlignJustify, { ...iconProps }),
|
|
1692
|
+
alignLeftControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.TextAlignStart, { ...iconProps }),
|
|
1693
|
+
alignRightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.TextAlignEnd, { ...iconProps }),
|
|
1694
|
+
blockquoteControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.TextQuote, { ...iconProps }),
|
|
1695
|
+
boldControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Bold, { ...iconProps }),
|
|
1696
|
+
bulletListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.List, { ...iconProps }),
|
|
1697
|
+
clearFormattingControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.RemoveFormatting, { ...iconProps }),
|
|
1698
|
+
codeBlockControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.SquareCode, { ...iconProps }),
|
|
1699
|
+
codeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Code, { ...iconProps }),
|
|
1700
|
+
h1ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading1, { ...iconProps }),
|
|
1701
|
+
h2ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading2, { ...iconProps }),
|
|
1702
|
+
h3ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading3, { ...iconProps }),
|
|
1703
|
+
h4ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading4, { ...iconProps }),
|
|
1704
|
+
h5ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading5, { ...iconProps }),
|
|
1705
|
+
h6ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Heading6, { ...iconProps }),
|
|
1706
|
+
highlightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Highlighter, { ...iconProps }),
|
|
1707
|
+
hrControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Minus, { ...iconProps }),
|
|
1708
|
+
italicControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Italic, { ...iconProps }),
|
|
1709
|
+
languageIcons: DEFAULT_LANGUAGE_ICONS,
|
|
1710
|
+
linkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Link, { ...iconProps }),
|
|
1711
|
+
orderedListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.ListOrdered, { ...iconProps }),
|
|
1712
|
+
redoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Redo2, { ...iconProps }),
|
|
1713
|
+
strikeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Strikethrough, { ...iconProps }),
|
|
1714
|
+
subscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Subscript, { ...iconProps }),
|
|
1715
|
+
superscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Superscript, { ...iconProps }),
|
|
1716
|
+
underlineControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Underline, { ...iconProps }),
|
|
1717
|
+
undoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Undo2, { ...iconProps }),
|
|
1718
|
+
unlinkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react.Link2Off, { ...iconProps })
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1721
|
+
// src/extensions/resizable-node-view.tsx
|
|
1722
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1723
|
+
var EmbedToolbar = ({
|
|
1724
|
+
align,
|
|
1725
|
+
videoSrc,
|
|
1726
|
+
watchUrl,
|
|
1727
|
+
deleteNode,
|
|
1728
|
+
inputRef,
|
|
1729
|
+
isEditingUrl,
|
|
1730
|
+
urlInput,
|
|
1731
|
+
setUrlInput,
|
|
1732
|
+
setIsEditingUrl,
|
|
1733
|
+
handleSaveUrl,
|
|
1734
|
+
handleApplyPreset,
|
|
1735
|
+
updateAttributes,
|
|
1736
|
+
nodeSrc
|
|
1737
|
+
}) => {
|
|
1738
|
+
if (isEditingUrl) {
|
|
1739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "rte-embed-selector-edit-form", children: [
|
|
1740
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1741
|
+
"input",
|
|
1742
|
+
{
|
|
1743
|
+
ref: inputRef,
|
|
1744
|
+
type: "text",
|
|
1745
|
+
value: urlInput,
|
|
1746
|
+
onChange: (e) => setUrlInput(e.target.value),
|
|
1747
|
+
placeholder: "Paste YouTube URL or video ID...",
|
|
1748
|
+
className: "rte-embed-selector-input",
|
|
1749
|
+
onKeyDown: (e) => {
|
|
1750
|
+
if (e.key === "Enter") {
|
|
1751
|
+
handleSaveUrl();
|
|
1752
|
+
} else if (e.key === "Escape") {
|
|
1753
|
+
setIsEditingUrl(false);
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
),
|
|
1758
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1759
|
+
"button",
|
|
1760
|
+
{
|
|
1761
|
+
type: "button",
|
|
1762
|
+
onClick: handleSaveUrl,
|
|
1763
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--save",
|
|
1764
|
+
children: "Save"
|
|
1765
|
+
}
|
|
1766
|
+
),
|
|
1767
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1768
|
+
"button",
|
|
1769
|
+
{
|
|
1770
|
+
type: "button",
|
|
1771
|
+
onClick: () => setIsEditingUrl(false),
|
|
1772
|
+
className: "rte-embed-selector-btn",
|
|
1773
|
+
children: "Cancel"
|
|
1774
|
+
}
|
|
1775
|
+
)
|
|
1776
|
+
] });
|
|
1777
|
+
}
|
|
1778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
1779
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1780
|
+
"button",
|
|
1781
|
+
{
|
|
1782
|
+
type: "button",
|
|
1783
|
+
title: `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
|
|
1784
|
+
"aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
|
|
1785
|
+
className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
|
|
1786
|
+
onClick: () => updateAttributes({ align: dir }),
|
|
1787
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(AlignIcon, { dir })
|
|
1788
|
+
},
|
|
1789
|
+
dir
|
|
1790
|
+
)) }),
|
|
1791
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "rte-embed-selector-divider" }),
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1793
|
+
"button",
|
|
1794
|
+
{
|
|
1795
|
+
type: "button",
|
|
1796
|
+
title: `${pct}%`,
|
|
1797
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--preset",
|
|
1798
|
+
onClick: () => handleApplyPreset(pct),
|
|
1799
|
+
children: [
|
|
1800
|
+
pct,
|
|
1801
|
+
"%"
|
|
1802
|
+
]
|
|
1803
|
+
},
|
|
1804
|
+
pct
|
|
1805
|
+
)) }),
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "rte-embed-selector-divider" }),
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "rte-embed-selector-group", children: [
|
|
1808
|
+
(videoSrc || nodeSrc) && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1809
|
+
"button",
|
|
1810
|
+
{
|
|
1811
|
+
type: "button",
|
|
1812
|
+
title: "Edit URL",
|
|
1813
|
+
"aria-label": "Edit URL",
|
|
1814
|
+
className: "rte-embed-selector-btn",
|
|
1815
|
+
onClick: () => {
|
|
1816
|
+
setUrlInput(videoSrc || nodeSrc || "");
|
|
1817
|
+
setIsEditingUrl(true);
|
|
1818
|
+
},
|
|
1819
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(EditUrlIcon, {})
|
|
1820
|
+
}
|
|
1821
|
+
),
|
|
1822
|
+
watchUrl && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1823
|
+
"button",
|
|
1824
|
+
{
|
|
1825
|
+
type: "button",
|
|
1826
|
+
title: "Open video in YouTube",
|
|
1827
|
+
"aria-label": "Open video in YouTube",
|
|
1828
|
+
className: "rte-embed-selector-btn",
|
|
1829
|
+
onClick: () => window.open(watchUrl, "_blank"),
|
|
1830
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(OpenInYouTubeIcon, {})
|
|
1831
|
+
}
|
|
1832
|
+
),
|
|
1833
|
+
deleteNode && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1834
|
+
"button",
|
|
1835
|
+
{
|
|
1836
|
+
type: "button",
|
|
1837
|
+
title: "Delete Embed",
|
|
1838
|
+
"aria-label": "Delete Embed",
|
|
1839
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
|
|
1840
|
+
onClick: () => deleteNode(),
|
|
1841
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(DeleteEmbedIcon, {})
|
|
1842
|
+
}
|
|
1843
|
+
)
|
|
1844
|
+
] })
|
|
1845
|
+
] });
|
|
1846
|
+
};
|
|
953
1847
|
var ResizableNodeView = ({
|
|
954
1848
|
node,
|
|
955
1849
|
selected,
|
|
956
1850
|
updateAttributes,
|
|
1851
|
+
deleteNode,
|
|
1852
|
+
editor,
|
|
957
1853
|
view,
|
|
958
1854
|
children,
|
|
959
1855
|
lockAspect = false,
|
|
960
1856
|
aspectRatio = 16 / 9,
|
|
961
1857
|
minWidth = 300,
|
|
962
|
-
maxWidth = 1200
|
|
1858
|
+
maxWidth = 1200,
|
|
1859
|
+
videoSrc,
|
|
1860
|
+
watchUrl,
|
|
1861
|
+
onSrcChange
|
|
963
1862
|
}) => {
|
|
964
|
-
const containerRef = (0,
|
|
965
|
-
const
|
|
1863
|
+
const containerRef = (0, import_react13.useRef)(null);
|
|
1864
|
+
const [isEditingUrl, setIsEditingUrl] = (0, import_react13.useState)(false);
|
|
1865
|
+
const [urlInput, setUrlInput] = (0, import_react13.useState)(videoSrc || "");
|
|
1866
|
+
const [isResizing, setIsResizing] = (0, import_react13.useState)(false);
|
|
1867
|
+
const [currentDimensions, setCurrentDimensions] = (0, import_react13.useState)(null);
|
|
1868
|
+
const resizingRef = (0, import_react13.useRef)(null);
|
|
966
1869
|
const width = node.attrs.width;
|
|
967
1870
|
const height = node.attrs.height;
|
|
968
1871
|
const align = node.attrs.align || "center";
|
|
969
|
-
const getEditorWidth = (0,
|
|
970
|
-
() => view?.dom?.parentElement?.offsetWidth ??
|
|
1872
|
+
const getEditorWidth = (0, import_react13.useCallback)(
|
|
1873
|
+
() => view?.dom?.parentElement?.offsetWidth ?? 800,
|
|
971
1874
|
[view]
|
|
972
1875
|
);
|
|
973
|
-
const
|
|
1876
|
+
const inputRef = (0, import_react13.useRef)(null);
|
|
1877
|
+
(0, import_react13.useEffect)(() => {
|
|
1878
|
+
if (isEditingUrl) {
|
|
1879
|
+
inputRef.current?.focus();
|
|
1880
|
+
}
|
|
1881
|
+
}, [isEditingUrl]);
|
|
1882
|
+
const handleMouseMove = (0, import_react13.useCallback)(
|
|
974
1883
|
(e) => {
|
|
975
1884
|
const resize = resizingRef.current;
|
|
976
1885
|
if (!resize) {
|
|
@@ -979,7 +1888,7 @@ var ResizableNodeView = ({
|
|
|
979
1888
|
const effectiveMax = Math.min(maxWidth, resize.editorWidth);
|
|
980
1889
|
let newWidth = resize.startWidth;
|
|
981
1890
|
let newHeight = resize.startHeight;
|
|
982
|
-
if (resize.direction === "right" || resize.direction === "corner") {
|
|
1891
|
+
if (resize.direction === "right" || resize.direction === "corner-br") {
|
|
983
1892
|
newWidth = Math.max(
|
|
984
1893
|
minWidth,
|
|
985
1894
|
Math.min(
|
|
@@ -987,8 +1896,16 @@ var ResizableNodeView = ({
|
|
|
987
1896
|
resize.startWidth + (e.clientX - resize.startX)
|
|
988
1897
|
)
|
|
989
1898
|
);
|
|
1899
|
+
} else if (resize.direction === "left" || resize.direction === "corner-bl") {
|
|
1900
|
+
newWidth = Math.max(
|
|
1901
|
+
minWidth,
|
|
1902
|
+
Math.min(
|
|
1903
|
+
effectiveMax,
|
|
1904
|
+
resize.startWidth - (e.clientX - resize.startX)
|
|
1905
|
+
)
|
|
1906
|
+
);
|
|
990
1907
|
}
|
|
991
|
-
if (resize.direction === "bottom" || resize.direction === "corner") {
|
|
1908
|
+
if (resize.direction === "bottom" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
|
|
992
1909
|
newHeight = Math.max(
|
|
993
1910
|
Math.round(minWidth / aspectRatio),
|
|
994
1911
|
Math.min(
|
|
@@ -998,7 +1915,7 @@ var ResizableNodeView = ({
|
|
|
998
1915
|
);
|
|
999
1916
|
}
|
|
1000
1917
|
if (lockAspect) {
|
|
1001
|
-
if (resize.direction === "right" || resize.direction === "corner") {
|
|
1918
|
+
if (resize.direction === "left" || resize.direction === "right" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
|
|
1002
1919
|
newHeight = Math.round(newWidth / aspectRatio);
|
|
1003
1920
|
} else {
|
|
1004
1921
|
newWidth = Math.round(newHeight * aspectRatio);
|
|
@@ -1008,10 +1925,11 @@ var ResizableNodeView = ({
|
|
|
1008
1925
|
containerRef.current.style.width = `${newWidth}px`;
|
|
1009
1926
|
containerRef.current.style.height = `${newHeight}px`;
|
|
1010
1927
|
}
|
|
1928
|
+
setCurrentDimensions({ h: newHeight, w: newWidth });
|
|
1011
1929
|
},
|
|
1012
1930
|
[lockAspect, aspectRatio, minWidth, maxWidth]
|
|
1013
1931
|
);
|
|
1014
|
-
const handleMouseUp = (0,
|
|
1932
|
+
const handleMouseUp = (0, import_react13.useCallback)(
|
|
1015
1933
|
function handleMouseUp2() {
|
|
1016
1934
|
const resize = resizingRef.current;
|
|
1017
1935
|
if (!resize) {
|
|
@@ -1027,10 +1945,12 @@ var ResizableNodeView = ({
|
|
|
1027
1945
|
updateAttributes({ height: h, width: w });
|
|
1028
1946
|
}
|
|
1029
1947
|
resizingRef.current = null;
|
|
1948
|
+
setIsResizing(false);
|
|
1949
|
+
setCurrentDimensions(null);
|
|
1030
1950
|
},
|
|
1031
1951
|
[handleMouseMove, updateAttributes]
|
|
1032
1952
|
);
|
|
1033
|
-
const handleMouseDown = (0,
|
|
1953
|
+
const handleMouseDown = (0, import_react13.useCallback)(
|
|
1034
1954
|
(e, direction) => {
|
|
1035
1955
|
e.preventDefault();
|
|
1036
1956
|
e.stopPropagation();
|
|
@@ -1045,20 +1965,23 @@ var ResizableNodeView = ({
|
|
|
1045
1965
|
startX: e.clientX,
|
|
1046
1966
|
startY: e.clientY
|
|
1047
1967
|
};
|
|
1968
|
+
setIsResizing(true);
|
|
1969
|
+
setCurrentDimensions({ h: startHeight, w: startWidth });
|
|
1048
1970
|
document.addEventListener("mousemove", handleMouseMove);
|
|
1049
1971
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1972
|
+
const cursors = {
|
|
1973
|
+
bottom: "ns-resize",
|
|
1974
|
+
"corner-bl": "nesw-resize",
|
|
1975
|
+
"corner-br": "nwse-resize",
|
|
1976
|
+
left: "ew-resize",
|
|
1977
|
+
right: "ew-resize"
|
|
1978
|
+
};
|
|
1979
|
+
document.body.style.cursor = cursors[direction];
|
|
1057
1980
|
document.body.style.userSelect = "none";
|
|
1058
1981
|
},
|
|
1059
1982
|
[width, height, getEditorWidth, handleMouseMove, handleMouseUp]
|
|
1060
1983
|
);
|
|
1061
|
-
(0,
|
|
1984
|
+
(0, import_react13.useEffect)(
|
|
1062
1985
|
() => () => {
|
|
1063
1986
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
1064
1987
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -1067,13 +1990,32 @@ var ResizableNodeView = ({
|
|
|
1067
1990
|
},
|
|
1068
1991
|
[handleMouseMove, handleMouseUp]
|
|
1069
1992
|
);
|
|
1070
|
-
|
|
1071
|
-
|
|
1993
|
+
const handleApplyPreset = (percent) => {
|
|
1994
|
+
const editorW = getEditorWidth() || 800;
|
|
1995
|
+
const targetW = Math.round(
|
|
1996
|
+
Math.max(minWidth, Math.min(maxWidth, editorW * percent / 100))
|
|
1997
|
+
);
|
|
1998
|
+
updateAttributes({
|
|
1999
|
+
height: Math.round(targetW / aspectRatio),
|
|
2000
|
+
width: targetW
|
|
2001
|
+
});
|
|
2002
|
+
};
|
|
2003
|
+
const handleSaveUrl = () => {
|
|
2004
|
+
if (urlInput && onSrcChange) {
|
|
2005
|
+
onSrcChange(urlInput);
|
|
2006
|
+
} else if (urlInput) {
|
|
2007
|
+
updateAttributes({ src: urlInput });
|
|
2008
|
+
}
|
|
2009
|
+
setIsEditingUrl(false);
|
|
2010
|
+
};
|
|
2011
|
+
const isEditable = editor ? editor.isEditable : true;
|
|
2012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2013
|
+
import_react12.NodeViewWrapper,
|
|
1072
2014
|
{
|
|
1073
2015
|
className: "rte-embed-wrapper",
|
|
1074
2016
|
"data-selected": selected || void 0,
|
|
1075
2017
|
"data-align": align,
|
|
1076
|
-
children: /* @__PURE__ */ (0,
|
|
2018
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1077
2019
|
"div",
|
|
1078
2020
|
{
|
|
1079
2021
|
ref: containerRef,
|
|
@@ -1082,207 +2024,232 @@ var ResizableNodeView = ({
|
|
|
1082
2024
|
style: {
|
|
1083
2025
|
height: height ? `${height}px` : "auto",
|
|
1084
2026
|
minWidth: `${minWidth}px`,
|
|
1085
|
-
width: width ? `${width}px` : "100%"
|
|
1086
|
-
},
|
|
1087
|
-
children: [
|
|
1088
|
-
children,
|
|
1089
|
-
selected && /* @__PURE__ */ (0,
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
),
|
|
1159
|
-
...props,
|
|
1160
|
-
children: [
|
|
1161
|
-
children,
|
|
1162
|
-
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1163
|
-
import_dialog.Dialog.Close,
|
|
1164
|
-
{
|
|
1165
|
-
"data-slot": "dialog-close",
|
|
1166
|
-
render: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1167
|
-
Button,
|
|
1168
|
-
{
|
|
1169
|
-
variant: "ghost",
|
|
1170
|
-
className: "absolute top-2 right-2",
|
|
1171
|
-
size: "icon-sm"
|
|
1172
|
-
}
|
|
1173
|
-
),
|
|
1174
|
-
children: [
|
|
1175
|
-
"X",
|
|
1176
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "Close" })
|
|
1177
|
-
]
|
|
1178
|
-
}
|
|
1179
|
-
)
|
|
1180
|
-
]
|
|
2027
|
+
width: width ? `${width}px` : "100%"
|
|
2028
|
+
},
|
|
2029
|
+
children: [
|
|
2030
|
+
children,
|
|
2031
|
+
selected && isEditable && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2032
|
+
EmbedToolbar,
|
|
2033
|
+
{
|
|
2034
|
+
align,
|
|
2035
|
+
videoSrc,
|
|
2036
|
+
watchUrl,
|
|
2037
|
+
deleteNode,
|
|
2038
|
+
inputRef,
|
|
2039
|
+
isEditingUrl,
|
|
2040
|
+
urlInput,
|
|
2041
|
+
setUrlInput,
|
|
2042
|
+
setIsEditingUrl,
|
|
2043
|
+
handleSaveUrl,
|
|
2044
|
+
handleApplyPreset,
|
|
2045
|
+
updateAttributes,
|
|
2046
|
+
nodeSrc: node.attrs.src
|
|
2047
|
+
}
|
|
2048
|
+
) }),
|
|
2049
|
+
isResizing && currentDimensions && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "rte-embed-resize-badge", children: [
|
|
2050
|
+
currentDimensions.w,
|
|
2051
|
+
" \xD7 ",
|
|
2052
|
+
currentDimensions.h,
|
|
2053
|
+
" px"
|
|
2054
|
+
] }),
|
|
2055
|
+
selected && isEditable && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2057
|
+
"div",
|
|
2058
|
+
{
|
|
2059
|
+
className: "rte-resize-handle rte-resize-handle--left",
|
|
2060
|
+
onMouseDown: (e) => handleMouseDown(e, "left"),
|
|
2061
|
+
role: "presentation"
|
|
2062
|
+
}
|
|
2063
|
+
),
|
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2065
|
+
"div",
|
|
2066
|
+
{
|
|
2067
|
+
className: "rte-resize-handle rte-resize-handle--right",
|
|
2068
|
+
onMouseDown: (e) => handleMouseDown(e, "right"),
|
|
2069
|
+
role: "presentation"
|
|
2070
|
+
}
|
|
2071
|
+
),
|
|
2072
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2073
|
+
"div",
|
|
2074
|
+
{
|
|
2075
|
+
className: "rte-resize-handle rte-resize-handle--bottom",
|
|
2076
|
+
onMouseDown: (e) => handleMouseDown(e, "bottom"),
|
|
2077
|
+
role: "presentation"
|
|
2078
|
+
}
|
|
2079
|
+
),
|
|
2080
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2081
|
+
"div",
|
|
2082
|
+
{
|
|
2083
|
+
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
|
|
2084
|
+
onMouseDown: (e) => handleMouseDown(e, "corner-bl"),
|
|
2085
|
+
role: "presentation"
|
|
2086
|
+
}
|
|
2087
|
+
),
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2089
|
+
"div",
|
|
2090
|
+
{
|
|
2091
|
+
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
|
|
2092
|
+
onMouseDown: (e) => handleMouseDown(e, "corner-br"),
|
|
2093
|
+
role: "presentation"
|
|
2094
|
+
}
|
|
2095
|
+
)
|
|
2096
|
+
] })
|
|
2097
|
+
]
|
|
2098
|
+
}
|
|
2099
|
+
)
|
|
1181
2100
|
}
|
|
1182
|
-
)
|
|
1183
|
-
|
|
1184
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1185
|
-
"div",
|
|
1186
|
-
{
|
|
1187
|
-
"data-slot": "dialog-header",
|
|
1188
|
-
className: cn("flex flex-col gap-1 text-left", className),
|
|
1189
|
-
...props
|
|
1190
|
-
}
|
|
1191
|
-
);
|
|
1192
|
-
var DialogFooter = ({
|
|
1193
|
-
className,
|
|
1194
|
-
showCloseButton = false,
|
|
1195
|
-
children,
|
|
1196
|
-
...props
|
|
1197
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1198
|
-
"div",
|
|
1199
|
-
{
|
|
1200
|
-
"data-slot": "dialog-footer",
|
|
1201
|
-
className: cn(
|
|
1202
|
-
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
1203
|
-
className
|
|
1204
|
-
),
|
|
1205
|
-
...props,
|
|
1206
|
-
children: [
|
|
1207
|
-
children,
|
|
1208
|
-
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Button, { variant: "outline" }), children: "Close" })
|
|
1209
|
-
]
|
|
1210
|
-
}
|
|
1211
|
-
);
|
|
1212
|
-
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1213
|
-
import_dialog.Dialog.Title,
|
|
1214
|
-
{
|
|
1215
|
-
"data-slot": "dialog-title",
|
|
1216
|
-
className: cn("text-sm font-medium", className),
|
|
1217
|
-
...props
|
|
1218
|
-
}
|
|
1219
|
-
);
|
|
1220
|
-
var DialogDescription = ({
|
|
1221
|
-
className,
|
|
1222
|
-
...props
|
|
1223
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1224
|
-
import_dialog.Dialog.Description,
|
|
1225
|
-
{
|
|
1226
|
-
"data-slot": "dialog-description",
|
|
1227
|
-
className: cn(
|
|
1228
|
-
"text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
|
|
1229
|
-
className
|
|
1230
|
-
),
|
|
1231
|
-
...props
|
|
1232
|
-
}
|
|
1233
|
-
);
|
|
2101
|
+
);
|
|
2102
|
+
};
|
|
1234
2103
|
|
|
1235
2104
|
// src/controls/rte-twitter-control.tsx
|
|
1236
|
-
var
|
|
2105
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1237
2106
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
2107
|
+
var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
|
|
2108
|
+
var READY_POLL_INTERVAL_MS = 50;
|
|
2109
|
+
var twitterScriptPromise = null;
|
|
2110
|
+
var loadTwitterScript = () => {
|
|
2111
|
+
if (typeof window === "undefined") {
|
|
2112
|
+
return Promise.resolve();
|
|
2113
|
+
}
|
|
2114
|
+
if (window.twttr?.widgets) {
|
|
2115
|
+
return Promise.resolve();
|
|
2116
|
+
}
|
|
2117
|
+
if (twitterScriptPromise) {
|
|
2118
|
+
return twitterScriptPromise;
|
|
2119
|
+
}
|
|
2120
|
+
twitterScriptPromise = new Promise((resolve, reject) => {
|
|
2121
|
+
let script = document.querySelector(
|
|
2122
|
+
`script[src="${WIDGET_SCRIPT_URL}"]`
|
|
2123
|
+
);
|
|
2124
|
+
const isNewScript = !script;
|
|
2125
|
+
if (!script) {
|
|
2126
|
+
script = document.createElement("script");
|
|
2127
|
+
script.src = WIDGET_SCRIPT_URL;
|
|
2128
|
+
script.async = true;
|
|
2129
|
+
document.body.append(script);
|
|
2130
|
+
}
|
|
2131
|
+
let settled = false;
|
|
2132
|
+
const timers = {};
|
|
2133
|
+
const cleanup = () => {
|
|
2134
|
+
clearInterval(timers.poll);
|
|
2135
|
+
clearTimeout(timers.timeout);
|
|
2136
|
+
};
|
|
2137
|
+
const succeed = () => {
|
|
2138
|
+
if (settled) {
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
settled = true;
|
|
2142
|
+
cleanup();
|
|
2143
|
+
resolve();
|
|
2144
|
+
};
|
|
2145
|
+
const fail = () => {
|
|
2146
|
+
if (settled) {
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
settled = true;
|
|
2150
|
+
cleanup();
|
|
2151
|
+
twitterScriptPromise = null;
|
|
2152
|
+
reject(new Error("Failed to load Twitter widgets script"));
|
|
2153
|
+
};
|
|
2154
|
+
if (window.twttr?.widgets) {
|
|
2155
|
+
succeed();
|
|
2156
|
+
return;
|
|
2157
|
+
}
|
|
2158
|
+
timers.poll = setInterval(() => {
|
|
2159
|
+
if (window.twttr?.widgets) {
|
|
2160
|
+
succeed();
|
|
2161
|
+
}
|
|
2162
|
+
}, READY_POLL_INTERVAL_MS);
|
|
2163
|
+
timers.timeout = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
|
|
2164
|
+
if (isNewScript) {
|
|
2165
|
+
script.addEventListener(
|
|
2166
|
+
"load",
|
|
2167
|
+
() => {
|
|
2168
|
+
if (window.twttr?.widgets) {
|
|
2169
|
+
succeed();
|
|
2170
|
+
}
|
|
2171
|
+
},
|
|
2172
|
+
{ once: true }
|
|
2173
|
+
);
|
|
2174
|
+
}
|
|
2175
|
+
script.addEventListener("error", fail, { once: true });
|
|
2176
|
+
});
|
|
2177
|
+
return twitterScriptPromise;
|
|
2178
|
+
};
|
|
1238
2179
|
var TwitterNodeView = (props) => {
|
|
1239
2180
|
const { node } = props;
|
|
1240
|
-
const containerRef = (0,
|
|
1241
|
-
const [loading, setLoading] = (0,
|
|
2181
|
+
const containerRef = (0, import_react15.useRef)(null);
|
|
2182
|
+
const [loading, setLoading] = (0, import_react15.useState)(true);
|
|
2183
|
+
const [failed, setFailed] = (0, import_react15.useState)(false);
|
|
1242
2184
|
const { tweetId } = node.attrs;
|
|
1243
|
-
const
|
|
1244
|
-
const
|
|
1245
|
-
const
|
|
2185
|
+
const renderedTweetIdRef = (0, import_react15.useRef)(null);
|
|
2186
|
+
const activeRenderIdRef = (0, import_react15.useRef)(0);
|
|
2187
|
+
const retryToken = (0, import_react15.useRef)(0);
|
|
2188
|
+
const [retryCount, setRetryCount] = (0, import_react15.useState)(0);
|
|
2189
|
+
(0, import_react15.useEffect)(() => {
|
|
1246
2190
|
if (!containerRef.current || !tweetId) {
|
|
1247
2191
|
return;
|
|
1248
2192
|
}
|
|
1249
|
-
containerRef.current.
|
|
1250
|
-
|
|
1251
|
-
const { twttr } = window;
|
|
1252
|
-
if (twttr?.widgets && containerRef.current) {
|
|
1253
|
-
try {
|
|
1254
|
-
await twttr.widgets.createTweet(tweetId, containerRef.current);
|
|
1255
|
-
setLoading(false);
|
|
1256
|
-
} catch {
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
}, [tweetId]);
|
|
1260
|
-
(0, import_react12.useEffect)(() => {
|
|
1261
|
-
if (!containerRef.current || !tweetId) {
|
|
2193
|
+
if (renderedTweetIdRef.current === tweetId && containerRef.current.children.length > 0 && !failed) {
|
|
2194
|
+
setLoading(false);
|
|
1262
2195
|
return;
|
|
1263
2196
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
2197
|
+
let isCancelled = false;
|
|
2198
|
+
activeRenderIdRef.current += 1;
|
|
2199
|
+
const renderId = activeRenderIdRef.current;
|
|
2200
|
+
setLoading(true);
|
|
2201
|
+
setFailed(false);
|
|
2202
|
+
const render = async () => {
|
|
2203
|
+
try {
|
|
2204
|
+
await loadTwitterScript();
|
|
2205
|
+
if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
const { twttr } = window;
|
|
2209
|
+
if (!twttr?.widgets) {
|
|
2210
|
+
throw new Error("Twitter widgets script unavailable");
|
|
2211
|
+
}
|
|
1266
2212
|
containerRef.current.innerHTML = "";
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
2213
|
+
const el = await twttr.widgets.createTweet(
|
|
2214
|
+
tweetId,
|
|
2215
|
+
containerRef.current
|
|
2216
|
+
);
|
|
2217
|
+
if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
|
|
2218
|
+
if (el && typeof el.remove === "function") {
|
|
2219
|
+
el.remove();
|
|
2220
|
+
} else if (containerRef.current) {
|
|
2221
|
+
containerRef.current.innerHTML = "";
|
|
2222
|
+
}
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
if (!el) {
|
|
2226
|
+
throw new Error("Tweet could not be embedded");
|
|
2227
|
+
}
|
|
2228
|
+
while (containerRef.current.children.length > 1) {
|
|
2229
|
+
containerRef.current.firstElementChild?.remove();
|
|
2230
|
+
}
|
|
2231
|
+
renderedTweetIdRef.current = tweetId;
|
|
2232
|
+
} catch {
|
|
2233
|
+
if (!isCancelled && renderId === activeRenderIdRef.current) {
|
|
2234
|
+
setFailed(true);
|
|
2235
|
+
renderedTweetIdRef.current = null;
|
|
2236
|
+
}
|
|
2237
|
+
} finally {
|
|
2238
|
+
if (!isCancelled && renderId === activeRenderIdRef.current) {
|
|
1270
2239
|
setLoading(false);
|
|
1271
|
-
} catch {
|
|
1272
2240
|
}
|
|
1273
|
-
} else {
|
|
1274
|
-
const script = document.createElement("script");
|
|
1275
|
-
script.src = WIDGET_SCRIPT_URL;
|
|
1276
|
-
script.async = true;
|
|
1277
|
-
script.addEventListener("load", () => {
|
|
1278
|
-
void renderTweet();
|
|
1279
|
-
});
|
|
1280
|
-
document.body.append(script);
|
|
1281
2241
|
}
|
|
1282
2242
|
};
|
|
1283
|
-
void
|
|
1284
|
-
|
|
1285
|
-
|
|
2243
|
+
void render();
|
|
2244
|
+
return () => {
|
|
2245
|
+
isCancelled = true;
|
|
2246
|
+
};
|
|
2247
|
+
}, [tweetId, retryCount, failed]);
|
|
2248
|
+
const handleRetry = (0, import_react15.useCallback)(() => {
|
|
2249
|
+
retryToken.current += 1;
|
|
2250
|
+
setRetryCount(retryToken.current);
|
|
2251
|
+
}, []);
|
|
2252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1286
2253
|
ResizableNodeView,
|
|
1287
2254
|
{
|
|
1288
2255
|
...props,
|
|
@@ -1290,8 +2257,12 @@ var TwitterNodeView = (props) => {
|
|
|
1290
2257
|
minWidth: 300,
|
|
1291
2258
|
maxWidth: 1200,
|
|
1292
2259
|
children: [
|
|
1293
|
-
loading && /* @__PURE__ */ (0,
|
|
1294
|
-
/* @__PURE__ */ (0,
|
|
2260
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
|
|
2261
|
+
!loading && failed && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "rte-embed-error", children: [
|
|
2262
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { children: "Couldn't load this tweet." }),
|
|
2263
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("button", { type: "button", onClick: handleRetry, children: "Retry" })
|
|
2264
|
+
] }),
|
|
2265
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ref: containerRef })
|
|
1295
2266
|
]
|
|
1296
2267
|
}
|
|
1297
2268
|
);
|
|
@@ -1347,7 +2318,7 @@ var TwitterEmbed = import_core2.Node.create({
|
|
|
1347
2318
|
];
|
|
1348
2319
|
},
|
|
1349
2320
|
addNodeView() {
|
|
1350
|
-
return (0,
|
|
2321
|
+
return (0, import_react14.ReactNodeViewRenderer)(TwitterNodeView);
|
|
1351
2322
|
},
|
|
1352
2323
|
atom: true,
|
|
1353
2324
|
draggable: true,
|
|
@@ -1381,88 +2352,119 @@ var extractTweetId = (input) => {
|
|
|
1381
2352
|
};
|
|
1382
2353
|
var TwitterEmbedControl = ({ className }) => {
|
|
1383
2354
|
const { editor } = useRichTextEditorContext();
|
|
1384
|
-
const [open, setOpen] = (0,
|
|
1385
|
-
const [url, setUrl] = (0,
|
|
1386
|
-
const
|
|
2355
|
+
const [open, setOpen] = (0, import_react15.useState)(false);
|
|
2356
|
+
const [url, setUrl] = (0, import_react15.useState)("");
|
|
2357
|
+
const [touched, setTouched] = (0, import_react15.useState)(false);
|
|
2358
|
+
const { active } = (0, import_react14.useEditorState)({
|
|
1387
2359
|
editor: editor ?? null,
|
|
1388
2360
|
selector: (ctx) => ({
|
|
1389
2361
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
|
|
1390
2362
|
})
|
|
1391
2363
|
}) ?? { active: false };
|
|
1392
|
-
const
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
2364
|
+
const tweetId = url ? extractTweetId(url) : null;
|
|
2365
|
+
const showError = touched && url.length > 0 && !tweetId;
|
|
2366
|
+
const resetState = (0, import_react15.useCallback)(() => {
|
|
2367
|
+
setUrl("");
|
|
2368
|
+
setTouched(false);
|
|
2369
|
+
}, []);
|
|
2370
|
+
const handleInsert = (0, import_react15.useCallback)(() => {
|
|
2371
|
+
setTouched(true);
|
|
2372
|
+
if (!tweetId || !editor) {
|
|
2373
|
+
return false;
|
|
1399
2374
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
2375
|
+
editor.chain().focus().setTwitterEmbed(tweetId).run();
|
|
2376
|
+
resetState();
|
|
2377
|
+
return true;
|
|
2378
|
+
}, [tweetId, editor, resetState]);
|
|
2379
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2380
|
+
Dialog,
|
|
2381
|
+
{
|
|
2382
|
+
open,
|
|
2383
|
+
onOpenChange: (next) => {
|
|
2384
|
+
setOpen(next);
|
|
2385
|
+
if (!next) {
|
|
2386
|
+
resetState();
|
|
2387
|
+
}
|
|
2388
|
+
},
|
|
2389
|
+
children: [
|
|
2390
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2391
|
+
DialogTrigger,
|
|
1407
2392
|
{
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
title: "Embed Tweet",
|
|
1411
|
-
"aria-label": "Embed Tweet",
|
|
1412
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1413
|
-
"svg",
|
|
2393
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2394
|
+
RichTextEditorControl,
|
|
1414
2395
|
{
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
children: /* @__PURE__ */ (0,
|
|
2396
|
+
active,
|
|
2397
|
+
className,
|
|
2398
|
+
title: "Embed Tweet",
|
|
2399
|
+
"aria-label": "Embed Tweet",
|
|
2400
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2401
|
+
"svg",
|
|
2402
|
+
{
|
|
2403
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2404
|
+
viewBox: "0 0 24 24",
|
|
2405
|
+
fill: "currentColor",
|
|
2406
|
+
className: "rte-editor-icon",
|
|
2407
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.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" })
|
|
2408
|
+
}
|
|
2409
|
+
)
|
|
1420
2410
|
}
|
|
1421
2411
|
)
|
|
1422
2412
|
}
|
|
1423
|
-
)
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
2413
|
+
),
|
|
2414
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(DialogContent, { children: [
|
|
2415
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(DialogHeader, { children: [
|
|
2416
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogTitle, { children: "Embed Tweet" }),
|
|
2417
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
2418
|
+
] }),
|
|
2419
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2420
|
+
Input,
|
|
2421
|
+
{
|
|
2422
|
+
value: url,
|
|
2423
|
+
onChange: (e) => {
|
|
2424
|
+
setUrl(e.target.value);
|
|
2425
|
+
if (touched) {
|
|
2426
|
+
setTouched(false);
|
|
2427
|
+
}
|
|
2428
|
+
},
|
|
2429
|
+
onBlur: () => setTouched(true),
|
|
2430
|
+
placeholder: "https://x.com/user/status/...",
|
|
2431
|
+
"aria-invalid": showError,
|
|
2432
|
+
onKeyDown: (e) => {
|
|
2433
|
+
if (e.key === "Enter" && url && handleInsert()) {
|
|
2434
|
+
setOpen(false);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
1441
2437
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
2438
|
+
),
|
|
2439
|
+
showError && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
|
|
2440
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(DialogFooter, { children: [
|
|
2441
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DialogClose, { children: "Cancel" }),
|
|
2442
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2443
|
+
"button",
|
|
2444
|
+
{
|
|
2445
|
+
type: "button",
|
|
2446
|
+
disabled: !url,
|
|
2447
|
+
className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
|
|
2448
|
+
onClick: () => {
|
|
2449
|
+
if (handleInsert()) {
|
|
2450
|
+
setOpen(false);
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
children: "Insert"
|
|
2454
|
+
}
|
|
2455
|
+
)
|
|
2456
|
+
] })
|
|
2457
|
+
] })
|
|
2458
|
+
]
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
1459
2461
|
};
|
|
1460
2462
|
|
|
1461
2463
|
// src/controls/rte-youtube-control.tsx
|
|
1462
2464
|
var import_core3 = require("@tiptap/core");
|
|
1463
|
-
var
|
|
1464
|
-
var
|
|
1465
|
-
var
|
|
2465
|
+
var import_react16 = require("@tiptap/react");
|
|
2466
|
+
var import_react17 = require("react");
|
|
2467
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1466
2468
|
var getYouTubeId = (url) => {
|
|
1467
2469
|
const clean = url.trim();
|
|
1468
2470
|
const patterns = [
|
|
@@ -1483,9 +2485,14 @@ var getYouTubeId = (url) => {
|
|
|
1483
2485
|
return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
|
|
1484
2486
|
};
|
|
1485
2487
|
var YouTubeNodeView = (props) => {
|
|
1486
|
-
const { node } = props;
|
|
1487
|
-
const
|
|
1488
|
-
|
|
2488
|
+
const { node, updateAttributes } = props;
|
|
2489
|
+
const rawSrc = node.attrs.src || "";
|
|
2490
|
+
const videoId = getYouTubeId(rawSrc) || rawSrc;
|
|
2491
|
+
let watchUrl;
|
|
2492
|
+
if (videoId) {
|
|
2493
|
+
watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
|
|
2494
|
+
}
|
|
2495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1489
2496
|
ResizableNodeView,
|
|
1490
2497
|
{
|
|
1491
2498
|
...props,
|
|
@@ -1493,7 +2500,10 @@ var YouTubeNodeView = (props) => {
|
|
|
1493
2500
|
aspectRatio: 16 / 9,
|
|
1494
2501
|
minWidth: 320,
|
|
1495
2502
|
maxWidth: 1200,
|
|
1496
|
-
|
|
2503
|
+
videoSrc: rawSrc,
|
|
2504
|
+
watchUrl,
|
|
2505
|
+
onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
|
|
2506
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1497
2507
|
"iframe",
|
|
1498
2508
|
{
|
|
1499
2509
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -1557,7 +2567,7 @@ var YouTubeEmbed = import_core3.Node.create({
|
|
|
1557
2567
|
];
|
|
1558
2568
|
},
|
|
1559
2569
|
addNodeView() {
|
|
1560
|
-
return (0,
|
|
2570
|
+
return (0, import_react16.ReactNodeViewRenderer)(YouTubeNodeView);
|
|
1561
2571
|
},
|
|
1562
2572
|
atom: true,
|
|
1563
2573
|
draggable: true,
|
|
@@ -1581,32 +2591,32 @@ var YouTubeEmbed = import_core3.Node.create({
|
|
|
1581
2591
|
});
|
|
1582
2592
|
var YouTubeEmbedControl = ({ className }) => {
|
|
1583
2593
|
const { editor } = useRichTextEditorContext();
|
|
1584
|
-
const [open, setOpen] = (0,
|
|
1585
|
-
const [url, setUrl] = (0,
|
|
1586
|
-
const { active } = (0,
|
|
2594
|
+
const [open, setOpen] = (0, import_react17.useState)(false);
|
|
2595
|
+
const [url, setUrl] = (0, import_react17.useState)("");
|
|
2596
|
+
const { active } = (0, import_react16.useEditorState)({
|
|
1587
2597
|
editor: editor ?? null,
|
|
1588
2598
|
selector: (ctx) => ({
|
|
1589
2599
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
|
|
1590
2600
|
})
|
|
1591
2601
|
}) ?? { active: false };
|
|
1592
|
-
const handleInsert = (0,
|
|
2602
|
+
const handleInsert = (0, import_react17.useCallback)(() => {
|
|
1593
2603
|
if (url && editor) {
|
|
1594
2604
|
editor.chain().focus().setYouTubeEmbed(url).run();
|
|
1595
2605
|
setUrl("");
|
|
1596
2606
|
}
|
|
1597
2607
|
}, [url, editor]);
|
|
1598
|
-
return /* @__PURE__ */ (0,
|
|
1599
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1600
2610
|
DialogTrigger,
|
|
1601
2611
|
{
|
|
1602
|
-
render: /* @__PURE__ */ (0,
|
|
2612
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1603
2613
|
RichTextEditorControl,
|
|
1604
2614
|
{
|
|
1605
2615
|
active,
|
|
1606
2616
|
className,
|
|
1607
2617
|
title: "Embed YouTube video",
|
|
1608
2618
|
"aria-label": "Embed YouTube video",
|
|
1609
|
-
children: /* @__PURE__ */ (0,
|
|
2619
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
1610
2620
|
"svg",
|
|
1611
2621
|
{
|
|
1612
2622
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1618,8 +2628,8 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1618
2628
|
strokeLinejoin: "round",
|
|
1619
2629
|
className: "rte-editor-icon",
|
|
1620
2630
|
children: [
|
|
1621
|
-
/* @__PURE__ */ (0,
|
|
1622
|
-
/* @__PURE__ */ (0,
|
|
2631
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.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" }),
|
|
2632
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
1623
2633
|
]
|
|
1624
2634
|
}
|
|
1625
2635
|
)
|
|
@@ -1627,12 +2637,12 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1627
2637
|
)
|
|
1628
2638
|
}
|
|
1629
2639
|
),
|
|
1630
|
-
/* @__PURE__ */ (0,
|
|
1631
|
-
/* @__PURE__ */ (0,
|
|
1632
|
-
/* @__PURE__ */ (0,
|
|
1633
|
-
/* @__PURE__ */ (0,
|
|
2640
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(DialogContent, { showCloseButton: false, children: [
|
|
2641
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(DialogHeader, { children: [
|
|
2642
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DialogTitle, { children: "Embed YouTube video" }),
|
|
2643
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
1634
2644
|
] }),
|
|
1635
|
-
/* @__PURE__ */ (0,
|
|
2645
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1636
2646
|
Input,
|
|
1637
2647
|
{
|
|
1638
2648
|
value: url,
|
|
@@ -1646,9 +2656,9 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1646
2656
|
}
|
|
1647
2657
|
}
|
|
1648
2658
|
),
|
|
1649
|
-
/* @__PURE__ */ (0,
|
|
1650
|
-
/* @__PURE__ */ (0,
|
|
1651
|
-
/* @__PURE__ */ (0,
|
|
2659
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(DialogFooter, { children: [
|
|
2660
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DialogClose, { children: "Cancel" }),
|
|
2661
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1652
2662
|
DialogClose,
|
|
1653
2663
|
{
|
|
1654
2664
|
disabled: !url,
|
|
@@ -1662,174 +2672,6 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1662
2672
|
] });
|
|
1663
2673
|
};
|
|
1664
2674
|
|
|
1665
|
-
// src/icons.tsx
|
|
1666
|
-
var import_lucide_react = require("lucide-react");
|
|
1667
|
-
var import_react15 = require("react");
|
|
1668
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1669
|
-
var iconProps = { className: "rte-editor-icon" };
|
|
1670
|
-
var LangIcon = ({
|
|
1671
|
-
children,
|
|
1672
|
-
className
|
|
1673
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1674
|
-
"svg",
|
|
1675
|
-
{
|
|
1676
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1677
|
-
viewBox: "0 0 24 24",
|
|
1678
|
-
fill: "none",
|
|
1679
|
-
stroke: "currentColor",
|
|
1680
|
-
strokeWidth: 1.5,
|
|
1681
|
-
strokeLinecap: "round",
|
|
1682
|
-
strokeLinejoin: "round",
|
|
1683
|
-
className,
|
|
1684
|
-
children
|
|
1685
|
-
}
|
|
1686
|
-
);
|
|
1687
|
-
var DEFAULT_LANGUAGE_ICONS = {
|
|
1688
|
-
bash: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1689
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
|
|
1690
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
|
|
1691
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 15.5h5.5" })
|
|
1692
|
-
] }),
|
|
1693
|
-
c: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1694
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "8.5" }),
|
|
1695
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
|
|
1696
|
-
] }),
|
|
1697
|
-
cpp: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1698
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "9.5", cy: "12", r: "6.5" }),
|
|
1699
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
|
|
1700
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.7 10.5v3M14.2 12h3" }),
|
|
1701
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M19.3 10.5v3M17.8 12h3" })
|
|
1702
|
-
] }),
|
|
1703
|
-
css: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1704
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1705
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.7 7.5l-1 9" }),
|
|
1706
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.3 7.5l-1 9" }),
|
|
1707
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M7 10.3h11" }),
|
|
1708
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 14.3h11" })
|
|
1709
|
-
] }),
|
|
1710
|
-
go: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1711
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1712
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
|
|
1713
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.6 12h-1.9" }),
|
|
1714
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "17", cy: "12", r: "2.9" })
|
|
1715
|
-
] }),
|
|
1716
|
-
html: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1717
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1718
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
|
|
1719
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
|
|
1720
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M13 7.3l-2 9.4" })
|
|
1721
|
-
] }),
|
|
1722
|
-
java: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1723
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
|
|
1724
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
|
|
1725
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
|
|
1726
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 19.3h10" })
|
|
1727
|
-
] }),
|
|
1728
|
-
javascript: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1729
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1730
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
|
|
1731
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1732
|
-
] }),
|
|
1733
|
-
json: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1734
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
|
|
1735
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
|
|
1736
|
-
] }),
|
|
1737
|
-
kotlin: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1738
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1739
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 7.5v9" }),
|
|
1740
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 12l6-4.5" }),
|
|
1741
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 12l6 4.5" })
|
|
1742
|
-
] }),
|
|
1743
|
-
markdown: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1744
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
|
|
1745
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 15V9l3 4 3-4v6" }),
|
|
1746
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16.5 9v6" }),
|
|
1747
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14.5 13l2 2 2-2" })
|
|
1748
|
-
] }),
|
|
1749
|
-
php: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1750
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1751
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
|
|
1752
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
|
|
1753
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
|
|
1754
|
-
] }),
|
|
1755
|
-
plaintext: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1756
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
|
|
1757
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
|
|
1758
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
|
|
1759
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
|
|
1760
|
-
] }),
|
|
1761
|
-
python: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1762
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
|
|
1763
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
|
|
1764
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
|
|
1765
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
|
|
1766
|
-
] }),
|
|
1767
|
-
ruby: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1768
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
|
|
1769
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4.5 8h15" }),
|
|
1770
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 2.5v19" })
|
|
1771
|
-
] }),
|
|
1772
|
-
rust: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1773
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "7" }),
|
|
1774
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "2.3" }),
|
|
1775
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
|
|
1776
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
|
|
1777
|
-
] }),
|
|
1778
|
-
sql: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1779
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
|
|
1780
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
|
|
1781
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
|
|
1782
|
-
] }),
|
|
1783
|
-
swift: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LangIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
|
|
1784
|
-
typescript: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1785
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1786
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
|
|
1787
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1788
|
-
] }),
|
|
1789
|
-
xml: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1790
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M8 7l-4.5 5 4.5 5" }),
|
|
1791
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 7l4.5 5-4.5 5" }),
|
|
1792
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 8v8" })
|
|
1793
|
-
] }),
|
|
1794
|
-
yaml: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
|
|
1795
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
|
|
1796
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 8h2M9.5 8h8" }),
|
|
1797
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 12h2M9.5 12h6" }),
|
|
1798
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 16h2M9.5 16h7" })
|
|
1799
|
-
] })
|
|
1800
|
-
};
|
|
1801
|
-
var DEFAULT_ICONS = {
|
|
1802
|
-
alignCenterControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.TextAlignCenter, { ...iconProps }),
|
|
1803
|
-
alignJustifyControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.TextAlignJustify, { ...iconProps }),
|
|
1804
|
-
alignLeftControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.TextAlignStart, { ...iconProps }),
|
|
1805
|
-
alignRightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.TextAlignEnd, { ...iconProps }),
|
|
1806
|
-
blockquoteControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.TextQuote, { ...iconProps }),
|
|
1807
|
-
boldControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Bold, { ...iconProps }),
|
|
1808
|
-
bulletListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.List, { ...iconProps }),
|
|
1809
|
-
clearFormattingControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.RemoveFormatting, { ...iconProps }),
|
|
1810
|
-
codeBlockControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.SquareCode, { ...iconProps }),
|
|
1811
|
-
codeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Code, { ...iconProps }),
|
|
1812
|
-
h1ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading1, { ...iconProps }),
|
|
1813
|
-
h2ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading2, { ...iconProps }),
|
|
1814
|
-
h3ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading3, { ...iconProps }),
|
|
1815
|
-
h4ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading4, { ...iconProps }),
|
|
1816
|
-
h5ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading5, { ...iconProps }),
|
|
1817
|
-
h6ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Heading6, { ...iconProps }),
|
|
1818
|
-
highlightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Highlighter, { ...iconProps }),
|
|
1819
|
-
hrControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Minus, { ...iconProps }),
|
|
1820
|
-
italicControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Italic, { ...iconProps }),
|
|
1821
|
-
languageIcons: DEFAULT_LANGUAGE_ICONS,
|
|
1822
|
-
linkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Link, { ...iconProps }),
|
|
1823
|
-
orderedListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.ListOrdered, { ...iconProps }),
|
|
1824
|
-
redoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Redo2, { ...iconProps }),
|
|
1825
|
-
strikeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Strikethrough, { ...iconProps }),
|
|
1826
|
-
subscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Subscript, { ...iconProps }),
|
|
1827
|
-
superscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Superscript, { ...iconProps }),
|
|
1828
|
-
underlineControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Underline, { ...iconProps }),
|
|
1829
|
-
undoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Undo2, { ...iconProps }),
|
|
1830
|
-
unlinkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react.Link2Off, { ...iconProps })
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1833
2675
|
// src/labels.ts
|
|
1834
2676
|
var DEFAULT_LABELS = {
|
|
1835
2677
|
alignCenterControlLabel: "Align center",
|
|
@@ -1872,16 +2714,16 @@ var DEFAULT_LABELS = {
|
|
|
1872
2714
|
};
|
|
1873
2715
|
|
|
1874
2716
|
// src/rte-content.tsx
|
|
1875
|
-
var
|
|
1876
|
-
var
|
|
2717
|
+
var import_react18 = require("@tiptap/react");
|
|
2718
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1877
2719
|
var Content = ({
|
|
1878
2720
|
children,
|
|
1879
2721
|
className
|
|
1880
2722
|
}) => {
|
|
1881
2723
|
const { editor } = useRichTextEditorContext();
|
|
1882
|
-
return /* @__PURE__ */ (0,
|
|
1883
|
-
/* @__PURE__ */ (0,
|
|
1884
|
-
|
|
2724
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "relative", children: [
|
|
2725
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2726
|
+
import_react18.EditorContent,
|
|
1885
2727
|
{
|
|
1886
2728
|
editor,
|
|
1887
2729
|
className: cn("rte-content w-full", className)
|
|
@@ -1892,15 +2734,15 @@ var Content = ({
|
|
|
1892
2734
|
};
|
|
1893
2735
|
|
|
1894
2736
|
// src/rte-controls-group.tsx
|
|
1895
|
-
var
|
|
2737
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
1896
2738
|
var ControlsGroup = ({
|
|
1897
2739
|
children,
|
|
1898
2740
|
className
|
|
1899
|
-
}) => /* @__PURE__ */ (0,
|
|
2741
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("rte-controls-group", className), children });
|
|
1900
2742
|
|
|
1901
2743
|
// src/rte-footer.tsx
|
|
1902
|
-
var
|
|
1903
|
-
var
|
|
2744
|
+
var import_react19 = require("react");
|
|
2745
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
1904
2746
|
var Footer = ({
|
|
1905
2747
|
children,
|
|
1906
2748
|
className,
|
|
@@ -1911,9 +2753,9 @@ var Footer = ({
|
|
|
1911
2753
|
wordCountFormatter
|
|
1912
2754
|
}) => {
|
|
1913
2755
|
const { editor, variant } = useRichTextEditorContext();
|
|
1914
|
-
const [, forceUpdate] = (0,
|
|
1915
|
-
const rafRef = (0,
|
|
1916
|
-
(0,
|
|
2756
|
+
const [, forceUpdate] = (0, import_react19.useState)(0);
|
|
2757
|
+
const rafRef = (0, import_react19.useRef)(null);
|
|
2758
|
+
(0, import_react19.useEffect)(() => {
|
|
1917
2759
|
if (!editor || !showWordCount) {
|
|
1918
2760
|
return;
|
|
1919
2761
|
}
|
|
@@ -1942,7 +2784,7 @@ var Footer = ({
|
|
|
1942
2784
|
}
|
|
1943
2785
|
};
|
|
1944
2786
|
}, [editor, showWordCount]);
|
|
1945
|
-
const wordCount = (0,
|
|
2787
|
+
const wordCount = (0, import_react19.useMemo)(() => {
|
|
1946
2788
|
if (!editor || !showWordCount) {
|
|
1947
2789
|
return null;
|
|
1948
2790
|
}
|
|
@@ -1959,7 +2801,7 @@ var Footer = ({
|
|
|
1959
2801
|
if (!showWordCount && !children) {
|
|
1960
2802
|
return null;
|
|
1961
2803
|
}
|
|
1962
|
-
return /* @__PURE__ */ (0,
|
|
2804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
1963
2805
|
"div",
|
|
1964
2806
|
{
|
|
1965
2807
|
className: cn(
|
|
@@ -1971,21 +2813,21 @@ var Footer = ({
|
|
|
1971
2813
|
"data-sticky": sticky ? "" : void 0,
|
|
1972
2814
|
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
1973
2815
|
children: [
|
|
1974
|
-
showWordCount && wordCount && /* @__PURE__ */ (0,
|
|
1975
|
-
/* @__PURE__ */ (0,
|
|
1976
|
-
/* @__PURE__ */ (0,
|
|
1977
|
-
/* @__PURE__ */ (0,
|
|
2816
|
+
showWordCount && wordCount && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
2817
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "rte-footer-word-count-stat", children: [
|
|
2818
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
|
|
2819
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rte-footer-word-count-unit", children: "words" })
|
|
1978
2820
|
] }),
|
|
1979
|
-
/* @__PURE__ */ (0,
|
|
2821
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
1980
2822
|
"span",
|
|
1981
2823
|
{
|
|
1982
2824
|
className: "rte-footer-word-count-separator",
|
|
1983
2825
|
"aria-hidden": "true"
|
|
1984
2826
|
}
|
|
1985
2827
|
),
|
|
1986
|
-
/* @__PURE__ */ (0,
|
|
1987
|
-
/* @__PURE__ */ (0,
|
|
1988
|
-
/* @__PURE__ */ (0,
|
|
2828
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "rte-footer-word-count-stat", children: [
|
|
2829
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
|
|
2830
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "rte-footer-word-count-unit", children: "characters" })
|
|
1989
2831
|
] })
|
|
1990
2832
|
] }) }),
|
|
1991
2833
|
children
|
|
@@ -1995,7 +2837,7 @@ var Footer = ({
|
|
|
1995
2837
|
};
|
|
1996
2838
|
|
|
1997
2839
|
// src/rte-toolbar.tsx
|
|
1998
|
-
var
|
|
2840
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
1999
2841
|
var Toolbar = ({
|
|
2000
2842
|
children,
|
|
2001
2843
|
className,
|
|
@@ -2006,7 +2848,7 @@ var Toolbar = ({
|
|
|
2006
2848
|
if (!editable) {
|
|
2007
2849
|
return null;
|
|
2008
2850
|
}
|
|
2009
|
-
return /* @__PURE__ */ (0,
|
|
2851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2010
2852
|
"div",
|
|
2011
2853
|
{
|
|
2012
2854
|
className: cn(
|
|
@@ -2023,7 +2865,7 @@ var Toolbar = ({
|
|
|
2023
2865
|
};
|
|
2024
2866
|
|
|
2025
2867
|
// src/rte-text-editor.tsx
|
|
2026
|
-
var
|
|
2868
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2027
2869
|
var RichTextEditorRoot = ({
|
|
2028
2870
|
editor,
|
|
2029
2871
|
children,
|
|
@@ -2033,17 +2875,17 @@ var RichTextEditorRoot = ({
|
|
|
2033
2875
|
variant = "default",
|
|
2034
2876
|
editable = true
|
|
2035
2877
|
}) => {
|
|
2036
|
-
const mergedLabels = (0,
|
|
2878
|
+
const mergedLabels = (0, import_react20.useMemo)(
|
|
2037
2879
|
() => ({ ...DEFAULT_LABELS, ...labels }),
|
|
2038
2880
|
[labels]
|
|
2039
2881
|
);
|
|
2040
|
-
const mergedIcons = (0,
|
|
2041
|
-
(0,
|
|
2882
|
+
const mergedIcons = (0, import_react20.useMemo)(() => ({ ...DEFAULT_ICONS, ...icons }), [icons]);
|
|
2883
|
+
(0, import_react20.useEffect)(() => {
|
|
2042
2884
|
if (editor && editor.isEditable !== editable) {
|
|
2043
2885
|
editor.setEditable(editable);
|
|
2044
2886
|
}
|
|
2045
2887
|
}, [editor, editable]);
|
|
2046
|
-
return /* @__PURE__ */ (0,
|
|
2888
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2047
2889
|
RichTextEditorContext.Provider,
|
|
2048
2890
|
{
|
|
2049
2891
|
value: {
|
|
@@ -2053,7 +2895,7 @@ var RichTextEditorRoot = ({
|
|
|
2053
2895
|
labels: mergedLabels,
|
|
2054
2896
|
variant
|
|
2055
2897
|
},
|
|
2056
|
-
children: /* @__PURE__ */ (0,
|
|
2898
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2057
2899
|
"div",
|
|
2058
2900
|
{
|
|
2059
2901
|
className: cn(
|