reactjs-tiptap-editor 0.4.1 → 1.0.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 (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 +43 -55
  5. package/lib/Attachment.d.ts +43 -55
  6. package/lib/Attachment.js +129 -99
  7. package/lib/Blockquote.cjs +3 -3
  8. package/lib/Blockquote.d.cts +43 -55
  9. package/lib/Blockquote.d.ts +43 -55
  10. package/lib/Blockquote.js +50 -22
  11. package/lib/Bold.cjs +1 -1
  12. package/lib/Bold.d.cts +43 -55
  13. package/lib/Bold.d.ts +43 -55
  14. package/lib/Bold.js +48 -20
  15. package/lib/BulletList.cjs +1 -1
  16. package/lib/BulletList.d.cts +43 -55
  17. package/lib/BulletList.d.ts +43 -55
  18. package/lib/BulletList.js +38 -9
  19. package/lib/Clear.cjs +1 -1
  20. package/lib/Clear.d.cts +43 -55
  21. package/lib/Clear.d.ts +43 -55
  22. package/lib/Clear.js +32 -6
  23. package/lib/Code.cjs +1 -1
  24. package/lib/Code.d.cts +43 -55
  25. package/lib/Code.d.ts +43 -55
  26. package/lib/Code.js +53 -25
  27. package/lib/CodeBlock.cjs +35 -35
  28. package/lib/CodeBlock.d.cts +43 -55
  29. package/lib/CodeBlock.d.ts +43 -55
  30. package/lib/CodeBlock.js +605 -590
  31. package/lib/CodeView.cjs +1 -1
  32. package/lib/CodeView.d.cts +44 -56
  33. package/lib/CodeView.d.ts +44 -56
  34. package/lib/CodeView.js +49 -21
  35. package/lib/Color.cjs +1 -1
  36. package/lib/Color.d.cts +47 -55
  37. package/lib/Color.d.ts +47 -55
  38. package/lib/Color.js +123 -79
  39. package/lib/Column.cjs +1 -0
  40. package/lib/{Document.d.cts → Column.d.cts} +49 -58
  41. package/lib/{Document.d.ts → Column.d.ts} +49 -58
  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 +43 -55
  47. package/lib/Drawer.d.ts +43 -55
  48. package/lib/Drawer.js +6 -5
  49. package/lib/Emoji.cjs +1 -1
  50. package/lib/Emoji.d.cts +43 -60
  51. package/lib/Emoji.d.ts +43 -60
  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 +43 -55
  57. package/lib/Excalidraw.d.ts +43 -55
  58. package/lib/Excalidraw.js +6 -4
  59. package/lib/ExportPdf.cjs +5 -5
  60. package/lib/ExportPdf.d.cts +43 -55
  61. package/lib/ExportPdf.d.ts +43 -55
  62. package/lib/ExportPdf.js +60 -32
  63. package/lib/ExportWord.cjs +1 -1
  64. package/lib/ExportWord.d.cts +44 -56
  65. package/lib/ExportWord.d.ts +44 -56
  66. package/lib/ExportWord.js +84 -21
  67. package/lib/FontFamily.cjs +1 -1
  68. package/lib/FontFamily.d.cts +57 -58
  69. package/lib/FontFamily.d.ts +57 -58
  70. package/lib/FontFamily.js +72 -74
  71. package/lib/FontSize.cjs +1 -1
  72. package/lib/FontSize.d.cts +54 -58
  73. package/lib/FontSize.d.ts +54 -58
  74. package/lib/FontSize.js +72 -64
  75. package/lib/Heading.cjs +1 -1
  76. package/lib/Heading.d.cts +57 -55
  77. package/lib/Heading.d.ts +57 -55
  78. package/lib/Heading.js +91 -73
  79. package/lib/Highlight.cjs +1 -1
  80. package/lib/Highlight.d.cts +47 -55
  81. package/lib/Highlight.d.ts +47 -55
  82. package/lib/Highlight.js +152 -21
  83. package/lib/History.cjs +1 -1
  84. package/lib/History.d.cts +45 -55
  85. package/lib/History.d.ts +45 -55
  86. package/lib/History.js +976 -53
  87. package/lib/HorizontalRule.cjs +1 -1
  88. package/lib/HorizontalRule.d.cts +43 -55
  89. package/lib/HorizontalRule.d.ts +43 -55
  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 +42 -61
  97. package/lib/Iframe.d.ts +42 -61
  98. package/lib/Iframe.js +6 -4
  99. package/lib/Image.cjs +1 -1
  100. package/lib/Image.d.cts +43 -56
  101. package/lib/Image.d.ts +43 -56
  102. package/lib/Image.js +848 -5
  103. package/lib/ImageGif.cjs +1 -1
  104. package/lib/ImageGif.d.cts +44 -58
  105. package/lib/ImageGif.d.ts +44 -58
  106. package/lib/ImageGif.js +424 -5
  107. package/lib/ImportWord.cjs +48 -48
  108. package/lib/ImportWord.d.cts +44 -56
  109. package/lib/ImportWord.d.ts +44 -56
  110. package/lib/ImportWord.js +2596 -2588
  111. package/lib/Indent.cjs +1 -1
  112. package/lib/Indent.d.cts +43 -55
  113. package/lib/Indent.d.ts +43 -55
  114. package/lib/Indent.js +97 -27
  115. package/lib/Italic.cjs +1 -1
  116. package/lib/Italic.d.cts +43 -55
  117. package/lib/Italic.d.ts +43 -55
  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 +43 -55
  123. package/lib/Katex.d.ts +43 -55
  124. package/lib/Katex.js +5 -196
  125. package/lib/LineHeight.cjs +1 -1
  126. package/lib/LineHeight.d.cts +45 -61
  127. package/lib/LineHeight.d.ts +45 -61
  128. package/lib/LineHeight.js +71 -112
  129. package/lib/Link.cjs +1 -1
  130. package/lib/Link.d.cts +44 -58
  131. package/lib/Link.d.ts +44 -58
  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 +40 -55
  137. package/lib/Mention.d.ts +40 -55
  138. package/lib/Mention.js +114 -130
  139. package/lib/Mermaid.cjs +2 -2
  140. package/lib/Mermaid.d.cts +43 -55
  141. package/lib/Mermaid.d.ts +43 -55
  142. package/lib/Mermaid.js +177 -165
  143. package/lib/MoreMark.cjs +1 -1
  144. package/lib/MoreMark.d.cts +58 -57
  145. package/lib/MoreMark.d.ts +58 -57
  146. package/lib/MoreMark.js +125 -55
  147. package/lib/OrderedList.cjs +1 -1
  148. package/lib/OrderedList.d.cts +43 -55
  149. package/lib/OrderedList.d.ts +43 -55
  150. package/lib/OrderedList.js +37 -9
  151. package/lib/SearchAndReplace.cjs +1 -1
  152. package/lib/SearchAndReplace.d.cts +43 -58
  153. package/lib/SearchAndReplace.d.ts +43 -58
  154. package/lib/SearchAndReplace.js +221 -197
  155. package/lib/SlashCommand.cjs +1 -1
  156. package/lib/SlashCommand.d.cts +55 -62
  157. package/lib/SlashCommand.d.ts +55 -62
  158. package/lib/SlashCommand.js +235 -249
  159. package/lib/Strike.cjs +1 -1
  160. package/lib/Strike.d.cts +43 -55
  161. package/lib/Strike.d.ts +43 -55
  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 +44 -58
  167. package/lib/Table.d.ts +44 -58
  168. package/lib/Table.js +3 -558
  169. package/lib/TaskList.cjs +1 -1
  170. package/lib/TaskList.d.cts +43 -55
  171. package/lib/TaskList.d.ts +43 -55
  172. package/lib/TaskList.js +38 -10
  173. package/lib/TextAlign.cjs +1 -1
  174. package/lib/TextAlign.d.cts +56 -55
  175. package/lib/TextAlign.d.ts +56 -55
  176. package/lib/TextAlign.js +108 -101
  177. package/lib/TextDirection.cjs +1 -1
  178. package/lib/TextDirection.d.cts +72 -55
  179. package/lib/TextDirection.d.ts +72 -55
  180. package/lib/TextDirection.js +105 -112
  181. package/lib/TextUnderline.cjs +1 -1
  182. package/lib/TextUnderline.d.cts +43 -55
  183. package/lib/TextUnderline.d.ts +43 -55
  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 +43 -55
  189. package/lib/Twitter.d.ts +43 -55
  190. package/lib/Twitter.js +5 -4
  191. package/lib/Video.cjs +1 -1
  192. package/lib/Video.d.cts +43 -55
  193. package/lib/Video.d.ts +43 -55
  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} +69 -70
  199. package/lib/{bubble-extra.d.ts → bubble.d.ts} +69 -70
  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 +45 -296
  235. package/lib/index.d.ts +45 -296
  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 +5421 -73
  245. package/lib/locale-bundle.d.ts +5421 -73
  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
package/lib/Mention.js CHANGED
@@ -1,73 +1,77 @@
1
- import { c as f, g as p, a as L, b as M } from "./dom-dataset-lYeH6gfI.js";
2
- import { N as v, s as w, u as H, m as c, a as S } from "./index-kbO3iWqL.js";
3
- import { S as C } from "./index-J3jHHZ4d.js";
1
+ import { N as w, y as v, m as c } from "./index-DnWWK9F_.js";
2
+ import { Node as T } from "@tiptap/pm/model";
3
+ import { S as L, u as g } from "./updatePosition-BPmcE0YD.js";
4
+ import { PluginKey as M } from "@tiptap/pm/state";
5
+ import { a as S } from "./index-DzcKxutn.js";
4
6
  import { jsx as m } from "react/jsx-runtime";
5
- import { forwardRef as A, useRef as x, useState as U, useEffect as b, useImperativeHandle as _ } from "react";
6
- import N from "scroll-into-view-if-needed";
7
- function $({
7
+ import { forwardRef as H, useRef as A, useState as C, useEffect as f, useImperativeHandle as N } from "react";
8
+ import { c as p } from "./clsx-OuTLNxxd.js";
9
+ import $ from "scroll-into-view-if-needed";
10
+ import { g as x } from "./dom-dataset-CIEeltF6.js";
11
+ function k({
8
12
  editor: e,
9
- overrideSuggestionOptions: r,
10
- extensionName: n,
11
- char: t = "@"
13
+ overrideSuggestionOptions: t,
14
+ extensionName: r,
15
+ char: n = "@"
12
16
  }) {
13
- const s = new S();
17
+ const i = new M();
14
18
  return {
15
19
  editor: e,
16
- char: t,
17
- pluginKey: s,
18
- command: ({ editor: i, range: a, props: d }) => {
19
- var u, o, l;
20
- const h = i.view.state.selection.$to.nodeAfter;
21
- ((u = h == null ? void 0 : h.text) == null ? void 0 : u.startsWith(" ")) && (a.to += 1), i.chain().focus().insertContentAt(a, [
20
+ char: n,
21
+ pluginKey: i,
22
+ command: ({ editor: s, range: a, props: l }) => {
23
+ var u, o, d;
24
+ const h = s.view.state.selection.$to.nodeAfter;
25
+ ((u = h == null ? void 0 : h.text) == null ? void 0 : u.startsWith(" ")) && (a.to += 1), s.chain().focus().insertContentAt(a, [
22
26
  {
23
- type: n,
24
- attrs: { ...d, mentionSuggestionChar: t }
27
+ type: r,
28
+ attrs: { ...l, mentionSuggestionChar: n }
25
29
  },
26
30
  {
27
31
  type: "text",
28
32
  text: " "
29
33
  }
30
- ]).run(), (l = (o = i.view.dom.ownerDocument.defaultView) == null ? void 0 : o.getSelection()) == null || l.collapseToEnd();
34
+ ]).run(), (d = (o = s.view.dom.ownerDocument.defaultView) == null ? void 0 : o.getSelection()) == null || d.collapseToEnd();
31
35
  },
32
- allow: ({ state: i, range: a }) => {
33
- const d = i.doc.resolve(a.from), u = i.schema.nodes[n];
34
- return !!d.parent.type.contentMatch.matchType(u);
36
+ allow: ({ state: s, range: a }) => {
37
+ const l = s.doc.resolve(a.from), u = s.schema.nodes[r];
38
+ return !!l.parent.type.contentMatch.matchType(u);
35
39
  },
36
- ...r
40
+ ...t
37
41
  };
38
42
  }
39
- function T(e) {
43
+ function y(e) {
40
44
  return (e.options.suggestions.length ? e.options.suggestions : [e.options.suggestion]).map(
41
- (r) => $({
45
+ (t) => k({
42
46
  // @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
43
47
  editor: e.editor,
44
- overrideSuggestionOptions: r,
48
+ overrideSuggestionOptions: t,
45
49
  extensionName: e.name,
46
- char: r.char
50
+ char: t.char
47
51
  })
48
52
  );
49
53
  }
50
- function y(e, r) {
51
- const n = T(e), t = n.find((s) => s.char === r);
52
- return t || (n.length ? n[0] : null);
54
+ function b(e, t) {
55
+ const r = y(e), n = r.find((i) => i.char === t);
56
+ return n || (r.length ? r[0] : null);
53
57
  }
54
- var k = v.create({
58
+ var D = w.create({
55
59
  name: "mention",
56
60
  priority: 101,
57
61
  addOptions() {
58
62
  return {
59
63
  HTMLAttributes: {},
60
- renderText({ node: e, suggestion: r }) {
61
- var n, t;
62
- return `${(n = r == null ? void 0 : r.char) != null ? n : "@"}${(t = e.attrs.label) != null ? t : e.attrs.id}`;
64
+ renderText({ node: e, suggestion: t }) {
65
+ var r, n;
66
+ return `${(r = t == null ? void 0 : t.char) != null ? r : "@"}${(n = e.attrs.label) != null ? n : e.attrs.id}`;
63
67
  },
64
68
  deleteTriggerWithBackspace: !1,
65
- renderHTML({ options: e, node: r, suggestion: n }) {
66
- var t, s;
69
+ renderHTML({ options: e, node: t, suggestion: r }) {
70
+ var n, i;
67
71
  return [
68
72
  "span",
69
73
  c(this.HTMLAttributes, e.HTMLAttributes),
70
- `${(t = n == null ? void 0 : n.char) != null ? t : "@"}${(s = r.attrs.label) != null ? s : r.attrs.id}`
74
+ `${(n = r == null ? void 0 : r.char) != null ? n : "@"}${(i = t.attrs.label) != null ? i : t.attrs.id}`
71
75
  ];
72
76
  },
73
77
  suggestions: [],
@@ -111,100 +115,106 @@ var k = v.create({
111
115
  }
112
116
  ];
113
117
  },
114
- renderHTML({ node: e, HTMLAttributes: r }) {
115
- const n = y(this, e.attrs.mentionSuggestionChar);
118
+ renderHTML({ node: e, HTMLAttributes: t }) {
119
+ const r = b(this, e.attrs.mentionSuggestionChar);
116
120
  if (this.options.renderLabel !== void 0)
117
121
  return console.warn("renderLabel is deprecated use renderText and renderHTML instead"), [
118
122
  "span",
119
- c({ "data-type": this.name }, this.options.HTMLAttributes, r),
123
+ c({ "data-type": this.name }, this.options.HTMLAttributes, t),
120
124
  this.options.renderLabel({
121
125
  options: this.options,
122
126
  node: e,
123
- suggestion: n
127
+ suggestion: r
124
128
  })
125
129
  ];
126
- const t = { ...this.options };
127
- t.HTMLAttributes = c(
130
+ const n = { ...this.options };
131
+ n.HTMLAttributes = c(
128
132
  { "data-type": this.name },
129
133
  this.options.HTMLAttributes,
130
- r
134
+ t
131
135
  );
132
- const s = this.options.renderHTML({
133
- options: t,
136
+ const i = this.options.renderHTML({
137
+ options: n,
134
138
  node: e,
135
- suggestion: n
139
+ suggestion: r
136
140
  });
137
- return typeof s == "string" ? ["span", c({ "data-type": this.name }, this.options.HTMLAttributes, r), s] : s;
141
+ return typeof i == "string" ? ["span", c({ "data-type": this.name }, this.options.HTMLAttributes, t), i] : i;
138
142
  },
139
- ...w({
143
+ ...v({
140
144
  nodeName: "mention",
141
145
  name: "@",
142
146
  selfClosing: !0,
143
- allowedAttributes: ["id", "label"]
147
+ allowedAttributes: ["id", "label", { name: "mentionSuggestionChar", skipIfDefault: "@" }],
148
+ parseAttributes: (e) => {
149
+ const t = {}, r = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
150
+ let n = r.exec(e);
151
+ for (; n !== null; ) {
152
+ const [, i, s, a] = n, l = s ?? a;
153
+ t[i === "char" ? "mentionSuggestionChar" : i] = l, n = r.exec(e);
154
+ }
155
+ return t;
156
+ },
157
+ serializeAttributes: (e) => Object.entries(e).filter(([, t]) => t != null).map(([t, r]) => `${t === "mentionSuggestionChar" ? "char" : t}="${r}"`).join(" ")
144
158
  }),
145
159
  renderText({ node: e }) {
146
- const r = {
160
+ const t = {
147
161
  options: this.options,
148
162
  node: e,
149
- suggestion: y(this, e.attrs.mentionSuggestionChar)
163
+ suggestion: b(this, e.attrs.mentionSuggestionChar)
150
164
  };
151
- return this.options.renderLabel !== void 0 ? (console.warn("renderLabel is deprecated use renderText and renderHTML instead"), this.options.renderLabel(r)) : this.options.renderText(r);
165
+ return this.options.renderLabel !== void 0 ? (console.warn("renderLabel is deprecated use renderText and renderHTML instead"), this.options.renderLabel(t)) : this.options.renderText(t);
152
166
  },
153
167
  addKeyboardShortcuts() {
154
168
  return {
155
- Backspace: () => this.editor.commands.command(({ tr: e, state: r }) => {
156
- let n = !1;
157
- const { selection: t } = r, { empty: s, anchor: i } = t;
158
- if (!s)
169
+ Backspace: () => this.editor.commands.command(({ tr: e, state: t }) => {
170
+ let r = !1;
171
+ const { selection: n } = t, { empty: i, anchor: s } = n;
172
+ if (!i)
159
173
  return !1;
160
- let a = new H(), d = 0;
161
- return r.doc.nodesBetween(i - 1, i, (u, o) => {
174
+ let a = new T(), l = 0;
175
+ return t.doc.nodesBetween(s - 1, s, (u, o) => {
162
176
  if (u.type.name === this.name)
163
- return n = !0, a = u, d = o, !1;
164
- }), n && e.insertText(
177
+ return r = !0, a = u, l = o, !1;
178
+ }), r && e.insertText(
165
179
  this.options.deleteTriggerWithBackspace ? "" : a.attrs.mentionSuggestionChar,
166
- d,
167
- d + a.nodeSize
168
- ), n;
180
+ l,
181
+ l + a.nodeSize
182
+ ), r;
169
183
  })
170
184
  };
171
185
  },
172
186
  addProseMirrorPlugins() {
173
- return T(this).map(C);
187
+ return y(this).map(L);
174
188
  }
175
- }), E = k;
176
- const D = "_listUsers_en3pm_1", R = "_itemUser_en3pm_10", K = "_selectedUser_en3pm_31", g = {
177
- listUsers: D,
178
- itemUser: R,
179
- selectedUser: K
180
- }, B = A((e, r) => {
181
- const n = x(null), [t, s] = U(0), i = (o) => {
182
- const l = e.items[o];
183
- l && (e.command({ id: l, label: l }), e != null && e.onClose && (e == null || e.onClose()));
189
+ }), K = D;
190
+ const _ = H((e, t) => {
191
+ const r = A(null), [n, i] = C(0), s = (o) => {
192
+ const d = e.items[o];
193
+ d && e.command({ id: d, label: d });
184
194
  }, a = () => {
185
- s((t + e.items.length - 1) % e.items.length);
186
- }, d = () => {
187
- s((t + 1) % e.items.length);
195
+ i((n + e.items.length - 1) % e.items.length);
196
+ }, l = () => {
197
+ i((n + 1) % e.items.length);
188
198
  }, u = () => {
189
- i(t);
199
+ s(n);
190
200
  };
191
- return b(() => s(0), [e.items]), b(() => {
192
- if (Number.isNaN(t + 1))
201
+ return f(() => i(0), [e.items]), f(() => {
202
+ if (Number.isNaN(n + 1))
193
203
  return;
194
- const o = n.current.querySelector(`span:nth-of-type(${t + 1})`);
195
- o && N(o, { behavior: "smooth", scrollMode: "if-needed" });
196
- }, [t]), _(r, () => ({
197
- onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a(), !0) : o.key === "ArrowDown" ? (d(), !0) : o.key === "Enter" ? (u(), !0) : !1
198
- })), /* @__PURE__ */ m("div", { className: f("listUsers", g.listUsers), children: /* @__PURE__ */ m("div", { ref: n, children: e.items.length > 0 ? e.items.map((o, l) => /* @__PURE__ */ m(
204
+ const o = r.current.querySelector(`span:nth-of-type(${n + 1})`);
205
+ o && $(o, { behavior: "smooth", scrollMode: "if-needed" });
206
+ }, [n]), N(t, () => ({
207
+ onKeyDown: ({ event: o }) => o.key === "ArrowUp" ? (a(), !0) : o.key === "ArrowDown" ? (l(), !0) : o.key === "Enter" ? (u(), !0) : !1
208
+ })), /* @__PURE__ */ m("div", { className: " !richtext-max-h-[320px] !richtext-w-[160px] 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", children: /* @__PURE__ */ m("div", { ref: r, children: e.items.length > 0 ? e.items.map((o, d) => /* @__PURE__ */ m(
199
209
  "span",
200
210
  {
201
- className: f("itemUser", g.itemUser, l === t ? g.selectedUser : ""),
202
- onClick: () => i(l),
211
+ className: p("richtext-flex richtext-w-full richtext-items-center richtext-gap-3 richtext-rounded-sm !richtext-border-none !richtext-bg-transparent richtext-px-2 richtext-py-1.5 richtext-text-left richtext-text-sm !richtext-text-neutral-800 !richtext-outline-none richtext-transition-colors hover:!richtext-bg-accent dark:!richtext-text-neutral-200", { "bg-item-active": d === n }),
212
+ onClick: () => s(d),
203
213
  children: o
204
214
  },
205
- l
206
- )) : /* @__PURE__ */ m("div", { className: f("itemUserEmpty", g.itemUser), children: "Empty" }) }) });
207
- }), I = [
215
+ d
216
+ )) : /* @__PURE__ */ m("div", { className: p("itemUserEmpty"), children: "Empty" }) }) });
217
+ }), E = [
208
218
  {
209
219
  id: "1",
210
220
  name: "John Doe"
@@ -221,16 +231,16 @@ const D = "_listUsers_en3pm_1", R = "_itemUser_en3pm_10", K = "_selectedUser_en3
221
231
  id: "4",
222
232
  name: "Bob"
223
233
  }
224
- ], z = /* @__PURE__ */ E.extend({
234
+ ], Q = /* @__PURE__ */ K.extend({
225
235
  addAttributes() {
226
236
  return {
227
237
  id: {
228
238
  default: "",
229
- parseHTML: p("id")
239
+ parseHTML: x("id")
230
240
  },
231
241
  label: {
232
242
  default: "",
233
- parseHTML: p("label")
243
+ parseHTML: x("label")
234
244
  }
235
245
  };
236
246
  }
@@ -239,56 +249,30 @@ const D = "_listUsers_en3pm_1", R = "_itemUser_en3pm_10", K = "_selectedUser_en3
239
249
  class: "mention"
240
250
  },
241
251
  suggestion: {
242
- items: async ({ query: e }) => I.map((n) => n.name).filter((n) => n.toLowerCase().startsWith(e.toLowerCase())),
252
+ items: async ({ query: e }) => E.map((r) => r.name).filter((r) => r.toLowerCase().startsWith(e.toLowerCase())),
243
253
  render: () => {
244
254
  let e;
245
- function r(t) {
246
- if (!e || !e.element)
247
- return;
248
- M({
249
- getBoundingClientRect() {
250
- return t;
251
- }
252
- }, e.element, {
253
- placement: "bottom-start"
254
- }).then((i) => {
255
- Object.assign(e.element.style, {
256
- left: `${i.x}px`,
257
- top: `${i.y}px`,
258
- position: i.strategy === "fixed" ? "fixed" : "absolute"
259
- });
260
- });
261
- }
262
- const n = () => {
263
- e && (document.body.contains(e.element) && document.body.removeChild(e.element), e.destroy());
264
- };
265
255
  return {
266
256
  onStart: (t) => {
267
- n(), e = new L(B, {
268
- props: {
269
- ...t,
270
- onClose: n
271
- },
257
+ t.clientRect && (e = new S(_, {
258
+ props: t,
272
259
  editor: t.editor
273
- }), document.body.appendChild(e.element), r(t.clientRect());
260
+ }), e.element.style.position = "absolute", document.body.appendChild(e.element), g(t.editor, e.element));
274
261
  },
275
262
  onUpdate(t) {
276
- e.updateProps(t), r(t.clientRect());
263
+ e.updateProps(t), t.clientRect && g(t.editor, e.element);
277
264
  },
278
265
  onKeyDown(t) {
279
- var s;
280
- return t.event.key === "Escape" ? (document.body.removeChild(e.element), e.destroy(), !0) : (s = e.ref) == null ? void 0 : s.onKeyDown(t);
266
+ var r;
267
+ return t.event.key === "Escape" ? (e.destroy(), e.element.remove(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
268
+ },
269
+ onExit() {
270
+ e.destroy(), e.element.remove();
281
271
  }
282
- // onExit() {
283
- // if (document.body.contains(component.element)) {
284
- // document.body.removeChild(component.element);
285
- // }
286
- // component.destroy();
287
- // },
288
272
  };
289
273
  }
290
274
  }
291
275
  });
292
276
  export {
293
- z as Mention
277
+ Q as Mention
294
278
  };
package/lib/Mermaid.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var W=Object.create;var G=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var J=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of U(e))!Y.call(t,c)&&c!==i&&G(t,c,{get:()=>e[c],enumerable:!(r=X(e,c))||r.enumerable});return t};var K=(t,e,i)=>(i=t!=null?W(Z(t)):{},J(e||!t||!t.__esModule?G(i,"default",{value:t,enumerable:!0}):i,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./index-DF2Lp4HZ.cjs"),u=require("./RichTextEditor-CxvwGvQG.cjs"),F=require("./dom-dataset-_6-diIRQ.cjs"),o=require("react/jsx-runtime"),a=require("react"),P=require("./shortId-Bfj8TyNr.cjs"),Q=require("./textarea-DFo_aXnj.cjs"),E=require("./index-6D1J-A-o.cjs"),$=`graph TB
2
- a-->b`,ee=({editor:t,upload:e,tooltipOptions:i})=>{const[r,c]=a.useState($),[y,L]=a.useState(""),[p,I]=a.useState(!1),v=a.useRef(null),[l,N]=a.useState(null),C=a.useCallback(d=>{d&&import("mermaid").then(M=>{N(M.default)})},[]),S=async d=>{try{const{svg:M}=await l.render("mermaid-svg",d);L(M)}catch{L("")}},H=()=>{l.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),S(r)};a.useEffect(()=>{l&&p&&H()},[l,p]),a.useEffect(()=>{l&&p&&S(r)},[l&&r]);const x=async()=>{if(r!==""){if(r){const d=v.current.querySelector("svg"),{width:M,height:A}=d.getBoundingClientRect(),O=`mermaid-${P.shortId()}.svg`;let T=P.i(d.outerHTML);if(e){console.log({src:T});const _=u.dataURLtoFile(T,O);T=await e(_)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:T,alt:encodeURIComponent(r),width:M,height:A},!!r).run()}I(!1)}};return o.jsxs(u.Dialog,{onOpenChange:I,open:p,children:[o.jsx(u.DialogTrigger,{asChild:!0,children:o.jsx(u.ActionButton,{action:()=>I(!0),icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:i})}),o.jsxs(u.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(u.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:C,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(Q.Textarea,{autoFocus:!0,className:"richtext-flex-1",defaultValue:$,onChange:d=>c(d.target.value),placeholder:"Text",required:!0,rows:10,value:r,style:{color:"hsl(var(--richtext-foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:y},ref:v,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),o.jsx(u.DialogFooter,{children:o.jsx(u.Button,{onClick:x,type:"button",children:"Save changes"})})]})]})},j={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({editor:t,node:e,updateAttributes:i,getPos:r,selected:c}){const[y,L]=a.useState({width:E.IMAGE_MAX_SIZE,height:E.IMAGE_MAX_SIZE}),[p,I]=a.useState({width:0,height:0}),[v]=a.useState([j.TOP_LEFT,j.TOP_RIGHT,j.BOTTOM_LEFT,j.BOTTOM_RIGHT]),[l,N]=a.useState(!1),[C,S]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:H}=e==null?void 0:e.attrs,x=a.useMemo(()=>{const{src:s,alt:g,width:m,height:b}=e==null?void 0:e.attrs,w=q.isNumber(m)?`${m}px`:m,n=q.isNumber(b)?`${b}px`:b;return{src:s||void 0,alt:g||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),d=a.useMemo(()=>{const{style:{width:s}}=x;return{width:s==="100%"?s:void 0}},[x]);function M(s){I({width:s.target.width,height:s.target.height})}function A(){t.commands.setNodeSelection(r())}const O=a.useCallback(u.throttle(()=>{const{width:s}=getComputedStyle(t.view.dom);L(g=>({...g,width:Number.parseInt(s,10)}))},E.IMAGE_THROTTLE_WAIT_TIME),[t]);function T(s,g){s.preventDefault(),s.stopPropagation();const m=p.width,b=p.height,w=m/b;let n=Number(e.attrs.width),f=Number(e.attrs.height);const h=y.width;n&&!f?(n=n>h?h:n,f=Math.round(n/w)):f&&!n?(n=Math.round(f*w),n=n>h?h:n):!n&&!f?(n=m>h?h:m,f=Math.round(n/w)):n=n>h?h:n,N(!0),S({x:s.clientX,y:s.clientY,w:n,h:f,dir:g})}const _=a.useCallback(u.throttle(s=>{if(s.preventDefault(),s.stopPropagation(),!l)return;const{x:g,w:m,dir:b}=C,w=(s.clientX-g)*(/l/.test(b)?-1:1),{width:n,height:f}=e==null?void 0:e.attrs,h=n/f,B=u.clamp(m+w,E.IMAGE_MIN_SIZE,y.width),V=Math.round(B/h);i({width:B,height:V})},E.IMAGE_THROTTLE_WAIT_TIME),[l,C,y,i,e==null?void 0:e.attrs]),R=a.useCallback(s=>{s.preventDefault(),s.stopPropagation(),l&&(S({x:0,y:0,w:0,h:0,dir:""}),N(!1),A())},[l,A]),D=a.useCallback(()=>{document==null||document.addEventListener("mousemove",_,!0),document==null||document.addEventListener("mouseup",R,!0)},[_,R]),z=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",_,!0),document==null||document.removeEventListener("mouseup",R,!0)},[_,R]);a.useEffect(()=>(l?D():z(),()=>{z()}),[l,D,z]);const k=a.useMemo(()=>new ResizeObserver(()=>O()),[O]);return a.useEffect(()=>(k.observe(t.view.dom),()=>{k.disconnect()}),[t.view.dom,k]),o.jsx(F.NodeViewWrapper,{className:"image-view",style:{...d,width:"100%",textAlign:H},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...d,background:"#fff"},className:`image-view__body ${c?"image-view__body--focused":""} ${l?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:x.alt,className:"image-view__body__image block",height:"auto",onClick:A,onLoad:M,src:x.src,style:x.style}),t.view.editable&&(c||l)&&o.jsx("div",{className:"image-resizer",children:v==null?void 0:v.map(s=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${s}`,onMouseDown:g=>T(g,s)},`image-dir-${s}`))})]})})}const re=u.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:i,extension:r})=>{var c;return{component:ee,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:i("editor.mermaid.tooltip"),upload:(c=r==null?void 0:r.options)==null?void 0:c.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const i=e.querySelector("img"),r=i==null?void 0:i.getAttribute("width");return r?Number.parseInt(r,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const i=e.querySelector("img"),r=i==null?void 0:i.getAttribute("height");return r?Number.parseInt(r,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return F.ReactNodeViewRenderer(te)},addCommands(){return{setMermaid:(t,e)=>({commands:i,editor:r})=>e?i.insertContent({type:this.name,attrs:t}):i.insertContentAt(r.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",q.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),i=e==null?void 0:e.getAttribute("width"),r=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:i?Number.parseInt(i,10):null,height:r?Number.parseInt(r,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=re;
1
+ "use strict";var U=Object.create;var G=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Q=(t,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of Y(e))!K.call(t,c)&&c!==r&&G(t,c,{get:()=>e[c],enumerable:!(a=Z(e,c))||a.enumerable});return t};var ee=(t,e,r)=>(r=t!=null?U(J(t)):{},Q(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("./index-RfTlOzIr.cjs"),D=require("./throttle-qX7Yjtsg.cjs"),W=require("./index-BH4bc3jN.cjs"),o=require("react/jsx-runtime"),s=require("react"),F=require("./shortId-Bfj8TyNr.cjs"),te=require("./toggle-D41PzQLJ.cjs"),E=require("./dialog-CaCS-W5S.cjs"),re=require("./textarea-B-6zTKQz.cjs"),L=require("./index-Dfmm6FTT.cjs"),P=require("./useButtonProps-C6Vpn190.cjs"),ie=require("./index-DV5kbgRU.cjs"),se=require("./file-i7e4nQY2.cjs"),ae=require("./button-B12K7BJ4.cjs"),ne=`graph TB
2
+ a-->b`;function oe(){const t=ie.useEditorInstance(),e=P.useButtonProps(V.name),{tooltipOptions:r={},isActive:a=void 0,upload:c}=(e==null?void 0:e.componentProps)??{},{editorDisabled:T}=P.useToggleActive(a),[d,N]=s.useState(ne),[q,y]=s.useState(""),[l,_]=s.useState(!1),S=s.useRef(null),[h,H]=s.useState(null),[f,C]=s.useState(!0),z=s.useCallback(u=>{u&&import("mermaid").then(g=>{H(g.default)}).finally(()=>C(!1))},[]),I=async u=>{try{const{svg:g}=await h.render("mermaid-svg",u);y(g)}catch{y("")}},O=()=>{h.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),I(d)};s.useEffect(()=>{!f&&h&&l&&O()},[h,l]),s.useEffect(()=>{!f&&h&&l&&I(d)},[h&&d]);const k=async()=>{if(d!==""){if(d){const u=S.current.querySelector("svg"),{width:g,height:R}=u.getBoundingClientRect(),A=`mermaid-${F.shortId()}.svg`;let b=F.i(u.outerHTML);if(c){const i=se.dataURLtoFile(b,A);b=await c(i)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(d),width:g,height:R},!!d).run()}_(!1)}};return o.jsxs(E.Dialog,{onOpenChange:_,open:l,children:[o.jsx(E.DialogTrigger,{asChild:!0,children:o.jsx(te.ActionButton,{disabled:T,icon:"Mermaid",tooltip:"Mermaid",tooltipOptions:r,action:()=>{T||_(!0)}})}),o.jsxs(E.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(E.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:z,style:{height:"100%",border:"1px solid hsl(var(--border))"},children:f?o.jsx("p",{children:"Loading..."}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[o.jsx(re.Textarea,{autoFocus:!0,className:"richtext-flex-1",onChange:u=>N(u.target.value),placeholder:"Text",required:!0,rows:10,value:d,style:{color:"hsl(var(--richtext-foreground))"}}),o.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:q},ref:S,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})})}),o.jsx(E.DialogFooter,{children:o.jsx(ae.Button,{disabled:!h,onClick:k,type:"button",children:"Save changes"})})]})]})}const j={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ce({editor:t,node:e,updateAttributes:r,getPos:a,selected:c}){const[T,d]=s.useState({width:L.IMAGE_MAX_SIZE,height:L.IMAGE_MAX_SIZE}),[N,q]=s.useState({width:0,height:0}),[y]=s.useState([j.TOP_LEFT,j.TOP_RIGHT,j.BOTTOM_LEFT,j.BOTTOM_RIGHT]),[l,_]=s.useState(!1),[S,h]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:H}=e==null?void 0:e.attrs,f=s.useMemo(()=>{const{src:i,alt:p,width:x,height:v}=e==null?void 0:e.attrs,w=$.isNumber(x)?`${x}px`:x,n=$.isNumber(v)?`${v}px`:v;return{src:i||void 0,alt:p||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),C=s.useMemo(()=>{const{style:{width:i}}=f;return{width:i==="100%"?i:void 0}},[f]);function z(i){q({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const O=s.useCallback(D.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);d(p=>({...p,width:Number.parseInt(i,10)}))},L.IMAGE_THROTTLE_WAIT_TIME),[t]);function k(i,p){i.preventDefault(),i.stopPropagation();const x=N.width,v=N.height,w=x/v;let n=Number(e.attrs.width),M=Number(e.attrs.height);const m=T.width;n&&!M?(n=n>m?m:n,M=Math.round(n/w)):M&&!n?(n=Math.round(M*w),n=n>m?m:n):!n&&!M?(n=x>m?m:x,M=Math.round(n/w)):n=n>m?m:n,_(!0),h({x:i.clientX,y:i.clientY,w:n,h:M,dir:p})}const u=s.useCallback(D.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!l)return;const{x:p,w:x,dir:v}=S,w=(i.clientX-p)*(/l/.test(v)?-1:1),{width:n,height:M}=e==null?void 0:e.attrs,m=n/M,B=P.clamp(x+w,L.IMAGE_MIN_SIZE,T.width),X=Math.round(B/m);r({width:B,height:X})},L.IMAGE_THROTTLE_WAIT_TIME),[l,S,T,r,e==null?void 0:e.attrs]),g=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),l&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),I())},[l,I]),R=s.useCallback(()=>{document==null||document.addEventListener("mousemove",u,!0),document==null||document.addEventListener("mouseup",g,!0)},[u,g]),A=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",u,!0),document==null||document.removeEventListener("mouseup",g,!0)},[u,g]);s.useEffect(()=>(l?R():A(),()=>{A()}),[l,R,A]);const b=s.useMemo(()=>new ResizeObserver(()=>O()),[O]);return s.useEffect(()=>(b.observe(t.view.dom),()=>{b.disconnect()}),[t.view.dom,b]),o.jsx(W.NodeViewWrapper,{className:"image-view",style:{...C,width:"100%",textAlign:H},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...C,background:"#fff"},className:`image-view__body ${c?"image-view__body--focused":""} ${l?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:z,src:f.src,style:f.style}),t.view.editable&&(c||l)&&o.jsx("div",{className:"image-resizer",children:y==null?void 0:y.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:p=>k(p,i)},`image-dir-${i}`))})]})})}const V=D.index_default.extend({name:"mermaid",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:e,t:r,extension:a})=>{var c;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(c=a==null?void 0:a.options)==null?void 0:c.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("width");return a?Number.parseInt(a,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const r=e.querySelector("img"),a=r==null?void 0:r.getAttribute("height");return a?Number.parseInt(a,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView(){return W.ReactNodeViewRenderer(ce)},addCommands(){return{setMermaid:(t,e)=>({commands:r,editor:a})=>e?r.insertContent({type:this.name,attrs:t}):r.insertContentAt(a.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageMermaid:t=>({commands:e})=>e.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:e}=t;return["div",{style:e?`text-align: ${e};`:"",class:"imageMermaid"},["img",$.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:t=>{const e=t.querySelector("img"),r=e==null?void 0:e.getAttribute("width"),a=e==null?void 0:e.getAttribute("height");return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.Mermaid=V;exports.RichTextMermaid=oe;
package/lib/Mermaid.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  import { Extension } from '@tiptap/core';
3
+ import { JSX } from 'react/jsx-runtime';
3
4
  import { Node as Node_2 } from '@tiptap/core';
4
5
 
5
6
  /**
@@ -78,6 +79,8 @@ export declare interface MermaidOptions extends GeneralOptions<MermaidOptions> {
78
79
  upload?: (file: File) => Promise<string>;
79
80
  }
80
81
 
82
+ export declare function RichTextMermaid(): JSX.Element;
83
+
81
84
  export { }
82
85
 
83
86
 
@@ -111,11 +114,22 @@ declare module '@tiptap/core' {
111
114
  }
112
115
 
113
116
 
117
+ declare module '@tiptap/core' {
118
+ interface Storage {
119
+ color: ColorStorage;
120
+ }
121
+ }
122
+
123
+
114
124
  declare module '@tiptap/core' {
115
125
  interface Commands<ReturnType> {
116
- drawer: {
117
- setDrawer: (options: any, replace?: any) => ReturnType;
118
- setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
126
+ columns: {
127
+ insertColumns: (attrs?: {
128
+ cols: number;
129
+ }) => ReturnType;
130
+ addColBefore: () => ReturnType;
131
+ addColAfter: () => ReturnType;
132
+ deleteCol: () => ReturnType;
119
133
  };
120
134
  }
121
135
  }
@@ -123,8 +137,9 @@ declare module '@tiptap/core' {
123
137
 
124
138
  declare module '@tiptap/core' {
125
139
  interface Commands<ReturnType> {
126
- excalidraw: {
127
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
140
+ drawer: {
141
+ setDrawer: (options: any, replace?: any) => ReturnType;
142
+ setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
128
143
  };
129
144
  }
130
145
  }
@@ -142,7 +157,16 @@ declare module '@tiptap/core' {
142
157
  declare module '@tiptap/core' {
143
158
  interface Commands<ReturnType> {
144
159
  exportWord: {
145
- exportToWord: () => ReturnType;
160
+ exportToWord: (docState: any) => ReturnType;
161
+ };
162
+ }
163
+ }
164
+
165
+
166
+ declare module '@tiptap/core' {
167
+ interface Commands<ReturnType> {
168
+ excalidraw: {
169
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
146
170
  };
147
171
  }
148
172
  }
@@ -167,10 +191,8 @@ declare module '@tiptap/core' {
167
191
 
168
192
 
169
193
  declare module '@tiptap/core' {
170
- interface Commands<ReturnType> {
171
- painter: {
172
- setPainter: (marks: Mark[]) => ReturnType;
173
- };
194
+ interface Storage {
195
+ highlight: HighlightStorage;
174
196
  }
175
197
  }
176
198
 
@@ -210,22 +232,6 @@ declare module '@tiptap/core' {
210
232
  }
211
233
 
212
234
 
213
- declare module '@tiptap/core' {
214
- interface Commands<ReturnType> {
215
- indent: {
216
- /**
217
- * Set the indent attribute
218
- */
219
- indent: () => ReturnType;
220
- /**
221
- * Set the outdent attribute
222
- */
223
- outdent: () => ReturnType;
224
- };
225
- }
226
- }
227
-
228
-
229
235
  declare module '@tiptap/core' {
230
236
  interface Commands<ReturnType> {
231
237
  imageGifUpload: {
@@ -248,8 +254,15 @@ declare module '@tiptap/core' {
248
254
 
249
255
  declare module '@tiptap/core' {
250
256
  interface Commands<ReturnType> {
251
- katex: {
252
- setKatex: (arg?: IKatexAttrs) => ReturnType;
257
+ indent: {
258
+ /**
259
+ * Set the indent attribute
260
+ */
261
+ indent: () => ReturnType;
262
+ /**
263
+ * Set the outdent attribute
264
+ */
265
+ outdent: () => ReturnType;
253
266
  };
254
267
  }
255
268
  }
@@ -257,9 +270,8 @@ declare module '@tiptap/core' {
257
270
 
258
271
  declare module '@tiptap/core' {
259
272
  interface Commands<ReturnType> {
260
- lineHeight: {
261
- setLineHeight: (lineHeight: string) => ReturnType;
262
- unsetLineHeight: () => ReturnType;
273
+ katex: {
274
+ setKatex: (arg?: IKatexAttrs) => ReturnType;
263
275
  };
264
276
  }
265
277
  }
@@ -275,20 +287,6 @@ declare module '@tiptap/core' {
275
287
  }
276
288
 
277
289
 
278
- declare module '@tiptap/core' {
279
- interface Commands<ReturnType> {
280
- columns: {
281
- insertColumns: (attrs?: {
282
- cols: number;
283
- }) => ReturnType;
284
- addColBefore: () => ReturnType;
285
- addColAfter: () => ReturnType;
286
- deleteCol: () => ReturnType;
287
- };
288
- }
289
- }
290
-
291
-
292
290
  declare module '@tiptap/core' {
293
291
  interface Commands<ReturnType> {
294
292
  search: {
@@ -312,16 +310,6 @@ declare module '@tiptap/core' {
312
310
  }
313
311
 
314
312
 
315
- declare module '@tiptap/core' {
316
- interface Commands<ReturnType> {
317
- tableOfContents: {
318
- setTableOfContents: () => ReturnType;
319
- removeTableOfContents: () => ReturnType;
320
- };
321
- }
322
- }
323
-
324
-
325
313
  declare module '@tiptap/core' {
326
314
  interface Commands<ReturnType> {
327
315
  twitter: {