@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.cjs CHANGED
@@ -35,7 +35,7 @@ __export(index_exports, {
35
35
  DEFAULT_ICONS: () => DEFAULT_ICONS,
36
36
  DEFAULT_LABELS: () => DEFAULT_LABELS,
37
37
  DEFAULT_LANGUAGE_ICONS: () => DEFAULT_LANGUAGE_ICONS,
38
- Link: () => Link,
38
+ Link: () => Link2,
39
39
  RichTextEditor: () => RichTextEditor,
40
40
  TwitterEmbed: () => TwitterEmbed,
41
41
  YouTubeEmbed: () => YouTubeEmbed,
@@ -71,23 +71,33 @@ var useRichTextEditorContext = () => {
71
71
  var import_react2 = require("react");
72
72
  var defaultEqual = (a, b) => a === b;
73
73
  var shallowEqual = (a, b) => {
74
- if (a === b) return true;
75
- if (!a || !b) return false;
74
+ if (a === b) {
75
+ return true;
76
+ }
77
+ if (!a || !b) {
78
+ return false;
79
+ }
76
80
  const ak = Object.keys(a);
77
81
  const bk = Object.keys(b);
78
- if (ak.length !== bk.length) return false;
82
+ if (ak.length !== bk.length) {
83
+ return false;
84
+ }
79
85
  return ak.every((k) => a[k] === b[k]);
80
86
  };
81
87
  var useEditorState = (editor, selector, isEqual = defaultEqual) => {
82
88
  const selectorRef = (0, import_react2.useRef)(selector);
83
- selectorRef.current = selector;
84
89
  const isEqualRef = (0, import_react2.useRef)(isEqual);
85
- isEqualRef.current = isEqual;
90
+ (0, import_react2.useEffect)(() => {
91
+ selectorRef.current = selector;
92
+ isEqualRef.current = isEqual;
93
+ });
86
94
  const snapshotRef = (0, import_react2.useRef)({
87
95
  value: editor ? selector(editor) : void 0
88
96
  });
89
97
  const updateSnapshot = (0, import_react2.useCallback)(() => {
90
- if (!editor) return;
98
+ if (!editor) {
99
+ return;
100
+ }
91
101
  const next = selectorRef.current(editor);
92
102
  if (snapshotRef.current && isEqualRef.current(snapshotRef.current.value, next)) {
93
103
  return;
@@ -139,6 +149,30 @@ var CODE_BLOCK_LANGUAGES = [
139
149
  "xml",
140
150
  "plaintext"
141
151
  ];
152
+ var CODE_BLOCK_LANGUAGE_LABELS = {
153
+ bash: "Bash",
154
+ c: "C",
155
+ cpp: "C++",
156
+ css: "CSS",
157
+ go: "Go",
158
+ html: "HTML",
159
+ java: "Java",
160
+ javascript: "JavaScript",
161
+ json: "JSON",
162
+ kotlin: "Kotlin",
163
+ markdown: "Markdown",
164
+ php: "PHP",
165
+ plaintext: "Plain Text",
166
+ python: "Python",
167
+ ruby: "Ruby",
168
+ rust: "Rust",
169
+ sql: "SQL",
170
+ swift: "Swift",
171
+ typescript: "TypeScript",
172
+ xml: "XML",
173
+ yaml: "YAML"
174
+ };
175
+ var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
142
176
 
143
177
  // src/bubble-menu/language-selector.tsx
144
178
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -161,6 +195,7 @@ var FallbackIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
161
195
  );
162
196
  var LanguageSelector = ({ editor }) => {
163
197
  const [open, setOpen] = (0, import_react3.useState)(false);
198
+ const [pill, setPill] = (0, import_react3.useState)(null);
164
199
  const { icons } = useRichTextEditorContext();
165
200
  const { currentLanguage } = useEditorState(
166
201
  editor,
@@ -170,6 +205,32 @@ var LanguageSelector = ({ editor }) => {
170
205
  shallowEqual
171
206
  );
172
207
  const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackIcon, {});
208
+ const handleItemEnter = (0, import_react3.useCallback)((target) => {
209
+ const item = target.closest(
210
+ "[data-dropdown-item]"
211
+ );
212
+ if (!item) {
213
+ return;
214
+ }
215
+ setPill({
216
+ height: item.offsetHeight,
217
+ left: item.offsetLeft,
218
+ top: item.offsetTop,
219
+ width: item.offsetWidth
220
+ });
221
+ }, []);
222
+ const handleMouseOver = (0, import_react3.useCallback)(
223
+ (event) => {
224
+ handleItemEnter(event.target);
225
+ },
226
+ [handleItemEnter]
227
+ );
228
+ const handleFocus = (0, import_react3.useCallback)(
229
+ (event) => {
230
+ handleItemEnter(event.target);
231
+ },
232
+ [handleItemEnter]
233
+ );
173
234
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { position: "relative" }, children: [
174
235
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
175
236
  "button",
@@ -180,7 +241,7 @@ var LanguageSelector = ({ editor }) => {
180
241
  onClick: () => setOpen(!open),
181
242
  children: [
182
243
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-btn-icon", children: langIcon }),
183
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-btn-text", children: currentLanguage }),
244
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
184
245
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-btn-icon", style: { height: 12, width: 12 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
185
246
  "svg",
186
247
  {
@@ -211,36 +272,51 @@ var LanguageSelector = ({ editor }) => {
211
272
  }
212
273
  }
213
274
  ),
214
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rte-bubble-dropdown rte-bubble-dropdown--language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
215
- "button",
275
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
276
+ "div",
216
277
  {
217
- type: "button",
218
- className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
219
- onMouseDown: (e) => e.preventDefault(),
220
- onClick: () => {
221
- editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
222
- setOpen(false);
223
- },
278
+ className: "rte-bubble-dropdown rte-bubble-dropdown--language",
279
+ onFocus: handleFocus,
280
+ onMouseLeave: () => setPill(null),
281
+ onMouseOver: handleMouseOver,
224
282
  children: [
225
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackIcon, {}) }),
226
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: lang }),
227
- currentLanguage === lang && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-dropdown-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
228
- "svg",
283
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
+ "div",
229
285
  {
230
- xmlns: "http://www.w3.org/2000/svg",
231
- viewBox: "0 0 24 24",
232
- fill: "none",
233
- stroke: "currentColor",
234
- strokeWidth: 2,
235
- strokeLinecap: "round",
236
- strokeLinejoin: "round",
237
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "20 6 9 17 4 12" })
286
+ "aria-hidden": "true",
287
+ className: [
288
+ "rte-bubble-dropdown-pill",
289
+ pill ? "rte-bubble-dropdown-pill--visible" : ""
290
+ ].filter(Boolean).join(" "),
291
+ style: pill ? {
292
+ height: pill.height,
293
+ left: pill.left,
294
+ top: pill.top,
295
+ width: pill.width
296
+ } : void 0
238
297
  }
239
- ) })
298
+ ),
299
+ CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
300
+ "button",
301
+ {
302
+ type: "button",
303
+ "data-dropdown-item": true,
304
+ className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
305
+ onMouseDown: (e) => e.preventDefault(),
306
+ onClick: () => {
307
+ editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
308
+ setOpen(false);
309
+ },
310
+ children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackIcon, {}) }),
312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: getLanguageLabel(lang) })
313
+ ]
314
+ },
315
+ lang
316
+ ))
240
317
  ]
241
- },
242
- lang
243
- )) })
318
+ }
319
+ )
244
320
  ] })
245
321
  ] });
246
322
  };
@@ -629,6 +705,7 @@ var H6Control = createControl({
629
705
  });
630
706
  var AlignLeftControl = createControl({
631
707
  iconKey: "alignLeftControlIcon",
708
+ isActive: { attrs: { textAlign: "left" } },
632
709
  label: "alignLeftControlLabel",
633
710
  operation: { attributes: "left", name: "setTextAlign" }
634
711
  });
@@ -869,34 +946,426 @@ var LinkControl = () => {
869
946
 
870
947
  // src/controls/rte-twitter-control.tsx
871
948
  var import_core2 = require("@tiptap/core");
872
- var import_react11 = require("@tiptap/react");
873
- var import_react12 = require("react");
949
+ var import_react12 = require("@tiptap/react");
950
+ var import_react13 = require("react");
874
951
 
875
952
  // src/extensions/resizable-node-view.tsx
876
- var import_react9 = require("@tiptap/react");
877
- var import_react10 = require("react");
953
+ var import_react10 = require("@tiptap/react");
954
+ var import_react11 = require("react");
955
+
956
+ // src/icons.tsx
957
+ var import_lucide_react = require("lucide-react");
958
+ var import_react9 = require("react");
878
959
  var import_jsx_runtime10 = require("react/jsx-runtime");
960
+ var ALIGN_PATHS = {
961
+ center: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
962
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
963
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
965
+ ] }),
966
+ left: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
967
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
968
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
969
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
970
+ ] }),
971
+ right: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
972
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
973
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
974
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
975
+ ] })
976
+ };
977
+ var AlignIcon = ({ dir }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
978
+ "svg",
979
+ {
980
+ xmlns: "http://www.w3.org/2000/svg",
981
+ viewBox: "0 0 24 24",
982
+ fill: "none",
983
+ stroke: "currentColor",
984
+ strokeWidth: "2",
985
+ strokeLinecap: "round",
986
+ strokeLinejoin: "round",
987
+ className: "rte-editor-icon",
988
+ children: ALIGN_PATHS[dir]
989
+ }
990
+ );
991
+ var EditUrlIcon = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
992
+ "svg",
993
+ {
994
+ xmlns: "http://www.w3.org/2000/svg",
995
+ viewBox: "0 0 24 24",
996
+ fill: "none",
997
+ stroke: "currentColor",
998
+ strokeWidth: "2",
999
+ strokeLinecap: "round",
1000
+ strokeLinejoin: "round",
1001
+ className: "rte-editor-icon",
1002
+ children: [
1003
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12 20h9" }),
1004
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
1005
+ ]
1006
+ }
1007
+ );
1008
+ var OpenInYouTubeIcon = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1009
+ "svg",
1010
+ {
1011
+ xmlns: "http://www.w3.org/2000/svg",
1012
+ viewBox: "0 0 24 24",
1013
+ fill: "none",
1014
+ stroke: "currentColor",
1015
+ strokeWidth: "2",
1016
+ strokeLinecap: "round",
1017
+ strokeLinejoin: "round",
1018
+ className: "rte-editor-icon",
1019
+ children: [
1020
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
1021
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("polyline", { points: "15 3 21 3 21 9" }),
1022
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
1023
+ ]
1024
+ }
1025
+ );
1026
+ var DeleteEmbedIcon = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1027
+ "svg",
1028
+ {
1029
+ xmlns: "http://www.w3.org/2000/svg",
1030
+ viewBox: "0 0 24 24",
1031
+ fill: "none",
1032
+ stroke: "currentColor",
1033
+ strokeWidth: "2",
1034
+ strokeLinecap: "round",
1035
+ strokeLinejoin: "round",
1036
+ className: "rte-editor-icon",
1037
+ children: [
1038
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("polyline", { points: "3 6 5 6 21 6" }),
1039
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
1040
+ ]
1041
+ }
1042
+ );
1043
+ var iconProps = { className: "rte-editor-icon" };
1044
+ var LangIcon = ({
1045
+ children,
1046
+ className
1047
+ }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1048
+ "svg",
1049
+ {
1050
+ xmlns: "http://www.w3.org/2000/svg",
1051
+ viewBox: "0 0 24 24",
1052
+ fill: "none",
1053
+ stroke: "currentColor",
1054
+ strokeWidth: 1.5,
1055
+ strokeLinecap: "round",
1056
+ strokeLinejoin: "round",
1057
+ className,
1058
+ children
1059
+ }
1060
+ );
1061
+ var DEFAULT_LANGUAGE_ICONS = {
1062
+ bash: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1063
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1064
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1065
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12 15.5h5.5" })
1066
+ ] }),
1067
+ c: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1068
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "12", cy: "12", r: "8.5" }),
1069
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1070
+ ] }),
1071
+ cpp: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1072
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1073
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1074
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1075
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M19.3 10.5v3M17.8 12h3" })
1076
+ ] }),
1077
+ css: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1078
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1079
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9.7 7.5l-1 9" }),
1080
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M15.3 7.5l-1 9" }),
1081
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M7 10.3h11" }),
1082
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6.5 14.3h11" })
1083
+ ] }),
1084
+ go: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1085
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1086
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1087
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12.6 12h-1.9" }),
1088
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "17", cy: "12", r: "2.9" })
1089
+ ] }),
1090
+ html: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1091
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1092
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1093
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1094
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M13 7.3l-2 9.4" })
1095
+ ] }),
1096
+ java: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1097
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1098
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1099
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
1100
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6 19.3h10" })
1101
+ ] }),
1102
+ javascript: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1103
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1104
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1105
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1106
+ ] }),
1107
+ json: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1108
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
1109
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
1110
+ ] }),
1111
+ kotlin: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1112
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1113
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9 7.5v9" }),
1114
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9 12l6-4.5" }),
1115
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9 12l6 4.5" })
1116
+ ] }),
1117
+ markdown: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1118
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1119
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6 15V9l3 4 3-4v6" }),
1120
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M16.5 9v6" }),
1121
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M14.5 13l2 2 2-2" })
1122
+ ] }),
1123
+ php: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1124
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1125
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1126
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
1127
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1128
+ ] }),
1129
+ plaintext: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1130
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1131
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1132
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1133
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1134
+ ] }),
1135
+ python: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1136
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1137
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1138
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1139
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1140
+ ] }),
1141
+ ruby: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1142
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1143
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M4.5 8h15" }),
1144
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12 2.5v19" })
1145
+ ] }),
1146
+ rust: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1147
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "12", cy: "12", r: "7" }),
1148
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { cx: "12", cy: "12", r: "2.3" }),
1149
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1150
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
1151
+ ] }),
1152
+ sql: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1153
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1154
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1155
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1156
+ ] }),
1157
+ swift: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LangIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
1158
+ typescript: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1159
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1160
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1161
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1162
+ ] }),
1163
+ xml: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1164
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M8 7l-4.5 5 4.5 5" }),
1165
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M16 7l4.5 5-4.5 5" }),
1166
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M12 8v8" })
1167
+ ] }),
1168
+ yaml: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(LangIcon, { children: [
1169
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1170
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6.5 8h2M9.5 8h8" }),
1171
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6.5 12h2M9.5 12h6" }),
1172
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M6.5 16h2M9.5 16h7" })
1173
+ ] })
1174
+ };
1175
+ var DEFAULT_ICONS = {
1176
+ alignCenterControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.TextAlignCenter, { ...iconProps }),
1177
+ alignJustifyControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.TextAlignJustify, { ...iconProps }),
1178
+ alignLeftControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.TextAlignStart, { ...iconProps }),
1179
+ alignRightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.TextAlignEnd, { ...iconProps }),
1180
+ blockquoteControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.TextQuote, { ...iconProps }),
1181
+ boldControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Bold, { ...iconProps }),
1182
+ bulletListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.List, { ...iconProps }),
1183
+ clearFormattingControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.RemoveFormatting, { ...iconProps }),
1184
+ codeBlockControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.SquareCode, { ...iconProps }),
1185
+ codeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Code, { ...iconProps }),
1186
+ h1ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading1, { ...iconProps }),
1187
+ h2ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading2, { ...iconProps }),
1188
+ h3ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading3, { ...iconProps }),
1189
+ h4ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading4, { ...iconProps }),
1190
+ h5ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading5, { ...iconProps }),
1191
+ h6ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Heading6, { ...iconProps }),
1192
+ highlightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Highlighter, { ...iconProps }),
1193
+ hrControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Minus, { ...iconProps }),
1194
+ italicControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Italic, { ...iconProps }),
1195
+ languageIcons: DEFAULT_LANGUAGE_ICONS,
1196
+ linkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Link, { ...iconProps }),
1197
+ orderedListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.ListOrdered, { ...iconProps }),
1198
+ redoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Redo2, { ...iconProps }),
1199
+ strikeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Strikethrough, { ...iconProps }),
1200
+ subscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Subscript, { ...iconProps }),
1201
+ superscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Superscript, { ...iconProps }),
1202
+ underlineControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Underline, { ...iconProps }),
1203
+ undoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Undo2, { ...iconProps }),
1204
+ unlinkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.Link2Off, { ...iconProps })
1205
+ };
1206
+
1207
+ // src/extensions/resizable-node-view.tsx
1208
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1209
+ var EmbedToolbar = ({
1210
+ align,
1211
+ videoSrc,
1212
+ watchUrl,
1213
+ deleteNode,
1214
+ inputRef,
1215
+ isEditingUrl,
1216
+ urlInput,
1217
+ setUrlInput,
1218
+ setIsEditingUrl,
1219
+ handleSaveUrl,
1220
+ handleApplyPreset,
1221
+ updateAttributes,
1222
+ nodeSrc
1223
+ }) => {
1224
+ if (isEditingUrl) {
1225
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-embed-selector-edit-form", children: [
1226
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1227
+ "input",
1228
+ {
1229
+ ref: inputRef,
1230
+ type: "text",
1231
+ value: urlInput,
1232
+ onChange: (e) => setUrlInput(e.target.value),
1233
+ placeholder: "Paste YouTube URL or video ID...",
1234
+ className: "rte-embed-selector-input",
1235
+ onKeyDown: (e) => {
1236
+ if (e.key === "Enter") {
1237
+ handleSaveUrl();
1238
+ } else if (e.key === "Escape") {
1239
+ setIsEditingUrl(false);
1240
+ }
1241
+ }
1242
+ }
1243
+ ),
1244
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1245
+ "button",
1246
+ {
1247
+ type: "button",
1248
+ onClick: handleSaveUrl,
1249
+ className: "rte-embed-selector-btn rte-embed-selector-btn--save",
1250
+ children: "Save"
1251
+ }
1252
+ ),
1253
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1254
+ "button",
1255
+ {
1256
+ type: "button",
1257
+ onClick: () => setIsEditingUrl(false),
1258
+ className: "rte-embed-selector-btn",
1259
+ children: "Cancel"
1260
+ }
1261
+ )
1262
+ ] });
1263
+ }
1264
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1265
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1266
+ "button",
1267
+ {
1268
+ type: "button",
1269
+ title: `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1270
+ "aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
1271
+ className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
1272
+ onClick: () => updateAttributes({ align: dir }),
1273
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(AlignIcon, { dir })
1274
+ },
1275
+ dir
1276
+ )) }),
1277
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-embed-selector-divider" }),
1278
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1279
+ "button",
1280
+ {
1281
+ type: "button",
1282
+ title: `${pct}%`,
1283
+ className: "rte-embed-selector-btn rte-embed-selector-btn--preset",
1284
+ onClick: () => handleApplyPreset(pct),
1285
+ children: [
1286
+ pct,
1287
+ "%"
1288
+ ]
1289
+ },
1290
+ pct
1291
+ )) }),
1292
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-embed-selector-divider" }),
1293
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-embed-selector-group", children: [
1294
+ (videoSrc || nodeSrc) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1295
+ "button",
1296
+ {
1297
+ type: "button",
1298
+ title: "Edit URL",
1299
+ "aria-label": "Edit URL",
1300
+ className: "rte-embed-selector-btn",
1301
+ onClick: () => {
1302
+ setUrlInput(videoSrc || nodeSrc || "");
1303
+ setIsEditingUrl(true);
1304
+ },
1305
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(EditUrlIcon, {})
1306
+ }
1307
+ ),
1308
+ watchUrl && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1309
+ "button",
1310
+ {
1311
+ type: "button",
1312
+ title: "Open video in YouTube",
1313
+ "aria-label": "Open video in YouTube",
1314
+ className: "rte-embed-selector-btn",
1315
+ onClick: () => window.open(watchUrl, "_blank"),
1316
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(OpenInYouTubeIcon, {})
1317
+ }
1318
+ ),
1319
+ deleteNode && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1320
+ "button",
1321
+ {
1322
+ type: "button",
1323
+ title: "Delete Embed",
1324
+ "aria-label": "Delete Embed",
1325
+ className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
1326
+ onClick: () => deleteNode(),
1327
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DeleteEmbedIcon, {})
1328
+ }
1329
+ )
1330
+ ] })
1331
+ ] });
1332
+ };
879
1333
  var ResizableNodeView = ({
880
1334
  node,
881
1335
  selected,
882
1336
  updateAttributes,
1337
+ deleteNode,
1338
+ editor,
883
1339
  view,
884
1340
  children,
885
1341
  lockAspect = false,
886
1342
  aspectRatio = 16 / 9,
887
1343
  minWidth = 300,
888
- maxWidth = 1200
1344
+ maxWidth = 1200,
1345
+ videoSrc,
1346
+ watchUrl,
1347
+ onSrcChange
889
1348
  }) => {
890
- const containerRef = (0, import_react10.useRef)(null);
891
- const resizingRef = (0, import_react10.useRef)(null);
1349
+ const containerRef = (0, import_react11.useRef)(null);
1350
+ const [isEditingUrl, setIsEditingUrl] = (0, import_react11.useState)(false);
1351
+ const [urlInput, setUrlInput] = (0, import_react11.useState)(videoSrc || "");
1352
+ const [isResizing, setIsResizing] = (0, import_react11.useState)(false);
1353
+ const [currentDimensions, setCurrentDimensions] = (0, import_react11.useState)(null);
1354
+ const resizingRef = (0, import_react11.useRef)(null);
892
1355
  const width = node.attrs.width;
893
1356
  const height = node.attrs.height;
894
1357
  const align = node.attrs.align || "center";
895
- const getEditorWidth = (0, import_react10.useCallback)(
896
- () => view?.dom?.parentElement?.offsetWidth ?? 0,
1358
+ const getEditorWidth = (0, import_react11.useCallback)(
1359
+ () => view?.dom?.parentElement?.offsetWidth ?? 800,
897
1360
  [view]
898
1361
  );
899
- const handleMouseMove = (0, import_react10.useCallback)(
1362
+ const inputRef = (0, import_react11.useRef)(null);
1363
+ (0, import_react11.useEffect)(() => {
1364
+ if (isEditingUrl) {
1365
+ inputRef.current?.focus();
1366
+ }
1367
+ }, [isEditingUrl]);
1368
+ const handleMouseMove = (0, import_react11.useCallback)(
900
1369
  (e) => {
901
1370
  const resize = resizingRef.current;
902
1371
  if (!resize) {
@@ -905,7 +1374,7 @@ var ResizableNodeView = ({
905
1374
  const effectiveMax = Math.min(maxWidth, resize.editorWidth);
906
1375
  let newWidth = resize.startWidth;
907
1376
  let newHeight = resize.startHeight;
908
- if (resize.direction === "right" || resize.direction === "corner") {
1377
+ if (resize.direction === "right" || resize.direction === "corner-br") {
909
1378
  newWidth = Math.max(
910
1379
  minWidth,
911
1380
  Math.min(
@@ -913,8 +1382,16 @@ var ResizableNodeView = ({
913
1382
  resize.startWidth + (e.clientX - resize.startX)
914
1383
  )
915
1384
  );
1385
+ } else if (resize.direction === "left" || resize.direction === "corner-bl") {
1386
+ newWidth = Math.max(
1387
+ minWidth,
1388
+ Math.min(
1389
+ effectiveMax,
1390
+ resize.startWidth - (e.clientX - resize.startX)
1391
+ )
1392
+ );
916
1393
  }
917
- if (resize.direction === "bottom" || resize.direction === "corner") {
1394
+ if (resize.direction === "bottom" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
918
1395
  newHeight = Math.max(
919
1396
  Math.round(minWidth / aspectRatio),
920
1397
  Math.min(
@@ -924,7 +1401,7 @@ var ResizableNodeView = ({
924
1401
  );
925
1402
  }
926
1403
  if (lockAspect) {
927
- if (resize.direction === "right" || resize.direction === "corner") {
1404
+ if (resize.direction === "left" || resize.direction === "right" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
928
1405
  newHeight = Math.round(newWidth / aspectRatio);
929
1406
  } else {
930
1407
  newWidth = Math.round(newHeight * aspectRatio);
@@ -934,10 +1411,11 @@ var ResizableNodeView = ({
934
1411
  containerRef.current.style.width = `${newWidth}px`;
935
1412
  containerRef.current.style.height = `${newHeight}px`;
936
1413
  }
1414
+ setCurrentDimensions({ h: newHeight, w: newWidth });
937
1415
  },
938
1416
  [lockAspect, aspectRatio, minWidth, maxWidth]
939
1417
  );
940
- const handleMouseUp = (0, import_react10.useCallback)(
1418
+ const handleMouseUp = (0, import_react11.useCallback)(
941
1419
  function handleMouseUp2() {
942
1420
  const resize = resizingRef.current;
943
1421
  if (!resize) {
@@ -953,10 +1431,12 @@ var ResizableNodeView = ({
953
1431
  updateAttributes({ height: h, width: w });
954
1432
  }
955
1433
  resizingRef.current = null;
1434
+ setIsResizing(false);
1435
+ setCurrentDimensions(null);
956
1436
  },
957
1437
  [handleMouseMove, updateAttributes]
958
1438
  );
959
- const handleMouseDown = (0, import_react10.useCallback)(
1439
+ const handleMouseDown = (0, import_react11.useCallback)(
960
1440
  (e, direction) => {
961
1441
  e.preventDefault();
962
1442
  e.stopPropagation();
@@ -971,20 +1451,23 @@ var ResizableNodeView = ({
971
1451
  startX: e.clientX,
972
1452
  startY: e.clientY
973
1453
  };
1454
+ setIsResizing(true);
1455
+ setCurrentDimensions({ h: startHeight, w: startWidth });
974
1456
  document.addEventListener("mousemove", handleMouseMove);
975
1457
  document.addEventListener("mouseup", handleMouseUp);
976
- let cursor = "nwse-resize";
977
- if (direction === "right") {
978
- cursor = "ew-resize";
979
- } else if (direction === "bottom") {
980
- cursor = "ns-resize";
981
- }
982
- document.body.style.cursor = cursor;
1458
+ const cursors = {
1459
+ bottom: "ns-resize",
1460
+ "corner-bl": "nesw-resize",
1461
+ "corner-br": "nwse-resize",
1462
+ left: "ew-resize",
1463
+ right: "ew-resize"
1464
+ };
1465
+ document.body.style.cursor = cursors[direction];
983
1466
  document.body.style.userSelect = "none";
984
1467
  },
985
1468
  [width, height, getEditorWidth, handleMouseMove, handleMouseUp]
986
1469
  );
987
- (0, import_react10.useEffect)(
1470
+ (0, import_react11.useEffect)(
988
1471
  () => () => {
989
1472
  document.removeEventListener("mousemove", handleMouseMove);
990
1473
  document.removeEventListener("mouseup", handleMouseUp);
@@ -993,13 +1476,32 @@ var ResizableNodeView = ({
993
1476
  },
994
1477
  [handleMouseMove, handleMouseUp]
995
1478
  );
996
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
997
- import_react9.NodeViewWrapper,
1479
+ const handleApplyPreset = (percent) => {
1480
+ const editorW = getEditorWidth() || 800;
1481
+ const targetW = Math.round(
1482
+ Math.max(minWidth, Math.min(maxWidth, editorW * percent / 100))
1483
+ );
1484
+ updateAttributes({
1485
+ height: Math.round(targetW / aspectRatio),
1486
+ width: targetW
1487
+ });
1488
+ };
1489
+ const handleSaveUrl = () => {
1490
+ if (urlInput && onSrcChange) {
1491
+ onSrcChange(urlInput);
1492
+ } else if (urlInput) {
1493
+ updateAttributes({ src: urlInput });
1494
+ }
1495
+ setIsEditingUrl(false);
1496
+ };
1497
+ const isEditable = editor ? editor.isEditable : true;
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1499
+ import_react10.NodeViewWrapper,
998
1500
  {
999
1501
  className: "rte-embed-wrapper",
1000
1502
  "data-selected": selected || void 0,
1001
1503
  "data-align": align,
1002
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1504
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1003
1505
  "div",
1004
1506
  {
1005
1507
  ref: containerRef,
@@ -1012,8 +1514,40 @@ var ResizableNodeView = ({
1012
1514
  },
1013
1515
  children: [
1014
1516
  children,
1015
- selected && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
1016
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1517
+ selected && isEditable && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1518
+ EmbedToolbar,
1519
+ {
1520
+ align,
1521
+ videoSrc,
1522
+ watchUrl,
1523
+ deleteNode,
1524
+ inputRef,
1525
+ isEditingUrl,
1526
+ urlInput,
1527
+ setUrlInput,
1528
+ setIsEditingUrl,
1529
+ handleSaveUrl,
1530
+ handleApplyPreset,
1531
+ updateAttributes,
1532
+ nodeSrc: node.attrs.src
1533
+ }
1534
+ ) }),
1535
+ isResizing && currentDimensions && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "rte-embed-resize-badge", children: [
1536
+ currentDimensions.w,
1537
+ " \xD7 ",
1538
+ currentDimensions.h,
1539
+ " px"
1540
+ ] }),
1541
+ selected && isEditable && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1542
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1543
+ "div",
1544
+ {
1545
+ className: "rte-resize-handle rte-resize-handle--left",
1546
+ onMouseDown: (e) => handleMouseDown(e, "left"),
1547
+ role: "presentation"
1548
+ }
1549
+ ),
1550
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1017
1551
  "div",
1018
1552
  {
1019
1553
  className: "rte-resize-handle rte-resize-handle--right",
@@ -1021,7 +1555,7 @@ var ResizableNodeView = ({
1021
1555
  role: "presentation"
1022
1556
  }
1023
1557
  ),
1024
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1558
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1025
1559
  "div",
1026
1560
  {
1027
1561
  className: "rte-resize-handle rte-resize-handle--bottom",
@@ -1029,11 +1563,19 @@ var ResizableNodeView = ({
1029
1563
  role: "presentation"
1030
1564
  }
1031
1565
  ),
1032
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1566
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1033
1567
  "div",
1034
1568
  {
1035
- className: "rte-resize-handle rte-resize-handle--corner",
1036
- onMouseDown: (e) => handleMouseDown(e, "corner"),
1569
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
1570
+ onMouseDown: (e) => handleMouseDown(e, "corner-bl"),
1571
+ role: "presentation"
1572
+ }
1573
+ ),
1574
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1575
+ "div",
1576
+ {
1577
+ className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
1578
+ onMouseDown: (e) => handleMouseDown(e, "corner-br"),
1037
1579
  role: "presentation"
1038
1580
  }
1039
1581
  )
@@ -1047,16 +1589,16 @@ var ResizableNodeView = ({
1047
1589
 
1048
1590
  // src/ui/dialog.tsx
1049
1591
  var import_dialog = require("@base-ui/react/dialog");
1050
- var React5 = require("react");
1051
- var import_jsx_runtime11 = require("react/jsx-runtime");
1052
- var Dialog = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
1053
- var DialogTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
1054
- var DialogPortal = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
1055
- var DialogClose = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
1592
+ var React6 = require("react");
1593
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1594
+ var Dialog = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Root, { "data-slot": "dialog", ...props });
1595
+ var DialogTrigger = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Trigger, { "data-slot": "dialog-trigger", ...props });
1596
+ var DialogPortal = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Portal, { "data-slot": "dialog-portal", ...props });
1597
+ var DialogClose = ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Close, { "data-slot": "dialog-close", ...props });
1056
1598
  var DialogOverlay = ({
1057
1599
  className,
1058
1600
  ...props
1059
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1601
+ }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1060
1602
  import_dialog.Dialog.Backdrop,
1061
1603
  {
1062
1604
  "data-slot": "dialog-overlay",
@@ -1072,9 +1614,9 @@ var DialogContent = ({
1072
1614
  children,
1073
1615
  showCloseButton = true,
1074
1616
  ...props
1075
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DialogPortal, { children: [
1076
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogOverlay, {}),
1077
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1617
+ }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DialogPortal, { children: [
1618
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DialogOverlay, {}),
1619
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1078
1620
  import_dialog.Dialog.Popup,
1079
1621
  {
1080
1622
  "data-slot": "dialog-content",
@@ -1085,11 +1627,11 @@ var DialogContent = ({
1085
1627
  ...props,
1086
1628
  children: [
1087
1629
  children,
1088
- showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1630
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1089
1631
  import_dialog.Dialog.Close,
1090
1632
  {
1091
1633
  "data-slot": "dialog-close",
1092
- render: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1634
+ render: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1093
1635
  Button,
1094
1636
  {
1095
1637
  variant: "ghost",
@@ -1099,7 +1641,7 @@ var DialogContent = ({
1099
1641
  ),
1100
1642
  children: [
1101
1643
  "X",
1102
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "sr-only", children: "Close" })
1644
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "sr-only", children: "Close" })
1103
1645
  ]
1104
1646
  }
1105
1647
  )
@@ -1107,7 +1649,7 @@ var DialogContent = ({
1107
1649
  }
1108
1650
  )
1109
1651
  ] });
1110
- var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1652
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1111
1653
  "div",
1112
1654
  {
1113
1655
  "data-slot": "dialog-header",
@@ -1120,7 +1662,7 @@ var DialogFooter = ({
1120
1662
  showCloseButton = false,
1121
1663
  children,
1122
1664
  ...props
1123
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1665
+ }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1124
1666
  "div",
1125
1667
  {
1126
1668
  "data-slot": "dialog-footer",
@@ -1131,11 +1673,11 @@ var DialogFooter = ({
1131
1673
  ...props,
1132
1674
  children: [
1133
1675
  children,
1134
- showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Button, { variant: "outline" }), children: "Close" })
1676
+ showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dialog.Dialog.Close, { render: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { variant: "outline" }), children: "Close" })
1135
1677
  ]
1136
1678
  }
1137
1679
  );
1138
- var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1680
+ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1139
1681
  import_dialog.Dialog.Title,
1140
1682
  {
1141
1683
  "data-slot": "dialog-title",
@@ -1146,7 +1688,7 @@ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_ru
1146
1688
  var DialogDescription = ({
1147
1689
  className,
1148
1690
  ...props
1149
- }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1691
+ }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1150
1692
  import_dialog.Dialog.Description,
1151
1693
  {
1152
1694
  "data-slot": "dialog-description",
@@ -1159,56 +1701,149 @@ var DialogDescription = ({
1159
1701
  );
1160
1702
 
1161
1703
  // src/controls/rte-twitter-control.tsx
1162
- var import_jsx_runtime12 = require("react/jsx-runtime");
1704
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1163
1705
  var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
1706
+ var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
1707
+ var READY_POLL_INTERVAL_MS = 50;
1708
+ var twitterScriptPromise = null;
1709
+ var loadTwitterScript = () => {
1710
+ if (typeof window === "undefined") {
1711
+ return Promise.resolve();
1712
+ }
1713
+ if (window.twttr?.widgets) {
1714
+ return Promise.resolve();
1715
+ }
1716
+ if (twitterScriptPromise) {
1717
+ return twitterScriptPromise;
1718
+ }
1719
+ twitterScriptPromise = new Promise((resolve, reject) => {
1720
+ let script = document.querySelector(
1721
+ `script[src="${WIDGET_SCRIPT_URL}"]`
1722
+ );
1723
+ const isNewScript = !script;
1724
+ if (!script) {
1725
+ script = document.createElement("script");
1726
+ script.src = WIDGET_SCRIPT_URL;
1727
+ script.async = true;
1728
+ document.body.append(script);
1729
+ }
1730
+ let settled = false;
1731
+ const cleanup = () => {
1732
+ clearInterval(pollId);
1733
+ clearTimeout(timeoutId);
1734
+ };
1735
+ const succeed = () => {
1736
+ if (settled) return;
1737
+ settled = true;
1738
+ cleanup();
1739
+ resolve();
1740
+ };
1741
+ const fail = () => {
1742
+ if (settled) return;
1743
+ settled = true;
1744
+ cleanup();
1745
+ twitterScriptPromise = null;
1746
+ reject(new Error("Failed to load Twitter widgets script"));
1747
+ };
1748
+ if (window.twttr?.widgets) {
1749
+ succeed();
1750
+ return;
1751
+ }
1752
+ const pollId = setInterval(() => {
1753
+ if (window.twttr?.widgets) {
1754
+ succeed();
1755
+ }
1756
+ }, READY_POLL_INTERVAL_MS);
1757
+ const timeoutId = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
1758
+ if (isNewScript) {
1759
+ script.addEventListener(
1760
+ "load",
1761
+ () => {
1762
+ if (window.twttr?.widgets) {
1763
+ succeed();
1764
+ }
1765
+ },
1766
+ { once: true }
1767
+ );
1768
+ }
1769
+ script.addEventListener("error", fail, { once: true });
1770
+ });
1771
+ return twitterScriptPromise;
1772
+ };
1164
1773
  var TwitterNodeView = (props) => {
1165
1774
  const { node } = props;
1166
- const containerRef = (0, import_react12.useRef)(null);
1167
- const [loading, setLoading] = (0, import_react12.useState)(true);
1775
+ const containerRef = (0, import_react13.useRef)(null);
1776
+ const [loading, setLoading] = (0, import_react13.useState)(true);
1777
+ const [failed, setFailed] = (0, import_react13.useState)(false);
1168
1778
  const { tweetId } = node.attrs;
1169
- const w = node.attrs.width;
1170
- const h = node.attrs.height;
1171
- const renderTweet = (0, import_react12.useCallback)(async () => {
1779
+ const renderedTweetIdRef = (0, import_react13.useRef)(null);
1780
+ const activeRenderIdRef = (0, import_react13.useRef)(0);
1781
+ const retryToken = (0, import_react13.useRef)(0);
1782
+ const [retryCount, setRetryCount] = (0, import_react13.useState)(0);
1783
+ (0, import_react13.useEffect)(() => {
1172
1784
  if (!containerRef.current || !tweetId) {
1173
1785
  return;
1174
1786
  }
1175
- containerRef.current.innerHTML = "";
1176
- setLoading(true);
1177
- const { twttr } = window;
1178
- if (twttr?.widgets && containerRef.current) {
1179
- try {
1180
- await twttr.widgets.createTweet(tweetId, containerRef.current);
1181
- setLoading(false);
1182
- } catch {
1183
- }
1184
- }
1185
- }, [tweetId]);
1186
- (0, import_react12.useEffect)(() => {
1187
- if (!containerRef.current || !tweetId) {
1787
+ if (renderedTweetIdRef.current === tweetId && containerRef.current.children.length > 0 && !failed) {
1788
+ setLoading(false);
1188
1789
  return;
1189
1790
  }
1190
- const load = async () => {
1191
- if (window.twttr?.widgets && containerRef.current) {
1791
+ let isCancelled = false;
1792
+ activeRenderIdRef.current += 1;
1793
+ const renderId = activeRenderIdRef.current;
1794
+ setLoading(true);
1795
+ setFailed(false);
1796
+ const render = async () => {
1797
+ try {
1798
+ await loadTwitterScript();
1799
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
1800
+ return;
1801
+ }
1802
+ const { twttr } = window;
1803
+ if (!twttr?.widgets) {
1804
+ throw new Error("Twitter widgets script unavailable");
1805
+ }
1192
1806
  containerRef.current.innerHTML = "";
1193
- setLoading(true);
1194
- try {
1195
- await window.twttr.widgets.createTweet(tweetId, containerRef.current);
1807
+ const el = await twttr.widgets.createTweet(
1808
+ tweetId,
1809
+ containerRef.current
1810
+ );
1811
+ if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
1812
+ if (el && typeof el.remove === "function") {
1813
+ el.remove();
1814
+ } else if (containerRef.current) {
1815
+ containerRef.current.innerHTML = "";
1816
+ }
1817
+ return;
1818
+ }
1819
+ if (!el) {
1820
+ throw new Error("Tweet could not be embedded");
1821
+ }
1822
+ while (containerRef.current.children.length > 1) {
1823
+ containerRef.current.firstElementChild?.remove();
1824
+ }
1825
+ renderedTweetIdRef.current = tweetId;
1826
+ } catch {
1827
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
1828
+ setFailed(true);
1829
+ renderedTweetIdRef.current = null;
1830
+ }
1831
+ } finally {
1832
+ if (!isCancelled && renderId === activeRenderIdRef.current) {
1196
1833
  setLoading(false);
1197
- } catch {
1198
1834
  }
1199
- } else {
1200
- const script = document.createElement("script");
1201
- script.src = WIDGET_SCRIPT_URL;
1202
- script.async = true;
1203
- script.addEventListener("load", () => {
1204
- void renderTweet();
1205
- });
1206
- document.body.append(script);
1207
1835
  }
1208
1836
  };
1209
- void load();
1210
- }, [tweetId, w, h, renderTweet]);
1211
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1837
+ void render();
1838
+ return () => {
1839
+ isCancelled = true;
1840
+ };
1841
+ }, [tweetId, retryCount, failed]);
1842
+ const handleRetry = (0, import_react13.useCallback)(() => {
1843
+ retryToken.current += 1;
1844
+ setRetryCount(retryToken.current);
1845
+ }, []);
1846
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1212
1847
  ResizableNodeView,
1213
1848
  {
1214
1849
  ...props,
@@ -1216,8 +1851,12 @@ var TwitterNodeView = (props) => {
1216
1851
  minWidth: 300,
1217
1852
  maxWidth: 1200,
1218
1853
  children: [
1219
- loading && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1220
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: containerRef })
1854
+ loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
1855
+ !loading && failed && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "rte-embed-error", children: [
1856
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: "Couldn't load this tweet." }),
1857
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { type: "button", onClick: handleRetry, children: "Retry" })
1858
+ ] }),
1859
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { ref: containerRef })
1221
1860
  ]
1222
1861
  }
1223
1862
  );
@@ -1273,7 +1912,7 @@ var TwitterEmbed = import_core2.Node.create({
1273
1912
  ];
1274
1913
  },
1275
1914
  addNodeView() {
1276
- return (0, import_react11.ReactNodeViewRenderer)(TwitterNodeView);
1915
+ return (0, import_react12.ReactNodeViewRenderer)(TwitterNodeView);
1277
1916
  },
1278
1917
  atom: true,
1279
1918
  draggable: true,
@@ -1307,88 +1946,119 @@ var extractTweetId = (input) => {
1307
1946
  };
1308
1947
  var TwitterEmbedControl = ({ className }) => {
1309
1948
  const { editor } = useRichTextEditorContext();
1310
- const [open, setOpen] = (0, import_react12.useState)(false);
1311
- const [url, setUrl] = (0, import_react12.useState)("");
1312
- const { active } = (0, import_react11.useEditorState)({
1949
+ const [open, setOpen] = (0, import_react13.useState)(false);
1950
+ const [url, setUrl] = (0, import_react13.useState)("");
1951
+ const [touched, setTouched] = (0, import_react13.useState)(false);
1952
+ const { active } = (0, import_react12.useEditorState)({
1313
1953
  editor: editor ?? null,
1314
1954
  selector: (ctx) => ({
1315
1955
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
1316
1956
  })
1317
1957
  }) ?? { active: false };
1318
- const handleInsert = (0, import_react12.useCallback)(() => {
1319
- if (url && editor) {
1320
- const tweetId = extractTweetId(url);
1321
- if (tweetId) {
1322
- editor.chain().focus().setTwitterEmbed(tweetId).run();
1323
- setUrl("");
1324
- }
1958
+ const tweetId = url ? extractTweetId(url) : null;
1959
+ const showError = touched && url.length > 0 && !tweetId;
1960
+ const resetState = (0, import_react13.useCallback)(() => {
1961
+ setUrl("");
1962
+ setTouched(false);
1963
+ }, []);
1964
+ const handleInsert = (0, import_react13.useCallback)(() => {
1965
+ setTouched(true);
1966
+ if (!tweetId || !editor) {
1967
+ return false;
1325
1968
  }
1326
- }, [url, editor]);
1327
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
1328
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1329
- DialogTrigger,
1330
- {
1331
- render: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1332
- RichTextEditorControl,
1969
+ editor.chain().focus().setTwitterEmbed(tweetId).run();
1970
+ resetState();
1971
+ return true;
1972
+ }, [tweetId, editor, resetState]);
1973
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1974
+ Dialog,
1975
+ {
1976
+ open,
1977
+ onOpenChange: (next) => {
1978
+ setOpen(next);
1979
+ if (!next) {
1980
+ resetState();
1981
+ }
1982
+ },
1983
+ children: [
1984
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1985
+ DialogTrigger,
1333
1986
  {
1334
- active,
1335
- className,
1336
- title: "Embed Tweet",
1337
- "aria-label": "Embed Tweet",
1338
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1339
- "svg",
1987
+ render: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1988
+ RichTextEditorControl,
1340
1989
  {
1341
- xmlns: "http://www.w3.org/2000/svg",
1342
- viewBox: "0 0 24 24",
1343
- fill: "currentColor",
1344
- className: "rte-editor-icon",
1345
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
1990
+ active,
1991
+ className,
1992
+ title: "Embed Tweet",
1993
+ "aria-label": "Embed Tweet",
1994
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1995
+ "svg",
1996
+ {
1997
+ xmlns: "http://www.w3.org/2000/svg",
1998
+ viewBox: "0 0 24 24",
1999
+ fill: "currentColor",
2000
+ className: "rte-editor-icon",
2001
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
2002
+ }
2003
+ )
1346
2004
  }
1347
2005
  )
1348
2006
  }
1349
- )
1350
- }
1351
- ),
1352
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DialogContent, { children: [
1353
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DialogHeader, { children: [
1354
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DialogTitle, { children: "Embed Tweet" }),
1355
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DialogDescription, { children: "Paste a tweet URL or ID." })
1356
- ] }),
1357
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1358
- Input,
1359
- {
1360
- value: url,
1361
- onChange: (e) => setUrl(e.target.value),
1362
- placeholder: "https://x.com/user/status/...",
1363
- onKeyDown: (e) => {
1364
- if (e.key === "Enter" && url) {
1365
- handleInsert();
1366
- setOpen(false);
2007
+ ),
2008
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogContent, { children: [
2009
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogHeader, { children: [
2010
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogTitle, { children: "Embed Tweet" }),
2011
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogDescription, { children: "Paste a tweet URL or ID." })
2012
+ ] }),
2013
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2014
+ Input,
2015
+ {
2016
+ value: url,
2017
+ onChange: (e) => {
2018
+ setUrl(e.target.value);
2019
+ if (touched) setTouched(false);
2020
+ },
2021
+ onBlur: () => setTouched(true),
2022
+ placeholder: "https://x.com/user/status/...",
2023
+ "aria-invalid": showError,
2024
+ onKeyDown: (e) => {
2025
+ if (e.key === "Enter" && url) {
2026
+ if (handleInsert()) {
2027
+ setOpen(false);
2028
+ }
2029
+ }
2030
+ }
1367
2031
  }
1368
- }
1369
- }
1370
- ),
1371
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(DialogFooter, { children: [
1372
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(DialogClose, { children: "Cancel" }),
1373
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1374
- DialogClose,
1375
- {
1376
- disabled: !url,
1377
- className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
1378
- onClick: handleInsert,
1379
- children: "Insert"
1380
- }
1381
- )
1382
- ] })
1383
- ] })
1384
- ] });
2032
+ ),
2033
+ showError && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
2034
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogFooter, { children: [
2035
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogClose, { children: "Cancel" }),
2036
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2037
+ "button",
2038
+ {
2039
+ type: "button",
2040
+ disabled: !url,
2041
+ className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
2042
+ onClick: () => {
2043
+ if (handleInsert()) {
2044
+ setOpen(false);
2045
+ }
2046
+ },
2047
+ children: "Insert"
2048
+ }
2049
+ )
2050
+ ] })
2051
+ ] })
2052
+ ]
2053
+ }
2054
+ );
1385
2055
  };
1386
2056
 
1387
2057
  // src/controls/rte-youtube-control.tsx
1388
2058
  var import_core3 = require("@tiptap/core");
1389
- var import_react13 = require("@tiptap/react");
1390
- var import_react14 = require("react");
1391
- var import_jsx_runtime13 = require("react/jsx-runtime");
2059
+ var import_react14 = require("@tiptap/react");
2060
+ var import_react15 = require("react");
2061
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1392
2062
  var getYouTubeId = (url) => {
1393
2063
  const clean = url.trim();
1394
2064
  const patterns = [
@@ -1409,9 +2079,14 @@ var getYouTubeId = (url) => {
1409
2079
  return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
1410
2080
  };
1411
2081
  var YouTubeNodeView = (props) => {
1412
- const { node } = props;
1413
- const videoId = getYouTubeId(node.attrs.src) || node.attrs.src;
1414
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2082
+ const { node, updateAttributes } = props;
2083
+ const rawSrc = node.attrs.src || "";
2084
+ const videoId = getYouTubeId(rawSrc) || rawSrc;
2085
+ let watchUrl;
2086
+ if (videoId) {
2087
+ watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
2088
+ }
2089
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1415
2090
  ResizableNodeView,
1416
2091
  {
1417
2092
  ...props,
@@ -1419,7 +2094,10 @@ var YouTubeNodeView = (props) => {
1419
2094
  aspectRatio: 16 / 9,
1420
2095
  minWidth: 320,
1421
2096
  maxWidth: 1200,
1422
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2097
+ videoSrc: rawSrc,
2098
+ watchUrl,
2099
+ onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
2100
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1423
2101
  "iframe",
1424
2102
  {
1425
2103
  src: `https://www.youtube-nocookie.com/embed/${videoId}`,
@@ -1483,7 +2161,7 @@ var YouTubeEmbed = import_core3.Node.create({
1483
2161
  ];
1484
2162
  },
1485
2163
  addNodeView() {
1486
- return (0, import_react13.ReactNodeViewRenderer)(YouTubeNodeView);
2164
+ return (0, import_react14.ReactNodeViewRenderer)(YouTubeNodeView);
1487
2165
  },
1488
2166
  atom: true,
1489
2167
  draggable: true,
@@ -1507,32 +2185,32 @@ var YouTubeEmbed = import_core3.Node.create({
1507
2185
  });
1508
2186
  var YouTubeEmbedControl = ({ className }) => {
1509
2187
  const { editor } = useRichTextEditorContext();
1510
- const [open, setOpen] = (0, import_react14.useState)(false);
1511
- const [url, setUrl] = (0, import_react14.useState)("");
1512
- const { active } = (0, import_react13.useEditorState)({
2188
+ const [open, setOpen] = (0, import_react15.useState)(false);
2189
+ const [url, setUrl] = (0, import_react15.useState)("");
2190
+ const { active } = (0, import_react14.useEditorState)({
1513
2191
  editor: editor ?? null,
1514
2192
  selector: (ctx) => ({
1515
2193
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
1516
2194
  })
1517
2195
  }) ?? { active: false };
1518
- const handleInsert = (0, import_react14.useCallback)(() => {
2196
+ const handleInsert = (0, import_react15.useCallback)(() => {
1519
2197
  if (url && editor) {
1520
2198
  editor.chain().focus().setYouTubeEmbed(url).run();
1521
2199
  setUrl("");
1522
2200
  }
1523
2201
  }, [url, editor]);
1524
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
1525
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2202
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Dialog, { open, onOpenChange: setOpen, children: [
2203
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1526
2204
  DialogTrigger,
1527
2205
  {
1528
- render: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2206
+ render: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1529
2207
  RichTextEditorControl,
1530
2208
  {
1531
2209
  active,
1532
2210
  className,
1533
2211
  title: "Embed YouTube video",
1534
2212
  "aria-label": "Embed YouTube video",
1535
- children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2213
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1536
2214
  "svg",
1537
2215
  {
1538
2216
  xmlns: "http://www.w3.org/2000/svg",
@@ -1544,8 +2222,8 @@ var YouTubeEmbedControl = ({ className }) => {
1544
2222
  strokeLinejoin: "round",
1545
2223
  className: "rte-editor-icon",
1546
2224
  children: [
1547
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
1548
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
2225
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
2226
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
1549
2227
  ]
1550
2228
  }
1551
2229
  )
@@ -1553,12 +2231,12 @@ var YouTubeEmbedControl = ({ className }) => {
1553
2231
  )
1554
2232
  }
1555
2233
  ),
1556
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogContent, { showCloseButton: false, children: [
1557
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogHeader, { children: [
1558
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogTitle, { children: "Embed YouTube video" }),
1559
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogDescription, { children: "Paste a YouTube video URL or ID." })
2234
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogContent, { showCloseButton: false, children: [
2235
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogHeader, { children: [
2236
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogTitle, { children: "Embed YouTube video" }),
2237
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogDescription, { children: "Paste a YouTube video URL or ID." })
1560
2238
  ] }),
1561
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2239
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1562
2240
  Input,
1563
2241
  {
1564
2242
  value: url,
@@ -1572,9 +2250,9 @@ var YouTubeEmbedControl = ({ className }) => {
1572
2250
  }
1573
2251
  }
1574
2252
  ),
1575
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(DialogFooter, { children: [
1576
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(DialogClose, { children: "Cancel" }),
1577
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
2253
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(DialogFooter, { children: [
2254
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(DialogClose, { children: "Cancel" }),
2255
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1578
2256
  DialogClose,
1579
2257
  {
1580
2258
  disabled: !url,
@@ -1588,310 +2266,6 @@ var YouTubeEmbedControl = ({ className }) => {
1588
2266
  ] });
1589
2267
  };
1590
2268
 
1591
- // src/icons.tsx
1592
- var import_react15 = require("react");
1593
- var import_jsx_runtime14 = require("react/jsx-runtime");
1594
- var iconProps = { className: "rte-editor-icon" };
1595
- var Svg2 = ({
1596
- children,
1597
- className,
1598
- strokeWidth = 2
1599
- }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1600
- "svg",
1601
- {
1602
- xmlns: "http://www.w3.org/2000/svg",
1603
- viewBox: "0 0 24 24",
1604
- fill: "none",
1605
- stroke: "currentColor",
1606
- strokeWidth,
1607
- strokeLinecap: "round",
1608
- strokeLinejoin: "round",
1609
- className,
1610
- children
1611
- }
1612
- );
1613
- var LangIcon = ({
1614
- children,
1615
- className
1616
- }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1617
- "svg",
1618
- {
1619
- xmlns: "http://www.w3.org/2000/svg",
1620
- viewBox: "0 0 24 24",
1621
- fill: "none",
1622
- stroke: "currentColor",
1623
- strokeWidth: 1.5,
1624
- strokeLinecap: "round",
1625
- strokeLinejoin: "round",
1626
- className,
1627
- children
1628
- }
1629
- );
1630
- var DEFAULT_LANGUAGE_ICONS = {
1631
- bash: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1632
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
1633
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
1634
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 15.5h5.5" })
1635
- ] }),
1636
- c: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1637
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "8.5" }),
1638
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
1639
- ] }),
1640
- cpp: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1641
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "9.5", cy: "12", r: "6.5" }),
1642
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
1643
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.7 10.5v3M14.2 12h3" }),
1644
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M19.3 10.5v3M17.8 12h3" })
1645
- ] }),
1646
- css: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1647
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1648
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.7 7.5l-1 9" }),
1649
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.3 7.5l-1 9" }),
1650
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M7 10.3h11" }),
1651
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 14.3h11" })
1652
- ] }),
1653
- go: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1654
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1655
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
1656
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12.6 12h-1.9" }),
1657
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "17", cy: "12", r: "2.9" })
1658
- ] }),
1659
- html: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1660
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1661
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
1662
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
1663
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M13 7.3l-2 9.4" })
1664
- ] }),
1665
- java: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1666
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
1667
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
1668
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
1669
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 19.3h10" })
1670
- ] }),
1671
- javascript: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1672
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1673
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
1674
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1675
- ] }),
1676
- json: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1677
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
1678
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
1679
- ] }),
1680
- kotlin: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1681
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1682
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 7.5v9" }),
1683
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 12l6-4.5" }),
1684
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 12l6 4.5" })
1685
- ] }),
1686
- markdown: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1687
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
1688
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 15V9l3 4 3-4v6" }),
1689
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16.5 9v6" }),
1690
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14.5 13l2 2 2-2" })
1691
- ] }),
1692
- php: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1693
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1694
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
1695
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
1696
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
1697
- ] }),
1698
- plaintext: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1699
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
1700
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
1701
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
1702
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
1703
- ] }),
1704
- python: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1705
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
1706
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
1707
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
1708
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
1709
- ] }),
1710
- ruby: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1711
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
1712
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4.5 8h15" }),
1713
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 2.5v19" })
1714
- ] }),
1715
- rust: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1716
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "7" }),
1717
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "12", cy: "12", r: "2.3" }),
1718
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
1719
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
1720
- ] }),
1721
- sql: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1722
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
1723
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
1724
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
1725
- ] }),
1726
- swift: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LangIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
1727
- typescript: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1728
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
1729
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
1730
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
1731
- ] }),
1732
- xml: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1733
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M8 7l-4.5 5 4.5 5" }),
1734
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 7l4.5 5-4.5 5" }),
1735
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 8v8" })
1736
- ] }),
1737
- yaml: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(LangIcon, { children: [
1738
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
1739
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 8h2M9.5 8h8" }),
1740
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 12h2M9.5 12h6" }),
1741
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6.5 16h2M9.5 16h7" })
1742
- ] })
1743
- };
1744
- var DEFAULT_ICONS = {
1745
- alignCenterControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1746
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1747
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7", y1: "12", x2: "17", y2: "12" }),
1748
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "5.5", y1: "18", x2: "18.5", y2: "18" })
1749
- ] }),
1750
- alignJustifyControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1751
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1752
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "12", x2: "20", y2: "12" }),
1753
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "18", x2: "20", y2: "18" })
1754
- ] }),
1755
- alignLeftControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1756
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1757
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "12", x2: "14", y2: "12" }),
1758
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "18", x2: "17", y2: "18" })
1759
- ] }),
1760
- alignRightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1761
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1762
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "10", y1: "12", x2: "20", y2: "12" }),
1763
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "7", y1: "18", x2: "20", y2: "18" })
1764
- ] }),
1765
- blockquoteControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1766
- /* @__PURE__ */ (0, import_jsx_runtime14.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" }),
1767
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1768
- ] }),
1769
- boldControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1770
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 4h7a4 4 0 0 1 0 8H6z" }),
1771
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })
1772
- ] }),
1773
- bulletListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1774
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "9", y1: "6", x2: "21", y2: "6" }),
1775
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "9", y1: "12", x2: "21", y2: "12" }),
1776
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "9", y1: "18", x2: "21", y2: "18" }),
1777
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "4", cy: "6", r: "1.2", fill: "currentColor", stroke: "none" }),
1778
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "4", cy: "12", r: "1.2", fill: "currentColor", stroke: "none" }),
1779
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", { cx: "4", cy: "18", r: "1.2", fill: "currentColor", stroke: "none" })
1780
- ] }),
1781
- clearFormattingControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1782
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 7V4h16v3" }),
1783
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M5 20h6" }),
1784
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M13 4 8 20" }),
1785
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m16 16 5 5" }),
1786
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m21 16-5 5" })
1787
- ] }),
1788
- codeBlockControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1789
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
1790
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polyline", { points: "10 9 8 12 10 15" }),
1791
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polyline", { points: "14 9 16 12 14 15" })
1792
- ] }),
1793
- codeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1794
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polyline", { points: "16 18 22 12 16 6" }),
1795
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("polyline", { points: "8 6 2 12 8 18" })
1796
- ] }),
1797
- h1ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1798
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1799
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1800
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1801
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m17 10 3-2v8" })
1802
- ] }),
1803
- h2ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1804
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1805
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1806
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1807
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M17 9.5a2.5 2.5 0 0 1 4.8-1c0 2-4.8 2.5-4.8 5.5h5" })
1808
- ] }),
1809
- h3ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1810
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1811
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1812
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1813
- /* @__PURE__ */ (0, import_jsx_runtime14.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" }),
1814
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1815
- ] }),
1816
- h4ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1817
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1818
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1819
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1820
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M20 9v5h-4l3.5-5.5" }),
1821
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M20 14v3" })
1822
- ] }),
1823
- h5ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1824
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1825
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1826
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1827
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1828
- ] }),
1829
- h6ControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1830
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 6v12" }),
1831
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M12 6v12" }),
1832
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 12h8" }),
1833
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1834
- ] }),
1835
- highlightControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1836
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 11 3 17v3h3l6-6" }),
1837
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14 6l4-4 4 4-4 4" }),
1838
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m9 11 4-4 5 5-4 4" })
1839
- ] }),
1840
- hrControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Svg2, { ...iconProps, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) }),
1841
- italicControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1842
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
1843
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
1844
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
1845
- ] }),
1846
- languageIcons: DEFAULT_LANGUAGE_ICONS,
1847
- linkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1848
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 17H7a5 5 0 0 1 0-10h2" }),
1849
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15 7h2a5 5 0 0 1 0 10h-2" }),
1850
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "8", y1: "12", x2: "16", y2: "12" })
1851
- ] }),
1852
- orderedListControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1853
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
1854
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
1855
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
1856
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 5h2v4" }),
1857
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 9h2" }),
1858
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 13h2.5L4 16h2.5" }),
1859
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 19h2.5" })
1860
- ] }),
1861
- redoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1862
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m15 14 5-5-5-5" }),
1863
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M20 9H9.5a5.5 5.5 0 0 0 0 11H13" })
1864
- ] }),
1865
- strikeControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1866
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
1867
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
1868
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
1869
- ] }),
1870
- subscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1871
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m4 4 8 9" }),
1872
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m12 4-8 9" }),
1873
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1874
- ] }),
1875
- superscriptControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1876
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m4 20 8-9" }),
1877
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "m12 20-8-9" }),
1878
- /* @__PURE__ */ (0, import_jsx_runtime14.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" })
1879
- ] }),
1880
- underlineControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1881
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
1882
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
1883
- ] }),
1884
- undoControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1885
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 14 4 9l5-5" }),
1886
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H11" })
1887
- ] }),
1888
- unlinkControlIcon: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Svg2, { ...iconProps, children: [
1889
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M9 17H7a5 5 0 0 1-1.7-9.7" }),
1890
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("path", { d: "M15 7h2a5 5 0 0 1 1.7 9.7" }),
1891
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("line", { x1: "3", y1: "3", x2: "21", y2: "21" })
1892
- ] })
1893
- };
1894
-
1895
2269
  // src/labels.ts
1896
2270
  var DEFAULT_LABELS = {
1897
2271
  alignCenterControlLabel: "Align center",
@@ -2011,7 +2385,7 @@ var Footer = ({
2011
2385
  const count = editor.storage.characterCount;
2012
2386
  const words = count?.words() ?? 0;
2013
2387
  const characters = count?.characters() ?? 0;
2014
- return wordCountFormatter ? wordCountFormatter({ characters, words }) : `${words} words | ${characters} characters`;
2388
+ return { characters, words };
2015
2389
  }, [
2016
2390
  editor,
2017
2391
  showWordCount,
@@ -2033,7 +2407,23 @@ var Footer = ({
2033
2407
  "data-sticky": sticky ? "" : void 0,
2034
2408
  style: sticky ? { bottom: stickyOffset } : void 0,
2035
2409
  children: [
2036
- showWordCount && wordCount && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCount }),
2410
+ showWordCount && wordCount && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
2411
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "rte-footer-word-count-stat", children: [
2412
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
2413
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "rte-footer-word-count-unit", children: "words" })
2414
+ ] }),
2415
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2416
+ "span",
2417
+ {
2418
+ className: "rte-footer-word-count-separator",
2419
+ "aria-hidden": "true"
2420
+ }
2421
+ ),
2422
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("span", { className: "rte-footer-word-count-stat", children: [
2423
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
2424
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "rte-footer-word-count-unit", children: "characters" })
2425
+ ] })
2426
+ ] }) }),
2037
2427
  children
2038
2428
  ]
2039
2429
  }
@@ -2155,7 +2545,7 @@ var RichTextEditor = Object.assign(RichTextEditorRoot, {
2155
2545
 
2156
2546
  // src/extensions/link.ts
2157
2547
  var import_extension_link = __toESM(require("@tiptap/extension-link"), 1);
2158
- var Link = import_extension_link.default.extend({
2548
+ var Link2 = import_extension_link.default.extend({
2159
2549
  addKeyboardShortcuts() {
2160
2550
  return {
2161
2551
  "Mod-k": () => {