reactjs-tiptap-editor 1.0.14 → 1.0.16

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 (186) hide show
  1. package/lib/{ActionMenuButton-DNj0f_A4.cjs → ActionMenuButton-BYu0NyVo.cjs} +1 -1
  2. package/lib/{ActionMenuButton-l5rSmAO_.js → ActionMenuButton-a8LhmHXe.js} +5 -5
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +6 -6
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +4 -4
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +4 -4
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +4 -4
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +36 -40
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +3 -3
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +4 -4
  17. package/lib/CodeBlock.cjs +1 -1
  18. package/lib/CodeBlock.js +6 -6
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +4 -4
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +6 -6
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +4 -4
  25. package/lib/{Drawer-Cbi_MURj.js → Drawer-CbOJ1Igo.js} +8 -8
  26. package/lib/{Drawer-DKU32YW_.cjs → Drawer-DNaDMoAk.cjs} +1 -1
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +3 -3
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +212 -2076
  31. package/lib/{Excalidraw-CWrVL5hs.js → Excalidraw-DnHTVOj8.js} +6 -6
  32. package/lib/{Excalidraw-Kb-TRcWY.cjs → Excalidraw-DxfO1lQ_.cjs} +1 -1
  33. package/lib/Excalidraw.cjs +1 -1
  34. package/lib/Excalidraw.js +2 -2
  35. package/lib/ExportPdf.cjs +1 -1
  36. package/lib/ExportPdf.js +4 -4
  37. package/lib/ExportWord.cjs +1 -1
  38. package/lib/ExportWord.js +4 -4
  39. package/lib/FontFamily.cjs +1 -1
  40. package/lib/FontFamily.js +6 -6
  41. package/lib/FontSize.cjs +1 -1
  42. package/lib/FontSize.js +6 -6
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +6 -6
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +6 -6
  47. package/lib/History.cjs +1 -1
  48. package/lib/History.js +22 -22
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +4 -4
  51. package/lib/{Icon-Ctva8VeB.js → Icon-C0TJMAOm.js} +2 -2
  52. package/lib/{Icon-yqCglrdK.cjs → Icon-DzK0_ztP.cjs} +1 -1
  53. package/lib/{Iframe-BczF8Hex.cjs → Iframe-BSNCsofW.cjs} +1 -1
  54. package/lib/{Iframe-C942bNjs.js → Iframe-CmjbQQcz.js} +6 -6
  55. package/lib/Iframe.cjs +1 -1
  56. package/lib/Iframe.js +2 -2
  57. package/lib/Image-BZEFuS0P.js +925 -0
  58. package/lib/Image-iKsGKjvg.cjs +1 -0
  59. package/lib/Image.cjs +1 -1
  60. package/lib/Image.js +5 -828
  61. package/lib/ImageGif.cjs +1 -1
  62. package/lib/ImageGif.js +9 -9
  63. package/lib/ImportWord.cjs +1 -231
  64. package/lib/ImportWord.js +91 -16623
  65. package/lib/{Indent-C_O5WdyR.js → Indent-BoG-vpIE.js} +4 -4
  66. package/lib/{Indent-CkEC7x36.cjs → Indent-Bou16OcB.cjs} +1 -1
  67. package/lib/Indent.cjs +1 -1
  68. package/lib/Indent.js +2 -2
  69. package/lib/Italic.cjs +1 -1
  70. package/lib/Italic.js +4 -4
  71. package/lib/Katex-BqDocr3a.cjs +4 -0
  72. package/lib/{Katex-D3PEWimM.js → Katex-ByL9snce.js} +369 -347
  73. package/lib/Katex.cjs +1 -1
  74. package/lib/Katex.js +2 -2
  75. package/lib/LineHeight.cjs +1 -1
  76. package/lib/LineHeight.js +7 -7
  77. package/lib/Link.cjs +1 -1
  78. package/lib/Link.js +2 -2
  79. package/lib/{LinkEditBlock-DL1e2ILk.cjs → LinkEditBlock-B0I0EUrt.cjs} +1 -1
  80. package/lib/{LinkEditBlock-h5054QDo.js → LinkEditBlock-Ckih17pU.js} +11 -11
  81. package/lib/Mention.cjs +1 -1
  82. package/lib/Mention.js +41 -63
  83. package/lib/Mermaid.cjs +1 -1
  84. package/lib/Mermaid.js +16 -16
  85. package/lib/MoreMark.cjs +1 -1
  86. package/lib/MoreMark.js +7 -7
  87. package/lib/OrderedList.cjs +1 -1
  88. package/lib/OrderedList.js +4 -4
  89. package/lib/SearchAndReplace.cjs +1 -1
  90. package/lib/SearchAndReplace.js +11 -11
  91. package/lib/SlashCommand.cjs +1 -1
  92. package/lib/SlashCommand.js +9 -9
  93. package/lib/{SlashCommandNodeView-DXUqkx82.js → SlashCommandNodeView-B2g1MbgN.js} +76 -83
  94. package/lib/SlashCommandNodeView-BEJhEzba.cjs +1 -0
  95. package/lib/Strike.cjs +1 -1
  96. package/lib/Strike.js +4 -4
  97. package/lib/{Table-DdrY4jcM.js → Table-BEwrZVup.js} +22 -22
  98. package/lib/{Table-kY0nbqJo.cjs → Table-BclWwp6P.cjs} +1 -1
  99. package/lib/Table.cjs +1 -1
  100. package/lib/Table.js +1 -1
  101. package/lib/TaskList.cjs +1 -1
  102. package/lib/TaskList.js +4 -4
  103. package/lib/TextAlign.cjs +1 -1
  104. package/lib/TextAlign.js +7 -7
  105. package/lib/TextDirection.cjs +1 -1
  106. package/lib/TextDirection.js +7 -7
  107. package/lib/TextUnderline.cjs +1 -1
  108. package/lib/TextUnderline.js +4 -4
  109. package/lib/{Twitter-B-JQ3ZJ1.js → Twitter-4U_ZBhpv.js} +10 -10
  110. package/lib/{Twitter-DjZcVa3l.cjs → Twitter-Dtq6PEMC.cjs} +1 -1
  111. package/lib/Twitter.cjs +1 -1
  112. package/lib/Twitter.js +2 -2
  113. package/lib/Video.cjs +1 -1
  114. package/lib/Video.js +9 -9
  115. package/lib/bubble.cjs +1 -1
  116. package/lib/bubble.js +27 -27
  117. package/lib/{button-Uv01FNnd.js → button-Bwn6gUuS.js} +2 -2
  118. package/lib/{button-BS3n6_Aq.cjs → button-CqJztfH2.cjs} +1 -1
  119. package/lib/{checkbox-C8ByRi7-.cjs → checkbox-BAzbZY2Y.cjs} +1 -1
  120. package/lib/{checkbox-DEFNwGwb.js → checkbox-B_rpz5Xq.js} +1 -1
  121. package/lib/{clsx-BWSGDJNJ.js → clsx-DSzxBzvL.js} +11 -11
  122. package/lib/{dialog-DwTMZSt6.js → dialog-CJvpoeMm.js} +1 -1
  123. package/lib/{dialog-Bt5zwGYB.cjs → dialog-CWYTvz5J.cjs} +1 -1
  124. package/lib/{dropdown-menu-BetI14G6.js → dropdown-menu-CW3Kthwy.js} +1 -1
  125. package/lib/{dropdown-menu-Bo68IEOT.cjs → dropdown-menu-eUeBXQeA.cjs} +1 -1
  126. package/lib/extensions/Emoji/Emoji.d.ts +3 -1
  127. package/lib/extensions/Emoji/components/EmojiList/EmojiNodeView.d.ts +9 -1
  128. package/lib/{index-CHKWG6E8.js → index-4bHF5ovf.js} +1 -1
  129. package/lib/index-BG0kQamI.js +285 -0
  130. package/lib/{index-Doks9cbR.cjs → index-BsFvo9PG.cjs} +1 -1
  131. package/lib/{index-Dujzr6bY.js → index-C07N8gA1.js} +69 -73
  132. package/lib/{index-CcoWj0mF.js → index-CL7JP-Xz.js} +1 -1
  133. package/lib/index-Cn-t3Zxw.cjs +1 -0
  134. package/lib/{index-mR8PNv5P.js → index-CpTykZBR.js} +1 -1
  135. package/lib/{index-BDKHXe7R.js → index-D8li6EQ4.js} +1 -1
  136. package/lib/{index-DJbmnBzK.js → index-DR5tIdL7.js} +1 -1
  137. package/lib/{index-DF5ZPtWM.js → index-DoiuU6VA.js} +54 -56
  138. package/lib/index-NsYff_Ni.cjs +1 -0
  139. package/lib/index.cjs +2 -2
  140. package/lib/index.js +4 -4
  141. package/lib/{input-DUBdJD3L.js → input-B1egKb-t.js} +1 -1
  142. package/lib/{input-Dt_BA_9B.cjs → input-ZGRt7lWR.cjs} +1 -1
  143. package/lib/{isNumber-CIgubz2e.js → isNumber-ClwLypY2.js} +1 -1
  144. package/lib/{label-topD46-u.js → label-Cjrzc5H2.js} +2 -2
  145. package/lib/{label-JNOksCA-.cjs → label-tzSPdqui.cjs} +1 -1
  146. package/lib/locale-bundle.cjs +1 -1
  147. package/lib/locale-bundle.js +1 -1
  148. package/lib/locales/index.d.ts +5 -1
  149. package/lib/{popover-mL-2sX5r.cjs → popover-C6Cya3Cz.cjs} +1 -1
  150. package/lib/{popover-LfNBhRyz.js → popover-CeY3RbI5.js} +1 -1
  151. package/lib/renderNodeView-CSazLrKF.js +28 -0
  152. package/lib/renderNodeView-DfLmGrgA.cjs +1 -0
  153. package/lib/{select-CwGYPsPq.cjs → select-Doa_-jkZ.cjs} +1 -1
  154. package/lib/{select-DctYuHLH.js → select-F0ZZ3VZB.js} +1 -1
  155. package/lib/{separator-NoH_SLRW.cjs → separator-CUh5Y7Rh.cjs} +1 -1
  156. package/lib/{separator-Ddfrhn4D.js → separator-Cjn4YH8a.js} +5 -5
  157. package/lib/store/commandList.d.ts +1 -1
  158. package/lib/store/store.d.ts +7 -6
  159. package/lib/{store-DNpS8vXA.js → store-BsJz5QRC.js} +1 -1
  160. package/lib/{store-CkjKIgjQ.cjs → store-DjkMIIEN.cjs} +1 -1
  161. package/lib/{tabs-DRSwUeKP.cjs → tabs-BP8ypR_m.cjs} +1 -1
  162. package/lib/{tabs-BT3AeqQQ.js → tabs-CBDjOLl_.js} +1 -1
  163. package/lib/{textarea-BDO6XQoF.cjs → textarea-BAolHF_W.cjs} +1 -1
  164. package/lib/{textarea-DZzMEDfZ.js → textarea-tOsPnxHf.js} +1 -1
  165. package/lib/theme.cjs +1 -1
  166. package/lib/theme.js +21 -27
  167. package/lib/{throttle-IERhwcLa.js → throttle-D040PfWL.js} +1 -1
  168. package/lib/{toggle-BQHMh_Q-.cjs → toggle-C_SSvDRy.cjs} +1 -1
  169. package/lib/{toggle-DKHg5sLm.js → toggle-DEerYRil.js} +4 -4
  170. package/lib/{tooltip-DNKq7zgN.js → tooltip-BJIvosho.js} +1 -1
  171. package/lib/{tooltip-BYtGp6FM.cjs → tooltip-FS1rsvd3.cjs} +1 -1
  172. package/lib/{updatePosition-Bie75EFq.js → updatePosition-CDK7OR0i.js} +2 -2
  173. package/lib/{useButtonProps-DVP4s_ER.js → useButtonProps-CtZCbMQu.js} +5 -5
  174. package/lib/{useButtonProps-DBJkNDS2.cjs → useButtonProps-Cz4W5dC8.cjs} +1 -1
  175. package/lib/utils/renderNodeView.d.ts +6 -0
  176. package/package.json +4 -4
  177. package/lib/Katex-DW_HjgNM.cjs +0 -4
  178. package/lib/SlashCommandNodeView-BqrmHCpu.cjs +0 -1
  179. package/lib/_commonjsHelpers-BItOPCY9.js +0 -28
  180. package/lib/_commonjsHelpers-BTDuMlIz.cjs +0 -1
  181. package/lib/extensions/Emoji/components/EmojiList/emojis.d.ts +0 -4
  182. package/lib/index-D3RLYf-J.cjs +0 -1
  183. package/lib/react-BEoMZB61.cjs +0 -1
  184. package/lib/react-c9FSfB30.js +0 -27
  185. package/lib/use-toast-Bz3QCOtE.cjs +0 -1
  186. package/lib/use-toast-Crf7-q5H.js +0 -98
package/lib/Image.js CHANGED
@@ -1,830 +1,7 @@
1
- import { h as he, m as fe, k as ge } from "./clsx-BWSGDJNJ.js";
2
- import { a as q, c as pe } from "./throttle-IERhwcLa.js";
3
- import { jsx as o, jsxs as b, Fragment as H } from "react/jsx-runtime";
4
- import j, { useState as L, useMemo as P, useCallback as F, useEffect as W, useRef as ae } from "react";
5
- import { I as Z, i as J, j as be, u as ne } from "./index-Dujzr6bY.js";
6
- import { i as K, c as xe } from "./isNumber-CIgubz2e.js";
7
- import { A as ye } from "./toggle-DKHg5sLm.js";
8
- import "./index-DF5ZPtWM.js";
9
- import "./theme.js";
10
- import { D as re, a as le, b as oe, c as se, d as we } from "./dialog-DwTMZSt6.js";
11
- import Ie from "react-image-crop";
12
- import { B } from "./button-Uv01FNnd.js";
13
- import { d as ce, c as ve, u as Te, a as Ae } from "./useButtonProps-DVP4s_ER.js";
14
- import { d as Ce, r as Ee } from "./file-BLas99n7.js";
15
- import { u as de } from "./use-toast-Crf7-q5H.js";
16
- import { I as $ } from "./Icon-Ctva8VeB.js";
17
- import { a as Me } from "./store-DNpS8vXA.js";
18
- import { l as Le, E as Ne } from "./events.constant-do95b767.js";
19
- import { T as Se, a as _e, b as Q, c as ee } from "./tabs-BT3AeqQQ.js";
20
- import { C as ze } from "./checkbox-DEFNwGwb.js";
21
- import { L as te } from "./label-topD46-u.js";
22
- import { I as ie } from "./input-DUBdJD3L.js";
23
- const X = {
24
- TOP_LEFT: "tl",
25
- TOP_RIGHT: "tr",
26
- BOTTOM_LEFT: "bl",
27
- BOTTOM_RIGHT: "br"
28
- };
29
- function Re(e) {
30
- var O, d, N;
31
- const [t, a] = L({
32
- width: Z,
33
- height: Z
34
- }), [s, f] = L({
35
- width: 0,
36
- height: 0
37
- }), [u] = L([
38
- X.TOP_LEFT,
39
- X.TOP_RIGHT,
40
- X.BOTTOM_LEFT,
41
- X.BOTTOM_RIGHT
42
- ]), [g, v] = L(!1), [m, x] = L({
43
- x: 0,
44
- y: 0,
45
- w: 0,
46
- h: 0,
47
- dir: ""
48
- }), { align: C, inline: T } = (O = e == null ? void 0 : e.node) == null ? void 0 : O.attrs, _ = T && (C === "left" || C === "right"), S = P(() => {
49
- var V;
50
- const { src: n, alt: y, width: i, height: r, flipX: h, flipY: l } = (V = e == null ? void 0 : e.node) == null ? void 0 : V.attrs, w = K(i) ? `${i}px` : i, I = K(r) ? `${r}px` : r, Y = [];
51
- h && Y.push("rotateX(180deg)"), l && Y.push("rotateY(180deg)");
52
- const me = Y.join(" ");
53
- return {
54
- src: n || void 0,
55
- alt: y || void 0,
56
- style: {
57
- width: w || void 0,
58
- height: I || void 0,
59
- transform: me || "none",
60
- ..._ ? { float: C } : {}
61
- }
62
- };
63
- }, [(d = e == null ? void 0 : e.node) == null ? void 0 : d.attrs]), k = P(() => {
64
- const {
65
- style: { width: n }
66
- } = S;
67
- return { width: n === "100%" ? n : void 0 };
68
- }, [S]);
69
- function R(n) {
70
- f({
71
- width: n.target.width,
72
- height: n.target.height
73
- });
74
- }
75
- function M() {
76
- const { editor: n, getPos: y } = e;
77
- n.commands.setNodeSelection(y());
78
- }
79
- const E = F(
80
- q(() => {
81
- const { editor: n } = e, { width: y } = getComputedStyle(n.view.dom);
82
- a((i) => ({
83
- ...i,
84
- width: Number.parseInt(y, 10)
85
- }));
86
- }, J),
87
- [e == null ? void 0 : e.editor]
88
- );
89
- function z(n, y) {
90
- n.preventDefault(), n.stopPropagation();
91
- const i = s.width, r = s.height, h = i / r;
92
- let l = Number(e.node.attrs.width), w = Number(e.node.attrs.height);
93
- const I = t.width;
94
- l && !w ? (l = l > I ? I : l, w = Math.round(l / h)) : w && !l ? (l = Math.round(w * h), l = l > I ? I : l) : !l && !w ? (l = i > I ? I : i, w = Math.round(l / h)) : l = l > I ? I : l, v(!0), x({
95
- x: n.clientX,
96
- y: n.clientY,
97
- w: l,
98
- h: w,
99
- dir: y
100
- });
101
- }
102
- const A = F(
103
- q((n) => {
104
- if (n.preventDefault(), n.stopPropagation(), !g)
105
- return;
106
- const { x: y, w: i, dir: r } = m, h = (n.clientX - y) * (/l/.test(r) ? -1 : 1), l = xe(i + h, be, t.width);
107
- e.updateAttributes({
108
- width: l,
109
- height: null
110
- });
111
- }, J),
112
- [g, m, t, e.updateAttributes]
113
- ), p = F(
114
- (n) => {
115
- n.preventDefault(), n.stopPropagation(), g && (x({
116
- x: 0,
117
- y: 0,
118
- w: 0,
119
- h: 0,
120
- dir: ""
121
- }), v(!1), M());
122
- },
123
- [g, M]
124
- ), c = F(() => {
125
- document == null || document.addEventListener("mousemove", A, !0), document == null || document.addEventListener("mouseup", p, !0);
126
- }, [A, p]), U = F(() => {
127
- document == null || document.removeEventListener("mousemove", A, !0), document == null || document.removeEventListener("mouseup", p, !0);
128
- }, [A, p]);
129
- W(() => (g ? c() : U(), () => {
130
- U();
131
- }), [g, c, U]);
132
- const D = P(() => new ResizeObserver(() => E()), [E]);
133
- return W(() => (D.observe(e.editor.view.dom), () => {
134
- D.disconnect();
135
- }), [e.editor.view.dom, D]), /* @__PURE__ */ o(
136
- he,
137
- {
138
- as: T ? "span" : "div",
139
- className: "image-view",
140
- style: {
141
- float: _ ? C : void 0,
142
- margin: _ ? C === "left" ? "1em 1em 1em 0" : "1em 0 1em 1em" : void 0,
143
- display: T ? "inline" : "block",
144
- textAlign: _ ? void 0 : C,
145
- width: ((N = S.style) == null ? void 0 : N.width) ?? "auto",
146
- ..._ ? {} : k
147
- },
148
- children: /* @__PURE__ */ b(
149
- "div",
150
- {
151
- "data-drag-handle": !0,
152
- draggable: "true",
153
- style: k,
154
- className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${g ? "image-view__body--resizing" : ""}`,
155
- children: [
156
- /* @__PURE__ */ o(
157
- "img",
158
- {
159
- alt: S.alt,
160
- className: "image-view__body__image block",
161
- height: "auto",
162
- onClick: M,
163
- onLoad: R,
164
- src: S.src,
165
- style: S.style
166
- }
167
- ),
168
- (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || g) && /* @__PURE__ */ o("div", { className: "image-resizer", children: u == null ? void 0 : u.map((n) => /* @__PURE__ */ o(
169
- "span",
170
- {
171
- className: `image-resizer__handler image-resizer__handler--${n}`,
172
- onMouseDown: (y) => z(y, n)
173
- },
174
- `image-dir-${n}`
175
- )) })
176
- ]
177
- }
178
- )
179
- }
180
- );
181
- }
182
- function ke(e, t) {
183
- const a = e.type, s = e.name.toLowerCase(), f = s.split(".").pop();
184
- if (!f) return !1;
185
- const g = a || {
186
- heif: "image/heif",
187
- heic: "image/heic",
188
- dng: "image/x-adobe-dng",
189
- cr2: "image/x-canon-cr2",
190
- nef: "image/x-nikon-nef",
191
- arw: "image/x-sony-arw",
192
- raf: "image/x-fuji-raf",
193
- orf: "image/x-olympus-orf"
194
- }[f];
195
- return t.some((v) => {
196
- if (v.startsWith("."))
197
- return s.endsWith(v);
198
- if (v.endsWith("/*")) {
199
- const m = v.split("/")[0];
200
- return g == null ? void 0 : g.startsWith(m + "/");
201
- }
202
- return g === v;
203
- });
204
- }
205
- function ue(e, t) {
206
- const { acceptMimes: a, maxSize: s, t: f, toast: u } = t, g = [];
207
- return (Array.isArray(e) ? e : Object.values(e)).forEach((m) => {
208
- if (!ke(m, a)) {
209
- t.onError ? t.onError({
210
- type: "type",
211
- message: f("editor.upload.fileTypeNotSupported", { fileName: m.name }),
212
- file: m
213
- }) : u({
214
- variant: "default",
215
- title: f("editor.upload.fileTypeNotSupported", { fileName: m.name })
216
- });
217
- return;
218
- }
219
- if (m.size > s) {
220
- const x = (s / 1024 / 1024).toFixed(2);
221
- t.onError ? t.onError({
222
- type: "size",
223
- message: f("editor.upload.fileSizeTooBig", { fileName: m.name, size: x }),
224
- file: m
225
- }) : u({
226
- variant: "default",
227
- title: f("editor.upload.fileSizeTooBig", { fileName: m.name, size: x })
228
- });
229
- return;
230
- }
231
- g.push(m);
232
- }), g;
233
- }
234
- function Ue({ editor: e, imageInline: t, onClose: a, disabled: s, alt: f }) {
235
- var n, y;
236
- const { t: u } = ne(), { toast: g } = de(), [v, m] = L(!1), [x, C] = L(!1), T = j.useRef(null), [_, S] = j.useState(), [k, R] = j.useState(""), M = ae(null), [E, z] = L({
237
- src: "",
238
- file: null
239
- }), A = ce(G.name), p = P(() => (A == null ? void 0 : A.options) ?? {}, [A]);
240
- function c(i) {
241
- if (T.current && i.width && i.height) {
242
- const r = U(T.current, i);
243
- R(r);
244
- }
245
- }
246
- function U(i, r) {
247
- const h = document.createElement("canvas"), l = i.naturalWidth / i.width, w = i.naturalHeight / i.height;
248
- h.width = r.width * l, h.height = r.height * w;
249
- const I = h.getContext("2d");
250
- return I && (I.imageSmoothingEnabled = !1, I.drawImage(
251
- i,
252
- r.x * l,
253
- r.y * w,
254
- r.width * l,
255
- r.height * w,
256
- 0,
257
- 0,
258
- r.width * l,
259
- r.height * w
260
- )), h.toDataURL("image/png", 1);
261
- }
262
- const D = j.useCallback(async () => {
263
- var i;
264
- if (!x) {
265
- C(!0);
266
- try {
267
- const r = Ce(k, ((i = E == null ? void 0 : E.file) == null ? void 0 : i.name) || "image.png");
268
- let h = "";
269
- p.upload ? h = await p.upload(r) : h = URL.createObjectURL(r), e.chain().focus().setImageInline({ src: h, inline: t, alt: f }).run(), m(!1), z({
270
- src: "",
271
- file: null
272
- }), N(), a();
273
- } catch (r) {
274
- console.error("Error cropping image", r);
275
- } finally {
276
- C(!1);
277
- }
278
- }
279
- }, [k, e, t, x, a, (n = E == null ? void 0 : E.file) == null ? void 0 : n.name, p]);
280
- function O(i) {
281
- var r;
282
- i.preventDefault(), (r = M.current) == null || r.click();
283
- }
284
- const d = async (i) => {
285
- var I;
286
- const r = (I = i == null ? void 0 : i.target) == null ? void 0 : I.files;
287
- if (!e || e.isDestroyed || r.length === 0) {
288
- i.target.value = "";
289
- return;
290
- }
291
- const h = ue(r, {
292
- acceptMimes: p == null ? void 0 : p.acceptMimes,
293
- maxSize: p == null ? void 0 : p.maxSize,
294
- t: u,
295
- toast: g,
296
- onError: p.onError
297
- });
298
- if (h.length <= 0) {
299
- i.target.value = "";
300
- return;
301
- }
302
- const l = h[0], w = await Ee(l);
303
- m(!0), z({
304
- src: w.src,
305
- file: l
306
- });
307
- }, N = () => {
308
- M.current && (M.current.value = "");
309
- };
310
- return /* @__PURE__ */ b(H, { children: [
311
- /* @__PURE__ */ o(
312
- B,
313
- {
314
- className: "richtext-mt-1 richtext-w-full",
315
- disabled: s,
316
- onClick: O,
317
- size: "sm",
318
- children: u("editor.image.dialog.tab.uploadCrop")
319
- }
320
- ),
321
- /* @__PURE__ */ b(
322
- re,
323
- {
324
- open: v,
325
- onOpenChange: (i) => {
326
- m(i), i || (z({ src: "", file: null }), N());
327
- },
328
- children: [
329
- /* @__PURE__ */ o(le, {}),
330
- /* @__PURE__ */ b(oe, { children: [
331
- /* @__PURE__ */ o(se, { children: u("editor.image.dialog.tab.uploadCrop") }),
332
- /* @__PURE__ */ o("div", { children: E.src && /* @__PURE__ */ o(
333
- Ie,
334
- {
335
- className: "richtext-w-full",
336
- crop: _,
337
- onChange: (i) => S(i),
338
- onComplete: (i) => c(i),
339
- children: /* @__PURE__ */ o(
340
- "img",
341
- {
342
- alt: "Crop me",
343
- ref: T,
344
- src: E.src
345
- }
346
- )
347
- }
348
- ) }),
349
- /* @__PURE__ */ b(we, { children: [
350
- /* @__PURE__ */ b(
351
- B,
352
- {
353
- disabled: x,
354
- onClick: () => {
355
- m(!1), z({
356
- src: "",
357
- file: null
358
- }), N();
359
- },
360
- children: [
361
- u("editor.imageUpload.cancel"),
362
- /* @__PURE__ */ o(
363
- $,
364
- {
365
- className: "richtext-ml-1",
366
- name: "Trash2"
367
- }
368
- )
369
- ]
370
- }
371
- ),
372
- /* @__PURE__ */ o(
373
- B,
374
- {
375
- className: "richtext-w-fit",
376
- disabled: x || !_,
377
- onClick: D,
378
- children: x ? /* @__PURE__ */ b(H, { children: [
379
- u("editor.imageUpload.uploading"),
380
- /* @__PURE__ */ o(
381
- $,
382
- {
383
- className: "richtext-ml-1 richtext-animate-spin",
384
- name: "Loader"
385
- }
386
- )
387
- ] }) : /* @__PURE__ */ b(H, { children: [
388
- u("editor.imageUpload.crop"),
389
- /* @__PURE__ */ o(
390
- $,
391
- {
392
- className: "richtext-ml-1",
393
- name: "Crop"
394
- }
395
- )
396
- ] })
397
- }
398
- )
399
- ] })
400
- ] })
401
- ]
402
- }
403
- ),
404
- /* @__PURE__ */ o(
405
- "input",
406
- {
407
- accept: ((y = p == null ? void 0 : p.acceptMimes) == null ? void 0 : y.join(",")) || "image/*",
408
- multiple: !1,
409
- onChange: d,
410
- ref: M,
411
- style: { display: "none" },
412
- type: "file"
413
- }
414
- )
415
- ] });
416
- }
417
- function lt() {
418
- const { t: e } = ne(), { toast: t } = de(), a = ve(), s = Te(G.name), {
419
- icon: f,
420
- tooltip: u
421
- } = (s == null ? void 0 : s.componentProps) ?? {}, { editorDisabled: g } = Ae(), [v, m] = L(!1), [x, C] = L(!1), T = ce(G.name), _ = (d) => {
422
- m(d.detail);
423
- }, [S, k] = L(""), [R, M] = L(""), E = ae(null), z = (T == null ? void 0 : T.options.defaultInline) || !1, [A, p] = L(z), c = P(() => T == null ? void 0 : T.options, [T]);
424
- W(() => {
425
- const d = Le(Ne.UPLOAD_IMAGE(a.id), _);
426
- return () => {
427
- d();
428
- };
429
- }, []);
430
- async function U(d) {
431
- var y;
432
- const N = (y = d == null ? void 0 : d.target) == null ? void 0 : y.files;
433
- if (!a || a.isDestroyed || N.length === 0 || x) {
434
- d.target.value = "";
435
- return;
436
- }
437
- const n = ue(N, {
438
- acceptMimes: c == null ? void 0 : c.acceptMimes,
439
- maxSize: c == null ? void 0 : c.maxSize,
440
- t: e,
441
- toast: t,
442
- onError: c.onError
443
- });
444
- if (n.length <= 0) {
445
- d.target.value = "";
446
- return;
447
- }
448
- C(!0);
449
- try {
450
- if (c != null && c.multiple) {
451
- const i = n.map(async (h) => {
452
- let l = "";
453
- return c.upload ? l = await c.upload(h) : l = URL.createObjectURL(h), l;
454
- });
455
- (await Promise.all(i)).forEach((h) => {
456
- a.chain().focus().setImageInline({ src: h, inline: A, alt: R }).run();
457
- });
458
- } else {
459
- const i = n[0];
460
- let r = "";
461
- c.upload ? r = await c.upload(i) : r = URL.createObjectURL(i), a.chain().focus().setImageInline({ src: r, inline: A, alt: R }).run();
462
- }
463
- m(!1), M(""), p(z);
464
- } catch (i) {
465
- console.error("Error uploading image", i), c.onError ? c.onError({
466
- type: "upload",
467
- message: e("editor.upload.error")
468
- }) : t({
469
- variant: "destructive",
470
- title: e("editor.upload.error")
471
- });
472
- } finally {
473
- C(!1), d.target.value = "";
474
- }
475
- }
476
- function D(d) {
477
- d.preventDefault(), d.stopPropagation(), a.chain().focus().setImageInline({ src: S, inline: A, alt: R }).run(), m(!1), p(z), k(""), M("");
478
- }
479
- function O(d) {
480
- var N;
481
- d.preventDefault(), (N = E.current) == null || N.click();
482
- }
483
- return s ? /* @__PURE__ */ b(
484
- re,
485
- {
486
- onOpenChange: m,
487
- open: v,
488
- children: [
489
- /* @__PURE__ */ o(
490
- le,
491
- {
492
- asChild: !0,
493
- children: /* @__PURE__ */ o(
494
- ye,
495
- {
496
- disabled: g,
497
- icon: f,
498
- tooltip: u,
499
- action: () => {
500
- g || m(!0);
501
- }
502
- }
503
- )
504
- }
505
- ),
506
- /* @__PURE__ */ b(oe, { children: [
507
- /* @__PURE__ */ o(se, { children: e("editor.image.dialog.title") }),
508
- /* @__PURE__ */ b(
509
- Se,
510
- {
511
- activationMode: "manual",
512
- defaultValue: c.resourceImage === "both" || c.resourceImage === "upload" ? "upload" : "link",
513
- children: [
514
- c.resourceImage === "both" && /* @__PURE__ */ b(_e, { className: "richtext-grid richtext-w-full richtext-grid-cols-2", children: [
515
- /* @__PURE__ */ o(Q, { value: "upload", children: e("editor.image.dialog.tab.upload") }),
516
- /* @__PURE__ */ o(Q, { value: "link", children: e("editor.image.dialog.tab.url") })
517
- ] }),
518
- /* @__PURE__ */ b("div", { className: "richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]", children: [
519
- /* @__PURE__ */ o(
520
- ze,
521
- {
522
- checked: A,
523
- onCheckedChange: (d) => {
524
- p(d);
525
- }
526
- }
527
- ),
528
- /* @__PURE__ */ o(te, { children: e("editor.link.dialog.inline") })
529
- ] }),
530
- c.enableAlt && /* @__PURE__ */ b("div", { className: "richtext-my-[10px] ", children: [
531
- /* @__PURE__ */ o(te, { className: "mb-[6px]", children: e("editor.imageUpload.alt") }),
532
- /* @__PURE__ */ o(
533
- ie,
534
- {
535
- onChange: (d) => M(d.target.value),
536
- required: !0,
537
- type: "text",
538
- value: R
539
- }
540
- )
541
- ] }),
542
- /* @__PURE__ */ b(ee, { value: "upload", children: [
543
- /* @__PURE__ */ b("div", { className: "richtext-flex richtext-items-center richtext-gap-[10px]", children: [
544
- /* @__PURE__ */ o(
545
- B,
546
- {
547
- className: "richtext-mt-1 richtext-w-full",
548
- disabled: x,
549
- onClick: O,
550
- size: "sm",
551
- children: x ? /* @__PURE__ */ b(H, { children: [
552
- e("editor.imageUpload.uploading"),
553
- /* @__PURE__ */ o(
554
- $,
555
- {
556
- className: "richtext-ml-1 richtext-animate-spin",
557
- name: "Loader"
558
- }
559
- )
560
- ] }) : e("editor.image.dialog.tab.upload")
561
- }
562
- ),
563
- /* @__PURE__ */ o(
564
- Ue,
565
- {
566
- alt: R,
567
- disabled: x,
568
- editor: a,
569
- imageInline: A,
570
- onClose: () => {
571
- Me.setOpen(a.id, !1), M("");
572
- }
573
- }
574
- )
575
- ] }),
576
- /* @__PURE__ */ o(
577
- "input",
578
- {
579
- accept: c.acceptMimes.join(",") || "image/*",
580
- multiple: c.multiple,
581
- onChange: U,
582
- ref: E,
583
- style: { display: "none" },
584
- type: "file"
585
- }
586
- )
587
- ] }),
588
- /* @__PURE__ */ o(ee, { value: "link", children: /* @__PURE__ */ o("form", { onSubmit: D, children: /* @__PURE__ */ b("div", { className: "richtext-flex richtext-items-center richtext-gap-2", children: [
589
- /* @__PURE__ */ o(
590
- ie,
591
- {
592
- autoFocus: !0,
593
- onChange: (d) => k(d.target.value),
594
- placeholder: e("editor.image.dialog.placeholder"),
595
- required: !0,
596
- type: "url",
597
- value: S
598
- }
599
- ),
600
- /* @__PURE__ */ o(B, { type: "submit", children: e("editor.image.dialog.button.apply") })
601
- ] }) }) })
602
- ]
603
- }
604
- )
605
- ] })
606
- ]
607
- }
608
- ) : /* @__PURE__ */ o(H, {});
609
- }
610
- const De = {
611
- acceptMimes: ["image/jpeg", "image/gif", "image/png", "image/jpg"],
612
- maxSize: 1024 * 1024 * 5,
613
- // 5MB
614
- multiple: !0,
615
- resourceImage: "both",
616
- defaultInline: !1,
617
- enableAlt: !0
618
- }, G = /* @__PURE__ */ pe.extend({
619
- group: "inline",
620
- inline: !0,
621
- defining: !0,
622
- draggable: !0,
623
- selectable: !0,
624
- addOptions() {
625
- var e;
626
- return {
627
- ...De,
628
- ...(e = this.parent) == null ? void 0 : e.call(this),
629
- upload: () => Promise.reject("Image Upload Function"),
630
- button: ({
631
- editor: t,
632
- extension: a,
633
- t: s
634
- }) => {
635
- var f, u;
636
- return {
637
- componentProps: {
638
- action: () => !0,
639
- upload: a.options.upload,
640
- /* If setImage is not available(when Image Component is not imported), the button is disabled */
641
- disabled: !((u = (f = t.can()).setImage) != null && u.call(f, {})),
642
- icon: "ImageUp",
643
- tooltip: s("editor.image.tooltip")
644
- }
645
- };
646
- }
647
- };
648
- },
649
- addAttributes() {
650
- var e;
651
- return {
652
- ...(e = this.parent) == null ? void 0 : e.call(this),
653
- flipX: {
654
- default: !1
655
- },
656
- flipY: {
657
- default: !1
658
- },
659
- width: {
660
- default: null,
661
- parseHTML: (t) => {
662
- const a = t.style.width || t.getAttribute("width") || null;
663
- return a ? Number.parseInt(a, 10) : null;
664
- },
665
- renderHTML: (t) => ({
666
- width: t.width
667
- })
668
- },
669
- align: {
670
- default: "center",
671
- parseHTML: (t) => t.getAttribute("align"),
672
- renderHTML: (t) => ({
673
- align: t.align
674
- })
675
- },
676
- inline: {
677
- default: !1,
678
- parseHTML: (t) => !!t.getAttribute("inline"),
679
- renderHTML: (t) => ({
680
- inline: t.inline
681
- })
682
- },
683
- alt: {
684
- default: "",
685
- parseHTML: (t) => t.getAttribute("alt"),
686
- renderHTML: (t) => ({
687
- alt: t.alt
688
- })
689
- }
690
- };
691
- },
692
- addNodeView() {
693
- return ge(Re);
694
- },
695
- addCommands() {
696
- var e;
697
- return {
698
- ...(e = this.parent) == null ? void 0 : e.call(this),
699
- setImageInline: (t) => ({ commands: a }) => a.insertContent({
700
- type: this.name,
701
- attrs: {
702
- ...t,
703
- inline: t.inline ?? this.options.defaultInline
704
- }
705
- }),
706
- updateImage: (t) => ({ commands: a }) => a.updateAttributes(this.name, t),
707
- setAlignImage: (t) => ({ commands: a }) => a.updateAttributes(this.name, { align: t })
708
- };
709
- },
710
- renderHTML({ HTMLAttributes: e }) {
711
- const { flipX: t, flipY: a, align: s, inline: f } = e, u = f && (s === "left" || s === "right"), g = t || a ? `transform: rotateX(${t ? "180" : "0"}deg) rotateY(${a ? "180" : "0"}deg);` : "", v = u ? "" : `text-align: ${s};`, C = `${u ? `float: ${s};` : ""}${u ? s === "left" ? "margin: 1em 1em 1em 0;" : "margin: 1em 0 1em 1em;" : ""}${g}`;
712
- return [
713
- f ? "span" : "div",
714
- {
715
- style: v,
716
- class: "image"
717
- },
718
- [
719
- "img",
720
- fe(
721
- {
722
- height: "auto",
723
- style: C
724
- },
725
- this.options.HTMLAttributes,
726
- e
727
- )
728
- ]
729
- ];
730
- },
731
- parseHTML() {
732
- return [
733
- {
734
- tag: "span.image img",
735
- getAttrs: (e) => {
736
- var u;
737
- const t = e == null ? void 0 : e.parentElement, a = e == null ? void 0 : e.getAttribute("width"), s = (e == null ? void 0 : e.getAttribute("flipx")) || !1, f = (e == null ? void 0 : e.getAttribute("flipy")) || !1;
738
- return {
739
- src: e == null ? void 0 : e.getAttribute("src"),
740
- alt: e == null ? void 0 : e.getAttribute("alt"),
741
- caption: e == null ? void 0 : e.getAttribute("caption"),
742
- width: a ? Number.parseInt(a, 10) : null,
743
- align: (e == null ? void 0 : e.getAttribute("align")) || ((u = t == null ? void 0 : t.style) == null ? void 0 : u.textAlign) || null,
744
- inline: (e == null ? void 0 : e.getAttribute("inline")) || !1,
745
- flipX: s === "true",
746
- flipY: f === "true"
747
- };
748
- }
749
- },
750
- {
751
- tag: "div[class=image]",
752
- getAttrs: (e) => {
753
- const t = e.querySelector("img"), a = t == null ? void 0 : t.getAttribute("width"), s = (t == null ? void 0 : t.getAttribute("flipx")) || !1, f = (t == null ? void 0 : t.getAttribute("flipy")) || !1;
754
- return {
755
- src: t == null ? void 0 : t.getAttribute("src"),
756
- alt: t == null ? void 0 : t.getAttribute("alt"),
757
- caption: t == null ? void 0 : t.getAttribute("caption"),
758
- width: a ? Number.parseInt(a, 10) : null,
759
- align: (t == null ? void 0 : t.getAttribute("align")) || e.style.textAlign || null,
760
- inline: (t == null ? void 0 : t.getAttribute("inline")) || !1,
761
- flipX: s === "true",
762
- flipY: f === "true"
763
- };
764
- }
765
- },
766
- {
767
- tag: 'img[src]:not([src^="data:"])'
768
- }
769
- ];
770
- }
771
- // addProseMirrorPlugins() {
772
- // const validateFile = (file: File): boolean => {
773
- // // @ts-expect-error
774
- // if (!this.options.acceptMimes.includes(file.type)) {
775
- // // toast({ description: t.value('editor.imageUpload.fileTypeNotSupported'), duration: 2000 });
776
- // return false;
777
- // }
778
- // // @ts-expect-error
779
- // if (file.size > this.options.maxSize) {
780
- // // toast({
781
- // // description: `${t.value('editor.imageUpload.fileSizeTooBig')} ${formatFileSize(
782
- // // this.options.maxSize,
783
- // // )}.`,
784
- // // duration: 2000,
785
- // // });
786
- // return false;
787
- // }
788
- // return true;
789
- // };
790
- // const uploadFn = createImageUpload({
791
- // validateFn: validateFile,
792
- // onUpload: this.options.upload as any,
793
- // // postUpload: this.options.postUpload,
794
- // defaultInline: this.options.defaultInline,
795
- // });
796
- // return [
797
- // UploadImagesPlugin(),
798
- // new Plugin({
799
- // key: new PluginKey(`richtextCustomPlugin${this.name}`),
800
- // props: {
801
- // handlePaste: (view, event) => {
802
- // const hasFiles =
803
- // event.clipboardData &&
804
- // event.clipboardData.files &&
805
- // event.clipboardData.files?.length;
806
- // if (!hasFiles) {
807
- // return;
808
- // }
809
- // const items = [...(event.clipboardData.files || [])];
810
- // if (items.some(x => x.type === 'text/html')) {
811
- // return false;
812
- // }
813
- // return handleImagePaste(view, event, uploadFn);
814
- // },
815
- // handleDrop: (view, event, _, moved) => {
816
- // if (!(event instanceof DragEvent) || !event.dataTransfer) {
817
- // return false;
818
- // }
819
- // handleImageDrop(view, event, moved, uploadFn);
820
- // return false;
821
- // },
822
- // },
823
- // }),
824
- // ];
825
- // },
826
- });
1
+ import "./clsx-DSzxBzvL.js";
2
+ import "./throttle-D040PfWL.js";
3
+ import { I as r, R as t } from "./Image-BZEFuS0P.js";
827
4
  export {
828
- G as Image,
829
- lt as RichTextImage
5
+ r as Image,
6
+ t as RichTextImage
830
7
  };