@wangeditor-next/editor 5.2.2 → 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 +22 -0
- package/README.md +1 -2
- package/dist/index.esm.js +221 -39
- package/dist/index.js +221 -39
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
|
|
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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Performance Improvements
|
|
21
|
+
|
|
22
|
+
* **issue 13:** add replace icon svg by menu config ([a897f58](https://github.com/cycleccc/wangEditor/commit/a897f58fd85a7f8f4bd1e6ad1cd114457eebaf13))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [5.2.2](https://github.com/cycleccc/wangEditor/compare/@wangeditor-next/editor@5.2.1...@wangeditor-next/editor@5.2.2) (2024-06-04)
|
|
7
29
|
|
|
8
30
|
|
package/README.md
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -24184,6 +24184,11 @@ var HoverBar = /** @class */ (function () {
|
|
|
24184
24184
|
menu = factory();
|
|
24185
24185
|
menus[key] = menu;
|
|
24186
24186
|
}
|
|
24187
|
+
//替换 icon svg
|
|
24188
|
+
var menuConf = editor.getMenuConfig(key);
|
|
24189
|
+
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
24190
|
+
menu.iconSvg = menuConf.iconSvg;
|
|
24191
|
+
}
|
|
24187
24192
|
var barItem = createBarItem(key, menu);
|
|
24188
24193
|
this.hoverbarItems.push(barItem);
|
|
24189
24194
|
// 保存 barItem 和 editor 的关系
|
|
@@ -24598,6 +24603,11 @@ var Toolbar = /** @class */ (function () {
|
|
|
24598
24603
|
else {
|
|
24599
24604
|
console.warn("Duplicated toolbar menu key '" + key + "'\n\u91CD\u590D\u6CE8\u518C\u4E86\u83DC\u5355\u680F menu '" + key + "'");
|
|
24600
24605
|
}
|
|
24606
|
+
// 替换 icon svg
|
|
24607
|
+
var menuConf = editor.getMenuConfig(key);
|
|
24608
|
+
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
24609
|
+
menu.iconSvg = menuConf.iconSvg;
|
|
24610
|
+
}
|
|
24601
24611
|
var toolbarItem = createBarItem(key, menu, inGroup);
|
|
24602
24612
|
this.toolbarItems.push(toolbarItem);
|
|
24603
24613
|
// 保存 toolbarItem 和 editor 的关系
|
|
@@ -27370,10 +27380,14 @@ var enResources$5 = {
|
|
|
27370
27380
|
netImage: 'Net image',
|
|
27371
27381
|
delete: 'Delete image',
|
|
27372
27382
|
edit: 'Edit image',
|
|
27383
|
+
editSize: 'Edit size',
|
|
27373
27384
|
viewLink: 'View link',
|
|
27374
27385
|
src: 'Image src',
|
|
27375
27386
|
desc: 'Description',
|
|
27376
27387
|
link: 'Image link',
|
|
27388
|
+
ok: 'Ok',
|
|
27389
|
+
width: 'Width',
|
|
27390
|
+
height: 'Height',
|
|
27377
27391
|
},
|
|
27378
27392
|
indent: {
|
|
27379
27393
|
decrease: 'Decrease',
|
|
@@ -27464,10 +27478,14 @@ var zhResources$5 = {
|
|
|
27464
27478
|
netImage: '网络图片',
|
|
27465
27479
|
delete: '删除图片',
|
|
27466
27480
|
edit: '编辑图片',
|
|
27481
|
+
editSize: '修改尺寸',
|
|
27467
27482
|
viewLink: '查看链接',
|
|
27468
27483
|
src: '图片地址',
|
|
27469
27484
|
desc: '图片描述',
|
|
27470
27485
|
link: '图片链接',
|
|
27486
|
+
ok: '确定',
|
|
27487
|
+
width: '宽度',
|
|
27488
|
+
height: '高度',
|
|
27471
27489
|
},
|
|
27472
27490
|
indent: {
|
|
27473
27491
|
decrease: '减少缩进',
|
|
@@ -29670,7 +29688,7 @@ var parseHtmlConf$4 = {
|
|
|
29670
29688
|
/**
|
|
29671
29689
|
* 生成唯一的 DOM ID
|
|
29672
29690
|
*/
|
|
29673
|
-
function genDomID$
|
|
29691
|
+
function genDomID$4() {
|
|
29674
29692
|
return genRandomStr$1('w-e-insert-link');
|
|
29675
29693
|
}
|
|
29676
29694
|
var InsertLinkMenu = /** @class */ (function () {
|
|
@@ -29681,9 +29699,9 @@ var InsertLinkMenu = /** @class */ (function () {
|
|
|
29681
29699
|
this.showModal = true; // 点击 button 时显示 modal
|
|
29682
29700
|
this.modalWidth = 300;
|
|
29683
29701
|
this.$content = null;
|
|
29684
|
-
this.textInputId = genDomID$
|
|
29685
|
-
this.urlInputId = genDomID$
|
|
29686
|
-
this.buttonId = genDomID$
|
|
29702
|
+
this.textInputId = genDomID$4();
|
|
29703
|
+
this.urlInputId = genDomID$4();
|
|
29704
|
+
this.buttonId = genDomID$4();
|
|
29687
29705
|
}
|
|
29688
29706
|
InsertLinkMenu.prototype.getValue = function (editor) {
|
|
29689
29707
|
// 插入菜单,不需要 value
|
|
@@ -29759,7 +29777,7 @@ var InsertLinkMenu = /** @class */ (function () {
|
|
|
29759
29777
|
/**
|
|
29760
29778
|
* 生成唯一的 DOM ID
|
|
29761
29779
|
*/
|
|
29762
|
-
function genDomID$
|
|
29780
|
+
function genDomID$3() {
|
|
29763
29781
|
return genRandomStr$1('w-e-update-link');
|
|
29764
29782
|
}
|
|
29765
29783
|
var EditLinkMenu = /** @class */ (function () {
|
|
@@ -29770,8 +29788,8 @@ var EditLinkMenu = /** @class */ (function () {
|
|
|
29770
29788
|
this.showModal = true; // 点击 button 时显示 modal
|
|
29771
29789
|
this.modalWidth = 300;
|
|
29772
29790
|
this.$content = null;
|
|
29773
|
-
this.urlInputId = genDomID$
|
|
29774
|
-
this.buttonId = genDomID$
|
|
29791
|
+
this.urlInputId = genDomID$3();
|
|
29792
|
+
this.buttonId = genDomID$3();
|
|
29775
29793
|
}
|
|
29776
29794
|
EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
|
|
29777
29795
|
var node = DomEditor.getSelectedNodeByType(editor, 'link');
|
|
@@ -30399,7 +30417,7 @@ function isInsertImageMenuDisabled(editor) {
|
|
|
30399
30417
|
/**
|
|
30400
30418
|
* 生成唯一的 DOM ID
|
|
30401
30419
|
*/
|
|
30402
|
-
function genDomID$
|
|
30420
|
+
function genDomID$2() {
|
|
30403
30421
|
return genRandomStr$1('w-e-insert-image');
|
|
30404
30422
|
}
|
|
30405
30423
|
var InsertImage = /** @class */ (function () {
|
|
@@ -30410,10 +30428,10 @@ var InsertImage = /** @class */ (function () {
|
|
|
30410
30428
|
this.showModal = true; // 点击 button 时显示 modal
|
|
30411
30429
|
this.modalWidth = 300;
|
|
30412
30430
|
this.$content = null;
|
|
30413
|
-
this.srcInputId = genDomID$
|
|
30414
|
-
this.altInputId = genDomID$
|
|
30415
|
-
this.hrefInputId = genDomID$
|
|
30416
|
-
this.buttonId = genDomID$
|
|
30431
|
+
this.srcInputId = genDomID$2();
|
|
30432
|
+
this.altInputId = genDomID$2();
|
|
30433
|
+
this.hrefInputId = genDomID$2();
|
|
30434
|
+
this.buttonId = genDomID$2();
|
|
30417
30435
|
}
|
|
30418
30436
|
InsertImage.prototype.getValue = function (editor) {
|
|
30419
30437
|
// 插入菜单,不需要 value
|
|
@@ -30537,7 +30555,7 @@ var DeleteImage = /** @class */ (function () {
|
|
|
30537
30555
|
/**
|
|
30538
30556
|
* 生成唯一的 DOM ID
|
|
30539
30557
|
*/
|
|
30540
|
-
function genDomID$
|
|
30558
|
+
function genDomID$1$1() {
|
|
30541
30559
|
return genRandomStr$1('w-e-edit-image');
|
|
30542
30560
|
}
|
|
30543
30561
|
var EditImage = /** @class */ (function () {
|
|
@@ -30548,10 +30566,10 @@ var EditImage = /** @class */ (function () {
|
|
|
30548
30566
|
this.showModal = true; // 点击 button 时显示 modal
|
|
30549
30567
|
this.modalWidth = 300;
|
|
30550
30568
|
this.$content = null;
|
|
30551
|
-
this.srcInputId = genDomID$
|
|
30552
|
-
this.altInputId = genDomID$
|
|
30553
|
-
this.hrefInputId = genDomID$
|
|
30554
|
-
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();
|
|
30555
30573
|
}
|
|
30556
30574
|
EditImage.prototype.getValue = function (editor) {
|
|
30557
30575
|
// 编辑图片,用不到 getValue
|
|
@@ -30786,6 +30804,122 @@ var ImageWidth100 = /** @class */ (function (_super) {
|
|
|
30786
30804
|
return ImageWidth100;
|
|
30787
30805
|
}(ImageWidthBaseClass));
|
|
30788
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
|
+
|
|
30789
30923
|
/**
|
|
30790
30924
|
* @description 图片菜单配置
|
|
30791
30925
|
* @author wangfupeng
|
|
@@ -30879,6 +31013,12 @@ var imageWidth100MenuConf = {
|
|
|
30879
31013
|
factory: function () {
|
|
30880
31014
|
return new ImageWidth100();
|
|
30881
31015
|
},
|
|
31016
|
+
};
|
|
31017
|
+
var EditorImageSizeMenuConf = {
|
|
31018
|
+
key: 'editorImageSizeMenu',
|
|
31019
|
+
factory: function () {
|
|
31020
|
+
return new EditorImageSizeMenu();
|
|
31021
|
+
},
|
|
30882
31022
|
};
|
|
30883
31023
|
|
|
30884
31024
|
/**
|
|
@@ -30897,6 +31037,7 @@ var image$1 = {
|
|
|
30897
31037
|
imageWidth30MenuConf,
|
|
30898
31038
|
imageWidth50MenuConf,
|
|
30899
31039
|
imageWidth100MenuConf,
|
|
31040
|
+
EditorImageSizeMenuConf,
|
|
30900
31041
|
],
|
|
30901
31042
|
editorPlugin: withImage,
|
|
30902
31043
|
};
|
|
@@ -32113,9 +32254,9 @@ var BaseMenu$5 = /** @class */ (function () {
|
|
|
32113
32254
|
return true;
|
|
32114
32255
|
var selectedElems = DomEditor.getSelectedElems(editor);
|
|
32115
32256
|
var notMatch = selectedElems.some(function (elem) {
|
|
32116
|
-
|
|
32117
|
-
if (Editor.isVoid(editor, elem) && Editor.isBlock(editor, elem) && type !== 'video')
|
|
32257
|
+
if (Editor.isVoid(editor, elem) && Editor.isBlock(editor, elem))
|
|
32118
32258
|
return true;
|
|
32259
|
+
var type = elem.type;
|
|
32119
32260
|
if (['pre', 'code'].includes(type))
|
|
32120
32261
|
return true;
|
|
32121
32262
|
});
|
|
@@ -32139,8 +32280,6 @@ var JustifyLeftMenu = /** @class */ (function (_super) {
|
|
|
32139
32280
|
return _this;
|
|
32140
32281
|
}
|
|
32141
32282
|
JustifyLeftMenu.prototype.exec = function (editor, value) {
|
|
32142
|
-
var selection = editor.selection;
|
|
32143
|
-
console.log('selection', selection);
|
|
32144
32283
|
Transforms.setNodes(editor, {
|
|
32145
32284
|
textAlign: 'left',
|
|
32146
32285
|
}, { match: function (n) { return Element$1.isElement(n) && !editor.isInline(n); } });
|
|
@@ -37327,12 +37466,20 @@ function getTagName($elem) {
|
|
|
37327
37466
|
* @param height height
|
|
37328
37467
|
* @returns iframe html string with size style
|
|
37329
37468
|
*/
|
|
37330
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
37469
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
37331
37470
|
if (width === void 0) { width = 'auto'; }
|
|
37332
37471
|
if (height === void 0) { height = 'auto'; }
|
|
37472
|
+
if (style === void 0) { style = {}; }
|
|
37333
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 + ";";
|
|
37334
37480
|
$iframe.attr('width', width);
|
|
37335
37481
|
$iframe.attr('height', height);
|
|
37482
|
+
$iframe.attr('style', styleStr);
|
|
37336
37483
|
return $iframe[0].outerHTML;
|
|
37337
37484
|
}
|
|
37338
37485
|
|
|
@@ -37341,19 +37488,19 @@ function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
|
37341
37488
|
* @author wangfupeng
|
|
37342
37489
|
*/
|
|
37343
37490
|
function renderVideo(elemNode, children, editor) {
|
|
37344
|
-
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;
|
|
37345
37492
|
// 是否选中
|
|
37346
37493
|
var selected = DomEditor.isNodeSelected(editor, elemNode);
|
|
37347
37494
|
var vnode;
|
|
37348
37495
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
37349
37496
|
// 增加尺寸样式
|
|
37350
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
37497
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
37351
37498
|
// iframe 形式,第三方视频
|
|
37352
37499
|
vnode = (jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
37353
37500
|
}
|
|
37354
37501
|
else {
|
|
37355
37502
|
// 其他,mp4 格式
|
|
37356
|
-
var videoVnode = (jsx("video", { poster: poster, controls: true },
|
|
37503
|
+
var videoVnode = (jsx("video", { poster: poster, controls: true, style: style },
|
|
37357
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"));
|
|
37358
37505
|
// @ts-ignore 添加尺寸
|
|
37359
37506
|
if (width !== 'auto')
|
|
@@ -37384,16 +37531,22 @@ var renderVideoConf = {
|
|
|
37384
37531
|
* @author wangfupeng
|
|
37385
37532
|
*/
|
|
37386
37533
|
function videoToHtml(elemNode, childrenHtml) {
|
|
37387
|
-
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;
|
|
37388
37535
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
37389
37536
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
37390
37537
|
// iframe 形式
|
|
37391
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
37538
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
37392
37539
|
res += iframeHtml;
|
|
37393
37540
|
}
|
|
37394
37541
|
else {
|
|
37395
37542
|
// 其他,mp4 等 url 格式
|
|
37396
|
-
|
|
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>";
|
|
37397
37550
|
}
|
|
37398
37551
|
res += '\n</div>';
|
|
37399
37552
|
return res;
|
|
@@ -37434,7 +37587,7 @@ function preParse(elem) {
|
|
|
37434
37587
|
var $parent = $video.parent();
|
|
37435
37588
|
if ($parent.attr('data-w-e-type') === 'video')
|
|
37436
37589
|
return $video[0];
|
|
37437
|
-
var $container = $("<div data-w-e-type=\"video\" data-w-e-is-void></div>");
|
|
37590
|
+
var $container = $("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
|
|
37438
37591
|
$container.append($video);
|
|
37439
37592
|
return $container[0];
|
|
37440
37593
|
}
|
|
@@ -37447,16 +37600,18 @@ var preParseHtmlConf = {
|
|
|
37447
37600
|
* @description parse html
|
|
37448
37601
|
* @author wangfupeng
|
|
37449
37602
|
*/
|
|
37450
|
-
function genVideoElem(src, poster, width, height) {
|
|
37603
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
37451
37604
|
if (poster === void 0) { poster = ''; }
|
|
37452
37605
|
if (width === void 0) { width = 'auto'; }
|
|
37453
37606
|
if (height === void 0) { height = 'auto'; }
|
|
37607
|
+
if (style === void 0) { style = {}; }
|
|
37454
37608
|
return {
|
|
37455
37609
|
type: 'video',
|
|
37456
37610
|
src: src,
|
|
37457
37611
|
poster: poster,
|
|
37458
37612
|
width: width,
|
|
37459
37613
|
height: height,
|
|
37614
|
+
style: style,
|
|
37460
37615
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
37461
37616
|
};
|
|
37462
37617
|
}
|
|
@@ -37466,13 +37621,15 @@ function parseHtml(elem, children, editor) {
|
|
|
37466
37621
|
var poster = '';
|
|
37467
37622
|
var width = 'auto';
|
|
37468
37623
|
var height = 'auto';
|
|
37624
|
+
var style = {};
|
|
37469
37625
|
// <iframe> 形式
|
|
37470
37626
|
var $iframe = $elem.find('iframe');
|
|
37471
37627
|
if ($iframe.length > 0) {
|
|
37472
37628
|
width = $iframe.attr('width') || 'auto';
|
|
37473
37629
|
height = $iframe.attr('height') || 'auto';
|
|
37630
|
+
style = $iframe.attr('style') || {};
|
|
37474
37631
|
src = $iframe[0].outerHTML;
|
|
37475
|
-
return genVideoElem(src, poster, width, height);
|
|
37632
|
+
return genVideoElem(src, poster, width, height, style);
|
|
37476
37633
|
}
|
|
37477
37634
|
// <video> 形式
|
|
37478
37635
|
var $video = $elem.find('video');
|
|
@@ -37486,7 +37643,8 @@ function parseHtml(elem, children, editor) {
|
|
|
37486
37643
|
width = $video.attr('width') || 'auto';
|
|
37487
37644
|
height = $video.attr('height') || 'auto';
|
|
37488
37645
|
poster = $video.attr('poster') || '';
|
|
37489
|
-
|
|
37646
|
+
style = $iframe.attr('style') || {};
|
|
37647
|
+
return genVideoElem(src, poster, width, height, style);
|
|
37490
37648
|
}
|
|
37491
37649
|
var parseHtmlConf = {
|
|
37492
37650
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -37537,8 +37695,10 @@ var UPLOAD_VIDEO_SVG = '<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.81
|
|
|
37537
37695
|
* @param src video src
|
|
37538
37696
|
* @param poster video poster
|
|
37539
37697
|
*/
|
|
37540
|
-
function insertVideo (editor, src, poster) {
|
|
37698
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
37541
37699
|
if (poster === void 0) { poster = ''; }
|
|
37700
|
+
if (width === void 0) { width = ''; }
|
|
37701
|
+
if (height === void 0) { height = ''; }
|
|
37542
37702
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
37543
37703
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
37544
37704
|
return __generator$1(this, function (_b) {
|
|
@@ -37571,7 +37731,11 @@ function insertVideo (editor, src, poster) {
|
|
|
37571
37731
|
type: 'video',
|
|
37572
37732
|
src: parsedSrc,
|
|
37573
37733
|
poster: poster,
|
|
37574
|
-
children: [{ text: '' }],
|
|
37734
|
+
children: [{ text: '' }],
|
|
37735
|
+
style: {
|
|
37736
|
+
width: width,
|
|
37737
|
+
height: height,
|
|
37738
|
+
},
|
|
37575
37739
|
};
|
|
37576
37740
|
// 插入视频
|
|
37577
37741
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -37974,13 +38138,30 @@ var EditorVideoSizeMenu = /** @class */ (function () {
|
|
|
37974
38138
|
e.preventDefault();
|
|
37975
38139
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
37976
38140
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
37977
|
-
var
|
|
37978
|
-
var
|
|
37979
|
-
var width =
|
|
37980
|
-
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;
|
|
37981
38158
|
editor.restoreSelection();
|
|
38159
|
+
var props = __assign$2(__assign$2({}, style), { style: {
|
|
38160
|
+
width: width,
|
|
38161
|
+
height: height,
|
|
38162
|
+
} });
|
|
37982
38163
|
// 修改尺寸
|
|
37983
|
-
Transforms.setNodes(editor,
|
|
38164
|
+
Transforms.setNodes(editor, props, {
|
|
37984
38165
|
match: function (n) { return DomEditor.checkNodeType(n, 'video'); },
|
|
37985
38166
|
});
|
|
37986
38167
|
editor.hidePanelOrModal(); // 隐藏 modal
|
|
@@ -43782,6 +43963,7 @@ var COMMON_HOVERBAR_KEYS = {
|
|
|
43782
43963
|
'imageWidth30',
|
|
43783
43964
|
'imageWidth50',
|
|
43784
43965
|
'imageWidth100',
|
|
43966
|
+
'editorImageSizeMenu',
|
|
43785
43967
|
'editImage',
|
|
43786
43968
|
'viewImageLink',
|
|
43787
43969
|
'deleteImage',
|
package/dist/index.js
CHANGED
|
@@ -28399,6 +28399,11 @@
|
|
|
28399
28399
|
menu = factory();
|
|
28400
28400
|
menus[key] = menu;
|
|
28401
28401
|
}
|
|
28402
|
+
//替换 icon svg
|
|
28403
|
+
var menuConf = editor.getMenuConfig(key);
|
|
28404
|
+
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
28405
|
+
menu.iconSvg = menuConf.iconSvg;
|
|
28406
|
+
}
|
|
28402
28407
|
var barItem = createBarItem(key, menu);
|
|
28403
28408
|
this.hoverbarItems.push(barItem);
|
|
28404
28409
|
// 保存 barItem 和 editor 的关系
|
|
@@ -28813,6 +28818,11 @@
|
|
|
28813
28818
|
else {
|
|
28814
28819
|
console.warn("Duplicated toolbar menu key '" + key + "'\n\u91CD\u590D\u6CE8\u518C\u4E86\u83DC\u5355\u680F menu '" + key + "'");
|
|
28815
28820
|
}
|
|
28821
|
+
// 替换 icon svg
|
|
28822
|
+
var menuConf = editor.getMenuConfig(key);
|
|
28823
|
+
if (menuConf && menuConf.iconSvg !== undefined) {
|
|
28824
|
+
menu.iconSvg = menuConf.iconSvg;
|
|
28825
|
+
}
|
|
28816
28826
|
var toolbarItem = createBarItem(key, menu, inGroup);
|
|
28817
28827
|
this.toolbarItems.push(toolbarItem);
|
|
28818
28828
|
// 保存 toolbarItem 和 editor 的关系
|
|
@@ -31701,10 +31711,14 @@
|
|
|
31701
31711
|
netImage: 'Net image',
|
|
31702
31712
|
delete: 'Delete image',
|
|
31703
31713
|
edit: 'Edit image',
|
|
31714
|
+
editSize: 'Edit size',
|
|
31704
31715
|
viewLink: 'View link',
|
|
31705
31716
|
src: 'Image src',
|
|
31706
31717
|
desc: 'Description',
|
|
31707
31718
|
link: 'Image link',
|
|
31719
|
+
ok: 'Ok',
|
|
31720
|
+
width: 'Width',
|
|
31721
|
+
height: 'Height',
|
|
31708
31722
|
},
|
|
31709
31723
|
indent: {
|
|
31710
31724
|
decrease: 'Decrease',
|
|
@@ -31795,10 +31809,14 @@
|
|
|
31795
31809
|
netImage: '网络图片',
|
|
31796
31810
|
delete: '删除图片',
|
|
31797
31811
|
edit: '编辑图片',
|
|
31812
|
+
editSize: '修改尺寸',
|
|
31798
31813
|
viewLink: '查看链接',
|
|
31799
31814
|
src: '图片地址',
|
|
31800
31815
|
desc: '图片描述',
|
|
31801
31816
|
link: '图片链接',
|
|
31817
|
+
ok: '确定',
|
|
31818
|
+
width: '宽度',
|
|
31819
|
+
height: '高度',
|
|
31802
31820
|
},
|
|
31803
31821
|
indent: {
|
|
31804
31822
|
decrease: '减少缩进',
|
|
@@ -34001,7 +34019,7 @@
|
|
|
34001
34019
|
/**
|
|
34002
34020
|
* 生成唯一的 DOM ID
|
|
34003
34021
|
*/
|
|
34004
|
-
function genDomID$
|
|
34022
|
+
function genDomID$4() {
|
|
34005
34023
|
return genRandomStr('w-e-insert-link');
|
|
34006
34024
|
}
|
|
34007
34025
|
var InsertLinkMenu = /** @class */ (function () {
|
|
@@ -34012,9 +34030,9 @@
|
|
|
34012
34030
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34013
34031
|
this.modalWidth = 300;
|
|
34014
34032
|
this.$content = null;
|
|
34015
|
-
this.textInputId = genDomID$
|
|
34016
|
-
this.urlInputId = genDomID$
|
|
34017
|
-
this.buttonId = genDomID$
|
|
34033
|
+
this.textInputId = genDomID$4();
|
|
34034
|
+
this.urlInputId = genDomID$4();
|
|
34035
|
+
this.buttonId = genDomID$4();
|
|
34018
34036
|
}
|
|
34019
34037
|
InsertLinkMenu.prototype.getValue = function (editor) {
|
|
34020
34038
|
// 插入菜单,不需要 value
|
|
@@ -34090,7 +34108,7 @@
|
|
|
34090
34108
|
/**
|
|
34091
34109
|
* 生成唯一的 DOM ID
|
|
34092
34110
|
*/
|
|
34093
|
-
function genDomID$
|
|
34111
|
+
function genDomID$3() {
|
|
34094
34112
|
return genRandomStr('w-e-update-link');
|
|
34095
34113
|
}
|
|
34096
34114
|
var EditLinkMenu = /** @class */ (function () {
|
|
@@ -34101,8 +34119,8 @@
|
|
|
34101
34119
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34102
34120
|
this.modalWidth = 300;
|
|
34103
34121
|
this.$content = null;
|
|
34104
|
-
this.urlInputId = genDomID$
|
|
34105
|
-
this.buttonId = genDomID$
|
|
34122
|
+
this.urlInputId = genDomID$3();
|
|
34123
|
+
this.buttonId = genDomID$3();
|
|
34106
34124
|
}
|
|
34107
34125
|
EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
|
|
34108
34126
|
var node = core.DomEditor.getSelectedNodeByType(editor, 'link');
|
|
@@ -34730,7 +34748,7 @@
|
|
|
34730
34748
|
/**
|
|
34731
34749
|
* 生成唯一的 DOM ID
|
|
34732
34750
|
*/
|
|
34733
|
-
function genDomID$
|
|
34751
|
+
function genDomID$2() {
|
|
34734
34752
|
return genRandomStr('w-e-insert-image');
|
|
34735
34753
|
}
|
|
34736
34754
|
var InsertImage = /** @class */ (function () {
|
|
@@ -34741,10 +34759,10 @@
|
|
|
34741
34759
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34742
34760
|
this.modalWidth = 300;
|
|
34743
34761
|
this.$content = null;
|
|
34744
|
-
this.srcInputId = genDomID$
|
|
34745
|
-
this.altInputId = genDomID$
|
|
34746
|
-
this.hrefInputId = genDomID$
|
|
34747
|
-
this.buttonId = genDomID$
|
|
34762
|
+
this.srcInputId = genDomID$2();
|
|
34763
|
+
this.altInputId = genDomID$2();
|
|
34764
|
+
this.hrefInputId = genDomID$2();
|
|
34765
|
+
this.buttonId = genDomID$2();
|
|
34748
34766
|
}
|
|
34749
34767
|
InsertImage.prototype.getValue = function (editor) {
|
|
34750
34768
|
// 插入菜单,不需要 value
|
|
@@ -34868,7 +34886,7 @@
|
|
|
34868
34886
|
/**
|
|
34869
34887
|
* 生成唯一的 DOM ID
|
|
34870
34888
|
*/
|
|
34871
|
-
function genDomID() {
|
|
34889
|
+
function genDomID$1() {
|
|
34872
34890
|
return genRandomStr('w-e-edit-image');
|
|
34873
34891
|
}
|
|
34874
34892
|
var EditImage = /** @class */ (function () {
|
|
@@ -34879,10 +34897,10 @@
|
|
|
34879
34897
|
this.showModal = true; // 点击 button 时显示 modal
|
|
34880
34898
|
this.modalWidth = 300;
|
|
34881
34899
|
this.$content = null;
|
|
34882
|
-
this.srcInputId = genDomID();
|
|
34883
|
-
this.altInputId = genDomID();
|
|
34884
|
-
this.hrefInputId = genDomID();
|
|
34885
|
-
this.buttonId = genDomID();
|
|
34900
|
+
this.srcInputId = genDomID$1();
|
|
34901
|
+
this.altInputId = genDomID$1();
|
|
34902
|
+
this.hrefInputId = genDomID$1();
|
|
34903
|
+
this.buttonId = genDomID$1();
|
|
34886
34904
|
}
|
|
34887
34905
|
EditImage.prototype.getValue = function (editor) {
|
|
34888
34906
|
// 编辑图片,用不到 getValue
|
|
@@ -35117,6 +35135,122 @@
|
|
|
35117
35135
|
return ImageWidth100;
|
|
35118
35136
|
}(ImageWidthBaseClass));
|
|
35119
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
|
+
|
|
35120
35254
|
/**
|
|
35121
35255
|
* @description 图片菜单配置
|
|
35122
35256
|
* @author wangfupeng
|
|
@@ -35210,6 +35344,12 @@
|
|
|
35210
35344
|
factory: function () {
|
|
35211
35345
|
return new ImageWidth100();
|
|
35212
35346
|
},
|
|
35347
|
+
};
|
|
35348
|
+
var EditorImageSizeMenuConf = {
|
|
35349
|
+
key: 'editorImageSizeMenu',
|
|
35350
|
+
factory: function () {
|
|
35351
|
+
return new EditorImageSizeMenu();
|
|
35352
|
+
},
|
|
35213
35353
|
};
|
|
35214
35354
|
|
|
35215
35355
|
/**
|
|
@@ -35228,6 +35368,7 @@
|
|
|
35228
35368
|
imageWidth30MenuConf,
|
|
35229
35369
|
imageWidth50MenuConf,
|
|
35230
35370
|
imageWidth100MenuConf,
|
|
35371
|
+
EditorImageSizeMenuConf,
|
|
35231
35372
|
],
|
|
35232
35373
|
editorPlugin: withImage,
|
|
35233
35374
|
};
|
|
@@ -36444,9 +36585,9 @@
|
|
|
36444
36585
|
return true;
|
|
36445
36586
|
var selectedElems = core.DomEditor.getSelectedElems(editor);
|
|
36446
36587
|
var notMatch = selectedElems.some(function (elem) {
|
|
36447
|
-
|
|
36448
|
-
if (slate.Editor.isVoid(editor, elem) && slate.Editor.isBlock(editor, elem) && type !== 'video')
|
|
36588
|
+
if (slate.Editor.isVoid(editor, elem) && slate.Editor.isBlock(editor, elem))
|
|
36449
36589
|
return true;
|
|
36590
|
+
var type = elem.type;
|
|
36450
36591
|
if (['pre', 'code'].includes(type))
|
|
36451
36592
|
return true;
|
|
36452
36593
|
});
|
|
@@ -36470,8 +36611,6 @@
|
|
|
36470
36611
|
return _this;
|
|
36471
36612
|
}
|
|
36472
36613
|
JustifyLeftMenu.prototype.exec = function (editor, value) {
|
|
36473
|
-
var selection = editor.selection;
|
|
36474
|
-
console.log('selection', selection);
|
|
36475
36614
|
slate.Transforms.setNodes(editor, {
|
|
36476
36615
|
textAlign: 'left',
|
|
36477
36616
|
}, { match: function (n) { return slate.Element.isElement(n) && !editor.isInline(n); } });
|
|
@@ -41716,12 +41855,20 @@
|
|
|
41716
41855
|
* @param height height
|
|
41717
41856
|
* @returns iframe html string with size style
|
|
41718
41857
|
*/
|
|
41719
|
-
function genSizeStyledIframeHtml(iframeHtml, width, height) {
|
|
41858
|
+
function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
|
|
41720
41859
|
if (width === void 0) { width = 'auto'; }
|
|
41721
41860
|
if (height === void 0) { height = 'auto'; }
|
|
41861
|
+
if (style === void 0) { style = {}; }
|
|
41722
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 + ";";
|
|
41723
41869
|
$iframe.attr('width', width);
|
|
41724
41870
|
$iframe.attr('height', height);
|
|
41871
|
+
$iframe.attr('style', styleStr);
|
|
41725
41872
|
return $iframe[0].outerHTML;
|
|
41726
41873
|
}
|
|
41727
41874
|
|
|
@@ -41730,19 +41877,19 @@
|
|
|
41730
41877
|
* @author wangfupeng
|
|
41731
41878
|
*/
|
|
41732
41879
|
function renderVideo(elemNode, children, editor) {
|
|
41733
|
-
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;
|
|
41734
41881
|
// 是否选中
|
|
41735
41882
|
var selected = core.DomEditor.isNodeSelected(editor, elemNode);
|
|
41736
41883
|
var vnode;
|
|
41737
41884
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
41738
41885
|
// 增加尺寸样式
|
|
41739
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
41886
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
41740
41887
|
// iframe 形式,第三方视频
|
|
41741
41888
|
vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
|
|
41742
41889
|
}
|
|
41743
41890
|
else {
|
|
41744
41891
|
// 其他,mp4 格式
|
|
41745
|
-
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true },
|
|
41892
|
+
var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true, style: style },
|
|
41746
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"));
|
|
41747
41894
|
// @ts-ignore 添加尺寸
|
|
41748
41895
|
if (width !== 'auto')
|
|
@@ -41773,16 +41920,22 @@
|
|
|
41773
41920
|
* @author wangfupeng
|
|
41774
41921
|
*/
|
|
41775
41922
|
function videoToHtml(elemNode, childrenHtml) {
|
|
41776
|
-
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;
|
|
41777
41924
|
var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
|
|
41778
41925
|
if (src.trim().indexOf('<iframe ') === 0) {
|
|
41779
41926
|
// iframe 形式
|
|
41780
|
-
var iframeHtml = genSizeStyledIframeHtml(src, width, height);
|
|
41927
|
+
var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
|
|
41781
41928
|
res += iframeHtml;
|
|
41782
41929
|
}
|
|
41783
41930
|
else {
|
|
41784
41931
|
// 其他,mp4 等 url 格式
|
|
41785
|
-
|
|
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>";
|
|
41786
41939
|
}
|
|
41787
41940
|
res += '\n</div>';
|
|
41788
41941
|
return res;
|
|
@@ -41823,7 +41976,7 @@
|
|
|
41823
41976
|
var $parent = $video.parent();
|
|
41824
41977
|
if ($parent.attr('data-w-e-type') === 'video')
|
|
41825
41978
|
return $video[0];
|
|
41826
|
-
var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void></div>");
|
|
41979
|
+
var $container = $__default["default"]("<div data-w-e-type=\"video\" data-w-e-is-void style=\"text-align: center;\"></div>");
|
|
41827
41980
|
$container.append($video);
|
|
41828
41981
|
return $container[0];
|
|
41829
41982
|
}
|
|
@@ -41836,16 +41989,18 @@
|
|
|
41836
41989
|
* @description parse html
|
|
41837
41990
|
* @author wangfupeng
|
|
41838
41991
|
*/
|
|
41839
|
-
function genVideoElem(src, poster, width, height) {
|
|
41992
|
+
function genVideoElem(src, poster, width, height, style) {
|
|
41840
41993
|
if (poster === void 0) { poster = ''; }
|
|
41841
41994
|
if (width === void 0) { width = 'auto'; }
|
|
41842
41995
|
if (height === void 0) { height = 'auto'; }
|
|
41996
|
+
if (style === void 0) { style = {}; }
|
|
41843
41997
|
return {
|
|
41844
41998
|
type: 'video',
|
|
41845
41999
|
src: src,
|
|
41846
42000
|
poster: poster,
|
|
41847
42001
|
width: width,
|
|
41848
42002
|
height: height,
|
|
42003
|
+
style: style,
|
|
41849
42004
|
children: [{ text: '' }], // void 元素有一个空 text
|
|
41850
42005
|
};
|
|
41851
42006
|
}
|
|
@@ -41855,13 +42010,15 @@
|
|
|
41855
42010
|
var poster = '';
|
|
41856
42011
|
var width = 'auto';
|
|
41857
42012
|
var height = 'auto';
|
|
42013
|
+
var style = {};
|
|
41858
42014
|
// <iframe> 形式
|
|
41859
42015
|
var $iframe = $elem.find('iframe');
|
|
41860
42016
|
if ($iframe.length > 0) {
|
|
41861
42017
|
width = $iframe.attr('width') || 'auto';
|
|
41862
42018
|
height = $iframe.attr('height') || 'auto';
|
|
42019
|
+
style = $iframe.attr('style') || {};
|
|
41863
42020
|
src = $iframe[0].outerHTML;
|
|
41864
|
-
return genVideoElem(src, poster, width, height);
|
|
42021
|
+
return genVideoElem(src, poster, width, height, style);
|
|
41865
42022
|
}
|
|
41866
42023
|
// <video> 形式
|
|
41867
42024
|
var $video = $elem.find('video');
|
|
@@ -41875,7 +42032,8 @@
|
|
|
41875
42032
|
width = $video.attr('width') || 'auto';
|
|
41876
42033
|
height = $video.attr('height') || 'auto';
|
|
41877
42034
|
poster = $video.attr('poster') || '';
|
|
41878
|
-
|
|
42035
|
+
style = $iframe.attr('style') || {};
|
|
42036
|
+
return genVideoElem(src, poster, width, height, style);
|
|
41879
42037
|
}
|
|
41880
42038
|
var parseHtmlConf = {
|
|
41881
42039
|
selector: 'div[data-w-e-type="video"]',
|
|
@@ -41926,8 +42084,10 @@
|
|
|
41926
42084
|
* @param src video src
|
|
41927
42085
|
* @param poster video poster
|
|
41928
42086
|
*/
|
|
41929
|
-
function insertVideo (editor, src, poster) {
|
|
42087
|
+
function insertVideo (editor, src, poster, width, height) {
|
|
41930
42088
|
if (poster === void 0) { poster = ''; }
|
|
42089
|
+
if (width === void 0) { width = ''; }
|
|
42090
|
+
if (height === void 0) { height = ''; }
|
|
41931
42091
|
return __awaiter(this, void 0, void 0, function () {
|
|
41932
42092
|
var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
|
|
41933
42093
|
return __generator(this, function (_b) {
|
|
@@ -41960,7 +42120,11 @@
|
|
|
41960
42120
|
type: 'video',
|
|
41961
42121
|
src: parsedSrc,
|
|
41962
42122
|
poster: poster,
|
|
41963
|
-
children: [{ text: '' }],
|
|
42123
|
+
children: [{ text: '' }],
|
|
42124
|
+
style: {
|
|
42125
|
+
width: width,
|
|
42126
|
+
height: height,
|
|
42127
|
+
},
|
|
41964
42128
|
};
|
|
41965
42129
|
// 插入视频
|
|
41966
42130
|
// 不使用此方式会比正常的选区选取先执行
|
|
@@ -42363,13 +42527,30 @@
|
|
|
42363
42527
|
e.preventDefault();
|
|
42364
42528
|
var rawWidth = $content_1.find("#" + widthInputId).val().trim();
|
|
42365
42529
|
var rawHeight = $content_1.find("#" + heightInputId).val().trim();
|
|
42366
|
-
var
|
|
42367
|
-
var
|
|
42368
|
-
var width =
|
|
42369
|
-
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;
|
|
42370
42547
|
editor.restoreSelection();
|
|
42548
|
+
var props = __assign(__assign({}, style), { style: {
|
|
42549
|
+
width: width,
|
|
42550
|
+
height: height,
|
|
42551
|
+
} });
|
|
42371
42552
|
// 修改尺寸
|
|
42372
|
-
slate.Transforms.setNodes(editor,
|
|
42553
|
+
slate.Transforms.setNodes(editor, props, {
|
|
42373
42554
|
match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
|
|
42374
42555
|
});
|
|
42375
42556
|
editor.hidePanelOrModal(); // 隐藏 modal
|
|
@@ -48215,6 +48396,7 @@
|
|
|
48215
48396
|
'imageWidth30',
|
|
48216
48397
|
'imageWidth50',
|
|
48217
48398
|
'imageWidth100',
|
|
48399
|
+
'editorImageSizeMenu',
|
|
48218
48400
|
'editImage',
|
|
48219
48401
|
'viewImageLink',
|
|
48220
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
|
-
"@wangeditor-next/core": "^1.2.
|
|
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
|
}
|