suneditor 2.44.9 → 2.44.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suneditor",
3
- "version": "2.44.9",
3
+ "version": "2.44.11",
4
4
  "description": "Pure JavaScript based WYSIWYG web editor",
5
5
  "author": "JiHong.Lee",
6
6
  "license": "MIT",
@@ -415,8 +415,13 @@
415
415
  .sun-editor-editable figure {
416
416
  display: block;
417
417
  outline: none;
418
- margin: 0;
419
418
  padding: 0;
419
+ margin: 0;
420
+ }
421
+ .sun-editor-editable .__se__float-left figure,
422
+ .sun-editor-editable .__se__float-right figure,
423
+ .sun-editor-editable .__se__float-center figure {
424
+ margin: auto !important;
420
425
  }
421
426
  .sun-editor-editable figure figcaption {
422
427
  padding: 1em .5em;
@@ -212,7 +212,7 @@
212
212
  .sun-editor .se-list-layer.se-list-line {width:125px;}
213
213
  .sun-editor .se-list-layer.se-list-line hr {border-width: 1px 0 0; height: 1px;}
214
214
  /* submenu layer - align */
215
- .sun-editor .se-list-layer.se-list-align .se-list-inner {left:9px; width:125px;}
215
+ .sun-editor .se-list-layer.se-list-align .se-list-inner {left:9px;}
216
216
  /** submenu layer - format block, paragraph style, text style */
217
217
  .sun-editor .se-list-layer.se-list-format {min-width:156px;}
218
218
  .sun-editor .se-list-layer.se-list-format li {padding:0; width:100%;}
package/src/lang/de.js CHANGED
@@ -101,12 +101,12 @@
101
101
  altText: 'Alternativer Text'
102
102
  },
103
103
  videoBox: {
104
- title: 'Video enfügen',
104
+ title: 'Video einfügen',
105
105
  file: 'Datei auswählen',
106
106
  url: 'Video-URL, YouTube/Vimeo'
107
107
  },
108
108
  audioBox: {
109
- title: 'Audio enfügen',
109
+ title: 'Audio einfügen',
110
110
  file: 'Datei auswählen',
111
111
  url: 'Audio-URL'
112
112
  },
@@ -185,4 +185,4 @@
185
185
  }
186
186
 
187
187
  return lang;
188
- }));
188
+ }));
package/src/lib/core.js CHANGED
@@ -1792,30 +1792,30 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1792
1792
  } else if (container.nodeType === 3 || util.isBreak(container) || insertListCell) {
1793
1793
  const depthFormat = util.getParentElement(container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
1794
1794
  afterNode = util.splitElement(container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
1795
- if (afterNode) {
1796
- if (insertListCell) {
1797
- if (line.contains(container)) {
1798
- const subList = util.isList(line.lastElementChild);
1799
- let newCell = null;
1800
- if (!isEdge) {
1795
+ if (!afterNode) {
1796
+ tempAfterNode = afterNode = line;
1797
+ } else if (insertListCell) {
1798
+ if (line.contains(container)) {
1799
+ const subList = util.isList(line.lastElementChild);
1800
+ let newCell = null;
1801
+ if (!isEdge) {
1802
+ newCell = line.cloneNode(false);
1803
+ newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
1804
+ }
1805
+ if (subList) {
1806
+ if (!newCell) {
1801
1807
  newCell = line.cloneNode(false);
1802
- newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
1803
- }
1804
- if (subList) {
1805
- if (!newCell) {
1806
- newCell = line.cloneNode(false);
1807
- newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
1808
- }
1809
- newCell.appendChild(line.lastElementChild);
1810
- }
1811
- if (newCell) {
1812
- line.parentNode.insertBefore(newCell, line.nextElementSibling);
1813
- tempAfterNode = afterNode = newCell;
1808
+ newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
1814
1809
  }
1810
+ newCell.appendChild(line.lastElementChild);
1811
+ }
1812
+ if (newCell) {
1813
+ line.parentNode.insertBefore(newCell, line.nextElementSibling);
1814
+ tempAfterNode = afterNode = newCell;
1815
1815
  }
1816
- } else {
1817
- afterNode = afterNode.previousSibling;
1818
1816
  }
1817
+ } else {
1818
+ afterNode = afterNode.previousSibling;
1819
1819
  }
1820
1820
  }
1821
1821
  }
@@ -2135,7 +2135,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2135
2135
 
2136
2136
  const range = this.getRange();
2137
2137
  const isStartEdge = range.startOffset === 0;
2138
- const isEndEdge = core.isEdgePoint(range.endContainer, range.endOffset);
2138
+ const isEndEdge = core.isEdgePoint(range.endContainer, range.endOffset, 'end');
2139
2139
  let prevContainer = null;
2140
2140
  let startPrevEl = null;
2141
2141
  let endNextEl = null;
@@ -3288,7 +3288,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
3288
3288
  if (!isRemoveNode && parentCon === endCon.parentNode && parentCon.nodeName === newInnerNode.nodeName) {
3289
3289
  if (util.onlyZeroWidthSpace(startCon.textContent.slice(0, startOff)) && util.onlyZeroWidthSpace(endCon.textContent.slice(endOff))) {
3290
3290
  const children = parentCon.childNodes;
3291
- let sameTag = true;
3291
+ let sameTag = false;
3292
3292
 
3293
3293
  for (let i = 0, len = children.length, c, s, e, z; i < len; i++) {
3294
3294
  c = children[i];
@@ -5141,12 +5141,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5141
5141
  const renderHTML = util.createElement('DIV');
5142
5142
  renderHTML.innerHTML = contents;
5143
5143
 
5144
- const figcaptions = util.getListChildren(renderHTML, function (current) {
5145
- return /FIGCAPTION/i.test(current.nodeName);
5144
+ const editableEls = util.getListChildren(renderHTML, function (current) {
5145
+ return current.hasAttribute('contenteditable');
5146
5146
  });
5147
5147
 
5148
- for (let i = 0, len = figcaptions.length; i < len; i++) {
5149
- figcaptions[i].removeAttribute('contenteditable');
5148
+ for (let i = 0, len = editableEls.length; i < len; i++) {
5149
+ editableEls[i].removeAttribute('contenteditable');
5150
5150
  }
5151
5151
 
5152
5152
  if (options.fullPage && !onlyContents) {
@@ -5373,13 +5373,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5373
5373
  if (util.isFigures(tagName)) {
5374
5374
  const sv = m.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);
5375
5375
  if (!v) v = [];
5376
- if (sv) {
5377
- const wsize = sv[0].match(/width\s?:\s?(\d+)(px|%)/);
5378
- const hsize = sv[0].match(/height\s?:\s?(\d+)(px|%)/);
5379
- const w_ = wsize && wsize[1] && wsize[2] ? wsize[1] + wsize[2] : 'auto';
5380
- const h_ = hsize && hsize[1] && hsize[2] ? hsize[1] + hsize[2] : 'auto';
5381
- v.push('style="width:'+ w_ + '; height:'+ h_ + ';"');
5382
- }
5376
+ if (sv) v.push(sv[0]);
5383
5377
  }
5384
5378
 
5385
5379
  if (v) {
@@ -6454,11 +6448,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6454
6448
  if (options.showPathLabel) context.element.navigation.textContent = core._variable.currentNodes.join(' > ');
6455
6449
  },
6456
6450
 
6457
- _cancelCaptionEdit: function () {
6458
- this.setAttribute('contenteditable', false);
6459
- this.removeEventListener('blur', event._cancelCaptionEdit);
6460
- },
6461
-
6462
6451
  _buttonsEventHandler: function (e) {
6463
6452
  let target = e.target;
6464
6453
  if (core._bindControllersOff) e.stopPropagation();
@@ -6510,6 +6499,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6510
6499
 
6511
6500
  onMouseDown_wysiwyg: function (e) {
6512
6501
  if (core.isReadOnly || util.isNonEditable(context.element.wysiwyg)) return;
6502
+ if (util._isExcludeSelectionElement(e.target)) {
6503
+ e.preventDefault();
6504
+ return;
6505
+ }
6506
+
6507
+ _w.setTimeout(core._editorRange.bind(core));
6513
6508
 
6514
6509
  // user event
6515
6510
  if (typeof functions.onMouseDown === 'function' && functions.onMouseDown(e, core) === false) return;
@@ -6527,8 +6522,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6527
6522
  if (core._isBalloon) {
6528
6523
  event._hideToolbar();
6529
6524
  }
6530
-
6531
- if (/FIGURE/i.test(e.target.nodeName)) e.preventDefault();
6532
6525
  },
6533
6526
 
6534
6527
  onClick_wysiwyg: function (e) {
@@ -6555,9 +6548,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
6555
6548
  }
6556
6549
 
6557
6550
  const figcaption = util.getParentElement(targetElement, 'FIGCAPTION');
6558
- if (figcaption && (util.isNonEditable(figcaption) || !figcaption.getAttribute("contenteditable"))) {
6551
+ if (figcaption && util.isNonEditable(figcaption)) {
6559
6552
  e.preventDefault();
6560
- figcaption.setAttribute('contenteditable', true);
6561
6553
  figcaption.focus();
6562
6554
 
6563
6555
  if (core._isInline && !core._inlineToolbarAttr.isShow) {
@@ -7723,7 +7715,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7723
7715
 
7724
7716
  onMouseDown_resizingBar: function (e) {
7725
7717
  e.stopPropagation();
7726
- _w.setTimeout(core._editorRange.bind(core));
7727
7718
 
7728
7719
  core.submenuOff();
7729
7720
  core.controllersOff();
@@ -53,7 +53,7 @@ export default function (core, change) {
53
53
 
54
54
  function pushStack () {
55
55
  core._checkComponents();
56
- const current = core.getContents(true);
56
+ const current = editor.wysiwyg.innerHTML;
57
57
  if (!current || (!!stack[stackIndex] && current === stack[stackIndex].contents)) return;
58
58
 
59
59
  stackIndex++;
package/src/lib/util.js CHANGED
@@ -1749,6 +1749,10 @@ const util = {
1749
1749
  }.bind(this));
1750
1750
  },
1751
1751
 
1752
+ _isExcludeSelectionElement: function (element) {
1753
+ return !/FIGCAPTION/i.test(element.nodeName) && (this.isComponent(element) || /FIGURE/i.test(element.nodeName));
1754
+ },
1755
+
1752
1756
  /**
1753
1757
  * @description Nodes that need to be added without modification when changing text nodes
1754
1758
  * @param {Node} element Element to check
@@ -660,7 +660,6 @@ export default {
660
660
  // caption
661
661
  if (contextImage._captionChecked) {
662
662
  contextImage._caption = this.plugins.component.create_caption.call(this);
663
- contextImage._caption.setAttribute('contenteditable', false);
664
663
  cover.appendChild(contextImage._caption);
665
664
  }
666
665
 
@@ -869,7 +868,7 @@ export default {
869
868
  contextImage._cover = this.util.getParentElement(element, 'FIGURE');
870
869
  contextImage._container = this.util.getParentElement(element, this.util.isMediaComponent);
871
870
  contextImage._caption = this.util.getChildElement(contextImage._cover, 'FIGCAPTION');
872
- contextImage._align = element.style.float || element.getAttribute('data-align') || 'none';
871
+ contextImage._align = element.getAttribute('data-align') || element.style.float || 'none';
873
872
  element.style.float = '';
874
873
  this.plugins.anchor.setCtx(contextImage._linkElement, contextImage.anchorCtx);
875
874
 
@@ -1068,12 +1067,6 @@ export default {
1068
1067
  if (!cover) cover = contextImage._cover;
1069
1068
  if (!container) container = contextImage._container;
1070
1069
 
1071
- if (align && align !== 'none') {
1072
- cover.style.margin = 'auto';
1073
- } else {
1074
- cover.style.margin = '0';
1075
- }
1076
-
1077
1070
  if (/%$/.test(element.style.width) && align === 'center') {
1078
1071
  container.style.minWidth = '100%';
1079
1072
  cover.style.width = container.style.width;
@@ -135,6 +135,7 @@ export default {
135
135
  if (!element.getAttribute('data-exp') || !this.options.katex) return;
136
136
  const dom = this._d.createRange().createContextualFragment(this.plugins.math._renderer.call(this, this.util.HTMLDecoder(element.getAttribute('data-exp'))));
137
137
  element.innerHTML = dom.querySelector('.katex').innerHTML;
138
+ element.setAttribute('contenteditable', false);
138
139
  }
139
140
  };
140
141
  },
@@ -931,12 +931,6 @@ export default {
931
931
  if (!cover) cover = contextVideo._cover;
932
932
  if (!container) container = contextVideo._container;
933
933
 
934
- if (align && align !== 'none') {
935
- cover.style.margin = 'auto';
936
- } else {
937
- cover.style.margin = '0';
938
- }
939
-
940
934
  if (/%$/.test(element.style.width) && align === 'center') {
941
935
  container.style.minWidth = '100%';
942
936
  cover.style.width = container.style.width;
@@ -55,9 +55,9 @@ export default {
55
55
  '</div>';
56
56
  },
57
57
 
58
- setImage: function (target) {
58
+ setImage: function (target, fileName) {
59
59
  this.callPlugin('image', function () {
60
- const file = {name: target.parentNode.querySelector('.__se__img_name').textContent, size: 0};
60
+ const file = {name: fileName, size: 0};
61
61
  this.plugins.image.create_image.call(this, target.getAttribute('data-value'), null, this.context.image._origin_w, this.context.image._origin_h, 'none', file, target.alt);
62
62
  }.bind(this), null);
63
63
  }
@@ -32,7 +32,6 @@
32
32
  set_container: function (cover, className) {
33
33
  const container = this.util.createElement('DIV');
34
34
  container.className = 'se-component ' + className;
35
- container.setAttribute('contenteditable', false);
36
35
  container.appendChild(cover);
37
36
 
38
37
  return container;
@@ -55,7 +54,6 @@
55
54
  */
56
55
  create_caption: function () {
57
56
  const caption = this.util.createElement('FIGCAPTION');
58
- caption.setAttribute('contenteditable', true);
59
57
  caption.innerHTML = '<div>' + this.lang.dialogBox.caption + '</div>';
60
58
  return caption;
61
59
  }
@@ -347,8 +347,8 @@
347
347
  if (!command) return;
348
348
 
349
349
  const handler = (fileBrowserContext.selectorHandler || this.context[fileBrowserContext.contextPlugin].selectorHandler);
350
+ handler(target, target.parentNode.querySelector('.__se__img_name').textContent);
350
351
  this.plugins.fileBrowser.close.call(this);
351
- handler(target);
352
352
  }
353
353
  };
354
354