@worktile/theia 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1716,6 +1716,30 @@
1716
1716
  return !containerNode ? CONTAINER_BLOCKS : __spreadArray(__spreadArray([], __read(CONTAINER_BLOCKS)), [containerNode[0].type]);
1717
1717
  };
1718
1718
 
1719
+ var getDirectlyParent = function (editor) {
1720
+ var _a = __read(getBlockAbove(editor), 2), anchorPath = _a[1];
1721
+ if (!anchorPath)
1722
+ return;
1723
+ var parentEntry = getParent(editor, anchorPath);
1724
+ if (!parentEntry)
1725
+ return;
1726
+ return parentEntry;
1727
+ };
1728
+
1729
+ var isTypesInParent = function (editor, types) {
1730
+ if (!Array.isArray(types)) {
1731
+ types = [types];
1732
+ }
1733
+ var _a = __read(getBlockAbove(editor), 2), anchorPath = _a[1];
1734
+ if (!anchorPath)
1735
+ return false;
1736
+ var parentEntry = slate.Editor.above(editor, { match: function (n) { return types.includes(n.type); } });
1737
+ if (!parentEntry)
1738
+ return false;
1739
+ var _b = __read(parentEntry, 1), parentNode = _b[0];
1740
+ return types.includes(parentNode.type);
1741
+ };
1742
+
1719
1743
  var index$1 = /*#__PURE__*/Object.freeze({
1720
1744
  __proto__: null,
1721
1745
  getLastNode: getLastNode,
@@ -1743,6 +1767,7 @@
1743
1767
  getPlainText: getPlainText,
1744
1768
  getSelectionMarks: getSelectionMarks,
1745
1769
  getContainerBlocks: getContainerBlocks,
1770
+ getDirectlyParent: getDirectlyParent,
1746
1771
  isAncestor: isAncestor,
1747
1772
  isCollapsed: isCollapsed,
1748
1773
  isEmptyParagraph: isEmptyParagraph,
@@ -1765,6 +1790,7 @@
1765
1790
  isEmptyContent: isEmptyContent,
1766
1791
  isEmptyParagraphByPath: isEmptyParagraphByPath,
1767
1792
  isContainer: isContainer,
1793
+ isTypesInParent: isTypesInParent,
1768
1794
  anchorBlock: anchorBlock,
1769
1795
  anchorBlockEntry: anchorBlockEntry,
1770
1796
  anchorInlineEntry: anchorInlineEntry,
@@ -1776,11 +1802,32 @@
1776
1802
  });
1777
1803
 
1778
1804
  var insertElementNext = function (editor, node) {
1805
+ var _a;
1779
1806
  if (slate.Range.isExpanded(editor.selection)) {
1780
1807
  slate.Editor.deleteFragment(editor);
1781
1808
  }
1782
- var anchorBlockPath = anchorBlockEntry(editor)[1];
1783
- var isEmpty = isEmptyParagraph(editor);
1809
+ var allowContainerOperateTypes = ((_a = editor.options) === null || _a === void 0 ? void 0 : _a.allowContainerOperateTypes) || [];
1810
+ var isAllowContainerInsert = isTypesInParent(editor, allowContainerOperateTypes);
1811
+ var isBlockCardCursor$1 = isBlockCardCursor(editor);
1812
+ var containerBlocks = getContainerBlocks(editor);
1813
+ var isContainer = isNodeTypeIn(editor, containerBlocks, { at: editor.selection });
1814
+ var _b = __read(anchorBlockEntry(editor), 2), anchorBlock = _b[0], anchorBlockPath = _b[1];
1815
+ var isEmpty = slate.Editor.isEmpty(editor, anchorBlock);
1816
+ if (isAllowContainerInsert && isContainer && !isBlockCardCursor$1) {
1817
+ var _c = __read(slate.Editor.above(editor, {
1818
+ match: function (n) { return slate.Editor.isBlock(editor, n) && allowContainerOperateTypes.includes(n.type); },
1819
+ at: editor.selection
1820
+ }), 2), containerPath_1 = _c[1];
1821
+ slate.Editor.withoutNormalizing(editor, function () {
1822
+ var containerPathFirstPath = anchorBlockPath.slice(0, containerPath_1.length + 1);
1823
+ slate.Transforms.insertNodes(editor, node, { at: slate.Path.next(containerPathFirstPath) });
1824
+ slate.Transforms.select(editor, slate.Editor.start(editor, slate.Path.next(containerPathFirstPath)));
1825
+ if (isEmpty) {
1826
+ slate.Transforms.removeNodes(editor, { at: anchorBlockPath });
1827
+ }
1828
+ });
1829
+ return;
1830
+ }
1784
1831
  var nextPath = slate.Path.next([anchorBlockPath[0]]);
1785
1832
  slate.Transforms.insertNodes(editor, node, { at: nextPath });
1786
1833
  if (isEmpty && anchorBlockPath.length === 1) {
@@ -1995,40 +2042,6 @@
1995
2042
  return false;
1996
2043
  }
1997
2044
 
1998
- var insertElementNode = function (editor, node) {
1999
- if (slate.Range.isExpanded(editor.selection)) {
2000
- slate.Editor.deleteFragment(editor);
2001
- }
2002
- var isBlockCardCursor$1 = isBlockCardCursor(editor);
2003
- var containerBlocks = getContainerBlocks(editor);
2004
- var isContainer = isNodeTypeIn(editor, containerBlocks, { at: editor.selection });
2005
- var _a = __read(anchorBlockEntry(editor), 2), anchorBlock = _a[0], anchorBlockPath = _a[1];
2006
- var isEmpty = slate.Editor.isEmpty(editor, anchorBlock);
2007
- if (isContainer && !isBlockCardCursor$1) {
2008
- var _b = __read(slate.Editor.above(editor, {
2009
- match: function (n) { return slate.Editor.isBlock(editor, n) && containerBlocks.includes(n.type); },
2010
- at: editor.selection
2011
- }), 2), containerPath_1 = _b[1];
2012
- slate.Editor.withoutNormalizing(editor, function () {
2013
- var containerPathFirstPath = anchorBlockPath.slice(0, containerPath_1.length + 1);
2014
- slate.Transforms.insertNodes(editor, node, { at: slate.Path.next(containerPathFirstPath), select: true });
2015
- if (isEmpty) {
2016
- slate.Transforms.removeNodes(editor, { at: anchorBlockPath });
2017
- }
2018
- });
2019
- return;
2020
- }
2021
- var nextPath = slate.Path.next([anchorBlockPath[0]]);
2022
- slate.Transforms.insertNodes(editor, node, { at: nextPath });
2023
- if (isEmpty && anchorBlockPath.length === 1) {
2024
- slate.Transforms.delete(editor, { at: anchorBlockPath });
2025
- slate.Transforms.select(editor, slate.Editor.start(editor, anchorBlockPath));
2026
- }
2027
- else {
2028
- slate.Transforms.select(editor, slate.Editor.start(editor, nextPath));
2029
- }
2030
- };
2031
-
2032
2045
  var index = /*#__PURE__*/Object.freeze({
2033
2046
  __proto__: null,
2034
2047
  setMarks: setMarks,
@@ -2048,8 +2061,7 @@
2048
2061
  setEndSelection: setEndSelection,
2049
2062
  closeConversionHint: closeConversionHint,
2050
2063
  handleContinualDeleteBackward: handleContinualDeleteBackward,
2051
- handleContinualInsertBreak: handleContinualInsertBreak,
2052
- insertElementNode: insertElementNode
2064
+ handleContinualInsertBreak: handleContinualInsertBreak
2053
2065
  });
2054
2066
 
2055
2067
  var TheConversionHintComponent = /** @class */ (function () {
@@ -12280,12 +12292,18 @@
12280
12292
  editor.onKeydown = function (event) {
12281
12293
  var _a;
12282
12294
  if (event.key === QUICK_TOOLBAR_HOTKEY) {
12283
- var types = __spreadArray([], __read((((_a = editor.options) === null || _a === void 0 ? void 0 : _a.triggerQuickToolbarTypes) || [])));
12295
+ var types = __spreadArray([], __read((((_a = editor.options) === null || _a === void 0 ? void 0 : _a.allowContainerOperateTypes) || [])));
12284
12296
  var _b = __read(getBlockAbove(editor), 1), block = _b[0];
12285
12297
  if (isPureEmptyParagraph(editor, block) && allowOpenQuickToolbar(editor, types)) {
12286
12298
  presseingQuickInsertHotkey = true;
12287
12299
  }
12288
12300
  }
12301
+ var quickToolbarRef = THE_EDITOR_QUICK_TOOLBAR_REF.get(editor);
12302
+ var isMoveUp = i1.hotkeys.isMoveUp(event);
12303
+ var isMoveDown = i1.hotkeys.isMoveDown(event);
12304
+ if (quickToolbarRef && (isMoveUp || isMoveDown)) {
12305
+ return;
12306
+ }
12289
12307
  onKeydown(event);
12290
12308
  };
12291
12309
  editor.deleteBackward = function (unit) {
@@ -12310,7 +12328,9 @@
12310
12328
  else {
12311
12329
  presseingQuickInsertHotkey = false;
12312
12330
  }
12313
- if (QuickInsertEditor.isOpenedToolbar(editor) && !isPureEmptyParagraph(editor, block) && slate.Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
12331
+ if (QuickInsertEditor.isOpenedToolbar(editor) &&
12332
+ !isPureEmptyParagraph(editor, block) &&
12333
+ slate.Node.string(block) !== QUICK_TOOLBAR_HOTKEY) {
12314
12334
  QuickInsertEditor.closeQuickInsertToolbar(editor);
12315
12335
  }
12316
12336
  }