@contentful/field-editor-rich-text 3.14.3 → 3.15.1
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 +17 -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 +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 +7 -5
- package/dist/cjs/plugins/Hyperlink/utils.js +6 -14
- 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 +20 -3
- 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 +13 -11
- 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 +3 -3
- package/dist/esm/plugins/Hyperlink/utils.js +2 -7
- 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 +9 -0
- 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/dist/types/plugins/Hyperlink/utils.d.ts +0 -1
- package/dist/types/plugins/shared/utils.d.ts +1 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "CommandList", {
|
|
|
8
8
|
return CommandList;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _reactpopper = require("react-popper");
|
|
13
13
|
const _f36components = require("@contentful/f36-components");
|
|
14
14
|
const _f36utils = require("@contentful/f36-utils");
|
|
@@ -16,7 +16,7 @@ const _emotion = require("emotion");
|
|
|
16
16
|
const _SdkProvider = require("../../../SdkProvider");
|
|
17
17
|
const _useCommandList = require("../hooks/useCommandList");
|
|
18
18
|
const _useCommands = require("../useCommands");
|
|
19
|
-
const _CommandListstyles = _interop_require_default(require("./CommandList.styles"));
|
|
19
|
+
const _CommandListstyles = /*#__PURE__*/ _interop_require_default(require("./CommandList.styles"));
|
|
20
20
|
function _interop_require_default(obj) {
|
|
21
21
|
return obj && obj.__esModule ? obj : {
|
|
22
22
|
default: obj
|
|
@@ -43,7 +43,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
43
43
|
if (cache && cache.has(obj)) {
|
|
44
44
|
return cache.get(obj);
|
|
45
45
|
}
|
|
46
|
-
var newObj = {
|
|
46
|
+
var newObj = {
|
|
47
|
+
__proto__: null
|
|
48
|
+
};
|
|
47
49
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
48
50
|
for(var key in obj){
|
|
49
51
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -61,47 +63,47 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
61
63
|
}
|
|
62
64
|
return newObj;
|
|
63
65
|
}
|
|
64
|
-
const Group = ({ commandGroup
|
|
66
|
+
const Group = ({ commandGroup, selectedItem })=>/*#__PURE__*/ _react.createElement("section", {
|
|
65
67
|
key: commandGroup.group
|
|
66
|
-
}, _react.createElement(_f36components.SectionHeading, {
|
|
68
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.SectionHeading, {
|
|
67
69
|
as: "h3",
|
|
68
70
|
marginBottom: "spacingS",
|
|
69
71
|
marginTop: "spacingS",
|
|
70
72
|
marginLeft: "spacingM",
|
|
71
73
|
marginRight: "spacingM"
|
|
72
|
-
}, commandGroup.group), commandGroup.commands.map((command)
|
|
74
|
+
}, commandGroup.group), commandGroup.commands.map((command)=>/*#__PURE__*/ _react.createElement("button", {
|
|
73
75
|
key: command.id,
|
|
74
76
|
id: command.id,
|
|
75
77
|
className: (0, _emotion.cx)(_CommandListstyles.default.menuItem, {
|
|
76
78
|
[_CommandListstyles.default.menuItemSelected]: command.id === selectedItem
|
|
77
79
|
}),
|
|
78
80
|
onClick: command.callback
|
|
79
|
-
}, command.label)), _react.createElement("hr", {
|
|
81
|
+
}, command.label)), /*#__PURE__*/ _react.createElement("hr", {
|
|
80
82
|
className: _CommandListstyles.default.menuDivider,
|
|
81
83
|
"aria-orientation": "horizontal"
|
|
82
84
|
}));
|
|
83
|
-
const Asset = ({ command
|
|
85
|
+
const Asset = ({ command, selectedItem })=>/*#__PURE__*/ _react.createElement("button", {
|
|
84
86
|
key: command.id,
|
|
85
87
|
id: command.id,
|
|
86
88
|
className: (0, _emotion.cx)(_CommandListstyles.default.menuItem, {
|
|
87
89
|
[_CommandListstyles.default.menuItemSelected]: command.id === selectedItem
|
|
88
90
|
}),
|
|
89
91
|
onClick: command.callback
|
|
90
|
-
}, _react.createElement(_f36components.Flex, {
|
|
92
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Flex, {
|
|
91
93
|
alignItems: "center",
|
|
92
94
|
gap: "spacingS"
|
|
93
|
-
}, command.thumbnail ? _react.createElement("img", {
|
|
95
|
+
}, command.thumbnail ? /*#__PURE__*/ _react.createElement("img", {
|
|
94
96
|
width: "30",
|
|
95
97
|
height: "30",
|
|
96
98
|
src: command.thumbnail,
|
|
97
99
|
alt: "",
|
|
98
100
|
className: _CommandListstyles.default.thumbnail
|
|
99
|
-
}) : _react.createElement(_f36components.AssetIcon, {
|
|
101
|
+
}) : /*#__PURE__*/ _react.createElement(_f36components.AssetIcon, {
|
|
100
102
|
width: "30",
|
|
101
103
|
height: "30",
|
|
102
104
|
className: _CommandListstyles.default.thumbnail
|
|
103
|
-
}), _react.createElement("span", null, command.label)));
|
|
104
|
-
const Item = ({ command
|
|
105
|
+
}), /*#__PURE__*/ _react.createElement("span", null, command.label)));
|
|
106
|
+
const Item = ({ command, selectedItem })=>/*#__PURE__*/ _react.createElement("button", {
|
|
105
107
|
key: command.id,
|
|
106
108
|
id: command.id,
|
|
107
109
|
className: (0, _emotion.cx)(_CommandListstyles.default.menuItem, {
|
|
@@ -109,70 +111,70 @@ const Item = ({ command , selectedItem })=>_react.createElement("button", {
|
|
|
109
111
|
}),
|
|
110
112
|
onClick: command.callback
|
|
111
113
|
}, command.label);
|
|
112
|
-
const CommandListItems = ({ commandItems
|
|
113
|
-
return _react.createElement(_react.Fragment, null, commandItems.map((command)=>{
|
|
114
|
-
return 'group' in command ? _react.createElement(Group, {
|
|
114
|
+
const CommandListItems = ({ commandItems, selectedItem })=>{
|
|
115
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, commandItems.map((command)=>{
|
|
116
|
+
return 'group' in command ? /*#__PURE__*/ _react.createElement(Group, {
|
|
115
117
|
key: command.group,
|
|
116
118
|
commandGroup: command,
|
|
117
119
|
selectedItem: selectedItem
|
|
118
|
-
}) : command.asset ? _react.createElement(Asset, {
|
|
120
|
+
}) : command.asset ? /*#__PURE__*/ _react.createElement(Asset, {
|
|
119
121
|
key: command.id,
|
|
120
122
|
command: command,
|
|
121
123
|
selectedItem: selectedItem
|
|
122
|
-
}) : _react.createElement(Item, {
|
|
124
|
+
}) : /*#__PURE__*/ _react.createElement(Item, {
|
|
123
125
|
key: command.id,
|
|
124
126
|
command: command,
|
|
125
127
|
selectedItem: selectedItem
|
|
126
128
|
});
|
|
127
129
|
}));
|
|
128
130
|
};
|
|
129
|
-
const CommandList = ({ query
|
|
131
|
+
const CommandList = ({ query, editor, textContainer })=>{
|
|
130
132
|
const sdk = (0, _SdkProvider.useSdkContext)();
|
|
131
133
|
const popoverContainer = _react.useRef(null);
|
|
132
134
|
const popper = (0, _reactpopper.usePopper)(textContainer, popoverContainer?.current, {
|
|
133
135
|
placement: 'bottom-start'
|
|
134
136
|
});
|
|
135
137
|
const commandItems = (0, _useCommands.useCommands)(sdk, query, editor);
|
|
136
|
-
const { selectedItem
|
|
138
|
+
const { selectedItem, isOpen } = (0, _useCommandList.useCommandList)(commandItems, popoverContainer);
|
|
137
139
|
if (!commandItems.length) {
|
|
138
140
|
return null;
|
|
139
141
|
}
|
|
140
|
-
return _react.createElement("div", {
|
|
142
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
141
143
|
className: _CommandListstyles.default.container,
|
|
142
144
|
tabIndex: -1,
|
|
143
145
|
contentEditable: false
|
|
144
|
-
}, _react.createElement("div", {
|
|
146
|
+
}, /*#__PURE__*/ _react.createElement("div", {
|
|
145
147
|
role: "alert"
|
|
146
|
-
}, _react.createElement(_f36components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", _react.createElement("kbd", null, "enter"), " to select, ", _react.createElement("kbd", null, "arrows"), " to navigate, ", _react.createElement("kbd", null, "escape"), " to close.")), _react.createElement(_f36utils.Portal, null, _react.createElement("div", {
|
|
148
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.ScreenReaderOnly, null, "Richtext commands. Currently focused item: ", selectedItem, ". Press ", /*#__PURE__*/ _react.createElement("kbd", null, "enter"), " to select, ", /*#__PURE__*/ _react.createElement("kbd", null, "arrows"), " to navigate, ", /*#__PURE__*/ _react.createElement("kbd", null, "escape"), " to close.")), /*#__PURE__*/ _react.createElement(_f36utils.Portal, null, /*#__PURE__*/ _react.createElement("div", {
|
|
147
149
|
"aria-hidden": true,
|
|
148
150
|
ref: popoverContainer,
|
|
149
151
|
className: _CommandListstyles.default.menuPoper,
|
|
150
152
|
style: popper.styles.popper,
|
|
151
153
|
...popper.attributes.popper
|
|
152
|
-
}, _react.createElement(_f36components.Popover, {
|
|
154
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Popover, {
|
|
153
155
|
isOpen: isOpen,
|
|
154
156
|
usePortal: false,
|
|
155
|
-
autoFocus: false
|
|
156
|
-
}, _react.createElement(_f36components.Popover.Trigger, null, _react.createElement("span", null)), _react.createElement(_f36components.Popover.Content, {
|
|
157
|
+
/* eslint-disable-next-line jsx-a11y/no-autofocus -- we want to keep focus on text input*/ autoFocus: false
|
|
158
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Popover.Trigger, null, /*#__PURE__*/ _react.createElement("span", null)), /*#__PURE__*/ _react.createElement(_f36components.Popover.Content, {
|
|
157
159
|
className: _CommandListstyles.default.menuContent,
|
|
158
160
|
testId: "rich-text-commands"
|
|
159
|
-
}, _react.createElement("header", {
|
|
161
|
+
}, /*#__PURE__*/ _react.createElement("header", {
|
|
160
162
|
className: _CommandListstyles.default.menuHeader
|
|
161
|
-
}, _react.createElement(_f36components.SectionHeading, {
|
|
163
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.SectionHeading, {
|
|
162
164
|
marginBottom: "none"
|
|
163
|
-
}, "Richtext commands")), _react.createElement("div", {
|
|
165
|
+
}, "Richtext commands")), /*#__PURE__*/ _react.createElement("div", {
|
|
164
166
|
className: _CommandListstyles.default.menuList,
|
|
165
167
|
"data-test-id": "rich-text-commands-list"
|
|
166
|
-
}, _react.createElement(CommandListItems, {
|
|
168
|
+
}, /*#__PURE__*/ _react.createElement(CommandListItems, {
|
|
167
169
|
commandItems: commandItems,
|
|
168
170
|
selectedItem: selectedItem
|
|
169
|
-
})), _react.createElement("footer", {
|
|
171
|
+
})), /*#__PURE__*/ _react.createElement("footer", {
|
|
170
172
|
className: _CommandListstyles.default.menuFooter
|
|
171
|
-
}, _react.createElement(_f36components.Stack, {
|
|
173
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Stack, {
|
|
172
174
|
as: "ul",
|
|
173
175
|
margin: "none",
|
|
174
176
|
padding: "none",
|
|
175
177
|
spacing: "spacingS",
|
|
176
178
|
className: _CommandListstyles.default.footerList
|
|
177
|
-
}, _react.createElement("li", null, _react.createElement("kbd", null, "↑"), _react.createElement("kbd", null, "↓"), " to navigate"), _react.createElement("li", null, _react.createElement("kbd", null, "↵"), " to confirm"), _react.createElement("li", null, _react.createElement("kbd", null, "esc"), " to close"))))))));
|
|
179
|
+
}, /*#__PURE__*/ _react.createElement("li", null, /*#__PURE__*/ _react.createElement("kbd", null, "↑"), /*#__PURE__*/ _react.createElement("kbd", null, "↓"), " to navigate"), /*#__PURE__*/ _react.createElement("li", null, /*#__PURE__*/ _react.createElement("kbd", null, "↵"), " to confirm"), /*#__PURE__*/ _react.createElement("li", null, /*#__PURE__*/ _react.createElement("kbd", null, "esc"), " to close"))))))));
|
|
178
180
|
};
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return _default;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
11
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
12
12
|
const _emotion = require("emotion");
|
|
13
13
|
function _interop_require_default(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "CommandPrompt", {
|
|
|
8
8
|
return CommandPrompt;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
13
|
const _emotion = require("emotion");
|
|
14
14
|
const _trimLeadingSlash = require("../utils/trimLeadingSlash");
|
|
15
15
|
const _CommandList = require("./CommandList");
|
|
@@ -39,7 +39,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
39
39
|
if (cache && cache.has(obj)) {
|
|
40
40
|
return cache.get(obj);
|
|
41
41
|
}
|
|
42
|
-
var newObj = {
|
|
42
|
+
var newObj = {
|
|
43
|
+
__proto__: null
|
|
44
|
+
};
|
|
43
45
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
46
|
for(var key in obj){
|
|
45
47
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -68,13 +70,13 @@ const CommandPrompt = (props)=>{
|
|
|
68
70
|
]);
|
|
69
71
|
const editor = props.editor;
|
|
70
72
|
const [textElement, setTextElement] = _react.useState();
|
|
71
|
-
return _react.createElement("span", {
|
|
73
|
+
return /*#__PURE__*/ _react.createElement("span", {
|
|
72
74
|
className: styles.commandPrompt,
|
|
73
75
|
ref: (e)=>{
|
|
74
76
|
setTextElement(e);
|
|
75
77
|
},
|
|
76
78
|
...props.attributes
|
|
77
|
-
}, props.children, _react.createElement(_CommandList.CommandList, {
|
|
79
|
+
}, props.children, /*#__PURE__*/ _react.createElement(_CommandList.CommandList, {
|
|
78
80
|
query: query,
|
|
79
81
|
editor: editor,
|
|
80
82
|
textContainer: textElement
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "useCommandList", {
|
|
|
8
8
|
return useCommandList;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
-
const _ishotkey = _interop_require_default(require("is-hotkey"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
+
const _ishotkey = /*#__PURE__*/ _interop_require_default(require("is-hotkey"));
|
|
13
13
|
function _interop_require_default(obj) {
|
|
14
14
|
return obj && obj.__esModule ? obj : {
|
|
15
15
|
default: obj
|
|
@@ -36,7 +36,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
36
36
|
if (cache && cache.has(obj)) {
|
|
37
37
|
return cache.get(obj);
|
|
38
38
|
}
|
|
39
|
-
var newObj = {
|
|
39
|
+
var newObj = {
|
|
40
|
+
__proto__: null
|
|
41
|
+
};
|
|
40
42
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
43
|
for(var key in obj){
|
|
42
44
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -56,6 +58,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
56
58
|
}
|
|
57
59
|
const useCommandList = (commandItems, container)=>{
|
|
58
60
|
const [selectedItem, setSelectedItem] = _react.useState(()=>{
|
|
61
|
+
// select the first item on initial render
|
|
59
62
|
if (!commandItems.length) {
|
|
60
63
|
return '';
|
|
61
64
|
}
|
|
@@ -108,6 +111,7 @@ const useCommandList = (commandItems, container)=>{
|
|
|
108
111
|
currBtn.click();
|
|
109
112
|
}
|
|
110
113
|
}
|
|
114
|
+
//TODO: handle shift+enter, which must be detected using separate events
|
|
111
115
|
}
|
|
112
116
|
if (commandItems.length) {
|
|
113
117
|
window.addEventListener('keydown', handleKeyDown);
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "createOnKeyDown", {
|
|
|
8
8
|
return createOnKeyDown;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _ishotkey = _interop_require_default(require("is-hotkey"));
|
|
11
|
+
const _ishotkey = /*#__PURE__*/ _interop_require_default(require("is-hotkey"));
|
|
12
12
|
const _internal = require("../../internal");
|
|
13
13
|
const _misc = require("../../internal/misc");
|
|
14
14
|
const _constants = require("./constants");
|
|
@@ -20,6 +20,10 @@ function _interop_require_default(obj) {
|
|
|
20
20
|
const createOnKeyDown = ()=>{
|
|
21
21
|
return (editor)=>{
|
|
22
22
|
return (event)=>{
|
|
23
|
+
// Support for different keyboard layouts:
|
|
24
|
+
// `isHotKey` uses by default `event.which`, which will never generates a match for all layouts (QWERTY: `/`, QWERTZ: `shift+7`)
|
|
25
|
+
// with `byKey: true` `isHotKey` uses `event.key` which will return the interpreted key '/'
|
|
26
|
+
// It would still fail without the the optional `shift?` param, as it first checks the modKeys (`shiftKey` would be true on QWERTZ)
|
|
23
27
|
if ((0, _ishotkey.default)('shift?+/', {
|
|
24
28
|
byKey: true
|
|
25
29
|
}, event)) {
|
|
@@ -36,6 +40,7 @@ const createOnKeyDown = ()=>{
|
|
|
36
40
|
const [, path] = (0, _internal.getAboveNode)(editor);
|
|
37
41
|
const range = (0, _internal.getRange)(editor, path);
|
|
38
42
|
if ((0, _ishotkey.default)('backspace', event)) {
|
|
43
|
+
// if it is the last character in the command string
|
|
39
44
|
if (range.focus.offset - range.anchor.offset === 1) {
|
|
40
45
|
(0, _internal.removeMark)(editor, _constants.COMMAND_PROMPT, range);
|
|
41
46
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
const _transforms = _interop_require_wildcard(require("../../internal/transforms"));
|
|
5
|
+
const _transforms = /*#__PURE__*/ _interop_require_wildcard(require("../../internal/transforms"));
|
|
6
6
|
const _testutils = require("../../test-utils");
|
|
7
7
|
const _constants = require("./constants");
|
|
8
8
|
const _onKeyDown = require("./onKeyDown");
|
|
@@ -27,7 +27,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
27
27
|
if (cache && cache.has(obj)) {
|
|
28
28
|
return cache.get(obj);
|
|
29
29
|
}
|
|
30
|
-
var newObj = {
|
|
30
|
+
var newObj = {
|
|
31
|
+
__proto__: null
|
|
32
|
+
};
|
|
31
33
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
32
34
|
for(var key in obj){
|
|
33
35
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -52,7 +54,7 @@ jest.mock('../../internal/transforms', ()=>{
|
|
|
52
54
|
};
|
|
53
55
|
});
|
|
54
56
|
describe('onKeyDown', ()=>{
|
|
55
|
-
const { editor
|
|
57
|
+
const { editor } = (0, _testutils.createTestEditor)({});
|
|
56
58
|
const addMark = jest.spyOn(_transforms, 'addMark');
|
|
57
59
|
const onCommandPaletteAction = jest.spyOn(editor.tracking, 'onCommandPaletteAction');
|
|
58
60
|
afterEach(()=>{
|
|
@@ -70,7 +72,7 @@ describe('onKeyDown', ()=>{
|
|
|
70
72
|
which: 55,
|
|
71
73
|
shiftKey: true
|
|
72
74
|
}}
|
|
73
|
-
`('supports hotKeys for every keyboard layout #{layout}', ({ key
|
|
75
|
+
`('supports hotKeys for every keyboard layout #{layout}', ({ key })=>{
|
|
74
76
|
(0, _onKeyDown.createOnKeyDown)()(editor, {})({
|
|
75
77
|
type: 'keydown',
|
|
76
78
|
...key
|
|
@@ -57,7 +57,7 @@ function isCommandPromptPluginEnabled(sdk) {
|
|
|
57
57
|
}
|
|
58
58
|
function getCommandPermissions(sdk, editor) {
|
|
59
59
|
const canInsertBlocks = !(0, _editor.isNodeTypeSelected)(editor, _richtexttypes.BLOCKS.TABLE);
|
|
60
|
-
const { inlineAllowed
|
|
60
|
+
const { inlineAllowed, entriesAllowed, assetsAllowed } = isCommandPromptPluginEnabled(sdk);
|
|
61
61
|
return {
|
|
62
62
|
inlineAllowed,
|
|
63
63
|
entriesAllowed: entriesAllowed && canInsertBlocks,
|
|
@@ -86,7 +86,7 @@ const getAllowedContentTypesFromValidation = (validations)=>{
|
|
|
86
86
|
};
|
|
87
87
|
const useCommands = (sdk, query, editor)=>{
|
|
88
88
|
const contentTypes = sdk.space.getCachedContentTypes();
|
|
89
|
-
const { inlineAllowed
|
|
89
|
+
const { inlineAllowed, entriesAllowed, assetsAllowed } = getCommandPermissions(sdk, editor);
|
|
90
90
|
const allowedContentTypesFromValidation = getAllowedContentTypesFromValidation(sdk.field.validations);
|
|
91
91
|
const filterContentTypesByValidation = (type)=>contentTypes.filter((contentType)=>allowedContentTypesFromValidation[type]?.[contentType.sys.id]);
|
|
92
92
|
const filteredBlockContentTypes = filterContentTypesByValidation(_richtexttypes.BLOCKS.EMBEDDED_ENTRY);
|
|
@@ -235,7 +235,7 @@ const useCommands = (sdk, query, editor)=>{
|
|
|
235
235
|
}
|
|
236
236
|
return contentTypeCommands;
|
|
237
237
|
});
|
|
238
|
-
return query ? commands.reduce((list, nextItem)=>{
|
|
238
|
+
/* filter both commands and groups of commands with the user typed query */ return query ? commands.reduce((list, nextItem)=>{
|
|
239
239
|
if ('group' in nextItem) {
|
|
240
240
|
const subcommands = nextItem.commands.filter((command)=>{
|
|
241
241
|
return command.label.toLowerCase().includes(query.toLowerCase());
|
|
@@ -17,11 +17,13 @@ async function fetchEntries(sdk, contentType, query) {
|
|
|
17
17
|
return entries.items.map((entry)=>{
|
|
18
18
|
const description = _fieldeditorshared.entityHelpers.getEntityDescription({
|
|
19
19
|
contentType,
|
|
20
|
+
// @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
|
|
20
21
|
entity: entry,
|
|
21
22
|
localeCode: sdk.field.locale,
|
|
22
23
|
defaultLocaleCode: sdk.locales.default
|
|
23
24
|
});
|
|
24
25
|
const displayTitle = _fieldeditorshared.entityHelpers.getEntryTitle({
|
|
26
|
+
// @ts-expect-error inconsistent in typing between app-sdk & field-editors-shared
|
|
25
27
|
entry,
|
|
26
28
|
contentType,
|
|
27
29
|
localeCode: sdk.field.locale,
|
|
@@ -19,7 +19,11 @@ function createDragAndDropPlugin() {
|
|
|
19
19
|
_richtexttypes.INLINES.EMBEDDED_ENTRY,
|
|
20
20
|
_richtexttypes.INLINES.EMBEDDED_RESOURCE
|
|
21
21
|
];
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* HTML node names where dropping should be allowed
|
|
24
|
+
* Usually for elements where `Transforms.removeNodes` is needed
|
|
25
|
+
* TODO: looking up for html nodes is not the best solution and it won't scale but it works fine for our current cases/elements
|
|
26
|
+
*/ const ON_DROP_ALLOWED_TYPES = {
|
|
23
27
|
TABLE: [
|
|
24
28
|
_richtexttypes.INLINES.EMBEDDED_ENTRY,
|
|
25
29
|
_richtexttypes.INLINES.EMBEDDED_RESOURCE
|
|
@@ -28,6 +32,7 @@ function createDragAndDropPlugin() {
|
|
|
28
32
|
return {
|
|
29
33
|
key: 'DragAndDropPlugin',
|
|
30
34
|
handlers: {
|
|
35
|
+
// If true, the next handlers will be skipped.
|
|
31
36
|
onDrop: (editor)=>(event)=>{
|
|
32
37
|
const [draggingBlock] = Array.from((0, _queries.getNodeEntries)(editor, {
|
|
33
38
|
match: (node)=>DRAGGABLE_TYPES.includes(node.type)
|
|
@@ -35,10 +40,13 @@ function createDragAndDropPlugin() {
|
|
|
35
40
|
if (!draggingBlock) return false;
|
|
36
41
|
const [draggingNode] = draggingBlock;
|
|
37
42
|
if (!event.nativeEvent.target) return false;
|
|
43
|
+
// TODO: looking up for html nodes is not the best solution and it won't scale, we need to find a way to know the dropping target slate element
|
|
38
44
|
const dropDisallowed = getParents(event.nativeEvent.target).some((node)=>{
|
|
39
45
|
return ON_DROP_ALLOWED_TYPES[node.nodeName] ? !ON_DROP_ALLOWED_TYPES[node.nodeName]?.includes(draggingNode.type) : false;
|
|
40
46
|
});
|
|
41
47
|
if (!dropDisallowed) {
|
|
48
|
+
// Move the drop event to a new undo batch mitigating the bug where undo not only moves it back,
|
|
49
|
+
// but also undoes a previous action: https://github.com/ianstormtaylor/slate/issues/4694
|
|
42
50
|
editor.history.undos.push([]);
|
|
43
51
|
}
|
|
44
52
|
return dropDisallowed;
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "LinkedEntityBlock", {
|
|
|
8
8
|
return LinkedEntityBlock;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _slatereact = require("slate-react");
|
|
13
13
|
const _ContentfulEditorProvider = require("../../ContentfulEditorProvider");
|
|
14
14
|
const _queries = require("../../internal/queries");
|
|
@@ -39,7 +39,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
39
39
|
if (cache && cache.has(obj)) {
|
|
40
40
|
return cache.get(obj);
|
|
41
41
|
}
|
|
42
|
-
var newObj = {
|
|
42
|
+
var newObj = {
|
|
43
|
+
__proto__: null
|
|
44
|
+
};
|
|
43
45
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
44
46
|
for(var key in obj){
|
|
45
47
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -58,13 +60,13 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
58
60
|
return newObj;
|
|
59
61
|
}
|
|
60
62
|
function LinkedEntityBlock(props) {
|
|
61
|
-
const { attributes
|
|
62
|
-
const { onEntityFetchComplete
|
|
63
|
+
const { attributes, children, element } = props;
|
|
64
|
+
const { onEntityFetchComplete } = (0, _linkstracking.useLinkTracking)();
|
|
63
65
|
const isSelected = (0, _slatereact.useSelected)();
|
|
64
66
|
const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
|
|
65
67
|
const sdk = (0, _SdkProvider.useSdkContext)();
|
|
66
68
|
const isDisabled = (0, _slatereact.useReadOnly)();
|
|
67
|
-
const { id: entityId
|
|
69
|
+
const { id: entityId, linkType: entityType } = element.data.target.sys;
|
|
68
70
|
const handleEditClick = _react.useCallback(()=>{
|
|
69
71
|
const openEntity = entityType === 'Asset' ? sdk.navigator.openAsset : sdk.navigator.openEntry;
|
|
70
72
|
return openEntity(entityId, {
|
|
@@ -85,9 +87,9 @@ function LinkedEntityBlock(props) {
|
|
|
85
87
|
editor,
|
|
86
88
|
element
|
|
87
89
|
]);
|
|
88
|
-
return _react.createElement(_LinkedBlockWrapper.LinkedBlockWrapper, {
|
|
90
|
+
return /*#__PURE__*/ _react.createElement(_LinkedBlockWrapper.LinkedBlockWrapper, {
|
|
89
91
|
attributes: attributes,
|
|
90
|
-
card: _react.createElement(_react.Fragment, null, entityType === 'Entry' && _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
92
|
+
card: /*#__PURE__*/ _react.createElement(_react.Fragment, null, entityType === 'Entry' && /*#__PURE__*/ _react.createElement(_FetchingWrappedEntryCard.FetchingWrappedEntryCard, {
|
|
91
93
|
sdk: sdk,
|
|
92
94
|
entryId: entityId,
|
|
93
95
|
locale: sdk.field.locale,
|
|
@@ -96,7 +98,7 @@ function LinkedEntityBlock(props) {
|
|
|
96
98
|
onRemove: handleRemoveClick,
|
|
97
99
|
onEdit: handleEditClick,
|
|
98
100
|
onEntityFetchComplete: onEntityFetchComplete
|
|
99
|
-
}), entityType === 'Asset' && _react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
101
|
+
}), entityType === 'Asset' && /*#__PURE__*/ _react.createElement(_FetchingWrappedAssetCard.FetchingWrappedAssetCard, {
|
|
100
102
|
sdk: sdk,
|
|
101
103
|
assetId: entityId,
|
|
102
104
|
locale: sdk.field.locale,
|
|
@@ -9,11 +9,11 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
createEmbeddedEntryBlockPlugin: function() {
|
|
13
|
-
return createEmbeddedEntryBlockPlugin;
|
|
14
|
-
},
|
|
15
12
|
createEmbeddedAssetBlockPlugin: function() {
|
|
16
13
|
return createEmbeddedAssetBlockPlugin;
|
|
14
|
+
},
|
|
15
|
+
createEmbeddedEntryBlockPlugin: function() {
|
|
16
|
+
return createEmbeddedEntryBlockPlugin;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
@@ -8,10 +8,10 @@ Object.defineProperty(exports, "FetchingWrappedInlineEntryCard", {
|
|
|
8
8
|
return FetchingWrappedInlineEntryCard;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36components = require("@contentful/f36-components");
|
|
13
13
|
const _f36icons = require("@contentful/f36-icons");
|
|
14
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
14
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
15
15
|
const _fieldeditorreference = require("@contentful/field-editor-reference");
|
|
16
16
|
const _fieldeditorshared = require("@contentful/field-editor-shared");
|
|
17
17
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
@@ -42,7 +42,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
42
42
|
if (cache && cache.has(obj)) {
|
|
43
43
|
return cache.get(obj);
|
|
44
44
|
}
|
|
45
|
-
var newObj = {
|
|
45
|
+
var newObj = {
|
|
46
|
+
__proto__: null
|
|
47
|
+
};
|
|
46
48
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
47
49
|
for(var key in obj){
|
|
48
50
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -60,7 +62,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
60
62
|
}
|
|
61
63
|
return newObj;
|
|
62
64
|
}
|
|
63
|
-
const { getEntryTitle
|
|
65
|
+
const { getEntryTitle, getEntryStatus } = _fieldeditorshared.entityHelpers;
|
|
64
66
|
const styles = {
|
|
65
67
|
scheduledIcon: (0, _emotion.css)({
|
|
66
68
|
verticalAlign: 'text-bottom',
|
|
@@ -68,11 +70,11 @@ const styles = {
|
|
|
68
70
|
})
|
|
69
71
|
};
|
|
70
72
|
function FetchingWrappedInlineEntryCard(props) {
|
|
71
|
-
const { data: entry
|
|
72
|
-
const { getEntityScheduledActions
|
|
73
|
+
const { data: entry, status: requestStatus } = (0, _fieldeditorreference.useEntity)('Entry', props.entryId);
|
|
74
|
+
const { getEntityScheduledActions } = (0, _fieldeditorreference.useEntityLoader)();
|
|
73
75
|
const loadEntityScheduledActions = ()=>getEntityScheduledActions('Entry', props.entryId);
|
|
74
76
|
const allContentTypes = props.sdk.space.getCachedContentTypes();
|
|
75
|
-
const { onEntityFetchComplete
|
|
77
|
+
const { onEntityFetchComplete } = props;
|
|
76
78
|
const contentType = _react.useMemo(()=>{
|
|
77
79
|
if (!entry || !allContentTypes) return undefined;
|
|
78
80
|
return allContentTypes.find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
|
|
@@ -103,25 +105,25 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
103
105
|
props.sdk.locales.default
|
|
104
106
|
]);
|
|
105
107
|
if (requestStatus === 'error') {
|
|
106
|
-
return _react.createElement(_f36components.InlineEntryCard, {
|
|
108
|
+
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
107
109
|
title: "Entry missing or inaccessible",
|
|
108
110
|
testId: _richtexttypes.INLINES.EMBEDDED_ENTRY,
|
|
109
111
|
isSelected: props.isSelected
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
if (requestStatus === 'loading') {
|
|
113
|
-
return _react.createElement(_f36components.InlineEntryCard, {
|
|
115
|
+
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
114
116
|
isLoading: true
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
const entryStatus = getEntryStatus(entry.sys);
|
|
118
120
|
if (entryStatus === 'deleted') {
|
|
119
|
-
return _react.createElement(_f36components.InlineEntryCard, {
|
|
121
|
+
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
120
122
|
title: "Entry missing or inaccessible",
|
|
121
123
|
testId: _richtexttypes.INLINES.EMBEDDED_ENTRY,
|
|
122
124
|
isSelected: props.isSelected,
|
|
123
125
|
actions: [
|
|
124
|
-
_react.createElement(_f36components.MenuItem, {
|
|
126
|
+
/*#__PURE__*/ _react.createElement(_f36components.MenuItem, {
|
|
125
127
|
key: "remove",
|
|
126
128
|
onClick: props.onRemove,
|
|
127
129
|
testId: "delete"
|
|
@@ -129,30 +131,30 @@ function FetchingWrappedInlineEntryCard(props) {
|
|
|
129
131
|
]
|
|
130
132
|
});
|
|
131
133
|
}
|
|
132
|
-
return _react.createElement(_f36components.InlineEntryCard, {
|
|
134
|
+
return /*#__PURE__*/ _react.createElement(_f36components.InlineEntryCard, {
|
|
133
135
|
testId: _richtexttypes.INLINES.EMBEDDED_ENTRY,
|
|
134
136
|
isSelected: props.isSelected,
|
|
135
137
|
title: `${contentTypeName}: ${title}`,
|
|
136
138
|
status: entryStatus,
|
|
137
139
|
actions: [
|
|
138
|
-
_react.createElement(_f36components.MenuItem, {
|
|
140
|
+
/*#__PURE__*/ _react.createElement(_f36components.MenuItem, {
|
|
139
141
|
key: "edit",
|
|
140
142
|
onClick: props.onEdit
|
|
141
143
|
}, "Edit"),
|
|
142
|
-
_react.createElement(_f36components.MenuItem, {
|
|
144
|
+
/*#__PURE__*/ _react.createElement(_f36components.MenuItem, {
|
|
143
145
|
key: "remove",
|
|
144
146
|
onClick: props.onRemove,
|
|
145
147
|
disabled: props.isDisabled,
|
|
146
148
|
testId: "delete"
|
|
147
149
|
}, "Remove")
|
|
148
150
|
]
|
|
149
|
-
}, _react.createElement(_fieldeditorreference.ScheduledIconWithTooltip, {
|
|
151
|
+
}, /*#__PURE__*/ _react.createElement(_fieldeditorreference.ScheduledIconWithTooltip, {
|
|
150
152
|
getEntityScheduledActions: loadEntityScheduledActions,
|
|
151
153
|
entityType: "Entry",
|
|
152
154
|
entityId: entry.sys.id
|
|
153
|
-
}, _react.createElement(_f36icons.ClockIcon, {
|
|
155
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.ClockIcon, {
|
|
154
156
|
className: styles.scheduledIcon,
|
|
155
157
|
variant: "muted",
|
|
156
158
|
testId: "scheduled-icon"
|
|
157
|
-
})), _react.createElement(_f36components.Text, null, title));
|
|
159
|
+
})), /*#__PURE__*/ _react.createElement(_f36components.Text, null, title));
|
|
158
160
|
}
|