@contentful/field-editor-rich-text 3.15.0 → 3.15.2
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 +22 -20
- package/dist/cjs/RichTextEditor.styles.js +2 -1
- package/dist/cjs/SdkProvider.js +7 -5
- package/dist/cjs/SyncEditorChanges.js +15 -6
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +17 -15
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +14 -10
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +10 -8
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +2 -2
- package/dist/cjs/Toolbar/index.js +33 -30
- package/dist/cjs/__fixtures__/FakeSdk.js +3 -3
- package/dist/cjs/__fixtures__/asset/index.js +10 -10
- package/dist/cjs/__fixtures__/content-type/index.js +1 -1
- package/dist/cjs/__fixtures__/entry/index.js +7 -7
- package/dist/cjs/__fixtures__/fixtures.js +8 -6
- package/dist/cjs/__fixtures__/locale/index.js +2 -2
- package/dist/cjs/__fixtures__/space/index.js +1 -1
- package/dist/cjs/constants/Schema.js +1 -0
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +43 -38
- package/dist/cjs/dialogs/openRichTextDialog.js +6 -4
- package/dist/cjs/dialogs/renderRichTextDialog.js +6 -4
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +10 -10
- package/dist/cjs/helpers/callbacks.js +3 -3
- package/dist/cjs/helpers/config.js +2 -2
- package/dist/cjs/helpers/editor.js +53 -44
- package/dist/cjs/helpers/environment.js +3 -3
- package/dist/cjs/helpers/formatDateAndTime.js +5 -4
- package/dist/cjs/helpers/getAllowedResourcesForNodeType.js +22 -5
- package/dist/cjs/helpers/getLinkedContentTypeIdsForNodeType.js +29 -5
- package/dist/cjs/helpers/nodeFactory.js +6 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +14 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +3 -2
- package/dist/cjs/helpers/toSlateValue.js +14 -3
- package/dist/cjs/helpers/transformers.js +5 -5
- package/dist/cjs/helpers/validations.js +12 -9
- package/dist/cjs/index.js +7 -5
- package/dist/cjs/internal/constants.js +4 -2
- package/dist/cjs/internal/hooks.js +8 -6
- package/dist/cjs/internal/misc.js +15 -12
- package/dist/cjs/internal/queries.js +115 -108
- package/dist/cjs/internal/transforms.js +51 -48
- package/dist/cjs/internal/types/editor.js +3 -1
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +4 -3
- package/dist/cjs/plugins/Break/createResetNodePlugin.js +1 -0
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +3 -3
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +35 -33
- package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +1 -1
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +7 -5
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +7 -3
- package/dist/cjs/plugins/CommandPalette/onKeyDown.js +6 -1
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +6 -4
- package/dist/cjs/plugins/CommandPalette/useCommands.js +3 -3
- package/dist/cjs/plugins/CommandPalette/utils/fetchEntries.js +2 -0
- package/dist/cjs/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
- package/dist/cjs/plugins/DragAndDrop/index.js +9 -1
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +10 -8
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +19 -17
- package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +9 -7
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +5 -5
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +13 -11
- package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +5 -5
- package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
- package/dist/cjs/plugins/Heading/components/Heading.js +13 -10
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +19 -11
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +7 -2
- package/dist/cjs/plugins/Hr/index.js +19 -14
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +32 -28
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +8 -6
- package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +8 -6
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +7 -5
- package/dist/cjs/plugins/Hyperlink/components/styles.js +1 -1
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +10 -4
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +6 -3
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +6 -4
- package/dist/cjs/plugins/Hyperlink/utils.js +4 -4
- package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +13 -13
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +29 -25
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +22 -22
- package/dist/cjs/plugins/List/components/List.js +9 -7
- package/dist/cjs/plugins/List/components/ListItem.js +6 -4
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +7 -5
- package/dist/cjs/plugins/List/createListPlugin.js +4 -0
- package/dist/cjs/plugins/List/insertListBreak.js +13 -4
- package/dist/cjs/plugins/List/insertListFragment.js +18 -5
- package/dist/cjs/plugins/List/onKeyDownList.js +7 -4
- package/dist/cjs/plugins/List/transforms/insertListItem.js +17 -2
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +8 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.js +7 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +15 -14
- package/dist/cjs/plugins/List/transforms/toggleList.js +8 -3
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/cjs/plugins/List/transforms/unwrapList.js +7 -2
- package/dist/cjs/plugins/List/utils.js +12 -11
- package/dist/cjs/plugins/List/withList.js +6 -2
- package/dist/cjs/plugins/Marks/Bold.js +9 -7
- package/dist/cjs/plugins/Marks/Code.js +15 -7
- package/dist/cjs/plugins/Marks/Italic.js +9 -7
- package/dist/cjs/plugins/Marks/Subscript.js +10 -8
- package/dist/cjs/plugins/Marks/Superscript.js +10 -8
- package/dist/cjs/plugins/Marks/Underline.js +6 -4
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +9 -7
- package/dist/cjs/plugins/Marks/helpers.js +5 -5
- package/dist/cjs/plugins/Normalizer/baseRules.js +2 -0
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/cjs/plugins/Normalizer/utils.js +4 -3
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +23 -3
- package/dist/cjs/plugins/Paragraph/Paragraph.js +6 -4
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +3 -2
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -6
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeAnchors.js +9 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
- package/dist/cjs/plugins/Quote/components/Quote.js +6 -4
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +6 -4
- package/dist/cjs/plugins/Quote/createQuotePlugin.js +1 -0
- package/dist/cjs/plugins/Quote/toggleQuote.js +5 -5
- package/dist/cjs/plugins/Quote/withQuote.js +4 -2
- package/dist/cjs/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
- package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +4 -4
- package/dist/cjs/plugins/Table/actions/addColumn.js +5 -4
- package/dist/cjs/plugins/Table/actions/addRow.js +6 -3
- package/dist/cjs/plugins/Table/components/Cell.js +7 -5
- package/dist/cjs/plugins/Table/components/HeaderCell.js +7 -5
- package/dist/cjs/plugins/Table/components/Row.js +6 -4
- package/dist/cjs/plugins/Table/components/Table.js +8 -6
- package/dist/cjs/plugins/Table/components/TableActions.js +19 -16
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +7 -4
- package/dist/cjs/plugins/Table/createTablePlugin.js +11 -1
- package/dist/cjs/plugins/Table/helpers.js +16 -12
- package/dist/cjs/plugins/Table/insertTableFragment.js +15 -2
- package/dist/cjs/plugins/Table/onKeyDownTable.js +10 -2
- package/dist/cjs/plugins/Table/tableTracking.js +6 -6
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
- package/dist/cjs/plugins/Text/createTextPlugin.js +22 -5
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +5 -4
- package/dist/cjs/plugins/Tracking/utils.js +6 -3
- package/dist/cjs/plugins/Voids/createVoidsPlugin.js +5 -0
- package/dist/cjs/plugins/Voids/transformVoid.js +1 -0
- package/dist/cjs/plugins/index.js +15 -3
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +12 -10
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +16 -6
- package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +10 -8
- package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +9 -5
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +13 -11
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +14 -12
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +14 -11
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +8 -4
- package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +10 -6
- package/dist/cjs/plugins/shared/ResourceNewBadge.js +5 -3
- package/dist/cjs/plugins/shared/ToolbarButton.js +8 -6
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +10 -5
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +11 -6
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +15 -13
- package/dist/cjs/plugins/shared/utils.js +4 -1
- package/dist/cjs/test-utils/assertOutput.js +1 -0
- package/dist/cjs/test-utils/hyperscript.d.js +1 -0
- package/dist/cjs/test-utils/randomId.js +3 -1
- package/dist/cjs/test-utils/validation.js +8 -5
- package/dist/esm/ContentfulEditorProvider.js +4 -1
- package/dist/esm/RichTextEditor.js +13 -13
- package/dist/esm/RichTextEditor.styles.js +1 -0
- package/dist/esm/SdkProvider.js +2 -2
- package/dist/esm/SyncEditorChanges.js +18 -3
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +12 -12
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +10 -8
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +6 -6
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/esm/Toolbar/index.js +28 -27
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/constants/Schema.js +1 -0
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +34 -31
- package/dist/esm/dialogs/openRichTextDialog.js +2 -2
- package/dist/esm/dialogs/renderRichTextDialog.js +2 -2
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +10 -10
- package/dist/esm/helpers/callbacks.js +1 -1
- package/dist/esm/helpers/config.js +9 -1
- package/dist/esm/helpers/editor.js +22 -6
- package/dist/esm/helpers/extractNodes.js +3 -1
- package/dist/esm/helpers/formatDateAndTime.js +11 -2
- package/dist/esm/helpers/getAllowedResourcesForNodeType.js +19 -2
- package/dist/esm/helpers/getLinkedContentTypeIdsForNodeType.js +26 -2
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +20 -6
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +1 -0
- package/dist/esm/helpers/toSlateValue.js +17 -3
- package/dist/esm/helpers/validations.js +5 -1
- package/dist/esm/internal/misc.js +23 -2
- package/dist/esm/internal/queries.js +11 -2
- package/dist/esm/internal/transforms.js +14 -3
- package/dist/esm/internal/types/editor.js +3 -1
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +4 -3
- package/dist/esm/plugins/Break/createResetNodePlugin.js +1 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +3 -3
- package/dist/esm/plugins/CommandPalette/components/CommandList.js +30 -30
- package/dist/esm/plugins/CommandPalette/components/CommandPrompt.js +2 -2
- package/dist/esm/plugins/CommandPalette/createCommandPalettePlugin.js +11 -1
- package/dist/esm/plugins/CommandPalette/hooks/useCommandList.js +2 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.js +5 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +2 -2
- package/dist/esm/plugins/CommandPalette/useCommands.js +3 -3
- package/dist/esm/plugins/CommandPalette/utils/fetchEntries.js +2 -0
- package/dist/esm/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
- package/dist/esm/plugins/DragAndDrop/index.js +9 -1
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +6 -6
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +14 -14
- package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +5 -5
- package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +4 -4
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +9 -9
- package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +4 -4
- package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
- package/dist/esm/plugins/Heading/components/Heading.js +8 -7
- package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +14 -8
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +6 -1
- package/dist/esm/plugins/Hr/index.js +8 -5
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +25 -23
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +2 -2
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +5 -1
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +6 -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__/createListPlugin.test.js +13 -13
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +29 -25
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +22 -22
- package/dist/esm/plugins/List/components/List.js +1 -1
- package/dist/esm/plugins/List/components/ListItem.js +1 -1
- package/dist/esm/plugins/List/components/ToolbarListButton.js +3 -3
- package/dist/esm/plugins/List/createListPlugin.js +4 -0
- package/dist/esm/plugins/List/insertListBreak.js +13 -4
- package/dist/esm/plugins/List/insertListFragment.js +18 -5
- package/dist/esm/plugins/List/onKeyDownList.js +5 -2
- package/dist/esm/plugins/List/transforms/insertListItem.js +20 -3
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +8 -2
- package/dist/esm/plugins/List/transforms/moveListItems.js +7 -2
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +15 -14
- package/dist/esm/plugins/List/transforms/toggleList.js +8 -3
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/esm/plugins/List/transforms/unwrapList.js +7 -2
- package/dist/esm/plugins/List/utils.js +7 -2
- package/dist/esm/plugins/List/withList.js +6 -2
- package/dist/esm/plugins/Marks/Bold.js +2 -2
- package/dist/esm/plugins/Marks/Code.js +8 -2
- package/dist/esm/plugins/Marks/Italic.js +2 -2
- package/dist/esm/plugins/Marks/Subscript.js +2 -2
- package/dist/esm/plugins/Marks/Superscript.js +2 -2
- package/dist/esm/plugins/Marks/Underline.js +2 -2
- package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +4 -4
- package/dist/esm/plugins/Marks/helpers.js +1 -1
- package/dist/esm/plugins/Normalizer/baseRules.js +4 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/esm/plugins/Normalizer/utils.js +1 -0
- package/dist/esm/plugins/Normalizer/withNormalizer.js +22 -2
- package/dist/esm/plugins/Paragraph/Paragraph.js +1 -1
- package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
- package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +2 -1
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -3
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
- package/dist/esm/plugins/PasteHTML/utils/sanitizeAnchors.js +27 -1
- package/dist/esm/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
- package/dist/esm/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
- package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
- package/dist/esm/plugins/Quote/components/Quote.js +1 -1
- package/dist/esm/plugins/Quote/components/ToolbarQuoteButton.js +2 -2
- package/dist/esm/plugins/Quote/createQuotePlugin.js +1 -0
- package/dist/esm/plugins/Quote/shouldResetQuote.js +6 -1
- package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
- package/dist/esm/plugins/Quote/withQuote.js +4 -2
- package/dist/esm/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
- package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +4 -4
- package/dist/esm/plugins/Table/actions/addColumn.js +2 -1
- package/dist/esm/plugins/Table/actions/addRow.js +3 -0
- package/dist/esm/plugins/Table/components/Cell.js +2 -2
- package/dist/esm/plugins/Table/components/HeaderCell.js +2 -2
- package/dist/esm/plugins/Table/components/Row.js +1 -1
- package/dist/esm/plugins/Table/components/Table.js +3 -3
- package/dist/esm/plugins/Table/components/TableActions.js +12 -11
- package/dist/esm/plugins/Table/components/ToolbarButton.js +3 -2
- package/dist/esm/plugins/Table/createTablePlugin.js +11 -1
- package/dist/esm/plugins/Table/helpers.js +10 -1
- package/dist/esm/plugins/Table/insertTableFragment.js +15 -2
- package/dist/esm/plugins/Table/onKeyDownTable.js +10 -2
- package/dist/esm/plugins/Table/tableTracking.js +6 -6
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
- package/dist/esm/plugins/Text/createTextPlugin.js +22 -5
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +2 -1
- package/dist/esm/plugins/Tracking/utils.js +1 -0
- package/dist/esm/plugins/Voids/createVoidsPlugin.js +5 -0
- package/dist/esm/plugins/Voids/transformVoid.js +4 -1
- package/dist/esm/plugins/index.js +12 -0
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +15 -5
- package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +8 -4
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +8 -8
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +9 -9
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +9 -8
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +7 -3
- package/dist/esm/plugins/shared/LinkedInlineWrapper.js +5 -3
- package/dist/esm/plugins/shared/ResourceNewBadge.js +1 -1
- package/dist/esm/plugins/shared/ToolbarButton.js +3 -3
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -2
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +5 -2
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +8 -8
- package/dist/esm/plugins/shared/utils.js +4 -1
- package/dist/esm/test-utils/assertOutput.js +1 -0
- package/dist/esm/test-utils/hyperscript.d.js +1 -0
- package/dist/esm/test-utils/jsx.js +5 -1
- package/dist/esm/test-utils/randomId.js +3 -1
- package/dist/esm/test-utils/setEmptyDataAttribute.js +4 -1
- package/dist/esm/test-utils/validation.js +7 -4
- package/package.json +3 -3
|
@@ -5,6 +5,9 @@ export function createTextPlugin(restrictedMarks = []) {
|
|
|
5
5
|
return {
|
|
6
6
|
key: 'TextPlugin',
|
|
7
7
|
handlers: {
|
|
8
|
+
// Triple selection in a non-Firefox browser undesirably selects
|
|
9
|
+
// the start of the next block. Editor.unhangRange helps removing
|
|
10
|
+
// the extra block at the end.
|
|
8
11
|
onMouseUp: (editor)=>()=>{
|
|
9
12
|
if (!editor.selection) {
|
|
10
13
|
return;
|
|
@@ -13,9 +16,16 @@ export function createTextPlugin(restrictedMarks = []) {
|
|
|
13
16
|
}
|
|
14
17
|
},
|
|
15
18
|
withOverrides: (editor)=>{
|
|
16
|
-
|
|
19
|
+
// Reverts the change made upstream that caused the cursor
|
|
20
|
+
// to be trapped inside inline elements.
|
|
21
|
+
//
|
|
22
|
+
// Reverts https://github.com/ianstormtaylor/slate/pull/4578/
|
|
23
|
+
// Related https://github.com/ianstormtaylor/slate/issues/4704
|
|
24
|
+
const { insertText } = editor;
|
|
17
25
|
editor.insertText = (text)=>{
|
|
18
|
-
const { selection
|
|
26
|
+
const { selection } = editor;
|
|
27
|
+
// If the cursor is at the end of an inline, move it outside
|
|
28
|
+
// before inserting
|
|
19
29
|
if (selection && isRangeCollapsed(selection)) {
|
|
20
30
|
const inlinePath = getAboveNode(editor, {
|
|
21
31
|
match: (n)=>isInline(editor, n),
|
|
@@ -31,7 +41,8 @@ export function createTextPlugin(restrictedMarks = []) {
|
|
|
31
41
|
}
|
|
32
42
|
return insertText(text);
|
|
33
43
|
};
|
|
34
|
-
|
|
44
|
+
// When pressing delete instead of backspace
|
|
45
|
+
const { deleteForward, deleteBackward } = editor;
|
|
35
46
|
editor.deleteBackward = (unit)=>{
|
|
36
47
|
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
37
48
|
};
|
|
@@ -67,8 +78,9 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
67
78
|
if (entry) {
|
|
68
79
|
const [paragraphOrHeading, path] = entry;
|
|
69
80
|
const isTextEmpty = isAncestorEmpty(editor, paragraphOrHeading);
|
|
81
|
+
// We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
|
|
70
82
|
const isRootLevel = path.length === 1;
|
|
71
|
-
const hasSiblings = editor.children.length > 1;
|
|
83
|
+
const hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
72
84
|
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
73
85
|
removeNodes(editor, {
|
|
74
86
|
at: path
|
|
@@ -102,7 +114,11 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
102
114
|
deleteFunction(unit);
|
|
103
115
|
}
|
|
104
116
|
}
|
|
105
|
-
|
|
117
|
+
/**
|
|
118
|
+
* To be compatible with the old behavior we need to treat each 2 consecutive
|
|
119
|
+
* line breaks as a new paragraph when pasting as plain text (also known as
|
|
120
|
+
* paste and match style in macOS)
|
|
121
|
+
*/ function fixPasteAsPlainText(editor) {
|
|
106
122
|
editor.insertTextData = (data)=>{
|
|
107
123
|
const text = data.getData('text/plain');
|
|
108
124
|
if (!text) {
|
|
@@ -111,6 +127,7 @@ function fixPasteAsPlainText(editor) {
|
|
|
111
127
|
const lines = text.split(/\n{2}/);
|
|
112
128
|
let split = false;
|
|
113
129
|
for (const line of lines){
|
|
130
|
+
// empty lines
|
|
114
131
|
if (/^(\r\n?|\n)$/.test(line)) {
|
|
115
132
|
continue;
|
|
116
133
|
}
|
|
@@ -21,6 +21,7 @@ export function getPastingSource(data) {
|
|
|
21
21
|
if (doc.querySelector('meta[content*="Microsoft Word"]')) {
|
|
22
22
|
return 'Microsoft Word';
|
|
23
23
|
}
|
|
24
|
+
// TODO: MS Word Online doesn't give us specific tags, we might need to have a closer look at its tracking result since we are using generic values to identify it
|
|
24
25
|
if (doc.querySelector('[style*="Arial_MSFontService"]') && (doc.querySelector('.TextRun') || doc.querySelector('.OutlineElement'))) {
|
|
25
26
|
return 'Microsoft Word Online';
|
|
26
27
|
}
|
|
@@ -58,7 +59,7 @@ export const createTrackingPlugin = (onAction)=>{
|
|
|
58
59
|
return {
|
|
59
60
|
key: 'TrackingPlugin',
|
|
60
61
|
withOverrides: (editor)=>{
|
|
61
|
-
const { insertData
|
|
62
|
+
const { insertData } = editor;
|
|
62
63
|
editor.tracking = trackingActions;
|
|
63
64
|
editor.insertData = (data)=>{
|
|
64
65
|
const isCopyAndPaste = data.types.length !== 0;
|
|
@@ -3,6 +3,7 @@ import { documentToPlainTextString } from '@contentful/rich-text-plain-text-rend
|
|
|
3
3
|
import Schema from '../../constants/Schema';
|
|
4
4
|
export function getCharacterCount(editor) {
|
|
5
5
|
const document = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6
|
+
// eslint-disable-next-line -- parameter type is not exported @typescript-eslint/no-explicit-any
|
|
6
7
|
document: editor.children,
|
|
7
8
|
schema: Schema
|
|
8
9
|
});
|
|
@@ -4,6 +4,8 @@ export const createVoidsPlugin = ()=>({
|
|
|
4
4
|
key: 'VoidsPlugin',
|
|
5
5
|
exitBreak: [
|
|
6
6
|
{
|
|
7
|
+
// Inserts a new paragraph *before* a void element if it's the very first
|
|
8
|
+
// node on the editor
|
|
7
9
|
hotkey: 'enter',
|
|
8
10
|
before: true,
|
|
9
11
|
query: {
|
|
@@ -11,7 +13,10 @@ export const createVoidsPlugin = ()=>({
|
|
|
11
13
|
}
|
|
12
14
|
},
|
|
13
15
|
{
|
|
16
|
+
// Inserts a new paragraph on enter when a void element is focused
|
|
14
17
|
hotkey: 'enter',
|
|
18
|
+
// exploit the internal use of Array.slice(0, level + 1) by the exitBreak plugin
|
|
19
|
+
// to stay in the parent element
|
|
15
20
|
level: -2,
|
|
16
21
|
query: {
|
|
17
22
|
filter: ([node, path])=>!(isRootLevel(path) && isFirstChildPath(path)) && !!node.isVoid
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { insertNodes, removeNodes } from '../../internal/transforms';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Re-creates a void node with valid children.
|
|
4
|
+
*/ export const transformVoid = (editor, [node, path])=>{
|
|
3
5
|
const validVoid = {
|
|
4
6
|
...node,
|
|
5
7
|
children: [
|
|
@@ -8,6 +10,7 @@ export const transformVoid = (editor, [node, path])=>{
|
|
|
8
10
|
}
|
|
9
11
|
]
|
|
10
12
|
};
|
|
13
|
+
// A workaround because Slate doesn't allow adjusting void nodes children
|
|
11
14
|
removeNodes(editor, {
|
|
12
15
|
at: path
|
|
13
16
|
});
|
|
@@ -24,11 +24,15 @@ import { createTrailingParagraphPlugin } from './TrailingParagraph';
|
|
|
24
24
|
import { createVoidsPlugin } from './Voids';
|
|
25
25
|
export const getPlugins = (sdk, onAction, restrictedMarks)=>[
|
|
26
26
|
createDeserializeDocxPlugin(),
|
|
27
|
+
// Tracking - This should come first so all plugins below will have access to `editor.tracking`
|
|
27
28
|
createTrackingPlugin(onAction),
|
|
29
|
+
// Global / Global shortcuts
|
|
28
30
|
createDragAndDropPlugin(),
|
|
31
|
+
// Enable command palette plugin only, if at least action type is allowed
|
|
29
32
|
...Object.values(isCommandPromptPluginEnabled(sdk)).some(Boolean) ? [
|
|
30
33
|
createCommandPalettePlugin()
|
|
31
34
|
] : [],
|
|
35
|
+
// Block Elements
|
|
32
36
|
createParagraphPlugin(),
|
|
33
37
|
createListPlugin(),
|
|
34
38
|
createHrPlugin(),
|
|
@@ -38,20 +42,28 @@ export const getPlugins = (sdk, onAction, restrictedMarks)=>[
|
|
|
38
42
|
createEmbeddedEntryBlockPlugin(sdk),
|
|
39
43
|
createEmbeddedAssetBlockPlugin(sdk),
|
|
40
44
|
createEmbeddedResourceBlockPlugin(sdk),
|
|
45
|
+
// Inline elements
|
|
41
46
|
createHyperlinkPlugin(sdk),
|
|
42
47
|
createEmbeddedEntityInlinePlugin(sdk),
|
|
43
48
|
createEmbeddedResourceInlinePlugin(sdk),
|
|
49
|
+
// Marks
|
|
44
50
|
createMarksPlugin(),
|
|
51
|
+
// Other
|
|
45
52
|
createTrailingParagraphPlugin(),
|
|
46
53
|
createTextPlugin(restrictedMarks),
|
|
47
54
|
createVoidsPlugin(),
|
|
48
55
|
createSelectOnBackspacePlugin(),
|
|
56
|
+
// Pasting content from other sources
|
|
49
57
|
createPasteHTMLPlugin(),
|
|
58
|
+
// These plugins drive their configurations from the list of plugins
|
|
59
|
+
// above. They MUST come last.
|
|
50
60
|
createSoftBreakPlugin(),
|
|
51
61
|
createExitBreakPlugin(),
|
|
52
62
|
createResetNodePlugin(),
|
|
53
63
|
createNormalizerPlugin()
|
|
54
64
|
];
|
|
55
65
|
export const disableCorePlugins = {
|
|
66
|
+
// Note: Enabled by default since v9.0.0 but it causes Cypress's
|
|
67
|
+
// .click() command to fail
|
|
56
68
|
eventEditor: true
|
|
57
69
|
};
|
|
@@ -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)=>{
|
|
@@ -29,19 +29,19 @@ export function EmbeddedBlockToolbarIcon({ isDisabled , nodeType , onClose }) {
|
|
|
29
29
|
};
|
|
30
30
|
const type = getEntityTypeFromNodeType(nodeType);
|
|
31
31
|
const baseClass = `rich-text__${nodeType}`;
|
|
32
|
-
return React.createElement(Menu.Item, {
|
|
32
|
+
return /*#__PURE__*/ React.createElement(Menu.Item, {
|
|
33
33
|
disabled: isDisabled,
|
|
34
34
|
className: `${baseClass}-list-item`,
|
|
35
35
|
onClick: handleClick,
|
|
36
36
|
testId: `toolbar-toggle-${nodeType}`
|
|
37
|
-
}, React.createElement(Flex, {
|
|
37
|
+
}, /*#__PURE__*/ React.createElement(Flex, {
|
|
38
38
|
alignItems: "center",
|
|
39
39
|
flexDirection: "row"
|
|
40
|
-
}, React.createElement(Icon, {
|
|
40
|
+
}, /*#__PURE__*/ React.createElement(Icon, {
|
|
41
41
|
as: type === 'Asset' ? AssetIcon : EmbeddedEntryBlockIcon,
|
|
42
42
|
className: `rich-text__embedded-entry-list-icon ${styles.icon}`,
|
|
43
43
|
variant: "secondary"
|
|
44
|
-
}), React.createElement("span", null, type, nodeType == BLOCKS.EMBEDDED_RESOURCE && React.createElement(ResourceNewBadge, null))));
|
|
44
|
+
}), /*#__PURE__*/ React.createElement("span", null, type, nodeType == BLOCKS.EMBEDDED_RESOURCE && /*#__PURE__*/ React.createElement(ResourceNewBadge, null))));
|
|
45
45
|
}
|
|
46
46
|
function getEntityTypeFromNodeType(nodeType) {
|
|
47
47
|
const words = nodeType.toLowerCase().split('-');
|
|
@@ -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) {
|
|
@@ -46,6 +46,8 @@ export async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
|
|
|
46
46
|
nodeType
|
|
47
47
|
});
|
|
48
48
|
} else {
|
|
49
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
50
|
+
// (i.e. when using hotkeys and slide-in)
|
|
49
51
|
select(editor, selection);
|
|
50
52
|
insertBlock(editor, nodeType, entity);
|
|
51
53
|
ensureFollowingParagraph(editor, [
|
|
@@ -56,6 +58,8 @@ export async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
|
|
|
56
58
|
nodeType
|
|
57
59
|
});
|
|
58
60
|
}
|
|
61
|
+
// If user chose to create a new entity, this might open slide-in to edit the
|
|
62
|
+
// entity. In this case, no point in focusing RTE which is now in the slide below.
|
|
59
63
|
rteSlide.onActive(()=>{
|
|
60
64
|
rteSlide.unwatch();
|
|
61
65
|
focus(editor);
|
|
@@ -65,15 +69,17 @@ export async function selectResourceEntityAndInsert(sdk, editor, logAction) {
|
|
|
65
69
|
logAction('openCreateEmbedDialog', {
|
|
66
70
|
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
67
71
|
});
|
|
68
|
-
const { field
|
|
72
|
+
const { field, dialogs } = sdk;
|
|
69
73
|
const config = newResourceEntitySelectorConfigFromRichTextField(field, BLOCKS.EMBEDDED_RESOURCE);
|
|
70
|
-
const { selection
|
|
74
|
+
const { selection } = editor;
|
|
71
75
|
const entity = await dialogs.selectSingleResourceEntry(config);
|
|
72
76
|
if (!entity) {
|
|
73
77
|
logAction('cancelCreateEmbedDialog', {
|
|
74
78
|
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
75
79
|
});
|
|
76
80
|
} else {
|
|
81
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
82
|
+
// (i.e. when using hotkeys and slide-in)
|
|
77
83
|
select(editor, selection);
|
|
78
84
|
insertBlock(editor, BLOCKS.EMBEDDED_RESOURCE, entity);
|
|
79
85
|
ensureFollowingParagraph(editor, [
|
|
@@ -84,6 +90,7 @@ export async function selectResourceEntityAndInsert(sdk, editor, logAction) {
|
|
|
84
90
|
});
|
|
85
91
|
}
|
|
86
92
|
}
|
|
93
|
+
// TODO: incorporate this logic inside the trailingParagraph plugin instead
|
|
87
94
|
function ensureFollowingParagraph(editor, nodeTypes) {
|
|
88
95
|
const entityBlock = getAboveNode(editor, {
|
|
89
96
|
match: {
|
|
@@ -96,6 +103,8 @@ function ensureFollowingParagraph(editor, nodeTypes) {
|
|
|
96
103
|
const level = entityBlock[1].length - 1;
|
|
97
104
|
const lastNode = getLastNodeByLevel(editor, level);
|
|
98
105
|
const isTextContainer = TEXT_CONTAINERS.includes(lastNode?.[0].type ?? '');
|
|
106
|
+
// If the new block isn't followed by a sibling text container (e.g. paragraph)
|
|
107
|
+
// we insert a new empty one. Level 0 is handled by the trailingParagraph plugin
|
|
99
108
|
if (level !== 0 && !isTextContainer) {
|
|
100
109
|
insertEmptyParagraph(editor);
|
|
101
110
|
}
|
|
@@ -131,6 +140,7 @@ const createNode = (nodeType, entity)=>{
|
|
|
131
140
|
isVoid: true
|
|
132
141
|
};
|
|
133
142
|
};
|
|
143
|
+
// TODO: DRY up copied code from HR
|
|
134
144
|
function insertBlock(editor, nodeType, entity) {
|
|
135
145
|
if (!editor?.selection) return;
|
|
136
146
|
const linkedEntityBlock = createNode(nodeType, entity);
|
|
@@ -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) {
|
|
@@ -36,16 +36,16 @@ export function EmbeddedInlineToolbarIcon({ onClose , nodeType , isDisabled })
|
|
|
36
36
|
}
|
|
37
37
|
moveToTheNextChar(editor);
|
|
38
38
|
}
|
|
39
|
-
return React.createElement(Menu.Item, {
|
|
39
|
+
return /*#__PURE__*/ React.createElement(Menu.Item, {
|
|
40
40
|
disabled: isDisabled,
|
|
41
41
|
className: "rich-text__entry-link-block-button",
|
|
42
42
|
testId: `toolbar-toggle-${nodeType}`,
|
|
43
43
|
onClick: handleClick
|
|
44
|
-
}, React.createElement(Flex, {
|
|
44
|
+
}, /*#__PURE__*/ React.createElement(Flex, {
|
|
45
45
|
alignItems: "center",
|
|
46
46
|
flexDirection: "row"
|
|
47
|
-
}, React.createElement(EmbeddedEntryInlineIcon, {
|
|
47
|
+
}, /*#__PURE__*/ React.createElement(EmbeddedEntryInlineIcon, {
|
|
48
48
|
variant: "secondary",
|
|
49
49
|
className: `rich-text__embedded-entry-list-icon ${styles.icon}`
|
|
50
|
-
}), React.createElement("span", null, "Inline entry", nodeType == INLINES.EMBEDDED_RESOURCE && React.createElement(ResourceNewBadge, null))));
|
|
50
|
+
}), /*#__PURE__*/ React.createElement("span", null, "Inline entry", nodeType == INLINES.EMBEDDED_RESOURCE && /*#__PURE__*/ React.createElement(ResourceNewBadge, null))));
|
|
51
51
|
}
|
|
@@ -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) {
|
|
@@ -64,6 +64,8 @@ export async function selectEntityAndInsert(editor, sdk, logAction) {
|
|
|
64
64
|
nodeType
|
|
65
65
|
});
|
|
66
66
|
} else {
|
|
67
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
68
|
+
// (i.e. when using hotkeys and slide-in)
|
|
67
69
|
select(editor, selection);
|
|
68
70
|
insertNodes(editor, createInlineEntryNode(nodeType, entry));
|
|
69
71
|
logAction('insert', {
|
|
@@ -80,18 +82,20 @@ export async function selectResourceEntityAndInsert(editor, sdk, logAction) {
|
|
|
80
82
|
logAction('openCreateEmbedDialog', {
|
|
81
83
|
nodeType
|
|
82
84
|
});
|
|
83
|
-
const { dialogs
|
|
85
|
+
const { dialogs, field } = sdk;
|
|
84
86
|
const config = {
|
|
85
87
|
...newResourceEntitySelectorConfigFromRichTextField(field, nodeType),
|
|
86
88
|
withCreate: true
|
|
87
89
|
};
|
|
88
|
-
const { selection
|
|
90
|
+
const { selection } = editor;
|
|
89
91
|
const entry = await dialogs.selectSingleResourceEntry(config);
|
|
90
92
|
if (!entry) {
|
|
91
93
|
logAction('cancelCreateEmbedDialog', {
|
|
92
94
|
nodeType
|
|
93
95
|
});
|
|
94
96
|
} else {
|
|
97
|
+
// Selection prevents incorrect position of inserted ref when RTE doesn't have focus
|
|
98
|
+
// (i.e. when using hotkeys and slide-in)
|
|
95
99
|
select(editor, selection);
|
|
96
100
|
insertNodes(editor, createInlineEntryNode(nodeType, entry));
|
|
97
101
|
logAction('insert', {
|
|
@@ -2,21 +2,21 @@ import * as React from 'react';
|
|
|
2
2
|
import { AssetCard } from '@contentful/f36-components';
|
|
3
3
|
import { useEntity, useEntityLoader, MissingEntityCard, WrappedAssetCard } from '@contentful/field-editor-reference';
|
|
4
4
|
import areEqual from 'fast-deep-equal';
|
|
5
|
-
const InternalAssetCard = React.memo((props)=>{
|
|
5
|
+
const InternalAssetCard = /*#__PURE__*/ React.memo((props)=>{
|
|
6
6
|
if (props.asset === undefined) {
|
|
7
|
-
return React.createElement(AssetCard, {
|
|
7
|
+
return /*#__PURE__*/ React.createElement(AssetCard, {
|
|
8
8
|
size: "default",
|
|
9
9
|
isLoading: true
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
if (props.asset === 'failed') {
|
|
13
|
-
return React.createElement(MissingEntityCard, {
|
|
13
|
+
return /*#__PURE__*/ React.createElement(MissingEntityCard, {
|
|
14
14
|
entityType: "Asset",
|
|
15
15
|
isDisabled: props.isDisabled,
|
|
16
16
|
onRemove: props.onRemove
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
return React.createElement(WrappedAssetCard, {
|
|
19
|
+
return /*#__PURE__*/ React.createElement(WrappedAssetCard, {
|
|
20
20
|
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
21
21
|
size: "small",
|
|
22
22
|
isSelected: props.isSelected,
|
|
@@ -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
|
|
@@ -46,7 +46,7 @@ export function FetchingWrappedAssetCard(props) {
|
|
|
46
46
|
onEntityFetchComplete,
|
|
47
47
|
status
|
|
48
48
|
]);
|
|
49
|
-
return React.createElement(InternalAssetCard, {
|
|
49
|
+
return /*#__PURE__*/ React.createElement(InternalAssetCard, {
|
|
50
50
|
asset: asset,
|
|
51
51
|
sdk: props.sdk,
|
|
52
52
|
isDisabled: props.isDisabled,
|
|
@@ -2,22 +2,22 @@ import * as React from 'react';
|
|
|
2
2
|
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
|
-
const InternalEntryCard = React.memo((props)=>{
|
|
6
|
-
const { entry
|
|
5
|
+
const InternalEntryCard = /*#__PURE__*/ React.memo((props)=>{
|
|
6
|
+
const { entry, sdk, loadEntityScheduledActions } = props;
|
|
7
7
|
if (entry === undefined) {
|
|
8
|
-
return React.createElement(EntryCard, {
|
|
8
|
+
return /*#__PURE__*/ React.createElement(EntryCard, {
|
|
9
9
|
isLoading: true
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
if (entry === 'failed') {
|
|
13
|
-
return React.createElement(MissingEntityCard, {
|
|
13
|
+
return /*#__PURE__*/ React.createElement(MissingEntityCard, {
|
|
14
14
|
entityType: "Entry",
|
|
15
15
|
isDisabled: props.isDisabled,
|
|
16
16
|
onRemove: props.onRemove
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
const contentType = sdk.space.getCachedContentTypes().find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
|
|
20
|
-
return React.createElement(WrappedEntryCard, {
|
|
20
|
+
return /*#__PURE__*/ React.createElement(WrappedEntryCard, {
|
|
21
21
|
size: "default",
|
|
22
22
|
getAsset: props.sdk.space.getAsset,
|
|
23
23
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
@@ -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
|
|
@@ -49,7 +49,7 @@ export const FetchingWrappedEntryCard = (props)=>{
|
|
|
49
49
|
onEntityFetchComplete,
|
|
50
50
|
status
|
|
51
51
|
]);
|
|
52
|
-
return React.createElement(InternalEntryCard, {
|
|
52
|
+
return /*#__PURE__*/ React.createElement(InternalEntryCard, {
|
|
53
53
|
entry: entry,
|
|
54
54
|
sdk: props.sdk,
|
|
55
55
|
locale: props.locale,
|
|
@@ -2,14 +2,14 @@ import * as React from 'react';
|
|
|
2
2
|
import { EntryCard } from '@contentful/f36-components';
|
|
3
3
|
import { ResourceEntityErrorCard, WrappedEntryCard, useResource } from '@contentful/field-editor-reference';
|
|
4
4
|
import areEqual from 'fast-deep-equal';
|
|
5
|
-
const InternalEntryCard = React.memo((props)=>{
|
|
5
|
+
const InternalEntryCard = /*#__PURE__*/ React.memo((props)=>{
|
|
6
6
|
if (props.data === undefined || props.status === 'loading') {
|
|
7
|
-
return React.createElement(EntryCard, {
|
|
7
|
+
return /*#__PURE__*/ React.createElement(EntryCard, {
|
|
8
8
|
isLoading: true
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
const { contentType
|
|
12
|
-
return React.createElement(WrappedEntryCard, {
|
|
11
|
+
const { contentType, resource: entry, space } = props.data;
|
|
12
|
+
return /*#__PURE__*/ React.createElement(WrappedEntryCard, {
|
|
13
13
|
size: "default",
|
|
14
14
|
getAsset: ()=>Promise.resolve(),
|
|
15
15
|
isSelected: props.isSelected,
|
|
@@ -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?.();
|
|
@@ -38,7 +38,7 @@ export const FetchingWrappedResourceCard = (props)=>{
|
|
|
38
38
|
status
|
|
39
39
|
]);
|
|
40
40
|
if (status === 'error') {
|
|
41
|
-
return React.createElement(ResourceEntityErrorCard, {
|
|
41
|
+
return /*#__PURE__*/ React.createElement(ResourceEntityErrorCard, {
|
|
42
42
|
error: error,
|
|
43
43
|
linkType: link.linkType,
|
|
44
44
|
isSelected: props.isSelected,
|
|
@@ -46,7 +46,8 @@ export const FetchingWrappedResourceCard = (props)=>{
|
|
|
46
46
|
onRemove: props.onRemove
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
return React.createElement(InternalEntryCard, {
|
|
49
|
+
return /*#__PURE__*/ React.createElement(InternalEntryCard, {
|
|
50
|
+
// entry is the only currently supported entity but TypeScript is not aware
|
|
50
51
|
data: data,
|
|
51
52
|
status: status,
|
|
52
53
|
sdk: props.sdk,
|
|
@@ -8,20 +8,24 @@ const styles = {
|
|
|
8
8
|
display: 'block'
|
|
9
9
|
}),
|
|
10
10
|
container: css({
|
|
11
|
+
// The next 2 properties ensure Entity card won't be aligned above
|
|
12
|
+
// a list item marker (i.e. bullet)
|
|
11
13
|
display: 'inline-block',
|
|
12
14
|
verticalAlign: 'text-top',
|
|
13
15
|
width: '100%'
|
|
14
16
|
})
|
|
15
17
|
};
|
|
16
|
-
export function LinkedBlockWrapper({ attributes
|
|
17
|
-
return React.createElement("div", {
|
|
18
|
+
export function LinkedBlockWrapper({ attributes, card, children, link }) {
|
|
19
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
18
20
|
...attributes,
|
|
19
21
|
className: styles.root,
|
|
20
22
|
"data-entity-type": link.sys.linkType,
|
|
21
23
|
"data-entity-id": getLinkEntityId(link),
|
|
24
|
+
// COMPAT: This makes copy & paste work for Firefox
|
|
22
25
|
contentEditable: IS_CHROME ? undefined : false,
|
|
23
26
|
draggable: IS_CHROME ? true : undefined
|
|
24
|
-
}, React.createElement("div", {
|
|
27
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
28
|
+
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
25
29
|
contentEditable: IS_CHROME ? false : undefined,
|
|
26
30
|
draggable: IS_CHROME ? true : undefined,
|
|
27
31
|
className: styles.container
|
|
@@ -16,15 +16,17 @@ const styles = {
|
|
|
16
16
|
}
|
|
17
17
|
})
|
|
18
18
|
};
|
|
19
|
-
export function LinkedInlineWrapper({ attributes
|
|
20
|
-
return React.createElement("span", {
|
|
19
|
+
export function LinkedInlineWrapper({ attributes, card, children, link }) {
|
|
20
|
+
return /*#__PURE__*/ React.createElement("span", {
|
|
21
21
|
...attributes,
|
|
22
22
|
className: styles.root,
|
|
23
23
|
"data-entity-type": link.sys.linkType,
|
|
24
24
|
"data-entity-id": getLinkEntityId(link),
|
|
25
|
+
// COMPAT: This makes copy & paste work for Firefox
|
|
25
26
|
contentEditable: IS_CHROME ? undefined : false,
|
|
26
27
|
draggable: IS_CHROME ? true : undefined
|
|
27
|
-
}, React.createElement("span", {
|
|
28
|
+
}, /*#__PURE__*/ React.createElement("span", {
|
|
29
|
+
// COMPAT: This makes copy & paste work for Chromium/Blink browsers and Safari
|
|
28
30
|
contentEditable: IS_CHROME ? false : undefined,
|
|
29
31
|
draggable: IS_CHROME ? true : undefined
|
|
30
32
|
}, card), children);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Badge } from '@contentful/f36-components';
|
|
3
3
|
export const ResourceNewBadge = ()=>{
|
|
4
|
-
return React.createElement(React.Fragment, null, ' ', "(different space)", ' ', React.createElement(Badge, {
|
|
4
|
+
return /*#__PURE__*/ React.createElement(React.Fragment, null, ' ', "(different space)", ' ', /*#__PURE__*/ React.createElement(Badge, {
|
|
5
5
|
variant: "primary-filled",
|
|
6
6
|
size: "small"
|
|
7
7
|
}, "new"));
|
|
@@ -14,12 +14,12 @@ 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();
|
|
21
21
|
};
|
|
22
|
-
const button = React.createElement(Button, {
|
|
22
|
+
const button = /*#__PURE__*/ React.createElement(Button, {
|
|
23
23
|
className: cx(styles.button, className),
|
|
24
24
|
isDisabled: isDisabled,
|
|
25
25
|
startIcon: children,
|
|
@@ -29,7 +29,7 @@ export function ToolbarButton(props) {
|
|
|
29
29
|
size: "small"
|
|
30
30
|
});
|
|
31
31
|
if (title) {
|
|
32
|
-
return React.createElement(Tooltip, {
|
|
32
|
+
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
33
33
|
className: styles.tooltip,
|
|
34
34
|
placement: "bottom",
|
|
35
35
|
content: title
|
|
@@ -38,17 +38,20 @@ beforeEach(()=>{
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
test('some dropdown actions should be disabled', async ()=>{
|
|
41
|
-
const { getByTestId
|
|
41
|
+
const { getByTestId, queryByTestId } = render(/*#__PURE__*/ React.createElement(EntityProvider, {
|
|
42
42
|
sdk: sdk
|
|
43
|
-
}, React.createElement(FetchingWrappedAssetCard, {
|
|
43
|
+
}, /*#__PURE__*/ React.createElement(FetchingWrappedAssetCard, {
|
|
44
44
|
sdk: sdk,
|
|
45
45
|
assetId: "asset-id",
|
|
46
46
|
locale: "en-US",
|
|
47
|
+
// eslint-disable-next-line -- TODO: explain this disable
|
|
47
48
|
onEdit: ()=>{},
|
|
49
|
+
// eslint-disable-next-line -- TODO: explain this disable
|
|
48
50
|
onRemove: ()=>{},
|
|
49
51
|
isDisabled: true,
|
|
50
52
|
isSelected: true
|
|
51
53
|
})));
|
|
54
|
+
// Assert Asset title
|
|
52
55
|
await waitFor(()=>expect(getByTestId('cf-ui-asset').textContent).toBe('asset title'));
|
|
53
56
|
fireEvent.click(getByTestId('cf-ui-card-actions'));
|
|
54
57
|
await waitFor(()=>{
|