@contentful/field-editor-rich-text 3.4.21 → 3.4.22

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.
@@ -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 as usePlateEditorRef$1, usePlateEditorState as usePlateEditorState$1, getPlateSelectors as getPlateSelectors$1, focusEditor as focusEditor$1, withoutNormalizing as withoutNormalizing$1, createPlateEditor as createPlateEditor$1, blurEditor as blurEditor$1, toSlatePoint, mockPlugin as mockPlugin$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, getLastNodeByLevel as getLastNodeByLevel$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, 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, select as select$1, liftNodes as liftNodes$1, toggleMark as toggleMark$1, normalizeEditor, setNodes as setNodes$1, toggleNodeType as toggleNodeType$1, deleteText as deleteText$1, moveSelection as moveSelection$1, deleteFragment as deleteFragment$1, splitNodes as splitNodes$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';
5
+ import { usePlateEditorRef as usePlateEditorRef$1, usePlateEditorState as usePlateEditorState$1, getPlateSelectors as getPlateSelectors$1, focusEditor as focusEditor$1, withoutNormalizing as withoutNormalizing$1, createPlateEditor as createPlateEditor$1, blurEditor as blurEditor$1, toSlatePoint, 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, getNodeEntry as getNodeEntry$1, isEditor as isEditor$1, getLastNodeByLevel as getLastNodeByLevel$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, createPathRef as createPathRef$1, getNodeTexts as getNodeTexts$1, getNodeChildren as getNodeChildren$1, isExpanded, isSelectionAtBlockStart as isSelectionAtBlockStart$1, 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, select as select$1, liftNodes as liftNodes$1, toggleMark as toggleMark$1, normalizeEditor, setNodes as setNodes$1, toggleNodeType as toggleNodeType$1, deleteText as deleteText$1, moveSelection as moveSelection$1, splitNodes as splitNodes$1, insertText as insertText$1, collapseSelection as collapseSelection$1, moveChildren as moveChildren$1, moveNodes as moveNodes$1, ELEMENT_DEFAULT as ELEMENT_DEFAULT$1, isBlockAboveEmpty, mockPlugin, 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';
@@ -21,7 +21,7 @@ import flow from 'lodash-es/flow';
21
21
  import get from 'lodash-es/get';
22
22
  import tokens from '@contentful/f36-tokens';
23
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
- 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';
24
+ import { getListTypes, ELEMENT_LIC, getListItemEntry, isListNested, moveListItemUp, ELEMENT_LI, unwrapList as unwrapList$1, deleteForwardList, deleteFragmentList, normalizeList, createListPlugin as createListPlugin$1, ELEMENT_UL, ELEMENT_OL } from '@udecode/plate-list';
25
25
  import castArray from 'lodash-es/castArray';
26
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';
@@ -96,10 +96,6 @@ const fromDOMPoint = (editor, domPoint, opts = {
96
96
  }) => {
97
97
  return toSlatePoint(editor, domPoint, opts);
98
98
  };
99
- const mockPlugin = plugin => {
100
- return mockPlugin$1( // TODO check if there is a way around this ugly casting
101
- plugin);
102
- };
103
99
  const getPlateSelectors = id => {
104
100
  return getPlateSelectors$1(id);
105
101
  };
@@ -328,9 +324,6 @@ const getChildren = entry => {
328
324
 
329
325
  return getChildren$1(entry);
330
326
  };
331
- const isFirstChild = path => {
332
- return isFirstChild$1(path);
333
- };
334
327
  const getDescendantNodeByPath = (root, path) => {
335
328
  // @ts-expect-error
336
329
  return Node.get(root, path);
@@ -412,7 +405,7 @@ const getPathLevels = (path, options) => {
412
405
  return Path.levels(path, options);
413
406
  };
414
407
  const isFirstChildPath = path => {
415
- return isFirstChild$1(path);
408
+ return isFirstChild(path);
416
409
  };
417
410
  const isLastChildPath = (entry, childPath) => {
418
411
  return isLastChild(entry, childPath);
@@ -530,9 +523,6 @@ const removeNodes = (editor, opts) => {
530
523
  const moveNodes = (editor, opts) => {
531
524
  moveNodes$1(editor, opts);
532
525
  };
533
- const deleteFragment = (editor, options) => {
534
- return deleteFragment$1(editor, options);
535
- };
536
526
 
537
527
  const IS_SAFARI = typeof navigator !== 'undefined' && /*#__PURE__*/ /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
538
528
  const IS_CHROME = /*#__PURE__*/ /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/.test(navigator.userAgent);
@@ -3926,7 +3916,7 @@ const listBreak = editor => {
3926
3916
  }
3927
3917
  }
3928
3918
 
3929
- const didReset = onKeyDownResetNode(editor, mockPlugin$1({
3919
+ const didReset = onKeyDownResetNode(editor, mockPlugin({
3930
3920
  options: {
3931
3921
  rules: [{
3932
3922
  types: [getPluginType$1(editor, ELEMENT_LI)],
@@ -4071,67 +4061,6 @@ const insertListFragment = editor => {
4071
4061
  };
4072
4062
  };
4073
4063
 
4074
- /**
4075
- * Credit: Modified version of Plate's list plugin
4076
- * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
4077
- */
4078
- const deleteBackwardList = (editor, unit) => {
4079
- const res = getListItemEntry(editor, {});
4080
- let moved = false;
4081
-
4082
- if (res) {
4083
- const {
4084
- list,
4085
- listItem
4086
- } = res;
4087
-
4088
- if (isSelectionAtBlockStart(editor, {
4089
- match: node => node.type === BLOCKS.LIST_ITEM
4090
- })) {
4091
- withoutNormalizing(editor, () => {
4092
- moved = removeFirstListItem(editor, {
4093
- list,
4094
- listItem
4095
- });
4096
- if (moved) return;
4097
- moved = removeListItem(editor, {
4098
- list,
4099
- listItem
4100
- });
4101
- if (moved) return;
4102
-
4103
- if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
4104
- onKeyDownResetNode(editor, // TODO look into this
4105
- // @ts-expect-error
4106
- mockPlugin({
4107
- options: {
4108
- rules: [{
4109
- types: [BLOCKS.LIST_ITEM],
4110
- defaultType: BLOCKS.PARAGRAPH,
4111
- hotkey: 'backspace',
4112
- predicate: () => isSelectionAtBlockStart(editor),
4113
- onReset: e => unwrapList(e)
4114
- }]
4115
- }
4116
- }))(SIMULATE_BACKSPACE);
4117
- moved = true;
4118
- return;
4119
- }
4120
-
4121
- deleteFragment(editor, {
4122
- // FIXME: see if we can remove unit
4123
- // @ts-expect-error
4124
- unit: unit,
4125
- reverse: true
4126
- });
4127
- moved = true;
4128
- });
4129
- }
4130
- }
4131
-
4132
- return moved;
4133
- };
4134
-
4135
4064
  /**
4136
4065
  * Credit: Modified version of Plate's list plugin
4137
4066
  * See: https://github.com/udecode/plate/blob/main/packages/nodes/list
@@ -4139,16 +4068,10 @@ const deleteBackwardList = (editor, unit) => {
4139
4068
  const validLiChildrenTypes = LIST_ITEM_BLOCKS;
4140
4069
  const withList = editor => {
4141
4070
  const {
4142
- deleteBackward,
4143
4071
  deleteForward,
4144
4072
  deleteFragment
4145
4073
  } = editor;
4146
4074
 
4147
- editor.deleteBackward = unit => {
4148
- if (deleteBackwardList(editor, unit)) return;
4149
- deleteBackward(unit);
4150
- };
4151
-
4152
4075
  editor.deleteForward = unit => {
4153
4076
  if (deleteForwardList(editor)) return;
4154
4077
  deleteForward(unit);