reactjs-tiptap-editor 1.0.16 → 1.0.17

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 (193) hide show
  1. package/lib/ActionMenuButton-B_E2mbAW.cjs +1 -0
  2. package/lib/{ActionMenuButton-a8LhmHXe.js → ActionMenuButton-lsIBc9sU.js} +12 -16
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +28 -32
  5. package/lib/Blockquote.cjs +2 -2
  6. package/lib/Blockquote.js +11 -13
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +13 -15
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +15 -17
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +56 -62
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +12 -13
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +8 -10
  17. package/lib/CodeBlock.cjs +29 -29
  18. package/lib/CodeBlock.js +11 -14
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +9 -11
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +26 -29
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +7 -9
  25. package/lib/{Drawer-CbOJ1Igo.js → Drawer-DQ4CxBwG.js} +23 -29
  26. package/lib/Drawer-FUeUKshi.cjs +1 -0
  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 +13 -15
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +276 -5
  33. package/lib/ExportPdf.cjs +2 -2
  34. package/lib/ExportPdf.js +19 -21
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +8 -10
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +9 -10
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +19 -20
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +27 -28
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +24 -27
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +25 -28
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +8 -10
  49. package/lib/{Iframe-CmjbQQcz.js → Iframe-CTajPyzs.js} +34 -38
  50. package/lib/Iframe-EVWXCqe4.cjs +1 -0
  51. package/lib/Iframe.cjs +1 -1
  52. package/lib/Iframe.js +2 -2
  53. package/lib/Image.cjs +1 -1
  54. package/lib/Image.js +4 -5
  55. package/lib/ImageGif.cjs +1 -1
  56. package/lib/ImageGif.js +109 -114
  57. package/lib/ImportWord.cjs +1 -1
  58. package/lib/ImportWord.js +15 -18
  59. package/lib/{Indent-BoG-vpIE.js → Indent-BGEHlRx_.js} +24 -26
  60. package/lib/Indent-q9cEWAa_.cjs +1 -0
  61. package/lib/Indent.cjs +1 -1
  62. package/lib/Indent.js +2 -2
  63. package/lib/Italic.cjs +1 -1
  64. package/lib/Italic.js +11 -13
  65. package/lib/Katex-ClqcEnN_.cjs +4 -0
  66. package/lib/{Katex-ByL9snce.js → Katex-tMh4bfBb.js} +19 -24
  67. package/lib/Katex.cjs +1 -1
  68. package/lib/Katex.js +2 -2
  69. package/lib/LineHeight.cjs +1 -1
  70. package/lib/LineHeight.js +17 -20
  71. package/lib/Link.cjs +1 -1
  72. package/lib/Link.js +2 -2
  73. package/lib/{LinkEditBlock-Ckih17pU.js → LinkEditBlock-CA5NhP-m.js} +19 -26
  74. package/lib/LinkEditBlock-DZXk4ln_.cjs +5 -0
  75. package/lib/Mention.js +3 -3
  76. package/lib/Mermaid.cjs +2 -2
  77. package/lib/Mermaid.js +31 -36
  78. package/lib/MoreMark.cjs +1 -1
  79. package/lib/MoreMark.js +25 -29
  80. package/lib/OrderedList.cjs +1 -1
  81. package/lib/OrderedList.js +13 -15
  82. package/lib/SearchAndReplace.cjs +1 -1
  83. package/lib/SearchAndReplace.js +62 -69
  84. package/lib/SlashCommand.cjs +1 -1
  85. package/lib/SlashCommand.js +5 -5
  86. package/lib/SlashCommandNodeView-CZoM3ZlS.cjs +1 -0
  87. package/lib/{SlashCommandNodeView-B2g1MbgN.js → SlashCommandNodeView-DLuqbX2o.js} +64 -69
  88. package/lib/Strike.cjs +1 -1
  89. package/lib/Strike.js +12 -14
  90. package/lib/{Table-BEwrZVup.js → Table-BC4Lbqzn.js} +27 -29
  91. package/lib/Table-BmDopO43.cjs +9 -0
  92. package/lib/Table.cjs +1 -1
  93. package/lib/Table.js +1 -1
  94. package/lib/TaskList.cjs +1 -1
  95. package/lib/TaskList.js +18 -20
  96. package/lib/TextAlign.cjs +1 -1
  97. package/lib/TextAlign.js +29 -33
  98. package/lib/TextDirection.cjs +1 -1
  99. package/lib/TextDirection.js +16 -20
  100. package/lib/TextUnderline.cjs +1 -1
  101. package/lib/TextUnderline.js +7 -9
  102. package/lib/Twitter-BbMD3Ybp.cjs +1 -0
  103. package/lib/{Twitter-4U_ZBhpv.js → Twitter-D8Cbgl7g.js} +17 -23
  104. package/lib/Twitter.cjs +1 -1
  105. package/lib/Twitter.js +2 -2
  106. package/lib/Video.cjs +1 -1
  107. package/lib/Video.js +5 -270
  108. package/lib/bubble.cjs +4 -4
  109. package/lib/bubble.js +543 -552
  110. package/lib/{clsx-DSzxBzvL.js → clsx-DaPvp9ji.js} +23 -23
  111. package/lib/components/ReactBus.d.ts +11 -0
  112. package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -0
  113. package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -0
  114. package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +5 -0
  115. package/lib/{dropdown-menu-eUeBXQeA.cjs → dropdown-menu-C_F7LEy5.cjs} +1 -1
  116. package/lib/{dropdown-menu-CW3Kthwy.js → dropdown-menu-q6RL_fkA.js} +1 -1
  117. package/lib/{index-4bHF5ovf.js → index-BDYJ8Ph2.js} +1 -1
  118. package/lib/index-BnVcq33n.cjs +1 -0
  119. package/lib/{index-DR5tIdL7.js → index-Do_dsOGB.js} +1 -1
  120. package/lib/{index-CpTykZBR.js → index-DqruLhsu.js} +1 -1
  121. package/lib/{index-D8li6EQ4.js → index-Qcl3BG94.js} +1 -1
  122. package/lib/index-RcSPeQHn.js +4941 -0
  123. package/lib/index.cjs +3 -3
  124. package/lib/index.js +45 -49
  125. package/lib/{popover-CeY3RbI5.js → popover-CtinPbiy.js} +1 -1
  126. package/lib/{popover-C6Cya3Cz.cjs → popover-DIMT3pae.cjs} +1 -1
  127. package/lib/{renderNodeView-CSazLrKF.js → renderNodeView-BEkECnnY.js} +2 -2
  128. package/lib/{select-Doa_-jkZ.cjs → select-CYyIeImH.cjs} +1 -1
  129. package/lib/{select-F0ZZ3VZB.js → select-CmV5uTXr.js} +1 -1
  130. package/lib/separator-BLp6xpSY.cjs +1 -0
  131. package/lib/{separator-Cjn4YH8a.js → separator-C7luvaG8.js} +13 -15
  132. package/lib/store/store.d.ts +2 -22
  133. package/lib/style.css +1 -1
  134. package/lib/{textarea-tOsPnxHf.js → textarea-CkVKMPqK.js} +1 -1
  135. package/lib/{textarea-BAolHF_W.cjs → textarea-Cn75Cm2n.cjs} +1 -1
  136. package/lib/{updatePosition-CDK7OR0i.js → updatePosition-DRmKQBGm.js} +2 -2
  137. package/lib/utils/checkIsVideoUrl.d.ts +1 -0
  138. package/lib/utils/customEvents/events.constant.d.ts +1 -0
  139. package/lib/utils/mitt.d.ts +6 -3
  140. package/package.json +1 -1
  141. package/lib/ActionMenuButton-BYu0NyVo.cjs +0 -1
  142. package/lib/Drawer-DNaDMoAk.cjs +0 -1
  143. package/lib/Excalidraw-DnHTVOj8.js +0 -355
  144. package/lib/Excalidraw-DxfO1lQ_.cjs +0 -1
  145. package/lib/Icon-C0TJMAOm.js +0 -12
  146. package/lib/Icon-DzK0_ztP.cjs +0 -1
  147. package/lib/Iframe-BSNCsofW.cjs +0 -1
  148. package/lib/Image-BZEFuS0P.js +0 -925
  149. package/lib/Image-iKsGKjvg.cjs +0 -1
  150. package/lib/Indent-Bou16OcB.cjs +0 -1
  151. package/lib/Katex-BqDocr3a.cjs +0 -4
  152. package/lib/LinkEditBlock-B0I0EUrt.cjs +0 -5
  153. package/lib/SlashCommandNodeView-BEJhEzba.cjs +0 -1
  154. package/lib/Table-BclWwp6P.cjs +0 -9
  155. package/lib/Twitter-Dtq6PEMC.cjs +0 -1
  156. package/lib/button-Bwn6gUuS.js +0 -43
  157. package/lib/button-CqJztfH2.cjs +0 -1
  158. package/lib/checkbox-BAzbZY2Y.cjs +0 -1
  159. package/lib/checkbox-B_rpz5Xq.js +0 -27
  160. package/lib/dialog-CJvpoeMm.js +0 -101
  161. package/lib/dialog-CWYTvz5J.cjs +0 -1
  162. package/lib/events.constant-Dq21NPdV.cjs +0 -1
  163. package/lib/events.constant-do95b767.js +0 -21
  164. package/lib/extensions/Image/store.d.ts +0 -4
  165. package/lib/extensions/Video/store.d.ts +0 -4
  166. package/lib/file-BLas99n7.js +0 -43
  167. package/lib/file-i7e4nQY2.cjs +0 -1
  168. package/lib/index-CL7JP-Xz.js +0 -426
  169. package/lib/index-Cn-t3Zxw.cjs +0 -1
  170. package/lib/index-DoiuU6VA.js +0 -2315
  171. package/lib/index-VhKd73hZ.cjs +0 -1
  172. package/lib/input-B1egKb-t.js +0 -21
  173. package/lib/input-ZGRt7lWR.cjs +0 -1
  174. package/lib/isNumber-BTYSVlKo.cjs +0 -1
  175. package/lib/isNumber-ClwLypY2.js +0 -15
  176. package/lib/label-Cjrzc5H2.js +0 -19
  177. package/lib/label-tzSPdqui.cjs +0 -1
  178. package/lib/separator-CUh5Y7Rh.cjs +0 -1
  179. package/lib/store/fast-context.d.ts +0 -7
  180. package/lib/store-BsJz5QRC.js +0 -10
  181. package/lib/store-DjkMIIEN.cjs +0 -1
  182. package/lib/tabs-BP8ypR_m.cjs +0 -1
  183. package/lib/tabs-CBDjOLl_.js +0 -46
  184. package/lib/throttle-D040PfWL.js +0 -249
  185. package/lib/throttle-gTTvqDTW.cjs +0 -1
  186. package/lib/toggle-C_SSvDRy.cjs +0 -1
  187. package/lib/toggle-DEerYRil.js +0 -99
  188. package/lib/tooltip-BJIvosho.js +0 -24
  189. package/lib/tooltip-FS1rsvd3.cjs +0 -1
  190. package/lib/useButtonProps-CtZCbMQu.js +0 -136
  191. package/lib/useButtonProps-Cz4W5dC8.cjs +0 -1
  192. package/lib/utils/_event.d.ts +0 -13
  193. package/lib/utils/customEvents/customEvents.d.ts +0 -3
package/lib/ImageGif.js CHANGED
@@ -1,15 +1,10 @@
1
- import { h as B, m as q, k as V } from "./clsx-DSzxBzvL.js";
2
- import { a as H, d as X, c as Y } from "./throttle-D040PfWL.js";
3
- import { jsx as u, jsxs as P, Fragment as Z } from "react/jsx-runtime";
4
- import { useState as G, useMemo as L, useCallback as M, useEffect as z, useRef as U } from "react";
5
- import { I as C, i as j, j as J } from "./index-C07N8gA1.js";
6
- import { i as W, c as Q } from "./isNumber-ClwLypY2.js";
7
- import { A as K } from "./toggle-DEerYRil.js";
8
- import "./index-DoiuU6VA.js";
1
+ import { h as B, m as q, k as V } from "./clsx-DaPvp9ji.js";
2
+ import { H as k, w as C, J as X, u as Y, d as D, A as Z, K as J, j as U, y as Q } from "./index-RcSPeQHn.js";
3
+ import { jsx as u, jsxs as z, Fragment as K } from "react/jsx-runtime";
4
+ import { useState as G, useMemo as P, useCallback as M, useEffect as $, useRef as ee } from "react";
5
+ import { I as j, i as W, j as te } from "./index-C07N8gA1.js";
9
6
  import "./theme.js";
10
- import { u as ee, a as D } from "./useButtonProps-CtZCbMQu.js";
11
- import { P as te, a as re, b as ne } from "./popover-CeY3RbI5.js";
12
- import { I as ie } from "./input-B1egKb-t.js";
7
+ import { P as ne, a as re, b as ie } from "./popover-CtinPbiy.js";
13
8
  const O = {
14
9
  TOP_LEFT: "tl",
15
10
  TOP_RIGHT: "tr",
@@ -17,14 +12,14 @@ const O = {
17
12
  BOTTOM_RIGHT: "br"
18
13
  };
19
14
  function ae(e) {
20
- var R, k;
21
- const [t, n] = G({
22
- width: C,
23
- height: C
15
+ var p, H;
16
+ const [t, r] = G({
17
+ width: j,
18
+ height: j
24
19
  }), [c, i] = G({
25
20
  width: 0,
26
21
  height: 0
27
- }), [r] = G([
22
+ }), [n] = G([
28
23
  O.TOP_LEFT,
29
24
  O.TOP_RIGHT,
30
25
  O.BOTTOM_LEFT,
@@ -35,66 +30,66 @@ function ae(e) {
35
30
  w: 0,
36
31
  h: 0,
37
32
  dir: ""
38
- }), { align: b } = (R = e == null ? void 0 : e.node) == null ? void 0 : R.attrs, m = L(() => {
33
+ }), { align: b } = (p = e == null ? void 0 : e.node) == null ? void 0 : p.attrs, g = P(() => {
39
34
  var w;
40
- const { src: o, alt: g, width: f, height: x } = (w = e == null ? void 0 : e.node) == null ? void 0 : w.attrs, A = W(f) ? `${f}px` : f, d = W(x) ? `${x}px` : x;
35
+ const { src: o, alt: m, width: f, height: x } = (w = e == null ? void 0 : e.node) == null ? void 0 : w.attrs, A = k(f) ? `${f}px` : f, d = k(x) ? `${x}px` : x;
41
36
  return {
42
37
  src: o || void 0,
43
- alt: g || void 0,
38
+ alt: m || void 0,
44
39
  style: {
45
40
  width: A || void 0,
46
41
  height: d || void 0
47
42
  }
48
43
  };
49
- }, [(k = e == null ? void 0 : e.node) == null ? void 0 : k.attrs]), _ = L(() => {
44
+ }, [(H = e == null ? void 0 : e.node) == null ? void 0 : H.attrs]), y = P(() => {
50
45
  const {
51
46
  style: { width: o }
52
- } = m;
47
+ } = g;
53
48
  return { width: o === "100%" ? o : void 0 };
54
- }, [m]);
49
+ }, [g]);
55
50
  function h(o) {
56
51
  i({
57
52
  width: o.target.width,
58
53
  height: o.target.height
59
54
  });
60
55
  }
61
- function y() {
62
- const { editor: o, getPos: g } = e;
63
- o.commands.setNodeSelection(g());
56
+ function _() {
57
+ const { editor: o, getPos: m } = e;
58
+ o.commands.setNodeSelection(m());
64
59
  }
65
- const T = M(
66
- H(() => {
67
- const { editor: o } = e, { width: g } = getComputedStyle(o.view.dom);
68
- n((f) => ({
60
+ const I = M(
61
+ C(() => {
62
+ const { editor: o } = e, { width: m } = getComputedStyle(o.view.dom);
63
+ r((f) => ({
69
64
  ...f,
70
- width: Number.parseInt(g, 10)
65
+ width: Number.parseInt(m, 10)
71
66
  }));
72
- }, j),
67
+ }, W),
73
68
  [e == null ? void 0 : e.editor]
74
69
  );
75
- function F(o, g) {
70
+ function F(o, m) {
76
71
  o.preventDefault(), o.stopPropagation();
77
72
  const f = c.width, x = c.height, A = f / x;
78
73
  let d = Number(e.node.attrs.width), w = Number(e.node.attrs.height);
79
- const I = t.width;
80
- d && !w ? (d = d > I ? I : d, w = Math.round(d / A)) : w && !d ? (d = Math.round(w * A), d = d > I ? I : d) : !d && !w ? (d = f > I ? I : f, w = Math.round(d / A)) : d = d > I ? I : d, s(!0), v({
74
+ const T = t.width;
75
+ d && !w ? (d = d > T ? T : d, w = Math.round(d / A)) : w && !d ? (d = Math.round(w * A), d = d > T ? T : d) : !d && !w ? (d = f > T ? T : f, w = Math.round(d / A)) : d = d > T ? T : d, s(!0), v({
81
76
  x: o.clientX,
82
77
  y: o.clientY,
83
78
  w: d,
84
79
  h: w,
85
- dir: g
80
+ dir: m
86
81
  });
87
82
  }
88
83
  const N = M(
89
- H((o) => {
84
+ C((o) => {
90
85
  if (o.preventDefault(), o.stopPropagation(), !a)
91
86
  return;
92
- const { x: g, w: f, dir: x } = l, A = (o.clientX - g) * (/l/.test(x) ? -1 : 1), d = Q(f + A, J, t.width);
87
+ const { x: m, w: f, dir: x } = l, A = (o.clientX - m) * (/l/.test(x) ? -1 : 1), d = X(f + A, te, t.width);
93
88
  e.updateAttributes({
94
89
  width: d,
95
90
  height: null
96
91
  });
97
- }, j),
92
+ }, W),
98
93
  [a, l, t, e.updateAttributes]
99
94
  ), E = M(
100
95
  (o) => {
@@ -104,50 +99,50 @@ function ae(e) {
104
99
  w: 0,
105
100
  h: 0,
106
101
  dir: ""
107
- }), s(!1), y());
102
+ }), s(!1), _());
108
103
  },
109
- [a, y]
110
- ), $ = M(() => {
104
+ [a, _]
105
+ ), R = M(() => {
111
106
  document == null || document.addEventListener("mousemove", N, !0), document == null || document.addEventListener("mouseup", E, !0);
112
- }, [N, E]), p = M(() => {
107
+ }, [N, E]), S = M(() => {
113
108
  document == null || document.removeEventListener("mousemove", N, !0), document == null || document.removeEventListener("mouseup", E, !0);
114
109
  }, [N, E]);
115
- z(() => (a ? $() : p(), () => {
116
- p();
117
- }), [a, $, p]);
118
- const S = L(() => new ResizeObserver(() => T()), [T]);
119
- return z(() => (S.observe(e.editor.view.dom), () => {
120
- S.disconnect();
121
- }), [e.editor.view.dom, S]), /* @__PURE__ */ u(
110
+ $(() => (a ? R() : S(), () => {
111
+ S();
112
+ }), [a, R, S]);
113
+ const L = P(() => new ResizeObserver(() => I()), [I]);
114
+ return $(() => (L.observe(e.editor.view.dom), () => {
115
+ L.disconnect();
116
+ }), [e.editor.view.dom, L]), /* @__PURE__ */ u(
122
117
  B,
123
118
  {
124
119
  className: "image-view",
125
- style: { ..._, width: "100%", textAlign: b },
126
- children: /* @__PURE__ */ P(
120
+ style: { ...y, width: "100%", textAlign: b },
121
+ children: /* @__PURE__ */ z(
127
122
  "div",
128
123
  {
129
124
  "data-drag-handle": !0,
130
125
  draggable: "true",
131
- style: _,
126
+ style: y,
132
127
  className: `image-view__body ${e != null && e.selected ? "image-view__body--focused" : ""} ${a ? "image-view__body--resizing" : ""}`,
133
128
  children: [
134
129
  /* @__PURE__ */ u(
135
130
  "img",
136
131
  {
137
- alt: m.alt,
132
+ alt: g.alt,
138
133
  className: "image-view__body__image block",
139
134
  height: "auto",
140
- onClick: y,
135
+ onClick: _,
141
136
  onLoad: h,
142
- src: m.src,
143
- style: m.style
137
+ src: g.src,
138
+ style: g.style
144
139
  }
145
140
  ),
146
- (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || a) && /* @__PURE__ */ u("div", { className: "image-resizer", children: r == null ? void 0 : r.map((o) => /* @__PURE__ */ u(
141
+ (e == null ? void 0 : e.editor.view.editable) && ((e == null ? void 0 : e.selected) || a) && /* @__PURE__ */ u("div", { className: "image-resizer", children: n == null ? void 0 : n.map((o) => /* @__PURE__ */ u(
147
142
  "span",
148
143
  {
149
144
  className: `image-resizer__handler image-resizer__handler--${o}`,
150
- onMouseDown: (g) => F(g, o)
145
+ onMouseDown: (m) => F(m, o)
151
146
  },
152
147
  `image-dir-${o}`
153
148
  )) })
@@ -159,12 +154,12 @@ function ae(e) {
159
154
  }
160
155
  async function se(e) {
161
156
  var c;
162
- const n = await (await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();
163
- return (c = n == null ? void 0 : n.data) == null ? void 0 : c.map((i) => {
164
- var r, a, s;
157
+ const r = await (await fetch(`https://api.giphy.com/v1/gifs/trending?q=&limit=15&api_key=${e}`)).json();
158
+ return (c = r == null ? void 0 : r.data) == null ? void 0 : c.map((i) => {
159
+ var n, a, s;
165
160
  return {
166
161
  id: i == null ? void 0 : i.id,
167
- src: (r = i == null ? void 0 : i.images.original) == null ? void 0 : r.url,
162
+ src: (n = i == null ? void 0 : i.images.original) == null ? void 0 : n.url,
168
163
  width: +((a = i == null ? void 0 : i.images.original) == null ? void 0 : a.width),
169
164
  height: +((s = i == null ? void 0 : i.images.original) == null ? void 0 : s.width)
170
165
  };
@@ -173,39 +168,39 @@ async function se(e) {
173
168
  async function oe(e, t) {
174
169
  var i;
175
170
  const c = await (await fetch(`https://api.giphy.com/v1/gifs/search?q=${e}&limit=15&api_key=${t}`)).json();
176
- return (i = c == null ? void 0 : c.data) == null ? void 0 : i.map((r) => {
171
+ return (i = c == null ? void 0 : c.data) == null ? void 0 : i.map((n) => {
177
172
  var a, s, l;
178
173
  return {
179
- id: r == null ? void 0 : r.id,
180
- src: (a = r == null ? void 0 : r.images.original) == null ? void 0 : a.url,
181
- width: +((s = r == null ? void 0 : r.images.original) == null ? void 0 : s.width),
182
- height: +((l = r == null ? void 0 : r.images.original) == null ? void 0 : l.width)
174
+ id: n == null ? void 0 : n.id,
175
+ src: (a = n == null ? void 0 : n.images.original) == null ? void 0 : a.url,
176
+ width: +((s = n == null ? void 0 : n.images.original) == null ? void 0 : s.width),
177
+ height: +((l = n == null ? void 0 : n.images.original) == null ? void 0 : l.width)
183
178
  };
184
179
  });
185
180
  }
186
181
  async function ce(e) {
187
- var r, a;
188
- const t = await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`), n = await (t == null ? void 0 : t.json()), i = await (await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(r = n == null ? void 0 : n.results) == null ? void 0 : r[0]}&limit=15`)).json();
182
+ var n, a;
183
+ const t = await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`), r = await (t == null ? void 0 : t.json()), i = await (await fetch(`https://tenor.googleapis.com/v2/search?key=${e}&q=${(n = r == null ? void 0 : r.results) == null ? void 0 : n[0]}&limit=15`)).json();
189
184
  return (a = i == null ? void 0 : i.results) == null ? void 0 : a.map((s) => {
190
- var l, v, b, m, _, h, y, T;
185
+ var l, v, b, g, y, h, _, I;
191
186
  return {
192
187
  id: s == null ? void 0 : s.id,
193
188
  src: (v = (l = s == null ? void 0 : s.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.url,
194
- width: (_ = (m = (b = s == null ? void 0 : s.media_formats) == null ? void 0 : b.gif) == null ? void 0 : m.dims) == null ? void 0 : _[0],
195
- height: (T = (y = (h = s == null ? void 0 : s.media_formats) == null ? void 0 : h.gif) == null ? void 0 : y.dims) == null ? void 0 : T[1]
189
+ width: (y = (g = (b = s == null ? void 0 : s.media_formats) == null ? void 0 : b.gif) == null ? void 0 : g.dims) == null ? void 0 : y[0],
190
+ height: (I = (_ = (h = s == null ? void 0 : s.media_formats) == null ? void 0 : h.gif) == null ? void 0 : _.dims) == null ? void 0 : I[1]
196
191
  };
197
192
  });
198
193
  }
199
194
  async function de(e, t) {
200
195
  var i;
201
196
  const c = await (await fetch(`https://tenor.googleapis.com/v2/search?key=${t}&q=${e}&limit=15`)).json();
202
- return (i = c == null ? void 0 : c.results) == null ? void 0 : i.map((r) => {
203
- var a, s, l, v, b, m, _, h;
197
+ return (i = c == null ? void 0 : c.results) == null ? void 0 : i.map((n) => {
198
+ var a, s, l, v, b, g, y, h;
204
199
  return {
205
- id: r == null ? void 0 : r.id,
206
- src: (s = (a = r == null ? void 0 : r.media_formats) == null ? void 0 : a.gif) == null ? void 0 : s.url,
207
- width: (b = (v = (l = r == null ? void 0 : r.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.dims) == null ? void 0 : b[0],
208
- height: (h = (_ = (m = r == null ? void 0 : r.media_formats) == null ? void 0 : m.gif) == null ? void 0 : _.dims) == null ? void 0 : h[1]
200
+ id: n == null ? void 0 : n.id,
201
+ src: (s = (a = n == null ? void 0 : n.media_formats) == null ? void 0 : a.gif) == null ? void 0 : s.url,
202
+ width: (b = (v = (l = n == null ? void 0 : n.media_formats) == null ? void 0 : l.gif) == null ? void 0 : v.dims) == null ? void 0 : b[0],
203
+ height: (h = (y = (g = n == null ? void 0 : n.media_formats) == null ? void 0 : g.gif) == null ? void 0 : y.dims) == null ? void 0 : h[1]
209
204
  };
210
205
  });
211
206
  }
@@ -215,32 +210,32 @@ function le(e, t) {
215
210
  searchWord: async (i) => t ? e === "giphy" ? oe(i, t) : e === "tenor" ? de(i, t) : [] : []
216
211
  };
217
212
  }
218
- function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
219
- const [i, r] = G(!1), [a, s] = G([]), { editorDisabled: l } = D(), v = U(null), { searchTrending: b, searchWord: m } = le(n, t);
220
- z(() => {
213
+ function he({ selectImage: e, apiKey: t, provider: r, children: c }) {
214
+ const [i, n] = G(!1), [a, s] = G([]), { editorDisabled: l } = D(), v = ee(null), { searchTrending: b, searchWord: g } = le(r, t);
215
+ $(() => {
221
216
  (async () => {
222
217
  const h = await b();
223
218
  s(h);
224
219
  })();
225
220
  }, []);
226
- const _ = M(
227
- X(async (h) => {
221
+ const y = M(
222
+ J(async (h) => {
228
223
  if (!h.target.value) {
229
- const T = await b();
230
- s(T);
224
+ const I = await b();
225
+ s(I);
231
226
  return;
232
227
  }
233
- const y = await m(h.target.value);
234
- s(y);
228
+ const _ = await g(h.target.value);
229
+ s(_);
235
230
  }, 350),
236
231
  // Adjust the debounce delay as needed
237
232
  []
238
233
  );
239
- return /* @__PURE__ */ P(
240
- te,
234
+ return /* @__PURE__ */ z(
235
+ ne,
241
236
  {
242
237
  modal: !0,
243
- onOpenChange: r,
238
+ onOpenChange: n,
244
239
  open: i,
245
240
  children: [
246
241
  /* @__PURE__ */ u(
@@ -252,17 +247,17 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
252
247
  }
253
248
  ),
254
249
  /* @__PURE__ */ u(
255
- ne,
250
+ ie,
256
251
  {
257
252
  align: "start",
258
253
  className: "richtext-size-full richtext-p-2",
259
254
  hideWhenDetached: !0,
260
255
  side: "bottom",
261
- children: t ? /* @__PURE__ */ P(Z, { children: [
256
+ children: t ? /* @__PURE__ */ z(K, { children: [
262
257
  /* @__PURE__ */ u("div", { className: "richtext-mb-[10px] richtext-w-full", children: /* @__PURE__ */ u(
263
- ie,
258
+ U,
264
259
  {
265
- onChange: _,
260
+ onChange: y,
266
261
  placeholder: "Search GIF",
267
262
  ref: v,
268
263
  type: "text"
@@ -275,7 +270,7 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
275
270
  className: "richtext-cursor-pointer richtext-object-contain richtext-text-center",
276
271
  src: h.src,
277
272
  onClick: () => {
278
- e(h.src), r(!1);
273
+ e(h.src), n(!1);
279
274
  }
280
275
  },
281
276
  h.id
@@ -287,34 +282,34 @@ function he({ selectImage: e, apiKey: t, provider: n, children: c }) {
287
282
  }
288
283
  );
289
284
  }
290
- function Ge() {
291
- const e = ee(ue.name), {
285
+ function _e() {
286
+ const e = Y(ue.name), {
292
287
  action: t,
293
- icon: n,
288
+ icon: r,
294
289
  tooltip: c,
295
290
  apiKey: i,
296
- provider: r
291
+ provider: n
297
292
  } = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a } = D();
298
293
  return /* @__PURE__ */ u(
299
294
  he,
300
295
  {
301
296
  apiKey: i,
302
- provider: r,
297
+ provider: n,
303
298
  selectImage: (l) => {
304
299
  a || t && t(l);
305
300
  },
306
301
  children: /* @__PURE__ */ u(
307
- K,
302
+ Z,
308
303
  {
309
304
  disabled: a,
310
- icon: n,
305
+ icon: r,
311
306
  tooltip: c
312
307
  }
313
308
  )
314
309
  }
315
310
  );
316
311
  }
317
- const ue = /* @__PURE__ */ Y.extend({
312
+ const ue = /* @__PURE__ */ Q.extend({
318
313
  name: "imageGif",
319
314
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
320
315
  //@ts-expect-error
@@ -331,9 +326,9 @@ const ue = /* @__PURE__ */ Y.extend({
331
326
  draggable: !1,
332
327
  selectable: !0,
333
328
  atom: !0,
334
- button: ({ editor: t, extension: n, t: c }) => {
329
+ button: ({ editor: t, extension: r, t: c }) => {
335
330
  var a, s;
336
- const i = ((a = n == null ? void 0 : n.options) == null ? void 0 : a.provider) || "", r = ((s = n == null ? void 0 : n.options) == null ? void 0 : s.API_KEY) || "";
331
+ const i = ((a = r == null ? void 0 : r.options) == null ? void 0 : a.provider) || "", n = ((s = r == null ? void 0 : r.options) == null ? void 0 : s.API_KEY) || "";
337
332
  return {
338
333
  componentProps: {
339
334
  action: (l) => {
@@ -343,7 +338,7 @@ const ue = /* @__PURE__ */ Y.extend({
343
338
  disabled: !1,
344
339
  icon: "GifIcon",
345
340
  tooltip: c("editor.imageGif.tooltip"),
346
- apiKey: r,
341
+ apiKey: n,
347
342
  provider: i
348
343
  }
349
344
  };
@@ -357,8 +352,8 @@ const ue = /* @__PURE__ */ Y.extend({
357
352
  width: {
358
353
  default: null,
359
354
  parseHTML: (t) => {
360
- const n = t.style.width || t.getAttribute("width") || "10";
361
- return n === void 0 ? null : Number.parseInt(`${n}`, 10);
355
+ const r = t.style.width || t.getAttribute("width") || "10";
356
+ return r === void 0 ? null : Number.parseInt(`${r}`, 10);
362
357
  },
363
358
  renderHTML: (t) => ({
364
359
  width: t.width
@@ -380,12 +375,12 @@ const ue = /* @__PURE__ */ Y.extend({
380
375
  var e;
381
376
  return {
382
377
  ...(e = this.parent) == null ? void 0 : e.call(this),
383
- setImageGif: (t) => ({ commands: n }) => n.insertContent({
378
+ setImageGif: (t) => ({ commands: r }) => r.insertContent({
384
379
  type: this.name,
385
380
  attrs: t
386
381
  }),
387
- updateImageGif: (t) => ({ commands: n }) => n.updateAttributes(this.name, t),
388
- setAlignImageGif: (t) => ({ commands: n }) => n.updateAttributes(this.name, { align: t })
382
+ updateImageGif: (t) => ({ commands: r }) => r.updateAttributes(this.name, t),
383
+ setAlignImageGif: (t) => ({ commands: r }) => r.updateAttributes(this.name, { align: t })
389
384
  };
390
385
  },
391
386
  renderHTML({ HTMLAttributes: e }) {
@@ -415,12 +410,12 @@ const ue = /* @__PURE__ */ Y.extend({
415
410
  {
416
411
  tag: "div[class=imageGIf]",
417
412
  getAttrs: (e) => {
418
- const t = e.querySelector("img"), n = t == null ? void 0 : t.getAttribute("width");
413
+ const t = e.querySelector("img"), r = t == null ? void 0 : t.getAttribute("width");
419
414
  return {
420
415
  src: t == null ? void 0 : t.getAttribute("src"),
421
416
  alt: t == null ? void 0 : t.getAttribute("alt"),
422
417
  title: t == null ? void 0 : t.getAttribute("title"),
423
- width: n ? Number.parseInt(n, 10) : null,
418
+ width: r ? Number.parseInt(r, 10) : null,
424
419
  align: (t == null ? void 0 : t.getAttribute("align")) || e.style.textAlign || null
425
420
  };
426
421
  }
@@ -430,5 +425,5 @@ const ue = /* @__PURE__ */ Y.extend({
430
425
  });
431
426
  export {
432
427
  ue as ImageGif,
433
- Ge as RichTextImageGif
428
+ _e as RichTextImageGif
434
429
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./clsx-CXbNJWDD.cjs"),l=require("react/jsx-runtime"),q=require("react"),H=require("mammoth"),N=require("./toggle-C_SSvDRy.cjs");require("./index-Cn-t3Zxw.cjs");require("./theme.cjs");const A=require("./Image-iKsGKjvg.cjs"),d=require("./useButtonProps-Cz4W5dC8.cjs"),k=require("./index-BsFvo9PG.cjs");function z(o,t){const s=atob(o.split(",")[1]),c=Array.from({length:s.length});for(let i=0;i<s.length;i++)c[i]=s.charCodeAt(i);const u=new Uint8Array(c);return new Blob([u],{type:t})}function D(o,t){return new File([o],t,{type:o.type})}function K(){const o=d.useEditorInstance(),t=d.useButtonProps(y.name),{icon:s=void 0,tooltip:c=void 0,tooltipOptions:u={},isActive:i=void 0,mammothOptions:w,limit:j,convert:b}=(t==null?void 0:t.componentProps)??{},{editorDisabled:W}=d.useToggleActive(i),p=d.useExtension(y.name),{toast:S}=A.useToast(),{t:B}=k.useLocale(),[C,v]=q.useState(!1),x=q.useRef(null);function O(){var e;(e=x.current)==null||e.click()}function R(e){const n=e.target.files[0];if(n){if(n.size>j){S({variant:"destructive",title:B("editor.importWord.limitSize")});return}F(n)}}async function E(e){const a=new DOMParser().parseFromString(e,"text/html"),f=a.querySelectorAll("img");if(f.length===0)return a.body.innerHTML;if(d.hasExtension(o,A.Image.name)){const g=p==null?void 0:p.options;if(g&&typeof g.upload=="function"){const T=[];for(const h of f){const m=h.getAttribute("src"),r=z(m,"image/jpeg"),M=D(r,"image.jpeg");T.push(M)}const L=await g.upload(T);for(const[h,m]of f.entries()){m.setAttribute("src",L[h].src);const r=m.parentElement;(r==null?void 0:r.tagName)==="P"&&(r.insertAdjacentElement("beforebegin",m),!r.hasChildNodes()&&r.textContent===""&&r.remove())}return a.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),a.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),a.body.innerHTML}async function F(e){v(!0);try{if(b){const n=await b(e);I(n)}else{const n=await e.arrayBuffer(),{value:a}=await H.convertToHtml({arrayBuffer:n},w);I(a)}}finally{v(!1)}}async function I(e){const n=await E(e);o.chain().setContent(n,!0).run()}return t?l.jsxs(l.Fragment,{children:[l.jsx(N.ActionButton,{action:O,disabled:W,icon:s,loading:C,tooltip:c,tooltipOptions:u}),l.jsx("input",{accept:".docx",onChange:R,ref:x,type:"file",style:{display:"none"}})]}):l.jsx(l.Fragment,{})}const y=P.Extension.create({name:"importWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({extension:t,t:s})=>{const{convert:c,limit:u,mammothOptions:i}=t.options;return{componentProps:{convert:c,limit:u,mammothOptions:i,icon:"Word",shortcutKeys:t.options.shortcutKeys??["alt","mod","S"],tooltip:s("editor.importWord.tooltip")}}}}}});exports.ImportWord=y;exports.RichTextImportWord=K;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("./clsx-CXbNJWDD.cjs"),u=require("react/jsx-runtime"),A=require("react"),H=require("mammoth"),s=require("./index-BnVcq33n.cjs");require("./theme.cjs");const P=require("./index-BsFvo9PG.cjs");function N(o,t){const a=atob(o.split(",")[1]),l=Array.from({length:a.length});for(let i=0;i<a.length;i++)l[i]=a.charCodeAt(i);const m=new Uint8Array(l);return new Blob([m],{type:t})}function k(o,t){return new File([o],t,{type:o.type})}function z(){const o=s.useEditorInstance(),t=s.useButtonProps(y.name),{icon:a=void 0,tooltip:l=void 0,tooltipOptions:m={},isActive:i=void 0,mammothOptions:w,limit:j,convert:b}=(t==null?void 0:t.componentProps)??{},{editorDisabled:W}=s.useToggleActive(i),p=s.useExtension(y.name),{toast:q}=s.useToast(),{t:S}=P.useLocale(),[C,v]=A.useState(!1),x=A.useRef(null);function O(){var e;(e=x.current)==null||e.click()}function R(e){const n=e.target.files[0];if(n){if(n.size>j){q({variant:"destructive",title:S("editor.importWord.limitSize")});return}E(n)}}async function B(e){const c=new DOMParser().parseFromString(e,"text/html"),f=c.querySelectorAll("img");if(f.length===0)return c.body.innerHTML;if(s.hasExtension(o,s.Image.name)){const g=p==null?void 0:p.options;if(g&&typeof g.upload=="function"){const T=[];for(const h of f){const d=h.getAttribute("src"),r=N(d,"image/jpeg"),L=k(r,"image.jpeg");T.push(L)}const F=await g.upload(T);for(const[h,d]of f.entries()){d.setAttribute("src",F[h].src);const r=d.parentElement;(r==null?void 0:r.tagName)==="P"&&(r.insertAdjacentElement("beforebegin",d),!r.hasChildNodes()&&r.textContent===""&&r.remove())}return c.body.innerHTML}else return console.warn("Image Upload method found, skip image conversion"),c.body.innerHTML}else return console.error("Image extension not found, unable to convert image"),c.body.innerHTML}async function E(e){v(!0);try{if(b){const n=await b(e);I(n)}else{const n=await e.arrayBuffer(),{value:c}=await H.convertToHtml({arrayBuffer:n},w);I(c)}}finally{v(!1)}}async function I(e){const n=await B(e);o.chain().setContent(n,!0).run()}return t?u.jsxs(u.Fragment,{children:[u.jsx(s.ActionButton,{action:O,disabled:W,icon:a,loading:C,tooltip:l,tooltipOptions:m}),u.jsx("input",{accept:".docx",onChange:R,ref:x,type:"file",style:{display:"none"}})]}):u.jsx(u.Fragment,{})}const y=M.Extension.create({name:"importWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),upload:void 0,convert:void 0,limit:1024*1024*10,button:({extension:t,t:a})=>{const{convert:l,limit:m,mammothOptions:i}=t.options;return{componentProps:{convert:l,limit:m,mammothOptions:i,icon:"Word",shortcutKeys:t.options.shortcutKeys??["alt","mod","S"],tooltip:a("editor.importWord.tooltip")}}}}}});exports.ImportWord=y;exports.RichTextImportWord=z;
package/lib/ImportWord.js CHANGED
@@ -1,12 +1,9 @@
1
- import { E as M } from "./clsx-DSzxBzvL.js";
1
+ import { E as M } from "./clsx-DaPvp9ji.js";
2
2
  import { jsx as g, Fragment as I, jsxs as P } from "react/jsx-runtime";
3
3
  import { useState as R, useRef as N } from "react";
4
4
  import k from "mammoth";
5
- import { A as z } from "./toggle-DEerYRil.js";
6
- import "./index-DoiuU6VA.js";
5
+ import { h as q, u as z, d as D, q as K, r as U, A as G, s as J, t as Q } from "./index-RcSPeQHn.js";
7
6
  import "./theme.js";
8
- import { u as D, I as K } from "./Image-BZEFuS0P.js";
9
- import { c as U, u as q, a as G, d as J, i as Q } from "./useButtonProps-CtZCbMQu.js";
10
7
  import { u as V } from "./index-C07N8gA1.js";
11
8
  function X(e, t) {
12
9
  const s = atob(e.split(",")[1]), c = Array.from({ length: s.length });
@@ -18,8 +15,8 @@ function X(e, t) {
18
15
  function Y(e, t) {
19
16
  return new File([e], t, { type: e.type });
20
17
  }
21
- function ct() {
22
- const e = U(), t = q(w.name), {
18
+ function it() {
19
+ const e = q(), t = z(w.name), {
23
20
  icon: s = void 0,
24
21
  tooltip: c = void 0,
25
22
  tooltipOptions: l = {},
@@ -27,7 +24,7 @@ function ct() {
27
24
  mammothOptions: T,
28
25
  limit: x,
29
26
  convert: h
30
- } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: C } = G(i), u = J(w.name), { toast: E } = D(), { t: W } = V(), [B, y] = R(!1), b = N(null);
27
+ } = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: C } = D(i), u = K(w.name), { toast: E } = U(), { t: W } = V(), [B, y] = R(!1), b = N(null);
31
28
  function L() {
32
29
  var o;
33
30
  (o = b.current) == null || o.click();
@@ -49,17 +46,17 @@ function ct() {
49
46
  const a = new DOMParser().parseFromString(o, "text/html"), p = a.querySelectorAll("img");
50
47
  if (p.length === 0)
51
48
  return a.body.innerHTML;
52
- if (Q(e, K.name)) {
53
- const f = u == null ? void 0 : u.options;
54
- if (f && typeof f.upload == "function") {
49
+ if (J(e, Q.name)) {
50
+ const d = u == null ? void 0 : u.options;
51
+ if (d && typeof d.upload == "function") {
55
52
  const A = [];
56
- for (const d of p) {
57
- const m = d.getAttribute("src"), r = X(m, "image/jpeg"), H = Y(r, "image.jpeg");
53
+ for (const f of p) {
54
+ const m = f.getAttribute("src"), r = X(m, "image/jpeg"), H = Y(r, "image.jpeg");
58
55
  A.push(H);
59
56
  }
60
- const F = await f.upload(A);
61
- for (const [d, m] of p.entries()) {
62
- m.setAttribute("src", F[d].src);
57
+ const F = await d.upload(A);
58
+ for (const [f, m] of p.entries()) {
59
+ m.setAttribute("src", F[f].src);
63
60
  const r = m.parentElement;
64
61
  (r == null ? void 0 : r.tagName) === "P" && (r.insertAdjacentElement("beforebegin", m), !r.hasChildNodes() && r.textContent === "" && r.remove());
65
62
  }
@@ -92,7 +89,7 @@ function ct() {
92
89
  }
93
90
  return t ? /* @__PURE__ */ P(I, { children: [
94
91
  /* @__PURE__ */ g(
95
- z,
92
+ G,
96
93
  {
97
94
  action: L,
98
95
  disabled: C,
@@ -148,5 +145,5 @@ const w = /* @__PURE__ */ M.create({
148
145
  });
149
146
  export {
150
147
  w as ImportWord,
151
- ct as RichTextImportWord
148
+ it as RichTextImportWord
152
149
  };