reactjs-tiptap-editor 0.3.30 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +8 -2
  2. package/lib/{ActionMenuButton-wiDnIxE2.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
  3. package/lib/{ActionMenuButton-B6fitGKu.js → ActionMenuButton-DKRF6oa0.js} +5 -5
  4. package/lib/Attachment.cjs +2 -2
  5. package/lib/Attachment.d.cts +47 -51
  6. package/lib/Attachment.d.ts +47 -51
  7. package/lib/Attachment.js +7 -6
  8. package/lib/BaseKit.cjs +3 -0
  9. package/lib/BaseKit.d.cts +481 -0
  10. package/lib/BaseKit.d.ts +481 -0
  11. package/lib/BaseKit.js +132 -0
  12. package/lib/Blockquote.cjs +5 -1
  13. package/lib/Blockquote.d.cts +47 -51
  14. package/lib/Blockquote.d.ts +47 -51
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +47 -51
  18. package/lib/Bold.d.ts +47 -51
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +48 -52
  22. package/lib/BulletList.d.ts +48 -52
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +47 -51
  26. package/lib/Clear.d.ts +47 -51
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +47 -51
  30. package/lib/Code.d.ts +47 -51
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +47 -51
  34. package/lib/CodeBlock.d.ts +47 -51
  35. package/lib/CodeBlock.js +5 -4
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +47 -51
  38. package/lib/CodeView.d.ts +47 -51
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +48 -52
  42. package/lib/Color.d.ts +48 -52
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +47 -51
  46. package/lib/Document.d.ts +47 -51
  47. package/lib/Document.js +4 -8
  48. package/lib/{Drawer-BKTU9CpU.js → Drawer-CaAfmqNo.js} +268 -265
  49. package/lib/Drawer-CdvCMSzN.cjs +1 -0
  50. package/lib/Drawer.cjs +1 -1
  51. package/lib/Drawer.d.cts +47 -51
  52. package/lib/Drawer.d.ts +47 -51
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +50 -52
  56. package/lib/Emoji.d.ts +50 -52
  57. package/lib/Emoji.js +19790 -178
  58. package/lib/Excalidraw-BbMQhNvs.cjs +1 -0
  59. package/lib/Excalidraw-CVWz2Vyn.js +290 -0
  60. package/lib/Excalidraw.cjs +1 -1
  61. package/lib/Excalidraw.d.cts +47 -51
  62. package/lib/Excalidraw.d.ts +47 -51
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +47 -51
  66. package/lib/ExportPdf.d.ts +47 -51
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +47 -51
  70. package/lib/ExportWord.d.ts +47 -51
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +48 -52
  74. package/lib/FontFamily.d.ts +48 -52
  75. package/lib/FontFamily.js +46 -74
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +47 -51
  78. package/lib/FontSize.d.ts +47 -51
  79. package/lib/FontSize.js +11 -8
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +47 -51
  82. package/lib/FormatPainter.d.ts +47 -51
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +47 -51
  86. package/lib/Heading.d.ts +47 -51
  87. package/lib/Heading.js +77 -65
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +47 -51
  90. package/lib/Highlight.d.ts +47 -51
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +49 -53
  94. package/lib/History.d.ts +49 -53
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +47 -51
  98. package/lib/HorizontalRule.d.ts +47 -51
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +47 -51
  102. package/lib/Iframe.d.ts +47 -51
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +47 -51
  106. package/lib/Image.d.ts +47 -51
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +47 -51
  110. package/lib/ImageGif.d.ts +47 -51
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +47 -51
  114. package/lib/ImportWord.d.ts +47 -51
  115. package/lib/ImportWord.js +5654 -5616
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +47 -51
  118. package/lib/Indent.d.ts +47 -51
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +47 -51
  122. package/lib/Italic.d.ts +47 -51
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +47 -51
  126. package/lib/Katex.d.ts +47 -51
  127. package/lib/Katex.js +49 -48
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +47 -51
  130. package/lib/LineHeight.d.ts +47 -51
  131. package/lib/LineHeight.js +21 -18
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +47 -51
  134. package/lib/Link.d.ts +47 -51
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +52 -52
  138. package/lib/ListItem.d.ts +52 -52
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +47 -51
  142. package/lib/Mention.d.ts +47 -51
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +47 -51
  146. package/lib/Mermaid.d.ts +47 -51
  147. package/lib/Mermaid.js +150 -147
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +47 -51
  150. package/lib/MoreMark.d.ts +47 -51
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +47 -51
  154. package/lib/MultiColumn.d.ts +47 -51
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +48 -52
  158. package/lib/OrderedList.d.ts +48 -52
  159. package/lib/OrderedList.js +11 -75
  160. package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
  161. package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
  162. package/lib/SearchAndReplace.cjs +1 -1
  163. package/lib/SearchAndReplace.d.cts +60 -134
  164. package/lib/SearchAndReplace.d.ts +60 -134
  165. package/lib/SearchAndReplace.js +207 -194
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +47 -51
  168. package/lib/Selection.d.ts +47 -51
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +47 -51
  172. package/lib/SlashCommand.d.ts +47 -51
  173. package/lib/SlashCommand.js +177 -222
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +47 -51
  176. package/lib/Strike.d.ts +47 -51
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +47 -51
  180. package/lib/SubAndSuperScript.d.ts +47 -51
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +50 -54
  184. package/lib/Table.d.ts +50 -54
  185. package/lib/Table.js +382 -2021
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +47 -51
  188. package/lib/TableOfContent.d.ts +47 -51
  189. package/lib/TableOfContent.js +53 -52
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +49 -53
  192. package/lib/TaskList.d.ts +49 -53
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +47 -51
  196. package/lib/TextAlign.d.ts +47 -51
  197. package/lib/TextAlign.js +11 -8
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +47 -51
  200. package/lib/TextBubble.d.ts +47 -51
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +47 -51
  204. package/lib/TextDirection.d.ts +47 -51
  205. package/lib/TextDirection.js +15 -15
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +47 -51
  208. package/lib/TextUnderline.d.ts +47 -51
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +47 -51
  212. package/lib/TrailingNode.d.ts +47 -51
  213. package/lib/TrailingNode.js +1 -1
  214. package/lib/Twitter-BFULyqdR.js +1628 -0
  215. package/lib/Twitter-Cutpkh3h.cjs +1 -0
  216. package/lib/Twitter.cjs +1 -1
  217. package/lib/Twitter.d.cts +47 -51
  218. package/lib/Twitter.d.ts +47 -51
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +47 -51
  222. package/lib/Video.d.ts +47 -51
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +47 -51
  226. package/lib/bubble-extra.d.ts +47 -51
  227. package/lib/bubble-extra.js +200 -192
  228. package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
  229. package/lib/dom-dataset-lYeH6gfI.js +2361 -0
  230. package/lib/index-5iBZLua9.cjs +12 -0
  231. package/lib/index-6D1J-A-o.cjs +1 -0
  232. package/lib/index-B96Cclrj.cjs +3 -0
  233. package/lib/index-BBz7Nmv9.js +55 -0
  234. package/lib/index-BeCTd5v2.cjs +1 -0
  235. package/lib/index-ByurDDMv.js +237 -0
  236. package/lib/index-CUogRI7j.cjs +1 -0
  237. package/lib/index-Ch6dBBad.js +709 -0
  238. package/lib/index-DF2Lp4HZ.cjs +100 -0
  239. package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
  240. package/lib/index-Dbvi-Bvh.cjs +1 -0
  241. package/lib/index-DpCrt7xs.cjs +1 -0
  242. package/lib/index-DsAX1Vq8.cjs +1 -0
  243. package/lib/index-Dy4DlW9o.js +12 -0
  244. package/lib/index-J3jHHZ4d.js +200 -0
  245. package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
  246. package/lib/index-VvXaaKe3.js +898 -0
  247. package/lib/index-kbO3iWqL.js +13432 -0
  248. package/lib/index.cjs +1 -2
  249. package/lib/index.d.cts +49 -251
  250. package/lib/index.d.ts +49 -251
  251. package/lib/index.js +2 -588
  252. package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
  253. package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
  254. package/lib/locale-bundle.cjs +1 -1
  255. package/lib/locale-bundle.d.cts +47 -51
  256. package/lib/locale-bundle.d.ts +47 -51
  257. package/lib/locale-bundle.js +1 -1
  258. package/lib/style.css +1 -1
  259. package/lib/{textarea-D5WVZMgt.cjs → textarea-DFo_aXnj.cjs} +1 -1
  260. package/lib/{textarea-BglwYF6b.js → textarea-aPtytkDx.js} +1 -1
  261. package/package.json +76 -70
  262. package/lib/Drawer-CmoEF-Zg.cjs +0 -1
  263. package/lib/Excalidraw-CM74U5tG.js +0 -289
  264. package/lib/Excalidraw-DAPP9qgY.cjs +0 -1
  265. package/lib/RichTextEditor-BQN2eLD_.js +0 -12775
  266. package/lib/RichTextEditor-C8Sm1E6J.cjs +0 -140
  267. package/lib/Twitter-CL2pu4QM.cjs +0 -17
  268. package/lib/Twitter-Dg6WWauX.js +0 -1743
  269. package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
  270. package/lib/dom-dataset-Di3tIRrR.js +0 -1031
  271. package/lib/index-BI-IcZcN.cjs +0 -1
  272. package/lib/index-ByRfqzMr.cjs +0 -89
  273. package/lib/index-C1fzuXpN.js +0 -46
  274. package/lib/index-CbQQFj2T.js +0 -133
  275. package/lib/index-DI9T3iLd.js +0 -12354
  276. package/lib/index-D_A0TBRA.cjs +0 -1
  277. package/lib/index-DclQSrIx.cjs +0 -1
  278. package/lib/index-Z4b9rzn-.cjs +0 -1
@@ -1,138 +1,157 @@
1
- import { E as _, P as M, a as $, b as N, D as P } from "./index-DI9T3iLd.js";
2
- import q from "scroll-into-view-if-needed";
3
- import { jsxs as f, jsx as o } from "react/jsx-runtime";
4
- import { useState as g, useEffect as E } from "react";
5
- import { l as k, E as d, P as B, m as j, A as F, k as A, n as O, L as I, o as y, B as T, S as W, p as K, q as R } from "./RichTextEditor-BQN2eLD_.js";
6
- import { u as U } from "./index-CsK90iVd.js";
1
+ import { a as j, E as O, P as q, D as N, j as V } from "./index-kbO3iWqL.js";
2
+ import { jsxs as g, jsx as o } from "react/jsx-runtime";
3
+ import { useState as T, useEffect as b } from "react";
4
+ import { P as F, o as K, A as M, f as P, p as W, L as y, q as L, B as C, S as H } from "./RichTextEditor-DGcKEUGr.js";
5
+ import { u as U } from "./index-LmrOdnen.js";
7
6
  function z({ editor: e, ...t }) {
8
- const { t: s } = U(), [c, r] = g(-1), [n, i] = g([]), [a, u] = g(""), [l, h] = g(""), [x, v] = g(!1), [b, V] = g(!1);
9
- return E(() => {
10
- x || (u(""), h(""), r(-1), i([]), e.commands.setSearchTerm(""), e.commands.setReplaceTerm(""));
11
- }, [e, x]), E(() => {
12
- x && e && e.commands && e.commands.setSearchTerm && e.commands.setSearchTerm(a);
13
- }, [x, a, e]), E(() => {
14
- x && e && e.commands && e.commands.setReplaceTerm && e.commands.setReplaceTerm(l);
15
- }, [x, l, e]), E(() => {
16
- if (!e)
17
- return;
18
- const m = e.extensionManager.extensions.find((S) => S.name === Y.name);
19
- if (!m)
20
- return;
21
- const w = () => {
22
- if (!x)
23
- return;
24
- const S = m ? m.storage.currentIndex : -1, L = m ? m.storage.results : [];
25
- r((C) => C !== S ? S : C), i((C) => K(C, L) ? C : L);
26
- };
27
- return k(d.SEARCH_REPLCE, w), () => {
28
- m && k(d.SEARCH_REPLCE, w);
29
- };
30
- }, [x, e]), /* @__PURE__ */ f(
31
- B,
7
+ const { t: s } = U(), [a, l] = T(!1), [c, n] = T(""), [i, h] = T(""), [r, f] = T(!1), [x, m] = T(""), d = () => {
8
+ var u, I, v, S;
9
+ m(`${((I = (u = e == null ? void 0 : e.storage) == null ? void 0 : u.searchAndReplace) == null ? void 0 : I.resultIndex) + 1}/${(S = (v = e == null ? void 0 : e.storage) == null ? void 0 : v.searchAndReplace) == null ? void 0 : S.results.length}`);
10
+ };
11
+ b(() => {
12
+ e && d();
13
+ }, [e]);
14
+ const R = (u = !1) => {
15
+ e && (u && e.commands.resetIndex(), e.commands.setSearchTerm(c), e.commands.setReplaceTerm(i), e.commands.setCaseSensitive(r), d());
16
+ }, A = () => {
17
+ if (!e) return;
18
+ const { results: u, resultIndex: I } = e.storage.searchAndReplace, v = u[I];
19
+ if (!v) return;
20
+ e.commands.setTextSelection(v);
21
+ const { node: S } = e.view.domAtPos(
22
+ e.state.selection.anchor
23
+ );
24
+ S instanceof HTMLElement && S.scrollIntoView({ behavior: "smooth", block: "center" }), d();
25
+ };
26
+ b(() => {
27
+ c.trim() || k(), c.trim() && R(!0);
28
+ }, [c]), b(() => {
29
+ i.trim() && R();
30
+ }, [i]), b(() => {
31
+ R(!0);
32
+ }, [r]);
33
+ const w = () => {
34
+ e == null || e.commands.replace(), A();
35
+ }, B = () => {
36
+ e == null || e.commands.nextSearchResult(), A();
37
+ }, D = () => {
38
+ e == null || e.commands.previousSearchResult(), A();
39
+ }, k = () => {
40
+ n(""), h(""), e.commands.resetIndex(), d();
41
+ }, E = () => {
42
+ e == null || e.commands.replaceAll(), m("0/0");
43
+ };
44
+ return /* @__PURE__ */ g(
45
+ F,
32
46
  {
33
- onOpenChange: v,
34
- open: x,
47
+ onOpenChange: l,
48
+ open: a,
35
49
  children: [
36
50
  /* @__PURE__ */ o(
37
- j,
51
+ K,
38
52
  {
39
53
  asChild: !0,
40
54
  disabled: t == null ? void 0 : t.disabled,
41
55
  children: /* @__PURE__ */ o(
42
- F,
56
+ M,
43
57
  {
44
58
  disabled: t == null ? void 0 : t.disabled,
45
59
  isActive: t == null ? void 0 : t.isActive,
46
60
  tooltip: t == null ? void 0 : t.tooltip,
47
- children: /* @__PURE__ */ o(A, { name: t == null ? void 0 : t.icon })
61
+ tooltipOptions: t == null ? void 0 : t.tooltipOptions,
62
+ children: /* @__PURE__ */ o(P, { name: t == null ? void 0 : t.icon })
48
63
  }
49
64
  )
50
65
  }
51
66
  ),
52
- /* @__PURE__ */ f(
53
- O,
67
+ /* @__PURE__ */ g(
68
+ W,
54
69
  {
55
70
  align: "start",
56
71
  className: "richtext-w-full",
57
72
  hideWhenDetached: !0,
58
73
  side: "bottom",
59
74
  children: [
60
- /* @__PURE__ */ f("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
61
- /* @__PURE__ */ o(I, { children: s("editor.search.dialog.text") }),
62
- /* @__PURE__ */ o("span", { className: "richtext-font-semibold", children: n.length > 0 ? `${c + 1}/${n.length}` : "0/0" })
75
+ /* @__PURE__ */ g("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
76
+ /* @__PURE__ */ o(y, { children: s("editor.search.dialog.text") }),
77
+ /* @__PURE__ */ o("span", { className: "richtext-font-semibold", children: x })
63
78
  ] }),
64
- /* @__PURE__ */ f("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
79
+ /* @__PURE__ */ g("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
65
80
  /* @__PURE__ */ o(
66
- y,
81
+ L,
67
82
  {
68
83
  autoFocus: !0,
69
84
  className: "richtext-w-full",
70
- onChange: (m) => u(m.target.value),
85
+ onChange: (u) => n(u.target.value),
71
86
  placeholder: "Text",
72
87
  required: !0,
73
88
  type: "text",
74
- value: a
89
+ value: c
90
+ }
91
+ ),
92
+ /* @__PURE__ */ o(
93
+ C,
94
+ {
95
+ className: "richtext-flex-1",
96
+ onClick: D,
97
+ children: /* @__PURE__ */ o(P, { name: "ChevronUp" })
75
98
  }
76
99
  ),
77
100
  /* @__PURE__ */ o(
78
- T,
101
+ C,
79
102
  {
80
103
  className: "richtext-flex-1",
81
- disabled: n.length === 0,
82
- onClick: e.commands.goToPrevSearchResult,
83
- children: /* @__PURE__ */ o(A, { name: "ChevronUp" })
104
+ onClick: B,
105
+ children: /* @__PURE__ */ o(P, { name: "ChevronDown" })
84
106
  }
85
107
  ),
86
108
  /* @__PURE__ */ o(
87
- T,
109
+ C,
88
110
  {
89
111
  className: "richtext-flex-1",
90
- disabled: n.length === 0,
91
- onClick: e.commands.goToNextSearchResult,
92
- children: /* @__PURE__ */ o(A, { name: "ChevronDown" })
112
+ onClick: k,
113
+ children: "Clear"
93
114
  }
94
115
  )
95
116
  ] }),
96
- /* @__PURE__ */ o(I, { className: "richtext-mb-[6px]", children: s("editor.replace.dialog.text") }),
117
+ /* @__PURE__ */ o(y, { className: "richtext-mb-[6px]", children: s("editor.replace.dialog.text") }),
97
118
  /* @__PURE__ */ o("div", { className: "richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: /* @__PURE__ */ o("div", { className: "richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center", children: /* @__PURE__ */ o(
98
- y,
119
+ L,
99
120
  {
100
121
  className: "richtext-w-80",
101
- onChange: (m) => h(m.target.value),
122
+ onChange: (u) => h(u.target.value),
102
123
  placeholder: "Text",
103
124
  required: !0,
104
125
  type: "text",
105
- value: l
126
+ value: i
106
127
  }
107
128
  ) }) }),
108
- /* @__PURE__ */ f("div", { className: "richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2", children: [
129
+ /* @__PURE__ */ g("div", { className: "richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2", children: [
109
130
  /* @__PURE__ */ o(
110
- W,
131
+ H,
111
132
  {
112
- checked: b,
113
- onCheckedChange: (m) => {
114
- V(m), e.commands.setCaseSensitive(m);
133
+ checked: r,
134
+ onCheckedChange: (u) => {
135
+ f(u), e.commands.setCaseSensitive(u);
115
136
  }
116
137
  }
117
138
  ),
118
- /* @__PURE__ */ o(I, { children: s("editor.replace.caseSensitive") })
139
+ /* @__PURE__ */ o(y, { children: s("editor.replace.caseSensitive") })
119
140
  ] }),
120
- /* @__PURE__ */ f("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
141
+ /* @__PURE__ */ g("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
121
142
  /* @__PURE__ */ o(
122
- T,
143
+ C,
123
144
  {
124
145
  className: "richtext-flex-1",
125
- disabled: n.length === 0,
126
- onClick: e.commands.replace,
146
+ onClick: w,
127
147
  children: s("editor.replace.dialog.text")
128
148
  }
129
149
  ),
130
150
  /* @__PURE__ */ o(
131
- T,
151
+ C,
132
152
  {
133
153
  className: "richtext-flex-1",
134
- disabled: n.length === 0,
135
- onClick: e.commands.replaceAll,
154
+ onClick: E,
136
155
  children: s("editor.replaceAll.dialog.text")
137
156
  }
138
157
  )
@@ -146,87 +165,86 @@ function z({ editor: e, ...t }) {
146
165
  }
147
166
  const p = (e, t) => t(e.tr);
148
167
  function G(e, t, s) {
149
- return RegExp(t ? e.replace(/[$()*+./?[\\\]^{|}-]/g, String.raw`\$&`) : e, s ? "gu" : "gui");
168
+ return RegExp(
169
+ t ? e.replace(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`) : e,
170
+ s ? "gu" : "gui"
171
+ );
150
172
  }
151
- function J(e, t, s) {
152
- const c = [];
153
- let r = [];
154
- const n = [];
155
- let i = 0;
173
+ function J(e, t, s, a) {
174
+ const l = [], c = [];
175
+ let n = [], i = 0;
156
176
  if (!t)
157
- return { decorationsToReturn: [], results: [] };
158
- e == null || e.descendants((a, u) => {
159
- a.isText ? r[i] ? r[i] = {
160
- text: r[i].text + a.text,
161
- pos: r[i].pos
162
- } : r[i] = {
163
- text: `${a.text}`,
164
- pos: u
177
+ return {
178
+ decorationsToReturn: N.empty,
179
+ results: []
180
+ };
181
+ e == null || e.descendants((h, r) => {
182
+ h.isText ? n[i] ? n[i] = {
183
+ text: n[i].text + h.text,
184
+ pos: n[i].pos
185
+ } : n[i] = {
186
+ text: `${h.text}`,
187
+ pos: r
165
188
  } : i += 1;
166
- }), r = r.filter(Boolean);
167
- for (const { text: a, pos: u } of r) {
168
- const l = [...a.matchAll(t)];
169
- for (const h of l) {
170
- if (h[0] === "")
171
- break;
172
- h.index !== void 0 && n.push({
173
- from: u + h.index,
174
- to: u + h.index + h[0].length
189
+ }), n = n.filter(Boolean);
190
+ for (const h of n) {
191
+ const { text: r, pos: f } = h, x = Array.from(r.matchAll(t)).filter(
192
+ ([m]) => m.trim()
193
+ );
194
+ for (const m of x) {
195
+ if (m[0] === "") break;
196
+ m.index !== void 0 && c.push({
197
+ from: f + m.index,
198
+ to: f + m.index + m[0].length
175
199
  });
176
200
  }
177
201
  }
178
- for (const a of n)
179
- c.push(N.inline(a.from, a.to, { class: s }));
202
+ for (const [h, r] of c.entries()) {
203
+ const f = h === a ? `${s} ${s}-current` : s, x = V.inline(r.from, r.to, {
204
+ class: f
205
+ });
206
+ l.push(x);
207
+ }
180
208
  return {
181
- decorationsToReturn: c,
182
- results: n
209
+ decorationsToReturn: N.create(e, l),
210
+ results: c
183
211
  };
184
212
  }
185
- function D(e, t, { state: s, dispatch: c }) {
186
- if (!t[0])
187
- return;
188
- const { from: n, to: i } = t[0];
189
- c && c(s.tr.insertText(e, n, i));
213
+ function $(e, t, { state: s, dispatch: a }) {
214
+ if (!t[0]) return;
215
+ const { from: c, to: n } = t[0];
216
+ a && a(s.tr.insertText(e, c, n));
190
217
  }
191
- function Q(e, t, s, c) {
192
- const r = t + 1;
193
- if (!c[r])
194
- return null;
195
- const { from: n, to: i } = c[t], a = i - n - e.length + s, { from: u, to: l } = c[r];
196
- return c[r] = {
197
- to: l - a,
198
- from: u - a
199
- }, [a, c];
218
+ function Q(e, t, s, a) {
219
+ const l = t + 1;
220
+ if (!a[l]) return null;
221
+ const { from: c, to: n } = a[t], i = n - c - e.length + s, { from: h, to: r } = a[l];
222
+ return a[l] = {
223
+ to: r - i,
224
+ from: h - i
225
+ }, [i, a];
200
226
  }
201
- function X(e, t, { tr: s, dispatch: c }) {
202
- let r = 0, n = t.slice();
203
- if (n.length === 0)
204
- return !1;
205
- for (let i = 0; i < n.length; i += 1) {
206
- const { from: a, to: u } = n[i];
207
- s.insertText(e, a, u);
208
- const l = Q(e, i, r, n);
209
- l && (r = l[0], n = l[1]);
210
- }
211
- return c(s), !0;
212
- }
213
- function H({ view: e, tr: t, searchResults: s, searchResultCurrentClass: c, gotoIndex: r }) {
214
- const n = s[r];
215
- if (n) {
216
- const i = t.setMeta("directDecoration", {
217
- fromPos: n.from,
218
- toPos: n.to,
219
- attrs: { class: c }
220
- });
221
- return e == null || e.dispatch(i), setTimeout(() => {
222
- const a = window.document.querySelector(`.${c}`);
223
- a && q(a, { behavior: "smooth", scrollMode: "if-needed" });
224
- }, 0), !0;
227
+ function X(e, t, { tr: s, dispatch: a }) {
228
+ let l = 0, c = t.slice();
229
+ if (c.length !== 0) {
230
+ for (let n = 0; n < c.length; n += 1) {
231
+ const { from: i, to: h } = c[n];
232
+ s.insertText(e, i, h);
233
+ const r = Q(
234
+ e,
235
+ n,
236
+ l,
237
+ c
238
+ );
239
+ r && (l = r[0], c = r[1]);
240
+ }
241
+ a(s);
225
242
  }
226
- return !1;
227
243
  }
228
- const Y = /* @__PURE__ */ _.create({
229
- name: "search",
244
+ const Y = new j(
245
+ "searchAndReplacePlugin"
246
+ ), ae = O.create({
247
+ name: "searchAndReplace",
230
248
  addOptions() {
231
249
  var e;
232
250
  return {
@@ -234,11 +252,10 @@ const Y = /* @__PURE__ */ _.create({
234
252
  searchTerm: "",
235
253
  replaceTerm: "",
236
254
  results: [],
237
- currentIndex: 0,
238
255
  searchResultClass: "search-result",
239
256
  searchResultCurrentClass: "search-result-current",
240
257
  caseSensitive: !1,
241
- disableRegex: !1,
258
+ disableRegex: !0,
242
259
  onChange: () => {
243
260
  },
244
261
  button: ({ editor: t, t: s }) => ({
@@ -257,77 +274,72 @@ const Y = /* @__PURE__ */ _.create({
257
274
  },
258
275
  addStorage() {
259
276
  return {
277
+ searchTerm: "",
278
+ replaceTerm: "",
260
279
  results: [],
261
- currentIndex: -1
280
+ lastSearchTerm: "",
281
+ caseSensitive: !1,
282
+ lastCaseSensitive: !1,
283
+ resultIndex: 0,
284
+ lastResultIndex: 0
262
285
  };
263
286
  },
264
287
  addCommands() {
265
288
  return {
266
- setSearchTerm: (e) => ({ state: t, dispatch: s }) => (this.options.searchTerm = e, this.storage.results = [], this.storage.currentIndex = 0, R(d.SEARCH_REPLCE), p(t, s), !1),
267
- setReplaceTerm: (e) => ({ state: t, dispatch: s }) => (this.options.replaceTerm = e, p(t, s), !1),
268
- setCaseSensitive: (e) => ({ state: t, dispatch: s }) => (this.options.caseSensitive = e, p(t, s), !1),
269
- replace: () => ({ state: e, dispatch: t }) => {
270
- const { replaceTerm: s } = this.options, { currentIndex: c, results: r } = this.storage, n = r[c];
271
- return n ? (D(s, [n], { state: e, dispatch: t }), this.storage.results.splice(c, 1)) : (D(s, r, { state: e, dispatch: t }), this.storage.results.shift()), R(d.SEARCH_REPLCE), p(e, t), !1;
289
+ setSearchTerm: (e) => ({ editor: t, state: s, dispatch: a }) => (t.storage.searchAndReplace.searchTerm = e, p(s, a), !1),
290
+ setReplaceTerm: (e) => ({ editor: t, state: s, dispatch: a }) => (t.storage.searchAndReplace.replaceTerm = e, p(s, a), !1),
291
+ setCaseSensitive: (e) => ({ editor: t, state: s, dispatch: a }) => (t.storage.searchAndReplace.caseSensitive = e, p(s, a), !1),
292
+ resetIndex: () => ({ editor: e, state: t, dispatch: s }) => (e.storage.searchAndReplace.resultIndex = 0, p(t, s), !1),
293
+ nextSearchResult: () => ({ editor: e }) => {
294
+ const { results: t, resultIndex: s } = e.storage.searchAndReplace, a = s + 1;
295
+ return t[a] ? e.storage.searchAndReplace.resultIndex = a : e.storage.searchAndReplace.resultIndex = 0, !1;
272
296
  },
273
- replaceAll: () => ({ state: e, tr: t, dispatch: s }) => {
274
- const { replaceTerm: c } = this.options, { results: r } = this.storage;
275
- return X(c, r, { tr: t, dispatch: s }), this.storage.currentIndex = -1, this.storage.results = [], R(d.SEARCH_REPLCE), p(e, s), !1;
297
+ previousSearchResult: () => ({ editor: e }) => {
298
+ const { results: t, resultIndex: s } = e.storage.searchAndReplace, a = s - 1;
299
+ return t[a] ? e.storage.searchAndReplace.resultIndex = a : e.storage.searchAndReplace.resultIndex = t.length - 1, !1;
276
300
  },
277
- goToPrevSearchResult: () => ({ view: e, tr: t }) => {
278
- const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: r } = this.storage, n = (c + r.length - 1) % r.length;
279
- return this.storage.currentIndex = n, R(d.SEARCH_REPLCE), H({
280
- view: e,
281
- tr: t,
282
- searchResults: r,
283
- searchResultCurrentClass: s,
284
- gotoIndex: n
285
- });
301
+ replace: () => ({ editor: e, state: t, dispatch: s }) => {
302
+ const { replaceTerm: a, results: l, resultIndex: c } = e.storage.searchAndReplace, n = l[c];
303
+ return n ? ($(a, [n], { state: t, dispatch: s }), e.storage.searchAndReplace.results.splice(c, 1)) : ($(a, l, { state: t, dispatch: s }), e.storage.searchAndReplace.results.shift()), p(t, s), !1;
286
304
  },
287
- goToNextSearchResult: () => ({ view: e, tr: t }) => {
288
- const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: r } = this.storage, n = (c + 1) % r.length;
289
- return this.storage.currentIndex = n, this.options.onChange && this.options.onChange(), R(d.SEARCH_REPLCE), H({
290
- view: e,
291
- tr: t,
292
- searchResults: r,
293
- searchResultCurrentClass: s,
294
- gotoIndex: n
295
- });
305
+ replaceAll: () => ({ editor: e, tr: t, state: s, dispatch: a }) => {
306
+ const { replaceTerm: l, results: c } = e.storage.searchAndReplace;
307
+ return X(l, c, { tr: t, dispatch: a }), e.storage.searchAndReplace.resultIndex = 0, e.storage.searchAndReplace.results = [], p(s, a), !1;
296
308
  }
297
309
  };
298
310
  },
299
311
  addProseMirrorPlugins() {
300
- const e = this;
312
+ const e = this.editor, { searchResultClass: t, disableRegex: s } = this.options, a = (n) => e.storage.searchAndReplace.lastSearchTerm = n, l = (n) => e.storage.searchAndReplace.lastCaseSensitive = n, c = (n) => e.storage.searchAndReplace.lastResultIndex = n;
301
313
  return [
302
- new M({
303
- key: new $("search"),
314
+ new q({
315
+ key: Y,
304
316
  state: {
305
- init() {
306
- return P.empty;
307
- },
308
- apply(t) {
309
- const { doc: s, docChanged: c } = t, { searchTerm: r, searchResultClass: n, searchResultCurrentClass: i, disableRegex: a, caseSensitive: u } = e.options;
310
- if (c || r) {
311
- const { decorationsToReturn: l, results: h } = J(
312
- s,
313
- G(r, a, u),
314
- n
315
- );
316
- if (e.storage.results = h, e.storage.currentIndex > h.length - 1 && (e.storage.currentIndex = 0), R(d.SEARCH_REPLCE), t.getMeta("directDecoration")) {
317
- const { fromPos: x, toPos: v, attrs: b } = t.getMeta("directDecoration");
318
- l.push(N.inline(x, v, b));
319
- } else
320
- h.length > 0 && (l[0] = N.inline(h[0].from, h[0].to, {
321
- class: i
322
- }));
323
- return P.create(s, l);
324
- }
325
- return P.empty;
317
+ init: () => N.empty,
318
+ apply({ doc: n, docChanged: i }, h) {
319
+ const {
320
+ searchTerm: r,
321
+ lastSearchTerm: f,
322
+ caseSensitive: x,
323
+ lastCaseSensitive: m,
324
+ resultIndex: d,
325
+ lastResultIndex: R
326
+ } = e.storage.searchAndReplace;
327
+ if (!i && f === r && m === x && R === d)
328
+ return h;
329
+ if (a(r), l(x), c(d), !r)
330
+ return e.storage.searchAndReplace.results = [], N.empty;
331
+ const { decorationsToReturn: A, results: w } = J(
332
+ n,
333
+ G(r, s, x),
334
+ t,
335
+ d
336
+ );
337
+ return e.storage.searchAndReplace.results = w, A;
326
338
  }
327
339
  },
328
340
  props: {
329
- decorations(t) {
330
- return this.getState(t);
341
+ decorations(n) {
342
+ return this.getState(n);
331
343
  }
332
344
  }
333
345
  })
@@ -335,5 +347,6 @@ const Y = /* @__PURE__ */ _.create({
335
347
  }
336
348
  });
337
349
  export {
338
- Y as SearchAndReplace
350
+ ae as SearchAndReplace,
351
+ Y as searchAndReplacePluginKey
339
352
  };
package/lib/Selection.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-ByRfqzMr.cjs"),o=e.Extension.create({name:"selection",addProseMirrorPlugins(){const{editor:i}=this;return[new e.Plugin({key:new e.PluginKey("selection"),props:{decorations(n){return n.selection.empty||i.isFocused===!0?null:e.DecorationSet.create(n.doc,[e.Decoration.inline(n.selection.from,n.selection.to,{class:"selection"})])}}})]}});exports.Selection=o;exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-DF2Lp4HZ.cjs"),o=e.Extension.create({name:"selection",addProseMirrorPlugins(){const{editor:i}=this;return[new e.Plugin({key:new e.PluginKey("selection"),props:{decorations(n){return n.selection.empty||i.isFocused===!0?null:e.DecorationSet.create(n.doc,[e.Decoration.inline(n.selection.from,n.selection.to,{class:"selection"})])}}})]}});exports.Selection=o;exports.default=o;