@wangeditor-next/editor 5.2.3 → 5.2.4
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 +11 -0
- package/dist/index.esm.js +208 -35
- package/dist/index.js +208 -35
- package/package.json +4 -4
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
|
+
## [5.2.4](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.2.3...@wangeditor-next/editor@5.2.4) (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
|
## [5.2.3](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.2.2...@wangeditor-next/editor@5.2.3) (2024-06-08)
|
|
7
18
|
|
|
8
19
|
|
package/dist/index.esm.js
CHANGED
|
@@ -24186,7 +24186,6 @@ var HoverBar = /** @class */ (function () {
|
|
|
24186
24186
|
}
|
|
24187
24187
|
//替换 icon svg
|
|
24188
24188
|
var menuConf = editor.getMenuConfig(key);
|
|
24189
|
-
console.log('🚀 ~ HoverBar ~ registerSingleItem ~ menuConf:', menuConf, menu);
|
|
24190
24189
|
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
24191
24190
|
menu.iconSvg = menuConf.iconSvg;
|
|
24192
24191
|
}
|
|
@@ -27381,10 +27380,14 @@ var enResources$5 = {
|
|
|
27381
27380
|
netImage: 'Net image',
|
|
27382
27381
|
delete: 'Delete image',
|
|
27383
27382
|
edit: 'Edit image',
|
|
27383
|
+
editSize: 'Edit size',
|
|
27384
27384
|
viewLink: 'View link',
|
|
27385
27385
|
src: 'Image src',
|
|
27386
27386
|
desc: 'Description',
|
|
27387
27387
|
link: 'Image link',
|
|
27388
|
+
ok: 'Ok',
|
|
27389
|
+
width: 'Width',
|
|
27390
|
+
height: 'Height',
|
|
27388
27391
|
},
|
|
27389
27392
|
indent: {
|
|
27390
27393
|
decrease: 'Decrease',
|
|
@@ -27475,10 +27478,14 @@ var zhResources$5 = {
|
|
|
27475
27478
|
netImage: '网络图片',
|
|
27476
27479
|
delete: '删除图片',
|
|
27477
27480
|
edit: '编辑图片',
|
|
27481
|
+
editSize: '修改尺寸',
|
|
27478
27482
|
viewLink: '查看链接',
|
|
27479
27483
|
src: '图片地址',
|
|
27480
27484
|
desc: '图片描述',
|
|
27481
27485
|
link: '图片链接',
|
|
27486
|
+
ok: '确定',
|
|
27487
|
+
width: '宽度',
|
|
27488
|
+
height: '高度',
|
|
27482
27489
|
},
|
|
27483
27490
|
indent: {
|
|
27484
27491
|
decrease: '减少缩进',
|
|
@@ -29681,7 +29688,7 @@ var parseHtmlConf$4 = {
|
|
|
29681
29688
|
/**
|
|
29682
29689
|
* 生成唯一的 DOM ID
|
|
29683
29690
|
*/
|
|
29684
|
-
function genDomID$
|
|
29691
|
+
function genDomID$4() {
|
|
29685
29692
|
return genRandomStr$1('w-e-insert-link');
|
|
29686
29693
|
}
|
|
29687
29694
|
var InsertLinkMenu = /** @class */ (function () {
|
|
@@ -29692,9 +29699,9 @@ var InsertLinkMenu = /** @class */ (function () {
|
|
|
29692
29699
|
this.showModal = true; // 点击 button 时显示 modal
|
|
29693
29700
|
this.modalWidth = 300;
|
|
29694
29701
|
this.$content = null;
|
|
29695
|
-
this.textInputId = genDomID$
|
|
29696
|
-
this.urlInputId = genDomID$
|
|
29697
|
-
this.buttonId = genDomID$
|
|
29702
|
+
this.textInputId = genDomID$4();
|
|
29703
|
+
this.urlInputId = genDomID$4();
|
|
29704
|
+
this.buttonId = genDomID$4();
|
|
29698
29705
|
}
|
|
29699
29706
|
InsertLinkMenu.prototype.getValue = function (editor) {
|
|
29700
29707
|
// 插入菜单,不需要 value
|
|
@@ -29770,7 +29777,7 @@ var InsertLinkMenu = /** @class */ (function () {
|
|
|
29770
29777
|
/**
|
|
29771
29778
|
* 生成唯一的 DOM ID
|
|
29772
29779
|
*/
|
|
29773
|
-
function genDomID$
|
|
29780
|
+
function genDomID$3() {
|
|
29774
29781
|
return genRandomStr$1('w-e-update-link');
|
|
29775
29782
|
}
|
|
29776
29783
|
var EditLinkMenu = /** @class */ (function () {
|
|
@@ -29781,8 +29788,8 @@ var EditLinkMenu = /** @class */ (function () {
|
|
|
29781
29788
|
this.showModal = true; // 点击 button 时显示 modal
|
|
29782
29789
|
this.modalWidth = 300;
|
|
29783
29790
|
this.$content = null;
|
|
29784
|
-
this.urlInputId = genDomID$
|
|
29785
|
-
this.buttonId = genDomID$
|
|
29791
|
+
this.urlInputId = genDomID$3();
|
|
29792
|
+
this.buttonId = genDomID$3();
|
|
29786
29793
|
}
|
|
29787
29794
|
EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
|
|
29788
29795
|
var node = DomEditor.getSelectedNodeByType(editor, 'link');
|
|
@@ -30410,7 +30417,7 @@ function isInsertImageMenuDisabled(editor) {
|
|
|
30410
30417
|
/**
|
|
30411
30418
|
* 生成唯一的 DOM ID
|
|
30412
30419
|
*/
|
|
30413
|
-
function genDomID$
|
|
30420
|
+
function genDomID$2() {
|
|
30414
30421
|
return genRandomStr$1('w-e-insert-image');
|
|
30415
30422
|
}
|
|
30416
30423
|
var InsertImage = /** @class */ (function () {
|
|
@@ -30421,10 +30428,10 @@ var InsertImage = /** @class */ (function () {
|
|
|
30421
30428
|
this.showModal = true; // 点击 button 时显示 modal
|
|
30422
30429
|
this.modalWidth = 300;
|
|
30423
30430
|
this.$content = null;
|
|
30424
|
-
this.srcInputId = genDomID$
|
|
30425
|
-
this.altInputId = genDomID$
|
|
30426
|
-
this.hrefInputId = genDomID$
|
|
30427
|
-
this.buttonId = genDomID$
|
|
30431
|
+
this.srcInputId = genDomID$2();
|
|
30432
|
+
this.altInputId = genDomID$2();
|
|
30433
|
+
this.hrefInputId = genDomID$2();
|
|
30434
|
+
this.buttonId = genDomID$2();
|
|
30428
30435
|
}
|
|
30429
30436
|
InsertImage.prototype.getValue = function (editor) {
|
|
30430
30437
|
// 插入菜单,不需要 value
|
|
@@ -30548,7 +30555,7 @@ var DeleteImage = /** @class */ (function () {
|
|
|
30548
30555
|
/**
|
|
30549
30556
|
* 生成唯一的 DOM ID
|
|
30550
30557
|
*/
|
|
30551
|
-
function genDomID$
|
|
30558
|
+
function genDomID$1$1() {
|
|
30552
30559
|
return genRandomStr$1('w-e-edit-image');
|
|
30553
30560
|
}
|
|
30554
30561
|
var EditImage = /** @class */ (function () {
|
|
@@ -30559,10 +30566,10 @@ var EditImage = /** @class */ (function () {
|
|
|
30559
30566
|
this.showModal = true; // 点击 button 时显示 modal
|
|
30560
30567
|
this.modalWidth = 300;
|
|
30561
30568
|
this.$content = null;
|
|
30562
|
-
this.srcInputId = genDomID$
|
|
30563
|
-
this.altInputId = genDomID$
|
|
30564
|
-
this.hrefInputId = genDomID$
|
|
30565
|
-
this.buttonId = genDomID$
|
|
30569
|
+
this.srcInputId = genDomID$1$1();
|
|
30570
|
+
this.altInputId = genDomID$1$1();
|
|
30571
|
+
this.hrefInputId = genDomID$1$1();
|
|
30572
|
+
this.buttonId = genDomID$1$1();
|
|
30566
30573
|
}
|
|
30567
30574
|
EditImage.prototype.getValue = function (editor) {
|
|
30568
30575
|
// 编辑图片,用不到 getValue
|
|
@@ -30797,6 +30804,122 @@ var ImageWidth100 = /** @class */ (function (_super) {
|
|
|
30797
30804
|
return ImageWidth100;
|
|
30798
30805
|
}(ImageWidthBaseClass));
|
|
30799
30806
|
|
|
30807
|
+
/**
|
|
30808
|
+
* @description 修改图片尺寸
|
|
30809
|
+
* @author wangfupeng
|
|
30810
|
+
*/
|
|
30811
|
+
/**
|
|
30812
|
+
* 生成唯一的 DOM ID
|
|
30813
|
+
*/
|
|
30814
|
+
function genDomID$5() {
|
|
30815
|
+
return genRandomStr$1('w-e-insert-image');
|
|
30816
|
+
}
|
|
30817
|
+
var EditorImageSizeMenu = /** @class */ (function () {
|
|
30818
|
+
function EditorImageSizeMenu() {
|
|
30819
|
+
this.title = t('image.editSize');
|
|
30820
|
+
this.tag = 'button';
|
|
30821
|
+
this.showModal = true; // 点击 button 时显示 modal
|
|
30822
|
+
this.modalWidth = 320;
|
|
30823
|
+
this.$content = null;
|
|
30824
|
+
this.widthInputId = genDomID$5();
|
|
30825
|
+
this.heightInputId = genDomID$5();
|
|
30826
|
+
this.buttonId = genDomID$5();
|
|
30827
|
+
}
|
|
30828
|
+
EditorImageSizeMenu.prototype.getSelectedImageNode = function (editor) {
|
|
30829
|
+
return DomEditor.getSelectedNodeByType(editor, 'image');
|
|
30830
|
+
};
|
|
30831
|
+
EditorImageSizeMenu.prototype.getValue = function (editor) {
|
|
30832
|
+
// 插入菜单,不需要 value
|
|
30833
|
+
return '';
|
|
30834
|
+
};
|
|
30835
|
+
EditorImageSizeMenu.prototype.isActive = function (editor) {
|
|
30836
|
+
// 任何时候,都不用激活 menu
|
|
30837
|
+
return false;
|
|
30838
|
+
};
|
|
30839
|
+
EditorImageSizeMenu.prototype.exec = function (editor, value) {
|
|
30840
|
+
// 点击菜单时,弹出 modal 之前,不需要执行其他代码
|
|
30841
|
+
// 此处空着即可
|
|
30842
|
+
};
|
|
30843
|
+
EditorImageSizeMenu.prototype.isDisabled = function (editor) {
|
|
30844
|
+
if (editor.selection == null)
|
|
30845
|
+
return true;
|
|
30846
|
+
var imageNode = this.getSelectedImageNode(editor);
|
|
30847
|
+
if (imageNode == null) {
|
|
30848
|
+
// 选区未处于 image node ,则禁用
|
|
30849
|
+
return true;
|
|
30850
|
+
}
|
|
30851
|
+
return false;
|
|
30852
|
+
};
|
|
30853
|
+
EditorImageSizeMenu.prototype.getModalPositionNode = function (editor) {
|
|
30854
|
+
return this.getSelectedImageNode(editor);
|
|
30855
|
+
};
|
|
30856
|
+
EditorImageSizeMenu.prototype.getModalContentElem = function (editor) {
|
|
30857
|
+
// return $('<div><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p></div>')[0]
|
|
30858
|
+
var _a = this, widthInputId = _a.widthInputId, heightInputId = _a.heightInputId, buttonId = _a.buttonId;
|
|
30859
|
+
var _b = __read$5(genModalInputElems(t('image.width'), widthInputId, 'auto'), 2), widthContainerElem = _b[0], inputWidthElem = _b[1];
|
|
30860
|
+
var $inputWidth = $(inputWidthElem);
|
|
30861
|
+
var _c = __read$5(genModalInputElems(t('image.height'), heightInputId, 'auto'), 2), heightContainerElem = _c[0], inputHeightElem = _c[1];
|
|
30862
|
+
var $inputHeight = $(inputHeightElem);
|
|
30863
|
+
var _d = __read$5(genModalButtonElems(buttonId, t('image.ok')), 1), buttonContainerElem = _d[0];
|
|
30864
|
+
if (this.$content == null) {
|
|
30865
|
+
// 第一次渲染
|
|
30866
|
+
var $content_1 = $('<div></div>');
|
|
30867
|
+
// 绑定事件(第一次渲染时绑定,不要重复绑定)
|
|
30868
|
+
$content_1.on('click', "#" + buttonId, function (e) {
|
|
30869
|
+
e.preventDefault();
|
|
30870
|
+
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
30871
|
+
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
30872
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
30873
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
30874
|
+
var width = 'auto';
|
|
30875
|
+
var height = 'auto';
|
|
30876
|
+
if (isPercentage(rawWidth)) {
|
|
30877
|
+
width = rawWidth;
|
|
30878
|
+
}
|
|
30879
|
+
else if (isNumeric(rawWidth)) {
|
|
30880
|
+
width = parseInt(rawWidth) + 'px';
|
|
30881
|
+
}
|
|
30882
|
+
if (isPercentage(rawHeight)) {
|
|
30883
|
+
height = rawHeight;
|
|
30884
|
+
}
|
|
30885
|
+
else if (isNumeric(rawHeight)) {
|
|
30886
|
+
height = parseInt(rawHeight) + 'px';
|
|
30887
|
+
}
|
|
30888
|
+
var _a = imageNode.style, style = _a === void 0 ? {} : _a;
|
|
30889
|
+
editor.restoreSelection();
|
|
30890
|
+
var props = __assign$3(__assign$3({}, style), { style: {
|
|
30891
|
+
width: width,
|
|
30892
|
+
height: height,
|
|
30893
|
+
} });
|
|
30894
|
+
// 修改尺寸
|
|
30895
|
+
Transforms.setNodes(editor, props, {
|
|
30896
|
+
match: function (n) { return DomEditor.checkNodeType(n, 'image'); },
|
|
30897
|
+
});
|
|
30898
|
+
editor.hidePanelOrModal(); // 隐藏 modal
|
|
30899
|
+
});
|
|
30900
|
+
this.$content = $content_1;
|
|
30901
|
+
}
|
|
30902
|
+
var $content = this.$content;
|
|
30903
|
+
// 先清空,再重新添加 DOM 内容
|
|
30904
|
+
$content.empty();
|
|
30905
|
+
$content.append(widthContainerElem);
|
|
30906
|
+
$content.append(heightContainerElem);
|
|
30907
|
+
$content.append(buttonContainerElem);
|
|
30908
|
+
var imageNode = this.getSelectedImageNode(editor);
|
|
30909
|
+
if (imageNode == null)
|
|
30910
|
+
return $content[0];
|
|
30911
|
+
// 初始化 input 值
|
|
30912
|
+
var _e = imageNode.width, width = _e === void 0 ? 'auto' : _e, _f = imageNode.height, height = _f === void 0 ? 'auto' : _f;
|
|
30913
|
+
$inputWidth.val(width);
|
|
30914
|
+
$inputHeight.val(height);
|
|
30915
|
+
setTimeout(function () {
|
|
30916
|
+
$inputWidth.focus();
|
|
30917
|
+
});
|
|
30918
|
+
return $content[0];
|
|
30919
|
+
};
|
|
30920
|
+
return EditorImageSizeMenu;
|
|
30921
|
+
}());
|
|
30922
|
+
|
|
30800
30923
|
/**
|
|
30801
30924
|
* @description 图片菜单配置
|
|
30802
30925
|
* @author wangfupeng
|
|
@@ -30890,6 +31013,12 @@ var imageWidth100MenuConf = {
|
|
|
30890
31013
|
factory: function () {
|
|
30891
31014
|
return new ImageWidth100();
|
|
30892
31015
|
},
|
|
31016
|
+
};
|
|
31017
|
+
var EditorImageSizeMenuConf = {
|
|
31018
|
+
key: 'editorImageSizeMenu',
|
|
31019
|
+
factory: function () {
|
|
31020
|
+
return new EditorImageSizeMenu();
|
|
31021
|
+
},
|
|
30893
31022
|
};
|
|
30894
31023
|
|
|
30895
31024
|
/**
|
|
@@ -30908,6 +31037,7 @@ var image$1 = {
|
|
|
30908
31037
|
imageWidth30MenuConf,
|
|
30909
31038
|
imageWidth50MenuConf,
|
|
30910
31039
|
imageWidth100MenuConf,
|
|
31040
|
+
EditorImageSizeMenuConf,
|
|
30911
31041
|
],
|
|
30912
31042
|
editorPlugin: withImage,
|
|
30913
31043
|
};
|
|
@@ -37336,12 +37466,20 @@ function getTagName($elem) {
|
|
|
37336
37466
|
* @param height height
|
|
37337
37467
|
* @returns iframe html string with size style
|
|
37338
37468
|
*/
|
|
37339
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
37469
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
37340
37470
|
if (width === void 0) { width = 'auto'; }
|
|
37341
37471
|
if (height === void 0) { height = 'auto'; }
|
|
37472
|
+
if (style === void 0) { style = {}; }
|
|
37342
37473
|
var $iframe = $(iframeHtml);
|
|
37474
|
+
var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
|
|
37475
|
+
var styleStr = '';
|
|
37476
|
+
if (styleWidth)
|
|
37477
|
+
styleStr += "width: " + styleWidth + ";";
|
|
37478
|
+
if (styleHeight)
|
|
37479
|
+
styleStr += "height: " + styleHeight + ";";
|
|
37343
37480
|
$iframe.attr('width', width);
|
|
37344
37481
|
$iframe.attr('height', height);
|
|
37482
|
+
$iframe.attr('style', styleStr);
|
|
37345
37483
|
return $iframe[0].outerHTML;
|
|
37346
37484
|
}
|
|
37347
37485
|
|
|
@@ -37350,19 +37488,19 @@ function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
|
37350
37488
|
* @author wangfupeng
|
|
37351
37489
|
*/
|
|
37352
37490
|
function renderVideo(elemNode, children, editor) {
|
|
37353
|
-
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;
|
|
37491
|
+
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;
|
|
37354
37492
|
// 是否选中
|
|
37355
37493
|
var selected = DomEditor.isNodeSelected(editor, elemNode);
|
|
37356
37494
|
var vnode;
|
|
37357
37495
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
37358
37496
|
// 增加尺寸样式
|
|
37359
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
37497
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
37360
37498
|
// iframe 形式,第三方视频
|
|
37361
37499
|
vnode = (jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
37362
37500
|
}
|
|
37363
37501
|
else {
|
|
37364
37502
|
// 其他,mp4 格式
|
|
37365
|
-
var videoVnode = (jsx("video", { poster: poster, controls: true },
|
|
37503
|
+
var videoVnode = (jsx("video", { poster: poster, controls: true, style: style },
|
|
37366
37504
|
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"));
|
|
37367
37505
|
// @ts-ignore 添加尺寸
|
|
37368
37506
|
if (width !== 'auto')
|
|
@@ -37393,16 +37531,22 @@ var renderVideoConf = {
|
|
|
37393
37531
|
* @author wangfupeng
|
|
37394
37532
|
*/
|
|
37395
37533
|
function videoToHtml(elemNode, childrenHtml) {
|
|
37396
|
-
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;
|
|
37534
|
+
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;
|
|
37397
37535
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
37398
37536
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
37399
37537
|
// iframe 形式
|
|
37400
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
37538
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
37401
37539
|
res += iframeHtml;
|
|
37402
37540
|
}
|
|
37403
37541
|
else {
|
|
37404
37542
|
// 其他,mp4 等 url 格式
|
|
37405
|
-
|
|
37543
|
+
var _g = style.width, styleWidth = _g === void 0 ? '' : _g, _h = style.height, styleHeight = _h === void 0 ? '' : _h;
|
|
37544
|
+
var styleStr = '';
|
|
37545
|
+
if (styleWidth)
|
|
37546
|
+
styleStr += "width: " + styleWidth + ";";
|
|
37547
|
+
if (styleHeight)
|
|
37548
|
+
styleStr += "height: " + styleHeight + ";";
|
|
37549
|
+
res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
|
|
37406
37550
|
}
|
|
37407
37551
|
res += '\n</div>';
|
|
37408
37552
|
return res;
|
|
@@ -37456,16 +37600,18 @@ var preParseHtmlConf = {
|
|
|
37456
37600
|
* @description parse html
|
|
37457
37601
|
* @author wangfupeng
|
|
37458
37602
|
*/
|
|
37459
|
-
function genVideoElem(src, poster, width, height) {
|
|
37603
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
37460
37604
|
if (poster === void 0) { poster = ''; }
|
|
37461
37605
|
if (width === void 0) { width = 'auto'; }
|
|
37462
37606
|
if (height === void 0) { height = 'auto'; }
|
|
37607
|
+
if (style === void 0) { style = {}; }
|
|
37463
37608
|
return {
|
|
37464
37609
|
type: 'video',
|
|
37465
37610
|
src: src,
|
|
37466
37611
|
poster: poster,
|
|
37467
37612
|
width: width,
|
|
37468
37613
|
height: height,
|
|
37614
|
+
style: style,
|
|
37469
37615
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
37470
37616
|
};
|
|
37471
37617
|
}
|
|
@@ -37475,13 +37621,15 @@ function parseHtml(elem, children, editor) {
|
|
|
37475
37621
|
var poster = '';
|
|
37476
37622
|
var width = 'auto';
|
|
37477
37623
|
var height = 'auto';
|
|
37624
|
+
var style = {};
|
|
37478
37625
|
// <iframe> 形式
|
|
37479
37626
|
var $iframe = $elem.find('iframe');
|
|
37480
37627
|
if ($iframe.length > 0) {
|
|
37481
37628
|
width = $iframe.attr('width') || 'auto';
|
|
37482
37629
|
height = $iframe.attr('height') || 'auto';
|
|
37630
|
+
style = $iframe.attr('style') || {};
|
|
37483
37631
|
src = $iframe[0].outerHTML;
|
|
37484
|
-
return genVideoElem(src, poster, width, height);
|
|
37632
|
+
return genVideoElem(src, poster, width, height, style);
|
|
37485
37633
|
}
|
|
37486
37634
|
// <video> 形式
|
|
37487
37635
|
var $video = $elem.find('video');
|
|
@@ -37495,7 +37643,8 @@ function parseHtml(elem, children, editor) {
|
|
|
37495
37643
|
width = $video.attr('width') || 'auto';
|
|
37496
37644
|
height = $video.attr('height') || 'auto';
|
|
37497
37645
|
poster = $video.attr('poster') || '';
|
|
37498
|
-
|
|
37646
|
+
style = $iframe.attr('style') || {};
|
|
37647
|
+
return genVideoElem(src, poster, width, height, style);
|
|
37499
37648
|
}
|
|
37500
37649
|
var parseHtmlConf = {
|
|
37501
37650
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -37546,8 +37695,10 @@ var UPLOAD_VIDEO_SVG = '<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.81
|
|
|
37546
37695
|
* @param src video src
|
|
37547
37696
|
* @param poster video poster
|
|
37548
37697
|
*/
|
|
37549
|
-
function insertVideo (editor, src, poster) {
|
|
37698
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
37550
37699
|
if (poster === void 0) { poster = ''; }
|
|
37700
|
+
if (width === void 0) { width = ''; }
|
|
37701
|
+
if (height === void 0) { height = ''; }
|
|
37551
37702
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
37552
37703
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
37553
37704
|
return __generator$1(this, function (_b) {
|
|
@@ -37580,7 +37731,11 @@ function insertVideo (editor, src, poster) {
|
|
|
37580
37731
|
type: 'video',
|
|
37581
37732
|
src: parsedSrc,
|
|
37582
37733
|
poster: poster,
|
|
37583
|
-
children: [{ text: '' }],
|
|
37734
|
+
children: [{ text: '' }],
|
|
37735
|
+
style: {
|
|
37736
|
+
width: width,
|
|
37737
|
+
height: height,
|
|
37738
|
+
},
|
|
37584
37739
|
};
|
|
37585
37740
|
// 插入视频
|
|
37586
37741
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -37983,13 +38138,30 @@ var EditorVideoSizeMenu = /** @class */ (function () {
|
|
|
37983
38138
|
e.preventDefault();
|
|
37984
38139
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
37985
38140
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
37986
|
-
var
|
|
37987
|
-
var
|
|
37988
|
-
var width =
|
|
37989
|
-
var height =
|
|
38141
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
38142
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
38143
|
+
var width = 'auto';
|
|
38144
|
+
var height = 'auto';
|
|
38145
|
+
if (isPercentage(rawWidth)) {
|
|
38146
|
+
width = rawWidth;
|
|
38147
|
+
}
|
|
38148
|
+
else if (isNumeric(rawWidth)) {
|
|
38149
|
+
width = parseInt(rawWidth) + 'px';
|
|
38150
|
+
}
|
|
38151
|
+
if (isPercentage(rawHeight)) {
|
|
38152
|
+
height = rawHeight;
|
|
38153
|
+
}
|
|
38154
|
+
else if (isNumeric(rawHeight)) {
|
|
38155
|
+
height = parseInt(rawHeight) + 'px';
|
|
38156
|
+
}
|
|
38157
|
+
var _a = videoNode.style, style = _a === void 0 ? {} : _a;
|
|
37990
38158
|
editor.restoreSelection();
|
|
38159
|
+
var props = __assign$2(__assign$2({}, style), { style: {
|
|
38160
|
+
width: width,
|
|
38161
|
+
height: height,
|
|
38162
|
+
} });
|
|
37991
38163
|
// 修改尺寸
|
|
37992
|
-
Transforms.setNodes(editor,
|
|
38164
|
+
Transforms.setNodes(editor, props, {
|
|
37993
38165
|
match: function (n) { return DomEditor.checkNodeType(n, 'video'); },
|
|
37994
38166
|
});
|
|
37995
38167
|
editor.hidePanelOrModal(); // 隐藏 modal
|
|
@@ -43791,6 +43963,7 @@ var COMMON_HOVERBAR_KEYS = {
|
|
|
43791
43963
|
'imageWidth30',
|
|
43792
43964
|
'imageWidth50',
|
|
43793
43965
|
'imageWidth100',
|
|
43966
|
+
'editorImageSizeMenu',
|
|
43794
43967
|
'editImage',
|
|
43795
43968
|
'viewImageLink',
|
|
43796
43969
|
'deleteImage',
|
package/dist/index.js
CHANGED
|
@@ -28401,7 +28401,6 @@
|
|
|
28401
28401
|
}
|
|
28402
28402
|
//替换 icon svg
|
|
28403
28403
|
var menuConf = editor.getMenuConfig(key);
|
|
28404
|
-
console.log('🚀 ~ HoverBar ~ registerSingleItem ~ menuConf:', menuConf, menu);
|
|
28405
28404
|
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
28406
28405
|
menu.iconSvg = menuConf.iconSvg;
|
|
28407
28406
|
}
|
|
@@ -31712,10 +31711,14 @@
|
|
|
31712
31711
|
netImage: 'Net image',
|
|
31713
31712
|
delete: 'Delete image',
|
|
31714
31713
|
edit: 'Edit image',
|
|
31714
|
+
editSize: 'Edit size',
|
|
31715
31715
|
viewLink: 'View link',
|
|
31716
31716
|
src: 'Image src',
|
|
31717
31717
|
desc: 'Description',
|
|
31718
31718
|
link: 'Image link',
|
|
31719
|
+
ok: 'Ok',
|
|
31720
|
+
width: 'Width',
|
|
31721
|
+
height: 'Height',
|
|
31719
31722
|
},
|
|
31720
31723
|
indent: {
|
|
31721
31724
|
decrease: 'Decrease',
|
|
@@ -31806,10 +31809,14 @@
|
|
|
31806
31809
|
netImage: '网络图片',
|
|
31807
31810
|
delete: '删除图片',
|
|
31808
31811
|
edit: '编辑图片',
|
|
31812
|
+
editSize: '修改尺寸',
|
|
31809
31813
|
viewLink: '查看链接',
|
|
31810
31814
|
src: '图片地址',
|
|
31811
31815
|
desc: '图片描述',
|
|
31812
31816
|
link: '图片链接',
|
|
31817
|
+
ok: '确定',
|
|
31818
|
+
width: '宽度',
|
|
31819
|
+
height: '高度',
|
|
31813
31820
|
},
|
|
31814
31821
|
indent: {
|
|
31815
31822
|
decrease: '减少缩进',
|
|
@@ -34012,7 +34019,7 @@
|
|
|
34012
34019
|
/**
|
|
34013
34020
|
* 生成唯一的 DOM ID
|
|
34014
34021
|
*/
|
|
34015
|
-
function genDomID$
|
|
34022
|
+
function genDomID$4() {
|
|
34016
34023
|
return genRandomStr('w-e-insert-link');
|
|
34017
34024
|
}
|
|
34018
34025
|
var InsertLinkMenu = /** @class */ (function () {
|
|
@@ -34023,9 +34030,9 @@
|
|
|
34023
34030
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34024
34031
|
this.modalWidth = 300;
|
|
34025
34032
|
this.$content = null;
|
|
34026
|
-
this.textInputId = genDomID$
|
|
34027
|
-
this.urlInputId = genDomID$
|
|
34028
|
-
this.buttonId = genDomID$
|
|
34033
|
+
this.textInputId = genDomID$4();
|
|
34034
|
+
this.urlInputId = genDomID$4();
|
|
34035
|
+
this.buttonId = genDomID$4();
|
|
34029
34036
|
}
|
|
34030
34037
|
InsertLinkMenu.prototype.getValue = function (editor) {
|
|
34031
34038
|
// 插入菜单,不需要 value
|
|
@@ -34101,7 +34108,7 @@
|
|
|
34101
34108
|
/**
|
|
34102
34109
|
* 生成唯一的 DOM ID
|
|
34103
34110
|
*/
|
|
34104
|
-
function genDomID$
|
|
34111
|
+
function genDomID$3() {
|
|
34105
34112
|
return genRandomStr('w-e-update-link');
|
|
34106
34113
|
}
|
|
34107
34114
|
var EditLinkMenu = /** @class */ (function () {
|
|
@@ -34112,8 +34119,8 @@
|
|
|
34112
34119
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34113
34120
|
this.modalWidth = 300;
|
|
34114
34121
|
this.$content = null;
|
|
34115
|
-
this.urlInputId = genDomID$
|
|
34116
|
-
this.buttonId = genDomID$
|
|
34122
|
+
this.urlInputId = genDomID$3();
|
|
34123
|
+
this.buttonId = genDomID$3();
|
|
34117
34124
|
}
|
|
34118
34125
|
EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
|
|
34119
34126
|
var node = core.DomEditor.getSelectedNodeByType(editor, 'link');
|
|
@@ -34741,7 +34748,7 @@
|
|
|
34741
34748
|
/**
|
|
34742
34749
|
* 生成唯一的 DOM ID
|
|
34743
34750
|
*/
|
|
34744
|
-
function genDomID$
|
|
34751
|
+
function genDomID$2() {
|
|
34745
34752
|
return genRandomStr('w-e-insert-image');
|
|
34746
34753
|
}
|
|
34747
34754
|
var InsertImage = /** @class */ (function () {
|
|
@@ -34752,10 +34759,10 @@
|
|
|
34752
34759
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34753
34760
|
this.modalWidth = 300;
|
|
34754
34761
|
this.$content = null;
|
|
34755
|
-
this.srcInputId = genDomID$
|
|
34756
|
-
this.altInputId = genDomID$
|
|
34757
|
-
this.hrefInputId = genDomID$
|
|
34758
|
-
this.buttonId = genDomID$
|
|
34762
|
+
this.srcInputId = genDomID$2();
|
|
34763
|
+
this.altInputId = genDomID$2();
|
|
34764
|
+
this.hrefInputId = genDomID$2();
|
|
34765
|
+
this.buttonId = genDomID$2();
|
|
34759
34766
|
}
|
|
34760
34767
|
InsertImage.prototype.getValue = function (editor) {
|
|
34761
34768
|
// 插入菜单,不需要 value
|
|
@@ -34879,7 +34886,7 @@
|
|
|
34879
34886
|
/**
|
|
34880
34887
|
* 生成唯一的 DOM ID
|
|
34881
34888
|
*/
|
|
34882
|
-
function genDomID() {
|
|
34889
|
+
function genDomID$1() {
|
|
34883
34890
|
return genRandomStr('w-e-edit-image');
|
|
34884
34891
|
}
|
|
34885
34892
|
var EditImage = /** @class */ (function () {
|
|
@@ -34890,10 +34897,10 @@
|
|
|
34890
34897
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34891
34898
|
this.modalWidth = 300;
|
|
34892
34899
|
this.$content = null;
|
|
34893
|
-
this.srcInputId = genDomID();
|
|
34894
|
-
this.altInputId = genDomID();
|
|
34895
|
-
this.hrefInputId = genDomID();
|
|
34896
|
-
this.buttonId = genDomID();
|
|
34900
|
+
this.srcInputId = genDomID$1();
|
|
34901
|
+
this.altInputId = genDomID$1();
|
|
34902
|
+
this.hrefInputId = genDomID$1();
|
|
34903
|
+
this.buttonId = genDomID$1();
|
|
34897
34904
|
}
|
|
34898
34905
|
EditImage.prototype.getValue = function (editor) {
|
|
34899
34906
|
// 编辑图片,用不到 getValue
|
|
@@ -35128,6 +35135,122 @@
|
|
|
35128
35135
|
return ImageWidth100;
|
|
35129
35136
|
}(ImageWidthBaseClass));
|
|
35130
35137
|
|
|
35138
|
+
/**
|
|
35139
|
+
* @description 修改图片尺寸
|
|
35140
|
+
* @author wangfupeng
|
|
35141
|
+
*/
|
|
35142
|
+
/**
|
|
35143
|
+
* 生成唯一的 DOM ID
|
|
35144
|
+
*/
|
|
35145
|
+
function genDomID() {
|
|
35146
|
+
return genRandomStr('w-e-insert-image');
|
|
35147
|
+
}
|
|
35148
|
+
var EditorImageSizeMenu = /** @class */ (function () {
|
|
35149
|
+
function EditorImageSizeMenu() {
|
|
35150
|
+
this.title = core.t('image.editSize');
|
|
35151
|
+
this.tag = 'button';
|
|
35152
|
+
this.showModal = true; // 点击 button 时显示 modal
|
|
35153
|
+
this.modalWidth = 320;
|
|
35154
|
+
this.$content = null;
|
|
35155
|
+
this.widthInputId = genDomID();
|
|
35156
|
+
this.heightInputId = genDomID();
|
|
35157
|
+
this.buttonId = genDomID();
|
|
35158
|
+
}
|
|
35159
|
+
EditorImageSizeMenu.prototype.getSelectedImageNode = function (editor) {
|
|
35160
|
+
return core.DomEditor.getSelectedNodeByType(editor, 'image');
|
|
35161
|
+
};
|
|
35162
|
+
EditorImageSizeMenu.prototype.getValue = function (editor) {
|
|
35163
|
+
// 插入菜单,不需要 value
|
|
35164
|
+
return '';
|
|
35165
|
+
};
|
|
35166
|
+
EditorImageSizeMenu.prototype.isActive = function (editor) {
|
|
35167
|
+
// 任何时候,都不用激活 menu
|
|
35168
|
+
return false;
|
|
35169
|
+
};
|
|
35170
|
+
EditorImageSizeMenu.prototype.exec = function (editor, value) {
|
|
35171
|
+
// 点击菜单时,弹出 modal 之前,不需要执行其他代码
|
|
35172
|
+
// 此处空着即可
|
|
35173
|
+
};
|
|
35174
|
+
EditorImageSizeMenu.prototype.isDisabled = function (editor) {
|
|
35175
|
+
if (editor.selection == null)
|
|
35176
|
+
return true;
|
|
35177
|
+
var imageNode = this.getSelectedImageNode(editor);
|
|
35178
|
+
if (imageNode == null) {
|
|
35179
|
+
// 选区未处于 image node ,则禁用
|
|
35180
|
+
return true;
|
|
35181
|
+
}
|
|
35182
|
+
return false;
|
|
35183
|
+
};
|
|
35184
|
+
EditorImageSizeMenu.prototype.getModalPositionNode = function (editor) {
|
|
35185
|
+
return this.getSelectedImageNode(editor);
|
|
35186
|
+
};
|
|
35187
|
+
EditorImageSizeMenu.prototype.getModalContentElem = function (editor) {
|
|
35188
|
+
// return $('<div><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p></div>')[0]
|
|
35189
|
+
var _a = this, widthInputId = _a.widthInputId, heightInputId = _a.heightInputId, buttonId = _a.buttonId;
|
|
35190
|
+
var _b = __read(core.genModalInputElems(core.t('image.width'), widthInputId, 'auto'), 2), widthContainerElem = _b[0], inputWidthElem = _b[1];
|
|
35191
|
+
var $inputWidth = $__default["default"](inputWidthElem);
|
|
35192
|
+
var _c = __read(core.genModalInputElems(core.t('image.height'), heightInputId, 'auto'), 2), heightContainerElem = _c[0], inputHeightElem = _c[1];
|
|
35193
|
+
var $inputHeight = $__default["default"](inputHeightElem);
|
|
35194
|
+
var _d = __read(core.genModalButtonElems(buttonId, core.t('image.ok')), 1), buttonContainerElem = _d[0];
|
|
35195
|
+
if (this.$content == null) {
|
|
35196
|
+
// 第一次渲染
|
|
35197
|
+
var $content_1 = $__default["default"]('<div></div>');
|
|
35198
|
+
// 绑定事件(第一次渲染时绑定,不要重复绑定)
|
|
35199
|
+
$content_1.on('click', "#" + buttonId, function (e) {
|
|
35200
|
+
e.preventDefault();
|
|
35201
|
+
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
35202
|
+
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
35203
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
35204
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
35205
|
+
var width = 'auto';
|
|
35206
|
+
var height = 'auto';
|
|
35207
|
+
if (isPercentage(rawWidth)) {
|
|
35208
|
+
width = rawWidth;
|
|
35209
|
+
}
|
|
35210
|
+
else if (isNumeric(rawWidth)) {
|
|
35211
|
+
width = parseInt(rawWidth) + 'px';
|
|
35212
|
+
}
|
|
35213
|
+
if (isPercentage(rawHeight)) {
|
|
35214
|
+
height = rawHeight;
|
|
35215
|
+
}
|
|
35216
|
+
else if (isNumeric(rawHeight)) {
|
|
35217
|
+
height = parseInt(rawHeight) + 'px';
|
|
35218
|
+
}
|
|
35219
|
+
var _a = imageNode.style, style = _a === void 0 ? {} : _a;
|
|
35220
|
+
editor.restoreSelection();
|
|
35221
|
+
var props = __assign(__assign({}, style), { style: {
|
|
35222
|
+
width: width,
|
|
35223
|
+
height: height,
|
|
35224
|
+
} });
|
|
35225
|
+
// 修改尺寸
|
|
35226
|
+
slate.Transforms.setNodes(editor, props, {
|
|
35227
|
+
match: function (n) { return core.DomEditor.checkNodeType(n, 'image'); },
|
|
35228
|
+
});
|
|
35229
|
+
editor.hidePanelOrModal(); // 隐藏 modal
|
|
35230
|
+
});
|
|
35231
|
+
this.$content = $content_1;
|
|
35232
|
+
}
|
|
35233
|
+
var $content = this.$content;
|
|
35234
|
+
// 先清空,再重新添加 DOM 内容
|
|
35235
|
+
$content.empty();
|
|
35236
|
+
$content.append(widthContainerElem);
|
|
35237
|
+
$content.append(heightContainerElem);
|
|
35238
|
+
$content.append(buttonContainerElem);
|
|
35239
|
+
var imageNode = this.getSelectedImageNode(editor);
|
|
35240
|
+
if (imageNode == null)
|
|
35241
|
+
return $content[0];
|
|
35242
|
+
// 初始化 input 值
|
|
35243
|
+
var _e = imageNode.width, width = _e === void 0 ? 'auto' : _e, _f = imageNode.height, height = _f === void 0 ? 'auto' : _f;
|
|
35244
|
+
$inputWidth.val(width);
|
|
35245
|
+
$inputHeight.val(height);
|
|
35246
|
+
setTimeout(function () {
|
|
35247
|
+
$inputWidth.focus();
|
|
35248
|
+
});
|
|
35249
|
+
return $content[0];
|
|
35250
|
+
};
|
|
35251
|
+
return EditorImageSizeMenu;
|
|
35252
|
+
}());
|
|
35253
|
+
|
|
35131
35254
|
/**
|
|
35132
35255
|
* @description 图片菜单配置
|
|
35133
35256
|
* @author wangfupeng
|
|
@@ -35221,6 +35344,12 @@
|
|
|
35221
35344
|
factory: function () {
|
|
35222
35345
|
return new ImageWidth100();
|
|
35223
35346
|
},
|
|
35347
|
+
};
|
|
35348
|
+
var EditorImageSizeMenuConf = {
|
|
35349
|
+
key: 'editorImageSizeMenu',
|
|
35350
|
+
factory: function () {
|
|
35351
|
+
return new EditorImageSizeMenu();
|
|
35352
|
+
},
|
|
35224
35353
|
};
|
|
35225
35354
|
|
|
35226
35355
|
/**
|
|
@@ -35239,6 +35368,7 @@
|
|
|
35239
35368
|
imageWidth30MenuConf,
|
|
35240
35369
|
imageWidth50MenuConf,
|
|
35241
35370
|
imageWidth100MenuConf,
|
|
35371
|
+
EditorImageSizeMenuConf,
|
|
35242
35372
|
],
|
|
35243
35373
|
editorPlugin: withImage,
|
|
35244
35374
|
};
|
|
@@ -41725,12 +41855,20 @@
|
|
|
41725
41855
|
* @param height height
|
|
41726
41856
|
* @returns iframe html string with size style
|
|
41727
41857
|
*/
|
|
41728
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
41858
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
41729
41859
|
if (width === void 0) { width = 'auto'; }
|
|
41730
41860
|
if (height === void 0) { height = 'auto'; }
|
|
41861
|
+
if (style === void 0) { style = {}; }
|
|
41731
41862
|
var $iframe = $__default["default"](iframeHtml);
|
|
41863
|
+
var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
|
|
41864
|
+
var styleStr = '';
|
|
41865
|
+
if (styleWidth)
|
|
41866
|
+
styleStr += "width: " + styleWidth + ";";
|
|
41867
|
+
if (styleHeight)
|
|
41868
|
+
styleStr += "height: " + styleHeight + ";";
|
|
41732
41869
|
$iframe.attr('width', width);
|
|
41733
41870
|
$iframe.attr('height', height);
|
|
41871
|
+
$iframe.attr('style', styleStr);
|
|
41734
41872
|
return $iframe[0].outerHTML;
|
|
41735
41873
|
}
|
|
41736
41874
|
|
|
@@ -41739,19 +41877,19 @@
|
|
|
41739
41877
|
* @author wangfupeng
|
|
41740
41878
|
*/
|
|
41741
41879
|
function renderVideo(elemNode, children, editor) {
|
|
41742
|
-
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;
|
|
41880
|
+
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;
|
|
41743
41881
|
// 是否选中
|
|
41744
41882
|
var selected = core.DomEditor.isNodeSelected(editor, elemNode);
|
|
41745
41883
|
var vnode;
|
|
41746
41884
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
41747
41885
|
// 增加尺寸样式
|
|
41748
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
41886
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
41749
41887
|
// iframe 形式,第三方视频
|
|
41750
41888
|
vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
41751
41889
|
}
|
|
41752
41890
|
else {
|
|
41753
41891
|
// 其他,mp4 格式
|
|
41754
|
-
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true },
|
|
41892
|
+
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true, style: style },
|
|
41755
41893
|
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"));
|
|
41756
41894
|
// @ts-ignore 添加尺寸
|
|
41757
41895
|
if (width !== 'auto')
|
|
@@ -41782,16 +41920,22 @@
|
|
|
41782
41920
|
* @author wangfupeng
|
|
41783
41921
|
*/
|
|
41784
41922
|
function videoToHtml(elemNode, childrenHtml) {
|
|
41785
|
-
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;
|
|
41923
|
+
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;
|
|
41786
41924
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
41787
41925
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
41788
41926
|
// iframe 形式
|
|
41789
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
41927
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
41790
41928
|
res += iframeHtml;
|
|
41791
41929
|
}
|
|
41792
41930
|
else {
|
|
41793
41931
|
// 其他,mp4 等 url 格式
|
|
41794
|
-
|
|
41932
|
+
var _g = style.width, styleWidth = _g === void 0 ? '' : _g, _h = style.height, styleHeight = _h === void 0 ? '' : _h;
|
|
41933
|
+
var styleStr = '';
|
|
41934
|
+
if (styleWidth)
|
|
41935
|
+
styleStr += "width: " + styleWidth + ";";
|
|
41936
|
+
if (styleHeight)
|
|
41937
|
+
styleStr += "height: " + styleHeight + ";";
|
|
41938
|
+
res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
|
|
41795
41939
|
}
|
|
41796
41940
|
res += '\n</div>';
|
|
41797
41941
|
return res;
|
|
@@ -41845,16 +41989,18 @@
|
|
|
41845
41989
|
* @description parse html
|
|
41846
41990
|
* @author wangfupeng
|
|
41847
41991
|
*/
|
|
41848
|
-
function genVideoElem(src, poster, width, height) {
|
|
41992
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
41849
41993
|
if (poster === void 0) { poster = ''; }
|
|
41850
41994
|
if (width === void 0) { width = 'auto'; }
|
|
41851
41995
|
if (height === void 0) { height = 'auto'; }
|
|
41996
|
+
if (style === void 0) { style = {}; }
|
|
41852
41997
|
return {
|
|
41853
41998
|
type: 'video',
|
|
41854
41999
|
src: src,
|
|
41855
42000
|
poster: poster,
|
|
41856
42001
|
width: width,
|
|
41857
42002
|
height: height,
|
|
42003
|
+
style: style,
|
|
41858
42004
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
41859
42005
|
};
|
|
41860
42006
|
}
|
|
@@ -41864,13 +42010,15 @@
|
|
|
41864
42010
|
var poster = '';
|
|
41865
42011
|
var width = 'auto';
|
|
41866
42012
|
var height = 'auto';
|
|
42013
|
+
var style = {};
|
|
41867
42014
|
// <iframe> 形式
|
|
41868
42015
|
var $iframe = $elem.find('iframe');
|
|
41869
42016
|
if ($iframe.length > 0) {
|
|
41870
42017
|
width = $iframe.attr('width') || 'auto';
|
|
41871
42018
|
height = $iframe.attr('height') || 'auto';
|
|
42019
|
+
style = $iframe.attr('style') || {};
|
|
41872
42020
|
src = $iframe[0].outerHTML;
|
|
41873
|
-
return genVideoElem(src, poster, width, height);
|
|
42021
|
+
return genVideoElem(src, poster, width, height, style);
|
|
41874
42022
|
}
|
|
41875
42023
|
// <video> 形式
|
|
41876
42024
|
var $video = $elem.find('video');
|
|
@@ -41884,7 +42032,8 @@
|
|
|
41884
42032
|
width = $video.attr('width') || 'auto';
|
|
41885
42033
|
height = $video.attr('height') || 'auto';
|
|
41886
42034
|
poster = $video.attr('poster') || '';
|
|
41887
|
-
|
|
42035
|
+
style = $iframe.attr('style') || {};
|
|
42036
|
+
return genVideoElem(src, poster, width, height, style);
|
|
41888
42037
|
}
|
|
41889
42038
|
var parseHtmlConf = {
|
|
41890
42039
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -41935,8 +42084,10 @@
|
|
|
41935
42084
|
* @param src video src
|
|
41936
42085
|
* @param poster video poster
|
|
41937
42086
|
*/
|
|
41938
|
-
function insertVideo (editor, src, poster) {
|
|
42087
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
41939
42088
|
if (poster === void 0) { poster = ''; }
|
|
42089
|
+
if (width === void 0) { width = ''; }
|
|
42090
|
+
if (height === void 0) { height = ''; }
|
|
41940
42091
|
return __awaiter(this, void 0, void 0, function () {
|
|
41941
42092
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
41942
42093
|
return __generator(this, function (_b) {
|
|
@@ -41969,7 +42120,11 @@
|
|
|
41969
42120
|
type: 'video',
|
|
41970
42121
|
src: parsedSrc,
|
|
41971
42122
|
poster: poster,
|
|
41972
|
-
children: [{ text: '' }],
|
|
42123
|
+
children: [{ text: '' }],
|
|
42124
|
+
style: {
|
|
42125
|
+
width: width,
|
|
42126
|
+
height: height,
|
|
42127
|
+
},
|
|
41973
42128
|
};
|
|
41974
42129
|
// 插入视频
|
|
41975
42130
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -42372,13 +42527,30 @@
|
|
|
42372
42527
|
e.preventDefault();
|
|
42373
42528
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
42374
42529
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
42375
|
-
var
|
|
42376
|
-
var
|
|
42377
|
-
var width =
|
|
42378
|
-
var height =
|
|
42530
|
+
var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
|
|
42531
|
+
var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
|
|
42532
|
+
var width = 'auto';
|
|
42533
|
+
var height = 'auto';
|
|
42534
|
+
if (isPercentage(rawWidth)) {
|
|
42535
|
+
width = rawWidth;
|
|
42536
|
+
}
|
|
42537
|
+
else if (isNumeric(rawWidth)) {
|
|
42538
|
+
width = parseInt(rawWidth) + 'px';
|
|
42539
|
+
}
|
|
42540
|
+
if (isPercentage(rawHeight)) {
|
|
42541
|
+
height = rawHeight;
|
|
42542
|
+
}
|
|
42543
|
+
else if (isNumeric(rawHeight)) {
|
|
42544
|
+
height = parseInt(rawHeight) + 'px';
|
|
42545
|
+
}
|
|
42546
|
+
var _a = videoNode.style, style = _a === void 0 ? {} : _a;
|
|
42379
42547
|
editor.restoreSelection();
|
|
42548
|
+
var props = __assign(__assign({}, style), { style: {
|
|
42549
|
+
width: width,
|
|
42550
|
+
height: height,
|
|
42551
|
+
} });
|
|
42380
42552
|
// 修改尺寸
|
|
42381
|
-
slate.Transforms.setNodes(editor,
|
|
42553
|
+
slate.Transforms.setNodes(editor, props, {
|
|
42382
42554
|
match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
|
|
42383
42555
|
});
|
|
42384
42556
|
editor.hidePanelOrModal(); // 隐藏 modal
|
|
@@ -48224,6 +48396,7 @@
|
|
|
48224
48396
|
'imageWidth30',
|
|
48225
48397
|
'imageWidth50',
|
|
48226
48398
|
'imageWidth100',
|
|
48399
|
+
'editorImageSizeMenu',
|
|
48227
48400
|
'editImage',
|
|
48228
48401
|
'viewImageLink',
|
|
48229
48402
|
'deleteImage',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wangeditor-next/editor",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "Web rich text editor, Web 富文本编辑器",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wangeditor",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@uppy/core": "^2.1.1",
|
|
52
52
|
"@uppy/xhr-upload": "^2.0.3",
|
|
53
|
-
"@wangeditor-next/basic-modules": "^1.2.
|
|
53
|
+
"@wangeditor-next/basic-modules": "^1.2.1",
|
|
54
54
|
"@wangeditor-next/code-highlight": "^1.2.0",
|
|
55
55
|
"@wangeditor-next/core": "^1.2.1",
|
|
56
56
|
"@wangeditor-next/list-module": "^1.1.0",
|
|
57
57
|
"@wangeditor-next/table-module": "^1.2.0",
|
|
58
58
|
"@wangeditor-next/upload-image-module": "^1.1.0",
|
|
59
|
-
"@wangeditor-next/video-module": "^1.2.
|
|
59
|
+
"@wangeditor-next/video-module": "^1.2.2",
|
|
60
60
|
"dom7": "^3.0.0",
|
|
61
61
|
"is-hotkey": "^0.2.0",
|
|
62
62
|
"lodash.camelcase": "^4.3.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"slate": "^0.72.0",
|
|
71
71
|
"snabbdom": "^3.1.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "4ccd72960067beab2c8905a9f38e216e2fd42994"
|
|
74
74
|
}
|