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.
@@ -1,6 +1,6 @@
1
- import { j as D, u as ce, a as ae, $ as T, b as V, c as q, d as J, e as ne, f as de, m as le, S as ge, C as z, g as ue, D as pe, K as me, h as we, i as xe, k as Ce, R as fe, L as ye, P as De, l as ve, n as be } from "./index-75a3fc49.js";
2
- import { L as Re } from "./LexicalNestedComposer.esm-6289c7f2.js";
3
- import C, { useRef as A, PureComponent as Ee, createRef as ie, useState as B, useCallback as G, useEffect as te, Suspense as Me } from "react";
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 = A(null), d = A({
25
+ const r = Y(null), d = Y({
26
26
  priority: "",
27
27
  value: "default"
28
- }), a = 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 = (m) => {
39
- const u = m === f.east || m === f.west, w = m === f.north || m === f.south, _ = m & f.north && m & f.west || m & f.south && m & f.east, E = u ? "ew" : w ? "ns" : _ ? "nwse" : "nesw";
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
- `${E}-resize`,
42
+ `${M}-resize`,
43
43
  "important"
44
44
  ), document.body !== null && (document.body.style.setProperty(
45
45
  "cursor",
46
- `${E}-resize`,
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
- }, W = () => {
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 = (m, u) => {
63
+ }, S = (w, u) => {
64
64
  if (!i.isEditable())
65
65
  return;
66
- const w = o.current, _ = r.current;
67
- if (w !== null && _ !== null) {
68
- m.preventDefault();
69
- const { width: E, height: b } = w.getBoundingClientRect(), v = a.current;
70
- v.startWidth = E, v.startHeight = b, v.ratio = E / b, v.currentWidth = E, v.currentHeight = b, v.startX = m.clientX, v.startY = m.clientY, v.isResizing = !0, v.direction = u, P(u), l(), _.classList.add("image-control-wrapper--resizing"), w.style.height = `${b}px`, w.style.width = `${E}px`, document.addEventListener("pointermove", X), document.addEventListener("pointerup", I);
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
- }, X = (m) => {
73
- const u = o.current, w = a.current, _ = w.direction & (f.east | f.west), E = w.direction & (f.south | f.north);
74
- if (u !== null && w.isResizing) {
75
- if (_ && E) {
76
- let b = Math.floor(w.startX - m.clientX);
77
- b = w.direction & f.east ? -b : b;
78
- const v = ee(
79
- w.startWidth + b,
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
- ), L = v / w.ratio;
83
- u.style.width = `${v}px`, u.style.height = `${L}px`, w.currentHeight = L, w.currentWidth = v;
84
- } else if (E) {
85
- let b = Math.floor(w.startY - m.clientY);
86
- b = w.direction & f.south ? -b : b;
87
- const v = ee(
88
- w.startHeight + b,
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 = `${v}px`, u.style.maxHeight = `${v}px`, w.currentHeight = v;
92
+ u.style.height = `${D}px`, u.style.maxHeight = `${D}px`, m.currentHeight = D;
93
93
  } else {
94
- let b = Math.floor(w.startX - m.clientX);
95
- b = w.direction & f.east ? -b : b;
96
- const v = ee(
97
- w.startWidth + b,
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 = `${v}px`, u.style.maxWidth = `${v}px`, w.currentWidth = v;
101
+ u.style.width = `${D}px`, u.style.maxWidth = `${D}px`, m.currentWidth = D;
102
102
  }
103
- u && (u.setAttribute("width", `${w.currentWidth}`), u.setAttribute("height", `${w.currentHeight}`));
103
+ u && (u.setAttribute("width", `${m.currentWidth}`), u.setAttribute("height", `${m.currentHeight}`));
104
104
  }
105
105
  }, I = () => {
106
- const m = o.current, u = a.current, w = r.current;
107
- if (m !== null && w !== null && u.isResizing) {
108
- const _ = u.currentWidth, E = 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"), W(), t(_, E), document.removeEventListener("pointermove", X), document.removeEventListener("pointerup", I);
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__ */ D.jsxs("div", { ref: r, children: [
113
- /* @__PURE__ */ D.jsx(
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: (m) => {
118
- S(m, f.north);
117
+ onPointerDown: (w) => {
118
+ S(w, f.north);
119
119
  }
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ D.jsx(
122
+ /* @__PURE__ */ v.jsx(
123
123
  "div",
124
124
  {
125
125
  className: "image-resizer image-resizer-ne",
126
- onPointerDown: (m) => {
127
- S(m, f.north | f.east);
126
+ onPointerDown: (w) => {
127
+ S(w, f.north | f.east);
128
128
  }
129
129
  }
130
130
  ),
131
- /* @__PURE__ */ D.jsx(
131
+ /* @__PURE__ */ v.jsx(
132
132
  "div",
133
133
  {
134
134
  className: "image-resizer image-resizer-e",
135
- onPointerDown: (m) => {
136
- S(m, f.east);
135
+ onPointerDown: (w) => {
136
+ S(w, f.east);
137
137
  }
138
138
  }
139
139
  ),
140
- /* @__PURE__ */ D.jsx(
140
+ /* @__PURE__ */ v.jsx(
141
141
  "div",
142
142
  {
143
143
  className: "image-resizer image-resizer-se",
144
- onPointerDown: (m) => {
145
- S(m, f.south | f.east);
144
+ onPointerDown: (w) => {
145
+ S(w, f.south | f.east);
146
146
  }
147
147
  }
148
148
  ),
149
- /* @__PURE__ */ D.jsx(
149
+ /* @__PURE__ */ v.jsx(
150
150
  "div",
151
151
  {
152
152
  className: "image-resizer image-resizer-s",
153
- onPointerDown: (m) => {
154
- S(m, f.south);
153
+ onPointerDown: (w) => {
154
+ S(w, f.south);
155
155
  }
156
156
  }
157
157
  ),
158
- /* @__PURE__ */ D.jsx(
158
+ /* @__PURE__ */ v.jsx(
159
159
  "div",
160
160
  {
161
161
  className: "image-resizer image-resizer-sw",
162
- onPointerDown: (m) => {
163
- S(m, f.south | f.west);
162
+ onPointerDown: (w) => {
163
+ S(w, f.south | f.west);
164
164
  }
165
165
  }
166
166
  ),
167
- /* @__PURE__ */ D.jsx(
167
+ /* @__PURE__ */ v.jsx(
168
168
  "div",
169
169
  {
170
170
  className: "image-resizer image-resizer-w",
171
- onPointerDown: (m) => {
172
- S(m, f.west);
171
+ onPointerDown: (w) => {
172
+ S(w, f.west);
173
173
  }
174
174
  }
175
175
  ),
176
- /* @__PURE__ */ D.jsx(
176
+ /* @__PURE__ */ v.jsx(
177
177
  "div",
178
178
  {
179
179
  className: "image-resizer image-resizer-nw",
180
- onPointerDown: (m) => {
181
- S(m, f.north | f.west);
180
+ onPointerDown: (w) => {
181
+ S(w, f.north | f.west);
182
182
  }
183
183
  }
184
184
  )
185
185
  ] });
186
186
  }
187
- const Q = {
187
+ const Z = {
188
188
  x: 0,
189
189
  y: 0,
190
190
  width: 0,
191
191
  height: 0,
192
192
  unit: "px"
193
- }, O = (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 K(l, t, e) {
195
- return l.unit === "%" ? { ...Q, ...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 Y(l, t, e) {
204
- return l.unit ? l.unit === "px" ? { ...Q, ...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
- } : { ...Q, ...l, unit: "px" };
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 j = { capture: !0, passive: !1 };
235
+ const W = { capture: !0, passive: !1 };
236
236
  let Se = 0;
237
- const k = class $ extends Ee {
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 = Y(e, n.width, n.height);
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(Y(d, p.width, p.height), K(d, p.width, p.height)), this.setState({ cropIsActive: !0, newCropIsBeingDrawn: !0 });
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
- Y(s, h.width, h.height),
306
- K(s, h.width, h.height)
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 = O(r.x, 0, s.width - r.width), r.y = O(r.y, 0, s.height - r.height);
319
- const a = Y(r, s.width, s.height), g = K(r, s.width, s.height);
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 = Y(n, g.width, g.height), N = Pe(y, t.key, c, e), x = oe(
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 = K(x, g.width, g.height);
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(Y(e, h.width, h.height), K(e, h.width, h.height)), this.setState({ cropIsActive: !1, newCropIsBeingDrawn: !1 }));
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(Y(e, n, i), K(e, n, i));
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, j), this.document.addEventListener("pointerup", this.onDocPointerDone, j), this.document.addEventListener("pointercancel", this.onDocPointerDone, j), this.docMoveBound = !0);
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, j), this.document.removeEventListener("pointerup", this.onDocPointerDone, j), this.document.removeEventListener("pointercancel", this.onDocPointerDone, j), this.docMoveBound = !1);
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 = O(t.startCropX + n, 0, e.width - o.width), o.y = O(t.startCropY + i, 0, e.height - o.height), o;
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 = O(s.x, 0, i.width - s.width), s.y = O(s.y, 0, i.height - s.height), s;
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 = { ...Q, ...this.props.crop || {} };
551
- return Y(e, t.width, t.height);
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
- k.xOrds = ["e", "w"], k.yOrds = ["n", "s"], k.xyOrds = ["nw", "ne", "se", "sw"], k.nudgeStep = 1, k.nudgeStepMedium = 10, k.nudgeStepLarge = 100, k.defaultProps = {
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 = k;
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] = B(null), [c, y] = B(null), [N, x] = B({
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(), W = () => {
624
+ }), [P] = ae(), T = () => {
625
625
  if (a) {
626
626
  const u = h.current;
627
627
  if (!u || !a)
628
628
  return;
629
- const w = u.naturalWidth / u.width, _ = u.naturalHeight / u.height, E = new OffscreenCanvas(
630
- a.width * w,
629
+ const m = u.naturalWidth / u.width, _ = u.naturalHeight / u.height, M = new OffscreenCanvas(
630
+ a.width * m,
631
631
  a.height * _
632
- ), b = E.getContext("2d");
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 * w,
637
+ a.x * m,
638
638
  a.y * _,
639
- a.width * w,
639
+ a.width * m,
640
640
  a.height * _,
641
641
  0,
642
642
  0,
643
- a.width * w,
643
+ a.width * m,
644
644
  a.height * _
645
- ), E.convertToBlob({ type: "image/png" }).then((v) => {
646
- const L = URL.createObjectURL(v);
647
- y(L), s(!1), P.update(() => {
648
- const F = q(d);
649
- J(F) && F.setSrc(L);
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 w = h.current;
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: w.width,
663
- height: w.height
669
+ width: m.width,
670
+ height: m.height
664
671
  });
665
672
  }
666
673
  return !u;
667
674
  });
668
- }, X = A(null), I = A(null);
675
+ }, k = Y(null), I = Y(null);
669
676
  te(() => {
670
- a && (X.current = a);
677
+ a && (k.current = a);
671
678
  }, [a]);
672
- const m = (u) => {
679
+ const w = (u) => {
673
680
  I.current && !I.current.contains(u.target) && s(!1);
674
681
  };
675
- return te(() => (document.addEventListener("mousedown", m), () => {
676
- document.removeEventListener("mousedown", m);
677
- }), []), /* @__PURE__ */ D.jsxs("div", { ref: I, children: [
678
- r && /* @__PURE__ */ D.jsx(
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__ */ D.jsx(
694
+ p && /* @__PURE__ */ v.jsx(
688
695
  "button",
689
696
  {
690
697
  style: { zIndex: 999 },
691
698
  className: "image-caption-button",
692
- onClick: () => W(),
699
+ onClick: () => T(),
693
700
  children: "Apply Crop"
694
701
  }
695
702
  ),
696
- p ? /* @__PURE__ */ D.jsx(
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__ */ D.jsx(
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__ */ D.jsx(
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 Ae({
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 = A(null), d = A(null), [a, g, c] = ce(e), [y, N] = B(!1), [x] = ae(), [P, W] = B(null), [S, X] = B(!1), I = A(null), m = G(
750
- (M) => {
751
- if (a && T(V())) {
752
- M.preventDefault();
753
- const H = q(e);
754
- if (J(H))
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 = G(
761
- (M) => {
762
- const R = V(), H = d.current;
763
- if (a && T(R) && R.getNodes().length === 1) {
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), M.preventDefault(), s.focus(), !0;
772
+ return ne(null), R.preventDefault(), s.focus(), !0;
766
773
  if (H !== null && H !== document.activeElement)
767
- return M.preventDefault(), H.focus(), !0;
774
+ return R.preventDefault(), H.focus(), !0;
768
775
  }
769
776
  return !1;
770
777
  },
771
778
  [s, a, p]
772
- ), w = G(
773
- (M) => I.current === s || d.current === M.target ? (ne(null), x.update(() => {
779
+ ), m = V(
780
+ (R) => I.current === s || d.current === R.target ? (ne(null), x.update(() => {
774
781
  g(!0);
775
- const R = x.getRootElement();
776
- R !== null && R.focus();
782
+ const E = x.getRootElement();
783
+ E !== null && E.focus();
777
784
  }), !0) : !1,
778
785
  [s, x, g]
779
- ), _ = G(
780
- (M) => {
781
- const R = M;
782
- return y ? !0 : R.target === r.current ? (R.shiftKey ? g(!a) : (c(), g(!0)), !0) : !1;
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
- ), E = G(
786
- (M) => {
792
+ ), M = V(
793
+ (R) => {
787
794
  x.getEditorState().read(() => {
788
- const R = V();
789
- M.target.tagName === "IMG" && de(R) && R.getNodes().length === 1 && x.dispatchCommand(
795
+ const E = q();
796
+ R.target.tagName === "IMG" && de(E) && E.getNodes().length === 1 && x.dispatchCommand(
790
797
  se,
791
- M
798
+ R
792
799
  );
793
800
  });
794
801
  },
795
802
  [x]
796
803
  );
797
804
  te(() => {
798
- let M = !0;
799
- const R = x.getRootElement(), H = le(
800
- x.registerUpdateListener(({ editorState: U }) => {
801
- M && W(U.read(() => V()));
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
- (U, he) => (I.current = he, !1),
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
- (U) => U.target === r.current ? (U.preventDefault(), !0) : !1,
827
+ (F) => F.target === r.current ? (F.preventDefault(), !0) : !1,
821
828
  z
822
829
  ),
823
830
  x.registerCommand(
824
- me,
825
- m,
831
+ we,
832
+ w,
826
833
  z
827
834
  ),
828
835
  x.registerCommand(
829
- we,
830
- m,
836
+ me,
837
+ w,
831
838
  z
832
839
  ),
833
840
  x.registerCommand(xe, u, z),
834
- x.registerCommand(Ce, w, z)
841
+ x.registerCommand(Ce, m, z)
835
842
  );
836
- return R == null || R.addEventListener("contextmenu", E), () => {
837
- M = !1, H(), R == null || R.removeEventListener("contextmenu", E);
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
- E,
856
+ M,
850
857
  g
851
858
  ]);
852
859
  const b = () => {
853
860
  x.update(() => {
854
- const M = q(e);
855
- J(M) && M.setShowCaption(!0);
861
+ const R = J(e);
862
+ Q(R) && R.setShowCaption(!0);
856
863
  });
857
- }, v = (M, R) => {
864
+ }, D = (R, E) => {
858
865
  setTimeout(() => {
859
866
  N(!1);
860
867
  }, 200), x.update(() => {
861
- const H = q(e);
862
- console.log(H, "node"), J(H) && H.setWidthAndHeight(M, R);
868
+ const H = J(e);
869
+ console.log(H, "node"), Q(H) && H.setWidthAndHeight(R, E);
863
870
  });
864
- }, L = () => {
871
+ }, X = () => {
865
872
  S || N(!0);
866
- }, F = a && T(P) && !y, Z = a || y;
867
- return /* @__PURE__ */ D.jsx(Me, { fallback: null, children: /* @__PURE__ */ D.jsxs(D.Fragment, { children: [
868
- /* @__PURE__ */ D.jsx("div", { draggable: F, children: /* @__PURE__ */ D.jsx(
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: Z ? `focused ${T(P) ? "draggable" : ""}` : null,
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: X,
880
- isFocused: Z,
886
+ setStartCrop: k,
887
+ isFocused: K,
881
888
  nodeKey: e
882
889
  }
883
890
  ) }),
884
- p && /* @__PURE__ */ D.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ D.jsx(Re, { initialEditor: s, children: /* @__PURE__ */ D.jsx(
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__ */ D.jsx(ye, { className: "ImageNode__contentEditable" }),
888
- placeholder: /* @__PURE__ */ D.jsx(De, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
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 && T(P) && Z && /* @__PURE__ */ D.jsx(
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
- } : L,
908
+ } : X,
902
909
  onResizeEnd: S ? () => {
903
- } : v,
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
- Ae as default
919
+ Ye as default
913
920
  };
914
- //# sourceMappingURL=ImageComponent-fc39a03e.js.map
921
+ //# sourceMappingURL=ImageComponent-ced58b97.js.map