@yoopta/video 1.9.13-rc → 1.9.15-rc

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1601
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,1601 +1 @@
1
- import { getElementClassname, UI_HELPERS, cx, createYooptaPlugin, getElementByPath, generateId } from '@yoopta/editor';
2
- import { Transforms, Element } from 'slate';
3
- import { jsxs, jsx } from 'react/jsx-runtime';
4
- import * as React from 'react';
5
- import { useState, useEffect, useRef, useMemo } from 'react';
6
- import { flushSync } from 'react-dom';
7
- import { ReactEditor, useSelected, useReadOnly } from 'slate-react';
8
-
9
- /******************************************************************************
10
- Copyright (c) Microsoft Corporation.
11
-
12
- Permission to use, copy, modify, and/or distribute this software for any
13
- purpose with or without fee is hereby granted.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
- PERFORMANCE OF THIS SOFTWARE.
22
- ***************************************************************************** */
23
-
24
- function __rest(s, e) {
25
- var t = {};
26
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
27
- t[p] = s[p];
28
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
29
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
30
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31
- t[p[i]] = s[p[i]];
32
- }
33
- return t;
34
- }
35
-
36
- function __awaiter(thisArg, _arguments, P, generator) {
37
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
- return new (P || (P = Promise))(function (resolve, reject) {
39
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
- step((generator = generator.apply(thisArg, _arguments || [])).next());
43
- });
44
- }
45
-
46
- /**
47
- *
48
- * @param {DOM Ref} elementRef - DOM ref for checking the intersection
49
- * @param {Observer Params} - https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
50
- * @returns {IntersectionObserverEntry} - https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserverEntry
51
- */
52
- function useIntersectionObserver(elementRef, { threshold = 0, root = null, rootMargin = '0%', freezeOnceVisible = false } = {}) {
53
- const [entry, setEntry] = useState({});
54
- const frozen = entry.isIntersecting && freezeOnceVisible;
55
- const updateEntry = ([e]) => setEntry(e);
56
- useEffect(() => {
57
- const node = elementRef === null || elementRef === void 0 ? void 0 : elementRef.current;
58
- const hasNotIOSupport = !window.IntersectionObserver;
59
- if (hasNotIOSupport || frozen || !node)
60
- return;
61
- const observerParams = { threshold, root, rootMargin };
62
- const observer = new IntersectionObserver(updateEntry, observerParams);
63
- observer.observe(node);
64
- return () => observer.disconnect();
65
- }, [elementRef, threshold, root, rootMargin, frozen]);
66
- return entry;
67
- }
68
-
69
- function styleInject(css, ref) {
70
- if ( ref === void 0 ) ref = {};
71
- var insertAt = ref.insertAt;
72
-
73
- if (!css || typeof document === 'undefined') { return; }
74
-
75
- var head = document.head || document.getElementsByTagName('head')[0];
76
- var style = document.createElement('style');
77
- style.type = 'text/css';
78
-
79
- if (insertAt === 'top') {
80
- if (head.firstChild) {
81
- head.insertBefore(style, head.firstChild);
82
- } else {
83
- head.appendChild(style);
84
- }
85
- } else {
86
- head.appendChild(style);
87
- }
88
-
89
- if (style.styleSheet) {
90
- style.styleSheet.cssText = css;
91
- } else {
92
- style.appendChild(document.createTextNode(css));
93
- }
94
- }
95
-
96
- var css_248z$4 = ".Video-module_videoElement{margin:20px 0 10px;position:relative}.Video-module_video{border-radius:1px;display:block;margin:0 auto;max-width:100%;object-fit:cover;pointer-events:auto}.Video-module_iframRoot{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.Video-module_iframe{background-color:#fff}.Video-module_iframe,.Video-module_iframeWrap{border-radius:1px;height:100%;left:0;pointer-events:auto;position:absolute;top:0;width:100%}.Video-module_iframePreview{filter:blur(10px);left:0;object-fit:cover;position:absolute;top:0;transition:opacity .15s ease-in,filter .15s ease-in}.Video-module_iframeRoot{height:100%;position:relative;width:100%}";
97
- var s$4 = {"videoElement":"Video-module_videoElement","video":"Video-module_video","iframRoot":"Video-module_iframRoot","iframe":"Video-module_iframe","iframeWrap":"Video-module_iframeWrap","iframePreview":"Video-module_iframePreview","iframeRoot":"Video-module_iframeRoot"};
98
- styleInject(css_248z$4);
99
-
100
- const getDayliMotionAPI = (videoId) => `https://api.dailymotion.com/video/${videoId}?fields=thumbnail_url`;
101
- function DailyMotion(_a) {
102
- var { videoId } = _a, other = __rest(_a, ["videoId"]);
103
- const dailyMotionRootRef = useRef(null);
104
- const [src, setSrc] = useState(null);
105
- const [isFrameLoaded, setFrameLoaded] = useState(false);
106
- const { isIntersecting: isInViewport } = useIntersectionObserver(dailyMotionRootRef, {
107
- freezeOnceVisible: true,
108
- rootMargin: '50%',
109
- });
110
- useEffect(() => {
111
- fetch(getDayliMotionAPI(videoId))
112
- .then((data) => data.json())
113
- .then((data) => setSrc(data.thumbnail_url))
114
- .catch(() => setSrc(null));
115
- }, [videoId]);
116
- return (jsxs("div", Object.assign({ ref: dailyMotionRootRef, className: s$4.iframeRoot }, { children: [jsx("img", { src: src || '', alt: "daylimotion_video_preview", width: "100%", height: "100%", className: s$4.iframePreview, style: {
117
- opacity: isInViewport && isFrameLoaded ? 0 : 1,
118
- zIndex: isInViewport && isFrameLoaded ? -1 : 0,
119
- } }), isInViewport && (jsx("iframe", Object.assign({ title: "Dailymotion Video Player", frameBorder: 0, onLoad: () => setFrameLoaded(true), src: `https://www.dailymotion.com/embed/video/${videoId}`, allowFullScreen: true, className: s$4.iframe }, other)))] })));
120
- }
121
-
122
- const VIMEO_API_URI = 'https://vimeo.com/api/v2/video';
123
- function VimeoPlayer(_a) {
124
- var { videoId } = _a, other = __rest(_a, ["videoId"]);
125
- const vimeoRootRef = useRef(null);
126
- const [src, setSrc] = useState(null);
127
- const [isFrameLoaded, setFrameLoaded] = useState(false);
128
- const { isIntersecting: isInViewport } = useIntersectionObserver(vimeoRootRef, {
129
- freezeOnceVisible: true,
130
- rootMargin: '50%',
131
- });
132
- useEffect(() => {
133
- fetch(`${VIMEO_API_URI}/${videoId}.json`)
134
- .then((data) => data.json())
135
- .then((data) => setSrc(data[0].thumbnail_medium))
136
- .catch(() => setSrc(null));
137
- }, [videoId]);
138
- return (jsxs("div", Object.assign({ ref: vimeoRootRef, className: s$4.iframeRoot }, { children: [jsx("img", { src: src || '', alt: "vimeo_video_preview", width: "100%", height: "100%", className: s$4.iframePreview, style: {
139
- opacity: isInViewport && isFrameLoaded ? 0 : 1,
140
- zIndex: isInViewport && isFrameLoaded ? -1 : 0,
141
- } }), isInViewport && (jsx("iframe", Object.assign({ title: "Video Player",
142
- // https://developer.vimeo.com/player/embedding
143
- src: `https://player.vimeo.com/video/${videoId}?badge=0&byline=0&portrait=0&title=0`, frameBorder: 0, allowFullScreen: true, onLoad: () => setFrameLoaded(true), className: s$4.iframe }, other)))] })));
144
- }
145
-
146
- function YouTubePlayer(_a) {
147
- var { videoId } = _a, other = __rest(_a, ["videoId"]);
148
- const youtubeRootRef = useRef(null);
149
- const [isFrameLoaded, setFrameLoaded] = useState(false);
150
- const { isIntersecting: isInViewport } = useIntersectionObserver(youtubeRootRef, {
151
- freezeOnceVisible: true,
152
- rootMargin: '50%',
153
- });
154
- return (jsxs("div", Object.assign({ ref: youtubeRootRef, className: s$4.iframeRoot }, { children: [jsx("img", { src: `https://i.ytimg.com/vi/${videoId}/default.jpg`, alt: "youtube_video_preview", width: "100%", height: "100%", className: s$4.iframePreview, style: {
155
- opacity: isInViewport && isFrameLoaded ? 0 : 1,
156
- zIndex: isInViewport && isFrameLoaded ? -1 : 0,
157
- } }), isInViewport && (jsx("iframe", Object.assign({ title: "Video Player",
158
- // https://developers.google.com/youtube/player_parameters?hl=en
159
- src: `https://www.youtube.com/embed/${videoId}`, frameBorder: 0, onLoad: () => setFrameLoaded(true), allowFullScreen: true, className: s$4.iframe }, other)))] })));
160
- }
161
-
162
- const PROVIDERS = {
163
- vimeo: VimeoPlayer,
164
- youtube: YouTubePlayer,
165
- dailymotion: DailyMotion,
166
- };
167
- const Video$1 = ({ attributes, element, children, size, HTMLAttributes }) => {
168
- var _a, _b, _c, _d;
169
- const width = (size === null || size === void 0 ? void 0 : size.width) || ((_b = (_a = element.data) === null || _a === void 0 ? void 0 : _a.size) === null || _b === void 0 ? void 0 : _b.width) || '100%';
170
- const height = (size === null || size === void 0 ? void 0 : size.height) || ((_d = (_c = element.data) === null || _c === void 0 ? void 0 : _c.size) === null || _d === void 0 ? void 0 : _d.height) || 400;
171
- if (typeof element.data.provider === 'string' && element.data.videoId && PROVIDERS[element.data.provider]) {
172
- const ProviderComponent = PROVIDERS[element.data.provider];
173
- return (jsxs("div", Object.assign({}, attributes, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s$4.videoElement }), contentEditable: false, draggable: false }, { children: [jsx("div", Object.assign({ className: s$4.iframRoot }, { children: jsx("div", Object.assign({ className: s$4.iframeWrap }, { children: jsx(ProviderComponent, { videoId: element.data.videoId }) })) })), children] })));
174
- }
175
- if (!element.data.url && !element.data['data-src'])
176
- return (jsx("div", Object.assign({}, attributes, { className: s$4.videoElement, contentEditable: false, draggable: false }, { children: children })));
177
- return (jsxs("div", Object.assign({}, attributes, { className: s$4.videoElement, contentEditable: false, draggable: false }, { children: [jsx("video", Object.assign({ controls: true, preload: "metadata", playsInline: true, src: element.data.url || element.data['data-src'] || '', width: width, height: height, onDragStart: (e) => e.preventDefault() }, HTMLAttributes, { className: getElementClassname({ element, HTMLAttributes, className: s$4.video }) })), children] })));
178
- };
179
-
180
- var __extends$1 = (undefined && undefined.__extends) || (function () {
181
- var extendStatics = function (d, b) {
182
- extendStatics = Object.setPrototypeOf ||
183
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
184
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
185
- return extendStatics(d, b);
186
- };
187
- return function (d, b) {
188
- extendStatics(d, b);
189
- function __() { this.constructor = d; }
190
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
191
- };
192
- })();
193
- var __assign$1 = (undefined && undefined.__assign) || function () {
194
- __assign$1 = Object.assign || function(t) {
195
- for (var s, i = 1, n = arguments.length; i < n; i++) {
196
- s = arguments[i];
197
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
198
- t[p] = s[p];
199
- }
200
- return t;
201
- };
202
- return __assign$1.apply(this, arguments);
203
- };
204
- var rowSizeBase = {
205
- width: '100%',
206
- height: '10px',
207
- top: '0px',
208
- left: '0px',
209
- cursor: 'row-resize',
210
- };
211
- var colSizeBase = {
212
- width: '10px',
213
- height: '100%',
214
- top: '0px',
215
- left: '0px',
216
- cursor: 'col-resize',
217
- };
218
- var edgeBase = {
219
- width: '20px',
220
- height: '20px',
221
- position: 'absolute',
222
- };
223
- var styles = {
224
- top: __assign$1(__assign$1({}, rowSizeBase), { top: '-5px' }),
225
- right: __assign$1(__assign$1({}, colSizeBase), { left: undefined, right: '-5px' }),
226
- bottom: __assign$1(__assign$1({}, rowSizeBase), { top: undefined, bottom: '-5px' }),
227
- left: __assign$1(__assign$1({}, colSizeBase), { left: '-5px' }),
228
- topRight: __assign$1(__assign$1({}, edgeBase), { right: '-10px', top: '-10px', cursor: 'ne-resize' }),
229
- bottomRight: __assign$1(__assign$1({}, edgeBase), { right: '-10px', bottom: '-10px', cursor: 'se-resize' }),
230
- bottomLeft: __assign$1(__assign$1({}, edgeBase), { left: '-10px', bottom: '-10px', cursor: 'sw-resize' }),
231
- topLeft: __assign$1(__assign$1({}, edgeBase), { left: '-10px', top: '-10px', cursor: 'nw-resize' }),
232
- };
233
- var Resizer = /** @class */ (function (_super) {
234
- __extends$1(Resizer, _super);
235
- function Resizer() {
236
- var _this = _super !== null && _super.apply(this, arguments) || this;
237
- _this.onMouseDown = function (e) {
238
- _this.props.onResizeStart(e, _this.props.direction);
239
- };
240
- _this.onTouchStart = function (e) {
241
- _this.props.onResizeStart(e, _this.props.direction);
242
- };
243
- return _this;
244
- }
245
- Resizer.prototype.render = function () {
246
- return (React.createElement("div", { className: this.props.className || '', style: __assign$1(__assign$1({ position: 'absolute', userSelect: 'none' }, styles[this.props.direction]), (this.props.replaceStyles || {})), onMouseDown: this.onMouseDown, onTouchStart: this.onTouchStart }, this.props.children));
247
- };
248
- return Resizer;
249
- }(React.PureComponent));
250
-
251
- var __extends = (undefined && undefined.__extends) || (function () {
252
- var extendStatics = function (d, b) {
253
- extendStatics = Object.setPrototypeOf ||
254
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
255
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
256
- return extendStatics(d, b);
257
- };
258
- return function (d, b) {
259
- extendStatics(d, b);
260
- function __() { this.constructor = d; }
261
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
262
- };
263
- })();
264
- var __assign = (undefined && undefined.__assign) || function () {
265
- __assign = Object.assign || function(t) {
266
- for (var s, i = 1, n = arguments.length; i < n; i++) {
267
- s = arguments[i];
268
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
269
- t[p] = s[p];
270
- }
271
- return t;
272
- };
273
- return __assign.apply(this, arguments);
274
- };
275
- var DEFAULT_SIZE = {
276
- width: 'auto',
277
- height: 'auto',
278
- };
279
- var clamp = function (n, min, max) { return Math.max(Math.min(n, max), min); };
280
- var snap = function (n, size) { return Math.round(n / size) * size; };
281
- var hasDirection = function (dir, target) {
282
- return new RegExp(dir, 'i').test(target);
283
- };
284
- // INFO: In case of window is a Proxy and does not porxy Events correctly, use isTouchEvent & isMouseEvent to distinguish event type instead of `instanceof`.
285
- var isTouchEvent = function (event) {
286
- return Boolean(event.touches && event.touches.length);
287
- };
288
- var isMouseEvent = function (event) {
289
- return Boolean((event.clientX || event.clientX === 0) &&
290
- (event.clientY || event.clientY === 0));
291
- };
292
- var findClosestSnap = function (n, snapArray, snapGap) {
293
- if (snapGap === void 0) { snapGap = 0; }
294
- var closestGapIndex = snapArray.reduce(function (prev, curr, index) { return (Math.abs(curr - n) < Math.abs(snapArray[prev] - n) ? index : prev); }, 0);
295
- var gap = Math.abs(snapArray[closestGapIndex] - n);
296
- return snapGap === 0 || gap < snapGap ? snapArray[closestGapIndex] : n;
297
- };
298
- var getStringSize = function (n) {
299
- n = n.toString();
300
- if (n === 'auto') {
301
- return n;
302
- }
303
- if (n.endsWith('px')) {
304
- return n;
305
- }
306
- if (n.endsWith('%')) {
307
- return n;
308
- }
309
- if (n.endsWith('vh')) {
310
- return n;
311
- }
312
- if (n.endsWith('vw')) {
313
- return n;
314
- }
315
- if (n.endsWith('vmax')) {
316
- return n;
317
- }
318
- if (n.endsWith('vmin')) {
319
- return n;
320
- }
321
- return n + "px";
322
- };
323
- var getPixelSize = function (size, parentSize, innerWidth, innerHeight) {
324
- if (size && typeof size === 'string') {
325
- if (size.endsWith('px')) {
326
- return Number(size.replace('px', ''));
327
- }
328
- if (size.endsWith('%')) {
329
- var ratio = Number(size.replace('%', '')) / 100;
330
- return parentSize * ratio;
331
- }
332
- if (size.endsWith('vw')) {
333
- var ratio = Number(size.replace('vw', '')) / 100;
334
- return innerWidth * ratio;
335
- }
336
- if (size.endsWith('vh')) {
337
- var ratio = Number(size.replace('vh', '')) / 100;
338
- return innerHeight * ratio;
339
- }
340
- }
341
- return size;
342
- };
343
- var calculateNewMax = function (parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
344
- maxWidth = getPixelSize(maxWidth, parentSize.width, innerWidth, innerHeight);
345
- maxHeight = getPixelSize(maxHeight, parentSize.height, innerWidth, innerHeight);
346
- minWidth = getPixelSize(minWidth, parentSize.width, innerWidth, innerHeight);
347
- minHeight = getPixelSize(minHeight, parentSize.height, innerWidth, innerHeight);
348
- return {
349
- maxWidth: typeof maxWidth === 'undefined' ? undefined : Number(maxWidth),
350
- maxHeight: typeof maxHeight === 'undefined' ? undefined : Number(maxHeight),
351
- minWidth: typeof minWidth === 'undefined' ? undefined : Number(minWidth),
352
- minHeight: typeof minHeight === 'undefined' ? undefined : Number(minHeight),
353
- };
354
- };
355
- var definedProps = [
356
- 'as',
357
- 'style',
358
- 'className',
359
- 'grid',
360
- 'snap',
361
- 'bounds',
362
- 'boundsByDirection',
363
- 'size',
364
- 'defaultSize',
365
- 'minWidth',
366
- 'minHeight',
367
- 'maxWidth',
368
- 'maxHeight',
369
- 'lockAspectRatio',
370
- 'lockAspectRatioExtraWidth',
371
- 'lockAspectRatioExtraHeight',
372
- 'enable',
373
- 'handleStyles',
374
- 'handleClasses',
375
- 'handleWrapperStyle',
376
- 'handleWrapperClass',
377
- 'children',
378
- 'onResizeStart',
379
- 'onResize',
380
- 'onResizeStop',
381
- 'handleComponent',
382
- 'scale',
383
- 'resizeRatio',
384
- 'snapGap',
385
- ];
386
- // HACK: This class is used to calculate % size.
387
- var baseClassName = '__resizable_base__';
388
- var Resizable = /** @class */ (function (_super) {
389
- __extends(Resizable, _super);
390
- function Resizable(props) {
391
- var _this = _super.call(this, props) || this;
392
- _this.ratio = 1;
393
- _this.resizable = null;
394
- // For parent boundary
395
- _this.parentLeft = 0;
396
- _this.parentTop = 0;
397
- // For boundary
398
- _this.resizableLeft = 0;
399
- _this.resizableRight = 0;
400
- _this.resizableTop = 0;
401
- _this.resizableBottom = 0;
402
- // For target boundary
403
- _this.targetLeft = 0;
404
- _this.targetTop = 0;
405
- _this.appendBase = function () {
406
- if (!_this.resizable || !_this.window) {
407
- return null;
408
- }
409
- var parent = _this.parentNode;
410
- if (!parent) {
411
- return null;
412
- }
413
- var element = _this.window.document.createElement('div');
414
- element.style.width = '100%';
415
- element.style.height = '100%';
416
- element.style.position = 'absolute';
417
- element.style.transform = 'scale(0, 0)';
418
- element.style.left = '0';
419
- element.style.flex = '0 0 100%';
420
- if (element.classList) {
421
- element.classList.add(baseClassName);
422
- }
423
- else {
424
- element.className += baseClassName;
425
- }
426
- parent.appendChild(element);
427
- return element;
428
- };
429
- _this.removeBase = function (base) {
430
- var parent = _this.parentNode;
431
- if (!parent) {
432
- return;
433
- }
434
- parent.removeChild(base);
435
- };
436
- _this.ref = function (c) {
437
- if (c) {
438
- _this.resizable = c;
439
- }
440
- };
441
- _this.state = {
442
- isResizing: false,
443
- width: typeof (_this.propsSize && _this.propsSize.width) === 'undefined'
444
- ? 'auto'
445
- : _this.propsSize && _this.propsSize.width,
446
- height: typeof (_this.propsSize && _this.propsSize.height) === 'undefined'
447
- ? 'auto'
448
- : _this.propsSize && _this.propsSize.height,
449
- direction: 'right',
450
- original: {
451
- x: 0,
452
- y: 0,
453
- width: 0,
454
- height: 0,
455
- },
456
- backgroundStyle: {
457
- height: '100%',
458
- width: '100%',
459
- backgroundColor: 'rgba(0,0,0,0)',
460
- cursor: 'auto',
461
- opacity: 0,
462
- position: 'fixed',
463
- zIndex: 9999,
464
- top: '0',
465
- left: '0',
466
- bottom: '0',
467
- right: '0',
468
- },
469
- flexBasis: undefined,
470
- };
471
- _this.onResizeStart = _this.onResizeStart.bind(_this);
472
- _this.onMouseMove = _this.onMouseMove.bind(_this);
473
- _this.onMouseUp = _this.onMouseUp.bind(_this);
474
- return _this;
475
- }
476
- Object.defineProperty(Resizable.prototype, "parentNode", {
477
- get: function () {
478
- if (!this.resizable) {
479
- return null;
480
- }
481
- return this.resizable.parentNode;
482
- },
483
- enumerable: false,
484
- configurable: true
485
- });
486
- Object.defineProperty(Resizable.prototype, "window", {
487
- get: function () {
488
- if (!this.resizable) {
489
- return null;
490
- }
491
- if (!this.resizable.ownerDocument) {
492
- return null;
493
- }
494
- return this.resizable.ownerDocument.defaultView;
495
- },
496
- enumerable: false,
497
- configurable: true
498
- });
499
- Object.defineProperty(Resizable.prototype, "propsSize", {
500
- get: function () {
501
- return this.props.size || this.props.defaultSize || DEFAULT_SIZE;
502
- },
503
- enumerable: false,
504
- configurable: true
505
- });
506
- Object.defineProperty(Resizable.prototype, "size", {
507
- get: function () {
508
- var width = 0;
509
- var height = 0;
510
- if (this.resizable && this.window) {
511
- var orgWidth = this.resizable.offsetWidth;
512
- var orgHeight = this.resizable.offsetHeight;
513
- // HACK: Set position `relative` to get parent size.
514
- // This is because when re-resizable set `absolute`, I can not get base width correctly.
515
- var orgPosition = this.resizable.style.position;
516
- if (orgPosition !== 'relative') {
517
- this.resizable.style.position = 'relative';
518
- }
519
- // INFO: Use original width or height if set auto.
520
- width = this.resizable.style.width !== 'auto' ? this.resizable.offsetWidth : orgWidth;
521
- height = this.resizable.style.height !== 'auto' ? this.resizable.offsetHeight : orgHeight;
522
- // Restore original position
523
- this.resizable.style.position = orgPosition;
524
- }
525
- return { width: width, height: height };
526
- },
527
- enumerable: false,
528
- configurable: true
529
- });
530
- Object.defineProperty(Resizable.prototype, "sizeStyle", {
531
- get: function () {
532
- var _this = this;
533
- var size = this.props.size;
534
- var getSize = function (key) {
535
- if (typeof _this.state[key] === 'undefined' || _this.state[key] === 'auto') {
536
- return 'auto';
537
- }
538
- if (_this.propsSize && _this.propsSize[key] && _this.propsSize[key].toString().endsWith('%')) {
539
- if (_this.state[key].toString().endsWith('%')) {
540
- return _this.state[key].toString();
541
- }
542
- var parentSize = _this.getParentSize();
543
- var value = Number(_this.state[key].toString().replace('px', ''));
544
- var percent = (value / parentSize[key]) * 100;
545
- return percent + "%";
546
- }
547
- return getStringSize(_this.state[key]);
548
- };
549
- var width = size && typeof size.width !== 'undefined' && !this.state.isResizing
550
- ? getStringSize(size.width)
551
- : getSize('width');
552
- var height = size && typeof size.height !== 'undefined' && !this.state.isResizing
553
- ? getStringSize(size.height)
554
- : getSize('height');
555
- return { width: width, height: height };
556
- },
557
- enumerable: false,
558
- configurable: true
559
- });
560
- Resizable.prototype.getParentSize = function () {
561
- if (!this.parentNode) {
562
- if (!this.window) {
563
- return { width: 0, height: 0 };
564
- }
565
- return { width: this.window.innerWidth, height: this.window.innerHeight };
566
- }
567
- var base = this.appendBase();
568
- if (!base) {
569
- return { width: 0, height: 0 };
570
- }
571
- // INFO: To calculate parent width with flex layout
572
- var wrapChanged = false;
573
- var wrap = this.parentNode.style.flexWrap;
574
- if (wrap !== 'wrap') {
575
- wrapChanged = true;
576
- this.parentNode.style.flexWrap = 'wrap';
577
- // HACK: Use relative to get parent padding size
578
- }
579
- base.style.position = 'relative';
580
- base.style.minWidth = '100%';
581
- base.style.minHeight = '100%';
582
- var size = {
583
- width: base.offsetWidth,
584
- height: base.offsetHeight,
585
- };
586
- if (wrapChanged) {
587
- this.parentNode.style.flexWrap = wrap;
588
- }
589
- this.removeBase(base);
590
- return size;
591
- };
592
- Resizable.prototype.bindEvents = function () {
593
- if (this.window) {
594
- this.window.addEventListener('mouseup', this.onMouseUp);
595
- this.window.addEventListener('mousemove', this.onMouseMove);
596
- this.window.addEventListener('mouseleave', this.onMouseUp);
597
- this.window.addEventListener('touchmove', this.onMouseMove, {
598
- capture: true,
599
- passive: false,
600
- });
601
- this.window.addEventListener('touchend', this.onMouseUp);
602
- }
603
- };
604
- Resizable.prototype.unbindEvents = function () {
605
- if (this.window) {
606
- this.window.removeEventListener('mouseup', this.onMouseUp);
607
- this.window.removeEventListener('mousemove', this.onMouseMove);
608
- this.window.removeEventListener('mouseleave', this.onMouseUp);
609
- this.window.removeEventListener('touchmove', this.onMouseMove, true);
610
- this.window.removeEventListener('touchend', this.onMouseUp);
611
- }
612
- };
613
- Resizable.prototype.componentDidMount = function () {
614
- if (!this.resizable || !this.window) {
615
- return;
616
- }
617
- var computedStyle = this.window.getComputedStyle(this.resizable);
618
- this.setState({
619
- width: this.state.width || this.size.width,
620
- height: this.state.height || this.size.height,
621
- flexBasis: computedStyle.flexBasis !== 'auto' ? computedStyle.flexBasis : undefined,
622
- });
623
- };
624
- Resizable.prototype.componentWillUnmount = function () {
625
- if (this.window) {
626
- this.unbindEvents();
627
- }
628
- };
629
- Resizable.prototype.createSizeForCssProperty = function (newSize, kind) {
630
- var propsSize = this.propsSize && this.propsSize[kind];
631
- return this.state[kind] === 'auto' &&
632
- this.state.original[kind] === newSize &&
633
- (typeof propsSize === 'undefined' || propsSize === 'auto')
634
- ? 'auto'
635
- : newSize;
636
- };
637
- Resizable.prototype.calculateNewMaxFromBoundary = function (maxWidth, maxHeight) {
638
- var boundsByDirection = this.props.boundsByDirection;
639
- var direction = this.state.direction;
640
- var widthByDirection = boundsByDirection && hasDirection('left', direction);
641
- var heightByDirection = boundsByDirection && hasDirection('top', direction);
642
- var boundWidth;
643
- var boundHeight;
644
- if (this.props.bounds === 'parent') {
645
- var parent_1 = this.parentNode;
646
- if (parent_1) {
647
- boundWidth = widthByDirection
648
- ? this.resizableRight - this.parentLeft
649
- : parent_1.offsetWidth + (this.parentLeft - this.resizableLeft);
650
- boundHeight = heightByDirection
651
- ? this.resizableBottom - this.parentTop
652
- : parent_1.offsetHeight + (this.parentTop - this.resizableTop);
653
- }
654
- }
655
- else if (this.props.bounds === 'window') {
656
- if (this.window) {
657
- boundWidth = widthByDirection ? this.resizableRight : this.window.innerWidth - this.resizableLeft;
658
- boundHeight = heightByDirection ? this.resizableBottom : this.window.innerHeight - this.resizableTop;
659
- }
660
- }
661
- else if (this.props.bounds) {
662
- boundWidth = widthByDirection
663
- ? this.resizableRight - this.targetLeft
664
- : this.props.bounds.offsetWidth + (this.targetLeft - this.resizableLeft);
665
- boundHeight = heightByDirection
666
- ? this.resizableBottom - this.targetTop
667
- : this.props.bounds.offsetHeight + (this.targetTop - this.resizableTop);
668
- }
669
- if (boundWidth && Number.isFinite(boundWidth)) {
670
- maxWidth = maxWidth && maxWidth < boundWidth ? maxWidth : boundWidth;
671
- }
672
- if (boundHeight && Number.isFinite(boundHeight)) {
673
- maxHeight = maxHeight && maxHeight < boundHeight ? maxHeight : boundHeight;
674
- }
675
- return { maxWidth: maxWidth, maxHeight: maxHeight };
676
- };
677
- Resizable.prototype.calculateNewSizeFromDirection = function (clientX, clientY) {
678
- var scale = this.props.scale || 1;
679
- var resizeRatio = this.props.resizeRatio || 1;
680
- var _a = this.state, direction = _a.direction, original = _a.original;
681
- var _b = this.props, lockAspectRatio = _b.lockAspectRatio, lockAspectRatioExtraHeight = _b.lockAspectRatioExtraHeight, lockAspectRatioExtraWidth = _b.lockAspectRatioExtraWidth;
682
- var newWidth = original.width;
683
- var newHeight = original.height;
684
- var extraHeight = lockAspectRatioExtraHeight || 0;
685
- var extraWidth = lockAspectRatioExtraWidth || 0;
686
- if (hasDirection('right', direction)) {
687
- newWidth = original.width + ((clientX - original.x) * resizeRatio) / scale;
688
- if (lockAspectRatio) {
689
- newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
690
- }
691
- }
692
- if (hasDirection('left', direction)) {
693
- newWidth = original.width - ((clientX - original.x) * resizeRatio) / scale;
694
- if (lockAspectRatio) {
695
- newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
696
- }
697
- }
698
- if (hasDirection('bottom', direction)) {
699
- newHeight = original.height + ((clientY - original.y) * resizeRatio) / scale;
700
- if (lockAspectRatio) {
701
- newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
702
- }
703
- }
704
- if (hasDirection('top', direction)) {
705
- newHeight = original.height - ((clientY - original.y) * resizeRatio) / scale;
706
- if (lockAspectRatio) {
707
- newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
708
- }
709
- }
710
- return { newWidth: newWidth, newHeight: newHeight };
711
- };
712
- Resizable.prototype.calculateNewSizeFromAspectRatio = function (newWidth, newHeight, max, min) {
713
- var _a = this.props, lockAspectRatio = _a.lockAspectRatio, lockAspectRatioExtraHeight = _a.lockAspectRatioExtraHeight, lockAspectRatioExtraWidth = _a.lockAspectRatioExtraWidth;
714
- var computedMinWidth = typeof min.width === 'undefined' ? 10 : min.width;
715
- var computedMaxWidth = typeof max.width === 'undefined' || max.width < 0 ? newWidth : max.width;
716
- var computedMinHeight = typeof min.height === 'undefined' ? 10 : min.height;
717
- var computedMaxHeight = typeof max.height === 'undefined' || max.height < 0 ? newHeight : max.height;
718
- var extraHeight = lockAspectRatioExtraHeight || 0;
719
- var extraWidth = lockAspectRatioExtraWidth || 0;
720
- if (lockAspectRatio) {
721
- var extraMinWidth = (computedMinHeight - extraHeight) * this.ratio + extraWidth;
722
- var extraMaxWidth = (computedMaxHeight - extraHeight) * this.ratio + extraWidth;
723
- var extraMinHeight = (computedMinWidth - extraWidth) / this.ratio + extraHeight;
724
- var extraMaxHeight = (computedMaxWidth - extraWidth) / this.ratio + extraHeight;
725
- var lockedMinWidth = Math.max(computedMinWidth, extraMinWidth);
726
- var lockedMaxWidth = Math.min(computedMaxWidth, extraMaxWidth);
727
- var lockedMinHeight = Math.max(computedMinHeight, extraMinHeight);
728
- var lockedMaxHeight = Math.min(computedMaxHeight, extraMaxHeight);
729
- newWidth = clamp(newWidth, lockedMinWidth, lockedMaxWidth);
730
- newHeight = clamp(newHeight, lockedMinHeight, lockedMaxHeight);
731
- }
732
- else {
733
- newWidth = clamp(newWidth, computedMinWidth, computedMaxWidth);
734
- newHeight = clamp(newHeight, computedMinHeight, computedMaxHeight);
735
- }
736
- return { newWidth: newWidth, newHeight: newHeight };
737
- };
738
- Resizable.prototype.setBoundingClientRect = function () {
739
- // For parent boundary
740
- if (this.props.bounds === 'parent') {
741
- var parent_2 = this.parentNode;
742
- if (parent_2) {
743
- var parentRect = parent_2.getBoundingClientRect();
744
- this.parentLeft = parentRect.left;
745
- this.parentTop = parentRect.top;
746
- }
747
- }
748
- // For target(html element) boundary
749
- if (this.props.bounds && typeof this.props.bounds !== 'string') {
750
- var targetRect = this.props.bounds.getBoundingClientRect();
751
- this.targetLeft = targetRect.left;
752
- this.targetTop = targetRect.top;
753
- }
754
- // For boundary
755
- if (this.resizable) {
756
- var _a = this.resizable.getBoundingClientRect(), left = _a.left, top_1 = _a.top, right = _a.right, bottom = _a.bottom;
757
- this.resizableLeft = left;
758
- this.resizableRight = right;
759
- this.resizableTop = top_1;
760
- this.resizableBottom = bottom;
761
- }
762
- };
763
- Resizable.prototype.onResizeStart = function (event, direction) {
764
- if (!this.resizable || !this.window) {
765
- return;
766
- }
767
- var clientX = 0;
768
- var clientY = 0;
769
- if (event.nativeEvent && isMouseEvent(event.nativeEvent)) {
770
- clientX = event.nativeEvent.clientX;
771
- clientY = event.nativeEvent.clientY;
772
- }
773
- else if (event.nativeEvent && isTouchEvent(event.nativeEvent)) {
774
- clientX = event.nativeEvent.touches[0].clientX;
775
- clientY = event.nativeEvent.touches[0].clientY;
776
- }
777
- if (this.props.onResizeStart) {
778
- if (this.resizable) {
779
- var startResize = this.props.onResizeStart(event, direction, this.resizable);
780
- if (startResize === false) {
781
- return;
782
- }
783
- }
784
- }
785
- // Fix #168
786
- if (this.props.size) {
787
- if (typeof this.props.size.height !== 'undefined' && this.props.size.height !== this.state.height) {
788
- this.setState({ height: this.props.size.height });
789
- }
790
- if (typeof this.props.size.width !== 'undefined' && this.props.size.width !== this.state.width) {
791
- this.setState({ width: this.props.size.width });
792
- }
793
- }
794
- // For lockAspectRatio case
795
- this.ratio =
796
- typeof this.props.lockAspectRatio === 'number' ? this.props.lockAspectRatio : this.size.width / this.size.height;
797
- var flexBasis;
798
- var computedStyle = this.window.getComputedStyle(this.resizable);
799
- if (computedStyle.flexBasis !== 'auto') {
800
- var parent_3 = this.parentNode;
801
- if (parent_3) {
802
- var dir = this.window.getComputedStyle(parent_3).flexDirection;
803
- this.flexDir = dir.startsWith('row') ? 'row' : 'column';
804
- flexBasis = computedStyle.flexBasis;
805
- }
806
- }
807
- // For boundary
808
- this.setBoundingClientRect();
809
- this.bindEvents();
810
- var state = {
811
- original: {
812
- x: clientX,
813
- y: clientY,
814
- width: this.size.width,
815
- height: this.size.height,
816
- },
817
- isResizing: true,
818
- backgroundStyle: __assign(__assign({}, this.state.backgroundStyle), { cursor: this.window.getComputedStyle(event.target).cursor || 'auto' }),
819
- direction: direction,
820
- flexBasis: flexBasis,
821
- };
822
- this.setState(state);
823
- };
824
- Resizable.prototype.onMouseMove = function (event) {
825
- var _this = this;
826
- if (!this.state.isResizing || !this.resizable || !this.window) {
827
- return;
828
- }
829
- if (this.window.TouchEvent && isTouchEvent(event)) {
830
- try {
831
- event.preventDefault();
832
- event.stopPropagation();
833
- }
834
- catch (e) {
835
- // Ignore on fail
836
- }
837
- }
838
- var _a = this.props, maxWidth = _a.maxWidth, maxHeight = _a.maxHeight, minWidth = _a.minWidth, minHeight = _a.minHeight;
839
- var clientX = isTouchEvent(event) ? event.touches[0].clientX : event.clientX;
840
- var clientY = isTouchEvent(event) ? event.touches[0].clientY : event.clientY;
841
- var _b = this.state, direction = _b.direction, original = _b.original, width = _b.width, height = _b.height;
842
- var parentSize = this.getParentSize();
843
- var max = calculateNewMax(parentSize, this.window.innerWidth, this.window.innerHeight, maxWidth, maxHeight, minWidth, minHeight);
844
- maxWidth = max.maxWidth;
845
- maxHeight = max.maxHeight;
846
- minWidth = max.minWidth;
847
- minHeight = max.minHeight;
848
- // Calculate new size
849
- var _c = this.calculateNewSizeFromDirection(clientX, clientY), newHeight = _c.newHeight, newWidth = _c.newWidth;
850
- // Calculate max size from boundary settings
851
- var boundaryMax = this.calculateNewMaxFromBoundary(maxWidth, maxHeight);
852
- if (this.props.snap && this.props.snap.x) {
853
- newWidth = findClosestSnap(newWidth, this.props.snap.x, this.props.snapGap);
854
- }
855
- if (this.props.snap && this.props.snap.y) {
856
- newHeight = findClosestSnap(newHeight, this.props.snap.y, this.props.snapGap);
857
- }
858
- // Calculate new size from aspect ratio
859
- var newSize = this.calculateNewSizeFromAspectRatio(newWidth, newHeight, { width: boundaryMax.maxWidth, height: boundaryMax.maxHeight }, { width: minWidth, height: minHeight });
860
- newWidth = newSize.newWidth;
861
- newHeight = newSize.newHeight;
862
- if (this.props.grid) {
863
- var newGridWidth = snap(newWidth, this.props.grid[0]);
864
- var newGridHeight = snap(newHeight, this.props.grid[1]);
865
- var gap = this.props.snapGap || 0;
866
- newWidth = gap === 0 || Math.abs(newGridWidth - newWidth) <= gap ? newGridWidth : newWidth;
867
- newHeight = gap === 0 || Math.abs(newGridHeight - newHeight) <= gap ? newGridHeight : newHeight;
868
- }
869
- var delta = {
870
- width: newWidth - original.width,
871
- height: newHeight - original.height,
872
- };
873
- if (width && typeof width === 'string') {
874
- if (width.endsWith('%')) {
875
- var percent = (newWidth / parentSize.width) * 100;
876
- newWidth = percent + "%";
877
- }
878
- else if (width.endsWith('vw')) {
879
- var vw = (newWidth / this.window.innerWidth) * 100;
880
- newWidth = vw + "vw";
881
- }
882
- else if (width.endsWith('vh')) {
883
- var vh = (newWidth / this.window.innerHeight) * 100;
884
- newWidth = vh + "vh";
885
- }
886
- }
887
- if (height && typeof height === 'string') {
888
- if (height.endsWith('%')) {
889
- var percent = (newHeight / parentSize.height) * 100;
890
- newHeight = percent + "%";
891
- }
892
- else if (height.endsWith('vw')) {
893
- var vw = (newHeight / this.window.innerWidth) * 100;
894
- newHeight = vw + "vw";
895
- }
896
- else if (height.endsWith('vh')) {
897
- var vh = (newHeight / this.window.innerHeight) * 100;
898
- newHeight = vh + "vh";
899
- }
900
- }
901
- var newState = {
902
- width: this.createSizeForCssProperty(newWidth, 'width'),
903
- height: this.createSizeForCssProperty(newHeight, 'height'),
904
- };
905
- if (this.flexDir === 'row') {
906
- newState.flexBasis = newState.width;
907
- }
908
- else if (this.flexDir === 'column') {
909
- newState.flexBasis = newState.height;
910
- }
911
- // For v18, update state sync
912
- flushSync(function () {
913
- _this.setState(newState);
914
- });
915
- if (this.props.onResize) {
916
- this.props.onResize(event, direction, this.resizable, delta);
917
- }
918
- };
919
- Resizable.prototype.onMouseUp = function (event) {
920
- var _a = this.state, isResizing = _a.isResizing, direction = _a.direction, original = _a.original;
921
- if (!isResizing || !this.resizable) {
922
- return;
923
- }
924
- var delta = {
925
- width: this.size.width - original.width,
926
- height: this.size.height - original.height,
927
- };
928
- if (this.props.onResizeStop) {
929
- this.props.onResizeStop(event, direction, this.resizable, delta);
930
- }
931
- if (this.props.size) {
932
- this.setState(this.props.size);
933
- }
934
- this.unbindEvents();
935
- this.setState({
936
- isResizing: false,
937
- backgroundStyle: __assign(__assign({}, this.state.backgroundStyle), { cursor: 'auto' }),
938
- });
939
- };
940
- Resizable.prototype.updateSize = function (size) {
941
- this.setState({ width: size.width, height: size.height });
942
- };
943
- Resizable.prototype.renderResizer = function () {
944
- var _this = this;
945
- var _a = this.props, enable = _a.enable, handleStyles = _a.handleStyles, handleClasses = _a.handleClasses, handleWrapperStyle = _a.handleWrapperStyle, handleWrapperClass = _a.handleWrapperClass, handleComponent = _a.handleComponent;
946
- if (!enable) {
947
- return null;
948
- }
949
- var resizers = Object.keys(enable).map(function (dir) {
950
- if (enable[dir] !== false) {
951
- return (React.createElement(Resizer, { key: dir, direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir] }, handleComponent && handleComponent[dir] ? handleComponent[dir] : null));
952
- }
953
- return null;
954
- });
955
- // #93 Wrap the resize box in span (will not break 100% width/height)
956
- return (React.createElement("div", { className: handleWrapperClass, style: handleWrapperStyle }, resizers));
957
- };
958
- Resizable.prototype.render = function () {
959
- var _this = this;
960
- var extendsProps = Object.keys(this.props).reduce(function (acc, key) {
961
- if (definedProps.indexOf(key) !== -1) {
962
- return acc;
963
- }
964
- acc[key] = _this.props[key];
965
- return acc;
966
- }, {});
967
- var style = __assign(__assign(__assign({ position: 'relative', userSelect: this.state.isResizing ? 'none' : 'auto' }, this.props.style), this.sizeStyle), { maxWidth: this.props.maxWidth, maxHeight: this.props.maxHeight, minWidth: this.props.minWidth, minHeight: this.props.minHeight, boxSizing: 'border-box', flexShrink: 0 });
968
- if (this.state.flexBasis) {
969
- style.flexBasis = this.state.flexBasis;
970
- }
971
- var Wrapper = this.props.as || 'div';
972
- return (React.createElement(Wrapper, __assign({ ref: this.ref, style: style, className: this.props.className }, extendsProps),
973
- this.state.isResizing && React.createElement("div", { style: this.state.backgroundStyle }),
974
- this.props.children,
975
- this.renderResizer()));
976
- };
977
- Resizable.defaultProps = {
978
- as: 'div',
979
- onResizeStart: function () { },
980
- onResize: function () { },
981
- onResizeStop: function () { },
982
- enable: {
983
- top: true,
984
- right: true,
985
- bottom: true,
986
- left: true,
987
- topRight: true,
988
- bottomRight: true,
989
- bottomLeft: true,
990
- topLeft: true,
991
- },
992
- style: {},
993
- grid: [1, 1],
994
- lockAspectRatio: false,
995
- lockAspectRatioExtraWidth: 0,
996
- lockAspectRatioExtraHeight: 0,
997
- scale: 1,
998
- resizeRatio: 1,
999
- snapGap: 0,
1000
- };
1001
- return Resizable;
1002
- }(React.PureComponent));
1003
-
1004
- var _path;
1005
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1006
- var SvgUpload = function SvgUpload(props) {
1007
- return /*#__PURE__*/React.createElement("svg", _extends({
1008
- fill: "currentColor",
1009
- "aria-hidden": "true",
1010
- viewBox: "0 0 24 24",
1011
- "data-testid": "uploadImage"
1012
- }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
1013
- d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"
1014
- })));
1015
- };
1016
-
1017
- var css_248z$3 = ".EditorUploader-module_container{position:fixed}.EditorUploader-module_content{background:#fff;box-shadow:0 0 0 1px hsla(0,0%,6%,.05),0 3px 6px hsla(0,0%,6%,.1),0 9px 24px hsla(0,0%,6%,.2);display:flex;flex-direction:column;height:100%;max-height:420px;max-width:calc(100vw - 24px);min-width:540px}.EditorUploader-module_tabs{box-shadow:inset 0 -1px 0 rgba(55,53,47,.09);display:flex;font-size:14px;height:40px;padding:0 8px;position:relative;width:100%;z-index:1}.EditorUploader-module_tab{align-items:center;background-color:inherit;border:none;border-radius:4px;color:#37352f;cursor:pointer;display:inline-flex;flex-shrink:0;font-size:14px;height:100%;line-height:1.2;min-width:0;padding:6px 8px;position:relative;transition:height 20ms ease-in 0s;user-select:none;white-space:nowrap}.EditorUploader-module_activeTab:after{background-color:#37352f;bottom:0;content:\"\";height:2px;left:0;position:absolute;width:100%}.EditorUploader-module_uploadContent{display:flex;justify-content:center;margin-left:12px;margin-right:12px;margin-top:4px;padding-bottom:6px;padding-top:6px}.EditorUploader-module_uploader{border:1px solid rgba(55,53,47,.16);border-radius:4px;cursor:pointer;height:32px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap;width:100%}.EditorUploader-module_uploaderLabel{align-items:center;cursor:pointer;display:inline-flex;font-size:14px;font-weight:500;height:100%;justify-content:center;line-height:1.2;width:100%}.EditorUploader-module_uploaderInput{left:0;position:absolute;top:0;visibility:hidden}.EditorUploader-module_embed{border:none!important;cursor:pointer!important;height:auto!important;padding-left:0!important;padding-right:0!important}.EditorUploader-module_embedInput{background:hsla(45,13%,94%,.6);box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1);cursor:text;height:32px;line-height:20px;padding:3px 6px;position:relative}.EditorUploader-module_embedButton,.EditorUploader-module_embedInput{align-items:center;border:none;border-radius:4px;display:flex;font-size:14px;width:100%}.EditorUploader-module_embedButton{fill:#fff;background:#2383e2;box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1),0 1px 2px hsla(0,0%,6%,.1);color:#fff;cursor:pointer;flex-shrink:0;font-weight:500;height:28px;justify-content:center;line-height:1.2;margin:12px auto 6px;max-width:300px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap}";
1018
- var s$3 = {"container":"EditorUploader-module_container","content":"EditorUploader-module_content","tabs":"EditorUploader-module_tabs","tab":"EditorUploader-module_tab","activeTab":"EditorUploader-module_activeTab","uploadContent":"EditorUploader-module_uploadContent","uploader":"EditorUploader-module_uploader","uploaderLabel":"EditorUploader-module_uploaderLabel","uploaderInput":"EditorUploader-module_uploaderInput","embed":"EditorUploader-module_embed EditorUploader-module_uploader","embedInput":"EditorUploader-module_embedInput","embedButton":"EditorUploader-module_embedButton"};
1019
- styleInject(css_248z$3);
1020
-
1021
- const Uploader = ({ onChange }) => {
1022
- const onChangeFile = (e) => {
1023
- const files = e.currentTarget.files;
1024
- if (files && files.length > 0) {
1025
- onChange(files[0]);
1026
- }
1027
- };
1028
- return (jsx("div", Object.assign({ className: s$3.uploader }, { children: jsxs("label", Object.assign({ htmlFor: "video-uploader", className: s$3.uploaderLabel }, { children: [jsx("input", { type: "file", id: "video-uploader", className: s$3.uploaderInput, accept: "video/*", onChange: onChangeFile, multiple: false }), "Upload file"] })) })));
1029
- };
1030
- const EmbedLink = ({ onEmbed }) => {
1031
- const [value, setValue] = useState('');
1032
- const onChange = (e) => setValue(e.target.value);
1033
- const onEmbedLink = () => onEmbed(value);
1034
- return (jsxs("div", Object.assign({ className: s$3.embed }, { children: [jsx("input", { type: "text", placeholder: "Paste video link (Youtube, Vimeo, Dailymotion)", value: value, className: s$3.embedInput, onChange: onChange }), jsx("button", Object.assign({ type: "button", className: s$3.embedButton, onClick: onEmbedLink }, { children: "Embed video" }))] })));
1035
- };
1036
- const EditorUploader = ({ activeTab = 'upload', style, switchTab, onChange, onClose, onEmbed }) => {
1037
- const isUploader = activeTab === 'upload';
1038
- const isEmbed = activeTab === 'embed';
1039
- return (jsx(UI_HELPERS.Overlay, Object.assign({ onClose: onClose }, { children: jsx("div", Object.assign({ className: s$3.container, style: style }, { children: jsxs("div", Object.assign({ className: s$3.content }, { children: [jsxs("div", Object.assign({ className: s$3.tabs }, { children: [jsx("button", Object.assign({ type: "button", onClick: () => switchTab('upload'), className: cx(s$3.tab, { [s$3.activeTab]: isUploader }) }, { children: "Upload" })), jsx("button", Object.assign({ type: "button", onClick: () => switchTab('embed'), className: cx(s$3.tab, { [s$3.activeTab]: isEmbed }) }, { children: "Video link" }))] })), jsxs("div", Object.assign({ className: s$3.uploadContent }, { children: [isUploader && jsx(Uploader, { onChange: onChange }), isEmbed && jsx(EmbedLink, { onEmbed: onEmbed })] }))] })) })) })));
1040
- };
1041
-
1042
- const getAspectRatio = (srcWidth, srcHeight, maxWidth, maxHeight) => {
1043
- if (!srcWidth || !srcHeight)
1044
- return {};
1045
- const ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
1046
- return { width: srcWidth * ratio, height: srcHeight * ratio };
1047
- };
1048
-
1049
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
1050
-
1051
- // Older browsers don't support event options, feature detect it.
1052
-
1053
- // Adopted and modified solution from Bohdan Didukh (2017)
1054
- // https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
1055
-
1056
- var hasPassiveEvents = false;
1057
- if (typeof window !== 'undefined') {
1058
- var passiveTestOptions = {
1059
- get passive() {
1060
- hasPassiveEvents = true;
1061
- return undefined;
1062
- }
1063
- };
1064
- window.addEventListener('testPassive', null, passiveTestOptions);
1065
- window.removeEventListener('testPassive', null, passiveTestOptions);
1066
- }
1067
-
1068
- var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
1069
-
1070
-
1071
- var locks = [];
1072
- var documentListenerAdded = false;
1073
- var initialClientY = -1;
1074
- var previousBodyOverflowSetting = void 0;
1075
- var previousBodyPosition = void 0;
1076
- var previousBodyPaddingRight = void 0;
1077
-
1078
- // returns true if `el` should be allowed to receive touchmove events.
1079
- var allowTouchMove = function allowTouchMove(el) {
1080
- return locks.some(function (lock) {
1081
- if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
1082
- return true;
1083
- }
1084
-
1085
- return false;
1086
- });
1087
- };
1088
-
1089
- var preventDefault = function preventDefault(rawEvent) {
1090
- var e = rawEvent || window.event;
1091
-
1092
- // For the case whereby consumers adds a touchmove event listener to document.
1093
- // Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
1094
- // in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
1095
- // the touchmove event on document will break.
1096
- if (allowTouchMove(e.target)) {
1097
- return true;
1098
- }
1099
-
1100
- // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
1101
- if (e.touches.length > 1) return true;
1102
-
1103
- if (e.preventDefault) e.preventDefault();
1104
-
1105
- return false;
1106
- };
1107
-
1108
- var setOverflowHidden = function setOverflowHidden(options) {
1109
- // If previousBodyPaddingRight is already set, don't set it again.
1110
- if (previousBodyPaddingRight === undefined) {
1111
- var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
1112
- var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
1113
-
1114
- if (_reserveScrollBarGap && scrollBarGap > 0) {
1115
- var computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
1116
- previousBodyPaddingRight = document.body.style.paddingRight;
1117
- document.body.style.paddingRight = computedBodyPaddingRight + scrollBarGap + 'px';
1118
- }
1119
- }
1120
-
1121
- // If previousBodyOverflowSetting is already set, don't set it again.
1122
- if (previousBodyOverflowSetting === undefined) {
1123
- previousBodyOverflowSetting = document.body.style.overflow;
1124
- document.body.style.overflow = 'hidden';
1125
- }
1126
- };
1127
-
1128
- var restoreOverflowSetting = function restoreOverflowSetting() {
1129
- if (previousBodyPaddingRight !== undefined) {
1130
- document.body.style.paddingRight = previousBodyPaddingRight;
1131
-
1132
- // Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
1133
- // can be set again.
1134
- previousBodyPaddingRight = undefined;
1135
- }
1136
-
1137
- if (previousBodyOverflowSetting !== undefined) {
1138
- document.body.style.overflow = previousBodyOverflowSetting;
1139
-
1140
- // Restore previousBodyOverflowSetting to undefined
1141
- // so setOverflowHidden knows it can be set again.
1142
- previousBodyOverflowSetting = undefined;
1143
- }
1144
- };
1145
-
1146
- var setPositionFixed = function setPositionFixed() {
1147
- return window.requestAnimationFrame(function () {
1148
- // If previousBodyPosition is already set, don't set it again.
1149
- if (previousBodyPosition === undefined) {
1150
- previousBodyPosition = {
1151
- position: document.body.style.position,
1152
- top: document.body.style.top,
1153
- left: document.body.style.left
1154
- };
1155
-
1156
- // Update the dom inside an animation frame
1157
- var _window = window,
1158
- scrollY = _window.scrollY,
1159
- scrollX = _window.scrollX,
1160
- innerHeight = _window.innerHeight;
1161
-
1162
- document.body.style.position = 'fixed';
1163
- document.body.style.top = -scrollY;
1164
- document.body.style.left = -scrollX;
1165
-
1166
- setTimeout(function () {
1167
- return window.requestAnimationFrame(function () {
1168
- // Attempt to check if the bottom bar appeared due to the position change
1169
- var bottomBarHeight = innerHeight - window.innerHeight;
1170
- if (bottomBarHeight && scrollY >= innerHeight) {
1171
- // Move the content further up so that the bottom bar doesn't hide it
1172
- document.body.style.top = -(scrollY + bottomBarHeight);
1173
- }
1174
- });
1175
- }, 300);
1176
- }
1177
- });
1178
- };
1179
-
1180
- var restorePositionSetting = function restorePositionSetting() {
1181
- if (previousBodyPosition !== undefined) {
1182
- // Convert the position from "px" to Int
1183
- var y = -parseInt(document.body.style.top, 10);
1184
- var x = -parseInt(document.body.style.left, 10);
1185
-
1186
- // Restore styles
1187
- document.body.style.position = previousBodyPosition.position;
1188
- document.body.style.top = previousBodyPosition.top;
1189
- document.body.style.left = previousBodyPosition.left;
1190
-
1191
- // Restore scroll
1192
- window.scrollTo(x, y);
1193
-
1194
- previousBodyPosition = undefined;
1195
- }
1196
- };
1197
-
1198
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
1199
- var isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {
1200
- return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
1201
- };
1202
-
1203
- var handleScroll = function handleScroll(event, targetElement) {
1204
- var clientY = event.targetTouches[0].clientY - initialClientY;
1205
-
1206
- if (allowTouchMove(event.target)) {
1207
- return false;
1208
- }
1209
-
1210
- if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
1211
- // element is at the top of its scroll.
1212
- return preventDefault(event);
1213
- }
1214
-
1215
- if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
1216
- // element is at the bottom of its scroll.
1217
- return preventDefault(event);
1218
- }
1219
-
1220
- event.stopPropagation();
1221
- return true;
1222
- };
1223
-
1224
- var disableBodyScroll = function disableBodyScroll(targetElement, options) {
1225
- // targetElement must be provided
1226
- if (!targetElement) {
1227
- // eslint-disable-next-line no-console
1228
- console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
1229
- return;
1230
- }
1231
-
1232
- // disableBodyScroll must not have been called on this targetElement before
1233
- if (locks.some(function (lock) {
1234
- return lock.targetElement === targetElement;
1235
- })) {
1236
- return;
1237
- }
1238
-
1239
- var lock = {
1240
- targetElement: targetElement,
1241
- options: options || {}
1242
- };
1243
-
1244
- locks = [].concat(_toConsumableArray(locks), [lock]);
1245
-
1246
- if (isIosDevice) {
1247
- setPositionFixed();
1248
- } else {
1249
- setOverflowHidden(options);
1250
- }
1251
-
1252
- if (isIosDevice) {
1253
- targetElement.ontouchstart = function (event) {
1254
- if (event.targetTouches.length === 1) {
1255
- // detect single touch.
1256
- initialClientY = event.targetTouches[0].clientY;
1257
- }
1258
- };
1259
- targetElement.ontouchmove = function (event) {
1260
- if (event.targetTouches.length === 1) {
1261
- // detect single touch.
1262
- handleScroll(event, targetElement);
1263
- }
1264
- };
1265
-
1266
- if (!documentListenerAdded) {
1267
- document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
1268
- documentListenerAdded = true;
1269
- }
1270
- }
1271
- };
1272
-
1273
- var enableBodyScroll = function enableBodyScroll(targetElement) {
1274
- if (!targetElement) {
1275
- // eslint-disable-next-line no-console
1276
- console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');
1277
- return;
1278
- }
1279
-
1280
- locks = locks.filter(function (lock) {
1281
- return lock.targetElement !== targetElement;
1282
- });
1283
-
1284
- if (isIosDevice) {
1285
- targetElement.ontouchstart = null;
1286
- targetElement.ontouchmove = null;
1287
-
1288
- if (documentListenerAdded && locks.length === 0) {
1289
- document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
1290
- documentListenerAdded = false;
1291
- }
1292
- }
1293
-
1294
- if (isIosDevice) {
1295
- restorePositionSetting();
1296
- } else {
1297
- restoreOverflowSetting();
1298
- }
1299
- };
1300
-
1301
- const getYoutubeId = (url) => {
1302
- const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
1303
- const match = url.match(regExp);
1304
- return match && match[2].length === 11 ? match[2] : null;
1305
- };
1306
- const getVimeoId = (url) => {
1307
- const vimeoUrl = new URL(url);
1308
- const vimeoVideoId = vimeoUrl.pathname.split('/')[1];
1309
- return vimeoVideoId;
1310
- };
1311
- const getDailymotionId = (url) => {
1312
- var m = url.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);
1313
- if (m !== null) {
1314
- if (m[4] !== undefined) {
1315
- return m[4];
1316
- }
1317
- return m[2];
1318
- }
1319
- return null;
1320
- };
1321
- function getProvider(url) {
1322
- if (url.includes('youtube.com') || url.includes('youtu.be')) {
1323
- return 'youtube';
1324
- }
1325
- else if (url.includes('vimeo.com')) {
1326
- return 'vimeo';
1327
- }
1328
- else if (url.includes('dailymotion.com') || url.includes('dai.ly')) {
1329
- return 'dailymotion';
1330
- }
1331
- // } else if (url.includes('twitch.tv')) {
1332
- // return 'Twitch';
1333
- // }
1334
- else {
1335
- return null;
1336
- }
1337
- }
1338
-
1339
- var css_248z$2 = ".EditorPlaceholder-module_editor{margin:20px 0 10px;position:relative;user-select:none;width:100%}.EditorPlaceholder-module_content{align-items:center;background-color:#efefef;border:none;border-radius:3px;color:rgba(55,53,47,.65);cursor:pointer;display:flex;font-size:14px;overflow:hidden;padding:12px 36px 12px 12px;position:relative;text-align:left;transition:background-color .1s ease-in;width:100%}.EditorPlaceholder-module_content:hover{background-color:#e3e3e3}.EditorPlaceholder-module_disabledUpload{background-color:#efefef;color:rgba(55,53,47,.65);cursor:not-allowed;pointer-events:none}.EditorPlaceholder-module_icon{margin-right:8px;user-select:none}.EditorPlaceholder-module_loading{left:50%;position:absolute;top:50%}";
1340
- var s$2 = {"editor":"EditorPlaceholder-module_editor","content":"EditorPlaceholder-module_content","disabledUpload":"EditorPlaceholder-module_disabledUpload","icon":"EditorPlaceholder-module_icon","loading":"EditorPlaceholder-module_loading"};
1341
- styleInject(css_248z$2);
1342
-
1343
- var css_248z$1 = ".Loader-module_container{height:100%;position:relative;width:100%}.Loader-module_container .Loader-module_dot{background-color:#909090;border-radius:5rem;height:10px;position:absolute;top:50%;transform:translate(-50%,-50%);width:10px}.Loader-module_container .Loader-module_dot:first-child{animation:Loader-module_waveUp 2s,Loader-module_smallExtend 2s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% - 60px)}.Loader-module_container .Loader-module_dot:nth-child(2){animation:Loader-module_waveUp 2s,Loader-module_largeExtend 2s;animation-delay:.15s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% - 30px)}.Loader-module_container .Loader-module_dot:nth-child(3){animation:Loader-module_waveUp 2s,Loader-module_smallExtend 2s;animation-delay:.3s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:50%}.Loader-module_container .Loader-module_dot:nth-child(4){animation:Loader-module_waveUp 2s,Loader-module_largeExtend 2s;animation-delay:.45s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% + 30px)}.Loader-module_container .Loader-module_dot:nth-child(5){animation:Loader-module_waveUp 2s,Loader-module_smallExtend 2s;animation-delay:.6s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% + 60px)}@keyframes Loader-module_waveUp{0%,15%{top:50%}45%,65%{top:42.5%}85%,to{top:50%}}@keyframes Loader-module_smallExtend{0%,8%{background-color:#909090;height:10px}14%,34%{background-color:#f8f8f8;height:17.5px}46%,to{background-color:#909090;height:10px}}@keyframes Loader-module_largeExtend{0%,8%{background-color:#909090;height:10px}14%,34%{background-color:#f8f8f8;height:32.5px}46%,to{background-color:#909090;height:10px}}";
1344
- var s$1 = {"container":"Loader-module_container","dot":"Loader-module_dot","waveUp":"Loader-module_waveUp","smallExtend":"Loader-module_smallExtend","largeExtend":"Loader-module_largeExtend"};
1345
- styleInject(css_248z$1);
1346
-
1347
- const Loader = () => {
1348
- return (jsxs("div", Object.assign({ className: s$1.container }, { children: [jsx("div", { className: s$1.dot }), jsx("div", { className: s$1.dot }), jsx("div", { className: s$1.dot }), jsx("div", { className: s$1.dot }), jsx("div", { className: s$1.dot })] })));
1349
- };
1350
-
1351
- const UPLOADER_HEIGHT = 88;
1352
- const EditorPlaceholder = ({ element, attributes, maxSizes, children, editor, onUpload }) => {
1353
- const [uploaderPos, setUploaderPos] = useState(null);
1354
- const [loading, setLoading] = useState(false);
1355
- const [activeTab, setActiveTab] = useState('upload');
1356
- const videoEditorRef = useRef(null);
1357
- const toggleUploaderOpen = (e) => {
1358
- var _a;
1359
- e.stopPropagation();
1360
- if (uploaderPos !== null) {
1361
- enableBodyScroll(document.body);
1362
- setUploaderPos(null);
1363
- return;
1364
- }
1365
- const videoEditorRect = (_a = videoEditorRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
1366
- if (videoEditorRect) {
1367
- const showAtTop = videoEditorRect.top + videoEditorRect.height + UPLOADER_HEIGHT + 20 > window.innerHeight;
1368
- const showAtBottom = !showAtTop;
1369
- console.log({ showAtTop, showAtBottom });
1370
- disableBodyScroll(document.body, { reserveScrollBarGap: true });
1371
- setUploaderPos({
1372
- left: videoEditorRect.left,
1373
- top: showAtTop ? videoEditorRect.top - UPLOADER_HEIGHT - 5 : videoEditorRect.top + videoEditorRect.height + 5,
1374
- });
1375
- }
1376
- };
1377
- const onEmbed = (src) => __awaiter(void 0, void 0, void 0, function* () {
1378
- if (src.length === 0)
1379
- return;
1380
- const provider = getProvider(src);
1381
- let videoId = null;
1382
- if (provider === 'youtube')
1383
- videoId = getYoutubeId(src);
1384
- else if (provider === 'vimeo')
1385
- videoId = getVimeoId(src);
1386
- else if (provider === 'dailymotion')
1387
- videoId = getDailymotionId(src);
1388
- if (!videoId)
1389
- return;
1390
- try {
1391
- enableBodyScroll(document.body);
1392
- setUploaderPos(null);
1393
- const updatedVideoNode = {
1394
- data: Object.assign(Object.assign({}, element.data), { url: null, 'data-src': undefined, size: { width: element.data.size.width, height: element.data.size.height }, provider: provider, videoId }),
1395
- };
1396
- Transforms.setNodes(editor, updatedVideoNode, {
1397
- at: ReactEditor.findPath(editor, element),
1398
- match: (n) => Element.isElement(n) && n.type === 'video',
1399
- });
1400
- }
1401
- catch (error) {
1402
- enableBodyScroll(document.body);
1403
- setUploaderPos(null);
1404
- }
1405
- });
1406
- const onChangeFile = (file) => __awaiter(void 0, void 0, void 0, function* () {
1407
- enableBodyScroll(document.body);
1408
- setUploaderPos(null);
1409
- setLoading(true);
1410
- if (!onUpload)
1411
- return console.error('Provide `onUpload` props in Video options');
1412
- try {
1413
- const response = yield onUpload(file);
1414
- const { width, height } = getAspectRatio(response.width, response.height, maxSizes.maxWidth, maxSizes.maxHeight);
1415
- const updateVideoNode = {
1416
- data: {
1417
- url: response.url,
1418
- 'data-src': undefined,
1419
- size: { width: width || element.data.size.width, height: height || element.data.size.height },
1420
- },
1421
- };
1422
- setLoading(false);
1423
- Transforms.setNodes(editor, updateVideoNode, {
1424
- at: ReactEditor.findPath(editor, element),
1425
- match: (n) => Element.isElement(n) && n.type === 'video',
1426
- });
1427
- }
1428
- catch (error) {
1429
- enableBodyScroll(document.body);
1430
- setUploaderPos(null);
1431
- setLoading(false);
1432
- }
1433
- });
1434
- return (jsxs("div", Object.assign({ className: cx(s$2.editor, { [s$2.disabledUpload]: loading }) }, attributes, { contentEditable: false }, { children: [jsxs("div", Object.assign({ ref: videoEditorRef }, { children: [jsxs("button", Object.assign({ className: s$2.content, onClick: toggleUploaderOpen, disabled: loading }, { children: [loading && (jsx("div", Object.assign({ className: s$2.loading }, { children: jsx(Loader, {}) }))), jsx(SvgUpload, { className: s$2.icon, width: 24, height: 24 }), jsx("span", { children: "Click to add video" })] })), uploaderPos !== null && (jsx(EditorUploader, { onChange: onChangeFile, onClose: toggleUploaderOpen, activeTab: activeTab, switchTab: (tab) => setActiveTab(tab), style: uploaderPos, onEmbed: onEmbed }))] })), children] })));
1435
- };
1436
-
1437
- var css_248z = ".VideoEditor-module_root{cursor:pointer;display:block;position:relative}.VideoEditor-module_root:hover .VideoEditor-module_dotsOptions,.VideoEditor-module_root:hover .VideoEditor-module_resizer{opacity:1}.VideoEditor-module_loadingState{pointer-events:none}.VideoEditor-module_extraMargin{margin:20px 0 30px}.VideoEditor-module_resizeLib{margin:0 auto}.VideoEditor-module_resizer{align-items:center;cursor:col-resize;display:flex;height:100%;justify-content:center;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;width:15px;z-index:1}.VideoEditor-module_leftResizer{left:0;top:0}.VideoEditor-module_rightResizer{right:0;top:0}.VideoEditor-module_resizeItem{background:hsla(0,0%,6%,.6);border:1px solid hsla(0,0%,100%,.9);border-radius:20px;box-shadow:0 0 0 .5px #fff;height:48px;max-height:50%;opacity:1;transition:opacity .3s ease-in 0s;width:6px}.VideoEditor-module_selectImg{opacity:0}.VideoEditor-module_selected{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;z-index:81}.VideoEditor-module_loader{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.VideoEditor-module_dotsOptions{align-items:center;background-color:#eee;border:none;border-radius:2px;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:0;padding:0 4px;position:absolute;right:10px;top:10px;transition:opacity .15s ease-in 0s;width:22px;z-index:1}.VideoEditor-module_dot{background-color:gray;border-radius:50%;min-height:3px;min-width:3px}";
1438
- var s = {"root":"VideoEditor-module_root","resizer":"VideoEditor-module_resizer","dotsOptions":"VideoEditor-module_dotsOptions","loadingState":"VideoEditor-module_loadingState","extraMargin":"VideoEditor-module_extraMargin","resizeLib":"VideoEditor-module_resizeLib","leftResizer":"VideoEditor-module_leftResizer VideoEditor-module_resizer","rightResizer":"VideoEditor-module_rightResizer VideoEditor-module_resizer","resizeItem":"VideoEditor-module_resizeItem","selectImg":"VideoEditor-module_selectImg","selected":"VideoEditor-module_selected","loader":"VideoEditor-module_loader","dot":"VideoEditor-module_dot"};
1439
- styleInject(css_248z);
1440
-
1441
- const OPTIONS_WIDTH = 265;
1442
- const VideoEditorFactory = (editor, plugin) => (props) => jsx(VideoEditor, Object.assign({ editor: editor, plugin: plugin }, props));
1443
- function VideoEditor(props) {
1444
- var _a, _b, _c, _d, _e, _f, _g;
1445
- const { element, editor, plugin } = props;
1446
- const selected = useSelected();
1447
- const readOnly = useReadOnly();
1448
- const [optionsPos, setOptionsPos] = useState(null);
1449
- const [size, setSize] = useState({
1450
- width: ((_b = (_a = element.data) === null || _a === void 0 ? void 0 : _a.size) === null || _b === void 0 ? void 0 : _b.width) || 'auto',
1451
- height: ((_d = (_c = element.data) === null || _c === void 0 ? void 0 : _c.size) === null || _d === void 0 ? void 0 : _d.height) || 'auto',
1452
- });
1453
- useEffect(() => {
1454
- var _a, _b, _c, _d;
1455
- if (element.data) {
1456
- setSize({
1457
- width: ((_b = (_a = element.data) === null || _a === void 0 ? void 0 : _a.size) === null || _b === void 0 ? void 0 : _b.width) || 'auto',
1458
- height: ((_d = (_c = element.data) === null || _c === void 0 ? void 0 : _c.size) === null || _d === void 0 ? void 0 : _d.height) || 'auto',
1459
- });
1460
- }
1461
- }, [(_e = element.data) === null || _e === void 0 ? void 0 : _e.size]);
1462
- const resizeProps = useMemo(() => {
1463
- var _a;
1464
- return ({
1465
- minWidth: 92,
1466
- size: { width: size.width, height: size.height },
1467
- maxWidth: ((_a = plugin.options) === null || _a === void 0 ? void 0 : _a.maxWidth) || 800,
1468
- lockAspectRatio: true,
1469
- resizeRatio: 2,
1470
- enable: {
1471
- left: !readOnly,
1472
- right: !readOnly,
1473
- },
1474
- handleStyles: {
1475
- left: { left: 0 },
1476
- right: { right: 0 },
1477
- },
1478
- onResize: (e, direction, ref) => {
1479
- setSize({ width: ref.offsetWidth, height: ref.offsetHeight });
1480
- },
1481
- onResizeStop: (e, direction, ref) => {
1482
- console.log('video editor editor.children', editor.children);
1483
- console.log('ReactEditor.findPath(editor, element)', ReactEditor.findPath(editor, element));
1484
- console.log('element', element);
1485
- Transforms.setNodes(editor, { data: Object.assign(Object.assign({}, element.data), { size: { width: ref.offsetWidth, height: ref.offsetHeight } }) }, {
1486
- at: ReactEditor.findPath(editor, element),
1487
- match: (n) => Element.isElement(n) && n.type === 'video',
1488
- });
1489
- },
1490
- handleComponent: {
1491
- left: (jsx("div", Object.assign({ contentEditable: false, className: s.leftResizer }, { children: jsx("div", { className: s.resizeItem }) }))),
1492
- right: (jsx("div", Object.assign({ contentEditable: false, className: s.rightResizer }, { children: jsx("div", { className: s.resizeItem }) }))),
1493
- },
1494
- });
1495
- }, [size.width, size.height, editor]);
1496
- const hasCaption = !!((_f = element.data) === null || _f === void 0 ? void 0 : _f.caption);
1497
- const isLoading = !!element.data['data-src'] && !element.data.url;
1498
- const closeOptions = () => {
1499
- enableBodyScroll(document.body);
1500
- setOptionsPos(null);
1501
- };
1502
- const toggleOptionsOpen = (e) => {
1503
- var _a;
1504
- e === null || e === void 0 ? void 0 : e.stopPropagation();
1505
- if (optionsPos !== null) {
1506
- return closeOptions();
1507
- }
1508
- const optionsButtonRect = (_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
1509
- const UPLOADER_HEIGHT = 164;
1510
- if (optionsButtonRect) {
1511
- const showAtTop = optionsButtonRect.top + optionsButtonRect.height + UPLOADER_HEIGHT + 20 > window.innerHeight;
1512
- disableBodyScroll(document.body, { reserveScrollBarGap: true });
1513
- setOptionsPos({
1514
- left: optionsButtonRect.right - optionsButtonRect.width + OPTIONS_WIDTH > window.innerWidth
1515
- ? window.innerWidth - OPTIONS_WIDTH - optionsButtonRect.width
1516
- : optionsButtonRect.right - optionsButtonRect.width,
1517
- top: showAtTop
1518
- ? optionsButtonRect.top - UPLOADER_HEIGHT / 2 - optionsButtonRect.height
1519
- : optionsButtonRect.top + optionsButtonRect.height + 5,
1520
- });
1521
- }
1522
- };
1523
- if (!element.data.url && !element.data['data-src'] && !element.data.videoId) {
1524
- const { maxWidth = 750, maxHeight = 800 } = plugin.options || {};
1525
- return (jsxs("div", Object.assign({ className: s.root, contentEditable: false }, { children: [jsx("div", { className: cx(s.selectImg, { [s.selected]: selected }) }), jsx(EditorPlaceholder, Object.assign({ attributes: props.attributes, element: props.element, editor: editor, onUpload: (_g = plugin.options) === null || _g === void 0 ? void 0 : _g.onUpload, maxSizes: { maxWidth, maxHeight } }, { children: !readOnly && (jsxs("div", { children: [jsxs("button", Object.assign({ type: "button", className: s.dotsOptions, onClick: toggleOptionsOpen }, { children: [jsx("span", { className: s.dot }), jsx("span", { className: s.dot }), jsx("span", { className: s.dot })] })), optionsPos !== null && (jsx(UI_HELPERS.ElementOptions, { onClose: closeOptions, style: optionsPos, element: element, onCopy: closeOptions, onDelete: closeOptions, onDuplicate: closeOptions }, element.id))] })) })), props.children] }), element.id));
1526
- }
1527
- return (jsx("div", Object.assign({ contentEditable: false, draggable: false, className: cx(s.root, { [s.extraMargin]: hasCaption, [s.loadingState]: isLoading }) }, { children: jsxs(Resizable, Object.assign({}, resizeProps, { className: s.resizeLib }, { children: [plugin.renderer.render(Object.assign(Object.assign({}, props), { size })), jsx("div", { className: cx(s.selectImg, { [s.selected]: selected }) }), isLoading && (jsx("div", Object.assign({ className: s.loader }, { children: jsx(Loader, {}) }))), !readOnly && (jsxs("div", { children: [jsxs("button", Object.assign({ type: "button", className: s.dotsOptions, onClick: toggleOptionsOpen }, { children: [jsx("span", { className: s.dot }), jsx("span", { className: s.dot }), jsx("span", { className: s.dot })] })), optionsPos !== null && (jsx(UI_HELPERS.ElementOptions, { onClose: closeOptions, style: optionsPos, element: element, onCopy: closeOptions, onDelete: closeOptions, onDuplicate: closeOptions }, element.id))] }))] })) }), element.id));
1528
- }
1529
-
1530
- const Video = createYooptaPlugin({
1531
- type: 'video',
1532
- renderer: {
1533
- // @ts-ignore [TODO: fix types]
1534
- editor: VideoEditorFactory,
1535
- render: Video$1,
1536
- },
1537
- extendEditor(editor) {
1538
- const { isVoid } = editor;
1539
- editor.isVoid = (element) => {
1540
- return element.type === Video.getPlugin.type ? true : isVoid(element);
1541
- };
1542
- return editor;
1543
- },
1544
- events: {
1545
- onKeyDown: (editor, { defaultNode, hotkeys }) => (event) => {
1546
- var _a;
1547
- const currentNode = getElementByPath(editor, (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path, 'highest');
1548
- if (currentNode.type !== 'video' || !editor.selection)
1549
- return;
1550
- console.log('hotkeys.isEnter(event)', hotkeys.isEnter(event));
1551
- if (hotkeys.isEnter(event)) {
1552
- event.preventDefault();
1553
- Transforms.insertNodes(editor, defaultNode, { mode: 'highest' });
1554
- return;
1555
- }
1556
- },
1557
- },
1558
- defineElement: () => ({
1559
- id: generateId(),
1560
- type: 'video',
1561
- nodeType: 'void',
1562
- data: { url: null, size: { width: 'auto', height: 'auto' } },
1563
- children: [{ text: '' }],
1564
- }),
1565
- createElement: (editor, elementData) => {
1566
- var _a;
1567
- const node = Object.assign(Object.assign({}, Video.getPlugin.defineElement()), elementData);
1568
- Transforms.setNodes(editor, node, {
1569
- at: (_a = editor.selection) === null || _a === void 0 ? void 0 : _a.anchor,
1570
- });
1571
- },
1572
- exports: {
1573
- markdown: {
1574
- serialize: (node, text) => {
1575
- return `<video preload controls src="${node.data.url}" height="${node.data.size.height}" width="${node.data.size.width}"></video>\n`;
1576
- },
1577
- },
1578
- html: {
1579
- serialize: (node) => {
1580
- // [TODO] - change to <source /> and add format
1581
- return `<video preload controls src="${node.data.url}" height="${node.data.size.height}" width="${node.data.size.width}"></video>`;
1582
- },
1583
- deserialize: {
1584
- nodeName: 'VIDEO',
1585
- parse: (el) => ({
1586
- url: el.getAttribute('src'),
1587
- size: {
1588
- height: typeof el.getAttribute('height') === 'string' ? Number(el.getAttribute('height')) : 'auto',
1589
- width: typeof el.getAttribute('width') === 'string' ? Number(el.getAttribute('width')) : 'auto',
1590
- },
1591
- }),
1592
- },
1593
- },
1594
- },
1595
- options: {
1596
- searchString: 'video media',
1597
- displayLabel: 'Video',
1598
- },
1599
- });
1600
-
1601
- export { Video as default };
1
+ import{getElementClassname as t,UI_HELPERS as e,cx as i,createYooptaPlugin as o,getElementByPath as n,generateId as s}from"@yoopta/editor";import{Transforms as r,Element as a}from"slate";import{jsxs as d,jsx as l}from"react/jsx-runtime";import*as h from"react";import{useState as c,useEffect as p,useRef as u,useMemo as g}from"react";import{flushSync as f}from"react-dom";import{ReactEditor as m,useSelected as v,useReadOnly as b}from"slate-react";function w(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(i[o[n]]=t[o[n]])}return i}function y(t,e,i,o){return new(i||(i=Promise))((function(n,s){function r(t){try{d(o.next(t))}catch(t){s(t)}}function a(t){try{d(o.throw(t))}catch(t){s(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}d((o=o.apply(t,e||[])).next())}))}function x(t,{threshold:e=0,root:i=null,rootMargin:o="0%",freezeOnceVisible:n=!1}={}){const[s,r]=c({}),a=s.isIntersecting&&n,d=([t])=>r(t);return p((()=>{const n=null==t?void 0:t.current;if(!window.IntersectionObserver||a||!n)return;const s=new IntersectionObserver(d,{threshold:e,root:i,rootMargin:o});return s.observe(n),()=>s.disconnect()}),[t,e,i,o,a]),s}function z(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===i&&o.firstChild?o.insertBefore(n,o.firstChild):o.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}}"function"==typeof SuppressedError&&SuppressedError;var N="TvZseAeh",S="EZu95fyq",j="dkxsZ5ZT",O="KsFU0JBg",E="D-8E3vsv",k="eEtEqZrx",R="_0icGyC6M";z(".TvZseAeh{margin:20px 0 10px;position:relative}.EZu95fyq{border-radius:1px;display:block;margin:0 auto;max-width:100%;object-fit:cover;pointer-events:auto}.dkxsZ5ZT{display:flex;height:0;justify-content:center;min-height:100px;padding-bottom:56.25%;position:relative;width:100%}.KsFU0JBg{background-color:#fff}.D-8E3vsv,.KsFU0JBg{border-radius:1px;height:100%;pointer-events:auto;width:100%}.D-8E3vsv,.KsFU0JBg,.eEtEqZrx{left:0;position:absolute;top:0}.eEtEqZrx{filter:blur(10px);object-fit:cover;transition:opacity .15s ease-in,filter .15s ease-in}._0icGyC6M{height:100%;position:relative;width:100%}");const W={vimeo:function(t){var{videoId:e}=t,i=w(t,["videoId"]);const o=u(null),[n,s]=c(null),[r,a]=c(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return p((()=>{fetch(`https://vimeo.com/api/v2/video/${e}.json`).then((t=>t.json())).then((t=>s(t[0].thumbnail_medium))).catch((()=>s(null)))}),[e]),d("div",Object.assign({ref:o,className:R},{children:[l("img",{src:n||"",alt:"vimeo_video_preview",width:"100%",height:"100%",className:k,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&l("iframe",Object.assign({title:"Video Player",src:`https://player.vimeo.com/video/${e}?badge=0&byline=0&portrait=0&title=0`,frameBorder:0,allowFullScreen:!0,onLoad:()=>a(!0),className:O},i))]}))},youtube:function(t){var{videoId:e}=t,i=w(t,["videoId"]);const o=u(null),[n,s]=c(!1),{isIntersecting:r}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return d("div",Object.assign({ref:o,className:R},{children:[l("img",{src:`https://i.ytimg.com/vi/${e}/default.jpg`,alt:"youtube_video_preview",width:"100%",height:"100%",className:k,style:{opacity:r&&n?0:1,zIndex:r&&n?-1:0}}),r&&l("iframe",Object.assign({title:"Video Player",src:`https://www.youtube.com/embed/${e}`,frameBorder:0,onLoad:()=>s(!0),allowFullScreen:!0,className:O},i))]}))},dailymotion:function(t){var{videoId:e}=t,i=w(t,["videoId"]);const o=u(null),[n,s]=c(null),[r,a]=c(!1),{isIntersecting:h}=x(o,{freezeOnceVisible:!0,rootMargin:"50%"});return p((()=>{fetch((t=>`https://api.dailymotion.com/video/${t}?fields=thumbnail_url`)(e)).then((t=>t.json())).then((t=>s(t.thumbnail_url))).catch((()=>s(null)))}),[e]),d("div",Object.assign({ref:o,className:R},{children:[l("img",{src:n||"",alt:"daylimotion_video_preview",width:"100%",height:"100%",className:k,style:{opacity:h&&r?0:1,zIndex:h&&r?-1:0}}),h&&l("iframe",Object.assign({title:"Dailymotion Video Player",frameBorder:0,onLoad:()=>a(!0),src:`https://www.dailymotion.com/embed/video/${e}`,allowFullScreen:!0,className:O},i))]}))}};var H,M,C=(H=function(t,e){return H=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},H(t,e)},function(t,e){function i(){this.constructor=t}H(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),B=function(){return B=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},B.apply(this,arguments)},A={width:"100%",height:"10px",top:"0px",left:"0px",cursor:"row-resize"},L={width:"10px",height:"100%",top:"0px",left:"0px",cursor:"col-resize"},P={width:"20px",height:"20px",position:"absolute"},D={top:B(B({},A),{top:"-5px"}),right:B(B({},L),{left:void 0,right:"-5px"}),bottom:B(B({},A),{top:void 0,bottom:"-5px"}),left:B(B({},L),{left:"-5px"}),topRight:B(B({},P),{right:"-10px",top:"-10px",cursor:"ne-resize"}),bottomRight:B(B({},P),{right:"-10px",bottom:"-10px",cursor:"se-resize"}),bottomLeft:B(B({},P),{left:"-10px",bottom:"-10px",cursor:"sw-resize"}),topLeft:B(B({},P),{left:"-10px",top:"-10px",cursor:"nw-resize"})},I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onMouseDown=function(t){e.props.onResizeStart(t,e.props.direction)},e.onTouchStart=function(t){e.props.onResizeStart(t,e.props.direction)},e}return C(e,t),e.prototype.render=function(){return h.createElement("div",{className:this.props.className||"",style:B(B({position:"absolute",userSelect:"none"},D[this.props.direction]),this.props.replaceStyles||{}),onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart},this.props.children)},e}(h.PureComponent),_=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){function o(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}(),T=function(){return T=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},T.apply(this,arguments)},V={width:"auto",height:"auto"},G=function(t,e,i){return Math.max(Math.min(t,i),e)},U=function(t,e){return Math.round(t/e)*e},F=function(t,e){return new RegExp(t,"i").test(e)},Y=function(t){return Boolean(t.touches&&t.touches.length)},X=function(t,e,i){void 0===i&&(i=0);var o=e.reduce((function(i,o,n){return Math.abs(o-t)<Math.abs(e[i]-t)?n:i}),0),n=Math.abs(e[o]-t);return 0===i||n<i?e[o]:t},Q=function(t){return"auto"===(t=t.toString())||t.endsWith("px")||t.endsWith("%")||t.endsWith("vh")||t.endsWith("vw")||t.endsWith("vmax")||t.endsWith("vmin")?t:t+"px"},q=function(t,e,i,o){if(t&&"string"==typeof t){if(t.endsWith("px"))return Number(t.replace("px",""));if(t.endsWith("%"))return e*(Number(t.replace("%",""))/100);if(t.endsWith("vw"))return i*(Number(t.replace("vw",""))/100);if(t.endsWith("vh"))return o*(Number(t.replace("vh",""))/100)}return t},J=["as","style","className","grid","snap","bounds","boundsByDirection","size","defaultSize","minWidth","minHeight","maxWidth","maxHeight","lockAspectRatio","lockAspectRatioExtraWidth","lockAspectRatioExtraHeight","enable","handleStyles","handleClasses","handleWrapperStyle","handleWrapperClass","children","onResizeStart","onResize","onResizeStop","handleComponent","scale","resizeRatio","snapGap"],Z="__resizable_base__",K=function(t){function e(e){var i=t.call(this,e)||this;return i.ratio=1,i.resizable=null,i.parentLeft=0,i.parentTop=0,i.resizableLeft=0,i.resizableRight=0,i.resizableTop=0,i.resizableBottom=0,i.targetLeft=0,i.targetTop=0,i.appendBase=function(){if(!i.resizable||!i.window)return null;var t=i.parentNode;if(!t)return null;var e=i.window.document.createElement("div");return e.style.width="100%",e.style.height="100%",e.style.position="absolute",e.style.transform="scale(0, 0)",e.style.left="0",e.style.flex="0 0 100%",e.classList?e.classList.add(Z):e.className+=Z,t.appendChild(e),e},i.removeBase=function(t){var e=i.parentNode;e&&e.removeChild(t)},i.ref=function(t){t&&(i.resizable=t)},i.state={isResizing:!1,width:void 0===(i.propsSize&&i.propsSize.width)?"auto":i.propsSize&&i.propsSize.width,height:void 0===(i.propsSize&&i.propsSize.height)?"auto":i.propsSize&&i.propsSize.height,direction:"right",original:{x:0,y:0,width:0,height:0},backgroundStyle:{height:"100%",width:"100%",backgroundColor:"rgba(0,0,0,0)",cursor:"auto",opacity:0,position:"fixed",zIndex:9999,top:"0",left:"0",bottom:"0",right:"0"},flexBasis:void 0},i.onResizeStart=i.onResizeStart.bind(i),i.onMouseMove=i.onMouseMove.bind(i),i.onMouseUp=i.onMouseUp.bind(i),i}return _(e,t),Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.resizable?this.resizable.parentNode:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"window",{get:function(){return this.resizable&&this.resizable.ownerDocument?this.resizable.ownerDocument.defaultView:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"propsSize",{get:function(){return this.props.size||this.props.defaultSize||V},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){var t=0,e=0;if(this.resizable&&this.window){var i=this.resizable.offsetWidth,o=this.resizable.offsetHeight,n=this.resizable.style.position;"relative"!==n&&(this.resizable.style.position="relative"),t="auto"!==this.resizable.style.width?this.resizable.offsetWidth:i,e="auto"!==this.resizable.style.height?this.resizable.offsetHeight:o,this.resizable.style.position=n}return{width:t,height:e}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sizeStyle",{get:function(){var t=this,e=this.props.size,i=function(e){if(void 0===t.state[e]||"auto"===t.state[e])return"auto";if(t.propsSize&&t.propsSize[e]&&t.propsSize[e].toString().endsWith("%")){if(t.state[e].toString().endsWith("%"))return t.state[e].toString();var i=t.getParentSize();return Number(t.state[e].toString().replace("px",""))/i[e]*100+"%"}return Q(t.state[e])};return{width:e&&void 0!==e.width&&!this.state.isResizing?Q(e.width):i("width"),height:e&&void 0!==e.height&&!this.state.isResizing?Q(e.height):i("height")}},enumerable:!1,configurable:!0}),e.prototype.getParentSize=function(){if(!this.parentNode)return this.window?{width:this.window.innerWidth,height:this.window.innerHeight}:{width:0,height:0};var t=this.appendBase();if(!t)return{width:0,height:0};var e=!1,i=this.parentNode.style.flexWrap;"wrap"!==i&&(e=!0,this.parentNode.style.flexWrap="wrap"),t.style.position="relative",t.style.minWidth="100%",t.style.minHeight="100%";var o={width:t.offsetWidth,height:t.offsetHeight};return e&&(this.parentNode.style.flexWrap=i),this.removeBase(t),o},e.prototype.bindEvents=function(){this.window&&(this.window.addEventListener("mouseup",this.onMouseUp),this.window.addEventListener("mousemove",this.onMouseMove),this.window.addEventListener("mouseleave",this.onMouseUp),this.window.addEventListener("touchmove",this.onMouseMove,{capture:!0,passive:!1}),this.window.addEventListener("touchend",this.onMouseUp))},e.prototype.unbindEvents=function(){this.window&&(this.window.removeEventListener("mouseup",this.onMouseUp),this.window.removeEventListener("mousemove",this.onMouseMove),this.window.removeEventListener("mouseleave",this.onMouseUp),this.window.removeEventListener("touchmove",this.onMouseMove,!0),this.window.removeEventListener("touchend",this.onMouseUp))},e.prototype.componentDidMount=function(){if(this.resizable&&this.window){var t=this.window.getComputedStyle(this.resizable);this.setState({width:this.state.width||this.size.width,height:this.state.height||this.size.height,flexBasis:"auto"!==t.flexBasis?t.flexBasis:void 0})}},e.prototype.componentWillUnmount=function(){this.window&&this.unbindEvents()},e.prototype.createSizeForCssProperty=function(t,e){var i=this.propsSize&&this.propsSize[e];return"auto"!==this.state[e]||this.state.original[e]!==t||void 0!==i&&"auto"!==i?t:"auto"},e.prototype.calculateNewMaxFromBoundary=function(t,e){var i,o,n=this.props.boundsByDirection,s=this.state.direction,r=n&&F("left",s),a=n&&F("top",s);if("parent"===this.props.bounds){var d=this.parentNode;d&&(i=r?this.resizableRight-this.parentLeft:d.offsetWidth+(this.parentLeft-this.resizableLeft),o=a?this.resizableBottom-this.parentTop:d.offsetHeight+(this.parentTop-this.resizableTop))}else"window"===this.props.bounds?this.window&&(i=r?this.resizableRight:this.window.innerWidth-this.resizableLeft,o=a?this.resizableBottom:this.window.innerHeight-this.resizableTop):this.props.bounds&&(i=r?this.resizableRight-this.targetLeft:this.props.bounds.offsetWidth+(this.targetLeft-this.resizableLeft),o=a?this.resizableBottom-this.targetTop:this.props.bounds.offsetHeight+(this.targetTop-this.resizableTop));return i&&Number.isFinite(i)&&(t=t&&t<i?t:i),o&&Number.isFinite(o)&&(e=e&&e<o?e:o),{maxWidth:t,maxHeight:e}},e.prototype.calculateNewSizeFromDirection=function(t,e){var i=this.props.scale||1,o=this.props.resizeRatio||1,n=this.state,s=n.direction,r=n.original,a=this.props,d=a.lockAspectRatio,l=a.lockAspectRatioExtraHeight,h=a.lockAspectRatioExtraWidth,c=r.width,p=r.height,u=l||0,g=h||0;return F("right",s)&&(c=r.width+(t-r.x)*o/i,d&&(p=(c-g)/this.ratio+u)),F("left",s)&&(c=r.width-(t-r.x)*o/i,d&&(p=(c-g)/this.ratio+u)),F("bottom",s)&&(p=r.height+(e-r.y)*o/i,d&&(c=(p-u)*this.ratio+g)),F("top",s)&&(p=r.height-(e-r.y)*o/i,d&&(c=(p-u)*this.ratio+g)),{newWidth:c,newHeight:p}},e.prototype.calculateNewSizeFromAspectRatio=function(t,e,i,o){var n=this.props,s=n.lockAspectRatio,r=n.lockAspectRatioExtraHeight,a=n.lockAspectRatioExtraWidth,d=void 0===o.width?10:o.width,l=void 0===i.width||i.width<0?t:i.width,h=void 0===o.height?10:o.height,c=void 0===i.height||i.height<0?e:i.height,p=r||0,u=a||0;if(s){var g=(h-p)*this.ratio+u,f=(c-p)*this.ratio+u,m=(d-u)/this.ratio+p,v=(l-u)/this.ratio+p,b=Math.max(d,g),w=Math.min(l,f),y=Math.max(h,m),x=Math.min(c,v);t=G(t,b,w),e=G(e,y,x)}else t=G(t,d,l),e=G(e,h,c);return{newWidth:t,newHeight:e}},e.prototype.setBoundingClientRect=function(){if("parent"===this.props.bounds){var t=this.parentNode;if(t){var e=t.getBoundingClientRect();this.parentLeft=e.left,this.parentTop=e.top}}if(this.props.bounds&&"string"!=typeof this.props.bounds){var i=this.props.bounds.getBoundingClientRect();this.targetLeft=i.left,this.targetTop=i.top}if(this.resizable){var o=this.resizable.getBoundingClientRect(),n=o.left,s=o.top,r=o.right,a=o.bottom;this.resizableLeft=n,this.resizableRight=r,this.resizableTop=s,this.resizableBottom=a}},e.prototype.onResizeStart=function(t,e){if(this.resizable&&this.window){var i,o=0,n=0;if(t.nativeEvent&&function(t){return Boolean((t.clientX||0===t.clientX)&&(t.clientY||0===t.clientY))}(t.nativeEvent)?(o=t.nativeEvent.clientX,n=t.nativeEvent.clientY):t.nativeEvent&&Y(t.nativeEvent)&&(o=t.nativeEvent.touches[0].clientX,n=t.nativeEvent.touches[0].clientY),this.props.onResizeStart)if(this.resizable)if(!1===this.props.onResizeStart(t,e,this.resizable))return;this.props.size&&(void 0!==this.props.size.height&&this.props.size.height!==this.state.height&&this.setState({height:this.props.size.height}),void 0!==this.props.size.width&&this.props.size.width!==this.state.width&&this.setState({width:this.props.size.width})),this.ratio="number"==typeof this.props.lockAspectRatio?this.props.lockAspectRatio:this.size.width/this.size.height;var s=this.window.getComputedStyle(this.resizable);if("auto"!==s.flexBasis){var r=this.parentNode;if(r){var a=this.window.getComputedStyle(r).flexDirection;this.flexDir=a.startsWith("row")?"row":"column",i=s.flexBasis}}this.setBoundingClientRect(),this.bindEvents();var d={original:{x:o,y:n,width:this.size.width,height:this.size.height},isResizing:!0,backgroundStyle:T(T({},this.state.backgroundStyle),{cursor:this.window.getComputedStyle(t.target).cursor||"auto"}),direction:e,flexBasis:i};this.setState(d)}},e.prototype.onMouseMove=function(t){var e=this;if(this.state.isResizing&&this.resizable&&this.window){if(this.window.TouchEvent&&Y(t))try{t.preventDefault(),t.stopPropagation()}catch(t){}var i=this.props,o=i.maxWidth,n=i.maxHeight,s=i.minWidth,r=i.minHeight,a=Y(t)?t.touches[0].clientX:t.clientX,d=Y(t)?t.touches[0].clientY:t.clientY,l=this.state,h=l.direction,c=l.original,p=l.width,u=l.height,g=this.getParentSize(),m=function(t,e,i,o,n,s,r){return o=q(o,t.width,e,i),n=q(n,t.height,e,i),s=q(s,t.width,e,i),r=q(r,t.height,e,i),{maxWidth:void 0===o?void 0:Number(o),maxHeight:void 0===n?void 0:Number(n),minWidth:void 0===s?void 0:Number(s),minHeight:void 0===r?void 0:Number(r)}}(g,this.window.innerWidth,this.window.innerHeight,o,n,s,r);o=m.maxWidth,n=m.maxHeight,s=m.minWidth,r=m.minHeight;var v=this.calculateNewSizeFromDirection(a,d),b=v.newHeight,w=v.newWidth,y=this.calculateNewMaxFromBoundary(o,n);this.props.snap&&this.props.snap.x&&(w=X(w,this.props.snap.x,this.props.snapGap)),this.props.snap&&this.props.snap.y&&(b=X(b,this.props.snap.y,this.props.snapGap));var x=this.calculateNewSizeFromAspectRatio(w,b,{width:y.maxWidth,height:y.maxHeight},{width:s,height:r});if(w=x.newWidth,b=x.newHeight,this.props.grid){var z=U(w,this.props.grid[0]),N=U(b,this.props.grid[1]),S=this.props.snapGap||0;w=0===S||Math.abs(z-w)<=S?z:w,b=0===S||Math.abs(N-b)<=S?N:b}var j={width:w-c.width,height:b-c.height};if(p&&"string"==typeof p)if(p.endsWith("%"))w=w/g.width*100+"%";else if(p.endsWith("vw")){w=w/this.window.innerWidth*100+"vw"}else if(p.endsWith("vh")){w=w/this.window.innerHeight*100+"vh"}if(u&&"string"==typeof u)if(u.endsWith("%"))b=b/g.height*100+"%";else if(u.endsWith("vw")){b=b/this.window.innerWidth*100+"vw"}else if(u.endsWith("vh")){b=b/this.window.innerHeight*100+"vh"}var O={width:this.createSizeForCssProperty(w,"width"),height:this.createSizeForCssProperty(b,"height")};"row"===this.flexDir?O.flexBasis=O.width:"column"===this.flexDir&&(O.flexBasis=O.height),f((function(){e.setState(O)})),this.props.onResize&&this.props.onResize(t,h,this.resizable,j)}},e.prototype.onMouseUp=function(t){var e=this.state,i=e.isResizing,o=e.direction,n=e.original;if(i&&this.resizable){var s={width:this.size.width-n.width,height:this.size.height-n.height};this.props.onResizeStop&&this.props.onResizeStop(t,o,this.resizable,s),this.props.size&&this.setState(this.props.size),this.unbindEvents(),this.setState({isResizing:!1,backgroundStyle:T(T({},this.state.backgroundStyle),{cursor:"auto"})})}},e.prototype.updateSize=function(t){this.setState({width:t.width,height:t.height})},e.prototype.renderResizer=function(){var t=this,e=this.props,i=e.enable,o=e.handleStyles,n=e.handleClasses,s=e.handleWrapperStyle,r=e.handleWrapperClass,a=e.handleComponent;if(!i)return null;var d=Object.keys(i).map((function(e){return!1!==i[e]?h.createElement(I,{key:e,direction:e,onResizeStart:t.onResizeStart,replaceStyles:o&&o[e],className:n&&n[e]},a&&a[e]?a[e]:null):null}));return h.createElement("div",{className:r,style:s},d)},e.prototype.render=function(){var t=this,e=Object.keys(this.props).reduce((function(e,i){return-1!==J.indexOf(i)||(e[i]=t.props[i]),e}),{}),i=T(T(T({position:"relative",userSelect:this.state.isResizing?"none":"auto"},this.props.style),this.sizeStyle),{maxWidth:this.props.maxWidth,maxHeight:this.props.maxHeight,minWidth:this.props.minWidth,minHeight:this.props.minHeight,boxSizing:"border-box",flexShrink:0});this.state.flexBasis&&(i.flexBasis=this.state.flexBasis);var o=this.props.as||"div";return h.createElement(o,T({ref:this.ref,style:i,className:this.props.className},e),this.state.isResizing&&h.createElement("div",{style:this.state.backgroundStyle}),this.props.children,this.renderResizer())},e.defaultProps={as:"div",onResizeStart:function(){},onResize:function(){},onResizeStop:function(){},enable:{top:!0,right:!0,bottom:!0,left:!0,topRight:!0,bottomRight:!0,bottomLeft:!0,topLeft:!0},style:{},grid:[1,1],lockAspectRatio:!1,lockAspectRatioExtraWidth:0,lockAspectRatioExtraHeight:0,scale:1,resizeRatio:1,snapGap:0},e}(h.PureComponent);function $(){return $=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}return t},$.apply(this,arguments)}var tt=function(t){return h.createElement("svg",$({fill:"currentColor","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"uploadImage"},t),M||(M=h.createElement("path",{d:"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"})))},et="rq2V2ceB",it="rc-sSm2o",ot="pa2jWsNN",nt="WCrDI0dy",st="d-YDdEGm",rt="zaYe5qHX",at="M0t11tGQ",dt="_9cpXcl96",lt="DZJetA3e",ht="oVy3BbqO M0t11tGQ",ct="GIpAKCJ0",pt="k7HVhRkA";z('.rq2V2ceB{position:fixed}.rc-sSm2o{background:#fff;box-shadow:0 0 0 1px hsla(0,0%,6%,.05),0 3px 6px hsla(0,0%,6%,.1),0 9px 24px hsla(0,0%,6%,.2);display:flex;flex-direction:column;height:100%;max-height:420px;max-width:calc(100vw - 24px);min-width:540px}.pa2jWsNN{box-shadow:inset 0 -1px 0 rgba(55,53,47,.09);display:flex;height:40px;padding:0 8px;width:100%;z-index:1}.WCrDI0dy,.pa2jWsNN{font-size:14px;position:relative}.WCrDI0dy{align-items:center;background-color:inherit;border:none;border-radius:4px;color:#37352f;cursor:pointer;display:inline-flex;flex-shrink:0;height:100%;line-height:1.2;min-width:0;padding:6px 8px;transition:height 20ms ease-in 0s;user-select:none;white-space:nowrap}.d-YDdEGm:after{background-color:#37352f;bottom:0;content:"";height:2px;left:0;position:absolute;width:100%}.zaYe5qHX{display:flex;justify-content:center;margin-left:12px;margin-right:12px;margin-top:4px;padding-bottom:6px;padding-top:6px}.M0t11tGQ{border:1px solid rgba(55,53,47,.16);border-radius:4px;height:32px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap}.M0t11tGQ,._9cpXcl96{cursor:pointer;width:100%}._9cpXcl96{align-items:center;display:inline-flex;font-size:14px;font-weight:500;height:100%;justify-content:center;line-height:1.2}.DZJetA3e{left:0;position:absolute;top:0;visibility:hidden}.oVy3BbqO{border:none!important;cursor:pointer!important;height:auto!important;padding-left:0!important;padding-right:0!important}.GIpAKCJ0{background:hsla(45,13%,94%,.6);box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1);cursor:text;height:32px;line-height:20px;padding:3px 6px;position:relative}.GIpAKCJ0,.k7HVhRkA{align-items:center;border:none;border-radius:4px;display:flex;font-size:14px;width:100%}.k7HVhRkA{fill:#fff;background:#2383e2;box-shadow:inset 0 0 0 1px hsla(0,0%,6%,.1),0 1px 2px hsla(0,0%,6%,.1);color:#fff;cursor:pointer;flex-shrink:0;font-weight:500;height:28px;justify-content:center;line-height:1.2;margin:12px auto 6px;max-width:300px;padding-left:12px;padding-right:12px;transition:background 20ms ease-in 0s;user-select:none;white-space:nowrap}');const ut=({onChange:t})=>l("div",Object.assign({className:at},{children:d("label",Object.assign({htmlFor:"video-uploader",className:dt},{children:[l("input",{type:"file",id:"video-uploader",className:lt,accept:"video/*",onChange:e=>{const i=e.currentTarget.files;i&&i.length>0&&t(i[0])},multiple:!1}),"Upload file"]}))})),gt=({onEmbed:t})=>{const[e,i]=c("");return d("div",Object.assign({className:ht},{children:[l("input",{type:"text",placeholder:"Paste video link (Youtube, Vimeo, Dailymotion)",value:e,className:ct,onChange:t=>i(t.target.value)}),l("button",Object.assign({type:"button",className:pt,onClick:()=>t(e)},{children:"Embed video"}))]}))},ft=({activeTab:t="upload",style:o,switchTab:n,onChange:s,onClose:r,onEmbed:a})=>{const h="upload"===t,c="embed"===t;return l(e.Overlay,Object.assign({onClose:r},{children:l("div",Object.assign({className:et,style:o},{children:d("div",Object.assign({className:it},{children:[d("div",Object.assign({className:ot},{children:[l("button",Object.assign({type:"button",onClick:()=>n("upload"),className:i(nt,{[st]:h})},{children:"Upload"})),l("button",Object.assign({type:"button",onClick:()=>n("embed"),className:i(nt,{[st]:c})},{children:"Video link"}))]})),d("div",Object.assign({className:rt},{children:[h&&l(ut,{onChange:s}),c&&l(gt,{onEmbed:a})]}))]}))}))}))};var mt=!1;if("undefined"!=typeof window){var vt={get passive(){mt=!0}};window.addEventListener("testPassive",null,vt),window.removeEventListener("testPassive",null,vt)}var bt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),wt=[],yt=!1,xt=-1,zt=void 0,Nt=void 0,St=void 0,jt=function(t){return wt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Ot=function(t){var e=t||window.event;return!!jt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Et=function(t,e){if(t){if(!wt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};wt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}(wt),[i]),bt?window.requestAnimationFrame((function(){if(void 0===Nt){Nt={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var t=window,e=t.scrollY,i=t.scrollX,o=t.innerHeight;document.body.style.position="fixed",document.body.style.top=-e,document.body.style.left=-i,setTimeout((function(){return window.requestAnimationFrame((function(){var t=o-window.innerHeight;t&&e>=o&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===St){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var o=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);St=document.body.style.paddingRight,document.body.style.paddingRight=o+i+"px"}}void 0===zt&&(zt=document.body.style.overflow,document.body.style.overflow="hidden")}(e),bt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(xt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-xt;!jt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Ot(t):t.stopPropagation())}(e,t)},yt||(document.addEventListener("touchmove",Ot,mt?{passive:!1}:void 0),yt=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},kt=function(t){t?(wt=wt.filter((function(e){return e.targetElement!==t})),bt&&(t.ontouchstart=null,t.ontouchmove=null,yt&&0===wt.length&&(document.removeEventListener("touchmove",Ot,mt?{passive:!1}:void 0),yt=!1)),bt?function(){if(void 0!==Nt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Nt.position,document.body.style.top=Nt.top,document.body.style.left=Nt.left,window.scrollTo(e,t),Nt=void 0}}():(void 0!==St&&(document.body.style.paddingRight=St,St=void 0),void 0!==zt&&(document.body.style.overflow=zt,zt=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};var Rt="ejxIcizu",Wt="tGCxkSAc",Ht="BAqjz8jz",Mt="tab3XKrp",Ct="UnxRu3H0";z(".ejxIcizu{margin:20px 0 10px;user-select:none}.ejxIcizu,.tGCxkSAc{position:relative;width:100%}.tGCxkSAc{align-items:center;background-color:#efefef;border:none;border-radius:3px;color:rgba(55,53,47,.65);cursor:pointer;display:flex;font-size:14px;overflow:hidden;padding:12px 36px 12px 12px;text-align:left;transition:background-color .1s ease-in}.tGCxkSAc:hover{background-color:#e3e3e3}.BAqjz8jz{background-color:#efefef;color:rgba(55,53,47,.65);cursor:not-allowed;pointer-events:none}.tab3XKrp{margin-right:8px;user-select:none}.UnxRu3H0{left:50%;position:absolute;top:50%}");var Bt="tmpFyHNs",At="NdlfkJmx";z(".tmpFyHNs{height:100%;position:relative;width:100%}.tmpFyHNs .NdlfkJmx{background-color:#909090;border-radius:5rem;height:10px;position:absolute;top:50%;transform:translate(-50%,-50%);width:10px}.tmpFyHNs .NdlfkJmx:first-child{animation:p3veiLIQ 2s,_4Q-HiXe1 2s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% - 60px)}.tmpFyHNs .NdlfkJmx:nth-child(2){animation:p3veiLIQ 2s,NAkUMYzr 2s;animation-delay:.15s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% - 30px)}.tmpFyHNs .NdlfkJmx:nth-child(3){animation:p3veiLIQ 2s,_4Q-HiXe1 2s;animation-delay:.3s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:50%}.tmpFyHNs .NdlfkJmx:nth-child(4){animation:p3veiLIQ 2s,NAkUMYzr 2s;animation-delay:.45s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% + 30px)}.tmpFyHNs .NdlfkJmx:nth-child(5){animation:p3veiLIQ 2s,_4Q-HiXe1 2s;animation-delay:.6s;animation-iteration-count:infinite;animation-timing-function:ease-in-out;left:calc(50% + 60px)}@keyframes p3veiLIQ{0%,15%{top:50%}45%,65%{top:42.5%}85%,to{top:50%}}@keyframes _4Q-HiXe1{0%,8%{background-color:#909090;height:10px}14%,34%{background-color:#f8f8f8;height:17.5px}46%,to{background-color:#909090;height:10px}}@keyframes NAkUMYzr{0%,8%{background-color:#909090;height:10px}14%,34%{background-color:#f8f8f8;height:32.5px}46%,to{background-color:#909090;height:10px}}");const Lt=()=>d("div",Object.assign({className:Bt},{children:[l("div",{className:At}),l("div",{className:At}),l("div",{className:At}),l("div",{className:At}),l("div",{className:At})]})),Pt=({element:t,attributes:e,maxSizes:o,children:n,editor:s,onUpload:h})=>{const[p,g]=c(null),[f,v]=c(!1),[b,w]=c("upload"),x=u(null),z=t=>{var e;if(t.stopPropagation(),null!==p)return kt(document.body),void g(null);const i=null===(e=x.current)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+88+20>window.innerHeight,e=!t;console.log({showAtTop:t,showAtBottom:e}),Et(document.body,{reserveScrollBarGap:!0}),g({left:i.left,top:t?i.top-88-5:i.top+i.height+5})}};return d("div",Object.assign({className:i(Rt,{[Ht]:f})},e,{contentEditable:!1},{children:[d("div",Object.assign({ref:x},{children:[d("button",Object.assign({className:Wt,onClick:z,disabled:f},{children:[f&&l("div",Object.assign({className:Ct},{children:l(Lt,{})})),l(tt,{className:Mt,width:24,height:24}),l("span",{children:"Click to add video"})]})),null!==p&&l(ft,{onChange:e=>y(void 0,void 0,void 0,(function*(){if(kt(document.body),g(null),v(!0),!h)return console.error("Provide `onUpload` props in Video options");try{const i=yield h(e),{width:n,height:d}=((t,e,i,o)=>{if(!t||!e)return{};const n=Math.min(i/t,o/e);return{width:t*n,height:e*n}})(i.width,i.height,o.maxWidth,o.maxHeight),l={data:{url:i.url,"data-src":void 0,size:{width:n||t.data.size.width,height:d||t.data.size.height}}};v(!1),r.setNodes(s,l,{at:m.findPath(s,t),match:t=>a.isElement(t)&&"video"===t.type})}catch(t){kt(document.body),g(null),v(!1)}})),onClose:z,activeTab:b,switchTab:t=>w(t),style:p,onEmbed:e=>y(void 0,void 0,void 0,(function*(){if(0===e.length)return;const i=(o=e).includes("youtube.com")||o.includes("youtu.be")?"youtube":o.includes("vimeo.com")?"vimeo":o.includes("dailymotion.com")||o.includes("dai.ly")?"dailymotion":null;var o;let n=null;if("youtube"===i?n=(t=>{const e=t.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return e&&11===e[2].length?e[2]:null})(e):"vimeo"===i?n=(t=>new URL(t).pathname.split("/")[1])(e):"dailymotion"===i&&(n=(t=>{var e=t.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);return null!==e?void 0!==e[4]?e[4]:e[2]:null})(e)),n)try{kt(document.body),g(null);const e={data:Object.assign(Object.assign({},t.data),{url:null,"data-src":void 0,size:{width:t.data.size.width,height:t.data.size.height},provider:i,videoId:n})};r.setNodes(s,e,{at:m.findPath(s,t),match:t=>a.isElement(t)&&"video"===t.type})}catch(t){kt(document.body),g(null)}}))})]})),n]}))};var Dt="jsof5eGh",It="_9ivUDLVr",_t="hD5QV2jP",Tt="M9o3j8I5",Vt="-dEl6QRc",Gt="_72L6ylPc WOn73-dw",Ut="OhmV3u2l WOn73-dw",Ft="fdfDEgiq",Yt="_7b-PdGXE",Xt="YKGzSDVj",Qt="yDd0Sn4a",qt="VZUnkjYn";z(".jsof5eGh{cursor:pointer;display:block;position:relative}.jsof5eGh:hover .WOn73-dw,.jsof5eGh:hover ._9ivUDLVr{opacity:1}.hD5QV2jP{pointer-events:none}.M9o3j8I5{margin:20px 0 30px}.-dEl6QRc{margin:0 auto}.WOn73-dw{align-items:center;cursor:col-resize;display:flex;height:100%;justify-content:center;opacity:0;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;width:15px;z-index:1}._72L6ylPc{left:0;top:0}.OhmV3u2l{right:0;top:0}.fdfDEgiq{background:hsla(0,0%,6%,.6);border:1px solid hsla(0,0%,100%,.9);border-radius:20px;box-shadow:0 0 0 .5px #fff;height:48px;max-height:50%;opacity:1;transition:opacity .3s ease-in 0s;width:6px}._7b-PdGXE{opacity:0}.YKGzSDVj{background:rgba(35,131,226,.14);border-radius:3px;inset:0;opacity:1;pointer-events:none;position:absolute;transition:opacity .15s ease-in 0s;z-index:81}.yDd0Sn4a{left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}._9ivUDLVr{align-items:center;background-color:#eee;border:none;border-radius:2px;cursor:pointer;display:flex;height:22px;justify-content:space-between;opacity:0;padding:0 4px;position:absolute;right:10px;top:10px;transition:opacity .15s ease-in 0s;width:22px;z-index:1}.VZUnkjYn{background-color:gray;border-radius:50%;min-height:3px;min-width:3px}");function Jt(t){var o,n,s,h,u,f,w;const{element:y,editor:x,plugin:z}=t,N=v(),S=b(),[j,O]=c(null),[E,k]=c({width:(null===(n=null===(o=y.data)||void 0===o?void 0:o.size)||void 0===n?void 0:n.width)||"auto",height:(null===(h=null===(s=y.data)||void 0===s?void 0:s.size)||void 0===h?void 0:h.height)||"auto"});p((()=>{var t,e,i,o;y.data&&k({width:(null===(e=null===(t=y.data)||void 0===t?void 0:t.size)||void 0===e?void 0:e.width)||"auto",height:(null===(o=null===(i=y.data)||void 0===i?void 0:i.size)||void 0===o?void 0:o.height)||"auto"})}),[null===(u=y.data)||void 0===u?void 0:u.size]);const R=g((()=>{var t;return{minWidth:92,size:{width:E.width,height:E.height},maxWidth:(null===(t=z.options)||void 0===t?void 0:t.maxWidth)||800,lockAspectRatio:!0,resizeRatio:2,enable:{left:!S,right:!S},handleStyles:{left:{left:0},right:{right:0}},onResize:(t,e,i)=>{k({width:i.offsetWidth,height:i.offsetHeight})},onResizeStop:(t,e,i)=>{console.log("video editor editor.children",x.children),console.log("ReactEditor.findPath(editor, element)",m.findPath(x,y)),console.log("element",y),r.setNodes(x,{data:Object.assign(Object.assign({},y.data),{size:{width:i.offsetWidth,height:i.offsetHeight}})},{at:m.findPath(x,y),match:t=>a.isElement(t)&&"video"===t.type})},handleComponent:{left:l("div",Object.assign({contentEditable:!1,className:Gt},{children:l("div",{className:Ft})})),right:l("div",Object.assign({contentEditable:!1,className:Ut},{children:l("div",{className:Ft})}))}}}),[E.width,E.height,x]),W=!!(null===(f=y.data)||void 0===f?void 0:f.caption),H=!!y.data["data-src"]&&!y.data.url,M=()=>{kt(document.body),O(null)},C=t=>{var e;if(null==t||t.stopPropagation(),null!==j)return M();const i=null===(e=null==t?void 0:t.currentTarget)||void 0===e?void 0:e.getBoundingClientRect();if(i){const t=i.top+i.height+164+20>window.innerHeight;Et(document.body,{reserveScrollBarGap:!0}),O({left:i.right-i.width+265>window.innerWidth?window.innerWidth-265-i.width:i.right-i.width,top:t?i.top-82-i.height:i.top+i.height+5})}};if(!y.data.url&&!y.data["data-src"]&&!y.data.videoId){const{maxWidth:o=750,maxHeight:n=800}=z.options||{};return d("div",Object.assign({className:Dt,contentEditable:!1},{children:[l("div",{className:i(Yt,{[Xt]:N})}),l(Pt,Object.assign({attributes:t.attributes,element:t.element,editor:x,onUpload:null===(w=z.options)||void 0===w?void 0:w.onUpload,maxSizes:{maxWidth:o,maxHeight:n}},{children:!S&&d("div",{children:[d("button",Object.assign({type:"button",className:It,onClick:C},{children:[l("span",{className:qt}),l("span",{className:qt}),l("span",{className:qt})]})),null!==j&&l(e.ElementOptions,{onClose:M,style:j,element:y,onCopy:M,onDelete:M,onDuplicate:M},y.id)]})})),t.children]}),y.id)}return l("div",Object.assign({contentEditable:!1,draggable:!1,className:i(Dt,{[Tt]:W,[_t]:H})},{children:d(K,Object.assign({},R,{className:Vt},{children:[z.renderer.render(Object.assign(Object.assign({},t),{size:E})),l("div",{className:i(Yt,{[Xt]:N})}),H&&l("div",Object.assign({className:Qt},{children:l(Lt,{})})),!S&&d("div",{children:[d("button",Object.assign({type:"button",className:It,onClick:C},{children:[l("span",{className:qt}),l("span",{className:qt}),l("span",{className:qt})]})),null!==j&&l(e.ElementOptions,{onClose:M,style:j,element:y,onCopy:M,onDelete:M,onDuplicate:M},y.id)]})]}))}),y.id)}const Zt=o({type:"video",renderer:{editor:(t,e)=>i=>l(Jt,Object.assign({editor:t,plugin:e},i)),render:({attributes:e,element:i,children:o,size:n,HTMLAttributes:s})=>{var r,a,h,c;const p=(null==n?void 0:n.width)||(null===(a=null===(r=i.data)||void 0===r?void 0:r.size)||void 0===a?void 0:a.width)||"100%",u=(null==n?void 0:n.height)||(null===(c=null===(h=i.data)||void 0===h?void 0:h.size)||void 0===c?void 0:c.height)||400;if("string"==typeof i.data.provider&&i.data.videoId&&W[i.data.provider]){const n=W[i.data.provider];return d("div",Object.assign({},e,s,{className:t({element:i,HTMLAttributes:s,className:N}),contentEditable:!1,draggable:!1},{children:[l("div",Object.assign({className:j},{children:l("div",Object.assign({className:E},{children:l(n,{videoId:i.data.videoId})}))})),o]}))}return i.data.url||i.data["data-src"]?d("div",Object.assign({},e,{className:N,contentEditable:!1,draggable:!1},{children:[l("video",Object.assign({controls:!0,preload:"metadata",playsInline:!0,src:i.data.url||i.data["data-src"]||"",width:p,height:u,onDragStart:t=>t.preventDefault()},s,{className:t({element:i,HTMLAttributes:s,className:S})})),o]})):l("div",Object.assign({},e,{className:N,contentEditable:!1,draggable:!1},{children:o}))}},extendEditor(t){const{isVoid:e}=t;return t.isVoid=t=>t.type===Zt.getPlugin.type||e(t),t},events:{onKeyDown:(t,{defaultNode:e,hotkeys:i})=>o=>{var s;if("video"===n(t,null===(s=t.selection)||void 0===s?void 0:s.anchor.path,"highest").type&&t.selection)return console.log("hotkeys.isEnter(event)",i.isEnter(o)),i.isEnter(o)?(o.preventDefault(),void r.insertNodes(t,e,{mode:"highest"})):void 0}},defineElement:()=>({id:s(),type:"video",nodeType:"void",data:{url:null,size:{width:"auto",height:"auto"}},children:[{text:""}]}),createElement:(t,e)=>{var i;const o=Object.assign(Object.assign({},Zt.getPlugin.defineElement()),e);r.setNodes(t,o,{at:null===(i=t.selection)||void 0===i?void 0:i.anchor})},exports:{markdown:{serialize:(t,e)=>`<video preload controls src="${t.data.url}" height="${t.data.size.height}" width="${t.data.size.width}"></video>\n`},html:{serialize:t=>`<video preload controls src="${t.data.url}" height="${t.data.size.height}" width="${t.data.size.width}"></video>`,deserialize:{nodeName:"VIDEO",parse:t=>({url:t.getAttribute("src"),size:{height:"string"==typeof t.getAttribute("height")?Number(t.getAttribute("height")):"auto",width:"string"==typeof t.getAttribute("width")?Number(t.getAttribute("width")):"auto"}})}}},options:{searchString:"video media",displayLabel:"Video"}});export{Zt as default};