@editorcn/editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1561 @@
1
+ // src/rte-text-editor.tsx
2
+ import { useMemo, useEffect as useEffect4 } from "react";
3
+
4
+ // src/ui/utils.ts
5
+ import { clsx } from "clsx";
6
+ import { twMerge } from "tailwind-merge";
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
9
+ }
10
+
11
+ // src/rte-context.ts
12
+ import "@tiptap/react";
13
+ import { createContext, useContext } from "react";
14
+ var RichTextEditorContext = createContext(null);
15
+ function useRichTextEditorContext() {
16
+ const context = useContext(RichTextEditorContext);
17
+ if (!context) {
18
+ throw new Error(
19
+ "useRichTextEditorContext must be used within RichTextEditor"
20
+ );
21
+ }
22
+ return context;
23
+ }
24
+
25
+ // src/labels.ts
26
+ var DEFAULT_LABELS = {
27
+ boldControlLabel: "Bold",
28
+ italicControlLabel: "Italic",
29
+ underlineControlLabel: "Underline",
30
+ strikeControlLabel: "Strikethrough",
31
+ clearFormattingControlLabel: "Clear formatting",
32
+ codeControlLabel: "Code",
33
+ codeBlockControlLabel: "Code block",
34
+ h1ControlLabel: "Heading 1",
35
+ h2ControlLabel: "Heading 2",
36
+ h3ControlLabel: "Heading 3",
37
+ h4ControlLabel: "Heading 4",
38
+ h5ControlLabel: "Heading 5",
39
+ h6ControlLabel: "Heading 6",
40
+ bulletListControlLabel: "Bullet list",
41
+ orderedListControlLabel: "Ordered list",
42
+ blockquoteControlLabel: "Blockquote",
43
+ hrControlLabel: "Horizontal rule",
44
+ linkControlLabel: "Link",
45
+ unlinkControlLabel: "Remove link",
46
+ undoControlLabel: "Undo",
47
+ redoControlLabel: "Redo",
48
+ alignLeftControlLabel: "Align left",
49
+ alignCenterControlLabel: "Align center",
50
+ alignRightControlLabel: "Align right",
51
+ alignJustifyControlLabel: "Align justify",
52
+ highlightControlLabel: "Highlight",
53
+ subscriptControlLabel: "Subscript",
54
+ superscriptControlLabel: "Superscript",
55
+ tasksControlLabel: "Task list",
56
+ tasksSinkLabel: "Decrease task level",
57
+ tasksLiftLabel: "Increase task level",
58
+ sourceCodeControlLabel: "Source code",
59
+ linkEditorInputLabel: "Enter URL",
60
+ linkEditorInputPlaceholder: "https://example.com",
61
+ linkEditorExternalLink: "Open in new tab",
62
+ linkEditorInternalLink: "Open in same tab",
63
+ linkEditorSave: "Save"
64
+ };
65
+
66
+ // src/icons.tsx
67
+ import "react";
68
+ import { jsx, jsxs } from "react/jsx-runtime";
69
+ function Svg({
70
+ children,
71
+ className
72
+ }) {
73
+ return /* @__PURE__ */ jsx(
74
+ "svg",
75
+ {
76
+ xmlns: "http://www.w3.org/2000/svg",
77
+ viewBox: "0 0 24 24",
78
+ fill: "none",
79
+ stroke: "currentColor",
80
+ strokeWidth: 2,
81
+ strokeLinecap: "round",
82
+ strokeLinejoin: "round",
83
+ className,
84
+ children
85
+ }
86
+ );
87
+ }
88
+ var iconProps = { className: "rte-editor-icon" };
89
+ var DEFAULT_ICONS = {
90
+ boldControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
91
+ /* @__PURE__ */ jsx("path", { d: "M6 4h7a4 4 0 0 1 0 8H6z" }),
92
+ /* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })
93
+ ] }),
94
+ italicControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
95
+ /* @__PURE__ */ jsx("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
96
+ /* @__PURE__ */ jsx("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
97
+ /* @__PURE__ */ jsx("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
98
+ ] }),
99
+ underlineControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
100
+ /* @__PURE__ */ jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
101
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
102
+ ] }),
103
+ strikeControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
104
+ /* @__PURE__ */ jsx("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
105
+ /* @__PURE__ */ jsx("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
106
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
107
+ ] }),
108
+ clearFormattingControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
109
+ /* @__PURE__ */ jsx("path", { d: "M4 7V4h16v3" }),
110
+ /* @__PURE__ */ jsx("path", { d: "M5 20h6" }),
111
+ /* @__PURE__ */ jsx("path", { d: "M13 4 8 20" }),
112
+ /* @__PURE__ */ jsx("path", { d: "m16 16 5 5" }),
113
+ /* @__PURE__ */ jsx("path", { d: "m21 16-5 5" })
114
+ ] }),
115
+ codeControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
116
+ /* @__PURE__ */ jsx("polyline", { points: "16 18 22 12 16 6" }),
117
+ /* @__PURE__ */ jsx("polyline", { points: "8 6 2 12 8 18" })
118
+ ] }),
119
+ codeBlockControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
120
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
121
+ /* @__PURE__ */ jsx("polyline", { points: "10 9 8 12 10 15" }),
122
+ /* @__PURE__ */ jsx("polyline", { points: "14 9 16 12 14 15" })
123
+ ] }),
124
+ h1ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
125
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
126
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
127
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
128
+ /* @__PURE__ */ jsx("path", { d: "m17 10 3-2v8" })
129
+ ] }),
130
+ h2ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
131
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
132
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
133
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
134
+ /* @__PURE__ */ jsx("path", { d: "M17 9.5a2.5 2.5 0 0 1 4.8-1c0 2-4.8 2.5-4.8 5.5h5" })
135
+ ] }),
136
+ h3ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
137
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
138
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
139
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
140
+ /* @__PURE__ */ jsx("path", { d: "M17.5 9.5c1.5-1 3.5-.2 3.5 1.3a1.8 1.8 0 0 1-1.8 1.7" }),
141
+ /* @__PURE__ */ jsx("path", { d: "M19.2 12.5a1.8 1.8 0 0 1 1.8 1.7c0 1.5-2 2.3-3.5 1.3" })
142
+ ] }),
143
+ h4ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
144
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
145
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
146
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
147
+ /* @__PURE__ */ jsx("path", { d: "M20 9v5h-4l3.5-5.5" }),
148
+ /* @__PURE__ */ jsx("path", { d: "M20 14v3" })
149
+ ] }),
150
+ h5ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
151
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
152
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
153
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
154
+ /* @__PURE__ */ jsx("path", { d: "M21 9h-4v3.5c2.5-.7 4.5.3 4.5 2a2.3 2.3 0 0 1-4.3 1.3" })
155
+ ] }),
156
+ h6ControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
157
+ /* @__PURE__ */ jsx("path", { d: "M4 6v12" }),
158
+ /* @__PURE__ */ jsx("path", { d: "M12 6v12" }),
159
+ /* @__PURE__ */ jsx("path", { d: "M4 12h8" }),
160
+ /* @__PURE__ */ jsx("path", { d: "M20.5 9.5c-3 1-3.5 4-3.5 5.5a2.5 2.5 0 1 0 2.5-2.5c-1 0-2 .4-2.5 1" })
161
+ ] }),
162
+ bulletListControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
163
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "6", x2: "21", y2: "6" }),
164
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "12", x2: "21", y2: "12" }),
165
+ /* @__PURE__ */ jsx("line", { x1: "9", y1: "18", x2: "21", y2: "18" }),
166
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "6", r: "1.2", fill: "currentColor", stroke: "none" }),
167
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "12", r: "1.2", fill: "currentColor", stroke: "none" }),
168
+ /* @__PURE__ */ jsx("circle", { cx: "4", cy: "18", r: "1.2", fill: "currentColor", stroke: "none" })
169
+ ] }),
170
+ orderedListControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
171
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
172
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
173
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
174
+ /* @__PURE__ */ jsx("path", { d: "M4 5h2v4" }),
175
+ /* @__PURE__ */ jsx("path", { d: "M4 9h2" }),
176
+ /* @__PURE__ */ jsx("path", { d: "M4 13h2.5L4 16h2.5" }),
177
+ /* @__PURE__ */ jsx("path", { d: "M4 19h2.5" })
178
+ ] }),
179
+ blockquoteControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
180
+ /* @__PURE__ */ jsx("path", { d: "M7 8a3 3 0 0 0-3 3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1H6a3 3 0 0 1 2-3" }),
181
+ /* @__PURE__ */ jsx("path", { d: "M16 8a3 3 0 0 0-3 3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a3 3 0 0 1 2-3" })
182
+ ] }),
183
+ hrControlIcon: /* @__PURE__ */ jsx(Svg, { ...iconProps, children: /* @__PURE__ */ jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) }),
184
+ linkControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
185
+ /* @__PURE__ */ jsx("path", { d: "M9 17H7a5 5 0 0 1 0-10h2" }),
186
+ /* @__PURE__ */ jsx("path", { d: "M15 7h2a5 5 0 0 1 0 10h-2" }),
187
+ /* @__PURE__ */ jsx("line", { x1: "8", y1: "12", x2: "16", y2: "12" })
188
+ ] }),
189
+ unlinkControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
190
+ /* @__PURE__ */ jsx("path", { d: "M9 17H7a5 5 0 0 1-1.7-9.7" }),
191
+ /* @__PURE__ */ jsx("path", { d: "M15 7h2a5 5 0 0 1 1.7 9.7" }),
192
+ /* @__PURE__ */ jsx("line", { x1: "3", y1: "3", x2: "21", y2: "21" })
193
+ ] }),
194
+ undoControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
195
+ /* @__PURE__ */ jsx("path", { d: "M9 14 4 9l5-5" }),
196
+ /* @__PURE__ */ jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H11" })
197
+ ] }),
198
+ redoControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
199
+ /* @__PURE__ */ jsx("path", { d: "m15 14 5-5-5-5" }),
200
+ /* @__PURE__ */ jsx("path", { d: "M20 9H9.5a5.5 5.5 0 0 0 0 11H13" })
201
+ ] }),
202
+ alignLeftControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
203
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
204
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "12", x2: "14", y2: "12" }),
205
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "18", x2: "17", y2: "18" })
206
+ ] }),
207
+ alignCenterControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
208
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
209
+ /* @__PURE__ */ jsx("line", { x1: "7", y1: "12", x2: "17", y2: "12" }),
210
+ /* @__PURE__ */ jsx("line", { x1: "5.5", y1: "18", x2: "18.5", y2: "18" })
211
+ ] }),
212
+ alignRightControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
213
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
214
+ /* @__PURE__ */ jsx("line", { x1: "10", y1: "12", x2: "20", y2: "12" }),
215
+ /* @__PURE__ */ jsx("line", { x1: "7", y1: "18", x2: "20", y2: "18" })
216
+ ] }),
217
+ alignJustifyControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
218
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
219
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "12", x2: "20", y2: "12" }),
220
+ /* @__PURE__ */ jsx("line", { x1: "4", y1: "18", x2: "20", y2: "18" })
221
+ ] }),
222
+ highlightControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
223
+ /* @__PURE__ */ jsx("path", { d: "M9 11 3 17v3h3l6-6" }),
224
+ /* @__PURE__ */ jsx("path", { d: "M14 6l4-4 4 4-4 4" }),
225
+ /* @__PURE__ */ jsx("path", { d: "m9 11 4-4 5 5-4 4" })
226
+ ] }),
227
+ subscriptControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
228
+ /* @__PURE__ */ jsx("path", { d: "m4 4 8 9" }),
229
+ /* @__PURE__ */ jsx("path", { d: "m12 4-8 9" }),
230
+ /* @__PURE__ */ jsx("path", { d: "M19 16h-3.5c0-1.6 3.5-1.9 3.5-3.8a1.8 1.8 0 0 0-3.3-1" })
231
+ ] }),
232
+ superscriptControlIcon: /* @__PURE__ */ jsxs(Svg, { ...iconProps, children: [
233
+ /* @__PURE__ */ jsx("path", { d: "m4 20 8-9" }),
234
+ /* @__PURE__ */ jsx("path", { d: "m12 20-8-9" }),
235
+ /* @__PURE__ */ jsx("path", { d: "M19 11h-3.5c0-1.6 3.5-1.9 3.5-3.8a1.8 1.8 0 0 0-3.3-1" })
236
+ ] })
237
+ };
238
+
239
+ // src/rte-toolbar.tsx
240
+ import { jsx as jsx2 } from "react/jsx-runtime";
241
+ function Toolbar({
242
+ children,
243
+ className,
244
+ sticky,
245
+ stickyOffset = 0
246
+ }) {
247
+ const { variant, editable } = useRichTextEditorContext();
248
+ if (!editable) return null;
249
+ return /* @__PURE__ */ jsx2(
250
+ "div",
251
+ {
252
+ className: cn(
253
+ "rte-toolbar",
254
+ variant !== "default" && `rte-toolbar--${variant}`,
255
+ sticky && "sticky z-10",
256
+ className
257
+ ),
258
+ "data-sticky": sticky ? "" : void 0,
259
+ style: sticky ? { top: stickyOffset } : void 0,
260
+ children
261
+ }
262
+ );
263
+ }
264
+
265
+ // src/rte-controls-group.tsx
266
+ import { jsx as jsx3 } from "react/jsx-runtime";
267
+ function ControlsGroup({
268
+ children,
269
+ className
270
+ }) {
271
+ return /* @__PURE__ */ jsx3(
272
+ "div",
273
+ {
274
+ className: cn("rte-controls-group", className),
275
+ children
276
+ }
277
+ );
278
+ }
279
+
280
+ // src/rte-content.tsx
281
+ import { EditorContent } from "@tiptap/react";
282
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
283
+ function Content({ children, className }) {
284
+ const { editor } = useRichTextEditorContext();
285
+ return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
286
+ /* @__PURE__ */ jsx4(
287
+ EditorContent,
288
+ {
289
+ editor,
290
+ className: cn("rte-content w-full", className)
291
+ }
292
+ ),
293
+ children
294
+ ] });
295
+ }
296
+
297
+ // src/controls/rte-control.tsx
298
+ import { useEditorState } from "@tiptap/react";
299
+ import "react";
300
+
301
+ // src/ui/toggle.tsx
302
+ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
303
+ import { cva } from "class-variance-authority";
304
+ import { jsx as jsx5 } from "react/jsx-runtime";
305
+ var toggleVariants = cva(
306
+ "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",
307
+ {
308
+ variants: {
309
+ variant: {
310
+ default: "bg-transparent",
311
+ outline: "border border-input bg-transparent hover:bg-muted"
312
+ },
313
+ size: {
314
+ default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
315
+ 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",
316
+ lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2"
317
+ }
318
+ },
319
+ defaultVariants: {
320
+ variant: "default",
321
+ size: "default"
322
+ }
323
+ }
324
+ );
325
+ function Toggle({
326
+ className,
327
+ variant = "default",
328
+ size = "default",
329
+ ...props
330
+ }) {
331
+ return /* @__PURE__ */ jsx5(
332
+ TogglePrimitive,
333
+ {
334
+ "data-slot": "toggle",
335
+ className: cn(toggleVariants({ variant, size, className })),
336
+ ...props
337
+ }
338
+ );
339
+ }
340
+
341
+ // src/controls/rte-control.tsx
342
+ import { jsx as jsx6 } from "react/jsx-runtime";
343
+ function RichTextEditorControl({
344
+ active,
345
+ interactive = true,
346
+ className,
347
+ children,
348
+ onMouseDown,
349
+ onClick,
350
+ disabled,
351
+ ...props
352
+ }) {
353
+ return /* @__PURE__ */ jsx6(
354
+ Toggle,
355
+ {
356
+ size: "sm",
357
+ pressed: active,
358
+ disabled,
359
+ "aria-label": props["aria-label"],
360
+ title: props.title,
361
+ className: cn("rte-control-button", className),
362
+ onMouseDown: (e) => {
363
+ e.preventDefault();
364
+ onMouseDown?.(e);
365
+ },
366
+ onPressedChange: () => onClick?.({}),
367
+ children
368
+ }
369
+ );
370
+ }
371
+ function createControl({
372
+ label,
373
+ iconKey,
374
+ isActive,
375
+ isDisabled,
376
+ operation
377
+ }) {
378
+ function Control({ className }) {
379
+ const { editor, labels, icons } = useRichTextEditorContext();
380
+ const ariaLabel = labels[label];
381
+ const editorState = useEditorState({
382
+ editor: editor ?? null,
383
+ selector: (ctx) => {
384
+ const safeEditor = ctx.editor && !ctx.editor.isDestroyed ? ctx.editor : null;
385
+ const checkIsActive = () => {
386
+ if (!safeEditor || !isActive) return false;
387
+ if ("attrs" in isActive) return safeEditor.isActive(isActive.attrs);
388
+ return safeEditor.isActive(isActive.name, isActive.attributes);
389
+ };
390
+ return {
391
+ active: checkIsActive(),
392
+ disabled: safeEditor ? isDisabled?.(safeEditor) ?? false : true
393
+ };
394
+ }
395
+ });
396
+ const active = editorState?.active ?? false;
397
+ const disabled = editorState?.disabled ?? true;
398
+ return /* @__PURE__ */ jsx6(
399
+ RichTextEditorControl,
400
+ {
401
+ active,
402
+ disabled,
403
+ "aria-label": ariaLabel,
404
+ title: ariaLabel,
405
+ className,
406
+ onClick: () => {
407
+ if (!editor || editor.isDestroyed) {
408
+ return;
409
+ }
410
+ editor.chain().focus()[operation.name](operation.attributes).run();
411
+ },
412
+ children: icons[iconKey]
413
+ }
414
+ );
415
+ }
416
+ Control.displayName = `RichTextEditor.${String(label)}`;
417
+ return Control;
418
+ }
419
+
420
+ // src/controls/rte-link-control.tsx
421
+ import * as React5 from "react";
422
+ import { useState } from "react";
423
+ import { useEditorState as useEditorState2 } from "@tiptap/react";
424
+
425
+ // src/ui/popover.tsx
426
+ import "react";
427
+ import { Popover as PopoverPrimitive } from "@base-ui/react/popover";
428
+ import { jsx as jsx7 } from "react/jsx-runtime";
429
+ function Popover({ ...props }) {
430
+ return /* @__PURE__ */ jsx7(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
431
+ }
432
+ function PopoverTrigger({ ...props }) {
433
+ return /* @__PURE__ */ jsx7(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
434
+ }
435
+ function PopoverContent({
436
+ className,
437
+ align = "center",
438
+ alignOffset = 0,
439
+ side = "bottom",
440
+ sideOffset = 4,
441
+ ...props
442
+ }) {
443
+ return /* @__PURE__ */ jsx7(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx7(
444
+ PopoverPrimitive.Positioner,
445
+ {
446
+ align,
447
+ alignOffset,
448
+ side,
449
+ sideOffset,
450
+ className: "isolate z-50",
451
+ children: /* @__PURE__ */ jsx7(
452
+ PopoverPrimitive.Popup,
453
+ {
454
+ "data-slot": "popover-content",
455
+ className: cn(
456
+ "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",
457
+ className
458
+ ),
459
+ ...props
460
+ }
461
+ )
462
+ }
463
+ ) });
464
+ }
465
+
466
+ // src/ui/input.tsx
467
+ import "react";
468
+ import { Input as InputPrimitive } from "@base-ui/react/input";
469
+ import { jsx as jsx8 } from "react/jsx-runtime";
470
+ function Input({ className, type, ...props }) {
471
+ return /* @__PURE__ */ jsx8(
472
+ InputPrimitive,
473
+ {
474
+ type,
475
+ "data-slot": "input",
476
+ className: cn(
477
+ "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",
478
+ className
479
+ ),
480
+ ...props
481
+ }
482
+ );
483
+ }
484
+
485
+ // src/ui/button.tsx
486
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
487
+ import { cva as cva2 } from "class-variance-authority";
488
+ import { jsx as jsx9 } from "react/jsx-runtime";
489
+ var buttonVariants = cva2(
490
+ "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",
491
+ {
492
+ variants: {
493
+ variant: {
494
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
495
+ 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",
496
+ 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",
497
+ ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
498
+ 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",
499
+ link: "text-primary underline-offset-4 hover:underline"
500
+ },
501
+ size: {
502
+ default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
503
+ 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",
504
+ 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",
505
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
506
+ icon: "size-8",
507
+ "icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
508
+ "icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
509
+ "icon-lg": "size-9"
510
+ }
511
+ },
512
+ defaultVariants: {
513
+ variant: "default",
514
+ size: "default"
515
+ }
516
+ }
517
+ );
518
+ function Button({
519
+ className,
520
+ variant = "default",
521
+ size = "default",
522
+ ...props
523
+ }) {
524
+ return /* @__PURE__ */ jsx9(
525
+ ButtonPrimitive,
526
+ {
527
+ "data-slot": "button",
528
+ className: cn(buttonVariants({ variant, size, className })),
529
+ ...props
530
+ }
531
+ );
532
+ }
533
+
534
+ // src/controls/rte-link-control.tsx
535
+ import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
536
+ function LinkControl() {
537
+ const { editor, labels, icons } = useRichTextEditorContext();
538
+ const [url, setUrl] = useState("");
539
+ const [open, setOpen] = useState(false);
540
+ const active = useEditorState2({
541
+ editor: editor ?? null,
542
+ selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
543
+ });
544
+ const handleOpen = (isOpen) => {
545
+ if (isOpen) {
546
+ const linkData = editor?.getAttributes("link");
547
+ setUrl(linkData?.href || "");
548
+ } else {
549
+ setUrl("");
550
+ }
551
+ setOpen(isOpen);
552
+ };
553
+ const handleSave = () => {
554
+ if (!editor || editor.isDestroyed) return;
555
+ if (url === "") {
556
+ editor.chain().focus().extendMarkRange("link").unsetLink().run();
557
+ } else {
558
+ editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
559
+ }
560
+ setOpen(false);
561
+ setUrl("");
562
+ };
563
+ const handleKeyDown = (e) => {
564
+ if (e.key === "Enter") {
565
+ e.preventDefault();
566
+ handleSave();
567
+ }
568
+ };
569
+ React5.useEffect(() => {
570
+ const handler = () => handleOpen(true);
571
+ window.addEventListener("edit-link", handler);
572
+ return () => window.removeEventListener("edit-link", handler);
573
+ }, [editor]);
574
+ return /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: handleOpen, children: [
575
+ /* @__PURE__ */ jsx10(
576
+ PopoverTrigger,
577
+ {
578
+ onMouseDown: (e) => e.preventDefault(),
579
+ children: /* @__PURE__ */ jsx10(
580
+ Toggle,
581
+ {
582
+ size: "sm",
583
+ pressed: active ?? false,
584
+ "aria-label": labels.linkControlLabel,
585
+ title: labels.linkControlLabel,
586
+ className: "p-0",
587
+ children: icons.linkControlIcon
588
+ }
589
+ )
590
+ }
591
+ ),
592
+ /* @__PURE__ */ jsx10(PopoverContent, { className: "w-72 p-3", children: /* @__PURE__ */ jsxs3("div", { className: "rte-link-editor", children: [
593
+ /* @__PURE__ */ jsx10(
594
+ Input,
595
+ {
596
+ type: "url",
597
+ placeholder: labels.linkEditorInputPlaceholder,
598
+ "aria-label": labels.linkEditorInputLabel,
599
+ value: url,
600
+ onChange: (e) => setUrl(e.target.value),
601
+ onKeyDown: handleKeyDown,
602
+ className: "rte-link-editor-input h-8 text-sm"
603
+ }
604
+ ),
605
+ /* @__PURE__ */ jsx10(
606
+ Button,
607
+ {
608
+ size: "sm",
609
+ variant: "default",
610
+ onClick: handleSave,
611
+ className: "rte-link-editor-save h-8",
612
+ children: labels.linkEditorSave
613
+ }
614
+ )
615
+ ] }) })
616
+ ] });
617
+ }
618
+
619
+ // src/controls/rte-controls.tsx
620
+ var BoldControl = createControl({
621
+ label: "boldControlLabel",
622
+ iconKey: "boldControlIcon",
623
+ isActive: { name: "bold" },
624
+ operation: { name: "toggleBold" }
625
+ });
626
+ var ItalicControl = createControl({
627
+ label: "italicControlLabel",
628
+ iconKey: "italicControlIcon",
629
+ isActive: { name: "italic" },
630
+ operation: { name: "toggleItalic" }
631
+ });
632
+ var UnderlineControl = createControl({
633
+ label: "underlineControlLabel",
634
+ iconKey: "underlineControlIcon",
635
+ isActive: { name: "underline" },
636
+ operation: { name: "toggleUnderline" }
637
+ });
638
+ var StrikethroughControl = createControl({
639
+ label: "strikeControlLabel",
640
+ iconKey: "strikeControlIcon",
641
+ isActive: { name: "strike" },
642
+ operation: { name: "toggleStrike" }
643
+ });
644
+ var ClearFormattingControl = createControl({
645
+ label: "clearFormattingControlLabel",
646
+ iconKey: "clearFormattingControlIcon",
647
+ operation: { name: "unsetAllMarks" }
648
+ });
649
+ var CodeControl = createControl({
650
+ label: "codeControlLabel",
651
+ iconKey: "codeControlIcon",
652
+ isActive: { name: "code" },
653
+ operation: { name: "toggleCode" }
654
+ });
655
+ var CodeBlockControl = createControl({
656
+ label: "codeBlockControlLabel",
657
+ iconKey: "codeBlockControlIcon",
658
+ isActive: { name: "codeBlock" },
659
+ operation: { name: "toggleCodeBlock" }
660
+ });
661
+ var H1Control = createControl({
662
+ label: "h1ControlLabel",
663
+ iconKey: "h1ControlIcon",
664
+ isActive: { name: "heading", attributes: { level: 1 } },
665
+ operation: { name: "toggleHeading", attributes: { level: 1 } }
666
+ });
667
+ var H2Control = createControl({
668
+ label: "h2ControlLabel",
669
+ iconKey: "h2ControlIcon",
670
+ isActive: { name: "heading", attributes: { level: 2 } },
671
+ operation: { name: "toggleHeading", attributes: { level: 2 } }
672
+ });
673
+ var H3Control = createControl({
674
+ label: "h3ControlLabel",
675
+ iconKey: "h3ControlIcon",
676
+ isActive: { name: "heading", attributes: { level: 3 } },
677
+ operation: { name: "toggleHeading", attributes: { level: 3 } }
678
+ });
679
+ var H4Control = createControl({
680
+ label: "h4ControlLabel",
681
+ iconKey: "h4ControlIcon",
682
+ isActive: { name: "heading", attributes: { level: 4 } },
683
+ operation: { name: "toggleHeading", attributes: { level: 4 } }
684
+ });
685
+ var BulletListControl = createControl({
686
+ label: "bulletListControlLabel",
687
+ iconKey: "bulletListControlIcon",
688
+ isActive: { name: "bulletList" },
689
+ operation: { name: "toggleBulletList" }
690
+ });
691
+ var OrderedListControl = createControl({
692
+ label: "orderedListControlLabel",
693
+ iconKey: "orderedListControlIcon",
694
+ isActive: { name: "orderedList" },
695
+ operation: { name: "toggleOrderedList" }
696
+ });
697
+ var BlockquoteControl = createControl({
698
+ label: "blockquoteControlLabel",
699
+ iconKey: "blockquoteControlIcon",
700
+ isActive: { name: "blockquote" },
701
+ operation: { name: "toggleBlockquote" }
702
+ });
703
+ var HrControl = createControl({
704
+ label: "hrControlLabel",
705
+ iconKey: "hrControlIcon",
706
+ operation: { name: "setHorizontalRule" }
707
+ });
708
+ var UnlinkControl = createControl({
709
+ label: "unlinkControlLabel",
710
+ iconKey: "unlinkControlIcon",
711
+ operation: { name: "unsetLink" }
712
+ });
713
+ var UndoControl = createControl({
714
+ label: "undoControlLabel",
715
+ iconKey: "undoControlIcon",
716
+ isDisabled: (editor) => !editor.can().undo(),
717
+ operation: { name: "undo" }
718
+ });
719
+ var RedoControl = createControl({
720
+ label: "redoControlLabel",
721
+ iconKey: "redoControlIcon",
722
+ isDisabled: (editor) => !editor.can().redo(),
723
+ operation: { name: "redo" }
724
+ });
725
+ var H5Control = createControl({
726
+ label: "h5ControlLabel",
727
+ iconKey: "h5ControlIcon",
728
+ isActive: { name: "heading", attributes: { level: 5 } },
729
+ operation: { name: "toggleHeading", attributes: { level: 5 } }
730
+ });
731
+ var H6Control = createControl({
732
+ label: "h6ControlLabel",
733
+ iconKey: "h6ControlIcon",
734
+ isActive: { name: "heading", attributes: { level: 6 } },
735
+ operation: { name: "toggleHeading", attributes: { level: 6 } }
736
+ });
737
+ var AlignLeftControl = createControl({
738
+ label: "alignLeftControlLabel",
739
+ iconKey: "alignLeftControlIcon",
740
+ operation: { name: "setTextAlign", attributes: "left" }
741
+ });
742
+ var AlignCenterControl = createControl({
743
+ label: "alignCenterControlLabel",
744
+ iconKey: "alignCenterControlIcon",
745
+ isActive: { attrs: { textAlign: "center" } },
746
+ operation: { name: "setTextAlign", attributes: "center" }
747
+ });
748
+ var AlignRightControl = createControl({
749
+ label: "alignRightControlLabel",
750
+ iconKey: "alignRightControlIcon",
751
+ isActive: { attrs: { textAlign: "right" } },
752
+ operation: { name: "setTextAlign", attributes: "right" }
753
+ });
754
+ var AlignJustifyControl = createControl({
755
+ label: "alignJustifyControlLabel",
756
+ iconKey: "alignJustifyControlIcon",
757
+ isActive: { attrs: { textAlign: "justify" } },
758
+ operation: { name: "setTextAlign", attributes: "justify" }
759
+ });
760
+ var HighlightControl = createControl({
761
+ label: "highlightControlLabel",
762
+ iconKey: "highlightControlIcon",
763
+ isActive: { name: "highlight" },
764
+ operation: { name: "toggleHighlight" }
765
+ });
766
+ var SubscriptControl = createControl({
767
+ label: "subscriptControlLabel",
768
+ iconKey: "subscriptControlIcon",
769
+ isActive: { name: "subscript" },
770
+ operation: { name: "toggleSubscript" }
771
+ });
772
+ var SuperscriptControl = createControl({
773
+ label: "superscriptControlLabel",
774
+ iconKey: "superscriptControlIcon",
775
+ isActive: { name: "superscript" },
776
+ operation: { name: "toggleSuperscript" }
777
+ });
778
+
779
+ // src/controls/rte-youtube-control.tsx
780
+ import { useState as useState2, useCallback as useCallback2 } from "react";
781
+ import { Node, nodeInputRule } from "@tiptap/core";
782
+ import {
783
+ ReactNodeViewRenderer,
784
+ useEditorState as useEditorState3
785
+ } from "@tiptap/react";
786
+
787
+ // src/ui/dialog.tsx
788
+ import "react";
789
+ import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
790
+ import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
791
+ function Dialog({ ...props }) {
792
+ return /* @__PURE__ */ jsx11(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
793
+ }
794
+ function DialogTrigger({ ...props }) {
795
+ return /* @__PURE__ */ jsx11(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
796
+ }
797
+ function DialogPortal({ ...props }) {
798
+ return /* @__PURE__ */ jsx11(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
799
+ }
800
+ function DialogClose({ ...props }) {
801
+ return /* @__PURE__ */ jsx11(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
802
+ }
803
+ function DialogOverlay({
804
+ className,
805
+ ...props
806
+ }) {
807
+ return /* @__PURE__ */ jsx11(
808
+ DialogPrimitive.Backdrop,
809
+ {
810
+ "data-slot": "dialog-overlay",
811
+ className: cn(
812
+ "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",
813
+ className
814
+ ),
815
+ ...props
816
+ }
817
+ );
818
+ }
819
+ function DialogContent({
820
+ className,
821
+ children,
822
+ showCloseButton = true,
823
+ ...props
824
+ }) {
825
+ return /* @__PURE__ */ jsxs4(DialogPortal, { children: [
826
+ /* @__PURE__ */ jsx11(DialogOverlay, {}),
827
+ /* @__PURE__ */ jsxs4(
828
+ DialogPrimitive.Popup,
829
+ {
830
+ "data-slot": "dialog-content",
831
+ className: cn(
832
+ "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",
833
+ className
834
+ ),
835
+ ...props,
836
+ children: [
837
+ children,
838
+ showCloseButton && /* @__PURE__ */ jsxs4(
839
+ DialogPrimitive.Close,
840
+ {
841
+ "data-slot": "dialog-close",
842
+ render: /* @__PURE__ */ jsx11(
843
+ Button,
844
+ {
845
+ variant: "ghost",
846
+ className: "absolute top-2 right-2",
847
+ size: "icon-sm"
848
+ }
849
+ ),
850
+ children: [
851
+ "X",
852
+ /* @__PURE__ */ jsx11("span", { className: "sr-only", children: "Close" })
853
+ ]
854
+ }
855
+ )
856
+ ]
857
+ }
858
+ )
859
+ ] });
860
+ }
861
+ function DialogHeader({ className, ...props }) {
862
+ return /* @__PURE__ */ jsx11(
863
+ "div",
864
+ {
865
+ "data-slot": "dialog-header",
866
+ className: cn("flex flex-col gap-1 text-left", className),
867
+ ...props
868
+ }
869
+ );
870
+ }
871
+ function DialogFooter({
872
+ className,
873
+ showCloseButton = false,
874
+ children,
875
+ ...props
876
+ }) {
877
+ return /* @__PURE__ */ jsxs4(
878
+ "div",
879
+ {
880
+ "data-slot": "dialog-footer",
881
+ className: cn(
882
+ "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
883
+ className
884
+ ),
885
+ ...props,
886
+ children: [
887
+ children,
888
+ showCloseButton && /* @__PURE__ */ jsx11(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx11(Button, { variant: "outline" }), children: "Close" })
889
+ ]
890
+ }
891
+ );
892
+ }
893
+ function DialogTitle({ className, ...props }) {
894
+ return /* @__PURE__ */ jsx11(
895
+ DialogPrimitive.Title,
896
+ {
897
+ "data-slot": "dialog-title",
898
+ className: cn("text-sm font-medium", className),
899
+ ...props
900
+ }
901
+ );
902
+ }
903
+ function DialogDescription({
904
+ className,
905
+ ...props
906
+ }) {
907
+ return /* @__PURE__ */ jsx11(
908
+ DialogPrimitive.Description,
909
+ {
910
+ "data-slot": "dialog-description",
911
+ className: cn(
912
+ "text-xs/relaxed text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
913
+ className
914
+ ),
915
+ ...props
916
+ }
917
+ );
918
+ }
919
+
920
+ // src/extensions/resizable-node-view.tsx
921
+ import { useCallback, useRef, useEffect as useEffect2 } from "react";
922
+ import { NodeViewWrapper } from "@tiptap/react";
923
+ import { Fragment, jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
924
+ function ResizableNodeView({
925
+ node,
926
+ selected,
927
+ updateAttributes,
928
+ view,
929
+ children,
930
+ lockAspect = false,
931
+ aspectRatio = 16 / 9,
932
+ minWidth = 300,
933
+ maxWidth = 1200
934
+ }) {
935
+ const containerRef = useRef(null);
936
+ const resizingRef = useRef(null);
937
+ const width = node.attrs.width;
938
+ const height = node.attrs.height;
939
+ const align = node.attrs.align || "center";
940
+ const getEditorWidth = useCallback(() => {
941
+ return view?.dom?.parentElement?.offsetWidth ?? 0;
942
+ }, [view]);
943
+ const handleMouseDown = useCallback(
944
+ (e, direction) => {
945
+ e.preventDefault();
946
+ e.stopPropagation();
947
+ const editorWidth = getEditorWidth();
948
+ const startWidth = containerRef.current?.offsetWidth ?? width ?? Math.min(560, editorWidth);
949
+ const startHeight = containerRef.current?.offsetHeight ?? height ?? 315;
950
+ resizingRef.current = {
951
+ direction,
952
+ startX: e.clientX,
953
+ startY: e.clientY,
954
+ startWidth,
955
+ startHeight,
956
+ editorWidth
957
+ };
958
+ document.addEventListener("mousemove", handleMouseMove);
959
+ document.addEventListener("mouseup", handleMouseUp);
960
+ document.body.style.cursor = direction === "right" ? "ew-resize" : direction === "bottom" ? "ns-resize" : "nwse-resize";
961
+ document.body.style.userSelect = "none";
962
+ },
963
+ [width, height, getEditorWidth]
964
+ );
965
+ const handleMouseMove = useCallback(
966
+ (e) => {
967
+ const resize = resizingRef.current;
968
+ if (!resize) return;
969
+ const effectiveMax = Math.min(maxWidth, resize.editorWidth);
970
+ let newWidth = resize.startWidth;
971
+ let newHeight = resize.startHeight;
972
+ if (resize.direction === "right" || resize.direction === "corner") {
973
+ newWidth = Math.max(
974
+ minWidth,
975
+ Math.min(effectiveMax, resize.startWidth + (e.clientX - resize.startX))
976
+ );
977
+ }
978
+ if (resize.direction === "bottom" || resize.direction === "corner") {
979
+ newHeight = Math.max(
980
+ Math.round(minWidth / aspectRatio),
981
+ Math.min(
982
+ Math.round(effectiveMax / aspectRatio),
983
+ resize.startHeight + (e.clientY - resize.startY)
984
+ )
985
+ );
986
+ }
987
+ if (lockAspect) {
988
+ if (resize.direction === "right" || resize.direction === "corner") {
989
+ newHeight = Math.round(newWidth / aspectRatio);
990
+ } else {
991
+ newWidth = Math.round(newHeight * aspectRatio);
992
+ }
993
+ }
994
+ if (containerRef.current) {
995
+ containerRef.current.style.width = `${newWidth}px`;
996
+ containerRef.current.style.height = `${newHeight}px`;
997
+ }
998
+ },
999
+ [lockAspect, aspectRatio, minWidth, maxWidth]
1000
+ );
1001
+ const handleMouseUp = useCallback(() => {
1002
+ const resize = resizingRef.current;
1003
+ if (!resize) return;
1004
+ document.removeEventListener("mousemove", handleMouseMove);
1005
+ document.removeEventListener("mouseup", handleMouseUp);
1006
+ document.body.style.cursor = "";
1007
+ document.body.style.userSelect = "";
1008
+ if (containerRef.current) {
1009
+ const w = containerRef.current.offsetWidth;
1010
+ const h = containerRef.current.offsetHeight;
1011
+ updateAttributes({ width: w, height: h });
1012
+ }
1013
+ resizingRef.current = null;
1014
+ }, [handleMouseMove, updateAttributes]);
1015
+ useEffect2(() => {
1016
+ return () => {
1017
+ document.removeEventListener("mousemove", handleMouseMove);
1018
+ document.removeEventListener("mouseup", handleMouseUp);
1019
+ document.body.style.cursor = "";
1020
+ document.body.style.userSelect = "";
1021
+ };
1022
+ }, [handleMouseMove]);
1023
+ return /* @__PURE__ */ jsx12(
1024
+ NodeViewWrapper,
1025
+ {
1026
+ className: "rte-embed-wrapper",
1027
+ "data-selected": selected || void 0,
1028
+ "data-align": align,
1029
+ children: /* @__PURE__ */ jsxs5(
1030
+ "div",
1031
+ {
1032
+ ref: containerRef,
1033
+ className: "rte-embed",
1034
+ contentEditable: false,
1035
+ style: {
1036
+ width: width ? `${width}px` : "100%",
1037
+ height: height ? `${height}px` : "auto",
1038
+ minWidth: `${minWidth}px`
1039
+ },
1040
+ children: [
1041
+ children,
1042
+ selected && /* @__PURE__ */ jsxs5(Fragment, { children: [
1043
+ /* @__PURE__ */ jsx12(
1044
+ "div",
1045
+ {
1046
+ className: "rte-resize-handle rte-resize-handle--right",
1047
+ onMouseDown: (e) => handleMouseDown(e, "right")
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ jsx12(
1051
+ "div",
1052
+ {
1053
+ className: "rte-resize-handle rte-resize-handle--bottom",
1054
+ onMouseDown: (e) => handleMouseDown(e, "bottom")
1055
+ }
1056
+ ),
1057
+ /* @__PURE__ */ jsx12(
1058
+ "div",
1059
+ {
1060
+ className: "rte-resize-handle rte-resize-handle--corner",
1061
+ onMouseDown: (e) => handleMouseDown(e, "corner")
1062
+ }
1063
+ )
1064
+ ] })
1065
+ ]
1066
+ }
1067
+ )
1068
+ }
1069
+ );
1070
+ }
1071
+
1072
+ // src/controls/rte-youtube-control.tsx
1073
+ import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1074
+ function getYouTubeId(url) {
1075
+ const clean = url.trim();
1076
+ const patterns = [
1077
+ /(?:youtube\.com\/watch\?v=)([a-zA-Z0-9_-]{11})/,
1078
+ /(?:youtu\.be\/)([a-zA-Z0-9_-]{11})/,
1079
+ /(?:youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/,
1080
+ /(?:youtube\.com\/shorts\/)([a-zA-Z0-9_-]{11})/,
1081
+ /(?:youtube\.com\/live\/)([a-zA-Z0-9_-]{11})/,
1082
+ /(?:youtube\.com\/v\/)([a-zA-Z0-9_-]{11})/,
1083
+ /(?:m\.youtube\.com\/watch\?v=)([a-zA-Z0-9_-]{11})/
1084
+ ];
1085
+ for (const pattern of patterns) {
1086
+ const match = clean.match(pattern);
1087
+ if (match) return match[1] ?? null;
1088
+ }
1089
+ return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
1090
+ }
1091
+ function YouTubeNodeView(props) {
1092
+ const { node } = props;
1093
+ const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
1094
+ return /* @__PURE__ */ jsx13(ResizableNodeView, { ...props, lockAspect: true, aspectRatio: 16 / 9, minWidth: 320, maxWidth: 1200, children: /* @__PURE__ */ jsx13(
1095
+ "iframe",
1096
+ {
1097
+ src: `https://www.youtube-nocookie.com/embed/${videoId}`,
1098
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
1099
+ allowFullScreen: true,
1100
+ title: "YouTube video",
1101
+ className: "rte-embed-iframe"
1102
+ }
1103
+ ) });
1104
+ }
1105
+ var YouTubeEmbed = Node.create({
1106
+ name: "youtube",
1107
+ group: "block",
1108
+ atom: true,
1109
+ draggable: true,
1110
+ addAttributes() {
1111
+ return {
1112
+ src: {
1113
+ default: null,
1114
+ parseHTML: (el) => el.getAttribute("data-src"),
1115
+ renderHTML: (attrs) => ({
1116
+ "data-src": attrs.src
1117
+ })
1118
+ },
1119
+ width: {
1120
+ default: 560,
1121
+ parseHTML: (el) => el.getAttribute("data-width") ? Number(el.getAttribute("data-width")) : 560,
1122
+ renderHTML: (attrs) => ({
1123
+ "data-width": attrs.width
1124
+ })
1125
+ },
1126
+ height: {
1127
+ default: 315,
1128
+ parseHTML: (el) => el.getAttribute("data-height") ? Number(el.getAttribute("data-height")) : 315,
1129
+ renderHTML: (attrs) => ({
1130
+ "data-height": attrs.height
1131
+ })
1132
+ },
1133
+ align: {
1134
+ default: "center",
1135
+ parseHTML: (el) => el.getAttribute("data-align") || "center",
1136
+ renderHTML: (attrs) => ({
1137
+ "data-align": attrs.align
1138
+ })
1139
+ }
1140
+ };
1141
+ },
1142
+ parseHTML() {
1143
+ return [{ tag: 'div[data-type="youtube"]' }];
1144
+ },
1145
+ renderHTML({ node }) {
1146
+ return [
1147
+ "div",
1148
+ {
1149
+ "data-type": "youtube",
1150
+ "data-src": node.attrs.src,
1151
+ "data-width": node.attrs.width,
1152
+ "data-height": node.attrs.height,
1153
+ "data-align": node.attrs.align
1154
+ }
1155
+ ];
1156
+ },
1157
+ addNodeView() {
1158
+ return ReactNodeViewRenderer(YouTubeNodeView);
1159
+ },
1160
+ addCommands() {
1161
+ return {
1162
+ setYouTubeEmbed: (src) => ({ commands }) => {
1163
+ return commands.insertContent({
1164
+ type: "youtube",
1165
+ attrs: { src }
1166
+ });
1167
+ }
1168
+ };
1169
+ },
1170
+ addInputRules() {
1171
+ return [
1172
+ nodeInputRule({
1173
+ find: /https?:\/\/(?:www\.|m\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=|embed\/|shorts\/|live\/|v\/)?([a-zA-Z0-9_-]{11})/,
1174
+ type: this.type,
1175
+ getAttributes: (match) => ({ src: match[0] })
1176
+ })
1177
+ ];
1178
+ }
1179
+ });
1180
+ function YouTubeEmbedControl({ className }) {
1181
+ const { editor } = useRichTextEditorContext();
1182
+ const [open, setOpen] = useState2(false);
1183
+ const [url, setUrl] = useState2("");
1184
+ const { active } = useEditorState3({
1185
+ editor: editor ?? null,
1186
+ selector: (ctx) => ({
1187
+ active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
1188
+ })
1189
+ }) ?? { active: false };
1190
+ const handleInsert = useCallback2(() => {
1191
+ if (url && editor) {
1192
+ editor.chain().focus().setYouTubeEmbed(url).run();
1193
+ setUrl("");
1194
+ }
1195
+ }, [url, editor]);
1196
+ return /* @__PURE__ */ jsxs6(Dialog, { open, onOpenChange: setOpen, children: [
1197
+ /* @__PURE__ */ jsx13(
1198
+ DialogTrigger,
1199
+ {
1200
+ render: /* @__PURE__ */ jsx13(
1201
+ RichTextEditorControl,
1202
+ {
1203
+ active,
1204
+ className,
1205
+ title: "Embed YouTube video",
1206
+ "aria-label": "Embed YouTube video",
1207
+ children: /* @__PURE__ */ jsxs6(
1208
+ "svg",
1209
+ {
1210
+ xmlns: "http://www.w3.org/2000/svg",
1211
+ viewBox: "0 0 24 24",
1212
+ fill: "none",
1213
+ stroke: "currentColor",
1214
+ "stroke-width": "2",
1215
+ "stroke-linecap": "round",
1216
+ "stroke-linejoin": "round",
1217
+ className: "rte-editor-icon",
1218
+ children: [
1219
+ /* @__PURE__ */ jsx13("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" }),
1220
+ /* @__PURE__ */ jsx13("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1221
+ ]
1222
+ }
1223
+ )
1224
+ }
1225
+ )
1226
+ }
1227
+ ),
1228
+ /* @__PURE__ */ jsxs6(DialogContent, { showCloseButton: false, children: [
1229
+ /* @__PURE__ */ jsxs6(DialogHeader, { children: [
1230
+ /* @__PURE__ */ jsx13(DialogTitle, { children: "Embed YouTube video" }),
1231
+ /* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1232
+ ] }),
1233
+ /* @__PURE__ */ jsx13(
1234
+ Input,
1235
+ {
1236
+ value: url,
1237
+ onChange: (e) => setUrl(e.target.value),
1238
+ placeholder: "https://youtube.com/watch?v=...",
1239
+ onKeyDown: (e) => {
1240
+ if (e.key === "Enter" && url) {
1241
+ handleInsert();
1242
+ setOpen(false);
1243
+ }
1244
+ }
1245
+ }
1246
+ ),
1247
+ /* @__PURE__ */ jsxs6(DialogFooter, { children: [
1248
+ /* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
1249
+ /* @__PURE__ */ jsx13(
1250
+ DialogClose,
1251
+ {
1252
+ disabled: !url,
1253
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
1254
+ onClick: handleInsert,
1255
+ children: "Insert"
1256
+ }
1257
+ )
1258
+ ] })
1259
+ ] })
1260
+ ] });
1261
+ }
1262
+
1263
+ // src/controls/rte-twitter-control.tsx
1264
+ import { useState as useState3, useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
1265
+ import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
1266
+ import {
1267
+ ReactNodeViewRenderer as ReactNodeViewRenderer2,
1268
+ useEditorState as useEditorState4
1269
+ } from "@tiptap/react";
1270
+ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1271
+ var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
1272
+ function TwitterNodeView(props) {
1273
+ const { node } = props;
1274
+ const containerRef = useRef2(null);
1275
+ const [loading, setLoading] = useState3(true);
1276
+ const tweetId = node.attrs.tweetId;
1277
+ const w = node.attrs.width;
1278
+ const h = node.attrs.height;
1279
+ const renderTweet = useCallback3(() => {
1280
+ if (!containerRef.current || !tweetId) return;
1281
+ containerRef.current.innerHTML = "";
1282
+ setLoading(true);
1283
+ const twttr = window.twttr;
1284
+ if (twttr?.widgets) {
1285
+ twttr.widgets.createTweet(tweetId, containerRef.current).then(() => {
1286
+ setLoading(false);
1287
+ });
1288
+ }
1289
+ }, [tweetId]);
1290
+ useEffect3(() => {
1291
+ if (!containerRef.current || !tweetId) return;
1292
+ if (window.twttr?.widgets) {
1293
+ renderTweet();
1294
+ } else {
1295
+ const script = document.createElement("script");
1296
+ script.src = WIDGET_SCRIPT_URL;
1297
+ script.async = true;
1298
+ script.onload = renderTweet;
1299
+ document.body.appendChild(script);
1300
+ }
1301
+ }, [tweetId, w, h, renderTweet]);
1302
+ return /* @__PURE__ */ jsxs7(ResizableNodeView, { ...props, lockAspect: false, minWidth: 300, maxWidth: 1200, children: [
1303
+ loading && /* @__PURE__ */ jsx14("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1304
+ /* @__PURE__ */ jsx14("div", { ref: containerRef })
1305
+ ] });
1306
+ }
1307
+ var TwitterEmbed = Node2.create({
1308
+ name: "twitter",
1309
+ group: "block",
1310
+ atom: true,
1311
+ draggable: true,
1312
+ addAttributes() {
1313
+ return {
1314
+ tweetId: {
1315
+ default: null,
1316
+ parseHTML: (el) => el.getAttribute("data-tweet-id"),
1317
+ renderHTML: (attrs) => ({
1318
+ "data-tweet-id": attrs.tweetId
1319
+ })
1320
+ },
1321
+ width: {
1322
+ default: 550,
1323
+ parseHTML: (el) => el.getAttribute("data-width") ? Number(el.getAttribute("data-width")) : 550,
1324
+ renderHTML: (attrs) => ({
1325
+ "data-width": attrs.width
1326
+ })
1327
+ },
1328
+ height: {
1329
+ default: 400,
1330
+ parseHTML: (el) => el.getAttribute("data-height") ? Number(el.getAttribute("data-height")) : 400,
1331
+ renderHTML: (attrs) => ({
1332
+ "data-height": attrs.height
1333
+ })
1334
+ },
1335
+ align: {
1336
+ default: "center",
1337
+ parseHTML: (el) => el.getAttribute("data-align") || "center",
1338
+ renderHTML: (attrs) => ({
1339
+ "data-align": attrs.align
1340
+ })
1341
+ }
1342
+ };
1343
+ },
1344
+ parseHTML() {
1345
+ return [{ tag: 'div[data-type="twitter"]' }];
1346
+ },
1347
+ renderHTML({ node }) {
1348
+ return [
1349
+ "div",
1350
+ {
1351
+ "data-type": "twitter",
1352
+ "data-tweet-id": node.attrs.tweetId,
1353
+ "data-width": node.attrs.width,
1354
+ "data-height": node.attrs.height,
1355
+ "data-align": node.attrs.align
1356
+ }
1357
+ ];
1358
+ },
1359
+ addNodeView() {
1360
+ return ReactNodeViewRenderer2(TwitterNodeView);
1361
+ },
1362
+ addCommands() {
1363
+ return {
1364
+ setTwitterEmbed: (tweetId) => ({ commands }) => {
1365
+ return commands.insertContent({
1366
+ type: "twitter",
1367
+ attrs: { tweetId }
1368
+ });
1369
+ }
1370
+ };
1371
+ },
1372
+ addInputRules() {
1373
+ return [
1374
+ nodeInputRule2({
1375
+ find: /https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/\w+\/status\/(\d+)/,
1376
+ type: this.type,
1377
+ getAttributes: (match) => ({ tweetId: match[1] })
1378
+ })
1379
+ ];
1380
+ }
1381
+ });
1382
+ function extractTweetId(input) {
1383
+ const clean = input.trim();
1384
+ const match = clean.match(/(?:twitter\.com|x\.com)\/(?:\w+\/status\/|i\/web\/status\/)(\d+)/);
1385
+ return match ? match[1] ?? null : /^\d+$/.test(clean) ? clean : null;
1386
+ }
1387
+ function TwitterEmbedControl({ className }) {
1388
+ const { editor } = useRichTextEditorContext();
1389
+ const [open, setOpen] = useState3(false);
1390
+ const [url, setUrl] = useState3("");
1391
+ const { active } = useEditorState4({
1392
+ editor: editor ?? null,
1393
+ selector: (ctx) => ({
1394
+ active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
1395
+ })
1396
+ }) ?? { active: false };
1397
+ const handleInsert = useCallback3(() => {
1398
+ if (url && editor) {
1399
+ const tweetId = extractTweetId(url);
1400
+ if (tweetId) {
1401
+ editor.chain().focus().setTwitterEmbed(tweetId).run();
1402
+ setUrl("");
1403
+ }
1404
+ }
1405
+ }, [url, editor]);
1406
+ return /* @__PURE__ */ jsxs7(Dialog, { open, onOpenChange: setOpen, children: [
1407
+ /* @__PURE__ */ jsx14(
1408
+ DialogTrigger,
1409
+ {
1410
+ render: /* @__PURE__ */ jsx14(
1411
+ RichTextEditorControl,
1412
+ {
1413
+ active,
1414
+ className,
1415
+ title: "Embed Tweet",
1416
+ "aria-label": "Embed Tweet",
1417
+ children: /* @__PURE__ */ jsx14(
1418
+ "svg",
1419
+ {
1420
+ xmlns: "http://www.w3.org/2000/svg",
1421
+ viewBox: "0 0 24 24",
1422
+ fill: "currentColor",
1423
+ className: "rte-editor-icon",
1424
+ children: /* @__PURE__ */ jsx14("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" })
1425
+ }
1426
+ )
1427
+ }
1428
+ )
1429
+ }
1430
+ ),
1431
+ /* @__PURE__ */ jsxs7(DialogContent, { children: [
1432
+ /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1433
+ /* @__PURE__ */ jsx14(DialogTitle, { children: "Embed Tweet" }),
1434
+ /* @__PURE__ */ jsx14(DialogDescription, { children: "Paste a tweet URL or ID." })
1435
+ ] }),
1436
+ /* @__PURE__ */ jsx14(
1437
+ Input,
1438
+ {
1439
+ value: url,
1440
+ onChange: (e) => setUrl(e.target.value),
1441
+ placeholder: "https://x.com/user/status/...",
1442
+ onKeyDown: (e) => {
1443
+ if (e.key === "Enter" && url) {
1444
+ handleInsert();
1445
+ setOpen(false);
1446
+ }
1447
+ }
1448
+ }
1449
+ ),
1450
+ /* @__PURE__ */ jsxs7(DialogFooter, { children: [
1451
+ /* @__PURE__ */ jsx14(DialogClose, { children: "Cancel" }),
1452
+ /* @__PURE__ */ jsx14(
1453
+ DialogClose,
1454
+ {
1455
+ disabled: !url,
1456
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
1457
+ onClick: handleInsert,
1458
+ children: "Insert"
1459
+ }
1460
+ )
1461
+ ] })
1462
+ ] })
1463
+ ] });
1464
+ }
1465
+
1466
+ // src/rte-text-editor.tsx
1467
+ import { jsx as jsx15 } from "react/jsx-runtime";
1468
+ function RichTextEditorRoot({
1469
+ editor,
1470
+ children,
1471
+ className,
1472
+ labels,
1473
+ icons,
1474
+ variant = "default",
1475
+ editable = true
1476
+ }) {
1477
+ const mergedLabels = useMemo(
1478
+ () => ({ ...DEFAULT_LABELS, ...labels }),
1479
+ [labels]
1480
+ );
1481
+ const mergedIcons = useMemo(
1482
+ () => ({ ...DEFAULT_ICONS, ...icons }),
1483
+ [icons]
1484
+ );
1485
+ useEffect4(() => {
1486
+ if (editor && editor.isEditable !== editable) {
1487
+ editor.setEditable(editable);
1488
+ }
1489
+ }, [editor, editable]);
1490
+ return /* @__PURE__ */ jsx15(RichTextEditorContext.Provider, { value: { editor, labels: mergedLabels, icons: mergedIcons, variant, editable }, children: /* @__PURE__ */ jsx15(
1491
+ "div",
1492
+ {
1493
+ className: cn(
1494
+ "rte-root",
1495
+ variant !== "default" && `rte-root--${variant}`,
1496
+ className
1497
+ ),
1498
+ "data-variant": variant,
1499
+ children
1500
+ }
1501
+ ) });
1502
+ }
1503
+ var RichTextEditor = Object.assign(RichTextEditorRoot, {
1504
+ Toolbar,
1505
+ ControlsGroup,
1506
+ Content,
1507
+ Control: RichTextEditorControl,
1508
+ Link: LinkControl,
1509
+ YouTubeEmbed: YouTubeEmbedControl,
1510
+ TwitterEmbed: TwitterEmbedControl,
1511
+ Bold: BoldControl,
1512
+ Italic: ItalicControl,
1513
+ Underline: UnderlineControl,
1514
+ Strikethrough: StrikethroughControl,
1515
+ ClearFormatting: ClearFormattingControl,
1516
+ Code: CodeControl,
1517
+ CodeBlock: CodeBlockControl,
1518
+ H1: H1Control,
1519
+ H2: H2Control,
1520
+ H3: H3Control,
1521
+ H4: H4Control,
1522
+ H5: H5Control,
1523
+ H6: H6Control,
1524
+ BulletList: BulletListControl,
1525
+ OrderedList: OrderedListControl,
1526
+ Blockquote: BlockquoteControl,
1527
+ Hr: HrControl,
1528
+ Unlink: UnlinkControl,
1529
+ Undo: UndoControl,
1530
+ Redo: RedoControl,
1531
+ AlignLeft: AlignLeftControl,
1532
+ AlignCenter: AlignCenterControl,
1533
+ AlignRight: AlignRightControl,
1534
+ AlignJustify: AlignJustifyControl,
1535
+ Highlight: HighlightControl,
1536
+ Subscript: SubscriptControl,
1537
+ Superscript: SuperscriptControl
1538
+ });
1539
+
1540
+ // src/extensions/link.ts
1541
+ import TipTapLink from "@tiptap/extension-link";
1542
+ var Link = TipTapLink.extend({
1543
+ addKeyboardShortcuts() {
1544
+ return {
1545
+ "Mod-k": () => {
1546
+ window.dispatchEvent(new Event("edit-link"));
1547
+ return true;
1548
+ }
1549
+ };
1550
+ }
1551
+ }).configure({ openOnClick: false });
1552
+ export {
1553
+ DEFAULT_ICONS,
1554
+ DEFAULT_LABELS,
1555
+ Link,
1556
+ RichTextEditor,
1557
+ TwitterEmbed,
1558
+ YouTubeEmbed,
1559
+ useRichTextEditorContext
1560
+ };
1561
+ //# sourceMappingURL=index.js.map