@wangeditor-next/video-module 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1205 +1,2 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@wangeditor-next/core'), require('slate'), require('snabbdom'), require('dom7'), require('nanoid')) :
3
- typeof define === 'function' && define.amd ? define(['@wangeditor-next/core', 'slate', 'snabbdom', 'dom7', 'nanoid'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.WangEditorVideoModule = factory(global.core, global.slate, global.snabbdom, global.$, global.nanoid));
5
- })(this, (function (core, slate, snabbdom, $, nanoid) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var $__default = /*#__PURE__*/_interopDefaultLegacy($);
10
-
11
- /**
12
- * @description i18n en
13
- * @author wangfupeng
14
- */
15
- var enResources = {
16
- videoModule: {
17
- delete: 'Delete',
18
- uploadVideo: 'Upload video',
19
- insertVideo: 'Insert video',
20
- videoSrc: 'Video source',
21
- videoSrcPlaceHolder: 'Video file url, or third-party <iframe>',
22
- videoPoster: 'Video poster',
23
- videoPosterPlaceHolder: 'Poster image url',
24
- ok: 'Ok',
25
- editSize: 'Edit size',
26
- edit: 'Edit video',
27
- width: 'Width',
28
- height: 'Height',
29
- },
30
- };
31
-
32
- /**
33
- * @description i18n zh-CN
34
- * @author wangfupeng
35
- */
36
- var zhResources = {
37
- videoModule: {
38
- delete: '删除视频',
39
- uploadVideo: '上传视频',
40
- insertVideo: '插入视频',
41
- videoSrc: '视频地址',
42
- videoSrcPlaceHolder: '视频文件 url 或第三方 <iframe>',
43
- videoPoster: '视频封面',
44
- videoPosterPlaceHolder: '封面图片 url',
45
- ok: '确定',
46
- editSize: '修改尺寸',
47
- edit: '编辑 视频',
48
- width: '宽度',
49
- height: '高度',
50
- },
51
- };
52
-
53
- /**
54
- * @description i18n entry
55
- * @author wangfupeng
56
- */
57
- core.i18nAddResources('en', enResources);
58
- core.i18nAddResources('zh-CN', zhResources);
59
-
60
- /*! *****************************************************************************
61
- Copyright (c) Microsoft Corporation.
62
-
63
- Permission to use, copy, modify, and/or distribute this software for any
64
- purpose with or without fee is hereby granted.
65
-
66
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
67
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
68
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
69
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72
- PERFORMANCE OF THIS SOFTWARE.
73
- ***************************************************************************** */
74
-
75
- var __assign = function() {
76
- __assign = Object.assign || function __assign(t) {
77
- for (var s, i = 1, n = arguments.length; i < n; i++) {
78
- s = arguments[i];
79
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
80
- }
81
- return t;
82
- };
83
- return __assign.apply(this, arguments);
84
- };
85
-
86
- function __awaiter(thisArg, _arguments, P, generator) {
87
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
88
- return new (P || (P = Promise))(function (resolve, reject) {
89
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
90
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
91
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92
- step((generator = generator.apply(thisArg, _arguments || [])).next());
93
- });
94
- }
95
-
96
- function __generator(thisArg, body) {
97
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
99
- function verb(n) { return function (v) { return step([n, v]); }; }
100
- function step(op) {
101
- if (f) throw new TypeError("Generator is already executing.");
102
- while (_) try {
103
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
104
- if (y = 0, t) op = [op[0] & 2, t.value];
105
- switch (op[0]) {
106
- case 0: case 1: t = op; break;
107
- case 4: _.label++; return { value: op[1], done: false };
108
- case 5: _.label++; y = op[1]; op = [0]; continue;
109
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
110
- default:
111
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
112
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
113
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
114
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
115
- if (t[2]) _.ops.pop();
116
- _.trys.pop(); continue;
117
- }
118
- op = body.call(thisArg, _);
119
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
120
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
121
- }
122
- }
123
-
124
- function __values(o) {
125
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
126
- if (m) return m.call(o);
127
- if (o && typeof o.length === "number") return {
128
- next: function () {
129
- if (o && i >= o.length) o = void 0;
130
- return { value: o && o[i++], done: !o };
131
- }
132
- };
133
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
134
- }
135
-
136
- function __read(o, n) {
137
- var m = typeof Symbol === "function" && o[Symbol.iterator];
138
- if (!m) return o;
139
- var i = m.call(o), r, ar = [], e;
140
- try {
141
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
142
- }
143
- catch (error) { e = { error: error }; }
144
- finally {
145
- try {
146
- if (r && !r.done && (m = i["return"])) m.call(i);
147
- }
148
- finally { if (e) throw e.error; }
149
- }
150
- return ar;
151
- }
152
-
153
- function __asyncValues(o) {
154
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
155
- var m = o[Symbol.asyncIterator], i;
156
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
157
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
158
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
159
- }
160
-
161
- /**
162
- * @description editor 插件,重写 editor API
163
- * @author wangfupeng
164
- */
165
- function withVideo(editor) {
166
- var isVoid = editor.isVoid, normalizeNode = editor.normalizeNode;
167
- var newEditor = editor;
168
- // 重写 isVoid
169
- newEditor.isVoid = function (elem) {
170
- var type = elem.type;
171
- if (type === 'video') {
172
- return true;
173
- }
174
- return isVoid(elem);
175
- };
176
- // 重写 normalizeNode
177
- newEditor.normalizeNode = function (_a) {
178
- var _b = __read(_a, 2), node = _b[0], path = _b[1];
179
- var type = core.DomEditor.getNodeType(node);
180
- // ----------------- video 后面必须跟一个 p header blockquote -----------------
181
- if (type === 'video') {
182
- // -------------- video 是 editor 最后一个节点,需要后面插入 p --------------
183
- var isLast = core.DomEditor.isLastNode(newEditor, node);
184
- if (isLast) {
185
- slate.Transforms.insertNodes(newEditor, core.DomEditor.genEmptyParagraph(), { at: [path[0] + 1] });
186
- }
187
- }
188
- // 执行默认的 normalizeNode ,重要!!!
189
- return normalizeNode([node, path]);
190
- };
191
- // 返回 editor ,重要!
192
- return newEditor;
193
- }
194
-
195
- /**
196
- * @description DOM 操作
197
- * @author wangfupeng
198
- */
199
- if ($.append)
200
- $__default["default"].fn.append = $.append;
201
- if ($.on)
202
- $__default["default"].fn.on = $.on;
203
- if ($.focus)
204
- $__default["default"].fn.focus = $.focus;
205
- if ($.attr)
206
- $__default["default"].fn.attr = $.attr;
207
- if ($.val)
208
- $__default["default"].fn.val = $.val;
209
- if ($.html)
210
- $__default["default"].fn.html = $.html;
211
- if ($.parent)
212
- $__default["default"].fn.parent = $.parent;
213
- if ($.hasClass)
214
- $__default["default"].fn.hasClass = $.hasClass;
215
- if ($.empty)
216
- $__default["default"].fn.empty = $.empty;
217
- /**
218
- * 获取 tagName lower-case
219
- * @param $elem $elem
220
- */
221
- function getTagName($elem) {
222
- if ($elem.length)
223
- return $elem[0].tagName.toLowerCase();
224
- return '';
225
- }
226
- /**
227
- * 生成带 size 样式的 iframe html
228
- * @param iframeHtml iframe html string
229
- * @param width width
230
- * @param height height
231
- * @returns iframe html string with size style
232
- */
233
- function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
234
- if (width === void 0) { width = 'auto'; }
235
- if (height === void 0) { height = 'auto'; }
236
- if (style === void 0) { style = {}; }
237
- var $iframe = $__default["default"](iframeHtml);
238
- var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
239
- var styleStr = '';
240
- if (styleWidth)
241
- styleStr += "width: " + styleWidth + ";";
242
- if (styleHeight)
243
- styleStr += "height: " + styleHeight + ";";
244
- $iframe.attr('width', width);
245
- $iframe.attr('height', height);
246
- $iframe.attr('style', styleStr);
247
- return $iframe[0].outerHTML;
248
- }
249
-
250
- /**
251
- * @description video render elem
252
- * @author wangfupeng
253
- */
254
- function renderVideo(elemNode, children, editor) {
255
- var _a = elemNode, _b = _a.src, src = _b === void 0 ? '' : _b, _c = _a.poster, poster = _c === void 0 ? '' : _c, _d = _a.key, key = _d === void 0 ? '' : _d, _e = _a.width, width = _e === void 0 ? 'auto' : _e, _f = _a.height, height = _f === void 0 ? 'auto' : _f, _g = _a.style, style = _g === void 0 ? {} : _g, _h = _a.textAlign, textAlign = _h === void 0 ? 'center' : _h;
256
- // 是否选中
257
- var selected = core.DomEditor.isNodeSelected(editor, elemNode);
258
- var vnode;
259
- if (src.trim().indexOf('<iframe ') === 0) {
260
- // 增加尺寸样式
261
- var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
262
- // iframe 形式,第三方视频
263
- vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', style: { textAlign: textAlign }, innerHTML: iframeHtml }));
264
- }
265
- else {
266
- // 其他,mp4 格式
267
- var videoVnode = (snabbdom.jsx("video", { key: key, poster: poster, controls: true, style: style },
268
- snabbdom.jsx("source", { src: src, type: "video/mp4" }), "Sorry, your browser doesn't support embedded videos.\n \u62B1\u6B49\uFF0C\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 video \u89C6\u9891"));
269
- // @ts-ignore 添加尺寸
270
- if (width !== 'auto')
271
- videoVnode.data.width = width;
272
- // @ts-ignore
273
- if (height !== 'auto')
274
- videoVnode.data.height = height;
275
- vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', style: { textAlign: textAlign } }, videoVnode));
276
- }
277
- // 【注意】void node 中,renderElem 不用处理 children 。core 会统一处理。
278
- var containerVnode = snabbdom.h('div', {
279
- props: {
280
- contentEditable: false,
281
- },
282
- on: {
283
- mousedown: function (e) { return e.preventDefault(); },
284
- },
285
- }, vnode);
286
- return containerVnode;
287
- }
288
- var renderVideoConf = {
289
- type: 'video',
290
- renderElem: renderVideo,
291
- };
292
-
293
- /**
294
- * @description to html
295
- * @author wangfupeng
296
- */
297
- function videoToHtml(elemNode, childrenHtml) {
298
- var _a = elemNode, _b = _a.src, src = _b === void 0 ? '' : _b, _c = _a.poster, poster = _c === void 0 ? '' : _c, _d = _a.width, width = _d === void 0 ? 'auto' : _d, _e = _a.height, height = _e === void 0 ? 'auto' : _e, _f = _a.style, style = _f === void 0 ? {} : _f, _g = _a.textAlign, textAlign = _g === void 0 ? 'center' : _g;
299
- var res = "<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: " + textAlign + ";\">\n";
300
- if (src.trim().indexOf('<iframe ') === 0) {
301
- // iframe 形式
302
- var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
303
- res += iframeHtml;
304
- }
305
- else {
306
- // 其他,mp4 等 url 格式
307
- var _h = style.width, styleWidth = _h === void 0 ? '' : _h, _j = style.height, styleHeight = _j === void 0 ? '' : _j;
308
- var styleStr = '';
309
- if (styleWidth)
310
- styleStr += "width: " + styleWidth + ";";
311
- if (styleHeight)
312
- styleStr += "height: " + styleHeight + ";";
313
- res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
314
- }
315
- res += '\n</div>';
316
- return res;
317
- }
318
- var videoToHtmlConf = {
319
- type: 'video',
320
- elemToHtml: videoToHtml,
321
- };
322
-
323
- /**
324
- * @description pre parse html
325
- * @author wangfupeng
326
- */
327
- /**
328
- * pre-prase video ,兼容 V4
329
- * @param elem elem
330
- */
331
- function preParse(elem) {
332
- var $elem = $__default["default"](elem);
333
- var $video = $elem;
334
- var elemTagName = getTagName($elem);
335
- if (elemTagName === 'p') {
336
- // v4 的 video 或 iframe 是被 p 包裹的
337
- var children = $elem.children();
338
- if (children.length === 1) {
339
- var firstChild = children[0];
340
- var firstChildTagName = firstChild.tagName.toLowerCase();
341
- if (['iframe', 'video'].includes(firstChildTagName)) {
342
- // p 下面包含 iframe 或 video
343
- $video = $__default["default"](firstChild);
344
- }
345
- }
346
- }
347
- var videoTagName = getTagName($video);
348
- if (videoTagName !== 'iframe' && videoTagName !== 'video')
349
- return $video[0];
350
- // 已经符合 V5 格式
351
- var $parent = $video.parent();
352
- if ($parent.attr('data-w-e-type') === 'video')
353
- return $video[0];
354
- var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
355
- $container.append($video);
356
- return $container[0];
357
- }
358
- var preParseHtmlConf = {
359
- selector: 'iframe,video,p',
360
- preParseHtml: preParse,
361
- };
362
-
363
- /**
364
- * @description parse html
365
- * @author wangfupeng
366
- */
367
- function genVideoElem(src, poster, width, height, style) {
368
- if (poster === void 0) { poster = ''; }
369
- if (width === void 0) { width = 'auto'; }
370
- if (height === void 0) { height = 'auto'; }
371
- if (style === void 0) { style = {}; }
372
- return {
373
- type: 'video',
374
- src: src,
375
- poster: poster,
376
- width: width,
377
- height: height,
378
- style: style,
379
- children: [{ text: '' }], // void 元素有一个空 text
380
- };
381
- }
382
- function parseHtml(elem, children, editor) {
383
- var $elem = $__default["default"](elem);
384
- var src = '';
385
- var poster = '';
386
- var width = 'auto';
387
- var height = 'auto';
388
- var style = {};
389
- // <iframe> 形式
390
- var $iframe = $elem.find('iframe');
391
- if ($iframe.length > 0) {
392
- width = $iframe.attr('width') || 'auto';
393
- height = $iframe.attr('height') || 'auto';
394
- style = $iframe.attr('style') || {};
395
- src = $iframe[0].outerHTML;
396
- return genVideoElem(src, poster, width, height, style);
397
- }
398
- // <video> 形式
399
- var $video = $elem.find('video');
400
- src = $video.attr('src') || '';
401
- if (!src) {
402
- if ($video.length > 0) {
403
- var $source = $video.find('source');
404
- src = $source.attr('src') || '';
405
- }
406
- }
407
- width = $video.attr('width') || 'auto';
408
- height = $video.attr('height') || 'auto';
409
- poster = $video.attr('poster') || '';
410
- style = $iframe.attr('style') || {};
411
- return genVideoElem(src, poster, width, height, style);
412
- }
413
- var parseHtmlConf = {
414
- selector: 'div[data-w-e-type="video"]',
415
- parseElemHtml: parseHtml,
416
- };
417
-
418
- /**
419
- * @description 工具函数
420
- * @author wangfupeng
421
- */
422
- /**
423
- * 获取随机数字符串
424
- * @param prefix 前缀
425
- * @returns 随机数字符串
426
- */
427
- function genRandomStr(prefix) {
428
- if (prefix === void 0) { prefix = 'r'; }
429
- return prefix + "-" + nanoid.nanoid();
430
- }
431
- function replaceSymbols(str) {
432
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
433
- }
434
-
435
- /**
436
- * @description icon svg
437
- * @author wangfupeng
438
- */
439
- /**
440
- * 【注意】svg 字符串的长度 ,否则会导致代码体积过大
441
- * 尽量选择 https://www.iconfont.cn/collections/detail?spm=a313x.7781069.0.da5a778a4&cid=20293
442
- * 找不到再从 iconfont.com 搜索
443
- */
444
- // 视频
445
- var VIDEO_SVG = '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>';
446
- // 上传视频
447
- var UPLOAD_VIDEO_SVG = '<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z" p-id="6802"></path><path d="M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z"></path></svg>';
448
- // 编辑
449
- var PENCIL_SVG = '<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>';
450
- // // 垃圾桶(删除)
451
- // export const TRASH_SVG =
452
- // '<svg viewBox="0 0 1024 1024"><path d="M826.8032 356.5312c-19.328 0-36.3776 15.6928-36.3776 35.0464v524.2624c0 19.328-16 34.56-35.328 34.56H264.9344c-19.328 0-35.5072-15.3088-35.5072-34.56V390.0416c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.6928-33.5104 35.0464V915.712c0 57.9328 44.6208 108.288 102.528 108.288H755.2c57.9328 0 108.0832-50.4576 108.0832-108.288V391.4752c-0.1024-19.2512-17.1264-34.944-36.48-34.944z" p-id="9577"></path><path d="M437.1712 775.7568V390.6048c0-19.328-14.1568-35.0464-33.5104-35.0464s-33.5104 15.616-33.5104 35.0464v385.152c0 19.328 14.1568 35.0464 33.5104 35.0464s33.5104-15.7184 33.5104-35.0464zM649.7024 775.7568V390.6048c0-19.328-17.0496-35.0464-36.3776-35.0464s-36.3776 15.616-36.3776 35.0464v385.152c0 19.328 17.0496 35.0464 36.3776 35.0464s36.3776-15.7184 36.3776-35.0464zM965.0432 217.0368h-174.6176V145.5104c0-57.9328-47.2064-101.76-104.6528-101.76h-350.976c-57.8304 0-105.3952 43.8528-105.3952 101.76v71.5264H54.784c-19.4304 0-35.0464 14.1568-35.0464 33.5104 0 19.328 15.616 33.5104 35.0464 33.5104h910.3616c19.328 0 35.0464-14.1568 35.0464-33.5104 0-19.3536-15.6928-33.5104-35.1488-33.5104z m-247.3728 0H297.3952V145.5104c0-19.328 18.2016-34.7648 37.4272-34.7648h350.976c19.1488 0 31.872 15.1296 31.872 34.7648v71.5264z"></path></svg>'
453
-
454
- /**
455
- * @description insert video
456
- * @author wangfupeng
457
- */
458
- /**
459
- * 插入视频
460
- * @param editor editor
461
- * @param src video src
462
- * @param poster video poster
463
- */
464
- function insertVideo (editor, src, poster, width, height) {
465
- if (poster === void 0) { poster = ''; }
466
- if (width === void 0) { width = ''; }
467
- if (height === void 0) { height = ''; }
468
- return __awaiter(this, void 0, void 0, function () {
469
- var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
470
- return __generator(this, function (_b) {
471
- switch (_b.label) {
472
- case 0:
473
- if (!src)
474
- return [2 /*return*/];
475
- // 还原选区
476
- editor.restoreSelection();
477
- _a = editor.getMenuConfig('insertVideo'), onInsertedVideo = _a.onInsertedVideo, checkVideo = _a.checkVideo, parseVideoSrc = _a.parseVideoSrc;
478
- return [4 /*yield*/, checkVideo(src, poster)];
479
- case 1:
480
- checkRes = _b.sent();
481
- if (typeof checkRes === 'string') {
482
- // 校验失败,给出提示
483
- editor.alert(checkRes, 'error');
484
- return [2 /*return*/];
485
- }
486
- if (checkRes == null) {
487
- // 校验失败,不给提示
488
- return [2 /*return*/];
489
- }
490
- return [4 /*yield*/, parseVideoSrc(src)];
491
- case 2:
492
- parsedSrc = _b.sent();
493
- if (parsedSrc.trim().indexOf('<iframe ') !== 0) {
494
- parsedSrc = replaceSymbols(parsedSrc);
495
- }
496
- video = {
497
- type: 'video',
498
- src: parsedSrc,
499
- poster: poster,
500
- children: [{ text: '' }],
501
- style: {
502
- width: width,
503
- height: height,
504
- },
505
- };
506
- // 插入视频
507
- // 不使用此方式会比正常的选区选取先执行
508
- Promise.resolve().then(function () {
509
- slate.Transforms.insertNodes(editor, video);
510
- });
511
- // 调用 callback
512
- onInsertedVideo(video);
513
- return [2 /*return*/];
514
- }
515
- });
516
- });
517
- }
518
-
519
- /**
520
- * @description insert video menu
521
- * @author wangfupeng
522
- */
523
- /**
524
- * 生成唯一的 DOM ID
525
- */
526
- function genDomID$2() {
527
- return genRandomStr('w-e-insert-video');
528
- }
529
- var InsertVideoMenu = /** @class */ (function () {
530
- function InsertVideoMenu() {
531
- this.title = core.t('videoModule.insertVideo');
532
- this.iconSvg = VIDEO_SVG;
533
- this.tag = 'button';
534
- this.showModal = true; // 点击 button 时显示 modal
535
- this.modalWidth = 320;
536
- this.$content = null;
537
- this.srcInputId = genDomID$2();
538
- this.posterInputId = genDomID$2();
539
- this.buttonId = genDomID$2();
540
- }
541
- InsertVideoMenu.prototype.getValue = function (editor) {
542
- // 插入菜单,不需要 value
543
- return '';
544
- };
545
- InsertVideoMenu.prototype.isActive = function (editor) {
546
- // 任何时候,都不用激活 menu
547
- return false;
548
- };
549
- InsertVideoMenu.prototype.exec = function (editor, value) {
550
- // 点击菜单时,弹出 modal 之前,不需要执行其他代码
551
- // 此处空着即可
552
- };
553
- InsertVideoMenu.prototype.isDisabled = function (editor) {
554
- var selection = editor.selection;
555
- if (selection == null)
556
- return true;
557
- if (!slate.Range.isCollapsed(selection))
558
- return true; // 选区非折叠,禁用
559
- var selectedElems = core.DomEditor.getSelectedElems(editor);
560
- var hasVoidOrPre = selectedElems.some(function (elem) {
561
- var type = core.DomEditor.getNodeType(elem);
562
- if (type === 'pre')
563
- return true;
564
- if (type === 'list-item')
565
- return true;
566
- if (editor.isVoid(elem))
567
- return true;
568
- return false;
569
- });
570
- if (hasVoidOrPre)
571
- return true; // void 或 pre ,禁用
572
- return false;
573
- };
574
- InsertVideoMenu.prototype.getModalPositionNode = function (editor) {
575
- return null; // modal 依据选区定位
576
- };
577
- InsertVideoMenu.prototype.getModalContentElem = function (editor) {
578
- var _this = this;
579
- var _a = this, srcInputId = _a.srcInputId, posterInputId = _a.posterInputId, buttonId = _a.buttonId;
580
- // 获取 input button elem
581
- var _b = __read(core.genModalInputElems(core.t('videoModule.videoSrc'), srcInputId, core.t('videoModule.videoSrcPlaceHolder')), 2), srcContainerElem = _b[0], inputSrcElem = _b[1];
582
- var _c = __read(core.genModalInputElems(core.t('videoModule.videoPoster'), posterInputId, core.t('videoModule.videoPosterPlaceHolder')), 2), posterContainerElem = _c[0], inputPosterElem = _c[1];
583
- var $inputSrc = $__default["default"](inputSrcElem);
584
- var $inputPoster = $__default["default"](inputPosterElem);
585
- var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
586
- if (this.$content == null) {
587
- // 第一次渲染
588
- var $content_1 = $__default["default"]('<div></div>');
589
- // 绑定事件(第一次渲染时绑定,不要重复绑定)
590
- $content_1.on('click', "#" + buttonId, function (e) { return __awaiter(_this, void 0, void 0, function () {
591
- var src, poster;
592
- return __generator(this, function (_a) {
593
- switch (_a.label) {
594
- case 0:
595
- e.preventDefault();
596
- src = $content_1.find("#" + srcInputId).val().trim();
597
- poster = $content_1.find("#" + posterInputId).val().trim();
598
- return [4 /*yield*/, insertVideo(editor, src, poster)];
599
- case 1:
600
- _a.sent();
601
- editor.hidePanelOrModal(); // 隐藏 modal
602
- return [2 /*return*/];
603
- }
604
- });
605
- }); });
606
- // 记录属性,重要
607
- this.$content = $content_1;
608
- }
609
- var $content = this.$content;
610
- $content.empty(); // 先清空内容
611
- // append inputs and button
612
- $content.append(srcContainerElem);
613
- $content.append(posterContainerElem);
614
- $content.append(buttonContainerElem);
615
- // 设置 input val
616
- $inputSrc.val('');
617
- $inputPoster.val('');
618
- // focus 一个 input(异步,此时 DOM 尚未渲染)
619
- setTimeout(function () {
620
- $inputSrc.focus();
621
- });
622
- return $content[0];
623
- };
624
- return InsertVideoMenu;
625
- }());
626
-
627
- /**
628
- * @description upload video
629
- * @author wangfupeng
630
- */
631
- function getMenuConfig(editor) {
632
- // 获取配置,见 `./config.js`
633
- return editor.getMenuConfig('uploadVideo');
634
- }
635
- // 存储 editor uppy 的关系 - 缓存 uppy ,不重复创建
636
- var EDITOR_TO_UPPY_MAP = new WeakMap();
637
- /**
638
- * 获取 uppy 实例(并通过 editor 缓存)
639
- * @param editor editor
640
- */
641
- function getUppy(editor) {
642
- // 从缓存中获取
643
- var uppy = EDITOR_TO_UPPY_MAP.get(editor);
644
- if (uppy != null)
645
- return uppy;
646
- var menuConfig = getMenuConfig(editor);
647
- var onSuccess = menuConfig.onSuccess, onProgress = menuConfig.onProgress, onFailed = menuConfig.onFailed, customInsert = menuConfig.customInsert, onError = menuConfig.onError;
648
- // 上传完成之后
649
- var successHandler = function (file, res) {
650
- // 预期 res 格式:
651
- // 成功:{ errno: 0, data: { url, poster } }
652
- // 失败:{ errno: !0, message: '失败信息' }
653
- if (customInsert) {
654
- // 用户自定义插入视频,此时 res 格式可能不符合预期
655
- customInsert(res, function (src, poster) { return insertVideo(editor, src, poster); });
656
- // success 回调
657
- onSuccess(file, res);
658
- return;
659
- }
660
- var _a = res.errno, errno = _a === void 0 ? 1 : _a, _b = res.data, data = _b === void 0 ? {} : _b;
661
- if (errno !== 0) {
662
- // failed 回调
663
- onFailed(file, res);
664
- return;
665
- }
666
- var _c = data.url, url = _c === void 0 ? '' : _c, _d = data.poster, poster = _d === void 0 ? '' : _d;
667
- insertVideo(editor, url, poster);
668
- // success 回调
669
- onSuccess(file, res);
670
- };
671
- // progress 显示进度条
672
- var progressHandler = function (progress) {
673
- editor.showProgressBar(progress);
674
- // 回调函数
675
- onProgress && onProgress(progress);
676
- };
677
- // onError 提示错误
678
- var errorHandler = function (file, err, res) {
679
- onError(file, err, res);
680
- };
681
- // 创建 uppy
682
- uppy = core.createUploader(__assign(__assign({}, menuConfig), { onProgress: progressHandler, onSuccess: successHandler, onError: errorHandler }));
683
- // 缓存 uppy
684
- EDITOR_TO_UPPY_MAP.set(editor, uppy);
685
- return uppy;
686
- }
687
- /**
688
- * 上传视频文件
689
- * @param editor editor
690
- * @param file file
691
- */
692
- function uploadFile(editor, file) {
693
- return __awaiter(this, void 0, void 0, function () {
694
- var uppy, name, type, size;
695
- return __generator(this, function (_a) {
696
- switch (_a.label) {
697
- case 0:
698
- uppy = getUppy(editor);
699
- name = file.name, type = file.type, size = file.size;
700
- uppy.addFile({
701
- name: name,
702
- type: type,
703
- size: size,
704
- data: file,
705
- });
706
- return [4 /*yield*/, uppy.upload()];
707
- case 1:
708
- _a.sent();
709
- return [2 /*return*/];
710
- }
711
- });
712
- });
713
- }
714
- function uploadVideos (editor, files) {
715
- var e_1, _a;
716
- return __awaiter(this, void 0, void 0, function () {
717
- var fileList, customUpload, fileList_1, fileList_1_1, file, e_1_1;
718
- return __generator(this, function (_b) {
719
- switch (_b.label) {
720
- case 0:
721
- if (files == null)
722
- return [2 /*return*/];
723
- fileList = Array.prototype.slice.call(files);
724
- customUpload = getMenuConfig(editor).customUpload;
725
- _b.label = 1;
726
- case 1:
727
- _b.trys.push([1, 9, 10, 15]);
728
- fileList_1 = __asyncValues(fileList);
729
- _b.label = 2;
730
- case 2: return [4 /*yield*/, fileList_1.next()];
731
- case 3:
732
- if (!(fileList_1_1 = _b.sent(), !fileList_1_1.done)) return [3 /*break*/, 8];
733
- file = fileList_1_1.value;
734
- if (!customUpload) return [3 /*break*/, 5];
735
- // 自定义上传
736
- return [4 /*yield*/, customUpload(file, function (src, poster) { return insertVideo(editor, src, poster); })];
737
- case 4:
738
- // 自定义上传
739
- _b.sent();
740
- return [3 /*break*/, 7];
741
- case 5:
742
- // 默认上传
743
- return [4 /*yield*/, uploadFile(editor, file)];
744
- case 6:
745
- // 默认上传
746
- _b.sent();
747
- _b.label = 7;
748
- case 7: return [3 /*break*/, 2];
749
- case 8: return [3 /*break*/, 15];
750
- case 9:
751
- e_1_1 = _b.sent();
752
- e_1 = { error: e_1_1 };
753
- return [3 /*break*/, 15];
754
- case 10:
755
- _b.trys.push([10, , 13, 14]);
756
- if (!(fileList_1_1 && !fileList_1_1.done && (_a = fileList_1.return))) return [3 /*break*/, 12];
757
- return [4 /*yield*/, _a.call(fileList_1)];
758
- case 11:
759
- _b.sent();
760
- _b.label = 12;
761
- case 12: return [3 /*break*/, 14];
762
- case 13:
763
- if (e_1) throw e_1.error;
764
- return [7 /*endfinally*/];
765
- case 14: return [7 /*endfinally*/];
766
- case 15: return [2 /*return*/];
767
- }
768
- });
769
- });
770
- }
771
-
772
- /**
773
- * @description upload video menu
774
- * @author wangfupeng
775
- */
776
- var UploadVideoMenu = /** @class */ (function () {
777
- function UploadVideoMenu() {
778
- this.title = core.t('videoModule.uploadVideo');
779
- this.iconSvg = UPLOAD_VIDEO_SVG;
780
- this.tag = 'button';
781
- }
782
- UploadVideoMenu.prototype.getValue = function (editor) {
783
- // 无需获取 val
784
- return '';
785
- };
786
- UploadVideoMenu.prototype.isActive = function (editor) {
787
- // 任何时候,都不用激活 menu
788
- return false;
789
- };
790
- UploadVideoMenu.prototype.exec = function (editor, value) {
791
- var _a = this.getMenuConfig(editor), _b = _a.allowedFileTypes, allowedFileTypes = _b === void 0 ? [] : _b, customBrowseAndUpload = _a.customBrowseAndUpload;
792
- // 自定义选择图片,并上传,如图床
793
- if (customBrowseAndUpload) {
794
- customBrowseAndUpload(function (src, poster) { return insertVideo(editor, src, poster); });
795
- return;
796
- }
797
- // 设置选择文件的类型
798
- var acceptAttr = '';
799
- if (allowedFileTypes.length > 0) {
800
- acceptAttr = "accept=\"" + allowedFileTypes.join(', ') + "\"";
801
- }
802
- // 添加 file input(每次重新创建 input)
803
- var $body = $__default["default"]('body');
804
- var $inputFile = $__default["default"]("<input type=\"file\" " + acceptAttr + " multiple/>");
805
- $inputFile.hide();
806
- $body.append($inputFile);
807
- $inputFile.click();
808
- // 选中文件
809
- $inputFile.on('change', function () {
810
- var files = $inputFile[0].files;
811
- uploadVideos(editor, files); // 上传文件
812
- });
813
- };
814
- UploadVideoMenu.prototype.isDisabled = function (editor) {
815
- var selection = editor.selection;
816
- if (selection == null)
817
- return true;
818
- if (!slate.Range.isCollapsed(selection))
819
- return true; // 选区非折叠,禁用
820
- var selectedElems = core.DomEditor.getSelectedElems(editor);
821
- var hasVoidOrPre = selectedElems.some(function (elem) {
822
- var type = core.DomEditor.getNodeType(elem);
823
- if (type === 'pre')
824
- return true;
825
- if (type === 'list-item')
826
- return true;
827
- if (editor.isVoid(elem))
828
- return true;
829
- return false;
830
- });
831
- if (hasVoidOrPre)
832
- return true; // void 或 pre ,禁用
833
- return false;
834
- };
835
- UploadVideoMenu.prototype.getMenuConfig = function (editor) {
836
- // 获取配置,见 `./config.js`
837
- return editor.getMenuConfig('uploadVideo');
838
- };
839
- return UploadVideoMenu;
840
- }());
841
-
842
- /**
843
- * @description 修改视频尺寸
844
- * @author wangfupeng
845
- */
846
- /**
847
- * 生成唯一的 DOM ID
848
- */
849
- function genDomID$1() {
850
- return genRandomStr('w-e-insert-video');
851
- }
852
- var EditorVideoSizeMenu = /** @class */ (function () {
853
- function EditorVideoSizeMenu() {
854
- this.title = core.t('videoModule.editSize');
855
- this.tag = 'button';
856
- this.showModal = true; // 点击 button 时显示 modal
857
- this.modalWidth = 320;
858
- this.$content = null;
859
- this.widthInputId = genDomID$1();
860
- this.heightInputId = genDomID$1();
861
- this.buttonId = genDomID$1();
862
- }
863
- EditorVideoSizeMenu.prototype.getSelectedVideoNode = function (editor) {
864
- return core.DomEditor.getSelectedNodeByType(editor, 'video');
865
- };
866
- EditorVideoSizeMenu.prototype.getValue = function (editor) {
867
- // 插入菜单,不需要 value
868
- return '';
869
- };
870
- EditorVideoSizeMenu.prototype.isActive = function (editor) {
871
- // 任何时候,都不用激活 menu
872
- return false;
873
- };
874
- EditorVideoSizeMenu.prototype.exec = function (editor, value) {
875
- // 点击菜单时,弹出 modal 之前,不需要执行其他代码
876
- // 此处空着即可
877
- };
878
- EditorVideoSizeMenu.prototype.isDisabled = function (editor) {
879
- if (editor.selection == null)
880
- return true;
881
- var videoNode = this.getSelectedVideoNode(editor);
882
- if (videoNode == null) {
883
- // 选区未处于 video node ,则禁用
884
- return true;
885
- }
886
- return false;
887
- };
888
- EditorVideoSizeMenu.prototype.getModalPositionNode = function (editor) {
889
- return this.getSelectedVideoNode(editor);
890
- };
891
- EditorVideoSizeMenu.prototype.getModalContentElem = function (editor) {
892
- var _a = this, widthInputId = _a.widthInputId, heightInputId = _a.heightInputId, buttonId = _a.buttonId;
893
- var _b = __read(core.genModalInputElems(core.t('videoModule.width'), widthInputId, 'auto'), 2), widthContainerElem = _b[0], inputWidthElem = _b[1];
894
- var $inputWidth = $__default["default"](inputWidthElem);
895
- var _c = __read(core.genModalInputElems(core.t('videoModule.height'), heightInputId, 'auto'), 2), heightContainerElem = _c[0], inputHeightElem = _c[1];
896
- var $inputHeight = $__default["default"](inputHeightElem);
897
- var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
898
- if (this.$content == null) {
899
- // 第一次渲染
900
- var $content_1 = $__default["default"]('<div></div>');
901
- // 绑定事件(第一次渲染时绑定,不要重复绑定)
902
- $content_1.on('click', "#" + buttonId, function (e) {
903
- e.preventDefault();
904
- var rawWidth = $content_1.find("#" + widthInputId).val().trim();
905
- var rawHeight = $content_1.find("#" + heightInputId).val().trim();
906
- var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
907
- var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
908
- var width = 'auto';
909
- var height = 'auto';
910
- if (isPercentage(rawWidth)) {
911
- width = rawWidth;
912
- }
913
- else if (isNumeric(rawWidth)) {
914
- width = parseInt(rawWidth) + 'px';
915
- }
916
- if (isPercentage(rawHeight)) {
917
- height = rawHeight;
918
- }
919
- else if (isNumeric(rawHeight)) {
920
- height = parseInt(rawHeight) + 'px';
921
- }
922
- var _a = videoNode.style, style = _a === void 0 ? {} : _a;
923
- editor.restoreSelection();
924
- var props = __assign(__assign({}, style), { style: {
925
- width: width,
926
- height: height,
927
- } });
928
- // 修改尺寸
929
- slate.Transforms.setNodes(editor, props, {
930
- match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
931
- });
932
- editor.hidePanelOrModal(); // 隐藏 modal
933
- });
934
- this.$content = $content_1;
935
- }
936
- var $content = this.$content;
937
- // 先清空,再重新添加 DOM 内容
938
- $content.empty();
939
- $content.append(widthContainerElem);
940
- $content.append(heightContainerElem);
941
- $content.append(buttonContainerElem);
942
- var videoNode = this.getSelectedVideoNode(editor);
943
- if (videoNode == null)
944
- return $content[0];
945
- // 初始化 input 值
946
- var _e = videoNode.style, style = _e === void 0 ? {} : _e;
947
- var _f = style.width, width = _f === void 0 ? '' : _f, _g = style.height, height = _g === void 0 ? '' : _g;
948
- $inputWidth.val(width);
949
- $inputHeight.val(height);
950
- setTimeout(function () {
951
- $inputWidth.focus();
952
- });
953
- return $content[0];
954
- };
955
- return EditorVideoSizeMenu;
956
- }());
957
-
958
- /**
959
- * @description editor video menu
960
- * @author
961
- */
962
- /**
963
- * 生成唯一的 DOM ID
964
- */
965
- function genDomID() {
966
- return genRandomStr('w-e-edit-video');
967
- }
968
- var Editvideo = /** @class */ (function () {
969
- function Editvideo() {
970
- this.title = core.t('videoModule.edit');
971
- this.iconSvg = PENCIL_SVG;
972
- this.tag = 'button';
973
- this.showModal = true; // 点击 button 时显示 modal
974
- this.modalWidth = 300;
975
- this.$content = null;
976
- this.srcInputId = genDomID();
977
- this.posterInputId = genDomID();
978
- this.buttonId = genDomID();
979
- }
980
- Editvideo.prototype.getSelectedVideoNode = function (editor) {
981
- return core.DomEditor.getSelectedNodeByType(editor, 'video');
982
- };
983
- Editvideo.prototype.getValue = function (editor) {
984
- // 编辑视频,用不到 getValue
985
- return '';
986
- };
987
- Editvideo.prototype.isActive = function (editor) {
988
- // 无需 active
989
- return false;
990
- };
991
- Editvideo.prototype.exec = function (editor, value) {
992
- // 点击菜单时,弹出 modal 之前,不需要执行其他代码
993
- // 此处空着即可
994
- };
995
- Editvideo.prototype.isDisabled = function (editor) {
996
- if (editor.selection == null)
997
- return true;
998
- var videoNode = this.getSelectedVideoNode(editor);
999
- if (videoNode == null) {
1000
- // 选区未处于 video node ,则禁用
1001
- return true;
1002
- }
1003
- return false;
1004
- };
1005
- Editvideo.prototype.getModalPositionNode = function (editor) {
1006
- return this.getSelectedVideoNode(editor);
1007
- };
1008
- Editvideo.prototype.getModalContentElem = function (editor) {
1009
- var _this = this;
1010
- var _a = this, srcInputId = _a.srcInputId, posterInputId = _a.posterInputId, buttonId = _a.buttonId;
1011
- // 获取 input button elem
1012
- var _b = __read(core.genModalInputElems(core.t('videoModule.videoSrc'), srcInputId, core.t('videoModule.videoSrcPlaceHolder')), 2), srcContainerElem = _b[0], inputSrcElem = _b[1];
1013
- var _c = __read(core.genModalInputElems(core.t('videoModule.videoPoster'), posterInputId, core.t('videoModule.videoPosterPlaceHolder')), 2), posterContainerElem = _c[0], inputPosterElem = _c[1];
1014
- var $inputSrc = $__default["default"](inputSrcElem);
1015
- var $inputPoster = $__default["default"](inputPosterElem);
1016
- var _d = __read(core.genModalButtonElems(buttonId, core.t('videoModule.ok')), 1), buttonContainerElem = _d[0];
1017
- if (this.$content == null) {
1018
- // 第一次渲染
1019
- var $content_1 = $__default["default"]('<div></div>');
1020
- // 绑定事件(第一次渲染时绑定,不要重复绑定)
1021
- $content_1.on('click', "#" + buttonId, function (e) { return __awaiter(_this, void 0, void 0, function () {
1022
- var src, poster, videoId, props;
1023
- return __generator(this, function (_a) {
1024
- e.preventDefault();
1025
- src = $content_1.find("#" + srcInputId).val().trim();
1026
- poster = $content_1.find("#" + posterInputId).val().trim();
1027
- videoId = genRandomStr('video-');
1028
- props = {
1029
- src: src,
1030
- poster: poster,
1031
- key: videoId,
1032
- };
1033
- editor.restoreSelection();
1034
- // 修改尺寸
1035
- slate.Transforms.setNodes(editor, props, {
1036
- match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
1037
- });
1038
- editor.hidePanelOrModal(); // 隐藏 modal
1039
- return [2 /*return*/];
1040
- });
1041
- }); });
1042
- // 记录属性,重要
1043
- this.$content = $content_1;
1044
- }
1045
- var $content = this.$content;
1046
- $content.empty(); // 先清空内容
1047
- // append inputs and button
1048
- $content.append(srcContainerElem);
1049
- $content.append(posterContainerElem);
1050
- $content.append(buttonContainerElem);
1051
- var videoNode = this.getSelectedVideoNode(editor);
1052
- if (videoNode == null)
1053
- return $content[0];
1054
- // 初始化 input 值
1055
- var _e = videoNode.src, src = _e === void 0 ? '' : _e, _f = videoNode.poster, poster = _f === void 0 ? '' : _f;
1056
- $inputSrc.val(src);
1057
- $inputPoster.val(poster);
1058
- // focus 一个 input(异步,此时 DOM 尚未渲染)
1059
- setTimeout(function () {
1060
- $inputSrc.focus();
1061
- });
1062
- return $content[0];
1063
- };
1064
- return Editvideo;
1065
- }());
1066
-
1067
- /**
1068
- * @description video menu config
1069
- * @author wangfupeng
1070
- */
1071
- function genUploadVideoMenuConfig() {
1072
- return {
1073
- server: '',
1074
- fieldName: 'wangeditor-uploaded-video',
1075
- maxFileSize: 10 * 1024 * 1024,
1076
- maxNumberOfFiles: 5,
1077
- allowedFileTypes: ['video/*'],
1078
- meta: {
1079
- // 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。
1080
- // 例如:token: 'xxxxx', x: 100
1081
- },
1082
- metaWithUrl: false,
1083
- // headers: {
1084
- // // 自定义 http headers
1085
- // // 例如:Accept: 'text/x-json', a: 100,
1086
- // },
1087
- withCredentials: false,
1088
- timeout: 30 * 1000,
1089
- onBeforeUpload: function (files) { return files; },
1090
- onProgress: function (progress) {
1091
- /* on progress */
1092
- },
1093
- onSuccess: function (file, res) {
1094
- /* on success */
1095
- },
1096
- onFailed: function (file, res) {
1097
- /* on failed */
1098
- console.error("'" + file.name + "' upload failed", res);
1099
- },
1100
- onError: function (file, err, res) {
1101
- /* on error */
1102
- /* on timeout */
1103
- console.error("'" + file.name + " upload error", err, res);
1104
- },
1105
- // 自定义插入视频,用户配置
1106
- // customInsert: (res, insertFn) => {},
1107
- // 自定义上传视频,用户配置
1108
- // customUpload: (file, insertFn) => {},
1109
- // 自定义选择,并上传视频,如:图床 (用户配置)
1110
- // customBrowseAndUpload: insertFn => {},
1111
- };
1112
- }
1113
- /**
1114
- * 生成插入网络视频的配置
1115
- */
1116
- function genInsertVideoMenuConfig() {
1117
- return {
1118
- onInsertedVideo: function (node) {
1119
- // 插入视频之后的 callback
1120
- },
1121
- /**
1122
- * 检查 video ,支持 async
1123
- * @param src src
1124
- * @param poster poster
1125
- */
1126
- checkVideo: function (src, poster) {
1127
- // 1. 返回 true ,说明检查通过
1128
- // 2. 返回一个字符串,说明检查未通过,编辑器会阻止插入。会 alert 出错误信息(即返回的字符串)
1129
- // 3. 返回 undefined(即没有任何返回),说明检查未通过,编辑器会阻止插入
1130
- return true;
1131
- },
1132
- /**
1133
- * 转换 video src
1134
- * @param src src
1135
- * @returns new src
1136
- */
1137
- parseVideoSrc: function (src) {
1138
- return src;
1139
- },
1140
- };
1141
- }
1142
-
1143
- /**
1144
- * @description video menu
1145
- * @author wangfupeng
1146
- */
1147
- var insertVideoMenuConf = {
1148
- key: 'insertVideo',
1149
- factory: function () {
1150
- return new InsertVideoMenu();
1151
- },
1152
- // 默认的菜单菜单配置,将存储在 editorConfig.MENU_CONF[key] 中
1153
- // 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
1154
- config: genInsertVideoMenuConfig(),
1155
- };
1156
- var uploadVideoMenuConf = {
1157
- key: 'uploadVideo',
1158
- factory: function () {
1159
- return new UploadVideoMenu();
1160
- },
1161
- // 默认的菜单菜单配置,将存储在 editorConfig.MENU_CONF[key] 中
1162
- // 创建编辑器时,可通过 editorConfig.MENU_CONF[key] = {...} 来修改
1163
- config: genUploadVideoMenuConfig(),
1164
- };
1165
- var editorVideSizeMenuConf = {
1166
- key: 'editVideoSize',
1167
- factory: function () {
1168
- return new EditorVideoSizeMenu();
1169
- },
1170
- };
1171
- var editorVideoSrcMenuConf = {
1172
- key: 'editVideoSrc',
1173
- factory: function () {
1174
- return new Editvideo();
1175
- },
1176
- };
1177
- // export const deleteVideoMenuConf = {
1178
- // key: 'deleteVideo',
1179
- // factory() {
1180
- // return new DeleteVideoMenu()
1181
- // },
1182
- // }
1183
- // 键盘能删除 video 了,注释掉这个菜单 wangfupeng 22.02.23
1184
-
1185
- /**
1186
- * @description video module
1187
- * @author wangfupeng
1188
- */
1189
- var video = {
1190
- renderElems: [renderVideoConf],
1191
- elemsToHtml: [videoToHtmlConf],
1192
- preParseHtml: [preParseHtmlConf],
1193
- parseElemsHtml: [parseHtmlConf],
1194
- menus: [insertVideoMenuConf, uploadVideoMenuConf, editorVideSizeMenuConf, editorVideoSrcMenuConf],
1195
- editorPlugin: withVideo,
1196
- };
1197
-
1198
- /**
1199
- * @description video module
1200
- * @author wangfupeng
1201
- */
1202
-
1203
- return video;
1204
-
1205
- }));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@wangeditor-next/core"),require("slate"),require("snabbdom"),require("dom7"),require("nanoid")):"function"==typeof define&&define.amd?define(["@wangeditor-next/core","slate","snabbdom","dom7","nanoid"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorVideoModule=e(t.core,t.slate,t.snabbdom,t.$,t.nanoid)}(this,(function(t,e,n,r,o){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var u=i(r);t.i18nAddResources("en",{videoModule:{delete:"Delete",uploadVideo:"Upload video",insertVideo:"Insert video",videoSrc:"Video source",videoSrcPlaceHolder:"Video file url, or third-party <iframe>",videoPoster:"Video poster",videoPosterPlaceHolder:"Poster image url",ok:"Ok",editSize:"Edit size",edit:"Edit video",width:"Width",height:"Height"}}),t.i18nAddResources("zh-CN",{videoModule:{delete:"删除视频",uploadVideo:"上传视频",insertVideo:"插入视频",videoSrc:"视频地址",videoSrcPlaceHolder:"视频文件 url 或第三方 <iframe>",videoPoster:"视频封面",videoPosterPlaceHolder:"封面图片 url",ok:"确定",editSize:"修改尺寸",edit:"编辑视频",width:"宽度",height:"高度"}});var a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)};function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function a(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,a)}c((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function f(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function d(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=f(t),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){(function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)})(r,o,(e=t[n](e)).done,e.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var p="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(t){var e={exports:{}};return t(e,e.exports),e.exports}var h,y,g=function(t){return t&&t.Math==Math&&t},m=g("object"==typeof globalThis&&globalThis)||g("object"==typeof window&&window)||g("object"==typeof self&&self)||g("object"==typeof p&&p)||function(){return this}()||Function("return this")(),b=function(t){try{return!!t()}catch(t){return!0}},w=!b((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),S=Function.prototype.call,x=S.bind?S.bind(S):function(){return S.apply(S,arguments)},E={}.propertyIsEnumerable,O=Object.getOwnPropertyDescriptor,I={f:O&&!E.call({1:2},1)?function(t){var e=O(this,t);return!!e&&e.enumerable}:E},j=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},M=Function.prototype,P=M.bind,T=M.call,A=P&&P.bind(T),k=P?function(t){return t&&A(T,t)}:function(t){return t&&function(){return T.apply(t,arguments)}},N=k({}.toString),R=k("".slice),C=function(t){return R(N(t),8,-1)},V=m.Object,L=k("".split),D=b((function(){return!V("z").propertyIsEnumerable(0)}))?function(t){return"String"==C(t)?L(t,""):V(t)}:V,z=m.TypeError,F=function(t){if(null==t)throw z("Can't call method on "+t);return t},$=function(t){return D(F(t))},_=function(t){return"function"==typeof t},B=function(t){return"object"==typeof t?null!==t:_(t)},H=function(t){return _(t)?t:void 0},G=function(t,e){return arguments.length<2?H(m[t]):m[t]&&m[t][e]},W=k({}.isPrototypeOf),U=G("navigator","userAgent")||"",q=m.process,K=m.Deno,X=q&&q.versions||K&&K.version,Y=X&&X.v8;Y&&(y=(h=Y.split("."))[0]>0&&h[0]<4?1:+(h[0]+h[1])),!y&&U&&(!(h=U.match(/Edge\/(\d+)/))||h[1]>=74)&&(h=U.match(/Chrome\/(\d+)/))&&(y=+h[1]);var J=y,Q=!!Object.getOwnPropertySymbols&&!b((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&J&&J<41})),Z=Q&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,tt=m.Object,et=Z?function(t){return"symbol"==typeof t}:function(t){var e=G("Symbol");return _(e)&&W(e.prototype,tt(t))},nt=m.String,rt=function(t){try{return nt(t)}catch(t){return"Object"}},ot=m.TypeError,it=function(t){if(_(t))return t;throw ot(rt(t)+" is not a function")},ut=function(t,e){var n=t[e];return null==n?void 0:it(n)},at=m.TypeError,ct=Object.defineProperty,st=function(t,e){try{ct(m,t,{value:e,configurable:!0,writable:!0})}catch(n){m[t]=e}return e},ft="__core-js_shared__",lt=m[ft]||st(ft,{}),dt=v((function(t){(t.exports=function(t,e){return lt[t]||(lt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),pt=m.Object,vt=function(t){return pt(F(t))},ht=k({}.hasOwnProperty),yt=Object.hasOwn||function(t,e){return ht(vt(t),e)},gt=0,mt=Math.random(),bt=k(1..toString),wt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+bt(++gt+mt,36)},St=dt("wks"),xt=m.Symbol,Et=xt&&xt.for,Ot=Z?xt:xt&&xt.withoutSetter||wt,It=function(t){if(!yt(St,t)||!Q&&"string"!=typeof St[t]){var e="Symbol."+t;Q&&yt(xt,t)?St[t]=xt[t]:St[t]=Z&&Et?Et(e):Ot(e)}return St[t]},jt=m.TypeError,Mt=It("toPrimitive"),Pt=function(t,e){if(!B(t)||et(t))return t;var n,r=ut(t,Mt);if(r){if(void 0===e&&(e="default"),n=x(r,t,e),!B(n)||et(n))return n;throw jt("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&_(n=t.toString)&&!B(r=x(n,t)))return r;if(_(n=t.valueOf)&&!B(r=x(n,t)))return r;if("string"!==e&&_(n=t.toString)&&!B(r=x(n,t)))return r;throw at("Can't convert object to primitive value")}(t,e)},Tt=function(t){var e=Pt(t,"string");return et(e)?e:e+""},At=m.document,kt=B(At)&&B(At.createElement),Nt=function(t){return kt?At.createElement(t):{}},Rt=!w&&!b((function(){return 7!=Object.defineProperty(Nt("div"),"a",{get:function(){return 7}}).a})),Ct=Object.getOwnPropertyDescriptor,Vt={f:w?Ct:function(t,e){if(t=$(t),e=Tt(e),Rt)try{return Ct(t,e)}catch(t){}if(yt(t,e))return j(!x(I.f,t,e),t[e])}},Lt=m.String,Dt=m.TypeError,zt=function(t){if(B(t))return t;throw Dt(Lt(t)+" is not an object")},Ft=m.TypeError,$t=Object.defineProperty,_t={f:w?$t:function(t,e,n){if(zt(t),e=Tt(e),zt(n),Rt)try{return $t(t,e,n)}catch(t){}if("get"in n||"set"in n)throw Ft("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Bt=w?function(t,e,n){return _t.f(t,e,j(1,n))}:function(t,e,n){return t[e]=n,t},Ht=k(Function.toString);_(lt.inspectSource)||(lt.inspectSource=function(t){return Ht(t)});var Gt,Wt,Ut,qt=lt.inspectSource,Kt=m.WeakMap,Xt=_(Kt)&&/native code/.test(qt(Kt)),Yt=dt("keys"),Jt=function(t){return Yt[t]||(Yt[t]=wt(t))},Qt={},Zt="Object already initialized",te=m.TypeError,ee=m.WeakMap;if(Xt||lt.state){var ne=lt.state||(lt.state=new ee),re=k(ne.get),oe=k(ne.has),ie=k(ne.set);Gt=function(t,e){if(oe(ne,t))throw new te(Zt);return e.facade=t,ie(ne,t,e),e},Wt=function(t){return re(ne,t)||{}},Ut=function(t){return oe(ne,t)}}else{var ue=Jt("state");Qt[ue]=!0,Gt=function(t,e){if(yt(t,ue))throw new te(Zt);return e.facade=t,Bt(t,ue,e),e},Wt=function(t){return yt(t,ue)?t[ue]:{}},Ut=function(t){return yt(t,ue)}}var ae={set:Gt,get:Wt,has:Ut,enforce:function(t){return Ut(t)?Wt(t):Gt(t,{})},getterFor:function(t){return function(e){var n;if(!B(e)||(n=Wt(e)).type!==t)throw te("Incompatible receiver, "+t+" required");return n}}},ce=Function.prototype,se=w&&Object.getOwnPropertyDescriptor,fe=yt(ce,"name"),le={EXISTS:fe,PROPER:fe&&"something"===function(){}.name,CONFIGURABLE:fe&&(!w||w&&se(ce,"name").configurable)},de=v((function(t){var e=le.CONFIGURABLE,n=ae.get,r=ae.enforce,o=String(String).split("String");(t.exports=function(t,n,i,u){var a,c=!!u&&!!u.unsafe,s=!!u&&!!u.enumerable,f=!!u&&!!u.noTargetGet,l=u&&void 0!==u.name?u.name:n;_(i)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!yt(i,"name")||e&&i.name!==l)&&Bt(i,"name",l),(a=r(i)).source||(a.source=o.join("string"==typeof l?l:""))),t!==m?(c?!f&&t[n]&&(s=!0):delete t[n],s?t[n]=i:Bt(t,n,i)):s?t[n]=i:st(n,i)})(Function.prototype,"toString",(function(){return _(this)&&n(this).source||qt(this)}))})),pe=Math.ceil,ve=Math.floor,he=function(t){var e=+t;return e!=e||0===e?0:(e>0?ve:pe)(e)},ye=Math.max,ge=Math.min,me=function(t,e){var n=he(t);return n<0?ye(n+e,0):ge(n,e)},be=Math.min,we=function(t){return t>0?be(he(t),9007199254740991):0},Se=function(t){return we(t.length)},xe=function(t){return function(e,n,r){var o,i=$(e),u=Se(i),a=me(r,u);if(t&&n!=n){for(;u>a;)if((o=i[a++])!=o)return!0}else for(;u>a;a++)if((t||a in i)&&i[a]===n)return t||a||0;return!t&&-1}},Ee={includes:xe(!0),indexOf:xe(!1)},Oe=Ee.indexOf,Ie=k([].push),je=function(t,e){var n,r=$(t),o=0,i=[];for(n in r)!yt(Qt,n)&&yt(r,n)&&Ie(i,n);for(;e.length>o;)yt(r,n=e[o++])&&(~Oe(i,n)||Ie(i,n));return i},Me=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pe=Me.concat("length","prototype"),Te={f:Object.getOwnPropertyNames||function(t){return je(t,Pe)}},Ae={f:Object.getOwnPropertySymbols},ke=k([].concat),Ne=G("Reflect","ownKeys")||function(t){var e=Te.f(zt(t)),n=Ae.f;return n?ke(e,n(t)):e},Re=function(t,e){for(var n=Ne(e),r=_t.f,o=Vt.f,i=0;i<n.length;i++){var u=n[i];yt(t,u)||r(t,u,o(e,u))}},Ce=/#|\.prototype\./,Ve=function(t,e){var n=De[Le(t)];return n==Fe||n!=ze&&(_(e)?b(e):!!e)},Le=Ve.normalize=function(t){return String(t).replace(Ce,".").toLowerCase()},De=Ve.data={},ze=Ve.NATIVE="N",Fe=Ve.POLYFILL="P",$e=Ve,_e=Vt.f,Be=function(t,e){var n,r,o,i,u,a=t.target,c=t.global,s=t.stat;if(n=c?m:s?m[a]||st(a,{}):(m[a]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(u=_e(n,r))&&u.value:n[r],!$e(c?r:a+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Re(i,o)}(t.sham||o&&o.sham)&&Bt(i,"sham",!0),de(n,r,i,t)}},He={};He[It("toStringTag")]="z";var Ge,We="[object z]"===String(He),Ue=It("toStringTag"),qe=m.Object,Ke="Arguments"==C(function(){return arguments}()),Xe=We?C:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=qe(t),Ue))?n:Ke?C(e):"Object"==(r=C(e))&&_(e.callee)?"Arguments":r},Ye=m.String,Je=function(t){if("Symbol"===Xe(t))throw TypeError("Cannot convert a Symbol value to a string");return Ye(t)},Qe="\t\n\v\f\r                 \u2028\u2029\ufeff",Ze=k("".replace),tn="["+Qe+"]",en=RegExp("^"+tn+tn+"*"),nn=RegExp(tn+tn+"*$"),rn=function(t){return function(e){var n=Je(F(e));return 1&t&&(n=Ze(n,en,"")),2&t&&(n=Ze(n,nn,"")),n}},on={start:rn(1),end:rn(2),trim:rn(3)},un=le.PROPER,an=on.trim;function cn(t){return t.length?t[0].tagName.toLowerCase():""}function sn(t,e,n,r){void 0===e&&(e="auto"),void 0===n&&(n="auto"),void 0===r&&(r={});var o=u.default(t),i=r.width,a=void 0===i?"":i,c=r.height,s=void 0===c?"":c,f="";return a&&(f+="width: "+a+";"),s&&(f+="height: "+s+";"),o.attr("width",e),o.attr("height",n),o.attr("style",f),o[0].outerHTML}Be({target:"String",proto:!0,forced:(Ge="trim",b((function(){return!!Qe[Ge]()||"​…᠎"!=="​…᠎"[Ge]()||un&&Qe[Ge].name!==Ge})))},{trim:function(){return an(this)}}),Be({global:!0},{globalThis:m}),r.append&&(u.default.fn.append=r.append),r.on&&(u.default.fn.on=r.on),r.focus&&(u.default.fn.focus=r.focus),r.attr&&(u.default.fn.attr=r.attr),r.val&&(u.default.fn.val=r.val),r.html&&(u.default.fn.html=r.html),r.parent&&(u.default.fn.parent=r.parent),r.hasClass&&(u.default.fn.hasClass=r.hasClass),r.empty&&(u.default.fn.empty=r.empty);var fn={type:"video",renderElem:function(e,r,o){var i,u=e,a=u.src,c=void 0===a?"":a,s=u.poster,f=void 0===s?"":s,l=u.key,d=void 0===l?"":l,p=u.width,v=void 0===p?"auto":p,h=u.height,y=void 0===h?"auto":h,g=u.style,m=void 0===g?{}:g,b=u.textAlign,w=void 0===b?"center":b,S=t.DomEditor.isNodeSelected(o,e);if(0===c.trim().indexOf("<iframe ")){var x=sn(c,v,y,m);i=n.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:w},innerHTML:x})}else{var E=n.jsx("video",{key:d,poster:f,controls:!0,style:m},n.jsx("source",{src:c,type:"video/mp4"}),"Sorry, your browser doesn't support embedded videos.\n 抱歉,浏览器不支持 video 视频");"auto"!==v&&(E.data.width=v),"auto"!==y&&(E.data.height=y),i=n.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:w}},E)}return n.h("div",{props:{contentEditable:!1},on:{mousedown:function(t){return t.preventDefault()}}},i)}};var ln,dn={type:"video",elemToHtml:function(t,e){var n=t,r=n.src,o=void 0===r?"":r,i=n.poster,u=void 0===i?"":i,a=n.width,c=void 0===a?"auto":a,s=n.height,f=void 0===s?"auto":s,l=n.style,d=void 0===l?{}:l,p=n.textAlign,v='<div data-w-e-type="video" data-w-e-is-void style="text-align: '+(void 0===p?"center":p)+';">\n';if(0===o.trim().indexOf("<iframe ")){v+=sn(o,c,f,d)}else{var h=d.width,y=void 0===h?"":h,g=d.height,m=void 0===g?"":g,b="";y&&(b+="width: "+y+";"),m&&(b+="height: "+m+";"),v+='<video poster="'+u+'" controls="true" width="'+c+'" height="'+f+'" style="'+b+'"><source src="'+o+'" type="video/mp4"/></video>'}return v+="\n</div>"}},pn=Object.keys||function(t){return je(t,Me)},vn=w?Object.defineProperties:function(t,e){zt(t);for(var n,r=$(e),o=pn(e),i=o.length,u=0;i>u;)_t.f(t,n=o[u++],r[n]);return t},hn=G("document","documentElement"),yn=Jt("IE_PROTO"),gn=function(){},mn=function(t){return"<script>"+t+"</"+"script>"},bn=function(t){t.write(mn("")),t.close();var e=t.parentWindow.Object;return t=null,e},wn=function(){try{ln=new ActiveXObject("htmlfile")}catch(t){}var t,e;wn="undefined"!=typeof document?document.domain&&ln?bn(ln):((e=Nt("iframe")).style.display="none",hn.appendChild(e),e.src=String("javascript:"),(t=e.contentWindow.document).open(),t.write(mn("document.F=Object")),t.close(),t.F):bn(ln);for(var n=Me.length;n--;)delete wn.prototype[Me[n]];return wn()};Qt[yn]=!0;var Sn=Object.create||function(t,e){var n;return null!==t?(gn.prototype=zt(t),n=new gn,gn.prototype=null,n[yn]=t):n=wn(),void 0===e?n:vn(n,e)},xn=It("unscopables"),En=Array.prototype;null==En[xn]&&_t.f(En,xn,{configurable:!0,value:Sn(null)});var On=function(t){En[xn][t]=!0},In=Ee.includes;Be({target:"Array",proto:!0},{includes:function(t){return In(this,t,arguments.length>1?arguments[1]:void 0)}}),On("includes");var jn={selector:"iframe,video,p",preParseHtml:function(t){var e=u.default(t),n=e;if("p"===cn(e)){var r=e.children();if(1===r.length){var o=r[0],i=o.tagName.toLowerCase();["iframe","video"].includes(i)&&(n=u.default(o))}}var a=cn(n);if("iframe"!==a&&"video"!==a)return n[0];if("video"===n.parent().attr("data-w-e-type"))return n[0];var c=u.default('<div data-w-e-type="video" data-w-e-is-void style="text-align: center;"></div>');return c.append(n),c[0]}},Mn=k(k.bind),Pn=function(t,e){return it(t),void 0===e?t:Mn?Mn(t,e):function(){return t.apply(e,arguments)}},Tn=Array.isArray||function(t){return"Array"==C(t)},An=function(){},kn=[],Nn=G("Reflect","construct"),Rn=/^\s*(?:class|function)\b/,Cn=k(Rn.exec),Vn=!Rn.exec(An),Ln=function(t){if(!_(t))return!1;try{return Nn(An,kn,t),!0}catch(t){return!1}},Dn=!Nn||b((function(){var t;return Ln(Ln.call)||!Ln(Object)||!Ln((function(){t=!0}))||t}))?function(t){if(!_(t))return!1;switch(Xe(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return Vn||!!Cn(Rn,qt(t))}:Ln,zn=It("species"),Fn=m.Array,$n=function(t,e){return new(function(t){var e;return Tn(t)&&(e=t.constructor,(Dn(e)&&(e===Fn||Tn(e.prototype))||B(e)&&null===(e=e[zn]))&&(e=void 0)),void 0===e?Fn:e}(t))(0===e?0:e)},_n=k([].push),Bn=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,u=7==t,a=5==t||i;return function(c,s,f,l){for(var d,p,v=vt(c),h=D(v),y=Pn(s,f),g=Se(h),m=0,b=l||$n,w=e?b(c,g):n||u?b(c,0):void 0;g>m;m++)if((a||m in h)&&(p=y(d=h[m],m,v),t))if(e)w[m]=p;else if(p)switch(t){case 3:return!0;case 5:return d;case 6:return m;case 2:_n(w,d)}else switch(t){case 4:return!1;case 7:_n(w,d)}return i?-1:r||o?o:w}},Hn={forEach:Bn(0),map:Bn(1),filter:Bn(2),some:Bn(3),every:Bn(4),find:Bn(5),findIndex:Bn(6),filterReject:Bn(7)},Gn=Hn.find,Wn="find",Un=!0;Wn in[]&&Array(1).find((function(){Un=!1})),Be({target:"Array",proto:!0,forced:Un},{find:function(t){return Gn(this,t,arguments.length>1?arguments[1]:void 0)}}),On(Wn);var qn=We?{}.toString:function(){return"[object "+Xe(this)+"]"};function Kn(t,e,n,r,o){return void 0===e&&(e=""),void 0===n&&(n="auto"),void 0===r&&(r="auto"),void 0===o&&(o={}),{type:"video",src:t,poster:e,width:n,height:r,style:o,children:[{text:""}]}}We||de(Object.prototype,"toString",qn,{unsafe:!0});var Xn,Yn,Jn={selector:'div[data-w-e-type="video"]',parseElemHtml:function(t,e,n){var r=u.default(t),o="",i="",a="auto",c="auto",s={},f=r.find("iframe");if(f.length>0)return a=f.attr("width")||"auto",c=f.attr("height")||"auto",s=f.attr("style")||{},Kn(o=f[0].outerHTML,i,a,c,s);var l=r.find("video");return(o=l.attr("src")||"")||l.length>0&&(o=l.find("source").attr("src")||""),a=l.attr("width")||"auto",c=l.attr("height")||"auto",Kn(o,i=l.attr("poster")||"",a,c,s=f.attr("style")||{})}},Qn=function(){var t=zt(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e},Zn=m.RegExp,tr=b((function(){var t=Zn("a","y");return t.lastIndex=2,null!=t.exec("abcd")})),er=tr||b((function(){return!Zn("a","y").sticky})),nr={BROKEN_CARET:tr||b((function(){var t=Zn("^r","gy");return t.lastIndex=2,null!=t.exec("str")})),MISSED_STICKY:er,UNSUPPORTED_Y:tr},rr=m.RegExp,or=b((function(){var t=rr(".","s");return!(t.dotAll&&t.exec("\n")&&"s"===t.flags)})),ir=m.RegExp,ur=b((function(){var t=ir("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")})),ar=ae.get,cr=dt("native-string-replace",String.prototype.replace),sr=RegExp.prototype.exec,fr=sr,lr=k("".charAt),dr=k("".indexOf),pr=k("".replace),vr=k("".slice),hr=(Yn=/b*/g,x(sr,Xn=/a/,"a"),x(sr,Yn,"a"),0!==Xn.lastIndex||0!==Yn.lastIndex),yr=nr.BROKEN_CARET,gr=void 0!==/()??/.exec("")[1];(hr||gr||yr||or||ur)&&(fr=function(t){var e,n,r,o,i,u,a,c=this,s=ar(c),f=Je(t),l=s.raw;if(l)return l.lastIndex=c.lastIndex,e=x(fr,l,f),c.lastIndex=l.lastIndex,e;var d=s.groups,p=yr&&c.sticky,v=x(Qn,c),h=c.source,y=0,g=f;if(p&&(v=pr(v,"y",""),-1===dr(v,"g")&&(v+="g"),g=vr(f,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==lr(f,c.lastIndex-1))&&(h="(?: "+h+")",g=" "+g,y++),n=new RegExp("^(?:"+h+")",v)),gr&&(n=new RegExp("^"+h+"$(?!\\s)",v)),hr&&(r=c.lastIndex),o=x(sr,p?n:c,g),p?o?(o.input=vr(o.input,y),o[0]=vr(o[0],y),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:hr&&o&&(c.lastIndex=c.global?o.index+o[0].length:r),gr&&o&&o.length>1&&x(cr,o[0],n,(function(){for(i=1;i<arguments.length-2;i++)void 0===arguments[i]&&(o[i]=void 0)})),o&&d)for(o.groups=u=Sn(null),i=0;i<d.length;i++)u[(a=d[i])[0]]=o[a[1]];return o});var mr=fr;Be({target:"RegExp",proto:!0,forced:/./.exec!==mr},{exec:mr});var br=Function.prototype,wr=br.apply,Sr=br.bind,xr=br.call,Er="object"==typeof Reflect&&Reflect.apply||(Sr?xr.bind(wr):function(){return xr.apply(wr,arguments)}),Or=It("species"),Ir=RegExp.prototype,jr=k("".charAt),Mr=k("".charCodeAt),Pr=k("".slice),Tr=function(t){return function(e,n){var r,o,i=Je(F(e)),u=he(n),a=i.length;return u<0||u>=a?t?"":void 0:(r=Mr(i,u))<55296||r>56319||u+1===a||(o=Mr(i,u+1))<56320||o>57343?t?jr(i,u):r:t?Pr(i,u,u+2):o-56320+(r-55296<<10)+65536}},Ar={codeAt:Tr(!1),charAt:Tr(!0)},kr=Ar.charAt,Nr=function(t,e,n){return e+(n?kr(t,e).length:1)},Rr=Math.floor,Cr=k("".charAt),Vr=k("".replace),Lr=k("".slice),Dr=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,zr=/\$([$&'`]|\d{1,2})/g,Fr=function(t,e,n,r,o,i){var u=n+t.length,a=r.length,c=zr;return void 0!==o&&(o=vt(o),c=Dr),Vr(i,c,(function(i,c){var s;switch(Cr(c,0)){case"$":return"$";case"&":return t;case"`":return Lr(e,0,n);case"'":return Lr(e,u);case"<":s=o[Lr(c,1,-1)];break;default:var f=+c;if(0===f)return i;if(f>a){var l=Rr(f/10);return 0===l?i:l<=a?void 0===r[l-1]?Cr(c,1):r[l-1]+Cr(c,1):i}s=r[f-1]}return void 0===s?"":s}))},$r=m.TypeError,_r=function(t,e){var n=t.exec;if(_(n)){var r=x(n,t,e);return null!==r&&zt(r),r}if("RegExp"===C(t))return x(mr,t,e);throw $r("RegExp#exec called on incompatible receiver")},Br=It("replace"),Hr=Math.max,Gr=Math.min,Wr=k([].concat),Ur=k([].push),qr=k("".indexOf),Kr=k("".slice),Xr="$0"==="a".replace(/./,"$0"),Yr=!!/./[Br]&&""===/./[Br]("a","$0");function Jr(t){return void 0===t&&(t="r"),t+"-"+o.nanoid()}!function(t,e,n,r){var o=It(t),i=!b((function(){var e={};return e[o]=function(){return 7},7!=""[t](e)})),u=i&&!b((function(){var e=!1,n=/a/;return"split"===t&&((n={}).constructor={},n.constructor[Or]=function(){return n},n.flags="",n[o]=/./[o]),n.exec=function(){return e=!0,null},n[o](""),!e}));if(!i||!u||n){var a=k(/./[o]),c=e(o,""[t],(function(t,e,n,r,o){var u=k(t),c=e.exec;return c===mr||c===Ir.exec?i&&!o?{done:!0,value:a(e,n,r)}:{done:!0,value:u(n,e,r)}:{done:!1}}));de(String.prototype,t,c[0]),de(Ir,o,c[1])}r&&Bt(Ir[o],"sham",!0)}("replace",(function(t,e,n){var r=Yr?"$":"$0";return[function(t,n){var r=F(this),o=null==t?void 0:ut(t,Br);return o?x(o,t,r,n):x(e,Je(r),t,n)},function(t,o){var i=zt(this),u=Je(t);if("string"==typeof o&&-1===qr(o,r)&&-1===qr(o,"$<")){var a=n(e,i,u,o);if(a.done)return a.value}var c=_(o);c||(o=Je(o));var s=i.global;if(s){var f=i.unicode;i.lastIndex=0}for(var l=[];;){var d=_r(i,u);if(null===d)break;if(Ur(l,d),!s)break;""===Je(d[0])&&(i.lastIndex=Nr(u,we(i.lastIndex),f))}for(var p,v="",h=0,y=0;y<l.length;y++){for(var g=Je((d=l[y])[0]),m=Hr(Gr(he(d.index),u.length),0),b=[],w=1;w<d.length;w++)Ur(b,void 0===(p=d[w])?p:String(p));var S=d.groups;if(c){var x=Wr([g],b,m,u);void 0!==S&&Ur(x,S);var E=Je(Er(o,void 0,x))}else E=Fr(g,u,m,b,S,o);m>=h&&(v+=Kr(u,h,m)+E,h=m+g.length)}return v+Kr(u,h)}]}),!!b((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")}))||!Xr||Yr);var Qr=m.Promise,Zr=function(t,e,n){for(var r in e)de(t,r,e[r],n);return t},to=m.String,eo=m.TypeError,no=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=k(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return zt(n),function(t){if("object"==typeof t||_(t))return t;throw eo("Can't set "+to(t)+" as a prototype")}(r),e?t(n,r):n.__proto__=r,n}}():void 0),ro=_t.f,oo=It("toStringTag"),io=function(t,e,n){t&&!yt(t=n?t:t.prototype,oo)&&ro(t,oo,{configurable:!0,value:e})},uo=It("species"),ao=m.TypeError,co=function(t,e){if(W(e,t))return t;throw ao("Incorrect invocation")},so={},fo=It("iterator"),lo=Array.prototype,po=It("iterator"),vo=function(t){if(null!=t)return ut(t,po)||ut(t,"@@iterator")||so[Xe(t)]},ho=m.TypeError,yo=function(t,e,n){var r,o;zt(t);try{if(!(r=ut(t,"return"))){if("throw"===e)throw n;return n}r=x(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return zt(r),n},go=m.TypeError,mo=function(t,e){this.stopped=t,this.result=e},bo=mo.prototype,wo=function(t,e,n){var r,o,i,u,a,c,s,f,l=n&&n.that,d=!(!n||!n.AS_ENTRIES),p=!(!n||!n.IS_ITERATOR),v=!(!n||!n.INTERRUPTED),h=Pn(e,l),y=function(t){return r&&yo(r,"normal",t),new mo(!0,t)},g=function(t){return d?(zt(t),v?h(t[0],t[1],y):h(t[0],t[1])):v?h(t,y):h(t)};if(p)r=t;else{if(!(o=vo(t)))throw go(rt(t)+" is not iterable");if(void 0!==(f=o)&&(so.Array===f||lo[fo]===f)){for(i=0,u=Se(t);u>i;i++)if((a=g(t[i]))&&W(bo,a))return a;return new mo(!1)}r=function(t,e){var n=arguments.length<2?vo(t):e;if(it(n))return zt(x(n,t));throw ho(rt(t)+" is not iterable")}(t,o)}for(c=r.next;!(s=x(c,r)).done;){try{a=g(s.value)}catch(t){yo(r,"throw",t)}if("object"==typeof a&&a&&W(bo,a))return a}return new mo(!1)},So=It("iterator"),xo=!1;try{var Eo=0,Oo={next:function(){return{done:!!Eo++}},return:function(){xo=!0}};Oo[So]=function(){return this},Array.from(Oo,(function(){throw 2}))}catch(t){}var Io,jo,Mo,Po,To=function(t,e){if(!e&&!xo)return!1;var n=!1;try{var r={};r[So]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},Ao=m.TypeError,ko=It("species"),No=function(t,e){var n,r=zt(t).constructor;return void 0===r||null==(n=zt(r)[ko])?e:function(t){if(Dn(t))return t;throw Ao(rt(t)+" is not a constructor")}(n)},Ro=k([].slice),Co=/(?:ipad|iphone|ipod).*applewebkit/i.test(U),Vo="process"==C(m.process),Lo=m.setImmediate,Do=m.clearImmediate,zo=m.process,Fo=m.Dispatch,$o=m.Function,_o=m.MessageChannel,Bo=m.String,Ho=0,Go={},Wo="onreadystatechange";try{Io=m.location}catch(t){}var Uo=function(t){if(yt(Go,t)){var e=Go[t];delete Go[t],e()}},qo=function(t){return function(){Uo(t)}},Ko=function(t){Uo(t.data)},Xo=function(t){m.postMessage(Bo(t),Io.protocol+"//"+Io.host)};Lo&&Do||(Lo=function(t){var e=Ro(arguments,1);return Go[++Ho]=function(){Er(_(t)?t:$o(t),void 0,e)},jo(Ho),Ho},Do=function(t){delete Go[t]},Vo?jo=function(t){zo.nextTick(qo(t))}:Fo&&Fo.now?jo=function(t){Fo.now(qo(t))}:_o&&!Co?(Po=(Mo=new _o).port2,Mo.port1.onmessage=Ko,jo=Pn(Po.postMessage,Po)):m.addEventListener&&_(m.postMessage)&&!m.importScripts&&Io&&"file:"!==Io.protocol&&!b(Xo)?(jo=Xo,m.addEventListener("message",Ko,!1)):jo=Wo in Nt("script")?function(t){hn.appendChild(Nt("script")).onreadystatechange=function(){hn.removeChild(this),Uo(t)}}:function(t){setTimeout(qo(t),0)});var Yo,Jo,Qo,Zo,ti,ei,ni,ri,oi={set:Lo,clear:Do},ii=/ipad|iphone|ipod/i.test(U)&&void 0!==m.Pebble,ui=/web0s(?!.*chrome)/i.test(U),ai=Vt.f,ci=oi.set,si=m.MutationObserver||m.WebKitMutationObserver,fi=m.document,li=m.process,di=m.Promise,pi=ai(m,"queueMicrotask"),vi=pi&&pi.value;vi||(Yo=function(){var t,e;for(Vo&&(t=li.domain)&&t.exit();Jo;){e=Jo.fn,Jo=Jo.next;try{e()}catch(t){throw Jo?Zo():Qo=void 0,t}}Qo=void 0,t&&t.enter()},Co||Vo||ui||!si||!fi?!ii&&di&&di.resolve?((ni=di.resolve(void 0)).constructor=di,ri=Pn(ni.then,ni),Zo=function(){ri(Yo)}):Vo?Zo=function(){li.nextTick(Yo)}:(ci=Pn(ci,m),Zo=function(){ci(Yo)}):(ti=!0,ei=fi.createTextNode(""),new si(Yo).observe(ei,{characterData:!0}),Zo=function(){ei.data=ti=!ti}));var hi,yi,gi,mi,bi=vi||function(t){var e={fn:t,next:void 0};Qo&&(Qo.next=e),Jo||(Jo=e,Zo()),Qo=e},wi=function(t){var e,n;this.promise=new t((function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r})),this.resolve=it(e),this.reject=it(n)},Si={f:function(t){return new wi(t)}},xi=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}},Ei="object"==typeof window,Oi=oi.set,Ii=It("species"),ji="Promise",Mi=ae.getterFor(ji),Pi=ae.set,Ti=ae.getterFor(ji),Ai=Qr&&Qr.prototype,ki=Qr,Ni=Ai,Ri=m.TypeError,Ci=m.document,Vi=m.process,Li=Si.f,Di=Li,zi=!!(Ci&&Ci.createEvent&&m.dispatchEvent),Fi=_(m.PromiseRejectionEvent),$i="unhandledrejection",_i=!1,Bi=$e(ji,(function(){var t=qt(ki),e=t!==String(ki);if(!e&&66===J)return!0;if(J>=51&&/native code/.test(t))return!1;var n=new ki((function(t){t(1)})),r=function(t){t((function(){}),(function(){}))};return(n.constructor={})[Ii]=r,!(_i=n.then((function(){}))instanceof r)||!e&&Ei&&!Fi})),Hi=Bi||!To((function(t){ki.all(t).catch((function(){}))})),Gi=function(t){var e;return!(!B(t)||!_(e=t.then))&&e},Wi=function(t,e){if(!t.notified){t.notified=!0;var n=t.reactions;bi((function(){for(var r=t.value,o=1==t.state,i=0;n.length>i;){var u,a,c,s=n[i++],f=o?s.ok:s.fail,l=s.resolve,d=s.reject,p=s.domain;try{f?(o||(2===t.rejection&&Xi(t),t.rejection=1),!0===f?u=r:(p&&p.enter(),u=f(r),p&&(p.exit(),c=!0)),u===s.promise?d(Ri("Promise-chain cycle")):(a=Gi(u))?x(a,u,l,d):l(u)):d(r)}catch(t){p&&!c&&p.exit(),d(t)}}t.reactions=[],t.notified=!1,e&&!t.rejection&&qi(t)}))}},Ui=function(t,e,n){var r,o;zi?((r=Ci.createEvent("Event")).promise=e,r.reason=n,r.initEvent(t,!1,!0),m.dispatchEvent(r)):r={promise:e,reason:n},!Fi&&(o=m["on"+t])?o(r):t===$i&&function(t,e){var n=m.console;n&&n.error&&(1==arguments.length?n.error(t):n.error(t,e))}("Unhandled promise rejection",n)},qi=function(t){x(Oi,m,(function(){var e,n=t.facade,r=t.value;if(Ki(t)&&(e=xi((function(){Vo?Vi.emit("unhandledRejection",r,n):Ui($i,n,r)})),t.rejection=Vo||Ki(t)?2:1,e.error))throw e.value}))},Ki=function(t){return 1!==t.rejection&&!t.parent},Xi=function(t){x(Oi,m,(function(){var e=t.facade;Vo?Vi.emit("rejectionHandled",e):Ui("rejectionhandled",e,t.value)}))},Yi=function(t,e,n){return function(r){t(e,r,n)}},Ji=function(t,e,n){t.done||(t.done=!0,n&&(t=n),t.value=e,t.state=2,Wi(t,!0))},Qi=function(t,e,n){if(!t.done){t.done=!0,n&&(t=n);try{if(t.facade===e)throw Ri("Promise can't be resolved itself");var r=Gi(e);r?bi((function(){var n={done:!1};try{x(r,e,Yi(Qi,n,t),Yi(Ji,n,t))}catch(e){Ji(n,e,t)}})):(t.value=e,t.state=1,Wi(t,!1))}catch(e){Ji({done:!1},e,t)}}};if(Bi&&(Ni=(ki=function(t){co(this,Ni),it(t),x(hi,this);var e=Mi(this);try{t(Yi(Qi,e),Yi(Ji,e))}catch(t){Ji(e,t)}}).prototype,(hi=function(t){Pi(this,{type:ji,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=Zr(Ni,{then:function(t,e){var n=Ti(this),r=n.reactions,o=Li(No(this,ki));return o.ok=!_(t)||t,o.fail=_(e)&&e,o.domain=Vo?Vi.domain:void 0,n.parent=!0,r[r.length]=o,0!=n.state&&Wi(n,!1),o.promise},catch:function(t){return this.then(void 0,t)}}),yi=function(){var t=new hi,e=Mi(t);this.promise=t,this.resolve=Yi(Qi,e),this.reject=Yi(Ji,e)},Si.f=Li=function(t){return t===ki||t===gi?new yi(t):Di(t)},_(Qr)&&Ai!==Object.prototype)){mi=Ai.then,_i||(de(Ai,"then",(function(t,e){var n=this;return new ki((function(t,e){x(mi,n,t,e)})).then(t,e)}),{unsafe:!0}),de(Ai,"catch",Ni.catch,{unsafe:!0}));try{delete Ai.constructor}catch(t){}no&&no(Ai,Ni)}function Zi(n,r,o,i,u){return void 0===o&&(o=""),void 0===i&&(i=""),void 0===u&&(u=""),c(this,void 0,void 0,(function(){var a,c,f,l,d,p,v;return s(this,(function(s){switch(s.label){case 0:return r?(n.restoreSelection(),a=n.getMenuConfig("insertVideo"),c=a.onInsertedVideo,f=a.checkVideo,l=a.parseVideoSrc,[4,f(r,o)]):[2];case 1:return"string"==typeof(d=s.sent())?(n.alert(d,"error"),[2]):null==d?[2]:[4,l(r)];case 2:return 0!==(p=s.sent()).trim().indexOf("<iframe ")&&(p=p.replace(/</g,"&lt;").replace(/>/g,"&gt;")),t.DomEditor.isSelectedEmptyParagraph(n)&&e.Transforms.removeNodes(n,{mode:"highest"}),v={type:"video",src:p,poster:o,children:[{text:""}],style:{width:i,height:u}},Promise.resolve().then((function(){e.Transforms.insertNodes(n,v)})),c(v),[2]}}))}))}function tu(){return Jr("w-e-insert-video")}Be({global:!0,wrap:!0,forced:Bi},{Promise:ki}),io(ki,ji,!1),function(t){var e=G(t),n=_t.f;w&&e&&!e[uo]&&n(e,uo,{configurable:!0,get:function(){return this}})}(ji),gi=G(ji),Be({target:ji,stat:!0,forced:Bi},{reject:function(t){var e=Li(this);return x(e.reject,void 0,t),e.promise}}),Be({target:ji,stat:!0,forced:Bi},{resolve:function(t){return function(t,e){if(zt(t),B(e)&&e.constructor===t)return e;var n=Si.f(t);return(0,n.resolve)(e),n.promise}(this,t)}}),Be({target:ji,stat:!0,forced:Hi},{all:function(t){var e=this,n=Li(e),r=n.resolve,o=n.reject,i=xi((function(){var n=it(e.resolve),i=[],u=0,a=1;wo(t,(function(t){var c=u++,s=!1;a++,x(n,e,t).then((function(t){s||(s=!0,i[c]=t,--a||r(i))}),o)})),--a||r(i)}));return i.error&&o(i.value),n.promise},race:function(t){var e=this,n=Li(e),r=n.reject,o=xi((function(){var o=it(e.resolve);wo(t,(function(t){x(o,e,t).then(n.resolve,r)}))}));return o.error&&r(o.value),n.promise}});var eu=function(){function n(){this.title=t.t("videoModule.insertVideo"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.srcInputId=tu(),this.posterInputId=tu(),this.buttonId=tu()}return n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(n){var r=n.selection;return null==r||(!e.Range.isCollapsed(r)||!!t.DomEditor.getSelectedElems(n).some((function(e){var r=t.DomEditor.getNodeType(e);return"pre"===r||("list-item"===r||!!n.isVoid(e))})))},n.prototype.getModalPositionNode=function(t){return null},n.prototype.getModalContentElem=function(e){var n=this,r=this,o=r.srcInputId,i=r.posterInputId,a=r.buttonId,f=l(t.genModalInputElems(t.t("videoModule.videoSrc"),o,t.t("videoModule.videoSrcPlaceHolder")),2),d=f[0],p=f[1],v=l(t.genModalInputElems(t.t("videoModule.videoPoster"),i,t.t("videoModule.videoPosterPlaceHolder")),2),h=v[0],y=v[1],g=u.default(p),m=u.default(y),b=l(t.genModalButtonElems(a,t.t("videoModule.ok")),1)[0];if(null==this.$content){var w=u.default("<div></div>");w.on("click","#"+a,(function(t){return c(n,void 0,void 0,(function(){var n,r;return s(this,(function(u){switch(u.label){case 0:return t.preventDefault(),n=w.find("#"+o).val().trim(),r=w.find("#"+i).val().trim(),[4,Zi(e,n,r)];case 1:return u.sent(),e.hidePanelOrModal(),[2]}}))}))})),this.$content=w}var S=this.$content;return S.empty(),S.append(d),S.append(h),S.append(b),g.val(""),m.val(""),setTimeout((function(){g.focus()})),S[0]},n}(),nu=k([].join),ru=D!=Object,ou=function(t,e){var n=[][t];return!!n&&b((function(){n.call(null,e||function(){throw 1},1)}))}("join",",");Be({target:"Array",proto:!0,forced:ru||!ou},{join:function(t){return nu($(this),void 0===t?",":t)}});var iu,uu,au,cu=!b((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),su=Jt("IE_PROTO"),fu=m.Object,lu=fu.prototype,du=cu?fu.getPrototypeOf:function(t){var e=vt(t);if(yt(e,su))return e[su];var n=e.constructor;return _(n)&&e instanceof n?n.prototype:e instanceof fu?lu:null},pu=It("iterator"),vu=!1;[].keys&&("next"in(au=[].keys())?(uu=du(du(au)))!==Object.prototype&&(iu=uu):vu=!0);var hu=null==iu||b((function(){var t={};return iu[pu].call(t)!==t}));hu&&(iu={}),_(iu[pu])||de(iu,pu,(function(){return this}));var yu={IteratorPrototype:iu,BUGGY_SAFARI_ITERATORS:vu},gu=yu.IteratorPrototype,mu=function(){return this},bu=le.PROPER,wu=le.CONFIGURABLE,Su=yu.IteratorPrototype,xu=yu.BUGGY_SAFARI_ITERATORS,Eu=It("iterator"),Ou="keys",Iu="values",ju="entries",Mu=function(){return this},Pu=function(t,e,n,r,o,i,u){!function(t,e,n,r){var o=e+" Iterator";t.prototype=Sn(gu,{next:j(+!r,n)}),io(t,o,!1),so[o]=mu}(n,e,r);var a,c,s,f=function(t){if(t===o&&h)return h;if(!xu&&t in p)return p[t];switch(t){case Ou:case Iu:case ju:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",d=!1,p=t.prototype,v=p[Eu]||p["@@iterator"]||o&&p[o],h=!xu&&v||f(o),y="Array"==e&&p.entries||v;if(y&&(a=du(y.call(new t)))!==Object.prototype&&a.next&&(du(a)!==Su&&(no?no(a,Su):_(a[Eu])||de(a,Eu,Mu)),io(a,l,!0)),bu&&o==Iu&&v&&v.name!==Iu&&(wu?Bt(p,"name",Iu):(d=!0,h=function(){return x(v,this)})),o)if(c={values:f(Iu),keys:i?h:f(Ou),entries:f(ju)},u)for(s in c)(xu||d||!(s in p))&&de(p,s,c[s]);else Be({target:e,proto:!0,forced:xu||d},c);return p[Eu]!==h&&de(p,Eu,h,{name:o}),so[e]=h,c},Tu="Array Iterator",Au=ae.set,ku=ae.getterFor(Tu),Nu=Pu(Array,"Array",(function(t,e){Au(this,{type:Tu,target:$(t),index:0,kind:e})}),(function(){var t=ku(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values");so.Arguments=so.Array,On("keys"),On("values"),On("entries");var Ru=Ar.charAt,Cu="String Iterator",Vu=ae.set,Lu=ae.getterFor(Cu);Pu(String,"String",(function(t){Vu(this,{type:Cu,string:Je(t),index:0})}),(function(){var t,e=Lu(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=Ru(n,r),e.index+=t.length,{value:t,done:!1})}));var Du=function(t,e,n){var r=Tt(e);r in t?_t.f(t,r,j(0,n)):t[r]=n},zu=m.Array,Fu=Math.max,$u=Te.f,_u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Bu=function(t){try{return $u(t)}catch(t){return function(t,e,n){for(var r=Se(t),o=me(e,r),i=me(void 0===n?r:n,r),u=zu(Fu(i-o,0)),a=0;o<i;o++,a++)Du(u,a,t[o]);return u.length=a,u}(_u)}},Hu={f:function(t){return _u&&"Window"==C(t)?Bu(t):$u($(t))}},Gu=b((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Wu=Object.isExtensible,Uu=b((function(){Wu(1)}))||Gu?function(t){return!!B(t)&&((!Gu||"ArrayBuffer"!=C(t))&&(!Wu||Wu(t)))}:Wu,qu=!b((function(){return Object.isExtensible(Object.preventExtensions({}))})),Ku=v((function(t){var e=_t.f,n=!1,r=wt("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},u=t.exports={enable:function(){u.enable=function(){},n=!0;var t=Te.f,e=k([].splice),o={};o[r]=1,t(o).length&&(Te.f=function(n){for(var o=t(n),i=0,u=o.length;i<u;i++)if(o[i]===r){e(o,i,1);break}return o},Be({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Hu.f}))},fastKey:function(t,e){if(!B(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!yt(t,r)){if(!Uu(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!yt(t,r)){if(!Uu(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return qu&&n&&Uu(t)&&!yt(t,r)&&i(t),t}};Qt[r]=!0})),Xu=Ku.getWeakData,Yu=ae.set,Ju=ae.getterFor,Qu=Hn.find,Zu=Hn.findIndex,ta=k([].splice),ea=0,na=function(t){return t.frozen||(t.frozen=new ra)},ra=function(){this.entries=[]},oa=function(t,e){return Qu(t.entries,(function(t){return t[0]===e}))};ra.prototype={get:function(t){var e=oa(this,t);if(e)return e[1]},has:function(t){return!!oa(this,t)},set:function(t,e){var n=oa(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=Zu(this.entries,(function(e){return e[0]===t}));return~e&&ta(this.entries,e,1),!!~e}};var ia,ua={getConstructor:function(t,e,n,r){var o=t((function(t,o){co(t,i),Yu(t,{type:e,id:ea++,frozen:void 0}),null!=o&&wo(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,u=Ju(e),a=function(t,e,n){var r=u(t),o=Xu(zt(e),!0);return!0===o?na(r).set(e,n):o[r.id]=n,t};return Zr(i,{delete:function(t){var e=u(this);if(!B(t))return!1;var n=Xu(t);return!0===n?na(e).delete(t):n&&yt(n,e.id)&&delete n[e.id]},has:function(t){var e=u(this);if(!B(t))return!1;var n=Xu(t);return!0===n?na(e).has(t):n&&yt(n,e.id)}}),Zr(i,n?{get:function(t){var e=u(this);if(B(t)){var n=Xu(t);return!0===n?na(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return a(this,t,e)}}:{add:function(t){return a(this,t,!0)}}),o}},aa=ae.enforce,ca=!m.ActiveXObject&&"ActiveXObject"in m,sa=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},fa=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",u=m[t],a=u&&u.prototype,c=u,s={},f=function(t){var e=k(a[t]);de(a,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!B(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!B(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!B(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if($e(t,!_(u)||!(o||a.forEach&&!b((function(){(new u).entries().next()})))))c=n.getConstructor(e,t,r,i),Ku.enable();else if($e(t,!0)){var l=new c,d=l[i](o?{}:-0,1)!=l,p=b((function(){l.has(1)})),v=To((function(t){new u(t)})),h=!o&&b((function(){for(var t=new u,e=5;e--;)t[i](e,e);return!t.has(-0)}));v||((c=e((function(t,e){co(t,a);var n=function(t,e,n){var r,o;return no&&_(r=e.constructor)&&r!==n&&B(o=r.prototype)&&o!==n.prototype&&no(t,o),t}(new u,t,c);return null!=e&&wo(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=a,a.constructor=c),(p||h)&&(f("delete"),f("has"),r&&f("get")),(h||d)&&f(i),o&&a.clear&&delete a.clear}return s[t]=c,Be({global:!0,forced:c!=u},s),io(c,t),o||n.setStrong(c,t,r),c}("WeakMap",sa,ua);if(Xt&&ca){ia=ua.getConstructor(sa,"WeakMap",!0),Ku.enable();var la=fa.prototype,da=k(la.delete),pa=k(la.has),va=k(la.get),ha=k(la.set);Zr(la,{delete:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),da(this,t)||e.frozen.delete(t)}return da(this,t)},has:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),pa(this,t)||e.frozen.has(t)}return pa(this,t)},get:function(t){if(B(t)&&!Uu(t)){var e=aa(this);return e.frozen||(e.frozen=new ia),pa(this,t)?va(this,t):e.frozen.get(t)}return va(this,t)},set:function(t,e){if(B(t)&&!Uu(t)){var n=aa(this);n.frozen||(n.frozen=new ia),pa(this,t)?ha(this,t,e):n.frozen.set(t,e)}else ha(this,t,e);return this}})}var ya={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ga=Nt("span").classList,ma=ga&&ga.constructor&&ga.constructor.prototype,ba=ma===Object.prototype?void 0:ma,wa=It("iterator"),Sa=It("toStringTag"),xa=Nu.values,Ea=function(t,e){if(t){if(t[wa]!==xa)try{Bt(t,wa,xa)}catch(e){t[wa]=xa}if(t[Sa]||Bt(t,Sa,e),ya[e])for(var n in Nu)if(t[n]!==Nu[n])try{Bt(t,n,Nu[n])}catch(e){t[n]=Nu[n]}}};for(var Oa in ya)Ea(m[Oa]&&m[Oa].prototype,Oa);Ea(ba,"DOMTokenList");var Ia=le.EXISTS,ja=_t.f,Ma=Function.prototype,Pa=k(Ma.toString),Ta=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,Aa=k(Ta.exec);w&&!Ia&&ja(Ma,"name",{configurable:!0,get:function(){try{return Aa(Ta,Pa(this))[1]}catch(t){return""}}});var ka=It("species"),Na=function(t){return J>=51||!b((function(){var e=[];return(e.constructor={})[ka]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}("slice"),Ra=It("species"),Ca=m.Array,Va=Math.max;function La(t){return t.getMenuConfig("uploadVideo")}Be({target:"Array",proto:!0,forced:!Na},{slice:function(t,e){var n,r,o,i=$(this),u=Se(i),a=me(t,u),c=me(void 0===e?u:e,u);if(Tn(i)&&(n=i.constructor,(Dn(n)&&(n===Ca||Tn(n.prototype))||B(n)&&null===(n=n[Ra]))&&(n=void 0),n===Ca||void 0===n))return Ro(i,a,c);for(r=new(void 0===n?Ca:n)(Va(c-a,0)),o=0;a<c;a++,o++)a in i&&Du(r,o,i[a]);return r.length=o,r}});var Da=new WeakMap;function za(e,n){return c(this,void 0,void 0,(function(){var r,o,i,u;return s(this,(function(c){switch(c.label){case 0:return r=function(e){var n=Da.get(e);if(null!=n)return n;var r=La(e),o=r.onSuccess,i=r.onProgress,u=r.onFailed,c=r.customInsert,s=r.onError;return n=t.createUploader(a(a({},r),{onProgress:function(t){e.showProgressBar(t),i&&i(t)},onSuccess:function(t,n){if(c)return c(n,(function(t,n){return Zi(e,t,n)})),void o(t,n);var r=n.errno,i=void 0===r?1:r,a=n.data,s=void 0===a?{}:a;if(0===i){var f=s.url,l=void 0===f?"":f,d=s.poster;Zi(e,l,void 0===d?"":d),o(t,n)}else u(t,n)},onError:function(t,e,n){s(t,e,n)}})),Da.set(e,n),n}(e),o=n.name,i=n.type,u=n.size,r.addFile({name:o,type:i,size:u,data:n}),[4,r.upload()];case 1:return c.sent(),[2]}}))}))}var Fa=function(){function n(){this.title=t.t("videoModule.uploadVideo"),this.iconSvg='<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z" p-id="6802"></path><path d="M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z"></path></svg>',this.tag="button"}return n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){var n=this.getMenuConfig(t),r=n.allowedFileTypes,o=void 0===r?[]:r,i=n.customBrowseAndUpload;if(i)i((function(e,n){return Zi(t,e,n)}));else{var a="";o.length>0&&(a='accept="'+o.join(", ")+'"');var f=u.default("body"),l=u.default('<input type="file" '+a+" multiple/>");l.hide(),f.append(l),l.click(),l.on("change",(function(){var e=l[0].files;!function(t,e){var n,r;c(this,void 0,void 0,(function(){var o,i,u,a,c,f;return s(this,(function(s){switch(s.label){case 0:if(null==e)return[2];o=Array.prototype.slice.call(e),i=La(t).customUpload,s.label=1;case 1:s.trys.push([1,9,10,15]),u=d(o),s.label=2;case 2:return[4,u.next()];case 3:return(a=s.sent()).done?[3,8]:(c=a.value,i?[4,i(c,(function(e,n){return Zi(t,e,n)}))]:[3,5]);case 4:return s.sent(),[3,7];case 5:return[4,za(t,c)];case 6:s.sent(),s.label=7;case 7:return[3,2];case 8:return[3,15];case 9:return f=s.sent(),n={error:f},[3,15];case 10:return s.trys.push([10,,13,14]),a&&!a.done&&(r=u.return)?[4,r.call(u)]:[3,12];case 11:s.sent(),s.label=12;case 12:return[3,14];case 13:if(n)throw n.error;return[7];case 14:return[7];case 15:return[2]}}))}))}(t,e)}))}},n.prototype.isDisabled=function(n){var r=n.selection;return null==r||(!e.Range.isCollapsed(r)||!!t.DomEditor.getSelectedElems(n).some((function(e){var r=t.DomEditor.getNodeType(e);return"pre"===r||("list-item"===r||!!n.isVoid(e))})))},n.prototype.getMenuConfig=function(t){return t.getMenuConfig("uploadVideo")},n}();function $a(){return Jr("w-e-insert-video")}var _a=function(){function n(){this.title=t.t("videoModule.editSize"),this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.widthInputId=$a(),this.heightInputId=$a(),this.buttonId=$a()}return n.prototype.getSelectedVideoNode=function(e){return t.DomEditor.getSelectedNodeByType(e,"video")},n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(t){return null==t.selection||null==this.getSelectedVideoNode(t)},n.prototype.getModalPositionNode=function(t){return this.getSelectedVideoNode(t)},n.prototype.getModalContentElem=function(n){var r=this,o=r.widthInputId,i=r.heightInputId,c=r.buttonId,s=l(t.genModalInputElems(t.t("videoModule.width"),o,"auto"),2),f=s[0],d=s[1],p=u.default(d),v=l(t.genModalInputElems(t.t("videoModule.height"),i,"auto"),2),h=v[0],y=v[1],g=u.default(y),m=l(t.genModalButtonElems(c,t.t("videoModule.ok")),1)[0];if(null==this.$content){var b=u.default("<div></div>");b.on("click","#"+c,(function(r){r.preventDefault();var u=b.find("#"+o).val().trim(),c=b.find("#"+i).val().trim(),s=function(t){return/^\d+(\.\d+)?%$/.test(t)},f=function(t){return/^\d+(\.\d+)?$/.test(t)},l="auto",d="auto";s(u)?l=u:f(u)&&(l=parseInt(u)+"px"),s(c)?d=c:f(c)&&(d=parseInt(c)+"px");var p=S.style,v=void 0===p?{}:p;n.restoreSelection();var h=a(a({},v),{style:{width:l,height:d}});e.Transforms.setNodes(n,h,{match:function(e){return t.DomEditor.checkNodeType(e,"video")}}),n.hidePanelOrModal()})),this.$content=b}var w=this.$content;w.empty(),w.append(f),w.append(h),w.append(m);var S=this.getSelectedVideoNode(n);if(null==S)return w[0];var x=S.style,E=void 0===x?{}:x,O=E.width,I=void 0===O?"":O,j=E.height,M=void 0===j?"":j;return p.val(I),g.val(M),setTimeout((function(){p.focus()})),w[0]},n}();function Ba(){return Jr("w-e-edit-video")}var Ha=function(){function n(){this.title=t.t("videoModule.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.srcInputId=Ba(),this.posterInputId=Ba(),this.buttonId=Ba()}return n.prototype.getSelectedVideoNode=function(e){return t.DomEditor.getSelectedNodeByType(e,"video")},n.prototype.getValue=function(t){return""},n.prototype.isActive=function(t){return!1},n.prototype.exec=function(t,e){},n.prototype.isDisabled=function(t){return null==t.selection||null==this.getSelectedVideoNode(t)},n.prototype.getModalPositionNode=function(t){return this.getSelectedVideoNode(t)},n.prototype.getModalContentElem=function(n){var r=this,o=this,i=o.srcInputId,a=o.posterInputId,f=o.buttonId,d=l(t.genModalInputElems(t.t("videoModule.videoSrc"),i,t.t("videoModule.videoSrcPlaceHolder")),2),p=d[0],v=d[1],h=l(t.genModalInputElems(t.t("videoModule.videoPoster"),a,t.t("videoModule.videoPosterPlaceHolder")),2),y=h[0],g=h[1],m=u.default(v),b=u.default(g),w=l(t.genModalButtonElems(f,t.t("videoModule.ok")),1)[0];if(null==this.$content){var S=u.default("<div></div>");S.on("click","#"+f,(function(o){return c(r,void 0,void 0,(function(){var r,u,c,f;return s(this,(function(s){return o.preventDefault(),r=S.find("#"+i).val().trim(),u=S.find("#"+a).val().trim(),c=Jr("video-"),f={src:r,poster:u,key:c},n.restoreSelection(),e.Transforms.setNodes(n,f,{match:function(e){return t.DomEditor.checkNodeType(e,"video")}}),n.hidePanelOrModal(),[2]}))}))})),this.$content=S}var x=this.$content;x.empty(),x.append(p),x.append(y),x.append(w);var E=this.getSelectedVideoNode(n);if(null==E)return x[0];var O=E.src,I=void 0===O?"":O,j=E.poster,M=void 0===j?"":j;return m.val(I),b.val(M),setTimeout((function(){m.focus()})),x[0]},n}();var Ga={renderElems:[fn],elemsToHtml:[dn],preParseHtml:[jn],parseElemsHtml:[Jn],menus:[{key:"insertVideo",factory:function(){return new eu},config:{onInsertedVideo:function(t){},checkVideo:function(t,e){return!0},parseVideoSrc:function(t){return t}}},{key:"uploadVideo",factory:function(){return new Fa},config:{server:"",fieldName:"wangeditor-uploaded-video",maxFileSize:10485760,maxNumberOfFiles:5,allowedFileTypes:["video/*"],meta:{},metaWithUrl:!1,withCredentials:!1,timeout:3e4,onBeforeUpload:function(t){return t},onProgress:function(t){},onSuccess:function(t,e){},onFailed:function(t,e){console.error("'"+t.name+"' upload failed",e)},onError:function(t,e,n){console.error("'"+t.name+" upload error",e,n)}}},{key:"editVideoSize",factory:function(){return new _a}},{key:"editVideoSrc",factory:function(){return new Ha}}],editorPlugin:function(n){var r=n.isVoid,o=n.normalizeNode,i=n;return i.isVoid=function(t){return"video"===t.type||r(t)},i.normalizeNode=function(n){var r=l(n,2),u=r[0],a=r[1];"video"===t.DomEditor.getNodeType(u)&&(t.DomEditor.isLastNode(i,u)&&e.Transforms.insertNodes(i,t.DomEditor.genEmptyParagraph(),{at:[a[0]+1]}));return o([u,a])},i}};return Ga}));
2
+ //# sourceMappingURL=index.js.map