@contentful/field-editor-rich-text 3.3.5 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/ContentfulEditorProvider.d.ts +3 -3
  3. package/dist/field-editor-rich-text.cjs.development.js +785 -466
  4. package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
  5. package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
  6. package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
  7. package/dist/field-editor-rich-text.esm.js +727 -408
  8. package/dist/field-editor-rich-text.esm.js.map +1 -1
  9. package/dist/helpers/editor.d.ts +15 -16
  10. package/dist/helpers/extractNodes.d.ts +2 -3
  11. package/dist/helpers/sanitizeIncomingSlateDoc.d.ts +1 -1
  12. package/dist/helpers/transformers.d.ts +6 -7
  13. package/dist/internal/constants.d.ts +1 -0
  14. package/dist/internal/hooks.d.ts +1 -0
  15. package/dist/internal/index.d.ts +4 -0
  16. package/dist/internal/misc.d.ts +35 -0
  17. package/dist/internal/queries.d.ts +78 -0
  18. package/dist/internal/transforms.d.ts +33 -0
  19. package/dist/internal/types/editor.d.ts +70 -0
  20. package/dist/internal/types/index.d.ts +2 -0
  21. package/dist/internal/types/plugins.d.ts +12 -0
  22. package/dist/plugins/Break/createExitBreakPlugin.d.ts +2 -2
  23. package/dist/plugins/Break/createResetNodePlugin.d.ts +2 -2
  24. package/dist/plugins/Break/createSoftBreakPlugin.d.ts +2 -2
  25. package/dist/plugins/CommandPalette/components/CommandList.d.ts +2 -2
  26. package/dist/plugins/CommandPalette/components/CommandPrompt.d.ts +4 -2
  27. package/dist/plugins/CommandPalette/createCommandPalettePlugin.d.ts +2 -2
  28. package/dist/plugins/CommandPalette/onKeyDown.d.ts +2 -3
  29. package/dist/plugins/CommandPalette/useCommands.d.ts +2 -2
  30. package/dist/plugins/DragAndDrop/index.d.ts +2 -2
  31. package/dist/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +1 -1
  32. package/dist/plugins/EmbeddedEntityBlock/Util.d.ts +2 -1
  33. package/dist/plugins/EmbeddedEntityBlock/index.d.ts +3 -3
  34. package/dist/plugins/EmbeddedEntityInline/index.d.ts +2 -2
  35. package/dist/plugins/Heading/createHeadingPlugin.d.ts +2 -2
  36. package/dist/plugins/Hr/index.d.ts +3 -3
  37. package/dist/plugins/Hyperlink/HyperlinkModal.d.ts +2 -3
  38. package/dist/plugins/Hyperlink/components/EntityHyperlink.d.ts +1 -1
  39. package/dist/plugins/Hyperlink/components/UrlHyperlink.d.ts +1 -1
  40. package/dist/plugins/Hyperlink/createHyperlinkPlugin.d.ts +2 -2
  41. package/dist/plugins/Hyperlink/utils.d.ts +3 -3
  42. package/dist/plugins/List/createListPlugin.d.ts +2 -2
  43. package/dist/plugins/List/insertListBreak.d.ts +2 -2
  44. package/dist/plugins/List/insertListFragment.d.ts +2 -3
  45. package/dist/plugins/List/onKeyDownList.d.ts +3 -3
  46. package/dist/plugins/List/transforms/deleteBackwardList.d.ts +2 -2
  47. package/dist/plugins/List/transforms/insertListItem.d.ts +2 -2
  48. package/dist/plugins/List/transforms/moveListItemDown.d.ts +3 -8
  49. package/dist/plugins/List/transforms/moveListItems.d.ts +2 -6
  50. package/dist/plugins/List/transforms/toggleList.d.ts +2 -2
  51. package/dist/plugins/List/transforms/unwrapList.d.ts +2 -3
  52. package/dist/plugins/List/utils.d.ts +8 -9
  53. package/dist/plugins/List/withList.d.ts +2 -4
  54. package/dist/plugins/Marks/Bold.d.ts +3 -4
  55. package/dist/plugins/Marks/Code.d.ts +3 -4
  56. package/dist/plugins/Marks/Italic.d.ts +3 -4
  57. package/dist/plugins/Marks/Subscript.d.ts +3 -4
  58. package/dist/plugins/Marks/Superscript.d.ts +3 -4
  59. package/dist/plugins/Marks/Underline.d.ts +3 -4
  60. package/dist/plugins/Marks/helpers.d.ts +3 -5
  61. package/dist/plugins/Marks/index.d.ts +2 -2
  62. package/dist/plugins/Normalizer/createNormalizerPlugin.d.ts +2 -2
  63. package/dist/plugins/Normalizer/types.d.ts +3 -5
  64. package/dist/plugins/Normalizer/utils.d.ts +0 -3
  65. package/dist/plugins/Normalizer/withNormalizer.d.ts +2 -2
  66. package/dist/plugins/Paragraph/Paragraph.d.ts +1 -1
  67. package/dist/plugins/Paragraph/createParagraphPlugin.d.ts +2 -2
  68. package/dist/plugins/PasteHTML/createPasteHTMLPlugin.d.ts +2 -2
  69. package/dist/plugins/Quote/components/Quote.d.ts +1 -1
  70. package/dist/plugins/Quote/createQuotePlugin.d.ts +2 -2
  71. package/dist/plugins/Quote/shouldResetQuote.d.ts +1 -1
  72. package/dist/plugins/Quote/toggleQuote.d.ts +2 -3
  73. package/dist/plugins/Quote/withQuote.d.ts +2 -3
  74. package/dist/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.d.ts +2 -2
  75. package/dist/plugins/Table/actions/addColumn.d.ts +7 -4
  76. package/dist/plugins/Table/actions/addRow.d.ts +3 -3
  77. package/dist/plugins/Table/actions/setHeader.d.ts +2 -2
  78. package/dist/plugins/Table/components/Cell.d.ts +2 -2
  79. package/dist/plugins/Table/components/HeaderCell.d.ts +2 -2
  80. package/dist/plugins/Table/createTablePlugin.d.ts +2 -2
  81. package/dist/plugins/Table/helpers.d.ts +8 -9
  82. package/dist/plugins/Table/insertTableFragment.d.ts +3 -3
  83. package/dist/plugins/Table/onKeyDownTable.d.ts +2 -3
  84. package/dist/plugins/Table/tableTracking.d.ts +2 -2
  85. package/dist/plugins/Text/createTextPlugin.d.ts +2 -2
  86. package/dist/plugins/Tracking/createTrackingPlugin.d.ts +2 -2
  87. package/dist/plugins/Tracking/utils.d.ts +2 -2
  88. package/dist/plugins/TrailingParagraph/index.d.ts +2 -2
  89. package/dist/plugins/Voids/createVoidsPlugin.d.ts +2 -2
  90. package/dist/plugins/Voids/transformVoid.d.ts +2 -3
  91. package/dist/plugins/index.d.ts +2 -2
  92. package/dist/prepareDocument.d.ts +5 -6
  93. package/dist/test-utils/assertOutput.d.ts +2 -2
  94. package/dist/test-utils/createEditor.d.ts +22 -4
  95. package/dist/test-utils/jsx.d.ts +1 -1
  96. package/dist/test-utils/mockPlugin.d.ts +2 -2
  97. package/dist/test-utils/setEmptyDataAttribute.d.ts +2 -2
  98. package/package.json +17 -16
  99. package/dist/types.d.ts +0 -52
@@ -9,7 +9,7 @@ var React__default = _interopDefault(React);
9
9
  var fieldEditorReference = require('@contentful/field-editor-reference');
10
10
  var fieldEditorShared = require('@contentful/field-editor-shared');
11
11
  var Contentful = require('@contentful/rich-text-types');
12
- var plateCore = require('@udecode/plate-core');
12
+ var p = require('@udecode/plate-core');
13
13
  var emotion = require('emotion');
14
14
  var areEqual = _interopDefault(require('fast-deep-equal'));
15
15
  var noop = _interopDefault(require('lodash/noop'));
@@ -21,12 +21,12 @@ var f36Components = require('@contentful/f36-components');
21
21
  var f36Utils = require('@contentful/f36-utils');
22
22
  var constate = _interopDefault(require('constate'));
23
23
  var isHotkey = _interopDefault(require('is-hotkey'));
24
- var slate = require('slate');
25
- var Slate = require('slate-react');
24
+ var s = require('slate');
26
25
  var find = _interopDefault(require('lodash/find'));
27
26
  var flow = _interopDefault(require('lodash/flow'));
28
27
  var get = _interopDefault(require('lodash/get'));
29
28
  var tokens = _interopDefault(require('@contentful/f36-tokens'));
29
+ var Slate = require('slate-react');
30
30
  var f36Icons = require('@contentful/f36-icons');
31
31
  var plateList = require('@udecode/plate-list');
32
32
  var castArray = _interopDefault(require('lodash/castArray'));
@@ -273,16 +273,53 @@ function useContentfulEditorId(id) {
273
273
 
274
274
  function useContentfulEditor(id) {
275
275
  var editorId = useContentfulEditorId(id);
276
- var editor = plateCore.usePlateEditorState(editorId);
276
+ var editor = p.usePlateEditorState(editorId);
277
277
  return editor;
278
278
  } // This doesn't re-render when the value changes
279
279
 
280
280
  function useContentfulEditorRef(id) {
281
281
  var editorId = useContentfulEditorId(id);
282
- var editor = plateCore.usePlateEditorRef(editorId);
282
+ var editor = p.usePlateEditorRef(editorId);
283
283
  return editor;
284
284
  }
285
285
 
286
+ var createPlateEditor = function createPlateEditor(options) {
287
+ if (options === void 0) {
288
+ options = {};
289
+ }
290
+
291
+ return p.createPlateEditor(options);
292
+ };
293
+ var withoutNormalizing = function withoutNormalizing(editor, fn) {
294
+ return p.withoutNormalizing(editor, fn);
295
+ };
296
+ var focusEditor = function focusEditor(editor, target) {
297
+ p.focusEditor(editor, target);
298
+ };
299
+ var blurEditor = function blurEditor(editor) {
300
+ p.blurEditor(editor);
301
+ };
302
+ var selectEditor = function selectEditor(editor, opts) {
303
+ p.selectEditor(editor, opts);
304
+ };
305
+ var fromDOMPoint = function fromDOMPoint(editor, domPoint, opts) {
306
+ if (opts === void 0) {
307
+ opts = {
308
+ exactMatch: false,
309
+ suppressThrow: false
310
+ };
311
+ }
312
+
313
+ return p.toSlatePoint(editor, domPoint, opts);
314
+ };
315
+ var mockPlugin = function mockPlugin(plugin) {
316
+ return p.mockPlugin( // TODO check if there is a way around this ugly casting
317
+ plugin);
318
+ };
319
+ var getPlateSelectors = function getPlateSelectors(id) {
320
+ return p.getPlateSelectors(id);
321
+ };
322
+
286
323
  var createSoftBreakPlugin = function createSoftBreakPlugin() {
287
324
  return plateBreak.createSoftBreakPlugin({
288
325
  then: function then(editor) {
@@ -472,14 +509,280 @@ var useCommandList = function useCommandList(commandItems, container) {
472
509
  };
473
510
  };
474
511
 
512
+ /**
513
+ * Get text content at location
514
+ */
515
+
516
+ var getText = function getText(editor, at) {
517
+ return p.getEditorString(editor, at);
518
+ };
519
+ var isText = function isText(value) {
520
+ return p.isText(value);
521
+ };
522
+ var getEndPoint = function getEndPoint(editor, at) {
523
+ return p.getEndPoint(editor, at);
524
+ };
525
+ var getStartPoint = function getStartPoint(editor, at) {
526
+ return p.getStartPoint(editor, at);
527
+ };
528
+ var isNode = function isNode(value) {
529
+ return p.isNode(value);
530
+ };
531
+ var isSelectionAtBlockEnd = function isSelectionAtBlockEnd(editor, options) {
532
+ return p.isSelectionAtBlockEnd(editor, options);
533
+ };
534
+ var isSelectionAtBlockStart = function isSelectionAtBlockStart(editor, options) {
535
+ return p.isSelectionAtBlockStart(editor, options);
536
+ };
537
+ var getBlockAbove = function getBlockAbove(editor, options) {
538
+ return p.getBlockAbove(editor, options);
539
+ };
540
+ var getNodeEntry = function getNodeEntry(editor, at, options) {
541
+ return p.getNodeEntry(editor, at, options);
542
+ };
543
+ var getNodeEntries = function getNodeEntries(editor, options) {
544
+ return p.getNodeEntries(editor, options);
545
+ }; // TODO: Ancestor may not be the correct type for root
546
+
547
+ var getNodeChildren = function getNodeChildren(root, path, options) {
548
+ return p.getNodeChildren(root, path, options);
549
+ };
550
+ var getParentNode = function getParentNode(editor, at, options) {
551
+ return p.getParentNode(editor, at, options);
552
+ };
553
+ var someNode = function someNode(editor, options) {
554
+ return p.someNode(editor, options);
555
+ };
556
+ var getChildren = function getChildren(entry) {
557
+ // Node.children crashes when given a text node
558
+ if (s.Text.isText(entry[0])) {
559
+ return [];
560
+ }
561
+
562
+ return p.getChildren(entry);
563
+ };
564
+ var isFirstChild = function isFirstChild(path) {
565
+ return p.isFirstChild(path);
566
+ };
567
+ var getDescendantNodeByPath = function getDescendantNodeByPath(root, path) {
568
+ // @ts-expect-error
569
+ return s.Node.get(root, path);
570
+ };
571
+ var isRangeCollapsed = function isRangeCollapsed(range) {
572
+ return p.isCollapsed(range);
573
+ }; // TODO: simplify
574
+
575
+ var isRangeAcrossBlocks = function isRangeAcrossBlocks(editor, options) {
576
+ return p.isRangeAcrossBlocks(editor, options);
577
+ };
578
+ var isRangeExpanded = function isRangeExpanded(range) {
579
+ return p.isExpanded(range);
580
+ };
581
+ var getRange = function getRange(editor, at, to) {
582
+ return p.getRange(editor, at, to);
583
+ };
584
+ var getRangeEdges = function getRangeEdges(range) {
585
+ return s.Range.edges(range);
586
+ };
587
+ var getRangeStart = function getRangeStart(range) {
588
+ return s.Range.start(range);
589
+ };
590
+ var getRangeEnd = function getRangeEnd(range) {
591
+ return s.Range.end(range);
592
+ };
593
+ var getAboveNode = function getAboveNode(editor, opts) {
594
+ return p.getAboveNode(editor, opts);
595
+ };
596
+ var getCommonNode = function getCommonNode(root, path, another) {
597
+ return p.getCommonNode(root, path, another);
598
+ };
599
+ var getNodeTexts = function getNodeTexts(root, opts) {
600
+ return p.getNodeTexts(root, opts);
601
+ };
602
+ var findNode = function findNode(editor, options) {
603
+ return p.findNode(editor, options);
604
+ };
605
+ var isMarkActive = function isMarkActive(editor, type) {
606
+ return p.isMarkActive(editor, type);
607
+ };
608
+ var getMarks = function getMarks(editor) {
609
+ return p.getMarks(editor);
610
+ };
611
+ var isEditor = function isEditor(value) {
612
+ return p.isEditor(value);
613
+ };
614
+ var isEditorReadOnly = function isEditorReadOnly(editor) {
615
+ return p.isEditorReadOnly(editor);
616
+ };
617
+ var isElement = function isElement(value) {
618
+ return p.isElement(value);
619
+ };
620
+ var isBlockNode = function isBlockNode(editor, value) {
621
+ return p.isBlock(editor, value);
622
+ };
623
+ var findNodePath = function findNodePath(editor, node) {
624
+ return p.findNodePath(editor, node);
625
+ };
626
+ var isAncestorPath = function isAncestorPath(path, another) {
627
+ return s.Path.isAncestor(path, another);
628
+ };
629
+ var isAncestorEmpty = function isAncestorEmpty(editor, node) {
630
+ return p.isAncestorEmpty(editor, node);
631
+ };
632
+ var getParentPath = function getParentPath(path) {
633
+ return s.Path.parent(path);
634
+ };
635
+ var getNextPath = function getNextPath(path) {
636
+ return s.Path.next(path);
637
+ };
638
+ var getPreviousPath = function getPreviousPath(path) {
639
+ return s.Path.previous(path);
640
+ };
641
+ var getLastChildPath = function getLastChildPath(nodeEntry) {
642
+ return p.getLastChildPath(nodeEntry);
643
+ };
644
+ var getPathLevels = function getPathLevels(path, options) {
645
+ return s.Path.levels(path, options);
646
+ };
647
+ var isFirstChildPath = function isFirstChildPath(path) {
648
+ return p.isFirstChild(path);
649
+ };
650
+ var isLastChildPath = function isLastChildPath(entry, childPath) {
651
+ return p.isLastChild(entry, childPath);
652
+ };
653
+ var matchNode = function matchNode(node, path, fn) {
654
+ return p.match(node, path, fn);
655
+ };
656
+ var someHtmlElement = function someHtmlElement(rootNode, predicate) {
657
+ return p.someHtmlElement(rootNode, predicate);
658
+ };
659
+ var getPointBefore = function getPointBefore(editor, at, options) {
660
+ return p.getPointBefore(editor, at, options);
661
+ };
662
+ var getPointAfter = function getPointAfter(editor, at, options) {
663
+ return p.getPointAfter(editor, at, options);
664
+ };
665
+ var isEndPoint = function isEndPoint(editor, point, at) {
666
+ return p.isEndPoint(editor, point, at);
667
+ };
668
+ var isInline = function isInline(editor, value) {
669
+ return p.isInline(editor, value);
670
+ };
671
+ var queryNode = function queryNode(entry, options) {
672
+ return p.queryNode(entry, options);
673
+ };
674
+ var getPluginType = function getPluginType(editor, key) {
675
+ return p.getPluginType(editor, key);
676
+ };
677
+ var createPathRef = function createPathRef(editor, at) {
678
+ return p.createPathRef(editor, at);
679
+ };
680
+ var match = function match(obj, path, predicate) {
681
+ return p.match(obj, path, predicate);
682
+ };
683
+ var getLastNodeByLevel = function getLastNodeByLevel(editor, level) {
684
+ return p.getLastNodeByLevel(editor, level);
685
+ };
686
+
687
+ /**
688
+ * Apply editor normalization rules
689
+ */
690
+
691
+ var normalize = function normalize(editor, options) {
692
+ if (options === void 0) {
693
+ options = {
694
+ force: true
695
+ };
696
+ }
697
+
698
+ return p.normalizeEditor(editor, options);
699
+ };
700
+ /**
701
+ * Set the selection to a location
702
+ */
703
+
704
+ var setSelection = function setSelection(editor, props) {
705
+ return p.setSelection(editor, props);
706
+ };
707
+ var select = function select(editor, location) {
708
+ return p.select(editor, location);
709
+ };
710
+ var moveSelection = function moveSelection(editor, options) {
711
+ return p.moveSelection(editor, options);
712
+ };
713
+ var moveChildren = function moveChildren(editor, options) {
714
+ return p.moveChildren(editor, options);
715
+ };
716
+ var collapseSelection = function collapseSelection(editor, options) {
717
+ return p.collapseSelection(editor, options);
718
+ };
719
+ var setNodes = function setNodes(editor, attrs, opts) {
720
+ p.setNodes(editor, attrs, opts);
721
+ };
722
+ var unsetNodes = function unsetNodes(editor, props, options) {
723
+ p.unsetNodes(editor, props, options);
724
+ };
725
+ var insertNodes = function insertNodes(editor, nodes, opts) {
726
+ return p.insertNodes(editor, nodes, opts);
727
+ };
728
+ var splitNodes = function splitNodes(editor, options) {
729
+ return p.splitNodes(editor, options);
730
+ };
731
+ var liftNodes = function liftNodes(editor, options) {
732
+ return p.liftNodes(editor, options);
733
+ };
734
+ var unwrapNodes = function unwrapNodes(editor, options) {
735
+ return p.unwrapNodes(editor, options);
736
+ };
737
+ var wrapNodes = function wrapNodes(editor, element, options) {
738
+ return p.wrapNodes(editor, element, options);
739
+ };
740
+ var toggleNodeType = function toggleNodeType(editor, options, editorOptions) {
741
+ p.toggleNodeType(editor, options, editorOptions);
742
+ };
743
+ var removeMark = function removeMark(editor, type, at) {
744
+ p.removeMark(editor, {
745
+ key: type,
746
+ at: at
747
+ });
748
+ };
749
+ var unhangRange = function unhangRange(editor, range, options) {
750
+ return p.unhangRange(editor, range, options);
751
+ };
752
+ var toggleMark = function toggleMark(editor, options) {
753
+ return p.toggleMark(editor, options);
754
+ };
755
+ var addMark = function addMark(editor, type, value) {
756
+ if (value === void 0) {
757
+ value = true;
758
+ }
759
+
760
+ p.addMark(editor, type, value);
761
+ };
762
+ var insertText = function insertText(editor, text, options) {
763
+ return p.insertText(editor, text, options);
764
+ };
765
+ var deleteText = function deleteText(editor, opts) {
766
+ p.deleteText(editor, opts);
767
+ };
768
+ var removeNodes = function removeNodes(editor, opts) {
769
+ p.removeNodes(editor, opts);
770
+ };
771
+ var moveNodes = function moveNodes(editor, opts) {
772
+ p.moveNodes(editor, opts);
773
+ };
774
+ var deleteFragment = function deleteFragment(editor, options) {
775
+ return p.deleteFragment(editor, options);
776
+ };
777
+
475
778
  var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
476
779
  var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
477
780
 
478
781
  var LINK_TYPES = [Contentful.INLINES.HYPERLINK, Contentful.INLINES.ENTRY_HYPERLINK, Contentful.INLINES.ASSET_HYPERLINK];
479
782
  function isBlockSelected(editor, type) {
480
- var _Array$from = Array.from(slate.Editor.nodes(editor, {
783
+ var _Array$from = Array.from(getNodeEntries(editor, {
481
784
  match: function match(node) {
482
- return slate.Element.isElement(node) && node.type === type;
785
+ return isElement(node) && node.type === type;
483
786
  }
484
787
  })),
485
788
  match = _Array$from[0];
@@ -497,7 +800,7 @@ function getNodeEntryFromSelection(editor, nodeTypeOrTypes, path) {
497
800
  var nodeTypes = Array.isArray(nodeTypeOrTypes) ? nodeTypeOrTypes : [nodeTypeOrTypes];
498
801
 
499
802
  for (var i = 0; i < path.length; i++) {
500
- var nodeEntry = slate.Editor.node(editor, path.slice(0, i + 1));
803
+ var nodeEntry = getNodeEntry(editor, path.slice(0, i + 1));
501
804
  if (nodeTypes.includes(nodeEntry[0].type)) return nodeEntry;
502
805
  }
503
806
 
@@ -512,13 +815,13 @@ function isNodeTypeSelected(editor, nodeType) {
512
815
  return !!node;
513
816
  }
514
817
  function moveToTheNextLine(editor) {
515
- slate.Transforms.move(editor, {
818
+ moveSelection(editor, {
516
819
  distance: 1,
517
820
  unit: 'line'
518
821
  });
519
822
  }
520
823
  function moveToTheNextChar(editor) {
521
- slate.Transforms.move(editor, {
824
+ moveSelection(editor, {
522
825
  distance: 1,
523
826
  unit: 'offset'
524
827
  });
@@ -532,11 +835,11 @@ function insertEmptyParagraph(editor, options) {
532
835
  data: {},
533
836
  isVoid: false
534
837
  };
535
- slate.Transforms.insertNodes(editor, emptyParagraph, options);
838
+ insertNodes(editor, emptyParagraph, options);
536
839
  }
537
840
  function getElementFromCurrentSelection(editor) {
538
841
  if (!editor.selection) return [];
539
- return Array.from(slate.Editor.nodes(editor, {
842
+ return Array.from(getNodeEntries(editor, {
540
843
  /**
541
844
  * editor.select is a Range, which includes anchor and focus, the beginning and the end of a selection
542
845
  * when using only editor.selection.focus, we might get only the end of the selection, or where the text cursor is
@@ -544,7 +847,7 @@ function getElementFromCurrentSelection(editor) {
544
847
  **/
545
848
  at: editor.selection,
546
849
  match: function match(node) {
547
- return slate.Element.isElement(node);
850
+ return isElement(node);
548
851
  }
549
852
  })).flat();
550
853
  }
@@ -573,9 +876,9 @@ function isLinkActive(editor) {
573
876
  return false;
574
877
  }
575
878
 
576
- var _Array$from2 = Array.from(slate.Editor.nodes(editor, {
879
+ var _Array$from2 = Array.from(getNodeEntries(editor, {
577
880
  match: function match(node) {
578
- return !slate.Editor.isEditor(node) && slate.Element.isElement(node) && LINK_TYPES.includes(node.type);
881
+ return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
579
882
  }
580
883
  })),
581
884
  link = _Array$from2[0];
@@ -584,9 +887,9 @@ function isLinkActive(editor) {
584
887
  } // TODO: move to hyperlink plugin
585
888
 
586
889
  function unwrapLink(editor) {
587
- slate.Transforms.unwrapNodes(editor, {
890
+ unwrapNodes(editor, {
588
891
  match: function match(node) {
589
- return !slate.Editor.isEditor(node) && slate.Element.isElement(node) && LINK_TYPES.includes(node.type);
892
+ return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
590
893
  }
591
894
  });
592
895
  } // TODO: move to hyperlink plugin
@@ -603,7 +906,7 @@ function wrapLink(editor, _ref) {
603
906
  }
604
907
 
605
908
  var selection = editor.selection;
606
- var isCollapsed = selection && slate.Range.isCollapsed(selection);
909
+ var isCollapsed = selection && isRangeCollapsed(selection);
607
910
  var link = {
608
911
  type: type,
609
912
  data: {},
@@ -626,41 +929,41 @@ function wrapLink(editor, _ref) {
626
929
 
627
930
 
628
931
  if (path) {
629
- slate.Transforms.setNodes(editor, link, {
932
+ setNodes(editor, link, {
630
933
  at: path
631
934
  });
632
- slate.Transforms.insertText(editor, text, {
935
+ insertText(editor, text, {
633
936
  at: path
634
937
  });
635
- slate.Transforms.select(editor, path);
938
+ select(editor, path);
636
939
  } else if (isCollapsed) {
637
- slate.Transforms.insertNodes(editor, link);
940
+ insertNodes(editor, link);
638
941
  } else {
639
- slate.Transforms.wrapNodes(editor, link, {
942
+ wrapNodes(editor, link, {
640
943
  split: true
641
944
  });
642
- slate.Transforms["delete"](editor);
643
- slate.Transforms.insertText(editor, text);
644
- slate.Transforms.collapse(editor, {
945
+ deleteText(editor);
946
+ insertText(editor, text);
947
+ collapseSelection(editor, {
645
948
  edge: 'end'
646
949
  });
647
950
  }
648
951
  }
649
952
  function getAncestorPathFromSelection(editor) {
650
953
  if (!editor.selection) return undefined;
651
- return slate.Path.levels(editor.selection.focus.path).find(function (level) {
954
+ return getPathLevels(editor.selection.focus.path).find(function (level) {
652
955
  return level.length === 1;
653
956
  });
654
957
  }
655
958
  var INLINE_TYPES = /*#__PURE__*/Object.values(Contentful.INLINES);
656
959
  var isInlineOrText = function isInlineOrText(node) {
657
960
  // either text or inline elements
658
- return slate.Text.isText(node) || slate.Element.isElement(node) && INLINE_TYPES.includes(node.type);
961
+ return isText(node) || isElement(node) && INLINE_TYPES.includes(node.type);
659
962
  };
660
963
  var focus = function focus(editor) {
661
964
  var x = window.scrollX;
662
965
  var y = window.scrollY;
663
- Slate.ReactEditor.focus(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
966
+ focusEditor(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
664
967
 
665
968
  if (IS_SAFARI) {
666
969
  setTimeout(function () {
@@ -669,9 +972,9 @@ var focus = function focus(editor) {
669
972
  }
670
973
  };
671
974
  function toggleElement(editor, options, editorOptions) {
672
- plateCore.toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
975
+ toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
673
976
 
674
- slate.Transforms.setNodes(editor, {
977
+ setNodes(editor, {
675
978
  data: {}
676
979
  });
677
980
  }
@@ -1577,38 +1880,35 @@ var createNode = function createNode(nodeType, entity) {
1577
1880
  function insertBlock(editor, nodeType, entity) {
1578
1881
  if (!(editor != null && editor.selection)) return;
1579
1882
  var linkedEntityBlock = createNode(nodeType, entity);
1580
- var hasText = editor.selection && !!plateCore.getText(editor, editor.selection.focus.path);
1883
+ var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
1581
1884
 
1582
1885
  if (hasText) {
1583
- slate.Transforms.insertNodes(editor, linkedEntityBlock);
1886
+ insertNodes(editor, linkedEntityBlock);
1584
1887
  } else {
1585
- slate.Transforms.setNodes(editor, linkedEntityBlock);
1888
+ setNodes(editor, linkedEntityBlock);
1586
1889
  }
1587
1890
 
1588
1891
  focus(editor);
1589
1892
  }
1590
1893
 
1591
1894
  var removeCommand = function removeCommand(editor) {
1592
- var _getAbove = plateCore.getAbove(editor),
1593
- path = _getAbove[1];
1895
+ var _getAboveNode = getAboveNode(editor),
1896
+ path = _getAboveNode[1];
1594
1897
 
1595
- var range = slate.Editor.range(editor, path);
1596
- slate.Transforms.select(editor, range.focus.path);
1597
- plateCore.removeMark(editor, {
1598
- key: COMMAND_PROMPT,
1599
- at: range
1600
- });
1601
- slate.Transforms["delete"](editor);
1898
+ var range = getRange(editor, path);
1899
+ select(editor, range.focus.path);
1900
+ removeMark(editor, COMMAND_PROMPT, range);
1901
+ deleteText(editor);
1602
1902
  };
1603
1903
 
1604
1904
  var removeQuery = function removeQuery(editor) {
1605
- var _getAbove2 = plateCore.getAbove(editor),
1606
- path = _getAbove2[1];
1905
+ var _getAboveNode2 = getAboveNode(editor),
1906
+ path = _getAboveNode2[1];
1607
1907
 
1608
- var range = slate.Editor.range(editor, path);
1908
+ var range = getRange(editor, path);
1609
1909
 
1610
1910
  if (range.focus.offset - range.anchor.offset > 1) {
1611
- slate.Transforms["delete"](editor, {
1911
+ deleteText(editor, {
1612
1912
  at: range.focus,
1613
1913
  distance: range.focus.offset - 1,
1614
1914
  reverse: true
@@ -1649,7 +1949,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1649
1949
  var selection = editor.selection;
1650
1950
  editor.insertSoftBreak();
1651
1951
  insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ENTRY, entry.entry);
1652
- slate.Transforms.select(editor, selection);
1952
+ select(editor, selection);
1653
1953
  editor.tracking.onCommandPaletteAction('insert', {
1654
1954
  nodeType: Contentful.BLOCKS.EMBEDDED_ENTRY
1655
1955
  });
@@ -1684,7 +1984,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1684
1984
  callback: function callback() {
1685
1985
  var inlineNode = createInlineEntryNode(entry.id);
1686
1986
  removeCommand(editor);
1687
- slate.Transforms.insertNodes(editor, inlineNode);
1987
+ insertNodes(editor, inlineNode);
1688
1988
  editor.insertText('');
1689
1989
  editor.tracking.onCommandPaletteAction('insert', {
1690
1990
  nodeType: Contentful.INLINES.EMBEDDED_ENTRY
@@ -1733,7 +2033,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1733
2033
  var selection = editor.selection;
1734
2034
  editor.insertSoftBreak();
1735
2035
  insertBlock(editor, Contentful.BLOCKS.EMBEDDED_ASSET, asset.entity);
1736
- slate.Transforms.select(editor, selection);
2036
+ select(editor, selection);
1737
2037
  editor.tracking.onCommandPaletteAction('insert', {
1738
2038
  nodeType: Contentful.BLOCKS.EMBEDDED_ASSET
1739
2039
  });
@@ -2015,42 +2315,36 @@ var createOnKeyDown = function createOnKeyDown() {
2015
2315
  return function (editor) {
2016
2316
  return function (event) {
2017
2317
  if (isHotkey('/', event)) {
2018
- var _setMarks;
2019
-
2020
- plateCore.setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
2318
+ addMark(editor, COMMAND_PROMPT);
2021
2319
  editor.tracking.onCommandPaletteAction('openRichTextCommandPalette');
2022
2320
  }
2023
2321
 
2024
- var isActive = plateCore.isMarkActive(editor, COMMAND_PROMPT);
2322
+ var isActive = isMarkActive(editor, COMMAND_PROMPT);
2025
2323
 
2026
- if (isActive) {
2027
- if (isHotkey('enter', event)) {
2028
- event.preventDefault();
2029
- } else if (isHotkey('backspace', event)) {
2030
- var _getAbove = plateCore.getAbove(editor),
2031
- path = _getAbove[1];
2324
+ if (!isActive) {
2325
+ return;
2326
+ }
2032
2327
 
2033
- var range = slate.Editor.range(editor, path); // if it is the last character in the command string
2328
+ if (isHotkey('enter', event)) {
2329
+ return event.preventDefault();
2330
+ }
2034
2331
 
2035
- if (range.focus.offset - range.anchor.offset === 1) {
2036
- plateCore.removeMark(editor, {
2037
- key: COMMAND_PROMPT,
2038
- at: range
2039
- });
2040
- }
2041
- } else if (isHotkey('escape', event)) {
2042
- var _getAbove2 = plateCore.getAbove(editor),
2043
- _path = _getAbove2[1];
2332
+ var _getAboveNode = getAboveNode(editor),
2333
+ path = _getAboveNode[1];
2044
2334
 
2045
- var _range = slate.Editor.range(editor, _path);
2335
+ var range = getRange(editor, path);
2046
2336
 
2047
- plateCore.removeMark(editor, {
2048
- key: COMMAND_PROMPT,
2049
- at: _range
2050
- });
2051
- editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
2337
+ if (isHotkey('backspace', event)) {
2338
+ // if it is the last character in the command string
2339
+ if (range.focus.offset - range.anchor.offset === 1) {
2340
+ removeMark(editor, COMMAND_PROMPT, range);
2052
2341
  }
2053
2342
  }
2343
+
2344
+ if (isHotkey('escape', event)) {
2345
+ removeMark(editor, COMMAND_PROMPT, range);
2346
+ editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
2347
+ }
2054
2348
  };
2055
2349
  };
2056
2350
  };
@@ -2096,9 +2390,9 @@ function createDragAndDropPlugin() {
2096
2390
  // If true, the next handlers will be skipped.
2097
2391
  onDrop: function onDrop(editor) {
2098
2392
  return function (event) {
2099
- var _Array$from = Array.from(plateCore.getNodes(editor, {
2393
+ var _Array$from = Array.from(getNodeEntries(editor, {
2100
2394
  match: function match(node) {
2101
- return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
2395
+ return DRAGGABLE_TYPES.includes(node.type);
2102
2396
  }
2103
2397
  })),
2104
2398
  draggingBlock = _Array$from[0];
@@ -2142,7 +2436,7 @@ function withLinkTracking(Component) {
2142
2436
  return function ComponentWithTracking(props) {
2143
2437
  var editor = useContentfulEditorRef();
2144
2438
  var onEntityFetchComplete = React__default.useCallback(function () {
2145
- return editor.tracking.onViewportAction('linkRendered');
2439
+ return editor == null ? void 0 : editor.tracking.onViewportAction('linkRendered');
2146
2440
  }, [editor]);
2147
2441
  return /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
2148
2442
  onEntityFetchComplete: onEntityFetchComplete
@@ -2312,8 +2606,8 @@ function LinkedEntityBlock(props) {
2312
2606
  }, [sdk, entityId, entityType]);
2313
2607
  var handleRemoveClick = React__default.useCallback(function () {
2314
2608
  if (!editor) return;
2315
- var pathToElement = Slate.ReactEditor.findPath(editor, element);
2316
- slate.Transforms.removeNodes(editor, {
2609
+ var pathToElement = findNodePath(editor, element);
2610
+ removeNodes(editor, {
2317
2611
  at: pathToElement
2318
2612
  });
2319
2613
  }, [editor, element]);
@@ -2423,7 +2717,7 @@ function getEntityTypeFromRichTextNode(nodeType) {
2423
2717
 
2424
2718
  function selectEntityAndInsert(_x, _x2, _x3, _x4) {
2425
2719
  return _selectEntityAndInsert.apply(this, arguments);
2426
- }
2720
+ } // TODO: incorporate this logic inside the trailingParagraph plugin instead
2427
2721
 
2428
2722
  function _selectEntityAndInsert() {
2429
2723
  _selectEntityAndInsert = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(nodeType, sdk, editor, logAction) {
@@ -2459,7 +2753,7 @@ function _selectEntityAndInsert() {
2459
2753
  return _context.abrupt("return");
2460
2754
 
2461
2755
  case 12:
2462
- slate.Transforms.select(editor, selection);
2756
+ select(editor, selection);
2463
2757
  insertBlock$1(editor, nodeType, entity);
2464
2758
  ensureFollowingParagraph(editor);
2465
2759
  logAction('insert', {
@@ -2477,37 +2771,25 @@ function _selectEntityAndInsert() {
2477
2771
  }
2478
2772
 
2479
2773
  function ensureFollowingParagraph(editor) {
2480
- /*
2481
- If the new block isn't followed by a sibling paragraph we insert a new empty one
2482
- */
2483
- var next = slate.Editor.next(editor);
2774
+ var _lastNode$0$type;
2484
2775
 
2485
- if (!next) {
2486
- return insertEmptyParagraph(editor);
2487
- }
2488
-
2489
- var parent = slate.Editor.above(editor, {
2490
- voids: false,
2491
- match: function match(e) {
2492
- return !slate.Element.isElement(e) || ![Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.EMBEDDED_ENTRY].includes(e.type);
2776
+ var entityBlock = getAboveNode(editor, {
2777
+ match: {
2778
+ type: [Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.EMBEDDED_ENTRY]
2493
2779
  }
2494
2780
  });
2495
2781
 
2496
- if (slate.Editor.isEditor(parent)) {
2497
- // at level 0, a following paragraph is handled by the tralingParagraph plugin
2498
- moveToTheNextChar(editor);
2782
+ if (!entityBlock) {
2499
2783
  return;
2500
2784
  }
2501
2785
 
2502
- var paragraph = slate.Editor.above(editor, {
2503
- at: next[1],
2504
- match: function match(e) {
2505
- return slate.Element.isElement(e) && Contentful.TEXT_CONTAINERS.includes(e.type);
2506
- }
2507
- });
2786
+ var level = entityBlock[1].length - 1;
2787
+ var lastNode = getLastNodeByLevel(editor, level);
2788
+ var isTextContainer = Contentful.TEXT_CONTAINERS.includes((_lastNode$0$type = lastNode == null ? void 0 : lastNode[0].type) != null ? _lastNode$0$type : ''); // If the new block isn't followed by a sibling text container (e.g. paragraph)
2789
+ // we insert a new empty one. Level 0 is handled by the trailingParagraph plugin
2508
2790
 
2509
- if (!paragraph || !parent || !slate.Path.isChild(paragraph[1], parent[1])) {
2510
- return insertEmptyParagraph(editor);
2791
+ if (level !== 0 && !isTextContainer) {
2792
+ insertEmptyParagraph(editor);
2511
2793
  }
2512
2794
 
2513
2795
  moveToTheNextChar(editor);
@@ -2536,12 +2818,12 @@ var createNode$1 = function createNode(nodeType, entity) {
2536
2818
  function insertBlock$1(editor, nodeType, entity) {
2537
2819
  if (!(editor != null && editor.selection)) return;
2538
2820
  var linkedEntityBlock = createNode$1(nodeType, entity);
2539
- var hasText = editor.selection && !!plateCore.getText(editor, editor.selection.focus.path);
2821
+ var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
2540
2822
 
2541
2823
  if (hasText) {
2542
- slate.Transforms.insertNodes(editor, linkedEntityBlock);
2824
+ insertNodes(editor, linkedEntityBlock);
2543
2825
  } else {
2544
- slate.Transforms.setNodes(editor, linkedEntityBlock);
2826
+ setNodes(editor, linkedEntityBlock);
2545
2827
  }
2546
2828
 
2547
2829
  focus(editor);
@@ -2566,11 +2848,20 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
2566
2848
  switch (_context.prev = _context.next) {
2567
2849
  case 0:
2568
2850
  event.preventDefault();
2851
+
2852
+ if (editor) {
2853
+ _context.next = 3;
2854
+ break;
2855
+ }
2856
+
2857
+ return _context.abrupt("return");
2858
+
2859
+ case 3:
2569
2860
  onClose();
2570
- _context.next = 4;
2861
+ _context.next = 6;
2571
2862
  return selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onToolbarAction);
2572
2863
 
2573
- case 4:
2864
+ case 6:
2574
2865
  case "end":
2575
2866
  return _context.stop();
2576
2867
  }
@@ -2630,7 +2921,7 @@ function getWithEmbeddedEntityEvents(nodeType, sdk) {
2630
2921
 
2631
2922
  if (isDelete || isBackspace) {
2632
2923
  event.preventDefault();
2633
- slate.Transforms.removeNodes(editor, {
2924
+ removeNodes(editor, {
2634
2925
  at: pathToSelectedElement
2635
2926
  });
2636
2927
  }
@@ -2839,8 +3130,8 @@ function EmbeddedEntityInline(props) {
2839
3130
 
2840
3131
  function handleRemoveClick() {
2841
3132
  if (!editor) return;
2842
- var pathToElement = Slate.ReactEditor.findPath(editor, props.element);
2843
- slate.Transforms.removeNodes(editor, {
3133
+ var pathToElement = findNodePath(editor, props.element);
3134
+ removeNodes(editor, {
2844
3135
  at: pathToElement
2845
3136
  });
2846
3137
  }
@@ -2909,8 +3200,8 @@ function _selectEntityAndInsert$1() {
2909
3200
 
2910
3201
  return _context2.abrupt("return", new Promise(function (resolve) {
2911
3202
  setTimeout(function () {
2912
- slate.Transforms.setSelection(editor, selection);
2913
- slate.Transforms.insertNodes(editor, inlineEntryNode);
3203
+ setSelection(editor, selection);
3204
+ insertNodes(editor, inlineEntryNode);
2914
3205
  resolve();
2915
3206
  }, 0);
2916
3207
  }));
@@ -3121,7 +3412,7 @@ function ToolbarHeadingButton(props) {
3121
3412
  }
3122
3413
 
3123
3414
  function extractNodes(editor, path, match) {
3124
- return Array.from(plateCore.getNodes(editor, {
3415
+ return Array.from(getNodeEntries(editor, {
3125
3416
  match: match,
3126
3417
  at: path,
3127
3418
  mode: 'lowest'
@@ -3147,7 +3438,7 @@ function extractParagraphs(editor, path) {
3147
3438
 
3148
3439
  var transformRemove = function transformRemove(editor, _ref) {
3149
3440
  var path = _ref[1];
3150
- slate.Transforms.removeNodes(editor, {
3441
+ removeNodes(editor, {
3151
3442
  at: path
3152
3443
  });
3153
3444
  };
@@ -3155,20 +3446,20 @@ var transformParagraphs = function transformParagraphs(editor, entry) {
3155
3446
  var path = entry[1];
3156
3447
  var nodes = extractParagraphs(editor, path);
3157
3448
  transformRemove(editor, entry);
3158
- slate.Transforms.insertNodes(editor, nodes, {
3449
+ insertNodes(editor, nodes, {
3159
3450
  at: path
3160
3451
  });
3161
3452
  };
3162
3453
  var transformUnwrap = function transformUnwrap(editor, _ref2) {
3163
3454
  var path = _ref2[1];
3164
- slate.Transforms.unwrapNodes(editor, {
3455
+ unwrapNodes(editor, {
3165
3456
  at: path
3166
3457
  });
3167
3458
  };
3168
3459
  var transformWrapIn = function transformWrapIn(type) {
3169
3460
  return function (editor, _ref3) {
3170
3461
  var path = _ref3[1];
3171
- slate.Transforms.wrapNodes(editor, {
3462
+ wrapNodes(editor, {
3172
3463
  type: type,
3173
3464
  data: {},
3174
3465
  children: []
@@ -3179,7 +3470,7 @@ var transformWrapIn = function transformWrapIn(type) {
3179
3470
  };
3180
3471
  var transformLift = function transformLift(editor, _ref4) {
3181
3472
  var path = _ref4[1];
3182
- slate.Transforms.liftNodes(editor, {
3473
+ liftNodes(editor, {
3183
3474
  at: path
3184
3475
  });
3185
3476
  };
@@ -3258,12 +3549,12 @@ var createHeadingPlugin = function createHeadingPlugin() {
3258
3549
  // insertBreak implementation
3259
3550
  filter: function filter(_ref3) {
3260
3551
  var path = _ref3[1];
3261
- return !plateCore.getAbove(editor, {
3552
+ return !getAboveNode(editor, {
3262
3553
  at: path,
3263
3554
  match: {
3264
3555
  type: Contentful.BLOCKS.LIST_ITEM
3265
3556
  }
3266
- }) && !plateCore.isMarkActive(editor, COMMAND_PROMPT);
3557
+ }) && !isMarkActive(editor, COMMAND_PROMPT);
3267
3558
  }
3268
3559
  }
3269
3560
  }]
@@ -3358,7 +3649,7 @@ function withHrEvents(editor) {
3358
3649
 
3359
3650
  if (isBackspace || isDelete) {
3360
3651
  event.preventDefault();
3361
- slate.Transforms.removeNodes(editor, {
3652
+ removeNodes(editor, {
3362
3653
  at: pathToSelectedHr
3363
3654
  });
3364
3655
  }
@@ -3378,8 +3669,8 @@ function ToolbarHrButton(props) {
3378
3669
  }],
3379
3670
  isVoid: true
3380
3671
  };
3381
- var hasText = !!plateCore.getText(editor, editor.selection.focus.path);
3382
- hasText ? slate.Transforms.insertNodes(editor, hr) : plateCore.setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
3672
+ var hasText = !!getText(editor, editor.selection.focus.path);
3673
+ hasText ? insertNodes(editor, hr) : setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
3383
3674
 
3384
3675
  moveToTheNextLine(editor);
3385
3676
  focus(editor);
@@ -3665,7 +3956,7 @@ function _addOrEditLink() {
3665
3956
  while (1) {
3666
3957
  switch (_context3.prev = _context3.next) {
3667
3958
  case 0:
3668
- isReadOnly = Slate.ReactEditor.isReadOnly(editor);
3959
+ isReadOnly = isEditorReadOnly(editor);
3669
3960
  selectionBeforeBlur = editor.selection ? _extends({}, editor.selection) : undefined;
3670
3961
 
3671
3962
  if (!(!targetPath && !selectionBeforeBlur)) {
@@ -3680,13 +3971,13 @@ function _addOrEditLink() {
3680
3971
 
3681
3972
  if (node && path) {
3682
3973
  linkType = node.type;
3683
- linkText = slate.Editor.string(editor, path);
3974
+ linkText = getText(editor, path);
3684
3975
  linkTarget = node.data.uri || '';
3685
3976
  linkEntity = node.data.target;
3686
3977
  }
3687
3978
 
3688
3979
  selectionAfterFocus = targetPath != null ? targetPath : selectionBeforeBlur;
3689
- currentLinkText = linkText || (editor.selection ? slate.Editor.string(editor, editor.selection) : '');
3980
+ currentLinkText = linkText || (editor.selection ? getText(editor, editor.selection) : '');
3690
3981
  isEditing = Boolean(node && path);
3691
3982
  logAction(isEditing ? 'openEditHyperlinkDialog' : 'openCreateHyperlinkDialog');
3692
3983
  _context3.next = 12;
@@ -3711,7 +4002,7 @@ function _addOrEditLink() {
3711
4002
 
3712
4003
  case 12:
3713
4004
  data = _context3.sent;
3714
- slate.Transforms.select(editor, selectionAfterFocus);
4005
+ select(editor, selectionAfterFocus);
3715
4006
 
3716
4007
  if (data) {
3717
4008
  _context3.next = 18;
@@ -3724,7 +4015,7 @@ function _addOrEditLink() {
3724
4015
 
3725
4016
  case 18:
3726
4017
  text = data.linkText, url = data.linkTarget, type = data.linkType, target = data.linkEntity;
3727
- slate.Editor.withoutNormalizing(editor, function () {
4018
+ withoutNormalizing(editor, function () {
3728
4019
  insertLink(editor, {
3729
4020
  text: text,
3730
4021
  url: url,
@@ -3801,8 +4092,9 @@ function ToolbarHyperlinkButton(props) {
3801
4092
  }
3802
4093
 
3803
4094
  var hasText = function hasText(editor, entry) {
3804
- var node = entry[0];
3805
- return !plateCore.isAncestorEmpty(editor, node) && slate.Node.string(node).trim() !== '';
4095
+ var node = entry[0],
4096
+ path = entry[1];
4097
+ return !p.isAncestorEmpty(editor, node) && getText(editor, path).trim() !== '';
3806
4098
  };
3807
4099
 
3808
4100
  function truncate(str, length) {
@@ -3993,11 +4285,11 @@ function EntityHyperlink(props) {
3993
4285
  event.preventDefault();
3994
4286
  event.stopPropagation();
3995
4287
  if (!editor) return;
3996
- var p = Slate.ReactEditor.toSlatePoint(editor, [event.target, 0], {
3997
- exactMatch: false,
3998
- suppressThrow: false
3999
- });
4000
- addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4288
+ var p = fromDOMPoint(editor, [event.target, 0]);
4289
+
4290
+ if (p) {
4291
+ addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4292
+ }
4001
4293
  }
4002
4294
 
4003
4295
  return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
@@ -4023,11 +4315,11 @@ function UrlHyperlink(props) {
4023
4315
  event.preventDefault();
4024
4316
  event.stopPropagation();
4025
4317
  if (!editor) return;
4026
- var p = Slate.ReactEditor.toSlatePoint(editor, [event.target, 0], {
4318
+ var p = fromDOMPoint(editor, [event.target, 0], {
4027
4319
  exactMatch: false,
4028
4320
  suppressThrow: false
4029
4321
  });
4030
- addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4322
+ addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p == null ? void 0 : p.path);
4031
4323
  }
4032
4324
 
4033
4325
  return /*#__PURE__*/React.createElement(f36Components.Tooltip, {
@@ -4199,27 +4491,28 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
4199
4491
  var previousListItemPath;
4200
4492
 
4201
4493
  try {
4202
- previousListItemPath = slate.Path.previous(listItemPath);
4494
+ previousListItemPath = getPreviousPath(listItemPath);
4203
4495
  } catch (e) {
4204
4496
  return;
4205
4497
  } // Previous sibling is the new parent
4206
4498
 
4207
4499
 
4208
- var previousSiblingItem = slate.Editor.node(editor, previousListItemPath);
4500
+ var previousSiblingItem = getNodeEntry(editor, previousListItemPath);
4209
4501
 
4210
4502
  if (previousSiblingItem) {
4211
4503
  var previousPath = previousSiblingItem[1];
4212
- var subList = Array.from(slate.Node.children(editor, previousPath)).find(function (_ref2) {
4213
- var n = _ref2[0];
4214
- return plateCore.match(n, {
4504
+ var subList = Array.from(getNodeChildren(editor, previousPath)).find(function (_ref2) {
4505
+ var n = _ref2[0],
4506
+ path = _ref2[1];
4507
+ return match(n, path, {
4215
4508
  type: plateList.getListTypes(editor)
4216
4509
  });
4217
4510
  });
4218
- var newPath = slate.Path.next(plateCore.getLastChildPath(subList != null ? subList : previousSiblingItem));
4219
- slate.Editor.withoutNormalizing(editor, function () {
4511
+ var newPath = getNextPath(getLastChildPath(subList != null ? subList : previousSiblingItem));
4512
+ withoutNormalizing(editor, function () {
4220
4513
  if (!subList) {
4221
4514
  // Create new sub-list
4222
- plateCore.wrapNodes(editor, {
4515
+ wrapNodes(editor, {
4223
4516
  type: listNode.type,
4224
4517
  children: [],
4225
4518
  data: {}
@@ -4229,7 +4522,7 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
4229
4522
  } // Move the current item to the sub-list
4230
4523
 
4231
4524
 
4232
- slate.Transforms.moveNodes(editor, {
4525
+ moveNodes(editor, {
4233
4526
  at: listItemPath,
4234
4527
  to: newPath
4235
4528
  });
@@ -4250,10 +4543,10 @@ var moveListItems = function moveListItems(editor, _temp) {
4250
4543
  _ref$at = _ref.at,
4251
4544
  at = _ref$at === void 0 ? (_editor$selection = editor.selection) != null ? _editor$selection : undefined : _ref$at;
4252
4545
 
4253
- var _nodes = plateCore.getNodes(editor, {
4546
+ var _nodes = getNodeEntries(editor, {
4254
4547
  at: at,
4255
4548
  match: {
4256
- type: plateCore.getPluginType(editor, plateList.ELEMENT_LIC)
4549
+ type: getPluginType(editor, plateList.ELEMENT_LIC)
4257
4550
  }
4258
4551
  }); // Get the selected lic
4259
4552
 
@@ -4265,19 +4558,19 @@ var moveListItems = function moveListItems(editor, _temp) {
4265
4558
 
4266
4559
  lics.forEach(function (lic) {
4267
4560
  var licPath = lic[1];
4268
- var liPath = slate.Path.parent(licPath);
4561
+ var liPath = getParentPath(licPath);
4269
4562
  var isAncestor = highestLicPaths.some(function (path) {
4270
- var highestLiPath = slate.Path.parent(path);
4271
- return slate.Path.isAncestor(highestLiPath, liPath);
4563
+ var highestLiPath = getParentPath(path);
4564
+ return isAncestorPath(highestLiPath, liPath);
4272
4565
  });
4273
4566
 
4274
4567
  if (!isAncestor) {
4275
4568
  highestLicPaths.push(licPath);
4276
- highestLicPathRefs.push(slate.Editor.pathRef(editor, licPath));
4569
+ highestLicPathRefs.push(createPathRef(editor, licPath));
4277
4570
  }
4278
4571
  });
4279
4572
  var licPathRefsToMove = increase ? highestLicPathRefs : highestLicPathRefs.reverse();
4280
- slate.Editor.withoutNormalizing(editor, function () {
4573
+ withoutNormalizing(editor, function () {
4281
4574
  licPathRefsToMove.forEach(function (licPathRef) {
4282
4575
  var licPath = licPathRef.unref();
4283
4576
  if (!licPath) return;
@@ -4298,16 +4591,18 @@ var moveListItems = function moveListItems(editor, _temp) {
4298
4591
  });
4299
4592
  };
4300
4593
 
4594
+ var ELEMENT_DEFAULT = p.ELEMENT_DEFAULT;
4595
+
4301
4596
  /**
4302
4597
  * Credit: Modified version of Plate's list plugin
4303
4598
  * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
4304
4599
  */
4305
4600
 
4306
4601
  function hasUnliftedListItems(editor, at) {
4307
- return slate.Editor.nodes(editor, {
4602
+ return getNodeEntries(editor, {
4308
4603
  at: at,
4309
4604
  match: function match(node, path) {
4310
- return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM && path.length >= 2;
4605
+ return isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM && path.length >= 2;
4311
4606
  }
4312
4607
  }).next().done;
4313
4608
  }
@@ -4316,20 +4611,20 @@ var unwrapList = function unwrapList(editor, _temp) {
4316
4611
  var _ref = _temp === void 0 ? {} : _temp,
4317
4612
  at = _ref.at;
4318
4613
 
4319
- slate.Editor.withoutNormalizing(editor, function () {
4614
+ withoutNormalizing(editor, function () {
4320
4615
  do {
4321
4616
  // lift list items to the root level
4322
- slate.Transforms.liftNodes(editor, {
4617
+ liftNodes(editor, {
4323
4618
  at: at,
4324
4619
  match: function match(node) {
4325
- return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM;
4620
+ return isElement(node) && node.type === Contentful.BLOCKS.LIST_ITEM;
4326
4621
  },
4327
4622
  mode: 'lowest'
4328
4623
  });
4329
4624
  } while (!hasUnliftedListItems(editor, at)); // finally unwrap all lifted items
4330
4625
 
4331
4626
 
4332
- plateCore.unwrapNodes(editor, {
4627
+ unwrapNodes(editor, {
4333
4628
  at: at,
4334
4629
  match: {
4335
4630
  type: Contentful.BLOCKS.LIST_ITEM
@@ -4342,12 +4637,12 @@ var unwrapList = function unwrapList(editor, _temp) {
4342
4637
  var listTypes = [Contentful.BLOCKS.UL_LIST, Contentful.BLOCKS.OL_LIST];
4343
4638
  var toggleList = function toggleList(editor, _ref) {
4344
4639
  var type = _ref.type;
4345
- return slate.Editor.withoutNormalizing(editor, function () {
4640
+ return withoutNormalizing(editor, function () {
4346
4641
  if (!editor.selection) {
4347
4642
  return;
4348
4643
  }
4349
4644
 
4350
- if (plateCore.isCollapsed(editor.selection) || !plateCore.isRangeAcrossBlocks(editor)) {
4645
+ if (isRangeCollapsed(editor.selection) || !isRangeAcrossBlocks(editor)) {
4351
4646
  // selection is collapsed
4352
4647
  var res = plateList.getListItemEntry(editor);
4353
4648
 
@@ -4355,7 +4650,7 @@ var toggleList = function toggleList(editor, _ref) {
4355
4650
  var list = res.list;
4356
4651
 
4357
4652
  if (list[0].type !== type) {
4358
- plateCore.setNodes(editor, {
4653
+ setNodes(editor, {
4359
4654
  type: type
4360
4655
  }, {
4361
4656
  at: editor.selection,
@@ -4373,10 +4668,10 @@ var toggleList = function toggleList(editor, _ref) {
4373
4668
  children: [],
4374
4669
  data: {}
4375
4670
  };
4376
- plateCore.wrapNodes(editor, _list);
4377
- var nodes = [].concat(plateCore.getNodes(editor, {
4671
+ wrapNodes(editor, _list);
4672
+ var nodes = [].concat(getNodeEntries(editor, {
4378
4673
  match: {
4379
- type: plateCore.getPluginType(editor, plateCore.ELEMENT_DEFAULT)
4674
+ type: getPluginType(editor, ELEMENT_DEFAULT)
4380
4675
  }
4381
4676
  }));
4382
4677
  var listItem = {
@@ -4388,36 +4683,38 @@ var toggleList = function toggleList(editor, _ref) {
4388
4683
  for (var _iterator = _createForOfIteratorHelperLoose(nodes), _step; !(_step = _iterator()).done;) {
4389
4684
  var _step$value = _step.value,
4390
4685
  path = _step$value[1];
4391
- plateCore.wrapNodes(editor, listItem, {
4686
+ wrapNodes(editor, listItem, {
4392
4687
  at: path
4393
4688
  });
4394
4689
  }
4395
4690
  }
4396
4691
  } else {
4397
4692
  // selection is a range
4398
- var _Range$edges = slate.Range.edges(editor.selection),
4399
- startPoint = _Range$edges[0],
4400
- endPoint = _Range$edges[1];
4693
+ var _getRangeEdges = getRangeEdges(editor.selection),
4694
+ startPoint = _getRangeEdges[0],
4695
+ endPoint = _getRangeEdges[1];
4401
4696
 
4402
- var commonEntry = slate.Node.common(editor, startPoint.path, endPoint.path);
4697
+ var commonEntry = getCommonNode(editor, startPoint.path, endPoint.path);
4403
4698
 
4404
4699
  if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === Contentful.BLOCKS.LIST_ITEM) {
4405
4700
  var listType = commonEntry[0].type;
4406
4701
 
4407
4702
  if (commonEntry[0].type === Contentful.BLOCKS.LIST_ITEM) {
4408
- listType = slate.Editor.parent(editor, commonEntry[1])[0].type;
4703
+ var _getParentNode, _getParentNode$;
4704
+
4705
+ listType = (_getParentNode = getParentNode(editor, commonEntry[1])) == null ? void 0 : (_getParentNode$ = _getParentNode[0]) == null ? void 0 : _getParentNode$.type;
4409
4706
  }
4410
4707
 
4411
4708
  if (listType !== type) {
4412
- var startList = plateCore.findNode(editor, {
4413
- at: slate.Range.start(editor.selection),
4709
+ var startList = findNode(editor, {
4710
+ at: getRangeStart(editor.selection),
4414
4711
  match: {
4415
4712
  type: listTypes
4416
4713
  },
4417
4714
  mode: 'lowest'
4418
4715
  });
4419
- var endList = plateCore.findNode(editor, {
4420
- at: slate.Range.end(editor.selection),
4716
+ var endList = findNode(editor, {
4717
+ at: getRangeEnd(editor.selection),
4421
4718
  match: {
4422
4719
  type: listTypes
4423
4720
  },
@@ -4429,7 +4726,7 @@ var toggleList = function toggleList(editor, _ref) {
4429
4726
  }
4430
4727
 
4431
4728
  var rangeLength = Math.min(startList[1].length, endList[1].length);
4432
- plateCore.setNodes(editor, {
4729
+ setNodes(editor, {
4433
4730
  type: type
4434
4731
  }, {
4435
4732
  at: editor.selection,
@@ -4444,7 +4741,7 @@ var toggleList = function toggleList(editor, _ref) {
4444
4741
  } else {
4445
4742
  var rootPathLength = commonEntry[1].length;
4446
4743
 
4447
- var _nodes = Array.from(plateCore.getNodes(editor, {
4744
+ var _nodes = Array.from(getNodeEntries(editor, {
4448
4745
  mode: 'all'
4449
4746
  })).filter(function (_ref2) {
4450
4747
  var path = _ref2[1];
@@ -4453,14 +4750,14 @@ var toggleList = function toggleList(editor, _ref) {
4453
4750
 
4454
4751
  _nodes.forEach(function (n) {
4455
4752
  if (listTypes.includes(n[0].type)) {
4456
- plateCore.setNodes(editor, {
4753
+ setNodes(editor, {
4457
4754
  type: type
4458
4755
  }, {
4459
4756
  at: n[1]
4460
4757
  });
4461
4758
  } else {
4462
- plateCore.setNodes(editor, {
4463
- type: plateCore.getPluginType(editor, plateList.ELEMENT_LIC)
4759
+ setNodes(editor, {
4760
+ type: getPluginType(editor, plateList.ELEMENT_LIC)
4464
4761
  }, {
4465
4762
  at: n[1]
4466
4763
  });
@@ -4469,7 +4766,7 @@ var toggleList = function toggleList(editor, _ref) {
4469
4766
  children: [],
4470
4767
  data: {}
4471
4768
  };
4472
- plateCore.wrapNodes(editor, _listItem, {
4769
+ wrapNodes(editor, _listItem, {
4473
4770
  at: n[1]
4474
4771
  });
4475
4772
  var _list2 = {
@@ -4477,7 +4774,7 @@ var toggleList = function toggleList(editor, _ref) {
4477
4774
  children: [],
4478
4775
  data: {}
4479
4776
  };
4480
- plateCore.wrapNodes(editor, _list2, {
4777
+ wrapNodes(editor, _list2, {
4481
4778
  at: n[1]
4482
4779
  });
4483
4780
  }
@@ -4492,7 +4789,7 @@ var onKeyDownList = function onKeyDownList(editor, _ref) {
4492
4789
  hotkey = _ref.options.hotkey;
4493
4790
  return function (e) {
4494
4791
  if (e.key === 'Tab' && editor.selection) {
4495
- var listSelected = plateCore.getAbove(editor, {
4792
+ var listSelected = getAboveNode(editor, {
4496
4793
  at: editor.selection,
4497
4794
  match: {
4498
4795
  type: type
@@ -4530,14 +4827,14 @@ var isList = function isList(node) {
4530
4827
  var hasListAsDirectParent = function hasListAsDirectParent(editor, _ref) {
4531
4828
  var path = _ref[1];
4532
4829
 
4533
- var _ref2 = plateCore.getParent(editor, path) || [],
4830
+ var _ref2 = p.getParentNode(editor, path) || [],
4534
4831
  parentNode = _ref2[0];
4535
4832
 
4536
4833
  return isList(parentNode);
4537
4834
  };
4538
4835
 
4539
4836
  var getNearestListAncestor = function getNearestListAncestor(editor, path) {
4540
- return plateCore.getAbove(editor, {
4837
+ return p.getAboveNode(editor, {
4541
4838
  at: path,
4542
4839
  mode: 'lowest',
4543
4840
  match: isList
@@ -4557,7 +4854,7 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
4557
4854
  parentList = _getNearestListAncest[0];
4558
4855
 
4559
4856
  var parentListType = parentList == null ? void 0 : parentList.type;
4560
- slate.Transforms.wrapNodes(editor, {
4857
+ wrapNodes(editor, {
4561
4858
  type: parentListType || Contentful.BLOCKS.UL_LIST,
4562
4859
  children: [],
4563
4860
  data: {}
@@ -4565,24 +4862,23 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
4565
4862
  at: path
4566
4863
  });
4567
4864
  };
4568
- var isNonEmptyListItem = function isNonEmptyListItem(editor, _ref4) {
4569
- var path = _ref4[1];
4570
- var listItemChildren = Array.from(slate.Node.children(editor, path));
4865
+ var isNonEmptyListItem = function isNonEmptyListItem(_, entry) {
4866
+ var listItemChildren = getChildren(entry);
4571
4867
  return listItemChildren.length !== 0;
4572
4868
  };
4573
- var firstNodeIsNotList = function firstNodeIsNotList(_editor, _ref5) {
4574
- var node = _ref5[0];
4869
+ var firstNodeIsNotList = function firstNodeIsNotList(_editor, _ref4) {
4870
+ var node = _ref4[0];
4575
4871
 
4576
4872
  if (node.children.length === 1) {
4577
4873
  var firstNode = node.children[0];
4578
- return !slate.Text.isText(firstNode) && !isList(firstNode);
4874
+ return !isText(firstNode) && !isList(firstNode);
4579
4875
  }
4580
4876
 
4581
4877
  return true;
4582
4878
  };
4583
- var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref6) {
4584
- var path = _ref6[1];
4585
- slate.Transforms.insertNodes(editor, [{
4879
+ var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref5) {
4880
+ var path = _ref5[1];
4881
+ insertNodes(editor, [{
4586
4882
  type: Contentful.BLOCKS.PARAGRAPH,
4587
4883
  data: {},
4588
4884
  children: [{
@@ -4595,10 +4891,10 @@ var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref6) {
4595
4891
  var replaceNodeWithListItems = function replaceNodeWithListItems(editor, entry) {
4596
4892
  var node = entry[0],
4597
4893
  path = entry[1];
4598
- slate.Transforms.removeNodes(editor, {
4894
+ removeNodes(editor, {
4599
4895
  at: path
4600
4896
  });
4601
- slate.Transforms.insertNodes(editor, node.children[0].children, {
4897
+ insertNodes(editor, node.children[0].children, {
4602
4898
  at: path
4603
4899
  });
4604
4900
  };
@@ -4609,12 +4905,12 @@ var isListTypeActive = function isListTypeActive(editor, type) {
4609
4905
  return false;
4610
4906
  }
4611
4907
 
4612
- if (slate.Range.isExpanded(selection)) {
4613
- var _Range$edges = slate.Range.edges(selection),
4614
- start = _Range$edges[0],
4615
- end = _Range$edges[1];
4908
+ if (isRangeExpanded(selection)) {
4909
+ var _getRangeEdges = getRangeEdges(selection),
4910
+ start = _getRangeEdges[0],
4911
+ end = _getRangeEdges[1];
4616
4912
 
4617
- var node = slate.Node.common(editor, start.path, end.path);
4913
+ var node = getCommonNode(editor, start.path, end.path);
4618
4914
 
4619
4915
  if (node[0].type === type) {
4620
4916
  return true;
@@ -4622,7 +4918,7 @@ var isListTypeActive = function isListTypeActive(editor, type) {
4622
4918
  } // Lists can be nested. Here, we take the list type at the lowest level
4623
4919
 
4624
4920
 
4625
- var listNode = plateCore.getBlockAbove(editor, {
4921
+ var listNode = p.getBlockAbove(editor, {
4626
4922
  match: {
4627
4923
  type: [Contentful.BLOCKS.OL_LIST, Contentful.BLOCKS.UL_LIST]
4628
4924
  },
@@ -4643,7 +4939,7 @@ var emptyListItemNode = function emptyListItemNode(editor, withChildren) {
4643
4939
  var children = [];
4644
4940
 
4645
4941
  if (withChildren) {
4646
- var marks = slate.Editor.marks(editor) || {};
4942
+ var marks = getMarks(editor) || {};
4647
4943
  children = [{
4648
4944
  type: Contentful.BLOCKS.PARAGRAPH,
4649
4945
  data: {},
@@ -4670,7 +4966,7 @@ var insertListItem = function insertListItem(editor) {
4670
4966
  } // Naming it paragraph for simplicity but can be a heading as well
4671
4967
 
4672
4968
 
4673
- var paragraph = plateCore.getAbove(editor, {
4969
+ var paragraph = getAboveNode(editor, {
4674
4970
  match: {
4675
4971
  type: Contentful.TEXT_CONTAINERS
4676
4972
  }
@@ -4681,7 +4977,7 @@ var insertListItem = function insertListItem(editor) {
4681
4977
  }
4682
4978
 
4683
4979
  var paragraphPath = paragraph[1];
4684
- var listItem = plateCore.getParent(editor, paragraphPath);
4980
+ var listItem = getParentNode(editor, paragraphPath);
4685
4981
 
4686
4982
  if (!listItem) {
4687
4983
  return false;
@@ -4695,30 +4991,30 @@ var insertListItem = function insertListItem(editor) {
4695
4991
  } // We are in a li>p (or heading)
4696
4992
 
4697
4993
 
4698
- slate.Editor.withoutNormalizing(editor, function () {
4994
+ withoutNormalizing(editor, function () {
4699
4995
  if (!editor.selection) {
4700
4996
  return;
4701
4997
  } // Check the cursor position in the current paragraph
4702
4998
 
4703
4999
 
4704
- var isAtStart = plateCore.isSelectionAtBlockStart(editor);
4705
- var isAtEnd = plateCore.isSelectionAtBlockEnd(editor);
4706
- var isAtStartOfListItem = isAtStart && plateCore.isFirstChild(paragraphPath);
5000
+ var isAtStart = isSelectionAtBlockStart(editor);
5001
+ var isAtEnd = isSelectionAtBlockEnd(editor);
5002
+ var isAtStartOfListItem = isAtStart && isFirstChildPath(paragraphPath);
4707
5003
  var shouldSplit = !isAtStart && !isAtEnd; // Split the current paragraph content if necessary
4708
5004
 
4709
5005
  if (shouldSplit) {
4710
- slate.Transforms.splitNodes(editor);
5006
+ splitNodes(editor);
4711
5007
  } // Insert the new li
4712
5008
 
4713
5009
 
4714
- var newListItemPath = isAtStartOfListItem ? listItemPath : slate.Path.next(listItemPath);
4715
- plateCore.insertNodes(editor, // Add an empty paragraph to the new li if We will not move some
5010
+ var newListItemPath = isAtStartOfListItem ? listItemPath : getNextPath(listItemPath);
5011
+ insertNodes(editor, // Add an empty paragraph to the new li if We will not move some
4716
5012
  // paragraphs over there.
4717
5013
  emptyListItemNode(editor, !shouldSplit), {
4718
5014
  at: newListItemPath
4719
5015
  }); // Move children *after* selection to the new li
4720
5016
 
4721
- var fromPath = isAtStart ? paragraphPath : slate.Path.next(paragraphPath);
5017
+ var fromPath = isAtStart ? paragraphPath : getNextPath(paragraphPath);
4722
5018
  var fromStartIndex = fromPath[fromPath.length - 1] || 0; // On split we don't add paragraph to the new li so we move
4723
5019
  // content to the very beginning. Otherwise, account for the empty
4724
5020
  // paragraph at the beginning by moving the content after
@@ -4726,7 +5022,7 @@ var insertListItem = function insertListItem(editor) {
4726
5022
  var toPath = newListItemPath.concat([shouldSplit ? 0 : 1]);
4727
5023
 
4728
5024
  if (!isAtStartOfListItem) {
4729
- plateCore.moveChildren(editor, {
5025
+ moveChildren(editor, {
4730
5026
  at: listItemPath,
4731
5027
  to: toPath,
4732
5028
  fromStartIndex: fromStartIndex
@@ -4734,8 +5030,8 @@ var insertListItem = function insertListItem(editor) {
4734
5030
  } // Move cursor to the start of the new li
4735
5031
 
4736
5032
 
4737
- slate.Transforms.select(editor, newListItemPath);
4738
- slate.Transforms.collapse(editor, {
5033
+ select(editor, newListItemPath);
5034
+ collapseSelection(editor, {
4739
5035
  edge: 'start'
4740
5036
  });
4741
5037
  }); // Returning True skips processing other editor.insertBreak handlers
@@ -4760,7 +5056,7 @@ var listBreak = function listBreak(editor) {
4760
5056
  listItem = res.listItem;
4761
5057
  var childNode = listItem[0].children[0]; // If selected li is empty, move it up.
4762
5058
 
4763
- if (plateCore.isBlockAboveEmpty(editor) && listItem[0].children.length === 1 && Contentful.TEXT_CONTAINERS.includes(childNode.type)) {
5059
+ if (p.isBlockAboveEmpty(editor) && listItem[0].children.length === 1 && Contentful.TEXT_CONTAINERS.includes(childNode.type)) {
4764
5060
  moved = plateList.moveListItemUp(editor, {
4765
5061
  list: list,
4766
5062
  listItem: listItem
@@ -4769,13 +5065,13 @@ var listBreak = function listBreak(editor) {
4769
5065
  }
4770
5066
  }
4771
5067
 
4772
- var didReset = plateResetNode.onKeyDownResetNode(editor, plateCore.mockPlugin({
5068
+ var didReset = plateResetNode.onKeyDownResetNode(editor, p.mockPlugin({
4773
5069
  options: {
4774
5070
  rules: [{
4775
- types: [plateCore.getPluginType(editor, plateList.ELEMENT_LI)],
4776
- defaultType: plateCore.getPluginType(editor, plateCore.ELEMENT_DEFAULT),
5071
+ types: [p.getPluginType(editor, plateList.ELEMENT_LI)],
5072
+ defaultType: p.getPluginType(editor, p.ELEMENT_DEFAULT),
4777
5073
  predicate: function predicate() {
4778
- return !moved && plateCore.isBlockAboveEmpty(editor);
5074
+ return !moved && p.isBlockAboveEmpty(editor);
4779
5075
  },
4780
5076
  onReset: function onReset(_editor) {
4781
5077
  return plateList.unwrapList(_editor);
@@ -4814,13 +5110,13 @@ var insertListBreak = function insertListBreak(editor) {
4814
5110
  */
4815
5111
 
4816
5112
  var getFirstAncestorOfType = function getFirstAncestorOfType(root, entry) {
4817
- var ancestor = slate.Path.parent(entry[1]);
5113
+ var ancestor = getParentPath(entry[1]);
4818
5114
 
4819
- while (slate.Node.get(root, ancestor).type !== Contentful.BLOCKS.LIST_ITEM) {
4820
- ancestor = slate.Path.parent(ancestor);
5115
+ while (getDescendantNodeByPath(root, ancestor).type !== Contentful.BLOCKS.LIST_ITEM) {
5116
+ ancestor = getParentPath(ancestor);
4821
5117
  }
4822
5118
 
4823
- return [slate.Node.get(root, ancestor), ancestor];
5119
+ return [getDescendantNodeByPath(root, ancestor), ancestor];
4824
5120
  };
4825
5121
 
4826
5122
  var isListRoot = function isListRoot(node) {
@@ -4838,9 +5134,9 @@ var trimList = function trimList(listRoot) {
4838
5134
  return [listRoot];
4839
5135
  }
4840
5136
 
4841
- var textEntries = Array.from(slate.Node.texts(listRoot));
5137
+ var textEntries = Array.from(getNodeTexts(listRoot));
4842
5138
  var commonAncestorEntry = textEntries.reduce(function (commonAncestor, textEntry) {
4843
- return slate.Path.isAncestor(commonAncestor[1], textEntry[1]) ? commonAncestor : slate.Node.common(listRoot, textEntry[1], commonAncestor[1]);
5139
+ return isAncestorPath(commonAncestor[1], textEntry[1]) ? commonAncestor : getCommonNode(listRoot, textEntry[1], commonAncestor[1]);
4844
5140
  }, // any list item would do, we grab the first one
4845
5141
  getFirstAncestorOfType(listRoot, textEntries[0]));
4846
5142
  return isListRoot(commonAncestorEntry[0]) ? commonAncestorEntry[0].children : [commonAncestorEntry[0]];
@@ -4881,7 +5177,7 @@ var insertListFragment = function insertListFragment(editor) {
4881
5177
  return;
4882
5178
  }
4883
5179
 
4884
- var liEntry = plateCore.findNode(editor, {
5180
+ var liEntry = p.findNode(editor, {
4885
5181
  match: {
4886
5182
  type: Contentful.BLOCKS.LIST_ITEM
4887
5183
  },
@@ -4893,7 +5189,7 @@ var insertListFragment = function insertListFragment(editor) {
4893
5189
  return trimList(node);
4894
5190
  })));
4895
5191
  var firstBlockIndex = nodes.findIndex(function (node) {
4896
- return slate.Editor.isBlock(editor, node);
5192
+ return isBlockNode(editor, node);
4897
5193
  });
4898
5194
 
4899
5195
  if (firstBlockIndex < 0) {
@@ -4905,11 +5201,11 @@ var insertListFragment = function insertListFragment(editor) {
4905
5201
  // after a text or inline element occurrence will be unwrapped for
4906
5202
  // some reason.
4907
5203
 
4908
- slate.Transforms.insertNodes(editor, inlines, {
5204
+ insertNodes(editor, inlines, {
4909
5205
  at: editor.selection,
4910
5206
  select: true
4911
5207
  });
4912
- return slate.Transforms.insertNodes(editor, blocks, {
5208
+ return insertNodes(editor, blocks, {
4913
5209
  at: editor.selection,
4914
5210
  select: true
4915
5211
  });
@@ -4934,12 +5230,12 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4934
5230
  var list = res.list,
4935
5231
  listItem = res.listItem;
4936
5232
 
4937
- if (plateCore.isSelectionAtBlockStart(editor, {
5233
+ if (isSelectionAtBlockStart(editor, {
4938
5234
  match: function match(node) {
4939
5235
  return node.type === Contentful.BLOCKS.LIST_ITEM;
4940
5236
  }
4941
5237
  })) {
4942
- slate.Editor.withoutNormalizing(editor, function () {
5238
+ withoutNormalizing(editor, function () {
4943
5239
  moved = plateList.removeFirstListItem(editor, {
4944
5240
  list: list,
4945
5241
  listItem: listItem
@@ -4951,15 +5247,17 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4951
5247
  });
4952
5248
  if (moved) return;
4953
5249
 
4954
- if (plateCore.isFirstChild(listItem[1]) && !plateList.isListNested(editor, list[1])) {
4955
- plateResetNode.onKeyDownResetNode(editor, plateCore.mockPlugin({
5250
+ if (isFirstChild(listItem[1]) && !plateList.isListNested(editor, list[1])) {
5251
+ plateResetNode.onKeyDownResetNode(editor, // TODO look into this
5252
+ // @ts-expect-error
5253
+ mockPlugin({
4956
5254
  options: {
4957
5255
  rules: [{
4958
5256
  types: [Contentful.BLOCKS.LIST_ITEM],
4959
5257
  defaultType: Contentful.BLOCKS.PARAGRAPH,
4960
5258
  hotkey: 'backspace',
4961
5259
  predicate: function predicate() {
4962
- return plateCore.isSelectionAtBlockStart(editor);
5260
+ return isSelectionAtBlockStart(editor);
4963
5261
  },
4964
5262
  onReset: function onReset(e) {
4965
5263
  return unwrapList(e);
@@ -4971,7 +5269,9 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4971
5269
  return;
4972
5270
  }
4973
5271
 
4974
- plateCore.deleteFragment(editor, {
5272
+ deleteFragment(editor, {
5273
+ // FIXME: see if we can remove unit
5274
+ // @ts-expect-error
4975
5275
  unit: unit,
4976
5276
  reverse: true
4977
5277
  });
@@ -5009,7 +5309,7 @@ var withList = function withList(editor) {
5009
5309
  };
5010
5310
 
5011
5311
  editor.insertBreak = insertListBreak(editor);
5012
- editor.insertFragment = insertListFragment(editor); // TODO: replace with Normalizer rules
5312
+ editor.insertFragment = insertListFragment(editor); // TODO: replace with our own Normalizer rules
5013
5313
 
5014
5314
  editor.normalizeNode = plateList.normalizeList(editor, {
5015
5315
  validLiChildrenTypes: validLiChildrenTypes
@@ -5099,7 +5399,7 @@ function ToolbarListButton(props) {
5099
5399
  var toggleMarkAndDeactivateConflictingMarks = function toggleMarkAndDeactivateConflictingMarks(editor, mark) {
5100
5400
  var subs = [Contentful.MARKS.SUPERSCRIPT, Contentful.MARKS.SUBSCRIPT];
5101
5401
  var clear = subs.includes(mark) ? subs : [];
5102
- plateCore.toggleMark(editor, {
5402
+ toggleMark(editor, {
5103
5403
  key: mark,
5104
5404
  clear: clear
5105
5405
  });
@@ -5110,7 +5410,7 @@ var buildMarkEventHandler = function buildMarkEventHandler(type) {
5110
5410
  return function (event) {
5111
5411
  if (editor.selection && hotkey && isHotkey(hotkey, event)) {
5112
5412
  event.preventDefault();
5113
- var isActive = plateCore.isMarkActive(editor, type);
5413
+ var isActive = isMarkActive(editor, type);
5114
5414
  editor.tracking.onShortcutAction(isActive ? 'unmark' : 'mark', {
5115
5415
  markType: type
5116
5416
  });
@@ -5136,7 +5436,7 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
5136
5436
  var editor = useContentfulEditor();
5137
5437
  var handleClick = React.useCallback(function () {
5138
5438
  if (!(editor != null && editor.selection)) return;
5139
- var isActive = plateCore.isMarkActive(editor, mark);
5439
+ var isActive = isMarkActive(editor, mark);
5140
5440
  editor.tracking.onToolbarAction(isActive ? 'unmark' : 'mark', {
5141
5441
  markType: mark
5142
5442
  });
@@ -5151,7 +5451,7 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
5151
5451
  return /*#__PURE__*/React.createElement(f36Components.Menu.Item, {
5152
5452
  onClick: handleClick,
5153
5453
  disabled: isDisabled,
5154
- className: emotion.cx((_cx = {}, _cx[styles$c.isActive] = plateCore.isMarkActive(editor, mark), _cx)),
5454
+ className: emotion.cx((_cx = {}, _cx[styles$c.isActive] = isMarkActive(editor, mark), _cx)),
5155
5455
  testId: mark + "-toolbar-button"
5156
5456
  }, title);
5157
5457
  }
@@ -5160,7 +5460,7 @@ var createMarkToolbarButton = function createMarkToolbarButton(_ref) {
5160
5460
  title: title,
5161
5461
  testId: mark + "-toolbar-button",
5162
5462
  onClick: handleClick,
5163
- isActive: plateCore.isMarkActive(editor, mark),
5463
+ isActive: isMarkActive(editor, mark),
5164
5464
  isDisabled: isDisabled
5165
5465
  }, icon);
5166
5466
  };
@@ -5208,7 +5508,7 @@ var createBoldPlugin = function createBoldPlugin() {
5208
5508
  }
5209
5509
  }],
5210
5510
  query: function query(el) {
5211
- return !isGoogleBoldWrapper(el) && !plateCore.someHtmlElement(el, function (node) {
5511
+ return !isGoogleBoldWrapper(el) && !someHtmlElement(el, function (node) {
5212
5512
  return node.style.fontWeight === 'normal';
5213
5513
  });
5214
5514
  }
@@ -5292,7 +5592,7 @@ var createItalicPlugin = function createItalicPlugin() {
5292
5592
  }
5293
5593
  }],
5294
5594
  query: function query(el) {
5295
- return !plateCore.someHtmlElement(el, function (node) {
5595
+ return !someHtmlElement(el, function (node) {
5296
5596
  return node.style.fontStyle === 'normal';
5297
5597
  });
5298
5598
  }
@@ -5300,42 +5600,44 @@ var createItalicPlugin = function createItalicPlugin() {
5300
5600
  });
5301
5601
  };
5302
5602
 
5303
- var ToolbarUnderlineButton = /*#__PURE__*/createMarkToolbarButton({
5304
- title: 'Underline',
5305
- mark: Contentful.MARKS.UNDERLINE,
5306
- icon: /*#__PURE__*/React.createElement(f36Icons.FormatUnderlinedIcon, null)
5603
+ var styles$g = {
5604
+ subscript: /*#__PURE__*/emotion.css({
5605
+ verticalAlign: 'sub',
5606
+ fontSize: 'smaller'
5607
+ })
5608
+ };
5609
+ var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5610
+ title: 'Subscript',
5611
+ mark: Contentful.MARKS.SUBSCRIPT,
5612
+ icon: /*#__PURE__*/React.createElement(f36Icons.SubscriptIcon, {
5613
+ viewBox: "0 0 23 18"
5614
+ })
5307
5615
  });
5308
- function Underline(props) {
5309
- return /*#__PURE__*/React.createElement("u", _extends({}, props.attributes), props.children);
5616
+ var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5617
+ title: 'Subscript',
5618
+ mark: Contentful.MARKS.SUBSCRIPT
5619
+ });
5620
+ function Subscript(props) {
5621
+ return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes, {
5622
+ className: styles$g.subscript
5623
+ }), props.children);
5310
5624
  }
5311
- var createUnderlinePlugin = function createUnderlinePlugin() {
5312
- return plateBasicMarks.createUnderlinePlugin({
5313
- type: Contentful.MARKS.UNDERLINE,
5314
- component: Underline,
5315
- options: {
5316
- hotkey: ['mod+u']
5317
- },
5625
+ var createSubscriptPlugin = function createSubscriptPlugin() {
5626
+ return plateBasicMarks.createSubscriptPlugin({
5627
+ type: Contentful.MARKS.SUBSCRIPT,
5628
+ component: Subscript,
5318
5629
  handlers: {
5319
- onKeyDown: buildMarkEventHandler(Contentful.MARKS.UNDERLINE)
5630
+ onKeyDown: buildMarkEventHandler(Contentful.MARKS.SUBSCRIPT)
5320
5631
  },
5321
5632
  deserializeHtml: {
5322
5633
  rules: [{
5323
- validNodeName: ['U']
5324
- }, {
5325
- validStyle: {
5326
- textDecoration: ['underline']
5327
- }
5328
- }],
5329
- query: function query(el) {
5330
- return !plateCore.someHtmlElement(el, function (node) {
5331
- return node.style.textDecoration === 'none';
5332
- });
5333
- }
5634
+ validNodeName: ['SUB']
5635
+ }]
5334
5636
  }
5335
5637
  });
5336
5638
  };
5337
5639
 
5338
- var styles$g = {
5640
+ var styles$h = {
5339
5641
  superscript: /*#__PURE__*/emotion.css({
5340
5642
  verticalAlign: 'super',
5341
5643
  fontSize: 'smaller'
@@ -5352,7 +5654,7 @@ var ToolbarDropdownSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
5352
5654
  });
5353
5655
  function Superscript(props) {
5354
5656
  return /*#__PURE__*/React.createElement("sup", _extends({}, props.attributes, {
5355
- className: styles$g.superscript
5657
+ className: styles$h.superscript
5356
5658
  }), props.children);
5357
5659
  }
5358
5660
  var createSuperscriptPlugin = function createSuperscriptPlugin() {
@@ -5370,39 +5672,37 @@ var createSuperscriptPlugin = function createSuperscriptPlugin() {
5370
5672
  });
5371
5673
  };
5372
5674
 
5373
- var styles$h = {
5374
- subscript: /*#__PURE__*/emotion.css({
5375
- verticalAlign: 'sub',
5376
- fontSize: 'smaller'
5377
- })
5378
- };
5379
- var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5380
- title: 'Subscript',
5381
- mark: Contentful.MARKS.SUBSCRIPT,
5382
- icon: /*#__PURE__*/React.createElement(f36Icons.SubscriptIcon, {
5383
- viewBox: "0 0 23 18"
5384
- })
5385
- });
5386
- var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5387
- title: 'Subscript',
5388
- mark: Contentful.MARKS.SUBSCRIPT
5675
+ var ToolbarUnderlineButton = /*#__PURE__*/createMarkToolbarButton({
5676
+ title: 'Underline',
5677
+ mark: Contentful.MARKS.UNDERLINE,
5678
+ icon: /*#__PURE__*/React.createElement(f36Icons.FormatUnderlinedIcon, null)
5389
5679
  });
5390
- function Subscript(props) {
5391
- return /*#__PURE__*/React.createElement("sub", _extends({}, props.attributes, {
5392
- className: styles$h.subscript
5393
- }), props.children);
5680
+ function Underline(props) {
5681
+ return /*#__PURE__*/React.createElement("u", _extends({}, props.attributes), props.children);
5394
5682
  }
5395
- var createSubscriptPlugin = function createSubscriptPlugin() {
5396
- return plateBasicMarks.createSubscriptPlugin({
5397
- type: Contentful.MARKS.SUBSCRIPT,
5398
- component: Subscript,
5683
+ var createUnderlinePlugin = function createUnderlinePlugin() {
5684
+ return plateBasicMarks.createUnderlinePlugin({
5685
+ type: Contentful.MARKS.UNDERLINE,
5686
+ component: Underline,
5687
+ options: {
5688
+ hotkey: ['mod+u']
5689
+ },
5399
5690
  handlers: {
5400
- onKeyDown: buildMarkEventHandler(Contentful.MARKS.SUBSCRIPT)
5691
+ onKeyDown: buildMarkEventHandler(Contentful.MARKS.UNDERLINE)
5401
5692
  },
5402
5693
  deserializeHtml: {
5403
5694
  rules: [{
5404
- validNodeName: ['SUB']
5405
- }]
5695
+ validNodeName: ['U']
5696
+ }, {
5697
+ validStyle: {
5698
+ textDecoration: ['underline']
5699
+ }
5700
+ }],
5701
+ query: function query(el) {
5702
+ return !someHtmlElement(el, function (node) {
5703
+ return node.style.textDecoration === 'none';
5704
+ });
5705
+ }
5406
5706
  }
5407
5707
  });
5408
5708
  };
@@ -5414,7 +5714,7 @@ var createMarksPlugin = function createMarksPlugin() {
5414
5714
  };
5415
5715
  };
5416
5716
 
5417
- var isInline = function isInline(node) {
5717
+ var isInline$1 = function isInline(node) {
5418
5718
  return INLINE_TYPES.includes(node.type);
5419
5719
  };
5420
5720
 
@@ -5426,13 +5726,13 @@ var isTextContainer = function isTextContainer(node) {
5426
5726
 
5427
5727
  var baseRules = [{
5428
5728
  // Wrap orphaned text nodes in a paragraph
5429
- match: slate.Text.isText,
5729
+ match: isText,
5430
5730
  validNode: function validNode(editor, _ref) {
5431
- var _getParent;
5731
+ var _getParentNode;
5432
5732
 
5433
5733
  var path = _ref[1];
5434
- var parent = (_getParent = plateCore.getParent(editor, path)) == null ? void 0 : _getParent[0];
5435
- return !!parent && (isTextContainer(parent) || isInline(parent) || editor.isVoid(parent));
5734
+ var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
5735
+ return !!parent && (isTextContainer(parent) || isInline$1(parent) || editor.isVoid(parent));
5436
5736
  },
5437
5737
  transform: function transform(editor, entry) {
5438
5738
  return transformWrapIn(Contentful.BLOCKS.PARAGRAPH)(editor, entry);
@@ -5443,10 +5743,10 @@ var baseRules = [{
5443
5743
  type: INLINE_TYPES
5444
5744
  },
5445
5745
  validNode: function validNode(editor, _ref2) {
5446
- var _getParent2;
5746
+ var _getParentNode2;
5447
5747
 
5448
5748
  var path = _ref2[1];
5449
- var parent = (_getParent2 = plateCore.getParent(editor, path)) == null ? void 0 : _getParent2[0];
5749
+ var parent = (_getParentNode2 = getParentNode(editor, path)) == null ? void 0 : _getParentNode2[0];
5450
5750
  return !!parent && isTextContainer(parent);
5451
5751
  },
5452
5752
  transform: /*#__PURE__*/transformWrapIn(Contentful.BLOCKS.PARAGRAPH)
@@ -5464,19 +5764,9 @@ var NormalizerError = /*#__PURE__*/function (_Error) {
5464
5764
  var createValidatorFromTypes = function createValidatorFromTypes(types) {
5465
5765
  return function (_, _ref) {
5466
5766
  var node = _ref[0];
5467
- return slate.Element.isElement(node) && types.includes(node.type);
5767
+ return isElement(node) && types.includes(node.type);
5468
5768
  };
5469
5769
  };
5470
- var getChildren = function getChildren(editor, _ref2) {
5471
- var node = _ref2[0],
5472
- path = _ref2[1];
5473
-
5474
- if (slate.Text.isText(node)) {
5475
- return [];
5476
- }
5477
-
5478
- return Array.from(slate.Node.children(editor, path));
5479
- };
5480
5770
  var createTransformerFromObject = function createTransformerFromObject(transforms) {
5481
5771
  // A default transformer must always be provided
5482
5772
  var fallback = transforms['default'];
@@ -5487,7 +5777,7 @@ var createTransformerFromObject = function createTransformerFromObject(transform
5487
5777
 
5488
5778
  return function (editor, entry) {
5489
5779
  var node = entry[0];
5490
- var key = slate.Element.isElement(node) ? node.type : 'default';
5780
+ var key = isElement(node) ? node.type : 'default';
5491
5781
  var transformer = transforms[key] || fallback;
5492
5782
  return transformer(editor, entry);
5493
5783
  };
@@ -5497,8 +5787,8 @@ var withNormalizer = function withNormalizer(editor) {
5497
5787
  var rules = baseRules; // Derive normalization rules from other plugin's configurations
5498
5788
 
5499
5789
  for (var _iterator = _createForOfIteratorHelperLoose(editor.plugins), _step; !(_step = _iterator()).done;) {
5500
- var p = _step.value;
5501
- var _rules = p.normalizer;
5790
+ var p$1 = _step.value;
5791
+ var _rules = p$1.normalizer;
5502
5792
 
5503
5793
  if (!_rules) {
5504
5794
  continue;
@@ -5510,14 +5800,14 @@ var withNormalizer = function withNormalizer(editor) {
5510
5800
  // Clone to avoid mutation bugs
5511
5801
  var rule = _extends({}, _rule);
5512
5802
 
5513
- if (!rule.match && !p.isElement) {
5803
+ if (!rule.match && !p$1.isElement) {
5514
5804
  throw new NormalizerError('rule.match MUST be defined in a non-element plugin');
5515
5805
  } // By default we filter elements with given plugin type
5516
5806
 
5517
5807
 
5518
5808
  if (!rule.match) {
5519
5809
  rule.match = {
5520
- type: plateCore.getPluginType(editor, p.key)
5810
+ type: p.getPluginType(editor, p$1.key)
5521
5811
  };
5522
5812
  } // Conditional transformation e.g.
5523
5813
  // {
@@ -5555,22 +5845,23 @@ var withNormalizer = function withNormalizer(editor) {
5555
5845
 
5556
5846
 
5557
5847
  var _transform = function _transform(tr, entry) {
5558
- slate.Editor.withoutNormalizing(editor, function () {
5848
+ withoutNormalizing(editor, function () {
5559
5849
  tr(editor, entry);
5560
5850
  });
5561
5851
  };
5562
5852
 
5563
- var normalizeNode = editor.normalizeNode;
5853
+ var normalizeNode = editor.normalizeNode; // @ts-expect-error
5564
5854
 
5565
5855
  editor.normalizeNode = function (entry) {
5566
- var node = entry[0];
5567
- var children = getChildren(editor, entry); // The order of validNode rules Vs validChildren doesn't matter. Slate
5856
+ var node = entry[0],
5857
+ path = entry[1];
5858
+ var children = getChildren(entry); // The order of validNode rules Vs validChildren doesn't matter. Slate
5568
5859
  // will always perform normalization in a depth-first fashion.
5569
5860
 
5570
5861
  for (var _iterator2 = _createForOfIteratorHelperLoose(rules), _step2; !(_step2 = _iterator2()).done;) {
5571
5862
  var rule = _step2.value;
5572
5863
 
5573
- if (!plateCore.match(node, rule.match)) {
5864
+ if (!matchNode(node, path, rule.match)) {
5574
5865
  continue;
5575
5866
  } // Normalize node
5576
5867
 
@@ -5612,7 +5903,6 @@ var withNormalizer = function withNormalizer(editor) {
5612
5903
  var createNormalizerPlugin = function createNormalizerPlugin() {
5613
5904
  return {
5614
5905
  key: 'NormalizerPlugin',
5615
- // @ts-expect-error
5616
5906
  withOverrides: withNormalizer
5617
5907
  };
5618
5908
  };
@@ -5820,7 +6110,7 @@ var createPasteHTMLPlugin = function createPasteHTMLPlugin() {
5820
6110
  return editor;
5821
6111
  },
5822
6112
  inject: {
5823
- pluginsByKey: (_pluginsByKey = {}, _pluginsByKey[plateCore.KEY_DESERIALIZE_HTML] = {
6113
+ pluginsByKey: (_pluginsByKey = {}, _pluginsByKey[p.KEY_DESERIALIZE_HTML] = {
5824
6114
  editor: {
5825
6115
  insertData: {
5826
6116
  format: 'text/html',
@@ -5853,7 +6143,7 @@ function Quote(props) {
5853
6143
  */
5854
6144
 
5855
6145
  var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
5856
- var container = plateCore.getAbove(editor, {
6146
+ var container = getAboveNode(editor, {
5857
6147
  match: {
5858
6148
  type: Contentful.TEXT_CONTAINERS
5859
6149
  },
@@ -5864,11 +6154,11 @@ var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
5864
6154
  return false;
5865
6155
  }
5866
6156
 
5867
- if (!plateCore.isAncestorEmpty(editor, container[0])) {
6157
+ if (!isAncestorEmpty(editor, container[0])) {
5868
6158
  return false;
5869
6159
  }
5870
6160
 
5871
- var quote = plateCore.getBlockAbove(editor, {
6161
+ var quote = getBlockAbove(editor, {
5872
6162
  match: {
5873
6163
  type: Contentful.BLOCKS.QUOTE
5874
6164
  },
@@ -5879,7 +6169,7 @@ var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
5879
6169
  return false;
5880
6170
  }
5881
6171
 
5882
- if (plateCore.hasSingleChild(quote[0]) && plateCore.isLastChild(quote, container[1])) {
6172
+ if (p.hasSingleChild(quote[0]) && p.isLastChild(quote, container[1])) {
5883
6173
  return true;
5884
6174
  }
5885
6175
 
@@ -5892,11 +6182,11 @@ function toggleQuote(editor, logAction) {
5892
6182
  logAction == null ? void 0 : logAction(isActive ? 'remove' : 'insert', {
5893
6183
  nodeType: Contentful.BLOCKS.QUOTE
5894
6184
  });
5895
- slate.Editor.withoutNormalizing(editor, function () {
6185
+ withoutNormalizing(editor, function () {
5896
6186
  if (!editor.selection) return;
5897
- slate.Transforms.unwrapNodes(editor, {
6187
+ unwrapNodes(editor, {
5898
6188
  match: function match(node) {
5899
- return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.QUOTE;
6189
+ return isElement(node) && node.type === Contentful.BLOCKS.QUOTE;
5900
6190
  },
5901
6191
  split: true
5902
6192
  });
@@ -5907,7 +6197,7 @@ function toggleQuote(editor, logAction) {
5907
6197
  data: {},
5908
6198
  children: []
5909
6199
  };
5910
- slate.Transforms.wrapNodes(editor, quote);
6200
+ wrapNodes(editor, quote);
5911
6201
  }
5912
6202
  });
5913
6203
  }
@@ -5927,39 +6217,39 @@ var withQuote = function withQuote(editor) {
5927
6217
 
5928
6218
  editor.insertFragment = function (fragment) {
5929
6219
  var startingNode = fragment.length && fragment[0];
5930
- var startsWithBlockquote = slate.Element.isElement(startingNode) && startingNode.type === Contentful.BLOCKS.QUOTE;
5931
- var containerEntry = plateCore.getAbove(editor, {
6220
+ var startsWithBlockquote = s.Element.isElement(startingNode) && startingNode.type === Contentful.BLOCKS.QUOTE;
6221
+ var containerEntry = getAboveNode(editor, {
5932
6222
  match: {
5933
6223
  type: Contentful.TEXT_CONTAINERS
5934
6224
  }
5935
6225
  });
5936
- var containerIsNotEmpty = containerEntry && slate.Node.string(containerEntry[0]) !== '';
6226
+ var containerIsNotEmpty = containerEntry && getText(editor, containerEntry[1]) !== '';
5937
6227
 
5938
6228
  if (startsWithBlockquote && containerIsNotEmpty) {
5939
6229
  var selection = editor.selection;
5940
6230
 
5941
6231
  var isContentSelected = function isContentSelected(selection) {
5942
- return !!selection && slate.Point.compare(selection.anchor, selection.focus) !== 0;
6232
+ return !!selection && s.Point.compare(selection.anchor, selection.focus) !== 0;
5943
6233
  }; // if something is selected (highlighted) we replace the selection
5944
6234
 
5945
6235
 
5946
6236
  if (isContentSelected(selection)) {
5947
- slate.Transforms["delete"](editor, {
6237
+ deleteText(editor, {
5948
6238
  at: selection
5949
6239
  });
5950
6240
  } // get the cursor entry again, it may be different after deletion
5951
6241
 
5952
6242
 
5953
- var _containerEntry = plateCore.getAbove(editor, {
6243
+ var _containerEntry = getAboveNode(editor, {
5954
6244
  match: {
5955
6245
  type: Contentful.TEXT_CONTAINERS
5956
6246
  }
5957
6247
  });
5958
6248
 
5959
- var _containerIsNotEmpty = _containerEntry && slate.Node.string(_containerEntry[0]) !== '';
6249
+ var _containerIsNotEmpty = _containerEntry && getText(editor, _containerEntry[1]) !== '';
5960
6250
 
5961
6251
  if (_containerIsNotEmpty) {
5962
- slate.Transforms.insertNodes(editor, fragment);
6252
+ insertNodes(editor, fragment);
5963
6253
  return;
5964
6254
  }
5965
6255
  }
@@ -6034,15 +6324,17 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
6034
6324
  });
6035
6325
  };
6036
6326
 
6327
+ var useReadOnly = Slate.useReadOnly;
6328
+
6037
6329
  var addRow = function addRow(editor, getNextRowPath) {
6038
- if (plateCore.someNode(editor, {
6330
+ if (someNode(editor, {
6039
6331
  match: {
6040
- type: plateCore.getPluginType(editor, plateTable.ELEMENT_TABLE)
6332
+ type: Contentful.BLOCKS.TABLE
6041
6333
  }
6042
6334
  })) {
6043
- var currentRowItem = plateCore.getAbove(editor, {
6335
+ var currentRowItem = getAboveNode(editor, {
6044
6336
  match: {
6045
- type: plateCore.getPluginType(editor, plateTable.ELEMENT_TR)
6337
+ type: Contentful.BLOCKS.TABLE_ROW
6046
6338
  }
6047
6339
  });
6048
6340
 
@@ -6050,8 +6342,7 @@ var addRow = function addRow(editor, getNextRowPath) {
6050
6342
  var currentRowElem = currentRowItem[0],
6051
6343
  currentRowPath = currentRowItem[1];
6052
6344
  var nextRowPath = getNextRowPath(currentRowPath);
6053
- plateCore.insertNodes(editor, // @ts-expect-error
6054
- plateTable.getEmptyRowNode(editor, {
6345
+ insertNodes(editor, plateTable.getEmptyRowNode(editor, {
6055
6346
  header: false,
6056
6347
  colCount: currentRowElem.children.length
6057
6348
  }), {
@@ -6060,14 +6351,14 @@ var addRow = function addRow(editor, getNextRowPath) {
6060
6351
  select: true
6061
6352
  }); // Select the first cell in the current row
6062
6353
 
6063
- slate.Transforms.select(editor, slate.Editor.start(editor, nextRowPath));
6354
+ select(editor, getStartPoint(editor, nextRowPath));
6064
6355
  }
6065
6356
  }
6066
6357
  };
6067
6358
 
6068
6359
  var addRowBelow = function addRowBelow(editor) {
6069
6360
  addRow(editor, function (currentRowPath) {
6070
- return slate.Path.next(currentRowPath);
6361
+ return getNextPath(currentRowPath);
6071
6362
  });
6072
6363
  };
6073
6364
  var addRowAbove = function addRowAbove(editor) {
@@ -6080,19 +6371,19 @@ var addRowAbove = function addRowAbove(editor) {
6080
6371
  var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6081
6372
  var header = _ref.header;
6082
6373
 
6083
- if (plateCore.someNode(editor, {
6374
+ if (someNode(editor, {
6084
6375
  match: {
6085
- type: plateCore.getPluginType(editor, plateTable.ELEMENT_TABLE)
6376
+ type: Contentful.BLOCKS.TABLE
6086
6377
  }
6087
6378
  })) {
6088
- var currentCellItem = plateCore.getAbove(editor, {
6379
+ var currentCellItem = getAboveNode(editor, {
6089
6380
  match: {
6090
- type: [plateCore.getPluginType(editor, plateTable.ELEMENT_TD), plateCore.getPluginType(editor, plateTable.ELEMENT_TH)]
6381
+ type: [Contentful.BLOCKS.TABLE_HEADER_CELL, Contentful.BLOCKS.TABLE_CELL]
6091
6382
  }
6092
6383
  });
6093
- var currentTableItem = plateCore.getAbove(editor, {
6384
+ var currentTableItem = getAboveNode(editor, {
6094
6385
  match: {
6095
- type: plateCore.getPluginType(editor, plateTable.ELEMENT_TABLE)
6386
+ type: Contentful.BLOCKS.TABLE
6096
6387
  }
6097
6388
  });
6098
6389
 
@@ -6102,8 +6393,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6102
6393
  var replacePathPos = newCellPath.length - 2;
6103
6394
  currentTableItem[0].children.forEach(function (_, rowIdx) {
6104
6395
  newCellPath[replacePathPos] = rowIdx;
6105
- plateCore.insertNodes(editor, // @ts-expect-error
6106
- plateTable.getEmptyCellNode(editor, {
6396
+ insertNodes(editor, plateTable.getEmptyCellNode(editor, {
6107
6397
  header: header && rowIdx === 0
6108
6398
  }), {
6109
6399
  at: newCellPath,
@@ -6117,7 +6407,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6117
6407
 
6118
6408
  var addColumnRight = function addColumnRight(editor, options) {
6119
6409
  addColumn(editor, options, function (currentCellPath) {
6120
- return slate.Path.next(currentCellPath);
6410
+ return getNextPath(currentCellPath);
6121
6411
  });
6122
6412
  };
6123
6413
  var addColumnLeft = function addColumnLeft(editor, options) {
@@ -6127,7 +6417,7 @@ var addColumnLeft = function addColumnLeft(editor, options) {
6127
6417
  };
6128
6418
 
6129
6419
  var setHeader = function setHeader(editor, enable) {
6130
- var tableItem = plateCore.getAbove(editor, {
6420
+ var tableItem = getAboveNode(editor, {
6131
6421
  match: {
6132
6422
  type: Contentful.BLOCKS.TABLE
6133
6423
  }
@@ -6137,15 +6427,15 @@ var setHeader = function setHeader(editor, enable) {
6137
6427
  return;
6138
6428
  }
6139
6429
 
6140
- var firstRow = plateCore.getChildren(tableItem)[0];
6430
+ var firstRow = getChildren(tableItem)[0];
6141
6431
 
6142
6432
  if (!firstRow) {
6143
6433
  return;
6144
6434
  }
6145
6435
 
6146
- plateCore.getChildren(firstRow).forEach(function (_ref) {
6436
+ getChildren(firstRow).forEach(function (_ref) {
6147
6437
  var path = _ref[1];
6148
- plateCore.setNodes(editor, {
6438
+ setNodes(editor, {
6149
6439
  type: enable ? Contentful.BLOCKS.TABLE_HEADER_CELL : Contentful.BLOCKS.TABLE_CELL
6150
6440
  }, {
6151
6441
  at: path
@@ -6154,9 +6444,30 @@ var setHeader = function setHeader(editor, enable) {
6154
6444
  };
6155
6445
 
6156
6446
  function insertTableAndFocusFirstCell(editor) {
6157
- plateTable.insertTable(editor, {
6158
- header: true
6159
- });
6447
+ var table = {
6448
+ type: Contentful.BLOCKS.TABLE,
6449
+ data: {},
6450
+ children: [plateTable.getEmptyRowNode(editor, {
6451
+ colCount: 2,
6452
+ header: true
6453
+ }), plateTable.getEmptyRowNode(editor, {
6454
+ colCount: 2
6455
+ })]
6456
+ };
6457
+ insertNodes(editor, table);
6458
+
6459
+ if (editor.selection) {
6460
+ var tableEntry = getBlockAbove(editor, {
6461
+ match: {
6462
+ type: Contentful.BLOCKS.TABLE
6463
+ }
6464
+ });
6465
+ if (!tableEntry) return;
6466
+ selectEditor(editor, {
6467
+ at: getStartPoint(editor, tableEntry[1])
6468
+ });
6469
+ }
6470
+
6160
6471
  replaceEmptyParagraphWithTable(editor);
6161
6472
  }
6162
6473
  function isTableActive(editor) {
@@ -6166,7 +6477,7 @@ function isTableActive(editor) {
6166
6477
  });
6167
6478
  }
6168
6479
  function isTableHeaderEnabled(editor) {
6169
- var tableItem = plateCore.getAbove(editor, {
6480
+ var tableItem = getAboveNode(editor, {
6170
6481
  match: {
6171
6482
  type: Contentful.BLOCKS.TABLE
6172
6483
  }
@@ -6176,43 +6487,43 @@ function isTableHeaderEnabled(editor) {
6176
6487
  return false;
6177
6488
  }
6178
6489
 
6179
- var firstRow = plateCore.getChildren(tableItem)[0];
6490
+ var firstRow = getChildren(tableItem)[0];
6180
6491
 
6181
6492
  if (!firstRow) {
6182
6493
  return false;
6183
6494
  }
6184
6495
 
6185
- return plateCore.getChildren(firstRow).every(function (_ref) {
6496
+ return getChildren(firstRow).every(function (_ref) {
6186
6497
  var node = _ref[0];
6187
6498
  return node.type === Contentful.BLOCKS.TABLE_HEADER_CELL;
6188
6499
  });
6189
6500
  }
6190
6501
  function replaceEmptyParagraphWithTable(editor) {
6191
6502
  var tablePath = getAncestorPathFromSelection(editor);
6192
- if (!tablePath || plateCore.isFirstChild(tablePath)) return;
6193
- var previousPath = slate.Path.previous(tablePath);
6503
+ if (!tablePath || isFirstChildPath(tablePath)) return;
6504
+ var previousPath = getPreviousPath(tablePath);
6194
6505
  if (!previousPath) return;
6195
6506
 
6196
- var _Editor$nodes = slate.Editor.nodes(editor, {
6507
+ var _getNodeEntries = getNodeEntries(editor, {
6197
6508
  at: previousPath,
6198
6509
  match: function match(node) {
6199
6510
  return node.type === Contentful.BLOCKS.PARAGRAPH;
6200
6511
  }
6201
6512
  }),
6202
- nodes = _Editor$nodes[0];
6513
+ nodes = _getNodeEntries[0];
6203
6514
 
6204
6515
  if (!nodes) return;
6205
6516
  var previousNode = nodes[0];
6206
- var isPreviousNodeTextEmpty = plateCore.isAncestorEmpty(editor, previousNode);
6517
+ var isPreviousNodeTextEmpty = isAncestorEmpty(editor, previousNode);
6207
6518
 
6208
6519
  if (isPreviousNodeTextEmpty) {
6209
6520
  // Switch table with previous empty paragraph
6210
- slate.Transforms.moveNodes(editor, {
6521
+ moveNodes(editor, {
6211
6522
  at: tablePath,
6212
6523
  to: previousPath
6213
6524
  }); // Remove previous paragraph that now is under the table
6214
6525
 
6215
- slate.Transforms.removeNodes(editor, {
6526
+ removeNodes(editor, {
6216
6527
  at: tablePath
6217
6528
  });
6218
6529
  }
@@ -6224,21 +6535,19 @@ function replaceEmptyParagraphWithTable(editor) {
6224
6535
  * normalization cycles.
6225
6536
  */
6226
6537
 
6227
- var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor, _ref2) {
6228
- var rowPath = _ref2[1];
6229
- var parent = plateCore.getParent(editor, rowPath); // This is ensured by normalization. The error is here just in case
6538
+ var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor, rowEntry) {
6539
+ var rowPath = rowEntry[1];
6540
+ var parent = getParentNode(editor, rowPath); // This is ensured by normalization. The error is here just in case
6230
6541
 
6231
6542
  if (!parent) {
6232
6543
  throw new Error('table rows must be wrapped in a table node');
6233
- }
6544
+ } // The longest table row determines its width
6234
6545
 
6235
- var tablePath = parent[1]; // The longest table row determines its width
6236
6546
 
6237
- var tableWidth = Math.max.apply(Math, Array.from(slate.Node.children(editor, tablePath)).map(function (_ref3) {
6238
- var path = _ref3[1];
6239
- return Array.from(slate.Node.children(editor, path)).length;
6547
+ var tableWidth = Math.max.apply(Math, getChildren(parent).map(function (entry) {
6548
+ return getChildren(entry).length;
6240
6549
  }));
6241
- var rowWidth = Array.from(slate.Node.children(editor, rowPath)).length;
6550
+ var rowWidth = getChildren(rowEntry).length;
6242
6551
  return tableWidth - rowWidth;
6243
6552
  };
6244
6553
  var createEmptyTableCells = function createEmptyTableCells(count) {
@@ -6255,12 +6564,11 @@ var createEmptyTableCells = function createEmptyTableCells(count) {
6255
6564
  };
6256
6565
  return new Array(count).fill(emptyTableCell);
6257
6566
  };
6258
- var isNotEmpty = function isNotEmpty(editor, _ref4) {
6259
- var path = _ref4[1];
6260
- return Array.from(slate.Node.children(editor, path)).length !== 0;
6567
+ var isNotEmpty = function isNotEmpty(_, entry) {
6568
+ return getChildren(entry).length !== 0;
6261
6569
  };
6262
6570
  var isTable = function isTable(node) {
6263
- return slate.Element.isElement(node) && node.type === Contentful.BLOCKS.TABLE;
6571
+ return isElement(node) && node.type === Contentful.BLOCKS.TABLE;
6264
6572
  };
6265
6573
 
6266
6574
  var styles$j = {
@@ -6280,7 +6588,7 @@ var getCurrentTableSize = function getCurrentTableSize(editor) {
6280
6588
 
6281
6589
  var TableActions = function TableActions() {
6282
6590
  var editor = useContentfulEditor();
6283
- var isDisabled = Slate.useReadOnly();
6591
+ var isDisabled = useReadOnly();
6284
6592
 
6285
6593
  var _React$useState = React__default.useState(false),
6286
6594
  isOpen = _React$useState[0],
@@ -6301,7 +6609,7 @@ var TableActions = function TableActions() {
6301
6609
  return false;
6302
6610
  }
6303
6611
 
6304
- var headerCell = plateCore.getAbove(editor, {
6612
+ var headerCell = getAboveNode(editor, {
6305
6613
  match: {
6306
6614
  type: Contentful.BLOCKS.TABLE_HEADER_CELL
6307
6615
  }
@@ -6324,7 +6632,7 @@ var TableActions = function TableActions() {
6324
6632
  if (!(editor != null && editor.selection)) return;
6325
6633
  close();
6326
6634
  var tableSize = getCurrentTableSize(editor);
6327
- slate.Editor.withoutNormalizing(editor, function () {
6635
+ withoutNormalizing(editor, function () {
6328
6636
  cb(editor, {
6329
6637
  header: isHeaderEnabled
6330
6638
  });
@@ -6426,7 +6734,7 @@ var Table = function Table(props) {
6426
6734
  var trimUnnecessaryTableWrapper = function trimUnnecessaryTableWrapper(node) {
6427
6735
  var _node$children, _row$children;
6428
6736
 
6429
- if (!slate.Element.isElement(node)) {
6737
+ if (!isElement(node)) {
6430
6738
  return [node];
6431
6739
  } // must be a table with a single row
6432
6740
 
@@ -6463,7 +6771,7 @@ var insertTableFragment = function insertTableFragment(editor) {
6463
6771
  var isTableFirstFragment = fragments.findIndex(function (fragment) {
6464
6772
  return isTable(fragment);
6465
6773
  }) === 0;
6466
- var currentLineHasText = plateCore.getText(editor, (_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.path) !== '';
6774
+ var currentLineHasText = getText(editor, (_editor$selection = editor.selection) == null ? void 0 : _editor$selection.focus.path) !== '';
6467
6775
 
6468
6776
  if (isInsertingTable && isTableFirstFragment && currentLineHasText) {
6469
6777
  insertEmptyParagraph(editor);
@@ -6476,20 +6784,21 @@ var insertTableFragment = function insertTableFragment(editor) {
6476
6784
  var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6477
6785
  var defaultHandler = plateTable.onKeyDownTable(editor, plugin);
6478
6786
  return function (event) {
6479
- // This fixes `Cannot resolve a Slate point from DOM point: [object HTMLDivElement]` when typing while the cursor is before table
6787
+ // This fixes `Cannot resolve a Slate point from DOM point:
6788
+ // [object HTMLDivElement]` when typing while the cursor is before table
6480
6789
  var windowSelection = window.getSelection();
6481
6790
 
6482
6791
  if (windowSelection) {
6483
6792
  var _windowSelection$anch, _windowSelection$anch2;
6484
6793
 
6485
6794
  // @ts-expect-error
6486
- var blockType = (_windowSelection$anch = windowSelection.anchorNode.attributes) == null ? void 0 : (_windowSelection$anch2 = _windowSelection$anch['data-block-type']) == null ? void 0 : _windowSelection$anch2.value; // this attribute comes from `plugins/Table/components/Table.tsx`
6487
-
6795
+ // this attribute comes from `plugins/Table/components/Table.tsx`
6796
+ var blockType = (_windowSelection$anch = windowSelection.anchorNode.attributes) == null ? void 0 : (_windowSelection$anch2 = _windowSelection$anch['data-block-type']) == null ? void 0 : _windowSelection$anch2.value;
6488
6797
  var isBeforeTable = blockType === Contentful.BLOCKS.TABLE;
6489
6798
 
6490
6799
  if (isBeforeTable) {
6491
6800
  if (event.key === 'Enter') {
6492
- var above = plateCore.getAbove(editor, {
6801
+ var above = getAboveNode(editor, {
6493
6802
  match: {
6494
6803
  type: Contentful.BLOCKS.TABLE
6495
6804
  }
@@ -6511,15 +6820,15 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6511
6820
 
6512
6821
 
6513
6822
  if (event.key === 'Tab' && !event.shiftKey) {
6514
- var res = plateTable.getTableCellEntry(editor, {});
6823
+ event.preventDefault();
6824
+ var entry = plateTable.getTableEntries(editor, {});
6515
6825
 
6516
- if (res) {
6517
- event.preventDefault();
6518
- var tableElement = res.tableElement,
6519
- tableRow = res.tableRow,
6520
- tableCell = res.tableCell;
6521
- var isLastCell = plateCore.isLastChild(tableRow, tableCell[1]);
6522
- var isLastRow = plateCore.isLastChild(tableElement, tableRow[1]);
6826
+ if (entry) {
6827
+ var table = entry.table,
6828
+ row = entry.row,
6829
+ cell = entry.cell;
6830
+ var isLastCell = isLastChildPath(row, cell[1]);
6831
+ var isLastRow = isLastChildPath(table, row[1]);
6523
6832
 
6524
6833
  if (isLastRow && isLastCell) {
6525
6834
  addRowBelow(editor); // skip default handler
@@ -6532,7 +6841,7 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6532
6841
  }
6533
6842
 
6534
6843
  if (event.key === 'Escape') {
6535
- Slate.ReactEditor.blur(editor);
6844
+ blurEditor(editor);
6536
6845
  }
6537
6846
  };
6538
6847
  };
@@ -6815,7 +7124,7 @@ var withInvalidCellChildrenTracking = function withInvalidCellChildrenTracking(t
6815
7124
  return function (editor, childEntry) {
6816
7125
  var node = childEntry[0];
6817
7126
 
6818
- if (slate.Element.isElement(node)) {
7127
+ if (isElement(node)) {
6819
7128
  var _editor$tracking;
6820
7129
 
6821
7130
  (_editor$tracking = editor.tracking) == null ? void 0 : _editor$tracking.onViewportAction('invalidTablePaste', {
@@ -6833,11 +7142,16 @@ var createTablePlugin = function createTablePlugin() {
6833
7142
  return plateTable.createTablePlugin({
6834
7143
  type: Contentful.BLOCKS.TABLE,
6835
7144
  handlers: {
7145
+ // @ts-expect-error
6836
7146
  onKeyDown: onKeyDownTable
6837
7147
  },
6838
7148
  withOverrides: function withOverrides(editor, plugin) {
6839
- // injects important fixes from plate's original table plugin
6840
- plateTable.withTable(editor, plugin);
7149
+ var normalizeNode = editor.normalizeNode; // injects important fixes from plate's original table plugin
7150
+
7151
+ plateTable.withTable(editor, plugin); // Resets all normalization rules added by @udecode/plate-table as
7152
+ // they conflict with our own
7153
+
7154
+ editor.normalizeNode = normalizeNode;
6841
7155
  addTableTrackingEvents(editor);
6842
7156
  editor.insertFragment = insertTableFragment(editor);
6843
7157
  return editor;
@@ -6851,7 +7165,9 @@ var createTablePlugin = function createTablePlugin() {
6851
7165
  // Move to root level unless nested
6852
7166
  validNode: function validNode(editor, _ref) {
6853
7167
  var path = _ref[1];
6854
- var isNestedTable = !!plateCore.getBlockAbove(editor, {
7168
+ // Nested tables are handled by another normalization
7169
+ // rule in a the table cell level
7170
+ var isNestedTable = !!getBlockAbove(editor, {
6855
7171
  at: path,
6856
7172
  match: {
6857
7173
  type: [Contentful.BLOCKS.TABLE_CELL, Contentful.BLOCKS.TABLE_HEADER_CELL]
@@ -6875,10 +7191,10 @@ var createTablePlugin = function createTablePlugin() {
6875
7191
  }, {
6876
7192
  // Parent must be a table
6877
7193
  validNode: function validNode(editor, _ref2) {
6878
- var _getParent;
7194
+ var _getParentNode;
6879
7195
 
6880
7196
  var path = _ref2[1];
6881
- var parent = (_getParent = plateCore.getParent(editor, path)) == null ? void 0 : _getParent[0];
7197
+ var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
6882
7198
  return parent && parent.type === Contentful.BLOCKS.TABLE;
6883
7199
  },
6884
7200
  transform: transformWrapIn(Contentful.BLOCKS.TABLE)
@@ -6889,8 +7205,8 @@ var createTablePlugin = function createTablePlugin() {
6889
7205
  },
6890
7206
  transform: function transform(editor, entry) {
6891
7207
  var howMany = getNoOfMissingTableCellsInRow(editor, entry);
6892
- var at = slate.Path.next(plateCore.getLastChildPath(entry));
6893
- slate.Transforms.insertNodes(editor, createEmptyTableCells(howMany), {
7208
+ var at = getNextPath(getLastChildPath(entry));
7209
+ insertNodes(editor, createEmptyTableCells(howMany), {
6894
7210
  at: at
6895
7211
  });
6896
7212
  }
@@ -6955,7 +7271,7 @@ function ToolbarTableButton(props) {
6955
7271
  testId: "table-toolbar-button",
6956
7272
  onClick: handleClick,
6957
7273
  // TODO: active state looks off since the button will be disabled. Do we still need it?
6958
- isActive: isActive,
7274
+ isActive: !!isActive,
6959
7275
  isDisabled: props.isDisabled
6960
7276
  }, /*#__PURE__*/React.createElement(f36Icons.TableIcon, null));
6961
7277
  }
@@ -6977,7 +7293,7 @@ function createTextPlugin(restrictedMarks) {
6977
7293
  return;
6978
7294
  }
6979
7295
 
6980
- slate.Transforms.setSelection(editor, slate.Editor.unhangRange(editor, editor.selection));
7296
+ setSelection(editor, unhangRange(editor, editor.selection));
6981
7297
  };
6982
7298
  }
6983
7299
  },
@@ -6993,19 +7309,19 @@ function createTextPlugin(restrictedMarks) {
6993
7309
  var selection = editor.selection; // If the cursor is at the end of an inline, move it outside
6994
7310
  // before inserting
6995
7311
 
6996
- if (selection && slate.Range.isCollapsed(selection)) {
6997
- var _Editor$above;
7312
+ if (selection && isRangeCollapsed(selection)) {
7313
+ var _getAboveNode;
6998
7314
 
6999
- var inlinePath = (_Editor$above = slate.Editor.above(editor, {
7315
+ var inlinePath = (_getAboveNode = getAboveNode(editor, {
7000
7316
  match: function match(n) {
7001
- return slate.Editor.isInline(editor, n);
7317
+ return isInline(editor, n);
7002
7318
  },
7003
7319
  mode: 'highest'
7004
- })) == null ? void 0 : _Editor$above[1];
7320
+ })) == null ? void 0 : _getAboveNode[1];
7005
7321
 
7006
- if (inlinePath && slate.Editor.isEnd(editor, selection.anchor, inlinePath)) {
7007
- var point = slate.Editor.after(editor, inlinePath);
7008
- slate.Transforms.setSelection(editor, {
7322
+ if (inlinePath && isEndPoint(editor, selection.anchor, inlinePath)) {
7323
+ var point = getPointAfter(editor, inlinePath);
7324
+ setSelection(editor, {
7009
7325
  anchor: point,
7010
7326
  focus: point
7011
7327
  });
@@ -7031,10 +7347,10 @@ function createTextPlugin(restrictedMarks) {
7031
7347
  return editor;
7032
7348
  },
7033
7349
  normalizer: [{
7034
- match: slate.Text.isText,
7350
+ match: isText,
7035
7351
  transform: function transform(editor, _ref) {
7036
7352
  var path = _ref[1];
7037
- plateCore.unsetNodes(editor, restrictedMarks, {
7353
+ unsetNodes(editor, restrictedMarks, {
7038
7354
  at: path
7039
7355
  });
7040
7356
  },
@@ -7049,7 +7365,7 @@ function createTextPlugin(restrictedMarks) {
7049
7365
  }
7050
7366
 
7051
7367
  function deleteEmptyParagraph(unit, editor, deleteFunction) {
7052
- var entry = plateCore.getAbove(editor, {
7368
+ var entry = getAboveNode(editor, {
7053
7369
  match: {
7054
7370
  type: Contentful.TEXT_CONTAINERS
7055
7371
  }
@@ -7058,32 +7374,32 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
7058
7374
  if (entry) {
7059
7375
  var paragraphOrHeading = entry[0],
7060
7376
  path = entry[1];
7061
- var isTextEmpty = plateCore.isAncestorEmpty(editor, paragraphOrHeading); // We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
7377
+ var isTextEmpty = isAncestorEmpty(editor, paragraphOrHeading); // We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
7062
7378
 
7063
7379
  var isRootLevel = path.length === 1;
7064
7380
  var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
7065
7381
 
7066
7382
  if (isTextEmpty && isRootLevel && hasSiblings) {
7067
- slate.Transforms.removeNodes(editor, {
7383
+ removeNodes(editor, {
7068
7384
  at: path
7069
7385
  });
7070
- var prevNode = slate.Editor.before(editor, editor.selection, {
7386
+ var prevNode = getPointBefore(editor, editor.selection, {
7071
7387
  unit: unit
7072
7388
  });
7073
7389
 
7074
7390
  if (prevNode) {
7075
- var _Editor$nodes = slate.Editor.nodes(editor, {
7391
+ var _getNodeEntries = getNodeEntries(editor, {
7076
7392
  match: function match(node) {
7077
- return plateCore.queryNode([node, prevNode.path], {
7393
+ return queryNode([node, prevNode.path], {
7078
7394
  allow: [Contentful.BLOCKS.EMBEDDED_ASSET, Contentful.BLOCKS.EMBEDDED_ENTRY, Contentful.BLOCKS.HR]
7079
7395
  });
7080
7396
  },
7081
7397
  at: prevNode
7082
7398
  }),
7083
- prevCell = _Editor$nodes[0];
7399
+ prevCell = _getNodeEntries[0];
7084
7400
 
7085
7401
  if (prevCell) {
7086
- slate.Transforms.select(editor, prevNode);
7402
+ select(editor, prevNode);
7087
7403
  }
7088
7404
  }
7089
7405
  } else {
@@ -7120,7 +7436,7 @@ function fixPasteAsPlainText(editor) {
7120
7436
  }
7121
7437
 
7122
7438
  if (split) {
7123
- slate.Transforms.splitNodes(editor, {
7439
+ splitNodes(editor, {
7124
7440
  always: true
7125
7441
  });
7126
7442
  }
@@ -7154,7 +7470,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
7154
7470
  filter: function filter(_ref) {
7155
7471
  var node = _ref[0],
7156
7472
  path = _ref[1];
7157
- return isRootLevel(path) && plateCore.isFirstChild(path) && !!node.isVoid;
7473
+ return isRootLevel(path) && isFirstChildPath(path) && !!node.isVoid;
7158
7474
  }
7159
7475
  }
7160
7476
  }, {
@@ -7167,7 +7483,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
7167
7483
  filter: function filter(_ref2) {
7168
7484
  var node = _ref2[0],
7169
7485
  path = _ref2[1];
7170
- return !(isRootLevel(path) && plateCore.isFirstChild(path)) && !!node.isVoid;
7486
+ return !(isRootLevel(path) && isFirstChildPath(path)) && !!node.isVoid;
7171
7487
  }
7172
7488
  }
7173
7489
  }]
@@ -7176,7 +7492,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
7176
7492
 
7177
7493
  var getPlugins = function getPlugins(sdk, onAction, restrictedMarks) {
7178
7494
  return [// AST must come after the HTML deserializer
7179
- plateCore.createDeserializeHtmlPlugin(), plateCore.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
7495
+ p.createDeserializeHtmlPlugin(), p.createDeserializeAstPlugin(), plateSerializerDocx.createDeserializeDocxPlugin(), // Tracking - This should come first so all plugins below will have access to `editor.tracking`
7180
7496
  createTrackingPlugin(onAction), // Global / Global shortcuts
7181
7497
  createDragAndDropPlugin(), createCommandPalettePlugin(), // Block Elements
7182
7498
  createParagraphPlugin(), createListPlugin(), createHrPlugin(), createHeadingPlugin(), createQuotePlugin(), createTablePlugin(), createEmbeddedEntryBlockPlugin(sdk), createEmbeddedAssetBlockPlugin(sdk), // Inline elements
@@ -7254,7 +7570,7 @@ var hasContent = function hasContent(doc) {
7254
7570
 
7255
7571
  var setEditorContent = function setEditorContent(editor, nodes) {
7256
7572
  // Replaces editor content while keeping change history
7257
- slate.Editor.withoutNormalizing(editor, function () {
7573
+ withoutNormalizing(editor, function () {
7258
7574
  var children = [].concat(editor.children);
7259
7575
  children.forEach(function (node) {
7260
7576
  return editor.apply({
@@ -7265,9 +7581,9 @@ var setEditorContent = function setEditorContent(editor, nodes) {
7265
7581
  });
7266
7582
 
7267
7583
  if (nodes) {
7268
- var nodesArray = slate.Node.isNode(nodes) ? [nodes] : nodes;
7584
+ var nodesArray = isNode(nodes) ? [nodes] : nodes;
7269
7585
  nodesArray.forEach(function (node, i) {
7270
- return editor.apply({
7586
+ editor.apply({
7271
7587
  type: 'insert_node',
7272
7588
  path: [i],
7273
7589
  node: node
@@ -7275,10 +7591,10 @@ var setEditorContent = function setEditorContent(editor, nodes) {
7275
7591
  });
7276
7592
  }
7277
7593
 
7278
- var point = slate.Editor.end(editor, []);
7594
+ var point = getEndPoint(editor, []);
7279
7595
 
7280
7596
  if (point) {
7281
- slate.Transforms.select(editor, point);
7597
+ select(editor, point);
7282
7598
  }
7283
7599
  });
7284
7600
  };
@@ -7296,9 +7612,9 @@ var documentToEditorValue = function documentToEditorValue(doc) {
7296
7612
  return sanitizeIncomingSlateDoc(slateDoc);
7297
7613
  };
7298
7614
  var normalizeEditorValue = function normalizeEditorValue(value, options) {
7299
- var editor = plateCore.createPlateEditor(options);
7615
+ var editor = createPlateEditor(options);
7300
7616
  editor.children = value;
7301
- slate.Editor.normalize(editor, {
7617
+ normalize(editor, {
7302
7618
  force: true
7303
7619
  });
7304
7620
  return editor.children;
@@ -7406,7 +7722,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
7406
7722
  nodeType: Contentful.BLOCKS.EMBEDDED_ENTRY,
7407
7723
  onClose: onCloseEntityDropdown
7408
7724
  }), inlineEntryEmbedEnabled && /*#__PURE__*/React__default.createElement(ToolbarEmbeddedEntityInlineButton, {
7409
- isDisabled: !!isDisabled || isLinkActive(editor),
7725
+ isDisabled: !!isDisabled || Boolean(isLinkActive(editor)),
7410
7726
  onClose: onCloseEntityDropdown
7411
7727
  }), blockAssetEmbedEnabled && /*#__PURE__*/React__default.createElement(EmbeddedEntityBlockToolbarIcon, {
7412
7728
  isDisabled: !!isDisabled,
@@ -7464,7 +7780,7 @@ var Dropdown = function Dropdown(_ref) {
7464
7780
  var sdk = _ref.sdk,
7465
7781
  isDisabled = _ref.isDisabled;
7466
7782
  var editor = useContentfulEditor();
7467
- var isActive = plateCore.isMarkActive(editor, Contentful.MARKS.SUPERSCRIPT) || plateCore.isMarkActive(editor, Contentful.MARKS.SUBSCRIPT) || plateCore.isMarkActive(editor, Contentful.MARKS.CODE);
7783
+ var isActive = editor && (isMarkActive(editor, Contentful.MARKS.SUPERSCRIPT) || isMarkActive(editor, Contentful.MARKS.SUBSCRIPT) || isMarkActive(editor, Contentful.MARKS.CODE));
7468
7784
  return /*#__PURE__*/React__default.createElement(f36Components.Menu, null, /*#__PURE__*/React__default.createElement(f36Components.Menu.Trigger, null, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(f36Components.IconButton, {
7469
7785
  size: "small",
7470
7786
  className: styles$l.toolbarBtn,
@@ -7618,7 +7934,7 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
7618
7934
  }, 500);
7619
7935
  }, [handler]);
7620
7936
  return React.useCallback(function (value) {
7621
- var editor = plateCore.getPlateSelectors(editorId).editor();
7937
+ var editor = p.getPlateSelectors(editorId).editor();
7622
7938
 
7623
7939
  if (!editor) {
7624
7940
  throw new Error('Editor change callback called but editor not defined. Editor id: ' + editorId);
@@ -7674,7 +7990,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7674
7990
  the change listener isn't invoked
7675
7991
  */
7676
7992
  setIsFirstRender(false);
7677
- var editor = plateCore.getPlateSelectors(id).editor();
7993
+ var editor = getPlateSelectors(id).editor();
7678
7994
 
7679
7995
  if (!editor) {
7680
7996
  return;
@@ -7691,7 +8007,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7691
8007
  return;
7692
8008
  }
7693
8009
 
7694
- plateCore.getPlateActions(id).value(normalizeEditorValue(documentToEditorValue(props.value), {
8010
+ p.getPlateActions(id).value( // FIXME: fix types here
8011
+ // @ts-expect-error
8012
+ normalizeEditorValue(documentToEditorValue(props.value), {
7695
8013
  plugins: plugins,
7696
8014
  disableCorePlugins: disableCorePlugins
7697
8015
  }));
@@ -7703,7 +8021,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7703
8021
  }, /*#__PURE__*/React__default.createElement("div", {
7704
8022
  className: styles$k.root,
7705
8023
  "data-test-id": "rich-text-editor"
7706
- }, /*#__PURE__*/React__default.createElement(plateCore.Plate, {
8024
+ }, /*#__PURE__*/React__default.createElement(p.Plate, {
7707
8025
  id: id,
7708
8026
  plugins: plugins,
7709
8027
  disableCorePlugins: disableCorePlugins,
@@ -7711,12 +8029,13 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7711
8029
  className: classNames,
7712
8030
  readOnly: props.isDisabled
7713
8031
  },
7714
- onChange: onValueChanged
7715
- }, !props.isToolbarHidden && /*#__PURE__*/React__default.createElement(StickyToolbarWrapper, {
7716
- isDisabled: props.isDisabled
7717
- }, /*#__PURE__*/React__default.createElement(Toolbar, {
7718
- isDisabled: props.isDisabled
7719
- }))))));
8032
+ onChange: onValueChanged,
8033
+ firstChildren: !props.isToolbarHidden && /*#__PURE__*/React__default.createElement(StickyToolbarWrapper, {
8034
+ isDisabled: props.isDisabled
8035
+ }, /*#__PURE__*/React__default.createElement(Toolbar, {
8036
+ isDisabled: props.isDisabled
8037
+ }))
8038
+ }))));
7720
8039
  };
7721
8040
 
7722
8041
  var RichTextEditor = function RichTextEditor(props) {