@contentful/field-editor-rich-text 3.16.8 → 3.16.11
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 +20 -22
- package/dist/cjs/RichTextEditor.styles.js +1 -2
- package/dist/cjs/SdkProvider.js +5 -7
- package/dist/cjs/SyncEditorChanges.js +6 -15
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +15 -17
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +9 -13
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +8 -10
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +2 -2
- package/dist/cjs/Toolbar/index.js +30 -33
- 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 +6 -8
- package/dist/cjs/__fixtures__/locale/index.js +2 -2
- package/dist/cjs/__fixtures__/space/index.js +1 -1
- package/dist/cjs/constants/Schema.js +0 -1
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +38 -43
- package/dist/cjs/dialogs/openRichTextDialog.js +4 -6
- package/dist/cjs/dialogs/renderRichTextDialog.js +4 -6
- 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 +44 -53
- package/dist/cjs/helpers/environment.js +3 -3
- package/dist/cjs/helpers/formatDateAndTime.js +4 -5
- package/dist/cjs/helpers/getAllowedResourcesForNodeType.js +5 -22
- package/dist/cjs/helpers/getLinkedContentTypeIdsForNodeType.js +5 -29
- package/dist/cjs/helpers/nodeFactory.js +6 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +6 -14
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +2 -3
- package/dist/cjs/helpers/toSlateValue.js +3 -14
- package/dist/cjs/helpers/transformers.js +5 -5
- package/dist/cjs/helpers/validations.js +9 -12
- package/dist/cjs/index.js +5 -7
- package/dist/cjs/internal/constants.js +2 -4
- package/dist/cjs/internal/hooks.js +7 -9
- package/dist/cjs/internal/misc.js +12 -15
- package/dist/cjs/internal/queries.js +108 -115
- package/dist/cjs/internal/transforms.js +48 -51
- package/dist/cjs/internal/types/editor.js +1 -3
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +3 -4
- package/dist/cjs/plugins/Break/createResetNodePlugin.js +0 -1
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +3 -3
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +33 -35
- package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +1 -1
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +5 -7
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +3 -7
- package/dist/cjs/plugins/CommandPalette/onKeyDown.js +1 -6
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +4 -6
- package/dist/cjs/plugins/CommandPalette/useCommands.js +3 -3
- package/dist/cjs/plugins/CommandPalette/utils/fetchEntries.js +0 -2
- package/dist/cjs/plugins/CommandPalette/utils/trimLeadingSlash.js +1 -6
- package/dist/cjs/plugins/DragAndDrop/index.js +1 -9
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +8 -10
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +17 -19
- package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +7 -9
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +5 -5
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +11 -13
- 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 +10 -13
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +29 -23
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +2 -7
- package/dist/cjs/plugins/Hr/index.js +14 -19
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +28 -32
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +8 -10
- package/dist/cjs/plugins/Hyperlink/components/LinkPopover.js +17 -23
- package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +8 -10
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +4 -6
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +6 -8
- package/dist/cjs/plugins/Hyperlink/components/linkHandlers.js +3 -3
- package/dist/cjs/plugins/Hyperlink/components/styles.js +1 -1
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +4 -10
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +3 -6
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +4 -6
- 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 +25 -29
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +22 -22
- package/dist/cjs/plugins/List/components/List.js +7 -9
- package/dist/cjs/plugins/List/components/ListItem.js +4 -6
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +5 -7
- package/dist/cjs/plugins/List/createListPlugin.js +0 -4
- package/dist/cjs/plugins/List/insertListBreak.js +4 -13
- package/dist/cjs/plugins/List/insertListFragment.js +5 -18
- package/dist/cjs/plugins/List/onKeyDownList.js +6 -8
- package/dist/cjs/plugins/List/transforms/insertListItem.js +2 -17
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +2 -8
- package/dist/cjs/plugins/List/transforms/moveListItems.js +2 -7
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +14 -15
- package/dist/cjs/plugins/List/transforms/toggleList.js +3 -8
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/cjs/plugins/List/transforms/unwrapList.js +2 -7
- package/dist/cjs/plugins/List/utils.js +11 -12
- package/dist/cjs/plugins/List/withList.js +2 -6
- package/dist/cjs/plugins/Marks/Bold.js +7 -9
- package/dist/cjs/plugins/Marks/Code.js +7 -15
- package/dist/cjs/plugins/Marks/Italic.js +7 -9
- package/dist/cjs/plugins/Marks/Subscript.js +8 -10
- package/dist/cjs/plugins/Marks/Superscript.js +8 -10
- package/dist/cjs/plugins/Marks/Underline.js +4 -6
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +7 -9
- package/dist/cjs/plugins/Marks/helpers.js +5 -5
- package/dist/cjs/plugins/Normalizer/baseRules.js +0 -2
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/cjs/plugins/Normalizer/utils.js +3 -4
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +3 -23
- package/dist/cjs/plugins/Paragraph/Paragraph.js +4 -6
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +2 -3
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +6 -9
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +0 -2
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeAnchors.js +0 -9
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeHTML.js +2 -17
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeSheets.js +1 -13
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
- package/dist/cjs/plugins/Quote/components/Quote.js +4 -6
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +4 -6
- package/dist/cjs/plugins/Quote/createQuotePlugin.js +0 -1
- package/dist/cjs/plugins/Quote/toggleQuote.js +5 -5
- package/dist/cjs/plugins/Quote/withQuote.js +2 -4
- package/dist/cjs/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +0 -1
- 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 +4 -5
- package/dist/cjs/plugins/Table/actions/addRow.js +3 -6
- package/dist/cjs/plugins/Table/components/Cell.js +5 -7
- package/dist/cjs/plugins/Table/components/HeaderCell.js +5 -7
- package/dist/cjs/plugins/Table/components/Row.js +4 -6
- package/dist/cjs/plugins/Table/components/Table.js +6 -8
- package/dist/cjs/plugins/Table/components/TableActions.js +16 -19
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +4 -7
- package/dist/cjs/plugins/Table/createTablePlugin.js +1 -11
- package/dist/cjs/plugins/Table/helpers.js +12 -16
- package/dist/cjs/plugins/Table/insertTableFragment.js +2 -15
- package/dist/cjs/plugins/Table/onKeyDownTable.js +2 -11
- package/dist/cjs/plugins/Table/tableTracking.js +6 -6
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +17 -19
- package/dist/cjs/plugins/Text/createTextPlugin.js +5 -22
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +4 -5
- package/dist/cjs/plugins/Tracking/utils.js +3 -6
- package/dist/cjs/plugins/Voids/createVoidsPlugin.js +0 -5
- package/dist/cjs/plugins/Voids/transformVoid.js +0 -1
- package/dist/cjs/plugins/index.js +3 -15
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +10 -12
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +6 -16
- package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +8 -10
- package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +5 -9
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +11 -13
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +12 -14
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +11 -14
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +4 -8
- package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +6 -10
- package/dist/cjs/plugins/shared/ResourceNewBadge.js +3 -5
- package/dist/cjs/plugins/shared/ToolbarButton.js +6 -8
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -10
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +6 -11
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +13 -15
- package/dist/cjs/plugins/shared/utils.js +1 -4
- package/dist/cjs/test-utils/assertOutput.js +0 -1
- package/dist/cjs/test-utils/hyperscript.d.js +0 -1
- package/dist/cjs/test-utils/randomId.js +1 -3
- package/dist/cjs/test-utils/validation.js +5 -8
- package/dist/esm/ContentfulEditorProvider.js +1 -4
- package/dist/esm/RichTextEditor.js +13 -13
- package/dist/esm/RichTextEditor.styles.js +0 -1
- package/dist/esm/SdkProvider.js +2 -2
- package/dist/esm/SyncEditorChanges.js +3 -18
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +12 -12
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +7 -9
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +6 -6
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/esm/Toolbar/index.js +27 -28
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/constants/Schema.js +0 -1
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +31 -34
- 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 +1 -9
- package/dist/esm/helpers/editor.js +6 -22
- package/dist/esm/helpers/extractNodes.js +1 -3
- package/dist/esm/helpers/formatDateAndTime.js +2 -11
- package/dist/esm/helpers/getAllowedResourcesForNodeType.js +2 -19
- package/dist/esm/helpers/getLinkedContentTypeIdsForNodeType.js +2 -26
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +6 -20
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +0 -1
- package/dist/esm/helpers/toSlateValue.js +3 -17
- package/dist/esm/helpers/validations.js +1 -5
- package/dist/esm/internal/misc.js +2 -23
- package/dist/esm/internal/queries.js +2 -11
- package/dist/esm/internal/transforms.js +3 -14
- package/dist/esm/internal/types/editor.js +1 -3
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +3 -4
- package/dist/esm/plugins/Break/createResetNodePlugin.js +0 -1
- 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 +1 -11
- package/dist/esm/plugins/CommandPalette/hooks/useCommandList.js +0 -2
- package/dist/esm/plugins/CommandPalette/onKeyDown.js +0 -5
- 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 +0 -2
- package/dist/esm/plugins/CommandPalette/utils/trimLeadingSlash.js +1 -6
- package/dist/esm/plugins/DragAndDrop/index.js +1 -9
- 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 +7 -8
- package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +26 -18
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +1 -6
- package/dist/esm/plugins/Hr/index.js +5 -8
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +23 -25
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +6 -6
- package/dist/esm/plugins/Hyperlink/components/LinkPopover.js +15 -19
- package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +6 -6
- package/dist/esm/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +2 -2
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +4 -4
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +1 -5
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +3 -6
- 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 +25 -29
- 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 +0 -4
- package/dist/esm/plugins/List/insertListBreak.js +4 -13
- package/dist/esm/plugins/List/insertListFragment.js +5 -18
- package/dist/esm/plugins/List/onKeyDownList.js +5 -7
- package/dist/esm/plugins/List/transforms/insertListItem.js +3 -20
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +2 -8
- package/dist/esm/plugins/List/transforms/moveListItems.js +2 -7
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +14 -15
- package/dist/esm/plugins/List/transforms/toggleList.js +3 -8
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/esm/plugins/List/transforms/unwrapList.js +2 -7
- package/dist/esm/plugins/List/utils.js +2 -7
- package/dist/esm/plugins/List/withList.js +2 -6
- package/dist/esm/plugins/Marks/Bold.js +2 -2
- package/dist/esm/plugins/Marks/Code.js +2 -8
- 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 +0 -4
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/esm/plugins/Normalizer/utils.js +0 -1
- package/dist/esm/plugins/Normalizer/withNormalizer.js +2 -22
- 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 +1 -2
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +3 -9
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +0 -2
- package/dist/esm/plugins/PasteHTML/utils/sanitizeAnchors.js +1 -27
- package/dist/esm/plugins/PasteHTML/utils/sanitizeHTML.js +2 -17
- package/dist/esm/plugins/PasteHTML/utils/sanitizeSheets.js +1 -13
- 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 +0 -1
- package/dist/esm/plugins/Quote/shouldResetQuote.js +1 -6
- package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
- package/dist/esm/plugins/Quote/withQuote.js +2 -4
- package/dist/esm/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +0 -1
- 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 +1 -2
- package/dist/esm/plugins/Table/actions/addRow.js +0 -3
- 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 +11 -12
- package/dist/esm/plugins/Table/components/ToolbarButton.js +2 -3
- package/dist/esm/plugins/Table/createTablePlugin.js +1 -11
- package/dist/esm/plugins/Table/helpers.js +1 -10
- package/dist/esm/plugins/Table/insertTableFragment.js +2 -15
- package/dist/esm/plugins/Table/onKeyDownTable.js +2 -11
- package/dist/esm/plugins/Table/tableTracking.js +6 -6
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +17 -19
- package/dist/esm/plugins/Text/createTextPlugin.js +5 -22
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +1 -2
- package/dist/esm/plugins/Tracking/utils.js +0 -1
- package/dist/esm/plugins/Voids/createVoidsPlugin.js +0 -5
- package/dist/esm/plugins/Voids/transformVoid.js +1 -4
- package/dist/esm/plugins/index.js +0 -12
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +5 -15
- package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +4 -8
- 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 +8 -9
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +3 -7
- package/dist/esm/plugins/shared/LinkedInlineWrapper.js +3 -5
- 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 +2 -5
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +2 -5
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +8 -8
- package/dist/esm/plugins/shared/utils.js +1 -4
- package/dist/esm/test-utils/assertOutput.js +0 -1
- package/dist/esm/test-utils/hyperscript.d.js +0 -1
- package/dist/esm/test-utils/jsx.js +1 -5
- package/dist/esm/test-utils/randomId.js +1 -3
- package/dist/esm/test-utils/setEmptyDataAttribute.js +1 -4
- package/dist/esm/test-utils/validation.js +4 -7
- package/dist/types/RichTextEditor.d.ts +2 -3
- package/dist/types/Toolbar/components/EmbedEntityWidget.d.ts +1 -2
- package/dist/types/Toolbar/components/EmbeddedEntityDropdownButton.d.ts +1 -1
- package/dist/types/Toolbar/components/StickyToolbarWrapper.d.ts +2 -2
- package/dist/types/Toolbar/index.d.ts +1 -2
- package/dist/types/dialogs/HypelinkDialog/HyperlinkDialog.d.ts +4 -4
- package/dist/types/dialogs/renderRichTextDialog.d.ts +1 -2
- package/dist/types/plugins/CommandPalette/components/CommandList.d.ts +1 -2
- package/dist/types/plugins/CommandPalette/components/CommandPrompt.d.ts +1 -2
- package/dist/types/plugins/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +1 -2
- package/dist/types/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.d.ts +1 -1
- package/dist/types/plugins/EmbeddedEntityInline/LinkedEntityInline.d.ts +1 -2
- package/dist/types/plugins/EmbeddedResourceBlock/LinkedResourceBlock.d.ts +1 -2
- package/dist/types/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.d.ts +1 -1
- package/dist/types/plugins/EmbeddedResourceInline/LinkedResourceInline.d.ts +1 -2
- package/dist/types/plugins/Heading/components/Heading.d.ts +6 -6
- package/dist/types/plugins/Heading/components/ToolbarHeadingButton.d.ts +1 -2
- package/dist/types/plugins/Hr/index.d.ts +2 -2
- package/dist/types/plugins/Hyperlink/HyperlinkModal.d.ts +1 -2
- package/dist/types/plugins/Hyperlink/components/EntityHyperlink.d.ts +1 -2
- package/dist/types/plugins/Hyperlink/components/LinkPopover.d.ts +1 -1
- package/dist/types/plugins/Hyperlink/components/ResourceHyperlink.d.ts +1 -2
- package/dist/types/plugins/Hyperlink/components/ToolbarHyperlinkButton.d.ts +1 -2
- package/dist/types/plugins/Hyperlink/components/UrlHyperlink.d.ts +1 -2
- package/dist/types/plugins/List/components/List.d.ts +2 -3
- package/dist/types/plugins/List/components/ListItem.d.ts +1 -2
- package/dist/types/plugins/List/components/ToolbarListButton.d.ts +1 -2
- package/dist/types/plugins/Marks/Bold.d.ts +2 -3
- package/dist/types/plugins/Marks/Code.d.ts +3 -4
- package/dist/types/plugins/Marks/Italic.d.ts +2 -3
- package/dist/types/plugins/Marks/Subscript.d.ts +3 -4
- package/dist/types/plugins/Marks/Superscript.d.ts +3 -4
- package/dist/types/plugins/Marks/Underline.d.ts +2 -3
- package/dist/types/plugins/Marks/components/MarkToolbarButton.d.ts +1 -1
- package/dist/types/plugins/Paragraph/Paragraph.d.ts +1 -2
- package/dist/types/plugins/Quote/components/Quote.d.ts +1 -2
- package/dist/types/plugins/Quote/components/ToolbarQuoteButton.d.ts +1 -2
- package/dist/types/plugins/Table/components/Cell.d.ts +1 -2
- package/dist/types/plugins/Table/components/HeaderCell.d.ts +1 -2
- package/dist/types/plugins/Table/components/Row.d.ts +1 -2
- package/dist/types/plugins/Table/components/Table.d.ts +1 -2
- package/dist/types/plugins/Table/components/TableActions.d.ts +1 -2
- package/dist/types/plugins/Table/components/ToolbarButton.d.ts +1 -2
- package/dist/types/plugins/shared/EmbeddedBlockToolbarIcon.d.ts +1 -2
- package/dist/types/plugins/shared/EmbeddedInlineToolbarIcon.d.ts +1 -2
- package/dist/types/plugins/shared/FetchingWrappedAssetCard.d.ts +1 -2
- package/dist/types/plugins/shared/FetchingWrappedEntryCard.d.ts +1 -2
- package/dist/types/plugins/shared/FetchingWrappedResourceCard.d.ts +1 -2
- package/dist/types/plugins/shared/LinkedBlockWrapper.d.ts +1 -1
- package/dist/types/plugins/shared/LinkedInlineWrapper.d.ts +1 -1
- package/dist/types/plugins/shared/ResourceNewBadge.d.ts +1 -2
- package/dist/types/plugins/shared/ToolbarButton.d.ts +1 -2
- package/package.json +8 -5
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { assertOutput, jsx } from '../../../test-utils';
|
|
2
2
|
describe('normalization', ()=>{
|
|
3
3
|
it('removes empty links from the document structure', ()=>{
|
|
4
|
-
const input =
|
|
4
|
+
const input = jsx("editor", null, jsx("hp", null, jsx("htext", null, "link"), jsx("hlink", {
|
|
5
5
|
uri: "https://link.com"
|
|
6
|
-
})),
|
|
6
|
+
})), jsx("hp", null, jsx("htext", null, "asset"), jsx("hlink", {
|
|
7
7
|
asset: "asset-id"
|
|
8
|
-
})),
|
|
8
|
+
})), jsx("hp", null, jsx("htext", null, "entry"), jsx("hlink", {
|
|
9
9
|
entry: "entry-id"
|
|
10
|
-
})),
|
|
10
|
+
})), jsx("hp", null, jsx("htext", null, "resource"), jsx("hlink", {
|
|
11
11
|
resource: "resource-urn"
|
|
12
|
-
})),
|
|
12
|
+
})), jsx("hp", null, jsx("htext", null, "explicit empty link"), jsx("hlink", {
|
|
13
13
|
uri: "https://link.com"
|
|
14
|
-
}, '')),
|
|
14
|
+
}, '')), jsx("hp", null, jsx("htext", null, "link with empty space"), jsx("hlink", {
|
|
15
15
|
uri: "https://link.com"
|
|
16
16
|
}, " ")));
|
|
17
|
-
const expected =
|
|
17
|
+
const expected = jsx("editor", null, jsx("hp", null, jsx("htext", null, "link")), jsx("hp", null, jsx("htext", null, "asset")), jsx("hp", null, jsx("htext", null, "entry")), jsx("hp", null, jsx("htext", null, "resource")), jsx("hp", null, jsx("htext", null, "explicit empty link")), jsx("hp", null, jsx("htext", null, "link with empty space")));
|
|
18
18
|
assertOutput({
|
|
19
19
|
input,
|
|
20
20
|
expected
|
|
@@ -7,9 +7,9 @@ import { LinkPopover } from './LinkPopover';
|
|
|
7
7
|
import { styles } from './styles';
|
|
8
8
|
import { useHyperlinkCommon } from './useHyperlinkCommon';
|
|
9
9
|
export function EntityHyperlink(props) {
|
|
10
|
-
const { editor, sdk, isLinkFocused, pathToElement
|
|
11
|
-
const { onEntityFetchComplete
|
|
12
|
-
const { target
|
|
10
|
+
const { editor , sdk , isLinkFocused , pathToElement } = useHyperlinkCommon(props.element);
|
|
11
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
12
|
+
const { target } = props.element.data;
|
|
13
13
|
const tooltipContent = useEntityInfo({
|
|
14
14
|
target,
|
|
15
15
|
sdk,
|
|
@@ -18,17 +18,17 @@ export function EntityHyperlink(props) {
|
|
|
18
18
|
if (!target) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
const popoverText =
|
|
21
|
+
const popoverText = React.createElement(Text, {
|
|
22
22
|
fontColor: "blue600",
|
|
23
23
|
fontWeight: "fontWeightMedium",
|
|
24
24
|
className: styles.openLink
|
|
25
25
|
}, tooltipContent);
|
|
26
|
-
return
|
|
26
|
+
return React.createElement(LinkPopover, {
|
|
27
27
|
isLinkFocused: isLinkFocused,
|
|
28
28
|
handleEditLink: ()=>handleEditLink(editor, sdk, pathToElement),
|
|
29
29
|
handleRemoveLink: ()=>handleRemoveLink(editor),
|
|
30
30
|
popoverText: popoverText
|
|
31
|
-
},
|
|
31
|
+
}, React.createElement(Text, {
|
|
32
32
|
testId: "cf-ui-text-link",
|
|
33
33
|
fontColor: "blue600",
|
|
34
34
|
fontWeight: "fontWeightMedium",
|
|
@@ -3,7 +3,7 @@ import { Popover, IconButton, Tooltip, Flex } from '@contentful/f36-components';
|
|
|
3
3
|
import { EditIcon, CopyIcon } from '@contentful/f36-icons';
|
|
4
4
|
import { useFocused } from '../../../internal/hooks';
|
|
5
5
|
import { styles } from './styles';
|
|
6
|
-
export const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handleRemoveLink, children, handleCopyLink
|
|
6
|
+
export const LinkPopover = ({ isLinkFocused , popoverText , handleEditLink , handleRemoveLink , children , handleCopyLink })=>{
|
|
7
7
|
const isEditorFocused = useFocused();
|
|
8
8
|
const popoverContent = React.useRef(null);
|
|
9
9
|
const [isPopoverContentClicked, setIsPopoverContentClicked] = React.useState(false);
|
|
@@ -21,69 +21,65 @@ export const LinkPopover = ({ isLinkFocused, popoverText, handleEditLink, handle
|
|
|
21
21
|
};
|
|
22
22
|
}, []);
|
|
23
23
|
const isOpen = isLinkFocused && isEditorFocused || isPopoverContentClicked;
|
|
24
|
-
|
|
25
|
-
// Otherwise the content of the popover will get copied over when users copy text from the rich text editor
|
|
26
|
-
return(// eslint-disable-next-line jsx-a11y/no-autofocus -- we don't want to autofocus the popover
|
|
27
|
-
/*#__PURE__*/ React.createElement(Popover, {
|
|
24
|
+
return React.createElement(Popover, {
|
|
28
25
|
renderOnlyWhenOpen: false,
|
|
29
26
|
usePortal: true,
|
|
30
27
|
autoFocus: false,
|
|
31
28
|
isOpen: isOpen
|
|
32
|
-
},
|
|
29
|
+
}, React.createElement(Popover.Trigger, null, children), React.createElement(Popover.Content, {
|
|
33
30
|
className: styles.popover
|
|
34
|
-
},
|
|
31
|
+
}, React.createElement(Flex, {
|
|
35
32
|
ref: popoverContent,
|
|
36
33
|
alignItems: "center",
|
|
37
34
|
paddingTop: "spacing2Xs",
|
|
38
35
|
paddingBottom: "spacing2Xs",
|
|
39
36
|
paddingRight: "spacing2Xs",
|
|
40
37
|
paddingLeft: "spacingXs"
|
|
41
|
-
}, popoverText, handleCopyLink &&
|
|
38
|
+
}, popoverText, handleCopyLink && React.createElement(Tooltip, {
|
|
42
39
|
placement: "bottom",
|
|
43
40
|
content: "Copy link",
|
|
44
41
|
usePortal: true
|
|
45
|
-
},
|
|
42
|
+
}, React.createElement(IconButton, {
|
|
46
43
|
className: styles.iconButton,
|
|
47
44
|
onClick: handleCopyLink,
|
|
48
45
|
size: "small",
|
|
49
46
|
variant: "transparent",
|
|
50
47
|
"aria-label": "Copy link",
|
|
51
|
-
icon:
|
|
48
|
+
icon: React.createElement(CopyIcon, {
|
|
52
49
|
size: "tiny"
|
|
53
50
|
})
|
|
54
|
-
})),
|
|
51
|
+
})), React.createElement(Tooltip, {
|
|
55
52
|
placement: "bottom",
|
|
56
53
|
content: "Edit link",
|
|
57
54
|
usePortal: true
|
|
58
|
-
},
|
|
55
|
+
}, React.createElement(IconButton, {
|
|
59
56
|
className: styles.iconButton,
|
|
60
57
|
onClick: handleEditLink,
|
|
61
58
|
size: "small",
|
|
62
59
|
variant: "transparent",
|
|
63
60
|
"aria-label": "Edit link",
|
|
64
|
-
icon:
|
|
61
|
+
icon: React.createElement(EditIcon, {
|
|
65
62
|
size: "tiny"
|
|
66
63
|
})
|
|
67
|
-
})),
|
|
64
|
+
})), React.createElement(Tooltip, {
|
|
68
65
|
placement: "bottom",
|
|
69
66
|
content: "Remove link",
|
|
70
67
|
usePortal: true
|
|
71
|
-
},
|
|
68
|
+
}, React.createElement(IconButton, {
|
|
72
69
|
onClick: handleRemoveLink,
|
|
73
70
|
className: styles.iconButton,
|
|
74
71
|
size: "small",
|
|
75
72
|
variant: "transparent",
|
|
76
73
|
"aria-label": "Remove link",
|
|
77
|
-
icon:
|
|
78
|
-
/*#__PURE__*/ React.createElement("svg", {
|
|
74
|
+
icon: React.createElement("svg", {
|
|
79
75
|
width: "16",
|
|
80
76
|
height: "16",
|
|
81
77
|
viewBox: "0 0 16 16",
|
|
82
78
|
fill: "none",
|
|
83
79
|
xmlns: "http://www.w3.org/2000/svg"
|
|
84
|
-
},
|
|
80
|
+
}, React.createElement("path", {
|
|
85
81
|
d: "M1.75 8C1.75 8.59674 1.98705 9.16903 2.40901 9.59099C2.83097 10.0129 3.40326 10.25 4 10.25H6.5C6.69891 10.25 6.88968 10.329 7.03033 10.4697C7.17098 10.6103 7.25 10.8011 7.25 11C7.25 11.1989 7.17098 11.3897 7.03033 11.5303C6.88968 11.671 6.69891 11.75 6.5 11.75H4C3.00544 11.75 2.05161 11.3549 1.34835 10.6517C0.645088 9.94839 0.25 8.99456 0.25 8C0.25 7.00544 0.645088 6.05161 1.34835 5.34835C2.05161 4.64509 3.00544 4.25 4 4.25H6.5C6.69891 4.25 6.88968 4.32902 7.03033 4.46967C7.17098 4.61032 7.25 4.80109 7.25 5C7.25 5.19891 7.17098 5.38968 7.03033 5.53033C6.88968 5.67098 6.69891 5.75 6.5 5.75H4C3.40326 5.75 2.83097 5.98705 2.40901 6.40901C1.98705 6.83097 1.75 7.40326 1.75 8ZM12 4.25H9.5C9.30109 4.25 9.11032 4.32902 8.96967 4.46967C8.82902 4.61032 8.75 4.80109 8.75 5C8.75 5.19891 8.82902 5.38968 8.96967 5.53033C9.11032 5.67098 9.30109 5.75 9.5 5.75H12C12.5967 5.75 13.169 5.98705 13.591 6.40901C14.0129 6.83097 14.25 7.40326 14.25 8C14.25 8.59674 14.0129 9.16903 13.591 9.59099C13.169 10.0129 12.5967 10.25 12 10.25H9.5C9.30109 10.25 9.11032 10.329 8.96967 10.4697C8.82902 10.6103 8.75 10.8011 8.75 11C8.75 11.1989 8.82902 11.3897 8.96967 11.5303C9.11032 11.671 9.30109 11.75 9.5 11.75H12C12.9946 11.75 13.9484 11.3549 14.6517 10.6517C15.3549 9.94839 15.75 8.99456 15.75 8C15.75 7.00544 15.3549 6.05161 14.6517 5.34835C13.9484 4.64509 12.9946 4.25 12 4.25Z",
|
|
86
82
|
fill: "black"
|
|
87
83
|
}))
|
|
88
|
-
})))))
|
|
84
|
+
})))));
|
|
89
85
|
};
|
|
@@ -7,9 +7,9 @@ import { LinkPopover } from './LinkPopover';
|
|
|
7
7
|
import { styles } from './styles';
|
|
8
8
|
import { useHyperlinkCommon } from './useHyperlinkCommon';
|
|
9
9
|
export function ResourceHyperlink(props) {
|
|
10
|
-
const { editor, sdk, isLinkFocused, pathToElement
|
|
11
|
-
const { onEntityFetchComplete
|
|
12
|
-
const { target
|
|
10
|
+
const { editor , sdk , isLinkFocused , pathToElement } = useHyperlinkCommon(props.element);
|
|
11
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
12
|
+
const { target } = props.element.data;
|
|
13
13
|
const tooltipContent = useResourceEntityInfo({
|
|
14
14
|
target,
|
|
15
15
|
onEntityFetchComplete
|
|
@@ -17,17 +17,17 @@ export function ResourceHyperlink(props) {
|
|
|
17
17
|
if (!target) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
|
-
const popoverText =
|
|
20
|
+
const popoverText = React.createElement(Text, {
|
|
21
21
|
fontColor: "blue600",
|
|
22
22
|
fontWeight: "fontWeightMedium",
|
|
23
23
|
className: styles.openLink
|
|
24
24
|
}, tooltipContent);
|
|
25
|
-
return
|
|
25
|
+
return React.createElement(LinkPopover, {
|
|
26
26
|
isLinkFocused: isLinkFocused,
|
|
27
27
|
handleEditLink: ()=>handleEditLink(editor, sdk, pathToElement),
|
|
28
28
|
handleRemoveLink: ()=>handleRemoveLink(editor),
|
|
29
29
|
popoverText: popoverText
|
|
30
|
-
},
|
|
30
|
+
}, React.createElement(Text, {
|
|
31
31
|
testId: "cf-ui-text-link",
|
|
32
32
|
fontColor: "blue600",
|
|
33
33
|
fontWeight: "fontWeightMedium",
|
|
@@ -19,11 +19,11 @@ export function ToolbarHyperlinkButton(props) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (!editor) return null;
|
|
22
|
-
return
|
|
22
|
+
return React.createElement(ToolbarButton, {
|
|
23
23
|
title: "Hyperlink",
|
|
24
24
|
testId: "hyperlink-toolbar-button",
|
|
25
25
|
onClick: handleClick,
|
|
26
26
|
isActive: isActive,
|
|
27
27
|
isDisabled: props.isDisabled
|
|
28
|
-
},
|
|
28
|
+
}, React.createElement(LinkIcon, null));
|
|
29
29
|
}
|
|
@@ -5,21 +5,21 @@ import { LinkPopover } from './LinkPopover';
|
|
|
5
5
|
import { styles } from './styles';
|
|
6
6
|
import { useHyperlinkCommon } from './useHyperlinkCommon';
|
|
7
7
|
export function UrlHyperlink(props) {
|
|
8
|
-
const { editor, sdk, isLinkFocused, pathToElement
|
|
8
|
+
const { editor , sdk , isLinkFocused , pathToElement } = useHyperlinkCommon(props.element);
|
|
9
9
|
const uri = props.element.data?.uri;
|
|
10
|
-
const popoverText =
|
|
10
|
+
const popoverText = React.createElement(TextLink, {
|
|
11
11
|
className: styles.openLink,
|
|
12
12
|
href: uri,
|
|
13
13
|
rel: "noopener noreferrer",
|
|
14
14
|
target: "_blank"
|
|
15
15
|
}, uri);
|
|
16
|
-
return
|
|
16
|
+
return React.createElement(LinkPopover, {
|
|
17
17
|
isLinkFocused: isLinkFocused,
|
|
18
18
|
handleEditLink: ()=>handleEditLink(editor, sdk, pathToElement),
|
|
19
19
|
handleRemoveLink: ()=>handleRemoveLink(editor),
|
|
20
20
|
handleCopyLink: ()=>handleCopyLink(uri),
|
|
21
21
|
popoverText: popoverText
|
|
22
|
-
},
|
|
22
|
+
}, React.createElement(TextLink, {
|
|
23
23
|
testId: "cf-ui-text-link",
|
|
24
24
|
href: uri,
|
|
25
25
|
onClick: (e)=>e.preventDefault(),
|
|
@@ -12,7 +12,7 @@ const isAnchor = (element)=>element.nodeName === 'A' && !!element.getAttribute('
|
|
|
12
12
|
const isEntryAnchor = (element)=>element.nodeName === 'A' && element.getAttribute('data-link-type') === 'Entry';
|
|
13
13
|
const isAssetAnchor = (element)=>element.nodeName === 'A' && element.getAttribute('data-link-type') === 'Asset';
|
|
14
14
|
const isResourceAnchor = (element)=>element.nodeName === 'A' && element.getAttribute('data-resource-link-type') === 'Contentful:Entry';
|
|
15
|
-
const buildHyperlinkEventHandler = (sdk)=>(editor, { options: { hotkey
|
|
15
|
+
const buildHyperlinkEventHandler = (sdk)=>(editor, { options: { hotkey } })=>{
|
|
16
16
|
return (event)=>{
|
|
17
17
|
if (!editor.selection) {
|
|
18
18
|
return;
|
|
@@ -65,7 +65,6 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
65
65
|
onKeyDown: buildHyperlinkEventHandler(sdk)
|
|
66
66
|
},
|
|
67
67
|
plugins: [
|
|
68
|
-
// URL Hyperlink
|
|
69
68
|
{
|
|
70
69
|
...common,
|
|
71
70
|
key: INLINES.HYPERLINK,
|
|
@@ -83,7 +82,6 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
83
82
|
getNode: getNodeOfType(INLINES.HYPERLINK)
|
|
84
83
|
}
|
|
85
84
|
},
|
|
86
|
-
// Entry Hyperlink
|
|
87
85
|
{
|
|
88
86
|
...common,
|
|
89
87
|
key: INLINES.ENTRY_HYPERLINK,
|
|
@@ -101,7 +99,6 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
101
99
|
getNode: getNodeOfType(INLINES.ENTRY_HYPERLINK)
|
|
102
100
|
}
|
|
103
101
|
},
|
|
104
|
-
// Resource Hyperlink
|
|
105
102
|
{
|
|
106
103
|
...common,
|
|
107
104
|
key: INLINES.RESOURCE_HYPERLINK,
|
|
@@ -119,7 +116,6 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
119
116
|
getNode: getNodeOfType(INLINES.RESOURCE_HYPERLINK)
|
|
120
117
|
}
|
|
121
118
|
},
|
|
122
|
-
// Asset Hyperlink
|
|
123
119
|
{
|
|
124
120
|
...common,
|
|
125
121
|
key: INLINES.ASSET_HYPERLINK,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
3
3
|
import { getEntityInfo } from './utils';
|
|
4
|
-
async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLocaleCode
|
|
4
|
+
async function fetchAllData({ sdk , entityId , entityType , localeCode , defaultLocaleCode }) {
|
|
5
5
|
let contentType;
|
|
6
6
|
const getEntity = entityType === 'Entry' ? sdk.space.getEntry : sdk.space.getAsset;
|
|
7
7
|
const entity = await getEntity(entityId);
|
|
@@ -10,7 +10,6 @@ async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLoca
|
|
|
10
10
|
contentType = sdk.space.getCachedContentTypes().find((ct)=>ct.sys.id === contentTypeId);
|
|
11
11
|
}
|
|
12
12
|
const entityTitle = entityType === 'Entry' ? entityHelpers.getEntryTitle({
|
|
13
|
-
//@ts-expect-error
|
|
14
13
|
entry: entity,
|
|
15
14
|
contentType,
|
|
16
15
|
localeCode,
|
|
@@ -23,14 +22,12 @@ async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLoca
|
|
|
23
22
|
defaultTitle: 'Untitled'
|
|
24
23
|
});
|
|
25
24
|
const entityDescription = entityHelpers.getEntityDescription({
|
|
26
|
-
// @ts-expect-error
|
|
27
25
|
entity,
|
|
28
26
|
contentType,
|
|
29
27
|
localeCode,
|
|
30
28
|
defaultLocaleCode
|
|
31
29
|
});
|
|
32
30
|
const jobs = await sdk.space.getEntityScheduledActions(entityType, entityId);
|
|
33
|
-
// @ts-expect-error
|
|
34
31
|
const entityStatus = entityHelpers.getEntryStatus(entity.sys);
|
|
35
32
|
return {
|
|
36
33
|
jobs,
|
|
@@ -41,7 +38,7 @@ async function fetchAllData({ sdk, entityId, entityType, localeCode, defaultLoca
|
|
|
41
38
|
contentTypeName: contentType ? contentType.name : ''
|
|
42
39
|
};
|
|
43
40
|
}
|
|
44
|
-
function useRequestStatus({ sdk, target, onEntityFetchComplete
|
|
41
|
+
function useRequestStatus({ sdk , target , onEntityFetchComplete }) {
|
|
45
42
|
const [requestStatus, setRequestStatus] = useState({
|
|
46
43
|
type: 'loading'
|
|
47
44
|
});
|
|
@@ -77,7 +74,7 @@ function useRequestStatus({ sdk, target, onEntityFetchComplete }) {
|
|
|
77
74
|
}
|
|
78
75
|
export function useEntityInfo(props) {
|
|
79
76
|
const status = useRequestStatus(props);
|
|
80
|
-
const { linkType
|
|
77
|
+
const { linkType } = props.target.sys;
|
|
81
78
|
if (status.type === 'loading') {
|
|
82
79
|
return `Loading ${linkType.toLowerCase()}...`;
|
|
83
80
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useResource } from '@contentful/field-editor-reference';
|
|
3
3
|
import { truncateTitle } from '../../plugins/shared/utils';
|
|
4
|
-
export function useResourceEntityInfo({ onEntityFetchComplete, target
|
|
5
|
-
const { data, error, status
|
|
4
|
+
export function useResourceEntityInfo({ onEntityFetchComplete , target }) {
|
|
5
|
+
const { data , error , status } = useResource(target.sys.linkType, target.sys.urn);
|
|
6
6
|
React.useEffect(()=>{
|
|
7
7
|
if (status === 'success') {
|
|
8
8
|
onEntityFetchComplete?.();
|
|
@@ -10,7 +10,7 @@ export function getEntityInfo(data) {
|
|
|
10
10
|
if (!data) {
|
|
11
11
|
return '';
|
|
12
12
|
}
|
|
13
|
-
const { entityTitle, contentTypeName, entityStatus, jobs
|
|
13
|
+
const { entityTitle , contentTypeName , entityStatus , jobs } = data;
|
|
14
14
|
const title = truncateTitle(entityTitle, 60) || 'Untitled';
|
|
15
15
|
const scheduledActions = jobs.length > 0 ? getScheduleTooltipContent({
|
|
16
16
|
job: jobs[0],
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
import { assertOutput, jsx } from '../../../test-utils';
|
|
2
2
|
describe('normalization', ()=>{
|
|
3
3
|
it('wraps orphaned list items in a list', ()=>{
|
|
4
|
-
const input =
|
|
5
|
-
const expected =
|
|
4
|
+
const input = jsx("editor", null, jsx("hli", null, jsx("hp", null, "Item")), jsx("hp", null));
|
|
5
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"))), jsx("hp", null, jsx("htext", null)));
|
|
6
6
|
assertOutput({
|
|
7
7
|
input,
|
|
8
8
|
expected
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
it('adds empty paragraph to empty list items', ()=>{
|
|
12
|
-
const input =
|
|
13
|
-
const expected =
|
|
12
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null)), jsx("hp", null));
|
|
13
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("htext", null)))), jsx("hp", null, jsx("htext", null)));
|
|
14
14
|
assertOutput({
|
|
15
15
|
input,
|
|
16
16
|
expected
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
it('replaces invalid list items with text', ()=>{
|
|
20
|
-
const input =
|
|
20
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"), jsx("htd", null, jsx("hp", null, jsx("htext", {
|
|
21
21
|
bold: true
|
|
22
|
-
}, "bold text"))),
|
|
22
|
+
}, "bold text"))), jsx("htd", null, jsx("hp", null, "Take a look at this ", jsx("hlink", {
|
|
23
23
|
uri: "https://google.com"
|
|
24
|
-
}, "link"))))),
|
|
25
|
-
const expected =
|
|
24
|
+
}, "link"))))), jsx("hp", null));
|
|
25
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"), jsx("hp", null, jsx("htext", {
|
|
26
26
|
bold: true
|
|
27
|
-
}, "bold text")),
|
|
27
|
+
}, "bold text")), jsx("hp", null, "Take a look at this ", jsx("hlink", {
|
|
28
28
|
uri: "https://google.com"
|
|
29
|
-
}, "link"),
|
|
29
|
+
}, "link"), jsx("htext", null)))), jsx("hp", null, jsx("htext", null)));
|
|
30
30
|
assertOutput({
|
|
31
31
|
input,
|
|
32
32
|
expected
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
it('replaces list items with nested lists as a first child', ()=>{
|
|
36
|
-
const input =
|
|
37
|
-
const expected =
|
|
36
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1.1")))), jsx("hli", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.2"))))), jsx("hp", null, jsx("htext", null)));
|
|
37
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.2"))), jsx("hp", null, jsx("htext", null)));
|
|
38
38
|
assertOutput({
|
|
39
39
|
input,
|
|
40
40
|
expected
|
|
@@ -1,72 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx, assertOutput, createTestEditor } from '../../../test-utils';
|
|
2
2
|
describe('insert line break', ()=>{
|
|
3
3
|
const tests = [
|
|
4
|
-
// single p
|
|
5
4
|
{
|
|
6
5
|
title: 'at the start of a li',
|
|
7
|
-
input:
|
|
8
|
-
expected:
|
|
6
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1"))),
|
|
7
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hp", null, "p1")))
|
|
9
8
|
},
|
|
10
9
|
{
|
|
11
10
|
title: 'at the end of a li',
|
|
12
|
-
input:
|
|
13
|
-
expected:
|
|
11
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1", jsx("cursor", null)))),
|
|
12
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
14
13
|
},
|
|
15
14
|
{
|
|
16
15
|
title: 'at the middle of a li',
|
|
17
|
-
input:
|
|
18
|
-
expected:
|
|
16
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ", jsx("cursor", null), "me"))),
|
|
17
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ")), jsx("hli", null, jsx("hp", null, jsx("cursor", null), "me")))
|
|
19
18
|
},
|
|
20
|
-
// multi p
|
|
21
19
|
{
|
|
22
20
|
title: 'at the start of a li with multiple p',
|
|
23
|
-
input:
|
|
24
|
-
expected:
|
|
21
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1"), jsx("hp", null, "p2"))),
|
|
22
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2")))
|
|
25
23
|
},
|
|
26
24
|
{
|
|
27
25
|
title: 'at the start of the second p of a li',
|
|
28
|
-
input:
|
|
29
|
-
expected:
|
|
26
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, jsx("cursor", null), "p2"))),
|
|
27
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null)), jsx("hp", null, "p2")))
|
|
30
28
|
},
|
|
31
29
|
{
|
|
32
30
|
title: 'at the end of a li with multiple p',
|
|
33
|
-
input:
|
|
34
|
-
expected:
|
|
31
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2", jsx("cursor", null)))),
|
|
32
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
35
33
|
},
|
|
36
34
|
{
|
|
37
35
|
title: 'at the middle of a li with multiple p',
|
|
38
|
-
input:
|
|
39
|
-
expected:
|
|
36
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ", jsx("cursor", null), "me"), jsx("hp", null, "move me"))),
|
|
37
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ")), jsx("hli", null, jsx("hp", null, jsx("cursor", null), "me"), jsx("hp", null, "move me")))
|
|
40
38
|
},
|
|
41
|
-
// with headings
|
|
42
39
|
{
|
|
43
40
|
title: 'at the start of a li with heading',
|
|
44
|
-
input:
|
|
45
|
-
expected:
|
|
41
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, jsx("cursor", null), "p1"))),
|
|
42
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hh1", null, "p1")))
|
|
46
43
|
},
|
|
47
44
|
{
|
|
48
45
|
title: 'at the end of a li with heading',
|
|
49
|
-
input:
|
|
50
|
-
expected:
|
|
46
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "p1", jsx("cursor", null)))),
|
|
47
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
51
48
|
},
|
|
52
49
|
{
|
|
53
50
|
title: 'at the middle of a li with heading',
|
|
54
|
-
input:
|
|
55
|
-
expected:
|
|
51
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "split ", jsx("cursor", null), "me"))),
|
|
52
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "split ")), jsx("hli", null, jsx("hh1", null, jsx("cursor", null), "me")))
|
|
56
53
|
},
|
|
57
54
|
{
|
|
58
55
|
title: 'at a li with nested list',
|
|
59
|
-
input:
|
|
60
|
-
expected:
|
|
56
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "item 1")), jsx("hli", null, jsx("hp", null, "item 2", jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "sub list"))))),
|
|
57
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "item 1")), jsx("hli", null, jsx("hp", null, "item 2")), jsx("hli", null, jsx("hp", null, jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "sub list")))))
|
|
61
58
|
}
|
|
62
59
|
];
|
|
63
|
-
const render = (children)
|
|
60
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
64
61
|
for (const t of tests){
|
|
65
62
|
test(t.title, ()=>{
|
|
66
|
-
const { editor
|
|
63
|
+
const { editor } = createTestEditor({
|
|
67
64
|
input: render(t.input)
|
|
68
65
|
});
|
|
69
|
-
// Equivalent of pressing ENTER
|
|
70
66
|
editor.insertBreak();
|
|
71
67
|
assertOutput({
|
|
72
68
|
editor,
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx, assertOutput, createTestEditor } from '../../../test-utils';
|
|
2
2
|
describe('insert fragment', ()=>{
|
|
3
3
|
const tests = [
|
|
4
4
|
{
|
|
5
5
|
title: 'text wrapped in li > p',
|
|
6
|
-
input:
|
|
7
|
-
fragment:
|
|
8
|
-
expected:
|
|
6
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
7
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hp", null, "world"))),
|
|
8
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world")))
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
title: 'text wrapped in li > h*',
|
|
12
|
-
input:
|
|
13
|
-
fragment:
|
|
14
|
-
expected:
|
|
12
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
13
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hh1", null, "world"))),
|
|
14
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world")))
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
title: 'single li with only asset card',
|
|
18
|
-
input:
|
|
19
|
-
fragment:
|
|
18
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello", jsx("cursor", null), "world"))),
|
|
19
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hembed", {
|
|
20
20
|
type: "Asset",
|
|
21
21
|
id: "asset-id"
|
|
22
22
|
}))),
|
|
23
|
-
expected:
|
|
23
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello"), jsx("hembed", {
|
|
24
24
|
type: "Asset",
|
|
25
25
|
id: "asset-id"
|
|
26
|
-
}),
|
|
26
|
+
}), jsx("hp", null, "world")))
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
title: 'two paragraphs',
|
|
30
|
-
input:
|
|
31
|
-
fragment:
|
|
32
|
-
expected:
|
|
30
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
31
|
+
fragment: jsx("fragment", null, jsx("hp", null, "world"), jsx("hp", null, "line 2")),
|
|
32
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world"), jsx("hp", null, "line 2")))
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
35
|
title: 'two headings',
|
|
36
|
-
input:
|
|
37
|
-
fragment:
|
|
38
|
-
expected:
|
|
36
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
37
|
+
fragment: jsx("fragment", null, jsx("hh1", null, "world"), jsx("hh1", null, "line 2")),
|
|
38
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world"), jsx("hh1", null, "line 2")))
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
title: 'two paragraphs wrapped in a li',
|
|
42
|
-
input:
|
|
43
|
-
fragment:
|
|
44
|
-
expected:
|
|
42
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
43
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hp", null, "world"), jsx("hp", null, "line 2"))),
|
|
44
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello "), jsx("hul", null, jsx("hli", null, jsx("hp", null, "world"), jsx("hp", null, "line 2")))))
|
|
45
45
|
}
|
|
46
46
|
];
|
|
47
|
-
const render = (children)
|
|
47
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
48
48
|
for (const t of tests){
|
|
49
49
|
test(t.title, ()=>{
|
|
50
|
-
const { editor
|
|
50
|
+
const { editor } = createTestEditor({
|
|
51
51
|
input: render(t.input)
|
|
52
52
|
});
|
|
53
53
|
editor.insertFragment(t.fragment);
|