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.
- package/lib/ActionMenuButton-B_E2mbAW.cjs +1 -0
- package/lib/{ActionMenuButton-a8LhmHXe.js → ActionMenuButton-lsIBc9sU.js} +12 -16
- package/lib/Attachment.cjs +2 -2
- package/lib/Attachment.js +28 -32
- package/lib/Blockquote.cjs +2 -2
- package/lib/Blockquote.js +11 -13
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +13 -15
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +15 -17
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +56 -62
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +12 -13
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +8 -10
- package/lib/CodeBlock.cjs +29 -29
- package/lib/CodeBlock.js +11 -14
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +9 -11
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +26 -29
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -9
- package/lib/{Drawer-CbOJ1Igo.js → Drawer-DQ4CxBwG.js} +23 -29
- package/lib/Drawer-FUeUKshi.cjs +1 -0
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +13 -15
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +276 -5
- package/lib/ExportPdf.cjs +2 -2
- package/lib/ExportPdf.js +19 -21
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +8 -10
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +9 -10
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +19 -20
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +27 -28
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +24 -27
- package/lib/History.cjs +1 -1
- package/lib/History.js +25 -28
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +8 -10
- package/lib/{Iframe-CmjbQQcz.js → Iframe-CTajPyzs.js} +34 -38
- package/lib/Iframe-EVWXCqe4.cjs +1 -0
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +4 -5
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +109 -114
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +15 -18
- package/lib/{Indent-BoG-vpIE.js → Indent-BGEHlRx_.js} +24 -26
- package/lib/Indent-q9cEWAa_.cjs +1 -0
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +11 -13
- package/lib/Katex-ClqcEnN_.cjs +4 -0
- package/lib/{Katex-ByL9snce.js → Katex-tMh4bfBb.js} +19 -24
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +17 -20
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-Ckih17pU.js → LinkEditBlock-CA5NhP-m.js} +19 -26
- package/lib/LinkEditBlock-DZXk4ln_.cjs +5 -0
- package/lib/Mention.js +3 -3
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +31 -36
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +25 -29
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +13 -15
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +62 -69
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +5 -5
- package/lib/SlashCommandNodeView-CZoM3ZlS.cjs +1 -0
- package/lib/{SlashCommandNodeView-B2g1MbgN.js → SlashCommandNodeView-DLuqbX2o.js} +64 -69
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +12 -14
- package/lib/{Table-BEwrZVup.js → Table-BC4Lbqzn.js} +27 -29
- package/lib/Table-BmDopO43.cjs +9 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +18 -20
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +29 -33
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +16 -20
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +7 -9
- package/lib/Twitter-BbMD3Ybp.cjs +1 -0
- package/lib/{Twitter-4U_ZBhpv.js → Twitter-D8Cbgl7g.js} +17 -23
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -270
- package/lib/bubble.cjs +4 -4
- package/lib/bubble.js +543 -552
- package/lib/{clsx-DSzxBzvL.js → clsx-DaPvp9ji.js} +23 -23
- package/lib/components/ReactBus.d.ts +11 -0
- package/lib/components/SlashDialogTrigger/RenderDialogUploadImage.d.ts +1 -0
- package/lib/components/SlashDialogTrigger/RenderDialogUploadVideo.d.ts +1 -0
- package/lib/components/SlashDialogTrigger/SlashDialogTrigger.d.ts +5 -0
- package/lib/{dropdown-menu-eUeBXQeA.cjs → dropdown-menu-C_F7LEy5.cjs} +1 -1
- package/lib/{dropdown-menu-CW3Kthwy.js → dropdown-menu-q6RL_fkA.js} +1 -1
- package/lib/{index-4bHF5ovf.js → index-BDYJ8Ph2.js} +1 -1
- package/lib/index-BnVcq33n.cjs +1 -0
- package/lib/{index-DR5tIdL7.js → index-Do_dsOGB.js} +1 -1
- package/lib/{index-CpTykZBR.js → index-DqruLhsu.js} +1 -1
- package/lib/{index-D8li6EQ4.js → index-Qcl3BG94.js} +1 -1
- package/lib/index-RcSPeQHn.js +4941 -0
- package/lib/index.cjs +3 -3
- package/lib/index.js +45 -49
- package/lib/{popover-CeY3RbI5.js → popover-CtinPbiy.js} +1 -1
- package/lib/{popover-C6Cya3Cz.cjs → popover-DIMT3pae.cjs} +1 -1
- package/lib/{renderNodeView-CSazLrKF.js → renderNodeView-BEkECnnY.js} +2 -2
- package/lib/{select-Doa_-jkZ.cjs → select-CYyIeImH.cjs} +1 -1
- package/lib/{select-F0ZZ3VZB.js → select-CmV5uTXr.js} +1 -1
- package/lib/separator-BLp6xpSY.cjs +1 -0
- package/lib/{separator-Cjn4YH8a.js → separator-C7luvaG8.js} +13 -15
- package/lib/store/store.d.ts +2 -22
- package/lib/style.css +1 -1
- package/lib/{textarea-tOsPnxHf.js → textarea-CkVKMPqK.js} +1 -1
- package/lib/{textarea-BAolHF_W.cjs → textarea-Cn75Cm2n.cjs} +1 -1
- package/lib/{updatePosition-CDK7OR0i.js → updatePosition-DRmKQBGm.js} +2 -2
- package/lib/utils/checkIsVideoUrl.d.ts +1 -0
- package/lib/utils/customEvents/events.constant.d.ts +1 -0
- package/lib/utils/mitt.d.ts +6 -3
- package/package.json +1 -1
- package/lib/ActionMenuButton-BYu0NyVo.cjs +0 -1
- package/lib/Drawer-DNaDMoAk.cjs +0 -1
- package/lib/Excalidraw-DnHTVOj8.js +0 -355
- package/lib/Excalidraw-DxfO1lQ_.cjs +0 -1
- package/lib/Icon-C0TJMAOm.js +0 -12
- package/lib/Icon-DzK0_ztP.cjs +0 -1
- package/lib/Iframe-BSNCsofW.cjs +0 -1
- package/lib/Image-BZEFuS0P.js +0 -925
- package/lib/Image-iKsGKjvg.cjs +0 -1
- package/lib/Indent-Bou16OcB.cjs +0 -1
- package/lib/Katex-BqDocr3a.cjs +0 -4
- package/lib/LinkEditBlock-B0I0EUrt.cjs +0 -5
- package/lib/SlashCommandNodeView-BEJhEzba.cjs +0 -1
- package/lib/Table-BclWwp6P.cjs +0 -9
- package/lib/Twitter-Dtq6PEMC.cjs +0 -1
- package/lib/button-Bwn6gUuS.js +0 -43
- package/lib/button-CqJztfH2.cjs +0 -1
- package/lib/checkbox-BAzbZY2Y.cjs +0 -1
- package/lib/checkbox-B_rpz5Xq.js +0 -27
- package/lib/dialog-CJvpoeMm.js +0 -101
- package/lib/dialog-CWYTvz5J.cjs +0 -1
- package/lib/events.constant-Dq21NPdV.cjs +0 -1
- package/lib/events.constant-do95b767.js +0 -21
- package/lib/extensions/Image/store.d.ts +0 -4
- package/lib/extensions/Video/store.d.ts +0 -4
- package/lib/file-BLas99n7.js +0 -43
- package/lib/file-i7e4nQY2.cjs +0 -1
- package/lib/index-CL7JP-Xz.js +0 -426
- package/lib/index-Cn-t3Zxw.cjs +0 -1
- package/lib/index-DoiuU6VA.js +0 -2315
- package/lib/index-VhKd73hZ.cjs +0 -1
- package/lib/input-B1egKb-t.js +0 -21
- package/lib/input-ZGRt7lWR.cjs +0 -1
- package/lib/isNumber-BTYSVlKo.cjs +0 -1
- package/lib/isNumber-ClwLypY2.js +0 -15
- package/lib/label-Cjrzc5H2.js +0 -19
- package/lib/label-tzSPdqui.cjs +0 -1
- package/lib/separator-CUh5Y7Rh.cjs +0 -1
- package/lib/store/fast-context.d.ts +0 -7
- package/lib/store-BsJz5QRC.js +0 -10
- package/lib/store-DjkMIIEN.cjs +0 -1
- package/lib/tabs-BP8ypR_m.cjs +0 -1
- package/lib/tabs-CBDjOLl_.js +0 -46
- package/lib/throttle-D040PfWL.js +0 -249
- package/lib/throttle-gTTvqDTW.cjs +0 -1
- package/lib/toggle-C_SSvDRy.cjs +0 -1
- package/lib/toggle-DEerYRil.js +0 -99
- package/lib/tooltip-BJIvosho.js +0 -24
- package/lib/tooltip-FS1rsvd3.cjs +0 -1
- package/lib/useButtonProps-CtZCbMQu.js +0 -136
- package/lib/useButtonProps-Cz4W5dC8.cjs +0 -1
- package/lib/utils/_event.d.ts +0 -13
- 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-
|
|
2
|
-
import {
|
|
3
|
-
import { jsx as u, jsxs as
|
|
4
|
-
import { useState as G, useMemo as
|
|
5
|
-
import { I as
|
|
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 {
|
|
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
|
|
21
|
-
const [t,
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
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
|
-
}), [
|
|
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 } = (
|
|
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:
|
|
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:
|
|
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
|
-
}, [(
|
|
44
|
+
}, [(H = e == null ? void 0 : e.node) == null ? void 0 : H.attrs]), y = P(() => {
|
|
50
45
|
const {
|
|
51
46
|
style: { width: o }
|
|
52
|
-
} =
|
|
47
|
+
} = g;
|
|
53
48
|
return { width: o === "100%" ? o : void 0 };
|
|
54
|
-
}, [
|
|
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
|
|
62
|
-
const { editor: o, getPos:
|
|
63
|
-
o.commands.setNodeSelection(
|
|
56
|
+
function _() {
|
|
57
|
+
const { editor: o, getPos: m } = e;
|
|
58
|
+
o.commands.setNodeSelection(m());
|
|
64
59
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const { editor: o } = e, { width:
|
|
68
|
-
|
|
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(
|
|
65
|
+
width: Number.parseInt(m, 10)
|
|
71
66
|
}));
|
|
72
|
-
},
|
|
67
|
+
}, W),
|
|
73
68
|
[e == null ? void 0 : e.editor]
|
|
74
69
|
);
|
|
75
|
-
function F(o,
|
|
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
|
|
80
|
-
d && !w ? (d = d >
|
|
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:
|
|
80
|
+
dir: m
|
|
86
81
|
});
|
|
87
82
|
}
|
|
88
83
|
const N = M(
|
|
89
|
-
|
|
84
|
+
C((o) => {
|
|
90
85
|
if (o.preventDefault(), o.stopPropagation(), !a)
|
|
91
86
|
return;
|
|
92
|
-
const { x:
|
|
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
|
-
},
|
|
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),
|
|
102
|
+
}), s(!1), _());
|
|
108
103
|
},
|
|
109
|
-
[a,
|
|
110
|
-
),
|
|
104
|
+
[a, _]
|
|
105
|
+
), R = M(() => {
|
|
111
106
|
document == null || document.addEventListener("mousemove", N, !0), document == null || document.addEventListener("mouseup", E, !0);
|
|
112
|
-
}, [N, E]),
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
}), [a,
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
|
|
121
|
-
}), [e.editor.view.dom,
|
|
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: { ...
|
|
126
|
-
children: /* @__PURE__ */
|
|
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:
|
|
132
|
+
alt: g.alt,
|
|
138
133
|
className: "image-view__body__image block",
|
|
139
134
|
height: "auto",
|
|
140
|
-
onClick:
|
|
135
|
+
onClick: _,
|
|
141
136
|
onLoad: h,
|
|
142
|
-
src:
|
|
143
|
-
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:
|
|
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: (
|
|
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
|
|
163
|
-
return (c =
|
|
164
|
-
var
|
|
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: (
|
|
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((
|
|
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:
|
|
180
|
-
src: (a =
|
|
181
|
-
width: +((s =
|
|
182
|
-
height: +((l =
|
|
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
|
|
188
|
-
const t = await fetch(`https://tenor.googleapis.com/v2/trending_terms?key=${e}&limit=10`),
|
|
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,
|
|
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: (
|
|
195
|
-
height: (
|
|
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((
|
|
203
|
-
var a, s, l, v, b,
|
|
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:
|
|
206
|
-
src: (s = (a =
|
|
207
|
-
width: (b = (v = (l =
|
|
208
|
-
height: (h = (
|
|
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:
|
|
219
|
-
const [i,
|
|
220
|
-
|
|
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
|
|
227
|
-
|
|
221
|
+
const y = M(
|
|
222
|
+
J(async (h) => {
|
|
228
223
|
if (!h.target.value) {
|
|
229
|
-
const
|
|
230
|
-
s(
|
|
224
|
+
const I = await b();
|
|
225
|
+
s(I);
|
|
231
226
|
return;
|
|
232
227
|
}
|
|
233
|
-
const
|
|
234
|
-
s(
|
|
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__ */
|
|
240
|
-
|
|
234
|
+
return /* @__PURE__ */ z(
|
|
235
|
+
ne,
|
|
241
236
|
{
|
|
242
237
|
modal: !0,
|
|
243
|
-
onOpenChange:
|
|
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
|
-
|
|
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__ */
|
|
256
|
+
children: t ? /* @__PURE__ */ z(K, { children: [
|
|
262
257
|
/* @__PURE__ */ u("div", { className: "richtext-mb-[10px] richtext-w-full", children: /* @__PURE__ */ u(
|
|
263
|
-
|
|
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),
|
|
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
|
|
291
|
-
const e =
|
|
285
|
+
function _e() {
|
|
286
|
+
const e = Y(ue.name), {
|
|
292
287
|
action: t,
|
|
293
|
-
icon:
|
|
288
|
+
icon: r,
|
|
294
289
|
tooltip: c,
|
|
295
290
|
apiKey: i,
|
|
296
|
-
provider:
|
|
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:
|
|
297
|
+
provider: n,
|
|
303
298
|
selectImage: (l) => {
|
|
304
299
|
a || t && t(l);
|
|
305
300
|
},
|
|
306
301
|
children: /* @__PURE__ */ u(
|
|
307
|
-
|
|
302
|
+
Z,
|
|
308
303
|
{
|
|
309
304
|
disabled: a,
|
|
310
|
-
icon:
|
|
305
|
+
icon: r,
|
|
311
306
|
tooltip: c
|
|
312
307
|
}
|
|
313
308
|
)
|
|
314
309
|
}
|
|
315
310
|
);
|
|
316
311
|
}
|
|
317
|
-
const ue = /* @__PURE__ */
|
|
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:
|
|
329
|
+
button: ({ editor: t, extension: r, t: c }) => {
|
|
335
330
|
var a, s;
|
|
336
|
-
const i = ((a =
|
|
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:
|
|
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
|
|
361
|
-
return
|
|
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:
|
|
378
|
+
setImageGif: (t) => ({ commands: r }) => r.insertContent({
|
|
384
379
|
type: this.name,
|
|
385
380
|
attrs: t
|
|
386
381
|
}),
|
|
387
|
-
updateImageGif: (t) => ({ commands:
|
|
388
|
-
setAlignImageGif: (t) => ({ commands:
|
|
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"),
|
|
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:
|
|
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
|
-
|
|
428
|
+
_e as RichTextImageGif
|
|
434
429
|
};
|
package/lib/ImportWord.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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-
|
|
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 {
|
|
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
|
|
22
|
-
const e =
|
|
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 } =
|
|
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 (
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
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
|
|
57
|
-
const m =
|
|
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
|
|
61
|
-
for (const [
|
|
62
|
-
m.setAttribute("src", F[
|
|
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
|
-
|
|
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
|
-
|
|
148
|
+
it as RichTextImportWord
|
|
152
149
|
};
|