sykpcomposer 0.0.252 → 0.0.253
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/dist/{ImageComponent-b85bff9f.js → ImageComponent-8ca7cea7.js} +308 -290
- package/dist/ImageComponent-8ca7cea7.js.map +1 -0
- package/dist/{InlineImageComponent-82c3932f.js → InlineImageComponent-0e08c4c2.js} +3 -3
- package/dist/{InlineImageComponent-82c3932f.js.map → InlineImageComponent-0e08c4c2.js.map} +1 -1
- package/dist/{LexicalNestedComposer.prod-2ca6d846.js → LexicalNestedComposer.prod-28bafc14.js} +2 -2
- package/dist/{LexicalNestedComposer.prod-2ca6d846.js.map → LexicalNestedComposer.prod-28bafc14.js.map} +1 -1
- package/dist/{index-73d1cd2f.js → index-2f6f39c0.js} +3 -3
- package/dist/{index-73d1cd2f.js.map → index-2f6f39c0.js.map} +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +23 -23
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/ImageComponent-b85bff9f.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { d as
|
|
3
|
-
import
|
|
1
|
+
import { j as b, u as ge, a as de, x as q, $ as J, d as G, w as ee, b as oe, c as ue, e as pe, f as we, C as I, g as me, k as fe, h as xe, I as ye, r as Ce, i as ve, l as De, m as be, t as Re } from "./index-2f6f39c0.js";
|
|
2
|
+
import { d as Ee, L as Me, P as Pe } from "./LexicalNestedComposer.prod-28bafc14.js";
|
|
3
|
+
import x, { useRef as Y, PureComponent as $e, createRef as se, useState as F, useEffect as te, useCallback as V, Suspense as He } from "react";
|
|
4
4
|
import "react-dom";
|
|
5
|
-
function
|
|
6
|
-
return Math.min(Math.max(
|
|
5
|
+
function ie(d, t, e) {
|
|
6
|
+
return Math.min(Math.max(d, t), e);
|
|
7
7
|
}
|
|
8
8
|
const y = {
|
|
9
9
|
east: 1,
|
|
@@ -11,8 +11,8 @@ const y = {
|
|
|
11
11
|
south: 2,
|
|
12
12
|
west: 4
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
onResizeStart:
|
|
14
|
+
function ze({
|
|
15
|
+
onResizeStart: d,
|
|
16
16
|
onResizeEnd: t,
|
|
17
17
|
buttonRef: e,
|
|
18
18
|
imageRef: o,
|
|
@@ -22,7 +22,7 @@ function Pe({
|
|
|
22
22
|
setShowCaption: p,
|
|
23
23
|
captionsEnabled: s
|
|
24
24
|
}) {
|
|
25
|
-
const i = Y(null),
|
|
25
|
+
const i = Y(null), l = Y({
|
|
26
26
|
priority: "",
|
|
27
27
|
value: "default"
|
|
28
28
|
}), a = Y({
|
|
@@ -35,8 +35,8 @@ function Pe({
|
|
|
35
35
|
startWidth: 0,
|
|
36
36
|
startX: 0,
|
|
37
37
|
startY: 0
|
|
38
|
-
}), g = r.getRootElement(), c = g !== null ? g.getBoundingClientRect().width - 20 : 100, C = g !== null ? g.getBoundingClientRect().height - 20 : 100, P = 100,
|
|
39
|
-
const u =
|
|
38
|
+
}), g = r.getRootElement(), c = g !== null ? g.getBoundingClientRect().width - 20 : 100, C = g !== null ? g.getBoundingClientRect().height - 20 : 100, P = 100, f = 100, H = (m) => {
|
|
39
|
+
const u = m === y.east || m === y.west, w = m === y.north || m === y.south, N = m & y.north && m & y.west || m & y.south && m & y.east, M = u ? "ew" : w ? "ns" : N ? "nwse" : "nesw";
|
|
40
40
|
g !== null && g.style.setProperty(
|
|
41
41
|
"cursor",
|
|
42
42
|
`${M}-resize`,
|
|
@@ -45,196 +45,196 @@ function Pe({
|
|
|
45
45
|
"cursor",
|
|
46
46
|
`${M}-resize`,
|
|
47
47
|
"important"
|
|
48
|
-
),
|
|
48
|
+
), l.current.value = document.body.style.getPropertyValue(
|
|
49
49
|
"-webkit-user-select"
|
|
50
|
-
),
|
|
50
|
+
), l.current.priority = document.body.style.getPropertyPriority(
|
|
51
51
|
"-webkit-user-select"
|
|
52
52
|
), document.body.style.setProperty(
|
|
53
53
|
"-webkit-user-select",
|
|
54
54
|
"none",
|
|
55
55
|
"important"
|
|
56
56
|
));
|
|
57
|
-
},
|
|
57
|
+
}, T = () => {
|
|
58
58
|
g !== null && g.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
|
|
59
59
|
"-webkit-user-select",
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
l.current.value,
|
|
61
|
+
l.current.priority
|
|
62
62
|
));
|
|
63
|
-
}, z = (
|
|
63
|
+
}, z = (m, u) => {
|
|
64
64
|
if (!r.isEditable())
|
|
65
65
|
return;
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const { width: M, height:
|
|
70
|
-
|
|
66
|
+
const w = o.current, N = i.current;
|
|
67
|
+
if (w !== null && N !== null) {
|
|
68
|
+
m.preventDefault();
|
|
69
|
+
const { width: M, height: v } = w.getBoundingClientRect(), D = a.current;
|
|
70
|
+
D.startWidth = M, D.startHeight = v, D.ratio = M / v, D.currentWidth = M, D.currentHeight = v, D.startX = m.clientX, D.startY = m.clientY, D.isResizing = !0, D.direction = u, H(u), d(), N.classList.add("image-control-wrapper--resizing"), w.style.height = `${v}px`, w.style.width = `${M}px`, document.addEventListener("pointermove", j), document.addEventListener("pointerup", k);
|
|
71
71
|
}
|
|
72
|
-
},
|
|
73
|
-
const u = o.current,
|
|
74
|
-
if (u !== null &&
|
|
75
|
-
if (
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
72
|
+
}, j = (m) => {
|
|
73
|
+
const u = o.current, w = a.current, N = w.direction & (y.east | y.west), M = w.direction & (y.south | y.north);
|
|
74
|
+
if (u !== null && w.isResizing) {
|
|
75
|
+
if (N && M) {
|
|
76
|
+
let v = Math.floor(w.startX - m.clientX);
|
|
77
|
+
v = w.direction & y.east ? -v : v;
|
|
78
|
+
const D = ie(
|
|
79
|
+
w.startWidth + v,
|
|
80
80
|
P,
|
|
81
81
|
c
|
|
82
|
-
),
|
|
83
|
-
u.style.width = `${
|
|
82
|
+
), A = D / w.ratio;
|
|
83
|
+
u.style.width = `${D}px`, u.style.height = `${A}px`, w.currentHeight = A, w.currentWidth = D;
|
|
84
84
|
} else if (M) {
|
|
85
|
-
let
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
let v = Math.floor(w.startY - m.clientY);
|
|
86
|
+
v = w.direction & y.south ? -v : v;
|
|
87
|
+
const D = ie(
|
|
88
|
+
w.startHeight + v,
|
|
89
|
+
f,
|
|
90
90
|
C
|
|
91
91
|
);
|
|
92
|
-
u.style.height = `${
|
|
92
|
+
u.style.height = `${D}px`, u.style.maxHeight = `${D}px`, w.currentHeight = D;
|
|
93
93
|
} else {
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
94
|
+
let v = Math.floor(w.startX - m.clientX);
|
|
95
|
+
v = w.direction & y.east ? -v : v;
|
|
96
|
+
const D = ie(
|
|
97
|
+
w.startWidth + v,
|
|
98
98
|
P,
|
|
99
99
|
c
|
|
100
100
|
);
|
|
101
|
-
u.style.width = `${
|
|
101
|
+
u.style.width = `${D}px`, u.style.maxWidth = `${D}px`, w.currentWidth = D;
|
|
102
102
|
}
|
|
103
|
-
u && (u.setAttribute("width", `${
|
|
103
|
+
u && (u.setAttribute("width", `${w.currentWidth}`), u.setAttribute("height", `${w.currentHeight}`));
|
|
104
104
|
}
|
|
105
105
|
}, k = () => {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
u.startWidth = 0, u.startHeight = 0, u.ratio = 0, u.startX = 0, u.startY = 0, u.currentWidth = 0, u.currentHeight = 0, u.isResizing = !1,
|
|
106
|
+
const m = o.current, u = a.current, w = i.current;
|
|
107
|
+
if (m !== null && w !== null && u.isResizing) {
|
|
108
|
+
const N = u.currentWidth, M = u.currentHeight;
|
|
109
|
+
u.startWidth = 0, u.startHeight = 0, u.ratio = 0, u.startX = 0, u.startY = 0, u.currentWidth = 0, u.currentHeight = 0, u.isResizing = !1, w.classList.remove("image-control-wrapper--resizing"), T(), t(N, M), document.removeEventListener("pointermove", j), document.removeEventListener("pointerup", k);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
return /* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ b.jsxs("div", { ref: i, children: [
|
|
113
|
+
/* @__PURE__ */ b.jsx(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
className: "image-resizer image-resizer-n",
|
|
117
|
-
onPointerDown: (
|
|
118
|
-
z(
|
|
117
|
+
onPointerDown: (m) => {
|
|
118
|
+
z(m, y.north);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ b.jsx(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
125
|
className: "image-resizer image-resizer-ne",
|
|
126
|
-
onPointerDown: (
|
|
127
|
-
z(
|
|
126
|
+
onPointerDown: (m) => {
|
|
127
|
+
z(m, y.north | y.east);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
),
|
|
131
|
-
/* @__PURE__ */
|
|
131
|
+
/* @__PURE__ */ b.jsx(
|
|
132
132
|
"div",
|
|
133
133
|
{
|
|
134
134
|
className: "image-resizer image-resizer-e",
|
|
135
|
-
onPointerDown: (
|
|
136
|
-
z(
|
|
135
|
+
onPointerDown: (m) => {
|
|
136
|
+
z(m, y.east);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
),
|
|
140
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ b.jsx(
|
|
141
141
|
"div",
|
|
142
142
|
{
|
|
143
143
|
className: "image-resizer image-resizer-se",
|
|
144
|
-
onPointerDown: (
|
|
145
|
-
z(
|
|
144
|
+
onPointerDown: (m) => {
|
|
145
|
+
z(m, y.south | y.east);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
),
|
|
149
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ b.jsx(
|
|
150
150
|
"div",
|
|
151
151
|
{
|
|
152
152
|
className: "image-resizer image-resizer-s",
|
|
153
|
-
onPointerDown: (
|
|
154
|
-
z(
|
|
153
|
+
onPointerDown: (m) => {
|
|
154
|
+
z(m, y.south);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
),
|
|
158
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ b.jsx(
|
|
159
159
|
"div",
|
|
160
160
|
{
|
|
161
161
|
className: "image-resizer image-resizer-sw",
|
|
162
|
-
onPointerDown: (
|
|
163
|
-
z(
|
|
162
|
+
onPointerDown: (m) => {
|
|
163
|
+
z(m, y.south | y.west);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ b.jsx(
|
|
168
168
|
"div",
|
|
169
169
|
{
|
|
170
170
|
className: "image-resizer image-resizer-w",
|
|
171
|
-
onPointerDown: (
|
|
172
|
-
z(
|
|
171
|
+
onPointerDown: (m) => {
|
|
172
|
+
z(m, y.west);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
),
|
|
176
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ b.jsx(
|
|
177
177
|
"div",
|
|
178
178
|
{
|
|
179
179
|
className: "image-resizer image-resizer-nw",
|
|
180
|
-
onPointerDown: (
|
|
181
|
-
z(
|
|
180
|
+
onPointerDown: (m) => {
|
|
181
|
+
z(m, y.north | y.west);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
)
|
|
185
185
|
] });
|
|
186
186
|
}
|
|
187
|
-
const
|
|
187
|
+
const ne = {
|
|
188
188
|
x: 0,
|
|
189
189
|
y: 0,
|
|
190
190
|
width: 0,
|
|
191
191
|
height: 0,
|
|
192
192
|
unit: "px"
|
|
193
|
-
},
|
|
194
|
-
function
|
|
195
|
-
return
|
|
193
|
+
}, W = (d, t, e) => Math.min(Math.max(d, t), e), Ne = (...d) => d.filter((t) => t && typeof t == "string").join(" "), ae = (d, t) => d === t || d.width === t.width && d.height === t.height && d.x === t.x && d.y === t.y && d.unit === t.unit;
|
|
194
|
+
function U(d, t, e) {
|
|
195
|
+
return d.unit === "%" ? { ...ne, ...d, unit: "%" } : {
|
|
196
196
|
unit: "%",
|
|
197
|
-
x:
|
|
198
|
-
y:
|
|
199
|
-
width:
|
|
200
|
-
height:
|
|
197
|
+
x: d.x ? d.x / t * 100 : 0,
|
|
198
|
+
y: d.y ? d.y / e * 100 : 0,
|
|
199
|
+
width: d.width ? d.width / t * 100 : 0,
|
|
200
|
+
height: d.height ? d.height / e * 100 : 0
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
function _(
|
|
204
|
-
return
|
|
203
|
+
function _(d, t, e) {
|
|
204
|
+
return d.unit ? d.unit === "px" ? { ...ne, ...d, unit: "px" } : {
|
|
205
205
|
unit: "px",
|
|
206
|
-
x:
|
|
207
|
-
y:
|
|
208
|
-
width:
|
|
209
|
-
height:
|
|
210
|
-
} : { ...
|
|
206
|
+
x: d.x ? d.x * t / 100 : 0,
|
|
207
|
+
y: d.y ? d.y * e / 100 : 0,
|
|
208
|
+
width: d.width ? d.width * t / 100 : 0,
|
|
209
|
+
height: d.height ? d.height * e / 100 : 0
|
|
210
|
+
} : { ...ne, ...d, unit: "px" };
|
|
211
211
|
}
|
|
212
|
-
function
|
|
213
|
-
const i = { ...
|
|
214
|
-
let
|
|
215
|
-
t && (t > 1 ? (
|
|
212
|
+
function he(d, t, e, o, n, r = 0, h = 0, p = o, s = n) {
|
|
213
|
+
const i = { ...d };
|
|
214
|
+
let l = Math.min(r, o), a = Math.min(h, n), g = Math.min(p, o), c = Math.min(s, n);
|
|
215
|
+
t && (t > 1 ? (l = h ? h * t : l, a = l / t, g = p * t) : (a = r ? r / t : a, l = a * t, c = s / t)), i.y < 0 && (i.height = Math.max(i.height + i.y, a), i.y = 0), i.x < 0 && (i.width = Math.max(i.width + i.x, l), i.x = 0);
|
|
216
216
|
const C = o - (i.x + i.width);
|
|
217
|
-
C < 0 && (i.x = Math.min(i.x, o -
|
|
217
|
+
C < 0 && (i.x = Math.min(i.x, o - l), i.width += C);
|
|
218
218
|
const P = n - (i.y + i.height);
|
|
219
|
-
if (P < 0 && (i.y = Math.min(i.y, n - a), i.height += P), i.width <
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
(e === "nw" || e == "ne") && (i.y -=
|
|
224
|
-
} else if (
|
|
225
|
-
const
|
|
226
|
-
(e === "sw" || e == "nw") && (i.x -=
|
|
219
|
+
if (P < 0 && (i.y = Math.min(i.y, n - a), i.height += P), i.width < l && ((e === "sw" || e == "nw") && (i.x -= l - i.width), i.width = l), i.height < a && ((e === "nw" || e == "ne") && (i.y -= a - i.height), i.height = a), i.width > g && ((e === "sw" || e == "nw") && (i.x -= g - i.width), i.width = g), i.height > c && ((e === "nw" || e == "ne") && (i.y -= c - i.height), i.height = c), t) {
|
|
220
|
+
const f = i.width / i.height;
|
|
221
|
+
if (f < t) {
|
|
222
|
+
const H = Math.max(i.width / t, a);
|
|
223
|
+
(e === "nw" || e == "ne") && (i.y -= H - i.height), i.height = H;
|
|
224
|
+
} else if (f > t) {
|
|
225
|
+
const H = Math.max(i.height * t, l);
|
|
226
|
+
(e === "sw" || e == "nw") && (i.x -= H - i.width), i.width = H;
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
return i;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
const n = { ...
|
|
231
|
+
function Se(d, t, e, o) {
|
|
232
|
+
const n = { ...d };
|
|
233
233
|
return t === "ArrowLeft" ? o === "nw" ? (n.x -= e, n.y -= e, n.width += e, n.height += e) : o === "w" ? (n.x -= e, n.width += e) : o === "sw" ? (n.x -= e, n.width += e, n.height += e) : o === "ne" ? (n.y += e, n.width -= e, n.height -= e) : o === "e" ? n.width -= e : o === "se" && (n.width -= e, n.height -= e) : t === "ArrowRight" && (o === "nw" ? (n.x += e, n.y += e, n.width -= e, n.height -= e) : o === "w" ? (n.x += e, n.width -= e) : o === "sw" ? (n.x += e, n.width -= e, n.height -= e) : o === "ne" ? (n.y -= e, n.width += e, n.height += e) : o === "e" ? n.width += e : o === "se" && (n.width += e, n.height += e)), t === "ArrowUp" ? o === "nw" ? (n.x -= e, n.y -= e, n.width += e, n.height += e) : o === "n" ? (n.y -= e, n.height += e) : o === "ne" ? (n.y -= e, n.width += e, n.height += e) : o === "sw" ? (n.x += e, n.width -= e, n.height -= e) : o === "s" ? n.height -= e : o === "se" && (n.width -= e, n.height -= e) : t === "ArrowDown" && (o === "nw" ? (n.x += e, n.y += e, n.width -= e, n.height -= e) : o === "n" ? (n.y += e, n.height -= e) : o === "ne" ? (n.y += e, n.width -= e, n.height -= e) : o === "sw" ? (n.x -= e, n.width += e, n.height += e) : o === "s" ? n.height += e : o === "se" && (n.width += e, n.height += e)), n;
|
|
234
234
|
}
|
|
235
235
|
const K = { capture: !0, passive: !1 };
|
|
236
|
-
let
|
|
237
|
-
const X = class S extends
|
|
236
|
+
let ke = 0;
|
|
237
|
+
const X = class S extends $e {
|
|
238
238
|
constructor() {
|
|
239
239
|
super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
|
|
240
240
|
startClientX: 0,
|
|
@@ -244,7 +244,7 @@ const X = class S extends Ee {
|
|
|
244
244
|
clientX: 0,
|
|
245
245
|
clientY: 0,
|
|
246
246
|
isResize: !0
|
|
247
|
-
}, this.componentRef =
|
|
247
|
+
}, this.componentRef = se(), this.mediaRef = se(), this.initChangeCalled = !1, this.instanceId = `rc-${ke++}`, this.state = {
|
|
248
248
|
cropIsActive: !1,
|
|
249
249
|
newCropIsBeingDrawn: !1
|
|
250
250
|
}, this.onCropPointerDown = (t) => {
|
|
@@ -256,16 +256,16 @@ const X = class S extends Ee {
|
|
|
256
256
|
return;
|
|
257
257
|
t.cancelable && t.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
258
258
|
const h = t.target.dataset.ord, p = !!h;
|
|
259
|
-
let s = t.clientX, i = t.clientY,
|
|
259
|
+
let s = t.clientX, i = t.clientY, l = r.x, a = r.y;
|
|
260
260
|
if (h) {
|
|
261
261
|
const g = t.clientX - n.x, c = t.clientY - n.y;
|
|
262
262
|
let C = 0, P = 0;
|
|
263
|
-
h === "ne" || h == "e" ? (C = g - (r.x + r.width), P = c - r.y,
|
|
263
|
+
h === "ne" || h == "e" ? (C = g - (r.x + r.width), P = c - r.y, l = r.x, a = r.y + r.height) : h === "se" || h === "s" ? (C = g - (r.x + r.width), P = c - (r.y + r.height), l = r.x, a = r.y) : h === "sw" || h == "w" ? (C = g - r.x, P = c - (r.y + r.height), l = r.x + r.width, a = r.y) : (h === "nw" || h == "n") && (C = g - r.x, P = c - r.y, l = r.x + r.width, a = r.y + r.height), s = l + n.x + C, i = a + n.y + P;
|
|
264
264
|
}
|
|
265
265
|
this.evData = {
|
|
266
266
|
startClientX: s,
|
|
267
267
|
startClientY: i,
|
|
268
|
-
startCropX:
|
|
268
|
+
startCropX: l,
|
|
269
269
|
startCropY: a,
|
|
270
270
|
clientX: t.clientX,
|
|
271
271
|
clientY: t.clientY,
|
|
@@ -277,7 +277,7 @@ const X = class S extends Ee {
|
|
|
277
277
|
if (o || n || r && e)
|
|
278
278
|
return;
|
|
279
279
|
t.cancelable && t.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
280
|
-
const s = t.clientX - p.x, i = t.clientY - p.y,
|
|
280
|
+
const s = t.clientX - p.x, i = t.clientY - p.y, l = {
|
|
281
281
|
unit: "px",
|
|
282
282
|
x: s,
|
|
283
283
|
y: i,
|
|
@@ -292,7 +292,7 @@ const X = class S extends Ee {
|
|
|
292
292
|
clientX: t.clientX,
|
|
293
293
|
clientY: t.clientY,
|
|
294
294
|
isResize: !0
|
|
295
|
-
}, this.mouseDownOnCrop = !0, h(_(
|
|
295
|
+
}, this.mouseDownOnCrop = !0, h(_(l, p.width, p.height), U(l, p.width, p.height)), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
|
|
296
296
|
}, this.onDocPointerMove = (t) => {
|
|
297
297
|
const { crop: e, disabled: o, onChange: n, onDragStart: r } = this.props, h = this.getBox();
|
|
298
298
|
if (o || !e || !this.mouseDownOnCrop)
|
|
@@ -301,9 +301,9 @@ const X = class S extends Ee {
|
|
|
301
301
|
const { evData: p } = this;
|
|
302
302
|
p.clientX = t.clientX, p.clientY = t.clientY;
|
|
303
303
|
let s;
|
|
304
|
-
p.isResize ? s = this.resizeCrop() : s = this.dragCrop(),
|
|
304
|
+
p.isResize ? s = this.resizeCrop() : s = this.dragCrop(), ae(e, s) || n(
|
|
305
305
|
_(s, h.width, h.height),
|
|
306
|
-
|
|
306
|
+
U(s, h.width, h.height)
|
|
307
307
|
);
|
|
308
308
|
}, this.onComponentKeyDown = (t) => {
|
|
309
309
|
const { crop: e, disabled: o, onChange: n, onComplete: r } = this.props;
|
|
@@ -313,10 +313,10 @@ const X = class S extends Ee {
|
|
|
313
313
|
let p = !1;
|
|
314
314
|
if (!e)
|
|
315
315
|
return;
|
|
316
|
-
const s = this.getBox(), i = this.makePixelCrop(s),
|
|
317
|
-
if (h === "ArrowLeft" ? (i.x -=
|
|
318
|
-
t.cancelable && t.preventDefault(), i.x =
|
|
319
|
-
const a = _(i, s.width, s.height), g =
|
|
316
|
+
const s = this.getBox(), i = this.makePixelCrop(s), l = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? S.nudgeStepLarge : t.shiftKey ? S.nudgeStepMedium : S.nudgeStep;
|
|
317
|
+
if (h === "ArrowLeft" ? (i.x -= l, p = !0) : h === "ArrowRight" ? (i.x += l, p = !0) : h === "ArrowUp" ? (i.y -= l, p = !0) : h === "ArrowDown" && (i.y += l, p = !0), p) {
|
|
318
|
+
t.cancelable && t.preventDefault(), i.x = W(i.x, 0, s.width - i.width), i.y = W(i.y, 0, s.height - i.height);
|
|
319
|
+
const a = _(i, s.width, s.height), g = U(i, s.width, s.height);
|
|
320
320
|
n(a, g), r && r(a, g);
|
|
321
321
|
}
|
|
322
322
|
}, this.onHandlerKeyDown = (t, e) => {
|
|
@@ -328,7 +328,7 @@ const X = class S extends Ee {
|
|
|
328
328
|
minHeight: p = 0,
|
|
329
329
|
maxWidth: s,
|
|
330
330
|
maxHeight: i,
|
|
331
|
-
onChange:
|
|
331
|
+
onChange: l,
|
|
332
332
|
onComplete: a
|
|
333
333
|
} = this.props, g = this.getBox();
|
|
334
334
|
if (r || !n)
|
|
@@ -337,7 +337,7 @@ const X = class S extends Ee {
|
|
|
337
337
|
t.stopPropagation(), t.preventDefault();
|
|
338
338
|
else
|
|
339
339
|
return;
|
|
340
|
-
const c = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? S.nudgeStepLarge : t.shiftKey ? S.nudgeStepMedium : S.nudgeStep, C = _(n, g.width, g.height), P =
|
|
340
|
+
const c = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? S.nudgeStepLarge : t.shiftKey ? S.nudgeStepMedium : S.nudgeStep, C = _(n, g.width, g.height), P = Se(C, t.key, c, e), f = he(
|
|
341
341
|
P,
|
|
342
342
|
o,
|
|
343
343
|
e,
|
|
@@ -348,13 +348,13 @@ const X = class S extends Ee {
|
|
|
348
348
|
s,
|
|
349
349
|
i
|
|
350
350
|
);
|
|
351
|
-
if (!
|
|
352
|
-
const
|
|
353
|
-
|
|
351
|
+
if (!ae(n, f)) {
|
|
352
|
+
const H = U(f, g.width, g.height);
|
|
353
|
+
l(f, H), a && a(f, H);
|
|
354
354
|
}
|
|
355
355
|
}, this.onDocPointerDone = (t) => {
|
|
356
356
|
const { crop: e, disabled: o, onComplete: n, onDragEnd: r } = this.props, h = this.getBox();
|
|
357
|
-
this.unbindDocMove(), !(o || !e) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, r && r(t), n && n(_(e, h.width, h.height),
|
|
357
|
+
this.unbindDocMove(), !(o || !e) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, r && r(t), n && n(_(e, h.width, h.height), U(e, h.width, h.height)), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
|
|
358
358
|
}, this.onDragFocus = () => {
|
|
359
359
|
var t;
|
|
360
360
|
(t = this.componentRef.current) == null || t.scrollTo(0, 0);
|
|
@@ -376,7 +376,7 @@ const X = class S extends Ee {
|
|
|
376
376
|
const { crop: e, onComplete: o } = this.props;
|
|
377
377
|
if (o && !t.crop && e) {
|
|
378
378
|
const { width: n, height: r } = this.getBox();
|
|
379
|
-
n && r && o(_(e, n, r),
|
|
379
|
+
n && r && o(_(e, n, r), U(e, n, r));
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
componentWillUnmount() {
|
|
@@ -400,7 +400,7 @@ const X = class S extends Ee {
|
|
|
400
400
|
}
|
|
401
401
|
dragCrop() {
|
|
402
402
|
const { evData: t } = this, e = this.getBox(), o = this.makePixelCrop(e), n = t.clientX - t.startClientX, r = t.clientY - t.startClientY;
|
|
403
|
-
return o.x =
|
|
403
|
+
return o.x = W(t.startCropX + n, 0, e.width - o.width), o.y = W(t.startCropY + r, 0, e.height - o.height), o;
|
|
404
404
|
}
|
|
405
405
|
getPointRegion(t, e, o, n) {
|
|
406
406
|
const { evData: r } = this, h = r.clientX - t.x, p = r.clientY - t.y;
|
|
@@ -416,9 +416,9 @@ const X = class S extends Ee {
|
|
|
416
416
|
resizeCrop() {
|
|
417
417
|
const { evData: t } = this, { aspect: e = 0, maxWidth: o, maxHeight: n } = this.props, r = this.getBox(), [h, p] = this.resolveMinDimensions(r, e, this.props.minWidth, this.props.minHeight);
|
|
418
418
|
let s = this.makePixelCrop(r);
|
|
419
|
-
const i = this.getPointRegion(r, t.ord, h, p),
|
|
419
|
+
const i = this.getPointRegion(r, t.ord, h, p), l = t.ord || i;
|
|
420
420
|
let a = t.clientX - t.startClientX, g = t.clientY - t.startClientY;
|
|
421
|
-
(h &&
|
|
421
|
+
(h && l === "nw" || l === "w" || l === "sw") && (a = Math.min(a, -h)), (p && l === "nw" || l === "n" || l === "ne") && (g = Math.min(g, -p));
|
|
422
422
|
const c = {
|
|
423
423
|
unit: "px",
|
|
424
424
|
x: 0,
|
|
@@ -427,7 +427,7 @@ const X = class S extends Ee {
|
|
|
427
427
|
height: 0
|
|
428
428
|
};
|
|
429
429
|
i === "ne" ? (c.x = t.startCropX, c.width = a, e ? (c.height = c.width / e, c.y = t.startCropY - c.height) : (c.height = Math.abs(g), c.y = t.startCropY - c.height)) : i === "se" ? (c.x = t.startCropX, c.y = t.startCropY, c.width = a, e ? c.height = c.width / e : c.height = g) : i === "sw" ? (c.x = t.startCropX + a, c.y = t.startCropY, c.width = Math.abs(a), e ? c.height = c.width / e : c.height = g) : i === "nw" && (c.x = t.startCropX + a, c.width = Math.abs(a), e ? (c.height = c.width / e, c.y = t.startCropY - c.height) : (c.height = Math.abs(g), c.y = t.startCropY + g));
|
|
430
|
-
const C =
|
|
430
|
+
const C = he(
|
|
431
431
|
c,
|
|
432
432
|
e,
|
|
433
433
|
i,
|
|
@@ -438,7 +438,7 @@ const X = class S extends Ee {
|
|
|
438
438
|
o,
|
|
439
439
|
n
|
|
440
440
|
);
|
|
441
|
-
return e || S.xyOrds.indexOf(
|
|
441
|
+
return e || S.xyOrds.indexOf(l) > -1 ? s = C : S.xOrds.indexOf(l) > -1 ? (s.x = C.x, s.width = C.width) : S.yOrds.indexOf(l) > -1 && (s.y = C.y, s.height = C.height), s.x = W(s.x, 0, r.width - s.width), s.y = W(s.y, 0, r.height - s.height), s;
|
|
442
442
|
}
|
|
443
443
|
renderCropSelection() {
|
|
444
444
|
const {
|
|
@@ -450,7 +450,7 @@ const X = class S extends Ee {
|
|
|
450
450
|
crop: h
|
|
451
451
|
} = this.props, p = this.getCropStyle();
|
|
452
452
|
if (h)
|
|
453
|
-
return /* @__PURE__ */
|
|
453
|
+
return /* @__PURE__ */ x.createElement(
|
|
454
454
|
"div",
|
|
455
455
|
{
|
|
456
456
|
style: p,
|
|
@@ -461,7 +461,7 @@ const X = class S extends Ee {
|
|
|
461
461
|
onKeyDown: this.onComponentKeyDown,
|
|
462
462
|
role: "group"
|
|
463
463
|
},
|
|
464
|
-
!e && !o && /* @__PURE__ */
|
|
464
|
+
!e && !o && /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__drag-elements", onFocus: this.onDragFocus }, /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__drag-bar ord-n", "data-ord": "n" }), /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__drag-bar ord-e", "data-ord": "e" }), /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__drag-bar ord-s", "data-ord": "s" }), /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__drag-bar ord-w", "data-ord": "w" }), /* @__PURE__ */ x.createElement(
|
|
465
465
|
"div",
|
|
466
466
|
{
|
|
467
467
|
className: "ReactCrop__drag-handle ord-nw",
|
|
@@ -471,7 +471,7 @@ const X = class S extends Ee {
|
|
|
471
471
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "nw"),
|
|
472
472
|
role: "button"
|
|
473
473
|
}
|
|
474
|
-
), /* @__PURE__ */
|
|
474
|
+
), /* @__PURE__ */ x.createElement(
|
|
475
475
|
"div",
|
|
476
476
|
{
|
|
477
477
|
className: "ReactCrop__drag-handle ord-n",
|
|
@@ -481,7 +481,7 @@ const X = class S extends Ee {
|
|
|
481
481
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "n"),
|
|
482
482
|
role: "button"
|
|
483
483
|
}
|
|
484
|
-
), /* @__PURE__ */
|
|
484
|
+
), /* @__PURE__ */ x.createElement(
|
|
485
485
|
"div",
|
|
486
486
|
{
|
|
487
487
|
className: "ReactCrop__drag-handle ord-ne",
|
|
@@ -491,7 +491,7 @@ const X = class S extends Ee {
|
|
|
491
491
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "ne"),
|
|
492
492
|
role: "button"
|
|
493
493
|
}
|
|
494
|
-
), /* @__PURE__ */
|
|
494
|
+
), /* @__PURE__ */ x.createElement(
|
|
495
495
|
"div",
|
|
496
496
|
{
|
|
497
497
|
className: "ReactCrop__drag-handle ord-e",
|
|
@@ -501,7 +501,7 @@ const X = class S extends Ee {
|
|
|
501
501
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "e"),
|
|
502
502
|
role: "button"
|
|
503
503
|
}
|
|
504
|
-
), /* @__PURE__ */
|
|
504
|
+
), /* @__PURE__ */ x.createElement(
|
|
505
505
|
"div",
|
|
506
506
|
{
|
|
507
507
|
className: "ReactCrop__drag-handle ord-se",
|
|
@@ -511,7 +511,7 @@ const X = class S extends Ee {
|
|
|
511
511
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "se"),
|
|
512
512
|
role: "button"
|
|
513
513
|
}
|
|
514
|
-
), /* @__PURE__ */
|
|
514
|
+
), /* @__PURE__ */ x.createElement(
|
|
515
515
|
"div",
|
|
516
516
|
{
|
|
517
517
|
className: "ReactCrop__drag-handle ord-s",
|
|
@@ -521,7 +521,7 @@ const X = class S extends Ee {
|
|
|
521
521
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "s"),
|
|
522
522
|
role: "button"
|
|
523
523
|
}
|
|
524
|
-
), /* @__PURE__ */
|
|
524
|
+
), /* @__PURE__ */ x.createElement(
|
|
525
525
|
"div",
|
|
526
526
|
{
|
|
527
527
|
className: "ReactCrop__drag-handle ord-sw",
|
|
@@ -531,7 +531,7 @@ const X = class S extends Ee {
|
|
|
531
531
|
onKeyDown: (s) => this.onHandlerKeyDown(s, "sw"),
|
|
532
532
|
role: "button"
|
|
533
533
|
}
|
|
534
|
-
), /* @__PURE__ */
|
|
534
|
+
), /* @__PURE__ */ x.createElement(
|
|
535
535
|
"div",
|
|
536
536
|
{
|
|
537
537
|
className: "ReactCrop__drag-handle ord-w",
|
|
@@ -542,19 +542,19 @@ const X = class S extends Ee {
|
|
|
542
542
|
role: "button"
|
|
543
543
|
}
|
|
544
544
|
)),
|
|
545
|
-
n && /* @__PURE__ */
|
|
546
|
-
r && /* @__PURE__ */
|
|
545
|
+
n && /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__selection-addon", onPointerDown: (s) => s.stopPropagation() }, n(this.state)),
|
|
546
|
+
r && /* @__PURE__ */ x.createElement(x.Fragment, null, /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__rule-of-thirds-hz" }), /* @__PURE__ */ x.createElement("div", { className: "ReactCrop__rule-of-thirds-vt" }))
|
|
547
547
|
);
|
|
548
548
|
}
|
|
549
549
|
makePixelCrop(t) {
|
|
550
|
-
const e = { ...
|
|
550
|
+
const e = { ...ne, ...this.props.crop || {} };
|
|
551
551
|
return _(e, t.width, t.height);
|
|
552
552
|
}
|
|
553
553
|
render() {
|
|
554
|
-
const { aspect: t, children: e, circularCrop: o, className: n, crop: r, disabled: h, locked: p, style: s, ruleOfThirds: i } = this.props, { cropIsActive:
|
|
554
|
+
const { aspect: t, children: e, circularCrop: o, className: n, crop: r, disabled: h, locked: p, style: s, ruleOfThirds: i } = this.props, { cropIsActive: l, newCropIsBeingDrawn: a } = this.state, g = r ? this.renderCropSelection() : null, c = Ne(
|
|
555
555
|
"ReactCrop",
|
|
556
556
|
n,
|
|
557
|
-
|
|
557
|
+
l && "ReactCrop--active",
|
|
558
558
|
h && "ReactCrop--disabled",
|
|
559
559
|
p && "ReactCrop--locked",
|
|
560
560
|
a && "ReactCrop--new-crop",
|
|
@@ -564,7 +564,7 @@ const X = class S extends Ee {
|
|
|
564
564
|
!this.dragStarted && r && !r.width && !r.height && "ReactCrop--invisible-crop",
|
|
565
565
|
o && "ReactCrop--no-animate"
|
|
566
566
|
);
|
|
567
|
-
return /* @__PURE__ */
|
|
567
|
+
return /* @__PURE__ */ x.createElement("div", { ref: this.componentRef, className: c, style: s }, /* @__PURE__ */ x.createElement("div", { ref: this.mediaRef, className: "ReactCrop__child-wrapper", onPointerDown: this.onComponentPointerDown }, e), r ? /* @__PURE__ */ x.createElement("svg", { className: "ReactCrop__crop-mask", width: "100%", height: "100%" }, /* @__PURE__ */ x.createElement("defs", null, /* @__PURE__ */ x.createElement("mask", { id: `hole-${this.instanceId}` }, /* @__PURE__ */ x.createElement("rect", { width: "100%", height: "100%", fill: "white" }), o ? /* @__PURE__ */ x.createElement(
|
|
568
568
|
"ellipse",
|
|
569
569
|
{
|
|
570
570
|
cx: `${r.x + r.width / 2}${r.unit}`,
|
|
@@ -573,7 +573,7 @@ const X = class S extends Ee {
|
|
|
573
573
|
ry: `${r.height / 2}${r.unit}`,
|
|
574
574
|
fill: "black"
|
|
575
575
|
}
|
|
576
|
-
) : /* @__PURE__ */
|
|
576
|
+
) : /* @__PURE__ */ x.createElement(
|
|
577
577
|
"rect",
|
|
578
578
|
{
|
|
579
579
|
x: `${r.x}${r.unit}`,
|
|
@@ -582,7 +582,7 @@ const X = class S extends Ee {
|
|
|
582
582
|
height: `${r.height}${r.unit}`,
|
|
583
583
|
fill: "black"
|
|
584
584
|
}
|
|
585
|
-
))), /* @__PURE__ */
|
|
585
|
+
))), /* @__PURE__ */ x.createElement("rect", { fill: "black", fillOpacity: 0.5, width: "100%", height: "100%", mask: `url(#hole-${this.instanceId})` })) : void 0, g);
|
|
586
586
|
}
|
|
587
587
|
};
|
|
588
588
|
X.xOrds = ["e", "w"], X.yOrds = ["n", "s"], X.xyOrds = ["nw", "ne", "se", "sw"], X.nudgeStep = 1, X.nudgeStepMedium = 10, X.nudgeStepLarge = 100, X.defaultProps = {
|
|
@@ -598,10 +598,10 @@ X.xOrds = ["e", "w"], X.yOrds = ["n", "s"], X.xyOrds = ["nw", "ne", "se", "sw"],
|
|
|
598
598
|
wDragHandle: "Use the up and down arrow keys to move the west drag handle to change the crop selection area"
|
|
599
599
|
}
|
|
600
600
|
};
|
|
601
|
-
let
|
|
602
|
-
const
|
|
603
|
-
function
|
|
604
|
-
altText:
|
|
601
|
+
let Ie = X;
|
|
602
|
+
const ce = Re();
|
|
603
|
+
function _e({
|
|
604
|
+
altText: d,
|
|
605
605
|
className: t,
|
|
606
606
|
src: e,
|
|
607
607
|
width: o,
|
|
@@ -611,9 +611,9 @@ function Se({
|
|
|
611
611
|
startCrop: p,
|
|
612
612
|
setStartCrop: s,
|
|
613
613
|
isFocused: i,
|
|
614
|
-
nodeKey:
|
|
614
|
+
nodeKey: l
|
|
615
615
|
}) {
|
|
616
|
-
const [a, g] =
|
|
616
|
+
const [a, g] = F(null), [c, C] = F(null), [P, f] = F({
|
|
617
617
|
//@ts-ignore
|
|
618
618
|
unit: "px",
|
|
619
619
|
// Can be 'px' or '%'
|
|
@@ -621,68 +621,68 @@ function Se({
|
|
|
621
621
|
y: 25,
|
|
622
622
|
width: 50,
|
|
623
623
|
height: 50
|
|
624
|
-
}), [
|
|
624
|
+
}), [H] = de(), T = () => {
|
|
625
625
|
if (a) {
|
|
626
626
|
const u = h.current;
|
|
627
627
|
if (!u || !a)
|
|
628
628
|
return;
|
|
629
|
-
const
|
|
630
|
-
a.width *
|
|
631
|
-
a.height *
|
|
632
|
-
),
|
|
633
|
-
if (!
|
|
629
|
+
const w = u.naturalWidth / u.width, N = u.naturalHeight / u.height, M = new OffscreenCanvas(
|
|
630
|
+
a.width * w,
|
|
631
|
+
a.height * N
|
|
632
|
+
), v = M.getContext("2d");
|
|
633
|
+
if (!v)
|
|
634
634
|
throw new Error("No 2D context available");
|
|
635
|
-
|
|
635
|
+
v.drawImage(
|
|
636
636
|
u,
|
|
637
|
-
a.x *
|
|
638
|
-
a.y *
|
|
639
|
-
a.width *
|
|
640
|
-
a.height *
|
|
637
|
+
a.x * w,
|
|
638
|
+
a.y * N,
|
|
639
|
+
a.width * w,
|
|
640
|
+
a.height * N,
|
|
641
641
|
0,
|
|
642
642
|
0,
|
|
643
|
-
a.width *
|
|
644
|
-
a.height *
|
|
645
|
-
), M.convertToBlob({ type: "image/png" }).then((
|
|
646
|
-
const
|
|
647
|
-
C(
|
|
648
|
-
const
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
const
|
|
653
|
-
|
|
643
|
+
a.width * w,
|
|
644
|
+
a.height * N
|
|
645
|
+
), M.convertToBlob({ type: "image/png" }).then((D) => {
|
|
646
|
+
const A = URL.createObjectURL(D);
|
|
647
|
+
C(A), s(!1);
|
|
648
|
+
const B = new FileReader();
|
|
649
|
+
B.onload = () => {
|
|
650
|
+
const Q = B.result;
|
|
651
|
+
H.update(() => {
|
|
652
|
+
const O = q(l);
|
|
653
|
+
J(O) && Q && O.setSrc(Q);
|
|
654
654
|
});
|
|
655
|
-
},
|
|
655
|
+
}, B.onerror = () => {
|
|
656
656
|
console.log("error");
|
|
657
|
-
},
|
|
657
|
+
}, B.readAsDataURL(D);
|
|
658
658
|
});
|
|
659
659
|
}
|
|
660
660
|
}, z = () => {
|
|
661
661
|
p || s((u) => {
|
|
662
662
|
if (u === !1) {
|
|
663
|
-
const
|
|
664
|
-
|
|
663
|
+
const w = h.current;
|
|
664
|
+
f({
|
|
665
665
|
unit: "px",
|
|
666
666
|
// Can be 'px' or '%'
|
|
667
667
|
x: 0,
|
|
668
668
|
y: 0,
|
|
669
|
-
width:
|
|
670
|
-
height:
|
|
669
|
+
width: w.width,
|
|
670
|
+
height: w.height
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
673
|
return !u;
|
|
674
674
|
});
|
|
675
|
-
},
|
|
675
|
+
}, j = Y(null), k = Y(null);
|
|
676
676
|
te(() => {
|
|
677
|
-
a && (
|
|
677
|
+
a && (j.current = a);
|
|
678
678
|
}, [a]);
|
|
679
|
-
const
|
|
679
|
+
const m = (u) => {
|
|
680
680
|
k.current && !k.current.contains(u.target) && s(!1);
|
|
681
681
|
};
|
|
682
|
-
return te(() => (document.addEventListener("mousedown",
|
|
683
|
-
document.removeEventListener("mousedown",
|
|
684
|
-
}), []), /* @__PURE__ */
|
|
685
|
-
i && /* @__PURE__ */
|
|
682
|
+
return te(() => (document.addEventListener("mousedown", m), () => {
|
|
683
|
+
document.removeEventListener("mousedown", m);
|
|
684
|
+
}), []), /* @__PURE__ */ b.jsxs("div", { ref: k, children: [
|
|
685
|
+
i && /* @__PURE__ */ b.jsx(
|
|
686
686
|
"button",
|
|
687
687
|
{
|
|
688
688
|
style: { zIndex: 999 },
|
|
@@ -691,27 +691,27 @@ function Se({
|
|
|
691
691
|
children: "Crop"
|
|
692
692
|
}
|
|
693
693
|
),
|
|
694
|
-
p && /* @__PURE__ */
|
|
694
|
+
p && /* @__PURE__ */ b.jsx(
|
|
695
695
|
"button",
|
|
696
696
|
{
|
|
697
697
|
style: { zIndex: 999 },
|
|
698
698
|
className: "image-caption-button",
|
|
699
|
-
onClick: () =>
|
|
699
|
+
onClick: () => T(),
|
|
700
700
|
children: "Apply Crop"
|
|
701
701
|
}
|
|
702
702
|
),
|
|
703
|
-
p ? /* @__PURE__ */
|
|
704
|
-
|
|
703
|
+
p ? /* @__PURE__ */ b.jsx(
|
|
704
|
+
Ie,
|
|
705
705
|
{
|
|
706
706
|
crop: P,
|
|
707
|
-
onChange: (u) =>
|
|
707
|
+
onChange: (u) => f(u),
|
|
708
708
|
onComplete: (u) => g(u),
|
|
709
|
-
children: /* @__PURE__ */
|
|
709
|
+
children: /* @__PURE__ */ b.jsx(
|
|
710
710
|
"img",
|
|
711
711
|
{
|
|
712
712
|
className: t || void 0,
|
|
713
713
|
src: c || e,
|
|
714
|
-
alt:
|
|
714
|
+
alt: d,
|
|
715
715
|
ref: h,
|
|
716
716
|
style: {
|
|
717
717
|
height: n,
|
|
@@ -724,12 +724,12 @@ function Se({
|
|
|
724
724
|
}
|
|
725
725
|
) : (
|
|
726
726
|
// When startCrop is false, show the cropped image or original image
|
|
727
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ b.jsx(
|
|
728
728
|
"img",
|
|
729
729
|
{
|
|
730
730
|
className: t || void 0,
|
|
731
731
|
src: c || e,
|
|
732
|
-
alt:
|
|
732
|
+
alt: d,
|
|
733
733
|
ref: h,
|
|
734
734
|
style: {
|
|
735
735
|
height: n,
|
|
@@ -742,8 +742,8 @@ function Se({
|
|
|
742
742
|
)
|
|
743
743
|
] });
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
src:
|
|
745
|
+
function Ae({
|
|
746
|
+
src: d,
|
|
747
747
|
altText: t,
|
|
748
748
|
nodeKey: e,
|
|
749
749
|
width: o,
|
|
@@ -753,161 +753,179 @@ function Ye({
|
|
|
753
753
|
showCaption: p,
|
|
754
754
|
caption: s
|
|
755
755
|
}) {
|
|
756
|
-
const i = Y(null),
|
|
757
|
-
(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
756
|
+
const i = Y(null), l = Y(null), [a, g, c] = ge(e), [C, P] = F(!1), [f] = de(), [H, T] = F(null), [z, j] = F(!1), k = Y(null), m = async (E) => {
|
|
757
|
+
const $ = await (await fetch(E)).blob();
|
|
758
|
+
return new Promise((L, re) => {
|
|
759
|
+
const Z = new FileReader();
|
|
760
|
+
Z.readAsDataURL($), Z.onloadend = () => {
|
|
761
|
+
const le = Z.result;
|
|
762
|
+
L(le);
|
|
763
|
+
}, Z.onerror = re;
|
|
764
|
+
});
|
|
765
|
+
};
|
|
766
|
+
te(() => {
|
|
767
|
+
/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i.test(d) && m(d).then((R) => {
|
|
768
|
+
f.update(() => {
|
|
769
|
+
const $ = q(e);
|
|
770
|
+
J($) && R && $.setSrc(R);
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
}, [d]);
|
|
774
|
+
const u = V(
|
|
775
|
+
(E) => {
|
|
776
|
+
if (a && G(ee())) {
|
|
777
|
+
E.preventDefault();
|
|
778
|
+
const $ = q(e);
|
|
779
|
+
if (J($))
|
|
780
|
+
return $.remove(), !0;
|
|
763
781
|
}
|
|
764
782
|
return !1;
|
|
765
783
|
},
|
|
766
784
|
[a, e]
|
|
767
|
-
),
|
|
768
|
-
(
|
|
769
|
-
const
|
|
770
|
-
if (a && G(
|
|
785
|
+
), w = V(
|
|
786
|
+
(E) => {
|
|
787
|
+
const R = ee(), $ = l.current;
|
|
788
|
+
if (a && G(R) && R.getNodes().length === 1) {
|
|
771
789
|
if (p)
|
|
772
|
-
return
|
|
773
|
-
if (
|
|
774
|
-
return
|
|
790
|
+
return oe(null), E.preventDefault(), s.focus(), !0;
|
|
791
|
+
if ($ !== null && $ !== document.activeElement)
|
|
792
|
+
return E.preventDefault(), $.focus(), !0;
|
|
775
793
|
}
|
|
776
794
|
return !1;
|
|
777
795
|
},
|
|
778
796
|
[s, a, p]
|
|
779
|
-
),
|
|
780
|
-
(
|
|
797
|
+
), N = V(
|
|
798
|
+
(E) => k.current === s || l.current === E.target ? (oe(null), f.update(() => {
|
|
781
799
|
g(!0);
|
|
782
|
-
const
|
|
783
|
-
|
|
800
|
+
const R = f.getRootElement();
|
|
801
|
+
R !== null && R.focus();
|
|
784
802
|
}), !0) : !1,
|
|
785
|
-
[s,
|
|
786
|
-
),
|
|
787
|
-
(
|
|
788
|
-
const
|
|
789
|
-
return C ? !0 :
|
|
803
|
+
[s, f, g]
|
|
804
|
+
), M = V(
|
|
805
|
+
(E) => {
|
|
806
|
+
const R = E;
|
|
807
|
+
return C ? !0 : R.target === i.current ? (R.shiftKey ? g(!a) : (c(), g(!0)), !0) : !1;
|
|
790
808
|
},
|
|
791
809
|
[C, a, g, c]
|
|
792
|
-
),
|
|
793
|
-
(
|
|
794
|
-
|
|
795
|
-
const
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
810
|
+
), v = V(
|
|
811
|
+
(E) => {
|
|
812
|
+
f.getEditorState().read(() => {
|
|
813
|
+
const R = ee();
|
|
814
|
+
E.target.tagName === "IMG" && ue(R) && R.getNodes().length === 1 && f.dispatchCommand(
|
|
815
|
+
ce,
|
|
816
|
+
E
|
|
799
817
|
);
|
|
800
818
|
});
|
|
801
819
|
},
|
|
802
|
-
[
|
|
820
|
+
[f]
|
|
803
821
|
);
|
|
804
822
|
te(() => {
|
|
805
|
-
let
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
|
|
823
|
+
let E = !0;
|
|
824
|
+
const R = f.getRootElement(), $ = pe(
|
|
825
|
+
f.registerUpdateListener(({ editorState: L }) => {
|
|
826
|
+
E && T(L.read(() => ee()));
|
|
809
827
|
}),
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
(
|
|
828
|
+
f.registerCommand(
|
|
829
|
+
ve,
|
|
830
|
+
(L, re) => (k.current = re, !1),
|
|
813
831
|
I
|
|
814
832
|
),
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
833
|
+
f.registerCommand(
|
|
834
|
+
Ce,
|
|
835
|
+
M,
|
|
818
836
|
I
|
|
819
837
|
),
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
838
|
+
f.registerCommand(
|
|
839
|
+
ce,
|
|
840
|
+
M,
|
|
823
841
|
I
|
|
824
842
|
),
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
(
|
|
843
|
+
f.registerCommand(
|
|
844
|
+
ye,
|
|
845
|
+
(L) => L.target === i.current ? (L.preventDefault(), !0) : !1,
|
|
828
846
|
I
|
|
829
847
|
),
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
848
|
+
f.registerCommand(
|
|
849
|
+
xe,
|
|
850
|
+
u,
|
|
833
851
|
I
|
|
834
852
|
),
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
853
|
+
f.registerCommand(
|
|
854
|
+
fe,
|
|
855
|
+
u,
|
|
838
856
|
I
|
|
839
857
|
),
|
|
840
|
-
|
|
841
|
-
|
|
858
|
+
f.registerCommand(me, w, I),
|
|
859
|
+
f.registerCommand(we, N, I)
|
|
842
860
|
);
|
|
843
|
-
return
|
|
844
|
-
|
|
861
|
+
return R == null || R.addEventListener("contextmenu", v), () => {
|
|
862
|
+
E = !1, $(), R == null || R.removeEventListener("contextmenu", v);
|
|
845
863
|
};
|
|
846
864
|
}, [
|
|
847
865
|
c,
|
|
848
|
-
|
|
866
|
+
f,
|
|
849
867
|
C,
|
|
850
868
|
a,
|
|
851
869
|
e,
|
|
852
|
-
w,
|
|
853
870
|
u,
|
|
854
|
-
|
|
855
|
-
|
|
871
|
+
w,
|
|
872
|
+
N,
|
|
856
873
|
M,
|
|
874
|
+
v,
|
|
857
875
|
g
|
|
858
876
|
]);
|
|
859
|
-
const
|
|
860
|
-
|
|
861
|
-
const
|
|
862
|
-
|
|
877
|
+
const D = () => {
|
|
878
|
+
f.update(() => {
|
|
879
|
+
const E = q(e);
|
|
880
|
+
J(E) && E.setShowCaption(!0);
|
|
863
881
|
});
|
|
864
|
-
},
|
|
882
|
+
}, A = (E, R) => {
|
|
865
883
|
setTimeout(() => {
|
|
866
884
|
P(!1);
|
|
867
|
-
}, 200),
|
|
868
|
-
const
|
|
869
|
-
console.log(
|
|
885
|
+
}, 200), f.update(() => {
|
|
886
|
+
const $ = q(e);
|
|
887
|
+
console.log($, "node"), J($) && $.setWidthAndHeight(E, R);
|
|
870
888
|
});
|
|
871
|
-
},
|
|
889
|
+
}, B = () => {
|
|
872
890
|
z || P(!0);
|
|
873
|
-
},
|
|
874
|
-
return /* @__PURE__ */
|
|
875
|
-
/* @__PURE__ */
|
|
876
|
-
|
|
891
|
+
}, Q = a && G(H) && !C, O = a || C;
|
|
892
|
+
return /* @__PURE__ */ b.jsx(He, { fallback: null, children: /* @__PURE__ */ b.jsxs(b.Fragment, { children: [
|
|
893
|
+
/* @__PURE__ */ b.jsx("div", { draggable: Q, children: /* @__PURE__ */ b.jsx(
|
|
894
|
+
_e,
|
|
877
895
|
{
|
|
878
|
-
className:
|
|
879
|
-
src:
|
|
896
|
+
className: O ? `focused ${G(H) ? "draggable" : ""}` : null,
|
|
897
|
+
src: d,
|
|
880
898
|
altText: t,
|
|
881
899
|
width: o,
|
|
882
900
|
height: n,
|
|
883
901
|
maxWidth: r,
|
|
884
902
|
imageRef: i,
|
|
885
903
|
startCrop: z,
|
|
886
|
-
setStartCrop:
|
|
887
|
-
isFocused:
|
|
904
|
+
setStartCrop: j,
|
|
905
|
+
isFocused: O,
|
|
888
906
|
nodeKey: e
|
|
889
907
|
}
|
|
890
908
|
) }),
|
|
891
|
-
p && /* @__PURE__ */
|
|
892
|
-
|
|
909
|
+
p && /* @__PURE__ */ b.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ b.jsx(Ee, { initialEditor: s, children: /* @__PURE__ */ b.jsx(
|
|
910
|
+
De,
|
|
893
911
|
{
|
|
894
|
-
contentEditable: /* @__PURE__ */
|
|
895
|
-
placeholder: /* @__PURE__ */
|
|
896
|
-
ErrorBoundary:
|
|
912
|
+
contentEditable: /* @__PURE__ */ b.jsx(Me, { className: "ImageNode__contentEditable" }),
|
|
913
|
+
placeholder: /* @__PURE__ */ b.jsx(Pe, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
|
|
914
|
+
ErrorBoundary: be
|
|
897
915
|
}
|
|
898
916
|
) }) }),
|
|
899
|
-
!z && h && G(
|
|
900
|
-
|
|
917
|
+
!z && h && G(H) && O && /* @__PURE__ */ b.jsx(
|
|
918
|
+
ze,
|
|
901
919
|
{
|
|
902
920
|
showCaption: p,
|
|
903
|
-
setShowCaption:
|
|
904
|
-
editor:
|
|
905
|
-
buttonRef:
|
|
921
|
+
setShowCaption: D,
|
|
922
|
+
editor: f,
|
|
923
|
+
buttonRef: l,
|
|
906
924
|
maxWidth: r,
|
|
907
925
|
onResizeStart: z ? () => {
|
|
908
|
-
} :
|
|
926
|
+
} : B,
|
|
909
927
|
onResizeEnd: z ? () => {
|
|
910
|
-
} :
|
|
928
|
+
} : A,
|
|
911
929
|
captionsEnabled: !1,
|
|
912
930
|
imageRef: i
|
|
913
931
|
}
|
|
@@ -915,7 +933,7 @@ function Ye({
|
|
|
915
933
|
] }) });
|
|
916
934
|
}
|
|
917
935
|
export {
|
|
918
|
-
|
|
919
|
-
|
|
936
|
+
ce as RIGHT_CLICK_IMAGE_COMMAND,
|
|
937
|
+
Ae as default
|
|
920
938
|
};
|
|
921
|
-
//# sourceMappingURL=ImageComponent-
|
|
939
|
+
//# sourceMappingURL=ImageComponent-8ca7cea7.js.map
|