suneditor 2.44.3 → 2.44.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.
Files changed (131) hide show
  1. package/LICENSE.txt +20 -20
  2. package/README.md +1585 -1585
  3. package/dist/css/suneditor.min.css +1 -1
  4. package/dist/suneditor.min.js +2 -2
  5. package/package.json +71 -71
  6. package/src/assets/css/suneditor-contents.css +556 -556
  7. package/src/assets/css/suneditor.css +0 -0
  8. package/src/assets/defaultIcons.js +103 -103
  9. package/src/lang/Lang.d.ts +143 -143
  10. package/src/lang/ckb.d.ts +4 -4
  11. package/src/lang/ckb.js +187 -187
  12. package/src/lang/da.d.ts +4 -4
  13. package/src/lang/da.js +191 -191
  14. package/src/lang/de.d.ts +4 -4
  15. package/src/lang/de.js +187 -187
  16. package/src/lang/en.d.ts +4 -4
  17. package/src/lang/en.js +187 -187
  18. package/src/lang/es.d.ts +4 -4
  19. package/src/lang/es.js +187 -187
  20. package/src/lang/fr.d.ts +4 -4
  21. package/src/lang/fr.js +188 -188
  22. package/src/lang/he.d.ts +4 -4
  23. package/src/lang/he.js +188 -188
  24. package/src/lang/index.d.ts +22 -21
  25. package/src/lang/index.js +25 -24
  26. package/src/lang/it.d.ts +4 -4
  27. package/src/lang/it.js +188 -188
  28. package/src/lang/ja.d.ts +4 -4
  29. package/src/lang/ja.js +187 -187
  30. package/src/lang/ko.d.ts +4 -4
  31. package/src/lang/ko.js +187 -187
  32. package/src/lang/lv.d.ts +4 -4
  33. package/src/lang/lv.js +187 -187
  34. package/src/lang/nl.d.ts +4 -4
  35. package/src/lang/nl.js +187 -187
  36. package/src/lang/pl.d.ts +4 -4
  37. package/src/lang/pl.js +187 -187
  38. package/src/lang/pt_br.d.ts +4 -4
  39. package/src/lang/pt_br.js +189 -189
  40. package/src/lang/ro.d.ts +4 -4
  41. package/src/lang/ro.js +187 -187
  42. package/src/lang/ru.d.ts +4 -4
  43. package/src/lang/ru.js +187 -187
  44. package/src/lang/se.d.ts +4 -4
  45. package/src/lang/se.js +191 -191
  46. package/src/lang/ua.d.ts +5 -5
  47. package/src/lang/ua.js +188 -188
  48. package/src/lang/ur.d.ts +5 -0
  49. package/src/lang/ur.js +188 -0
  50. package/src/lang/zh_cn.d.ts +4 -4
  51. package/src/lang/zh_cn.js +187 -187
  52. package/src/lib/constructor.js +1 -2
  53. package/src/lib/context.d.ts +42 -42
  54. package/src/lib/context.js +0 -0
  55. package/src/lib/core.d.ts +1101 -1101
  56. package/src/lib/core.js +205 -88
  57. package/src/lib/history.d.ts +48 -48
  58. package/src/lib/history.js +218 -218
  59. package/src/lib/util.d.ts +677 -677
  60. package/src/lib/util.js +38 -12
  61. package/src/options.d.ts +608 -608
  62. package/src/plugins/CommandPlugin.d.ts +7 -7
  63. package/src/plugins/DialogPlugin.d.ts +19 -19
  64. package/src/plugins/FileBrowserPlugin.d.ts +29 -29
  65. package/src/plugins/Module.d.ts +14 -14
  66. package/src/plugins/Plugin.d.ts +41 -41
  67. package/src/plugins/SubmenuPlugin.d.ts +7 -7
  68. package/src/plugins/command/blockquote.d.ts +4 -4
  69. package/src/plugins/command/blockquote.js +46 -46
  70. package/src/plugins/dialog/audio.d.ts +4 -4
  71. package/src/plugins/dialog/audio.js +556 -554
  72. package/src/plugins/dialog/image.d.ts +4 -4
  73. package/src/plugins/dialog/image.js +1122 -1107
  74. package/src/plugins/dialog/link.d.ts +4 -4
  75. package/src/plugins/dialog/link.js +223 -223
  76. package/src/plugins/dialog/math.d.ts +4 -4
  77. package/src/plugins/dialog/math.js +294 -294
  78. package/src/plugins/dialog/mention.d.ts +5 -5
  79. package/src/plugins/dialog/mention.js +242 -242
  80. package/src/plugins/dialog/video.d.ts +4 -4
  81. package/src/plugins/dialog/video.js +983 -981
  82. package/src/plugins/fileBrowser/imageGallery.d.ts +4 -4
  83. package/src/plugins/fileBrowser/imageGallery.js +63 -63
  84. package/src/plugins/index.d.ts +79 -79
  85. package/src/plugins/index.js +32 -32
  86. package/src/plugins/modules/_anchor.js +461 -462
  87. package/src/plugins/modules/_colorPicker.d.ts +59 -59
  88. package/src/plugins/modules/_colorPicker.js +0 -0
  89. package/src/plugins/modules/_notice.d.ts +20 -20
  90. package/src/plugins/modules/_notice.js +72 -72
  91. package/src/plugins/modules/_selectMenu.js +118 -118
  92. package/src/plugins/modules/component.d.ts +24 -24
  93. package/src/plugins/modules/component.js +82 -82
  94. package/src/plugins/modules/dialog.d.ts +27 -27
  95. package/src/plugins/modules/dialog.js +174 -174
  96. package/src/plugins/modules/fileBrowser.d.ts +41 -41
  97. package/src/plugins/modules/fileBrowser.js +373 -373
  98. package/src/plugins/modules/fileManager.d.ts +66 -66
  99. package/src/plugins/modules/fileManager.js +325 -324
  100. package/src/plugins/modules/index.d.ts +10 -10
  101. package/src/plugins/modules/index.js +8 -8
  102. package/src/plugins/modules/resizing.d.ts +153 -153
  103. package/src/plugins/modules/resizing.js +895 -895
  104. package/src/plugins/submenu/align.d.ts +4 -4
  105. package/src/plugins/submenu/align.js +160 -160
  106. package/src/plugins/submenu/font.d.ts +4 -4
  107. package/src/plugins/submenu/font.js +120 -120
  108. package/src/plugins/submenu/fontColor.d.ts +4 -4
  109. package/src/plugins/submenu/fontColor.js +0 -0
  110. package/src/plugins/submenu/fontSize.d.ts +4 -4
  111. package/src/plugins/submenu/fontSize.js +112 -112
  112. package/src/plugins/submenu/formatBlock.d.ts +4 -4
  113. package/src/plugins/submenu/formatBlock.js +273 -273
  114. package/src/plugins/submenu/hiliteColor.d.ts +4 -4
  115. package/src/plugins/submenu/hiliteColor.js +0 -0
  116. package/src/plugins/submenu/horizontalRule.d.ts +4 -4
  117. package/src/plugins/submenu/horizontalRule.js +98 -98
  118. package/src/plugins/submenu/lineHeight.d.ts +4 -4
  119. package/src/plugins/submenu/lineHeight.js +104 -104
  120. package/src/plugins/submenu/list.d.ts +4 -4
  121. package/src/plugins/submenu/list.js +456 -455
  122. package/src/plugins/submenu/paragraphStyle.d.ts +4 -4
  123. package/src/plugins/submenu/paragraphStyle.js +135 -135
  124. package/src/plugins/submenu/table.d.ts +4 -4
  125. package/src/plugins/submenu/template.d.ts +4 -4
  126. package/src/plugins/submenu/template.js +71 -71
  127. package/src/plugins/submenu/textStyle.d.ts +4 -4
  128. package/src/plugins/submenu/textStyle.js +167 -167
  129. package/src/suneditor.d.ts +9 -9
  130. package/src/suneditor.js +75 -75
  131. package/src/suneditor_build.js +17 -17
package/src/lib/core.js CHANGED
@@ -448,7 +448,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
448
448
  * @property {Element} OUTDENT outdent button
449
449
  * @property {Element} INDENT indent button
450
450
  */
451
- commandMap: null,
451
+ commandMap: {},
452
452
 
453
453
  /**
454
454
  * @description CSS properties related to style tags
@@ -514,6 +514,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
514
514
  _lineBreakDir: ''
515
515
  },
516
516
 
517
+ /**
518
+ * @description Temp variable for set line attrs
519
+ * @private
520
+ */
521
+ _formatAttrsTemp: null,
522
+
517
523
  /**
518
524
  * @description Save the current buttons states to "allCommandButtons" object
519
525
  * @private
@@ -1143,7 +1149,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1143
1149
  * @returns {Object}
1144
1150
  */
1145
1151
  getSelection: function () {
1146
- return this._shadowRoot && this._shadowRoot.getSelection ? this._shadowRoot.getSelection() : this._ww.getSelection();
1152
+ const selection = this._shadowRoot && this._shadowRoot.getSelection ? this._shadowRoot.getSelection() : this._ww.getSelection();
1153
+ if (!context.element.wysiwyg.contains(selection.focusNode)) {
1154
+ selection.removeAllRanges();
1155
+ selection.addRange(this._createDefaultRange());
1156
+ }
1157
+ return selection;
1147
1158
  },
1148
1159
 
1149
1160
  /**
@@ -1212,14 +1223,21 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1212
1223
  */
1213
1224
  _createDefaultRange: function () {
1214
1225
  const wysiwyg = context.element.wysiwyg;
1215
- wysiwyg.focus();
1216
1226
  const range = this._wd.createRange();
1217
1227
 
1218
- let focusEl = wysiwyg.firstElementChild;
1219
- if (!focusEl) {
1220
- focusEl = util.createElement(options.defaultTag);
1221
- focusEl.innerHTML = '<br>';
1222
- wysiwyg.appendChild(focusEl);
1228
+ let firstFormat = wysiwyg.firstElementChild;
1229
+ let focusEl = null;
1230
+ if (!firstFormat) {
1231
+ firstFormat = util.createElement(options.defaultTag);
1232
+ focusEl = util.createElement('BR');
1233
+ firstFormat.appendChild(focusEl);
1234
+ wysiwyg.appendChild(firstFormat);
1235
+ } else {
1236
+ focusEl = firstFormat.firstChild;
1237
+ if (!focusEl) {
1238
+ focusEl = util.createElement('BR');
1239
+ firstFormat.appendChild(focusEl);
1240
+ }
1223
1241
  }
1224
1242
 
1225
1243
  range.setStart(focusEl, 0);
@@ -1518,7 +1536,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1518
1536
  oFormat = util.createElement(oFormatName);
1519
1537
  oFormat.innerHTML = '<br>';
1520
1538
  if ((formatNode && typeof formatNode !== 'string') || (!formatNode && util.isFormatElement(currentFormatEl))) {
1521
- util.copyTagAttributes(oFormat, formatNode || currentFormatEl);
1539
+ util.copyTagAttributes(oFormat, formatNode || currentFormatEl, ['id']);
1522
1540
  }
1523
1541
  }
1524
1542
 
@@ -1884,6 +1902,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1884
1902
  } else {
1885
1903
  afterNode = null;
1886
1904
  }
1905
+ } else if (util.isWysiwygDiv(container) && !util.isFormatElement(oNode)) {
1906
+ parentNode = container.appendChild(util.createElement(options.defaultTag));
1907
+ afterNode = null;
1887
1908
  } else {
1888
1909
  afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
1889
1910
  parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
@@ -2125,11 +2146,16 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2125
2146
  startOff = endOff = 0;
2126
2147
  }
2127
2148
 
2149
+ if (!startCon || !endCon) return {
2150
+ container: commonCon,
2151
+ offset: 0
2152
+ };
2153
+
2128
2154
  if (startCon === endCon && range.collapsed) {
2129
2155
  if (startCon.textContent && util.onlyZeroWidthSpace(startCon.textContent.substr(startOff))) {
2130
2156
  return {
2131
2157
  container: startCon,
2132
- offset: offset,
2158
+ offset: startOff,
2133
2159
  prevContainer: startCon && startCon.parentNode ? startCon : null
2134
2160
  };
2135
2161
  }
@@ -2459,8 +2485,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2459
2485
  */
2460
2486
  detachRangeFormatElement: function (rangeElement, selectedFormats, newRangeElement, remove, notHistoryPush) {
2461
2487
  const range = this.getRange();
2462
- const so = range.startOffset;
2463
- const eo = range.endOffset;
2488
+ let so = range.startOffset;
2489
+ let eo = range.endOffset;
2464
2490
 
2465
2491
  let children = util.getListChildNodes(rangeElement, function (current) { return current.parentNode === rangeElement; });
2466
2492
  let parent = rangeElement.parentNode;
@@ -2475,7 +2501,10 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2475
2501
  let moveComplete = false;
2476
2502
 
2477
2503
  function appendNode (parent, insNode, sibling, originNode) {
2478
- if (util.onlyZeroWidthSpace(insNode)) insNode.innerHTML = util.zeroWidthSpace;
2504
+ if (util.onlyZeroWidthSpace(insNode)) {
2505
+ insNode.innerHTML = util.zeroWidthSpace;
2506
+ so = eo = 1;
2507
+ }
2479
2508
 
2480
2509
  if (insNode.nodeType === 3) {
2481
2510
  parent.insertBefore(insNode, sibling);
@@ -2636,7 +2665,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2636
2665
  if (rangeElement.children.length === 0 || rangeElement.textContent.length === 0) {
2637
2666
  util.removeItem(rangeElement);
2638
2667
  } else {
2639
- util.removeEmptyNode(rangeElement, null);
2668
+ util.removeEmptyNode(rangeElement, null, false);
2640
2669
  }
2641
2670
 
2642
2671
  let edge = null;
@@ -2644,7 +2673,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2644
2673
  edge = {
2645
2674
  cc: rangeParent,
2646
2675
  sc: firstNode,
2676
+ so: so,
2647
2677
  ec: rangeRight,
2678
+ eo: eo,
2648
2679
  removeArray: removeArray
2649
2680
  };
2650
2681
  } else {
@@ -2654,7 +2685,10 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2654
2685
  edge = {
2655
2686
  cc: (childEdge.sc || childEdge.ec).parentNode,
2656
2687
  sc: childEdge.sc,
2657
- ec: childEdge.ec
2688
+ so: so,
2689
+ ec: childEdge.ec,
2690
+ eo: eo,
2691
+ removeArray: null
2658
2692
  };
2659
2693
  }
2660
2694
 
@@ -3604,7 +3638,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
3604
3638
  }
3605
3639
  }
3606
3640
 
3607
- util.removeEmptyNode(pNode, newInnerNode);
3641
+ util.removeEmptyNode(pNode, newInnerNode, false);
3608
3642
 
3609
3643
  if (collapsed) {
3610
3644
  startOffset = startContainer.textContent.length;
@@ -3911,7 +3945,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
3911
3945
  element.appendChild(container);
3912
3946
  }
3913
3947
  } else {
3914
- util.removeEmptyNode(pNode, newInnerNode);
3948
+ util.removeEmptyNode(pNode, newInnerNode, false);
3915
3949
 
3916
3950
  if (util.onlyZeroWidthSpace(pNode.textContent)) {
3917
3951
  container = pNode.firstChild;
@@ -4060,7 +4094,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4060
4094
  }
4061
4095
  }
4062
4096
 
4063
- util.removeEmptyNode(pNode, newInnerNode);
4097
+ util.removeEmptyNode(pNode, newInnerNode, false);
4064
4098
  util.mergeSameTags(pNode, null, true);
4065
4099
 
4066
4100
  // node change
@@ -4335,7 +4369,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4335
4369
  }
4336
4370
  } else {
4337
4371
  if (!isRemoveNode && newInnerNode.textContent.length === 0) {
4338
- util.removeEmptyNode(pNode, null);
4372
+ util.removeEmptyNode(pNode, null, false);
4339
4373
  return {
4340
4374
  ancestor: null,
4341
4375
  container: null,
@@ -4343,7 +4377,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4343
4377
  };
4344
4378
  }
4345
4379
 
4346
- util.removeEmptyNode(pNode, newInnerNode);
4380
+ util.removeEmptyNode(pNode, newInnerNode, false);
4347
4381
 
4348
4382
  if (util.onlyZeroWidthSpace(pNode.textContent)) {
4349
4383
  container = pNode.firstChild;
@@ -4799,7 +4833,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4799
4833
  _var._codeOriginCssText = code.style.cssText;
4800
4834
 
4801
4835
  editorArea.style.cssText = toolbar.style.cssText = '';
4802
- wysiwygFrame.style.cssText = (wysiwygFrame.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/) || [''])[0] + options.defaultStyle;
4836
+ wysiwygFrame.style.cssText = (wysiwygFrame.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/) || [''])[0] + options._editorStyles.editor;
4803
4837
  code.style.cssText = (code.style.cssText.match(/\s?display(\s+)?:(\s+)?[a-zA-Z]+;/) || [''])[0];
4804
4838
  toolbar.style.width = wysiwygFrame.style.height = code.style.height = '100%';
4805
4839
  toolbar.style.position = 'relative';
@@ -5048,7 +5082,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5048
5082
  setContents: function (html) {
5049
5083
  this.removeRange();
5050
5084
 
5051
- const convertValue = (html === null || html === undefined) ? '' : this.convertContentsForEditor(html);
5085
+ const convertValue = (html === null || html === undefined) ? '' : this.cleanHTML(html, null, null);
5052
5086
  this._resetComponents();
5053
5087
 
5054
5088
  if (!this._variable.isCodeView) {
@@ -5077,7 +5111,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5077
5111
  * @returns {Object}
5078
5112
  */
5079
5113
  getContents: function (onlyContents) {
5080
- const contents = this.convertHTMLForCodeView(context.element.wysiwyg, true);
5114
+ const contents = this.cleanHTML(context.element.wysiwyg.innerHTML, null, null);
5081
5115
  const renderHTML = util.createElement('DIV');
5082
5116
  renderHTML.innerHTML = contents;
5083
5117
 
@@ -5120,7 +5154,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5120
5154
  if (node.nodeType === 1) {
5121
5155
  if (util._disallowedTags(node)) return '';
5122
5156
 
5123
- const ch = util.getListChildNodes(node, function(current) { return util.isSpanWithoutAttr(current); }) || [];
5157
+ const ch = util.getListChildNodes(node, function(current) { return util.isSpanWithoutAttr(current) && !util.getParentElement(current, util.isNotCheckingNode); }) || [];
5124
5158
  for (let i = ch.length - 1; i >= 0; i--) {
5125
5159
  ch[i].outerHTML = ch[i].innerHTML;
5126
5160
  }
@@ -5172,24 +5206,28 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5172
5206
  * @private
5173
5207
  */
5174
5208
  _deleteDisallowedTags: function (html) {
5175
- return html
5176
- .replace(/\n/g, '')
5177
- .replace(/<(script|style)[\s\S]*>[\s\S]*<\/(script|style)>/gi, '')
5178
- .replace(/<[a-z0-9]+\:[a-z0-9]+[^>^\/]*>[^>]*<\/[a-z0-9]+\:[a-z0-9]+>/gi, '')
5179
- .replace(this.editorTagsWhitelistRegExp, '')
5180
- .replace(this.editorTagsBlacklistRegExp, '');
5181
- },
5209
+ html = html
5210
+ .replace(/<(script|style)[\s\S]*>[\s\S]*<\/(script|style)>/gi, '')
5211
+ .replace(/<[a-z0-9]+\:[a-z0-9]+[^>^\/]*>[^>]*<\/[a-z0-9]+\:[a-z0-9]+>/gi, '');
5212
+
5213
+ if (!/\bfont\b/i.test(this.options._editorTagsWhitelist)) {
5214
+ html = html.replace(/(<\/?)font(\s?)/gi, '$1span$2');
5215
+ }
5216
+
5217
+ return html.replace(this.editorTagsWhitelistRegExp, '').replace(this.editorTagsBlacklistRegExp, '');
5218
+ },
5182
5219
 
5183
5220
  _convertFontSize: function (to, size) {
5221
+ const math = this._w.Math;
5184
5222
  const value = size.match(/(\d+(?:\.\d+)?)(.+)/);
5185
5223
  const sizeNum = value[1] * 1;
5186
5224
  const from = value[2];
5187
5225
  let pxSize = sizeNum;
5188
5226
 
5189
5227
  if (/em/.test(from)) {
5190
- pxSize = this.round(sizeNum / 0.0625);
5228
+ pxSize = math.round(sizeNum / 0.0625);
5191
5229
  } else if (from === 'pt') {
5192
- pxSize = this.round(sizeNum * 1.333);
5230
+ pxSize = math.round(sizeNum * 1.333);
5193
5231
  } else if (from === '%') {
5194
5232
  pxSize = sizeNum / 100;
5195
5233
  }
@@ -5200,17 +5238,26 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5200
5238
  case '%':
5201
5239
  return (pxSize * 0.0625).toFixed(2) + to;
5202
5240
  case 'pt':
5203
- return this.floor(pxSize / 1.333) + to;
5241
+ return math.floor(pxSize / 1.333) + to;
5204
5242
  default: // px
5205
5243
  return pxSize + to;
5206
5244
  }
5207
5245
  },
5208
5246
 
5209
5247
  _cleanStyle: function (m, v, name) {
5210
- const sv = m.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);
5248
+ let sv = (m.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/) || [])[0];
5249
+ if (/span/i.test(name) && !sv && (m.match(/<span\s(.+)/) || [])[1]) {
5250
+ const size = (m.match(/\ssize="([^"]+)"/i) || [])[1];
5251
+ const face = (m.match(/\sface="([^"]+)"/i) || [])[1];
5252
+ const color = (m.match(/\scolor="([^"]+)"/i) || [])[1];
5253
+ if (size || face || color) {
5254
+ sv = 'style="' + (size ? 'font-size:' + (this.util.getNumber(size/3.333, 1)) + 'rem;' : '') + (face ? 'font-family:' + face + ';' : '') + (color ? 'color:' + color + ';' : '') + '"';
5255
+ }
5256
+ }
5257
+
5211
5258
  if (sv) {
5212
5259
  if (!v) v = [];
5213
- const style = sv[0].replace(/&quot;/g, '').match(this._cleanStyleRegExp[name]);
5260
+ const style = sv.replace(/&quot;/g, '').match(this._cleanStyleRegExp[name]);
5214
5261
  if (style) {
5215
5262
  const allowedStyle = [];
5216
5263
  for (let i = 0, len = style.length, r; i < len; i++) {
@@ -5226,7 +5273,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5226
5273
  case 'fontSize':
5227
5274
  if (!options.plugins.fontSize) continue;
5228
5275
  if (!this._cleanStyleRegExp.fontSizeUnit.test(r[0])) {
5229
- r[0] = r[0].replace(this._w.RegExp('\\d+' + r[0].match(/\d+(.+$)/)[1]), this._convertFontSize.bind(this._w.Math, options.fontSizeUnit));
5276
+ r[0] = r[0].replace(this._w.RegExp('\\d+' + r[0].match(/\d+(.+$)/)[1]), this._convertFontSize.bind(this, options.fontSizeUnit));
5230
5277
  }
5231
5278
  break;
5232
5279
  case 'color':
@@ -5259,21 +5306,21 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5259
5306
  */
5260
5307
  _cleanTags: function (lowLevelCheck, m, t) {
5261
5308
  if (/^<[a-z0-9]+\:[a-z0-9]+/i.test(m)) return m;
5262
-
5309
+
5263
5310
  let v = null;
5264
5311
  const tagName = t.match(/(?!<)[a-zA-Z0-9\-]+/)[0].toLowerCase();
5265
-
5312
+
5266
5313
  // blacklist
5267
5314
  const bAttr = this._attributesTagsBlacklist[tagName];
5268
5315
  m = m.replace(/\s(?:on[a-z]+)\s*=\s*(")[^"]*\1/ig, '');
5269
5316
  if (bAttr) m = m.replace(bAttr, '');
5270
5317
  else m = m.replace(this._attributesBlacklistRegExp, '');
5271
-
5318
+
5272
5319
  // whitelist
5273
5320
  const wAttr = this._attributesTagsWhitelist[tagName];
5274
5321
  if (wAttr) v = m.match(wAttr);
5275
5322
  else v = m.match(lowLevelCheck ? this._attributesWhitelistRegExp : this._attributesWhitelistRegExp_all_data);
5276
-
5323
+
5277
5324
  // attribute
5278
5325
  if (lowLevelCheck) {
5279
5326
  if (tagName === 'a') {
@@ -5320,7 +5367,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5320
5367
 
5321
5368
  if (v) {
5322
5369
  for (let i = 0, len = v.length; i < len; i++) {
5323
- if (lowLevelCheck && /^class="(?!(__se__|se-|katex))/.test(v[i].trim())) continue;
5370
+ // if (lowLevelCheck && /^class="(?!(__se__|se-|katex))/.test(v[i].trim())) continue;
5324
5371
  t += ' ' + (/^(?:href|src)\s*=\s*('|"|\s)*javascript\s*\:/i.test(v[i].trim()) ? '' : v[i]);
5325
5372
  }
5326
5373
  }
@@ -5337,9 +5384,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5337
5384
  _editFormat: function (dom) {
5338
5385
  let value = '', f;
5339
5386
  const tempTree = dom.childNodes;
5387
+
5340
5388
  for (let i = 0, len = tempTree.length, n; i < len; i++) {
5341
5389
  n = tempTree[i];
5342
- if (!util.isFormatElement(n) && !util.isRangeFormatElement(n) && !util.isComponent(n) && !/meta/i.test(n.nodeName)) {
5390
+ if (n.nodeType === 8) {
5391
+ value += '<!-- ' + n.textContent + ' -->';
5392
+ } else if (!util.isFormatElement(n) && !util.isRangeFormatElement(n) && !util.isComponent(n) && !/meta/i.test(n.nodeName)) {
5343
5393
  if (!f) f = util.createElement(options.defaultTag);
5344
5394
  f.appendChild(n);
5345
5395
  i--; len--;
@@ -5962,25 +6012,24 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5962
6012
  this.codeViewDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-code-view-enabled"]):not([data-display="MORE"])');
5963
6013
  this.resizingDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-resizing-enabled"]):not([data-display="MORE"])');
5964
6014
 
5965
- this._saveButtonStates();
5966
-
5967
6015
  const tool = context.tool;
5968
- this.commandMap = {
5969
- OUTDENT: tool.outdent,
5970
- INDENT: tool.indent
5971
- };
5972
- this.commandMap[options.textTags.bold.toUpperCase()] = tool.bold;
5973
- this.commandMap[options.textTags.underline.toUpperCase()] = tool.underline;
5974
- this.commandMap[options.textTags.italic.toUpperCase()] = tool.italic;
5975
- this.commandMap[options.textTags.strike.toUpperCase()] = tool.strike;
5976
- this.commandMap[options.textTags.sub.toUpperCase()] = tool.subscript;
5977
- this.commandMap[options.textTags.sup.toUpperCase()] = tool.superscript;
6016
+ const commandMap = this.commandMap;
6017
+ commandMap.INDENT = tool.indent;
6018
+ commandMap.OUTDENT = tool.outdent;
6019
+ commandMap[options.textTags.bold.toUpperCase()] = tool.bold;
6020
+ commandMap[options.textTags.underline.toUpperCase()] = tool.underline;
6021
+ commandMap[options.textTags.italic.toUpperCase()] = tool.italic;
6022
+ commandMap[options.textTags.strike.toUpperCase()] = tool.strike;
6023
+ commandMap[options.textTags.sub.toUpperCase()] = tool.subscript;
6024
+ commandMap[options.textTags.sup.toUpperCase()] = tool.superscript;
5978
6025
 
5979
6026
  this._styleCommandMap = {
5980
6027
  fullScreen: tool.fullScreen,
5981
6028
  showBlocks: tool.showBlocks,
5982
6029
  codeView: tool.codeView
5983
6030
  };
6031
+
6032
+ this._saveButtonStates();
5984
6033
  },
5985
6034
 
5986
6035
  /**
@@ -6024,9 +6073,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6024
6073
  _w.setTimeout(function () {
6025
6074
  const h = core._iframeAuto.offsetHeight;
6026
6075
  context.element.wysiwygFrame.style.height = h + 'px';
6027
- if (util.isIE) core.__callResizeFunction(h, null);
6076
+ if (!util.isResizeObserverSupported) core.__callResizeFunction(h, null);
6028
6077
  });
6029
- } else if (util.isIE) {
6078
+ } else if (!util.isResizeObserverSupported) {
6030
6079
  core.__callResizeFunction(context.element.wysiwygFrame.offsetHeight, null);
6031
6080
  }
6032
6081
  },
@@ -6187,10 +6236,10 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6187
6236
  if (event._resizeObserver) event._resizeObserver.observe(context.element.wysiwygFrame);
6188
6237
  if (event._toolbarObserver) event._toolbarObserver.observe(context.element._toolbarShadow);
6189
6238
  // resource state
6190
- core._resourcesStateChange();
6239
+ this._resourcesStateChange();
6191
6240
  // user event
6192
6241
  if (typeof functions.onload === 'function') functions.onload(core, reload);
6193
- });
6242
+ }.bind(this));
6194
6243
  },
6195
6244
 
6196
6245
  /**
@@ -6767,7 +6816,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6767
6816
  if (!siblingNode) {
6768
6817
  siblingNode = util.getFormatElement(container);
6769
6818
  siblingNode = siblingNode ? siblingNode[siblingKey] : null;
6770
- if (siblingNode && !util.isComponent(siblingNode)) siblingNode = siblingKey === 'previousSibling' ? siblingNode.firstElementChild : siblingNode.lastElementChild;
6819
+ if (siblingNode && !util.isComponent(siblingNode)) siblingNode = siblingKey === 'previousSibling' ? siblingNode.firstChild : siblingNode.lastChild;
6771
6820
  else return null;
6772
6821
  }
6773
6822
 
@@ -6900,6 +6949,13 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6900
6949
  break;
6901
6950
  }
6902
6951
 
6952
+ // format attributes
6953
+ if (!selectRange && core._isEdgeFormat(range.startContainer, range.startOffset, 'start')) {
6954
+ if (util.isFormatElement(formatEl.previousElementSibling)) {
6955
+ core._formatAttrsTemp = formatEl.previousElementSibling.attributes;
6956
+ }
6957
+ }
6958
+
6903
6959
  // nested list
6904
6960
  const commonCon = range.commonAncestorContainer;
6905
6961
  formatEl = util.getFormatElement(range.startContainer, null);
@@ -6986,7 +7042,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6986
7042
  const prev = formatEl.previousSibling;
6987
7043
  // select file component
6988
7044
  const ignoreZWS = (commonCon.nodeType === 3 || util.isBreak(commonCon)) && !commonCon.previousSibling && range.startOffset === 0;
6989
- if (!sel.previousSibling && (util.isComponent(commonCon.previousSibling) || (ignoreZWS && util.isComponent(prev)))) {
7045
+ if (sel && !sel.previousSibling && ( (commonCon && util.isComponent(commonCon.previousSibling)) || (ignoreZWS && util.isComponent(prev)))) {
6990
7046
  const fileComponentInfo = core.getFileComponent(prev);
6991
7047
  if (fileComponentInfo) {
6992
7048
  e.preventDefault();
@@ -7001,7 +7057,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7001
7057
  break;
7002
7058
  }
7003
7059
  // delete nonEditable
7004
- if (util.isNonEditable(sel.previousSibling)) {
7060
+ if (sel && util.isNonEditable(sel.previousSibling)) {
7005
7061
  e.preventDefault();
7006
7062
  e.stopPropagation();
7007
7063
  util.removeItem(sel.previousSibling);
@@ -7079,6 +7135,13 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7079
7135
  }
7080
7136
  }
7081
7137
 
7138
+ // format attributes
7139
+ if (!selectRange && core._isEdgeFormat(range.endContainer, range.endOffset, 'end')) {
7140
+ if (util.isFormatElement(formatEl.nextElementSibling)) {
7141
+ core._formatAttrsTemp = formatEl.attributes;
7142
+ }
7143
+ }
7144
+
7082
7145
  // nested list
7083
7146
  formatEl = util.getFormatElement(range.startContainer, null);
7084
7147
  rangeEl = util.getRangeFormatElement(formatEl, null);
@@ -7260,17 +7323,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7260
7323
  }
7261
7324
 
7262
7325
  if (!shift) {
7263
- const formatInners = core._isEdgeFormat(range.endContainer, range.endOffset, 'end');
7264
- if ((formatInners && /^H[1-6]$/i.test(formatEl.nodeName)) || /^HR$/i.test(formatEl.nodeName)) {
7326
+ const formatEndEdge = core._isEdgeFormat(range.endContainer, range.endOffset, 'end');
7327
+ const formatStartEdge = core._isEdgeFormat(range.startContainer, range.startOffset, 'start');
7328
+ // add default format line
7329
+ if (formatEndEdge && (/^H[1-6]$/i.test(formatEl.nodeName) || /^HR$/i.test(formatEl.nodeName))) {
7265
7330
  e.preventDefault();
7266
7331
  let temp = null;
7267
7332
  const newFormat = core.appendFormatTag(formatEl, options.defaultTag);
7268
7333
 
7269
- if (formatInners && formatInners.length > 0) {
7270
- temp = formatInners.pop();
7334
+ if (formatEndEdge && formatEndEdge.length > 0) {
7335
+ temp = formatEndEdge.pop();
7271
7336
  const innerNode = temp;
7272
- while(formatInners.length > 0) {
7273
- temp = temp.appendChild(formatInners.pop());
7337
+ while(formatEndEdge.length > 0) {
7338
+ temp = temp.appendChild(formatEndEdge.pop());
7274
7339
  }
7275
7340
  newFormat.appendChild(innerNode);
7276
7341
  }
@@ -7278,7 +7343,28 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7278
7343
  temp = !temp ? newFormat.firstChild : temp.appendChild(newFormat.firstChild);
7279
7344
  core.setRange(temp, 0, temp, 0);
7280
7345
  break;
7281
- } else if (options.lineAttrReset && formatEl && !util.isListCell(formatEl)) {
7346
+ }
7347
+
7348
+ // set format attrs - edge
7349
+ if (formatStartEdge || formatEndEdge) {
7350
+ e.preventDefault();
7351
+ const focusBR = util.createElement('BR');
7352
+ const newFormat = util.createElement(formatEl.nodeName);
7353
+ newFormat.appendChild(focusBR);
7354
+
7355
+ util.copyTagAttributes(newFormat, formatEl, ['id'].concat(options.lineAttrReset));
7356
+
7357
+ formatEl.parentNode.insertBefore(newFormat, formatStartEdge ? formatEl : formatEl.nextElementSibling);
7358
+ if (formatEndEdge) {
7359
+ core.setRange(focusBR, 1, focusBR, 1);
7360
+ }
7361
+
7362
+ break;
7363
+ } else {
7364
+ core._formatAttrsTemp = formatEl.attributes;
7365
+ }
7366
+
7367
+ if (options.lineAttrReset && formatEl && !util.isListCell(formatEl)) {
7282
7368
  e.preventDefault();
7283
7369
  e.stopPropagation();
7284
7370
 
@@ -7304,11 +7390,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7304
7390
  else newEl = util.splitElement(range.endContainer, range.endOffset, 0);
7305
7391
  }
7306
7392
 
7307
- const resetAttr = options.lineAttrReset === '*' ? null : options.lineAttrReset;
7393
+ const resetAttr = options.lineAttrReset;
7308
7394
  const attrs = newEl.attributes;
7309
7395
  let i = 0;
7310
7396
  while (attrs[i]) {
7311
- if (resetAttr && resetAttr.test(attrs[i].name)) {
7397
+ if (resetAttr && resetAttr.indexOf(attrs[i].name.toLowerCase()) > -1) {
7312
7398
  i++;
7313
7399
  continue;
7314
7400
  }
@@ -7520,6 +7606,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7520
7606
 
7521
7607
  const formatEl = util.getFormatElement(selectionNode, null);
7522
7608
  const rangeEl = util.getRangeFormatElement(selectionNode, null);
7609
+ const attrs = core._formatAttrsTemp;
7610
+
7611
+ if (attrs) {
7612
+ for (let i = 0, len = attrs.length; i < len; i++) {
7613
+ if (keyCode === 13 && /^id$/i.test(attrs[i].name)) {
7614
+ formatEl.removeAttribute('id');
7615
+ continue;
7616
+ }
7617
+ formatEl.setAttribute(attrs[i].name, attrs[i].value);
7618
+ }
7619
+ core._formatAttrsTemp = null;
7620
+ }
7621
+
7523
7622
  if (!formatEl && range.collapsed && !util.isComponent(selectionNode) && !util.isList(selectionNode) && core._setDefaultFormat(util.isRangeFormatElement(rangeEl) ? 'DIV' : options.defaultTag) !== null) {
7524
7623
  selectionNode = core.getSelectionNode();
7525
7624
  }
@@ -7580,9 +7679,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7580
7679
  core._variable.currentNodes = [];
7581
7680
  core._variable.currentNodesMap = [];
7582
7681
  if (options.showPathLabel) context.element.navigation.textContent = '';
7583
-
7584
7682
  // user event
7585
- if (typeof functions.onBlur === 'function') functions.onBlur(e, core);
7683
+ if (typeof functions.onBlur === 'function') functions.onBlur(e, core,this);
7586
7684
  },
7587
7685
 
7588
7686
  onMouseDown_resizingBar: function (e) {
@@ -7609,13 +7707,15 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7609
7707
  const h = (resizeInterval < core._variable.minResizingSize ? core._variable.minResizingSize : resizeInterval);
7610
7708
  context.element.wysiwygFrame.style.height = context.element.code.style.height = h + 'px';
7611
7709
  core._variable.resizeClientY = e.clientY;
7612
- if (util.isIE) core.__callResizeFunction(h, null);
7710
+ if (!util.isResizeObserverSupported) core.__callResizeFunction(h, null);
7613
7711
  },
7614
7712
 
7615
7713
  onResize_window: function () {
7616
- if (util.isIE) core.resetResponsiveToolbar();
7714
+ if (!util.isResizeObserverSupported) core.resetResponsiveToolbar();
7617
7715
 
7618
- if (context.element.toolbar.offsetWidth === 0) return;
7716
+ const toolbar = context.element.toolbar;
7717
+ const isToolbarHidden = (toolbar.style.display === 'none' || (core._isInline && !core._inlineToolbarAttr.isShow));
7718
+ if (toolbar.offsetWidth === 0 && !isToolbarHidden) return;
7619
7719
 
7620
7720
  if (context.fileBrowser && context.fileBrowser.area.style.display === 'block') {
7621
7721
  context.fileBrowser.body.style.maxHeight = (_w.innerHeight - context.fileBrowser.header.offsetHeight - 50) + 'px';
@@ -7626,7 +7726,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7626
7726
  }
7627
7727
 
7628
7728
  if (core._variable.isFullScreen) {
7629
- core._variable.innerHeight_fullScreen += (_w.innerHeight - context.element.toolbar.offsetHeight) - core._variable.innerHeight_fullScreen;
7729
+ core._variable.innerHeight_fullScreen += (_w.innerHeight - toolbar.offsetHeight) - core._variable.innerHeight_fullScreen;
7630
7730
  context.element.editorArea.style.height = core._variable.innerHeight_fullScreen + 'px';
7631
7731
  return;
7632
7732
  }
@@ -7639,7 +7739,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7639
7739
  core._iframeAutoHeight();
7640
7740
 
7641
7741
  if (core._sticky) {
7642
- context.element.toolbar.style.width = (context.element.topArea.offsetWidth - 2) + 'px';
7742
+ toolbar.style.width = (context.element.topArea.offsetWidth - 2) + 'px';
7643
7743
  event.onScroll_window();
7644
7744
  }
7645
7745
  },
@@ -7767,7 +7867,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7767
7867
  const clipboardData = util.isIE ? _w.clipboardData : e.clipboardData;
7768
7868
 
7769
7869
  // user event
7770
- if (typeof functions.onCopy === 'function' && !functions.onCopy(e, clipboardData, core)) {
7870
+ if (typeof functions.onCopy === 'function' && functions.onCopy(e, clipboardData, core) === false) {
7771
7871
  e.preventDefault();
7772
7872
  e.stopPropagation();
7773
7873
  return false;
@@ -7796,7 +7896,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7796
7896
  const clipboardData = util.isIE ? _w.clipboardData : e.clipboardData;
7797
7897
 
7798
7898
  // user event
7799
- if (typeof functions.onCut === 'function' && !functions.onCut(e, clipboardData, core)) {
7899
+ if (typeof functions.onCut === 'function' && functions.onCut(e, clipboardData, core) === false) {
7800
7900
  e.preventDefault();
7801
7901
  e.stopPropagation();
7802
7902
  return false;
@@ -7891,8 +7991,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7891
7991
  if (MSData) {
7892
7992
  cleanData = cleanData.replace(/\n/g, ' ');
7893
7993
  plainText = plainText.replace(/\n/g, ' ');
7894
- } else {
7895
- cleanData = (plainText === cleanData ? plainText : cleanData).replace(/\n/g, '<br>');
7896
7994
  }
7897
7995
  cleanData = core.cleanHTML(cleanData, core.pasteTagsWhitelistRegExp, core.pasteTagsBlacklistRegExp);
7898
7996
  } else {
@@ -7903,14 +8001,22 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7903
8001
  // user event - paste
7904
8002
  if (type === 'paste' && typeof functions.onPaste === 'function') {
7905
8003
  const value = functions.onPaste(e, cleanData, maxCharCount, core);
7906
- if (!value) return false;
7907
- if (typeof value === 'string') cleanData = value;
8004
+ if (value === false) {
8005
+ return false;
8006
+ } else if (typeof value === 'string') {
8007
+ if (!value) return false;
8008
+ cleanData = value;
8009
+ }
7908
8010
  }
7909
8011
  // user event - drop
7910
8012
  if (type === 'drop' && typeof functions.onDrop === 'function') {
7911
8013
  const value = functions.onDrop(e, cleanData, maxCharCount, core);
7912
- if (!value) return false;
7913
- if (typeof value === 'string') cleanData = value;
8014
+ if (value === false) {
8015
+ return false;
8016
+ } else if (typeof value === 'string') {
8017
+ if (!value) return false;
8018
+ cleanData = value;
8019
+ }
7914
8020
  }
7915
8021
 
7916
8022
  // files
@@ -8006,7 +8112,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8006
8112
  _toolbarObserver: null,
8007
8113
  _addEvent: function () {
8008
8114
  const eventWysiwyg = options.iframe ? core._ww : context.element.wysiwyg;
8009
- if (!util.isIE) {
8115
+ if (util.isResizeObserverSupported) {
8010
8116
  this._resizeObserver = new _w.ResizeObserver(function(entries) {
8011
8117
  core.__callResizeFunction(-1, entries[0]);
8012
8118
  });
@@ -8063,7 +8169,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8063
8169
  event._setResponsiveToolbar();
8064
8170
 
8065
8171
  /** responsive toolbar observer */
8066
- if (!util.isIE) this._toolbarObserver = new _w.ResizeObserver(core.resetResponsiveToolbar);
8172
+ if (util.isResizeObserverSupported) this._toolbarObserver = new _w.ResizeObserver(core.resetResponsiveToolbar);
8067
8173
 
8068
8174
  /** window event */
8069
8175
  _w.addEventListener('resize', event.onResize_window, false);
@@ -8166,6 +8272,13 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8166
8272
  onCopy: null,
8167
8273
  onCut: null,
8168
8274
  onFocus: null,
8275
+
8276
+ /**
8277
+ * @description Event functions
8278
+ * @param {Object} e Event Object
8279
+ * @param {Object} core Core object
8280
+ * @param {String} contents Current contents
8281
+ */
8169
8282
  onBlur: null,
8170
8283
 
8171
8284
  /**
@@ -8898,6 +9011,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8898
9011
  context.element.toolbar.style.display = '';
8899
9012
  context.element._stickyDummy.style.display = '';
8900
9013
  }
9014
+
9015
+ event.onResize_window();
8901
9016
  },
8902
9017
 
8903
9018
  /**
@@ -8910,6 +9025,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8910
9025
  context.element.toolbar.style.display = 'none';
8911
9026
  context.element._stickyDummy.style.display = 'none';
8912
9027
  }
9028
+
9029
+ event.onResize_window();
8913
9030
  },
8914
9031
  },
8915
9032