sykpcomposer 0.0.396 → 0.0.398
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-fc39a03e.js → ImageComponent-ced58b97.js} +192 -185
- package/dist/ImageComponent-ced58b97.js.map +1 -0
- package/dist/{InlineImageComponent-377a250f.js → InlineImageComponent-531380f5.js} +3 -3
- package/dist/{InlineImageComponent-377a250f.js.map → InlineImageComponent-531380f5.js.map} +1 -1
- package/dist/{LexicalNestedComposer.esm-6289c7f2.js → LexicalNestedComposer.esm-9f194204.js} +2 -2
- package/dist/{LexicalNestedComposer.esm-6289c7f2.js.map → LexicalNestedComposer.esm-9f194204.js.map} +1 -1
- package/dist/{PollComponent-8d21e358.js → PollComponent-008dc9fe.js} +2 -2
- package/dist/{PollComponent-8d21e358.js.map → PollComponent-008dc9fe.js.map} +1 -1
- package/dist/{index-75a3fc49.js → index-7c78a104.js} +4 -4
- package/dist/{index-75a3fc49.js.map → index-7c78a104.js.map} +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/ImageComponent-fc39a03e.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import { L as Re } from "./LexicalNestedComposer.esm-
|
|
3
|
-
import C, { useRef as
|
|
1
|
+
import { j as v, u as ce, a as ae, $ as G, b as q, c as J, d as Q, e as ne, f as de, m as le, S as ge, C as z, g as ue, D as pe, K as we, h as me, i as xe, k as Ce, R as fe, L as ye, P as De, l as ve, n as be } from "./index-7c78a104.js";
|
|
2
|
+
import { L as Re } from "./LexicalNestedComposer.esm-9f194204.js";
|
|
3
|
+
import C, { useRef as Y, PureComponent as Ee, createRef as ie, useState as U, useCallback as V, useEffect as te, Suspense as Me } from "react";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
function ee(l, t, e) {
|
|
6
6
|
return Math.min(Math.max(l, t), e);
|
|
@@ -22,10 +22,10 @@ function Ne({
|
|
|
22
22
|
setShowCaption: p,
|
|
23
23
|
captionsEnabled: s
|
|
24
24
|
}) {
|
|
25
|
-
const r =
|
|
25
|
+
const r = Y(null), d = Y({
|
|
26
26
|
priority: "",
|
|
27
27
|
value: "default"
|
|
28
|
-
}), a =
|
|
28
|
+
}), a = Y({
|
|
29
29
|
currentHeight: 0,
|
|
30
30
|
currentWidth: 0,
|
|
31
31
|
direction: 0,
|
|
@@ -35,15 +35,15 @@ function Ne({
|
|
|
35
35
|
startWidth: 0,
|
|
36
36
|
startX: 0,
|
|
37
37
|
startY: 0
|
|
38
|
-
}), g = i.getRootElement(), c = g !== null ? g.getBoundingClientRect().width - 20 : 100, y = g !== null ? g.getBoundingClientRect().height - 20 : 100, N = 100, x = 100, P = (
|
|
39
|
-
const u =
|
|
38
|
+
}), g = i.getRootElement(), c = g !== null ? g.getBoundingClientRect().width - 20 : 100, y = g !== null ? g.getBoundingClientRect().height - 20 : 100, N = 100, x = 100, P = (w) => {
|
|
39
|
+
const u = w === f.east || w === f.west, m = w === f.north || w === f.south, _ = w & f.north && w & f.west || w & f.south && w & f.east, M = u ? "ew" : m ? "ns" : _ ? "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,145 +54,145 @@ function Ne({
|
|
|
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
60
|
d.current.value,
|
|
61
61
|
d.current.priority
|
|
62
62
|
));
|
|
63
|
-
}, S = (
|
|
63
|
+
}, S = (w, u) => {
|
|
64
64
|
if (!i.isEditable())
|
|
65
65
|
return;
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const { width:
|
|
70
|
-
|
|
66
|
+
const m = o.current, _ = r.current;
|
|
67
|
+
if (m !== null && _ !== null) {
|
|
68
|
+
w.preventDefault();
|
|
69
|
+
const { width: M, height: b } = m.getBoundingClientRect(), D = a.current;
|
|
70
|
+
D.startWidth = M, D.startHeight = b, D.ratio = M / b, D.currentWidth = M, D.currentHeight = b, D.startX = w.clientX, D.startY = w.clientY, D.isResizing = !0, D.direction = u, P(u), l(), _.classList.add("image-control-wrapper--resizing"), m.style.height = `${b}px`, m.style.width = `${M}px`, document.addEventListener("pointermove", k), document.addEventListener("pointerup", I);
|
|
71
71
|
}
|
|
72
|
-
},
|
|
73
|
-
const u = o.current,
|
|
74
|
-
if (u !== null &&
|
|
75
|
-
if (_ &&
|
|
76
|
-
let b = Math.floor(
|
|
77
|
-
b =
|
|
78
|
-
const
|
|
79
|
-
|
|
72
|
+
}, k = (w) => {
|
|
73
|
+
const u = o.current, m = a.current, _ = m.direction & (f.east | f.west), M = m.direction & (f.south | f.north);
|
|
74
|
+
if (u !== null && m.isResizing) {
|
|
75
|
+
if (_ && M) {
|
|
76
|
+
let b = Math.floor(m.startX - w.clientX);
|
|
77
|
+
b = m.direction & f.east ? -b : b;
|
|
78
|
+
const D = ee(
|
|
79
|
+
m.startWidth + b,
|
|
80
80
|
N,
|
|
81
81
|
c
|
|
82
|
-
),
|
|
83
|
-
u.style.width = `${
|
|
84
|
-
} else if (
|
|
85
|
-
let b = Math.floor(
|
|
86
|
-
b =
|
|
87
|
-
const
|
|
88
|
-
|
|
82
|
+
), X = D / m.ratio;
|
|
83
|
+
u.style.width = `${D}px`, u.style.height = `${X}px`, m.currentHeight = X, m.currentWidth = D;
|
|
84
|
+
} else if (M) {
|
|
85
|
+
let b = Math.floor(m.startY - w.clientY);
|
|
86
|
+
b = m.direction & f.south ? -b : b;
|
|
87
|
+
const D = ee(
|
|
88
|
+
m.startHeight + b,
|
|
89
89
|
x,
|
|
90
90
|
y
|
|
91
91
|
);
|
|
92
|
-
u.style.height = `${
|
|
92
|
+
u.style.height = `${D}px`, u.style.maxHeight = `${D}px`, m.currentHeight = D;
|
|
93
93
|
} else {
|
|
94
|
-
let b = Math.floor(
|
|
95
|
-
b =
|
|
96
|
-
const
|
|
97
|
-
|
|
94
|
+
let b = Math.floor(m.startX - w.clientX);
|
|
95
|
+
b = m.direction & f.east ? -b : b;
|
|
96
|
+
const D = ee(
|
|
97
|
+
m.startWidth + b,
|
|
98
98
|
N,
|
|
99
99
|
c
|
|
100
100
|
);
|
|
101
|
-
u.style.width = `${
|
|
101
|
+
u.style.width = `${D}px`, u.style.maxWidth = `${D}px`, m.currentWidth = D;
|
|
102
102
|
}
|
|
103
|
-
u && (u.setAttribute("width", `${
|
|
103
|
+
u && (u.setAttribute("width", `${m.currentWidth}`), u.setAttribute("height", `${m.currentHeight}`));
|
|
104
104
|
}
|
|
105
105
|
}, I = () => {
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const _ = u.currentWidth,
|
|
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 w = o.current, u = a.current, m = r.current;
|
|
107
|
+
if (w !== null && m !== null && u.isResizing) {
|
|
108
|
+
const _ = 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"), T(), t(_, M), document.removeEventListener("pointermove", k), document.removeEventListener("pointerup", I);
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
return /* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ v.jsxs("div", { ref: r, children: [
|
|
113
|
+
/* @__PURE__ */ v.jsx(
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
className: "image-resizer image-resizer-n",
|
|
117
|
-
onPointerDown: (
|
|
118
|
-
S(
|
|
117
|
+
onPointerDown: (w) => {
|
|
118
|
+
S(w, f.north);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ v.jsx(
|
|
123
123
|
"div",
|
|
124
124
|
{
|
|
125
125
|
className: "image-resizer image-resizer-ne",
|
|
126
|
-
onPointerDown: (
|
|
127
|
-
S(
|
|
126
|
+
onPointerDown: (w) => {
|
|
127
|
+
S(w, f.north | f.east);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
),
|
|
131
|
-
/* @__PURE__ */
|
|
131
|
+
/* @__PURE__ */ v.jsx(
|
|
132
132
|
"div",
|
|
133
133
|
{
|
|
134
134
|
className: "image-resizer image-resizer-e",
|
|
135
|
-
onPointerDown: (
|
|
136
|
-
S(
|
|
135
|
+
onPointerDown: (w) => {
|
|
136
|
+
S(w, f.east);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
),
|
|
140
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ v.jsx(
|
|
141
141
|
"div",
|
|
142
142
|
{
|
|
143
143
|
className: "image-resizer image-resizer-se",
|
|
144
|
-
onPointerDown: (
|
|
145
|
-
S(
|
|
144
|
+
onPointerDown: (w) => {
|
|
145
|
+
S(w, f.south | f.east);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
),
|
|
149
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ v.jsx(
|
|
150
150
|
"div",
|
|
151
151
|
{
|
|
152
152
|
className: "image-resizer image-resizer-s",
|
|
153
|
-
onPointerDown: (
|
|
154
|
-
S(
|
|
153
|
+
onPointerDown: (w) => {
|
|
154
|
+
S(w, f.south);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
),
|
|
158
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ v.jsx(
|
|
159
159
|
"div",
|
|
160
160
|
{
|
|
161
161
|
className: "image-resizer image-resizer-sw",
|
|
162
|
-
onPointerDown: (
|
|
163
|
-
S(
|
|
162
|
+
onPointerDown: (w) => {
|
|
163
|
+
S(w, f.south | f.west);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
),
|
|
167
|
-
/* @__PURE__ */
|
|
167
|
+
/* @__PURE__ */ v.jsx(
|
|
168
168
|
"div",
|
|
169
169
|
{
|
|
170
170
|
className: "image-resizer image-resizer-w",
|
|
171
|
-
onPointerDown: (
|
|
172
|
-
S(
|
|
171
|
+
onPointerDown: (w) => {
|
|
172
|
+
S(w, f.west);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
),
|
|
176
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ v.jsx(
|
|
177
177
|
"div",
|
|
178
178
|
{
|
|
179
179
|
className: "image-resizer image-resizer-nw",
|
|
180
|
-
onPointerDown: (
|
|
181
|
-
S(
|
|
180
|
+
onPointerDown: (w) => {
|
|
181
|
+
S(w, f.north | f.west);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
)
|
|
185
185
|
] });
|
|
186
186
|
}
|
|
187
|
-
const
|
|
187
|
+
const Z = {
|
|
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 l.unit === "%" ? { ...
|
|
193
|
+
}, j = (l, t, e) => Math.min(Math.max(l, t), e), _e = (...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
|
+
function B(l, t, e) {
|
|
195
|
+
return l.unit === "%" ? { ...Z, ...l, unit: "%" } : {
|
|
196
196
|
unit: "%",
|
|
197
197
|
x: l.x ? l.x / t * 100 : 0,
|
|
198
198
|
y: l.y ? l.y / e * 100 : 0,
|
|
@@ -200,14 +200,14 @@ function K(l, t, e) {
|
|
|
200
200
|
height: l.height ? l.height / e * 100 : 0
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
function
|
|
204
|
-
return l.unit ? l.unit === "px" ? { ...
|
|
203
|
+
function A(l, t, e) {
|
|
204
|
+
return l.unit ? l.unit === "px" ? { ...Z, ...l, unit: "px" } : {
|
|
205
205
|
unit: "px",
|
|
206
206
|
x: l.x ? l.x * t / 100 : 0,
|
|
207
207
|
y: l.y ? l.y * e / 100 : 0,
|
|
208
208
|
width: l.width ? l.width * t / 100 : 0,
|
|
209
209
|
height: l.height ? l.height * e / 100 : 0
|
|
210
|
-
} : { ...
|
|
210
|
+
} : { ...Z, ...l, unit: "px" };
|
|
211
211
|
}
|
|
212
212
|
function oe(l, t, e, o, n, i = 0, h = 0, p = o, s = n) {
|
|
213
213
|
const r = { ...l };
|
|
@@ -232,9 +232,9 @@ function Pe(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
|
|
235
|
+
const W = { capture: !0, passive: !1 };
|
|
236
236
|
let Se = 0;
|
|
237
|
-
const
|
|
237
|
+
const L = class $ extends Ee {
|
|
238
238
|
constructor() {
|
|
239
239
|
super(...arguments), this.docMoveBound = !1, this.mouseDownOnCrop = !1, this.dragStarted = !1, this.evData = {
|
|
240
240
|
startClientX: 0,
|
|
@@ -251,7 +251,7 @@ const k = class $ extends Ee {
|
|
|
251
251
|
const { crop: e, disabled: o } = this.props, n = this.getBox();
|
|
252
252
|
if (!e)
|
|
253
253
|
return;
|
|
254
|
-
const i =
|
|
254
|
+
const i = A(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 });
|
|
@@ -292,7 +292,7 @@ const k = class $ 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(A(d, p.width, p.height), B(d, 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: i } = this.props, h = this.getBox();
|
|
298
298
|
if (o || !e || !this.mouseDownOnCrop)
|
|
@@ -302,8 +302,8 @@ const k = class $ extends Ee {
|
|
|
302
302
|
p.clientX = t.clientX, p.clientY = t.clientY;
|
|
303
303
|
let s;
|
|
304
304
|
p.isResize ? s = this.resizeCrop() : s = this.dragCrop(), re(e, s) || n(
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
A(s, h.width, h.height),
|
|
306
|
+
B(s, h.width, h.height)
|
|
307
307
|
);
|
|
308
308
|
}, this.onComponentKeyDown = (t) => {
|
|
309
309
|
const { crop: e, disabled: o, onChange: n, onComplete: i } = this.props;
|
|
@@ -315,8 +315,8 @@ const k = class $ extends Ee {
|
|
|
315
315
|
return;
|
|
316
316
|
const s = this.getBox(), r = this.makePixelCrop(s), d = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? $.nudgeStepLarge : t.shiftKey ? $.nudgeStepMedium : $.nudgeStep;
|
|
317
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 =
|
|
319
|
-
const a =
|
|
318
|
+
t.cancelable && t.preventDefault(), r.x = j(r.x, 0, s.width - r.width), r.y = j(r.y, 0, s.height - r.height);
|
|
319
|
+
const a = A(r, s.width, s.height), g = B(r, s.width, s.height);
|
|
320
320
|
n(a, g), i && i(a, g);
|
|
321
321
|
}
|
|
322
322
|
}, this.onHandlerKeyDown = (t, e) => {
|
|
@@ -337,7 +337,7 @@ const k = class $ 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) ? $.nudgeStepLarge : t.shiftKey ? $.nudgeStepMedium : $.nudgeStep, y =
|
|
340
|
+
const c = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? $.nudgeStepLarge : t.shiftKey ? $.nudgeStepMedium : $.nudgeStep, y = A(n, g.width, g.height), N = Pe(y, t.key, c, e), x = oe(
|
|
341
341
|
N,
|
|
342
342
|
o,
|
|
343
343
|
e,
|
|
@@ -349,12 +349,12 @@ const k = class $ extends Ee {
|
|
|
349
349
|
r
|
|
350
350
|
);
|
|
351
351
|
if (!re(n, x)) {
|
|
352
|
-
const P =
|
|
352
|
+
const P = B(x, g.width, g.height);
|
|
353
353
|
d(x, P), a && a(x, P);
|
|
354
354
|
}
|
|
355
355
|
}, this.onDocPointerDone = (t) => {
|
|
356
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(
|
|
357
|
+
this.unbindDocMove(), !(o || !e) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, i && i(t), n && n(A(e, h.width, h.height), B(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,17 +376,17 @@ const k = class $ extends Ee {
|
|
|
376
376
|
const { crop: e, onComplete: o } = this.props;
|
|
377
377
|
if (o && !t.crop && e) {
|
|
378
378
|
const { width: n, height: i } = this.getBox();
|
|
379
|
-
n && i && o(
|
|
379
|
+
n && i && o(A(e, n, i), B(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, W), this.document.addEventListener("pointerup", this.onDocPointerDone, W), this.document.addEventListener("pointercancel", this.onDocPointerDone, W), 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, W), this.document.removeEventListener("pointerup", this.onDocPointerDone, W), this.document.removeEventListener("pointercancel", this.onDocPointerDone, W), this.docMoveBound = !1);
|
|
390
390
|
}
|
|
391
391
|
getCropStyle() {
|
|
392
392
|
const { crop: t } = this.props;
|
|
@@ -400,7 +400,7 @@ const k = class $ 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, i = t.clientY - t.startClientY;
|
|
403
|
-
return o.x =
|
|
403
|
+
return o.x = j(t.startCropX + n, 0, e.width - o.width), o.y = j(t.startCropY + i, 0, e.height - o.height), o;
|
|
404
404
|
}
|
|
405
405
|
getPointRegion(t, e, o, n) {
|
|
406
406
|
const { evData: i } = this, h = i.clientX - t.x, p = i.clientY - t.y;
|
|
@@ -438,7 +438,7 @@ const k = class $ extends Ee {
|
|
|
438
438
|
o,
|
|
439
439
|
n
|
|
440
440
|
);
|
|
441
|
-
return e || $.xyOrds.indexOf(d) > -1 ? s = y : $.xOrds.indexOf(d) > -1 ? (s.x = y.x, s.width = y.width) : $.yOrds.indexOf(d) > -1 && (s.y = y.y, s.height = y.height), s.x =
|
|
441
|
+
return e || $.xyOrds.indexOf(d) > -1 ? s = y : $.xOrds.indexOf(d) > -1 ? (s.x = y.x, s.width = y.width) : $.yOrds.indexOf(d) > -1 && (s.y = y.y, s.height = y.height), s.x = j(s.x, 0, i.width - s.width), s.y = j(s.y, 0, i.height - s.height), s;
|
|
442
442
|
}
|
|
443
443
|
renderCropSelection() {
|
|
444
444
|
const {
|
|
@@ -547,8 +547,8 @@ const k = class $ extends Ee {
|
|
|
547
547
|
);
|
|
548
548
|
}
|
|
549
549
|
makePixelCrop(t) {
|
|
550
|
-
const e = { ...
|
|
551
|
-
return
|
|
550
|
+
const e = { ...Z, ...this.props.crop || {} };
|
|
551
|
+
return A(e, t.width, t.height);
|
|
552
552
|
}
|
|
553
553
|
render() {
|
|
554
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 = _e(
|
|
@@ -585,7 +585,7 @@ const k = class $ extends Ee {
|
|
|
585
585
|
))), /* @__PURE__ */ C.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
|
+
L.xOrds = ["e", "w"], L.yOrds = ["n", "s"], L.xyOrds = ["nw", "ne", "se", "sw"], L.nudgeStep = 1, L.nudgeStepMedium = 10, L.nudgeStepLarge = 100, L.defaultProps = {
|
|
589
589
|
ariaLabels: {
|
|
590
590
|
cropArea: "Use the arrow keys to move the crop selection area",
|
|
591
591
|
nwDragHandle: "Use the arrow keys to move the north west drag handle to change the crop selection area",
|
|
@@ -598,7 +598,7 @@ k.xOrds = ["e", "w"], k.yOrds = ["n", "s"], k.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 He =
|
|
601
|
+
let He = L;
|
|
602
602
|
const se = be("RIGHT_CLICK_IMAGE_COMMAND");
|
|
603
603
|
function $e({
|
|
604
604
|
altText: l,
|
|
@@ -613,7 +613,7 @@ function $e({
|
|
|
613
613
|
isFocused: r,
|
|
614
614
|
nodeKey: d
|
|
615
615
|
}) {
|
|
616
|
-
const [a, g] =
|
|
616
|
+
const [a, g] = U(null), [c, y] = U(null), [N, x] = U({
|
|
617
617
|
//@ts-ignore
|
|
618
618
|
unit: "px",
|
|
619
619
|
// Can be 'px' or '%'
|
|
@@ -621,61 +621,68 @@ function $e({
|
|
|
621
621
|
y: 25,
|
|
622
622
|
width: 50,
|
|
623
623
|
height: 50
|
|
624
|
-
}), [P] = ae(),
|
|
624
|
+
}), [P] = ae(), T = () => {
|
|
625
625
|
if (a) {
|
|
626
626
|
const u = h.current;
|
|
627
627
|
if (!u || !a)
|
|
628
628
|
return;
|
|
629
|
-
const
|
|
630
|
-
a.width *
|
|
629
|
+
const m = u.naturalWidth / u.width, _ = u.naturalHeight / u.height, M = new OffscreenCanvas(
|
|
630
|
+
a.width * m,
|
|
631
631
|
a.height * _
|
|
632
|
-
), b =
|
|
632
|
+
), b = M.getContext("2d");
|
|
633
633
|
if (!b)
|
|
634
634
|
throw new Error("No 2D context available");
|
|
635
635
|
b.drawImage(
|
|
636
636
|
u,
|
|
637
|
-
a.x *
|
|
637
|
+
a.x * m,
|
|
638
638
|
a.y * _,
|
|
639
|
-
a.width *
|
|
639
|
+
a.width * m,
|
|
640
640
|
a.height * _,
|
|
641
641
|
0,
|
|
642
642
|
0,
|
|
643
|
-
a.width *
|
|
643
|
+
a.width * m,
|
|
644
644
|
a.height * _
|
|
645
|
-
),
|
|
646
|
-
const
|
|
647
|
-
y(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
645
|
+
), M.convertToBlob({ type: "image/png" }).then((D) => {
|
|
646
|
+
const X = URL.createObjectURL(D);
|
|
647
|
+
y(X), s(!1);
|
|
648
|
+
const O = new FileReader();
|
|
649
|
+
O.onload = () => {
|
|
650
|
+
const K = O.result;
|
|
651
|
+
P.update(() => {
|
|
652
|
+
const R = J(d);
|
|
653
|
+
Q(R) && K && R.setSrc(K);
|
|
654
|
+
});
|
|
655
|
+
}, O.onerror = () => {
|
|
656
|
+
console.log("error");
|
|
657
|
+
}, O.readAsDataURL(D);
|
|
651
658
|
});
|
|
652
659
|
}
|
|
653
660
|
}, S = () => {
|
|
654
661
|
p || s((u) => {
|
|
655
662
|
if (u === !1) {
|
|
656
|
-
const
|
|
663
|
+
const m = h.current;
|
|
657
664
|
x({
|
|
658
665
|
unit: "px",
|
|
659
666
|
// Can be 'px' or '%'
|
|
660
667
|
x: 0,
|
|
661
668
|
y: 0,
|
|
662
|
-
width:
|
|
663
|
-
height:
|
|
669
|
+
width: m.width,
|
|
670
|
+
height: m.height
|
|
664
671
|
});
|
|
665
672
|
}
|
|
666
673
|
return !u;
|
|
667
674
|
});
|
|
668
|
-
},
|
|
675
|
+
}, k = Y(null), I = Y(null);
|
|
669
676
|
te(() => {
|
|
670
|
-
a && (
|
|
677
|
+
a && (k.current = a);
|
|
671
678
|
}, [a]);
|
|
672
|
-
const
|
|
679
|
+
const w = (u) => {
|
|
673
680
|
I.current && !I.current.contains(u.target) && s(!1);
|
|
674
681
|
};
|
|
675
|
-
return te(() => (document.addEventListener("mousedown",
|
|
676
|
-
document.removeEventListener("mousedown",
|
|
677
|
-
}), []), /* @__PURE__ */
|
|
678
|
-
r && /* @__PURE__ */
|
|
682
|
+
return te(() => (document.addEventListener("mousedown", w), () => {
|
|
683
|
+
document.removeEventListener("mousedown", w);
|
|
684
|
+
}), []), /* @__PURE__ */ v.jsxs("div", { ref: I, children: [
|
|
685
|
+
r && /* @__PURE__ */ v.jsx(
|
|
679
686
|
"button",
|
|
680
687
|
{
|
|
681
688
|
style: { zIndex: 999 },
|
|
@@ -684,22 +691,22 @@ function $e({
|
|
|
684
691
|
children: "Crop"
|
|
685
692
|
}
|
|
686
693
|
),
|
|
687
|
-
p && /* @__PURE__ */
|
|
694
|
+
p && /* @__PURE__ */ v.jsx(
|
|
688
695
|
"button",
|
|
689
696
|
{
|
|
690
697
|
style: { zIndex: 999 },
|
|
691
698
|
className: "image-caption-button",
|
|
692
|
-
onClick: () =>
|
|
699
|
+
onClick: () => T(),
|
|
693
700
|
children: "Apply Crop"
|
|
694
701
|
}
|
|
695
702
|
),
|
|
696
|
-
p ? /* @__PURE__ */
|
|
703
|
+
p ? /* @__PURE__ */ v.jsx(
|
|
697
704
|
He,
|
|
698
705
|
{
|
|
699
706
|
crop: N,
|
|
700
707
|
onChange: (u) => x(u),
|
|
701
708
|
onComplete: (u) => g(u),
|
|
702
|
-
children: /* @__PURE__ */
|
|
709
|
+
children: /* @__PURE__ */ v.jsx(
|
|
703
710
|
"img",
|
|
704
711
|
{
|
|
705
712
|
className: t || void 0,
|
|
@@ -717,7 +724,7 @@ function $e({
|
|
|
717
724
|
}
|
|
718
725
|
) : (
|
|
719
726
|
// When startCrop is false, show the cropped image or original image
|
|
720
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ v.jsx(
|
|
721
728
|
"img",
|
|
722
729
|
{
|
|
723
730
|
className: t || void 0,
|
|
@@ -735,7 +742,7 @@ function $e({
|
|
|
735
742
|
)
|
|
736
743
|
] });
|
|
737
744
|
}
|
|
738
|
-
function
|
|
745
|
+
function Ye({
|
|
739
746
|
src: l,
|
|
740
747
|
altText: t,
|
|
741
748
|
nodeKey: e,
|
|
@@ -746,63 +753,63 @@ function Ae({
|
|
|
746
753
|
showCaption: p,
|
|
747
754
|
caption: s
|
|
748
755
|
}) {
|
|
749
|
-
const r =
|
|
750
|
-
(
|
|
751
|
-
if (a &&
|
|
752
|
-
|
|
753
|
-
const H =
|
|
754
|
-
if (
|
|
756
|
+
const r = Y(null), d = Y(null), [a, g, c] = ce(e), [y, N] = U(!1), [x] = ae(), [P, T] = U(null), [S, k] = U(!1), I = Y(null), w = V(
|
|
757
|
+
(R) => {
|
|
758
|
+
if (a && G(q())) {
|
|
759
|
+
R.preventDefault();
|
|
760
|
+
const H = J(e);
|
|
761
|
+
if (Q(H))
|
|
755
762
|
return H.remove(), !0;
|
|
756
763
|
}
|
|
757
764
|
return !1;
|
|
758
765
|
},
|
|
759
766
|
[a, e]
|
|
760
|
-
), u =
|
|
761
|
-
(
|
|
762
|
-
const
|
|
763
|
-
if (a &&
|
|
767
|
+
), u = V(
|
|
768
|
+
(R) => {
|
|
769
|
+
const E = q(), H = d.current;
|
|
770
|
+
if (a && G(E) && E.getNodes().length === 1) {
|
|
764
771
|
if (p)
|
|
765
|
-
return ne(null),
|
|
772
|
+
return ne(null), R.preventDefault(), s.focus(), !0;
|
|
766
773
|
if (H !== null && H !== document.activeElement)
|
|
767
|
-
return
|
|
774
|
+
return R.preventDefault(), H.focus(), !0;
|
|
768
775
|
}
|
|
769
776
|
return !1;
|
|
770
777
|
},
|
|
771
778
|
[s, a, p]
|
|
772
|
-
),
|
|
773
|
-
(
|
|
779
|
+
), m = V(
|
|
780
|
+
(R) => I.current === s || d.current === R.target ? (ne(null), x.update(() => {
|
|
774
781
|
g(!0);
|
|
775
|
-
const
|
|
776
|
-
|
|
782
|
+
const E = x.getRootElement();
|
|
783
|
+
E !== null && E.focus();
|
|
777
784
|
}), !0) : !1,
|
|
778
785
|
[s, x, g]
|
|
779
|
-
), _ =
|
|
780
|
-
(
|
|
781
|
-
const
|
|
782
|
-
return y ? !0 :
|
|
786
|
+
), _ = V(
|
|
787
|
+
(R) => {
|
|
788
|
+
const E = R;
|
|
789
|
+
return y ? !0 : E.target === r.current ? (E.shiftKey ? g(!a) : (c(), g(!0)), !0) : !1;
|
|
783
790
|
},
|
|
784
791
|
[y, a, g, c]
|
|
785
|
-
),
|
|
786
|
-
(
|
|
792
|
+
), M = V(
|
|
793
|
+
(R) => {
|
|
787
794
|
x.getEditorState().read(() => {
|
|
788
|
-
const
|
|
789
|
-
|
|
795
|
+
const E = q();
|
|
796
|
+
R.target.tagName === "IMG" && de(E) && E.getNodes().length === 1 && x.dispatchCommand(
|
|
790
797
|
se,
|
|
791
|
-
|
|
798
|
+
R
|
|
792
799
|
);
|
|
793
800
|
});
|
|
794
801
|
},
|
|
795
802
|
[x]
|
|
796
803
|
);
|
|
797
804
|
te(() => {
|
|
798
|
-
let
|
|
799
|
-
const
|
|
800
|
-
x.registerUpdateListener(({ editorState:
|
|
801
|
-
|
|
805
|
+
let R = !0;
|
|
806
|
+
const E = x.getRootElement(), H = le(
|
|
807
|
+
x.registerUpdateListener(({ editorState: F }) => {
|
|
808
|
+
R && T(F.read(() => q()));
|
|
802
809
|
}),
|
|
803
810
|
x.registerCommand(
|
|
804
811
|
ge,
|
|
805
|
-
(
|
|
812
|
+
(F, he) => (I.current = he, !1),
|
|
806
813
|
z
|
|
807
814
|
),
|
|
808
815
|
x.registerCommand(
|
|
@@ -817,24 +824,24 @@ function Ae({
|
|
|
817
824
|
),
|
|
818
825
|
x.registerCommand(
|
|
819
826
|
pe,
|
|
820
|
-
(
|
|
827
|
+
(F) => F.target === r.current ? (F.preventDefault(), !0) : !1,
|
|
821
828
|
z
|
|
822
829
|
),
|
|
823
830
|
x.registerCommand(
|
|
824
|
-
|
|
825
|
-
|
|
831
|
+
we,
|
|
832
|
+
w,
|
|
826
833
|
z
|
|
827
834
|
),
|
|
828
835
|
x.registerCommand(
|
|
829
|
-
|
|
830
|
-
|
|
836
|
+
me,
|
|
837
|
+
w,
|
|
831
838
|
z
|
|
832
839
|
),
|
|
833
840
|
x.registerCommand(xe, u, z),
|
|
834
|
-
x.registerCommand(Ce,
|
|
841
|
+
x.registerCommand(Ce, m, z)
|
|
835
842
|
);
|
|
836
|
-
return
|
|
837
|
-
|
|
843
|
+
return E == null || E.addEventListener("contextmenu", M), () => {
|
|
844
|
+
R = !1, H(), E == null || E.removeEventListener("contextmenu", M);
|
|
838
845
|
};
|
|
839
846
|
}, [
|
|
840
847
|
c,
|
|
@@ -842,33 +849,33 @@ function Ae({
|
|
|
842
849
|
y,
|
|
843
850
|
a,
|
|
844
851
|
e,
|
|
845
|
-
m,
|
|
846
|
-
u,
|
|
847
852
|
w,
|
|
853
|
+
u,
|
|
854
|
+
m,
|
|
848
855
|
_,
|
|
849
|
-
|
|
856
|
+
M,
|
|
850
857
|
g
|
|
851
858
|
]);
|
|
852
859
|
const b = () => {
|
|
853
860
|
x.update(() => {
|
|
854
|
-
const
|
|
855
|
-
|
|
861
|
+
const R = J(e);
|
|
862
|
+
Q(R) && R.setShowCaption(!0);
|
|
856
863
|
});
|
|
857
|
-
},
|
|
864
|
+
}, D = (R, E) => {
|
|
858
865
|
setTimeout(() => {
|
|
859
866
|
N(!1);
|
|
860
867
|
}, 200), x.update(() => {
|
|
861
|
-
const H =
|
|
862
|
-
console.log(H, "node"),
|
|
868
|
+
const H = J(e);
|
|
869
|
+
console.log(H, "node"), Q(H) && H.setWidthAndHeight(R, E);
|
|
863
870
|
});
|
|
864
|
-
},
|
|
871
|
+
}, X = () => {
|
|
865
872
|
S || N(!0);
|
|
866
|
-
},
|
|
867
|
-
return /* @__PURE__ */
|
|
868
|
-
/* @__PURE__ */
|
|
873
|
+
}, O = a && G(P) && !y, K = a || y;
|
|
874
|
+
return /* @__PURE__ */ v.jsx(Me, { fallback: null, children: /* @__PURE__ */ v.jsxs(v.Fragment, { children: [
|
|
875
|
+
/* @__PURE__ */ v.jsx("div", { draggable: O, children: /* @__PURE__ */ v.jsx(
|
|
869
876
|
$e,
|
|
870
877
|
{
|
|
871
|
-
className:
|
|
878
|
+
className: K ? `focused ${G(P) ? "draggable" : ""}` : null,
|
|
872
879
|
src: l,
|
|
873
880
|
altText: t,
|
|
874
881
|
width: o,
|
|
@@ -876,20 +883,20 @@ function Ae({
|
|
|
876
883
|
maxWidth: i,
|
|
877
884
|
imageRef: r,
|
|
878
885
|
startCrop: S,
|
|
879
|
-
setStartCrop:
|
|
880
|
-
isFocused:
|
|
886
|
+
setStartCrop: k,
|
|
887
|
+
isFocused: K,
|
|
881
888
|
nodeKey: e
|
|
882
889
|
}
|
|
883
890
|
) }),
|
|
884
|
-
p && /* @__PURE__ */
|
|
891
|
+
p && /* @__PURE__ */ v.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ v.jsx(Re, { initialEditor: s, children: /* @__PURE__ */ v.jsx(
|
|
885
892
|
fe,
|
|
886
893
|
{
|
|
887
|
-
contentEditable: /* @__PURE__ */
|
|
888
|
-
placeholder: /* @__PURE__ */
|
|
894
|
+
contentEditable: /* @__PURE__ */ v.jsx(ye, { className: "ImageNode__contentEditable" }),
|
|
895
|
+
placeholder: /* @__PURE__ */ v.jsx(De, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
|
|
889
896
|
ErrorBoundary: ve
|
|
890
897
|
}
|
|
891
898
|
) }) }),
|
|
892
|
-
!S && h &&
|
|
899
|
+
!S && h && G(P) && K && /* @__PURE__ */ v.jsx(
|
|
893
900
|
Ne,
|
|
894
901
|
{
|
|
895
902
|
showCaption: p,
|
|
@@ -898,9 +905,9 @@ function Ae({
|
|
|
898
905
|
buttonRef: d,
|
|
899
906
|
maxWidth: i,
|
|
900
907
|
onResizeStart: S ? () => {
|
|
901
|
-
} :
|
|
908
|
+
} : X,
|
|
902
909
|
onResizeEnd: S ? () => {
|
|
903
|
-
} :
|
|
910
|
+
} : D,
|
|
904
911
|
captionsEnabled: !1,
|
|
905
912
|
imageRef: r
|
|
906
913
|
}
|
|
@@ -909,6 +916,6 @@ function Ae({
|
|
|
909
916
|
}
|
|
910
917
|
export {
|
|
911
918
|
se as RIGHT_CLICK_IMAGE_COMMAND,
|
|
912
|
-
|
|
919
|
+
Ye as default
|
|
913
920
|
};
|
|
914
|
-
//# sourceMappingURL=ImageComponent-
|
|
921
|
+
//# sourceMappingURL=ImageComponent-ced58b97.js.map
|