reactjs-tiptap-editor 0.2.29 → 0.3.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 (255) hide show
  1. package/lib/ActionMenuButton-Bycn676n.js +33 -0
  2. package/lib/ActionMenuButton-CpFNwSUZ.cjs +1 -0
  3. package/lib/Attachment.cjs +19 -0
  4. package/lib/Attachment.d.cts +344 -0
  5. package/lib/Attachment.d.ts +344 -0
  6. package/lib/Attachment.js +259 -0
  7. package/lib/Blockquote.cjs +1 -0
  8. package/lib/Blockquote.d.cts +343 -0
  9. package/lib/Blockquote.d.ts +343 -0
  10. package/lib/Blockquote.js +65 -0
  11. package/lib/Bold.cjs +1 -0
  12. package/lib/Bold.d.cts +343 -0
  13. package/lib/Bold.d.ts +343 -0
  14. package/lib/Bold.js +90 -0
  15. package/lib/BulletList.cjs +1 -0
  16. package/lib/BulletList.d.cts +343 -0
  17. package/lib/BulletList.d.ts +343 -0
  18. package/lib/BulletList.js +72 -0
  19. package/lib/Clear.cjs +1 -0
  20. package/lib/Clear.d.cts +342 -0
  21. package/lib/Clear.d.ts +342 -0
  22. package/lib/Clear.js +23 -0
  23. package/lib/Code.cjs +1 -0
  24. package/lib/Code.d.cts +343 -0
  25. package/lib/Code.d.ts +343 -0
  26. package/lib/Code.js +70 -0
  27. package/lib/CodeBlock.cjs +39 -0
  28. package/lib/CodeBlock.d.cts +352 -0
  29. package/lib/CodeBlock.d.ts +352 -0
  30. package/lib/CodeBlock.js +3639 -0
  31. package/lib/Color.cjs +1 -0
  32. package/lib/Color.d.cts +350 -0
  33. package/lib/Color.d.ts +350 -0
  34. package/lib/Color.js +141 -0
  35. package/lib/Document.cjs +1 -0
  36. package/lib/Document.d.cts +272 -0
  37. package/lib/Document.d.ts +272 -0
  38. package/lib/Document.js +13 -0
  39. package/lib/Drawer-BZadE1gM.js +1367 -0
  40. package/lib/Drawer-rwnFvgZR.cjs +1 -0
  41. package/lib/Drawer.cjs +1 -0
  42. package/lib/Drawer.d.cts +344 -0
  43. package/lib/Drawer.d.ts +344 -0
  44. package/lib/Drawer.js +7 -0
  45. package/lib/Emoji.cjs +1 -0
  46. package/lib/Emoji.d.cts +277 -0
  47. package/lib/Emoji.d.ts +277 -0
  48. package/lib/Emoji.js +2168 -0
  49. package/lib/Excalidraw-B2414Smc.js +651 -0
  50. package/lib/Excalidraw-D21vMFe0.cjs +1 -0
  51. package/lib/Excalidraw.cjs +1 -0
  52. package/lib/Excalidraw.d.cts +278 -0
  53. package/lib/Excalidraw.d.ts +278 -0
  54. package/lib/Excalidraw.js +6 -0
  55. package/lib/ExportPdf.cjs +15 -0
  56. package/lib/ExportPdf.d.cts +270 -0
  57. package/lib/ExportPdf.d.ts +270 -0
  58. package/lib/ExportPdf.js +67 -0
  59. package/lib/ExportWord.cjs +1 -0
  60. package/lib/ExportWord.d.cts +341 -0
  61. package/lib/ExportWord.d.ts +341 -0
  62. package/lib/ExportWord.js +72 -0
  63. package/lib/FontFamily.cjs +1 -0
  64. package/lib/FontFamily.d.cts +354 -0
  65. package/lib/FontFamily.d.ts +354 -0
  66. package/lib/FontFamily.js +136 -0
  67. package/lib/FontSize.cjs +1 -0
  68. package/lib/FontSize.d.cts +359 -0
  69. package/lib/FontSize.d.ts +359 -0
  70. package/lib/FontSize.js +110 -0
  71. package/lib/FormatPainter.cjs +1 -0
  72. package/lib/FormatPainter.d.cts +353 -0
  73. package/lib/FormatPainter.d.ts +353 -0
  74. package/lib/FormatPainter.js +74 -0
  75. package/lib/Heading.cjs +1 -0
  76. package/lib/Heading.d.cts +343 -0
  77. package/lib/Heading.d.ts +343 -0
  78. package/lib/Heading.js +147 -0
  79. package/lib/Highlight.cjs +1 -0
  80. package/lib/Highlight.d.cts +344 -0
  81. package/lib/Highlight.d.ts +344 -0
  82. package/lib/Highlight.js +85 -0
  83. package/lib/History.cjs +1 -0
  84. package/lib/History.d.cts +343 -0
  85. package/lib/History.d.ts +343 -0
  86. package/lib/History.js +431 -0
  87. package/lib/HorizontalRule.cjs +1 -0
  88. package/lib/HorizontalRule.d.cts +343 -0
  89. package/lib/HorizontalRule.d.ts +343 -0
  90. package/lib/HorizontalRule.js +87 -0
  91. package/lib/Iframe.cjs +1 -0
  92. package/lib/Iframe.d.cts +277 -0
  93. package/lib/Iframe.d.ts +277 -0
  94. package/lib/Iframe.js +6 -0
  95. package/lib/Image.cjs +1 -0
  96. package/lib/Image.d.cts +370 -0
  97. package/lib/Image.d.ts +370 -0
  98. package/lib/Image.js +7 -0
  99. package/lib/ImageGif.cjs +1 -0
  100. package/lib/ImageGif.d.cts +292 -0
  101. package/lib/ImageGif.d.ts +292 -0
  102. package/lib/ImageGif.js +7 -0
  103. package/lib/ImportWord.cjs +231 -0
  104. package/lib/ImportWord.d.cts +353 -0
  105. package/lib/ImportWord.d.ts +353 -0
  106. package/lib/ImportWord.js +16620 -0
  107. package/lib/Indent.cjs +1 -0
  108. package/lib/Indent.d.cts +344 -0
  109. package/lib/Indent.d.ts +344 -0
  110. package/lib/Indent.js +78 -0
  111. package/lib/Italic.cjs +1 -0
  112. package/lib/Italic.d.cts +343 -0
  113. package/lib/Italic.d.ts +343 -0
  114. package/lib/Italic.js +91 -0
  115. package/lib/Katex.cjs +1 -0
  116. package/lib/Katex.d.cts +279 -0
  117. package/lib/Katex.d.ts +279 -0
  118. package/lib/Katex.js +197 -0
  119. package/lib/LineHeight.cjs +1 -0
  120. package/lib/LineHeight.d.cts +347 -0
  121. package/lib/LineHeight.d.ts +347 -0
  122. package/lib/LineHeight.js +137 -0
  123. package/lib/Link.cjs +5 -0
  124. package/lib/Link.d.cts +343 -0
  125. package/lib/Link.d.ts +343 -0
  126. package/lib/Link.js +1048 -0
  127. package/lib/ListItem.cjs +1 -0
  128. package/lib/ListItem.d.cts +269 -0
  129. package/lib/ListItem.d.ts +269 -0
  130. package/lib/ListItem.js +33 -0
  131. package/lib/Mention.cjs +1 -0
  132. package/lib/Mention.d.cts +272 -0
  133. package/lib/Mention.d.ts +272 -0
  134. package/lib/Mention.js +233 -0
  135. package/lib/Mermaid.cjs +2 -0
  136. package/lib/Mermaid.d.cts +344 -0
  137. package/lib/Mermaid.d.ts +344 -0
  138. package/lib/Mermaid.js +390 -0
  139. package/lib/MoreMark.cjs +1 -0
  140. package/lib/MoreMark.d.cts +355 -0
  141. package/lib/MoreMark.d.ts +355 -0
  142. package/lib/MoreMark.js +95 -0
  143. package/lib/MultiColumn.cjs +1 -0
  144. package/lib/MultiColumn.d.cts +277 -0
  145. package/lib/MultiColumn.d.ts +277 -0
  146. package/lib/MultiColumn.js +8 -0
  147. package/lib/OrderedList.cjs +1 -0
  148. package/lib/OrderedList.d.cts +343 -0
  149. package/lib/OrderedList.d.ts +343 -0
  150. package/lib/OrderedList.js +90 -0
  151. package/lib/RichTextEditor-Cy9XKEI5.js +11178 -0
  152. package/lib/RichTextEditor-DkpDEr5U.cjs +137 -0
  153. package/lib/SearchAndReplace.cjs +1 -0
  154. package/lib/SearchAndReplace.d.cts +358 -0
  155. package/lib/SearchAndReplace.d.ts +358 -0
  156. package/lib/SearchAndReplace.js +339 -0
  157. package/lib/Selection.cjs +1 -0
  158. package/lib/Selection.d.cts +272 -0
  159. package/lib/Selection.d.ts +272 -0
  160. package/lib/Selection.js +25 -0
  161. package/lib/SlashCommand.cjs +1 -0
  162. package/lib/SlashCommand.d.cts +299 -0
  163. package/lib/SlashCommand.d.ts +299 -0
  164. package/lib/SlashCommand.js +369 -0
  165. package/lib/Strike.cjs +1 -0
  166. package/lib/Strike.d.cts +343 -0
  167. package/lib/Strike.d.ts +343 -0
  168. package/lib/Strike.js +80 -0
  169. package/lib/SubAndSuperScript.cjs +1 -0
  170. package/lib/SubAndSuperScript.d.cts +358 -0
  171. package/lib/SubAndSuperScript.d.ts +358 -0
  172. package/lib/SubAndSuperScript.js +41 -0
  173. package/lib/Table.cjs +1 -0
  174. package/lib/Table.d.cts +366 -0
  175. package/lib/Table.d.ts +366 -0
  176. package/lib/Table.js +2165 -0
  177. package/lib/TableOfContent.cjs +1 -0
  178. package/lib/TableOfContent.d.cts +274 -0
  179. package/lib/TableOfContent.d.ts +274 -0
  180. package/lib/TableOfContent.js +184 -0
  181. package/lib/TaskList.cjs +1 -0
  182. package/lib/TaskList.d.cts +349 -0
  183. package/lib/TaskList.d.ts +349 -0
  184. package/lib/TaskList.js +175 -0
  185. package/lib/TextAlign.cjs +1 -0
  186. package/lib/TextAlign.d.cts +353 -0
  187. package/lib/TextAlign.d.ts +353 -0
  188. package/lib/TextAlign.js +165 -0
  189. package/lib/TextBubble.cjs +1 -0
  190. package/lib/TextBubble.d.cts +343 -0
  191. package/lib/TextBubble.d.ts +343 -0
  192. package/lib/TextBubble.js +131 -0
  193. package/lib/TextDirection.cjs +1 -0
  194. package/lib/TextDirection.d.cts +270 -0
  195. package/lib/TextDirection.d.ts +270 -0
  196. package/lib/TextDirection.js +142 -0
  197. package/lib/TextUnderline.cjs +1 -0
  198. package/lib/TextUnderline.d.cts +343 -0
  199. package/lib/TextUnderline.d.ts +343 -0
  200. package/lib/TextUnderline.js +61 -0
  201. package/lib/TrailingNode.cjs +1 -0
  202. package/lib/TrailingNode.d.cts +280 -0
  203. package/lib/TrailingNode.d.ts +280 -0
  204. package/lib/TrailingNode.js +41 -0
  205. package/lib/Twitter-B_tSItrW.js +1743 -0
  206. package/lib/Twitter-CfDC4bFV.cjs +17 -0
  207. package/lib/Twitter.cjs +1 -0
  208. package/lib/Twitter.d.cts +295 -0
  209. package/lib/Twitter.d.ts +295 -0
  210. package/lib/Twitter.js +6 -0
  211. package/lib/Video.cjs +1 -0
  212. package/lib/Video.d.cts +371 -0
  213. package/lib/Video.d.ts +371 -0
  214. package/lib/Video.js +6 -0
  215. package/lib/bubble-extra.cjs +2 -0
  216. package/lib/bubble-extra.d.cts +294 -0
  217. package/lib/bubble-extra.d.ts +294 -0
  218. package/lib/bubble-extra.js +623 -0
  219. package/lib/dom-dataset-CAXnsjYE.cjs +33 -0
  220. package/lib/dom-dataset-CJ7GyQ2E.js +999 -0
  221. package/lib/index-COecBbaE.cjs +89 -0
  222. package/lib/index-ClFtfQ0J.cjs +1 -0
  223. package/lib/index-CvYIX2-x.js +129 -0
  224. package/lib/index-CySbCeQd.cjs +1 -0
  225. package/lib/{index-CO-iymkb.js → index-D9llIWB5.js} +442 -101
  226. package/lib/index-DXBa3JBo.js +46 -0
  227. package/lib/index-DjP7Onch.cjs +1 -0
  228. package/lib/index-Drmyqk9P.js +12322 -0
  229. package/lib/index-DuhDIOel.js +76 -0
  230. package/lib/index-LbrE7K9i.cjs +1 -0
  231. package/lib/index.cjs +2 -1
  232. package/lib/index.d.cts +290 -108
  233. package/lib/index.d.ts +290 -108
  234. package/lib/index.js +587 -13
  235. package/lib/locale-bundle.cjs +1 -1
  236. package/lib/locale-bundle.d.cts +108 -108
  237. package/lib/locale-bundle.d.ts +108 -108
  238. package/lib/locale-bundle.js +1 -1
  239. package/lib/shortId-Bfj8TyNr.cjs +2 -0
  240. package/lib/shortId-WJVkrvml.js +30 -0
  241. package/lib/style.css +1 -1
  242. package/lib/textarea-B45fP3gP.cjs +1 -0
  243. package/lib/textarea-DXTdXr2y.js +20 -0
  244. package/package.json +678 -15
  245. package/lib/RichTextEditor-Ce2IeNE6.js +0 -8265
  246. package/lib/RichTextEditor-hDDApaDD.cjs +0 -136
  247. package/lib/extension-bundle.cjs +0 -33
  248. package/lib/extension-bundle.d.cts +0 -951
  249. package/lib/extension-bundle.d.ts +0 -951
  250. package/lib/extension-bundle.js +0 -5982
  251. package/lib/index-CJ6Hb9MN.cjs +0 -1
  252. package/lib/tiptap-DOP8lVCQ.js +0 -5950
  253. package/lib/tiptap-Dq62HiQ9.cjs +0 -113
  254. package/lib/vendor-BbgkyoD-.js +0 -40297
  255. package/lib/vendor-DdwtMmSr.cjs +0 -302
@@ -0,0 +1,623 @@
1
+ import { jsxs as b, jsx as t, Fragment as w } from "react/jsx-runtime";
2
+ import { useState as y, useRef as L, useCallback as v, useEffect as T, useMemo as W, Fragment as G } from "react";
3
+ import { B as z } from "./dom-dataset-CJ7GyQ2E.js";
4
+ import { w as Z, x as J, A as S, y as Q, z as X, F as Y, B as H, G as ee, O as D, a3 as ce, a4 as te, a5 as R, a6 as se, a7 as le } from "./RichTextEditor-Cy9XKEI5.js";
5
+ import { Mermaid as j } from "./Mermaid.js";
6
+ import { s as re, i as ne } from "./shortId-WJVkrvml.js";
7
+ import { T as ie } from "./textarea-DXTdXr2y.js";
8
+ import { u as O } from "./index-D9llIWB5.js";
9
+ import { E as I, t as de } from "./Excalidraw-B2414Smc.js";
10
+ import { T as K, F as he } from "./Twitter-B_tSItrW.js";
11
+ import ue from "katex";
12
+ import { HelpCircle as me, Pencil as xe, Trash2 as fe } from "lucide-react";
13
+ import { Katex as P } from "./Katex.js";
14
+ import { C as pe, D as _ } from "./Drawer-BZadE1gM.js";
15
+ import { Editor as ge, makeDropdownToolbar as be } from "easydrawer";
16
+ const q = `graph TB
17
+ a-->b`, we = ({ editor: e, attrs: s, extension: o }) => {
18
+ const { alt: a, align: n } = s, [r, i] = y(decodeURIComponent(a ?? q)), [l, h] = y(""), [m, x] = y(!1), p = L(null), [f, M] = y(null), k = o == null ? void 0 : o.options.upload, A = v(
19
+ (g) => {
20
+ g && import("mermaid").then((B) => {
21
+ M(B.default);
22
+ });
23
+ },
24
+ []
25
+ ), E = async (g) => {
26
+ try {
27
+ const { svg: B } = await f.render("mermaid-svg", g);
28
+ h(B);
29
+ } catch {
30
+ h("");
31
+ }
32
+ }, $ = () => {
33
+ f.initialize({
34
+ darkMode: !1,
35
+ startOnLoad: !1,
36
+ // fontFamily:'',
37
+ fontSize: 12,
38
+ theme: "base"
39
+ }), E(r);
40
+ };
41
+ return T(() => {
42
+ f && m && $();
43
+ }, [f, m]), T(() => {
44
+ f && m && E(r);
45
+ }, [f, r]), /* @__PURE__ */ b(
46
+ Z,
47
+ {
48
+ onOpenChange: x,
49
+ open: m,
50
+ children: [
51
+ /* @__PURE__ */ t(J, { asChild: !0, children: /* @__PURE__ */ t(
52
+ S,
53
+ {
54
+ action: () => x(!0),
55
+ icon: "Pencil",
56
+ tooltip: "Edit Mermaid"
57
+ }
58
+ ) }),
59
+ /* @__PURE__ */ b(Q, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
60
+ /* @__PURE__ */ t(X, { children: "Edit Mermaid" }),
61
+ /* @__PURE__ */ t(
62
+ "div",
63
+ {
64
+ ref: A,
65
+ style: { height: "100%", border: "1px solid hsl(var(--border))" },
66
+ children: /* @__PURE__ */ b("div", { className: "richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]", children: [
67
+ /* @__PURE__ */ t(
68
+ ie,
69
+ {
70
+ autoFocus: !0,
71
+ className: "richtext-flex-1",
72
+ defaultValue: q,
73
+ onChange: (g) => i(g.target.value),
74
+ placeholder: "Text",
75
+ required: !0,
76
+ rows: 10,
77
+ value: r,
78
+ style: {
79
+ color: "hsl(var(--richtext-foreground))"
80
+ }
81
+ }
82
+ ),
83
+ /* @__PURE__ */ t(
84
+ "div",
85
+ {
86
+ className: "richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",
87
+ dangerouslySetInnerHTML: { __html: l },
88
+ ref: p,
89
+ style: { height: "100%", border: "1px solid hsl(var(--border))", minHeight: 500, background: "#fff" }
90
+ }
91
+ )
92
+ ] })
93
+ }
94
+ ),
95
+ /* @__PURE__ */ t(Y, { children: /* @__PURE__ */ t(
96
+ H,
97
+ {
98
+ onClick: async () => {
99
+ if (r !== "") {
100
+ if (r) {
101
+ const g = p.current.querySelector("svg"), { width: B, height: V } = g.getBoundingClientRect(), u = `mermaid-${re()}.svg`;
102
+ let c = ne(g.outerHTML);
103
+ if (k) {
104
+ const d = ee(c, u);
105
+ c = await k(d);
106
+ }
107
+ e == null || e.chain().focus().setMermaid(
108
+ {
109
+ type: "mermaid",
110
+ src: c,
111
+ alt: encodeURIComponent(r),
112
+ width: B,
113
+ height: V
114
+ },
115
+ !!r
116
+ ).run(), e == null || e.commands.setAlignImageMermaid(n);
117
+ }
118
+ x(!1);
119
+ }
120
+ },
121
+ type: "button",
122
+ children: "Save changes"
123
+ }
124
+ ) })
125
+ ] })
126
+ ]
127
+ }
128
+ );
129
+ };
130
+ function oe(e, s) {
131
+ const [o, a] = y(void 0);
132
+ return T(() => {
133
+ const n = () => {
134
+ const r = e.extensionManager.extensions.find((i) => i.name === s);
135
+ r && a(r);
136
+ };
137
+ return e.on("selectionUpdate", n), e.on("transaction", n), () => {
138
+ e.off("selectionUpdate", n), e.off("transaction", n);
139
+ };
140
+ }, [e, s]), o;
141
+ }
142
+ const ve = {
143
+ maxWidth: "auto",
144
+ zIndex: 20,
145
+ appendTo: "parent",
146
+ moveTransition: "transform 0.1s ease-out"
147
+ };
148
+ function ye({ item: e, disabled: s, editor: o }) {
149
+ var n;
150
+ const a = e.component;
151
+ return a ? /* @__PURE__ */ t(G, { children: e.type === "divider" ? /* @__PURE__ */ t(
152
+ te,
153
+ {
154
+ className: "!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",
155
+ orientation: "vertical"
156
+ }
157
+ ) : /* @__PURE__ */ t(
158
+ a,
159
+ {
160
+ ...e.componentProps,
161
+ disabled: s || ((n = e == null ? void 0 : e.componentProps) == null ? void 0 : n.disabled),
162
+ editor: o
163
+ }
164
+ ) }) : /* @__PURE__ */ t(w, {});
165
+ }
166
+ function Se(e) {
167
+ return e.type.name === "mermaid";
168
+ }
169
+ function Ve(e) {
170
+ const { lang: s } = O(), o = D(e.editor, j.name), a = oe(e.editor, j.name), n = ({ editor: i }) => {
171
+ const { selection: l } = i.view.state, { $from: h, to: m } = l;
172
+ let x = !1;
173
+ return i.view.state.doc.nodesBetween(h.pos, m, (p) => {
174
+ if (Se(p))
175
+ return x = !0, !1;
176
+ }), x;
177
+ }, r = W(() => e.disabled ? [] : ce(e.editor), [e.disabled, e.editor, s]);
178
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(
179
+ z,
180
+ {
181
+ editor: e == null ? void 0 : e.editor,
182
+ shouldShow: n,
183
+ tippyOptions: ve,
184
+ children: r != null && r.length ? /* @__PURE__ */ t("div", { className: "richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800", children: /* @__PURE__ */ t("div", { className: "richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap", children: r == null ? void 0 : r.map((i, l) => i.type === "edit" && (o != null && o.src) ? /* @__PURE__ */ t(
185
+ we,
186
+ {
187
+ attrs: o,
188
+ editor: e.editor,
189
+ extension: a
190
+ },
191
+ `bubbleMenu-mermaid-${l}`
192
+ ) : /* @__PURE__ */ t(
193
+ ye,
194
+ {
195
+ disabled: e.disabled,
196
+ editor: e.editor,
197
+ item: i
198
+ },
199
+ `bubbleMenu-mermaid-${l}`
200
+ )) }) }) : /* @__PURE__ */ t(w, {})
201
+ }
202
+ ) });
203
+ }
204
+ const C = /* @__PURE__ */ new Map();
205
+ function Ce(e) {
206
+ const s = e.options.element;
207
+ C.has("width") || C.set("width", s.clientWidth), C.has("width") && C.get("width") <= 0 && C.set("width", s.clientWidth);
208
+ const o = { attributes: !0, childList: !0, subtree: !0 }, a = function() {
209
+ C.set("width", s.clientWidth);
210
+ }, n = new MutationObserver(a);
211
+ return n.observe(s, o), e.on("destroy", () => {
212
+ n.disconnect();
213
+ }), { width: C.get("width") };
214
+ }
215
+ function je({ editor: e }) {
216
+ const { t: s } = O(), { width: o } = Ce(e), a = D(e, I.name, {
217
+ defaultShowPicker: !1,
218
+ createUser: "",
219
+ width: 0,
220
+ height: 0
221
+ }), { defaultShowPicker: n, createUser: r, width: i, height: l } = a, h = v(
222
+ (f) => {
223
+ e.chain().updateAttributes(I.name, f).setNodeSelection(e.state.selection.from).focus().run();
224
+ },
225
+ [e]
226
+ ), m = v(() => {
227
+ de(a);
228
+ }, [e, a]), x = v(() => e.isActive(I.name), [e]), p = v(() => R(I.name, e), [e]);
229
+ return T(() => {
230
+ n && (m(), e.chain().updateAttributes(I.name, { defaultShowPicker: !1 }).focus().run());
231
+ }, [r, n, e, m]), /* @__PURE__ */ t(
232
+ z,
233
+ {
234
+ className: "bubble-menu",
235
+ editor: e,
236
+ pluginKey: "excalidraw-bubble-menu",
237
+ shouldShow: x,
238
+ tippyOptions: {
239
+ popperOptions: {
240
+ modifiers: [{ name: "flip", enabled: !1 }]
241
+ },
242
+ placement: "bottom-start",
243
+ offset: [-2, 16],
244
+ zIndex: 9999
245
+ // onHidden: () => {
246
+ // toggleVisible(false)
247
+ // },
248
+ },
249
+ children: /* @__PURE__ */ b("div", { className: "richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background", children: [
250
+ /* @__PURE__ */ t(
251
+ S,
252
+ {
253
+ icon: "Pencil",
254
+ action: m,
255
+ tooltip: s("editor.edit")
256
+ }
257
+ ),
258
+ /* @__PURE__ */ t(se, { width: i, maxWidth: o, height: l, onOk: h, children: /* @__PURE__ */ t(
259
+ S,
260
+ {
261
+ icon: "Settings",
262
+ tooltip: s("editor.settings")
263
+ }
264
+ ) }),
265
+ /* @__PURE__ */ t(
266
+ S,
267
+ {
268
+ icon: "Trash2",
269
+ action: p,
270
+ tooltip: s("editor.delete")
271
+ }
272
+ )
273
+ ] })
274
+ }
275
+ );
276
+ }
277
+ function Ke({ editor: e, disabled: s }) {
278
+ const [o, a] = y(!1), { t: n } = O(), r = v(({ editor: h }) => h.isActive(K.name), []), i = (h) => {
279
+ e.commands.updateTweet({ src: h }), a(!1);
280
+ }, l = v(() => R(K.name, e), [e]);
281
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(
282
+ z,
283
+ {
284
+ editor: e,
285
+ shouldShow: r,
286
+ tippyOptions: {
287
+ popperOptions: {
288
+ modifiers: [{ name: "flip", enabled: !1 }]
289
+ },
290
+ placement: "bottom-start",
291
+ offset: [-2, 16],
292
+ zIndex: 9999,
293
+ onHidden: () => {
294
+ a(!1);
295
+ }
296
+ },
297
+ children: s ? /* @__PURE__ */ t(w, {}) : /* @__PURE__ */ t(w, { children: o ? /* @__PURE__ */ t(
298
+ he,
299
+ {
300
+ editor: e,
301
+ onSetLink: i
302
+ }
303
+ ) : /* @__PURE__ */ t("div", { className: "richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-lg !richtext-border richtext-border-neutral-200 richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black", children: /* @__PURE__ */ b("div", { className: "richtext-flex richtext-flex-nowrap", children: [
304
+ /* @__PURE__ */ t(
305
+ S,
306
+ {
307
+ icon: "Pencil",
308
+ tooltip: n("editor.link.edit.tooltip"),
309
+ tooltipOptions: { sideOffset: 15 },
310
+ action: () => {
311
+ a(!0);
312
+ }
313
+ }
314
+ ),
315
+ /* @__PURE__ */ t(
316
+ S,
317
+ {
318
+ action: l,
319
+ icon: "Trash",
320
+ tooltip: n("editor.delete"),
321
+ tooltipOptions: { sideOffset: 15 }
322
+ }
323
+ )
324
+ ] }) }) })
325
+ }
326
+ ) });
327
+ }
328
+ function _e({ editor: e, ...s }) {
329
+ const o = D(e, P.name, {
330
+ text: "",
331
+ defaultShowPicker: !1
332
+ }), { text: a, defaultShowPicker: n } = o, [r, i] = y(""), [l, h] = y(!1), m = v(() => e.isActive(P.name), [e]), x = v(() => R(P.name, e), [e]), p = v(() => {
333
+ e.chain().focus().setKatex({ text: r }).run(), h(!1);
334
+ }, [e, r]);
335
+ T(() => {
336
+ n && (h(!0), e.chain().updateAttributes(P.name, { defaultShowPicker: !1 }).focus().run());
337
+ }, [e, n, h]), T(() => {
338
+ l && i(a || "");
339
+ }, [l]);
340
+ const f = W(() => {
341
+ try {
342
+ return ue.renderToString(`${r}`);
343
+ } catch {
344
+ return r;
345
+ }
346
+ }, [r]), M = W(
347
+ () => `${r}`.trim() ? /* @__PURE__ */ t(
348
+ "span",
349
+ {
350
+ contentEditable: !1,
351
+ dangerouslySetInnerHTML: { __html: f || "" }
352
+ }
353
+ ) : null,
354
+ [r, f]
355
+ );
356
+ return /* @__PURE__ */ t(
357
+ z,
358
+ {
359
+ editor: e,
360
+ pluginKey: "Katex-bubble-menu",
361
+ shouldShow: m,
362
+ tippyOptions: {
363
+ popperOptions: {
364
+ modifiers: [{ name: "flip", enabled: !1 }]
365
+ },
366
+ placement: "bottom-start",
367
+ offset: [-2, 16],
368
+ zIndex: 9999,
369
+ onHidden: () => {
370
+ h(!1);
371
+ }
372
+ },
373
+ children: s != null && s.disabled ? /* @__PURE__ */ t(w, {}) : /* @__PURE__ */ t("div", { className: "richtext-rounded-lg !richtext-border richtext-border-neutral-200 richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black", children: l ? /* @__PURE__ */ b(w, { children: [
374
+ /* @__PURE__ */ t(
375
+ ie,
376
+ {
377
+ autoFocus: !0,
378
+ defaultValue: a,
379
+ onChange: (k) => i(k.target.value),
380
+ placeholder: "Formula text",
381
+ rows: 3,
382
+ style: { marginBottom: 8 },
383
+ value: r
384
+ }
385
+ ),
386
+ M && /* @__PURE__ */ t("div", { className: "richtext-my-[10px] richtext-overflow-auto richtext-whitespace-nowrap richtext-rounded-[6px] !richtext-border richtext-p-[10px]", children: M }),
387
+ /* @__PURE__ */ b("div", { className: "richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]", children: [
388
+ /* @__PURE__ */ t(
389
+ H,
390
+ {
391
+ className: "richtext-flex-1",
392
+ onClick: p,
393
+ children: "Submit"
394
+ }
395
+ ),
396
+ /* @__PURE__ */ t(
397
+ "a",
398
+ {
399
+ href: "https://katex.org/docs/supported",
400
+ rel: "noreferrer noopener",
401
+ target: "_blank",
402
+ children: /* @__PURE__ */ t(me, { size: 16 })
403
+ }
404
+ )
405
+ ] })
406
+ ] }) : /* @__PURE__ */ b("div", { className: "richtext-flex richtext-items-center richtext-justify-center richtext-gap-[6px]", children: [
407
+ /* @__PURE__ */ t(
408
+ S,
409
+ {
410
+ action: () => h(!l),
411
+ tooltip: "Edit",
412
+ children: /* @__PURE__ */ t(xe, { size: 16 })
413
+ }
414
+ ),
415
+ /* @__PURE__ */ t(
416
+ S,
417
+ {
418
+ action: x,
419
+ tooltip: "Delete",
420
+ children: /* @__PURE__ */ t(fe, { size: 16 })
421
+ }
422
+ )
423
+ ] }) })
424
+ }
425
+ );
426
+ }
427
+ let N = !1;
428
+ function Te({ editor: e, attrs: s, extension: o }) {
429
+ const [a, n] = y(!1), r = L(null), i = L(null), { alt: l, align: h } = s, m = o == null ? void 0 : o.options.upload, x = () => {
430
+ (async () => {
431
+ const c = document.querySelector("#easydrawer");
432
+ c && (r.current = new ge(c, {
433
+ wheelEventsEnabled: !1,
434
+ disableZoom: !0
435
+ }), i.current = be(r.current), i.current.addDefaultToolWidgets(), r.current.loadFromSVG(decodeURIComponent(l)));
436
+ })();
437
+ };
438
+ T(() => {
439
+ a && setTimeout(() => {
440
+ x();
441
+ }, 200);
442
+ }, [a]);
443
+ const p = async () => {
444
+ if (r.current) {
445
+ const u = r.current.toSVG(), c = u.outerHTML, d = `drawer-${re()}.svg`;
446
+ let F = ne(u.outerHTML);
447
+ if (m) {
448
+ const ae = ee(F, d);
449
+ F = await m(ae);
450
+ }
451
+ e == null || e.chain().focus().setDrawer(
452
+ {
453
+ type: "drawer",
454
+ src: F,
455
+ alt: encodeURIComponent(c),
456
+ width: 426,
457
+ height: 212
458
+ },
459
+ !!c
460
+ ).run(), e == null || e.commands.setAlignImageDrawer(h);
461
+ }
462
+ n(!1);
463
+ }, f = (u) => {
464
+ const c = r.current.toolController.getPrimaryTools()[2], d = i.current.getWidgetById("pen-1");
465
+ c && d && (c.setColor(u), d.serializeState());
466
+ }, M = (u) => {
467
+ const c = r.current.toolController.getPrimaryTools()[2], d = i.current.getWidgetById("pen-1");
468
+ c && d && (c.setThickness(u), d.serializeState());
469
+ }, k = (u) => {
470
+ const c = r.current.toolController.getPrimaryTools()[3], d = i.current.getWidgetById("pen-2");
471
+ c && d && (c.setColor(u), d.serializeState());
472
+ }, A = (u) => {
473
+ const c = i.current.getWidgetById("shape");
474
+ c && c.setShapeType(u);
475
+ }, E = (u) => {
476
+ const c = r.current.toolController.getPrimaryTools()[5], d = i.current.getWidgetById("shape");
477
+ c && d && (c.setColor(u), d.serializeState());
478
+ }, $ = (u) => {
479
+ const c = r.current.toolController.getPrimaryTools()[5], d = i.current.getWidgetById("shape");
480
+ c && d && (c.setThickness(u), d.serializeState());
481
+ }, U = (u) => {
482
+ const c = r.current.toolController.getPrimaryTools()[5], d = i.current.getWidgetById("shape");
483
+ c && d && (c.setBorderColor(u), d.serializeState());
484
+ }, g = () => {
485
+ if (N) {
486
+ for (; r.current.history.redoStackSize > 0; )
487
+ r.current.history.redo();
488
+ N = !1;
489
+ return;
490
+ }
491
+ r.current.history.undo();
492
+ };
493
+ return /* @__PURE__ */ b(
494
+ Z,
495
+ {
496
+ onOpenChange: n,
497
+ open: a,
498
+ children: [
499
+ /* @__PURE__ */ t(J, { asChild: !0, children: /* @__PURE__ */ t(
500
+ S,
501
+ {
502
+ action: () => n(!0),
503
+ icon: "Pencil",
504
+ tooltip: "Edit Drawer"
505
+ }
506
+ ) }),
507
+ /* @__PURE__ */ b(Q, { className: "richtext-z-[99999] !richtext-max-w-[1300px]", children: [
508
+ /* @__PURE__ */ t(X, { children: "Edit Drawer" }),
509
+ /* @__PURE__ */ b("div", { style: { height: "100%", borderWidth: 1, background: "white", position: "relative" }, children: [
510
+ /* @__PURE__ */ t(
511
+ "div",
512
+ {
513
+ className: "richtext-size-full",
514
+ id: "easydrawer"
515
+ }
516
+ ),
517
+ /* @__PURE__ */ t(
518
+ pe,
519
+ {
520
+ changeBorderColorShape: U,
521
+ changeColorShape: E,
522
+ changeShape: A,
523
+ onClear: () => {
524
+ if (!N) {
525
+ for (; r.current.history.undoStackSize > 0; )
526
+ g();
527
+ N = !0;
528
+ }
529
+ },
530
+ onRedo: () => {
531
+ N || r.current.history.redo();
532
+ },
533
+ onThicknessChange: $,
534
+ onUndo: g,
535
+ refEditor: r,
536
+ setColorHighlight: k,
537
+ setColorPen: f,
538
+ setThicknessPen: M
539
+ }
540
+ )
541
+ ] }),
542
+ /* @__PURE__ */ t(Y, { children: /* @__PURE__ */ t(
543
+ H,
544
+ {
545
+ onClick: p,
546
+ type: "button",
547
+ children: "Save changes"
548
+ }
549
+ ) })
550
+ ] })
551
+ ]
552
+ }
553
+ );
554
+ }
555
+ const Me = {
556
+ maxWidth: "auto",
557
+ zIndex: 20,
558
+ appendTo: "parent",
559
+ moveTransition: "transform 0.1s ease-out"
560
+ };
561
+ function ke({ item: e, disabled: s, editor: o }) {
562
+ var n;
563
+ const a = e.component;
564
+ return a ? /* @__PURE__ */ t(G, { children: e.type === "divider" ? /* @__PURE__ */ t(
565
+ te,
566
+ {
567
+ className: "!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",
568
+ orientation: "vertical"
569
+ }
570
+ ) : /* @__PURE__ */ t(
571
+ a,
572
+ {
573
+ ...e.componentProps,
574
+ disabled: s || ((n = e == null ? void 0 : e.componentProps) == null ? void 0 : n.disabled),
575
+ editor: o
576
+ }
577
+ ) }) : /* @__PURE__ */ t(w, {});
578
+ }
579
+ function Be(e) {
580
+ return e.type.name === "drawer";
581
+ }
582
+ function qe(e) {
583
+ const { lang: s } = O(), o = D(e.editor, _.name), a = oe(e.editor, _.name), n = ({ editor: i }) => {
584
+ const { selection: l } = i.view.state, { $from: h, to: m } = l;
585
+ let x = !1;
586
+ return i.view.state.doc.nodesBetween(h.pos, m, (p) => {
587
+ if (Be(p))
588
+ return x = !0, !1;
589
+ }), x;
590
+ }, r = W(() => e.disabled ? [] : le(e.editor), [e.disabled, e.editor, s]);
591
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(
592
+ z,
593
+ {
594
+ editor: e == null ? void 0 : e.editor,
595
+ shouldShow: n,
596
+ tippyOptions: Me,
597
+ children: r != null && r.length ? /* @__PURE__ */ t("div", { className: "richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800", children: /* @__PURE__ */ t("div", { className: "richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap", children: r == null ? void 0 : r.map((i, l) => i.type === "edit" && (o != null && o.src) ? /* @__PURE__ */ t(
598
+ Te,
599
+ {
600
+ attrs: o,
601
+ editor: e.editor,
602
+ extension: a
603
+ },
604
+ `bubbleMenu-drawer-${l}`
605
+ ) : /* @__PURE__ */ t(
606
+ ke,
607
+ {
608
+ disabled: e.disabled,
609
+ editor: e.editor,
610
+ item: i
611
+ },
612
+ `bubbleMenu-drawer-${l}`
613
+ )) }) }) : /* @__PURE__ */ t(w, {})
614
+ }
615
+ ) });
616
+ }
617
+ export {
618
+ qe as BubbleMenuDrawer,
619
+ je as BubbleMenuExcalidraw,
620
+ _e as BubbleMenuKatex,
621
+ Ve as BubbleMenuMermaid,
622
+ Ke as BubbleMenuTwitter
623
+ };