reactjs-tiptap-editor 0.4.2 → 1.0.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 (338) hide show
  1. package/lib/ActionMenuButton-BKOg7hkq.js +38 -0
  2. package/lib/ActionMenuButton-DLQyd_gx.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.d.cts +27 -39
  5. package/lib/Attachment.d.ts +27 -39
  6. package/lib/Attachment.js +129 -99
  7. package/lib/Blockquote.cjs +3 -3
  8. package/lib/Blockquote.d.cts +27 -39
  9. package/lib/Blockquote.d.ts +27 -39
  10. package/lib/Blockquote.js +50 -22
  11. package/lib/Bold.cjs +1 -1
  12. package/lib/Bold.d.cts +27 -39
  13. package/lib/Bold.d.ts +27 -39
  14. package/lib/Bold.js +48 -20
  15. package/lib/BulletList.cjs +1 -1
  16. package/lib/BulletList.d.cts +27 -39
  17. package/lib/BulletList.d.ts +27 -39
  18. package/lib/BulletList.js +38 -9
  19. package/lib/Clear.cjs +1 -1
  20. package/lib/Clear.d.cts +27 -39
  21. package/lib/Clear.d.ts +27 -39
  22. package/lib/Clear.js +32 -6
  23. package/lib/Code.cjs +1 -1
  24. package/lib/Code.d.cts +27 -39
  25. package/lib/Code.d.ts +27 -39
  26. package/lib/Code.js +53 -25
  27. package/lib/CodeBlock.cjs +35 -35
  28. package/lib/CodeBlock.d.cts +27 -39
  29. package/lib/CodeBlock.d.ts +27 -39
  30. package/lib/CodeBlock.js +605 -590
  31. package/lib/CodeView.cjs +1 -1
  32. package/lib/CodeView.d.cts +28 -40
  33. package/lib/CodeView.d.ts +28 -40
  34. package/lib/CodeView.js +49 -21
  35. package/lib/Color.cjs +1 -1
  36. package/lib/Color.d.cts +31 -39
  37. package/lib/Color.d.ts +31 -39
  38. package/lib/Color.js +123 -79
  39. package/lib/Column.cjs +1 -0
  40. package/lib/{Document.d.cts → Column.d.cts} +33 -42
  41. package/lib/{Document.d.ts → Column.d.ts} +33 -42
  42. package/lib/Column.js +217 -0
  43. package/lib/{Drawer-CaAfmqNo.js → Drawer-DZ5jvmrX.js} +404 -394
  44. package/lib/Drawer-SRhwOc6T.cjs +1 -0
  45. package/lib/Drawer.cjs +1 -1
  46. package/lib/Drawer.d.cts +27 -39
  47. package/lib/Drawer.d.ts +27 -39
  48. package/lib/Drawer.js +6 -5
  49. package/lib/Emoji.cjs +1 -1
  50. package/lib/Emoji.d.cts +27 -44
  51. package/lib/Emoji.d.ts +27 -44
  52. package/lib/Emoji.js +377 -392
  53. package/lib/Excalidraw-DwBRXEtC.js +345 -0
  54. package/lib/Excalidraw-ZN3DQvDC.cjs +1 -0
  55. package/lib/Excalidraw.cjs +1 -1
  56. package/lib/Excalidraw.d.cts +27 -39
  57. package/lib/Excalidraw.d.ts +27 -39
  58. package/lib/Excalidraw.js +6 -4
  59. package/lib/ExportPdf.cjs +5 -5
  60. package/lib/ExportPdf.d.cts +27 -39
  61. package/lib/ExportPdf.d.ts +27 -39
  62. package/lib/ExportPdf.js +60 -32
  63. package/lib/ExportWord.cjs +1 -1
  64. package/lib/ExportWord.d.cts +28 -40
  65. package/lib/ExportWord.d.ts +28 -40
  66. package/lib/ExportWord.js +84 -21
  67. package/lib/FontFamily.cjs +1 -1
  68. package/lib/FontFamily.d.cts +41 -42
  69. package/lib/FontFamily.d.ts +41 -42
  70. package/lib/FontFamily.js +72 -74
  71. package/lib/FontSize.cjs +1 -1
  72. package/lib/FontSize.d.cts +38 -42
  73. package/lib/FontSize.d.ts +38 -42
  74. package/lib/FontSize.js +72 -64
  75. package/lib/Heading.cjs +1 -1
  76. package/lib/Heading.d.cts +41 -39
  77. package/lib/Heading.d.ts +41 -39
  78. package/lib/Heading.js +91 -73
  79. package/lib/Highlight.cjs +1 -1
  80. package/lib/Highlight.d.cts +31 -39
  81. package/lib/Highlight.d.ts +31 -39
  82. package/lib/Highlight.js +150 -19
  83. package/lib/History.cjs +1 -1
  84. package/lib/History.d.cts +29 -39
  85. package/lib/History.d.ts +29 -39
  86. package/lib/History.js +976 -53
  87. package/lib/HorizontalRule.cjs +1 -1
  88. package/lib/HorizontalRule.d.cts +27 -39
  89. package/lib/HorizontalRule.d.ts +27 -39
  90. package/lib/HorizontalRule.js +97 -17
  91. package/lib/Icon-DUpv2cI6.cjs +1 -0
  92. package/lib/Icon-jKs8Hr6p.js +11 -0
  93. package/lib/Iframe-CmXkEqOd.js +431 -0
  94. package/lib/Iframe-Cvca2G7X.cjs +1 -0
  95. package/lib/Iframe.cjs +1 -1
  96. package/lib/Iframe.d.cts +26 -45
  97. package/lib/Iframe.d.ts +26 -45
  98. package/lib/Iframe.js +6 -4
  99. package/lib/Image.cjs +1 -1
  100. package/lib/Image.d.cts +27 -40
  101. package/lib/Image.d.ts +27 -40
  102. package/lib/Image.js +848 -5
  103. package/lib/ImageGif.cjs +1 -1
  104. package/lib/ImageGif.d.cts +28 -42
  105. package/lib/ImageGif.d.ts +28 -42
  106. package/lib/ImageGif.js +424 -5
  107. package/lib/ImportWord.cjs +48 -48
  108. package/lib/ImportWord.d.cts +28 -40
  109. package/lib/ImportWord.d.ts +28 -40
  110. package/lib/ImportWord.js +2759 -2751
  111. package/lib/Indent.cjs +1 -1
  112. package/lib/Indent.d.cts +27 -39
  113. package/lib/Indent.d.ts +27 -39
  114. package/lib/Indent.js +97 -27
  115. package/lib/Italic.cjs +1 -1
  116. package/lib/Italic.d.cts +27 -39
  117. package/lib/Italic.d.ts +27 -39
  118. package/lib/Italic.js +47 -19
  119. package/lib/Katex-DsYXsjSS.js +2740 -0
  120. package/lib/Katex-XfrNne6U.cjs +4 -0
  121. package/lib/Katex.cjs +1 -1
  122. package/lib/Katex.d.cts +27 -39
  123. package/lib/Katex.d.ts +27 -39
  124. package/lib/Katex.js +5 -196
  125. package/lib/LineHeight.cjs +1 -1
  126. package/lib/LineHeight.d.cts +29 -45
  127. package/lib/LineHeight.d.ts +29 -45
  128. package/lib/LineHeight.js +71 -112
  129. package/lib/Link.cjs +1 -1
  130. package/lib/Link.d.cts +28 -42
  131. package/lib/Link.d.ts +28 -42
  132. package/lib/Link.js +3 -3
  133. package/lib/LinkEditBlock-BZenZq-Z.cjs +5 -0
  134. package/lib/LinkEditBlock-CB8yIffE.js +1241 -0
  135. package/lib/Mention.cjs +1 -1
  136. package/lib/Mention.d.cts +24 -39
  137. package/lib/Mention.d.ts +24 -39
  138. package/lib/Mention.js +112 -124
  139. package/lib/Mermaid.cjs +2 -2
  140. package/lib/Mermaid.d.cts +27 -39
  141. package/lib/Mermaid.d.ts +27 -39
  142. package/lib/Mermaid.js +177 -165
  143. package/lib/MoreMark.cjs +1 -1
  144. package/lib/MoreMark.d.cts +42 -41
  145. package/lib/MoreMark.d.ts +42 -41
  146. package/lib/MoreMark.js +125 -55
  147. package/lib/OrderedList.cjs +1 -1
  148. package/lib/OrderedList.d.cts +27 -39
  149. package/lib/OrderedList.d.ts +27 -39
  150. package/lib/OrderedList.js +37 -9
  151. package/lib/SearchAndReplace.cjs +1 -1
  152. package/lib/SearchAndReplace.d.cts +27 -42
  153. package/lib/SearchAndReplace.d.ts +27 -42
  154. package/lib/SearchAndReplace.js +221 -197
  155. package/lib/SlashCommand.cjs +1 -1
  156. package/lib/SlashCommand.d.cts +39 -46
  157. package/lib/SlashCommand.d.ts +39 -46
  158. package/lib/SlashCommand.js +235 -249
  159. package/lib/Strike.cjs +1 -1
  160. package/lib/Strike.d.cts +27 -39
  161. package/lib/Strike.d.ts +27 -39
  162. package/lib/Strike.js +39 -11
  163. package/lib/Table-B1j1Ebmh.cjs +9 -0
  164. package/lib/Table-Db8TcQX8.js +1984 -0
  165. package/lib/Table.cjs +1 -9
  166. package/lib/Table.d.cts +28 -42
  167. package/lib/Table.d.ts +28 -42
  168. package/lib/Table.js +3 -558
  169. package/lib/TaskList.cjs +1 -1
  170. package/lib/TaskList.d.cts +27 -39
  171. package/lib/TaskList.d.ts +27 -39
  172. package/lib/TaskList.js +38 -10
  173. package/lib/TextAlign.cjs +1 -1
  174. package/lib/TextAlign.d.cts +40 -39
  175. package/lib/TextAlign.d.ts +40 -39
  176. package/lib/TextAlign.js +108 -101
  177. package/lib/TextDirection.cjs +1 -1
  178. package/lib/TextDirection.d.cts +56 -39
  179. package/lib/TextDirection.d.ts +56 -39
  180. package/lib/TextDirection.js +105 -112
  181. package/lib/TextUnderline.cjs +1 -1
  182. package/lib/TextUnderline.d.cts +27 -39
  183. package/lib/TextUnderline.d.ts +27 -39
  184. package/lib/TextUnderline.js +46 -18
  185. package/lib/{Twitter-BFULyqdR.js → Twitter-CXmmjz9R.js} +536 -498
  186. package/lib/Twitter-CtVTIWJW.cjs +1 -0
  187. package/lib/Twitter.cjs +1 -1
  188. package/lib/Twitter.d.cts +27 -39
  189. package/lib/Twitter.d.ts +27 -39
  190. package/lib/Twitter.js +5 -4
  191. package/lib/Video.cjs +1 -1
  192. package/lib/Video.d.cts +27 -39
  193. package/lib/Video.d.ts +27 -39
  194. package/lib/Video.js +261 -4
  195. package/lib/_commonjsHelpers-BItOPCY9.js +28 -0
  196. package/lib/_commonjsHelpers-BTDuMlIz.cjs +1 -0
  197. package/lib/bubble.cjs +2 -0
  198. package/lib/{bubble-extra.d.cts → bubble.d.cts} +53 -54
  199. package/lib/{bubble-extra.d.ts → bubble.d.ts} +53 -54
  200. package/lib/bubble.js +1925 -0
  201. package/lib/button-B12K7BJ4.cjs +1 -0
  202. package/lib/button-DXMsXUEn.js +43 -0
  203. package/lib/clsx-C11secjj.cjs +1 -0
  204. package/lib/clsx-OuTLNxxd.js +16 -0
  205. package/lib/delete-node-CosiBes5.cjs +1 -0
  206. package/lib/delete-node-IyVmiRbI.js +22 -0
  207. package/lib/dialog-CaCS-W5S.cjs +1 -0
  208. package/lib/dialog-PtQivpHS.js +100 -0
  209. package/lib/dom-dataset-BqoJhJXt.cjs +1 -0
  210. package/lib/dom-dataset-CIEeltF6.js +47 -0
  211. package/lib/dropdown-menu-BPp2Z_U-.js +136 -0
  212. package/lib/dropdown-menu-CdSm4emp.cjs +1 -0
  213. package/lib/file-BLas99n7.js +43 -0
  214. package/lib/file-i7e4nQY2.cjs +1 -0
  215. package/lib/floating-ui.dom-U1vPFQ5f.js +1151 -0
  216. package/lib/floating-ui.dom-VCrc58uF.cjs +1 -0
  217. package/lib/icons-Cllpys39.js +362 -0
  218. package/lib/icons-CqHjeW5T.cjs +1 -0
  219. package/lib/index-BH4bc3jN.cjs +33 -0
  220. package/lib/index-BPfVXs5_.js +2380 -0
  221. package/lib/index-Bnmd0WvY.js +1631 -0
  222. package/lib/{index-Ch6dBBad.js → index-CBce_TWY.js} +40 -42
  223. package/lib/{index-5iBZLua9.cjs → index-D-5U8dY8.cjs} +8 -8
  224. package/lib/{index-ByurDDMv.js → index-D2TUfKkC.js} +2 -2
  225. package/lib/index-DV5kbgRU.cjs +1 -0
  226. package/lib/{index-LmrOdnen.js → index-DYkucCoF.js} +396 -495
  227. package/lib/index-Dfmm6FTT.cjs +1 -0
  228. package/lib/index-DnWWK9F_.js +6374 -0
  229. package/lib/index-DzcKxutn.js +632 -0
  230. package/lib/index-DzvuNTxo.cjs +4 -0
  231. package/lib/{index-BeCTd5v2.cjs → index-N--9MohJ.cjs} +1 -1
  232. package/lib/index-RfTlOzIr.cjs +22 -0
  233. package/lib/index.cjs +132 -1
  234. package/lib/index.d.cts +29 -280
  235. package/lib/index.d.ts +29 -280
  236. package/lib/index.js +243 -2
  237. package/lib/input-_ECRfn3Y.cjs +1 -0
  238. package/lib/input-wJ9PDEzZ.js +21 -0
  239. package/lib/isNumber-ClPupm7P.cjs +1 -0
  240. package/lib/isNumber-fpLGS0AZ.js +15 -0
  241. package/lib/label-BkgAe7IY.cjs +1 -0
  242. package/lib/label-CGdLYWv7.js +19 -0
  243. package/lib/locale-bundle.cjs +1 -1
  244. package/lib/locale-bundle.d.cts +5405 -57
  245. package/lib/locale-bundle.d.ts +5405 -57
  246. package/lib/locale-bundle.js +9 -7
  247. package/lib/popover-BgmUNMHj.cjs +1 -0
  248. package/lib/popover-CAuEW0Mr.js +23 -0
  249. package/lib/separator-CuBW_w98.js +328 -0
  250. package/lib/separator-DRIrVZ2N.cjs +1 -0
  251. package/lib/store-DX599H5W.js +10 -0
  252. package/lib/store-WStcMOiW.cjs +1 -0
  253. package/lib/style.css +1 -1
  254. package/lib/switch-CnLJ7Y-b.cjs +1 -0
  255. package/lib/switch-Coix_FA1.js +27 -0
  256. package/lib/tabs-B5mVSN1I.js +46 -0
  257. package/lib/tabs-BoLCMcCI.cjs +1 -0
  258. package/lib/textarea-B-6zTKQz.cjs +1 -0
  259. package/lib/{textarea-aPtytkDx.js → textarea-DUUM1jZd.js} +1 -1
  260. package/lib/theme-B7aAsK_T.js +15 -0
  261. package/lib/theme-D8_cxGqB.cjs +1 -0
  262. package/lib/throttle-CdwDrFpn.js +249 -0
  263. package/lib/throttle-qX7Yjtsg.cjs +1 -0
  264. package/lib/toggle-Cdp4IT2U.js +85 -0
  265. package/lib/toggle-D41PzQLJ.cjs +1 -0
  266. package/lib/tooltip-BuEiE96N.cjs +1 -0
  267. package/lib/tooltip-CopwsU8q.js +23 -0
  268. package/lib/updatePosition-8Sdem5jb.cjs +1 -0
  269. package/lib/updatePosition-BPmcE0YD.js +215 -0
  270. package/lib/use-toast-Bz3QCOtE.cjs +1 -0
  271. package/lib/use-toast-Crf7-q5H.js +98 -0
  272. package/lib/useButtonProps-BsEd4zYM.js +141 -0
  273. package/lib/useButtonProps-C6Vpn190.cjs +1 -0
  274. package/package.json +22 -105
  275. package/lib/ActionMenuButton-CYdM1xx5.cjs +0 -1
  276. package/lib/ActionMenuButton-DKRF6oa0.js +0 -33
  277. package/lib/BaseKit.cjs +0 -3
  278. package/lib/BaseKit.d.cts +0 -481
  279. package/lib/BaseKit.d.ts +0 -481
  280. package/lib/BaseKit.js +0 -132
  281. package/lib/Document.cjs +0 -1
  282. package/lib/Document.js +0 -9
  283. package/lib/Drawer-CdvCMSzN.cjs +0 -1
  284. package/lib/Excalidraw-BbMQhNvs.cjs +0 -1
  285. package/lib/Excalidraw-CVWz2Vyn.js +0 -290
  286. package/lib/FormatPainter.cjs +0 -1
  287. package/lib/FormatPainter.d.cts +0 -372
  288. package/lib/FormatPainter.d.ts +0 -372
  289. package/lib/FormatPainter.js +0 -76
  290. package/lib/ListItem.cjs +0 -1
  291. package/lib/ListItem.d.cts +0 -290
  292. package/lib/ListItem.d.ts +0 -290
  293. package/lib/ListItem.js +0 -7
  294. package/lib/MultiColumn.cjs +0 -1
  295. package/lib/MultiColumn.d.cts +0 -294
  296. package/lib/MultiColumn.d.ts +0 -294
  297. package/lib/MultiColumn.js +0 -8
  298. package/lib/RichTextEditor-CxvwGvQG.cjs +0 -142
  299. package/lib/RichTextEditor-DGcKEUGr.js +0 -22166
  300. package/lib/Selection.cjs +0 -1
  301. package/lib/Selection.d.cts +0 -289
  302. package/lib/Selection.d.ts +0 -289
  303. package/lib/Selection.js +0 -25
  304. package/lib/SubAndSuperScript.cjs +0 -1
  305. package/lib/SubAndSuperScript.d.cts +0 -377
  306. package/lib/SubAndSuperScript.d.ts +0 -377
  307. package/lib/SubAndSuperScript.js +0 -43
  308. package/lib/TableOfContent.cjs +0 -1
  309. package/lib/TableOfContent.d.cts +0 -291
  310. package/lib/TableOfContent.d.ts +0 -291
  311. package/lib/TableOfContent.js +0 -185
  312. package/lib/TextBubble.cjs +0 -1
  313. package/lib/TextBubble.d.cts +0 -362
  314. package/lib/TextBubble.d.ts +0 -362
  315. package/lib/TextBubble.js +0 -133
  316. package/lib/TrailingNode.cjs +0 -1
  317. package/lib/TrailingNode.d.cts +0 -297
  318. package/lib/TrailingNode.d.ts +0 -297
  319. package/lib/TrailingNode.js +0 -41
  320. package/lib/Twitter-Cutpkh3h.cjs +0 -1
  321. package/lib/bubble-extra.cjs +0 -2
  322. package/lib/bubble-extra.js +0 -631
  323. package/lib/dom-dataset-_6-diIRQ.cjs +0 -33
  324. package/lib/dom-dataset-lYeH6gfI.js +0 -2361
  325. package/lib/index-6D1J-A-o.cjs +0 -1
  326. package/lib/index-B96Cclrj.cjs +0 -3
  327. package/lib/index-BBz7Nmv9.js +0 -55
  328. package/lib/index-CUogRI7j.cjs +0 -1
  329. package/lib/index-DF2Lp4HZ.cjs +0 -100
  330. package/lib/index-D_L6n8O8.js +0 -76
  331. package/lib/index-Dbvi-Bvh.cjs +0 -1
  332. package/lib/index-DpCrt7xs.cjs +0 -1
  333. package/lib/index-DsAX1Vq8.cjs +0 -1
  334. package/lib/index-Dy4DlW9o.js +0 -12
  335. package/lib/index-J3jHHZ4d.js +0 -200
  336. package/lib/index-VvXaaKe3.js +0 -898
  337. package/lib/index-kbO3iWqL.js +0 -13432
  338. package/lib/textarea-DFo_aXnj.cjs +0 -1
@@ -1,158 +1,185 @@
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";
6
- function z({ editor: e, ...t }) {
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}`);
1
+ import { E as Q } from "./index-DnWWK9F_.js";
2
+ import { Plugin as X, PluginKey as Y } from "@tiptap/pm/state";
3
+ import { DecorationSet as $, Decoration as Z } from "@tiptap/pm/view";
4
+ import { jsx as u, Fragment as _, jsxs as T } from "react/jsx-runtime";
5
+ import { useState as b, useEffect as k } from "react";
6
+ import { A as ee } from "./toggle-Cdp4IT2U.js";
7
+ import { a as te } from "./index-BPfVXs5_.js";
8
+ import { I as V } from "./Icon-jKs8Hr6p.js";
9
+ import { u as se, b as re } from "./useButtonProps-BsEd4zYM.js";
10
+ import { u as ne } from "./index-DYkucCoF.js";
11
+ import { P as ce, a as ae, b as le } from "./popover-CAuEW0Mr.js";
12
+ import { L as B } from "./label-CGdLYWv7.js";
13
+ import { I as q } from "./input-wJ9PDEzZ.js";
14
+ import { B as N } from "./button-DXMsXUEn.js";
15
+ import { S as oe } from "./switch-Coix_FA1.js";
16
+ function ye() {
17
+ const { t } = ne(), e = te(), s = se(pe.name), {
18
+ icon: n = void 0,
19
+ tooltip: i = void 0,
20
+ shortcutKeys: l = void 0,
21
+ tooltipOptions: c = {},
22
+ action: m = void 0,
23
+ isActive: h = void 0
24
+ } = (s == null ? void 0 : s.componentProps) ?? {}, { disabled: o } = re(h), [f, d] = b(!1), [p, A] = b(""), [S, w] = b(""), [I, M] = b(!1), [W, D] = b(""), P = () => {
25
+ var r, a, g, x;
26
+ D(`${((a = (r = e == null ? void 0 : e.storage) == null ? void 0 : r.searchAndReplace) == null ? void 0 : a.resultIndex) + 1}/${(x = (g = e == null ? void 0 : e.storage) == null ? void 0 : g.searchAndReplace) == null ? void 0 : x.results.length}`);
10
27
  };
11
- b(() => {
12
- e && d();
28
+ k(() => {
29
+ e && P();
13
30
  }, [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 = () => {
31
+ const H = () => {
32
+ o || m && m();
33
+ }, L = (r = !1) => {
34
+ var a, g, x, R, v, F, y, O;
35
+ e && (r && ((g = (a = e == null ? void 0 : e.commands) == null ? void 0 : a.resetIndex) == null || g.call(a)), (R = (x = e == null ? void 0 : e.commands) == null ? void 0 : x.setSearchTerm) == null || R.call(x, p), (F = (v = e == null ? void 0 : e.commands) == null ? void 0 : v.setReplaceTerm) == null || F.call(v, S), (O = (y = e == null ? void 0 : e.commands) == null ? void 0 : y.setCaseSensitive) == null || O.call(y, I), P());
36
+ }, E = () => {
37
+ var R, v;
17
38
  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(
39
+ const { results: r, resultIndex: a } = e.storage.searchAndReplace, g = r[a];
40
+ if (!g) return;
41
+ (v = (R = e == null ? void 0 : e.commands) == null ? void 0 : R.setTextSelection) == null || v.call(R, g);
42
+ const { node: x } = e.view.domAtPos(
22
43
  e.state.selection.anchor
23
44
  );
24
- S instanceof HTMLElement && S.scrollIntoView({ behavior: "smooth", block: "center" }), d();
45
+ x instanceof HTMLElement && x.scrollIntoView({ behavior: "smooth", block: "center" }), P();
25
46
  };
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");
47
+ k(() => {
48
+ p.trim() || j(), p.trim() && L(!0);
49
+ }, [p]), k(() => {
50
+ S.trim() && L();
51
+ }, [S]), k(() => {
52
+ L(!0);
53
+ }, [I]);
54
+ const U = () => {
55
+ var r, a;
56
+ (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replace) == null || a.call(r), E();
57
+ }, z = () => {
58
+ var r, a;
59
+ (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.nextSearchResult) == null || a.call(r), E();
60
+ }, G = () => {
61
+ var r, a;
62
+ (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.previousSearchResult) == null || a.call(r), E();
63
+ }, j = () => {
64
+ var r, a;
65
+ A(""), w(""), (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.resetIndex) == null || a.call(r), P();
66
+ }, J = () => {
67
+ var r, a;
68
+ (a = (r = e == null ? void 0 : e.commands) == null ? void 0 : r.replaceAll) == null || a.call(r), D("0/0");
43
69
  };
44
- return /* @__PURE__ */ g(
45
- F,
70
+ return s ? /* @__PURE__ */ T(
71
+ ce,
46
72
  {
47
- onOpenChange: l,
48
- open: a,
73
+ onOpenChange: d,
74
+ open: f,
49
75
  children: [
50
- /* @__PURE__ */ o(
51
- K,
76
+ /* @__PURE__ */ u(
77
+ ae,
52
78
  {
53
79
  asChild: !0,
54
- disabled: t == null ? void 0 : t.disabled,
55
- children: /* @__PURE__ */ o(
56
- M,
80
+ disabled: o,
81
+ children: /* @__PURE__ */ u(
82
+ ee,
57
83
  {
58
- disabled: t == null ? void 0 : t.disabled,
59
- isActive: t == null ? void 0 : t.isActive,
60
- tooltip: t == null ? void 0 : t.tooltip,
61
- tooltipOptions: t == null ? void 0 : t.tooltipOptions,
62
- children: /* @__PURE__ */ o(P, { name: t == null ? void 0 : t.icon })
84
+ action: H,
85
+ disabled: o,
86
+ icon: n,
87
+ shortcutKeys: l,
88
+ tooltip: i,
89
+ tooltipOptions: c
63
90
  }
64
91
  )
65
92
  }
66
93
  ),
67
- /* @__PURE__ */ g(
68
- W,
94
+ /* @__PURE__ */ T(
95
+ le,
69
96
  {
70
97
  align: "start",
71
98
  className: "richtext-w-full",
72
99
  hideWhenDetached: !0,
73
100
  side: "bottom",
74
101
  children: [
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 })
102
+ /* @__PURE__ */ T("div", { className: "richtext-mb-[6px] richtext-flex richtext-items-center richtext-justify-between", children: [
103
+ /* @__PURE__ */ u(B, { children: t("editor.search.dialog.text") }),
104
+ /* @__PURE__ */ u("span", { className: "richtext-font-semibold", children: W })
78
105
  ] }),
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: [
80
- /* @__PURE__ */ o(
81
- L,
106
+ /* @__PURE__ */ T("div", { className: "richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: [
107
+ /* @__PURE__ */ u(
108
+ q,
82
109
  {
83
110
  autoFocus: !0,
84
111
  className: "richtext-w-full",
85
- onChange: (u) => n(u.target.value),
112
+ onChange: (r) => A(r.target.value),
86
113
  placeholder: "Text",
87
114
  required: !0,
88
115
  type: "text",
89
- value: c
116
+ value: p
90
117
  }
91
118
  ),
92
- /* @__PURE__ */ o(
93
- C,
119
+ /* @__PURE__ */ u(
120
+ N,
94
121
  {
95
122
  className: "richtext-flex-1",
96
- onClick: D,
97
- children: /* @__PURE__ */ o(P, { name: "ChevronUp" })
123
+ onClick: G,
124
+ children: /* @__PURE__ */ u(V, { name: "ChevronUp" })
98
125
  }
99
126
  ),
100
- /* @__PURE__ */ o(
101
- C,
127
+ /* @__PURE__ */ u(
128
+ N,
102
129
  {
103
130
  className: "richtext-flex-1",
104
- onClick: B,
105
- children: /* @__PURE__ */ o(P, { name: "ChevronDown" })
131
+ onClick: z,
132
+ children: /* @__PURE__ */ u(V, { name: "ChevronDown" })
106
133
  }
107
134
  ),
108
- /* @__PURE__ */ o(
109
- C,
135
+ /* @__PURE__ */ u(
136
+ N,
110
137
  {
111
138
  className: "richtext-flex-1",
112
- onClick: k,
139
+ onClick: j,
113
140
  children: "Clear"
114
141
  }
115
142
  )
116
143
  ] }),
117
- /* @__PURE__ */ o(y, { className: "richtext-mb-[6px]", children: s("editor.replace.dialog.text") }),
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(
119
- L,
144
+ /* @__PURE__ */ u(B, { className: "richtext-mb-[6px]", children: t("editor.replace.dialog.text") }),
145
+ /* @__PURE__ */ u("div", { className: "richtext-mb-[5px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5", children: /* @__PURE__ */ u("div", { className: "richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center", children: /* @__PURE__ */ u(
146
+ q,
120
147
  {
121
148
  className: "richtext-w-80",
122
- onChange: (u) => h(u.target.value),
149
+ onChange: (r) => w(r.target.value),
123
150
  placeholder: "Text",
124
151
  required: !0,
125
152
  type: "text",
126
- value: i
153
+ value: S
127
154
  }
128
155
  ) }) }),
129
- /* @__PURE__ */ g("div", { className: "richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2", children: [
130
- /* @__PURE__ */ o(
131
- H,
156
+ /* @__PURE__ */ T("div", { className: "richtext-mb-[10px] richtext-flex richtext-items-center richtext-space-x-2", children: [
157
+ /* @__PURE__ */ u(
158
+ oe,
132
159
  {
133
- checked: r,
134
- onCheckedChange: (u) => {
135
- f(u), e.commands.setCaseSensitive(u);
160
+ checked: I,
161
+ onCheckedChange: (r) => {
162
+ M(r), e.commands.setCaseSensitive(r);
136
163
  }
137
164
  }
138
165
  ),
139
- /* @__PURE__ */ o(y, { children: s("editor.replace.caseSensitive") })
166
+ /* @__PURE__ */ u(B, { children: t("editor.replace.caseSensitive") })
140
167
  ] }),
141
- /* @__PURE__ */ g("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
142
- /* @__PURE__ */ o(
143
- C,
168
+ /* @__PURE__ */ T("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
169
+ /* @__PURE__ */ u(
170
+ N,
144
171
  {
145
172
  className: "richtext-flex-1",
146
- onClick: w,
147
- children: s("editor.replace.dialog.text")
173
+ onClick: U,
174
+ children: t("editor.replace.dialog.text")
148
175
  }
149
176
  ),
150
- /* @__PURE__ */ o(
151
- C,
177
+ /* @__PURE__ */ u(
178
+ N,
152
179
  {
153
180
  className: "richtext-flex-1",
154
- onClick: E,
155
- children: s("editor.replaceAll.dialog.text")
181
+ onClick: J,
182
+ children: t("editor.replaceAll.dialog.text")
156
183
  }
157
184
  )
158
185
  ] })
@@ -161,94 +188,92 @@ function z({ editor: e, ...t }) {
161
188
  )
162
189
  ]
163
190
  }
164
- );
191
+ ) : /* @__PURE__ */ u(_, {});
165
192
  }
166
- const p = (e, t) => t(e.tr);
167
- function G(e, t, s) {
193
+ const C = (t, e) => e(t.tr);
194
+ function ie(t, e, s) {
168
195
  return RegExp(
169
- t ? e.replace(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`) : e,
196
+ e ? t.replace(/[$()*+.?[\\\]^{|}]/g, String.raw`\$&`) : t,
170
197
  s ? "gu" : "gui"
171
198
  );
172
199
  }
173
- function J(e, t, s, a) {
174
- const l = [], c = [];
175
- let n = [], i = 0;
176
- if (!t)
200
+ function ue(t, e, s, n) {
201
+ const i = [], l = [];
202
+ let c = [], m = 0;
203
+ if (!e)
177
204
  return {
178
- decorationsToReturn: N.empty,
205
+ decorationsToReturn: $.empty,
179
206
  results: []
180
207
  };
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] = {
208
+ t == null || t.descendants((h, o) => {
209
+ h.isText ? c[m] ? c[m] = {
210
+ text: c[m].text + h.text,
211
+ pos: c[m].pos
212
+ } : c[m] = {
186
213
  text: `${h.text}`,
187
- pos: r
188
- } : i += 1;
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()
214
+ pos: o
215
+ } : m += 1;
216
+ }), c = c.filter(Boolean);
217
+ for (const h of c) {
218
+ const { text: o, pos: f } = h, d = Array.from(o.matchAll(e)).filter(
219
+ ([p]) => p.trim()
193
220
  );
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
221
+ for (const p of d) {
222
+ if (p[0] === "") break;
223
+ p.index !== void 0 && l.push({
224
+ from: f + p.index,
225
+ to: f + p.index + p[0].length
199
226
  });
200
227
  }
201
228
  }
202
- for (const [h, r] of c.entries()) {
203
- const f = h === a ? `${s} ${s}-current` : s, x = V.inline(r.from, r.to, {
229
+ for (const [h, o] of l.entries()) {
230
+ const f = h === n ? `${s} ${s}-current` : s, d = Z.inline(o.from, o.to, {
204
231
  class: f
205
232
  });
206
- l.push(x);
233
+ i.push(d);
207
234
  }
208
235
  return {
209
- decorationsToReturn: N.create(e, l),
210
- results: c
236
+ decorationsToReturn: $.create(t, i),
237
+ results: l
211
238
  };
212
239
  }
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));
240
+ function K(t, e, { state: s, dispatch: n }) {
241
+ if (!e[0]) return;
242
+ const { from: l, to: c } = e[0];
243
+ n && n(s.tr.insertText(t, l, c));
217
244
  }
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];
245
+ function me(t, e, s, n) {
246
+ const i = e + 1;
247
+ if (!n[i]) return null;
248
+ const { from: l, to: c } = n[e], m = c - l - t.length + s, { from: h, to: o } = n[i];
249
+ return n[i] = {
250
+ to: o - m,
251
+ from: h - m
252
+ }, [m, n];
226
253
  }
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
254
+ function he(t, e, { tr: s, dispatch: n }) {
255
+ let i = 0, l = e.slice();
256
+ if (l.length !== 0) {
257
+ for (let c = 0; c < l.length; c += 1) {
258
+ const { from: m, to: h } = l[c];
259
+ s.insertText(t, m, h);
260
+ const o = me(
261
+ t,
262
+ c,
263
+ i,
264
+ l
238
265
  );
239
- r && (l = r[0], c = r[1]);
266
+ o && (i = o[0], l = o[1]);
240
267
  }
241
- a(s);
268
+ n(s);
242
269
  }
243
270
  }
244
- const Y = new j(
245
- "searchAndReplacePlugin"
246
- ), ae = O.create({
271
+ const pe = Q.create({
247
272
  name: "searchAndReplace",
248
273
  addOptions() {
249
- var e;
274
+ var t;
250
275
  return {
251
- ...(e = this.parent) == null ? void 0 : e.call(this),
276
+ ...(t = this.parent) == null ? void 0 : t.call(this),
252
277
  searchTerm: "",
253
278
  replaceTerm: "",
254
279
  results: [],
@@ -258,16 +283,15 @@ const Y = new j(
258
283
  disableRegex: !0,
259
284
  onChange: () => {
260
285
  },
261
- button: ({ editor: t, t: s }) => ({
262
- component: z,
286
+ button: ({ editor: e, t: s }) => ({
287
+ // component: RichTextSearchAndReplace,
263
288
  componentProps: {
264
289
  action: () => {
265
290
  },
266
291
  icon: "SearchAndReplace",
267
292
  tooltip: s("editor.searchAndReplace.tooltip"),
268
- isActive: () => !1,
269
- disabled: !1,
270
- editor: t
293
+ isActive: () => !0,
294
+ editor: e
271
295
  }
272
296
  })
273
297
  };
@@ -286,60 +310,60 @@ const Y = new j(
286
310
  },
287
311
  addCommands() {
288
312
  return {
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;
313
+ setSearchTerm: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.searchTerm = t, C(s, n), !1),
314
+ setReplaceTerm: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.replaceTerm = t, C(s, n), !1),
315
+ setCaseSensitive: (t) => ({ editor: e, state: s, dispatch: n }) => (e.storage.searchAndReplace.caseSensitive = t, C(s, n), !1),
316
+ resetIndex: () => ({ editor: t, state: e, dispatch: s }) => (t.storage.searchAndReplace.resultIndex = 0, C(e, s), !1),
317
+ nextSearchResult: () => ({ editor: t }) => {
318
+ const { results: e, resultIndex: s } = t.storage.searchAndReplace, n = s + 1;
319
+ return e[n] ? t.storage.searchAndReplace.resultIndex = n : t.storage.searchAndReplace.resultIndex = 0, !1;
296
320
  },
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;
321
+ previousSearchResult: () => ({ editor: t }) => {
322
+ const { results: e, resultIndex: s } = t.storage.searchAndReplace, n = s - 1;
323
+ return e[n] ? t.storage.searchAndReplace.resultIndex = n : t.storage.searchAndReplace.resultIndex = e.length - 1, !1;
300
324
  },
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;
325
+ replace: () => ({ editor: t, state: e, dispatch: s }) => {
326
+ const { replaceTerm: n, results: i, resultIndex: l } = t.storage.searchAndReplace, c = i[l];
327
+ return c ? (K(n, [c], { state: e, dispatch: s }), t.storage.searchAndReplace.results.splice(l, 1)) : (K(n, i, { state: e, dispatch: s }), t.storage.searchAndReplace.results.shift()), C(e, s), !1;
304
328
  },
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;
329
+ replaceAll: () => ({ editor: t, tr: e, state: s, dispatch: n }) => {
330
+ const { replaceTerm: i, results: l } = t.storage.searchAndReplace;
331
+ return he(i, l, { tr: e, dispatch: n }), t.storage.searchAndReplace.resultIndex = 0, t.storage.searchAndReplace.results = [], C(s, n), !1;
308
332
  }
309
333
  };
310
334
  },
311
335
  addProseMirrorPlugins() {
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;
336
+ const t = this.editor, { searchResultClass: e, disableRegex: s } = this.options, n = (c) => t.storage.searchAndReplace.lastSearchTerm = c, i = (c) => t.storage.searchAndReplace.lastCaseSensitive = c, l = (c) => t.storage.searchAndReplace.lastResultIndex = c;
313
337
  return [
314
- new q({
315
- key: Y,
338
+ new X({
339
+ key: new Y(`richtextCustomPlugin${this.name}`),
316
340
  state: {
317
- init: () => N.empty,
318
- apply({ doc: n, docChanged: i }, h) {
341
+ init: () => $.empty,
342
+ apply({ doc: c, docChanged: m }, h) {
319
343
  const {
320
- searchTerm: r,
344
+ searchTerm: o,
321
345
  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)
346
+ caseSensitive: d,
347
+ lastCaseSensitive: p,
348
+ resultIndex: A,
349
+ lastResultIndex: S
350
+ } = t.storage.searchAndReplace;
351
+ if (!m && f === o && p === d && S === A)
328
352
  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
353
+ if (n(o), i(d), l(A), !o)
354
+ return t.storage.searchAndReplace.results = [], $.empty;
355
+ const { decorationsToReturn: w, results: I } = ue(
356
+ c,
357
+ ie(o, s, d),
358
+ e,
359
+ A
336
360
  );
337
- return e.storage.searchAndReplace.results = w, A;
361
+ return t.storage.searchAndReplace.results = I, w;
338
362
  }
339
363
  },
340
364
  props: {
341
- decorations(n) {
342
- return this.getState(n);
365
+ decorations(c) {
366
+ return this.getState(c);
343
367
  }
344
368
  }
345
369
  })
@@ -347,6 +371,6 @@ const Y = new j(
347
371
  }
348
372
  });
349
373
  export {
350
- ae as SearchAndReplace,
351
- Y as searchAndReplacePluginKey
374
+ ye as RichTextSearchAndReplace,
375
+ pe as SearchAndReplace
352
376
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("./dom-dataset-_6-diIRQ.cjs"),R=require("./index-DF2Lp4HZ.cjs"),H=require("./index-DpCrt7xs.cjs"),u=require("react/jsx-runtime"),f=require("react"),g=require("./RichTextEditor-CxvwGvQG.cjs"),d=require("./index-6D1J-A-o.cjs");function $(t,r){var v,L;const[n,i]=f.useState(0),[e,o]=f.useState(0),l=f.useRef(null),{t:m}=d.useLocale(),x=f.useRef([]);f.useImperativeHandle(r,()=>({onKeyDown:h})),f.useEffect(()=>{if(!l.current)return;const s=e*1e3+n,a=x.current[s];a&&a.scrollIntoView({behavior:"smooth",block:"nearest"})},[n,e]);function h({event:s}){return s.key==="ArrowUp"?(b(),!0):s.key==="ArrowDown"?(w(),!0):s.key==="Enter"?(y(),!0):!1}function b(){var c;if(t.items.length===0)return!1;let s=n-1,a=e;s<0&&(a=e-1,s=((c=t.items[a])==null?void 0:c.commands.length)-1||0),a<0&&(a=t.items.length-1,s=t.items[a].commands.length-1),i(s),o(a)}function w(){if(t.items.length===0)return!1;const s=t.items[e].commands;let a=n+1,c=e;s.length-1<a&&(a=0,c=e+1),t.items.length-1<c&&(c=0),i(a),o(c)}function y(){if(t.items.length===0||e===-1||n===-1)return!1;C(e,n)}function C(s,a){const c=t.items[s].commands[a];t.command(c),t!=null&&t.onClose&&(t==null||t.onClose())}function I(s,a){C(s,a)}function E(s,a,c){x.current[s*1e3+a]=c}return u.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-[hsl(var(--richtext-border))] richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",ref:l,children:(v=t==null?void 0:t.items)!=null&&v.length?u.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:(L=t==null?void 0:t.items)==null?void 0:L.map((s,a)=>u.jsxs(f.Fragment,{children:[u.jsx("div",{className:"richtext-col-[1/-1] richtext-mx-2 richtext-mt-2 richtext-select-none richtext-text-[0.65rem] richtext-font-semibold richtext-uppercase richtext-tracking-wider !richtext-text-neutral-500 first:richtext-mt-0.5",children:s.title}),s.commands.map((c,p)=>u.jsxs("button",{onClick:()=>I(a,p),ref:S=>E(a,p,S),className:g.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm !richtext-text-neutral-800 dark:!richtext-text-neutral-200 richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"bg-item-active":e===a&&n===p}),children:[c.iconUrl&&u.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&u.jsx(g.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${p}`))]},`slash-${s.title}`))}):u.jsx("div",{className:"richtext-p-3",children:u.jsx("span",{className:"richtext-text-xs richtext-text-gray-800 dark:richtext-text-gray-100",children:m("editor.slash.empty")})})})}const j=f.forwardRef($),q={setOpen:(t,r)=>{g.dispatchEvent(g.EVENTS.UPLOAD_VIDEO(t),r)}};function O(t,r){const n=[{name:"format",title:d.localeActions.t("editor.slash.format"),commands:[]},{name:"insert",title:d.localeActions.t("editor.slash.insert"),commands:[]}];return t.forEach(i=>{i.name.toLowerCase()==="heading"&&i.options.levels.forEach(e=>{n[0].commands.push({name:`heading${e}`,label:d.localeActions.t(`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,action:({editor:o,range:l})=>{o.chain().focus().deleteRange(l).setHeading({level:e}).run()}})}),i.name.toLowerCase()==="bulletlist"&&n[0].commands.push({name:"bulletList",label:d.localeActions.t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleBulletList().run()}}),i.name.toLowerCase()==="orderedlist"&&n[0].commands.push({name:"numberedList",label:d.localeActions.t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleOrderedList().run()}}),i.name.toLowerCase()==="tasklist"&&n[0].commands.push({name:"taskList",label:d.localeActions.t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).toggleTaskList().run()}}),i.name.toLowerCase()==="blockquote"&&n[0].commands.push({name:"blockquote",label:d.localeActions.t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setBlockquote().run()}}),i.name.toLowerCase()==="codeblock"&&n[0].commands.push({name:"codeBlock",label:d.localeActions.t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setCodeBlock().run()}}),i.name.toLowerCase()===g.Image.name&&n[1].commands.push({name:"image",label:d.localeActions.t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),g.actionDialogImage.setOpen(e.id,!0)}}),i.name.toLowerCase()===g.Video.name&&n[1].commands.push({name:"video",label:d.localeActions.t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).run(),q.setOpen(e.id,!0)}}),i.name.toLowerCase()==="table"&&n[1].commands.push({name:"table",label:d.localeActions.t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),i.name.toLowerCase()==="horizontalrule"&&n[1].commands.push({name:"horizontalRule",label:d.localeActions.t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:o})=>{e.chain().focus().deleteRange(o).setHorizontalRule().run()}}),i.name.toLowerCase()==="columns"&&n[1].commands.push({name:"columns",label:d.localeActions.t("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),r==null||r(i,n)}),n}const k="slashCommand",A=R.Extension.create({name:k,priority:200,addProseMirrorPlugins(){return[H.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new R.PluginKey(k),allow:({state:t,range:r})=>{var h,b,w;const n=t.doc.resolve(r.from),i=n.depth===1,e=n.parent.type.name==="paragraph",o=((h=n.parent.textContent)==null?void 0:h.charAt(0))==="/",l=this.editor.isActive("column"),m=(w=n.parent.textContent)==null?void 0:w.slice(Math.max(0,(b=n.parent.textContent)==null?void 0:b.indexOf("/"))),x=!(m!=null&&m.endsWith(" "));return(i&&e&&o||l&&e&&o)&&x},command:({editor:t,range:r,props:n})=>{const{view:i}=t;n.action({editor:t,range:r}),i.focus()},items:({query:t,editor:r})=>O(r.extensionManager.extensions,this.options.renderGroupItem).map(l=>({...l,commands:l.commands.filter(m=>{const x=m.label.toLowerCase().trim(),h=t.toLowerCase().trim();if(m.aliases){const b=m.aliases.map(C=>C.toLowerCase().trim()),w=x.match(h),y=b.some(C=>C.match(h));return w||y}return x.match(h)}).filter(m=>m.shouldBeHidden?!m.shouldBeHidden(this.editor):!0)})).filter(l=>l.commands.length>0).map(l=>({...l,commands:l.commands.map(m=>({...m,isEnabled:!0}))})),render:()=>{let t;function r(i){if(!t||!t.element)return;const e={getBoundingClientRect(){return i}};N.computePosition(e,t.element,{placement:"bottom-start"}).then(o=>{Object.assign(t.element.style,{left:`${o.x}px`,top:`${o.y}px`,position:o.strategy==="fixed"?"fixed":"absolute"})})}const n=()=>{t&&(document.body.contains(t.element)&&document.body.removeChild(t.element),t.destroy())};return{onStart:i=>{n(),t=new N.ReactRenderer(j,{props:{...i,onClose:n},editor:i.editor}),document.body.appendChild(t.element),r(i.clientRect())},onUpdate(i){t.updateProps(i),r(i.clientRect())},onKeyDown(i){var e;return i.event.key==="Escape"?(document.body.removeChild(t.element),t.destroy(),!0):(e=t.ref)==null?void 0:e.onKeyDown(i)}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}});exports.SlashCommand=A;exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index-RfTlOzIr.cjs"),H=require("@tiptap/pm/state"),$=require("./index-BH4bc3jN.cjs"),w=require("./updatePosition-8Sdem5jb.cjs"),d=require("react/jsx-runtime"),u=require("react"),j=require("./index-DV5kbgRU.cjs"),A=require("./Icon-DUpv2cI6.cjs"),g=require("./index-Dfmm6FTT.cjs"),D=require("./store-WStcMOiW.cjs"),O=g.d([]);function v(){const[t,n]=g.x(O);return[t,n]}const P={setOpen:(t,n)=>{g.dispatchEvent(g.EVENTS.UPLOAD_VIDEO(t),n)}};function y({t}){const n=[{name:"format",title:t("editor.slash.format"),commands:[]},{name:"insert",title:t("editor.slash.insert"),commands:[]}];return[1,2,3,4,5,6].forEach(e=>{n[0].commands.push({name:`heading${e}`,label:t(`editor.heading.h${e}.tooltip`),aliases:[`h${e}`,"bt",`bt${e}`],iconName:`Heading${e}`,action:({editor:i,range:l})=>{i.chain().focus().deleteRange(l).setHeading({level:e}).run()}})}),n[0].commands.push({name:"bulletList",label:t("editor.bulletlist.tooltip"),aliases:["ul","yxlb"],iconName:"List",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleBulletList().run()}}),n[0].commands.push({name:"numberedList",label:t("editor.orderedlist.tooltip"),aliases:["ol","yxlb"],iconName:"ListOrdered",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleOrderedList().run()}}),n[0].commands.push({name:"taskList",label:t("editor.tasklist.tooltip"),iconName:"ListTodo",description:"Task list with todo items",aliases:["todo"],action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).toggleTaskList().run()}}),n[0].commands.push({name:"blockquote",label:t("editor.blockquote.tooltip"),description:"插入引入格式",aliases:["yr"],iconName:"TextQuote",action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setBlockquote().run()}}),n[0].commands.push({name:"codeBlock",label:t("editor.codeblock.tooltip"),iconName:"Code2",description:"Code block with syntax highlighting",shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setCodeBlock().run()}}),n[1].commands.push({name:"image",label:t("editor.image.tooltip"),iconName:"ImageUp",description:"Insert a image",aliases:["image","tp","tupian"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).run(),D.actionDialogImage.setOpen(e.id,!0)}}),n[1].commands.push({name:"video",label:t("editor.video.tooltip"),iconName:"Video",description:"Insert a video",aliases:["video","sp","shipin"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).run(),P.setOpen(e.id,!0)}}),n[1].commands.push({name:"table",label:t("editor.table.tooltip"),iconName:"Table",description:"Insert a table",aliases:["table","bg","biaoge","biao"],shouldBeHidden:e=>e.isActive("columns"),action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).insertTable({rows:3,cols:3,withHeaderRow:!1}).run()}}),n[1].commands.push({name:"horizontalRule",label:t("editor.horizontalrule.tooltip"),iconName:"Minus",description:"Insert a horizontal divider",aliases:["hr","fgx","fg"],action:({editor:e,range:i})=>{e.chain().focus().deleteRange(i).setHorizontalRule().run()}}),n[1].commands.push({name:"columns",label:t("editor.columns.tooltip"),iconName:"Columns2",description:"Add two column content",action:({editor:e})=>{e.chain().focus().insertColumns({cols:2}).run()}}),n}function N(t,n){return t.map(l=>({...l,commands:l.commands.filter(s=>{const x=s.label.toLowerCase().trim(),m=n.toLowerCase().trim();if(s.aliases){const p=s.aliases.map(h=>h.toLowerCase().trim()),a=x.match(m),f=p.some(h=>h.match(m));return a||f}return x.match(m)})})).filter(l=>l.commands.length>0)}function V(t,n){const[e]=v(),[i,l]=u.useState(0),[s,x]=u.useState(0),m=u.useRef(null),{t:p}=g.useLocale(),a=N(e,t.query),f=u.useRef([]);u.useImperativeHandle(n,()=>({onKeyDown:h})),u.useEffect(()=>{if(!m.current)return;const r=s*1e3+i,o=f.current[r];o&&o.scrollIntoView({behavior:"smooth",block:"nearest"})},[i,s]);function h({event:r}){return r.key==="ArrowUp"?(R(),!0):r.key==="ArrowDown"?(L(),!0):r.key==="Enter"?(k(),!0):!1}function R(){var c;if(a.length===0)return!1;let r=i-1,o=s;r<0&&(o=s-1,r=((c=a[o])==null?void 0:c.commands.length)-1||0),o<0&&(o=a.length-1,r=a[o].commands.length-1),l(r),x(o)}function L(){if(a.length===0)return!1;const r=a[s].commands;let o=i+1,c=s;r.length-1<o&&(o=0,c=s+1),a.length-1<c&&(c=0),l(o),x(c)}function k(){if(a.length===0||s===-1||i===-1)return!1;C(s,i)}function C(r,o){const c=a[r].commands[o];t==null||t.command(c)}function I(r,o){C(r,o)}function S(r,o,c){f.current[r*1e3+o]=c}return d.jsx("div",{className:"richtext-max-h-[min(80vh,24rem)] richtext-flex-wrap richtext-overflow-y-auto richtext-overflow-x-hidden richtext-rounded-md !richtext-border !richtext-border-solid !richtext-border-[hsl(var(--richtext-border))] richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none",ref:m,children:a!=null&&a.length?d.jsx("div",{className:"richtext-grid richtext-min-w-48 richtext-grid-cols-1 richtext-gap-0.5",children:a==null?void 0:a.map((r,o)=>d.jsxs(u.Fragment,{children:[d.jsx("div",{className:"richtext-col-[1/-1] richtext-mx-2 richtext-mt-2 richtext-select-none richtext-text-[0.65rem] richtext-font-semibold richtext-uppercase richtext-tracking-wider !richtext-text-neutral-500 first:richtext-mt-0.5",children:r.title}),r.commands.map((c,b)=>d.jsxs("button",{onClick:()=>I(o,b),ref:q=>S(o,b,q),className:j.cn("richtext-flex richtext-items-center richtext-gap-3 richtext-px-2 richtext-py-1.5 richtext-text-sm !richtext-text-neutral-800 dark:!richtext-text-neutral-200 richtext-text-left richtext-w-full richtext-rounded-sm !richtext-outline-none !richtext-border-none richtext-transition-colors !richtext-bg-transparent hover:!richtext-bg-accent ",{"bg-item-active":s===o&&i===b}),children:[c.iconUrl&&d.jsx("img",{alt:"",className:"richtext-size-6",src:c.iconUrl}),c.iconName&&d.jsx(A.IconComponent,{className:"!richtext-mr-1 !richtext-text-lg",name:c.iconName}),c.label]},`command-${b}`))]},`slash-${r.title}`))}):d.jsx("div",{className:"richtext-p-3",children:d.jsx("span",{className:"richtext-text-xs richtext-text-gray-800 dark:richtext-text-gray-100",children:p("editor.slash.empty")})})})}const B=u.forwardRef(V);function T({commandList:t}){const[,n]=v(),{t:e}=g.useLocale();return u.useEffect(()=>{if(!(t!=null&&t.length)){const i=y({t:e});n(i);return}n(t)},[e,t]),d.jsx(d.Fragment,{})}const z=E.Extension.create({name:"richtextSlashCommand",priority:200,addProseMirrorPlugins(){return[w.Suggestion({editor:this.editor,char:"/",allowSpaces:!0,startOfLine:!0,pluginKey:new H.PluginKey(`richtextCustomPlugin${this.name}`),allow:({state:t,range:n})=>{var a,f,h;const e=t.doc.resolve(n.from),i=e.depth===1,l=e.parent.type.name==="paragraph",s=((a=e.parent.textContent)==null?void 0:a.charAt(0))==="/",x=this.editor.isActive("column"),m=(h=e.parent.textContent)==null?void 0:h.slice(Math.max(0,(f=e.parent.textContent)==null?void 0:f.indexOf("/"))),p=!(m!=null&&m.endsWith(" "));return(i&&l&&s||x&&l&&s)&&p},command:({editor:t,range:n,props:e})=>{const{view:i}=t;e.action({editor:t,range:n}),i.focus()},render:()=>{let t;return{onStart:n=>{n.clientRect&&(t=new $.ReactRenderer(B,{props:n,editor:n.editor}),t.element.style.position="absolute",document.body.appendChild(t.element),w.updatePosition(n.editor,t.element))},onUpdate(n){t.updateProps(n),n.clientRect&&w.updatePosition(n.editor,t.element)},onKeyDown(n){var e;return n.event.key==="Escape"?(t.destroy(),t.element.remove(),!0):(e=t.ref)==null?void 0:e.onKeyDown(n)},onExit(){t.destroy(),t.element.remove()}}}})]},addStorage(){return{rect:{width:0,height:0,left:0,top:0,right:0,bottom:0}}}});exports.SlashCommand=z;exports.SlashCommandList=T;exports.renderCommandListDefault=y;exports.useFilterCommandList=N;