@editorcn/editor 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,10 +4,10 @@ import { useMemo as useMemo2, useEffect as useEffect5 } from "react";
4
4
  // src/bubble-menu/index.tsx
5
5
  import { isTextSelection } from "@tiptap/core";
6
6
  import { BubbleMenu as TiptapBubbleMenu } from "@tiptap/react/menus";
7
- import { useCallback as useCallback2 } from "react";
7
+ import { useCallback as useCallback3 } from "react";
8
8
 
9
9
  // src/bubble-menu/language-selector.tsx
10
- import { useState } from "react";
10
+ import { useCallback as useCallback2, useState } from "react";
11
11
 
12
12
  // src/rte-context.ts
13
13
  import { createContext, useContext } from "react";
@@ -26,11 +26,17 @@ var useRichTextEditorContext = () => {
26
26
  import { useCallback, useRef, useSyncExternalStore } from "react";
27
27
  var defaultEqual = (a, b) => a === b;
28
28
  var shallowEqual = (a, b) => {
29
- if (a === b) return true;
30
- if (!a || !b) return false;
29
+ if (a === b) {
30
+ return true;
31
+ }
32
+ if (!a || !b) {
33
+ return false;
34
+ }
31
35
  const ak = Object.keys(a);
32
36
  const bk = Object.keys(b);
33
- if (ak.length !== bk.length) return false;
37
+ if (ak.length !== bk.length) {
38
+ return false;
39
+ }
34
40
  return ak.every((k) => a[k] === b[k]);
35
41
  };
36
42
  var useEditorState = (editor, selector, isEqual = defaultEqual) => {
@@ -42,7 +48,9 @@ var useEditorState = (editor, selector, isEqual = defaultEqual) => {
42
48
  value: editor ? selector(editor) : void 0
43
49
  });
44
50
  const updateSnapshot = useCallback(() => {
45
- if (!editor) return;
51
+ if (!editor) {
52
+ return;
53
+ }
46
54
  const next = selectorRef.current(editor);
47
55
  if (snapshotRef.current && isEqualRef.current(snapshotRef.current.value, next)) {
48
56
  return;
@@ -94,6 +102,30 @@ var CODE_BLOCK_LANGUAGES = [
94
102
  "xml",
95
103
  "plaintext"
96
104
  ];
105
+ var CODE_BLOCK_LANGUAGE_LABELS = {
106
+ bash: "Bash",
107
+ c: "C",
108
+ cpp: "C++",
109
+ css: "CSS",
110
+ go: "Go",
111
+ html: "HTML",
112
+ java: "Java",
113
+ javascript: "JavaScript",
114
+ json: "JSON",
115
+ kotlin: "Kotlin",
116
+ markdown: "Markdown",
117
+ php: "PHP",
118
+ plaintext: "Plain Text",
119
+ python: "Python",
120
+ ruby: "Ruby",
121
+ rust: "Rust",
122
+ sql: "SQL",
123
+ swift: "Swift",
124
+ typescript: "TypeScript",
125
+ xml: "XML",
126
+ yaml: "YAML"
127
+ };
128
+ var getLanguageLabel = (lang) => CODE_BLOCK_LANGUAGE_LABELS[lang] ?? lang;
97
129
 
98
130
  // src/bubble-menu/language-selector.tsx
99
131
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -116,6 +148,7 @@ var FallbackIcon = () => /* @__PURE__ */ jsxs(
116
148
  );
117
149
  var LanguageSelector = ({ editor }) => {
118
150
  const [open, setOpen] = useState(false);
151
+ const [pill, setPill] = useState(null);
119
152
  const { icons } = useRichTextEditorContext();
120
153
  const { currentLanguage } = useEditorState(
121
154
  editor,
@@ -125,6 +158,32 @@ var LanguageSelector = ({ editor }) => {
125
158
  shallowEqual
126
159
  );
127
160
  const langIcon = icons.languageIcons[currentLanguage] ?? /* @__PURE__ */ jsx(FallbackIcon, {});
161
+ const handleItemEnter = useCallback2((target) => {
162
+ const item = target.closest(
163
+ "[data-dropdown-item]"
164
+ );
165
+ if (!item) {
166
+ return;
167
+ }
168
+ setPill({
169
+ height: item.offsetHeight,
170
+ left: item.offsetLeft,
171
+ top: item.offsetTop,
172
+ width: item.offsetWidth
173
+ });
174
+ }, []);
175
+ const handleMouseOver = useCallback2(
176
+ (event) => {
177
+ handleItemEnter(event.target);
178
+ },
179
+ [handleItemEnter]
180
+ );
181
+ const handleFocus = useCallback2(
182
+ (event) => {
183
+ handleItemEnter(event.target);
184
+ },
185
+ [handleItemEnter]
186
+ );
128
187
  return /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
129
188
  /* @__PURE__ */ jsxs(
130
189
  "button",
@@ -135,7 +194,7 @@ var LanguageSelector = ({ editor }) => {
135
194
  onClick: () => setOpen(!open),
136
195
  children: [
137
196
  /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", children: langIcon }),
138
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-text", children: currentLanguage }),
197
+ /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-text", children: getLanguageLabel(currentLanguage) }),
139
198
  /* @__PURE__ */ jsx("span", { className: "rte-bubble-btn-icon", style: { height: 12, width: 12 }, children: /* @__PURE__ */ jsx(
140
199
  "svg",
141
200
  {
@@ -166,36 +225,51 @@ var LanguageSelector = ({ editor }) => {
166
225
  }
167
226
  }
168
227
  ),
169
- /* @__PURE__ */ jsx("div", { className: "rte-bubble-dropdown rte-bubble-dropdown--language", children: CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
170
- "button",
228
+ /* @__PURE__ */ jsxs(
229
+ "div",
171
230
  {
172
- type: "button",
173
- className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
174
- onMouseDown: (e) => e.preventDefault(),
175
- onClick: () => {
176
- editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
177
- setOpen(false);
178
- },
231
+ className: "rte-bubble-dropdown rte-bubble-dropdown--language",
232
+ onFocus: handleFocus,
233
+ onMouseLeave: () => setPill(null),
234
+ onMouseOver: handleMouseOver,
179
235
  children: [
180
- /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
181
- /* @__PURE__ */ jsx("span", { children: lang }),
182
- currentLanguage === lang && /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: /* @__PURE__ */ jsx(
183
- "svg",
236
+ /* @__PURE__ */ jsx(
237
+ "div",
184
238
  {
185
- xmlns: "http://www.w3.org/2000/svg",
186
- viewBox: "0 0 24 24",
187
- fill: "none",
188
- stroke: "currentColor",
189
- strokeWidth: 2,
190
- strokeLinecap: "round",
191
- strokeLinejoin: "round",
192
- children: /* @__PURE__ */ jsx("polyline", { points: "20 6 9 17 4 12" })
239
+ "aria-hidden": "true",
240
+ className: [
241
+ "rte-bubble-dropdown-pill",
242
+ pill ? "rte-bubble-dropdown-pill--visible" : ""
243
+ ].filter(Boolean).join(" "),
244
+ style: pill ? {
245
+ height: pill.height,
246
+ left: pill.left,
247
+ top: pill.top,
248
+ width: pill.width
249
+ } : void 0
193
250
  }
194
- ) })
251
+ ),
252
+ CODE_BLOCK_LANGUAGES.map((lang) => /* @__PURE__ */ jsxs(
253
+ "button",
254
+ {
255
+ type: "button",
256
+ "data-dropdown-item": true,
257
+ className: `rte-bubble-dropdown-item${currentLanguage === lang ? " rte-bubble-dropdown-item--active" : ""}`,
258
+ onMouseDown: (e) => e.preventDefault(),
259
+ onClick: () => {
260
+ editor.chain().focus().updateAttributes("codeBlock", { language: lang }).run();
261
+ setOpen(false);
262
+ },
263
+ children: [
264
+ /* @__PURE__ */ jsx("span", { className: "rte-bubble-dropdown-icon", children: icons.languageIcons[lang] ?? /* @__PURE__ */ jsx(FallbackIcon, {}) }),
265
+ /* @__PURE__ */ jsx("span", { children: getLanguageLabel(lang) })
266
+ ]
267
+ },
268
+ lang
269
+ ))
195
270
  ]
196
- },
197
- lang
198
- )) })
271
+ }
272
+ )
199
273
  ] })
200
274
  ] });
201
275
  };
@@ -298,7 +372,7 @@ var BubbleMenu = ({ editor }) => {
298
372
  }),
299
373
  shallowEqual
300
374
  );
301
- const shouldShow = useCallback2(
375
+ const shouldShow = useCallback3(
302
376
  ({
303
377
  editor: ed,
304
378
  state
@@ -627,7 +701,7 @@ var SuperscriptControl = createControl({
627
701
  // src/controls/rte-link-control.tsx
628
702
  import { useEditorState as useEditorState3 } from "@tiptap/react";
629
703
  import * as React4 from "react";
630
- import { useCallback as useCallback3, useState as useState2 } from "react";
704
+ import { useCallback as useCallback4, useState as useState2 } from "react";
631
705
 
632
706
  // src/ui/button.tsx
633
707
  import { Button as ButtonPrimitive } from "@base-ui/react/button";
@@ -742,7 +816,7 @@ var LinkControl = () => {
742
816
  editor: editor ?? null,
743
817
  selector: (ctx) => ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("link") : false
744
818
  });
745
- const handleOpen = useCallback3(
819
+ const handleOpen = useCallback4(
746
820
  (isOpen) => {
747
821
  if (isOpen) {
748
822
  const linkData = editor?.getAttributes("link");
@@ -825,11 +899,11 @@ var LinkControl = () => {
825
899
  // src/controls/rte-twitter-control.tsx
826
900
  import { Node, nodeInputRule } from "@tiptap/core";
827
901
  import { ReactNodeViewRenderer, useEditorState as useEditorState4 } from "@tiptap/react";
828
- import { useState as useState3, useCallback as useCallback5, useEffect as useEffect3, useRef as useRef3 } from "react";
902
+ import { useState as useState3, useCallback as useCallback6, useEffect as useEffect3, useRef as useRef3 } from "react";
829
903
 
830
904
  // src/extensions/resizable-node-view.tsx
831
905
  import { NodeViewWrapper } from "@tiptap/react";
832
- import { useCallback as useCallback4, useRef as useRef2, useEffect as useEffect2 } from "react";
906
+ import { useCallback as useCallback5, useRef as useRef2, useEffect as useEffect2 } from "react";
833
907
  import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
834
908
  var ResizableNodeView = ({
835
909
  node,
@@ -847,11 +921,11 @@ var ResizableNodeView = ({
847
921
  const width = node.attrs.width;
848
922
  const height = node.attrs.height;
849
923
  const align = node.attrs.align || "center";
850
- const getEditorWidth = useCallback4(
924
+ const getEditorWidth = useCallback5(
851
925
  () => view?.dom?.parentElement?.offsetWidth ?? 0,
852
926
  [view]
853
927
  );
854
- const handleMouseMove = useCallback4(
928
+ const handleMouseMove = useCallback5(
855
929
  (e) => {
856
930
  const resize = resizingRef.current;
857
931
  if (!resize) {
@@ -892,7 +966,7 @@ var ResizableNodeView = ({
892
966
  },
893
967
  [lockAspect, aspectRatio, minWidth, maxWidth]
894
968
  );
895
- const handleMouseUp = useCallback4(
969
+ const handleMouseUp = useCallback5(
896
970
  function handleMouseUp2() {
897
971
  const resize = resizingRef.current;
898
972
  if (!resize) {
@@ -911,7 +985,7 @@ var ResizableNodeView = ({
911
985
  },
912
986
  [handleMouseMove, updateAttributes]
913
987
  );
914
- const handleMouseDown = useCallback4(
988
+ const handleMouseDown = useCallback5(
915
989
  (e, direction) => {
916
990
  e.preventDefault();
917
991
  e.stopPropagation();
@@ -1123,7 +1197,7 @@ var TwitterNodeView = (props) => {
1123
1197
  const { tweetId } = node.attrs;
1124
1198
  const w = node.attrs.width;
1125
1199
  const h = node.attrs.height;
1126
- const renderTweet = useCallback5(async () => {
1200
+ const renderTweet = useCallback6(async () => {
1127
1201
  if (!containerRef.current || !tweetId) {
1128
1202
  return;
1129
1203
  }
@@ -1270,7 +1344,7 @@ var TwitterEmbedControl = ({ className }) => {
1270
1344
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
1271
1345
  })
1272
1346
  }) ?? { active: false };
1273
- const handleInsert = useCallback5(() => {
1347
+ const handleInsert = useCallback6(() => {
1274
1348
  if (url && editor) {
1275
1349
  const tweetId = extractTweetId(url);
1276
1350
  if (tweetId) {
@@ -1342,7 +1416,7 @@ var TwitterEmbedControl = ({ className }) => {
1342
1416
  // src/controls/rte-youtube-control.tsx
1343
1417
  import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
1344
1418
  import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
1345
- import { useState as useState4, useCallback as useCallback6 } from "react";
1419
+ import { useState as useState4, useCallback as useCallback7 } from "react";
1346
1420
  import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1347
1421
  var getYouTubeId = (url) => {
1348
1422
  const clean = url.trim();
@@ -1470,7 +1544,7 @@ var YouTubeEmbedControl = ({ className }) => {
1470
1544
  active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("youtube") : false
1471
1545
  })
1472
1546
  }) ?? { active: false };
1473
- const handleInsert = useCallback6(() => {
1547
+ const handleInsert = useCallback7(() => {
1474
1548
  if (url && editor) {
1475
1549
  editor.chain().focus().setYouTubeEmbed(url).run();
1476
1550
  setUrl("");
@@ -1544,27 +1618,39 @@ var YouTubeEmbedControl = ({ className }) => {
1544
1618
  };
1545
1619
 
1546
1620
  // src/icons.tsx
1621
+ import {
1622
+ Bold,
1623
+ Code,
1624
+ Heading1,
1625
+ Heading2,
1626
+ Heading3,
1627
+ Heading4,
1628
+ Heading5,
1629
+ Heading6,
1630
+ Highlighter,
1631
+ Italic,
1632
+ Link,
1633
+ Link2Off,
1634
+ List,
1635
+ ListOrdered,
1636
+ Minus,
1637
+ Redo2,
1638
+ RemoveFormatting,
1639
+ SquareCode,
1640
+ Strikethrough,
1641
+ Subscript,
1642
+ Superscript,
1643
+ TextAlignCenter,
1644
+ TextAlignEnd,
1645
+ TextAlignJustify,
1646
+ TextAlignStart,
1647
+ TextQuote,
1648
+ Underline,
1649
+ Undo2
1650
+ } from "lucide-react";
1547
1651
  import "react";
1548
1652
  import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1549
1653
  var iconProps = { className: "rte-editor-icon" };
1550
- var Svg2 = ({
1551
- children,
1552
- className,
1553
- strokeWidth = 2
1554
- }) => /* @__PURE__ */ jsx14(
1555
- "svg",
1556
- {
1557
- xmlns: "http://www.w3.org/2000/svg",
1558
- viewBox: "0 0 24 24",
1559
- fill: "none",
1560
- stroke: "currentColor",
1561
- strokeWidth,
1562
- strokeLinecap: "round",
1563
- strokeLinejoin: "round",
1564
- className,
1565
- children
1566
- }
1567
- );
1568
1654
  var LangIcon = ({
1569
1655
  children,
1570
1656
  className
@@ -1697,154 +1783,35 @@ var DEFAULT_LANGUAGE_ICONS = {
1697
1783
  ] })
1698
1784
  };
1699
1785
  var DEFAULT_ICONS = {
1700
- alignCenterControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1701
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1702
- /* @__PURE__ */ jsx14("line", { x1: "7", y1: "12", x2: "17", y2: "12" }),
1703
- /* @__PURE__ */ jsx14("line", { x1: "5.5", y1: "18", x2: "18.5", y2: "18" })
1704
- ] }),
1705
- alignJustifyControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1706
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1707
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" }),
1708
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "18", x2: "20", y2: "18" })
1709
- ] }),
1710
- alignLeftControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1711
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1712
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "14", y2: "12" }),
1713
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "18", x2: "17", y2: "18" })
1714
- ] }),
1715
- alignRightControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1716
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "6", x2: "20", y2: "6" }),
1717
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "12", x2: "20", y2: "12" }),
1718
- /* @__PURE__ */ jsx14("line", { x1: "7", y1: "18", x2: "20", y2: "18" })
1719
- ] }),
1720
- blockquoteControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1721
- /* @__PURE__ */ jsx14("path", { d: "M7 8a3 3 0 0 0-3 3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1H6a3 3 0 0 1 2-3" }),
1722
- /* @__PURE__ */ jsx14("path", { d: "M16 8a3 3 0 0 0-3 3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a3 3 0 0 1 2-3" })
1723
- ] }),
1724
- boldControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1725
- /* @__PURE__ */ jsx14("path", { d: "M6 4h7a4 4 0 0 1 0 8H6z" }),
1726
- /* @__PURE__ */ jsx14("path", { d: "M6 12h9a4 4 0 0 1 0 8H6z" })
1727
- ] }),
1728
- bulletListControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1729
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "6", x2: "21", y2: "6" }),
1730
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "12", x2: "21", y2: "12" }),
1731
- /* @__PURE__ */ jsx14("line", { x1: "9", y1: "18", x2: "21", y2: "18" }),
1732
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "6", r: "1.2", fill: "currentColor", stroke: "none" }),
1733
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "12", r: "1.2", fill: "currentColor", stroke: "none" }),
1734
- /* @__PURE__ */ jsx14("circle", { cx: "4", cy: "18", r: "1.2", fill: "currentColor", stroke: "none" })
1735
- ] }),
1736
- clearFormattingControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1737
- /* @__PURE__ */ jsx14("path", { d: "M4 7V4h16v3" }),
1738
- /* @__PURE__ */ jsx14("path", { d: "M5 20h6" }),
1739
- /* @__PURE__ */ jsx14("path", { d: "M13 4 8 20" }),
1740
- /* @__PURE__ */ jsx14("path", { d: "m16 16 5 5" }),
1741
- /* @__PURE__ */ jsx14("path", { d: "m21 16-5 5" })
1742
- ] }),
1743
- codeBlockControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1744
- /* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
1745
- /* @__PURE__ */ jsx14("polyline", { points: "10 9 8 12 10 15" }),
1746
- /* @__PURE__ */ jsx14("polyline", { points: "14 9 16 12 14 15" })
1747
- ] }),
1748
- codeControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1749
- /* @__PURE__ */ jsx14("polyline", { points: "16 18 22 12 16 6" }),
1750
- /* @__PURE__ */ jsx14("polyline", { points: "8 6 2 12 8 18" })
1751
- ] }),
1752
- h1ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1753
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1754
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1755
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1756
- /* @__PURE__ */ jsx14("path", { d: "m17 10 3-2v8" })
1757
- ] }),
1758
- h2ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1759
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1760
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1761
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1762
- /* @__PURE__ */ jsx14("path", { d: "M17 9.5a2.5 2.5 0 0 1 4.8-1c0 2-4.8 2.5-4.8 5.5h5" })
1763
- ] }),
1764
- h3ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1765
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1766
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1767
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1768
- /* @__PURE__ */ jsx14("path", { d: "M17.5 9.5c1.5-1 3.5-.2 3.5 1.3a1.8 1.8 0 0 1-1.8 1.7" }),
1769
- /* @__PURE__ */ jsx14("path", { d: "M19.2 12.5a1.8 1.8 0 0 1 1.8 1.7c0 1.5-2 2.3-3.5 1.3" })
1770
- ] }),
1771
- h4ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1772
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1773
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1774
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1775
- /* @__PURE__ */ jsx14("path", { d: "M20 9v5h-4l3.5-5.5" }),
1776
- /* @__PURE__ */ jsx14("path", { d: "M20 14v3" })
1777
- ] }),
1778
- h5ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1779
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1780
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1781
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1782
- /* @__PURE__ */ jsx14("path", { d: "M21 9h-4v3.5c2.5-.7 4.5.3 4.5 2a2.3 2.3 0 0 1-4.3 1.3" })
1783
- ] }),
1784
- h6ControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1785
- /* @__PURE__ */ jsx14("path", { d: "M4 6v12" }),
1786
- /* @__PURE__ */ jsx14("path", { d: "M12 6v12" }),
1787
- /* @__PURE__ */ jsx14("path", { d: "M4 12h8" }),
1788
- /* @__PURE__ */ jsx14("path", { d: "M20.5 9.5c-3 1-3.5 4-3.5 5.5a2.5 2.5 0 1 0 2.5-2.5c-1 0-2 .4-2.5 1" })
1789
- ] }),
1790
- highlightControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1791
- /* @__PURE__ */ jsx14("path", { d: "M9 11 3 17v3h3l6-6" }),
1792
- /* @__PURE__ */ jsx14("path", { d: "M14 6l4-4 4 4-4 4" }),
1793
- /* @__PURE__ */ jsx14("path", { d: "m9 11 4-4 5 5-4 4" })
1794
- ] }),
1795
- hrControlIcon: /* @__PURE__ */ jsx14(Svg2, { ...iconProps, children: /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" }) }),
1796
- italicControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1797
- /* @__PURE__ */ jsx14("line", { x1: "19", y1: "4", x2: "10", y2: "4" }),
1798
- /* @__PURE__ */ jsx14("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
1799
- /* @__PURE__ */ jsx14("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
1800
- ] }),
1786
+ alignCenterControlIcon: /* @__PURE__ */ jsx14(TextAlignCenter, { ...iconProps }),
1787
+ alignJustifyControlIcon: /* @__PURE__ */ jsx14(TextAlignJustify, { ...iconProps }),
1788
+ alignLeftControlIcon: /* @__PURE__ */ jsx14(TextAlignStart, { ...iconProps }),
1789
+ alignRightControlIcon: /* @__PURE__ */ jsx14(TextAlignEnd, { ...iconProps }),
1790
+ blockquoteControlIcon: /* @__PURE__ */ jsx14(TextQuote, { ...iconProps }),
1791
+ boldControlIcon: /* @__PURE__ */ jsx14(Bold, { ...iconProps }),
1792
+ bulletListControlIcon: /* @__PURE__ */ jsx14(List, { ...iconProps }),
1793
+ clearFormattingControlIcon: /* @__PURE__ */ jsx14(RemoveFormatting, { ...iconProps }),
1794
+ codeBlockControlIcon: /* @__PURE__ */ jsx14(SquareCode, { ...iconProps }),
1795
+ codeControlIcon: /* @__PURE__ */ jsx14(Code, { ...iconProps }),
1796
+ h1ControlIcon: /* @__PURE__ */ jsx14(Heading1, { ...iconProps }),
1797
+ h2ControlIcon: /* @__PURE__ */ jsx14(Heading2, { ...iconProps }),
1798
+ h3ControlIcon: /* @__PURE__ */ jsx14(Heading3, { ...iconProps }),
1799
+ h4ControlIcon: /* @__PURE__ */ jsx14(Heading4, { ...iconProps }),
1800
+ h5ControlIcon: /* @__PURE__ */ jsx14(Heading5, { ...iconProps }),
1801
+ h6ControlIcon: /* @__PURE__ */ jsx14(Heading6, { ...iconProps }),
1802
+ highlightControlIcon: /* @__PURE__ */ jsx14(Highlighter, { ...iconProps }),
1803
+ hrControlIcon: /* @__PURE__ */ jsx14(Minus, { ...iconProps }),
1804
+ italicControlIcon: /* @__PURE__ */ jsx14(Italic, { ...iconProps }),
1801
1805
  languageIcons: DEFAULT_LANGUAGE_ICONS,
1802
- linkControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1803
- /* @__PURE__ */ jsx14("path", { d: "M9 17H7a5 5 0 0 1 0-10h2" }),
1804
- /* @__PURE__ */ jsx14("path", { d: "M15 7h2a5 5 0 0 1 0 10h-2" }),
1805
- /* @__PURE__ */ jsx14("line", { x1: "8", y1: "12", x2: "16", y2: "12" })
1806
- ] }),
1807
- orderedListControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1808
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "6", x2: "21", y2: "6" }),
1809
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "12", x2: "21", y2: "12" }),
1810
- /* @__PURE__ */ jsx14("line", { x1: "10", y1: "18", x2: "21", y2: "18" }),
1811
- /* @__PURE__ */ jsx14("path", { d: "M4 5h2v4" }),
1812
- /* @__PURE__ */ jsx14("path", { d: "M4 9h2" }),
1813
- /* @__PURE__ */ jsx14("path", { d: "M4 13h2.5L4 16h2.5" }),
1814
- /* @__PURE__ */ jsx14("path", { d: "M4 19h2.5" })
1815
- ] }),
1816
- redoControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1817
- /* @__PURE__ */ jsx14("path", { d: "m15 14 5-5-5-5" }),
1818
- /* @__PURE__ */ jsx14("path", { d: "M20 9H9.5a5.5 5.5 0 0 0 0 11H13" })
1819
- ] }),
1820
- strikeControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1821
- /* @__PURE__ */ jsx14("path", { d: "M16 4H9.5a3.5 3.5 0 0 0-2.9 5.4" }),
1822
- /* @__PURE__ */ jsx14("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
1823
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
1824
- ] }),
1825
- subscriptControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1826
- /* @__PURE__ */ jsx14("path", { d: "m4 4 8 9" }),
1827
- /* @__PURE__ */ jsx14("path", { d: "m12 4-8 9" }),
1828
- /* @__PURE__ */ jsx14("path", { d: "M19 16h-3.5c0-1.6 3.5-1.9 3.5-3.8a1.8 1.8 0 0 0-3.3-1" })
1829
- ] }),
1830
- superscriptControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1831
- /* @__PURE__ */ jsx14("path", { d: "m4 20 8-9" }),
1832
- /* @__PURE__ */ jsx14("path", { d: "m12 20-8-9" }),
1833
- /* @__PURE__ */ jsx14("path", { d: "M19 11h-3.5c0-1.6 3.5-1.9 3.5-3.8a1.8 1.8 0 0 0-3.3-1" })
1834
- ] }),
1835
- underlineControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1836
- /* @__PURE__ */ jsx14("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
1837
- /* @__PURE__ */ jsx14("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
1838
- ] }),
1839
- undoControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1840
- /* @__PURE__ */ jsx14("path", { d: "M9 14 4 9l5-5" }),
1841
- /* @__PURE__ */ jsx14("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 0 11H11" })
1842
- ] }),
1843
- unlinkControlIcon: /* @__PURE__ */ jsxs8(Svg2, { ...iconProps, children: [
1844
- /* @__PURE__ */ jsx14("path", { d: "M9 17H7a5 5 0 0 1-1.7-9.7" }),
1845
- /* @__PURE__ */ jsx14("path", { d: "M15 7h2a5 5 0 0 1 1.7 9.7" }),
1846
- /* @__PURE__ */ jsx14("line", { x1: "3", y1: "3", x2: "21", y2: "21" })
1847
- ] })
1806
+ linkControlIcon: /* @__PURE__ */ jsx14(Link, { ...iconProps }),
1807
+ orderedListControlIcon: /* @__PURE__ */ jsx14(ListOrdered, { ...iconProps }),
1808
+ redoControlIcon: /* @__PURE__ */ jsx14(Redo2, { ...iconProps }),
1809
+ strikeControlIcon: /* @__PURE__ */ jsx14(Strikethrough, { ...iconProps }),
1810
+ subscriptControlIcon: /* @__PURE__ */ jsx14(Subscript, { ...iconProps }),
1811
+ superscriptControlIcon: /* @__PURE__ */ jsx14(Superscript, { ...iconProps }),
1812
+ underlineControlIcon: /* @__PURE__ */ jsx14(Underline, { ...iconProps }),
1813
+ undoControlIcon: /* @__PURE__ */ jsx14(Undo2, { ...iconProps }),
1814
+ unlinkControlIcon: /* @__PURE__ */ jsx14(Link2Off, { ...iconProps })
1848
1815
  };
1849
1816
 
1850
1817
  // src/labels.ts
@@ -1917,7 +1884,7 @@ var ControlsGroup = ({
1917
1884
 
1918
1885
  // src/rte-footer.tsx
1919
1886
  import { useEffect as useEffect4, useMemo, useRef as useRef4, useState as useState5 } from "react";
1920
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1887
+ import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1921
1888
  var Footer = ({
1922
1889
  children,
1923
1890
  className,
@@ -1966,7 +1933,7 @@ var Footer = ({
1966
1933
  const count = editor.storage.characterCount;
1967
1934
  const words = count?.words() ?? 0;
1968
1935
  const characters = count?.characters() ?? 0;
1969
- return wordCountFormatter ? wordCountFormatter({ characters, words }) : `${words} words | ${characters} characters`;
1936
+ return { characters, words };
1970
1937
  }, [
1971
1938
  editor,
1972
1939
  showWordCount,
@@ -1988,7 +1955,23 @@ var Footer = ({
1988
1955
  "data-sticky": sticky ? "" : void 0,
1989
1956
  style: sticky ? { bottom: stickyOffset } : void 0,
1990
1957
  children: [
1991
- showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCount }),
1958
+ showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs10(Fragment3, { children: [
1959
+ /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
1960
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
1961
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "words" })
1962
+ ] }),
1963
+ /* @__PURE__ */ jsx17(
1964
+ "span",
1965
+ {
1966
+ className: "rte-footer-word-count-separator",
1967
+ "aria-hidden": "true"
1968
+ }
1969
+ ),
1970
+ /* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
1971
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.characters }),
1972
+ /* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "characters" })
1973
+ ] })
1974
+ ] }) }),
1992
1975
  children
1993
1976
  ]
1994
1977
  }
@@ -2110,7 +2093,7 @@ var RichTextEditor = Object.assign(RichTextEditorRoot, {
2110
2093
 
2111
2094
  // src/extensions/link.ts
2112
2095
  import TipTapLink from "@tiptap/extension-link";
2113
- var Link = TipTapLink.extend({
2096
+ var Link2 = TipTapLink.extend({
2114
2097
  addKeyboardShortcuts() {
2115
2098
  return {
2116
2099
  "Mod-k": () => {
@@ -2135,7 +2118,7 @@ export {
2135
2118
  DEFAULT_ICONS,
2136
2119
  DEFAULT_LABELS,
2137
2120
  DEFAULT_LANGUAGE_ICONS,
2138
- Link,
2121
+ Link2 as Link,
2139
2122
  RichTextEditor,
2140
2123
  TwitterEmbed,
2141
2124
  YouTubeEmbed,