@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
@@ -2,7 +2,7 @@ import React__default, { createContext, useContext, useMemo, useState, useEffect
2
2
  import { MissingEntityCard, WrappedAssetCard, useEntity, useEntityLoader, WrappedEntryCard, ScheduledIconWithTooltip, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
3
3
  import { entityHelpers, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
4
4
  import { BLOCKS, INLINES, TEXT_CONTAINERS, HEADINGS, LIST_ITEM_BLOCKS, MARKS, CONTAINERS, TOP_LEVEL_BLOCKS, VOID_BLOCKS, EMPTY_DOCUMENT } from '@contentful/rich-text-types';
5
- import { usePlateEditorRef, usePlateEditorState, toggleNodeType, getText, getAbove, removeMark, setMarks, isMarkActive, getNodes, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, unsetNodes, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
5
+ import { usePlateEditorRef, usePlateEditorState, getPlateSelectors as getPlateSelectors$1, withoutNormalizing as withoutNormalizing$1, createPlateEditor as createPlateEditor$1, blurEditor as blurEditor$1, toSlatePoint, mockPlugin as mockPlugin$1, focusEditor as focusEditor$1, selectEditor as selectEditor$1, getNodeEntries as getNodeEntries$1, isMarkActive as isMarkActive$1, getAboveNode as getAboveNode$1, getRange as getRange$1, isText as isText$1, isElement as isElement$1, getEditorString, getBlockAbove as getBlockAbove$1, getParentNode as getParentNode$1, getLastChildPath as getLastChildPath$1, someHtmlElement as someHtmlElement$1, isCollapsed, isInline as isInline$2, isEndPoint as isEndPoint$1, getPointAfter as getPointAfter$1, isFirstChild as isFirstChild$1, getNodeEntry as getNodeEntry$1, isEditor as isEditor$1, isEditorReadOnly as isEditorReadOnly$1, isRangeAcrossBlocks as isRangeAcrossBlocks$1, getPluginType as getPluginType$1, getCommonNode as getCommonNode$1, findNode as findNode$1, isBlock, match as match$1, isAncestorEmpty as isAncestorEmpty$1, isLastChild, getPointBefore as getPointBefore$1, queryNode as queryNode$1, isNode as isNode$1, getEndPoint as getEndPoint$1, getChildren as getChildren$1, findNodePath as findNodePath$1, getLastNodeByLevel as getLastNodeByLevel$1, createPathRef as createPathRef$1, getNodeTexts as getNodeTexts$1, isSelectionAtBlockStart as isSelectionAtBlockStart$1, getNodeChildren as getNodeChildren$1, isExpanded, isSelectionAtBlockEnd as isSelectionAtBlockEnd$1, someNode as someNode$1, getStartPoint as getStartPoint$1, getMarks as getMarks$1, wrapNodes as wrapNodes$1, insertNodes as insertNodes$1, unhangRange as unhangRange$1, setSelection as setSelection$1, unsetNodes as unsetNodes$1, removeMark as removeMark$1, addMark as addMark$1, removeNodes as removeNodes$1, unwrapNodes as unwrapNodes$1, liftNodes as liftNodes$1, select as select$1, toggleMark as toggleMark$1, normalizeEditor, setNodes as setNodes$1, toggleNodeType as toggleNodeType$1, deleteText as deleteText$1, deleteFragment as deleteFragment$1, splitNodes as splitNodes$1, moveSelection as moveSelection$1, insertText as insertText$1, collapseSelection as collapseSelection$1, moveChildren as moveChildren$1, moveNodes as moveNodes$1, ELEMENT_DEFAULT as ELEMENT_DEFAULT$1, isBlockAboveEmpty, KEY_DESERIALIZE_HTML, hasSingleChild, createDeserializeHtmlPlugin, createDeserializeAstPlugin, getPlateActions, Plate } from '@udecode/plate-core';
6
6
  import { css, cx } from 'emotion';
7
7
  import areEqual from 'fast-deep-equal';
8
8
  import noop from 'lodash-es/noop';
@@ -14,20 +14,20 @@ import { ScreenReaderOnly, Popover, SectionHeading, Stack, Flex, AssetCard, Entr
14
14
  import { Portal } from '@contentful/f36-utils';
15
15
  import constate from 'constate';
16
16
  import isHotkey from 'is-hotkey';
17
- import { Text, Element, Editor, Transforms, Range, Path, Node, Point } from 'slate';
18
- import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
17
+ import { Path, Range, Text, Node, Element, Point } from 'slate';
19
18
  import find from 'lodash-es/find';
20
19
  import flow from 'lodash-es/flow';
21
20
  import get from 'lodash-es/get';
22
21
  import tokens from '@contentful/f36-tokens';
23
- import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, SuperscriptIcon, SubscriptIcon, QuoteIcon, TableIcon, PlusIcon, MoreHorizontalIcon } from '@contentful/f36-icons';
22
+ import { useSelected, useReadOnly as useReadOnly$1, useFocused } from 'slate-react';
23
+ import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, SubscriptIcon, SuperscriptIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon, MoreHorizontalIcon } from '@contentful/f36-icons';
24
24
  import { getListTypes, ELEMENT_LIC, getListItemEntry, isListNested, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, removeFirstListItem, removeListItem, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL } from '@udecode/plate-list';
25
25
  import castArray from 'lodash-es/castArray';
26
- import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1, createSuperscriptPlugin as createSuperscriptPlugin$1, createSubscriptPlugin as createSubscriptPlugin$1 } from '@udecode/plate-basic-marks';
26
+ import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createSubscriptPlugin as createSubscriptPlugin$1, createSuperscriptPlugin as createSuperscriptPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
27
27
  import isPlainObject from 'is-plain-obj';
28
28
  import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
29
29
  import { createSelectOnBackspacePlugin as createSelectOnBackspacePlugin$1 } from '@udecode/plate-select';
30
- import { ELEMENT_TABLE, ELEMENT_TR, getEmptyRowNode, ELEMENT_TD, ELEMENT_TH, getEmptyCellNode, insertTable, deleteRow, deleteColumn, deleteTable, onKeyDownTable as onKeyDownTable$1, getTableCellEntry, createTablePlugin as createTablePlugin$1, withTable } from '@udecode/plate-table';
30
+ import { getEmptyRowNode, getEmptyCellNode, ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TR, ELEMENT_TD, deleteRow, deleteColumn, deleteTable, onKeyDownTable as onKeyDownTable$1, getTableEntries, createTablePlugin as createTablePlugin$1, withTable } from '@udecode/plate-table';
31
31
  import { toContentfulDocument, toSlatejsDocument } from '@contentful/contentful-slatejs-adapter';
32
32
  import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';
33
33
  import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
@@ -276,6 +276,43 @@ function useContentfulEditorRef(id) {
276
276
  return editor;
277
277
  }
278
278
 
279
+ var createPlateEditor = function createPlateEditor(options) {
280
+ if (options === void 0) {
281
+ options = {};
282
+ }
283
+
284
+ return createPlateEditor$1(options);
285
+ };
286
+ var withoutNormalizing = function withoutNormalizing(editor, fn) {
287
+ return withoutNormalizing$1(editor, fn);
288
+ };
289
+ var focusEditor = function focusEditor(editor, target) {
290
+ focusEditor$1(editor, target);
291
+ };
292
+ var blurEditor = function blurEditor(editor) {
293
+ blurEditor$1(editor);
294
+ };
295
+ var selectEditor = function selectEditor(editor, opts) {
296
+ selectEditor$1(editor, opts);
297
+ };
298
+ var fromDOMPoint = function fromDOMPoint(editor, domPoint, opts) {
299
+ if (opts === void 0) {
300
+ opts = {
301
+ exactMatch: false,
302
+ suppressThrow: false
303
+ };
304
+ }
305
+
306
+ return toSlatePoint(editor, domPoint, opts);
307
+ };
308
+ var mockPlugin = function mockPlugin(plugin) {
309
+ return mockPlugin$1( // TODO check if there is a way around this ugly casting
310
+ plugin);
311
+ };
312
+ var getPlateSelectors = function getPlateSelectors(id) {
313
+ return getPlateSelectors$1(id);
314
+ };
315
+
279
316
  var createSoftBreakPlugin = function createSoftBreakPlugin() {
280
317
  return createSoftBreakPlugin$1({
281
318
  then: function then(editor) {
@@ -465,14 +502,280 @@ var useCommandList = function useCommandList(commandItems, container) {
465
502
  };
466
503
  };
467
504
 
505
+ /**
506
+ * Get text content at location
507
+ */
508
+
509
+ var getText = function getText(editor, at) {
510
+ return getEditorString(editor, at);
511
+ };
512
+ var isText = function isText(value) {
513
+ return isText$1(value);
514
+ };
515
+ var getEndPoint = function getEndPoint(editor, at) {
516
+ return getEndPoint$1(editor, at);
517
+ };
518
+ var getStartPoint = function getStartPoint(editor, at) {
519
+ return getStartPoint$1(editor, at);
520
+ };
521
+ var isNode = function isNode(value) {
522
+ return isNode$1(value);
523
+ };
524
+ var isSelectionAtBlockEnd = function isSelectionAtBlockEnd(editor, options) {
525
+ return isSelectionAtBlockEnd$1(editor, options);
526
+ };
527
+ var isSelectionAtBlockStart = function isSelectionAtBlockStart(editor, options) {
528
+ return isSelectionAtBlockStart$1(editor, options);
529
+ };
530
+ var getBlockAbove = function getBlockAbove(editor, options) {
531
+ return getBlockAbove$1(editor, options);
532
+ };
533
+ var getNodeEntry = function getNodeEntry(editor, at, options) {
534
+ return getNodeEntry$1(editor, at, options);
535
+ };
536
+ var getNodeEntries = function getNodeEntries(editor, options) {
537
+ return getNodeEntries$1(editor, options);
538
+ }; // TODO: Ancestor may not be the correct type for root
539
+
540
+ var getNodeChildren = function getNodeChildren(root, path, options) {
541
+ return getNodeChildren$1(root, path, options);
542
+ };
543
+ var getParentNode = function getParentNode(editor, at, options) {
544
+ return getParentNode$1(editor, at, options);
545
+ };
546
+ var someNode = function someNode(editor, options) {
547
+ return someNode$1(editor, options);
548
+ };
549
+ var getChildren = function getChildren(entry) {
550
+ // Node.children crashes when given a text node
551
+ if (Text.isText(entry[0])) {
552
+ return [];
553
+ }
554
+
555
+ return getChildren$1(entry);
556
+ };
557
+ var isFirstChild = function isFirstChild(path) {
558
+ return isFirstChild$1(path);
559
+ };
560
+ var getDescendantNodeByPath = function getDescendantNodeByPath(root, path) {
561
+ // @ts-expect-error
562
+ return Node.get(root, path);
563
+ };
564
+ var isRangeCollapsed = function isRangeCollapsed(range) {
565
+ return isCollapsed(range);
566
+ }; // TODO: simplify
567
+
568
+ var isRangeAcrossBlocks = function isRangeAcrossBlocks(editor, options) {
569
+ return isRangeAcrossBlocks$1(editor, options);
570
+ };
571
+ var isRangeExpanded = function isRangeExpanded(range) {
572
+ return isExpanded(range);
573
+ };
574
+ var getRange = function getRange(editor, at, to) {
575
+ return getRange$1(editor, at, to);
576
+ };
577
+ var getRangeEdges = function getRangeEdges(range) {
578
+ return Range.edges(range);
579
+ };
580
+ var getRangeStart = function getRangeStart(range) {
581
+ return Range.start(range);
582
+ };
583
+ var getRangeEnd = function getRangeEnd(range) {
584
+ return Range.end(range);
585
+ };
586
+ var getAboveNode = function getAboveNode(editor, opts) {
587
+ return getAboveNode$1(editor, opts);
588
+ };
589
+ var getCommonNode = function getCommonNode(root, path, another) {
590
+ return getCommonNode$1(root, path, another);
591
+ };
592
+ var getNodeTexts = function getNodeTexts(root, opts) {
593
+ return getNodeTexts$1(root, opts);
594
+ };
595
+ var findNode = function findNode(editor, options) {
596
+ return findNode$1(editor, options);
597
+ };
598
+ var isMarkActive = function isMarkActive(editor, type) {
599
+ return isMarkActive$1(editor, type);
600
+ };
601
+ var getMarks = function getMarks(editor) {
602
+ return getMarks$1(editor);
603
+ };
604
+ var isEditor = function isEditor(value) {
605
+ return isEditor$1(value);
606
+ };
607
+ var isEditorReadOnly = function isEditorReadOnly(editor) {
608
+ return isEditorReadOnly$1(editor);
609
+ };
610
+ var isElement = function isElement(value) {
611
+ return isElement$1(value);
612
+ };
613
+ var isBlockNode = function isBlockNode(editor, value) {
614
+ return isBlock(editor, value);
615
+ };
616
+ var findNodePath = function findNodePath(editor, node) {
617
+ return findNodePath$1(editor, node);
618
+ };
619
+ var isAncestorPath = function isAncestorPath(path, another) {
620
+ return Path.isAncestor(path, another);
621
+ };
622
+ var isAncestorEmpty = function isAncestorEmpty(editor, node) {
623
+ return isAncestorEmpty$1(editor, node);
624
+ };
625
+ var getParentPath = function getParentPath(path) {
626
+ return Path.parent(path);
627
+ };
628
+ var getNextPath = function getNextPath(path) {
629
+ return Path.next(path);
630
+ };
631
+ var getPreviousPath = function getPreviousPath(path) {
632
+ return Path.previous(path);
633
+ };
634
+ var getLastChildPath = function getLastChildPath(nodeEntry) {
635
+ return getLastChildPath$1(nodeEntry);
636
+ };
637
+ var getPathLevels = function getPathLevels(path, options) {
638
+ return Path.levels(path, options);
639
+ };
640
+ var isFirstChildPath = function isFirstChildPath(path) {
641
+ return isFirstChild$1(path);
642
+ };
643
+ var isLastChildPath = function isLastChildPath(entry, childPath) {
644
+ return isLastChild(entry, childPath);
645
+ };
646
+ var matchNode = function matchNode(node, path, fn) {
647
+ return match$1(node, path, fn);
648
+ };
649
+ var someHtmlElement = function someHtmlElement(rootNode, predicate) {
650
+ return someHtmlElement$1(rootNode, predicate);
651
+ };
652
+ var getPointBefore = function getPointBefore(editor, at, options) {
653
+ return getPointBefore$1(editor, at, options);
654
+ };
655
+ var getPointAfter = function getPointAfter(editor, at, options) {
656
+ return getPointAfter$1(editor, at, options);
657
+ };
658
+ var isEndPoint = function isEndPoint(editor, point, at) {
659
+ return isEndPoint$1(editor, point, at);
660
+ };
661
+ var isInline = function isInline(editor, value) {
662
+ return isInline$2(editor, value);
663
+ };
664
+ var queryNode = function queryNode(entry, options) {
665
+ return queryNode$1(entry, options);
666
+ };
667
+ var getPluginType = function getPluginType(editor, key) {
668
+ return getPluginType$1(editor, key);
669
+ };
670
+ var createPathRef = function createPathRef(editor, at) {
671
+ return createPathRef$1(editor, at);
672
+ };
673
+ var match = function match(obj, path, predicate) {
674
+ return match$1(obj, path, predicate);
675
+ };
676
+ var getLastNodeByLevel = function getLastNodeByLevel(editor, level) {
677
+ return getLastNodeByLevel$1(editor, level);
678
+ };
679
+
680
+ /**
681
+ * Apply editor normalization rules
682
+ */
683
+
684
+ var normalize = function normalize(editor, options) {
685
+ if (options === void 0) {
686
+ options = {
687
+ force: true
688
+ };
689
+ }
690
+
691
+ return normalizeEditor(editor, options);
692
+ };
693
+ /**
694
+ * Set the selection to a location
695
+ */
696
+
697
+ var setSelection = function setSelection(editor, props) {
698
+ return setSelection$1(editor, props);
699
+ };
700
+ var select = function select(editor, location) {
701
+ return select$1(editor, location);
702
+ };
703
+ var moveSelection = function moveSelection(editor, options) {
704
+ return moveSelection$1(editor, options);
705
+ };
706
+ var moveChildren = function moveChildren(editor, options) {
707
+ return moveChildren$1(editor, options);
708
+ };
709
+ var collapseSelection = function collapseSelection(editor, options) {
710
+ return collapseSelection$1(editor, options);
711
+ };
712
+ var setNodes = function setNodes(editor, attrs, opts) {
713
+ setNodes$1(editor, attrs, opts);
714
+ };
715
+ var unsetNodes = function unsetNodes(editor, props, options) {
716
+ unsetNodes$1(editor, props, options);
717
+ };
718
+ var insertNodes = function insertNodes(editor, nodes, opts) {
719
+ return insertNodes$1(editor, nodes, opts);
720
+ };
721
+ var splitNodes = function splitNodes(editor, options) {
722
+ return splitNodes$1(editor, options);
723
+ };
724
+ var liftNodes = function liftNodes(editor, options) {
725
+ return liftNodes$1(editor, options);
726
+ };
727
+ var unwrapNodes = function unwrapNodes(editor, options) {
728
+ return unwrapNodes$1(editor, options);
729
+ };
730
+ var wrapNodes = function wrapNodes(editor, element, options) {
731
+ return wrapNodes$1(editor, element, options);
732
+ };
733
+ var toggleNodeType = function toggleNodeType(editor, options, editorOptions) {
734
+ toggleNodeType$1(editor, options, editorOptions);
735
+ };
736
+ var removeMark = function removeMark(editor, type, at) {
737
+ removeMark$1(editor, {
738
+ key: type,
739
+ at: at
740
+ });
741
+ };
742
+ var unhangRange = function unhangRange(editor, range, options) {
743
+ return unhangRange$1(editor, range, options);
744
+ };
745
+ var toggleMark = function toggleMark(editor, options) {
746
+ return toggleMark$1(editor, options);
747
+ };
748
+ var addMark = function addMark(editor, type, value) {
749
+ if (value === void 0) {
750
+ value = true;
751
+ }
752
+
753
+ addMark$1(editor, type, value);
754
+ };
755
+ var insertText = function insertText(editor, text, options) {
756
+ return insertText$1(editor, text, options);
757
+ };
758
+ var deleteText = function deleteText(editor, opts) {
759
+ deleteText$1(editor, opts);
760
+ };
761
+ var removeNodes = function removeNodes(editor, opts) {
762
+ removeNodes$1(editor, opts);
763
+ };
764
+ var moveNodes = function moveNodes(editor, opts) {
765
+ moveNodes$1(editor, opts);
766
+ };
767
+ var deleteFragment = function deleteFragment(editor, options) {
768
+ return deleteFragment$1(editor, options);
769
+ };
770
+
468
771
  var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
469
772
  var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
470
773
 
471
774
  var LINK_TYPES = [INLINES.HYPERLINK, INLINES.ENTRY_HYPERLINK, INLINES.ASSET_HYPERLINK];
472
775
  function isBlockSelected(editor, type) {
473
- var _Array$from = Array.from(Editor.nodes(editor, {
776
+ var _Array$from = Array.from(getNodeEntries(editor, {
474
777
  match: function match(node) {
475
- return Element.isElement(node) && node.type === type;
778
+ return isElement(node) && node.type === type;
476
779
  }
477
780
  })),
478
781
  match = _Array$from[0];
@@ -490,7 +793,7 @@ function getNodeEntryFromSelection(editor, nodeTypeOrTypes, path) {
490
793
  var nodeTypes = Array.isArray(nodeTypeOrTypes) ? nodeTypeOrTypes : [nodeTypeOrTypes];
491
794
 
492
795
  for (var i = 0; i < path.length; i++) {
493
- var nodeEntry = Editor.node(editor, path.slice(0, i + 1));
796
+ var nodeEntry = getNodeEntry(editor, path.slice(0, i + 1));
494
797
  if (nodeTypes.includes(nodeEntry[0].type)) return nodeEntry;
495
798
  }
496
799
 
@@ -505,13 +808,13 @@ function isNodeTypeSelected(editor, nodeType) {
505
808
  return !!node;
506
809
  }
507
810
  function moveToTheNextLine(editor) {
508
- Transforms.move(editor, {
811
+ moveSelection(editor, {
509
812
  distance: 1,
510
813
  unit: 'line'
511
814
  });
512
815
  }
513
816
  function moveToTheNextChar(editor) {
514
- Transforms.move(editor, {
817
+ moveSelection(editor, {
515
818
  distance: 1,
516
819
  unit: 'offset'
517
820
  });
@@ -525,11 +828,11 @@ function insertEmptyParagraph(editor, options) {
525
828
  data: {},
526
829
  isVoid: false
527
830
  };
528
- Transforms.insertNodes(editor, emptyParagraph, options);
831
+ insertNodes(editor, emptyParagraph, options);
529
832
  }
530
833
  function getElementFromCurrentSelection(editor) {
531
834
  if (!editor.selection) return [];
532
- return Array.from(Editor.nodes(editor, {
835
+ return Array.from(getNodeEntries(editor, {
533
836
  /**
534
837
  * editor.select is a Range, which includes anchor and focus, the beginning and the end of a selection
535
838
  * when using only editor.selection.focus, we might get only the end of the selection, or where the text cursor is
@@ -537,7 +840,7 @@ function getElementFromCurrentSelection(editor) {
537
840
  **/
538
841
  at: editor.selection,
539
842
  match: function match(node) {
540
- return Element.isElement(node);
843
+ return isElement(node);
541
844
  }
542
845
  })).flat();
543
846
  }
@@ -566,9 +869,9 @@ function isLinkActive(editor) {
566
869
  return false;
567
870
  }
568
871
 
569
- var _Array$from2 = Array.from(Editor.nodes(editor, {
872
+ var _Array$from2 = Array.from(getNodeEntries(editor, {
570
873
  match: function match(node) {
571
- return !Editor.isEditor(node) && Element.isElement(node) && LINK_TYPES.includes(node.type);
874
+ return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
572
875
  }
573
876
  })),
574
877
  link = _Array$from2[0];
@@ -577,9 +880,9 @@ function isLinkActive(editor) {
577
880
  } // TODO: move to hyperlink plugin
578
881
 
579
882
  function unwrapLink(editor) {
580
- Transforms.unwrapNodes(editor, {
883
+ unwrapNodes(editor, {
581
884
  match: function match(node) {
582
- return !Editor.isEditor(node) && Element.isElement(node) && LINK_TYPES.includes(node.type);
885
+ return !isEditor(node) && isElement(node) && LINK_TYPES.includes(node.type);
583
886
  }
584
887
  });
585
888
  } // TODO: move to hyperlink plugin
@@ -596,7 +899,7 @@ function wrapLink(editor, _ref) {
596
899
  }
597
900
 
598
901
  var selection = editor.selection;
599
- var isCollapsed = selection && Range.isCollapsed(selection);
902
+ var isCollapsed = selection && isRangeCollapsed(selection);
600
903
  var link = {
601
904
  type: type,
602
905
  data: {},
@@ -619,41 +922,41 @@ function wrapLink(editor, _ref) {
619
922
 
620
923
 
621
924
  if (path) {
622
- Transforms.setNodes(editor, link, {
925
+ setNodes(editor, link, {
623
926
  at: path
624
927
  });
625
- Transforms.insertText(editor, text, {
928
+ insertText(editor, text, {
626
929
  at: path
627
930
  });
628
- Transforms.select(editor, path);
931
+ select(editor, path);
629
932
  } else if (isCollapsed) {
630
- Transforms.insertNodes(editor, link);
933
+ insertNodes(editor, link);
631
934
  } else {
632
- Transforms.wrapNodes(editor, link, {
935
+ wrapNodes(editor, link, {
633
936
  split: true
634
937
  });
635
- Transforms["delete"](editor);
636
- Transforms.insertText(editor, text);
637
- Transforms.collapse(editor, {
938
+ deleteText(editor);
939
+ insertText(editor, text);
940
+ collapseSelection(editor, {
638
941
  edge: 'end'
639
942
  });
640
943
  }
641
944
  }
642
945
  function getAncestorPathFromSelection(editor) {
643
946
  if (!editor.selection) return undefined;
644
- return Path.levels(editor.selection.focus.path).find(function (level) {
947
+ return getPathLevels(editor.selection.focus.path).find(function (level) {
645
948
  return level.length === 1;
646
949
  });
647
950
  }
648
951
  var INLINE_TYPES = /*#__PURE__*/Object.values(INLINES);
649
952
  var isInlineOrText = function isInlineOrText(node) {
650
953
  // either text or inline elements
651
- return Text.isText(node) || Element.isElement(node) && INLINE_TYPES.includes(node.type);
954
+ return isText(node) || isElement(node) && INLINE_TYPES.includes(node.type);
652
955
  };
653
956
  var focus = function focus(editor) {
654
957
  var x = window.scrollX;
655
958
  var y = window.scrollY;
656
- ReactEditor.focus(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
959
+ focusEditor(editor); // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
657
960
 
658
961
  if (IS_SAFARI) {
659
962
  setTimeout(function () {
@@ -664,7 +967,7 @@ var focus = function focus(editor) {
664
967
  function toggleElement(editor, options, editorOptions) {
665
968
  toggleNodeType(editor, options, editorOptions); // We must reset `data` from one element to another
666
969
 
667
- Transforms.setNodes(editor, {
970
+ setNodes(editor, {
668
971
  data: {}
669
972
  });
670
973
  }
@@ -1573,35 +1876,32 @@ function insertBlock(editor, nodeType, entity) {
1573
1876
  var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
1574
1877
 
1575
1878
  if (hasText) {
1576
- Transforms.insertNodes(editor, linkedEntityBlock);
1879
+ insertNodes(editor, linkedEntityBlock);
1577
1880
  } else {
1578
- Transforms.setNodes(editor, linkedEntityBlock);
1881
+ setNodes(editor, linkedEntityBlock);
1579
1882
  }
1580
1883
 
1581
1884
  focus(editor);
1582
1885
  }
1583
1886
 
1584
1887
  var removeCommand = function removeCommand(editor) {
1585
- var _getAbove = getAbove(editor),
1586
- path = _getAbove[1];
1888
+ var _getAboveNode = getAboveNode(editor),
1889
+ path = _getAboveNode[1];
1587
1890
 
1588
- var range = Editor.range(editor, path);
1589
- Transforms.select(editor, range.focus.path);
1590
- removeMark(editor, {
1591
- key: COMMAND_PROMPT,
1592
- at: range
1593
- });
1594
- Transforms["delete"](editor);
1891
+ var range = getRange(editor, path);
1892
+ select(editor, range.focus.path);
1893
+ removeMark(editor, COMMAND_PROMPT, range);
1894
+ deleteText(editor);
1595
1895
  };
1596
1896
 
1597
1897
  var removeQuery = function removeQuery(editor) {
1598
- var _getAbove2 = getAbove(editor),
1599
- path = _getAbove2[1];
1898
+ var _getAboveNode2 = getAboveNode(editor),
1899
+ path = _getAboveNode2[1];
1600
1900
 
1601
- var range = Editor.range(editor, path);
1901
+ var range = getRange(editor, path);
1602
1902
 
1603
1903
  if (range.focus.offset - range.anchor.offset > 1) {
1604
- Transforms["delete"](editor, {
1904
+ deleteText(editor, {
1605
1905
  at: range.focus,
1606
1906
  distance: range.focus.offset - 1,
1607
1907
  reverse: true
@@ -1642,7 +1942,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1642
1942
  var selection = editor.selection;
1643
1943
  editor.insertSoftBreak();
1644
1944
  insertBlock(editor, BLOCKS.EMBEDDED_ENTRY, entry.entry);
1645
- Transforms.select(editor, selection);
1945
+ select(editor, selection);
1646
1946
  editor.tracking.onCommandPaletteAction('insert', {
1647
1947
  nodeType: BLOCKS.EMBEDDED_ENTRY
1648
1948
  });
@@ -1677,7 +1977,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1677
1977
  callback: function callback() {
1678
1978
  var inlineNode = createInlineEntryNode(entry.id);
1679
1979
  removeCommand(editor);
1680
- Transforms.insertNodes(editor, inlineNode);
1980
+ insertNodes(editor, inlineNode);
1681
1981
  editor.insertText('');
1682
1982
  editor.tracking.onCommandPaletteAction('insert', {
1683
1983
  nodeType: INLINES.EMBEDDED_ENTRY
@@ -1726,7 +2026,7 @@ var useCommands = function useCommands(sdk, query, editor) {
1726
2026
  var selection = editor.selection;
1727
2027
  editor.insertSoftBreak();
1728
2028
  insertBlock(editor, BLOCKS.EMBEDDED_ASSET, asset.entity);
1729
- Transforms.select(editor, selection);
2029
+ select(editor, selection);
1730
2030
  editor.tracking.onCommandPaletteAction('insert', {
1731
2031
  nodeType: BLOCKS.EMBEDDED_ASSET
1732
2032
  });
@@ -2008,42 +2308,36 @@ var createOnKeyDown = function createOnKeyDown() {
2008
2308
  return function (editor) {
2009
2309
  return function (event) {
2010
2310
  if (isHotkey('/', event)) {
2011
- var _setMarks;
2012
-
2013
- setMarks(editor, (_setMarks = {}, _setMarks[COMMAND_PROMPT] = true, _setMarks));
2311
+ addMark(editor, COMMAND_PROMPT);
2014
2312
  editor.tracking.onCommandPaletteAction('openRichTextCommandPalette');
2015
2313
  }
2016
2314
 
2017
2315
  var isActive = isMarkActive(editor, COMMAND_PROMPT);
2018
2316
 
2019
- if (isActive) {
2020
- if (isHotkey('enter', event)) {
2021
- event.preventDefault();
2022
- } else if (isHotkey('backspace', event)) {
2023
- var _getAbove = getAbove(editor),
2024
- path = _getAbove[1];
2317
+ if (!isActive) {
2318
+ return;
2319
+ }
2025
2320
 
2026
- var range = Editor.range(editor, path); // if it is the last character in the command string
2321
+ if (isHotkey('enter', event)) {
2322
+ return event.preventDefault();
2323
+ }
2027
2324
 
2028
- if (range.focus.offset - range.anchor.offset === 1) {
2029
- removeMark(editor, {
2030
- key: COMMAND_PROMPT,
2031
- at: range
2032
- });
2033
- }
2034
- } else if (isHotkey('escape', event)) {
2035
- var _getAbove2 = getAbove(editor),
2036
- _path = _getAbove2[1];
2325
+ var _getAboveNode = getAboveNode(editor),
2326
+ path = _getAboveNode[1];
2037
2327
 
2038
- var _range = Editor.range(editor, _path);
2328
+ var range = getRange(editor, path);
2039
2329
 
2040
- removeMark(editor, {
2041
- key: COMMAND_PROMPT,
2042
- at: _range
2043
- });
2044
- editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
2330
+ if (isHotkey('backspace', event)) {
2331
+ // if it is the last character in the command string
2332
+ if (range.focus.offset - range.anchor.offset === 1) {
2333
+ removeMark(editor, COMMAND_PROMPT, range);
2045
2334
  }
2046
2335
  }
2336
+
2337
+ if (isHotkey('escape', event)) {
2338
+ removeMark(editor, COMMAND_PROMPT, range);
2339
+ editor.tracking.onCommandPaletteAction('cancelRichTextCommandPalette');
2340
+ }
2047
2341
  };
2048
2342
  };
2049
2343
  };
@@ -2089,9 +2383,9 @@ function createDragAndDropPlugin() {
2089
2383
  // If true, the next handlers will be skipped.
2090
2384
  onDrop: function onDrop(editor) {
2091
2385
  return function (event) {
2092
- var _Array$from = Array.from(getNodes(editor, {
2386
+ var _Array$from = Array.from(getNodeEntries(editor, {
2093
2387
  match: function match(node) {
2094
- return DRAGGABLE_TYPES.includes(node == null ? void 0 : node.type);
2388
+ return DRAGGABLE_TYPES.includes(node.type);
2095
2389
  }
2096
2390
  })),
2097
2391
  draggingBlock = _Array$from[0];
@@ -2135,7 +2429,7 @@ function withLinkTracking(Component) {
2135
2429
  return function ComponentWithTracking(props) {
2136
2430
  var editor = useContentfulEditorRef();
2137
2431
  var onEntityFetchComplete = React__default.useCallback(function () {
2138
- return editor.tracking.onViewportAction('linkRendered');
2432
+ return editor == null ? void 0 : editor.tracking.onViewportAction('linkRendered');
2139
2433
  }, [editor]);
2140
2434
  return /*#__PURE__*/React__default.createElement(Component, _extends({}, props, {
2141
2435
  onEntityFetchComplete: onEntityFetchComplete
@@ -2293,7 +2587,7 @@ function LinkedEntityBlock(props) {
2293
2587
  var isSelected = useSelected();
2294
2588
  var editor = useContentfulEditor();
2295
2589
  var sdk = useSdkContext();
2296
- var isDisabled = useReadOnly();
2590
+ var isDisabled = useReadOnly$1();
2297
2591
  var _element$data$target$ = element.data.target.sys,
2298
2592
  entityId = _element$data$target$.id,
2299
2593
  entityType = _element$data$target$.linkType;
@@ -2305,8 +2599,8 @@ function LinkedEntityBlock(props) {
2305
2599
  }, [sdk, entityId, entityType]);
2306
2600
  var handleRemoveClick = React__default.useCallback(function () {
2307
2601
  if (!editor) return;
2308
- var pathToElement = ReactEditor.findPath(editor, element);
2309
- Transforms.removeNodes(editor, {
2602
+ var pathToElement = findNodePath(editor, element);
2603
+ removeNodes(editor, {
2310
2604
  at: pathToElement
2311
2605
  });
2312
2606
  }, [editor, element]);
@@ -2416,7 +2710,7 @@ function getEntityTypeFromRichTextNode(nodeType) {
2416
2710
 
2417
2711
  function selectEntityAndInsert(_x, _x2, _x3, _x4) {
2418
2712
  return _selectEntityAndInsert.apply(this, arguments);
2419
- }
2713
+ } // TODO: incorporate this logic inside the trailingParagraph plugin instead
2420
2714
 
2421
2715
  function _selectEntityAndInsert() {
2422
2716
  _selectEntityAndInsert = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(nodeType, sdk, editor, logAction) {
@@ -2452,7 +2746,7 @@ function _selectEntityAndInsert() {
2452
2746
  return _context.abrupt("return");
2453
2747
 
2454
2748
  case 12:
2455
- Transforms.select(editor, selection);
2749
+ select(editor, selection);
2456
2750
  insertBlock$1(editor, nodeType, entity);
2457
2751
  ensureFollowingParagraph(editor);
2458
2752
  logAction('insert', {
@@ -2470,37 +2764,25 @@ function _selectEntityAndInsert() {
2470
2764
  }
2471
2765
 
2472
2766
  function ensureFollowingParagraph(editor) {
2473
- /*
2474
- If the new block isn't followed by a sibling paragraph we insert a new empty one
2475
- */
2476
- var next = Editor.next(editor);
2477
-
2478
- if (!next) {
2479
- return insertEmptyParagraph(editor);
2480
- }
2767
+ var _lastNode$0$type;
2481
2768
 
2482
- var parent = Editor.above(editor, {
2483
- voids: false,
2484
- match: function match(e) {
2485
- return !Element.isElement(e) || ![BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY].includes(e.type);
2769
+ var entityBlock = getAboveNode(editor, {
2770
+ match: {
2771
+ type: [BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY]
2486
2772
  }
2487
2773
  });
2488
2774
 
2489
- if (Editor.isEditor(parent)) {
2490
- // at level 0, a following paragraph is handled by the tralingParagraph plugin
2491
- moveToTheNextChar(editor);
2775
+ if (!entityBlock) {
2492
2776
  return;
2493
2777
  }
2494
2778
 
2495
- var paragraph = Editor.above(editor, {
2496
- at: next[1],
2497
- match: function match(e) {
2498
- return Element.isElement(e) && TEXT_CONTAINERS.includes(e.type);
2499
- }
2500
- });
2779
+ var level = entityBlock[1].length - 1;
2780
+ var lastNode = getLastNodeByLevel(editor, level);
2781
+ var isTextContainer = 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)
2782
+ // we insert a new empty one. Level 0 is handled by the trailingParagraph plugin
2501
2783
 
2502
- if (!paragraph || !parent || !Path.isChild(paragraph[1], parent[1])) {
2503
- return insertEmptyParagraph(editor);
2784
+ if (level !== 0 && !isTextContainer) {
2785
+ insertEmptyParagraph(editor);
2504
2786
  }
2505
2787
 
2506
2788
  moveToTheNextChar(editor);
@@ -2532,9 +2814,9 @@ function insertBlock$1(editor, nodeType, entity) {
2532
2814
  var hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
2533
2815
 
2534
2816
  if (hasText) {
2535
- Transforms.insertNodes(editor, linkedEntityBlock);
2817
+ insertNodes(editor, linkedEntityBlock);
2536
2818
  } else {
2537
- Transforms.setNodes(editor, linkedEntityBlock);
2819
+ setNodes(editor, linkedEntityBlock);
2538
2820
  }
2539
2821
 
2540
2822
  focus(editor);
@@ -2559,11 +2841,20 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
2559
2841
  switch (_context.prev = _context.next) {
2560
2842
  case 0:
2561
2843
  event.preventDefault();
2844
+
2845
+ if (editor) {
2846
+ _context.next = 3;
2847
+ break;
2848
+ }
2849
+
2850
+ return _context.abrupt("return");
2851
+
2852
+ case 3:
2562
2853
  onClose();
2563
- _context.next = 4;
2854
+ _context.next = 6;
2564
2855
  return selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onToolbarAction);
2565
2856
 
2566
- case 4:
2857
+ case 6:
2567
2858
  case "end":
2568
2859
  return _context.stop();
2569
2860
  }
@@ -2623,7 +2914,7 @@ function getWithEmbeddedEntityEvents(nodeType, sdk) {
2623
2914
 
2624
2915
  if (isDelete || isBackspace) {
2625
2916
  event.preventDefault();
2626
- Transforms.removeNodes(editor, {
2917
+ removeNodes(editor, {
2627
2918
  at: pathToSelectedElement
2628
2919
  });
2629
2920
  }
@@ -2822,7 +3113,7 @@ function EmbeddedEntityInline(props) {
2822
3113
  var sdk = useSdkContext();
2823
3114
  var isSelected = useSelected();
2824
3115
  var entryId = props.element.data.target.sys.id;
2825
- var isDisabled = useReadOnly();
3116
+ var isDisabled = useReadOnly$1();
2826
3117
 
2827
3118
  function handleEditClick() {
2828
3119
  return sdk.navigator.openEntry(entryId, {
@@ -2832,8 +3123,8 @@ function EmbeddedEntityInline(props) {
2832
3123
 
2833
3124
  function handleRemoveClick() {
2834
3125
  if (!editor) return;
2835
- var pathToElement = ReactEditor.findPath(editor, props.element);
2836
- Transforms.removeNodes(editor, {
3126
+ var pathToElement = findNodePath(editor, props.element);
3127
+ removeNodes(editor, {
2837
3128
  at: pathToElement
2838
3129
  });
2839
3130
  }
@@ -2902,8 +3193,8 @@ function _selectEntityAndInsert$1() {
2902
3193
 
2903
3194
  return _context2.abrupt("return", new Promise(function (resolve) {
2904
3195
  setTimeout(function () {
2905
- Transforms.setSelection(editor, selection);
2906
- Transforms.insertNodes(editor, inlineEntryNode);
3196
+ setSelection(editor, selection);
3197
+ insertNodes(editor, inlineEntryNode);
2907
3198
  resolve();
2908
3199
  }, 0);
2909
3200
  }));
@@ -3114,7 +3405,7 @@ function ToolbarHeadingButton(props) {
3114
3405
  }
3115
3406
 
3116
3407
  function extractNodes(editor, path, match) {
3117
- return Array.from(getNodes(editor, {
3408
+ return Array.from(getNodeEntries(editor, {
3118
3409
  match: match,
3119
3410
  at: path,
3120
3411
  mode: 'lowest'
@@ -3140,7 +3431,7 @@ function extractParagraphs(editor, path) {
3140
3431
 
3141
3432
  var transformRemove = function transformRemove(editor, _ref) {
3142
3433
  var path = _ref[1];
3143
- Transforms.removeNodes(editor, {
3434
+ removeNodes(editor, {
3144
3435
  at: path
3145
3436
  });
3146
3437
  };
@@ -3148,20 +3439,20 @@ var transformParagraphs = function transformParagraphs(editor, entry) {
3148
3439
  var path = entry[1];
3149
3440
  var nodes = extractParagraphs(editor, path);
3150
3441
  transformRemove(editor, entry);
3151
- Transforms.insertNodes(editor, nodes, {
3442
+ insertNodes(editor, nodes, {
3152
3443
  at: path
3153
3444
  });
3154
3445
  };
3155
3446
  var transformUnwrap = function transformUnwrap(editor, _ref2) {
3156
3447
  var path = _ref2[1];
3157
- Transforms.unwrapNodes(editor, {
3448
+ unwrapNodes(editor, {
3158
3449
  at: path
3159
3450
  });
3160
3451
  };
3161
3452
  var transformWrapIn = function transformWrapIn(type) {
3162
3453
  return function (editor, _ref3) {
3163
3454
  var path = _ref3[1];
3164
- Transforms.wrapNodes(editor, {
3455
+ wrapNodes(editor, {
3165
3456
  type: type,
3166
3457
  data: {},
3167
3458
  children: []
@@ -3172,7 +3463,7 @@ var transformWrapIn = function transformWrapIn(type) {
3172
3463
  };
3173
3464
  var transformLift = function transformLift(editor, _ref4) {
3174
3465
  var path = _ref4[1];
3175
- Transforms.liftNodes(editor, {
3466
+ liftNodes(editor, {
3176
3467
  at: path
3177
3468
  });
3178
3469
  };
@@ -3251,7 +3542,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
3251
3542
  // insertBreak implementation
3252
3543
  filter: function filter(_ref3) {
3253
3544
  var path = _ref3[1];
3254
- return !getAbove(editor, {
3545
+ return !getAboveNode(editor, {
3255
3546
  at: path,
3256
3547
  match: {
3257
3548
  type: BLOCKS.LIST_ITEM
@@ -3351,7 +3642,7 @@ function withHrEvents(editor) {
3351
3642
 
3352
3643
  if (isBackspace || isDelete) {
3353
3644
  event.preventDefault();
3354
- Transforms.removeNodes(editor, {
3645
+ removeNodes(editor, {
3355
3646
  at: pathToSelectedHr
3356
3647
  });
3357
3648
  }
@@ -3372,7 +3663,7 @@ function ToolbarHrButton(props) {
3372
3663
  isVoid: true
3373
3664
  };
3374
3665
  var hasText = !!getText(editor, editor.selection.focus.path);
3375
- hasText ? Transforms.insertNodes(editor, hr) : setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
3666
+ hasText ? insertNodes(editor, hr) : setNodes(editor, hr); // Move focus to the next paragraph (added by TrailingParagraph plugin)
3376
3667
 
3377
3668
  moveToTheNextLine(editor);
3378
3669
  focus(editor);
@@ -3658,7 +3949,7 @@ function _addOrEditLink() {
3658
3949
  while (1) {
3659
3950
  switch (_context3.prev = _context3.next) {
3660
3951
  case 0:
3661
- isReadOnly = ReactEditor.isReadOnly(editor);
3952
+ isReadOnly = isEditorReadOnly(editor);
3662
3953
  selectionBeforeBlur = editor.selection ? _extends({}, editor.selection) : undefined;
3663
3954
 
3664
3955
  if (!(!targetPath && !selectionBeforeBlur)) {
@@ -3673,13 +3964,13 @@ function _addOrEditLink() {
3673
3964
 
3674
3965
  if (node && path) {
3675
3966
  linkType = node.type;
3676
- linkText = Editor.string(editor, path);
3967
+ linkText = getText(editor, path);
3677
3968
  linkTarget = node.data.uri || '';
3678
3969
  linkEntity = node.data.target;
3679
3970
  }
3680
3971
 
3681
3972
  selectionAfterFocus = targetPath != null ? targetPath : selectionBeforeBlur;
3682
- currentLinkText = linkText || (editor.selection ? Editor.string(editor, editor.selection) : '');
3973
+ currentLinkText = linkText || (editor.selection ? getText(editor, editor.selection) : '');
3683
3974
  isEditing = Boolean(node && path);
3684
3975
  logAction(isEditing ? 'openEditHyperlinkDialog' : 'openCreateHyperlinkDialog');
3685
3976
  _context3.next = 12;
@@ -3704,7 +3995,7 @@ function _addOrEditLink() {
3704
3995
 
3705
3996
  case 12:
3706
3997
  data = _context3.sent;
3707
- Transforms.select(editor, selectionAfterFocus);
3998
+ select(editor, selectionAfterFocus);
3708
3999
 
3709
4000
  if (data) {
3710
4001
  _context3.next = 18;
@@ -3717,7 +4008,7 @@ function _addOrEditLink() {
3717
4008
 
3718
4009
  case 18:
3719
4010
  text = data.linkText, url = data.linkTarget, type = data.linkType, target = data.linkEntity;
3720
- Editor.withoutNormalizing(editor, function () {
4011
+ withoutNormalizing(editor, function () {
3721
4012
  insertLink(editor, {
3722
4013
  text: text,
3723
4014
  url: url,
@@ -3794,8 +4085,9 @@ function ToolbarHyperlinkButton(props) {
3794
4085
  }
3795
4086
 
3796
4087
  var hasText = function hasText(editor, entry) {
3797
- var node = entry[0];
3798
- return !isAncestorEmpty(editor, node) && Node.string(node).trim() !== '';
4088
+ var node = entry[0],
4089
+ path = entry[1];
4090
+ return !isAncestorEmpty$1(editor, node) && getText(editor, path).trim() !== '';
3799
4091
  };
3800
4092
 
3801
4093
  function truncate(str, length) {
@@ -3986,11 +4278,11 @@ function EntityHyperlink(props) {
3986
4278
  event.preventDefault();
3987
4279
  event.stopPropagation();
3988
4280
  if (!editor) return;
3989
- var p = ReactEditor.toSlatePoint(editor, [event.target, 0], {
3990
- exactMatch: false,
3991
- suppressThrow: false
3992
- });
3993
- addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4281
+ var p = fromDOMPoint(editor, [event.target, 0]);
4282
+
4283
+ if (p) {
4284
+ addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4285
+ }
3994
4286
  }
3995
4287
 
3996
4288
  return /*#__PURE__*/createElement(Tooltip, {
@@ -4016,11 +4308,11 @@ function UrlHyperlink(props) {
4016
4308
  event.preventDefault();
4017
4309
  event.stopPropagation();
4018
4310
  if (!editor) return;
4019
- var p = ReactEditor.toSlatePoint(editor, [event.target, 0], {
4311
+ var p = fromDOMPoint(editor, [event.target, 0], {
4020
4312
  exactMatch: false,
4021
4313
  suppressThrow: false
4022
4314
  });
4023
- addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
4315
+ addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p == null ? void 0 : p.path);
4024
4316
  }
4025
4317
 
4026
4318
  return /*#__PURE__*/createElement(Tooltip, {
@@ -4192,24 +4484,25 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
4192
4484
  var previousListItemPath;
4193
4485
 
4194
4486
  try {
4195
- previousListItemPath = Path.previous(listItemPath);
4487
+ previousListItemPath = getPreviousPath(listItemPath);
4196
4488
  } catch (e) {
4197
4489
  return;
4198
4490
  } // Previous sibling is the new parent
4199
4491
 
4200
4492
 
4201
- var previousSiblingItem = Editor.node(editor, previousListItemPath);
4493
+ var previousSiblingItem = getNodeEntry(editor, previousListItemPath);
4202
4494
 
4203
4495
  if (previousSiblingItem) {
4204
4496
  var previousPath = previousSiblingItem[1];
4205
- var subList = Array.from(Node.children(editor, previousPath)).find(function (_ref2) {
4206
- var n = _ref2[0];
4207
- return match(n, {
4497
+ var subList = Array.from(getNodeChildren(editor, previousPath)).find(function (_ref2) {
4498
+ var n = _ref2[0],
4499
+ path = _ref2[1];
4500
+ return match(n, path, {
4208
4501
  type: getListTypes(editor)
4209
4502
  });
4210
4503
  });
4211
- var newPath = Path.next(getLastChildPath(subList != null ? subList : previousSiblingItem));
4212
- Editor.withoutNormalizing(editor, function () {
4504
+ var newPath = getNextPath(getLastChildPath(subList != null ? subList : previousSiblingItem));
4505
+ withoutNormalizing(editor, function () {
4213
4506
  if (!subList) {
4214
4507
  // Create new sub-list
4215
4508
  wrapNodes(editor, {
@@ -4222,7 +4515,7 @@ var moveListItemDown = function moveListItemDown(editor, _ref) {
4222
4515
  } // Move the current item to the sub-list
4223
4516
 
4224
4517
 
4225
- Transforms.moveNodes(editor, {
4518
+ moveNodes(editor, {
4226
4519
  at: listItemPath,
4227
4520
  to: newPath
4228
4521
  });
@@ -4243,7 +4536,7 @@ var moveListItems = function moveListItems(editor, _temp) {
4243
4536
  _ref$at = _ref.at,
4244
4537
  at = _ref$at === void 0 ? (_editor$selection = editor.selection) != null ? _editor$selection : undefined : _ref$at;
4245
4538
 
4246
- var _nodes = getNodes(editor, {
4539
+ var _nodes = getNodeEntries(editor, {
4247
4540
  at: at,
4248
4541
  match: {
4249
4542
  type: getPluginType(editor, ELEMENT_LIC)
@@ -4258,19 +4551,19 @@ var moveListItems = function moveListItems(editor, _temp) {
4258
4551
 
4259
4552
  lics.forEach(function (lic) {
4260
4553
  var licPath = lic[1];
4261
- var liPath = Path.parent(licPath);
4554
+ var liPath = getParentPath(licPath);
4262
4555
  var isAncestor = highestLicPaths.some(function (path) {
4263
- var highestLiPath = Path.parent(path);
4264
- return Path.isAncestor(highestLiPath, liPath);
4556
+ var highestLiPath = getParentPath(path);
4557
+ return isAncestorPath(highestLiPath, liPath);
4265
4558
  });
4266
4559
 
4267
4560
  if (!isAncestor) {
4268
4561
  highestLicPaths.push(licPath);
4269
- highestLicPathRefs.push(Editor.pathRef(editor, licPath));
4562
+ highestLicPathRefs.push(createPathRef(editor, licPath));
4270
4563
  }
4271
4564
  });
4272
4565
  var licPathRefsToMove = increase ? highestLicPathRefs : highestLicPathRefs.reverse();
4273
- Editor.withoutNormalizing(editor, function () {
4566
+ withoutNormalizing(editor, function () {
4274
4567
  licPathRefsToMove.forEach(function (licPathRef) {
4275
4568
  var licPath = licPathRef.unref();
4276
4569
  if (!licPath) return;
@@ -4291,16 +4584,18 @@ var moveListItems = function moveListItems(editor, _temp) {
4291
4584
  });
4292
4585
  };
4293
4586
 
4587
+ var ELEMENT_DEFAULT = ELEMENT_DEFAULT$1;
4588
+
4294
4589
  /**
4295
4590
  * Credit: Modified version of Plate's list plugin
4296
4591
  * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
4297
4592
  */
4298
4593
 
4299
4594
  function hasUnliftedListItems(editor, at) {
4300
- return Editor.nodes(editor, {
4595
+ return getNodeEntries(editor, {
4301
4596
  at: at,
4302
4597
  match: function match(node, path) {
4303
- return Element.isElement(node) && node.type === BLOCKS.LIST_ITEM && path.length >= 2;
4598
+ return isElement(node) && node.type === BLOCKS.LIST_ITEM && path.length >= 2;
4304
4599
  }
4305
4600
  }).next().done;
4306
4601
  }
@@ -4309,13 +4604,13 @@ var unwrapList = function unwrapList(editor, _temp) {
4309
4604
  var _ref = _temp === void 0 ? {} : _temp,
4310
4605
  at = _ref.at;
4311
4606
 
4312
- Editor.withoutNormalizing(editor, function () {
4607
+ withoutNormalizing(editor, function () {
4313
4608
  do {
4314
4609
  // lift list items to the root level
4315
- Transforms.liftNodes(editor, {
4610
+ liftNodes(editor, {
4316
4611
  at: at,
4317
4612
  match: function match(node) {
4318
- return Element.isElement(node) && node.type === BLOCKS.LIST_ITEM;
4613
+ return isElement(node) && node.type === BLOCKS.LIST_ITEM;
4319
4614
  },
4320
4615
  mode: 'lowest'
4321
4616
  });
@@ -4335,12 +4630,12 @@ var unwrapList = function unwrapList(editor, _temp) {
4335
4630
  var listTypes = [BLOCKS.UL_LIST, BLOCKS.OL_LIST];
4336
4631
  var toggleList = function toggleList(editor, _ref) {
4337
4632
  var type = _ref.type;
4338
- return Editor.withoutNormalizing(editor, function () {
4633
+ return withoutNormalizing(editor, function () {
4339
4634
  if (!editor.selection) {
4340
4635
  return;
4341
4636
  }
4342
4637
 
4343
- if (isCollapsed(editor.selection) || !isRangeAcrossBlocks(editor)) {
4638
+ if (isRangeCollapsed(editor.selection) || !isRangeAcrossBlocks(editor)) {
4344
4639
  // selection is collapsed
4345
4640
  var res = getListItemEntry(editor);
4346
4641
 
@@ -4367,7 +4662,7 @@ var toggleList = function toggleList(editor, _ref) {
4367
4662
  data: {}
4368
4663
  };
4369
4664
  wrapNodes(editor, _list);
4370
- var nodes = [].concat(getNodes(editor, {
4665
+ var nodes = [].concat(getNodeEntries(editor, {
4371
4666
  match: {
4372
4667
  type: getPluginType(editor, ELEMENT_DEFAULT)
4373
4668
  }
@@ -4388,29 +4683,31 @@ var toggleList = function toggleList(editor, _ref) {
4388
4683
  }
4389
4684
  } else {
4390
4685
  // selection is a range
4391
- var _Range$edges = Range.edges(editor.selection),
4392
- startPoint = _Range$edges[0],
4393
- endPoint = _Range$edges[1];
4686
+ var _getRangeEdges = getRangeEdges(editor.selection),
4687
+ startPoint = _getRangeEdges[0],
4688
+ endPoint = _getRangeEdges[1];
4394
4689
 
4395
- var commonEntry = Node.common(editor, startPoint.path, endPoint.path);
4690
+ var commonEntry = getCommonNode(editor, startPoint.path, endPoint.path);
4396
4691
 
4397
4692
  if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === BLOCKS.LIST_ITEM) {
4398
4693
  var listType = commonEntry[0].type;
4399
4694
 
4400
4695
  if (commonEntry[0].type === BLOCKS.LIST_ITEM) {
4401
- listType = Editor.parent(editor, commonEntry[1])[0].type;
4696
+ var _getParentNode, _getParentNode$;
4697
+
4698
+ listType = (_getParentNode = getParentNode(editor, commonEntry[1])) == null ? void 0 : (_getParentNode$ = _getParentNode[0]) == null ? void 0 : _getParentNode$.type;
4402
4699
  }
4403
4700
 
4404
4701
  if (listType !== type) {
4405
4702
  var startList = findNode(editor, {
4406
- at: Range.start(editor.selection),
4703
+ at: getRangeStart(editor.selection),
4407
4704
  match: {
4408
4705
  type: listTypes
4409
4706
  },
4410
4707
  mode: 'lowest'
4411
4708
  });
4412
4709
  var endList = findNode(editor, {
4413
- at: Range.end(editor.selection),
4710
+ at: getRangeEnd(editor.selection),
4414
4711
  match: {
4415
4712
  type: listTypes
4416
4713
  },
@@ -4437,7 +4734,7 @@ var toggleList = function toggleList(editor, _ref) {
4437
4734
  } else {
4438
4735
  var rootPathLength = commonEntry[1].length;
4439
4736
 
4440
- var _nodes = Array.from(getNodes(editor, {
4737
+ var _nodes = Array.from(getNodeEntries(editor, {
4441
4738
  mode: 'all'
4442
4739
  })).filter(function (_ref2) {
4443
4740
  var path = _ref2[1];
@@ -4485,7 +4782,7 @@ var onKeyDownList = function onKeyDownList(editor, _ref) {
4485
4782
  hotkey = _ref.options.hotkey;
4486
4783
  return function (e) {
4487
4784
  if (e.key === 'Tab' && editor.selection) {
4488
- var listSelected = getAbove(editor, {
4785
+ var listSelected = getAboveNode(editor, {
4489
4786
  at: editor.selection,
4490
4787
  match: {
4491
4788
  type: type
@@ -4523,14 +4820,14 @@ var isList = function isList(node) {
4523
4820
  var hasListAsDirectParent = function hasListAsDirectParent(editor, _ref) {
4524
4821
  var path = _ref[1];
4525
4822
 
4526
- var _ref2 = getParent(editor, path) || [],
4823
+ var _ref2 = getParentNode$1(editor, path) || [],
4527
4824
  parentNode = _ref2[0];
4528
4825
 
4529
4826
  return isList(parentNode);
4530
4827
  };
4531
4828
 
4532
4829
  var getNearestListAncestor = function getNearestListAncestor(editor, path) {
4533
- return getAbove(editor, {
4830
+ return getAboveNode$1(editor, {
4534
4831
  at: path,
4535
4832
  mode: 'lowest',
4536
4833
  match: isList
@@ -4550,7 +4847,7 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
4550
4847
  parentList = _getNearestListAncest[0];
4551
4848
 
4552
4849
  var parentListType = parentList == null ? void 0 : parentList.type;
4553
- Transforms.wrapNodes(editor, {
4850
+ wrapNodes(editor, {
4554
4851
  type: parentListType || BLOCKS.UL_LIST,
4555
4852
  children: [],
4556
4853
  data: {}
@@ -4558,24 +4855,23 @@ var normalizeOrphanedListItem = function normalizeOrphanedListItem(editor, _ref3
4558
4855
  at: path
4559
4856
  });
4560
4857
  };
4561
- var isNonEmptyListItem = function isNonEmptyListItem(editor, _ref4) {
4562
- var path = _ref4[1];
4563
- var listItemChildren = Array.from(Node.children(editor, path));
4858
+ var isNonEmptyListItem = function isNonEmptyListItem(_, entry) {
4859
+ var listItemChildren = getChildren(entry);
4564
4860
  return listItemChildren.length !== 0;
4565
4861
  };
4566
- var firstNodeIsNotList = function firstNodeIsNotList(_editor, _ref5) {
4567
- var node = _ref5[0];
4862
+ var firstNodeIsNotList = function firstNodeIsNotList(_editor, _ref4) {
4863
+ var node = _ref4[0];
4568
4864
 
4569
4865
  if (node.children.length === 1) {
4570
4866
  var firstNode = node.children[0];
4571
- return !Text.isText(firstNode) && !isList(firstNode);
4867
+ return !isText(firstNode) && !isList(firstNode);
4572
4868
  }
4573
4869
 
4574
4870
  return true;
4575
4871
  };
4576
- var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref6) {
4577
- var path = _ref6[1];
4578
- Transforms.insertNodes(editor, [{
4872
+ var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref5) {
4873
+ var path = _ref5[1];
4874
+ insertNodes(editor, [{
4579
4875
  type: BLOCKS.PARAGRAPH,
4580
4876
  data: {},
4581
4877
  children: [{
@@ -4588,10 +4884,10 @@ var insertParagraphAsChild = function insertParagraphAsChild(editor, _ref6) {
4588
4884
  var replaceNodeWithListItems = function replaceNodeWithListItems(editor, entry) {
4589
4885
  var node = entry[0],
4590
4886
  path = entry[1];
4591
- Transforms.removeNodes(editor, {
4887
+ removeNodes(editor, {
4592
4888
  at: path
4593
4889
  });
4594
- Transforms.insertNodes(editor, node.children[0].children, {
4890
+ insertNodes(editor, node.children[0].children, {
4595
4891
  at: path
4596
4892
  });
4597
4893
  };
@@ -4602,12 +4898,12 @@ var isListTypeActive = function isListTypeActive(editor, type) {
4602
4898
  return false;
4603
4899
  }
4604
4900
 
4605
- if (Range.isExpanded(selection)) {
4606
- var _Range$edges = Range.edges(selection),
4607
- start = _Range$edges[0],
4608
- end = _Range$edges[1];
4901
+ if (isRangeExpanded(selection)) {
4902
+ var _getRangeEdges = getRangeEdges(selection),
4903
+ start = _getRangeEdges[0],
4904
+ end = _getRangeEdges[1];
4609
4905
 
4610
- var node = Node.common(editor, start.path, end.path);
4906
+ var node = getCommonNode(editor, start.path, end.path);
4611
4907
 
4612
4908
  if (node[0].type === type) {
4613
4909
  return true;
@@ -4615,7 +4911,7 @@ var isListTypeActive = function isListTypeActive(editor, type) {
4615
4911
  } // Lists can be nested. Here, we take the list type at the lowest level
4616
4912
 
4617
4913
 
4618
- var listNode = getBlockAbove(editor, {
4914
+ var listNode = getBlockAbove$1(editor, {
4619
4915
  match: {
4620
4916
  type: [BLOCKS.OL_LIST, BLOCKS.UL_LIST]
4621
4917
  },
@@ -4636,7 +4932,7 @@ var emptyListItemNode = function emptyListItemNode(editor, withChildren) {
4636
4932
  var children = [];
4637
4933
 
4638
4934
  if (withChildren) {
4639
- var marks = Editor.marks(editor) || {};
4935
+ var marks = getMarks(editor) || {};
4640
4936
  children = [{
4641
4937
  type: BLOCKS.PARAGRAPH,
4642
4938
  data: {},
@@ -4663,7 +4959,7 @@ var insertListItem = function insertListItem(editor) {
4663
4959
  } // Naming it paragraph for simplicity but can be a heading as well
4664
4960
 
4665
4961
 
4666
- var paragraph = getAbove(editor, {
4962
+ var paragraph = getAboveNode(editor, {
4667
4963
  match: {
4668
4964
  type: TEXT_CONTAINERS
4669
4965
  }
@@ -4674,7 +4970,7 @@ var insertListItem = function insertListItem(editor) {
4674
4970
  }
4675
4971
 
4676
4972
  var paragraphPath = paragraph[1];
4677
- var listItem = getParent(editor, paragraphPath);
4973
+ var listItem = getParentNode(editor, paragraphPath);
4678
4974
 
4679
4975
  if (!listItem) {
4680
4976
  return false;
@@ -4688,7 +4984,7 @@ var insertListItem = function insertListItem(editor) {
4688
4984
  } // We are in a li>p (or heading)
4689
4985
 
4690
4986
 
4691
- Editor.withoutNormalizing(editor, function () {
4987
+ withoutNormalizing(editor, function () {
4692
4988
  if (!editor.selection) {
4693
4989
  return;
4694
4990
  } // Check the cursor position in the current paragraph
@@ -4696,22 +4992,22 @@ var insertListItem = function insertListItem(editor) {
4696
4992
 
4697
4993
  var isAtStart = isSelectionAtBlockStart(editor);
4698
4994
  var isAtEnd = isSelectionAtBlockEnd(editor);
4699
- var isAtStartOfListItem = isAtStart && isFirstChild(paragraphPath);
4995
+ var isAtStartOfListItem = isAtStart && isFirstChildPath(paragraphPath);
4700
4996
  var shouldSplit = !isAtStart && !isAtEnd; // Split the current paragraph content if necessary
4701
4997
 
4702
4998
  if (shouldSplit) {
4703
- Transforms.splitNodes(editor);
4999
+ splitNodes(editor);
4704
5000
  } // Insert the new li
4705
5001
 
4706
5002
 
4707
- var newListItemPath = isAtStartOfListItem ? listItemPath : Path.next(listItemPath);
5003
+ var newListItemPath = isAtStartOfListItem ? listItemPath : getNextPath(listItemPath);
4708
5004
  insertNodes(editor, // Add an empty paragraph to the new li if We will not move some
4709
5005
  // paragraphs over there.
4710
5006
  emptyListItemNode(editor, !shouldSplit), {
4711
5007
  at: newListItemPath
4712
5008
  }); // Move children *after* selection to the new li
4713
5009
 
4714
- var fromPath = isAtStart ? paragraphPath : Path.next(paragraphPath);
5010
+ var fromPath = isAtStart ? paragraphPath : getNextPath(paragraphPath);
4715
5011
  var fromStartIndex = fromPath[fromPath.length - 1] || 0; // On split we don't add paragraph to the new li so we move
4716
5012
  // content to the very beginning. Otherwise, account for the empty
4717
5013
  // paragraph at the beginning by moving the content after
@@ -4727,8 +5023,8 @@ var insertListItem = function insertListItem(editor) {
4727
5023
  } // Move cursor to the start of the new li
4728
5024
 
4729
5025
 
4730
- Transforms.select(editor, newListItemPath);
4731
- Transforms.collapse(editor, {
5026
+ select(editor, newListItemPath);
5027
+ collapseSelection(editor, {
4732
5028
  edge: 'start'
4733
5029
  });
4734
5030
  }); // Returning True skips processing other editor.insertBreak handlers
@@ -4762,11 +5058,11 @@ var listBreak = function listBreak(editor) {
4762
5058
  }
4763
5059
  }
4764
5060
 
4765
- var didReset = onKeyDownResetNode(editor, mockPlugin({
5061
+ var didReset = onKeyDownResetNode(editor, mockPlugin$1({
4766
5062
  options: {
4767
5063
  rules: [{
4768
- types: [getPluginType(editor, ELEMENT_LI)],
4769
- defaultType: getPluginType(editor, ELEMENT_DEFAULT),
5064
+ types: [getPluginType$1(editor, ELEMENT_LI)],
5065
+ defaultType: getPluginType$1(editor, ELEMENT_DEFAULT$1),
4770
5066
  predicate: function predicate() {
4771
5067
  return !moved && isBlockAboveEmpty(editor);
4772
5068
  },
@@ -4807,13 +5103,13 @@ var insertListBreak = function insertListBreak(editor) {
4807
5103
  */
4808
5104
 
4809
5105
  var getFirstAncestorOfType = function getFirstAncestorOfType(root, entry) {
4810
- var ancestor = Path.parent(entry[1]);
5106
+ var ancestor = getParentPath(entry[1]);
4811
5107
 
4812
- while (Node.get(root, ancestor).type !== BLOCKS.LIST_ITEM) {
4813
- ancestor = Path.parent(ancestor);
5108
+ while (getDescendantNodeByPath(root, ancestor).type !== BLOCKS.LIST_ITEM) {
5109
+ ancestor = getParentPath(ancestor);
4814
5110
  }
4815
5111
 
4816
- return [Node.get(root, ancestor), ancestor];
5112
+ return [getDescendantNodeByPath(root, ancestor), ancestor];
4817
5113
  };
4818
5114
 
4819
5115
  var isListRoot = function isListRoot(node) {
@@ -4831,9 +5127,9 @@ var trimList = function trimList(listRoot) {
4831
5127
  return [listRoot];
4832
5128
  }
4833
5129
 
4834
- var textEntries = Array.from(Node.texts(listRoot));
5130
+ var textEntries = Array.from(getNodeTexts(listRoot));
4835
5131
  var commonAncestorEntry = textEntries.reduce(function (commonAncestor, textEntry) {
4836
- return Path.isAncestor(commonAncestor[1], textEntry[1]) ? commonAncestor : Node.common(listRoot, textEntry[1], commonAncestor[1]);
5132
+ return isAncestorPath(commonAncestor[1], textEntry[1]) ? commonAncestor : getCommonNode(listRoot, textEntry[1], commonAncestor[1]);
4837
5133
  }, // any list item would do, we grab the first one
4838
5134
  getFirstAncestorOfType(listRoot, textEntries[0]));
4839
5135
  return isListRoot(commonAncestorEntry[0]) ? commonAncestorEntry[0].children : [commonAncestorEntry[0]];
@@ -4874,7 +5170,7 @@ var insertListFragment = function insertListFragment(editor) {
4874
5170
  return;
4875
5171
  }
4876
5172
 
4877
- var liEntry = findNode(editor, {
5173
+ var liEntry = findNode$1(editor, {
4878
5174
  match: {
4879
5175
  type: BLOCKS.LIST_ITEM
4880
5176
  },
@@ -4886,7 +5182,7 @@ var insertListFragment = function insertListFragment(editor) {
4886
5182
  return trimList(node);
4887
5183
  })));
4888
5184
  var firstBlockIndex = nodes.findIndex(function (node) {
4889
- return Editor.isBlock(editor, node);
5185
+ return isBlockNode(editor, node);
4890
5186
  });
4891
5187
 
4892
5188
  if (firstBlockIndex < 0) {
@@ -4898,11 +5194,11 @@ var insertListFragment = function insertListFragment(editor) {
4898
5194
  // after a text or inline element occurrence will be unwrapped for
4899
5195
  // some reason.
4900
5196
 
4901
- Transforms.insertNodes(editor, inlines, {
5197
+ insertNodes(editor, inlines, {
4902
5198
  at: editor.selection,
4903
5199
  select: true
4904
5200
  });
4905
- return Transforms.insertNodes(editor, blocks, {
5201
+ return insertNodes(editor, blocks, {
4906
5202
  at: editor.selection,
4907
5203
  select: true
4908
5204
  });
@@ -4932,7 +5228,7 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4932
5228
  return node.type === BLOCKS.LIST_ITEM;
4933
5229
  }
4934
5230
  })) {
4935
- Editor.withoutNormalizing(editor, function () {
5231
+ withoutNormalizing(editor, function () {
4936
5232
  moved = removeFirstListItem(editor, {
4937
5233
  list: list,
4938
5234
  listItem: listItem
@@ -4945,7 +5241,9 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4945
5241
  if (moved) return;
4946
5242
 
4947
5243
  if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
4948
- onKeyDownResetNode(editor, mockPlugin({
5244
+ onKeyDownResetNode(editor, // TODO look into this
5245
+ // @ts-expect-error
5246
+ mockPlugin({
4949
5247
  options: {
4950
5248
  rules: [{
4951
5249
  types: [BLOCKS.LIST_ITEM],
@@ -4965,6 +5263,8 @@ var deleteBackwardList = function deleteBackwardList(editor, unit) {
4965
5263
  }
4966
5264
 
4967
5265
  deleteFragment(editor, {
5266
+ // FIXME: see if we can remove unit
5267
+ // @ts-expect-error
4968
5268
  unit: unit,
4969
5269
  reverse: true
4970
5270
  });
@@ -5002,7 +5302,7 @@ var withList = function withList(editor) {
5002
5302
  };
5003
5303
 
5004
5304
  editor.insertBreak = insertListBreak(editor);
5005
- editor.insertFragment = insertListFragment(editor); // TODO: replace with Normalizer rules
5305
+ editor.insertFragment = insertListFragment(editor); // TODO: replace with our own Normalizer rules
5006
5306
 
5007
5307
  editor.normalizeNode = normalizeList(editor, {
5008
5308
  validLiChildrenTypes: validLiChildrenTypes
@@ -5293,42 +5593,44 @@ var createItalicPlugin = function createItalicPlugin() {
5293
5593
  });
5294
5594
  };
5295
5595
 
5296
- var ToolbarUnderlineButton = /*#__PURE__*/createMarkToolbarButton({
5297
- title: 'Underline',
5298
- mark: MARKS.UNDERLINE,
5299
- icon: /*#__PURE__*/createElement(FormatUnderlinedIcon, null)
5596
+ var styles$g = {
5597
+ subscript: /*#__PURE__*/css({
5598
+ verticalAlign: 'sub',
5599
+ fontSize: 'smaller'
5600
+ })
5601
+ };
5602
+ var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5603
+ title: 'Subscript',
5604
+ mark: MARKS.SUBSCRIPT,
5605
+ icon: /*#__PURE__*/createElement(SubscriptIcon, {
5606
+ viewBox: "0 0 23 18"
5607
+ })
5300
5608
  });
5301
- function Underline(props) {
5302
- return /*#__PURE__*/createElement("u", _extends({}, props.attributes), props.children);
5609
+ var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5610
+ title: 'Subscript',
5611
+ mark: MARKS.SUBSCRIPT
5612
+ });
5613
+ function Subscript(props) {
5614
+ return /*#__PURE__*/createElement("sub", _extends({}, props.attributes, {
5615
+ className: styles$g.subscript
5616
+ }), props.children);
5303
5617
  }
5304
- var createUnderlinePlugin = function createUnderlinePlugin() {
5305
- return createUnderlinePlugin$1({
5306
- type: MARKS.UNDERLINE,
5307
- component: Underline,
5308
- options: {
5309
- hotkey: ['mod+u']
5310
- },
5618
+ var createSubscriptPlugin = function createSubscriptPlugin() {
5619
+ return createSubscriptPlugin$1({
5620
+ type: MARKS.SUBSCRIPT,
5621
+ component: Subscript,
5311
5622
  handlers: {
5312
- onKeyDown: buildMarkEventHandler(MARKS.UNDERLINE)
5623
+ onKeyDown: buildMarkEventHandler(MARKS.SUBSCRIPT)
5313
5624
  },
5314
5625
  deserializeHtml: {
5315
5626
  rules: [{
5316
- validNodeName: ['U']
5317
- }, {
5318
- validStyle: {
5319
- textDecoration: ['underline']
5320
- }
5321
- }],
5322
- query: function query(el) {
5323
- return !someHtmlElement(el, function (node) {
5324
- return node.style.textDecoration === 'none';
5325
- });
5326
- }
5627
+ validNodeName: ['SUB']
5628
+ }]
5327
5629
  }
5328
5630
  });
5329
5631
  };
5330
5632
 
5331
- var styles$g = {
5633
+ var styles$h = {
5332
5634
  superscript: /*#__PURE__*/css({
5333
5635
  verticalAlign: 'super',
5334
5636
  fontSize: 'smaller'
@@ -5345,7 +5647,7 @@ var ToolbarDropdownSuperscriptButton = /*#__PURE__*/createMarkToolbarButton({
5345
5647
  });
5346
5648
  function Superscript(props) {
5347
5649
  return /*#__PURE__*/createElement("sup", _extends({}, props.attributes, {
5348
- className: styles$g.superscript
5650
+ className: styles$h.superscript
5349
5651
  }), props.children);
5350
5652
  }
5351
5653
  var createSuperscriptPlugin = function createSuperscriptPlugin() {
@@ -5363,39 +5665,37 @@ var createSuperscriptPlugin = function createSuperscriptPlugin() {
5363
5665
  });
5364
5666
  };
5365
5667
 
5366
- var styles$h = {
5367
- subscript: /*#__PURE__*/css({
5368
- verticalAlign: 'sub',
5369
- fontSize: 'smaller'
5370
- })
5371
- };
5372
- var ToolbarSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5373
- title: 'Subscript',
5374
- mark: MARKS.SUBSCRIPT,
5375
- icon: /*#__PURE__*/createElement(SubscriptIcon, {
5376
- viewBox: "0 0 23 18"
5377
- })
5378
- });
5379
- var ToolbarDropdownSubscriptButton = /*#__PURE__*/createMarkToolbarButton({
5380
- title: 'Subscript',
5381
- mark: MARKS.SUBSCRIPT
5668
+ var ToolbarUnderlineButton = /*#__PURE__*/createMarkToolbarButton({
5669
+ title: 'Underline',
5670
+ mark: MARKS.UNDERLINE,
5671
+ icon: /*#__PURE__*/createElement(FormatUnderlinedIcon, null)
5382
5672
  });
5383
- function Subscript(props) {
5384
- return /*#__PURE__*/createElement("sub", _extends({}, props.attributes, {
5385
- className: styles$h.subscript
5386
- }), props.children);
5673
+ function Underline(props) {
5674
+ return /*#__PURE__*/createElement("u", _extends({}, props.attributes), props.children);
5387
5675
  }
5388
- var createSubscriptPlugin = function createSubscriptPlugin() {
5389
- return createSubscriptPlugin$1({
5390
- type: MARKS.SUBSCRIPT,
5391
- component: Subscript,
5676
+ var createUnderlinePlugin = function createUnderlinePlugin() {
5677
+ return createUnderlinePlugin$1({
5678
+ type: MARKS.UNDERLINE,
5679
+ component: Underline,
5680
+ options: {
5681
+ hotkey: ['mod+u']
5682
+ },
5392
5683
  handlers: {
5393
- onKeyDown: buildMarkEventHandler(MARKS.SUBSCRIPT)
5684
+ onKeyDown: buildMarkEventHandler(MARKS.UNDERLINE)
5394
5685
  },
5395
5686
  deserializeHtml: {
5396
5687
  rules: [{
5397
- validNodeName: ['SUB']
5398
- }]
5688
+ validNodeName: ['U']
5689
+ }, {
5690
+ validStyle: {
5691
+ textDecoration: ['underline']
5692
+ }
5693
+ }],
5694
+ query: function query(el) {
5695
+ return !someHtmlElement(el, function (node) {
5696
+ return node.style.textDecoration === 'none';
5697
+ });
5698
+ }
5399
5699
  }
5400
5700
  });
5401
5701
  };
@@ -5407,7 +5707,7 @@ var createMarksPlugin = function createMarksPlugin() {
5407
5707
  };
5408
5708
  };
5409
5709
 
5410
- var isInline = function isInline(node) {
5710
+ var isInline$1 = function isInline(node) {
5411
5711
  return INLINE_TYPES.includes(node.type);
5412
5712
  };
5413
5713
 
@@ -5419,13 +5719,13 @@ var isTextContainer = function isTextContainer(node) {
5419
5719
 
5420
5720
  var baseRules = [{
5421
5721
  // Wrap orphaned text nodes in a paragraph
5422
- match: Text.isText,
5722
+ match: isText,
5423
5723
  validNode: function validNode(editor, _ref) {
5424
- var _getParent;
5724
+ var _getParentNode;
5425
5725
 
5426
5726
  var path = _ref[1];
5427
- var parent = (_getParent = getParent(editor, path)) == null ? void 0 : _getParent[0];
5428
- return !!parent && (isTextContainer(parent) || isInline(parent) || editor.isVoid(parent));
5727
+ var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
5728
+ return !!parent && (isTextContainer(parent) || isInline$1(parent) || editor.isVoid(parent));
5429
5729
  },
5430
5730
  transform: function transform(editor, entry) {
5431
5731
  return transformWrapIn(BLOCKS.PARAGRAPH)(editor, entry);
@@ -5436,10 +5736,10 @@ var baseRules = [{
5436
5736
  type: INLINE_TYPES
5437
5737
  },
5438
5738
  validNode: function validNode(editor, _ref2) {
5439
- var _getParent2;
5739
+ var _getParentNode2;
5440
5740
 
5441
5741
  var path = _ref2[1];
5442
- var parent = (_getParent2 = getParent(editor, path)) == null ? void 0 : _getParent2[0];
5742
+ var parent = (_getParentNode2 = getParentNode(editor, path)) == null ? void 0 : _getParentNode2[0];
5443
5743
  return !!parent && isTextContainer(parent);
5444
5744
  },
5445
5745
  transform: /*#__PURE__*/transformWrapIn(BLOCKS.PARAGRAPH)
@@ -5457,19 +5757,9 @@ var NormalizerError = /*#__PURE__*/function (_Error) {
5457
5757
  var createValidatorFromTypes = function createValidatorFromTypes(types) {
5458
5758
  return function (_, _ref) {
5459
5759
  var node = _ref[0];
5460
- return Element.isElement(node) && types.includes(node.type);
5760
+ return isElement(node) && types.includes(node.type);
5461
5761
  };
5462
5762
  };
5463
- var getChildren = function getChildren(editor, _ref2) {
5464
- var node = _ref2[0],
5465
- path = _ref2[1];
5466
-
5467
- if (Text.isText(node)) {
5468
- return [];
5469
- }
5470
-
5471
- return Array.from(Node.children(editor, path));
5472
- };
5473
5763
  var createTransformerFromObject = function createTransformerFromObject(transforms) {
5474
5764
  // A default transformer must always be provided
5475
5765
  var fallback = transforms['default'];
@@ -5480,7 +5770,7 @@ var createTransformerFromObject = function createTransformerFromObject(transform
5480
5770
 
5481
5771
  return function (editor, entry) {
5482
5772
  var node = entry[0];
5483
- var key = Element.isElement(node) ? node.type : 'default';
5773
+ var key = isElement(node) ? node.type : 'default';
5484
5774
  var transformer = transforms[key] || fallback;
5485
5775
  return transformer(editor, entry);
5486
5776
  };
@@ -5510,7 +5800,7 @@ var withNormalizer = function withNormalizer(editor) {
5510
5800
 
5511
5801
  if (!rule.match) {
5512
5802
  rule.match = {
5513
- type: getPluginType(editor, p.key)
5803
+ type: getPluginType$1(editor, p.key)
5514
5804
  };
5515
5805
  } // Conditional transformation e.g.
5516
5806
  // {
@@ -5548,22 +5838,23 @@ var withNormalizer = function withNormalizer(editor) {
5548
5838
 
5549
5839
 
5550
5840
  var _transform = function _transform(tr, entry) {
5551
- Editor.withoutNormalizing(editor, function () {
5841
+ withoutNormalizing(editor, function () {
5552
5842
  tr(editor, entry);
5553
5843
  });
5554
5844
  };
5555
5845
 
5556
- var normalizeNode = editor.normalizeNode;
5846
+ var normalizeNode = editor.normalizeNode; // @ts-expect-error
5557
5847
 
5558
5848
  editor.normalizeNode = function (entry) {
5559
- var node = entry[0];
5560
- var children = getChildren(editor, entry); // The order of validNode rules Vs validChildren doesn't matter. Slate
5849
+ var node = entry[0],
5850
+ path = entry[1];
5851
+ var children = getChildren(entry); // The order of validNode rules Vs validChildren doesn't matter. Slate
5561
5852
  // will always perform normalization in a depth-first fashion.
5562
5853
 
5563
5854
  for (var _iterator2 = _createForOfIteratorHelperLoose(rules), _step2; !(_step2 = _iterator2()).done;) {
5564
5855
  var rule = _step2.value;
5565
5856
 
5566
- if (!match(node, rule.match)) {
5857
+ if (!matchNode(node, path, rule.match)) {
5567
5858
  continue;
5568
5859
  } // Normalize node
5569
5860
 
@@ -5605,7 +5896,6 @@ var withNormalizer = function withNormalizer(editor) {
5605
5896
  var createNormalizerPlugin = function createNormalizerPlugin() {
5606
5897
  return {
5607
5898
  key: 'NormalizerPlugin',
5608
- // @ts-expect-error
5609
5899
  withOverrides: withNormalizer
5610
5900
  };
5611
5901
  };
@@ -5846,7 +6136,7 @@ function Quote(props) {
5846
6136
  */
5847
6137
 
5848
6138
  var shouldResetQuoteOnBackspace = function shouldResetQuoteOnBackspace(editor) {
5849
- var container = getAbove(editor, {
6139
+ var container = getAboveNode(editor, {
5850
6140
  match: {
5851
6141
  type: TEXT_CONTAINERS
5852
6142
  },
@@ -5885,11 +6175,11 @@ function toggleQuote(editor, logAction) {
5885
6175
  logAction == null ? void 0 : logAction(isActive ? 'remove' : 'insert', {
5886
6176
  nodeType: BLOCKS.QUOTE
5887
6177
  });
5888
- Editor.withoutNormalizing(editor, function () {
6178
+ withoutNormalizing(editor, function () {
5889
6179
  if (!editor.selection) return;
5890
- Transforms.unwrapNodes(editor, {
6180
+ unwrapNodes(editor, {
5891
6181
  match: function match(node) {
5892
- return Element.isElement(node) && node.type === BLOCKS.QUOTE;
6182
+ return isElement(node) && node.type === BLOCKS.QUOTE;
5893
6183
  },
5894
6184
  split: true
5895
6185
  });
@@ -5900,7 +6190,7 @@ function toggleQuote(editor, logAction) {
5900
6190
  data: {},
5901
6191
  children: []
5902
6192
  };
5903
- Transforms.wrapNodes(editor, quote);
6193
+ wrapNodes(editor, quote);
5904
6194
  }
5905
6195
  });
5906
6196
  }
@@ -5921,12 +6211,12 @@ var withQuote = function withQuote(editor) {
5921
6211
  editor.insertFragment = function (fragment) {
5922
6212
  var startingNode = fragment.length && fragment[0];
5923
6213
  var startsWithBlockquote = Element.isElement(startingNode) && startingNode.type === BLOCKS.QUOTE;
5924
- var containerEntry = getAbove(editor, {
6214
+ var containerEntry = getAboveNode(editor, {
5925
6215
  match: {
5926
6216
  type: TEXT_CONTAINERS
5927
6217
  }
5928
6218
  });
5929
- var containerIsNotEmpty = containerEntry && Node.string(containerEntry[0]) !== '';
6219
+ var containerIsNotEmpty = containerEntry && getText(editor, containerEntry[1]) !== '';
5930
6220
 
5931
6221
  if (startsWithBlockquote && containerIsNotEmpty) {
5932
6222
  var selection = editor.selection;
@@ -5937,22 +6227,22 @@ var withQuote = function withQuote(editor) {
5937
6227
 
5938
6228
 
5939
6229
  if (isContentSelected(selection)) {
5940
- Transforms["delete"](editor, {
6230
+ deleteText(editor, {
5941
6231
  at: selection
5942
6232
  });
5943
6233
  } // get the cursor entry again, it may be different after deletion
5944
6234
 
5945
6235
 
5946
- var _containerEntry = getAbove(editor, {
6236
+ var _containerEntry = getAboveNode(editor, {
5947
6237
  match: {
5948
6238
  type: TEXT_CONTAINERS
5949
6239
  }
5950
6240
  });
5951
6241
 
5952
- var _containerIsNotEmpty = _containerEntry && Node.string(_containerEntry[0]) !== '';
6242
+ var _containerIsNotEmpty = _containerEntry && getText(editor, _containerEntry[1]) !== '';
5953
6243
 
5954
6244
  if (_containerIsNotEmpty) {
5955
- Transforms.insertNodes(editor, fragment);
6245
+ insertNodes(editor, fragment);
5956
6246
  return;
5957
6247
  }
5958
6248
  }
@@ -6027,15 +6317,17 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
6027
6317
  });
6028
6318
  };
6029
6319
 
6320
+ var useReadOnly = useReadOnly$1;
6321
+
6030
6322
  var addRow = function addRow(editor, getNextRowPath) {
6031
6323
  if (someNode(editor, {
6032
6324
  match: {
6033
- type: getPluginType(editor, ELEMENT_TABLE)
6325
+ type: BLOCKS.TABLE
6034
6326
  }
6035
6327
  })) {
6036
- var currentRowItem = getAbove(editor, {
6328
+ var currentRowItem = getAboveNode(editor, {
6037
6329
  match: {
6038
- type: getPluginType(editor, ELEMENT_TR)
6330
+ type: BLOCKS.TABLE_ROW
6039
6331
  }
6040
6332
  });
6041
6333
 
@@ -6043,8 +6335,7 @@ var addRow = function addRow(editor, getNextRowPath) {
6043
6335
  var currentRowElem = currentRowItem[0],
6044
6336
  currentRowPath = currentRowItem[1];
6045
6337
  var nextRowPath = getNextRowPath(currentRowPath);
6046
- insertNodes(editor, // @ts-expect-error
6047
- getEmptyRowNode(editor, {
6338
+ insertNodes(editor, getEmptyRowNode(editor, {
6048
6339
  header: false,
6049
6340
  colCount: currentRowElem.children.length
6050
6341
  }), {
@@ -6053,14 +6344,14 @@ var addRow = function addRow(editor, getNextRowPath) {
6053
6344
  select: true
6054
6345
  }); // Select the first cell in the current row
6055
6346
 
6056
- Transforms.select(editor, Editor.start(editor, nextRowPath));
6347
+ select(editor, getStartPoint(editor, nextRowPath));
6057
6348
  }
6058
6349
  }
6059
6350
  };
6060
6351
 
6061
6352
  var addRowBelow = function addRowBelow(editor) {
6062
6353
  addRow(editor, function (currentRowPath) {
6063
- return Path.next(currentRowPath);
6354
+ return getNextPath(currentRowPath);
6064
6355
  });
6065
6356
  };
6066
6357
  var addRowAbove = function addRowAbove(editor) {
@@ -6075,17 +6366,17 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6075
6366
 
6076
6367
  if (someNode(editor, {
6077
6368
  match: {
6078
- type: getPluginType(editor, ELEMENT_TABLE)
6369
+ type: BLOCKS.TABLE
6079
6370
  }
6080
6371
  })) {
6081
- var currentCellItem = getAbove(editor, {
6372
+ var currentCellItem = getAboveNode(editor, {
6082
6373
  match: {
6083
- type: [getPluginType(editor, ELEMENT_TD), getPluginType(editor, ELEMENT_TH)]
6374
+ type: [BLOCKS.TABLE_HEADER_CELL, BLOCKS.TABLE_CELL]
6084
6375
  }
6085
6376
  });
6086
- var currentTableItem = getAbove(editor, {
6377
+ var currentTableItem = getAboveNode(editor, {
6087
6378
  match: {
6088
- type: getPluginType(editor, ELEMENT_TABLE)
6379
+ type: BLOCKS.TABLE
6089
6380
  }
6090
6381
  });
6091
6382
 
@@ -6095,8 +6386,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6095
6386
  var replacePathPos = newCellPath.length - 2;
6096
6387
  currentTableItem[0].children.forEach(function (_, rowIdx) {
6097
6388
  newCellPath[replacePathPos] = rowIdx;
6098
- insertNodes(editor, // @ts-expect-error
6099
- getEmptyCellNode(editor, {
6389
+ insertNodes(editor, getEmptyCellNode(editor, {
6100
6390
  header: header && rowIdx === 0
6101
6391
  }), {
6102
6392
  at: newCellPath,
@@ -6110,7 +6400,7 @@ var addColumn = function addColumn(editor, _ref, getNextCellPath) {
6110
6400
 
6111
6401
  var addColumnRight = function addColumnRight(editor, options) {
6112
6402
  addColumn(editor, options, function (currentCellPath) {
6113
- return Path.next(currentCellPath);
6403
+ return getNextPath(currentCellPath);
6114
6404
  });
6115
6405
  };
6116
6406
  var addColumnLeft = function addColumnLeft(editor, options) {
@@ -6120,7 +6410,7 @@ var addColumnLeft = function addColumnLeft(editor, options) {
6120
6410
  };
6121
6411
 
6122
6412
  var setHeader = function setHeader(editor, enable) {
6123
- var tableItem = getAbove(editor, {
6413
+ var tableItem = getAboveNode(editor, {
6124
6414
  match: {
6125
6415
  type: BLOCKS.TABLE
6126
6416
  }
@@ -6130,13 +6420,13 @@ var setHeader = function setHeader(editor, enable) {
6130
6420
  return;
6131
6421
  }
6132
6422
 
6133
- var firstRow = getChildren$1(tableItem)[0];
6423
+ var firstRow = getChildren(tableItem)[0];
6134
6424
 
6135
6425
  if (!firstRow) {
6136
6426
  return;
6137
6427
  }
6138
6428
 
6139
- getChildren$1(firstRow).forEach(function (_ref) {
6429
+ getChildren(firstRow).forEach(function (_ref) {
6140
6430
  var path = _ref[1];
6141
6431
  setNodes(editor, {
6142
6432
  type: enable ? BLOCKS.TABLE_HEADER_CELL : BLOCKS.TABLE_CELL
@@ -6147,9 +6437,30 @@ var setHeader = function setHeader(editor, enable) {
6147
6437
  };
6148
6438
 
6149
6439
  function insertTableAndFocusFirstCell(editor) {
6150
- insertTable(editor, {
6151
- header: true
6152
- });
6440
+ var table = {
6441
+ type: BLOCKS.TABLE,
6442
+ data: {},
6443
+ children: [getEmptyRowNode(editor, {
6444
+ colCount: 2,
6445
+ header: true
6446
+ }), getEmptyRowNode(editor, {
6447
+ colCount: 2
6448
+ })]
6449
+ };
6450
+ insertNodes(editor, table);
6451
+
6452
+ if (editor.selection) {
6453
+ var tableEntry = getBlockAbove(editor, {
6454
+ match: {
6455
+ type: BLOCKS.TABLE
6456
+ }
6457
+ });
6458
+ if (!tableEntry) return;
6459
+ selectEditor(editor, {
6460
+ at: getStartPoint(editor, tableEntry[1])
6461
+ });
6462
+ }
6463
+
6153
6464
  replaceEmptyParagraphWithTable(editor);
6154
6465
  }
6155
6466
  function isTableActive(editor) {
@@ -6159,7 +6470,7 @@ function isTableActive(editor) {
6159
6470
  });
6160
6471
  }
6161
6472
  function isTableHeaderEnabled(editor) {
6162
- var tableItem = getAbove(editor, {
6473
+ var tableItem = getAboveNode(editor, {
6163
6474
  match: {
6164
6475
  type: BLOCKS.TABLE
6165
6476
  }
@@ -6169,30 +6480,30 @@ function isTableHeaderEnabled(editor) {
6169
6480
  return false;
6170
6481
  }
6171
6482
 
6172
- var firstRow = getChildren$1(tableItem)[0];
6483
+ var firstRow = getChildren(tableItem)[0];
6173
6484
 
6174
6485
  if (!firstRow) {
6175
6486
  return false;
6176
6487
  }
6177
6488
 
6178
- return getChildren$1(firstRow).every(function (_ref) {
6489
+ return getChildren(firstRow).every(function (_ref) {
6179
6490
  var node = _ref[0];
6180
6491
  return node.type === BLOCKS.TABLE_HEADER_CELL;
6181
6492
  });
6182
6493
  }
6183
6494
  function replaceEmptyParagraphWithTable(editor) {
6184
6495
  var tablePath = getAncestorPathFromSelection(editor);
6185
- if (!tablePath || isFirstChild(tablePath)) return;
6186
- var previousPath = Path.previous(tablePath);
6496
+ if (!tablePath || isFirstChildPath(tablePath)) return;
6497
+ var previousPath = getPreviousPath(tablePath);
6187
6498
  if (!previousPath) return;
6188
6499
 
6189
- var _Editor$nodes = Editor.nodes(editor, {
6500
+ var _getNodeEntries = getNodeEntries(editor, {
6190
6501
  at: previousPath,
6191
6502
  match: function match(node) {
6192
6503
  return node.type === BLOCKS.PARAGRAPH;
6193
6504
  }
6194
6505
  }),
6195
- nodes = _Editor$nodes[0];
6506
+ nodes = _getNodeEntries[0];
6196
6507
 
6197
6508
  if (!nodes) return;
6198
6509
  var previousNode = nodes[0];
@@ -6200,12 +6511,12 @@ function replaceEmptyParagraphWithTable(editor) {
6200
6511
 
6201
6512
  if (isPreviousNodeTextEmpty) {
6202
6513
  // Switch table with previous empty paragraph
6203
- Transforms.moveNodes(editor, {
6514
+ moveNodes(editor, {
6204
6515
  at: tablePath,
6205
6516
  to: previousPath
6206
6517
  }); // Remove previous paragraph that now is under the table
6207
6518
 
6208
- Transforms.removeNodes(editor, {
6519
+ removeNodes(editor, {
6209
6520
  at: tablePath
6210
6521
  });
6211
6522
  }
@@ -6217,21 +6528,19 @@ function replaceEmptyParagraphWithTable(editor) {
6217
6528
  * normalization cycles.
6218
6529
  */
6219
6530
 
6220
- var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor, _ref2) {
6221
- var rowPath = _ref2[1];
6222
- var parent = getParent(editor, rowPath); // This is ensured by normalization. The error is here just in case
6531
+ var getNoOfMissingTableCellsInRow = function getNoOfMissingTableCellsInRow(editor, rowEntry) {
6532
+ var rowPath = rowEntry[1];
6533
+ var parent = getParentNode(editor, rowPath); // This is ensured by normalization. The error is here just in case
6223
6534
 
6224
6535
  if (!parent) {
6225
6536
  throw new Error('table rows must be wrapped in a table node');
6226
- }
6537
+ } // The longest table row determines its width
6227
6538
 
6228
- var tablePath = parent[1]; // The longest table row determines its width
6229
6539
 
6230
- var tableWidth = Math.max.apply(Math, Array.from(Node.children(editor, tablePath)).map(function (_ref3) {
6231
- var path = _ref3[1];
6232
- return Array.from(Node.children(editor, path)).length;
6540
+ var tableWidth = Math.max.apply(Math, getChildren(parent).map(function (entry) {
6541
+ return getChildren(entry).length;
6233
6542
  }));
6234
- var rowWidth = Array.from(Node.children(editor, rowPath)).length;
6543
+ var rowWidth = getChildren(rowEntry).length;
6235
6544
  return tableWidth - rowWidth;
6236
6545
  };
6237
6546
  var createEmptyTableCells = function createEmptyTableCells(count) {
@@ -6248,12 +6557,11 @@ var createEmptyTableCells = function createEmptyTableCells(count) {
6248
6557
  };
6249
6558
  return new Array(count).fill(emptyTableCell);
6250
6559
  };
6251
- var isNotEmpty = function isNotEmpty(editor, _ref4) {
6252
- var path = _ref4[1];
6253
- return Array.from(Node.children(editor, path)).length !== 0;
6560
+ var isNotEmpty = function isNotEmpty(_, entry) {
6561
+ return getChildren(entry).length !== 0;
6254
6562
  };
6255
6563
  var isTable = function isTable(node) {
6256
- return Element.isElement(node) && node.type === BLOCKS.TABLE;
6564
+ return isElement(node) && node.type === BLOCKS.TABLE;
6257
6565
  };
6258
6566
 
6259
6567
  var styles$j = {
@@ -6294,7 +6602,7 @@ var TableActions = function TableActions() {
6294
6602
  return false;
6295
6603
  }
6296
6604
 
6297
- var headerCell = getAbove(editor, {
6605
+ var headerCell = getAboveNode(editor, {
6298
6606
  match: {
6299
6607
  type: BLOCKS.TABLE_HEADER_CELL
6300
6608
  }
@@ -6317,7 +6625,7 @@ var TableActions = function TableActions() {
6317
6625
  if (!(editor != null && editor.selection)) return;
6318
6626
  close();
6319
6627
  var tableSize = getCurrentTableSize(editor);
6320
- Editor.withoutNormalizing(editor, function () {
6628
+ withoutNormalizing(editor, function () {
6321
6629
  cb(editor, {
6322
6630
  header: isHeaderEnabled
6323
6631
  });
@@ -6419,7 +6727,7 @@ var Table = function Table(props) {
6419
6727
  var trimUnnecessaryTableWrapper = function trimUnnecessaryTableWrapper(node) {
6420
6728
  var _node$children, _row$children;
6421
6729
 
6422
- if (!Element.isElement(node)) {
6730
+ if (!isElement(node)) {
6423
6731
  return [node];
6424
6732
  } // must be a table with a single row
6425
6733
 
@@ -6469,20 +6777,21 @@ var insertTableFragment = function insertTableFragment(editor) {
6469
6777
  var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6470
6778
  var defaultHandler = onKeyDownTable$1(editor, plugin);
6471
6779
  return function (event) {
6472
- // This fixes `Cannot resolve a Slate point from DOM point: [object HTMLDivElement]` when typing while the cursor is before table
6780
+ // This fixes `Cannot resolve a Slate point from DOM point:
6781
+ // [object HTMLDivElement]` when typing while the cursor is before table
6473
6782
  var windowSelection = window.getSelection();
6474
6783
 
6475
6784
  if (windowSelection) {
6476
6785
  var _windowSelection$anch, _windowSelection$anch2;
6477
6786
 
6478
6787
  // @ts-expect-error
6479
- 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`
6480
-
6788
+ // this attribute comes from `plugins/Table/components/Table.tsx`
6789
+ var blockType = (_windowSelection$anch = windowSelection.anchorNode.attributes) == null ? void 0 : (_windowSelection$anch2 = _windowSelection$anch['data-block-type']) == null ? void 0 : _windowSelection$anch2.value;
6481
6790
  var isBeforeTable = blockType === BLOCKS.TABLE;
6482
6791
 
6483
6792
  if (isBeforeTable) {
6484
6793
  if (event.key === 'Enter') {
6485
- var above = getAbove(editor, {
6794
+ var above = getAboveNode(editor, {
6486
6795
  match: {
6487
6796
  type: BLOCKS.TABLE
6488
6797
  }
@@ -6504,15 +6813,15 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6504
6813
 
6505
6814
 
6506
6815
  if (event.key === 'Tab' && !event.shiftKey) {
6507
- var res = getTableCellEntry(editor, {});
6816
+ event.preventDefault();
6817
+ var entry = getTableEntries(editor, {});
6508
6818
 
6509
- if (res) {
6510
- event.preventDefault();
6511
- var tableElement = res.tableElement,
6512
- tableRow = res.tableRow,
6513
- tableCell = res.tableCell;
6514
- var isLastCell = isLastChild(tableRow, tableCell[1]);
6515
- var isLastRow = isLastChild(tableElement, tableRow[1]);
6819
+ if (entry) {
6820
+ var table = entry.table,
6821
+ row = entry.row,
6822
+ cell = entry.cell;
6823
+ var isLastCell = isLastChildPath(row, cell[1]);
6824
+ var isLastRow = isLastChildPath(table, row[1]);
6516
6825
 
6517
6826
  if (isLastRow && isLastCell) {
6518
6827
  addRowBelow(editor); // skip default handler
@@ -6525,7 +6834,7 @@ var onKeyDownTable = function onKeyDownTable(editor, plugin) {
6525
6834
  }
6526
6835
 
6527
6836
  if (event.key === 'Escape') {
6528
- ReactEditor.blur(editor);
6837
+ blurEditor(editor);
6529
6838
  }
6530
6839
  };
6531
6840
  };
@@ -6808,7 +7117,7 @@ var withInvalidCellChildrenTracking = function withInvalidCellChildrenTracking(t
6808
7117
  return function (editor, childEntry) {
6809
7118
  var node = childEntry[0];
6810
7119
 
6811
- if (Element.isElement(node)) {
7120
+ if (isElement(node)) {
6812
7121
  var _editor$tracking;
6813
7122
 
6814
7123
  (_editor$tracking = editor.tracking) == null ? void 0 : _editor$tracking.onViewportAction('invalidTablePaste', {
@@ -6826,11 +7135,16 @@ var createTablePlugin = function createTablePlugin() {
6826
7135
  return createTablePlugin$1({
6827
7136
  type: BLOCKS.TABLE,
6828
7137
  handlers: {
7138
+ // @ts-expect-error
6829
7139
  onKeyDown: onKeyDownTable
6830
7140
  },
6831
7141
  withOverrides: function withOverrides(editor, plugin) {
6832
- // injects important fixes from plate's original table plugin
6833
- withTable(editor, plugin);
7142
+ var normalizeNode = editor.normalizeNode; // injects important fixes from plate's original table plugin
7143
+
7144
+ withTable(editor, plugin); // Resets all normalization rules added by @udecode/plate-table as
7145
+ // they conflict with our own
7146
+
7147
+ editor.normalizeNode = normalizeNode;
6834
7148
  addTableTrackingEvents(editor);
6835
7149
  editor.insertFragment = insertTableFragment(editor);
6836
7150
  return editor;
@@ -6844,6 +7158,8 @@ var createTablePlugin = function createTablePlugin() {
6844
7158
  // Move to root level unless nested
6845
7159
  validNode: function validNode(editor, _ref) {
6846
7160
  var path = _ref[1];
7161
+ // Nested tables are handled by another normalization
7162
+ // rule in a the table cell level
6847
7163
  var isNestedTable = !!getBlockAbove(editor, {
6848
7164
  at: path,
6849
7165
  match: {
@@ -6868,10 +7184,10 @@ var createTablePlugin = function createTablePlugin() {
6868
7184
  }, {
6869
7185
  // Parent must be a table
6870
7186
  validNode: function validNode(editor, _ref2) {
6871
- var _getParent;
7187
+ var _getParentNode;
6872
7188
 
6873
7189
  var path = _ref2[1];
6874
- var parent = (_getParent = getParent(editor, path)) == null ? void 0 : _getParent[0];
7190
+ var parent = (_getParentNode = getParentNode(editor, path)) == null ? void 0 : _getParentNode[0];
6875
7191
  return parent && parent.type === BLOCKS.TABLE;
6876
7192
  },
6877
7193
  transform: transformWrapIn(BLOCKS.TABLE)
@@ -6882,8 +7198,8 @@ var createTablePlugin = function createTablePlugin() {
6882
7198
  },
6883
7199
  transform: function transform(editor, entry) {
6884
7200
  var howMany = getNoOfMissingTableCellsInRow(editor, entry);
6885
- var at = Path.next(getLastChildPath(entry));
6886
- Transforms.insertNodes(editor, createEmptyTableCells(howMany), {
7201
+ var at = getNextPath(getLastChildPath(entry));
7202
+ insertNodes(editor, createEmptyTableCells(howMany), {
6887
7203
  at: at
6888
7204
  });
6889
7205
  }
@@ -6948,7 +7264,7 @@ function ToolbarTableButton(props) {
6948
7264
  testId: "table-toolbar-button",
6949
7265
  onClick: handleClick,
6950
7266
  // TODO: active state looks off since the button will be disabled. Do we still need it?
6951
- isActive: isActive,
7267
+ isActive: !!isActive,
6952
7268
  isDisabled: props.isDisabled
6953
7269
  }, /*#__PURE__*/createElement(TableIcon, null));
6954
7270
  }
@@ -6970,7 +7286,7 @@ function createTextPlugin(restrictedMarks) {
6970
7286
  return;
6971
7287
  }
6972
7288
 
6973
- Transforms.setSelection(editor, Editor.unhangRange(editor, editor.selection));
7289
+ setSelection(editor, unhangRange(editor, editor.selection));
6974
7290
  };
6975
7291
  }
6976
7292
  },
@@ -6986,19 +7302,19 @@ function createTextPlugin(restrictedMarks) {
6986
7302
  var selection = editor.selection; // If the cursor is at the end of an inline, move it outside
6987
7303
  // before inserting
6988
7304
 
6989
- if (selection && Range.isCollapsed(selection)) {
6990
- var _Editor$above;
7305
+ if (selection && isRangeCollapsed(selection)) {
7306
+ var _getAboveNode;
6991
7307
 
6992
- var inlinePath = (_Editor$above = Editor.above(editor, {
7308
+ var inlinePath = (_getAboveNode = getAboveNode(editor, {
6993
7309
  match: function match(n) {
6994
- return Editor.isInline(editor, n);
7310
+ return isInline(editor, n);
6995
7311
  },
6996
7312
  mode: 'highest'
6997
- })) == null ? void 0 : _Editor$above[1];
7313
+ })) == null ? void 0 : _getAboveNode[1];
6998
7314
 
6999
- if (inlinePath && Editor.isEnd(editor, selection.anchor, inlinePath)) {
7000
- var point = Editor.after(editor, inlinePath);
7001
- Transforms.setSelection(editor, {
7315
+ if (inlinePath && isEndPoint(editor, selection.anchor, inlinePath)) {
7316
+ var point = getPointAfter(editor, inlinePath);
7317
+ setSelection(editor, {
7002
7318
  anchor: point,
7003
7319
  focus: point
7004
7320
  });
@@ -7024,7 +7340,7 @@ function createTextPlugin(restrictedMarks) {
7024
7340
  return editor;
7025
7341
  },
7026
7342
  normalizer: [{
7027
- match: Text.isText,
7343
+ match: isText,
7028
7344
  transform: function transform(editor, _ref) {
7029
7345
  var path = _ref[1];
7030
7346
  unsetNodes(editor, restrictedMarks, {
@@ -7042,7 +7358,7 @@ function createTextPlugin(restrictedMarks) {
7042
7358
  }
7043
7359
 
7044
7360
  function deleteEmptyParagraph(unit, editor, deleteFunction) {
7045
- var entry = getAbove(editor, {
7361
+ var entry = getAboveNode(editor, {
7046
7362
  match: {
7047
7363
  type: TEXT_CONTAINERS
7048
7364
  }
@@ -7057,15 +7373,15 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
7057
7373
  var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
7058
7374
 
7059
7375
  if (isTextEmpty && isRootLevel && hasSiblings) {
7060
- Transforms.removeNodes(editor, {
7376
+ removeNodes(editor, {
7061
7377
  at: path
7062
7378
  });
7063
- var prevNode = Editor.before(editor, editor.selection, {
7379
+ var prevNode = getPointBefore(editor, editor.selection, {
7064
7380
  unit: unit
7065
7381
  });
7066
7382
 
7067
7383
  if (prevNode) {
7068
- var _Editor$nodes = Editor.nodes(editor, {
7384
+ var _getNodeEntries = getNodeEntries(editor, {
7069
7385
  match: function match(node) {
7070
7386
  return queryNode([node, prevNode.path], {
7071
7387
  allow: [BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY, BLOCKS.HR]
@@ -7073,10 +7389,10 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
7073
7389
  },
7074
7390
  at: prevNode
7075
7391
  }),
7076
- prevCell = _Editor$nodes[0];
7392
+ prevCell = _getNodeEntries[0];
7077
7393
 
7078
7394
  if (prevCell) {
7079
- Transforms.select(editor, prevNode);
7395
+ select(editor, prevNode);
7080
7396
  }
7081
7397
  }
7082
7398
  } else {
@@ -7113,7 +7429,7 @@ function fixPasteAsPlainText(editor) {
7113
7429
  }
7114
7430
 
7115
7431
  if (split) {
7116
- Transforms.splitNodes(editor, {
7432
+ splitNodes(editor, {
7117
7433
  always: true
7118
7434
  });
7119
7435
  }
@@ -7147,7 +7463,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
7147
7463
  filter: function filter(_ref) {
7148
7464
  var node = _ref[0],
7149
7465
  path = _ref[1];
7150
- return isRootLevel(path) && isFirstChild(path) && !!node.isVoid;
7466
+ return isRootLevel(path) && isFirstChildPath(path) && !!node.isVoid;
7151
7467
  }
7152
7468
  }
7153
7469
  }, {
@@ -7160,7 +7476,7 @@ var createVoidsPlugin = function createVoidsPlugin() {
7160
7476
  filter: function filter(_ref2) {
7161
7477
  var node = _ref2[0],
7162
7478
  path = _ref2[1];
7163
- return !(isRootLevel(path) && isFirstChild(path)) && !!node.isVoid;
7479
+ return !(isRootLevel(path) && isFirstChildPath(path)) && !!node.isVoid;
7164
7480
  }
7165
7481
  }
7166
7482
  }]
@@ -7247,7 +7563,7 @@ var hasContent = function hasContent(doc) {
7247
7563
 
7248
7564
  var setEditorContent = function setEditorContent(editor, nodes) {
7249
7565
  // Replaces editor content while keeping change history
7250
- Editor.withoutNormalizing(editor, function () {
7566
+ withoutNormalizing(editor, function () {
7251
7567
  var children = [].concat(editor.children);
7252
7568
  children.forEach(function (node) {
7253
7569
  return editor.apply({
@@ -7258,9 +7574,9 @@ var setEditorContent = function setEditorContent(editor, nodes) {
7258
7574
  });
7259
7575
 
7260
7576
  if (nodes) {
7261
- var nodesArray = Node.isNode(nodes) ? [nodes] : nodes;
7577
+ var nodesArray = isNode(nodes) ? [nodes] : nodes;
7262
7578
  nodesArray.forEach(function (node, i) {
7263
- return editor.apply({
7579
+ editor.apply({
7264
7580
  type: 'insert_node',
7265
7581
  path: [i],
7266
7582
  node: node
@@ -7268,10 +7584,10 @@ var setEditorContent = function setEditorContent(editor, nodes) {
7268
7584
  });
7269
7585
  }
7270
7586
 
7271
- var point = Editor.end(editor, []);
7587
+ var point = getEndPoint(editor, []);
7272
7588
 
7273
7589
  if (point) {
7274
- Transforms.select(editor, point);
7590
+ select(editor, point);
7275
7591
  }
7276
7592
  });
7277
7593
  };
@@ -7291,7 +7607,7 @@ var documentToEditorValue = function documentToEditorValue(doc) {
7291
7607
  var normalizeEditorValue = function normalizeEditorValue(value, options) {
7292
7608
  var editor = createPlateEditor(options);
7293
7609
  editor.children = value;
7294
- Editor.normalize(editor, {
7610
+ normalize(editor, {
7295
7611
  force: true
7296
7612
  });
7297
7613
  return editor.children;
@@ -7399,7 +7715,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
7399
7715
  nodeType: BLOCKS.EMBEDDED_ENTRY,
7400
7716
  onClose: onCloseEntityDropdown
7401
7717
  }), inlineEntryEmbedEnabled && /*#__PURE__*/React__default.createElement(ToolbarEmbeddedEntityInlineButton, {
7402
- isDisabled: !!isDisabled || isLinkActive(editor),
7718
+ isDisabled: !!isDisabled || Boolean(isLinkActive(editor)),
7403
7719
  onClose: onCloseEntityDropdown
7404
7720
  }), blockAssetEmbedEnabled && /*#__PURE__*/React__default.createElement(EmbeddedEntityBlockToolbarIcon, {
7405
7721
  isDisabled: !!isDisabled,
@@ -7457,7 +7773,7 @@ var Dropdown = function Dropdown(_ref) {
7457
7773
  var sdk = _ref.sdk,
7458
7774
  isDisabled = _ref.isDisabled;
7459
7775
  var editor = useContentfulEditor();
7460
- var isActive = isMarkActive(editor, MARKS.SUPERSCRIPT) || isMarkActive(editor, MARKS.SUBSCRIPT) || isMarkActive(editor, MARKS.CODE);
7776
+ var isActive = editor && (isMarkActive(editor, MARKS.SUPERSCRIPT) || isMarkActive(editor, MARKS.SUBSCRIPT) || isMarkActive(editor, MARKS.CODE));
7461
7777
  return /*#__PURE__*/React__default.createElement(Menu, null, /*#__PURE__*/React__default.createElement(Menu.Trigger, null, /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.createElement(IconButton, {
7462
7778
  size: "small",
7463
7779
  className: styles$l.toolbarBtn,
@@ -7611,7 +7927,7 @@ var useOnValueChanged = function useOnValueChanged(_ref) {
7611
7927
  }, 500);
7612
7928
  }, [handler]);
7613
7929
  return useCallback(function (value) {
7614
- var editor = getPlateSelectors(editorId).editor();
7930
+ var editor = getPlateSelectors$1(editorId).editor();
7615
7931
 
7616
7932
  if (!editor) {
7617
7933
  throw new Error('Editor change callback called but editor not defined. Editor id: ' + editorId);
@@ -7684,7 +8000,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7684
8000
  return;
7685
8001
  }
7686
8002
 
7687
- getPlateActions(id).value(normalizeEditorValue(documentToEditorValue(props.value), {
8003
+ getPlateActions(id).value( // FIXME: fix types here
8004
+ // @ts-expect-error
8005
+ normalizeEditorValue(documentToEditorValue(props.value), {
7688
8006
  plugins: plugins,
7689
8007
  disableCorePlugins: disableCorePlugins
7690
8008
  }));
@@ -7704,12 +8022,13 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
7704
8022
  className: classNames,
7705
8023
  readOnly: props.isDisabled
7706
8024
  },
7707
- onChange: onValueChanged
7708
- }, !props.isToolbarHidden && /*#__PURE__*/React__default.createElement(StickyToolbarWrapper, {
7709
- isDisabled: props.isDisabled
7710
- }, /*#__PURE__*/React__default.createElement(Toolbar, {
7711
- isDisabled: props.isDisabled
7712
- }))))));
8025
+ onChange: onValueChanged,
8026
+ firstChildren: !props.isToolbarHidden && /*#__PURE__*/React__default.createElement(StickyToolbarWrapper, {
8027
+ isDisabled: props.isDisabled
8028
+ }, /*#__PURE__*/React__default.createElement(Toolbar, {
8029
+ isDisabled: props.isDisabled
8030
+ }))
8031
+ }))));
7713
8032
  };
7714
8033
 
7715
8034
  var RichTextEditor = function RichTextEditor(props) {