reactjs-tiptap-editor 0.3.30 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +8 -2
  2. package/lib/{ActionMenuButton-wiDnIxE2.cjs → ActionMenuButton-CYdM1xx5.cjs} +1 -1
  3. package/lib/{ActionMenuButton-B6fitGKu.js → ActionMenuButton-DKRF6oa0.js} +5 -5
  4. package/lib/Attachment.cjs +2 -2
  5. package/lib/Attachment.d.cts +47 -51
  6. package/lib/Attachment.d.ts +47 -51
  7. package/lib/Attachment.js +7 -6
  8. package/lib/BaseKit.cjs +3 -0
  9. package/lib/BaseKit.d.cts +481 -0
  10. package/lib/BaseKit.d.ts +481 -0
  11. package/lib/BaseKit.js +132 -0
  12. package/lib/Blockquote.cjs +5 -1
  13. package/lib/Blockquote.d.cts +47 -51
  14. package/lib/Blockquote.d.ts +47 -51
  15. package/lib/Blockquote.js +33 -17
  16. package/lib/Bold.cjs +1 -1
  17. package/lib/Bold.d.cts +47 -51
  18. package/lib/Bold.d.ts +47 -51
  19. package/lib/Bold.js +23 -16
  20. package/lib/BulletList.cjs +1 -1
  21. package/lib/BulletList.d.cts +48 -52
  22. package/lib/BulletList.d.ts +48 -52
  23. package/lib/BulletList.js +11 -57
  24. package/lib/Clear.cjs +1 -1
  25. package/lib/Clear.d.cts +47 -51
  26. package/lib/Clear.d.ts +47 -51
  27. package/lib/Clear.js +4 -2
  28. package/lib/Code.cjs +1 -1
  29. package/lib/Code.d.cts +47 -51
  30. package/lib/Code.d.ts +47 -51
  31. package/lib/Code.js +29 -25
  32. package/lib/CodeBlock.cjs +2 -2
  33. package/lib/CodeBlock.d.cts +47 -51
  34. package/lib/CodeBlock.d.ts +47 -51
  35. package/lib/CodeBlock.js +5 -4
  36. package/lib/CodeView.cjs +1 -1
  37. package/lib/CodeView.d.cts +47 -51
  38. package/lib/CodeView.d.ts +47 -51
  39. package/lib/CodeView.js +3 -2
  40. package/lib/Color.cjs +1 -1
  41. package/lib/Color.d.cts +48 -52
  42. package/lib/Color.d.ts +48 -52
  43. package/lib/Color.js +42 -74
  44. package/lib/Document.cjs +1 -1
  45. package/lib/Document.d.cts +47 -51
  46. package/lib/Document.d.ts +47 -51
  47. package/lib/Document.js +4 -8
  48. package/lib/{Drawer-BKTU9CpU.js → Drawer-CaAfmqNo.js} +268 -265
  49. package/lib/Drawer-CdvCMSzN.cjs +1 -0
  50. package/lib/Drawer.cjs +1 -1
  51. package/lib/Drawer.d.cts +47 -51
  52. package/lib/Drawer.d.ts +47 -51
  53. package/lib/Drawer.js +4 -4
  54. package/lib/Emoji.cjs +1 -1
  55. package/lib/Emoji.d.cts +50 -52
  56. package/lib/Emoji.d.ts +50 -52
  57. package/lib/Emoji.js +19790 -178
  58. package/lib/Excalidraw-BbMQhNvs.cjs +1 -0
  59. package/lib/Excalidraw-CVWz2Vyn.js +290 -0
  60. package/lib/Excalidraw.cjs +1 -1
  61. package/lib/Excalidraw.d.cts +47 -51
  62. package/lib/Excalidraw.d.ts +47 -51
  63. package/lib/Excalidraw.js +3 -3
  64. package/lib/ExportPdf.cjs +1 -1
  65. package/lib/ExportPdf.d.cts +47 -51
  66. package/lib/ExportPdf.d.ts +47 -51
  67. package/lib/ExportPdf.js +4 -2
  68. package/lib/ExportWord.cjs +1 -1
  69. package/lib/ExportWord.d.cts +47 -51
  70. package/lib/ExportWord.d.ts +47 -51
  71. package/lib/ExportWord.js +22 -51
  72. package/lib/FontFamily.cjs +1 -1
  73. package/lib/FontFamily.d.cts +48 -52
  74. package/lib/FontFamily.d.ts +48 -52
  75. package/lib/FontFamily.js +46 -74
  76. package/lib/FontSize.cjs +1 -1
  77. package/lib/FontSize.d.cts +47 -51
  78. package/lib/FontSize.d.ts +47 -51
  79. package/lib/FontSize.js +11 -8
  80. package/lib/FormatPainter.cjs +1 -1
  81. package/lib/FormatPainter.d.cts +47 -51
  82. package/lib/FormatPainter.d.ts +47 -51
  83. package/lib/FormatPainter.js +4 -2
  84. package/lib/Heading.cjs +1 -1
  85. package/lib/Heading.d.cts +47 -51
  86. package/lib/Heading.d.ts +47 -51
  87. package/lib/Heading.js +77 -65
  88. package/lib/Highlight.cjs +1 -1
  89. package/lib/Highlight.d.cts +47 -51
  90. package/lib/Highlight.d.ts +47 -51
  91. package/lib/Highlight.js +5 -4
  92. package/lib/History.cjs +1 -1
  93. package/lib/History.d.cts +49 -53
  94. package/lib/History.d.ts +49 -53
  95. package/lib/History.js +39 -403
  96. package/lib/HorizontalRule.cjs +1 -1
  97. package/lib/HorizontalRule.d.cts +47 -51
  98. package/lib/HorizontalRule.d.ts +47 -51
  99. package/lib/HorizontalRule.js +16 -65
  100. package/lib/Iframe.cjs +1 -1
  101. package/lib/Iframe.d.cts +47 -51
  102. package/lib/Iframe.d.ts +47 -51
  103. package/lib/Iframe.js +4 -4
  104. package/lib/Image.cjs +1 -1
  105. package/lib/Image.d.cts +47 -51
  106. package/lib/Image.d.ts +47 -51
  107. package/lib/Image.js +3 -3
  108. package/lib/ImageGif.cjs +1 -1
  109. package/lib/ImageGif.d.cts +47 -51
  110. package/lib/ImageGif.d.ts +47 -51
  111. package/lib/ImageGif.js +5 -5
  112. package/lib/ImportWord.cjs +72 -72
  113. package/lib/ImportWord.d.cts +47 -51
  114. package/lib/ImportWord.d.ts +47 -51
  115. package/lib/ImportWord.js +5654 -5616
  116. package/lib/Indent.cjs +1 -1
  117. package/lib/Indent.d.cts +47 -51
  118. package/lib/Indent.d.ts +47 -51
  119. package/lib/Indent.js +4 -2
  120. package/lib/Italic.cjs +1 -1
  121. package/lib/Italic.d.cts +47 -51
  122. package/lib/Italic.d.ts +47 -51
  123. package/lib/Italic.js +20 -14
  124. package/lib/Katex.cjs +1 -1
  125. package/lib/Katex.d.cts +47 -51
  126. package/lib/Katex.d.ts +47 -51
  127. package/lib/Katex.js +49 -48
  128. package/lib/LineHeight.cjs +1 -1
  129. package/lib/LineHeight.d.cts +47 -51
  130. package/lib/LineHeight.d.ts +47 -51
  131. package/lib/LineHeight.js +21 -18
  132. package/lib/Link.cjs +1 -1
  133. package/lib/Link.d.cts +47 -51
  134. package/lib/Link.d.ts +47 -51
  135. package/lib/Link.js +4 -4
  136. package/lib/ListItem.cjs +1 -1
  137. package/lib/ListItem.d.cts +52 -52
  138. package/lib/ListItem.d.ts +52 -52
  139. package/lib/ListItem.js +4 -30
  140. package/lib/Mention.cjs +1 -1
  141. package/lib/Mention.d.cts +47 -51
  142. package/lib/Mention.d.ts +47 -51
  143. package/lib/Mention.js +161 -132
  144. package/lib/Mermaid.cjs +2 -2
  145. package/lib/Mermaid.d.cts +47 -51
  146. package/lib/Mermaid.d.ts +47 -51
  147. package/lib/Mermaid.js +150 -147
  148. package/lib/MoreMark.cjs +1 -1
  149. package/lib/MoreMark.d.cts +47 -51
  150. package/lib/MoreMark.d.ts +47 -51
  151. package/lib/MoreMark.js +5 -3
  152. package/lib/MultiColumn.cjs +1 -1
  153. package/lib/MultiColumn.d.cts +47 -51
  154. package/lib/MultiColumn.d.ts +47 -51
  155. package/lib/MultiColumn.js +2 -2
  156. package/lib/OrderedList.cjs +1 -1
  157. package/lib/OrderedList.d.cts +48 -52
  158. package/lib/OrderedList.d.ts +48 -52
  159. package/lib/OrderedList.js +11 -75
  160. package/lib/RichTextEditor-CxvwGvQG.cjs +142 -0
  161. package/lib/RichTextEditor-DGcKEUGr.js +22166 -0
  162. package/lib/SearchAndReplace.cjs +1 -1
  163. package/lib/SearchAndReplace.d.cts +60 -134
  164. package/lib/SearchAndReplace.d.ts +60 -134
  165. package/lib/SearchAndReplace.js +207 -194
  166. package/lib/Selection.cjs +1 -1
  167. package/lib/Selection.d.cts +47 -51
  168. package/lib/Selection.d.ts +47 -51
  169. package/lib/Selection.js +1 -1
  170. package/lib/SlashCommand.cjs +1 -1
  171. package/lib/SlashCommand.d.cts +47 -51
  172. package/lib/SlashCommand.d.ts +47 -51
  173. package/lib/SlashCommand.js +177 -222
  174. package/lib/Strike.cjs +1 -1
  175. package/lib/Strike.d.cts +47 -51
  176. package/lib/Strike.d.ts +47 -51
  177. package/lib/Strike.js +20 -14
  178. package/lib/SubAndSuperScript.cjs +1 -1
  179. package/lib/SubAndSuperScript.d.cts +47 -51
  180. package/lib/SubAndSuperScript.d.ts +47 -51
  181. package/lib/SubAndSuperScript.js +5 -3
  182. package/lib/Table.cjs +8 -10
  183. package/lib/Table.d.cts +50 -54
  184. package/lib/Table.d.ts +50 -54
  185. package/lib/Table.js +382 -2021
  186. package/lib/TableOfContent.cjs +1 -1
  187. package/lib/TableOfContent.d.cts +47 -51
  188. package/lib/TableOfContent.d.ts +47 -51
  189. package/lib/TableOfContent.js +53 -52
  190. package/lib/TaskList.cjs +1 -1
  191. package/lib/TaskList.d.cts +49 -53
  192. package/lib/TaskList.d.ts +49 -53
  193. package/lib/TaskList.js +12 -154
  194. package/lib/TextAlign.cjs +1 -1
  195. package/lib/TextAlign.d.cts +47 -51
  196. package/lib/TextAlign.d.ts +47 -51
  197. package/lib/TextAlign.js +11 -8
  198. package/lib/TextBubble.cjs +1 -1
  199. package/lib/TextBubble.d.cts +47 -51
  200. package/lib/TextBubble.d.ts +47 -51
  201. package/lib/TextBubble.js +5 -3
  202. package/lib/TextDirection.cjs +1 -1
  203. package/lib/TextDirection.d.cts +47 -51
  204. package/lib/TextDirection.d.ts +47 -51
  205. package/lib/TextDirection.js +15 -15
  206. package/lib/TextUnderline.cjs +1 -1
  207. package/lib/TextUnderline.d.cts +47 -51
  208. package/lib/TextUnderline.d.ts +47 -51
  209. package/lib/TextUnderline.js +40 -12
  210. package/lib/TrailingNode.cjs +1 -1
  211. package/lib/TrailingNode.d.cts +47 -51
  212. package/lib/TrailingNode.d.ts +47 -51
  213. package/lib/TrailingNode.js +1 -1
  214. package/lib/Twitter-BFULyqdR.js +1628 -0
  215. package/lib/Twitter-Cutpkh3h.cjs +1 -0
  216. package/lib/Twitter.cjs +1 -1
  217. package/lib/Twitter.d.cts +47 -51
  218. package/lib/Twitter.d.ts +47 -51
  219. package/lib/Twitter.js +3 -3
  220. package/lib/Video.cjs +1 -1
  221. package/lib/Video.d.cts +47 -51
  222. package/lib/Video.d.ts +47 -51
  223. package/lib/Video.js +3 -3
  224. package/lib/bubble-extra.cjs +2 -2
  225. package/lib/bubble-extra.d.cts +47 -51
  226. package/lib/bubble-extra.d.ts +47 -51
  227. package/lib/bubble-extra.js +200 -192
  228. package/lib/dom-dataset-_6-diIRQ.cjs +33 -0
  229. package/lib/dom-dataset-lYeH6gfI.js +2361 -0
  230. package/lib/index-5iBZLua9.cjs +12 -0
  231. package/lib/index-6D1J-A-o.cjs +1 -0
  232. package/lib/index-B96Cclrj.cjs +3 -0
  233. package/lib/index-BBz7Nmv9.js +55 -0
  234. package/lib/index-BeCTd5v2.cjs +1 -0
  235. package/lib/index-ByurDDMv.js +237 -0
  236. package/lib/index-CUogRI7j.cjs +1 -0
  237. package/lib/index-Ch6dBBad.js +709 -0
  238. package/lib/index-DF2Lp4HZ.cjs +100 -0
  239. package/lib/{index-LUL9mqY4.js → index-D_L6n8O8.js} +4 -4
  240. package/lib/index-Dbvi-Bvh.cjs +1 -0
  241. package/lib/index-DpCrt7xs.cjs +1 -0
  242. package/lib/index-DsAX1Vq8.cjs +1 -0
  243. package/lib/index-Dy4DlW9o.js +12 -0
  244. package/lib/index-J3jHHZ4d.js +200 -0
  245. package/lib/{index-CsK90iVd.js → index-LmrOdnen.js} +302 -389
  246. package/lib/index-VvXaaKe3.js +898 -0
  247. package/lib/index-kbO3iWqL.js +13432 -0
  248. package/lib/index.cjs +1 -2
  249. package/lib/index.d.cts +49 -251
  250. package/lib/index.d.ts +49 -251
  251. package/lib/index.js +2 -588
  252. package/lib/jsx-runtime-CT7Pcg-t.js +13 -0
  253. package/lib/jsx-runtime-C_NLcKys.cjs +1 -0
  254. package/lib/locale-bundle.cjs +1 -1
  255. package/lib/locale-bundle.d.cts +47 -51
  256. package/lib/locale-bundle.d.ts +47 -51
  257. package/lib/locale-bundle.js +1 -1
  258. package/lib/style.css +1 -1
  259. package/lib/{textarea-D5WVZMgt.cjs → textarea-DFo_aXnj.cjs} +1 -1
  260. package/lib/{textarea-BglwYF6b.js → textarea-aPtytkDx.js} +1 -1
  261. package/package.json +76 -70
  262. package/lib/Drawer-CmoEF-Zg.cjs +0 -1
  263. package/lib/Excalidraw-CM74U5tG.js +0 -289
  264. package/lib/Excalidraw-DAPP9qgY.cjs +0 -1
  265. package/lib/RichTextEditor-BQN2eLD_.js +0 -12775
  266. package/lib/RichTextEditor-C8Sm1E6J.cjs +0 -140
  267. package/lib/Twitter-CL2pu4QM.cjs +0 -17
  268. package/lib/Twitter-Dg6WWauX.js +0 -1743
  269. package/lib/dom-dataset-Byuf1YmW.cjs +0 -33
  270. package/lib/dom-dataset-Di3tIRrR.js +0 -1031
  271. package/lib/index-BI-IcZcN.cjs +0 -1
  272. package/lib/index-ByRfqzMr.cjs +0 -89
  273. package/lib/index-C1fzuXpN.js +0 -46
  274. package/lib/index-CbQQFj2T.js +0 -133
  275. package/lib/index-DI9T3iLd.js +0 -12354
  276. package/lib/index-D_A0TBRA.cjs +0 -1
  277. package/lib/index-DclQSrIx.cjs +0 -1
  278. package/lib/index-Z4b9rzn-.cjs +0 -1
package/lib/Mention.d.ts CHANGED
@@ -39,9 +39,8 @@ declare module '@tiptap/core' {
39
39
 
40
40
  declare module '@tiptap/core' {
41
41
  interface Commands<ReturnType> {
42
- drawer: {
43
- setDrawer: (options: any, replace?: any) => ReturnType;
44
- setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
42
+ excalidraw: {
43
+ setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
45
44
  };
46
45
  }
47
46
  }
@@ -49,11 +48,9 @@ declare module '@tiptap/core' {
49
48
 
50
49
  declare module '@tiptap/core' {
51
50
  interface Commands<ReturnType> {
52
- emoji: {
53
- setEmoji: (emoji: {
54
- name: string;
55
- emoji: string;
56
- }) => ReturnType;
51
+ drawer: {
52
+ setDrawer: (options: any, replace?: any) => ReturnType;
53
+ setAlignImageDrawer: (align: 'left' | 'center' | 'right') => ReturnType;
57
54
  };
58
55
  }
59
56
  }
@@ -61,8 +58,8 @@ declare module '@tiptap/core' {
61
58
 
62
59
  declare module '@tiptap/core' {
63
60
  interface Commands<ReturnType> {
64
- excalidraw: {
65
- setExcalidraw: (attrs?: IExcalidrawAttrs) => ReturnType;
61
+ exportPdf: {
62
+ exportToPdf: () => ReturnType;
66
63
  };
67
64
  }
68
65
  }
@@ -70,8 +67,8 @@ declare module '@tiptap/core' {
70
67
 
71
68
  declare module '@tiptap/core' {
72
69
  interface Commands<ReturnType> {
73
- exportPdf: {
74
- exportToPdf: () => ReturnType;
70
+ exportWord: {
71
+ exportToWord: () => ReturnType;
75
72
  };
76
73
  }
77
74
  }
@@ -79,8 +76,8 @@ declare module '@tiptap/core' {
79
76
 
80
77
  declare module '@tiptap/core' {
81
78
  interface Commands<ReturnType> {
82
- exportWord: {
83
- exportToWord: () => ReturnType;
79
+ painter: {
80
+ setPainter: (marks: Mark[]) => ReturnType;
84
81
  };
85
82
  }
86
83
  }
@@ -106,8 +103,14 @@ declare module '@tiptap/core' {
106
103
 
107
104
  declare module '@tiptap/core' {
108
105
  interface Commands<ReturnType> {
109
- painter: {
110
- setPainter: (marks: Mark[]) => ReturnType;
106
+ iframe: {
107
+ /**
108
+ * Add an iframe
109
+ */
110
+ setIframe: (options: {
111
+ src: string;
112
+ service: string;
113
+ }) => ReturnType;
111
114
  };
112
115
  }
113
116
  }
@@ -133,21 +136,6 @@ declare module '@tiptap/core' {
133
136
  }
134
137
 
135
138
 
136
- declare module '@tiptap/core' {
137
- interface Commands<ReturnType> {
138
- iframe: {
139
- /**
140
- * Add an iframe
141
- */
142
- setIframe: (options: {
143
- src: string;
144
- service: string;
145
- }) => ReturnType;
146
- };
147
- }
148
- }
149
-
150
-
151
139
  declare module '@tiptap/core' {
152
140
  interface Commands<ReturnType> {
153
141
  imageGifUpload: {
@@ -168,6 +156,15 @@ declare module '@tiptap/core' {
168
156
  }
169
157
 
170
158
 
159
+ declare module '@tiptap/core' {
160
+ interface Commands<ReturnType> {
161
+ katex: {
162
+ setKatex: (arg?: IKatexAttrs) => ReturnType;
163
+ };
164
+ }
165
+ }
166
+
167
+
171
168
  declare module '@tiptap/core' {
172
169
  interface Commands<ReturnType> {
173
170
  indent: {
@@ -186,8 +183,9 @@ declare module '@tiptap/core' {
186
183
 
187
184
  declare module '@tiptap/core' {
188
185
  interface Commands<ReturnType> {
189
- katex: {
190
- setKatex: (arg?: IKatexAttrs) => ReturnType;
186
+ lineHeight: {
187
+ setLineHeight: (lineHeight: string) => ReturnType;
188
+ unsetLineHeight: () => ReturnType;
191
189
  };
192
190
  }
193
191
  }
@@ -195,9 +193,13 @@ declare module '@tiptap/core' {
195
193
 
196
194
  declare module '@tiptap/core' {
197
195
  interface Commands<ReturnType> {
198
- lineHeight: {
199
- setLineHeight: (lineHeight: string) => ReturnType;
200
- unsetLineHeight: () => ReturnType;
196
+ columns: {
197
+ insertColumns: (attrs?: {
198
+ cols: number;
199
+ }) => ReturnType;
200
+ addColBefore: () => ReturnType;
201
+ addColAfter: () => ReturnType;
202
+ deleteCol: () => ReturnType;
201
203
  };
202
204
  }
203
205
  }
@@ -215,13 +217,9 @@ declare module '@tiptap/core' {
215
217
 
216
218
  declare module '@tiptap/core' {
217
219
  interface Commands<ReturnType> {
218
- columns: {
219
- insertColumns: (attrs?: {
220
- cols: number;
221
- }) => ReturnType;
222
- addColBefore: () => ReturnType;
223
- addColAfter: () => ReturnType;
224
- deleteCol: () => ReturnType;
220
+ tableOfContents: {
221
+ setTableOfContents: () => ReturnType;
222
+ removeTableOfContents: () => ReturnType;
225
223
  };
226
224
  }
227
225
  }
@@ -232,22 +230,20 @@ declare module '@tiptap/core' {
232
230
  search: {
233
231
  setSearchTerm: (searchTerm: string) => ReturnType;
234
232
  setReplaceTerm: (replaceTerm: string) => ReturnType;
233
+ setCaseSensitive: (caseSensitive: boolean) => ReturnType;
234
+ resetIndex: () => ReturnType;
235
+ nextSearchResult: () => ReturnType;
236
+ previousSearchResult: () => ReturnType;
235
237
  replace: () => ReturnType;
236
238
  replaceAll: () => ReturnType;
237
- goToPrevSearchResult: () => void;
238
- goToNextSearchResult: () => void;
239
- setCaseSensitive: (caseSensitive: boolean) => ReturnType;
240
239
  };
241
240
  }
242
241
  }
243
242
 
244
243
 
245
244
  declare module '@tiptap/core' {
246
- interface Commands<ReturnType> {
247
- tableOfContents: {
248
- setTableOfContents: () => ReturnType;
249
- removeTableOfContents: () => ReturnType;
250
- };
245
+ interface Storage {
246
+ searchAndReplace: SearchAndReplaceStorage;
251
247
  }
252
248
  }
253
249
 
package/lib/Mention.js CHANGED
@@ -1,67 +1,73 @@
1
- import { N as v, q as L, m as c, a as M } from "./index-DI9T3iLd.js";
2
- import { S as w } from "./index-CbQQFj2T.js";
3
- import { c as h, g as f, a as H } from "./dom-dataset-Di3tIRrR.js";
4
- import S from "tippy.js";
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";
5
4
  import { jsx as m } from "react/jsx-runtime";
6
- import { forwardRef as A, useRef as U, useState as _, useEffect as b, useImperativeHandle as x } from "react";
7
- import C from "scroll-into-view-if-needed";
8
- function N({ editor: e, overrideSuggestionOptions: n, extensionName: t, char: r = "@" }) {
9
- const i = new M();
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 $({
8
+ editor: e,
9
+ overrideSuggestionOptions: r,
10
+ extensionName: n,
11
+ char: t = "@"
12
+ }) {
13
+ const s = new S();
10
14
  return {
11
15
  editor: e,
12
- char: r,
13
- pluginKey: i,
14
- command: ({ editor: o, range: l, props: u }) => {
15
- var a, s, d;
16
- const p = o.view.state.selection.$to.nodeAfter;
17
- ((a = p == null ? void 0 : p.text) === null || a === void 0 ? void 0 : a.startsWith(" ")) && (l.to += 1), o.chain().focus().insertContentAt(l, [
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, [
18
22
  {
19
- type: t,
20
- attrs: { ...u, mentionSuggestionChar: r }
23
+ type: n,
24
+ attrs: { ...d, mentionSuggestionChar: t }
21
25
  },
22
26
  {
23
27
  type: "text",
24
28
  text: " "
25
29
  }
26
- ]).run(), (d = (s = o.view.dom.ownerDocument.defaultView) === null || s === void 0 ? void 0 : s.getSelection()) === null || d === void 0 || d.collapseToEnd();
30
+ ]).run(), (l = (o = i.view.dom.ownerDocument.defaultView) == null ? void 0 : o.getSelection()) == null || l.collapseToEnd();
27
31
  },
28
- allow: ({ state: o, range: l }) => {
29
- const u = o.doc.resolve(l.from), a = o.schema.nodes[t];
30
- return !!u.parent.type.contentMatch.matchType(a);
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);
31
35
  },
32
- ...n
36
+ ...r
33
37
  };
34
38
  }
35
39
  function T(e) {
36
- return (e.options.suggestions.length ? e.options.suggestions : [e.options.suggestion]).map((n) => N({
37
- // @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
38
- editor: e.editor,
39
- overrideSuggestionOptions: n,
40
- extensionName: e.name,
41
- char: n.char
42
- }));
40
+ return (e.options.suggestions.length ? e.options.suggestions : [e.options.suggestion]).map(
41
+ (r) => $({
42
+ // @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
43
+ editor: e.editor,
44
+ overrideSuggestionOptions: r,
45
+ extensionName: e.name,
46
+ char: r.char
47
+ })
48
+ );
43
49
  }
44
- function y(e, n) {
45
- const t = T(e), r = t.find((i) => i.char === n);
46
- return r || (t.length ? t[0] : null);
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);
47
53
  }
48
- const R = v.create({
54
+ var k = v.create({
49
55
  name: "mention",
50
56
  priority: 101,
51
57
  addOptions() {
52
58
  return {
53
59
  HTMLAttributes: {},
54
- renderText({ node: e, suggestion: n }) {
55
- var t, r;
56
- return `${(t = n == null ? void 0 : n.char) !== null && t !== void 0 ? t : "@"}${(r = e.attrs.label) !== null && r !== void 0 ? r : e.attrs.id}`;
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}`;
57
63
  },
58
64
  deleteTriggerWithBackspace: !1,
59
- renderHTML({ options: e, node: n, suggestion: t }) {
60
- var r, i;
65
+ renderHTML({ options: e, node: r, suggestion: n }) {
66
+ var t, s;
61
67
  return [
62
68
  "span",
63
69
  c(this.HTMLAttributes, e.HTMLAttributes),
64
- `${(r = t == null ? void 0 : t.char) !== null && r !== void 0 ? r : "@"}${(i = n.attrs.label) !== null && i !== void 0 ? i : n.attrs.id}`
70
+ `${(t = n == null ? void 0 : n.char) != null ? t : "@"}${(s = r.attrs.label) != null ? s : r.attrs.id}`
65
71
  ];
66
72
  },
67
73
  suggestions: [],
@@ -105,93 +111,100 @@ const R = v.create({
105
111
  }
106
112
  ];
107
113
  },
108
- renderHTML({ node: e, HTMLAttributes: n }) {
109
- const t = y(this, e.attrs.mentionSuggestionChar);
114
+ renderHTML({ node: e, HTMLAttributes: r }) {
115
+ const n = y(this, e.attrs.mentionSuggestionChar);
110
116
  if (this.options.renderLabel !== void 0)
111
117
  return console.warn("renderLabel is deprecated use renderText and renderHTML instead"), [
112
118
  "span",
113
- c({ "data-type": this.name }, this.options.HTMLAttributes, n),
119
+ c({ "data-type": this.name }, this.options.HTMLAttributes, r),
114
120
  this.options.renderLabel({
115
121
  options: this.options,
116
122
  node: e,
117
- suggestion: t
123
+ suggestion: n
118
124
  })
119
125
  ];
120
- const r = { ...this.options };
121
- r.HTMLAttributes = c({ "data-type": this.name }, this.options.HTMLAttributes, n);
122
- const i = this.options.renderHTML({
123
- options: r,
126
+ const t = { ...this.options };
127
+ t.HTMLAttributes = c(
128
+ { "data-type": this.name },
129
+ this.options.HTMLAttributes,
130
+ r
131
+ );
132
+ const s = this.options.renderHTML({
133
+ options: t,
124
134
  node: e,
125
- suggestion: t
135
+ suggestion: n
126
136
  });
127
- return typeof i == "string" ? [
128
- "span",
129
- c({ "data-type": this.name }, this.options.HTMLAttributes, n),
130
- i
131
- ] : i;
137
+ return typeof s == "string" ? ["span", c({ "data-type": this.name }, this.options.HTMLAttributes, r), s] : s;
132
138
  },
139
+ ...w({
140
+ nodeName: "mention",
141
+ name: "@",
142
+ selfClosing: !0,
143
+ allowedAttributes: ["id", "label"]
144
+ }),
133
145
  renderText({ node: e }) {
134
- const n = {
146
+ const r = {
135
147
  options: this.options,
136
148
  node: e,
137
149
  suggestion: y(this, e.attrs.mentionSuggestionChar)
138
150
  };
139
- return this.options.renderLabel !== void 0 ? (console.warn("renderLabel is deprecated use renderText and renderHTML instead"), this.options.renderLabel(n)) : this.options.renderText(n);
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);
140
152
  },
141
153
  addKeyboardShortcuts() {
142
154
  return {
143
- Backspace: () => this.editor.commands.command(({ tr: e, state: n }) => {
144
- let t = !1;
145
- const { selection: r } = n, { empty: i, anchor: o } = r;
146
- if (!i)
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)
147
159
  return !1;
148
- n.doc.nodesBetween(o - 1, o, (a, s) => {
149
- if (a.type.name === this.name)
150
- return t = !0, e.insertText(this.options.deleteTriggerWithBackspace ? "" : this.options.suggestion.char || "", s, s + a.nodeSize), !1;
151
- });
152
- let l = new L(), u = 0;
153
- return n.doc.nodesBetween(o - 1, o, (a, s) => {
154
- if (a.type.name === this.name)
155
- return t = !0, l = a, u = s, !1;
156
- }), t && e.insertText(this.options.deleteTriggerWithBackspace ? "" : l.attrs.mentionSuggestionChar, u, u + l.nodeSize), t;
160
+ let a = new H(), d = 0;
161
+ return r.doc.nodesBetween(i - 1, i, (u, o) => {
162
+ if (u.type.name === this.name)
163
+ return n = !0, a = u, d = o, !1;
164
+ }), n && e.insertText(
165
+ this.options.deleteTriggerWithBackspace ? "" : a.attrs.mentionSuggestionChar,
166
+ d,
167
+ d + a.nodeSize
168
+ ), n;
157
169
  })
158
170
  };
159
171
  },
160
172
  addProseMirrorPlugins() {
161
- return T(this).map(w);
173
+ return T(this).map(C);
162
174
  }
163
- }), $ = "_listUsers_en3pm_1", k = "_itemUser_en3pm_10", D = "_selectedUser_en3pm_31", g = {
164
- listUsers: $,
165
- itemUser: k,
166
- selectedUser: D
167
- }, E = A((e, n) => {
168
- const t = U(null), [r, i] = _(0), o = (s) => {
169
- const d = e.items[s];
170
- d && e.command({ id: d, label: d });
171
- }, l = () => {
172
- i((r + e.items.length - 1) % e.items.length);
173
- }, u = () => {
174
- i((r + 1) % e.items.length);
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()));
175
184
  }, a = () => {
176
- o(r);
185
+ s((t + e.items.length - 1) % e.items.length);
186
+ }, d = () => {
187
+ s((t + 1) % e.items.length);
188
+ }, u = () => {
189
+ i(t);
177
190
  };
178
- return b(() => i(0), [e.items]), b(() => {
179
- if (Number.isNaN(r + 1))
191
+ return b(() => s(0), [e.items]), b(() => {
192
+ if (Number.isNaN(t + 1))
180
193
  return;
181
- const s = t.current.querySelector(`span:nth-of-type(${r + 1})`);
182
- s && C(s, { behavior: "smooth", scrollMode: "if-needed" });
183
- }, [r]), x(n, () => ({
184
- onKeyDown: ({ event: s }) => s.key === "ArrowUp" ? (l(), !0) : s.key === "ArrowDown" ? (u(), !0) : s.key === "Enter" ? (a(), !0) : !1
185
- })), /* @__PURE__ */ m("div", { className: h("listUsers", g.listUsers), children: /* @__PURE__ */ m("div", { ref: t, children: e.items.length > 0 ? e.items.map((s, d) => /* @__PURE__ */ m(
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(
186
199
  "span",
187
200
  {
188
- className: h("itemUser", g.itemUser, d === r ? g.selectedUser : ""),
189
- onClick: () => o(d),
190
- children: s
201
+ className: f("itemUser", g.itemUser, l === t ? g.selectedUser : ""),
202
+ onClick: () => i(l),
203
+ children: o
191
204
  },
192
- d
193
- )) : /* @__PURE__ */ m("div", { className: h("itemUserEmpty", g.itemUser), children: "Empty" }) }) });
194
- }), B = [
205
+ l
206
+ )) : /* @__PURE__ */ m("div", { className: f("itemUserEmpty", g.itemUser), children: "Empty" }) }) });
207
+ }), I = [
195
208
  {
196
209
  id: "1",
197
210
  name: "John Doe"
@@ -208,49 +221,16 @@ const R = v.create({
208
221
  id: "4",
209
222
  name: "Bob"
210
223
  }
211
- ], K = {
212
- items: async ({ query: e }) => B.map((t) => t.name).filter((t) => t.toLowerCase().startsWith(e.toLowerCase())),
213
- render: () => {
214
- let e, n;
215
- return {
216
- onStart: (t) => {
217
- e = new H(E, {
218
- props: t,
219
- editor: t.editor
220
- }), n = S("body", {
221
- getReferenceClientRect: t.clientRect,
222
- appendTo: () => document.body,
223
- content: e.element,
224
- showOnCreate: !0,
225
- interactive: !0,
226
- trigger: "manual",
227
- placement: "bottom-start"
228
- });
229
- },
230
- onUpdate(t) {
231
- e.updateProps(t), n[0].setProps({
232
- getReferenceClientRect: t.clientRect
233
- });
234
- },
235
- onKeyDown(t) {
236
- var r;
237
- return t.event.key === "Escape" ? (n[0].hide(), !0) : (r = e.ref) == null ? void 0 : r.onKeyDown(t);
238
- },
239
- onExit() {
240
- n[0].destroy(), e.destroy();
241
- }
242
- };
243
- }
244
- }, j = /* @__PURE__ */ R.extend({
224
+ ], z = /* @__PURE__ */ E.extend({
245
225
  addAttributes() {
246
226
  return {
247
227
  id: {
248
228
  default: "",
249
- parseHTML: f("id")
229
+ parseHTML: p("id")
250
230
  },
251
231
  label: {
252
232
  default: "",
253
- parseHTML: f("label")
233
+ parseHTML: p("label")
254
234
  }
255
235
  };
256
236
  }
@@ -258,8 +238,57 @@ const R = v.create({
258
238
  HTMLAttributes: {
259
239
  class: "mention"
260
240
  },
261
- suggestion: K
241
+ suggestion: {
242
+ items: async ({ query: e }) => I.map((n) => n.name).filter((n) => n.toLowerCase().startsWith(e.toLowerCase())),
243
+ render: () => {
244
+ 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
+ return {
266
+ onStart: (t) => {
267
+ n(), e = new L(B, {
268
+ props: {
269
+ ...t,
270
+ onClose: n
271
+ },
272
+ editor: t.editor
273
+ }), document.body.appendChild(e.element), r(t.clientRect());
274
+ },
275
+ onUpdate(t) {
276
+ e.updateProps(t), r(t.clientRect());
277
+ },
278
+ 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);
281
+ }
282
+ // onExit() {
283
+ // if (document.body.contains(component.element)) {
284
+ // document.body.removeChild(component.element);
285
+ // }
286
+ // component.destroy();
287
+ // },
288
+ };
289
+ }
290
+ }
262
291
  });
263
292
  export {
264
- j as Mention
293
+ z as Mention
265
294
  };
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,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of U(e))!Y.call(t,l)&&l!==r&&G(t,l,{get:()=>e[l],enumerable:!(a=X(e,l))||a.enumerable});return t};var K=(t,e,r)=>(r=t!=null?W(Z(t)):{},J(e||!t||!t.__esModule?G(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./index-ByRfqzMr.cjs"),u=require("./RichTextEditor-C8Sm1E6J.cjs"),F=require("./dom-dataset-Byuf1YmW.cjs"),o=require("react/jsx-runtime"),s=require("react"),P=require("./shortId-Bfj8TyNr.cjs"),Q=require("./textarea-D5WVZMgt.cjs"),S=require("./index-D_A0TBRA.cjs"),$=`graph TB
2
- a-->b`,ee=({editor:t,upload:e})=>{const[r,a]=s.useState($),[l,v]=s.useState(""),[T,y]=s.useState(!1),A=s.useRef(null),[d,h]=s.useState(null),E=s.useCallback(c=>{c&&import("mermaid").then(x=>{h(x.default)})},[]),_=async c=>{try{const{svg:x}=await d.render("mermaid-svg",c);v(x)}catch{v("")}},L=()=>{d.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),_(r)};s.useEffect(()=>{d&&T&&L()},[d,T]),s.useEffect(()=>{d&&T&&_(r)},[d&&r]);const R=async()=>{if(r!==""){if(r){const c=A.current.querySelector("svg"),{width:x,height:j}=c.getBoundingClientRect(),I=`mermaid-${P.shortId()}.svg`;let M=P.i(c.outerHTML);if(e){console.log({src:M});const H=u.dataURLtoFile(M,I);M=await e(H)}t==null||t.chain().focus().setMermaid({type:"mermaid",src:M,alt:encodeURIComponent(r),width:x,height:j},!!r).run()}y(!1)}};return o.jsxs(u.Dialog,{onOpenChange:y,open:T,children:[o.jsx(u.DialogTrigger,{asChild:!0,children:o.jsx(u.ActionButton,{action:()=>y(!0),icon:"Mermaid",tooltip:"Mermaid"})}),o.jsxs(u.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[o.jsx(u.DialogTitle,{children:"Mermaid"}),o.jsx("div",{ref:E,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:c=>a(c.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:l},ref:A,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),o.jsx(u.DialogFooter,{children:o.jsx(u.Button,{onClick:R,type:"button",children:"Save changes"})})]})]})},O={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function te({editor:t,node:e,updateAttributes:r,getPos:a,selected:l}){const[v,T]=s.useState({width:S.IMAGE_MAX_SIZE,height:S.IMAGE_MAX_SIZE}),[y,A]=s.useState({width:0,height:0}),[d]=s.useState([O.TOP_LEFT,O.TOP_RIGHT,O.BOTTOM_LEFT,O.BOTTOM_RIGHT]),[h,E]=s.useState(!1),[_,L]=s.useState({x:0,y:0,w:0,h:0,dir:""}),{align:R}=e==null?void 0:e.attrs,c=s.useMemo(()=>{const{src:i,alt:m,width:f,height:b}=e==null?void 0:e.attrs,w=q.isNumber(f)?`${f}px`:f,n=q.isNumber(b)?`${b}px`:b;return{src:i||void 0,alt:m||void 0,style:{width:w||void 0,height:n||void 0}}},[e==null?void 0:e.attrs]),x=s.useMemo(()=>{const{style:{width:i}}=c;return{width:i==="100%"?i:void 0}},[c]);function j(i){A({width:i.target.width,height:i.target.height})}function I(){t.commands.setNodeSelection(a())}const M=s.useCallback(u.throttle(()=>{const{width:i}=getComputedStyle(t.view.dom);T(m=>({...m,width:Number.parseInt(i,10)}))},S.IMAGE_THROTTLE_WAIT_TIME),[t]);function H(i,m){i.preventDefault(),i.stopPropagation();const f=y.width,b=y.height,w=f/b;let n=Number(e.attrs.width),p=Number(e.attrs.height);const g=v.width;n&&!p?(n=n>g?g:n,p=Math.round(n/w)):p&&!n?(n=Math.round(p*w),n=n>g?g:n):!n&&!p?(n=f>g?g:f,p=Math.round(n/w)):n=n>g?g:n,E(!0),L({x:i.clientX,y:i.clientY,w:n,h:p,dir:m})}const N=s.useCallback(u.throttle(i=>{if(i.preventDefault(),i.stopPropagation(),!h)return;const{x:m,w:f,dir:b}=_,w=(i.clientX-m)*(/l/.test(b)?-1:1),{width:n,height:p}=e==null?void 0:e.attrs,g=n/p,B=u.clamp(f+w,S.IMAGE_MIN_SIZE,v.width),V=Math.round(B/g);r({width:B,height:V})},S.IMAGE_THROTTLE_WAIT_TIME),[h,_,v,r,e==null?void 0:e.attrs]),C=s.useCallback(i=>{i.preventDefault(),i.stopPropagation(),h&&(L({x:0,y:0,w:0,h:0,dir:""}),E(!1),I())},[h,I]),D=s.useCallback(()=>{document==null||document.addEventListener("mousemove",N,!0),document==null||document.addEventListener("mouseup",C,!0)},[N,C]),z=s.useCallback(()=>{document==null||document.removeEventListener("mousemove",N,!0),document==null||document.removeEventListener("mouseup",C,!0)},[N,C]);s.useEffect(()=>(h?D():z(),()=>{z()}),[h,D,z]);const k=s.useMemo(()=>new ResizeObserver(()=>M()),[M]);return s.useEffect(()=>(k.observe(t.view.dom),()=>{k.disconnect()}),[t.view.dom,k]),o.jsx(F.NodeViewWrapper,{className:"image-view",style:{...x,width:"100%",textAlign:R},children:o.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...x,background:"#fff"},className:`image-view__body ${l?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[o.jsx("img",{alt:c.alt,className:"image-view__body__image block",height:"auto",onClick:I,onLoad:j,src:c.src,style:c.style}),t.view.editable&&(l||h)&&o.jsx("div",{className:"image-resizer",children:d==null?void 0:d.map(i=>o.jsx("span",{className:`image-resizer__handler image-resizer__handler--${i}`,onMouseDown:m=>H(m,i)},`image-dir-${i}`))})]})})}const re=u.Image.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 l;return{component:ee,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:e,icon:"Mermaid",tooltip:r("editor.mermaid.tooltip"),upload:(l=a==null?void 0:a.options)==null?void 0:l.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 F.ReactNodeViewRenderer(te)},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",q.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=re;
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;