@contentful/field-editor-rich-text 2.0.0-next.40 → 2.0.0-next.43

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.
@@ -1,6 +1,6 @@
1
- import React__default, { createContext, useContext, useMemo, useEffect, createElement, useState, memo, Fragment, useCallback } from 'react';
2
- import { useEntities, MissingEntityCard, WrappedAssetCard, WrappedEntryCard, ScheduledIconWithTooltip, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
3
- import { entityHelpers, ModalDialogLauncher, FieldConnector } from '@contentful/field-editor-shared';
1
+ import React__default, { createContext, useContext, useMemo, createElement, useEffect, useState, memo, Fragment, useCallback } from 'react';
2
+ import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
3
+ import { entityHelpers, shortenStorageUnit, isValidImage, 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
5
  import { usePlateEditorRef, usePlateEditorState, getNodes, toggleNodeType, getText, getAbove, setNodes, isAncestorEmpty, match, getLastChildPath, wrapNodes, getPluginType, unwrapNodes, isCollapsed, isRangeAcrossBlocks, ELEMENT_DEFAULT, findNode, getParent, getBlockAbove, isSelectionAtBlockStart, isSelectionAtBlockEnd, isFirstChild, insertNodes, moveChildren, isBlockAboveEmpty, mockPlugin, deleteFragment, isMarkActive, toggleMark, someHtmlElement, KEY_DESERIALIZE_HTML, hasSingleChild, isLastChild, someNode, getChildren as getChildren$1, queryNode, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
6
6
  import { css, cx } from 'emotion';
@@ -13,12 +13,13 @@ import isHotkey from 'is-hotkey';
13
13
  import { Text, Element, Editor, Transforms, Range, Path, Node, Point } from 'slate';
14
14
  import { ReactEditor, useSelected, useReadOnly, useFocused } from 'slate-react';
15
15
  import constate from 'constate';
16
- import { AssetCard, EntryCard, Menu, Flex, Icon, InlineEntryCard, MenuItem, Text as Text$1, Button, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, Card, IconButton } from '@contentful/f36-components';
17
- import find from 'lodash-es/find';
18
- import flow from 'lodash-es/flow';
16
+ import { AssetCard, Menu, Text as Text$1, Notification, EntryCard, MenuItem, Flex, Icon, InlineEntryCard, Button, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, Card, IconButton } from '@contentful/f36-components';
17
+ import mimetype from '@contentful/mimetype';
19
18
  import get from 'lodash-es/get';
20
- import { AssetIcon, EmbeddedEntryBlockIcon, ClockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon } from '@contentful/f36-icons';
19
+ import { ClockIcon, AssetIcon, EmbeddedEntryBlockIcon, EmbeddedEntryInlineIcon, ChevronDownIcon, HorizontalRuleIcon, LinkIcon, ListBulletedIcon, ListNumberedIcon, FormatBoldIcon, CodeIcon, FormatItalicIcon, FormatUnderlinedIcon, QuoteIcon, TableIcon, PlusIcon } from '@contentful/f36-icons';
21
20
  import tokens from '@contentful/f36-tokens';
21
+ import find from 'lodash-es/find';
22
+ import flow from 'lodash-es/flow';
22
23
  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';
23
24
  import castArray from 'lodash-es/castArray';
24
25
  import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodePlugin$1, createItalicPlugin as createItalicPlugin$1, createUnderlinePlugin as createUnderlinePlugin$1 } from '@udecode/plate-basic-marks';
@@ -393,17 +394,8 @@ function getParents(el) {
393
394
  return parents;
394
395
  }
395
396
 
396
- // "modern" Edge was released at 79.x
397
- var IS_EDGE_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Edge?\/(?:[0-6][0-9]|[0-7][0-8])/i.test(navigator.userAgent); // Native `beforeInput` events don't work well with react on Chrome 75
398
- // and older, Chrome 76+ can use `beforeInput` though.
399
-
400
- var IS_CHROME_LEGACY = typeof navigator !== 'undefined' && /*#__PURE__*/ /Chrome?\/(?:[0-7][0-5]|[0-6][0-9])/i.test(navigator.userAgent); // COMPAT: Firefox/Edge Legacy don't support the `beforeinput` event
401
- // Chrome Legacy doesn't support `beforeinput` correctly
402
-
403
- var HAS_BEFORE_INPUT_SUPPORT = !IS_CHROME_LEGACY && !IS_EDGE_LEGACY && // globalThis is undefined in older browsers
404
- typeof globalThis !== 'undefined' && globalThis.InputEvent && typeof globalThis.InputEvent.prototype.getTargetRanges === 'function'; // The `getTargetRanges` property isn't recognized.
405
-
406
397
  var IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
398
+ var IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
407
399
 
408
400
  var LINK_TYPES = [INLINES.HYPERLINK, INLINES.ENTRY_HYPERLINK, INLINES.ASSET_HYPERLINK];
409
401
  function isBlockSelected(editor, type) {
@@ -631,24 +623,179 @@ var _constate = /*#__PURE__*/constate(useSdk),
631
623
  SdkProvider = _constate[0],
632
624
  useSdkContext = _constate[1];
633
625
 
626
+ var styles = {
627
+ scheduleIcon: /*#__PURE__*/css({
628
+ marginRight: tokens.spacing2Xs
629
+ })
630
+ };
631
+ function EntityStatusIcon(_ref) {
632
+ var entity = _ref.entity,
633
+ entityType = _ref.entityType;
634
+
635
+ var _useEntities = useEntities(),
636
+ loadEntityScheduledActions = _useEntities.loadEntityScheduledActions;
637
+
638
+ return /*#__PURE__*/createElement(ScheduledIconWithTooltip, {
639
+ getEntityScheduledActions: loadEntityScheduledActions,
640
+ entityType: entityType,
641
+ entityId: entity.sys.id
642
+ }, /*#__PURE__*/createElement(ClockIcon, {
643
+ className: styles.scheduleIcon,
644
+ size: "small",
645
+ color: "muted",
646
+ testId: "schedule-icon"
647
+ }));
648
+ }
649
+
650
+ var styles$1 = {
651
+ assetCard: /*#__PURE__*/css({
652
+ cursor: 'pointer'
653
+ }),
654
+ cardDropdown: /*#__PURE__*/css({
655
+ width: '300px'
656
+ }),
657
+ truncated: /*#__PURE__*/css({
658
+ overflow: 'hidden',
659
+ whiteSpace: 'nowrap',
660
+ textOverflow: 'ellipsis'
661
+ })
662
+ };
663
+
664
+ function downloadAsset(url, fileName) {
665
+ // This method won't work if we have CORS disabled(asset not on the contentful server)
666
+ fetch(url, {
667
+ method: 'GET',
668
+ headers: {}
669
+ }).then(function (response) {
670
+ response.arrayBuffer().then(function (buffer) {
671
+ var url = window.URL.createObjectURL(new Blob([buffer]));
672
+ var link = document.createElement('a');
673
+ link.href = url;
674
+ link.setAttribute('download', fileName); //or any other extension
675
+
676
+ document.body.appendChild(link);
677
+ link.click();
678
+ document.body.removeChild(link);
679
+ });
680
+ })["catch"](function (err) {
681
+ Notification.error('Failed to download asset');
682
+ console.log(err);
683
+ });
684
+ }
685
+
686
+ function renderAssetInfo(props) {
687
+ var entityFile = props.entityFile;
688
+ var fileName = get(entityFile, 'fileName');
689
+ var mimeType = get(entityFile, 'contentType');
690
+ var fileSize = get(entityFile, 'details.size');
691
+ var image = get(entityFile, 'details.image');
692
+ return [/*#__PURE__*/createElement(Menu.SectionTitle, {
693
+ key: "file-section"
694
+ }, "File info"), fileName && /*#__PURE__*/createElement(Menu.Item, {
695
+ key: "file-name"
696
+ }, /*#__PURE__*/createElement(Text$1, {
697
+ isTruncated: true
698
+ }, fileName)), mimeType && /*#__PURE__*/createElement(Menu.Item, {
699
+ key: "file-type"
700
+ }, /*#__PURE__*/createElement(Text$1, {
701
+ isTruncated: true
702
+ }, mimeType)), fileSize && /*#__PURE__*/createElement(Menu.Item, {
703
+ key: "file-size"
704
+ }, shortenStorageUnit(fileSize, 'B')), image && /*#__PURE__*/createElement(Menu.Item, {
705
+ key: "file-dimentions"
706
+ }, image.width + " \xD7 " + image.height)].filter(function (item) {
707
+ return item;
708
+ });
709
+ }
710
+ function renderActions(props) {
711
+ var entityFile = props.entityFile,
712
+ isDisabled = props.isDisabled,
713
+ onEdit = props.onEdit,
714
+ onRemove = props.onRemove;
715
+ return [/*#__PURE__*/createElement(Menu.SectionTitle, {
716
+ key: "section-title"
717
+ }, "Actions"), onEdit ? /*#__PURE__*/createElement(Menu.Item, {
718
+ key: "edit",
719
+ onClick: onEdit,
720
+ testId: "card-action-edit"
721
+ }, "Edit") : null, entityFile ? /*#__PURE__*/createElement(Menu.Item, {
722
+ key: "download",
723
+ onClick: function onClick() {
724
+ if (typeof entityFile.url === 'string') {
725
+ downloadAsset(entityFile.url, get(entityFile, 'fileName'));
726
+ }
727
+ },
728
+ testId: "card-action-download"
729
+ }, "Download") : null, onRemove ? /*#__PURE__*/createElement(Menu.Item, {
730
+ key: "remove",
731
+ disabled: isDisabled,
732
+ onClick: onRemove,
733
+ testId: "card-action-remove"
734
+ }, "Remove") : null].filter(function (item) {
735
+ return item;
736
+ });
737
+ }
634
738
  function FetchingWrappedAssetCard(props) {
635
- var onEntityFetchComplete = props.onEntityFetchComplete,
636
- assetId = props.assetId;
739
+ var _asset$fields;
637
740
 
638
741
  var _useEntities = useEntities(),
639
742
  getOrLoadAsset = _useEntities.getOrLoadAsset,
640
- loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
641
743
  assets = _useEntities.assets;
642
744
 
745
+ var asset = assets[props.assetId];
746
+ var defaultLocaleCode = props.sdk.locales["default"];
747
+ var entityFile = asset != null && (_asset$fields = asset.fields) != null && _asset$fields.file ? asset.fields.file[props.locale] || asset.fields.file[defaultLocaleCode] : undefined;
748
+ var onEntityFetchComplete = props.onEntityFetchComplete;
643
749
  useEffect(function () {
644
- getOrLoadAsset(assetId);
645
- }, [getOrLoadAsset, assetId]);
646
- var asset = assets[assetId];
750
+ getOrLoadAsset(props.assetId);
751
+ }, [props.assetId]); // eslint-disable-line
752
+
647
753
  useEffect(function () {
648
- if (asset) {
649
- onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
754
+ if (!asset) {
755
+ return;
756
+ }
757
+
758
+ onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
759
+ }, [asset, onEntityFetchComplete]);
760
+
761
+ function getAssetSrc() {
762
+ if (!(entityFile != null && entityFile.url)) return '';
763
+ return entityFile.url + "?h=300";
764
+ }
765
+
766
+ function getFileType() {
767
+ var groupToIconMap = {
768
+ image: 'image',
769
+ video: 'video',
770
+ audio: 'audio',
771
+ richtext: 'richtext',
772
+ presentation: 'presentation',
773
+ spreadsheet: 'spreadsheet',
774
+ pdfdocument: 'pdf',
775
+ archive: 'archive',
776
+ plaintext: 'plaintext',
777
+ code: 'code',
778
+ markup: 'markup'
779
+ };
780
+ var archive = groupToIconMap['archive'];
781
+
782
+ if (!entityFile) {
783
+ return archive;
650
784
  }
651
- }, [onEntityFetchComplete, asset]);
785
+
786
+ var groupName = mimetype.getGroupLabel({
787
+ type: entityFile.contentType,
788
+ fallbackFileName: entityFile.fileName
789
+ });
790
+ return groupToIconMap[groupName] || archive;
791
+ }
792
+
793
+ if (asset === undefined) {
794
+ return /*#__PURE__*/createElement(AssetCard, {
795
+ size: "small",
796
+ isLoading: true
797
+ });
798
+ }
652
799
 
653
800
  if (asset === 'failed') {
654
801
  return /*#__PURE__*/createElement(MissingEntityCard, {
@@ -658,48 +805,138 @@ function FetchingWrappedAssetCard(props) {
658
805
  });
659
806
  }
660
807
 
661
- if (asset === undefined) {
662
- return /*#__PURE__*/createElement(AssetCard, {
663
- size: "default",
664
- isLoading: true
808
+ var status = asset ? entityHelpers.getEntryStatus(asset.sys) : undefined;
809
+
810
+ if (status === 'deleted') {
811
+ return /*#__PURE__*/createElement(MissingEntityCard, {
812
+ entityType: "Asset",
813
+ asSquare: true,
814
+ isDisabled: props.isDisabled,
815
+ onRemove: props.onRemove
665
816
  });
666
817
  }
667
818
 
668
- return /*#__PURE__*/createElement(WrappedAssetCard, {
669
- getEntityScheduledActions: loadEntityScheduledActions,
670
- size: "small",
671
- isSelected: props.isSelected,
672
- isDisabled: props.isDisabled,
673
- localeCode: props.locale,
674
- defaultLocaleCode: props.sdk.locales["default"],
819
+ var entityTitle = entityHelpers.getAssetTitle({
675
820
  asset: asset,
676
- onEdit: props.onEdit,
677
- onRemove: props.isDisabled ? undefined : props.onRemove,
678
- isClickable: false
821
+ localeCode: props.locale,
822
+ defaultLocaleCode: defaultLocaleCode,
823
+ defaultTitle: 'Untitled'
824
+ });
825
+ return /*#__PURE__*/createElement(AssetCard, {
826
+ title: entityTitle,
827
+ isSelected: props.isSelected,
828
+ size: "small",
829
+ src: getAssetSrc(),
830
+ type: getFileType(),
831
+ status: status,
832
+ icon: /*#__PURE__*/createElement(EntityStatusIcon, {
833
+ entityType: "Asset",
834
+ entity: asset
835
+ }),
836
+ className: styles$1.assetCard,
837
+ actions: [renderActions({
838
+ entityFile: entityFile,
839
+ isDisabled: props.isDisabled,
840
+ onEdit: props.onEdit,
841
+ onRemove: props.onRemove
842
+ }), entityFile ? renderAssetInfo({
843
+ entityFile: entityFile
844
+ }) : null].filter(function (item) {
845
+ return item;
846
+ })
679
847
  });
680
848
  }
681
849
 
682
- function FetchingWrappedEntryCard(props) {
683
- var entryId = props.entryId,
684
- onEntityFetchComplete = props.onEntityFetchComplete;
850
+ var styles$2 = {
851
+ entryCard: /*#__PURE__*/css({
852
+ cursor: 'pointer'
853
+ })
854
+ };
855
+
856
+ function EntryThumbnail(_ref) {
857
+ var file = _ref.file;
858
+ if (!isValidImage(file)) return null;
859
+ return /*#__PURE__*/createElement(AssetThumbnail, {
860
+ file: file
861
+ });
862
+ }
685
863
 
864
+ function FetchingWrappedEntryCard(props) {
686
865
  var _useEntities = useEntities(),
687
866
  getOrLoadEntry = _useEntities.getOrLoadEntry,
688
- loadEntityScheduledActions = _useEntities.loadEntityScheduledActions,
689
- entries = _useEntities.entries;
867
+ entries = _useEntities.entries,
868
+ getOrLoadAsset = _useEntities.getOrLoadAsset;
869
+
870
+ var _React$useState = useState(null),
871
+ file = _React$useState[0],
872
+ setFile = _React$useState[1];
873
+
874
+ var entry = entries[props.entryId];
875
+ var contentType = useMemo(function () {
876
+ if (!entry || entry === 'failed') {
877
+ return undefined;
878
+ }
690
879
 
880
+ return props.sdk.space.getCachedContentTypes().find(function (contentType) {
881
+ return contentType.sys.id === entry.sys.contentType.sys.id;
882
+ });
883
+ }, [props.sdk, entry]);
884
+ var defaultLocaleCode = props.sdk.locales["default"];
885
+ var onEntityFetchComplete = props.onEntityFetchComplete;
886
+ useEffect(function () {
887
+ if (!entry || entry === 'failed') return;
888
+ var subscribed = true;
889
+ entityHelpers.getEntryImage({
890
+ entry: entry,
891
+ contentType: contentType,
892
+ localeCode: props.locale,
893
+ defaultLocaleCode: defaultLocaleCode
894
+ }, getOrLoadAsset)["catch"](function () {
895
+ return null;
896
+ }).then(function (file) {
897
+ if (subscribed) {
898
+ setFile(file);
899
+ }
900
+ });
901
+ return function () {
902
+ subscribed = false;
903
+ };
904
+ }, [entry, contentType, props.locale, defaultLocaleCode, props.sdk, file, getOrLoadAsset]);
691
905
  useEffect(function () {
692
- getOrLoadEntry(entryId);
693
- }, [getOrLoadEntry, entryId]);
694
- var entry = entries[entryId];
906
+ getOrLoadEntry(props.entryId);
907
+ }, [props.entryId]); // eslint-disable-line
908
+
695
909
  useEffect(function () {
696
- if (entry) {
697
- onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
910
+ if (!entry) {
911
+ return;
698
912
  }
699
- }, [onEntityFetchComplete, entry]);
913
+
914
+ onEntityFetchComplete == null ? void 0 : onEntityFetchComplete();
915
+ }, [entry, onEntityFetchComplete]);
916
+
917
+ function renderDropdown() {
918
+ if (!props.onEdit || !props.onRemove) return undefined;
919
+ return [props.onEdit ? /*#__PURE__*/createElement(MenuItem, {
920
+ key: "edit",
921
+ testId: "card-action-edit",
922
+ onClick: function onClick() {
923
+ props.onEdit && props.onEdit();
924
+ }
925
+ }, "Edit") : null, props.onRemove ? /*#__PURE__*/createElement(MenuItem, {
926
+ key: "delete",
927
+ disabled: props.isDisabled,
928
+ testId: "card-action-remove",
929
+ onClick: function onClick() {
930
+ props.onRemove && props.onRemove();
931
+ }
932
+ }, "Remove") : null].filter(function (item) {
933
+ return item;
934
+ });
935
+ }
700
936
 
701
937
  if (entry === undefined) {
702
938
  return /*#__PURE__*/createElement(EntryCard, {
939
+ size: "default",
703
940
  isLoading: true
704
941
  });
705
942
  }
@@ -712,26 +949,50 @@ function FetchingWrappedEntryCard(props) {
712
949
  });
713
950
  }
714
951
 
715
- var contentType = props.sdk.space.getCachedContentTypes().find(function (contentType) {
716
- return contentType.sys.id === entry.sys.contentType.sys.id;
952
+ var entryStatus = entry ? entityHelpers.getEntryStatus(entry.sys) : undefined;
953
+
954
+ if (entryStatus === 'deleted') {
955
+ return /*#__PURE__*/createElement(MissingEntityCard, {
956
+ entityType: "Entry",
957
+ isDisabled: props.isDisabled,
958
+ onRemove: props.onRemove
959
+ });
960
+ }
961
+
962
+ var title = entityHelpers.getEntryTitle({
963
+ entry: entry,
964
+ contentType: contentType,
965
+ localeCode: props.locale,
966
+ defaultLocaleCode: defaultLocaleCode,
967
+ defaultTitle: 'Untitled'
968
+ });
969
+ var description = entityHelpers.getEntityDescription({
970
+ entity: entry,
971
+ contentType: contentType,
972
+ localeCode: props.locale,
973
+ defaultLocaleCode: defaultLocaleCode
717
974
  });
718
- return /*#__PURE__*/createElement(WrappedEntryCard, {
975
+ return /*#__PURE__*/createElement(EntryCard, {
976
+ contentType: contentType == null ? void 0 : contentType.name,
977
+ title: title,
978
+ description: description,
719
979
  size: "default",
720
- getAsset: props.sdk.space.getAsset,
721
- getEntityScheduledActions: loadEntityScheduledActions,
722
980
  isSelected: props.isSelected,
723
- isDisabled: props.isDisabled,
724
- localeCode: props.locale,
725
- defaultLocaleCode: props.sdk.locales["default"],
726
- contentType: contentType,
727
- entry: entry,
728
- onEdit: props.onEdit,
729
- onRemove: props.isDisabled ? undefined : props.onRemove,
730
- isClickable: false
981
+ status: entryStatus,
982
+ className: styles$2.entryCard,
983
+ thumbnailElement: file ? /*#__PURE__*/createElement(EntryThumbnail, {
984
+ file: file
985
+ }) : undefined,
986
+ icon: /*#__PURE__*/createElement(EntityStatusIcon, {
987
+ entityType: "Entry",
988
+ entity: entry
989
+ }),
990
+ withDragHandle: false,
991
+ actions: renderDropdown()
731
992
  });
732
993
  }
733
994
 
734
- var styles = {
995
+ var styles$3 = {
735
996
  root: /*#__PURE__*/css({
736
997
  marginBottom: '1.25rem !important',
737
998
  display: 'block'
@@ -773,17 +1034,17 @@ function LinkedEntityBlock(props) {
773
1034
  };
774
1035
 
775
1036
  return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
776
- className: styles.root,
1037
+ className: styles$3.root,
777
1038
  "data-entity-type": entityType,
778
1039
  "data-entity-id": entityId,
779
1040
  // COMPAT: This makes copy & paste work for Firefox
780
- contentEditable: !HAS_BEFORE_INPUT_SUPPORT ? false : undefined,
781
- draggable: !HAS_BEFORE_INPUT_SUPPORT ? true : undefined
1041
+ contentEditable: IS_CHROME ? undefined : false,
1042
+ draggable: IS_CHROME ? true : undefined
782
1043
  }), /*#__PURE__*/React__default.createElement("div", {
783
1044
  // COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
784
- contentEditable: HAS_BEFORE_INPUT_SUPPORT ? false : undefined,
785
- draggable: HAS_BEFORE_INPUT_SUPPORT ? true : undefined,
786
- className: styles.container
1045
+ contentEditable: IS_CHROME ? false : undefined,
1046
+ draggable: IS_CHROME ? true : undefined,
1047
+ className: styles$3.container
787
1048
  }, entityType === 'Entry' && /*#__PURE__*/React__default.createElement(FetchingWrappedEntryCard, {
788
1049
  sdk: sdk,
789
1050
  entryId: entityId,
@@ -1731,7 +1992,7 @@ function insertBlock(editor, nodeType, entity) {
1731
1992
  focus(editor);
1732
1993
  }
1733
1994
 
1734
- var styles$1 = {
1995
+ var styles$4 = {
1735
1996
  icon: /*#__PURE__*/css({
1736
1997
  marginRight: '10px'
1737
1998
  })
@@ -1779,7 +2040,7 @@ function EmbeddedEntityBlockToolbarIcon(_ref) {
1779
2040
  flexDirection: "row"
1780
2041
  }, /*#__PURE__*/React__default.createElement(Icon, {
1781
2042
  as: type === 'Asset' ? AssetIcon : EmbeddedEntryBlockIcon,
1782
- className: "rich-text__embedded-entry-list-icon " + styles$1.icon,
2043
+ className: "rich-text__embedded-entry-list-icon " + styles$4.icon,
1783
2044
  variant: "secondary"
1784
2045
  }), /*#__PURE__*/React__default.createElement("span", null, type)));
1785
2046
  }
@@ -1878,7 +2139,7 @@ var createEmbeddedAssetBlockPlugin = /*#__PURE__*/createEmbeddedEntityPlugin(BLO
1878
2139
 
1879
2140
  var getEntryTitle = entityHelpers.getEntryTitle,
1880
2141
  getEntryStatus = entityHelpers.getEntryStatus;
1881
- var styles$2 = {
2142
+ var styles$5 = {
1882
2143
  scheduledIcon: /*#__PURE__*/css({
1883
2144
  verticalAlign: 'text-bottom',
1884
2145
  marginRight: tokens.spacing2Xs
@@ -1949,7 +2210,7 @@ function FetchingWrappedInlineEntryCard(props) {
1949
2210
  actions: [/*#__PURE__*/React__default.createElement(MenuItem, {
1950
2211
  key: "remove",
1951
2212
  onClick: props.onRemove,
1952
- testId: "delete"
2213
+ testId: "card-action-remove"
1953
2214
  }, "Remove")]
1954
2215
  });
1955
2216
  }
@@ -1966,14 +2227,14 @@ function FetchingWrappedInlineEntryCard(props) {
1966
2227
  key: "remove",
1967
2228
  onClick: props.onRemove,
1968
2229
  disabled: props.isDisabled,
1969
- testId: "delete"
2230
+ testId: "card-action-remove"
1970
2231
  }, "Remove")]
1971
2232
  }, /*#__PURE__*/React__default.createElement(ScheduledIconWithTooltip, {
1972
2233
  getEntityScheduledActions: loadEntityScheduledActions,
1973
2234
  entityType: "Entry",
1974
2235
  entityId: entry.sys.id
1975
2236
  }, /*#__PURE__*/React__default.createElement(ClockIcon, {
1976
- className: styles$2.scheduledIcon,
2237
+ className: styles$5.scheduledIcon,
1977
2238
  variant: "muted",
1978
2239
  testId: "scheduled-icon"
1979
2240
  })), /*#__PURE__*/React__default.createElement(Text$1, null, title));
@@ -1997,7 +2258,7 @@ function createInlineEntryNode(id) {
1997
2258
  };
1998
2259
  }
1999
2260
 
2000
- var styles$3 = {
2261
+ var styles$6 = {
2001
2262
  icon: /*#__PURE__*/css({
2002
2263
  marginRight: '10px'
2003
2264
  }),
@@ -2033,15 +2294,15 @@ function EmbeddedEntityInline(props) {
2033
2294
  }
2034
2295
 
2035
2296
  return /*#__PURE__*/createElement("span", Object.assign({}, props.attributes, {
2036
- className: styles$3.root,
2297
+ className: styles$6.root,
2037
2298
  "data-embedded-entity-inline-id": entryId,
2038
2299
  // COMPAT: This makes copy & paste work for Firefox
2039
- contentEditable: !HAS_BEFORE_INPUT_SUPPORT ? false : undefined,
2040
- draggable: !HAS_BEFORE_INPUT_SUPPORT ? true : undefined
2300
+ contentEditable: IS_CHROME ? undefined : false,
2301
+ draggable: IS_CHROME ? true : undefined
2041
2302
  }), /*#__PURE__*/createElement("span", {
2042
2303
  // COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
2043
- contentEditable: HAS_BEFORE_INPUT_SUPPORT ? false : undefined,
2044
- draggable: HAS_BEFORE_INPUT_SUPPORT ? true : undefined
2304
+ contentEditable: IS_CHROME ? false : undefined,
2305
+ draggable: IS_CHROME ? true : undefined
2045
2306
  }, /*#__PURE__*/createElement(FetchingWrappedInlineEntryCard, {
2046
2307
  sdk: sdk,
2047
2308
  entryId: entryId,
@@ -2163,7 +2424,7 @@ function ToolbarEmbeddedEntityInlineButton(props) {
2163
2424
  flexDirection: "row"
2164
2425
  }, /*#__PURE__*/createElement(EmbeddedEntryInlineIcon, {
2165
2426
  variant: "secondary",
2166
- className: "rich-text__embedded-entry-list-icon " + styles$3.icon
2427
+ className: "rich-text__embedded-entry-list-icon " + styles$6.icon
2167
2428
  }), /*#__PURE__*/createElement("span", null, "Inline entry")));
2168
2429
  }
2169
2430
  function createEmbeddedEntityInlinePlugin(sdk) {
@@ -2239,7 +2500,7 @@ var isMarkEnabled = function isMarkEnabled(field, mark) {
2239
2500
  };
2240
2501
 
2241
2502
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _dropdown, _LABELS;
2242
- var styles$4 = {
2503
+ var styles$7 = {
2243
2504
  dropdown: (_dropdown = {
2244
2505
  root: /*#__PURE__*/css(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
2245
2506
  }, _dropdown[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown[BLOCKS.HEADING_1] = /*#__PURE__*/css(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown[BLOCKS.HEADING_2] = /*#__PURE__*/css(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown[BLOCKS.HEADING_3] = /*#__PURE__*/css(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown[BLOCKS.HEADING_4] = /*#__PURE__*/css(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown[BLOCKS.HEADING_5] = /*#__PURE__*/css(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown[BLOCKS.HEADING_6] = /*#__PURE__*/css(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown)
@@ -2334,7 +2595,7 @@ function ToolbarHeadingButton(props) {
2334
2595
  testId: "dropdown-option-" + nodeType,
2335
2596
  disabled: props.isDisabled
2336
2597
  }, /*#__PURE__*/createElement("span", {
2337
- className: cx(styles$4.dropdown.root, styles$4.dropdown[nodeType])
2598
+ className: cx(styles$7.dropdown.root, styles$7.dropdown[nodeType])
2338
2599
  }, LABELS[nodeType]));
2339
2600
  }).filter(Boolean)));
2340
2601
  }
@@ -2404,7 +2665,7 @@ var transformLift = function transformLift(editor, _ref4) {
2404
2665
  };
2405
2666
 
2406
2667
  var _templateObject$1, _templateObject2$1, _templateObject3$1, _templateObject4$1, _templateObject5$1, _templateObject6$1, _templateObject7$1, _templateObject8$1, _dropdown$1, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _headings, _HeadingComponents;
2407
- var styles$5 = {
2668
+ var styles$8 = {
2408
2669
  dropdown: (_dropdown$1 = {
2409
2670
  root: /*#__PURE__*/css(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-weight: ", ";\n "])), tokens.fontWeightDemiBold)
2410
2671
  }, _dropdown$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject2$1 || (_templateObject2$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: ", ";\n "])), tokens.fontSizeL), _dropdown$1[BLOCKS.HEADING_1] = /*#__PURE__*/css(_templateObject3$1 || (_templateObject3$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.625rem;\n "]))), _dropdown$1[BLOCKS.HEADING_2] = /*#__PURE__*/css(_templateObject4$1 || (_templateObject4$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.4375rem;\n "]))), _dropdown$1[BLOCKS.HEADING_3] = /*#__PURE__*/css(_templateObject5$1 || (_templateObject5$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.25rem;\n "]))), _dropdown$1[BLOCKS.HEADING_4] = /*#__PURE__*/css(_templateObject6$1 || (_templateObject6$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1.125rem;\n "]))), _dropdown$1[BLOCKS.HEADING_5] = /*#__PURE__*/css(_templateObject7$1 || (_templateObject7$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 1rem;\n "]))), _dropdown$1[BLOCKS.HEADING_6] = /*#__PURE__*/css(_templateObject8$1 || (_templateObject8$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 0.875rem;\n "]))), _dropdown$1),
@@ -2416,7 +2677,7 @@ var styles$5 = {
2416
2677
  function createHeading(Tag, block) {
2417
2678
  return function Heading(props) {
2418
2679
  return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
2419
- className: cx(styles$5.headings.root, styles$5.headings[block])
2680
+ className: cx(styles$8.headings.root, styles$8.headings[block])
2420
2681
  }), props.children);
2421
2682
  };
2422
2683
  }
@@ -2512,7 +2773,7 @@ var createHeadingPlugin = function createHeadingPlugin() {
2512
2773
  };
2513
2774
  };
2514
2775
 
2515
- var styles$6 = {
2776
+ var styles$9 = {
2516
2777
  button: /*#__PURE__*/css({
2517
2778
  height: '30px',
2518
2779
  width: '30px',
@@ -2538,7 +2799,7 @@ function ToolbarButton(props) {
2538
2799
  };
2539
2800
 
2540
2801
  var button = /*#__PURE__*/React__default.createElement(Button, {
2541
- className: cx(styles$6.button, className),
2802
+ className: cx(styles$9.button, className),
2542
2803
  isDisabled: isDisabled,
2543
2804
  startIcon: children,
2544
2805
  onClick: handleClick,
@@ -2549,7 +2810,7 @@ function ToolbarButton(props) {
2549
2810
 
2550
2811
  if (title) {
2551
2812
  return /*#__PURE__*/React__default.createElement(Tooltip, {
2552
- className: styles$6.tooltip,
2813
+ className: styles$9.tooltip,
2553
2814
  placement: "bottom",
2554
2815
  content: title
2555
2816
  }, button);
@@ -2559,7 +2820,7 @@ function ToolbarButton(props) {
2559
2820
  }
2560
2821
 
2561
2822
  var _templateObject$2, _templateObject2$2, _templateObject3$2;
2562
- var styles$7 = {
2823
+ var styles$a = {
2563
2824
  container: /*#__PURE__*/css(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0 0 ", ";\n "])), tokens.spacingL),
2564
2825
  hr: /*#__PURE__*/css(_templateObject2$2 || (_templateObject2$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n height: ", ";\n background: transparent;\n position: relative;\n border: 0;\n user-select: none;\n &:hover {\n cursor: pointer;\n }\n &::after {\n content: '';\n position: absolute;\n width: 100%;\n height: 1px;\n background: ", ";\n top: 50%;\n }\n "])), tokens.spacingM, tokens.gray300),
2565
2826
  hrSelected: /*#__PURE__*/css(_templateObject3$2 || (_templateObject3$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n &::after {\n background: ", ";\n -webkit-box-shadow: 0px 0px 5px ", ";\n box-shadow: 0px 0px 5px ", ";\n }\n "])), tokens.colorPrimary, tokens.colorPrimary, tokens.colorPrimary)
@@ -2617,14 +2878,14 @@ function Hr(props) {
2617
2878
  var isSelected = useSelected();
2618
2879
  var isFocused = useFocused();
2619
2880
  return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
2620
- className: styles$7.container,
2881
+ className: styles$a.container,
2621
2882
  "data-void-element": BLOCKS.HR
2622
2883
  }), /*#__PURE__*/createElement("div", {
2623
2884
  draggable: true,
2624
2885
  // Moving `contentEditable` to this div makes it to be selectable when being the first void element, e.g pressing ctrl + a to select everything
2625
2886
  contentEditable: false
2626
2887
  }, /*#__PURE__*/createElement("hr", {
2627
- className: cx(styles$7.hr, isSelected && isFocused ? styles$7.hrSelected : undefined)
2888
+ className: cx(styles$a.hr, isSelected && isFocused ? styles$a.hrSelected : undefined)
2628
2889
  })), props.children);
2629
2890
  }
2630
2891
  var createHrPlugin = function createHrPlugin() {
@@ -2651,7 +2912,7 @@ var createHrPlugin = function createHrPlugin() {
2651
2912
  };
2652
2913
 
2653
2914
  var _templateObject$3, _SYS_LINK_TYPES, _LINK_TYPE_SELECTION_;
2654
- var styles$8 = {
2915
+ var styles$b = {
2655
2916
  removeSelectionLabel: /*#__PURE__*/css(_templateObject$3 || (_templateObject$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-left: ", ";\n "])), tokens.spacingS)
2656
2917
  };
2657
2918
  var SYS_LINK_TYPES = (_SYS_LINK_TYPES = {}, _SYS_LINK_TYPES[INLINES.ENTRY_HYPERLINK] = 'Entry', _SYS_LINK_TYPES[INLINES.ASSET_HYPERLINK] = 'Asset', _SYS_LINK_TYPES);
@@ -2834,7 +3095,7 @@ function HyperlinkModal(props) {
2834
3095
  }, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/createElement(Fragment, null, !props.readonly && /*#__PURE__*/createElement(TextLink, {
2835
3096
  testId: "entity-selection-link",
2836
3097
  onClick: resetLinkEntity,
2837
- className: styles$8.removeSelectionLabel
3098
+ className: styles$b.removeSelectionLabel
2838
3099
  }, "Remove selection"), /*#__PURE__*/createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && /*#__PURE__*/createElement(FetchingWrappedEntryCard, {
2839
3100
  sdk: props.sdk,
2840
3101
  locale: props.sdk.field.locale,
@@ -3175,7 +3436,7 @@ function useEntityInfo(props) {
3175
3436
  return getEntityInfo(status.data);
3176
3437
  }
3177
3438
 
3178
- var styles$9 = {
3439
+ var styles$c = {
3179
3440
  hyperlinkWrapper: /*#__PURE__*/css({
3180
3441
  display: 'inline',
3181
3442
  position: 'static',
@@ -3220,13 +3481,13 @@ function EntityHyperlink(props) {
3220
3481
 
3221
3482
  return /*#__PURE__*/createElement(Tooltip, {
3222
3483
  content: tooltipContent,
3223
- targetWrapperClassName: styles$9.hyperlinkWrapper,
3484
+ targetWrapperClassName: styles$c.hyperlinkWrapper,
3224
3485
  placement: "bottom",
3225
3486
  maxWidth: "auto"
3226
3487
  }, /*#__PURE__*/createElement(TextLink, {
3227
3488
  as: "a",
3228
3489
  onClick: handleClick,
3229
- className: styles$9.hyperlink,
3490
+ className: styles$c.hyperlink,
3230
3491
  "data-link-type": target.sys.linkType,
3231
3492
  "data-link-id": target.sys.id
3232
3493
  }, props.children));
@@ -3250,7 +3511,7 @@ function UrlHyperlink(props) {
3250
3511
 
3251
3512
  return /*#__PURE__*/createElement(Tooltip, {
3252
3513
  content: uri,
3253
- targetWrapperClassName: styles$9.hyperlinkWrapper,
3514
+ targetWrapperClassName: styles$c.hyperlinkWrapper,
3254
3515
  placement: "bottom",
3255
3516
  maxWidth: "auto"
3256
3517
  }, /*#__PURE__*/createElement(TextLink, {
@@ -3258,7 +3519,7 @@ function UrlHyperlink(props) {
3258
3519
  href: uri,
3259
3520
  rel: "noopener noreferrer",
3260
3521
  onClick: handleClick,
3261
- className: styles$9.hyperlink
3522
+ className: styles$c.hyperlink
3262
3523
  }, props.children));
3263
3524
  }
3264
3525
 
@@ -3384,12 +3645,12 @@ var createHyperlinkPlugin = function createHyperlinkPlugin(sdk) {
3384
3645
 
3385
3646
  var _templateObject$4, _templateObject2$3, _templateObject3$3, _styles;
3386
3647
  var baseStyle = /*#__PURE__*/css(_templateObject$4 || (_templateObject$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n padding: 0;\n margin: 0 0 1.25rem 1.25rem;\n\n div:first-child {\n margin: 0;\n line-height: ", ";\n }\n"])), tokens.lineHeightDefault);
3387
- var styles$a = (_styles = {}, _styles[BLOCKS.UL_LIST] = /*#__PURE__*/css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))), _styles[BLOCKS.OL_LIST] = /*#__PURE__*/css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))), _styles);
3648
+ var styles$d = (_styles = {}, _styles[BLOCKS.UL_LIST] = /*#__PURE__*/css(_templateObject2$3 || (_templateObject2$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: disc;\n ul {\n list-style-type: circle;\n ul {\n list-style-type: square;\n }\n }\n "]))), _styles[BLOCKS.OL_LIST] = /*#__PURE__*/css(_templateObject3$3 || (_templateObject3$3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n list-style-type: decimal;\n ol {\n list-style-type: upper-alpha;\n ol {\n list-style-type: lower-roman;\n ol {\n list-style-type: lower-alpha;\n }\n }\n }\n "]))), _styles);
3388
3649
 
3389
3650
  function createList(Tag, block) {
3390
3651
  return function List(props) {
3391
3652
  return /*#__PURE__*/createElement(Tag, Object.assign({}, props.attributes, {
3392
- className: cx(baseStyle, styles$a[block])
3653
+ className: cx(baseStyle, styles$d[block])
3393
3654
  }), props.children);
3394
3655
  };
3395
3656
  }
@@ -4370,14 +4631,14 @@ var ToolbarBoldButton = /*#__PURE__*/createMarkToolbarButton({
4370
4631
  mark: MARKS.BOLD,
4371
4632
  icon: /*#__PURE__*/createElement(FormatBoldIcon, null)
4372
4633
  });
4373
- var styles$b = {
4634
+ var styles$e = {
4374
4635
  bold: /*#__PURE__*/css({
4375
4636
  fontWeight: 600
4376
4637
  })
4377
4638
  };
4378
4639
  function Bold(props) {
4379
4640
  return /*#__PURE__*/createElement("strong", Object.assign({}, props.attributes, {
4380
- className: styles$b.bold
4641
+ className: styles$e.bold
4381
4642
  }), props.children);
4382
4643
  }
4383
4644
 
@@ -4417,7 +4678,7 @@ var ToolbarCodeButton = /*#__PURE__*/createMarkToolbarButton({
4417
4678
  mark: MARKS.CODE,
4418
4679
  icon: /*#__PURE__*/createElement(CodeIcon, null)
4419
4680
  });
4420
- var styles$c = {
4681
+ var styles$f = {
4421
4682
  code: /*#__PURE__*/css({
4422
4683
  fontFamily: 'monospace',
4423
4684
  fontSize: '.9em'
@@ -4425,7 +4686,7 @@ var styles$c = {
4425
4686
  };
4426
4687
  function Code(props) {
4427
4688
  return /*#__PURE__*/createElement("code", Object.assign({}, props.attributes, {
4428
- className: styles$c.code
4689
+ className: styles$f.code
4429
4690
  }), props.children);
4430
4691
  }
4431
4692
  var createCodePlugin = function createCodePlugin() {
@@ -4455,14 +4716,14 @@ var ToolbarItalicButton = /*#__PURE__*/createMarkToolbarButton({
4455
4716
  mark: MARKS.ITALIC,
4456
4717
  icon: /*#__PURE__*/createElement(FormatItalicIcon, null)
4457
4718
  });
4458
- var styles$d = {
4719
+ var styles$g = {
4459
4720
  italic: /*#__PURE__*/css({
4460
4721
  fontStyle: 'italic'
4461
4722
  })
4462
4723
  };
4463
4724
  function Italic(props) {
4464
4725
  return /*#__PURE__*/createElement("em", Object.assign({}, props.attributes, {
4465
- className: styles$d.italic
4726
+ className: styles$g.italic
4466
4727
  }), props.children);
4467
4728
  }
4468
4729
  var createItalicPlugin = function createItalicPlugin() {
@@ -4738,10 +4999,10 @@ var createNormalizerPlugin = function createNormalizerPlugin() {
4738
4999
  };
4739
5000
 
4740
5001
  var _templateObject$6, _styles$1;
4741
- var styles$e = (_styles$1 = {}, _styles$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
5002
+ var styles$h = (_styles$1 = {}, _styles$1[BLOCKS.PARAGRAPH] = /*#__PURE__*/css(_templateObject$6 || (_templateObject$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n line-height: ", ";\n margin-bottom: 1.5em;\n "])), tokens.lineHeightDefault), _styles$1);
4742
5003
  function Paragraph(props) {
4743
5004
  return /*#__PURE__*/createElement("div", Object.assign({}, props.attributes, {
4744
- className: styles$e[BLOCKS.PARAGRAPH]
5005
+ className: styles$h[BLOCKS.PARAGRAPH]
4745
5006
  }), props.children);
4746
5007
  }
4747
5008
 
@@ -5562,7 +5823,7 @@ var isTable = function isTable(node) {
5562
5823
  return Element.isElement(node) && node.type === BLOCKS.TABLE;
5563
5824
  };
5564
5825
 
5565
- var styles$f = {
5826
+ var styles$i = {
5566
5827
  topRight: /*#__PURE__*/css({
5567
5828
  position: 'absolute',
5568
5829
  top: '6px',
@@ -5651,7 +5912,7 @@ var TableActions = function TableActions() {
5651
5912
  size: "small",
5652
5913
  variant: "transparent",
5653
5914
  tabIndex: -1,
5654
- className: styles$f.topRight,
5915
+ className: styles$i.topRight,
5655
5916
  icon: /*#__PURE__*/React__default.createElement(ChevronDownIcon, null),
5656
5917
  "aria-label": "Open table menu",
5657
5918
  testId: "cf-table-actions-button"
@@ -6473,6 +6734,42 @@ var disableCorePlugins = {
6473
6734
  eventEditor: true
6474
6735
  };
6475
6736
 
6737
+ var isTextElement = function isTextElement(node) {
6738
+ return 'text' in node;
6739
+ };
6740
+ /**
6741
+ * Ensures all nodes have a child leaf text element. This should be handled by
6742
+ * Slate but its behavior has proven to be buggy and unpredictable.
6743
+ */
6744
+
6745
+
6746
+ function sanitizeIncomingSlateDoc(nodes) {
6747
+ if (nodes === void 0) {
6748
+ nodes = [];
6749
+ }
6750
+
6751
+ return nodes.map(function (node) {
6752
+ var _node$children;
6753
+
6754
+ if (isTextElement(node)) {
6755
+ return node;
6756
+ }
6757
+
6758
+ if (((_node$children = node.children) == null ? void 0 : _node$children.length) === 0) {
6759
+ return _extends({}, node, {
6760
+ children: [{
6761
+ text: '',
6762
+ data: {}
6763
+ }]
6764
+ });
6765
+ }
6766
+
6767
+ return _extends({}, node, {
6768
+ children: sanitizeIncomingSlateDoc(node.children)
6769
+ });
6770
+ });
6771
+ }
6772
+
6476
6773
  /**
6477
6774
  * For legacy reasons, a document may not have any content at all
6478
6775
  * e.g:
@@ -6527,16 +6824,17 @@ var setEditorContent = function setEditorContent(editor, nodes) {
6527
6824
  });
6528
6825
  };
6529
6826
  /**
6530
- * Converts a contenful rich text document to the corresponding slate editor
6827
+ * Converts a Contentful rich text document to the corresponding slate editor
6531
6828
  * value
6532
6829
  */
6533
6830
 
6534
6831
  var documentToEditorValue = function documentToEditorValue(doc) {
6535
- return toSlatejsDocument({
6832
+ var slateDoc = toSlatejsDocument({
6536
6833
  document: hasContent(doc) ? doc : EMPTY_DOCUMENT,
6537
6834
  // TODO: get rid of schema, https://github.com/contentful/field-editors/pull/1065#discussion_r826723248
6538
6835
  schema: schema
6539
6836
  });
6837
+ return sanitizeIncomingSlateDoc(slateDoc);
6540
6838
  };
6541
6839
  var normalizeEditorValue = function normalizeEditorValue(value, options) {
6542
6840
  var editor = createPlateEditor(options);
@@ -6548,7 +6846,7 @@ var normalizeEditorValue = function normalizeEditorValue(value, options) {
6548
6846
  };
6549
6847
 
6550
6848
  var STYLE_EDITOR_BORDER = "1px solid " + tokens.gray400;
6551
- var styles$g = {
6849
+ var styles$j = {
6552
6850
  root: /*#__PURE__*/css({
6553
6851
  position: 'relative'
6554
6852
  }),
@@ -6664,7 +6962,7 @@ var EmbedEntityWidget = function EmbedEntityWidget(_ref) {
6664
6962
  }, actions);
6665
6963
  };
6666
6964
 
6667
- var styles$h = {
6965
+ var styles$k = {
6668
6966
  toolbar: /*#__PURE__*/css({
6669
6967
  border: "1px solid " + tokens.gray400,
6670
6968
  backgroundColor: tokens.gray100,
@@ -6709,14 +7007,14 @@ var Toolbar = function Toolbar(_ref) {
6709
7007
  var shouldDisableTables = isDisabled || !canInsertBlocks || isListSelected || isBlockquoteSelected;
6710
7008
  return /*#__PURE__*/React__default.createElement(Flex, {
6711
7009
  testId: "toolbar",
6712
- className: styles$h.toolbar,
7010
+ className: styles$k.toolbar,
6713
7011
  alignItems: "center"
6714
7012
  }, /*#__PURE__*/React__default.createElement("div", {
6715
- className: styles$h.formattingOptionsWrapper
7013
+ className: styles$k.formattingOptionsWrapper
6716
7014
  }, /*#__PURE__*/React__default.createElement(ToolbarHeadingButton, {
6717
7015
  isDisabled: isDisabled || !canInsertBlocks
6718
7016
  }), validationInfo.isAnyMarkEnabled && /*#__PURE__*/React__default.createElement("span", {
6719
- className: styles$h.divider
7017
+ className: styles$k.divider
6720
7018
  }), isMarkEnabled(sdk.field, MARKS.BOLD) && /*#__PURE__*/React__default.createElement(ToolbarBoldButton, {
6721
7019
  isDisabled: isDisabled
6722
7020
  }), isMarkEnabled(sdk.field, MARKS.ITALIC) && /*#__PURE__*/React__default.createElement(ToolbarItalicButton, {
@@ -6726,11 +7024,11 @@ var Toolbar = function Toolbar(_ref) {
6726
7024
  }), isMarkEnabled(sdk.field, MARKS.CODE) && /*#__PURE__*/React__default.createElement(ToolbarCodeButton, {
6727
7025
  isDisabled: isDisabled
6728
7026
  }), validationInfo.isAnyHyperlinkEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("span", {
6729
- className: styles$h.divider
7027
+ className: styles$k.divider
6730
7028
  }), /*#__PURE__*/React__default.createElement(ToolbarHyperlinkButton, {
6731
7029
  isDisabled: isDisabled
6732
7030
  })), validationInfo.isAnyBlockFormattingEnabled && /*#__PURE__*/React__default.createElement("span", {
6733
- className: styles$h.divider
7031
+ className: styles$k.divider
6734
7032
  }), /*#__PURE__*/React__default.createElement(ToolbarListButton, {
6735
7033
  isDisabled: isDisabled || !canInsertBlocks
6736
7034
  }), isNodeTypeEnabled(sdk.field, BLOCKS.QUOTE) && /*#__PURE__*/React__default.createElement(ToolbarQuoteButton, {
@@ -6740,7 +7038,7 @@ var Toolbar = function Toolbar(_ref) {
6740
7038
  }), isNodeTypeEnabled(sdk.field, BLOCKS.TABLE) && /*#__PURE__*/React__default.createElement(ToolbarTableButton, {
6741
7039
  isDisabled: shouldDisableTables
6742
7040
  })), /*#__PURE__*/React__default.createElement("div", {
6743
- className: styles$h.embedActionsWrapper
7041
+ className: styles$k.embedActionsWrapper
6744
7042
  }, /*#__PURE__*/React__default.createElement(EmbedEntityWidget, {
6745
7043
  isDisabled: isDisabled,
6746
7044
  canInsertBlocks: canInsertBlocks
@@ -6765,7 +7063,7 @@ function getValidationInfo(field) {
6765
7063
  }
6766
7064
 
6767
7065
  var _templateObject$b;
6768
- var styles$i = {
7066
+ var styles$l = {
6769
7067
  nativeSticky: /*#__PURE__*/css(_templateObject$b || (_templateObject$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: -webkit-sticky;\n position: sticky;\n top: -1px;\n z-index: 2;\n "])))
6770
7068
  };
6771
7069
 
@@ -6773,7 +7071,7 @@ var StickyToolbarWrapper = function StickyToolbarWrapper(_ref) {
6773
7071
  var isDisabled = _ref.isDisabled,
6774
7072
  children = _ref.children;
6775
7073
  return /*#__PURE__*/React__default.createElement("div", {
6776
- className: isDisabled ? '' : styles$i.nativeSticky
7074
+ className: isDisabled ? '' : styles$l.nativeSticky
6777
7075
  }, children);
6778
7076
  };
6779
7077
 
@@ -6868,9 +7166,9 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6868
7166
  setPendingExternalUpdate(true);
6869
7167
  setEditorContent(editor, documentToEditorValue(props.value));
6870
7168
  }, [props.value, id]);
6871
- var classNames = cx(styles$g.editor, props.minHeight !== undefined ? css({
7169
+ var classNames = cx(styles$j.editor, props.minHeight !== undefined ? css({
6872
7170
  minHeight: props.minHeight
6873
- }) : undefined, props.isDisabled ? styles$g.disabled : styles$g.enabled, props.isToolbarHidden && styles$g.hiddenToolbar);
7171
+ }) : undefined, props.isDisabled ? styles$j.disabled : styles$j.enabled, props.isToolbarHidden && styles$j.hiddenToolbar);
6874
7172
  useEffect(function () {
6875
7173
  if (!isFirstRender) {
6876
7174
  return;
@@ -6886,7 +7184,7 @@ var ConnectedRichTextEditor = function ConnectedRichTextEditor(props) {
6886
7184
  }, /*#__PURE__*/React__default.createElement(ContentfulEditorIdProvider, {
6887
7185
  value: id
6888
7186
  }, /*#__PURE__*/React__default.createElement("div", {
6889
- className: styles$g.root,
7187
+ className: styles$j.root,
6890
7188
  "data-test-id": "rich-text-editor"
6891
7189
  }, /*#__PURE__*/React__default.createElement(Plate, {
6892
7190
  id: id,