@contentful/field-editor-rich-text 3.4.20 → 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.
- package/dist/field-editor-rich-text.cjs.development.js +4 -77
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +38 -38
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +8 -81
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/package.json +2 -2
- package/CHANGELOG.md +0 -942
- package/dist/plugins/List/transforms/deleteBackwardList.d.ts +0 -2
|
@@ -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,
|
|
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,
|
|
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
|
|
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);
|
|
@@ -1776,6 +1766,8 @@ async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
|
|
|
1776
1766
|
nodeType
|
|
1777
1767
|
});
|
|
1778
1768
|
} else {
|
|
1769
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
1770
|
+
// (i.e. when using hotkeys and slide-in)
|
|
1779
1771
|
select(editor, selection);
|
|
1780
1772
|
insertBlock$1(editor, nodeType, entity);
|
|
1781
1773
|
ensureFollowingParagraph(editor);
|
|
@@ -2171,6 +2163,8 @@ async function selectEntityAndInsert$1(editor, sdk, logAction) {
|
|
|
2171
2163
|
nodeType: INLINES.EMBEDDED_ENTRY
|
|
2172
2164
|
});
|
|
2173
2165
|
} else {
|
|
2166
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
2167
|
+
// (i.e. when using hotkeys and slide-in)
|
|
2174
2168
|
select(editor, selection);
|
|
2175
2169
|
insertNodes(editor, createInlineEntryNode$1(entry.sys.id));
|
|
2176
2170
|
logAction('insert', {
|
|
@@ -3922,7 +3916,7 @@ const listBreak = editor => {
|
|
|
3922
3916
|
}
|
|
3923
3917
|
}
|
|
3924
3918
|
|
|
3925
|
-
const didReset = onKeyDownResetNode(editor, mockPlugin
|
|
3919
|
+
const didReset = onKeyDownResetNode(editor, mockPlugin({
|
|
3926
3920
|
options: {
|
|
3927
3921
|
rules: [{
|
|
3928
3922
|
types: [getPluginType$1(editor, ELEMENT_LI)],
|
|
@@ -4067,67 +4061,6 @@ const insertListFragment = editor => {
|
|
|
4067
4061
|
};
|
|
4068
4062
|
};
|
|
4069
4063
|
|
|
4070
|
-
/**
|
|
4071
|
-
* Credit: Modified version of Plate's list plugin
|
|
4072
|
-
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4073
|
-
*/
|
|
4074
|
-
const deleteBackwardList = (editor, unit) => {
|
|
4075
|
-
const res = getListItemEntry(editor, {});
|
|
4076
|
-
let moved = false;
|
|
4077
|
-
|
|
4078
|
-
if (res) {
|
|
4079
|
-
const {
|
|
4080
|
-
list,
|
|
4081
|
-
listItem
|
|
4082
|
-
} = res;
|
|
4083
|
-
|
|
4084
|
-
if (isSelectionAtBlockStart(editor, {
|
|
4085
|
-
match: node => node.type === BLOCKS.LIST_ITEM
|
|
4086
|
-
})) {
|
|
4087
|
-
withoutNormalizing(editor, () => {
|
|
4088
|
-
moved = removeFirstListItem(editor, {
|
|
4089
|
-
list,
|
|
4090
|
-
listItem
|
|
4091
|
-
});
|
|
4092
|
-
if (moved) return;
|
|
4093
|
-
moved = removeListItem(editor, {
|
|
4094
|
-
list,
|
|
4095
|
-
listItem
|
|
4096
|
-
});
|
|
4097
|
-
if (moved) return;
|
|
4098
|
-
|
|
4099
|
-
if (isFirstChild(listItem[1]) && !isListNested(editor, list[1])) {
|
|
4100
|
-
onKeyDownResetNode(editor, // TODO look into this
|
|
4101
|
-
// @ts-expect-error
|
|
4102
|
-
mockPlugin({
|
|
4103
|
-
options: {
|
|
4104
|
-
rules: [{
|
|
4105
|
-
types: [BLOCKS.LIST_ITEM],
|
|
4106
|
-
defaultType: BLOCKS.PARAGRAPH,
|
|
4107
|
-
hotkey: 'backspace',
|
|
4108
|
-
predicate: () => isSelectionAtBlockStart(editor),
|
|
4109
|
-
onReset: e => unwrapList(e)
|
|
4110
|
-
}]
|
|
4111
|
-
}
|
|
4112
|
-
}))(SIMULATE_BACKSPACE);
|
|
4113
|
-
moved = true;
|
|
4114
|
-
return;
|
|
4115
|
-
}
|
|
4116
|
-
|
|
4117
|
-
deleteFragment(editor, {
|
|
4118
|
-
// FIXME: see if we can remove unit
|
|
4119
|
-
// @ts-expect-error
|
|
4120
|
-
unit: unit,
|
|
4121
|
-
reverse: true
|
|
4122
|
-
});
|
|
4123
|
-
moved = true;
|
|
4124
|
-
});
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4127
|
-
|
|
4128
|
-
return moved;
|
|
4129
|
-
};
|
|
4130
|
-
|
|
4131
4064
|
/**
|
|
4132
4065
|
* Credit: Modified version of Plate's list plugin
|
|
4133
4066
|
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
@@ -4135,16 +4068,10 @@ const deleteBackwardList = (editor, unit) => {
|
|
|
4135
4068
|
const validLiChildrenTypes = LIST_ITEM_BLOCKS;
|
|
4136
4069
|
const withList = editor => {
|
|
4137
4070
|
const {
|
|
4138
|
-
deleteBackward,
|
|
4139
4071
|
deleteForward,
|
|
4140
4072
|
deleteFragment
|
|
4141
4073
|
} = editor;
|
|
4142
4074
|
|
|
4143
|
-
editor.deleteBackward = unit => {
|
|
4144
|
-
if (deleteBackwardList(editor, unit)) return;
|
|
4145
|
-
deleteBackward(unit);
|
|
4146
|
-
};
|
|
4147
|
-
|
|
4148
4075
|
editor.deleteForward = unit => {
|
|
4149
4076
|
if (deleteForwardList(editor)) return;
|
|
4150
4077
|
deleteForward(unit);
|