suneditor 2.43.5 → 2.43.6

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
@@ -459,13 +459,6 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
459
459
  DEL: ['text-decoration']
460
460
  },
461
461
 
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
462
  /**
470
463
  * @description Style button related to edit area
471
464
  * @property {Element} fullScreen fullScreen button element
@@ -510,6 +503,42 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
510
503
  _lineBreakDir: ''
511
504
  },
512
505
 
506
+ /**
507
+ * @description Save the current buttons states to "allCommandButtons" object
508
+ * @private
509
+ */
510
+ _saveButtonStates: function () {
511
+ if (!this.allCommandButtons) this.allCommandButtons = {};
512
+
513
+ const currentButtons = this.context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]');
514
+ for (let i = 0, element, command; i < currentButtons.length; i++) {
515
+ element = currentButtons[i];
516
+ command = element.getAttribute('data-command');
517
+
518
+ this.allCommandButtons[command] = element;
519
+ }
520
+ },
521
+
522
+ /**
523
+ * @description Recover the current buttons states from "allCommandButtons" object
524
+ * @private
525
+ */
526
+ _recoverButtonStates: function () {
527
+ if (this.allCommandButtons) {
528
+ const currentButtons = this.context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]');
529
+ for (let i = 0, button, command, oldButton; i < currentButtons.length; i++) {
530
+ button = currentButtons[i];
531
+ command = button.getAttribute('data-command');
532
+
533
+ oldButton = this.allCommandButtons[command];
534
+ if (oldButton) {
535
+ button.parentElement.replaceChild(oldButton, button);
536
+ if (this.context.tool[command]) this.context.tool[command] = oldButton;
537
+ }
538
+ }
539
+ }
540
+ },
541
+
513
542
  /**
514
543
  * @description If the plugin is not added, add the plugin and call the 'add' function.
515
544
  * If the plugin is added call callBack function.
@@ -1645,165 +1674,261 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1645
1674
  return null;
1646
1675
  }
1647
1676
 
1648
- const line = util.getFormatElement(this.getSelectionNode(), null);
1649
- const listCell = util.isListCell(line);
1677
+ let range = this.getRange();
1678
+ let line = util.isListCell(range.commonAncestorContainer) ? range.commonAncestorContainer : util.getFormatElement(this.getSelectionNode(), null);
1679
+ let insertListCell = util.isListCell(line) && (util.isListCell(oNode) || util.isList(oNode));
1680
+
1681
+ let parentNode, originAfter, tempAfterNode, tempParentNode = null;
1650
1682
  const freeFormat = util.isFreeFormatElement(line);
1651
1683
  const isFormats = (!freeFormat && (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode))) || util.isComponent(oNode);
1652
1684
 
1685
+ if (insertListCell) {
1686
+ tempAfterNode = afterNode || util.isList(oNode) ? line.lastChild : line.nextElementSibling;
1687
+ tempParentNode = util.isList(oNode) ? line : (tempAfterNode || line).parentNode;
1688
+ }
1689
+
1653
1690
  if (!afterNode && (isFormats || util.isComponent(oNode) || util.isMedia(oNode))) {
1691
+ const isEdge = this.isEdgePoint(range.endContainer, range.endOffset, 'end');
1654
1692
  const r = this.removeNode();
1655
- if (r.container.nodeType === 3 || util.isBreak(r.container)) {
1656
- const depthFormat = util.getParentElement(r.container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
1657
- afterNode = util.splitElement(r.container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
1658
- if (afterNode) afterNode = afterNode.previousSibling;
1693
+ const container = r.container;
1694
+ const prevContainer = r.prevContainer;
1695
+
1696
+ if (insertListCell && prevContainer) {
1697
+ tempParentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1698
+ if (tempParentNode.contains(container)) {
1699
+ let sameParent = true;
1700
+ tempAfterNode = container;
1701
+ while (tempAfterNode.parentNode && tempAfterNode.parentNode !== tempParentNode) {
1702
+ tempAfterNode = tempAfterNode.parentNode;
1703
+ sameParent = false;
1704
+ }
1705
+ if (sameParent && container === prevContainer) tempAfterNode = tempAfterNode.nextSibling;
1706
+ } else {
1707
+ tempAfterNode = null;
1708
+ }
1709
+ } else if (insertListCell && util.isListCell(container) && !line.parentElement) {
1710
+ line = util.createElement('LI');
1711
+ tempParentNode.appendChild(line);
1712
+ container.appendChild(tempParentNode);
1713
+ tempAfterNode = null;
1714
+ } else if (container.nodeType === 3 || util.isBreak(container) || insertListCell) {
1715
+ const depthFormat = util.getParentElement(container, function (current) { return this.isRangeFormatElement(current) || this.isListCell(current); }.bind(util));
1716
+ afterNode = util.splitElement(container, r.offset, !depthFormat ? 0 : util.getElementDepth(depthFormat) + 1);
1717
+ if (afterNode) {
1718
+ if (insertListCell) {
1719
+ if (line.contains(container)) {
1720
+ const subList = util.isList(line.lastElementChild);
1721
+ let newCell = null;
1722
+ if (!isEdge) {
1723
+ newCell = line.cloneNode(false);
1724
+ newCell.appendChild(afterNode.textContent.trim() ? afterNode : util.createTextNode(util.zeroWidthSpace));
1725
+ }
1726
+ if (subList) {
1727
+ if (!newCell) {
1728
+ newCell = line.cloneNode(false);
1729
+ newCell.appendChild(util.createTextNode(util.zeroWidthSpace));
1730
+ }
1731
+ newCell.appendChild(line.lastElementChild);
1732
+ }
1733
+ if (newCell) {
1734
+ tempParentNode.insertBefore(newCell, line.nextElementSibling);
1735
+ tempAfterNode = afterNode = newCell;
1736
+ }
1737
+ }
1738
+ } else {
1739
+ afterNode = afterNode.previousSibling;
1740
+ }
1741
+ }
1659
1742
  }
1660
1743
  }
1661
1744
 
1662
- const range = (!afterNode && !isFormats) ? this.getRange_addLine(this.getRange(), null) : this.getRange();
1745
+ range = (!afterNode && !isFormats) ? this.getRange_addLine(this.getRange(), null) : this.getRange();
1663
1746
  const commonCon = range.commonAncestorContainer;
1664
1747
  const startOff = range.startOffset;
1665
1748
  const endOff = range.endOffset;
1666
1749
  const formatRange = range.startContainer === commonCon && util.isFormatElement(commonCon);
1667
1750
  const startCon = formatRange ? (commonCon.childNodes[startOff] || commonCon.childNodes[0] || range.startContainer) : range.startContainer;
1668
1751
  const endCon = formatRange ? (commonCon.childNodes[endOff] || commonCon.childNodes[commonCon.childNodes.length - 1] || range.endContainer) : range.endContainer;
1669
- let parentNode, originAfter = null;
1670
-
1671
- if (!afterNode) {
1672
- parentNode = startCon;
1673
- if (startCon.nodeType === 3) {
1674
- parentNode = startCon.parentNode;
1675
- }
1676
1752
 
1677
- /** No Select range node */
1678
- if (range.collapsed) {
1679
- if (commonCon.nodeType === 3) {
1680
- if (commonCon.textContent.length > endOff) afterNode = commonCon.splitText(endOff);
1681
- else afterNode = commonCon.nextSibling;
1682
- } else {
1683
- if (!util.isBreak(parentNode)) {
1684
- let c = parentNode.childNodes[startOff];
1685
- const focusNode = (c && c.nodeType === 3 && util.onlyZeroWidthSpace(c) && util.isBreak(c.nextSibling)) ? c.nextSibling : c;
1686
- if (focusNode) {
1687
- if (!focusNode.nextSibling) {
1688
- parentNode.removeChild(focusNode);
1689
- afterNode = null;
1753
+ if (!insertListCell) {
1754
+ if (!afterNode) {
1755
+ parentNode = startCon;
1756
+ if (startCon.nodeType === 3) {
1757
+ parentNode = startCon.parentNode;
1758
+ }
1759
+
1760
+ /** No Select range node */
1761
+ if (range.collapsed) {
1762
+ if (commonCon.nodeType === 3) {
1763
+ if (commonCon.textContent.length > endOff) afterNode = commonCon.splitText(endOff);
1764
+ else afterNode = commonCon.nextSibling;
1765
+ } else {
1766
+ if (!util.isBreak(parentNode)) {
1767
+ let c = parentNode.childNodes[startOff];
1768
+ const focusNode = (c && c.nodeType === 3 && util.onlyZeroWidthSpace(c) && util.isBreak(c.nextSibling)) ? c.nextSibling : c;
1769
+ if (focusNode) {
1770
+ if (!focusNode.nextSibling) {
1771
+ parentNode.removeChild(focusNode);
1772
+ afterNode = null;
1773
+ } else {
1774
+ afterNode = (util.isBreak(focusNode) && !util.isBreak(oNode)) ? focusNode : focusNode.nextSibling;
1775
+ }
1690
1776
  } else {
1691
- afterNode = (util.isBreak(focusNode) && !util.isBreak(oNode)) ? focusNode : focusNode.nextSibling;
1777
+ afterNode = null;
1692
1778
  }
1693
1779
  } else {
1694
- afterNode = null;
1780
+ afterNode = parentNode;
1781
+ parentNode = parentNode.parentNode;
1695
1782
  }
1696
- } else {
1697
- afterNode = parentNode;
1698
- parentNode = parentNode.parentNode;
1699
- }
1700
- }
1701
- } else { /** Select range nodes */
1702
- const isSameContainer = startCon === endCon;
1703
-
1704
- if (isSameContainer) {
1705
- if (this.isEdgePoint(endCon, endOff)) afterNode = endCon.nextSibling;
1706
- else afterNode = endCon.splitText(endOff);
1707
-
1708
- let removeNode = startCon;
1709
- if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);
1710
-
1711
- parentNode.removeChild(removeNode);
1712
- if (parentNode.childNodes.length === 0 && isFormats) {
1713
- parentNode.innerHTML = '<br>';
1714
1783
  }
1715
- }
1716
- else {
1717
- const removedTag = this.removeNode();
1718
- const container = removedTag.container;
1719
- const prevContainer = removedTag.prevContainer;
1720
- if (container && container.childNodes.length === 0 && isFormats) {
1721
- if (util.isFormatElement(container)) {
1722
- container.innerHTML = '<br>';
1723
- } else if (util.isRangeFormatElement(container)) {
1724
- container.innerHTML = '<' + options.defaultTag + '><br></' + options.defaultTag + '>';
1784
+ } else { /** Select range nodes */
1785
+ const isSameContainer = startCon === endCon;
1786
+
1787
+ if (isSameContainer) {
1788
+ if (this.isEdgePoint(endCon, endOff)) afterNode = endCon.nextSibling;
1789
+ else afterNode = endCon.splitText(endOff);
1790
+
1791
+ let removeNode = startCon;
1792
+ if (!this.isEdgePoint(startCon, startOff)) removeNode = startCon.splitText(startOff);
1793
+
1794
+ parentNode.removeChild(removeNode);
1795
+ if (parentNode.childNodes.length === 0 && isFormats) {
1796
+ parentNode.innerHTML = '<br>';
1725
1797
  }
1726
1798
  }
1727
-
1728
- if (!isFormats && prevContainer) {
1729
- parentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1730
- if (parentNode.contains(container)) {
1731
- let sameParent = true;
1732
- afterNode = container;
1733
- while (afterNode.parentNode !== parentNode) {
1734
- afterNode = afterNode.parentNode;
1735
- sameParent = false;
1799
+ else {
1800
+ const removedTag = this.removeNode();
1801
+ const container = removedTag.container;
1802
+ const prevContainer = removedTag.prevContainer;
1803
+
1804
+ if (container && container.childNodes.length === 0 && isFormats) {
1805
+ if (util.isFormatElement(container)) {
1806
+ container.innerHTML = '<br>';
1807
+ } else if (util.isRangeFormatElement(container)) {
1808
+ container.innerHTML = '<' + options.defaultTag + '><br></' + options.defaultTag + '>';
1736
1809
  }
1737
- if (sameParent && container === prevContainer) afterNode = afterNode.nextSibling;
1738
- } else {
1810
+ }
1811
+
1812
+ if (util.isListCell(container) && oNode.nodeType === 3) {
1813
+ parentNode = container;
1739
1814
  afterNode = null;
1815
+ } else if (!isFormats && prevContainer) {
1816
+ parentNode = prevContainer.nodeType === 3 ? prevContainer.parentNode : prevContainer;
1817
+ if (parentNode.contains(container)) {
1818
+ let sameParent = true;
1819
+ afterNode = container;
1820
+ while (afterNode.parentNode && afterNode.parentNode !== parentNode) {
1821
+ afterNode = afterNode.parentNode;
1822
+ sameParent = false;
1823
+ }
1824
+ if (sameParent && container === prevContainer) afterNode = afterNode.nextSibling;
1825
+ } else {
1826
+ afterNode = null;
1827
+ }
1828
+ } else {
1829
+ afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
1830
+ parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
1831
+ }
1832
+
1833
+ while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
1834
+ afterNode = afterNode.parentNode;
1740
1835
  }
1741
- } else {
1742
- afterNode = isFormats ? endCon : container === prevContainer ? container.nextSibling : container;
1743
- parentNode = (!afterNode || !afterNode.parentNode) ? commonCon : afterNode.parentNode;
1744
- }
1745
-
1746
- while (afterNode && !util.isFormatElement(afterNode) && afterNode.parentNode !== commonCon) {
1747
- afterNode = afterNode.parentNode;
1748
1836
  }
1749
1837
  }
1838
+ } else { // has afterNode
1839
+ parentNode = afterNode.parentNode;
1840
+ afterNode = afterNode.nextSibling;
1841
+ originAfter = true;
1750
1842
  }
1751
1843
  }
1752
- // has afterNode
1753
- else {
1754
- parentNode = afterNode.parentNode;
1755
- afterNode = afterNode.nextSibling;
1756
- originAfter = true;
1757
- }
1758
1844
 
1759
- // --- insert node ---
1760
1845
  try {
1761
- if (util.isWysiwygDiv(afterNode) || parentNode === context.element.wysiwyg.parentNode) {
1762
- parentNode = context.element.wysiwyg;
1763
- afterNode = null;
1764
- }
1765
-
1766
- if (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode) || (!util.isListCell(parentNode) && util.isComponent(oNode))) {
1767
- const oldParent = parentNode;
1768
- if (util.isList(afterNode)) {
1769
- parentNode = afterNode;
1846
+ // set node
1847
+ if (!insertListCell) {
1848
+ if (util.isWysiwygDiv(afterNode) || parentNode === context.element.wysiwyg.parentNode) {
1849
+ parentNode = context.element.wysiwyg;
1770
1850
  afterNode = null;
1771
- } else if (util.isListCell(afterNode)) {
1772
- parentNode = afterNode.previousElementSibling || afterNode;
1773
- } else if (!originAfter && !afterNode) {
1774
- const r = this.removeNode();
1775
- 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;
1776
- const rangeCon = util.isWysiwygDiv(container) || util.isRangeFormatElement(container);
1777
- parentNode = rangeCon ? container : container.parentNode;
1778
- afterNode = rangeCon ? null : container.nextSibling;
1779
1851
  }
1780
-
1781
- if (oldParent.childNodes.length === 0 && parentNode !== oldParent) util.removeItem(oldParent);
1782
- }
1783
-
1784
- if (isFormats && !freeFormat && !util.isRangeFormatElement(parentNode) && !util.isListCell(parentNode) && !util.isWysiwygDiv(parentNode)) {
1785
- afterNode = parentNode.nextElementSibling;
1786
- parentNode = parentNode.parentNode;
1787
- }
1788
-
1789
- if (util.isWysiwygDiv(parentNode) && (oNode.nodeType === 3 || util.isBreak(oNode))) {
1790
- const fNode = util.createElement(options.defaultTag);
1791
- fNode.appendChild(oNode);
1792
- oNode = fNode;
1852
+
1853
+ if (util.isFormatElement(oNode) || util.isRangeFormatElement(oNode) || (!util.isListCell(parentNode) && util.isComponent(oNode))) {
1854
+ const oldParent = parentNode;
1855
+ if (util.isList(afterNode)) {
1856
+ parentNode = afterNode;
1857
+ afterNode = null;
1858
+ } else if (util.isListCell(afterNode)) {
1859
+ parentNode = afterNode.previousElementSibling || afterNode;
1860
+ } else if (!originAfter && !afterNode) {
1861
+ const r = this.removeNode();
1862
+ 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;
1863
+ const rangeCon = util.isWysiwygDiv(container) || util.isRangeFormatElement(container);
1864
+ parentNode = rangeCon ? container : container.parentNode;
1865
+ afterNode = rangeCon ? null : container.nextSibling;
1866
+ }
1867
+
1868
+ if (oldParent.childNodes.length === 0 && parentNode !== oldParent) util.removeItem(oldParent);
1869
+ }
1870
+
1871
+ if (isFormats && !freeFormat && !util.isRangeFormatElement(parentNode) && !util.isListCell(parentNode) && !util.isWysiwygDiv(parentNode)) {
1872
+ afterNode = parentNode.nextElementSibling;
1873
+ parentNode = parentNode.parentNode;
1874
+ }
1875
+
1876
+ if (util.isWysiwygDiv(parentNode) && (oNode.nodeType === 3 || util.isBreak(oNode))) {
1877
+ const fNode = util.createElement(options.defaultTag);
1878
+ fNode.appendChild(oNode);
1879
+ oNode = fNode;
1880
+ }
1793
1881
  }
1794
1882
 
1795
1883
  // insert--
1796
- let emptyListCell = false;
1797
- if (listCell && util.isListCell(oNode)) {
1798
- afterNode = line.nextElementSibling;
1799
- parentNode = line.parentNode;
1800
- emptyListCell = util.onlyZeroWidthSpace(line.textContent);
1884
+ if (insertListCell) {
1885
+ if (!tempParentNode.parentNode) {
1886
+ parentNode = context.element.wysiwyg;
1887
+ afterNode = null;
1888
+ } else {
1889
+ parentNode = tempParentNode;
1890
+ afterNode = tempAfterNode;
1891
+ }
1801
1892
  } else {
1802
1893
  afterNode = parentNode === afterNode ? parentNode.lastChild : afterNode;
1803
1894
  }
1804
1895
 
1896
+ if (util.isListCell(oNode) && !util.isList(parentNode)) {
1897
+ if (util.isListCell(parentNode)) {
1898
+ afterNode = parentNode.nextElementSibling;
1899
+ parentNode = parentNode.parentNode;
1900
+ } else {
1901
+ const ul = util.createElement('ol');
1902
+ parentNode.insertBefore(ul, afterNode);
1903
+ parentNode = ul;
1904
+ afterNode = null;
1905
+ }
1906
+ insertListCell = true;
1907
+ }
1908
+
1805
1909
  parentNode.insertBefore(oNode, afterNode);
1806
- if (emptyListCell) util.removeItem(line);
1910
+
1911
+ if (insertListCell) {
1912
+ if (util.onlyZeroWidthSpace(line.textContent.trim())) {
1913
+ util.removeItem(line);
1914
+ oNode = oNode.lastChild;
1915
+ } else {
1916
+ const chList = util.getArrayItem(line.children, util.isList);
1917
+ if (chList) {
1918
+ if (oNode !== chList) {
1919
+ oNode.appendChild(chList);
1920
+ oNode = chList.previousSibling;
1921
+ } else {
1922
+ parentNode.appendChild(oNode);
1923
+ oNode = parentNode;
1924
+ }
1925
+
1926
+ if (util.onlyZeroWidthSpace(line.textContent.trim())) {
1927
+ util.removeItem(line);
1928
+ }
1929
+ }
1930
+ }
1931
+ }
1807
1932
  } catch (e) {
1808
1933
  parentNode.appendChild(oNode);
1809
1934
  } finally {
@@ -1972,28 +2097,11 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
1972
2097
  startIndex = endIndex = 0;
1973
2098
  }
1974
2099
 
1975
- function remove (item) {
1976
- const format = util.getFormatElement(item, null);
1977
- util.removeItem(item);
1978
-
1979
- if(util.isListCell(format)) {
1980
- const list = util.getArrayItem(format.children, util.isList, false);
1981
- if (list) {
1982
- const child = list.firstElementChild;
1983
- const children = child.childNodes;
1984
- while (children[0]) {
1985
- format.insertBefore(children[0], list);
1986
- }
1987
- util.removeItemAllParents(child, null, null);
1988
- }
1989
- }
1990
- }
1991
-
1992
2100
  for (let i = startIndex; i <= endIndex; i++) {
1993
2101
  const item = childNodes[i];
1994
2102
 
1995
2103
  if (item.length === 0 || (item.nodeType === 3 && item.data === undefined)) {
1996
- remove(item);
2104
+ this._nodeRemoveListItem(item);
1997
2105
  continue;
1998
2106
  }
1999
2107
 
@@ -2013,7 +2121,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2013
2121
  if (beforeNode.length > 0) {
2014
2122
  startCon.data = beforeNode.data;
2015
2123
  } else {
2016
- remove(startCon);
2124
+ this._nodeRemoveListItem(startCon);
2017
2125
  }
2018
2126
 
2019
2127
  if (item === endCon) break;
@@ -2031,24 +2139,26 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2031
2139
  if (afterNode.length > 0) {
2032
2140
  endCon.data = afterNode.data;
2033
2141
  } else {
2034
- remove(endCon);
2142
+ this._nodeRemoveListItem(endCon);
2035
2143
  }
2036
2144
 
2037
2145
  continue;
2038
2146
  }
2039
2147
 
2040
- remove(item);
2148
+ this._nodeRemoveListItem(item);
2041
2149
  }
2042
2150
 
2043
- container = endCon && endCon.parentNode ? endCon : startCon && startCon.parentNode ? startCon : (range.endContainer || range.startContainer);
2151
+ const endUl = util.getParentElement(endCon, 'ul');
2152
+ const startLi = util.getParentElement(startCon, 'li');
2153
+ if (endUl && startLi && startLi.contains(endUl)) {
2154
+ container = endUl.previousSibling;
2155
+ offset = container.textContent.length;
2156
+ } else {
2157
+ container = endCon && endCon.parentNode ? endCon : startCon && startCon.parentNode ? startCon : (range.endContainer || range.startContainer);
2158
+ }
2044
2159
 
2045
2160
  if (!util.isWysiwygDiv(container) && container.childNodes.length === 0) {
2046
- const rc = util.removeItemAllParents(container, function (current) {
2047
- if (this.isComponent(current)) return false;
2048
- const text = current.textContent;
2049
- return text.length === 0 || /^(\n|\u200B)+$/.test(text);
2050
- }.bind(util), null);
2051
-
2161
+ const rc = util.removeItemAllParents(container, null, null);
2052
2162
  if (rc) container = rc.sc || rc.ec || context.element.wysiwyg;
2053
2163
  }
2054
2164
 
@@ -2064,6 +2174,19 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
2064
2174
  };
2065
2175
  },
2066
2176
 
2177
+ _nodeRemoveListItem: function (item) {
2178
+ const format = util.getFormatElement(item, null);
2179
+ util.removeItem(item);
2180
+
2181
+ if(!util.isListCell(format)) return;
2182
+
2183
+ util.removeItemAllParents(format, null, null);
2184
+
2185
+ if (format && util.isList(format.firstChild)) {
2186
+ format.insertBefore(util.createTextNode(util.zeroWidthSpace), format.firstChild);
2187
+ }
2188
+ },
2189
+
2067
2190
  /**
2068
2191
  * @description Appended all selected format Element to the argument element and insert
2069
2192
  * @param {Element} rangeElement Element of wrap the arguments (BLOCKQUOTE...)
@@ -5606,6 +5729,8 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5606
5729
  this.codeViewDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-code-view-enabled"]):not([data-display="MORE"])');
5607
5730
  this.resizingDisabledButtons = context.element._buttonTray.querySelectorAll('.se-menu-list button[data-display]:not([class~="se-resizing-enabled"]):not([data-display="MORE"])');
5608
5731
 
5732
+ this._saveButtonStates();
5733
+
5609
5734
  const tool = context.tool;
5610
5735
  this.commandMap = {
5611
5736
  OUTDENT: tool.outdent,
@@ -5943,7 +6068,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
5943
6068
  break;
5944
6069
  }
5945
6070
 
5946
- if (!command) return keyStr === 'B'; // chromium - bold disabled
6071
+ if (!command) return !!keyStr;
5947
6072
 
5948
6073
  core.commandHandler(core.commandMap[command], command);
5949
6074
  return true;
@@ -7568,23 +7693,21 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
7568
7693
  if (cleanData) {
7569
7694
  if (util.isListCell(util.getFormatElement(core.getSelectionNode(), null))) {
7570
7695
  const dom = (_d.createRange().createContextualFragment(cleanData));
7571
- if (dom.childNodes[0].nodeType === 1) {
7572
- cleanData = event._convertListCell(dom);
7573
- }
7696
+ const domTree = dom.childNodes;
7697
+ if (domTree.length > 1 && domTree[0].nodeType === 1) cleanData = event._convertListCell(domTree);
7574
7698
  }
7575
7699
  functions.insertHTML(cleanData, true, false);
7576
7700
  return false;
7577
7701
  }
7578
7702
  },
7579
7703
 
7580
- _convertListCell: function (dom) {
7581
- const domTree = dom.childNodes;
7704
+ _convertListCell: function (domTree) {
7582
7705
  let html = '';
7583
7706
 
7584
7707
  for (let i = 0, len = domTree.length, node; i < len; i++) {
7585
7708
  node = domTree[i];
7586
7709
  if (node.nodeType === 1) {
7587
- if (util.isListCell(node)) {
7710
+ if (util.isListCell(node) || util.isList(node)) {
7588
7711
  html += node.outerHTML;
7589
7712
  } else if (util.isFormatElement(node)) {
7590
7713
  html += '<li>' +(node.innerHTML.trim() || '<br>') + '</li>';
@@ -8098,6 +8221,7 @@ export default function (context, pluginCallButtons, plugins, lang, options, _re
8098
8221
  context.tool = newContext.tool;
8099
8222
  if (options.iframe) context.element.wysiwyg = core._wd.body;
8100
8223
 
8224
+ core._recoverButtonStates();
8101
8225
  core._cachingButtons();
8102
8226
  core.history._resetCachingButton();
8103
8227
 
package/src/lib/util.js CHANGED
@@ -1380,6 +1380,7 @@ const util = {
1380
1380
  * @returns {Element}
1381
1381
  */
1382
1382
  splitElement: function (baseNode, offset, depth) {
1383
+ if (this.isWysiwygDiv(baseNode)) return baseNode;
1383
1384
  const bp = baseNode.parentNode;
1384
1385
  let index = 0, newEl, children, temp;
1385
1386
  let next = true;
@@ -73,7 +73,7 @@ export default {
73
73
  let html = '' +
74
74
  '<form method="post" enctype="multipart/form-data">' +
75
75
  '<div class="se-dialog-header">' +
76
- '<button type="button" data-command="close" class="se-btn se-dialog-close" aria-label="Close" title="' + lang.dialogBox.close + '">' +
76
+ '<button type="button" data-command="close" class="se-btn se-dialog-close" title="' + lang.dialogBox.close + '" aria-label="' + lang.dialogBox.close + '">' +
77
77
  core.icons.cancel +
78
78
  '</button>' +
79
79
  '<span class="se-modal-title">' + lang.dialogBox.audioBox.title + '</span>' +
@@ -86,7 +86,7 @@ export default {
86
86
  '<label>' + lang.dialogBox.audioBox.file + '</label>' +
87
87
  '<div class="se-dialog-form-files">' +
88
88
  '<input class="se-input-form _se_audio_files" type="file" accept="' + option.audioAccept + '"' + (option.audioMultipleFile ? ' multiple="multiple"' : '') + '/>' +
89
- '<button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="' + lang.controller.remove + '">' + core.icons.cancel + '</button>' +
89
+ '<button type="button" data-command="filesRemove" class="se-btn se-dialog-files-edge-button se-file-remove" title="' + lang.controller.remove + '" aria-label="' + lang.controller.remove + '">' + core.icons.cancel + '</button>' +
90
90
  '</div>' +
91
91
  '</div>';
92
92
  }
@@ -103,7 +103,7 @@ export default {
103
103
  html += '' +
104
104
  '</div>' +
105
105
  '<div class="se-dialog-footer">' +
106
- '<button type="submit" class="se-btn-primary" title="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
106
+ '<button type="submit" class="se-btn-primary" title="' + lang.dialogBox.submitButton + '" aria-label="' + lang.dialogBox.submitButton + '"><span>' + lang.dialogBox.submitButton + '</span></button>' +
107
107
  '</div>' +
108
108
  '</form>';
109
109