@wangeditor-next/video-module 1.2.1 → 1.2.2
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.2.2](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/video-module@1.2.1...@wangeditor-next/video-module@1.2.2) (2024-06-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Performance Improvements
|
|
10
|
+
|
|
11
|
+
* add edit image and video width height menu ([f0a9ce6](https://github.com/cycleccc/wangEditor/commit/f0a9ce6a24107e6e4865f38dd8cd1c7f048551f2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.2.1](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/video-module@1.2.0...@wangeditor-next/video-module@1.2.1) (2024-06-04)
|
|
7
18
|
|
|
8
19
|
|
package/dist/index.esm.js
CHANGED
|
@@ -224,12 +224,20 @@ function getTagName($elem) {
|
|
|
224
224
|
* @param height height
|
|
225
225
|
* @returns iframe html string with size style
|
|
226
226
|
*/
|
|
227
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
227
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
228
228
|
if (width === void 0) { width = 'auto'; }
|
|
229
229
|
if (height === void 0) { height = 'auto'; }
|
|
230
|
+
if (style === void 0) { style = {}; }
|
|
230
231
|
var $iframe = $(iframeHtml);
|
|
232
|
+
var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
|
|
233
|
+
var styleStr = '';
|
|
234
|
+
if (styleWidth)
|
|
235
|
+
styleStr += "width: " + styleWidth + ";";
|
|
236
|
+
if (styleHeight)
|
|
237
|
+
styleStr += "height: " + styleHeight + ";";
|
|
231
238
|
$iframe.attr('width', width);
|
|
232
239
|
$iframe.attr('height', height);
|
|
240
|
+
$iframe.attr('style', styleStr);
|
|
233
241
|
return $iframe[0].outerHTML;
|
|
234
242
|
}
|
|
235
243
|
|
|
@@ -238,19 +246,19 @@ function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
|
238
246
|
* @author wangfupeng
|
|
239
247
|
*/
|
|
240
248
|
function renderVideo(elemNode, children, editor) {
|
|
241
|
-
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;
|
|
249
|
+
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;
|
|
242
250
|
// 是否选中
|
|
243
251
|
var selected = DomEditor.isNodeSelected(editor, elemNode);
|
|
244
252
|
var vnode;
|
|
245
253
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
246
254
|
// 增加尺寸样式
|
|
247
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
255
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
248
256
|
// iframe 形式,第三方视频
|
|
249
257
|
vnode = (jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
250
258
|
}
|
|
251
259
|
else {
|
|
252
260
|
// 其他,mp4 格式
|
|
253
|
-
var videoVnode = (jsx("video", { poster: poster, controls: true },
|
|
261
|
+
var videoVnode = (jsx("video", { poster: poster, controls: true, style: style },
|
|
254
262
|
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"));
|
|
255
263
|
// @ts-ignore 添加尺寸
|
|
256
264
|
if (width !== 'auto')
|
|
@@ -281,16 +289,22 @@ var renderVideoConf = {
|
|
|
281
289
|
* @author wangfupeng
|
|
282
290
|
*/
|
|
283
291
|
function videoToHtml(elemNode, childrenHtml) {
|
|
284
|
-
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;
|
|
292
|
+
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;
|
|
285
293
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
286
294
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
287
295
|
// iframe 形式
|
|
288
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
296
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
289
297
|
res += iframeHtml;
|
|
290
298
|
}
|
|
291
299
|
else {
|
|
292
300
|
// 其他,mp4 等 url 格式
|
|
293
|
-
|
|
301
|
+
var _g = style.width, styleWidth = _g === void 0 ? '' : _g, _h = style.height, styleHeight = _h === void 0 ? '' : _h;
|
|
302
|
+
var styleStr = '';
|
|
303
|
+
if (styleWidth)
|
|
304
|
+
styleStr += "width: " + styleWidth + ";";
|
|
305
|
+
if (styleHeight)
|
|
306
|
+
styleStr += "height: " + styleHeight + ";";
|
|
307
|
+
res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
|
|
294
308
|
}
|
|
295
309
|
res += '\n</div>';
|
|
296
310
|
return res;
|
|
@@ -331,7 +345,7 @@ function preParse(elem) {
|
|
|
331
345
|
var $parent = $video.parent();
|
|
332
346
|
if ($parent.attr('data-w-e-type') === 'video')
|
|
333
347
|
return $video[0];
|
|
334
|
-
var $container = $("<div data-w-e-type=\"video\" data-w-e-is-void></div>");
|
|
348
|
+
var $container = $("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
|
|
335
349
|
$container.append($video);
|
|
336
350
|
return $container[0];
|
|
337
351
|
}
|
|
@@ -344,16 +358,18 @@ var preParseHtmlConf = {
|
|
|
344
358
|
* @description parse html
|
|
345
359
|
* @author wangfupeng
|
|
346
360
|
*/
|
|
347
|
-
function genVideoElem(src, poster, width, height) {
|
|
361
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
348
362
|
if (poster === void 0) { poster = ''; }
|
|
349
363
|
if (width === void 0) { width = 'auto'; }
|
|
350
364
|
if (height === void 0) { height = 'auto'; }
|
|
365
|
+
if (style === void 0) { style = {}; }
|
|
351
366
|
return {
|
|
352
367
|
type: 'video',
|
|
353
368
|
src: src,
|
|
354
369
|
poster: poster,
|
|
355
370
|
width: width,
|
|
356
371
|
height: height,
|
|
372
|
+
style: style,
|
|
357
373
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
358
374
|
};
|
|
359
375
|
}
|
|
@@ -363,13 +379,15 @@ function parseHtml(elem, children, editor) {
|
|
|
363
379
|
var poster = '';
|
|
364
380
|
var width = 'auto';
|
|
365
381
|
var height = 'auto';
|
|
382
|
+
var style = {};
|
|
366
383
|
// <iframe> 形式
|
|
367
384
|
var $iframe = $elem.find('iframe');
|
|
368
385
|
if ($iframe.length > 0) {
|
|
369
386
|
width = $iframe.attr('width') || 'auto';
|
|
370
387
|
height = $iframe.attr('height') || 'auto';
|
|
388
|
+
style = $iframe.attr('style') || {};
|
|
371
389
|
src = $iframe[0].outerHTML;
|
|
372
|
-
return genVideoElem(src, poster, width, height);
|
|
390
|
+
return genVideoElem(src, poster, width, height, style);
|
|
373
391
|
}
|
|
374
392
|
// <video> 形式
|
|
375
393
|
var $video = $elem.find('video');
|
|
@@ -383,7 +401,8 @@ function parseHtml(elem, children, editor) {
|
|
|
383
401
|
width = $video.attr('width') || 'auto';
|
|
384
402
|
height = $video.attr('height') || 'auto';
|
|
385
403
|
poster = $video.attr('poster') || '';
|
|
386
|
-
|
|
404
|
+
style = $iframe.attr('style') || {};
|
|
405
|
+
return genVideoElem(src, poster, width, height, style);
|
|
387
406
|
}
|
|
388
407
|
var parseHtmlConf = {
|
|
389
408
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -434,8 +453,10 @@ var UPLOAD_VIDEO_SVG = '<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.81
|
|
|
434
453
|
* @param src video src
|
|
435
454
|
* @param poster video poster
|
|
436
455
|
*/
|
|
437
|
-
function insertVideo (editor, src, poster) {
|
|
456
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
438
457
|
if (poster === void 0) { poster = ''; }
|
|
458
|
+
if (width === void 0) { width = ''; }
|
|
459
|
+
if (height === void 0) { height = ''; }
|
|
439
460
|
return __awaiter(this, void 0, void 0, function () {
|
|
440
461
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
441
462
|
return __generator(this, function (_b) {
|
|
@@ -468,7 +489,11 @@ function insertVideo (editor, src, poster) {
|
|
|
468
489
|
type: 'video',
|
|
469
490
|
src: parsedSrc,
|
|
470
491
|
poster: poster,
|
|
471
|
-
children: [{ text: '' }],
|
|
492
|
+
children: [{ text: '' }],
|
|
493
|
+
style: {
|
|
494
|
+
width: width,
|
|
495
|
+
height: height,
|
|
496
|
+
},
|
|
472
497
|
};
|
|
473
498
|
// 插入视频
|
|
474
499
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -871,13 +896,30 @@ var EditorVideoSizeMenu = /** @class */ (function () {
|
|
|
871
896
|
e.preventDefault();
|
|
872
897
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
873
898
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
874
|
-
var
|
|
875
|
-
var
|
|
876
|
-
var width =
|
|
877
|
-
var height =
|
|
899
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
900
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
901
|
+
var width = 'auto';
|
|
902
|
+
var height = 'auto';
|
|
903
|
+
if (isPercentage(rawWidth)) {
|
|
904
|
+
width = rawWidth;
|
|
905
|
+
}
|
|
906
|
+
else if (isNumeric(rawWidth)) {
|
|
907
|
+
width = parseInt(rawWidth) + 'px';
|
|
908
|
+
}
|
|
909
|
+
if (isPercentage(rawHeight)) {
|
|
910
|
+
height = rawHeight;
|
|
911
|
+
}
|
|
912
|
+
else if (isNumeric(rawHeight)) {
|
|
913
|
+
height = parseInt(rawHeight) + 'px';
|
|
914
|
+
}
|
|
915
|
+
var _a = videoNode.style, style = _a === void 0 ? {} : _a;
|
|
878
916
|
editor.restoreSelection();
|
|
917
|
+
var props = __assign(__assign({}, style), { style: {
|
|
918
|
+
width: width,
|
|
919
|
+
height: height,
|
|
920
|
+
} });
|
|
879
921
|
// 修改尺寸
|
|
880
|
-
Transforms.setNodes(editor,
|
|
922
|
+
Transforms.setNodes(editor, props, {
|
|
881
923
|
match: function (n) { return DomEditor.checkNodeType(n, 'video'); },
|
|
882
924
|
});
|
|
883
925
|
editor.hidePanelOrModal(); // 隐藏 modal
|
package/dist/index.js
CHANGED
|
@@ -228,12 +228,20 @@
|
|
|
228
228
|
* @param height height
|
|
229
229
|
* @returns iframe html string with size style
|
|
230
230
|
*/
|
|
231
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
231
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
232
232
|
if (width === void 0) { width = 'auto'; }
|
|
233
233
|
if (height === void 0) { height = 'auto'; }
|
|
234
|
+
if (style === void 0) { style = {}; }
|
|
234
235
|
var $iframe = $__default["default"](iframeHtml);
|
|
236
|
+
var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
|
|
237
|
+
var styleStr = '';
|
|
238
|
+
if (styleWidth)
|
|
239
|
+
styleStr += "width: " + styleWidth + ";";
|
|
240
|
+
if (styleHeight)
|
|
241
|
+
styleStr += "height: " + styleHeight + ";";
|
|
235
242
|
$iframe.attr('width', width);
|
|
236
243
|
$iframe.attr('height', height);
|
|
244
|
+
$iframe.attr('style', styleStr);
|
|
237
245
|
return $iframe[0].outerHTML;
|
|
238
246
|
}
|
|
239
247
|
|
|
@@ -242,19 +250,19 @@
|
|
|
242
250
|
* @author wangfupeng
|
|
243
251
|
*/
|
|
244
252
|
function renderVideo(elemNode, children, editor) {
|
|
245
|
-
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;
|
|
253
|
+
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;
|
|
246
254
|
// 是否选中
|
|
247
255
|
var selected = core.DomEditor.isNodeSelected(editor, elemNode);
|
|
248
256
|
var vnode;
|
|
249
257
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
250
258
|
// 增加尺寸样式
|
|
251
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
259
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
252
260
|
// iframe 形式,第三方视频
|
|
253
261
|
vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
254
262
|
}
|
|
255
263
|
else {
|
|
256
264
|
// 其他,mp4 格式
|
|
257
|
-
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true },
|
|
265
|
+
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true, style: style },
|
|
258
266
|
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"));
|
|
259
267
|
// @ts-ignore 添加尺寸
|
|
260
268
|
if (width !== 'auto')
|
|
@@ -285,16 +293,22 @@
|
|
|
285
293
|
* @author wangfupeng
|
|
286
294
|
*/
|
|
287
295
|
function videoToHtml(elemNode, childrenHtml) {
|
|
288
|
-
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;
|
|
296
|
+
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;
|
|
289
297
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
290
298
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
291
299
|
// iframe 形式
|
|
292
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
300
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
293
301
|
res += iframeHtml;
|
|
294
302
|
}
|
|
295
303
|
else {
|
|
296
304
|
// 其他,mp4 等 url 格式
|
|
297
|
-
|
|
305
|
+
var _g = style.width, styleWidth = _g === void 0 ? '' : _g, _h = style.height, styleHeight = _h === void 0 ? '' : _h;
|
|
306
|
+
var styleStr = '';
|
|
307
|
+
if (styleWidth)
|
|
308
|
+
styleStr += "width: " + styleWidth + ";";
|
|
309
|
+
if (styleHeight)
|
|
310
|
+
styleStr += "height: " + styleHeight + ";";
|
|
311
|
+
res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
|
|
298
312
|
}
|
|
299
313
|
res += '\n</div>';
|
|
300
314
|
return res;
|
|
@@ -335,7 +349,7 @@
|
|
|
335
349
|
var $parent = $video.parent();
|
|
336
350
|
if ($parent.attr('data-w-e-type') === 'video')
|
|
337
351
|
return $video[0];
|
|
338
|
-
var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void></div>");
|
|
352
|
+
var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
|
|
339
353
|
$container.append($video);
|
|
340
354
|
return $container[0];
|
|
341
355
|
}
|
|
@@ -348,16 +362,18 @@
|
|
|
348
362
|
* @description parse html
|
|
349
363
|
* @author wangfupeng
|
|
350
364
|
*/
|
|
351
|
-
function genVideoElem(src, poster, width, height) {
|
|
365
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
352
366
|
if (poster === void 0) { poster = ''; }
|
|
353
367
|
if (width === void 0) { width = 'auto'; }
|
|
354
368
|
if (height === void 0) { height = 'auto'; }
|
|
369
|
+
if (style === void 0) { style = {}; }
|
|
355
370
|
return {
|
|
356
371
|
type: 'video',
|
|
357
372
|
src: src,
|
|
358
373
|
poster: poster,
|
|
359
374
|
width: width,
|
|
360
375
|
height: height,
|
|
376
|
+
style: style,
|
|
361
377
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
362
378
|
};
|
|
363
379
|
}
|
|
@@ -367,13 +383,15 @@
|
|
|
367
383
|
var poster = '';
|
|
368
384
|
var width = 'auto';
|
|
369
385
|
var height = 'auto';
|
|
386
|
+
var style = {};
|
|
370
387
|
// <iframe> 形式
|
|
371
388
|
var $iframe = $elem.find('iframe');
|
|
372
389
|
if ($iframe.length > 0) {
|
|
373
390
|
width = $iframe.attr('width') || 'auto';
|
|
374
391
|
height = $iframe.attr('height') || 'auto';
|
|
392
|
+
style = $iframe.attr('style') || {};
|
|
375
393
|
src = $iframe[0].outerHTML;
|
|
376
|
-
return genVideoElem(src, poster, width, height);
|
|
394
|
+
return genVideoElem(src, poster, width, height, style);
|
|
377
395
|
}
|
|
378
396
|
// <video> 形式
|
|
379
397
|
var $video = $elem.find('video');
|
|
@@ -387,7 +405,8 @@
|
|
|
387
405
|
width = $video.attr('width') || 'auto';
|
|
388
406
|
height = $video.attr('height') || 'auto';
|
|
389
407
|
poster = $video.attr('poster') || '';
|
|
390
|
-
|
|
408
|
+
style = $iframe.attr('style') || {};
|
|
409
|
+
return genVideoElem(src, poster, width, height, style);
|
|
391
410
|
}
|
|
392
411
|
var parseHtmlConf = {
|
|
393
412
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -438,8 +457,10 @@
|
|
|
438
457
|
* @param src video src
|
|
439
458
|
* @param poster video poster
|
|
440
459
|
*/
|
|
441
|
-
function insertVideo (editor, src, poster) {
|
|
460
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
442
461
|
if (poster === void 0) { poster = ''; }
|
|
462
|
+
if (width === void 0) { width = ''; }
|
|
463
|
+
if (height === void 0) { height = ''; }
|
|
443
464
|
return __awaiter(this, void 0, void 0, function () {
|
|
444
465
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
445
466
|
return __generator(this, function (_b) {
|
|
@@ -472,7 +493,11 @@
|
|
|
472
493
|
type: 'video',
|
|
473
494
|
src: parsedSrc,
|
|
474
495
|
poster: poster,
|
|
475
|
-
children: [{ text: '' }],
|
|
496
|
+
children: [{ text: '' }],
|
|
497
|
+
style: {
|
|
498
|
+
width: width,
|
|
499
|
+
height: height,
|
|
500
|
+
},
|
|
476
501
|
};
|
|
477
502
|
// 插入视频
|
|
478
503
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -875,13 +900,30 @@
|
|
|
875
900
|
e.preventDefault();
|
|
876
901
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
877
902
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
878
|
-
var
|
|
879
|
-
var
|
|
880
|
-
var width =
|
|
881
|
-
var height =
|
|
903
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
904
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
905
|
+
var width = 'auto';
|
|
906
|
+
var height = 'auto';
|
|
907
|
+
if (isPercentage(rawWidth)) {
|
|
908
|
+
width = rawWidth;
|
|
909
|
+
}
|
|
910
|
+
else if (isNumeric(rawWidth)) {
|
|
911
|
+
width = parseInt(rawWidth) + 'px';
|
|
912
|
+
}
|
|
913
|
+
if (isPercentage(rawHeight)) {
|
|
914
|
+
height = rawHeight;
|
|
915
|
+
}
|
|
916
|
+
else if (isNumeric(rawHeight)) {
|
|
917
|
+
height = parseInt(rawHeight) + 'px';
|
|
918
|
+
}
|
|
919
|
+
var _a = videoNode.style, style = _a === void 0 ? {} : _a;
|
|
882
920
|
editor.restoreSelection();
|
|
921
|
+
var props = __assign(__assign({}, style), { style: {
|
|
922
|
+
width: width,
|
|
923
|
+
height: height,
|
|
924
|
+
} });
|
|
883
925
|
// 修改尺寸
|
|
884
|
-
slate.Transforms.setNodes(editor,
|
|
926
|
+
slate.Transforms.setNodes(editor, props, {
|
|
885
927
|
match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
|
|
886
928
|
});
|
|
887
929
|
editor.hidePanelOrModal(); // 隐藏 modal
|
|
@@ -5,12 +5,17 @@
|
|
|
5
5
|
declare type EmptyText = {
|
|
6
6
|
text: '';
|
|
7
7
|
};
|
|
8
|
+
export declare type videoStyle = {
|
|
9
|
+
width?: string;
|
|
10
|
+
height?: string;
|
|
11
|
+
};
|
|
8
12
|
export declare type VideoElement = {
|
|
9
13
|
type: 'video';
|
|
10
14
|
src: string;
|
|
11
15
|
poster?: string;
|
|
12
16
|
width?: string;
|
|
13
17
|
height?: string;
|
|
18
|
+
style?: videoStyle;
|
|
14
19
|
children: EmptyText[];
|
|
15
20
|
};
|
|
16
21
|
export {};
|
|
@@ -9,4 +9,4 @@ import { IDomEditor } from '@wangeditor-next/core';
|
|
|
9
9
|
* @param src video src
|
|
10
10
|
* @param poster video poster
|
|
11
11
|
*/
|
|
12
|
-
export default function (editor: IDomEditor, src: string, poster?: string): Promise<void>;
|
|
12
|
+
export default function (editor: IDomEditor, src: string, poster?: string, width?: string, height?: string): Promise<void>;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
5
|
import $, { Dom7Array } from 'dom7';
|
|
6
|
+
import { videoStyle } from '../module/custom-types';
|
|
6
7
|
export { Dom7Array } from 'dom7';
|
|
7
8
|
export default $;
|
|
8
9
|
/**
|
|
@@ -17,7 +18,7 @@ export declare function getTagName($elem: Dom7Array): string;
|
|
|
17
18
|
* @param height height
|
|
18
19
|
* @returns iframe html string with size style
|
|
19
20
|
*/
|
|
20
|
-
export declare function genSizeStyledIframeHtml(iframeHtml: string, width?: string, height?: string): string;
|
|
21
|
+
export declare function genSizeStyledIframeHtml(iframeHtml: string, width?: string, height?: string, style?: videoStyle): string;
|
|
21
22
|
import DOMNode = globalThis.Node;
|
|
22
23
|
import DOMComment = globalThis.Comment;
|
|
23
24
|
import DOMElement = globalThis.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wangeditor-next/video-module",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "wangEditor video module",
|
|
5
5
|
"author": "wangfupeng1988 <wangfupeng1988@163.com>",
|
|
6
6
|
"contributors": [],
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"slate": "^0.72.0",
|
|
49
49
|
"snabbdom": "^3.1.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "4ccd72960067beab2c8905a9f38e216e2fd42994"
|
|
52
52
|
}
|