@contentful/field-editor-rich-text 2.0.0-next.34 → 2.0.0-next.35
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 +25 -5
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +26 -6
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import React__default, { createContext, useContext, useMemo, createElement, useE
|
|
|
2
2
|
import { useEntities, ScheduledIconWithTooltip, MissingEntityCard, AssetThumbnail, EntityProvider, getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
3
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
|
-
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, createDeserializeHtmlPlugin, createDeserializeAstPlugin, createPlateEditor, getPlateSelectors, getPlateActions, Plate } from '@udecode/plate-core';
|
|
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';
|
|
7
7
|
import deepEquals from 'fast-deep-equal';
|
|
8
8
|
import noop from 'lodash-es/noop';
|
|
@@ -5436,7 +5436,8 @@ var createSelectOnBackspacePlugin = function createSelectOnBackspacePlugin() {
|
|
|
5436
5436
|
return createSelectOnBackspacePlugin$1({
|
|
5437
5437
|
options: {
|
|
5438
5438
|
query: {
|
|
5439
|
-
|
|
5439
|
+
// `createTextPlugin` is taking care of block elements
|
|
5440
|
+
allow: [INLINES.EMBEDDED_ENTRY]
|
|
5440
5441
|
}
|
|
5441
5442
|
}
|
|
5442
5443
|
});
|
|
@@ -6599,11 +6600,11 @@ function createTextPlugin() {
|
|
|
6599
6600
|
deleteBackward = editor.deleteBackward;
|
|
6600
6601
|
|
|
6601
6602
|
editor.deleteBackward = function (unit) {
|
|
6602
|
-
|
|
6603
|
+
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
6603
6604
|
};
|
|
6604
6605
|
|
|
6605
6606
|
editor.deleteForward = function (unit) {
|
|
6606
|
-
|
|
6607
|
+
deleteEmptyParagraph(unit, editor, deleteForward);
|
|
6607
6608
|
};
|
|
6608
6609
|
|
|
6609
6610
|
return editor;
|
|
@@ -6611,7 +6612,7 @@ function createTextPlugin() {
|
|
|
6611
6612
|
};
|
|
6612
6613
|
}
|
|
6613
6614
|
|
|
6614
|
-
function
|
|
6615
|
+
function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
6615
6616
|
var entry = getAbove(editor, {
|
|
6616
6617
|
match: {
|
|
6617
6618
|
type: TEXT_CONTAINERS
|
|
@@ -6626,10 +6627,29 @@ function deleteFirstEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
6626
6627
|
var isRootLevel = path.length === 1;
|
|
6627
6628
|
var hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
6628
6629
|
|
|
6629
|
-
if (isTextEmpty && isRootLevel &&
|
|
6630
|
+
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
6630
6631
|
Transforms.removeNodes(editor, {
|
|
6631
6632
|
at: path
|
|
6632
6633
|
});
|
|
6634
|
+
var prevNode = Editor.before(editor, editor.selection, {
|
|
6635
|
+
unit: unit
|
|
6636
|
+
});
|
|
6637
|
+
|
|
6638
|
+
if (prevNode) {
|
|
6639
|
+
var _Editor$nodes = Editor.nodes(editor, {
|
|
6640
|
+
match: function match(node) {
|
|
6641
|
+
return queryNode([node, prevNode.path], {
|
|
6642
|
+
allow: [BLOCKS.EMBEDDED_ASSET, BLOCKS.EMBEDDED_ENTRY, BLOCKS.HR]
|
|
6643
|
+
});
|
|
6644
|
+
},
|
|
6645
|
+
at: prevNode
|
|
6646
|
+
}),
|
|
6647
|
+
prevCell = _Editor$nodes[0];
|
|
6648
|
+
|
|
6649
|
+
if (prevCell) {
|
|
6650
|
+
Transforms.select(editor, prevNode);
|
|
6651
|
+
}
|
|
6652
|
+
}
|
|
6633
6653
|
} else {
|
|
6634
6654
|
deleteFunction(unit);
|
|
6635
6655
|
}
|