@wangeditor-next/editor 5.2.3 → 5.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21944,7 +21944,7 @@
21944
21944
  };
21945
21945
  var withHistory_1 = withHistory;
21946
21946
 
21947
- /*! *****************************************************************************
21947
+ /******************************************************************************
21948
21948
  Copyright (c) Microsoft Corporation.
21949
21949
 
21950
21950
  Permission to use, copy, modify, and/or distribute this software for any
@@ -21958,7 +21958,7 @@
21958
21958
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21959
21959
  PERFORMANCE OF THIS SOFTWARE.
21960
21960
  ***************************************************************************** */
21961
- /* global Reflect, Promise */
21961
+ /* global Reflect, Promise, SuppressedError, Symbol */
21962
21962
 
21963
21963
  var extendStatics = function(d, b) {
21964
21964
  extendStatics = Object.setPrototypeOf ||
@@ -22015,11 +22015,20 @@
22015
22015
  return ar;
22016
22016
  }
22017
22017
 
22018
- function __spreadArray(to, from) {
22019
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
22020
- to[j] = from[i];
22021
- return to;
22022
- }
22018
+ function __spreadArray(to, from, pack) {
22019
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
22020
+ if (ar || !(i in from)) {
22021
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22022
+ ar[i] = from[i];
22023
+ }
22024
+ }
22025
+ return to.concat(ar || Array.prototype.slice.call(from));
22026
+ }
22027
+
22028
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
22029
+ var e = new Error(message);
22030
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
22031
+ };
22023
22032
 
22024
22033
  /**
22025
22034
  * An auto-incrementing identifier for keys.
@@ -23974,6 +23983,14 @@
23974
23983
  return parseCommonElemHtml($elem, editor);
23975
23984
  }
23976
23985
  else {
23986
+ if ($elem[0].childNodes.length > 1) {
23987
+ var childNodes = $elem[0].childNodes;
23988
+ return Array.from(childNodes).map(function (child) {
23989
+ $__default["default"]($elem[0]).empty();
23990
+ $__default["default"]($elem[0]).append($__default["default"](child));
23991
+ return parseTextElemHtml($__default["default"]($elem[0]), editor);
23992
+ });
23993
+ }
23977
23994
  return parseTextElemHtml($elem, editor);
23978
23995
  }
23979
23996
  }
@@ -28401,7 +28418,6 @@
28401
28418
  }
28402
28419
  //替换 icon svg
28403
28420
  var menuConf = editor.getMenuConfig(key);
28404
- console.log('🚀 ~ HoverBar ~ registerSingleItem ~ menuConf:', menuConf, menu);
28405
28421
  if (menuConf && menuConf.iconSvg !== undefined) {
28406
28422
  menu.iconSvg = menuConf.iconSvg;
28407
28423
  }
@@ -31712,10 +31728,14 @@
31712
31728
  netImage: 'Net image',
31713
31729
  delete: 'Delete image',
31714
31730
  edit: 'Edit image',
31731
+ editSize: 'Edit size',
31715
31732
  viewLink: 'View link',
31716
31733
  src: 'Image src',
31717
31734
  desc: 'Description',
31718
31735
  link: 'Image link',
31736
+ ok: 'Ok',
31737
+ width: 'Width',
31738
+ height: 'Height',
31719
31739
  },
31720
31740
  indent: {
31721
31741
  decrease: 'Decrease',
@@ -31806,10 +31826,14 @@
31806
31826
  netImage: '网络图片',
31807
31827
  delete: '删除图片',
31808
31828
  edit: '编辑图片',
31829
+ editSize: '修改尺寸',
31809
31830
  viewLink: '查看链接',
31810
31831
  src: '图片地址',
31811
31832
  desc: '图片描述',
31812
31833
  link: '图片链接',
31834
+ ok: '确定',
31835
+ width: '宽度',
31836
+ height: '高度',
31813
31837
  },
31814
31838
  indent: {
31815
31839
  decrease: '减少缩进',
@@ -32030,7 +32054,7 @@
32030
32054
  parseElemHtml: parseParagraphHtml,
32031
32055
  };
32032
32056
 
32033
- /*! *****************************************************************************
32057
+ /******************************************************************************
32034
32058
  Copyright (c) Microsoft Corporation.
32035
32059
 
32036
32060
  Permission to use, copy, modify, and/or distribute this software for any
@@ -32044,7 +32068,7 @@
32044
32068
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
32045
32069
  PERFORMANCE OF THIS SOFTWARE.
32046
32070
  ***************************************************************************** */
32047
- /* global Reflect, Promise */
32071
+ /* global Reflect, Promise, SuppressedError, Symbol */
32048
32072
 
32049
32073
  var extendStatics = function(d, b) {
32050
32074
  extendStatics = Object.setPrototypeOf ||
@@ -32088,7 +32112,7 @@
32088
32112
  function verb(n) { return function (v) { return step([n, v]); }; }
32089
32113
  function step(op) {
32090
32114
  if (f) throw new TypeError("Generator is already executing.");
32091
- while (_) try {
32115
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32092
32116
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32093
32117
  if (y = 0, t) op = [op[0] & 2, t.value];
32094
32118
  switch (op[0]) {
@@ -32137,7 +32161,12 @@
32137
32161
  finally { if (e) throw e.error; }
32138
32162
  }
32139
32163
  return ar;
32140
- }
32164
+ }
32165
+
32166
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
32167
+ var e = new Error(message);
32168
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
32169
+ };
32141
32170
 
32142
32171
  /**
32143
32172
  * @description editor 插件,重写 editor API
@@ -34012,7 +34041,7 @@
34012
34041
  /**
34013
34042
  * 生成唯一的 DOM ID
34014
34043
  */
34015
- function genDomID$3() {
34044
+ function genDomID$4() {
34016
34045
  return genRandomStr('w-e-insert-link');
34017
34046
  }
34018
34047
  var InsertLinkMenu = /** @class */ (function () {
@@ -34023,9 +34052,9 @@
34023
34052
  this.showModal = true; // 点击 button 时显示 modal
34024
34053
  this.modalWidth = 300;
34025
34054
  this.$content = null;
34026
- this.textInputId = genDomID$3();
34027
- this.urlInputId = genDomID$3();
34028
- this.buttonId = genDomID$3();
34055
+ this.textInputId = genDomID$4();
34056
+ this.urlInputId = genDomID$4();
34057
+ this.buttonId = genDomID$4();
34029
34058
  }
34030
34059
  InsertLinkMenu.prototype.getValue = function (editor) {
34031
34060
  // 插入菜单,不需要 value
@@ -34101,7 +34130,7 @@
34101
34130
  /**
34102
34131
  * 生成唯一的 DOM ID
34103
34132
  */
34104
- function genDomID$2() {
34133
+ function genDomID$3() {
34105
34134
  return genRandomStr('w-e-update-link');
34106
34135
  }
34107
34136
  var EditLinkMenu = /** @class */ (function () {
@@ -34112,8 +34141,8 @@
34112
34141
  this.showModal = true; // 点击 button 时显示 modal
34113
34142
  this.modalWidth = 300;
34114
34143
  this.$content = null;
34115
- this.urlInputId = genDomID$2();
34116
- this.buttonId = genDomID$2();
34144
+ this.urlInputId = genDomID$3();
34145
+ this.buttonId = genDomID$3();
34117
34146
  }
34118
34147
  EditLinkMenu.prototype.getSelectedLinkElem = function (editor) {
34119
34148
  var node = core.DomEditor.getSelectedNodeByType(editor, 'link');
@@ -34741,7 +34770,7 @@
34741
34770
  /**
34742
34771
  * 生成唯一的 DOM ID
34743
34772
  */
34744
- function genDomID$1() {
34773
+ function genDomID$2() {
34745
34774
  return genRandomStr('w-e-insert-image');
34746
34775
  }
34747
34776
  var InsertImage = /** @class */ (function () {
@@ -34752,10 +34781,10 @@
34752
34781
  this.showModal = true; // 点击 button 时显示 modal
34753
34782
  this.modalWidth = 300;
34754
34783
  this.$content = null;
34755
- this.srcInputId = genDomID$1();
34756
- this.altInputId = genDomID$1();
34757
- this.hrefInputId = genDomID$1();
34758
- this.buttonId = genDomID$1();
34784
+ this.srcInputId = genDomID$2();
34785
+ this.altInputId = genDomID$2();
34786
+ this.hrefInputId = genDomID$2();
34787
+ this.buttonId = genDomID$2();
34759
34788
  }
34760
34789
  InsertImage.prototype.getValue = function (editor) {
34761
34790
  // 插入菜单,不需要 value
@@ -34879,7 +34908,7 @@
34879
34908
  /**
34880
34909
  * 生成唯一的 DOM ID
34881
34910
  */
34882
- function genDomID() {
34911
+ function genDomID$1() {
34883
34912
  return genRandomStr('w-e-edit-image');
34884
34913
  }
34885
34914
  var EditImage = /** @class */ (function () {
@@ -34890,10 +34919,10 @@
34890
34919
  this.showModal = true; // 点击 button 时显示 modal
34891
34920
  this.modalWidth = 300;
34892
34921
  this.$content = null;
34893
- this.srcInputId = genDomID();
34894
- this.altInputId = genDomID();
34895
- this.hrefInputId = genDomID();
34896
- this.buttonId = genDomID();
34922
+ this.srcInputId = genDomID$1();
34923
+ this.altInputId = genDomID$1();
34924
+ this.hrefInputId = genDomID$1();
34925
+ this.buttonId = genDomID$1();
34897
34926
  }
34898
34927
  EditImage.prototype.getValue = function (editor) {
34899
34928
  // 编辑图片,用不到 getValue
@@ -35128,6 +35157,122 @@
35128
35157
  return ImageWidth100;
35129
35158
  }(ImageWidthBaseClass));
35130
35159
 
35160
+ /**
35161
+ * @description 修改图片尺寸
35162
+ * @author wangfupeng
35163
+ */
35164
+ /**
35165
+ * 生成唯一的 DOM ID
35166
+ */
35167
+ function genDomID() {
35168
+ return genRandomStr('w-e-insert-image');
35169
+ }
35170
+ var EditorImageSizeMenu = /** @class */ (function () {
35171
+ function EditorImageSizeMenu() {
35172
+ this.title = core.t('image.editSize');
35173
+ this.tag = 'button';
35174
+ this.showModal = true; // 点击 button 时显示 modal
35175
+ this.modalWidth = 320;
35176
+ this.$content = null;
35177
+ this.widthInputId = genDomID();
35178
+ this.heightInputId = genDomID();
35179
+ this.buttonId = genDomID();
35180
+ }
35181
+ EditorImageSizeMenu.prototype.getSelectedImageNode = function (editor) {
35182
+ return core.DomEditor.getSelectedNodeByType(editor, 'image');
35183
+ };
35184
+ EditorImageSizeMenu.prototype.getValue = function (editor) {
35185
+ // 插入菜单,不需要 value
35186
+ return '';
35187
+ };
35188
+ EditorImageSizeMenu.prototype.isActive = function (editor) {
35189
+ // 任何时候,都不用激活 menu
35190
+ return false;
35191
+ };
35192
+ EditorImageSizeMenu.prototype.exec = function (editor, value) {
35193
+ // 点击菜单时,弹出 modal 之前,不需要执行其他代码
35194
+ // 此处空着即可
35195
+ };
35196
+ EditorImageSizeMenu.prototype.isDisabled = function (editor) {
35197
+ if (editor.selection == null)
35198
+ return true;
35199
+ var imageNode = this.getSelectedImageNode(editor);
35200
+ if (imageNode == null) {
35201
+ // 选区未处于 image node ,则禁用
35202
+ return true;
35203
+ }
35204
+ return false;
35205
+ };
35206
+ EditorImageSizeMenu.prototype.getModalPositionNode = function (editor) {
35207
+ return this.getSelectedImageNode(editor);
35208
+ };
35209
+ EditorImageSizeMenu.prototype.getModalContentElem = function (editor) {
35210
+ // return $('<div><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p><p>修改尺寸</p></div>')[0]
35211
+ var _a = this, widthInputId = _a.widthInputId, heightInputId = _a.heightInputId, buttonId = _a.buttonId;
35212
+ var _b = __read(core.genModalInputElems(core.t('image.width'), widthInputId, 'auto'), 2), widthContainerElem = _b[0], inputWidthElem = _b[1];
35213
+ var $inputWidth = $__default["default"](inputWidthElem);
35214
+ var _c = __read(core.genModalInputElems(core.t('image.height'), heightInputId, 'auto'), 2), heightContainerElem = _c[0], inputHeightElem = _c[1];
35215
+ var $inputHeight = $__default["default"](inputHeightElem);
35216
+ var _d = __read(core.genModalButtonElems(buttonId, core.t('image.ok')), 1), buttonContainerElem = _d[0];
35217
+ if (this.$content == null) {
35218
+ // 第一次渲染
35219
+ var $content_1 = $__default["default"]('<div></div>');
35220
+ // 绑定事件(第一次渲染时绑定,不要重复绑定)
35221
+ $content_1.on('click', "#" + buttonId, function (e) {
35222
+ e.preventDefault();
35223
+ var rawWidth = $content_1.find("#" + widthInputId).val().trim();
35224
+ var rawHeight = $content_1.find("#" + heightInputId).val().trim();
35225
+ var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
35226
+ var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
35227
+ var width = 'auto';
35228
+ var height = 'auto';
35229
+ if (isPercentage(rawWidth)) {
35230
+ width = rawWidth;
35231
+ }
35232
+ else if (isNumeric(rawWidth)) {
35233
+ width = parseInt(rawWidth) + 'px';
35234
+ }
35235
+ if (isPercentage(rawHeight)) {
35236
+ height = rawHeight;
35237
+ }
35238
+ else if (isNumeric(rawHeight)) {
35239
+ height = parseInt(rawHeight) + 'px';
35240
+ }
35241
+ var _a = imageNode.style, style = _a === void 0 ? {} : _a;
35242
+ editor.restoreSelection();
35243
+ var props = __assign(__assign({}, style), { style: {
35244
+ width: width,
35245
+ height: height,
35246
+ } });
35247
+ // 修改尺寸
35248
+ slate.Transforms.setNodes(editor, props, {
35249
+ match: function (n) { return core.DomEditor.checkNodeType(n, 'image'); },
35250
+ });
35251
+ editor.hidePanelOrModal(); // 隐藏 modal
35252
+ });
35253
+ this.$content = $content_1;
35254
+ }
35255
+ var $content = this.$content;
35256
+ // 先清空,再重新添加 DOM 内容
35257
+ $content.empty();
35258
+ $content.append(widthContainerElem);
35259
+ $content.append(heightContainerElem);
35260
+ $content.append(buttonContainerElem);
35261
+ var imageNode = this.getSelectedImageNode(editor);
35262
+ if (imageNode == null)
35263
+ return $content[0];
35264
+ // 初始化 input 值
35265
+ var _e = imageNode.width, width = _e === void 0 ? 'auto' : _e, _f = imageNode.height, height = _f === void 0 ? 'auto' : _f;
35266
+ $inputWidth.val(width);
35267
+ $inputHeight.val(height);
35268
+ setTimeout(function () {
35269
+ $inputWidth.focus();
35270
+ });
35271
+ return $content[0];
35272
+ };
35273
+ return EditorImageSizeMenu;
35274
+ }());
35275
+
35131
35276
  /**
35132
35277
  * @description 图片菜单配置
35133
35278
  * @author wangfupeng
@@ -35221,6 +35366,12 @@
35221
35366
  factory: function () {
35222
35367
  return new ImageWidth100();
35223
35368
  },
35369
+ };
35370
+ var EditorImageSizeMenuConf = {
35371
+ key: 'editorImageSizeMenu',
35372
+ factory: function () {
35373
+ return new EditorImageSizeMenu();
35374
+ },
35224
35375
  };
35225
35376
 
35226
35377
  /**
@@ -35239,6 +35390,7 @@
35239
35390
  imageWidth30MenuConf,
35240
35391
  imageWidth50MenuConf,
35241
35392
  imageWidth100MenuConf,
35393
+ EditorImageSizeMenuConf,
35242
35394
  ],
35243
35395
  editorPlugin: withImage,
35244
35396
  };
@@ -37651,7 +37803,7 @@
37651
37803
  renderElem: renderListElem,
37652
37804
  };
37653
37805
 
37654
- /*! *****************************************************************************
37806
+ /******************************************************************************
37655
37807
  Copyright (c) Microsoft Corporation.
37656
37808
 
37657
37809
  Permission to use, copy, modify, and/or distribute this software for any
@@ -37665,7 +37817,7 @@
37665
37817
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
37666
37818
  PERFORMANCE OF THIS SOFTWARE.
37667
37819
  ***************************************************************************** */
37668
- /* global Reflect, Promise */
37820
+ /* global Reflect, Promise, SuppressedError, Symbol */
37669
37821
 
37670
37822
  var extendStatics = function(d, b) {
37671
37823
  extendStatics = Object.setPrototypeOf ||
@@ -37721,7 +37873,12 @@
37721
37873
  finally { if (e) throw e.error; }
37722
37874
  }
37723
37875
  return ar;
37724
- }
37876
+ }
37877
+
37878
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
37879
+ var e = new Error(message);
37880
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
37881
+ };
37725
37882
 
37726
37883
  /**
37727
37884
  * @description table menu helpers
@@ -40190,7 +40347,7 @@
40190
40347
  core.i18nAddResources('en', enResources);
40191
40348
  core.i18nAddResources('zh-CN', zhResources);
40192
40349
 
40193
- /*! *****************************************************************************
40350
+ /******************************************************************************
40194
40351
  Copyright (c) Microsoft Corporation.
40195
40352
 
40196
40353
  Permission to use, copy, modify, and/or distribute this software for any
@@ -40232,7 +40389,12 @@
40232
40389
  finally { if (e) throw e.error; }
40233
40390
  }
40234
40391
  return ar;
40235
- }
40392
+ }
40393
+
40394
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
40395
+ var e = new Error(message);
40396
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
40397
+ };
40236
40398
 
40237
40399
  /**
40238
40400
  * @description editor 插件,重写 editor API
@@ -41552,7 +41714,7 @@
41552
41714
  core.i18nAddResources('en', enResources);
41553
41715
  core.i18nAddResources('zh-CN', zhResources);
41554
41716
 
41555
- /*! *****************************************************************************
41717
+ /******************************************************************************
41556
41718
  Copyright (c) Microsoft Corporation.
41557
41719
 
41558
41720
  Permission to use, copy, modify, and/or distribute this software for any
@@ -41594,7 +41756,7 @@
41594
41756
  function verb(n) { return function (v) { return step([n, v]); }; }
41595
41757
  function step(op) {
41596
41758
  if (f) throw new TypeError("Generator is already executing.");
41597
- while (_) try {
41759
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41598
41760
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
41599
41761
  if (y = 0, t) op = [op[0] & 2, t.value];
41600
41762
  switch (op[0]) {
@@ -41651,7 +41813,12 @@
41651
41813
  return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
41652
41814
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
41653
41815
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
41654
- }
41816
+ }
41817
+
41818
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
41819
+ var e = new Error(message);
41820
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
41821
+ };
41655
41822
 
41656
41823
  /**
41657
41824
  * @description editor 插件,重写 editor API
@@ -41725,12 +41892,20 @@
41725
41892
  * @param height height
41726
41893
  * @returns iframe html string with size style
41727
41894
  */
41728
- function genSizeStyledIframeHtml(iframeHtml, width, height) {
41895
+ function genSizeStyledIframeHtml(iframeHtml, width, height, style) {
41729
41896
  if (width === void 0) { width = 'auto'; }
41730
41897
  if (height === void 0) { height = 'auto'; }
41898
+ if (style === void 0) { style = {}; }
41731
41899
  var $iframe = $__default["default"](iframeHtml);
41900
+ var _a = style.width, styleWidth = _a === void 0 ? '' : _a, _b = style.height, styleHeight = _b === void 0 ? '' : _b;
41901
+ var styleStr = '';
41902
+ if (styleWidth)
41903
+ styleStr += "width: " + styleWidth + ";";
41904
+ if (styleHeight)
41905
+ styleStr += "height: " + styleHeight + ";";
41732
41906
  $iframe.attr('width', width);
41733
41907
  $iframe.attr('height', height);
41908
+ $iframe.attr('style', styleStr);
41734
41909
  return $iframe[0].outerHTML;
41735
41910
  }
41736
41911
 
@@ -41739,19 +41914,19 @@
41739
41914
  * @author wangfupeng
41740
41915
  */
41741
41916
  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;
41917
+ 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
41918
  // 是否选中
41744
41919
  var selected = core.DomEditor.isNodeSelected(editor, elemNode);
41745
41920
  var vnode;
41746
41921
  if (src.trim().indexOf('<iframe ') === 0) {
41747
41922
  // 增加尺寸样式
41748
- var iframeHtml = genSizeStyledIframeHtml(src, width, height);
41923
+ var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
41749
41924
  // iframe 形式,第三方视频
41750
41925
  vnode = (snabbdom.jsx("div", { className: "w-e-textarea-video-container", "data-selected": selected ? 'true' : '', innerHTML: iframeHtml }));
41751
41926
  }
41752
41927
  else {
41753
41928
  // 其他,mp4 格式
41754
- var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true },
41929
+ var videoVnode = (snabbdom.jsx("video", { poster: poster, controls: true, style: style },
41755
41930
  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
41931
  // @ts-ignore 添加尺寸
41757
41932
  if (width !== 'auto')
@@ -41782,16 +41957,22 @@
41782
41957
  * @author wangfupeng
41783
41958
  */
41784
41959
  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;
41960
+ 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
41961
  var res = '<div data-w-e-type="video" data-w-e-is-void style="text-align: center;">\n';
41787
41962
  if (src.trim().indexOf('<iframe ') === 0) {
41788
41963
  // iframe 形式
41789
- var iframeHtml = genSizeStyledIframeHtml(src, width, height);
41964
+ var iframeHtml = genSizeStyledIframeHtml(src, width, height, style);
41790
41965
  res += iframeHtml;
41791
41966
  }
41792
41967
  else {
41793
41968
  // 其他,mp4 等 url 格式
41794
- res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
41969
+ var _g = style.width, styleWidth = _g === void 0 ? '' : _g, _h = style.height, styleHeight = _h === void 0 ? '' : _h;
41970
+ var styleStr = '';
41971
+ if (styleWidth)
41972
+ styleStr += "width: " + styleWidth + ";";
41973
+ if (styleHeight)
41974
+ styleStr += "height: " + styleHeight + ";";
41975
+ res += "<video poster=\"" + poster + "\" controls=\"true\" width=\"" + width + "\" height=\"" + height + "\" style=\"" + styleStr + "\"><source src=\"" + src + "\" type=\"video/mp4\"/></video>";
41795
41976
  }
41796
41977
  res += '\n</div>';
41797
41978
  return res;
@@ -41845,16 +42026,18 @@
41845
42026
  * @description parse html
41846
42027
  * @author wangfupeng
41847
42028
  */
41848
- function genVideoElem(src, poster, width, height) {
42029
+ function genVideoElem(src, poster, width, height, style) {
41849
42030
  if (poster === void 0) { poster = ''; }
41850
42031
  if (width === void 0) { width = 'auto'; }
41851
42032
  if (height === void 0) { height = 'auto'; }
42033
+ if (style === void 0) { style = {}; }
41852
42034
  return {
41853
42035
  type: 'video',
41854
42036
  src: src,
41855
42037
  poster: poster,
41856
42038
  width: width,
41857
42039
  height: height,
42040
+ style: style,
41858
42041
  children: [{ text: '' }], // void 元素有一个空 text
41859
42042
  };
41860
42043
  }
@@ -41864,13 +42047,15 @@
41864
42047
  var poster = '';
41865
42048
  var width = 'auto';
41866
42049
  var height = 'auto';
42050
+ var style = {};
41867
42051
  // <iframe> 形式
41868
42052
  var $iframe = $elem.find('iframe');
41869
42053
  if ($iframe.length > 0) {
41870
42054
  width = $iframe.attr('width') || 'auto';
41871
42055
  height = $iframe.attr('height') || 'auto';
42056
+ style = $iframe.attr('style') || {};
41872
42057
  src = $iframe[0].outerHTML;
41873
- return genVideoElem(src, poster, width, height);
42058
+ return genVideoElem(src, poster, width, height, style);
41874
42059
  }
41875
42060
  // <video> 形式
41876
42061
  var $video = $elem.find('video');
@@ -41884,7 +42069,8 @@
41884
42069
  width = $video.attr('width') || 'auto';
41885
42070
  height = $video.attr('height') || 'auto';
41886
42071
  poster = $video.attr('poster') || '';
41887
- return genVideoElem(src, poster, width, height);
42072
+ style = $iframe.attr('style') || {};
42073
+ return genVideoElem(src, poster, width, height, style);
41888
42074
  }
41889
42075
  var parseHtmlConf = {
41890
42076
  selector: 'div[data-w-e-type="video"]',
@@ -41935,8 +42121,10 @@
41935
42121
  * @param src video src
41936
42122
  * @param poster video poster
41937
42123
  */
41938
- function insertVideo (editor, src, poster) {
42124
+ function insertVideo (editor, src, poster, width, height) {
41939
42125
  if (poster === void 0) { poster = ''; }
42126
+ if (width === void 0) { width = ''; }
42127
+ if (height === void 0) { height = ''; }
41940
42128
  return __awaiter(this, void 0, void 0, function () {
41941
42129
  var _a, onInsertedVideo, checkVideo, parseVideoSrc, checkRes, parsedSrc, video;
41942
42130
  return __generator(this, function (_b) {
@@ -41969,7 +42157,11 @@
41969
42157
  type: 'video',
41970
42158
  src: parsedSrc,
41971
42159
  poster: poster,
41972
- children: [{ text: '' }], // 【注意】void node 需要一个空 text 作为 children
42160
+ children: [{ text: '' }],
42161
+ style: {
42162
+ width: width,
42163
+ height: height,
42164
+ },
41973
42165
  };
41974
42166
  // 插入视频
41975
42167
  // 不使用此方式会比正常的选区选取先执行
@@ -42372,13 +42564,30 @@
42372
42564
  e.preventDefault();
42373
42565
  var rawWidth = $content_1.find("#" + widthInputId).val().trim();
42374
42566
  var rawHeight = $content_1.find("#" + heightInputId).val().trim();
42375
- var numberWidth = parseInt(rawWidth);
42376
- var numberHeight = parseInt(rawHeight);
42377
- var width = numberWidth ? numberWidth.toString() : 'auto';
42378
- var height = numberHeight ? numberHeight.toString() : 'auto';
42567
+ var isPercentage = function (value) { return /^\d+(\.\d+)?%$/.test(value); }; // 检查是否为合法的百分比字符串
42568
+ var isNumeric = function (value) { return /^\d+(\.\d+)?$/.test(value); }; // 检查是否为合法的数字
42569
+ var width = 'auto';
42570
+ var height = 'auto';
42571
+ if (isPercentage(rawWidth)) {
42572
+ width = rawWidth;
42573
+ }
42574
+ else if (isNumeric(rawWidth)) {
42575
+ width = parseInt(rawWidth) + 'px';
42576
+ }
42577
+ if (isPercentage(rawHeight)) {
42578
+ height = rawHeight;
42579
+ }
42580
+ else if (isNumeric(rawHeight)) {
42581
+ height = parseInt(rawHeight) + 'px';
42582
+ }
42583
+ var _a = videoNode.style, style = _a === void 0 ? {} : _a;
42379
42584
  editor.restoreSelection();
42585
+ var props = __assign(__assign({}, style), { style: {
42586
+ width: width,
42587
+ height: height,
42588
+ } });
42380
42589
  // 修改尺寸
42381
- slate.Transforms.setNodes(editor, { width: width, height: height }, {
42590
+ slate.Transforms.setNodes(editor, props, {
42382
42591
  match: function (n) { return core.DomEditor.checkNodeType(n, 'video'); },
42383
42592
  });
42384
42593
  editor.hidePanelOrModal(); // 隐藏 modal
@@ -42578,7 +42787,7 @@
42578
42787
  core.i18nAddResources('en', enResources);
42579
42788
  core.i18nAddResources('zh-CN', zhResources);
42580
42789
 
42581
- /*! *****************************************************************************
42790
+ /******************************************************************************
42582
42791
  Copyright (c) Microsoft Corporation.
42583
42792
 
42584
42793
  Permission to use, copy, modify, and/or distribute this software for any
@@ -42620,7 +42829,7 @@
42620
42829
  function verb(n) { return function (v) { return step([n, v]); }; }
42621
42830
  function step(op) {
42622
42831
  if (f) throw new TypeError("Generator is already executing.");
42623
- while (_) try {
42832
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
42624
42833
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42625
42834
  if (y = 0, t) op = [op[0] & 2, t.value];
42626
42835
  switch (op[0]) {
@@ -42677,7 +42886,12 @@
42677
42886
  return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
42678
42887
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
42679
42888
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
42680
- }
42889
+ }
42890
+
42891
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
42892
+ var e = new Error(message);
42893
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
42894
+ };
42681
42895
 
42682
42896
  /**
42683
42897
  * @description 上传文件
@@ -47814,7 +48028,7 @@
47814
48028
  elemsToHtml: [codeToHtmlConf],
47815
48029
  };
47816
48030
 
47817
- /*! *****************************************************************************
48031
+ /******************************************************************************
47818
48032
  Copyright (c) Microsoft Corporation.
47819
48033
 
47820
48034
  Permission to use, copy, modify, and/or distribute this software for any
@@ -47856,7 +48070,12 @@
47856
48070
  finally { if (e) throw e.error; }
47857
48071
  }
47858
48072
  return ar;
47859
- }
48073
+ }
48074
+
48075
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48076
+ var e = new Error(message);
48077
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
48078
+ };
47860
48079
 
47861
48080
  /**
47862
48081
  * @description code-highlight decorate
@@ -47926,7 +48145,7 @@
47926
48145
  }));
47927
48146
  });
47928
48147
 
47929
- /*! *****************************************************************************
48148
+ /******************************************************************************
47930
48149
  Copyright (c) Microsoft Corporation.
47931
48150
 
47932
48151
  Permission to use, copy, modify, and/or distribute this software for any
@@ -47950,6 +48169,11 @@
47950
48169
  return t;
47951
48170
  };
47952
48171
  return __assign.apply(this, arguments);
48172
+ };
48173
+
48174
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48175
+ var e = new Error(message);
48176
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
47953
48177
  };
47954
48178
 
47955
48179
  /**
@@ -48224,6 +48448,7 @@
48224
48448
  'imageWidth30',
48225
48449
  'imageWidth50',
48226
48450
  'imageWidth100',
48451
+ 'editorImageSizeMenu',
48227
48452
  'editImage',
48228
48453
  'viewImageLink',
48229
48454
  'deleteImage',