@contentful/field-editor-rich-text 2.0.0-next.27 → 2.0.0-next.28
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 +1 -62
- 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 +3 -64
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +0 -2
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { createContext, useContext, useMemo, createElement, useEffect, useState, memo, Fragment, useCallback } from 'react';
|
|
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
|
-
import { BLOCKS, INLINES,
|
|
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, 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';
|
|
@@ -10,7 +10,7 @@ import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
|
10
10
|
import { createSoftBreakPlugin as createSoftBreakPlugin$1, createExitBreakPlugin as createExitBreakPlugin$1 } from '@udecode/plate-break';
|
|
11
11
|
import { createResetNodePlugin as createResetNodePlugin$1, onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
12
12
|
import isHotkey from 'is-hotkey';
|
|
13
|
-
import { Text, Element, Editor, Transforms, Range,
|
|
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
16
|
import { AssetCard, Menu, Text as Text$1, Notification, EntryCard, MenuItem, Button, Flex, Icon, InlineEntryCard, Tooltip, ModalContent, Form, FormControl, TextInput, Select, FormLabel, TextLink, ModalControls, IconButton } from '@contentful/f36-components';
|
|
@@ -583,58 +583,6 @@ function getAncestorPathFromSelection(editor) {
|
|
|
583
583
|
return level.length === 1;
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
|
-
var isAtEndOfTextSelection = function isAtEndOfTextSelection(editor) {
|
|
587
|
-
var _editor$selection2, _editor$selection3;
|
|
588
|
-
|
|
589
|
-
return ((_editor$selection2 = editor.selection) == null ? void 0 : _editor$selection2.focus.offset) === getText(editor, (_editor$selection3 = editor.selection) == null ? void 0 : _editor$selection3.focus.path).length;
|
|
590
|
-
};
|
|
591
|
-
function currentSelectionStartsTableCell(editor) {
|
|
592
|
-
var _editor$selection4;
|
|
593
|
-
|
|
594
|
-
var _getNodeEntryFromSele2 = getNodeEntryFromSelection(editor, [BLOCKS.TABLE_CELL, BLOCKS.TABLE_HEADER_CELL]),
|
|
595
|
-
tableCellNode = _getNodeEntryFromSele2[0],
|
|
596
|
-
path = _getNodeEntryFromSele2[1];
|
|
597
|
-
|
|
598
|
-
return !!tableCellNode && (!getText(editor, path) || ((_editor$selection4 = editor.selection) == null ? void 0 : _editor$selection4.focus.offset) === 0);
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* This traversal strategy is unfortunately necessary because Slate doesn't
|
|
602
|
-
* expose something like Node.next(editor).
|
|
603
|
-
*/
|
|
604
|
-
|
|
605
|
-
function getNextNode(editor) {
|
|
606
|
-
if (!editor.selection) {
|
|
607
|
-
return null;
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
var descendants = Node.descendants(editor, {
|
|
611
|
-
from: editor.selection.focus.path
|
|
612
|
-
}); // eslint-disable-next-line no-constant-condition
|
|
613
|
-
|
|
614
|
-
while (true) {
|
|
615
|
-
var _descendants$next = descendants.next(),
|
|
616
|
-
done = _descendants$next.done,
|
|
617
|
-
value = _descendants$next.value;
|
|
618
|
-
|
|
619
|
-
if (done) {
|
|
620
|
-
return null;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
var node = value[0],
|
|
624
|
-
path = value[1];
|
|
625
|
-
|
|
626
|
-
if (Path.isCommon(path, editor.selection.focus.path)) {
|
|
627
|
-
continue;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
return node;
|
|
631
|
-
}
|
|
632
|
-
} // TODO: move to table plugin
|
|
633
|
-
|
|
634
|
-
function currentSelectionPrecedesTableCell(editor) {
|
|
635
|
-
var nextNode = getNextNode(editor);
|
|
636
|
-
return !!nextNode && TABLE_BLOCKS.includes(nextNode.type) && isAtEndOfTextSelection(editor);
|
|
637
|
-
}
|
|
638
586
|
var INLINE_TYPES = /*#__PURE__*/Object.values(INLINES);
|
|
639
587
|
var isInlineOrText = function isInlineOrText(node) {
|
|
640
588
|
// either text or inline elements
|
|
@@ -5926,16 +5874,7 @@ var Table = function Table(props) {
|
|
|
5926
5874
|
var createTableOnKeyDown = function createTableOnKeyDown(editor, plugin) {
|
|
5927
5875
|
var defaultHandler = onKeyDownTable(editor, plugin);
|
|
5928
5876
|
return function (event) {
|
|
5929
|
-
|
|
5930
|
-
// The default behavior here would be to delete the preceding or forthcoming
|
|
5931
|
-
// leaf node, in this case a cell or header cell. But we don't want to do that,
|
|
5932
|
-
// because it would leave us with a non-standard number of table cells.
|
|
5933
|
-
event.preventDefault();
|
|
5934
|
-
event.stopPropagation();
|
|
5935
|
-
return;
|
|
5936
|
-
} // This fixes `Cannot resolve a Slate point from DOM point: [object HTMLDivElement]` when typing while the cursor is before table
|
|
5937
|
-
|
|
5938
|
-
|
|
5877
|
+
// This fixes `Cannot resolve a Slate point from DOM point: [object HTMLDivElement]` when typing while the cursor is before table
|
|
5939
5878
|
var windowSelection = window.getSelection();
|
|
5940
5879
|
|
|
5941
5880
|
if (windowSelection) {
|