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