reactjs-tiptap-editor 0.3.31 → 0.4.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.
Files changed (275) hide show
  1. package/README.md +8 -2
  2. package/lib/{ActionMenuButton-BCgqJsST.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
  3. package/lib/{ActionMenuButton-D97K0UWT.js → ActionMenuButton-DKRF6oa0.js} +1 -1
  4. package/lib/Attachment.cjs +2 -2
  5. package/lib/Attachment.d.cts +25 -29
  6. package/lib/Attachment.d.ts +25 -29
  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 +25 -29
  14. package/lib/Blockquote.d.ts +25 -29
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +25 -29
  18. package/lib/Bold.d.ts +25 -29
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +26 -30
  22. package/lib/BulletList.d.ts +26 -30
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +25 -29
  26. package/lib/Clear.d.ts +25 -29
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +25 -29
  30. package/lib/Code.d.ts +25 -29
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +25 -29
  34. package/lib/CodeBlock.d.ts +25 -29
  35. package/lib/CodeBlock.js +3 -3
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +25 -29
  38. package/lib/CodeView.d.ts +25 -29
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +26 -30
  42. package/lib/Color.d.ts +26 -30
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +25 -29
  46. package/lib/Document.d.ts +25 -29
  47. package/lib/Document.js +4 -8
  48. package/lib/{Drawer-BHkje8ys.js → Drawer-CaAfmqNo.js} +37 -35
  49. package/lib/{Drawer-5Q_-WRhc.cjs → Drawer-CdvCMSzN.cjs} +1 -1
  50. package/lib/Drawer.cjs +1 -1
  51. package/lib/Drawer.d.cts +25 -29
  52. package/lib/Drawer.d.ts +25 -29
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +28 -30
  56. package/lib/Emoji.d.ts +28 -30
  57. package/lib/Emoji.js +19795 -184
  58. package/lib/{Excalidraw-GUVW-IqC.cjs → Excalidraw-BbMQhNvs.cjs} +1 -1
  59. package/lib/{Excalidraw-CG498239.js → Excalidraw-CVWz2Vyn.js} +20 -20
  60. package/lib/Excalidraw.cjs +1 -1
  61. package/lib/Excalidraw.d.cts +25 -29
  62. package/lib/Excalidraw.d.ts +25 -29
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +25 -29
  66. package/lib/ExportPdf.d.ts +25 -29
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +25 -29
  70. package/lib/ExportWord.d.ts +25 -29
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +26 -30
  74. package/lib/FontFamily.d.ts +26 -30
  75. package/lib/FontFamily.js +44 -73
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +25 -29
  78. package/lib/FontSize.d.ts +25 -29
  79. package/lib/FontSize.js +7 -5
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +25 -29
  82. package/lib/FormatPainter.d.ts +25 -29
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +25 -29
  86. package/lib/Heading.d.ts +25 -29
  87. package/lib/Heading.js +71 -60
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +25 -29
  90. package/lib/Highlight.d.ts +25 -29
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +27 -31
  94. package/lib/History.d.ts +27 -31
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +25 -29
  98. package/lib/HorizontalRule.d.ts +25 -29
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +25 -29
  102. package/lib/Iframe.d.ts +25 -29
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +25 -29
  106. package/lib/Image.d.ts +25 -29
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +25 -29
  110. package/lib/ImageGif.d.ts +25 -29
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +25 -29
  114. package/lib/ImportWord.d.ts +25 -29
  115. package/lib/ImportWord.js +5652 -5615
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +25 -29
  118. package/lib/Indent.d.ts +25 -29
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +25 -29
  122. package/lib/Italic.d.ts +25 -29
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +25 -29
  126. package/lib/Katex.d.ts +25 -29
  127. package/lib/Katex.js +12 -12
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +25 -29
  130. package/lib/LineHeight.d.ts +25 -29
  131. package/lib/LineHeight.js +5 -3
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +25 -29
  134. package/lib/Link.d.ts +25 -29
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +30 -30
  138. package/lib/ListItem.d.ts +30 -30
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +25 -29
  142. package/lib/Mention.d.ts +25 -29
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +25 -29
  146. package/lib/Mermaid.d.ts +25 -29
  147. package/lib/Mermaid.js +50 -48
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +25 -29
  150. package/lib/MoreMark.d.ts +25 -29
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +25 -29
  154. package/lib/MultiColumn.d.ts +25 -29
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +26 -30
  158. package/lib/OrderedList.d.ts +26 -30
  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 +38 -112
  164. package/lib/SearchAndReplace.d.ts +38 -112
  165. package/lib/SearchAndReplace.js +204 -192
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +25 -29
  168. package/lib/Selection.d.ts +25 -29
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +25 -29
  172. package/lib/SlashCommand.d.ts +25 -29
  173. package/lib/SlashCommand.js +178 -223
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +25 -29
  176. package/lib/Strike.d.ts +25 -29
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +25 -29
  180. package/lib/SubAndSuperScript.d.ts +25 -29
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +28 -32
  184. package/lib/Table.d.ts +28 -32
  185. package/lib/Table.js +382 -2022
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +25 -29
  188. package/lib/TableOfContent.d.ts +25 -29
  189. package/lib/TableOfContent.js +5 -5
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +27 -31
  192. package/lib/TaskList.d.ts +27 -31
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +25 -29
  196. package/lib/TextAlign.d.ts +25 -29
  197. package/lib/TextAlign.js +11 -9
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +25 -29
  200. package/lib/TextBubble.d.ts +25 -29
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +25 -29
  204. package/lib/TextDirection.d.ts +25 -29
  205. package/lib/TextDirection.js +2 -3
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +25 -29
  208. package/lib/TextUnderline.d.ts +25 -29
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +25 -29
  212. package/lib/TrailingNode.d.ts +25 -29
  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 +25 -29
  218. package/lib/Twitter.d.ts +25 -29
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +25 -29
  222. package/lib/Video.d.ts +25 -29
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +25 -29
  226. package/lib/bubble-extra.d.ts +25 -29
  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 +26 -229
  250. package/lib/index.d.ts +26 -229
  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 +25 -29
  256. package/lib/locale-bundle.d.ts +25 -29
  257. package/lib/locale-bundle.js +1 -1
  258. package/lib/style.css +1 -1
  259. package/lib/{textarea-DdH64g04.cjs → textarea-DFo_aXnj.cjs} +1 -1
  260. package/lib/{textarea-CktfkXNe.js → textarea-aPtytkDx.js} +1 -1
  261. package/package.json +76 -70
  262. package/lib/RichTextEditor-DWlLqTl9.cjs +0 -140
  263. package/lib/RichTextEditor-KP2Rgcqe.js +0 -12751
  264. package/lib/Twitter-99ivY5qv.js +0 -1744
  265. package/lib/Twitter-BvfvUtNT.cjs +0 -17
  266. package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
  267. package/lib/dom-dataset-Di3tIRrR.js +0 -1031
  268. package/lib/index-BI-IcZcN.cjs +0 -1
  269. package/lib/index-ByRfqzMr.cjs +0 -89
  270. package/lib/index-C1fzuXpN.js +0 -46
  271. package/lib/index-CbQQFj2T.js +0 -133
  272. package/lib/index-DI9T3iLd.js +0 -12354
  273. package/lib/index-D_A0TBRA.cjs +0 -1
  274. package/lib/index-DclQSrIx.cjs +0 -1
  275. package/lib/index-Z4b9rzn-.cjs +0 -1
@@ -1,139 +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 p } from "react";
5
- import { l as k, E as d, P as B, m as O, A as j, k as A, n as F, L as I, o as y, B as T, S as W, p as K, q as R } from "./RichTextEditor-KP2Rgcqe.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, n] = g(-1), [r, i] = g([]), [a, u] = g(""), [l, h] = g(""), [x, v] = g(!1), [b, V] = g(!1);
9
- return p(() => {
10
- x || (u(""), h(""), n(-1), i([]), e.commands.setSearchTerm(""), e.commands.setReplaceTerm(""));
11
- }, [e, x]), p(() => {
12
- x && e && e.commands && e.commands.setSearchTerm && e.commands.setSearchTerm(a);
13
- }, [x, a, e]), p(() => {
14
- x && e && e.commands && e.commands.setReplaceTerm && e.commands.setReplaceTerm(l);
15
- }, [x, l, e]), p(() => {
16
- if (!e)
17
- return;
18
- const m = e.extensionManager.extensions.find((E) => E.name === Y.name);
19
- if (!m)
20
- return;
21
- const w = () => {
22
- if (!x)
23
- return;
24
- const E = m ? m.storage.currentIndex : -1, L = m ? m.storage.results : [];
25
- n((C) => C !== E ? E : 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
- O,
51
+ K,
38
52
  {
39
53
  asChild: !0,
40
54
  disabled: t == null ? void 0 : t.disabled,
41
55
  children: /* @__PURE__ */ o(
42
- j,
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
61
  tooltipOptions: t == null ? void 0 : t.tooltipOptions,
48
- children: /* @__PURE__ */ o(A, { name: t == null ? void 0 : t.icon })
62
+ children: /* @__PURE__ */ o(P, { name: t == null ? void 0 : t.icon })
49
63
  }
50
64
  )
51
65
  }
52
66
  ),
53
- /* @__PURE__ */ f(
54
- F,
67
+ /* @__PURE__ */ g(
68
+ W,
55
69
  {
56
70
  align: "start",
57
71
  className: "richtext-w-full",
58
72
  hideWhenDetached: !0,
59
73
  side: "bottom",
60
74
  children: [
61
- /* @__PURE__ */ f("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
62
- /* @__PURE__ */ o(I, { children: s("editor.search.dialog.text") }),
63
- /* @__PURE__ */ o("span", { className: "richtext-font-semibold", children: r.length > 0 ? `${c + 1}/${r.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 })
64
78
  ] }),
65
- /* @__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: [
66
80
  /* @__PURE__ */ o(
67
- y,
81
+ L,
68
82
  {
69
83
  autoFocus: !0,
70
84
  className: "richtext-w-full",
71
- onChange: (m) => u(m.target.value),
85
+ onChange: (u) => n(u.target.value),
72
86
  placeholder: "Text",
73
87
  required: !0,
74
88
  type: "text",
75
- 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" })
76
98
  }
77
99
  ),
78
100
  /* @__PURE__ */ o(
79
- T,
101
+ C,
80
102
  {
81
103
  className: "richtext-flex-1",
82
- disabled: r.length === 0,
83
- onClick: e.commands.goToPrevSearchResult,
84
- children: /* @__PURE__ */ o(A, { name: "ChevronUp" })
104
+ onClick: B,
105
+ children: /* @__PURE__ */ o(P, { name: "ChevronDown" })
85
106
  }
86
107
  ),
87
108
  /* @__PURE__ */ o(
88
- T,
109
+ C,
89
110
  {
90
111
  className: "richtext-flex-1",
91
- disabled: r.length === 0,
92
- onClick: e.commands.goToNextSearchResult,
93
- children: /* @__PURE__ */ o(A, { name: "ChevronDown" })
112
+ onClick: k,
113
+ children: "Clear"
94
114
  }
95
115
  )
96
116
  ] }),
97
- /* @__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") }),
98
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(
99
- y,
119
+ L,
100
120
  {
101
121
  className: "richtext-w-80",
102
- onChange: (m) => h(m.target.value),
122
+ onChange: (u) => h(u.target.value),
103
123
  placeholder: "Text",
104
124
  required: !0,
105
125
  type: "text",
106
- value: l
126
+ value: i
107
127
  }
108
128
  ) }) }),
109
- /* @__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: [
110
130
  /* @__PURE__ */ o(
111
- W,
131
+ H,
112
132
  {
113
- checked: b,
114
- onCheckedChange: (m) => {
115
- V(m), e.commands.setCaseSensitive(m);
133
+ checked: r,
134
+ onCheckedChange: (u) => {
135
+ f(u), e.commands.setCaseSensitive(u);
116
136
  }
117
137
  }
118
138
  ),
119
- /* @__PURE__ */ o(I, { children: s("editor.replace.caseSensitive") })
139
+ /* @__PURE__ */ o(y, { children: s("editor.replace.caseSensitive") })
120
140
  ] }),
121
- /* @__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: [
122
142
  /* @__PURE__ */ o(
123
- T,
143
+ C,
124
144
  {
125
145
  className: "richtext-flex-1",
126
- disabled: r.length === 0,
127
- onClick: e.commands.replace,
146
+ onClick: w,
128
147
  children: s("editor.replace.dialog.text")
129
148
  }
130
149
  ),
131
150
  /* @__PURE__ */ o(
132
- T,
151
+ C,
133
152
  {
134
153
  className: "richtext-flex-1",
135
- disabled: r.length === 0,
136
- onClick: e.commands.replaceAll,
154
+ onClick: E,
137
155
  children: s("editor.replaceAll.dialog.text")
138
156
  }
139
157
  )
@@ -145,89 +163,88 @@ function z({ editor: e, ...t }) {
145
163
  }
146
164
  );
147
165
  }
148
- const S = (e, t) => t(e.tr);
166
+ const p = (e, t) => t(e.tr);
149
167
  function G(e, t, s) {
150
- 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
+ );
151
172
  }
152
- function J(e, t, s) {
153
- const c = [];
154
- let n = [];
155
- const r = [];
156
- let i = 0;
173
+ function J(e, t, s, a) {
174
+ const l = [], c = [];
175
+ let n = [], i = 0;
157
176
  if (!t)
158
- return { decorationsToReturn: [], results: [] };
159
- e == null || e.descendants((a, u) => {
160
- a.isText ? n[i] ? n[i] = {
161
- text: n[i].text + a.text,
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,
162
184
  pos: n[i].pos
163
185
  } : n[i] = {
164
- text: `${a.text}`,
165
- pos: u
186
+ text: `${h.text}`,
187
+ pos: r
166
188
  } : i += 1;
167
189
  }), n = n.filter(Boolean);
168
- for (const { text: a, pos: u } of n) {
169
- const l = [...a.matchAll(t)];
170
- for (const h of l) {
171
- if (h[0] === "")
172
- break;
173
- h.index !== void 0 && r.push({
174
- from: u + h.index,
175
- to: u + h.index + h[0].length
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
176
199
  });
177
200
  }
178
201
  }
179
- for (const a of r)
180
- 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
+ }
181
208
  return {
182
- decorationsToReturn: c,
183
- results: r
209
+ decorationsToReturn: N.create(e, l),
210
+ results: c
184
211
  };
185
212
  }
186
- function D(e, t, { state: s, dispatch: c }) {
187
- if (!t[0])
188
- return;
189
- const { from: r, to: i } = t[0];
190
- c && c(s.tr.insertText(e, r, 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));
191
217
  }
192
- function Q(e, t, s, c) {
193
- const n = t + 1;
194
- if (!c[n])
195
- return null;
196
- const { from: r, to: i } = c[t], a = i - r - e.length + s, { from: u, to: l } = c[n];
197
- return c[n] = {
198
- to: l - a,
199
- from: u - a
200
- }, [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];
201
226
  }
202
- function X(e, t, { tr: s, dispatch: c }) {
203
- let n = 0, r = t.slice();
204
- if (r.length === 0)
205
- return !1;
206
- for (let i = 0; i < r.length; i += 1) {
207
- const { from: a, to: u } = r[i];
208
- s.insertText(e, a, u);
209
- const l = Q(e, i, n, r);
210
- l && (n = l[0], r = l[1]);
211
- }
212
- return c(s), !0;
213
- }
214
- function H({ view: e, tr: t, searchResults: s, searchResultCurrentClass: c, gotoIndex: n }) {
215
- const r = s[n];
216
- if (r) {
217
- const i = t.setMeta("directDecoration", {
218
- fromPos: r.from,
219
- toPos: r.to,
220
- attrs: { class: c }
221
- });
222
- return e == null || e.dispatch(i), setTimeout(() => {
223
- const a = window.document.querySelector(`.${c}`);
224
- a && q(a, { behavior: "smooth", scrollMode: "if-needed" });
225
- }, 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);
226
242
  }
227
- return !1;
228
243
  }
229
- const Y = /* @__PURE__ */ _.create({
230
- name: "search",
244
+ const Y = new j(
245
+ "searchAndReplacePlugin"
246
+ ), ae = O.create({
247
+ name: "searchAndReplace",
231
248
  addOptions() {
232
249
  var e;
233
250
  return {
@@ -235,11 +252,10 @@ const Y = /* @__PURE__ */ _.create({
235
252
  searchTerm: "",
236
253
  replaceTerm: "",
237
254
  results: [],
238
- currentIndex: 0,
239
255
  searchResultClass: "search-result",
240
256
  searchResultCurrentClass: "search-result-current",
241
257
  caseSensitive: !1,
242
- disableRegex: !1,
258
+ disableRegex: !0,
243
259
  onChange: () => {
244
260
  },
245
261
  button: ({ editor: t, t: s }) => ({
@@ -258,77 +274,72 @@ const Y = /* @__PURE__ */ _.create({
258
274
  },
259
275
  addStorage() {
260
276
  return {
277
+ searchTerm: "",
278
+ replaceTerm: "",
261
279
  results: [],
262
- currentIndex: -1
280
+ lastSearchTerm: "",
281
+ caseSensitive: !1,
282
+ lastCaseSensitive: !1,
283
+ resultIndex: 0,
284
+ lastResultIndex: 0
263
285
  };
264
286
  },
265
287
  addCommands() {
266
288
  return {
267
- setSearchTerm: (e) => ({ state: t, dispatch: s }) => (this.options.searchTerm = e, this.storage.results = [], this.storage.currentIndex = 0, R(d.SEARCH_REPLCE), S(t, s), !1),
268
- setReplaceTerm: (e) => ({ state: t, dispatch: s }) => (this.options.replaceTerm = e, S(t, s), !1),
269
- setCaseSensitive: (e) => ({ state: t, dispatch: s }) => (this.options.caseSensitive = e, S(t, s), !1),
270
- replace: () => ({ state: e, dispatch: t }) => {
271
- const { replaceTerm: s } = this.options, { currentIndex: c, results: n } = this.storage, r = n[c];
272
- return r ? (D(s, [r], { state: e, dispatch: t }), this.storage.results.splice(c, 1)) : (D(s, n, { state: e, dispatch: t }), this.storage.results.shift()), R(d.SEARCH_REPLCE), S(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;
273
296
  },
274
- replaceAll: () => ({ state: e, tr: t, dispatch: s }) => {
275
- const { replaceTerm: c } = this.options, { results: n } = this.storage;
276
- return X(c, n, { tr: t, dispatch: s }), this.storage.currentIndex = -1, this.storage.results = [], R(d.SEARCH_REPLCE), S(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;
277
300
  },
278
- goToPrevSearchResult: () => ({ view: e, tr: t }) => {
279
- const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: n } = this.storage, r = (c + n.length - 1) % n.length;
280
- return this.storage.currentIndex = r, R(d.SEARCH_REPLCE), H({
281
- view: e,
282
- tr: t,
283
- searchResults: n,
284
- searchResultCurrentClass: s,
285
- gotoIndex: r
286
- });
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;
287
304
  },
288
- goToNextSearchResult: () => ({ view: e, tr: t }) => {
289
- const { searchResultCurrentClass: s } = this.options, { currentIndex: c, results: n } = this.storage, r = (c + 1) % n.length;
290
- return this.storage.currentIndex = r, this.options.onChange && this.options.onChange(), R(d.SEARCH_REPLCE), H({
291
- view: e,
292
- tr: t,
293
- searchResults: n,
294
- searchResultCurrentClass: s,
295
- gotoIndex: r
296
- });
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;
297
308
  }
298
309
  };
299
310
  },
300
311
  addProseMirrorPlugins() {
301
- 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;
302
313
  return [
303
- new M({
304
- key: new $("search"),
314
+ new q({
315
+ key: Y,
305
316
  state: {
306
- init() {
307
- return P.empty;
308
- },
309
- apply(t) {
310
- const { doc: s, docChanged: c } = t, { searchTerm: n, searchResultClass: r, searchResultCurrentClass: i, disableRegex: a, caseSensitive: u } = e.options;
311
- if (c || n) {
312
- const { decorationsToReturn: l, results: h } = J(
313
- s,
314
- G(n, a, u),
315
- r
316
- );
317
- if (e.storage.results = h, e.storage.currentIndex > h.length - 1 && (e.storage.currentIndex = 0), R(d.SEARCH_REPLCE), t.getMeta("directDecoration")) {
318
- const { fromPos: x, toPos: v, attrs: b } = t.getMeta("directDecoration");
319
- l.push(N.inline(x, v, b));
320
- } else
321
- h.length > 0 && (l[0] = N.inline(h[0].from, h[0].to, {
322
- class: i
323
- }));
324
- return P.create(s, l);
325
- }
326
- 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;
327
338
  }
328
339
  },
329
340
  props: {
330
- decorations(t) {
331
- return this.getState(t);
341
+ decorations(n) {
342
+ return this.getState(n);
332
343
  }
333
344
  }
334
345
  })
@@ -336,5 +347,6 @@ const Y = /* @__PURE__ */ _.create({
336
347
  }
337
348
  });
338
349
  export {
339
- Y as SearchAndReplace
350
+ ae as SearchAndReplace,
351
+ Y as searchAndReplacePluginKey
340
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;
@@ -47,18 +47,6 @@ declare module '@tiptap/core' {
47
47
  }
48
48
 
49
49
 
50
- declare module '@tiptap/core' {
51
- interface Commands<ReturnType> {
52
- emoji: {
53
- setEmoji: (emoji: {
54
- name: string;
55
- emoji: string;
56
- }) => ReturnType;
57
- };
58
- }
59
- }
60
-
61
-
62
50
  declare module '@tiptap/core' {
63
51
  interface Commands<ReturnType> {
64
52
  excalidraw: {
@@ -150,19 +138,15 @@ declare module '@tiptap/core' {
150
138
 
151
139
  declare module '@tiptap/core' {
152
140
  interface Commands<ReturnType> {
153
- imageGifUpload: {
154
- /**
155
- * Add an image gif
156
- */
157
- setImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
141
+ indent: {
158
142
  /**
159
- * Update an image gif
143
+ * Set the indent attribute
160
144
  */
161
- updateImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
145
+ indent: () => ReturnType;
162
146
  /**
163
- * Set image alignment
147
+ * Set the outdent attribute
164
148
  */
165
- setAlignImageGif: (align: 'left' | 'center' | 'right') => ReturnType;
149
+ outdent: () => ReturnType;
166
150
  };
167
151
  }
168
152
  }
@@ -170,15 +154,19 @@ declare module '@tiptap/core' {
170
154
 
171
155
  declare module '@tiptap/core' {
172
156
  interface Commands<ReturnType> {
173
- indent: {
157
+ imageGifUpload: {
174
158
  /**
175
- * Set the indent attribute
159
+ * Add an image gif
176
160
  */
177
- indent: () => ReturnType;
161
+ setImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
178
162
  /**
179
- * Set the outdent attribute
163
+ * Update an image gif
180
164
  */
181
- outdent: () => ReturnType;
165
+ updateImageGif: (options: Partial<SetImageAttrsOptions>) => ReturnType;
166
+ /**
167
+ * Set image alignment
168
+ */
169
+ setAlignImageGif: (align: 'left' | 'center' | 'right') => ReturnType;
182
170
  };
183
171
  }
184
172
  }
@@ -232,16 +220,24 @@ declare module '@tiptap/core' {
232
220
  search: {
233
221
  setSearchTerm: (searchTerm: string) => ReturnType;
234
222
  setReplaceTerm: (replaceTerm: string) => ReturnType;
223
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
224
+ resetIndex: () => ReturnType;
225
+ nextSearchResult: () => ReturnType;
226
+ previousSearchResult: () => ReturnType;
235
227
  replace: () => ReturnType;
236
228
  replaceAll: () => ReturnType;
237
- goToPrevSearchResult: () => void;
238
- goToNextSearchResult: () => void;
239
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
240
229
  };
241
230
  }
242
231
  }
243
232
 
244
233
 
234
+ declare module '@tiptap/core' {
235
+ interface Storage {
236
+ searchAndReplace: SearchAndReplaceStorage;
237
+ }
238
+ }
239
+
240
+
245
241
  declare module '@tiptap/core' {
246
242
  interface Commands<ReturnType> {
247
243
  tableOfContents: {