suneditor 2.43.4 → 2.43.7

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/src/lib/core.js CHANGED
@@ -41,6 +41,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
41
41
  _parser: new _w.DOMParser(),
42
42
  _prevRtl: options.rtl,
43
43
  _editorHeight: 0,
44
+ _editorHeightPadding: 0,
44
45
  _listCamel: options.__listCommonStyle,
45
46
  _listKebab: util.camelToKebabCase(options.__listCommonStyle),
46
47
 
@@ -459,13 +460,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
459
460
  DEL: ['text-decoration']
460
461
  },
461
462
 
462
- /**
463
- * @description Contains pairs of all "data-commands" and "elements" setted in toolbar over time
464
- * Used primarily to save and recover button states after the toolbar re-creation
465
- * Updates each "_cachingButtons()" invocation
466
- */
467
- allCommandButtons: null,
468
-
469
463
  /**
470
464
  * @description Style button related to edit area
471
465
  * @property {Element} fullScreen fullScreen button element
@@ -475,19 +469,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
475
469
  */
476
470
  _styleCommandMap: null,
477
471
 
478
- /**
479
- * @description Map of default command
480
- * @private
481
- */
482
- _defaultCommand: {
483
- bold: options.textTags.bold,
484
- underline: options.textTags.underline,
485
- italic: options.textTags.italic,
486
- strike: options.textTags.strike,
487
- subscript: options.textTags.sub,
488
- superscript: options.textTags.sup
489
- },
490
-
491
472
  /**
492
473
  * @description Variables used internally in editor operation
493
474
  * @property {Boolean} isCodeView State of code view
@@ -525,8 +506,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
525
506
 
526
507
  /**
527
508
  * @description Save the current buttons states to "allCommandButtons" object
509
+ * @private
528
510
  */
529
- saveButtonStates: function () {
511
+ _saveButtonStates: function () {
530
512
  if (!this.allCommandButtons) this.allCommandButtons = {};
531
513
 
532
514
  const currentButtons = this.context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]');
@@ -540,8 +522,9 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
540
522
 
541
523
  /**
542
524
  * @description Recover the current buttons states from "allCommandButtons" object
525
+ * @private
543
526
  */
544
- recoverButtonStates: function () {
527
+ _recoverButtonStates: function () {
545
528
  if (this.allCommandButtons) {
546
529
  const currentButtons = this.context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]');
547
530
  for (let i = 0, button, command, oldButton; i < currentButtons.length; i++) {
@@ -1518,7 +1501,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1518
1501
 
1519
1502
  const currentFormatEl = util.getFormatElement(this.getSelectionNode(), null);
1520
1503
  let oFormat = null;
1521
- if (util.isFreeFormatElement(currentFormatEl || element.parentNode)) {
1504
+ if (!util.isFormatElement(element) && util.isFreeFormatElement(currentFormatEl || element.parentNode)) {
1522
1505
  oFormat = util.createElement('BR');
1523
1506
  } else {
1524
1507
  const oFormatName = formatNode ? (typeof formatNode === 'string' ? formatNode : formatNode.nodeName) : (util.isFormatElement(currentFormatEl) && !util.isRangeFormatElement(currentFormatEl) && !util.isFreeFormatElement(currentFormatEl)) ? currentFormatEl.nodeName : options.defaultTag;
@@ -1692,152 +1675,261 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1692
1675
  return null;
1693
1676
  }
1694
1677
 
1695
- const freeFormat = util.getFreeFormatElement(this.getSelectionNode(), null);
1678
+ let range = this.getRange();
1679
+ let line = util.isListCell(range.commonAncestorContainer) ? range.commonAncestorContainer : util.getFormatElement(this.getSelectionNode(), null);
1680
+ let insertListCell = util.isListCell(line) && (util.isListCell(oNode) || util.isList(oNode));
1681
+
1682
+ let parentNode, originAfter, tempAfterNode, tempParentNode = null;
1683
+ const freeFormat = util.isFreeFormatElement(line);
1696
1684
  const isFormats = (!freeFormat && (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode))) || util.isComponent(oNode);
1697
1685
 
1686
+ if (insertListCell) {
1687
+ tempAfterNode = afterNode || util.isList(oNode) ? line.lastChild : line.nextElementSibling;
1688
+ tempParentNode = util.isList(oNode) ? line : (tempAfterNode || line).parentNode;
1689
+ }
1690
+
1698
1691
  if (!afterNode && (isFormats || util.isComponent(oNode) || util.isMedia(oNode))) {
1692
+ const isEdge = this.isEdgePoint(range.endContainer, range.endOffset, 'end');
1699
1693
  const r = this.removeNode();
1700
- if (r.container.nodeType === 3 || util.isBreak(r.container)) {
1701
- const depthFormat = util.getParentElement(r.container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
1702
- afterNode = util.splitElement(r.container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
1703
- if (afterNode) afterNode = afterNode.previousSibling;
1694
+ const container = r.container;
1695
+ const prevContainer = (container === r.prevContainer && range.collapsed) ? null : r.prevContainer;
1696
+
1697
+ if (insertListCell && prevContainer) {
1698
+ tempParentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1699
+ if (tempParentNode.contains(container)) {
1700
+ let sameParent = true;
1701
+ tempAfterNode = container;
1702
+ while (tempAfterNode.parentNode && tempAfterNode.parentNode !== tempParentNode) {
1703
+ tempAfterNode = tempAfterNode.parentNode;
1704
+ sameParent = false;
1705
+ }
1706
+ if (sameParent && container === prevContainer) tempAfterNode = tempAfterNode.nextSibling;
1707
+ } else {
1708
+ tempAfterNode = null;
1709
+ }
1710
+ } else if (insertListCell && util.isListCell(container) && !line.parentElement) {
1711
+ line = util.createElement('LI');
1712
+ tempParentNode.appendChild(line);
1713
+ container.appendChild(tempParentNode);
1714
+ tempAfterNode = null;
1715
+ } else if (container.nodeType === 3 || util.isBreak(container) || insertListCell) {
1716
+ const depthFormat = util.getParentElement(container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
1717
+ afterNode = util.splitElement(container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
1718
+ if (afterNode) {
1719
+ if (insertListCell) {
1720
+ if (line.contains(container)) {
1721
+ const subList = util.isList(line.lastElementChild);
1722
+ let newCell = null;
1723
+ if (!isEdge) {
1724
+ newCell = line.cloneNode(false);
1725
+ newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
1726
+ }
1727
+ if (subList) {
1728
+ if (!newCell) {
1729
+ newCell = line.cloneNode(false);
1730
+ newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
1731
+ }
1732
+ newCell.appendChild(line.lastElementChild);
1733
+ }
1734
+ if (newCell) {
1735
+ line.parentNode.insertBefore(newCell, line.nextElementSibling);
1736
+ tempAfterNode = afterNode = newCell;
1737
+ }
1738
+ }
1739
+ } else {
1740
+ afterNode = afterNode.previousSibling;
1741
+ }
1742
+ }
1704
1743
  }
1705
1744
  }
1706
1745
 
1707
- const range = (!afterNode && !isFormats) ? this.getRange_addLine(this.getRange(), null) : this.getRange();
1746
+ range = (!afterNode && !isFormats) ? this.getRange_addLine(this.getRange(), null) : this.getRange();
1708
1747
  const commonCon = range.commonAncestorContainer;
1709
1748
  const startOff = range.startOffset;
1710
1749
  const endOff = range.endOffset;
1711
1750
  const formatRange = range.startContainer === commonCon && util.isFormatElement(commonCon);
1712
1751
  const startCon = formatRange ? (commonCon.childNodes[startOff] || commonCon.childNodes[0] || range.startContainer) : range.startContainer;
1713
1752
  const endCon = formatRange ? (commonCon.childNodes[endOff] || commonCon.childNodes[commonCon.childNodes.length - 1] || range.endContainer) : range.endContainer;
1714
- let parentNode, originAfter = null;
1715
-
1716
- if (!afterNode) {
1717
- parentNode = startCon;
1718
- if (startCon.nodeType === 3) {
1719
- parentNode = startCon.parentNode;
1720
- }
1721
1753
 
1722
- /** No Select range node */
1723
- if (range.collapsed) {
1724
- if (commonCon.nodeType === 3) {
1725
- if (commonCon.textContent.length > endOff) afterNode = commonCon.splitText(endOff);
1726
- else afterNode = commonCon.nextSibling;
1727
- } else {
1728
- if (!util.isBreak(parentNode)) {
1729
- let c = parentNode.childNodes[startOff];
1730
- const focusNode = (c && c.nodeType === 3 && util.onlyZeroWidthSpace(c) && util.isBreak(c.nextSibling)) ? c.nextSibling : c;
1731
- if (focusNode) {
1732
- if (!focusNode.nextSibling) {
1733
- parentNode.removeChild(focusNode);
1734
- afterNode = null;
1754
+ if (!insertListCell) {
1755
+ if (!afterNode) {
1756
+ parentNode = startCon;
1757
+ if (startCon.nodeType === 3) {
1758
+ parentNode = startCon.parentNode;
1759
+ }
1760
+
1761
+ /** No Select range node */
1762
+ if (range.collapsed) {
1763
+ if (commonCon.nodeType === 3) {
1764
+ if (commonCon.textContent.length > endOff) afterNode = commonCon.splitText(endOff);
1765
+ else afterNode = commonCon.nextSibling;
1766
+ } else {
1767
+ if (!util.isBreak(parentNode)) {
1768
+ let c = parentNode.childNodes[startOff];
1769
+ const focusNode = (c && c.nodeType === 3 && util.onlyZeroWidthSpace(c) && util.isBreak(c.nextSibling)) ? c.nextSibling : c;
1770
+ if (focusNode) {
1771
+ if (!focusNode.nextSibling) {
1772
+ parentNode.removeChild(focusNode);
1773
+ afterNode = null;
1774
+ } else {
1775
+ afterNode = (util.isBreak(focusNode) && !util.isBreak(oNode)) ? focusNode : focusNode.nextSibling;
1776
+ }
1735
1777
  } else {
1736
- afterNode = (util.isBreak(focusNode) && !util.isBreak(oNode)) ? focusNode : focusNode.nextSibling;
1778
+ afterNode = null;
1737
1779
  }
1738
1780
  } else {
1739
- afterNode = null;
1781
+ afterNode = parentNode;
1782
+ parentNode = parentNode.parentNode;
1740
1783
  }
1741
- } else {
1742
- afterNode = parentNode;
1743
- parentNode = parentNode.parentNode;
1744
1784
  }
1745
- }
1746
- } else { /** Select range nodes */
1747
- const isSameContainer = startCon === endCon;
1748
-
1749
- if (isSameContainer) {
1750
- if (this.isEdgePoint(endCon, endOff)) afterNode = endCon.nextSibling;
1751
- else afterNode = endCon.splitText(endOff);
1752
-
1753
- let removeNode = startCon;
1754
- if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);
1755
-
1756
- parentNode.removeChild(removeNode);
1757
- if (parentNode.childNodes.length === 0 && isFormats) {
1758
- parentNode.innerHTML = '<br>';
1759
- }
1760
- }
1761
- else {
1762
- const removedTag = this.removeNode();
1763
- const container = removedTag.container;
1764
- const prevContainer = removedTag.prevContainer;
1765
- if (container && container.childNodes.length === 0 && isFormats) {
1766
- if (util.isFormatElement(container)) {
1767
- container.innerHTML = '<br>';
1768
- } else if (util.isRangeFormatElement(container)) {
1769
- container.innerHTML = '<' + options.defaultTag + '><br></' + options.defaultTag + '>';
1785
+ } else { /** Select range nodes */
1786
+ const isSameContainer = startCon === endCon;
1787
+
1788
+ if (isSameContainer) {
1789
+ if (this.isEdgePoint(endCon, endOff)) afterNode = endCon.nextSibling;
1790
+ else afterNode = endCon.splitText(endOff);
1791
+
1792
+ let removeNode = startCon;
1793
+ if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);
1794
+
1795
+ parentNode.removeChild(removeNode);
1796
+ if (parentNode.childNodes.length === 0 && isFormats) {
1797
+ parentNode.innerHTML = '<br>';
1770
1798
  }
1771
1799
  }
1772
-
1773
- if (!isFormats && prevContainer) {
1774
- parentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1775
- if (parentNode.contains(container)) {
1776
- let sameParent = true;
1777
- afterNode = container;
1778
- while (afterNode.parentNode !== parentNode) {
1779
- afterNode = afterNode.parentNode;
1780
- sameParent = false;
1800
+ else {
1801
+ const removedTag = this.removeNode();
1802
+ const container = removedTag.container;
1803
+ const prevContainer = removedTag.prevContainer;
1804
+
1805
+ if (container && container.childNodes.length === 0 && isFormats) {
1806
+ if (util.isFormatElement(container)) {
1807
+ container.innerHTML = '<br>';
1808
+ } else if (util.isRangeFormatElement(container)) {
1809
+ container.innerHTML = '<' + options.defaultTag + '><br></' + options.defaultTag + '>';
1781
1810
  }
1782
- if (sameParent && container === prevContainer) afterNode = afterNode.nextSibling;
1783
- } else {
1811
+ }
1812
+
1813
+ if (util.isListCell(container) && oNode.nodeType === 3) {
1814
+ parentNode = container;
1784
1815
  afterNode = null;
1816
+ } else if (!isFormats && prevContainer) {
1817
+ parentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1818
+ if (parentNode.contains(container)) {
1819
+ let sameParent = true;
1820
+ afterNode = container;
1821
+ while (afterNode.parentNode && afterNode.parentNode !== parentNode) {
1822
+ afterNode = afterNode.parentNode;
1823
+ sameParent = false;
1824
+ }
1825
+ if (sameParent && container === prevContainer) afterNode = afterNode.nextSibling;
1826
+ } else {
1827
+ afterNode = null;
1828
+ }
1829
+ } else {
1830
+ afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
1831
+ parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
1832
+ }
1833
+
1834
+ while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
1835
+ afterNode = afterNode.parentNode;
1785
1836
  }
1786
- } else {
1787
- afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
1788
- parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
1789
- }
1790
-
1791
- while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
1792
- afterNode = afterNode.parentNode;
1793
1837
  }
1794
1838
  }
1839
+ } else { // has afterNode
1840
+ parentNode = afterNode.parentNode;
1841
+ afterNode = afterNode.nextSibling;
1842
+ originAfter = true;
1795
1843
  }
1796
1844
  }
1797
- // has afterNode
1798
- else {
1799
- parentNode = afterNode.parentNode;
1800
- afterNode = afterNode.nextSibling;
1801
- originAfter = true;
1802
- }
1803
1845
 
1804
- // --- insert node ---
1805
1846
  try {
1806
- if (util.isWysiwygDiv(afterNode) || parentNode === context.element.wysiwyg.parentNode) {
1807
- parentNode = context.element.wysiwyg;
1808
- afterNode = null;
1847
+ // set node
1848
+ if (!insertListCell) {
1849
+ if (util.isWysiwygDiv(afterNode) || parentNode === context.element.wysiwyg.parentNode) {
1850
+ parentNode = context.element.wysiwyg;
1851
+ afterNode = null;
1852
+ }
1853
+
1854
+ if (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode) || (!util.isListCell(parentNode) && util.isComponent(oNode))) {
1855
+ const oldParent = parentNode;
1856
+ if (util.isList(afterNode)) {
1857
+ parentNode = afterNode;
1858
+ afterNode = null;
1859
+ } else if (util.isListCell(afterNode)) {
1860
+ parentNode = afterNode.previousElementSibling || afterNode;
1861
+ } else if (!originAfter && !afterNode) {
1862
+ const r = this.removeNode();
1863
+ const container = r.container.nodeType === 3 ? (util.isListCell(util.getFormatElement(r.container, null)) ? r.container : (util.getFormatElement(r.container, null) || r.container.parentNode)) : r.container;
1864
+ const rangeCon = util.isWysiwygDiv(container) || util.isRangeFormatElement(container);
1865
+ parentNode = rangeCon ? container : container.parentNode;
1866
+ afterNode = rangeCon ? null : container.nextSibling;
1867
+ }
1868
+
1869
+ if (oldParent.childNodes.length === 0 && parentNode !== oldParent) util.removeItem(oldParent);
1870
+ }
1871
+
1872
+ if (isFormats && !freeFormat && !util.isRangeFormatElement(parentNode) && !util.isListCell(parentNode) && !util.isWysiwygDiv(parentNode)) {
1873
+ afterNode = parentNode.nextElementSibling;
1874
+ parentNode = parentNode.parentNode;
1875
+ }
1876
+
1877
+ if (util.isWysiwygDiv(parentNode) && (oNode.nodeType === 3 || util.isBreak(oNode))) {
1878
+ const fNode = util.createElement(options.defaultTag);
1879
+ fNode.appendChild(oNode);
1880
+ oNode = fNode;
1881
+ }
1809
1882
  }
1810
1883
 
1811
- if (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode) || (!util.isListCell(parentNode) && util.isComponent(oNode))) {
1812
- const oldParent = parentNode;
1813
- if (util.isList(afterNode)) {
1814
- parentNode = afterNode;
1884
+ // insert--
1885
+ if (insertListCell) {
1886
+ if (!tempParentNode.parentNode) {
1887
+ parentNode = context.element.wysiwyg;
1815
1888
  afterNode = null;
1816
- } else if (util.isListCell(afterNode)) {
1817
- parentNode = afterNode.previousElementSibling || afterNode;
1818
- } else if (!originAfter && !afterNode) {
1819
- const r = this.removeNode();
1820
- const container = r.container.nodeType === 3 ? (util.isListCell(util.getFormatElement(r.container, null)) ? r.container : (util.getFormatElement(r.container, null) || r.container.parentNode)) : r.container;
1821
- const rangeCon = util.isWysiwygDiv(container) || util.isRangeFormatElement(container);
1822
- parentNode = rangeCon ? container : container.parentNode;
1823
- afterNode = rangeCon ? null : container.nextSibling;
1889
+ } else {
1890
+ parentNode = tempParentNode;
1891
+ afterNode = tempAfterNode;
1824
1892
  }
1825
-
1826
- if (oldParent.childNodes.length === 0 && parentNode !== oldParent) util.removeItem(oldParent);
1893
+ } else {
1894
+ afterNode = parentNode === afterNode ? parentNode.lastChild : afterNode;
1827
1895
  }
1828
1896
 
1829
- if (isFormats && !freeFormat && !util.isRangeFormatElement(parentNode) && !util.isListCell(parentNode) && !util.isWysiwygDiv(parentNode)) {
1830
- afterNode = parentNode.nextElementSibling;
1831
- parentNode = parentNode.parentNode;
1897
+ if (util.isListCell(oNode) && !util.isList(parentNode)) {
1898
+ if (util.isListCell(parentNode)) {
1899
+ afterNode = parentNode.nextElementSibling;
1900
+ parentNode = parentNode.parentNode;
1901
+ } else {
1902
+ const ul = util.createElement('ol');
1903
+ parentNode.insertBefore(ul, afterNode);
1904
+ parentNode = ul;
1905
+ afterNode = null;
1906
+ }
1907
+ insertListCell = true;
1832
1908
  }
1833
1909
 
1834
- if (util.isWysiwygDiv(parentNode) && (oNode.nodeType === 3 || util.isBreak(oNode))) {
1835
- const fNode = util.createElement(options.defaultTag);
1836
- fNode.appendChild(oNode);
1837
- oNode = fNode;
1838
- }
1910
+ parentNode.insertBefore(oNode, afterNode);
1839
1911
 
1840
- parentNode.insertBefore(oNode, parentNode === afterNode ? parentNode.lastChild : afterNode);
1912
+ if (insertListCell) {
1913
+ if (util.onlyZeroWidthSpace(line.textContent.trim())) {
1914
+ util.removeItem(line);
1915
+ oNode = oNode.lastChild;
1916
+ } else {
1917
+ const chList = util.getArrayItem(line.children, util.isList);
1918
+ if (chList) {
1919
+ if (oNode !== chList) {
1920
+ oNode.appendChild(chList);
1921
+ oNode = chList.previousSibling;
1922
+ } else {
1923
+ parentNode.appendChild(oNode);
1924
+ oNode = parentNode;
1925
+ }
1926
+
1927
+ if (util.onlyZeroWidthSpace(line.textContent.trim())) {
1928
+ util.removeItem(line);
1929
+ }
1930
+ }
1931
+ }
1932
+ }
1841
1933
  } catch (e) {
1842
1934
  parentNode.appendChild(oNode);
1843
1935
  } finally {
@@ -2006,28 +2098,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2006
2098
  startIndex = endIndex = 0;
2007
2099
  }
2008
2100
 
2009
- function remove (item) {
2010
- const format = util.getFormatElement(item, null);
2011
- util.removeItem(item);
2012
-
2013
- if(util.isListCell(format)) {
2014
- const list = util.getArrayItem(format.children, util.isList, false);
2015
- if (list) {
2016
- const child = list.firstElementChild;
2017
- const children = child.childNodes;
2018
- while (children[0]) {
2019
- format.insertBefore(children[0], list);
2020
- }
2021
- util.removeItemAllParents(child, null, null);
2022
- }
2023
- }
2024
- }
2025
-
2026
2101
  for (let i = startIndex; i <= endIndex; i++) {
2027
2102
  const item = childNodes[i];
2028
2103
 
2029
2104
  if (item.length === 0 || (item.nodeType === 3 && item.data === undefined)) {
2030
- remove(item);
2105
+ this._nodeRemoveListItem(item);
2031
2106
  continue;
2032
2107
  }
2033
2108
 
@@ -2047,7 +2122,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2047
2122
  if (beforeNode.length > 0) {
2048
2123
  startCon.data = beforeNode.data;
2049
2124
  } else {
2050
- remove(startCon);
2125
+ this._nodeRemoveListItem(startCon);
2051
2126
  }
2052
2127
 
2053
2128
  if (item === endCon) break;
@@ -2065,24 +2140,26 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2065
2140
  if (afterNode.length > 0) {
2066
2141
  endCon.data = afterNode.data;
2067
2142
  } else {
2068
- remove(endCon);
2143
+ this._nodeRemoveListItem(endCon);
2069
2144
  }
2070
2145
 
2071
2146
  continue;
2072
2147
  }
2073
2148
 
2074
- remove(item);
2149
+ this._nodeRemoveListItem(item);
2075
2150
  }
2076
2151
 
2077
- container = endCon && endCon.parentNode ? endCon : startCon && startCon.parentNode ? startCon : (range.endContainer || range.startContainer);
2152
+ const endUl = util.getParentElement(endCon, 'ul');
2153
+ const startLi = util.getParentElement(startCon, 'li');
2154
+ if (endUl && startLi && startLi.contains(endUl)) {
2155
+ container = endUl.previousSibling;
2156
+ offset = container.textContent.length;
2157
+ } else {
2158
+ container = endCon && endCon.parentNode ? endCon : startCon && startCon.parentNode ? startCon : (range.endContainer || range.startContainer);
2159
+ }
2078
2160
 
2079
2161
  if (!util.isWysiwygDiv(container) && container.childNodes.length === 0) {
2080
- const rc = util.removeItemAllParents(container, function (current) {
2081
- if (this.isComponent(current)) return false;
2082
- const text = current.textContent;
2083
- return text.length === 0 || /^(\n|\u200B)+$/.test(text);
2084
- }.bind(util), null);
2085
-
2162
+ const rc = util.removeItemAllParents(container, null, null);
2086
2163
  if (rc) container = rc.sc || rc.ec || context.element.wysiwyg;
2087
2164
  }
2088
2165
 
@@ -2098,6 +2175,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2098
2175
  };
2099
2176
  },
2100
2177
 
2178
+ _nodeRemoveListItem: function (item) {
2179
+ const format = util.getFormatElement(item, null);
2180
+ util.removeItem(item);
2181
+
2182
+ if(!util.isListCell(format)) return;
2183
+
2184
+ util.removeItemAllParents(format, null, null);
2185
+
2186
+ if (format && util.isList(format.firstChild)) {
2187
+ format.insertBefore(util.createTextNode(util.zeroWidthSpace), format.firstChild);
2188
+ }
2189
+ },
2190
+
2101
2191
  /**
2102
2192
  * @description Appended all selected format Element to the argument element and insert
2103
2193
  * @param {Element} rangeElement Element of wrap the arguments (BLOCKQUOTE...)
@@ -2810,20 +2900,26 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2810
2900
 
2811
2901
  // one line
2812
2902
  if (oneLine) {
2813
- this._resetCommonListCell(lineNodes[0], styleArray);
2903
+ if (this._resetCommonListCell(lineNodes[0], styleArray)) range = this.setRange(startCon, startOff, endCon, endOff);
2904
+
2814
2905
  const newRange = this._nodeChange_oneLine(lineNodes[0], newNode, validation, startCon, startOff, endCon, endOff, isRemoveFormat, isRemoveNode, range.collapsed, _removeCheck, _getMaintainedNode, _isMaintainedNode);
2815
2906
  start.container = newRange.startContainer;
2816
2907
  start.offset = newRange.startOffset;
2817
2908
  end.container = newRange.endContainer;
2818
2909
  end.offset = newRange.endOffset;
2910
+
2819
2911
  if (start.container === end.container && util.onlyZeroWidthSpace(start.container)) {
2820
2912
  start.offset = end.offset = 1;
2821
2913
  }
2822
2914
  this._setCommonListStyle(newRange.ancestor, null);
2823
2915
  } else { // multi line
2916
+ let appliedCommonList = false;
2917
+ if (endLength > 0 && this._resetCommonListCell(lineNodes[endLength], styleArray)) appliedCommonList = true;
2918
+ if (this._resetCommonListCell(lineNodes[0], styleArray)) appliedCommonList = true;
2919
+ if (appliedCommonList) this.setRange(startCon, startOff, endCon, endOff);
2920
+
2824
2921
  // end
2825
2922
  if (endLength > 0) {
2826
- this._resetCommonListCell(lineNodes[endLength], styleArray);
2827
2923
  newNode = appendNode.cloneNode(false);
2828
2924
  end = this._nodeChange_endLine(lineNodes[endLength], newNode, validation, endCon, endOff, isRemoveFormat, isRemoveNode, _removeCheck, _getMaintainedNode, _isMaintainedNode);
2829
2925
  }
@@ -2841,7 +2937,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2841
2937
  }
2842
2938
 
2843
2939
  // start
2844
- this._resetCommonListCell(lineNodes[0], styleArray);
2845
2940
  newNode = appendNode.cloneNode(false);
2846
2941
  start = this._nodeChange_startLine(lineNodes[0], newNode, validation, startCon, startOff, isRemoveFormat, isRemoveNode, _removeCheck, _getMaintainedNode, _isMaintainedNode, end.container);
2847
2942
 
@@ -2901,9 +2996,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2901
2996
  }
2902
2997
 
2903
2998
  let sel = refer.cloneNode(false);
2904
- let r = null;
2999
+ let r = null, appliedEl = false;
2905
3000
  for (let i = 0, len = children.length, c, s; i < len; i++) {
2906
3001
  c = children[i];
3002
+ if (options._textTagsMap[c.nodeName.toLowerCase()]) continue;
3003
+
2907
3004
  s = util.getValues(c.style);
2908
3005
  if (s.length === 0 || (ec.some(function (k) {return s.indexOf(k) === -1;}) && s.some(function(k) {ec.indexOf(k) > -1;}))) {
2909
3006
  r = c.nextSibling;
@@ -2912,11 +3009,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2912
3009
  el.insertBefore(sel, r);
2913
3010
  sel = refer.cloneNode(false);
2914
3011
  r = null;
3012
+ appliedEl = true;
2915
3013
  }
2916
3014
  }
2917
3015
 
2918
- if (sel.childNodes.length > 0) el.insertBefore(sel, r);
2919
- if (!elStyles.length) el.removeAttribute('style');
3016
+ if (sel.childNodes.length > 0) {
3017
+ el.insertBefore(sel, r);
3018
+ appliedEl = true;
3019
+ }
3020
+ if (!elStyles.length) {
3021
+ el.removeAttribute('style');
3022
+ }
3023
+
3024
+ return appliedEl;
2920
3025
  },
2921
3026
 
2922
3027
  /**
@@ -2934,40 +3039,39 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2934
3039
  if (!child || children.length > 1 || child.nodeType !== 1) return;
2935
3040
 
2936
3041
  // set cell style---
2937
- const commonStyleElements = [];
2938
3042
  const childStyle = child.style;
2939
3043
  const elStyle = el.style;
3044
+ const nodeName = child.nodeName.toLowerCase();
3045
+ let appliedEl = false;
2940
3046
 
2941
3047
  // bold, italic
2942
- if (options._textTagsMap[child.nodeName.toLowerCase()] === this._defaultCommand.bold.toLowerCase()) elStyle.fontWeight = 'bold'; // bold
2943
- else if (childStyle.fontWeight) elStyle.fontWeight = childStyle.fontWeight;
2944
- if (options._textTagsMap[child.nodeName.toLowerCase()] === this._defaultCommand.italic.toLowerCase()) elStyle.fontStyle = 'italic'; // italic
2945
- else if (childStyle.fontStyle) elStyle.fontStyle = childStyle.fontStyle;
3048
+ if (options._textTagsMap[nodeName] === options._defaultCommand.bold.toLowerCase()) elStyle.fontWeight = 'bold';
3049
+ if (options._textTagsMap[nodeName] === options._defaultCommand.italic.toLowerCase()) elStyle.fontStyle = 'italic';
2946
3050
 
2947
3051
  // styles
2948
3052
  const cKeys = util.getValues(childStyle);
2949
- for (let i = 0, len = this._listCamel.length; i < len; i++) {
2950
- if (cKeys.indexOf(this._listKebab[i]) > -1) {
2951
- elStyle[this._listCamel[i]] = childStyle[this._listCamel[i]];
2952
- childStyle.removeProperty(this._listKebab[i]);
3053
+ if (cKeys.length > 0) {
3054
+ for (let i = 0, len = this._listCamel.length; i < len; i++) {
3055
+ if (cKeys.indexOf(this._listKebab[i]) > -1) {
3056
+ elStyle[this._listCamel[i]] = childStyle[this._listCamel[i]];
3057
+ childStyle.removeProperty(this._listKebab[i]);
3058
+ appliedEl = true;
3059
+ }
2953
3060
  }
2954
3061
  }
2955
-
2956
- // remove child
2957
- if (!childStyle.length) commonStyleElements.push(child);
2958
3062
 
2959
3063
  this._setCommonListStyle(el, child);
3064
+ if (!appliedEl) return;
2960
3065
 
2961
3066
  // common style
2962
- for (let i = 0, len = commonStyleElements.length, n, ch, p; i < len; i++) {
2963
- n = commonStyleElements[i];
2964
- ch = n.childNodes;
2965
- p = n.parentNode;
2966
- n = n.nextSibling;
3067
+ if (!childStyle.length) {
3068
+ const ch = child.childNodes;
3069
+ const p = child.parentNode;
3070
+ const n = child.nextSibling;
2967
3071
  while (ch.length > 0) {
2968
3072
  p.insertBefore(ch[0], n);
2969
3073
  }
2970
- util.removeItem(commonStyleElements[i]);
3074
+ util.removeItem(child);
2971
3075
  }
2972
3076
  },
2973
3077
 
@@ -4337,7 +4441,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4337
4441
  if (context.tool.save) context.tool.save.setAttribute('disabled', true);
4338
4442
  break;
4339
4443
  default : // 'STRONG', 'U', 'EM', 'DEL', 'SUB', 'SUP'..
4340
- command = this._defaultCommand[command.toLowerCase()] || command;
4444
+ command = options._defaultCommand[command.toLowerCase()] || command;
4341
4445
  if (!this.commandMap[command]) this.commandMap[command] = target;
4342
4446
 
4343
4447
  const nodesMap = this._variable.currentNodesMap;
@@ -4928,10 +5032,16 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
4928
5032
  // element
4929
5033
  if (node.nodeType === 1) {
4930
5034
  if (util._disallowedTags(node)) return '';
5035
+
5036
+ const ch = util.getListChildNodes(node, function(current) { return util.isSpanWithoutAttr(current); }) || [];
5037
+ for (let i = ch.length - 1; i >= 0; i--) {
5038
+ ch[i].outerHTML = ch[i].innerHTML;
5039
+ }
5040
+
4931
5041
  if (!requireFormat || (util.isFormatElement(node) || util.isRangeFormatElement(node) || util.isComponent(node) || util.isMedia(node) || (util.isAnchor(node) && util.isMedia(node.firstElementChild)))) {
4932
- return node.outerHTML;
5042
+ return util.isSpanWithoutAttr(node) ? node.innerHTML : node.outerHTML;
4933
5043
  } else {
4934
- return '<' + defaultTag + '>' + node.outerHTML + '</' + defaultTag + '>';
5044
+ return '<' + defaultTag + '>' + (util.isSpanWithoutAttr(node) ? node.innerHTML : node.outerHTML) + '</' + defaultTag + '>';
4935
5045
  }
4936
5046
  }
4937
5047
  // text
@@ -5021,7 +5131,37 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5021
5131
  const sv = m.match(/style\s*=\s*(?:"|')[^"']*(?:"|')/);
5022
5132
  if (sv) {
5023
5133
  if (!v) v = [];
5024
- v.push(sv[0]);
5134
+ const style = sv[0].replace(/&quot;/g, '').match(/\s*(font-family|font-size|color|background-color)\s*:[^;]+(?!;)*/ig);
5135
+ if (style) {
5136
+ const allowedStyle = [];
5137
+ for (let i = 0, len = style.length, r; i < len; i++) {
5138
+ r = style[i].match(/(.+)(:)([^:]+$)/);
5139
+ if (r && !/inherit|initial/i.test(r[3])) {
5140
+ const k = util.kebabToCamelCase(r[1].trim());
5141
+ const v = this.wwComputedStyle[k].replace(/"/g, '');
5142
+ const c = r[3].trim();
5143
+ switch (k) {
5144
+ case 'fontFamily':
5145
+ if (options.plugins.font ? options.font.indexOf(c) === -1 : true) continue;
5146
+ break;
5147
+ case 'fontSize':
5148
+ if (!options.plugins.fontSize) continue;
5149
+ break;
5150
+ case 'color':
5151
+ if (!options.plugins.fontColor) continue;
5152
+ break;
5153
+ case 'backgroundColor':
5154
+ if (!options.plugins.hiliteColor) continue;
5155
+ break;
5156
+ }
5157
+
5158
+ if (v !== c) {
5159
+ allowedStyle.push(r[0]);
5160
+ }
5161
+ }
5162
+ }
5163
+ if (allowedStyle.length > 0) v.push('style="' + allowedStyle.join(';') + '"');
5164
+ }
5025
5165
  }
5026
5166
  }
5027
5167
 
@@ -5050,14 +5190,82 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5050
5190
 
5051
5191
  if (v) {
5052
5192
  for (let i = 0, len = v.length; i < len; i++) {
5053
- if (lowLevelCheck && /^class="(?!(__se__|se-|katex))/.test(v[i])) continue;
5054
- t += ' ' + (/^(?:href|src)\s*=\s*('|"|\s)*javascript\s*\:/i.test(v[i]) ? '' : v[i]);
5193
+ if (lowLevelCheck && /^class="(?!(__se__|se-|katex))/.test(v[i].trim())) continue;
5194
+ t += ' ' + (/^(?:href|src)\s*=\s*('|"|\s)*javascript\s*\:/i.test(v[i].trim()) ? '' : v[i]);
5055
5195
  }
5056
5196
  }
5057
5197
 
5058
5198
  return t;
5059
5199
  },
5060
5200
 
5201
+ /**
5202
+ * @description Determines if formatting is required and returns a domTree
5203
+ * @param {Element} dom documentFragment
5204
+ * @returns {Element}
5205
+ * @private
5206
+ */
5207
+ _editFormat: function (dom) {
5208
+ let value = '', f;
5209
+ const tempTree = dom.childNodes;
5210
+ for (let i = 0, len = tempTree.length, n; i < len; i++) {
5211
+ n = tempTree[i];
5212
+ if (!util.isFormatElement(n) && !util.isRangeFormatElement(n) && !util.isComponent(n) && !/meta/i.test(n.nodeName)) {
5213
+ if (!f) f = util.createElement(options.defaultTag);
5214
+ f.appendChild(n);
5215
+ i--; len--;
5216
+ } else {
5217
+ if (f) {
5218
+ value += f.outerHTML;
5219
+ f = null;
5220
+ }
5221
+ value += n.outerHTML;
5222
+ }
5223
+ }
5224
+
5225
+ if (f) value += f.outerHTML;
5226
+
5227
+ return _d.createRange().createContextualFragment(value);
5228
+ },
5229
+
5230
+ _convertListCell: function (domTree) {
5231
+ let html = '';
5232
+
5233
+ for (let i = 0, len = domTree.length, node; i < len; i++) {
5234
+ node = domTree[i];
5235
+ if (node.nodeType === 1) {
5236
+ if (util.isList(node)) {
5237
+ html += node.innerHTML;
5238
+ } else if (util.isListCell(node)) {
5239
+ html += node.outerHTML;
5240
+ } else if (util.isFormatElement(node)) {
5241
+ html += '<li>' +(node.innerHTML.trim() || '<br>') + '</li>';
5242
+ } else if (util.isRangeFormatElement(node) && !util.isTable(node)) {
5243
+ html += event._convertListCell(node);
5244
+ } else {
5245
+ html += '<li>' + node.outerHTML + '</li>';
5246
+ }
5247
+ } else {
5248
+ html += '<li>' + (node.textContent || '<br>') + '</li>';
5249
+ }
5250
+ }
5251
+
5252
+ return html;
5253
+ },
5254
+
5255
+ _isFormatData: function (domTree) {
5256
+ let requireFormat = false;
5257
+
5258
+ for (let i = 0, len = domTree.length, t; i < len; i++) {
5259
+ t = domTree[i];
5260
+ if (t.nodeType === 1 && !util.isTextStyleElement(t) && !util.isBreak(t) && !util._disallowedTags(t)) {
5261
+ requireFormat = true;
5262
+ break;
5263
+ }
5264
+ }
5265
+
5266
+ return requireFormat;
5267
+ },
5268
+
5061
5269
  /**
5062
5270
  * @description Gets the clean HTML code for editor
5063
5271
  * @param {String} html HTML string
@@ -5091,16 +5299,12 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5091
5299
  }
5092
5300
  }
5093
5301
 
5094
- const domTree = dom.childNodes;
5302
+ let domTree = dom.childNodes;
5095
5303
  let cleanHTML = '';
5096
- let requireFormat = false;
5304
+ const requireFormat = this._isFormatData(domTree);
5097
5305
 
5098
- for (let i = 0, len = domTree.length, t; i < len; i++) {
5099
- t = domTree[i];
5100
- if (t.nodeType === 1 && !util.isTextStyleElement(t) && !util.isBreak(t) && !util._disallowedTags(t)) {
5101
- requireFormat = true;
5102
- break;
5103
- }
5306
+ if(requireFormat) {
5307
+ domTree = this._editFormat(dom).childNodes;
5104
5308
  }
5105
5309
 
5106
5310
  for (let i = 0, len = domTree.length; i < len; i++) {
@@ -5152,7 +5356,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5152
5356
  for (let i = 0, t; i < domTree.length; i++) {
5153
5357
  t = domTree[i];
5154
5358
 
5155
- if (!util.isFormatElement(t) && !util.isComponent(t) && !util.isMedia(t)) {
5359
+ if (!util.isFormatElement(t) && !util.isRangeFormatElement(t) && !util.isComponent(t) && !util.isMedia(t)) {
5156
5360
  if (!p) p = util.createElement(options.defaultTag);
5157
5361
  p.appendChild(t);
5158
5362
  i--;
@@ -5463,6 +5667,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5463
5667
  this._charTypeHTML = options.charCounterType === 'byte-html';
5464
5668
  this.wwComputedStyle = _w.getComputedStyle(context.element.wysiwyg);
5465
5669
  this._editorHeight = context.element.wysiwygFrame.offsetHeight;
5670
+ this._editorHeightPadding = util.getNumber(this.wwComputedStyle.getPropertyValue('padding-top')) + util.getNumber(this.wwComputedStyle.getPropertyValue('padding-bottom'));
5466
5671
 
5467
5672
  if (!options.iframe && typeof _w.ShadowRoot === 'function') {
5468
5673
  let child = context.element.wysiwygFrame;
@@ -5626,12 +5831,10 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5626
5831
  this.codeViewDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-code-view-enabled"]):not([data-display="MORE"])');
5627
5832
  this.resizingDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-resizing-enabled"]):not([data-display="MORE"])');
5628
5833
 
5629
- this.saveButtonStates();
5834
+ this._saveButtonStates();
5630
5835
 
5631
5836
  const tool = context.tool;
5632
5837
  this.commandMap = {
5633
- SUB: tool.subscript,
5634
- SUP: tool.superscript,
5635
5838
  OUTDENT: tool.outdent,
5636
5839
  INDENT: tool.indent
5637
5840
  };
@@ -5639,6 +5842,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5639
5842
  this.commandMap[options.textTags.underline.toUpperCase()] = tool.underline;
5640
5843
  this.commandMap[options.textTags.italic.toUpperCase()] = tool.italic;
5641
5844
  this.commandMap[options.textTags.strike.toUpperCase()] = tool.strike;
5845
+ this.commandMap[options.textTags.sub.toUpperCase()] = tool.subscript;
5846
+ this.commandMap[options.textTags.sup.toUpperCase()] = tool.superscript;
5642
5847
 
5643
5848
  this._styleCommandMap = {
5644
5849
  fullScreen: tool.fullScreen,
@@ -5696,7 +5901,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5696
5901
  },
5697
5902
 
5698
5903
  __callResizeFunction: function (h, resizeObserverEntry) {
5699
- h = h === -1 ? resizeObserverEntry.borderBoxSize[0].blockSize : h;
5904
+ h = h === -1 ? (resizeObserverEntry.borderBoxSize ? resizeObserverEntry.borderBoxSize[0].blockSize : (resizeObserverEntry.contentRect.height + this._editorHeightPadding)) : h;
5700
5905
  if (this._editorHeight !== h) {
5701
5906
  if (typeof functions.onResizeEditor === 'function') functions.onResizeEditor(h, this._editorHeight, core, resizeObserverEntry);
5702
5907
  this._editorHeight = h;
@@ -5965,7 +6170,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5965
6170
  break;
5966
6171
  }
5967
6172
 
5968
- if (!command) return keyStr === 'B'; // chromium - bold disabled
6173
+ if (!command) return !!keyStr;
5969
6174
 
5970
6175
  core.commandHandler(core.commandMap[command], command);
5971
6176
  return true;
@@ -5978,7 +6183,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5978
6183
 
5979
6184
  const marginDir = options.rtl ? 'marginRight' : 'marginLeft';
5980
6185
  const commandMap = core.commandMap;
5981
- const classOnCheck = this._onButtonsCheck;
6186
+ const classOnCheck = event._onButtonsCheck;
5982
6187
  const commandMapNodes = [];
5983
6188
  const currentNodes = [];
5984
6189
 
@@ -7233,6 +7438,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7233
7438
  onBlur_wysiwyg: function (e) {
7234
7439
  if (core._antiBlur || core._variable.isCodeView) return;
7235
7440
  core.hasFocus = false;
7441
+ core.effectNode = null;
7236
7442
  core.controllersOff();
7237
7443
  if (core._isInline || core._isBalloon) event._hideToolbar();
7238
7444
 
@@ -7587,39 +7793,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7587
7793
  }
7588
7794
 
7589
7795
  if (cleanData) {
7590
- if (util.isListCell(util.getFormatElement(core.getSelectionNode(), null))) {
7591
- const dom = (_d.createRange().createContextualFragment(cleanData));
7592
- if (dom.childNodes[0].nodeType === 1) {
7593
- cleanData = event._convertListCell(dom);
7594
- }
7595
- }
7596
7796
  functions.insertHTML(cleanData, true, false);
7597
7797
  return false;
7598
7798
  }
7599
7799
  },
7600
7800
 
7601
- _convertListCell: function (dom) {
7602
- const domTree = dom.childNodes;
7603
- let html = '';
7604
-
7605
- for (let i = 0, len = domTree.length, node; i < len; i++) {
7606
- node = domTree[i];
7607
- if (node.nodeType === 1) {
7608
- if (util.isFormatElement(node)) {
7609
- html += '<li>' +(node.innerHTML.trim() || '<br>') + '</li>';
7610
- } else if (util.isRangeFormatElement(node) && !util.isTable(node)) {
7611
- html += event._convertListCell(node);
7612
- } else {
7613
- html += '<li>' + node.outerHTML + '</li>';
7614
- }
7615
- } else {
7616
- html += '<li>' + (node.textContent || '<br>') + '</li>';
7617
- }
7618
- }
7619
-
7620
- return html;
7621
- },
7622
-
7623
7801
  onMouseMove_wysiwyg: function (e) {
7624
7802
  if (core.isDisabled || core.isReadOnly) return false;
7625
7803
  const component = util.getParentElement(e.target, util.isComponent);
@@ -8117,11 +8295,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8117
8295
  context.tool = newContext.tool;
8118
8296
  if (options.iframe) context.element.wysiwyg = core._wd.body;
8119
8297
 
8120
- core.recoverButtonStates();
8121
-
8298
+ core._recoverButtonStates();
8122
8299
  core._cachingButtons();
8123
8300
  core.history._resetCachingButton();
8124
8301
 
8302
+ core.effectNode = null;
8125
8303
  if (core.hasFocus) event._applyTagEffects();
8126
8304
  if (core.isReadOnly) util.setDisabledButtons(true, core.resizingDisabledButtons);
8127
8305
  if (typeof functions.onSetToolbarButtons === 'function') functions.onSetToolbarButtons(newToolbar._buttonTray.querySelectorAll('button'), core);
@@ -8335,10 +8513,16 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8335
8513
  */
8336
8514
  insertHTML: function (html, notCleaningData, checkCharCount, rangeSelection) {
8337
8515
  if (!context.element.wysiwygFrame.contains(core.getSelection().focusNode)) core.focus();
8338
-
8516
+
8339
8517
  if (typeof html === 'string') {
8340
8518
  if (!notCleaningData) html = core.cleanHTML(html, null, null);
8341
8519
  try {
8520
+ if (util.isListCell(util.getFormatElement(core.getSelectionNode(), null))) {
8521
+ const dom = _d.createRange().createContextualFragment(html);
8522
+ const domTree = dom.childNodes;
8523
+ if (core._isFormatData(domTree)) html = core._convertListCell(domTree);
8524
+ }
8525
+
8342
8526
  const dom = _d.createRange().createContextualFragment(html);
8343
8527
  const domTree = dom.childNodes;
8344
8528