@editorcn/editor 0.3.0 → 0.3.2

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 CHANGED
@@ -1,13 +1,13 @@
1
1
  // src/rte-text-editor.tsx
2
- import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
2
+ import { useMemo as useMemo2, useEffect as useEffect6 } from "react";
3
3
 
4
4
  // src/bubble-menu/index.tsx
5
5
  import { isTextSelection } from "@tiptap/core";
6
6
  import { BubbleMenu as TiptapBubbleMenu } from "@tiptap/react/menus";
7
- import { useCallback as useCallback2 } from "react";
7
+ import { useCallback as useCallback3 } from "react";
8
8
 
9
9
  // src/bubble-menu/language-selector.tsx
10
- import { useState } from "react";
10
+ import { useCallback as useCallback2, useState } from "react";
11
11
 
12
12
  // src/rte-context.ts
13
13
  import { createContext, useContext } from "react";
@@ -23,26 +23,36 @@ var useRichTextEditorContext = () => {
23
23
  };
24
24
 
25
25
  // src/bubble-menu/utils.ts
26
- import { useCallback, useRef, useSyncExternalStore } from "react";
26
+ import { useCallback, useEffect, useRef, useSyncExternalStore } from "react";
27
27
  var defaultEqual = (a, b) => a === b;
28
28
  var shallowEqual = (a, b) => {
29
- if (a === b) return true;
30
- if (!a || !b) return false;
29
+ if (a === b) {
30
+ return true;
31
+ }
32
+ if (!a || !b) {
33
+ return false;
34
+ }
31
35
  const ak = Object.keys(a);
32
36
  const bk = Object.keys(b);
33
- if (ak.length !== bk.length) return false;
37
+ if (ak.length !== bk.length) {
38
+ return false;
39
+ }
34
40
  return ak.every((k) => a[k] === b[k]);
35
41
  };
36
42
  var useEditorState = (editor, selector, isEqual = defaultEqual) => {
37
43
  const selectorRef = useRef(selector);
38
- selectorRef.current = selector;
39
44
  const isEqualRef = useRef(isEqual);
40
- isEqualRef.current = isEqual;
45
+ useEffect(() => {
46
+ selectorRef.current = selector;
47
+ isEqualRef.current = isEqual;
48
+ });
41
49
  const snapshotRef = useRef({
42
50
  value: editor ? selector(editor) : void 0
43
51
  });
44
52
  const updateSnapshot = useCallback(() => {
45
- if (!editor) return;
53
+ if (!editor) {
54
+ return;
55
+ }
46
56
  const next = selectorRef.current(editor);
47
57
  if (snapshotRef.current && isEqualRef.current(snapshotRef.current.value, next)) {
48
58
  return;
@@ -94,6 +104,30 @@ var CODE_BLOCK_LANGUAGES = [
94
104
  "xml",
95
105
  "plaintext"
96
106
  ];
107
+ var CODE_BLOCK_LANGUAGE_LABELS = {
108
+ bash: "Bash",
109
+ c: "C",
110
+ cpp: "C++",
111
+ css: "CSS",
112
+ go: "Go",
113
+ html: "HTML",
114
+ java: "Java",
115
+ javascript: "JavaScript",
116
+ json: "JSON",
117
+ kotlin: "Kotlin",
118
+ markdown: "Markdown",
119
+ php: "PHP",
120
+ plaintext: "Plain Text",
121
+ python: "Python",
122
+ ruby: "Ruby",
123
+ rust: "Rust",
124
+ sql: "SQL",
125
+ swift: "Swift",
126
+ typescript: "TypeScript",
127
+ xml: "XML",
128
+ yaml: "YAML"
129
+ };
130
+ var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
97
131
 
98
132
  // src/bubble-menu/language-selector.tsx
99
133
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -116,6 +150,7 @@ var FallbackIcon = () => /* @__PURE__ */ jsxs(
116
150
  );
117
151
  var LanguageSelector = ({ editor }) => {
118
152
  const [open, setOpen] = useState(false);
153
+ const [pill, setPill] = useState(null);
119
154
  const { icons } = useRichTextEditorContext();
120
155
  const { currentLanguage } = useEditorState(
121
156
  editor,
@@ -125,6 +160,32 @@ var LanguageSelector = ({ editor }) => {
125
160
  shallowEqual
126
161
  );
127
162
  const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ jsx(FallbackIcon, {});
163
+ const handleItemEnter = useCallback2((target) => {
164
+ const item = target.closest(
165
+ "[data-dropdown-item]"
166
+ );
167
+ if (!item) {
168
+ return;
169
+ }
170
+ setPill({
171
+ height: item.offsetHeight,
172
+ left: item.offsetLeft,
173
+ top: item.offsetTop,
174
+ width: item.offsetWidth
175
+ });
176
+ }, []);
177
+ const handleMouseOver = useCallback2(
178
+ (event) => {
179
+ handleItemEnter(event.target);
180
+ },
181
+ [handleItemEnter]
182
+ );
183
+ const handleFocus = useCallback2(
184
+ (event) => {
185
+ handleItemEnter(event.target);
186
+ },
187
+ [handleItemEnter]
188
+ );
128
189
  return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
129
190
  /* @__PURE__ */ jsxs(
130
191
  "button",
@@ -135,7 +196,7 @@ var LanguageSelector = ({ editor }) => {
135
196
  onClick: () => setOpen(!open),
136
197
  children: [
137
198
  /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", children: langIcon }),
138
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-text", children: currentLanguage }),
199
+ /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
139
200
  /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", style: { height: 12, width: 12 }, children: /* @__PURE__ */ jsx(
140
201
  "svg",
141
202
  {
@@ -166,36 +227,51 @@ var LanguageSelector = ({ editor }) => {
166
227
  }
167
228
  }
168
229
  ),
169
- /* @__PURE__ */ jsx("div", { className: "rte-bubble-dropdown rte-bubble-dropdown--language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
170
- "button",
230
+ /* @__PURE__ */ jsxs(
231
+ "div",
171
232
  {
172
- type: "button",
173
- className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
174
- onMouseDown: (e) => e.preventDefault(),
175
- onClick: () => {
176
- editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
177
- setOpen(false);
178
- },
233
+ className: "rte-bubble-dropdown rte-bubble-dropdown--language",
234
+ onFocus: handleFocus,
235
+ onMouseLeave: () => setPill(null),
236
+ onMouseOver: handleMouseOver,
179
237
  children: [
180
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
181
- /* @__PURE__ */ jsx("span", { children: lang }),
182
- currentLanguage === lang && /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: /* @__PURE__ */ jsx(
183
- "svg",
238
+ /* @__PURE__ */ jsx(
239
+ "div",
184
240
  {
185
- xmlns: "http://www.w3.org/2000/svg",
186
- viewBox: "0 0 24 24",
187
- fill: "none",
188
- stroke: "currentColor",
189
- strokeWidth: 2,
190
- strokeLinecap: "round",
191
- strokeLinejoin: "round",
192
- children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
241
+ "aria-hidden": "true",
242
+ className: [
243
+ "rte-bubble-dropdown-pill",
244
+ pill ? "rte-bubble-dropdown-pill--visible" : ""
245
+ ].filter(Boolean).join(" "),
246
+ style: pill ? {
247
+ height: pill.height,
248
+ left: pill.left,
249
+ top: pill.top,
250
+ width: pill.width
251
+ } : void 0
193
252
  }
194
- ) })
253
+ ),
254
+ CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
255
+ "button",
256
+ {
257
+ type: "button",
258
+ "data-dropdown-item": true,
259
+ className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
260
+ onMouseDown: (e) => e.preventDefault(),
261
+ onClick: () => {
262
+ editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
263
+ setOpen(false);
264
+ },
265
+ children: [
266
+ /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
267
+ /* @__PURE__ */ jsx("span", { children: getLanguageLabel(lang) })
268
+ ]
269
+ },
270
+ lang
271
+ ))
195
272
  ]
196
- },
197
- lang
198
- )) })
273
+ }
274
+ )
199
275
  ] })
200
276
  ] });
201
277
  };
@@ -298,7 +374,7 @@ var BubbleMenu = ({ editor }) => {
298
374
  }),
299
375
  shallowEqual
300
376
  );
301
- const shouldShow = useCallback2(
377
+ const shouldShow = useCallback3(
302
378
  ({
303
379
  editor: ed,
304
380
  state
@@ -584,6 +660,7 @@ var H6Control = createControl({
584
660
  });
585
661
  var AlignLeftControl = createControl({
586
662
  iconKey: "alignLeftControlIcon",
663
+ isActive: { attrs: { textAlign: "left" } },
587
664
  label: "alignLeftControlLabel",
588
665
  operation: { attributes: "left", name: "setTextAlign" }
589
666
  });
@@ -627,7 +704,7 @@ var SuperscriptControl = createControl({
627
704
  // src/controls/rte-link-control.tsx
628
705
  import { useEditorState as useEditorState3 } from "@tiptap/react";
629
706
  import * as React4 from "react";
630
- import { useCallback as useCallback3, useState as useState2 } from "react";
707
+ import { useCallback as useCallback4, useState as useState2 } from "react";
631
708
 
632
709
  // src/ui/button.tsx
633
710
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
@@ -742,7 +819,7 @@ var LinkControl = () => {
742
819
  editor: editor ?? null,
743
820
  selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
744
821
  });
745
- const handleOpen = useCallback3(
822
+ const handleOpen = useCallback4(
746
823
  (isOpen) => {
747
824
  if (isOpen) {
748
825
  const linkData = editor?.getAttributes("link");
@@ -825,33 +902,454 @@ var LinkControl = () => {
825
902
  // src/controls/rte-twitter-control.tsx
826
903
  import { Node, nodeInputRule } from "@tiptap/core";
827
904
  import { ReactNodeViewRenderer, useEditorState as useEditorState4 } from "@tiptap/react";
828
- import { useState as useState3, useCallback as useCallback5, useEffect as useEffect3, useRef as useRef3 } from "react";
905
+ import { useState as useState4, useCallback as useCallback6, useEffect as useEffect4, useRef as useRef3 } from "react";
829
906
 
830
907
  // src/extensions/resizable-node-view.tsx
831
908
  import { NodeViewWrapper } from "@tiptap/react";
832
- import { useCallback as useCallback4, useRef as useRef2, useEffect as useEffect2 } from "react";
909
+ import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
910
+
911
+ // src/icons.tsx
912
+ import {
913
+ Bold,
914
+ Code,
915
+ Heading1,
916
+ Heading2,
917
+ Heading3,
918
+ Heading4,
919
+ Heading5,
920
+ Heading6,
921
+ Highlighter,
922
+ Italic,
923
+ Link,
924
+ Link2Off,
925
+ List,
926
+ ListOrdered,
927
+ Minus,
928
+ Redo2,
929
+ RemoveFormatting,
930
+ SquareCode,
931
+ Strikethrough,
932
+ Subscript,
933
+ Superscript,
934
+ TextAlignCenter,
935
+ TextAlignEnd,
936
+ TextAlignJustify,
937
+ TextAlignStart,
938
+ TextQuote,
939
+ Underline,
940
+ Undo2
941
+ } from "lucide-react";
942
+ import "react";
833
943
  import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
944
+ var ALIGN_PATHS = {
945
+ center: /* @__PURE__ */ jsxs4(Fragment2, { children: [
946
+ /* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
947
+ /* @__PURE__ */ jsx10("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
948
+ /* @__PURE__ */ jsx10("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
949
+ ] }),
950
+ left: /* @__PURE__ */ jsxs4(Fragment2, { children: [
951
+ /* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
952
+ /* @__PURE__ */ jsx10("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
953
+ /* @__PURE__ */ jsx10("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
954
+ ] }),
955
+ right: /* @__PURE__ */ jsxs4(Fragment2, { children: [
956
+ /* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
957
+ /* @__PURE__ */ jsx10("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
958
+ /* @__PURE__ */ jsx10("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
959
+ ] })
960
+ };
961
+ var AlignIcon = ({ dir }) => /* @__PURE__ */ jsx10(
962
+ "svg",
963
+ {
964
+ xmlns: "http://www.w3.org/2000/svg",
965
+ viewBox: "0 0 24 24",
966
+ fill: "none",
967
+ stroke: "currentColor",
968
+ strokeWidth: "2",
969
+ strokeLinecap: "round",
970
+ strokeLinejoin: "round",
971
+ className: "rte-editor-icon",
972
+ children: ALIGN_PATHS[dir]
973
+ }
974
+ );
975
+ var EditUrlIcon = () => /* @__PURE__ */ jsxs4(
976
+ "svg",
977
+ {
978
+ xmlns: "http://www.w3.org/2000/svg",
979
+ viewBox: "0 0 24 24",
980
+ fill: "none",
981
+ stroke: "currentColor",
982
+ strokeWidth: "2",
983
+ strokeLinecap: "round",
984
+ strokeLinejoin: "round",
985
+ className: "rte-editor-icon",
986
+ children: [
987
+ /* @__PURE__ */ jsx10("path", { d: "M12 20h9" }),
988
+ /* @__PURE__ */ jsx10("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
989
+ ]
990
+ }
991
+ );
992
+ var OpenInYouTubeIcon = () => /* @__PURE__ */ jsxs4(
993
+ "svg",
994
+ {
995
+ xmlns: "http://www.w3.org/2000/svg",
996
+ viewBox: "0 0 24 24",
997
+ fill: "none",
998
+ stroke: "currentColor",
999
+ strokeWidth: "2",
1000
+ strokeLinecap: "round",
1001
+ strokeLinejoin: "round",
1002
+ className: "rte-editor-icon",
1003
+ children: [
1004
+ /* @__PURE__ */ jsx10("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
1005
+ /* @__PURE__ */ jsx10("polyline", { points: "15 3 21 3 21 9" }),
1006
+ /* @__PURE__ */ jsx10("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
1007
+ ]
1008
+ }
1009
+ );
1010
+ var DeleteEmbedIcon = () => /* @__PURE__ */ jsxs4(
1011
+ "svg",
1012
+ {
1013
+ xmlns: "http://www.w3.org/2000/svg",
1014
+ viewBox: "0 0 24 24",
1015
+ fill: "none",
1016
+ stroke: "currentColor",
1017
+ strokeWidth: "2",
1018
+ strokeLinecap: "round",
1019
+ strokeLinejoin: "round",
1020
+ className: "rte-editor-icon",
1021
+ children: [
1022
+ /* @__PURE__ */ jsx10("polyline", { points: "3 6 5 6 21 6" }),
1023
+ /* @__PURE__ */ jsx10("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
1024
+ ]
1025
+ }
1026
+ );
1027
+ var iconProps = { className: "rte-editor-icon" };
1028
+ var LangIcon = ({
1029
+ children,
1030
+ className
1031
+ }) => /* @__PURE__ */ jsx10(
1032
+ "svg",
1033
+ {
1034
+ xmlns: "http://www.w3.org/2000/svg",
1035
+ viewBox: "0 0 24 24",
1036
+ fill: "none",
1037
+ stroke: "currentColor",
1038
+ strokeWidth: 1.5,
1039
+ strokeLinecap: "round",
1040
+ strokeLinejoin: "round",
1041
+ className,
1042
+ children
1043
+ }
1044
+ );
1045
+ var DEFAULT_LANGUAGE_ICONS = {
1046
+ bash: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1047
+ /* @__PURE__ */ jsx10("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1048
+ /* @__PURE__ */ jsx10("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1049
+ /* @__PURE__ */ jsx10("path", { d: "M12 15.5h5.5" })
1050
+ ] }),
1051
+ c: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1052
+ /* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "8.5" }),
1053
+ /* @__PURE__ */ jsx10("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1054
+ ] }),
1055
+ cpp: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1056
+ /* @__PURE__ */ jsx10("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1057
+ /* @__PURE__ */ jsx10("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1058
+ /* @__PURE__ */ jsx10("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1059
+ /* @__PURE__ */ jsx10("path", { d: "M19.3 10.5v3M17.8 12h3" })
1060
+ ] }),
1061
+ css: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1062
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1063
+ /* @__PURE__ */ jsx10("path", { d: "M9.7 7.5l-1 9" }),
1064
+ /* @__PURE__ */ jsx10("path", { d: "M15.3 7.5l-1 9" }),
1065
+ /* @__PURE__ */ jsx10("path", { d: "M7 10.3h11" }),
1066
+ /* @__PURE__ */ jsx10("path", { d: "M6.5 14.3h11" })
1067
+ ] }),
1068
+ go: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1069
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1070
+ /* @__PURE__ */ jsx10("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1071
+ /* @__PURE__ */ jsx10("path", { d: "M12.6 12h-1.9" }),
1072
+ /* @__PURE__ */ jsx10("circle", { cx: "17", cy: "12", r: "2.9" })
1073
+ ] }),
1074
+ html: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1075
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1076
+ /* @__PURE__ */ jsx10("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1077
+ /* @__PURE__ */ jsx10("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1078
+ /* @__PURE__ */ jsx10("path", { d: "M13 7.3l-2 9.4" })
1079
+ ] }),
1080
+ java: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1081
+ /* @__PURE__ */ jsx10("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1082
+ /* @__PURE__ */ jsx10("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1083
+ /* @__PURE__ */ jsx10("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" }),
1084
+ /* @__PURE__ */ jsx10("path", { d: "M6 19.3h10" })
1085
+ ] }),
1086
+ javascript: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1087
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1088
+ /* @__PURE__ */ jsx10("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1089
+ /* @__PURE__ */ jsx10("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1090
+ ] }),
1091
+ json: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1092
+ /* @__PURE__ */ jsx10("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" }),
1093
+ /* @__PURE__ */ jsx10("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
1094
+ ] }),
1095
+ kotlin: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1096
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1097
+ /* @__PURE__ */ jsx10("path", { d: "M9 7.5v9" }),
1098
+ /* @__PURE__ */ jsx10("path", { d: "M9 12l6-4.5" }),
1099
+ /* @__PURE__ */ jsx10("path", { d: "M9 12l6 4.5" })
1100
+ ] }),
1101
+ markdown: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1102
+ /* @__PURE__ */ jsx10("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1103
+ /* @__PURE__ */ jsx10("path", { d: "M6 15V9l3 4 3-4v6" }),
1104
+ /* @__PURE__ */ jsx10("path", { d: "M16.5 9v6" }),
1105
+ /* @__PURE__ */ jsx10("path", { d: "M14.5 13l2 2 2-2" })
1106
+ ] }),
1107
+ php: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1108
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1109
+ /* @__PURE__ */ jsx10("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1110
+ /* @__PURE__ */ jsx10("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" }),
1111
+ /* @__PURE__ */ jsx10("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1112
+ ] }),
1113
+ plaintext: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1114
+ /* @__PURE__ */ jsx10("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1115
+ /* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1116
+ /* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1117
+ /* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1118
+ ] }),
1119
+ python: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1120
+ /* @__PURE__ */ jsx10("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1121
+ /* @__PURE__ */ jsx10("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1122
+ /* @__PURE__ */ jsx10("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1123
+ /* @__PURE__ */ jsx10("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1124
+ ] }),
1125
+ ruby: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1126
+ /* @__PURE__ */ jsx10("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1127
+ /* @__PURE__ */ jsx10("path", { d: "M4.5 8h15" }),
1128
+ /* @__PURE__ */ jsx10("path", { d: "M12 2.5v19" })
1129
+ ] }),
1130
+ rust: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1131
+ /* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "7" }),
1132
+ /* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "2.3" }),
1133
+ /* @__PURE__ */ jsx10("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1134
+ /* @__PURE__ */ jsx10("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
1135
+ ] }),
1136
+ sql: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1137
+ /* @__PURE__ */ jsx10("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1138
+ /* @__PURE__ */ jsx10("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1139
+ /* @__PURE__ */ jsx10("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1140
+ ] }),
1141
+ swift: /* @__PURE__ */ jsx10(LangIcon, { children: /* @__PURE__ */ jsx10("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" }) }),
1142
+ typescript: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1143
+ /* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1144
+ /* @__PURE__ */ jsx10("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1145
+ /* @__PURE__ */ jsx10("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1146
+ ] }),
1147
+ xml: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1148
+ /* @__PURE__ */ jsx10("path", { d: "M8 7l-4.5 5 4.5 5" }),
1149
+ /* @__PURE__ */ jsx10("path", { d: "M16 7l4.5 5-4.5 5" }),
1150
+ /* @__PURE__ */ jsx10("path", { d: "M12 8v8" })
1151
+ ] }),
1152
+ yaml: /* @__PURE__ */ jsxs4(LangIcon, { children: [
1153
+ /* @__PURE__ */ jsx10("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1154
+ /* @__PURE__ */ jsx10("path", { d: "M6.5 8h2M9.5 8h8" }),
1155
+ /* @__PURE__ */ jsx10("path", { d: "M6.5 12h2M9.5 12h6" }),
1156
+ /* @__PURE__ */ jsx10("path", { d: "M6.5 16h2M9.5 16h7" })
1157
+ ] })
1158
+ };
1159
+ var DEFAULT_ICONS = {
1160
+ alignCenterControlIcon: /* @__PURE__ */ jsx10(TextAlignCenter, { ...iconProps }),
1161
+ alignJustifyControlIcon: /* @__PURE__ */ jsx10(TextAlignJustify, { ...iconProps }),
1162
+ alignLeftControlIcon: /* @__PURE__ */ jsx10(TextAlignStart, { ...iconProps }),
1163
+ alignRightControlIcon: /* @__PURE__ */ jsx10(TextAlignEnd, { ...iconProps }),
1164
+ blockquoteControlIcon: /* @__PURE__ */ jsx10(TextQuote, { ...iconProps }),
1165
+ boldControlIcon: /* @__PURE__ */ jsx10(Bold, { ...iconProps }),
1166
+ bulletListControlIcon: /* @__PURE__ */ jsx10(List, { ...iconProps }),
1167
+ clearFormattingControlIcon: /* @__PURE__ */ jsx10(RemoveFormatting, { ...iconProps }),
1168
+ codeBlockControlIcon: /* @__PURE__ */ jsx10(SquareCode, { ...iconProps }),
1169
+ codeControlIcon: /* @__PURE__ */ jsx10(Code, { ...iconProps }),
1170
+ h1ControlIcon: /* @__PURE__ */ jsx10(Heading1, { ...iconProps }),
1171
+ h2ControlIcon: /* @__PURE__ */ jsx10(Heading2, { ...iconProps }),
1172
+ h3ControlIcon: /* @__PURE__ */ jsx10(Heading3, { ...iconProps }),
1173
+ h4ControlIcon: /* @__PURE__ */ jsx10(Heading4, { ...iconProps }),
1174
+ h5ControlIcon: /* @__PURE__ */ jsx10(Heading5, { ...iconProps }),
1175
+ h6ControlIcon: /* @__PURE__ */ jsx10(Heading6, { ...iconProps }),
1176
+ highlightControlIcon: /* @__PURE__ */ jsx10(Highlighter, { ...iconProps }),
1177
+ hrControlIcon: /* @__PURE__ */ jsx10(Minus, { ...iconProps }),
1178
+ italicControlIcon: /* @__PURE__ */ jsx10(Italic, { ...iconProps }),
1179
+ languageIcons: DEFAULT_LANGUAGE_ICONS,
1180
+ linkControlIcon: /* @__PURE__ */ jsx10(Link, { ...iconProps }),
1181
+ orderedListControlIcon: /* @__PURE__ */ jsx10(ListOrdered, { ...iconProps }),
1182
+ redoControlIcon: /* @__PURE__ */ jsx10(Redo2, { ...iconProps }),
1183
+ strikeControlIcon: /* @__PURE__ */ jsx10(Strikethrough, { ...iconProps }),
1184
+ subscriptControlIcon: /* @__PURE__ */ jsx10(Subscript, { ...iconProps }),
1185
+ superscriptControlIcon: /* @__PURE__ */ jsx10(Superscript, { ...iconProps }),
1186
+ underlineControlIcon: /* @__PURE__ */ jsx10(Underline, { ...iconProps }),
1187
+ undoControlIcon: /* @__PURE__ */ jsx10(Undo2, { ...iconProps }),
1188
+ unlinkControlIcon: /* @__PURE__ */ jsx10(Link2Off, { ...iconProps })
1189
+ };
1190
+
1191
+ // src/extensions/resizable-node-view.tsx
1192
+ import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1193
+ var EmbedToolbar = ({
1194
+ align,
1195
+ videoSrc,
1196
+ watchUrl,
1197
+ deleteNode,
1198
+ inputRef,
1199
+ isEditingUrl,
1200
+ urlInput,
1201
+ setUrlInput,
1202
+ setIsEditingUrl,
1203
+ handleSaveUrl,
1204
+ handleApplyPreset,
1205
+ updateAttributes,
1206
+ nodeSrc
1207
+ }) => {
1208
+ if (isEditingUrl) {
1209
+ return /* @__PURE__ */ jsxs5("div", { className: "rte-embed-selector-edit-form", children: [
1210
+ /* @__PURE__ */ jsx11(
1211
+ "input",
1212
+ {
1213
+ ref: inputRef,
1214
+ type: "text",
1215
+ value: urlInput,
1216
+ onChange: (e) => setUrlInput(e.target.value),
1217
+ placeholder: "Paste YouTube URL or video ID...",
1218
+ className: "rte-embed-selector-input",
1219
+ onKeyDown: (e) => {
1220
+ if (e.key === "Enter") {
1221
+ handleSaveUrl();
1222
+ } else if (e.key === "Escape") {
1223
+ setIsEditingUrl(false);
1224
+ }
1225
+ }
1226
+ }
1227
+ ),
1228
+ /* @__PURE__ */ jsx11(
1229
+ "button",
1230
+ {
1231
+ type: "button",
1232
+ onClick: handleSaveUrl,
1233
+ className: "rte-embed-selector-btn rte-embed-selector-btn--save",
1234
+ children: "Save"
1235
+ }
1236
+ ),
1237
+ /* @__PURE__ */ jsx11(
1238
+ "button",
1239
+ {
1240
+ type: "button",
1241
+ onClick: () => setIsEditingUrl(false),
1242
+ className: "rte-embed-selector-btn",
1243
+ children: "Cancel"
1244
+ }
1245
+ )
1246
+ ] });
1247
+ }
1248
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
1249
+ /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ jsx11(
1250
+ "button",
1251
+ {
1252
+ type: "button",
1253
+ title: `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1254
+ "aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1255
+ className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
1256
+ onClick: () => updateAttributes({ align: dir }),
1257
+ children: /* @__PURE__ */ jsx11(AlignIcon, { dir })
1258
+ },
1259
+ dir
1260
+ )) }),
1261
+ /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-divider" }),
1262
+ /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ jsxs5(
1263
+ "button",
1264
+ {
1265
+ type: "button",
1266
+ title: `${pct}%`,
1267
+ className: "rte-embed-selector-btn rte-embed-selector-btn--preset",
1268
+ onClick: () => handleApplyPreset(pct),
1269
+ children: [
1270
+ pct,
1271
+ "%"
1272
+ ]
1273
+ },
1274
+ pct
1275
+ )) }),
1276
+ /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-divider" }),
1277
+ /* @__PURE__ */ jsxs5("div", { className: "rte-embed-selector-group", children: [
1278
+ (videoSrc || nodeSrc) && /* @__PURE__ */ jsx11(
1279
+ "button",
1280
+ {
1281
+ type: "button",
1282
+ title: "Edit URL",
1283
+ "aria-label": "Edit URL",
1284
+ className: "rte-embed-selector-btn",
1285
+ onClick: () => {
1286
+ setUrlInput(videoSrc || nodeSrc || "");
1287
+ setIsEditingUrl(true);
1288
+ },
1289
+ children: /* @__PURE__ */ jsx11(EditUrlIcon, {})
1290
+ }
1291
+ ),
1292
+ watchUrl && /* @__PURE__ */ jsx11(
1293
+ "button",
1294
+ {
1295
+ type: "button",
1296
+ title: "Open video in YouTube",
1297
+ "aria-label": "Open video in YouTube",
1298
+ className: "rte-embed-selector-btn",
1299
+ onClick: () => window.open(watchUrl, "_blank"),
1300
+ children: /* @__PURE__ */ jsx11(OpenInYouTubeIcon, {})
1301
+ }
1302
+ ),
1303
+ deleteNode && /* @__PURE__ */ jsx11(
1304
+ "button",
1305
+ {
1306
+ type: "button",
1307
+ title: "Delete Embed",
1308
+ "aria-label": "Delete Embed",
1309
+ className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
1310
+ onClick: () => deleteNode(),
1311
+ children: /* @__PURE__ */ jsx11(DeleteEmbedIcon, {})
1312
+ }
1313
+ )
1314
+ ] })
1315
+ ] });
1316
+ };
834
1317
  var ResizableNodeView = ({
835
1318
  node,
836
1319
  selected,
837
1320
  updateAttributes,
1321
+ deleteNode,
1322
+ editor,
838
1323
  view,
839
1324
  children,
840
1325
  lockAspect = false,
841
1326
  aspectRatio = 16 / 9,
842
1327
  minWidth = 300,
843
- maxWidth = 1200
1328
+ maxWidth = 1200,
1329
+ videoSrc,
1330
+ watchUrl,
1331
+ onSrcChange
844
1332
  }) => {
845
1333
  const containerRef = useRef2(null);
1334
+ const [isEditingUrl, setIsEditingUrl] = useState3(false);
1335
+ const [urlInput, setUrlInput] = useState3(videoSrc || "");
1336
+ const [isResizing, setIsResizing] = useState3(false);
1337
+ const [currentDimensions, setCurrentDimensions] = useState3(null);
846
1338
  const resizingRef = useRef2(null);
847
1339
  const width = node.attrs.width;
848
1340
  const height = node.attrs.height;
849
1341
  const align = node.attrs.align || "center";
850
- const getEditorWidth = useCallback4(
851
- () => view?.dom?.parentElement?.offsetWidth ?? 0,
1342
+ const getEditorWidth = useCallback5(
1343
+ () => view?.dom?.parentElement?.offsetWidth ?? 800,
852
1344
  [view]
853
1345
  );
854
- const handleMouseMove = useCallback4(
1346
+ const inputRef = useRef2(null);
1347
+ useEffect3(() => {
1348
+ if (isEditingUrl) {
1349
+ inputRef.current?.focus();
1350
+ }
1351
+ }, [isEditingUrl]);
1352
+ const handleMouseMove = useCallback5(
855
1353
  (e) => {
856
1354
  const resize = resizingRef.current;
857
1355
  if (!resize) {
@@ -860,7 +1358,7 @@ var ResizableNodeView = ({
860
1358
  const effectiveMax = Math.min(maxWidth, resize.editorWidth);
861
1359
  let newWidth = resize.startWidth;
862
1360
  let newHeight = resize.startHeight;
863
- if (resize.direction === "right" || resize.direction === "corner") {
1361
+ if (resize.direction === "right" || resize.direction === "corner-br") {
864
1362
  newWidth = Math.max(
865
1363
  minWidth,
866
1364
  Math.min(
@@ -868,8 +1366,16 @@ var ResizableNodeView = ({
868
1366
  resize.startWidth + (e.clientX - resize.startX)
869
1367
  )
870
1368
  );
1369
+ } else if (resize.direction === "left" || resize.direction === "corner-bl") {
1370
+ newWidth = Math.max(
1371
+ minWidth,
1372
+ Math.min(
1373
+ effectiveMax,
1374
+ resize.startWidth - (e.clientX - resize.startX)
1375
+ )
1376
+ );
871
1377
  }
872
- if (resize.direction === "bottom" || resize.direction === "corner") {
1378
+ if (resize.direction === "bottom" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
873
1379
  newHeight = Math.max(
874
1380
  Math.round(minWidth / aspectRatio),
875
1381
  Math.min(
@@ -879,7 +1385,7 @@ var ResizableNodeView = ({
879
1385
  );
880
1386
  }
881
1387
  if (lockAspect) {
882
- if (resize.direction === "right" || resize.direction === "corner") {
1388
+ if (resize.direction === "left" || resize.direction === "right" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
883
1389
  newHeight = Math.round(newWidth / aspectRatio);
884
1390
  } else {
885
1391
  newWidth = Math.round(newHeight * aspectRatio);
@@ -889,10 +1395,11 @@ var ResizableNodeView = ({
889
1395
  containerRef.current.style.width = `${newWidth}px`;
890
1396
  containerRef.current.style.height = `${newHeight}px`;
891
1397
  }
1398
+ setCurrentDimensions({ h: newHeight, w: newWidth });
892
1399
  },
893
1400
  [lockAspect, aspectRatio, minWidth, maxWidth]
894
1401
  );
895
- const handleMouseUp = useCallback4(
1402
+ const handleMouseUp = useCallback5(
896
1403
  function handleMouseUp2() {
897
1404
  const resize = resizingRef.current;
898
1405
  if (!resize) {
@@ -908,10 +1415,12 @@ var ResizableNodeView = ({
908
1415
  updateAttributes({ height: h, width: w });
909
1416
  }
910
1417
  resizingRef.current = null;
1418
+ setIsResizing(false);
1419
+ setCurrentDimensions(null);
911
1420
  },
912
1421
  [handleMouseMove, updateAttributes]
913
1422
  );
914
- const handleMouseDown = useCallback4(
1423
+ const handleMouseDown = useCallback5(
915
1424
  (e, direction) => {
916
1425
  e.preventDefault();
917
1426
  e.stopPropagation();
@@ -926,20 +1435,23 @@ var ResizableNodeView = ({
926
1435
  startX: e.clientX,
927
1436
  startY: e.clientY
928
1437
  };
1438
+ setIsResizing(true);
1439
+ setCurrentDimensions({ h: startHeight, w: startWidth });
929
1440
  document.addEventListener("mousemove", handleMouseMove);
930
1441
  document.addEventListener("mouseup", handleMouseUp);
931
- let cursor = "nwse-resize";
932
- if (direction === "right") {
933
- cursor = "ew-resize";
934
- } else if (direction === "bottom") {
935
- cursor = "ns-resize";
936
- }
937
- document.body.style.cursor = cursor;
1442
+ const cursors = {
1443
+ bottom: "ns-resize",
1444
+ "corner-bl": "nesw-resize",
1445
+ "corner-br": "nwse-resize",
1446
+ left: "ew-resize",
1447
+ right: "ew-resize"
1448
+ };
1449
+ document.body.style.cursor = cursors[direction];
938
1450
  document.body.style.userSelect = "none";
939
1451
  },
940
1452
  [width, height, getEditorWidth, handleMouseMove, handleMouseUp]
941
1453
  );
942
- useEffect2(
1454
+ useEffect3(
943
1455
  () => () => {
944
1456
  document.removeEventListener("mousemove", handleMouseMove);
945
1457
  document.removeEventListener("mouseup", handleMouseUp);
@@ -948,13 +1460,32 @@ var ResizableNodeView = ({
948
1460
  },
949
1461
  [handleMouseMove, handleMouseUp]
950
1462
  );
951
- return /* @__PURE__ */ jsx10(
1463
+ const handleApplyPreset = (percent) => {
1464
+ const editorW = getEditorWidth() || 800;
1465
+ const targetW = Math.round(
1466
+ Math.max(minWidth, Math.min(maxWidth, editorW * percent / 100))
1467
+ );
1468
+ updateAttributes({
1469
+ height: Math.round(targetW / aspectRatio),
1470
+ width: targetW
1471
+ });
1472
+ };
1473
+ const handleSaveUrl = () => {
1474
+ if (urlInput && onSrcChange) {
1475
+ onSrcChange(urlInput);
1476
+ } else if (urlInput) {
1477
+ updateAttributes({ src: urlInput });
1478
+ }
1479
+ setIsEditingUrl(false);
1480
+ };
1481
+ const isEditable = editor ? editor.isEditable : true;
1482
+ return /* @__PURE__ */ jsx11(
952
1483
  NodeViewWrapper,
953
1484
  {
954
1485
  className: "rte-embed-wrapper",
955
1486
  "data-selected": selected || void 0,
956
1487
  "data-align": align,
957
- children: /* @__PURE__ */ jsxs4(
1488
+ children: /* @__PURE__ */ jsxs5(
958
1489
  "div",
959
1490
  {
960
1491
  ref: containerRef,
@@ -967,8 +1498,40 @@ var ResizableNodeView = ({
967
1498
  },
968
1499
  children: [
969
1500
  children,
970
- selected && /* @__PURE__ */ jsxs4(Fragment2, { children: [
971
- /* @__PURE__ */ jsx10(
1501
+ selected && isEditable && /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ jsx11(
1502
+ EmbedToolbar,
1503
+ {
1504
+ align,
1505
+ videoSrc,
1506
+ watchUrl,
1507
+ deleteNode,
1508
+ inputRef,
1509
+ isEditingUrl,
1510
+ urlInput,
1511
+ setUrlInput,
1512
+ setIsEditingUrl,
1513
+ handleSaveUrl,
1514
+ handleApplyPreset,
1515
+ updateAttributes,
1516
+ nodeSrc: node.attrs.src
1517
+ }
1518
+ ) }),
1519
+ isResizing && currentDimensions && /* @__PURE__ */ jsxs5("div", { className: "rte-embed-resize-badge", children: [
1520
+ currentDimensions.w,
1521
+ " \xD7 ",
1522
+ currentDimensions.h,
1523
+ " px"
1524
+ ] }),
1525
+ selected && isEditable && /* @__PURE__ */ jsxs5(Fragment3, { children: [
1526
+ /* @__PURE__ */ jsx11(
1527
+ "div",
1528
+ {
1529
+ className: "rte-resize-handle rte-resize-handle--left",
1530
+ onMouseDown: (e) => handleMouseDown(e, "left"),
1531
+ role: "presentation"
1532
+ }
1533
+ ),
1534
+ /* @__PURE__ */ jsx11(
972
1535
  "div",
973
1536
  {
974
1537
  className: "rte-resize-handle rte-resize-handle--right",
@@ -976,7 +1539,7 @@ var ResizableNodeView = ({
976
1539
  role: "presentation"
977
1540
  }
978
1541
  ),
979
- /* @__PURE__ */ jsx10(
1542
+ /* @__PURE__ */ jsx11(
980
1543
  "div",
981
1544
  {
982
1545
  className: "rte-resize-handle rte-resize-handle--bottom",
@@ -984,11 +1547,19 @@ var ResizableNodeView = ({
984
1547
  role: "presentation"
985
1548
  }
986
1549
  ),
987
- /* @__PURE__ */ jsx10(
1550
+ /* @__PURE__ */ jsx11(
988
1551
  "div",
989
1552
  {
990
- className: "rte-resize-handle rte-resize-handle--corner",
991
- onMouseDown: (e) => handleMouseDown(e, "corner"),
1553
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
1554
+ onMouseDown: (e) => handleMouseDown(e, "corner-bl"),
1555
+ role: "presentation"
1556
+ }
1557
+ ),
1558
+ /* @__PURE__ */ jsx11(
1559
+ "div",
1560
+ {
1561
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
1562
+ onMouseDown: (e) => handleMouseDown(e, "corner-br"),
992
1563
  role: "presentation"
993
1564
  }
994
1565
  )
@@ -1003,15 +1574,15 @@ var ResizableNodeView = ({
1003
1574
  // src/ui/dialog.tsx
1004
1575
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
1005
1576
  import "react";
1006
- import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
1007
- var Dialog = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1008
- var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1009
- var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1010
- var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx11(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1577
+ import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1578
+ var Dialog = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1579
+ var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1580
+ var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1581
+ var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1011
1582
  var DialogOverlay = ({
1012
1583
  className,
1013
1584
  ...props
1014
- }) => /* @__PURE__ */ jsx11(
1585
+ }) => /* @__PURE__ */ jsx12(
1015
1586
  DialogPrimitive.Backdrop,
1016
1587
  {
1017
1588
  "data-slot": "dialog-overlay",
@@ -1027,9 +1598,9 @@ var DialogContent = ({
1027
1598
  children,
1028
1599
  showCloseButton = true,
1029
1600
  ...props
1030
- }) => /* @__PURE__ */ jsxs5(DialogPortal, { children: [
1031
- /* @__PURE__ */ jsx11(DialogOverlay, {}),
1032
- /* @__PURE__ */ jsxs5(
1601
+ }) => /* @__PURE__ */ jsxs6(DialogPortal, { children: [
1602
+ /* @__PURE__ */ jsx12(DialogOverlay, {}),
1603
+ /* @__PURE__ */ jsxs6(
1033
1604
  DialogPrimitive.Popup,
1034
1605
  {
1035
1606
  "data-slot": "dialog-content",
@@ -1040,11 +1611,11 @@ var DialogContent = ({
1040
1611
  ...props,
1041
1612
  children: [
1042
1613
  children,
1043
- showCloseButton && /* @__PURE__ */ jsxs5(
1614
+ showCloseButton && /* @__PURE__ */ jsxs6(
1044
1615
  DialogPrimitive.Close,
1045
1616
  {
1046
1617
  "data-slot": "dialog-close",
1047
- render: /* @__PURE__ */ jsx11(
1618
+ render: /* @__PURE__ */ jsx12(
1048
1619
  Button,
1049
1620
  {
1050
1621
  variant: "ghost",
@@ -1054,7 +1625,7 @@ var DialogContent = ({
1054
1625
  ),
1055
1626
  children: [
1056
1627
  "X",
1057
- /* @__PURE__ */ jsx11("span", { className: "sr-only", children: "Close" })
1628
+ /* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Close" })
1058
1629
  ]
1059
1630
  }
1060
1631
  )
@@ -1062,7 +1633,7 @@ var DialogContent = ({
1062
1633
  }
1063
1634
  )
1064
1635
  ] });
1065
- var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx11(
1636
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx12(
1066
1637
  "div",
1067
1638
  {
1068
1639
  "data-slot": "dialog-header",
@@ -1075,7 +1646,7 @@ var DialogFooter = ({
1075
1646
  showCloseButton = false,
1076
1647
  children,
1077
1648
  ...props
1078
- }) => /* @__PURE__ */ jsxs5(
1649
+ }) => /* @__PURE__ */ jsxs6(
1079
1650
  "div",
1080
1651
  {
1081
1652
  "data-slot": "dialog-footer",
@@ -1086,11 +1657,11 @@ var DialogFooter = ({
1086
1657
  ...props,
1087
1658
  children: [
1088
1659
  children,
1089
- showCloseButton && /* @__PURE__ */ jsx11(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx11(Button, { variant: "outline" }), children: "Close" })
1660
+ showCloseButton && /* @__PURE__ */ jsx12(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx12(Button, { variant: "outline" }), children: "Close" })
1090
1661
  ]
1091
1662
  }
1092
1663
  );
1093
- var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx11(
1664
+ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx12(
1094
1665
  DialogPrimitive.Title,
1095
1666
  {
1096
1667
  "data-slot": "dialog-title",
@@ -1101,7 +1672,7 @@ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx11(
1101
1672
  var DialogDescription = ({
1102
1673
  className,
1103
1674
  ...props
1104
- }) => /* @__PURE__ */ jsx11(
1675
+ }) => /* @__PURE__ */ jsx12(
1105
1676
  DialogPrimitive.Description,
1106
1677
  {
1107
1678
  "data-slot": "dialog-description",
@@ -1114,56 +1685,149 @@ var DialogDescription = ({
1114
1685
  );
1115
1686
 
1116
1687
  // src/controls/rte-twitter-control.tsx
1117
- import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1688
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1118
1689
  var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
1690
+ var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
1691
+ var READY_POLL_INTERVAL_MS = 50;
1692
+ var twitterScriptPromise = null;
1693
+ var loadTwitterScript = () => {
1694
+ if (typeof window === "undefined") {
1695
+ return Promise.resolve();
1696
+ }
1697
+ if (window.twttr?.widgets) {
1698
+ return Promise.resolve();
1699
+ }
1700
+ if (twitterScriptPromise) {
1701
+ return twitterScriptPromise;
1702
+ }
1703
+ twitterScriptPromise = new Promise((resolve, reject) => {
1704
+ let script = document.querySelector(
1705
+ `script[src="${WIDGET_SCRIPT_URL}"]`
1706
+ );
1707
+ const isNewScript = !script;
1708
+ if (!script) {
1709
+ script = document.createElement("script");
1710
+ script.src = WIDGET_SCRIPT_URL;
1711
+ script.async = true;
1712
+ document.body.append(script);
1713
+ }
1714
+ let settled = false;
1715
+ const cleanup = () => {
1716
+ clearInterval(pollId);
1717
+ clearTimeout(timeoutId);
1718
+ };
1719
+ const succeed = () => {
1720
+ if (settled) return;
1721
+ settled = true;
1722
+ cleanup();
1723
+ resolve();
1724
+ };
1725
+ const fail = () => {
1726
+ if (settled) return;
1727
+ settled = true;
1728
+ cleanup();
1729
+ twitterScriptPromise = null;
1730
+ reject(new Error("Failed to load Twitter widgets script"));
1731
+ };
1732
+ if (window.twttr?.widgets) {
1733
+ succeed();
1734
+ return;
1735
+ }
1736
+ const pollId = setInterval(() => {
1737
+ if (window.twttr?.widgets) {
1738
+ succeed();
1739
+ }
1740
+ }, READY_POLL_INTERVAL_MS);
1741
+ const timeoutId = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
1742
+ if (isNewScript) {
1743
+ script.addEventListener(
1744
+ "load",
1745
+ () => {
1746
+ if (window.twttr?.widgets) {
1747
+ succeed();
1748
+ }
1749
+ },
1750
+ { once: true }
1751
+ );
1752
+ }
1753
+ script.addEventListener("error", fail, { once: true });
1754
+ });
1755
+ return twitterScriptPromise;
1756
+ };
1119
1757
  var TwitterNodeView = (props) => {
1120
1758
  const { node } = props;
1121
1759
  const containerRef = useRef3(null);
1122
- const [loading, setLoading] = useState3(true);
1760
+ const [loading, setLoading] = useState4(true);
1761
+ const [failed, setFailed] = useState4(false);
1123
1762
  const { tweetId } = node.attrs;
1124
- const w = node.attrs.width;
1125
- const h = node.attrs.height;
1126
- const renderTweet = useCallback5(async () => {
1763
+ const renderedTweetIdRef = useRef3(null);
1764
+ const activeRenderIdRef = useRef3(0);
1765
+ const retryToken = useRef3(0);
1766
+ const [retryCount, setRetryCount] = useState4(0);
1767
+ useEffect4(() => {
1127
1768
  if (!containerRef.current || !tweetId) {
1128
1769
  return;
1129
1770
  }
1130
- containerRef.current.innerHTML = "";
1131
- setLoading(true);
1132
- const { twttr } = window;
1133
- if (twttr?.widgets && containerRef.current) {
1134
- try {
1135
- await twttr.widgets.createTweet(tweetId, containerRef.current);
1136
- setLoading(false);
1137
- } catch {
1138
- }
1139
- }
1140
- }, [tweetId]);
1141
- useEffect3(() => {
1142
- if (!containerRef.current || !tweetId) {
1771
+ if (renderedTweetIdRef.current === tweetId && containerRef.current.children.length > 0 && !failed) {
1772
+ setLoading(false);
1143
1773
  return;
1144
1774
  }
1145
- const load = async () => {
1146
- if (window.twttr?.widgets && containerRef.current) {
1775
+ let isCancelled = false;
1776
+ activeRenderIdRef.current += 1;
1777
+ const renderId = activeRenderIdRef.current;
1778
+ setLoading(true);
1779
+ setFailed(false);
1780
+ const render = async () => {
1781
+ try {
1782
+ await loadTwitterScript();
1783
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
1784
+ return;
1785
+ }
1786
+ const { twttr } = window;
1787
+ if (!twttr?.widgets) {
1788
+ throw new Error("Twitter widgets script unavailable");
1789
+ }
1147
1790
  containerRef.current.innerHTML = "";
1148
- setLoading(true);
1149
- try {
1150
- await window.twttr.widgets.createTweet(tweetId, containerRef.current);
1791
+ const el = await twttr.widgets.createTweet(
1792
+ tweetId,
1793
+ containerRef.current
1794
+ );
1795
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
1796
+ if (el && typeof el.remove === "function") {
1797
+ el.remove();
1798
+ } else if (containerRef.current) {
1799
+ containerRef.current.innerHTML = "";
1800
+ }
1801
+ return;
1802
+ }
1803
+ if (!el) {
1804
+ throw new Error("Tweet could not be embedded");
1805
+ }
1806
+ while (containerRef.current.children.length > 1) {
1807
+ containerRef.current.firstElementChild?.remove();
1808
+ }
1809
+ renderedTweetIdRef.current = tweetId;
1810
+ } catch {
1811
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
1812
+ setFailed(true);
1813
+ renderedTweetIdRef.current = null;
1814
+ }
1815
+ } finally {
1816
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
1151
1817
  setLoading(false);
1152
- } catch {
1153
1818
  }
1154
- } else {
1155
- const script = document.createElement("script");
1156
- script.src = WIDGET_SCRIPT_URL;
1157
- script.async = true;
1158
- script.addEventListener("load", () => {
1159
- void renderTweet();
1160
- });
1161
- document.body.append(script);
1162
1819
  }
1163
1820
  };
1164
- void load();
1165
- }, [tweetId, w, h, renderTweet]);
1166
- return /* @__PURE__ */ jsxs6(
1821
+ void render();
1822
+ return () => {
1823
+ isCancelled = true;
1824
+ };
1825
+ }, [tweetId, retryCount, failed]);
1826
+ const handleRetry = useCallback6(() => {
1827
+ retryToken.current += 1;
1828
+ setRetryCount(retryToken.current);
1829
+ }, []);
1830
+ return /* @__PURE__ */ jsxs7(
1167
1831
  ResizableNodeView,
1168
1832
  {
1169
1833
  ...props,
@@ -1171,8 +1835,12 @@ var TwitterNodeView = (props) => {
1171
1835
  minWidth: 300,
1172
1836
  maxWidth: 1200,
1173
1837
  children: [
1174
- loading && /* @__PURE__ */ jsx12("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1175
- /* @__PURE__ */ jsx12("div", { ref: containerRef })
1838
+ loading && /* @__PURE__ */ jsx13("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1839
+ !loading && failed && /* @__PURE__ */ jsxs7("div", { className: "rte-embed-error", children: [
1840
+ /* @__PURE__ */ jsx13("p", { children: "Couldn't load this tweet." }),
1841
+ /* @__PURE__ */ jsx13("button", { type: "button", onClick: handleRetry, children: "Retry" })
1842
+ ] }),
1843
+ /* @__PURE__ */ jsx13("div", { ref: containerRef })
1176
1844
  ]
1177
1845
  }
1178
1846
  );
@@ -1262,88 +1930,119 @@ var extractTweetId = (input) => {
1262
1930
  };
1263
1931
  var TwitterEmbedControl = ({ className }) => {
1264
1932
  const { editor } = useRichTextEditorContext();
1265
- const [open, setOpen] = useState3(false);
1266
- const [url, setUrl] = useState3("");
1933
+ const [open, setOpen] = useState4(false);
1934
+ const [url, setUrl] = useState4("");
1935
+ const [touched, setTouched] = useState4(false);
1267
1936
  const { active } = useEditorState4({
1268
1937
  editor: editor ?? null,
1269
1938
  selector: (ctx) => ({
1270
1939
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
1271
1940
  })
1272
1941
  }) ?? { active: false };
1273
- const handleInsert = useCallback5(() => {
1274
- if (url && editor) {
1275
- const tweetId = extractTweetId(url);
1276
- if (tweetId) {
1277
- editor.chain().focus().setTwitterEmbed(tweetId).run();
1278
- setUrl("");
1279
- }
1942
+ const tweetId = url ? extractTweetId(url) : null;
1943
+ const showError = touched && url.length > 0 && !tweetId;
1944
+ const resetState = useCallback6(() => {
1945
+ setUrl("");
1946
+ setTouched(false);
1947
+ }, []);
1948
+ const handleInsert = useCallback6(() => {
1949
+ setTouched(true);
1950
+ if (!tweetId || !editor) {
1951
+ return false;
1280
1952
  }
1281
- }, [url, editor]);
1282
- return /* @__PURE__ */ jsxs6(Dialog, { open, onOpenChange: setOpen, children: [
1283
- /* @__PURE__ */ jsx12(
1284
- DialogTrigger,
1285
- {
1286
- render: /* @__PURE__ */ jsx12(
1287
- RichTextEditorControl,
1953
+ editor.chain().focus().setTwitterEmbed(tweetId).run();
1954
+ resetState();
1955
+ return true;
1956
+ }, [tweetId, editor, resetState]);
1957
+ return /* @__PURE__ */ jsxs7(
1958
+ Dialog,
1959
+ {
1960
+ open,
1961
+ onOpenChange: (next) => {
1962
+ setOpen(next);
1963
+ if (!next) {
1964
+ resetState();
1965
+ }
1966
+ },
1967
+ children: [
1968
+ /* @__PURE__ */ jsx13(
1969
+ DialogTrigger,
1288
1970
  {
1289
- active,
1290
- className,
1291
- title: "Embed Tweet",
1292
- "aria-label": "Embed Tweet",
1293
- children: /* @__PURE__ */ jsx12(
1294
- "svg",
1971
+ render: /* @__PURE__ */ jsx13(
1972
+ RichTextEditorControl,
1295
1973
  {
1296
- xmlns: "http://www.w3.org/2000/svg",
1297
- viewBox: "0 0 24 24",
1298
- fill: "currentColor",
1299
- className: "rte-editor-icon",
1300
- children: /* @__PURE__ */ jsx12("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" })
1974
+ active,
1975
+ className,
1976
+ title: "Embed Tweet",
1977
+ "aria-label": "Embed Tweet",
1978
+ children: /* @__PURE__ */ jsx13(
1979
+ "svg",
1980
+ {
1981
+ xmlns: "http://www.w3.org/2000/svg",
1982
+ viewBox: "0 0 24 24",
1983
+ fill: "currentColor",
1984
+ className: "rte-editor-icon",
1985
+ children: /* @__PURE__ */ jsx13("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
1986
+ }
1987
+ )
1301
1988
  }
1302
1989
  )
1303
1990
  }
1304
- )
1305
- }
1306
- ),
1307
- /* @__PURE__ */ jsxs6(DialogContent, { children: [
1308
- /* @__PURE__ */ jsxs6(DialogHeader, { children: [
1309
- /* @__PURE__ */ jsx12(DialogTitle, { children: "Embed Tweet" }),
1310
- /* @__PURE__ */ jsx12(DialogDescription, { children: "Paste a tweet URL or ID." })
1311
- ] }),
1312
- /* @__PURE__ */ jsx12(
1313
- Input,
1314
- {
1315
- value: url,
1316
- onChange: (e) => setUrl(e.target.value),
1317
- placeholder: "https://x.com/user/status/...",
1318
- onKeyDown: (e) => {
1319
- if (e.key === "Enter" && url) {
1320
- handleInsert();
1321
- setOpen(false);
1991
+ ),
1992
+ /* @__PURE__ */ jsxs7(DialogContent, { children: [
1993
+ /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1994
+ /* @__PURE__ */ jsx13(DialogTitle, { children: "Embed Tweet" }),
1995
+ /* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a tweet URL or ID." })
1996
+ ] }),
1997
+ /* @__PURE__ */ jsx13(
1998
+ Input,
1999
+ {
2000
+ value: url,
2001
+ onChange: (e) => {
2002
+ setUrl(e.target.value);
2003
+ if (touched) setTouched(false);
2004
+ },
2005
+ onBlur: () => setTouched(true),
2006
+ placeholder: "https://x.com/user/status/...",
2007
+ "aria-invalid": showError,
2008
+ onKeyDown: (e) => {
2009
+ if (e.key === "Enter" && url) {
2010
+ if (handleInsert()) {
2011
+ setOpen(false);
2012
+ }
2013
+ }
2014
+ }
1322
2015
  }
1323
- }
1324
- }
1325
- ),
1326
- /* @__PURE__ */ jsxs6(DialogFooter, { children: [
1327
- /* @__PURE__ */ jsx12(DialogClose, { children: "Cancel" }),
1328
- /* @__PURE__ */ jsx12(
1329
- DialogClose,
1330
- {
1331
- disabled: !url,
1332
- className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
1333
- onClick: handleInsert,
1334
- children: "Insert"
1335
- }
1336
- )
1337
- ] })
1338
- ] })
1339
- ] });
2016
+ ),
2017
+ showError && /* @__PURE__ */ jsx13("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
2018
+ /* @__PURE__ */ jsxs7(DialogFooter, { children: [
2019
+ /* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
2020
+ /* @__PURE__ */ jsx13(
2021
+ "button",
2022
+ {
2023
+ type: "button",
2024
+ disabled: !url,
2025
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
2026
+ onClick: () => {
2027
+ if (handleInsert()) {
2028
+ setOpen(false);
2029
+ }
2030
+ },
2031
+ children: "Insert"
2032
+ }
2033
+ )
2034
+ ] })
2035
+ ] })
2036
+ ]
2037
+ }
2038
+ );
1340
2039
  };
1341
2040
 
1342
2041
  // src/controls/rte-youtube-control.tsx
1343
2042
  import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
1344
2043
  import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
1345
- import { useState as useState4, useCallback as useCallback6 } from "react";
1346
- import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
2044
+ import { useState as useState5, useCallback as useCallback7 } from "react";
2045
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1347
2046
  var getYouTubeId = (url) => {
1348
2047
  const clean = url.trim();
1349
2048
  const patterns = [
@@ -1364,9 +2063,14 @@ var getYouTubeId = (url) => {
1364
2063
  return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
1365
2064
  };
1366
2065
  var YouTubeNodeView = (props) => {
1367
- const { node } = props;
1368
- const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
1369
- return /* @__PURE__ */ jsx13(
2066
+ const { node, updateAttributes } = props;
2067
+ const rawSrc = node.attrs.src || "";
2068
+ const videoId = getYouTubeId(rawSrc) || rawSrc;
2069
+ let watchUrl;
2070
+ if (videoId) {
2071
+ watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
2072
+ }
2073
+ return /* @__PURE__ */ jsx14(
1370
2074
  ResizableNodeView,
1371
2075
  {
1372
2076
  ...props,
@@ -1374,7 +2078,10 @@ var YouTubeNodeView = (props) => {
1374
2078
  aspectRatio: 16 / 9,
1375
2079
  minWidth: 320,
1376
2080
  maxWidth: 1200,
1377
- children: /* @__PURE__ */ jsx13(
2081
+ videoSrc: rawSrc,
2082
+ watchUrl,
2083
+ onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
2084
+ children: /* @__PURE__ */ jsx14(
1378
2085
  "iframe",
1379
2086
  {
1380
2087
  src: `https://www.youtube-nocookie.com/embed/${videoId}`,
@@ -1462,32 +2169,32 @@ var YouTubeEmbed = Node2.create({
1462
2169
  });
1463
2170
  var YouTubeEmbedControl = ({ className }) => {
1464
2171
  const { editor } = useRichTextEditorContext();
1465
- const [open, setOpen] = useState4(false);
1466
- const [url, setUrl] = useState4("");
2172
+ const [open, setOpen] = useState5(false);
2173
+ const [url, setUrl] = useState5("");
1467
2174
  const { active } = useEditorState5({
1468
2175
  editor: editor ?? null,
1469
2176
  selector: (ctx) => ({
1470
2177
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
1471
2178
  })
1472
2179
  }) ?? { active: false };
1473
- const handleInsert = useCallback6(() => {
2180
+ const handleInsert = useCallback7(() => {
1474
2181
  if (url && editor) {
1475
2182
  editor.chain().focus().setYouTubeEmbed(url).run();
1476
2183
  setUrl("");
1477
2184
  }
1478
2185
  }, [url, editor]);
1479
- return /* @__PURE__ */ jsxs7(Dialog, { open, onOpenChange: setOpen, children: [
1480
- /* @__PURE__ */ jsx13(
2186
+ return /* @__PURE__ */ jsxs8(Dialog, { open, onOpenChange: setOpen, children: [
2187
+ /* @__PURE__ */ jsx14(
1481
2188
  DialogTrigger,
1482
2189
  {
1483
- render: /* @__PURE__ */ jsx13(
2190
+ render: /* @__PURE__ */ jsx14(
1484
2191
  RichTextEditorControl,
1485
2192
  {
1486
2193
  active,
1487
2194
  className,
1488
2195
  title: "Embed YouTube video",
1489
2196
  "aria-label": "Embed YouTube video",
1490
- children: /* @__PURE__ */ jsxs7(
2197
+ children: /* @__PURE__ */ jsxs8(
1491
2198
  "svg",
1492
2199
  {
1493
2200
  xmlns: "http://www.w3.org/2000/svg",
@@ -1499,8 +2206,8 @@ var YouTubeEmbedControl = ({ className }) => {
1499
2206
  strokeLinejoin: "round",
1500
2207
  className: "rte-editor-icon",
1501
2208
  children: [
1502
- /* @__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" }),
1503
- /* @__PURE__ */ jsx13("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
2209
+ /* @__PURE__ */ jsx14("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" }),
2210
+ /* @__PURE__ */ jsx14("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1504
2211
  ]
1505
2212
  }
1506
2213
  )
@@ -1508,12 +2215,12 @@ var YouTubeEmbedControl = ({ className }) => {
1508
2215
  )
1509
2216
  }
1510
2217
  ),
1511
- /* @__PURE__ */ jsxs7(DialogContent, { showCloseButton: false, children: [
1512
- /* @__PURE__ */ jsxs7(DialogHeader, { children: [
1513
- /* @__PURE__ */ jsx13(DialogTitle, { children: "Embed YouTube video" }),
1514
- /* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a YouTube video URL or ID." })
2218
+ /* @__PURE__ */ jsxs8(DialogContent, { showCloseButton: false, children: [
2219
+ /* @__PURE__ */ jsxs8(DialogHeader, { children: [
2220
+ /* @__PURE__ */ jsx14(DialogTitle, { children: "Embed YouTube video" }),
2221
+ /* @__PURE__ */ jsx14(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1515
2222
  ] }),
1516
- /* @__PURE__ */ jsx13(
2223
+ /* @__PURE__ */ jsx14(
1517
2224
  Input,
1518
2225
  {
1519
2226
  value: url,
@@ -1527,9 +2234,9 @@ var YouTubeEmbedControl = ({ className }) => {
1527
2234
  }
1528
2235
  }
1529
2236
  ),
1530
- /* @__PURE__ */ jsxs7(DialogFooter, { children: [
1531
- /* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
1532
- /* @__PURE__ */ jsx13(
2237
+ /* @__PURE__ */ jsxs8(DialogFooter, { children: [
2238
+ /* @__PURE__ */ jsx14(DialogClose, { children: "Cancel" }),
2239
+ /* @__PURE__ */ jsx14(
1533
2240
  DialogClose,
1534
2241
  {
1535
2242
  disabled: !url,
@@ -1543,310 +2250,6 @@ var YouTubeEmbedControl = ({ className }) => {
1543
2250
  ] });
1544
2251
  };
1545
2252
 
1546
- // src/icons.tsx
1547
- import "react";
1548
- import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1549
- var iconProps = { className: "rte-editor-icon" };
1550
- var Svg2 = ({
1551
- children,
1552
- className,
1553
- strokeWidth = 2
1554
- }) => /* @__PURE__ */ jsx14(
1555
- "svg",
1556
- {
1557
- xmlns: "http://www.w3.org/2000/svg",
1558
- viewBox: "0 0 24 24",
1559
- fill: "none",
1560
- stroke: "currentColor",
1561
- strokeWidth,
1562
- strokeLinecap: "round",
1563
- strokeLinejoin: "round",
1564
- className,
1565
- children
1566
- }
1567
- );
1568
- var LangIcon = ({
1569
- children,
1570
- className
1571
- }) => /* @__PURE__ */ jsx14(
1572
- "svg",
1573
- {
1574
- xmlns: "http://www.w3.org/2000/svg",
1575
- viewBox: "0 0 24 24",
1576
- fill: "none",
1577
- stroke: "currentColor",
1578
- strokeWidth: 1.5,
1579
- strokeLinecap: "round",
1580
- strokeLinejoin: "round",
1581
- className,
1582
- children
1583
- }
1584
- );
1585
- var DEFAULT_LANGUAGE_ICONS = {
1586
- bash: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1587
- /* @__PURE__ */ jsx14("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1588
- /* @__PURE__ */ jsx14("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1589
- /* @__PURE__ */ jsx14("path", { d: "M12 15.5h5.5" })
1590
- ] }),
1591
- c: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1592
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "8.5" }),
1593
- /* @__PURE__ */ jsx14("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1594
- ] }),
1595
- cpp: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1596
- /* @__PURE__ */ jsx14("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1597
- /* @__PURE__ */ jsx14("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1598
- /* @__PURE__ */ jsx14("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1599
- /* @__PURE__ */ jsx14("path", { d: "M19.3 10.5v3M17.8 12h3" })
1600
- ] }),
1601
- css: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1602
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1603
- /* @__PURE__ */ jsx14("path", { d: "M9.7 7.5l-1 9" }),
1604
- /* @__PURE__ */ jsx14("path", { d: "M15.3 7.5l-1 9" }),
1605
- /* @__PURE__ */ jsx14("path", { d: "M7 10.3h11" }),
1606
- /* @__PURE__ */ jsx14("path", { d: "M6.5 14.3h11" })
1607
- ] }),
1608
- go: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1609
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1610
- /* @__PURE__ */ jsx14("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1611
- /* @__PURE__ */ jsx14("path", { d: "M12.6 12h-1.9" }),
1612
- /* @__PURE__ */ jsx14("circle", { cx: "17", cy: "12", r: "2.9" })
1613
- ] }),
1614
- html: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1615
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1616
- /* @__PURE__ */ jsx14("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1617
- /* @__PURE__ */ jsx14("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1618
- /* @__PURE__ */ jsx14("path", { d: "M13 7.3l-2 9.4" })
1619
- ] }),
1620
- java: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1621
- /* @__PURE__ */ jsx14("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1622
- /* @__PURE__ */ jsx14("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1623
- /* @__PURE__ */ jsx14("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" }),
1624
- /* @__PURE__ */ jsx14("path", { d: "M6 19.3h10" })
1625
- ] }),
1626
- javascript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1627
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1628
- /* @__PURE__ */ jsx14("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1629
- /* @__PURE__ */ jsx14("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" })
1630
- ] }),
1631
- json: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1632
- /* @__PURE__ */ jsx14("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" }),
1633
- /* @__PURE__ */ jsx14("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" })
1634
- ] }),
1635
- kotlin: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1636
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1637
- /* @__PURE__ */ jsx14("path", { d: "M9 7.5v9" }),
1638
- /* @__PURE__ */ jsx14("path", { d: "M9 12l6-4.5" }),
1639
- /* @__PURE__ */ jsx14("path", { d: "M9 12l6 4.5" })
1640
- ] }),
1641
- markdown: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1642
- /* @__PURE__ */ jsx14("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1643
- /* @__PURE__ */ jsx14("path", { d: "M6 15V9l3 4 3-4v6" }),
1644
- /* @__PURE__ */ jsx14("path", { d: "M16.5 9v6" }),
1645
- /* @__PURE__ */ jsx14("path", { d: "M14.5 13l2 2 2-2" })
1646
- ] }),
1647
- php: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1648
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1649
- /* @__PURE__ */ jsx14("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1650
- /* @__PURE__ */ jsx14("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" }),
1651
- /* @__PURE__ */ jsx14("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1652
- ] }),
1653
- plaintext: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1654
- /* @__PURE__ */ jsx14("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1655
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1656
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1657
- /* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1658
- ] }),
1659
- python: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1660
- /* @__PURE__ */ jsx14("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1661
- /* @__PURE__ */ jsx14("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1662
- /* @__PURE__ */ jsx14("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1663
- /* @__PURE__ */ jsx14("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1664
- ] }),
1665
- ruby: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1666
- /* @__PURE__ */ jsx14("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1667
- /* @__PURE__ */ jsx14("path", { d: "M4.5 8h15" }),
1668
- /* @__PURE__ */ jsx14("path", { d: "M12 2.5v19" })
1669
- ] }),
1670
- rust: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1671
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "7" }),
1672
- /* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "2.3" }),
1673
- /* @__PURE__ */ jsx14("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1674
- /* @__PURE__ */ jsx14("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" })
1675
- ] }),
1676
- sql: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1677
- /* @__PURE__ */ jsx14("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1678
- /* @__PURE__ */ jsx14("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1679
- /* @__PURE__ */ jsx14("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1680
- ] }),
1681
- swift: /* @__PURE__ */ jsx14(LangIcon, { children: /* @__PURE__ */ jsx14("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" }) }),
1682
- typescript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1683
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1684
- /* @__PURE__ */ jsx14("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1685
- /* @__PURE__ */ jsx14("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" })
1686
- ] }),
1687
- xml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1688
- /* @__PURE__ */ jsx14("path", { d: "M8 7l-4.5 5 4.5 5" }),
1689
- /* @__PURE__ */ jsx14("path", { d: "M16 7l4.5 5-4.5 5" }),
1690
- /* @__PURE__ */ jsx14("path", { d: "M12 8v8" })
1691
- ] }),
1692
- yaml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
1693
- /* @__PURE__ */ jsx14("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1694
- /* @__PURE__ */ jsx14("path", { d: "M6.5 8h2M9.5 8h8" }),
1695
- /* @__PURE__ */ jsx14("path", { d: "M6.5 12h2M9.5 12h6" }),
1696
- /* @__PURE__ */ jsx14("path", { d: "M6.5 16h2M9.5 16h7" })
1697
- ] })
1698
- };
1699
- var DEFAULT_ICONS = {
1700
- alignCenterControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1701
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1702
- /* @__PURE__ */ jsx14("line", { x1: "7", y1: "12", x2: "17", y2: "12" }),
1703
- /* @__PURE__ */ jsx14("line", { x1: "5.5", y1: "18", x2: "18.5", y2: "18" })
1704
- ] }),
1705
- alignJustifyControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1706
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1707
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" }),
1708
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "18", x2: "20", y2: "18" })
1709
- ] }),
1710
- alignLeftControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1711
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1712
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "14", y2: "12" }),
1713
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "18", x2: "17", y2: "18" })
1714
- ] }),
1715
- alignRightControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1716
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1717
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "12", x2: "20", y2: "12" }),
1718
- /* @__PURE__ */ jsx14("line", { x1: "7", y1: "18", x2: "20", y2: "18" })
1719
- ] }),
1720
- blockquoteControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1721
- /* @__PURE__ */ jsx14("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" }),
1722
- /* @__PURE__ */ jsx14("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" })
1723
- ] }),
1724
- boldControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1725
- /* @__PURE__ */ jsx14("path", { d: "M6 4h7a4 4 0 0 1 0 8H6z" }),
1726
- /* @__PURE__ */ jsx14("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })
1727
- ] }),
1728
- bulletListControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1729
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "6", x2: "21", y2: "6" }),
1730
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "12", x2: "21", y2: "12" }),
1731
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "18", x2: "21", y2: "18" }),
1732
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "6", r: "1.2", fill: "currentColor", stroke: "none" }),
1733
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "12", r: "1.2", fill: "currentColor", stroke: "none" }),
1734
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "18", r: "1.2", fill: "currentColor", stroke: "none" })
1735
- ] }),
1736
- clearFormattingControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1737
- /* @__PURE__ */ jsx14("path", { d: "M4 7V4h16v3" }),
1738
- /* @__PURE__ */ jsx14("path", { d: "M5 20h6" }),
1739
- /* @__PURE__ */ jsx14("path", { d: "M13 4 8 20" }),
1740
- /* @__PURE__ */ jsx14("path", { d: "m16 16 5 5" }),
1741
- /* @__PURE__ */ jsx14("path", { d: "m21 16-5 5" })
1742
- ] }),
1743
- codeBlockControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1744
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
1745
- /* @__PURE__ */ jsx14("polyline", { points: "10 9 8 12 10 15" }),
1746
- /* @__PURE__ */ jsx14("polyline", { points: "14 9 16 12 14 15" })
1747
- ] }),
1748
- codeControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1749
- /* @__PURE__ */ jsx14("polyline", { points: "16 18 22 12 16 6" }),
1750
- /* @__PURE__ */ jsx14("polyline", { points: "8 6 2 12 8 18" })
1751
- ] }),
1752
- h1ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1753
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1754
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1755
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1756
- /* @__PURE__ */ jsx14("path", { d: "m17 10 3-2v8" })
1757
- ] }),
1758
- h2ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1759
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1760
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1761
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1762
- /* @__PURE__ */ jsx14("path", { d: "M17 9.5a2.5 2.5 0 0 1 4.8-1c0 2-4.8 2.5-4.8 5.5h5" })
1763
- ] }),
1764
- h3ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1765
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1766
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1767
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1768
- /* @__PURE__ */ jsx14("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" }),
1769
- /* @__PURE__ */ jsx14("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" })
1770
- ] }),
1771
- h4ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1772
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1773
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1774
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1775
- /* @__PURE__ */ jsx14("path", { d: "M20 9v5h-4l3.5-5.5" }),
1776
- /* @__PURE__ */ jsx14("path", { d: "M20 14v3" })
1777
- ] }),
1778
- h5ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1779
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1780
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1781
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1782
- /* @__PURE__ */ jsx14("path", { d: "M21 9h-4v3.5c2.5-.7 4.5.3 4.5 2a2.3 2.3 0 0 1-4.3 1.3" })
1783
- ] }),
1784
- h6ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1785
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1786
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1787
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1788
- /* @__PURE__ */ jsx14("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" })
1789
- ] }),
1790
- highlightControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1791
- /* @__PURE__ */ jsx14("path", { d: "M9 11 3 17v3h3l6-6" }),
1792
- /* @__PURE__ */ jsx14("path", { d: "M14 6l4-4 4 4-4 4" }),
1793
- /* @__PURE__ */ jsx14("path", { d: "m9 11 4-4 5 5-4 4" })
1794
- ] }),
1795
- hrControlIcon: /* @__PURE__ */ jsx14(Svg2, { ...iconProps, children: /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) }),
1796
- italicControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1797
- /* @__PURE__ */ jsx14("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
1798
- /* @__PURE__ */ jsx14("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
1799
- /* @__PURE__ */ jsx14("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
1800
- ] }),
1801
- languageIcons: DEFAULT_LANGUAGE_ICONS,
1802
- linkControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1803
- /* @__PURE__ */ jsx14("path", { d: "M9 17H7a5 5 0 0 1 0-10h2" }),
1804
- /* @__PURE__ */ jsx14("path", { d: "M15 7h2a5 5 0 0 1 0 10h-2" }),
1805
- /* @__PURE__ */ jsx14("line", { x1: "8", y1: "12", x2: "16", y2: "12" })
1806
- ] }),
1807
- orderedListControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1808
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
1809
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
1810
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
1811
- /* @__PURE__ */ jsx14("path", { d: "M4 5h2v4" }),
1812
- /* @__PURE__ */ jsx14("path", { d: "M4 9h2" }),
1813
- /* @__PURE__ */ jsx14("path", { d: "M4 13h2.5L4 16h2.5" }),
1814
- /* @__PURE__ */ jsx14("path", { d: "M4 19h2.5" })
1815
- ] }),
1816
- redoControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1817
- /* @__PURE__ */ jsx14("path", { d: "m15 14 5-5-5-5" }),
1818
- /* @__PURE__ */ jsx14("path", { d: "M20 9H9.5a5.5 5.5 0 0 0 0 11H13" })
1819
- ] }),
1820
- strikeControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1821
- /* @__PURE__ */ jsx14("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
1822
- /* @__PURE__ */ jsx14("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
1823
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
1824
- ] }),
1825
- subscriptControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1826
- /* @__PURE__ */ jsx14("path", { d: "m4 4 8 9" }),
1827
- /* @__PURE__ */ jsx14("path", { d: "m12 4-8 9" }),
1828
- /* @__PURE__ */ jsx14("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" })
1829
- ] }),
1830
- superscriptControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1831
- /* @__PURE__ */ jsx14("path", { d: "m4 20 8-9" }),
1832
- /* @__PURE__ */ jsx14("path", { d: "m12 20-8-9" }),
1833
- /* @__PURE__ */ jsx14("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" })
1834
- ] }),
1835
- underlineControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1836
- /* @__PURE__ */ jsx14("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
1837
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
1838
- ] }),
1839
- undoControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1840
- /* @__PURE__ */ jsx14("path", { d: "M9 14 4 9l5-5" }),
1841
- /* @__PURE__ */ jsx14("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H11" })
1842
- ] }),
1843
- unlinkControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1844
- /* @__PURE__ */ jsx14("path", { d: "M9 17H7a5 5 0 0 1-1.7-9.7" }),
1845
- /* @__PURE__ */ jsx14("path", { d: "M15 7h2a5 5 0 0 1 1.7 9.7" }),
1846
- /* @__PURE__ */ jsx14("line", { x1: "3", y1: "3", x2: "21", y2: "21" })
1847
- ] })
1848
- };
1849
-
1850
2253
  // src/labels.ts
1851
2254
  var DEFAULT_LABELS = {
1852
2255
  alignCenterControlLabel: "Align center",
@@ -1916,8 +2319,8 @@ var ControlsGroup = ({
1916
2319
  }) => /* @__PURE__ */ jsx16("div", { className: cn("rte-controls-group", className), children });
1917
2320
 
1918
2321
  // src/rte-footer.tsx
1919
- import { useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState5 } from "react";
1920
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
2322
+ import { useEffect as useEffect5, useMemo, useRef as useRef4, useState as useState6 } from "react";
2323
+ import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1921
2324
  var Footer = ({
1922
2325
  children,
1923
2326
  className,
@@ -1928,9 +2331,9 @@ var Footer = ({
1928
2331
  wordCountFormatter
1929
2332
  }) => {
1930
2333
  const { editor, variant } = useRichTextEditorContext();
1931
- const [, forceUpdate] = useState5(0);
2334
+ const [, forceUpdate] = useState6(0);
1932
2335
  const rafRef = useRef4(null);
1933
- useEffect4(() => {
2336
+ useEffect5(() => {
1934
2337
  if (!editor || !showWordCount) {
1935
2338
  return;
1936
2339
  }
@@ -1966,7 +2369,7 @@ var Footer = ({
1966
2369
  const count = editor.storage.characterCount;
1967
2370
  const words = count?.words() ?? 0;
1968
2371
  const characters = count?.characters() ?? 0;
1969
- return wordCountFormatter ? wordCountFormatter({ characters, words }) : `${words} words | ${characters} characters`;
2372
+ return { characters, words };
1970
2373
  }, [
1971
2374
  editor,
1972
2375
  showWordCount,
@@ -1988,7 +2391,23 @@ var Footer = ({
1988
2391
  "data-sticky": sticky ? "" : void 0,
1989
2392
  style: sticky ? { bottom: stickyOffset } : void 0,
1990
2393
  children: [
1991
- showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCount }),
2394
+ showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
2395
+ /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
2396
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
2397
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "words" })
2398
+ ] }),
2399
+ /* @__PURE__ */ jsx17(
2400
+ "span",
2401
+ {
2402
+ className: "rte-footer-word-count-separator",
2403
+ "aria-hidden": "true"
2404
+ }
2405
+ ),
2406
+ /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
2407
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
2408
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "characters" })
2409
+ ] })
2410
+ ] }) }),
1992
2411
  children
1993
2412
  ]
1994
2413
  }
@@ -2039,7 +2458,7 @@ var RichTextEditorRoot = ({
2039
2458
  [labels]
2040
2459
  );
2041
2460
  const mergedIcons = useMemo2(() => ({ ...DEFAULT_ICONS, ...icons }), [icons]);
2042
- useEffect5(() => {
2461
+ useEffect6(() => {
2043
2462
  if (editor && editor.isEditable !== editable) {
2044
2463
  editor.setEditable(editable);
2045
2464
  }
@@ -2110,7 +2529,7 @@ var RichTextEditor = Object.assign(RichTextEditorRoot, {
2110
2529
 
2111
2530
  // src/extensions/link.ts
2112
2531
  import TipTapLink from "@tiptap/extension-link";
2113
- var Link = TipTapLink.extend({
2532
+ var Link2 = TipTapLink.extend({
2114
2533
  addKeyboardShortcuts() {
2115
2534
  return {
2116
2535
  "Mod-k": () => {
@@ -2135,7 +2554,7 @@ export {
2135
2554
  DEFAULT_ICONS,
2136
2555
  DEFAULT_LABELS,
2137
2556
  DEFAULT_LANGUAGE_ICONS,
2138
- Link,
2557
+ Link2 as Link,
2139
2558
  RichTextEditor,
2140
2559
  TwitterEmbed,
2141
2560
  YouTubeEmbed,