@contentful/field-editor-rich-text 3.16.10 → 3.16.12
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/cjs/ContentfulEditorProvider.js +8 -8
- package/dist/cjs/RichTextEditor.js +6 -4
- package/dist/cjs/SdkProvider.js +4 -2
- package/dist/cjs/SyncEditorChanges.js +4 -2
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +6 -4
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +4 -2
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +4 -2
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/cjs/Toolbar/index.js +5 -3
- package/dist/cjs/__fixtures__/FakeSdk.js +3 -3
- package/dist/cjs/__fixtures__/asset/index.js +5 -5
- package/dist/cjs/__fixtures__/entry/index.js +3 -3
- package/dist/cjs/__fixtures__/fixtures.js +3 -1
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +17 -15
- package/dist/cjs/dialogs/openRichTextDialog.js +4 -2
- package/dist/cjs/dialogs/renderRichTextDialog.js +3 -1
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +1 -1
- package/dist/cjs/helpers/editor.js +42 -42
- package/dist/cjs/helpers/environment.js +3 -3
- package/dist/cjs/helpers/formatDateAndTime.js +3 -3
- package/dist/cjs/helpers/nodeFactory.js +6 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +1 -1
- package/dist/cjs/helpers/transformers.js +5 -5
- package/dist/cjs/helpers/validations.js +5 -5
- package/dist/cjs/index.js +6 -4
- package/dist/cjs/internal/constants.js +3 -1
- package/dist/cjs/internal/hooks.js +7 -5
- package/dist/cjs/internal/misc.js +12 -10
- package/dist/cjs/internal/queries.js +107 -105
- package/dist/cjs/internal/transforms.js +49 -47
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +1 -1
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +1 -1
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +9 -7
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +3 -1
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +3 -1
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +5 -3
- package/dist/cjs/plugins/CommandPalette/useCommands.js +2 -2
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +6 -4
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +7 -5
- package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +6 -4
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +7 -5
- package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +2 -2
- package/dist/cjs/plugins/Heading/components/Heading.js +3 -1
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +3 -1
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +1 -1
- package/dist/cjs/plugins/Hr/index.js +8 -6
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +7 -5
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/LinkPopover.js +4 -2
- package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +3 -1
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +4 -2
- package/dist/cjs/plugins/Hyperlink/components/linkHandlers.js +3 -3
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +4 -2
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +3 -3
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +5 -3
- package/dist/cjs/plugins/Hyperlink/utils.js +4 -4
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +1 -1
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +1 -1
- package/dist/cjs/plugins/List/components/List.js +6 -4
- package/dist/cjs/plugins/List/components/ListItem.js +3 -1
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +3 -1
- package/dist/cjs/plugins/List/insertListBreak.js +2 -2
- package/dist/cjs/plugins/List/insertListFragment.js +1 -1
- package/dist/cjs/plugins/List/onKeyDownList.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItems.js +1 -1
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +1 -1
- package/dist/cjs/plugins/List/transforms/toggleList.js +3 -3
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +9 -9
- package/dist/cjs/plugins/List/transforms/unwrapList.js +1 -1
- package/dist/cjs/plugins/List/utils.js +11 -11
- package/dist/cjs/plugins/List/withList.js +1 -1
- package/dist/cjs/plugins/Marks/Bold.js +6 -4
- package/dist/cjs/plugins/Marks/Code.js +6 -4
- package/dist/cjs/plugins/Marks/Italic.js +6 -4
- package/dist/cjs/plugins/Marks/Subscript.js +7 -5
- package/dist/cjs/plugins/Marks/Superscript.js +7 -5
- package/dist/cjs/plugins/Marks/Underline.js +3 -1
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +5 -3
- package/dist/cjs/plugins/Marks/helpers.js +4 -4
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +3 -3
- package/dist/cjs/plugins/Normalizer/utils.js +3 -3
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +2 -2
- package/dist/cjs/plugins/Paragraph/Paragraph.js +3 -1
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +1 -1
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +5 -5
- package/dist/cjs/plugins/Quote/components/Quote.js +3 -1
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +3 -1
- package/dist/cjs/plugins/Quote/toggleQuote.js +4 -4
- package/dist/cjs/plugins/Quote/withQuote.js +2 -2
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +1 -1
- package/dist/cjs/plugins/Table/actions/addColumn.js +4 -4
- package/dist/cjs/plugins/Table/actions/addRow.js +3 -3
- package/dist/cjs/plugins/Table/components/Cell.js +3 -1
- package/dist/cjs/plugins/Table/components/HeaderCell.js +3 -1
- package/dist/cjs/plugins/Table/components/Row.js +3 -1
- package/dist/cjs/plugins/Table/components/Table.js +3 -1
- package/dist/cjs/plugins/Table/components/TableActions.js +6 -4
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +3 -1
- package/dist/cjs/plugins/Table/createTablePlugin.js +1 -1
- package/dist/cjs/plugins/Table/helpers.js +12 -12
- package/dist/cjs/plugins/Table/insertTableFragment.js +1 -1
- package/dist/cjs/plugins/Table/onKeyDownTable.js +2 -2
- package/dist/cjs/plugins/Table/tableTracking.js +6 -6
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +2 -2
- package/dist/cjs/plugins/Text/createTextPlugin.js +3 -3
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +4 -4
- package/dist/cjs/plugins/Tracking/utils.js +3 -1
- package/dist/cjs/plugins/index.js +3 -3
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +7 -5
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +5 -5
- package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +4 -2
- package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +4 -4
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +6 -4
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +7 -5
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +6 -4
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +1 -1
- package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +4 -2
- package/dist/cjs/plugins/shared/ResourceNewBadge.js +3 -1
- package/dist/cjs/plugins/shared/ToolbarButton.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +4 -2
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +9 -7
- package/dist/cjs/test-utils/validation.js +3 -3
- package/dist/esm/ContentfulEditorProvider.js +1 -1
- package/dist/esm/RichTextEditor.js +3 -3
- package/dist/esm/SdkProvider.js +1 -1
- package/dist/esm/SyncEditorChanges.js +1 -1
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +3 -3
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +1 -1
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +1 -1
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/esm/Toolbar/index.js +2 -2
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +11 -11
- package/dist/esm/dialogs/openRichTextDialog.js +1 -1
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +1 -1
- package/dist/esm/helpers/editor.js +3 -3
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +1 -1
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +1 -1
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +1 -1
- package/dist/esm/plugins/CommandPalette/components/CommandList.js +6 -6
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +2 -2
- package/dist/esm/plugins/CommandPalette/useCommands.js +2 -2
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +3 -3
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +4 -4
- package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +3 -3
- package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +2 -2
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +4 -4
- package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +2 -2
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +1 -1
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/components/LinkPopover.js +1 -1
- package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +1 -1
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +1 -1
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +3 -3
- package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +2 -2
- package/dist/esm/plugins/Hyperlink/utils.js +1 -1
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +1 -1
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +1 -1
- package/dist/esm/plugins/List/insertListBreak.js +2 -2
- package/dist/esm/plugins/List/insertListFragment.js +1 -1
- package/dist/esm/plugins/List/onKeyDownList.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItems.js +1 -1
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +1 -1
- package/dist/esm/plugins/List/transforms/toggleList.js +3 -3
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +9 -9
- package/dist/esm/plugins/List/transforms/unwrapList.js +1 -1
- package/dist/esm/plugins/List/utils.js +1 -1
- package/dist/esm/plugins/List/withList.js +1 -1
- package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +2 -2
- package/dist/esm/plugins/Marks/helpers.js +1 -1
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +3 -3
- package/dist/esm/plugins/Normalizer/withNormalizer.js +2 -2
- package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +1 -1
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +1 -1
- package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
- package/dist/esm/plugins/Quote/withQuote.js +2 -2
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +1 -1
- package/dist/esm/plugins/Table/actions/addColumn.js +1 -1
- package/dist/esm/plugins/Table/createTablePlugin.js +1 -1
- package/dist/esm/plugins/Table/insertTableFragment.js +1 -1
- package/dist/esm/plugins/Table/onKeyDownTable.js +2 -2
- package/dist/esm/plugins/Table/tableTracking.js +6 -6
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +2 -2
- package/dist/esm/plugins/Text/createTextPlugin.js +3 -3
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +1 -1
- package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +4 -4
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +3 -3
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +4 -4
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +3 -3
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +1 -1
- package/dist/esm/plugins/shared/LinkedInlineWrapper.js +1 -1
- package/dist/esm/plugins/shared/ToolbarButton.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +1 -1
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +6 -6
- package/dist/esm/test-utils/validation.js +3 -3
- package/package.json +5 -5
|
@@ -2,22 +2,22 @@ import { BLOCKS } from '@contentful/rich-text-types';
|
|
|
2
2
|
import { isElement } from '../../internal/queries';
|
|
3
3
|
import { getPastingSource } from '../../plugins/Tracking';
|
|
4
4
|
function hasTables(nodes) {
|
|
5
|
-
return nodes.some(({ type
|
|
5
|
+
return nodes.some(({ type })=>{
|
|
6
6
|
return type === BLOCKS.TABLE;
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
const isTableHeaderCell = ({ type
|
|
9
|
+
const isTableHeaderCell = ({ type })=>type === BLOCKS.TABLE_HEADER_CELL;
|
|
10
10
|
function hasHeadersOutsideFirstRow(nodes) {
|
|
11
|
-
return nodes.filter(({ type
|
|
11
|
+
return nodes.filter(({ type })=>type === BLOCKS.TABLE).flatMap(({ children })=>children.slice(1)).some(({ children })=>children.some(isTableHeaderCell));
|
|
12
12
|
}
|
|
13
13
|
export function addTableTrackingEvents(editor) {
|
|
14
|
-
const { insertData
|
|
14
|
+
const { insertData } = editor;
|
|
15
15
|
editor.insertData = (data)=>{
|
|
16
16
|
const html = data.getData('text/html');
|
|
17
17
|
if (html) {
|
|
18
|
-
const { children: markupBefore
|
|
18
|
+
const { children: markupBefore } = editor;
|
|
19
19
|
insertData(data);
|
|
20
|
-
const { children: markupAfter
|
|
20
|
+
const { children: markupAfter } = editor;
|
|
21
21
|
setTimeout(()=>{
|
|
22
22
|
if (hasTables(markupBefore)) return;
|
|
23
23
|
if (hasTables(markupAfter)) {
|
|
@@ -15,7 +15,7 @@ describe('delete backward', ()=>{
|
|
|
15
15
|
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
16
16
|
for (const t of tests){
|
|
17
17
|
test(t.title, ()=>{
|
|
18
|
-
const { editor
|
|
18
|
+
const { editor } = createTestEditor({
|
|
19
19
|
input: render(t.input)
|
|
20
20
|
});
|
|
21
21
|
editor.deleteBackward('character');
|
|
@@ -52,7 +52,7 @@ describe('delete forward', ()=>{
|
|
|
52
52
|
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
53
53
|
for (const t of tests){
|
|
54
54
|
test(t.title, ()=>{
|
|
55
|
-
const { editor
|
|
55
|
+
const { editor } = createTestEditor({
|
|
56
56
|
input: render(t.input)
|
|
57
57
|
});
|
|
58
58
|
editor.deleteForward('character');
|
|
@@ -13,9 +13,9 @@ export function createTextPlugin(restrictedMarks = []) {
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
withOverrides: (editor)=>{
|
|
16
|
-
const { insertText
|
|
16
|
+
const { insertText } = editor;
|
|
17
17
|
editor.insertText = (text)=>{
|
|
18
|
-
const { selection
|
|
18
|
+
const { selection } = editor;
|
|
19
19
|
if (selection && isRangeCollapsed(selection)) {
|
|
20
20
|
const inlinePath = getAboveNode(editor, {
|
|
21
21
|
match: (n)=>isInline(editor, n),
|
|
@@ -31,7 +31,7 @@ export function createTextPlugin(restrictedMarks = []) {
|
|
|
31
31
|
}
|
|
32
32
|
return insertText(text);
|
|
33
33
|
};
|
|
34
|
-
const { deleteForward
|
|
34
|
+
const { deleteForward, deleteBackward } = editor;
|
|
35
35
|
editor.deleteBackward = (unit)=>{
|
|
36
36
|
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
37
37
|
};
|
|
@@ -58,7 +58,7 @@ export const createTrackingPlugin = (onAction)=>{
|
|
|
58
58
|
return {
|
|
59
59
|
key: 'TrackingPlugin',
|
|
60
60
|
withOverrides: (editor)=>{
|
|
61
|
-
const { insertData
|
|
61
|
+
const { insertData } = editor;
|
|
62
62
|
editor.tracking = trackingActions;
|
|
63
63
|
editor.insertData = (data)=>{
|
|
64
64
|
const isCopyAndPaste = data.types.length !== 0;
|
|
@@ -12,7 +12,7 @@ export const styles = {
|
|
|
12
12
|
marginRight: '10px'
|
|
13
13
|
})
|
|
14
14
|
};
|
|
15
|
-
export function EmbeddedBlockToolbarIcon({ isDisabled
|
|
15
|
+
export function EmbeddedBlockToolbarIcon({ isDisabled, nodeType, onClose }) {
|
|
16
16
|
const editor = useContentfulEditor();
|
|
17
17
|
const sdk = useSdkContext();
|
|
18
18
|
const handleClick = async (event)=>{
|
|
@@ -5,7 +5,7 @@ import { focus, getNodeEntryFromSelection, insertEmptyParagraph, moveToTheNextCh
|
|
|
5
5
|
import { watchCurrentSlide } from '../../helpers/sdkNavigatorSlideIn';
|
|
6
6
|
import { getText, getAboveNode, getLastNodeByLevel, insertNodes, setNodes, select, removeNodes } from '../../internal';
|
|
7
7
|
export function getWithEmbeddedBlockEvents(nodeType, sdk) {
|
|
8
|
-
return (editor, { options: { hotkey
|
|
8
|
+
return (editor, { options: { hotkey } })=>(event)=>{
|
|
9
9
|
const [, pathToSelectedElement] = getNodeEntryFromSelection(editor, nodeType);
|
|
10
10
|
if (pathToSelectedElement) {
|
|
11
11
|
const isDelete = event.key === 'Delete';
|
|
@@ -31,14 +31,14 @@ export async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
|
|
|
31
31
|
logAction('openCreateEmbedDialog', {
|
|
32
32
|
nodeType
|
|
33
33
|
});
|
|
34
|
-
const { field
|
|
34
|
+
const { field, dialogs } = sdk;
|
|
35
35
|
const baseConfig = newEntitySelectorConfigFromRichTextField(field, nodeType);
|
|
36
36
|
const selectEntity = baseConfig.entityType === 'Asset' ? dialogs.selectSingleAsset : dialogs.selectSingleEntry;
|
|
37
37
|
const config = {
|
|
38
38
|
...baseConfig,
|
|
39
39
|
withCreate: true
|
|
40
40
|
};
|
|
41
|
-
const { selection
|
|
41
|
+
const { selection } = editor;
|
|
42
42
|
const rteSlide = watchCurrentSlide(sdk.navigator);
|
|
43
43
|
const entity = await selectEntity(config);
|
|
44
44
|
if (!entity) {
|
|
@@ -65,9 +65,9 @@ export async function selectResourceEntityAndInsert(sdk, editor, logAction) {
|
|
|
65
65
|
logAction('openCreateEmbedDialog', {
|
|
66
66
|
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
67
67
|
});
|
|
68
|
-
const { field
|
|
68
|
+
const { field, dialogs } = sdk;
|
|
69
69
|
const config = newResourceEntitySelectorConfigFromRichTextField(field, BLOCKS.EMBEDDED_RESOURCE);
|
|
70
|
-
const { selection
|
|
70
|
+
const { selection } = editor;
|
|
71
71
|
const entity = await dialogs.selectSingleResourceEntry(config);
|
|
72
72
|
if (!entity) {
|
|
73
73
|
logAction('cancelCreateEmbedDialog', {
|
|
@@ -22,7 +22,7 @@ const styles = {
|
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
};
|
|
25
|
-
export function EmbeddedInlineToolbarIcon({ onClose
|
|
25
|
+
export function EmbeddedInlineToolbarIcon({ onClose, nodeType, isDisabled }) {
|
|
26
26
|
const editor = useContentfulEditor();
|
|
27
27
|
const sdk = useSdkContext();
|
|
28
28
|
async function handleClick(event) {
|
|
@@ -5,7 +5,7 @@ import { focus } from '../../helpers/editor';
|
|
|
5
5
|
import { watchCurrentSlide } from '../../helpers/sdkNavigatorSlideIn';
|
|
6
6
|
import { insertNodes, select } from '../../internal/transforms';
|
|
7
7
|
export function getWithEmbeddedEntryInlineEvents(nodeType, sdk) {
|
|
8
|
-
return function withEmbeddedEntryInlineEvents(editor, { options: { hotkey
|
|
8
|
+
return function withEmbeddedEntryInlineEvents(editor, { options: { hotkey } }) {
|
|
9
9
|
return function handleEvent(event) {
|
|
10
10
|
if (!editor) return;
|
|
11
11
|
if (hotkey && isHotkey(hotkey, event)) {
|
|
@@ -56,7 +56,7 @@ export async function selectEntityAndInsert(editor, sdk, logAction) {
|
|
|
56
56
|
...newEntitySelectorConfigFromRichTextField(sdk.field, nodeType),
|
|
57
57
|
withCreate: true
|
|
58
58
|
};
|
|
59
|
-
const { selection
|
|
59
|
+
const { selection } = editor;
|
|
60
60
|
const rteSlide = watchCurrentSlide(sdk.navigator);
|
|
61
61
|
const entry = await sdk.dialogs.selectSingleEntry(config);
|
|
62
62
|
if (!entry) {
|
|
@@ -80,12 +80,12 @@ export async function selectResourceEntityAndInsert(editor, sdk, logAction) {
|
|
|
80
80
|
logAction('openCreateEmbedDialog', {
|
|
81
81
|
nodeType
|
|
82
82
|
});
|
|
83
|
-
const { dialogs
|
|
83
|
+
const { dialogs, field } = sdk;
|
|
84
84
|
const config = {
|
|
85
85
|
...newResourceEntitySelectorConfigFromRichTextField(field, nodeType),
|
|
86
86
|
withCreate: true
|
|
87
87
|
};
|
|
88
|
-
const { selection
|
|
88
|
+
const { selection } = editor;
|
|
89
89
|
const entry = await dialogs.selectSingleResourceEntry(config);
|
|
90
90
|
if (!entry) {
|
|
91
91
|
logAction('cancelCreateEmbedDialog', {
|
|
@@ -31,9 +31,9 @@ const InternalAssetCard = React.memo((props)=>{
|
|
|
31
31
|
}, areEqual);
|
|
32
32
|
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
33
33
|
export function FetchingWrappedAssetCard(props) {
|
|
34
|
-
const { onEntityFetchComplete
|
|
35
|
-
const { data: asset
|
|
36
|
-
const { getEntityScheduledActions
|
|
34
|
+
const { onEntityFetchComplete } = props;
|
|
35
|
+
const { data: asset, status } = useEntity('Asset', props.assetId);
|
|
36
|
+
const { getEntityScheduledActions } = useEntityLoader();
|
|
37
37
|
const loadEntityScheduledActions = React.useCallback(()=>getEntityScheduledActions('Asset', props.assetId), [
|
|
38
38
|
getEntityScheduledActions,
|
|
39
39
|
props.assetId
|
|
@@ -3,7 +3,7 @@ import { EntryCard } from '@contentful/f36-components';
|
|
|
3
3
|
import { useEntity, MissingEntityCard, WrappedEntryCard, useEntityLoader } from '@contentful/field-editor-reference';
|
|
4
4
|
import areEqual from 'fast-deep-equal';
|
|
5
5
|
const InternalEntryCard = React.memo((props)=>{
|
|
6
|
-
const { entry
|
|
6
|
+
const { entry, sdk, loadEntityScheduledActions } = props;
|
|
7
7
|
if (entry === undefined) {
|
|
8
8
|
return React.createElement(EntryCard, {
|
|
9
9
|
isLoading: true
|
|
@@ -34,9 +34,9 @@ const InternalEntryCard = React.memo((props)=>{
|
|
|
34
34
|
}, areEqual);
|
|
35
35
|
InternalEntryCard.displayName = 'ReferenceCard';
|
|
36
36
|
export const FetchingWrappedEntryCard = (props)=>{
|
|
37
|
-
const { entryId
|
|
38
|
-
const { data: entry
|
|
39
|
-
const { getEntityScheduledActions
|
|
37
|
+
const { entryId, onEntityFetchComplete } = props;
|
|
38
|
+
const { data: entry, status } = useEntity('Entry', entryId);
|
|
39
|
+
const { getEntityScheduledActions } = useEntityLoader();
|
|
40
40
|
const loadEntityScheduledActions = React.useCallback(()=>getEntityScheduledActions('Entry', entryId), [
|
|
41
41
|
getEntityScheduledActions,
|
|
42
42
|
entryId
|
|
@@ -8,7 +8,7 @@ const InternalEntryCard = React.memo((props)=>{
|
|
|
8
8
|
isLoading: true
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
const { contentType
|
|
11
|
+
const { contentType, resource: entry, space } = props.data;
|
|
12
12
|
return React.createElement(WrappedEntryCard, {
|
|
13
13
|
size: "default",
|
|
14
14
|
getAsset: ()=>Promise.resolve(),
|
|
@@ -27,8 +27,8 @@ const InternalEntryCard = React.memo((props)=>{
|
|
|
27
27
|
}, areEqual);
|
|
28
28
|
InternalEntryCard.displayName = 'ReferenceCard';
|
|
29
29
|
export const FetchingWrappedResourceCard = (props)=>{
|
|
30
|
-
const { link
|
|
31
|
-
const { data
|
|
30
|
+
const { link, onEntityFetchComplete } = props;
|
|
31
|
+
const { data, status, error } = useResource(link.linkType, link.urn);
|
|
32
32
|
React.useEffect(()=>{
|
|
33
33
|
if (status === 'success') {
|
|
34
34
|
onEntityFetchComplete?.();
|
|
@@ -13,7 +13,7 @@ const styles = {
|
|
|
13
13
|
width: '100%'
|
|
14
14
|
})
|
|
15
15
|
};
|
|
16
|
-
export function LinkedBlockWrapper({ attributes
|
|
16
|
+
export function LinkedBlockWrapper({ attributes, card, children, link }) {
|
|
17
17
|
return React.createElement("div", {
|
|
18
18
|
...attributes,
|
|
19
19
|
className: styles.root,
|
|
@@ -16,7 +16,7 @@ const styles = {
|
|
|
16
16
|
}
|
|
17
17
|
})
|
|
18
18
|
};
|
|
19
|
-
export function LinkedInlineWrapper({ attributes
|
|
19
|
+
export function LinkedInlineWrapper({ attributes, card, children, link }) {
|
|
20
20
|
return React.createElement("span", {
|
|
21
21
|
...attributes,
|
|
22
22
|
className: styles.root,
|
|
@@ -14,7 +14,7 @@ const styles = {
|
|
|
14
14
|
})
|
|
15
15
|
};
|
|
16
16
|
export function ToolbarButton(props) {
|
|
17
|
-
const { title
|
|
17
|
+
const { title, testId, isActive, children, className, isDisabled = false } = props;
|
|
18
18
|
const handleClick = (event)=>{
|
|
19
19
|
event.preventDefault();
|
|
20
20
|
props.onClick();
|
|
@@ -38,7 +38,7 @@ beforeEach(()=>{
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
test('some dropdown actions should be disabled', async ()=>{
|
|
41
|
-
const { getByTestId
|
|
41
|
+
const { getByTestId, queryByTestId } = render(React.createElement(EntityProvider, {
|
|
42
42
|
sdk: sdk
|
|
43
43
|
}, React.createElement(FetchingWrappedAssetCard, {
|
|
44
44
|
sdk: sdk,
|
|
@@ -42,7 +42,7 @@ beforeEach(()=>{
|
|
|
42
42
|
};
|
|
43
43
|
});
|
|
44
44
|
test('some dropdown actions should be disabled/removed', async ()=>{
|
|
45
|
-
const { getByTestId
|
|
45
|
+
const { getByTestId, queryByTestId } = render(React.createElement(EntityProvider, {
|
|
46
46
|
sdk: sdk
|
|
47
47
|
}, React.createElement(FetchingWrappedEntryCard, {
|
|
48
48
|
sdk: sdk,
|
|
@@ -23,7 +23,7 @@ beforeEach(()=>{
|
|
|
23
23
|
get: jest.fn().mockReturnValue(publishedCT)
|
|
24
24
|
},
|
|
25
25
|
Entry: {
|
|
26
|
-
get: jest.fn().mockImplementation(({ entryId
|
|
26
|
+
get: jest.fn().mockImplementation(({ entryId })=>{
|
|
27
27
|
if (entryId === 'linked-entry-urn') {
|
|
28
28
|
return Promise.resolve(publishedEntry);
|
|
29
29
|
}
|
|
@@ -60,7 +60,7 @@ beforeEach(()=>{
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
|
-
function renderResourceCard({ linkType ='Contentful:Entry'
|
|
63
|
+
function renderResourceCard({ linkType = 'Contentful:Entry', entryUrn = resolvableEntryUrn } = {}) {
|
|
64
64
|
return render(React.createElement(EntityProvider, {
|
|
65
65
|
sdk: sdk
|
|
66
66
|
}, React.createElement(FetchingWrappedResourceCard, {
|
|
@@ -75,23 +75,23 @@ function renderResourceCard({ linkType ='Contentful:Entry' , entryUrn =resolvabl
|
|
|
75
75
|
})));
|
|
76
76
|
}
|
|
77
77
|
test('renders entry card', async ()=>{
|
|
78
|
-
const { getByTestId
|
|
78
|
+
const { getByTestId, getByText } = renderResourceCard();
|
|
79
79
|
await waitFor(()=>expect(getByTestId('cf-ui-entry-card')).toBeDefined());
|
|
80
80
|
expect(getByText(publishedEntry.fields.exField.en)).toBeDefined();
|
|
81
81
|
expect(getByText(space.name)).toBeDefined();
|
|
82
82
|
});
|
|
83
83
|
test('renders skeleton when no data is provided', ()=>{
|
|
84
|
-
const { getByTestId
|
|
84
|
+
const { getByTestId } = renderResourceCard();
|
|
85
85
|
expect(getByTestId('cf-ui-skeleton-form')).toBeDefined();
|
|
86
86
|
});
|
|
87
87
|
test('renders unsupported entity card when unsupported link is passed', async ()=>{
|
|
88
|
-
const { getByText
|
|
88
|
+
const { getByText } = renderResourceCard({
|
|
89
89
|
linkType: 'Contentful:UnsupportedLink'
|
|
90
90
|
});
|
|
91
91
|
await waitFor(()=>expect(getByText('Resource type Contentful:UnsupportedLink is currently not supported')).toBeDefined());
|
|
92
92
|
});
|
|
93
93
|
test('renders missing entity card when unknown error is returned', async ()=>{
|
|
94
|
-
const { getByTestId
|
|
94
|
+
const { getByTestId } = renderResourceCard({
|
|
95
95
|
entryUrn: unknownEntryUrn
|
|
96
96
|
});
|
|
97
97
|
await waitFor(()=>expect(getByTestId('cf-ui-missing-entry-card')).toBeDefined());
|
|
@@ -60,7 +60,7 @@ function buildSchemaErrors(validateSchema, _, errors) {
|
|
|
60
60
|
errors.push(...schemaErrors);
|
|
61
61
|
}
|
|
62
62
|
function resetChildNodes(node) {
|
|
63
|
-
const { content
|
|
63
|
+
const { content } = node;
|
|
64
64
|
if (isLeafNode(node)) {
|
|
65
65
|
return node;
|
|
66
66
|
}
|
|
@@ -69,7 +69,7 @@ function resetChildNodes(node) {
|
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
function resetNode(node) {
|
|
72
|
-
const { nodeType
|
|
72
|
+
const { nodeType } = node;
|
|
73
73
|
if (helpers.isText(node)) {
|
|
74
74
|
return {
|
|
75
75
|
nodeType,
|
|
@@ -85,7 +85,7 @@ function resetNode(node) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
function removeGrandChildNodes(node) {
|
|
88
|
-
const { content
|
|
88
|
+
const { content } = node;
|
|
89
89
|
if (isLeafNode(node)) {
|
|
90
90
|
return node;
|
|
91
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-rich-text",
|
|
3
|
-
"version": "3.16.
|
|
3
|
+
"version": "3.16.12",
|
|
4
4
|
"source": "./src/index.tsx",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@contentful/f36-icons": "^4.1.1",
|
|
45
45
|
"@contentful/f36-tokens": "^4.0.0",
|
|
46
46
|
"@contentful/f36-utils": "^4.19.0",
|
|
47
|
-
"@contentful/field-editor-reference": "^5.21.
|
|
48
|
-
"@contentful/field-editor-shared": "^1.4.
|
|
47
|
+
"@contentful/field-editor-reference": "^5.21.5",
|
|
48
|
+
"@contentful/field-editor-shared": "^1.4.4",
|
|
49
49
|
"@contentful/rich-text-plain-text-renderer": "^16.0.4",
|
|
50
50
|
"@contentful/rich-text-types": "16.3.0",
|
|
51
51
|
"@popperjs/core": "^2.11.5",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"react-dom": ">=16.14.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@contentful/field-editor-test-utils": "^1.4.
|
|
79
|
+
"@contentful/field-editor-test-utils": "^1.4.5",
|
|
80
80
|
"@contentful/rich-text-react-renderer": "^15.16.4",
|
|
81
81
|
"@types/is-hotkey": "^0.1.6",
|
|
82
82
|
"@udecode/plate-test-utils": "^3.2.0",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"registry": "https://npm.pkg.github.com/"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "89b14d123bc36f18214825404a33a6c2f7bc26b3"
|
|
90
90
|
}
|