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