@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
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { assertOutput, jsx } from '../../../test-utils';
|
|
1
|
+
/* eslint-disable react/no-unknown-property */ /** @jsx jsx */ import { assertOutput, jsx } from '../../../test-utils';
|
|
2
2
|
describe('normalization', ()=>{
|
|
3
3
|
it('can contain inline entries & hyperlinks', ()=>{
|
|
4
|
-
const input = jsx("editor", null, jsx("hh1", null, "some text before", jsx("hinline", {
|
|
4
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some text before", /*#__PURE__*/ jsx("hinline", {
|
|
5
5
|
type: "Entry",
|
|
6
6
|
id: "inline-entry"
|
|
7
|
-
}), jsx("hlink", {
|
|
7
|
+
}), /*#__PURE__*/ jsx("hlink", {
|
|
8
8
|
uri: "https://contentful.com"
|
|
9
|
-
}), jsx("hlink", {
|
|
9
|
+
}), /*#__PURE__*/ jsx("hlink", {
|
|
10
10
|
entry: "entry-id"
|
|
11
|
-
}), jsx("hlink", {
|
|
11
|
+
}), /*#__PURE__*/ jsx("hlink", {
|
|
12
12
|
resource: "resource-urn"
|
|
13
|
-
}), jsx("hlink", {
|
|
13
|
+
}), /*#__PURE__*/ jsx("hlink", {
|
|
14
14
|
asset: "asset-id"
|
|
15
|
-
}), "some text after"), jsx("hp", null, jsx("htext", null)));
|
|
15
|
+
}), "some text after"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
16
16
|
assertOutput({
|
|
17
17
|
input,
|
|
18
18
|
expected: input
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
it('unwraps nested paragraphs', ()=>{
|
|
22
|
-
const input = jsx("editor", null, jsx("hh1", null, "one", ' ', jsx("hp", null, "two ", jsx("hp", null, "three ")), "four"));
|
|
23
|
-
const expected = jsx("editor", null, jsx("hh1", null, "one two three four"), jsx("hp", null, jsx("htext", null)));
|
|
22
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "one", ' ', /*#__PURE__*/ jsx("hp", null, "two ", /*#__PURE__*/ jsx("hp", null, "three ")), "four"));
|
|
23
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "one two three four"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
24
24
|
assertOutput({
|
|
25
25
|
input,
|
|
26
26
|
expected
|
|
@@ -28,84 +28,84 @@ describe('normalization', ()=>{
|
|
|
28
28
|
});
|
|
29
29
|
describe('lifts other invalid children', ()=>{
|
|
30
30
|
it('block void elements', ()=>{
|
|
31
|
-
const input = jsx("editor", null, jsx("hh1", null, jsx("hembed", {
|
|
31
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, /*#__PURE__*/ jsx("hembed", {
|
|
32
32
|
type: "Asset",
|
|
33
33
|
id: "1"
|
|
34
|
-
}), " start"), jsx("hh1", null, "end ", jsx("hembed", {
|
|
34
|
+
}), " start"), /*#__PURE__*/ jsx("hh1", null, "end ", /*#__PURE__*/ jsx("hembed", {
|
|
35
35
|
type: "Asset",
|
|
36
36
|
id: "2"
|
|
37
|
-
})), jsx("hh1", null, "in ", jsx("hembed", {
|
|
37
|
+
})), /*#__PURE__*/ jsx("hh1", null, "in ", /*#__PURE__*/ jsx("hembed", {
|
|
38
38
|
type: "Asset",
|
|
39
39
|
id: "3"
|
|
40
|
-
}), " between"), jsx("hh1", null, jsx("hembed", {
|
|
40
|
+
}), " between"), /*#__PURE__*/ jsx("hh1", null, /*#__PURE__*/ jsx("hembed", {
|
|
41
41
|
type: "Entry",
|
|
42
42
|
id: "1"
|
|
43
|
-
}), " start"), jsx("hh1", null, "end ", jsx("hembed", {
|
|
43
|
+
}), " start"), /*#__PURE__*/ jsx("hh1", null, "end ", /*#__PURE__*/ jsx("hembed", {
|
|
44
44
|
type: "Entry",
|
|
45
45
|
id: "2"
|
|
46
|
-
})), jsx("hh1", null, "in ", jsx("hembed", {
|
|
46
|
+
})), /*#__PURE__*/ jsx("hh1", null, "in ", /*#__PURE__*/ jsx("hembed", {
|
|
47
47
|
type: "Entry",
|
|
48
48
|
id: "3"
|
|
49
|
-
}), " between"), jsx("hh1", null, jsx("hhr", null), " start"), jsx("hh1", null, "end ", jsx("hhr", null)), jsx("hh1", null, "in ", jsx("hhr", null), " between"));
|
|
50
|
-
const expected = jsx("editor", null, jsx("hembed", {
|
|
49
|
+
}), " between"), /*#__PURE__*/ jsx("hh1", null, /*#__PURE__*/ jsx("hhr", null), " start"), /*#__PURE__*/ jsx("hh1", null, "end ", /*#__PURE__*/ jsx("hhr", null)), /*#__PURE__*/ jsx("hh1", null, "in ", /*#__PURE__*/ jsx("hhr", null), " between"));
|
|
50
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hembed", {
|
|
51
51
|
type: "Asset",
|
|
52
52
|
id: "1"
|
|
53
|
-
}), jsx("hh1", null, " start"), jsx("hh1", null, "end "), jsx("hembed", {
|
|
53
|
+
}), /*#__PURE__*/ jsx("hh1", null, " start"), /*#__PURE__*/ jsx("hh1", null, "end "), /*#__PURE__*/ jsx("hembed", {
|
|
54
54
|
type: "Asset",
|
|
55
55
|
id: "2"
|
|
56
|
-
}), jsx("hh1", null, "in "), jsx("hembed", {
|
|
56
|
+
}), /*#__PURE__*/ jsx("hh1", null, "in "), /*#__PURE__*/ jsx("hembed", {
|
|
57
57
|
type: "Asset",
|
|
58
58
|
id: "3"
|
|
59
|
-
}), jsx("hh1", null, " between"), jsx("hembed", {
|
|
59
|
+
}), /*#__PURE__*/ jsx("hh1", null, " between"), /*#__PURE__*/ jsx("hembed", {
|
|
60
60
|
type: "Entry",
|
|
61
61
|
id: "1"
|
|
62
|
-
}), jsx("hh1", null, " start"), jsx("hh1", null, "end "), jsx("hembed", {
|
|
62
|
+
}), /*#__PURE__*/ jsx("hh1", null, " start"), /*#__PURE__*/ jsx("hh1", null, "end "), /*#__PURE__*/ jsx("hembed", {
|
|
63
63
|
type: "Entry",
|
|
64
64
|
id: "2"
|
|
65
|
-
}), jsx("hh1", null, "in "), jsx("hembed", {
|
|
65
|
+
}), /*#__PURE__*/ jsx("hh1", null, "in "), /*#__PURE__*/ jsx("hembed", {
|
|
66
66
|
type: "Entry",
|
|
67
67
|
id: "3"
|
|
68
|
-
}), jsx("hh1", null, " between"), jsx("hhr", null), jsx("hh1", null, " start"), jsx("hh1", null, "end "), jsx("hhr", null), jsx("hh1", null, "in "), jsx("hhr", null), jsx("hh1", null, " between"), jsx("hp", null, jsx("htext", null)));
|
|
68
|
+
}), /*#__PURE__*/ jsx("hh1", null, " between"), /*#__PURE__*/ jsx("hhr", null), /*#__PURE__*/ jsx("hh1", null, " start"), /*#__PURE__*/ jsx("hh1", null, "end "), /*#__PURE__*/ jsx("hhr", null), /*#__PURE__*/ jsx("hh1", null, "in "), /*#__PURE__*/ jsx("hhr", null), /*#__PURE__*/ jsx("hh1", null, " between"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
69
69
|
assertOutput({
|
|
70
70
|
input,
|
|
71
71
|
expected
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
it('nested headings', ()=>{
|
|
75
|
-
const input = jsx("editor", null, jsx("hh1", null, "some", jsx("hh1", null, jsx("htext", {
|
|
75
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some", /*#__PURE__*/ jsx("hh1", null, /*#__PURE__*/ jsx("htext", {
|
|
76
76
|
bold: true,
|
|
77
77
|
italic: true,
|
|
78
78
|
underline: true
|
|
79
79
|
}, "paragraph")), "text"));
|
|
80
|
-
const expected = jsx("editor", null, jsx("hh1", null, "some"), jsx("hh1", null, jsx("htext", {
|
|
80
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some"), /*#__PURE__*/ jsx("hh1", null, /*#__PURE__*/ jsx("htext", {
|
|
81
81
|
bold: true,
|
|
82
82
|
italic: true,
|
|
83
83
|
underline: true
|
|
84
|
-
}, "paragraph")), jsx("hh1", null, "text"), jsx("hp", null, jsx("htext", null)));
|
|
84
|
+
}, "paragraph")), /*#__PURE__*/ jsx("hh1", null, "text"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
85
85
|
assertOutput({
|
|
86
86
|
input,
|
|
87
87
|
expected
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
90
|
it('handles quotes', ()=>{
|
|
91
|
-
const input = jsx("editor", null, jsx("hh1", null, "some", jsx("hquote", null, jsx("hp", null, "quote")), "text"));
|
|
92
|
-
const expected = jsx("editor", null, jsx("hh1", null, "some"), jsx("hquote", null, jsx("hp", null, "quote")), jsx("hh1", null, "text"), jsx("hp", null, jsx("htext", null)));
|
|
91
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some", /*#__PURE__*/ jsx("hquote", null, /*#__PURE__*/ jsx("hp", null, "quote")), "text"));
|
|
92
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some"), /*#__PURE__*/ jsx("hquote", null, /*#__PURE__*/ jsx("hp", null, "quote")), /*#__PURE__*/ jsx("hh1", null, "text"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
93
93
|
assertOutput({
|
|
94
94
|
input,
|
|
95
95
|
expected
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
it('handles lists', ()=>{
|
|
99
|
-
const input = jsx("editor", null, jsx("hh1", null, "some", jsx("hul", null, jsx("hli", null, jsx("hp", null, "list item"))), "text"));
|
|
100
|
-
const expected = jsx("editor", null, jsx("hh1", null, "some"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "list item"))), jsx("hh1", null, "text"), jsx("hp", null, jsx("htext", null)));
|
|
99
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some", /*#__PURE__*/ jsx("hul", null, /*#__PURE__*/ jsx("hli", null, /*#__PURE__*/ jsx("hp", null, "list item"))), "text"));
|
|
100
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some"), /*#__PURE__*/ jsx("hul", null, /*#__PURE__*/ jsx("hli", null, /*#__PURE__*/ jsx("hp", null, "list item"))), /*#__PURE__*/ jsx("hh1", null, "text"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
101
101
|
assertOutput({
|
|
102
102
|
input,
|
|
103
103
|
expected
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
106
|
it('handles tables', ()=>{
|
|
107
|
-
const input = jsx("editor", null, jsx("hh1", null, "some", jsx("htable", null, jsx("htr", null, jsx("htd", null, jsx("hp", null, "cell 1")), jsx("htd", null, jsx("hp", null, "cell 2")))), "text"));
|
|
108
|
-
const expected = jsx("editor", null, jsx("hh1", null, "some"), jsx("htable", null, jsx("htr", null, jsx("htd", null, jsx("hp", null, "cell 1")), jsx("htd", null, jsx("hp", null, "cell 2")))), jsx("hh1", null, "text"), jsx("hp", null, jsx("htext", null)));
|
|
107
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some", /*#__PURE__*/ jsx("htable", null, /*#__PURE__*/ jsx("htr", null, /*#__PURE__*/ jsx("htd", null, /*#__PURE__*/ jsx("hp", null, "cell 1")), /*#__PURE__*/ jsx("htd", null, /*#__PURE__*/ jsx("hp", null, "cell 2")))), "text"));
|
|
108
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hh1", null, "some"), /*#__PURE__*/ jsx("htable", null, /*#__PURE__*/ jsx("htr", null, /*#__PURE__*/ jsx("htd", null, /*#__PURE__*/ jsx("hp", null, "cell 1")), /*#__PURE__*/ jsx("htd", null, /*#__PURE__*/ jsx("hp", null, "cell 2")))), /*#__PURE__*/ jsx("hh1", null, "text"), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null)));
|
|
109
109
|
assertOutput({
|
|
110
110
|
input,
|
|
111
111
|
expected
|
|
@@ -55,19 +55,20 @@ const styles = {
|
|
|
55
55
|
`
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- TODO: explain this disable
|
|
58
59
|
function createHeading(Tag, block) {
|
|
59
60
|
return function Heading(props) {
|
|
60
|
-
return React.createElement(Tag, {
|
|
61
|
+
return /*#__PURE__*/ React.createElement(Tag, {
|
|
61
62
|
...props.attributes,
|
|
62
63
|
className: cx(styles.headings.root, styles.headings[block])
|
|
63
64
|
}, props.children);
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
67
|
export const HeadingComponents = {
|
|
67
|
-
[BLOCKS.HEADING_1]: React.memo(createHeading('h1', BLOCKS.HEADING_1)),
|
|
68
|
-
[BLOCKS.HEADING_2]: React.memo(createHeading('h2', BLOCKS.HEADING_2)),
|
|
69
|
-
[BLOCKS.HEADING_3]: React.memo(createHeading('h3', BLOCKS.HEADING_3)),
|
|
70
|
-
[BLOCKS.HEADING_4]: React.memo(createHeading('h4', BLOCKS.HEADING_4)),
|
|
71
|
-
[BLOCKS.HEADING_5]: React.memo(createHeading('h5', BLOCKS.HEADING_5)),
|
|
72
|
-
[BLOCKS.HEADING_6]: React.memo(createHeading('h6', BLOCKS.HEADING_6))
|
|
68
|
+
[BLOCKS.HEADING_1]: /*#__PURE__*/ React.memo(createHeading('h1', BLOCKS.HEADING_1)),
|
|
69
|
+
[BLOCKS.HEADING_2]: /*#__PURE__*/ React.memo(createHeading('h2', BLOCKS.HEADING_2)),
|
|
70
|
+
[BLOCKS.HEADING_3]: /*#__PURE__*/ React.memo(createHeading('h3', BLOCKS.HEADING_3)),
|
|
71
|
+
[BLOCKS.HEADING_4]: /*#__PURE__*/ React.memo(createHeading('h4', BLOCKS.HEADING_4)),
|
|
72
|
+
[BLOCKS.HEADING_5]: /*#__PURE__*/ React.memo(createHeading('h5', BLOCKS.HEADING_5)),
|
|
73
|
+
[BLOCKS.HEADING_6]: /*#__PURE__*/ React.memo(createHeading('h6', BLOCKS.HEADING_6))
|
|
73
74
|
};
|
|
@@ -58,7 +58,7 @@ export function ToolbarHeadingButton(props) {
|
|
|
58
58
|
}, [
|
|
59
59
|
editor?.operations,
|
|
60
60
|
editor?.selection
|
|
61
|
-
]);
|
|
61
|
+
]); // eslint-disable-line -- TODO: explain this disable
|
|
62
62
|
const [nodeTypesByEnablement, someHeadingsEnabled] = React.useMemo(()=>{
|
|
63
63
|
const nodeTypesByEnablement = Object.fromEntries(Object.keys(LABELS).map((nodeType)=>[
|
|
64
64
|
nodeType,
|
|
@@ -79,7 +79,13 @@ export function ToolbarHeadingButton(props) {
|
|
|
79
79
|
setSelected(type);
|
|
80
80
|
setOpen(false);
|
|
81
81
|
const prevOnChange = editor.onChange;
|
|
82
|
-
|
|
82
|
+
/*
|
|
83
|
+
The focus might happen at point in time when
|
|
84
|
+
`toggleElement` (helper for toggleNodeType) changes aren't rendered yet, causing the browser
|
|
85
|
+
to place the cursor at the start of the text.
|
|
86
|
+
We wait for the change event before focusing
|
|
87
|
+
the editor again. This ensures the cursor is back at the previous
|
|
88
|
+
position.*/ editor.onChange = (...args)=>{
|
|
83
89
|
focus(editor);
|
|
84
90
|
editor.onChange = prevOnChange;
|
|
85
91
|
prevOnChange(...args);
|
|
@@ -95,25 +101,25 @@ export function ToolbarHeadingButton(props) {
|
|
|
95
101
|
};
|
|
96
102
|
}
|
|
97
103
|
if (!editor) return null;
|
|
98
|
-
return React.createElement(Menu, {
|
|
104
|
+
return /*#__PURE__*/ React.createElement(Menu, {
|
|
99
105
|
isOpen: isOpen,
|
|
100
106
|
onClose: ()=>setOpen(false)
|
|
101
|
-
}, React.createElement(Menu.Trigger, null, React.createElement(Button, {
|
|
107
|
+
}, /*#__PURE__*/ React.createElement(Menu.Trigger, null, /*#__PURE__*/ React.createElement(Button, {
|
|
102
108
|
size: "small",
|
|
103
109
|
testId: "toolbar-heading-toggle",
|
|
104
110
|
variant: "transparent",
|
|
105
|
-
endIcon: React.createElement(ChevronDownIcon, null),
|
|
111
|
+
endIcon: /*#__PURE__*/ React.createElement(ChevronDownIcon, null),
|
|
106
112
|
isDisabled: props.isDisabled,
|
|
107
113
|
onClick: ()=>someHeadingsEnabled && setOpen(!isOpen)
|
|
108
|
-
}, LABELS[selected])), React.createElement(Menu.List, {
|
|
114
|
+
}, LABELS[selected])), /*#__PURE__*/ React.createElement(Menu.List, {
|
|
109
115
|
testId: "dropdown-heading-list"
|
|
110
|
-
}, ' ', Object.keys(LABELS).map((nodeType)=>nodeTypesByEnablement[nodeType] && React.createElement(Menu.Item, {
|
|
116
|
+
}, ' ', Object.keys(LABELS).map((nodeType)=>nodeTypesByEnablement[nodeType] && /*#__PURE__*/ React.createElement(Menu.Item, {
|
|
111
117
|
key: nodeType,
|
|
112
118
|
isInitiallyFocused: selected === nodeType,
|
|
113
119
|
onClick: handleOnSelectItem(nodeType),
|
|
114
120
|
testId: `dropdown-option-${nodeType}`,
|
|
115
121
|
disabled: props.isDisabled
|
|
116
|
-
}, React.createElement("span", {
|
|
122
|
+
}, /*#__PURE__*/ React.createElement("span", {
|
|
117
123
|
className: cx(styles.dropdown.root, styles.dropdown[nodeType])
|
|
118
124
|
}, LABELS[nodeType]))).filter(Boolean)));
|
|
119
125
|
}
|
|
@@ -5,7 +5,7 @@ import { transformLift, transformUnwrap } from '../../helpers/transformers';
|
|
|
5
5
|
import { isMarkActive, getAboveNode } from '../../internal/queries';
|
|
6
6
|
import { COMMAND_PROMPT } from '../CommandPalette/constants';
|
|
7
7
|
import { HeadingComponents } from './components/Heading';
|
|
8
|
-
const buildHeadingEventHandler = (type)=>(editor, { options: { hotkey
|
|
8
|
+
const buildHeadingEventHandler = (type)=>(editor, { options: { hotkey } })=>(event)=>{
|
|
9
9
|
if (editor.selection && hotkey && isHotkey(hotkey, event)) {
|
|
10
10
|
const isActive = isBlockSelected(editor, type);
|
|
11
11
|
editor.tracking.onShortcutAction(isActive ? 'remove' : 'insert', {
|
|
@@ -20,6 +20,7 @@ const buildHeadingEventHandler = (type)=>(editor, { options: { hotkey } })=>(e
|
|
|
20
20
|
export const createHeadingPlugin = ()=>({
|
|
21
21
|
key: 'HeadingPlugin',
|
|
22
22
|
softBreak: [
|
|
23
|
+
// create a new line with SHIFT+Enter inside a heading
|
|
23
24
|
{
|
|
24
25
|
hotkey: 'shift+enter',
|
|
25
26
|
query: {
|
|
@@ -42,12 +43,16 @@ export const createHeadingPlugin = ()=>({
|
|
|
42
43
|
then: (editor)=>{
|
|
43
44
|
return {
|
|
44
45
|
exitBreak: [
|
|
46
|
+
// Pressing ENTER at the start or end of a heading text inserts a
|
|
47
|
+
// normal paragraph.
|
|
45
48
|
{
|
|
46
49
|
hotkey: 'enter',
|
|
47
50
|
query: {
|
|
48
51
|
allow: HEADINGS,
|
|
49
52
|
end: true,
|
|
50
53
|
start: true,
|
|
54
|
+
// Exclude headings inside lists as it interferes with the list's
|
|
55
|
+
// insertBreak implementation
|
|
51
56
|
filter: ([, path])=>!getAboveNode(editor, {
|
|
52
57
|
at: path,
|
|
53
58
|
match: {
|
|
@@ -72,29 +72,32 @@ export function ToolbarHrButton(props) {
|
|
|
72
72
|
};
|
|
73
73
|
const hasText = !!getText(editor, editor.selection.focus.path);
|
|
74
74
|
hasText ? insertNodes(editor, hr) : setNodes(editor, hr);
|
|
75
|
+
// Move focus to the next paragraph (added by TrailingParagraph plugin)
|
|
75
76
|
moveToTheNextLine(editor);
|
|
76
77
|
focus(editor);
|
|
77
78
|
}
|
|
78
79
|
if (!editor) return null;
|
|
79
|
-
return React.createElement(ToolbarButton, {
|
|
80
|
+
return /*#__PURE__*/ React.createElement(ToolbarButton, {
|
|
80
81
|
title: "HR",
|
|
81
82
|
isDisabled: props.isDisabled,
|
|
82
83
|
onClick: handleOnClick,
|
|
83
84
|
testId: "hr-toolbar-button",
|
|
84
85
|
isActive: isBlockSelected(editor, BLOCKS.HR)
|
|
85
|
-
}, React.createElement(HorizontalRuleIcon, null));
|
|
86
|
+
}, /*#__PURE__*/ React.createElement(HorizontalRuleIcon, null));
|
|
86
87
|
}
|
|
87
88
|
export function Hr(props) {
|
|
88
89
|
const isSelected = Slate.useSelected();
|
|
89
90
|
const isFocused = Slate.useFocused();
|
|
90
|
-
return React.createElement("div", {
|
|
91
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
91
92
|
...props.attributes,
|
|
92
93
|
className: styles.container,
|
|
94
|
+
// COMPAT: To make HR copyable in Safari, we verify this attribute below on `deserialize`
|
|
93
95
|
"data-void-element": BLOCKS.HR
|
|
94
|
-
}, React.createElement("div", {
|
|
96
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
95
97
|
draggable: true,
|
|
98
|
+
// Moving `contentEditable` to this div makes it to be selectable when being the first void element, e.g pressing ctrl + a to select everything
|
|
96
99
|
contentEditable: false
|
|
97
|
-
}, React.createElement("hr", {
|
|
100
|
+
}, /*#__PURE__*/ React.createElement("hr", {
|
|
98
101
|
className: cx(styles.hr, isSelected && isFocused ? styles.hrSelected : undefined)
|
|
99
102
|
})), props.children);
|
|
100
103
|
}
|
|
@@ -78,7 +78,7 @@ export function HyperlinkModal(props) {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
function entityToLink(entity) {
|
|
81
|
-
const { id
|
|
81
|
+
const { id, type } = entity.sys;
|
|
82
82
|
return {
|
|
83
83
|
sys: {
|
|
84
84
|
id,
|
|
@@ -88,7 +88,8 @@ export function HyperlinkModal(props) {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
function entityToResourceLink(entity) {
|
|
91
|
-
const { urn
|
|
91
|
+
const { urn } = entity.sys;
|
|
92
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
92
93
|
return {
|
|
93
94
|
sys: {
|
|
94
95
|
urn,
|
|
@@ -121,6 +122,7 @@ export function HyperlinkModal(props) {
|
|
|
121
122
|
const options = {
|
|
122
123
|
allowedResources: getAllowedResourcesForNodeType(props.sdk.field, INLINES.RESOURCE_HYPERLINK)
|
|
123
124
|
};
|
|
125
|
+
// @ts-expect-error wait for update of app-sdk version
|
|
124
126
|
const entry = await props.sdk.dialogs.selectSingleResourceEntry(options);
|
|
125
127
|
if (entry) {
|
|
126
128
|
setLinkTarget('');
|
|
@@ -141,30 +143,30 @@ export function HyperlinkModal(props) {
|
|
|
141
143
|
event.preventDefault();
|
|
142
144
|
setLinkEntity(null);
|
|
143
145
|
}
|
|
144
|
-
return React.createElement(EntityProvider, {
|
|
146
|
+
return /*#__PURE__*/ React.createElement(EntityProvider, {
|
|
145
147
|
sdk: props.sdk
|
|
146
|
-
}, React.createElement(React.Fragment, null, React.createElement(ModalContent, null, React.createElement(Form, null, !props.linkType && React.createElement(FormControl, {
|
|
148
|
+
}, /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ModalContent, null, /*#__PURE__*/ React.createElement(Form, null, !props.linkType && /*#__PURE__*/ React.createElement(FormControl, {
|
|
147
149
|
id: "link-text",
|
|
148
150
|
isRequired: true
|
|
149
|
-
}, React.createElement(FormControl.Label, null, "Link text"), React.createElement(TextInput, {
|
|
151
|
+
}, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link text"), /*#__PURE__*/ React.createElement(TextInput, {
|
|
150
152
|
testId: "link-text-input",
|
|
151
153
|
name: "link-text",
|
|
152
154
|
value: linkText,
|
|
153
155
|
onChange: (event)=>setLinkText(event.target.value)
|
|
154
|
-
})), enabledLinkTypes.length > 1 && React.createElement(FormControl, {
|
|
156
|
+
})), enabledLinkTypes.length > 1 && /*#__PURE__*/ React.createElement(FormControl, {
|
|
155
157
|
id: "link-type"
|
|
156
|
-
}, React.createElement(FormControl.Label, null, "Link type"), React.createElement(Select, {
|
|
158
|
+
}, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link type"), /*#__PURE__*/ React.createElement(Select, {
|
|
157
159
|
value: linkType,
|
|
158
160
|
onChange: (event)=>setLinkType(event.target.value),
|
|
159
161
|
testId: "link-type-input",
|
|
160
162
|
isDisabled: props.readonly
|
|
161
|
-
}, enabledLinkTypes.map((nodeType)
|
|
163
|
+
}, enabledLinkTypes.map((nodeType)=>/*#__PURE__*/ React.createElement(Select.Option, {
|
|
162
164
|
key: nodeType,
|
|
163
165
|
value: nodeType
|
|
164
|
-
}, LINK_TYPE_SELECTION_VALUES[nodeType])))), linkType === INLINES.HYPERLINK && React.createElement(FormControl, {
|
|
166
|
+
}, LINK_TYPE_SELECTION_VALUES[nodeType])))), linkType === INLINES.HYPERLINK && /*#__PURE__*/ React.createElement(FormControl, {
|
|
165
167
|
id: "linkTarget",
|
|
166
168
|
isRequired: true
|
|
167
|
-
}, React.createElement(FormControl.Label, null, "Link target"), React.createElement(TextInput, {
|
|
169
|
+
}, /*#__PURE__*/ React.createElement(FormControl.Label, null, "Link target"), /*#__PURE__*/ React.createElement(TextInput, {
|
|
168
170
|
ref: linkTargetInputRef,
|
|
169
171
|
name: "linkTarget",
|
|
170
172
|
value: linkTarget,
|
|
@@ -174,46 +176,46 @@ export function HyperlinkModal(props) {
|
|
|
174
176
|
},
|
|
175
177
|
testId: "link-target-input",
|
|
176
178
|
isDisabled: props.readonly
|
|
177
|
-
}), React.createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")), linkType !== INLINES.HYPERLINK && React.createElement("div", null, React.createElement(FormLabel, {
|
|
179
|
+
}), /*#__PURE__*/ React.createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")), linkType !== INLINES.HYPERLINK && /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(FormLabel, {
|
|
178
180
|
isRequired: true,
|
|
179
181
|
htmlFor: ""
|
|
180
|
-
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? React.createElement(React.Fragment, null, !props.readonly && React.createElement(TextLink, {
|
|
182
|
+
}, "Link target", ' '), linkEntity && linkEntity.sys.linkType === SYS_LINK_TYPES[linkType] ? /*#__PURE__*/ React.createElement(React.Fragment, null, !props.readonly && /*#__PURE__*/ React.createElement(TextLink, {
|
|
181
183
|
testId: "entity-selection-link",
|
|
182
184
|
onClick: resetLinkEntity,
|
|
183
185
|
className: styles.removeSelectionLabel
|
|
184
|
-
}, "Remove selection"), React.createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && isEntryLink(linkEntity) && React.createElement(FetchingWrappedEntryCard, {
|
|
186
|
+
}, "Remove selection"), /*#__PURE__*/ React.createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && isEntryLink(linkEntity) && /*#__PURE__*/ React.createElement(FetchingWrappedEntryCard, {
|
|
185
187
|
sdk: props.sdk,
|
|
186
188
|
locale: props.sdk.field.locale,
|
|
187
189
|
entryId: linkEntity.sys.id,
|
|
188
190
|
isDisabled: true,
|
|
189
191
|
isSelected: false
|
|
190
|
-
}), linkType === INLINES.RESOURCE_HYPERLINK && isResourceLink(linkEntity) && React.createElement(FetchingWrappedResourceCard, {
|
|
192
|
+
}), linkType === INLINES.RESOURCE_HYPERLINK && isResourceLink(linkEntity) && /*#__PURE__*/ React.createElement(FetchingWrappedResourceCard, {
|
|
191
193
|
sdk: props.sdk,
|
|
192
194
|
link: linkEntity.sys,
|
|
193
195
|
isDisabled: true,
|
|
194
196
|
isSelected: false
|
|
195
|
-
}), linkType === INLINES.ASSET_HYPERLINK && isAssetLink(linkEntity) && React.createElement(FetchingWrappedAssetCard, {
|
|
197
|
+
}), linkType === INLINES.ASSET_HYPERLINK && isAssetLink(linkEntity) && /*#__PURE__*/ React.createElement(FetchingWrappedAssetCard, {
|
|
196
198
|
sdk: props.sdk,
|
|
197
199
|
locale: props.sdk.field.locale,
|
|
198
200
|
assetId: linkEntity.sys.id,
|
|
199
201
|
isDisabled: true,
|
|
200
202
|
isSelected: false
|
|
201
|
-
}))) : React.createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && React.createElement(TextLink, {
|
|
203
|
+
}))) : /*#__PURE__*/ React.createElement("div", null, linkType === INLINES.ENTRY_HYPERLINK && /*#__PURE__*/ React.createElement(TextLink, {
|
|
202
204
|
testId: "entity-selection-link",
|
|
203
205
|
onClick: selectEntry
|
|
204
|
-
}, "Select entry"), linkType === INLINES.RESOURCE_HYPERLINK && React.createElement(TextLink, {
|
|
206
|
+
}, "Select entry"), linkType === INLINES.RESOURCE_HYPERLINK && /*#__PURE__*/ React.createElement(TextLink, {
|
|
205
207
|
testId: "entity-selection-link",
|
|
206
208
|
onClick: selectResourceEntry
|
|
207
|
-
}, "Select entry"), linkType === INLINES.ASSET_HYPERLINK && React.createElement(TextLink, {
|
|
209
|
+
}, "Select entry"), linkType === INLINES.ASSET_HYPERLINK && /*#__PURE__*/ React.createElement(TextLink, {
|
|
208
210
|
testId: "entity-selection-link",
|
|
209
211
|
onClick: selectAsset
|
|
210
|
-
}, "Select asset"))))), React.createElement(ModalControls, null, React.createElement(Button, {
|
|
212
|
+
}, "Select asset"))))), /*#__PURE__*/ React.createElement(ModalControls, null, /*#__PURE__*/ React.createElement(Button, {
|
|
211
213
|
type: "button",
|
|
212
214
|
onClick: ()=>props.onClose(null),
|
|
213
215
|
variant: "secondary",
|
|
214
216
|
testId: "cancel-cta",
|
|
215
217
|
size: "small"
|
|
216
|
-
}, "Cancel"), React.createElement(Button, {
|
|
218
|
+
}, "Cancel"), /*#__PURE__*/ React.createElement(Button, {
|
|
217
219
|
type: "submit",
|
|
218
220
|
variant: "positive",
|
|
219
221
|
size: "small",
|
|
@@ -249,8 +251,8 @@ export async function addOrEditLink(editor, sdk, logAction, targetPath) {
|
|
|
249
251
|
shouldCloseOnEscapePress: true,
|
|
250
252
|
shouldCloseOnOverlayClick: true,
|
|
251
253
|
allowHeightOverflow: true
|
|
252
|
-
}, ({ onClose
|
|
253
|
-
return React.createElement(HyperlinkModal, {
|
|
254
|
+
}, ({ onClose })=>{
|
|
255
|
+
return /*#__PURE__*/ React.createElement(HyperlinkModal, {
|
|
254
256
|
linkTarget: linkTarget,
|
|
255
257
|
linkText: currentLinkText,
|
|
256
258
|
linkType: linkType,
|
|
@@ -266,7 +268,7 @@ export async function addOrEditLink(editor, sdk, logAction, targetPath) {
|
|
|
266
268
|
logAction(isEditing ? 'cancelEditHyperlinkDialog' : 'cancelCreateHyperlinkDialog');
|
|
267
269
|
return;
|
|
268
270
|
}
|
|
269
|
-
const { linkText: text
|
|
271
|
+
const { linkText: text, linkTarget: url, linkType: type, linkEntity: target } = data;
|
|
270
272
|
withoutNormalizing(editor, ()=>{
|
|
271
273
|
insertLink(editor, {
|
|
272
274
|
text,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { assertOutput, jsx } from '../../../test-utils';
|
|
1
|
+
/* eslint-disable react/no-unknown-property */ /** @jsx jsx */ import { assertOutput, jsx } from '../../../test-utils';
|
|
2
2
|
describe('normalization', ()=>{
|
|
3
3
|
it('removes empty links from the document structure', ()=>{
|
|
4
|
-
const input = jsx("editor", null, jsx("hp", null, jsx("htext", null, "link"), jsx("hlink", {
|
|
4
|
+
const input = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "link"), /*#__PURE__*/ jsx("hlink", {
|
|
5
5
|
uri: "https://link.com"
|
|
6
|
-
})), jsx("hp", null, jsx("htext", null, "asset"), jsx("hlink", {
|
|
6
|
+
})), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "asset"), /*#__PURE__*/ jsx("hlink", {
|
|
7
7
|
asset: "asset-id"
|
|
8
|
-
})), jsx("hp", null, jsx("htext", null, "entry"), jsx("hlink", {
|
|
8
|
+
})), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "entry"), /*#__PURE__*/ jsx("hlink", {
|
|
9
9
|
entry: "entry-id"
|
|
10
|
-
})), jsx("hp", null, jsx("htext", null, "resource"), jsx("hlink", {
|
|
10
|
+
})), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "resource"), /*#__PURE__*/ jsx("hlink", {
|
|
11
11
|
resource: "resource-urn"
|
|
12
|
-
})), jsx("hp", null, jsx("htext", null, "explicit empty link"), jsx("hlink", {
|
|
12
|
+
})), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "explicit empty link"), /*#__PURE__*/ jsx("hlink", {
|
|
13
13
|
uri: "https://link.com"
|
|
14
|
-
}, '')), jsx("hp", null, jsx("htext", null, "link with empty space"), jsx("hlink", {
|
|
14
|
+
}, '')), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "link with empty space"), /*#__PURE__*/ jsx("hlink", {
|
|
15
15
|
uri: "https://link.com"
|
|
16
16
|
}, " ")));
|
|
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")));
|
|
17
|
+
const expected = /*#__PURE__*/ jsx("editor", null, /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "link")), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "asset")), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "entry")), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "resource")), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "explicit empty link")), /*#__PURE__*/ jsx("hp", null, /*#__PURE__*/ jsx("htext", null, "link with empty space")));
|
|
18
18
|
assertOutput({
|
|
19
19
|
input,
|
|
20
20
|
expected
|
|
@@ -10,8 +10,8 @@ import { styles } from './styles';
|
|
|
10
10
|
export function EntityHyperlink(props) {
|
|
11
11
|
const editor = useContentfulEditor();
|
|
12
12
|
const sdk = useSdkContext();
|
|
13
|
-
const { target
|
|
14
|
-
const { onEntityFetchComplete
|
|
13
|
+
const { target } = props.element.data;
|
|
14
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
15
15
|
const tooltipContent = useEntityInfo({
|
|
16
16
|
target,
|
|
17
17
|
sdk,
|
|
@@ -30,12 +30,12 @@ export function EntityHyperlink(props) {
|
|
|
30
30
|
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
return React.createElement(Tooltip, {
|
|
33
|
+
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
34
34
|
content: tooltipContent,
|
|
35
35
|
targetWrapperClassName: styles.hyperlinkWrapper,
|
|
36
36
|
placement: "bottom",
|
|
37
37
|
maxWidth: "auto"
|
|
38
|
-
}, React.createElement(TextLink, {
|
|
38
|
+
}, /*#__PURE__*/ React.createElement(TextLink, {
|
|
39
39
|
as: "a",
|
|
40
40
|
onClick: handleClick,
|
|
41
41
|
className: styles.hyperlink,
|
|
@@ -10,8 +10,8 @@ import { styles } from './styles';
|
|
|
10
10
|
export function ResourceHyperlink(props) {
|
|
11
11
|
const editor = useContentfulEditor();
|
|
12
12
|
const sdk = useSdkContext();
|
|
13
|
-
const { target
|
|
14
|
-
const { onEntityFetchComplete
|
|
13
|
+
const { target } = props.element.data;
|
|
14
|
+
const { onEntityFetchComplete } = useLinkTracking();
|
|
15
15
|
const tooltipContent = useResourceEntityInfo({
|
|
16
16
|
target,
|
|
17
17
|
onEntityFetchComplete
|
|
@@ -29,12 +29,12 @@ export function ResourceHyperlink(props) {
|
|
|
29
29
|
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p.path);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
return React.createElement(Tooltip, {
|
|
32
|
+
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
33
33
|
content: tooltipContent,
|
|
34
34
|
targetWrapperClassName: styles.hyperlinkWrapper,
|
|
35
35
|
placement: "bottom",
|
|
36
36
|
maxWidth: "auto"
|
|
37
|
-
}, React.createElement(TextLink, {
|
|
37
|
+
}, /*#__PURE__*/ React.createElement(TextLink, {
|
|
38
38
|
as: "a",
|
|
39
39
|
onClick: handleClick,
|
|
40
40
|
className: styles.hyperlink,
|
|
@@ -19,11 +19,11 @@ export function ToolbarHyperlinkButton(props) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
if (!editor) return null;
|
|
22
|
-
return React.createElement(ToolbarButton, {
|
|
22
|
+
return /*#__PURE__*/ 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
|
-
}, React.createElement(LinkIcon, null));
|
|
28
|
+
}, /*#__PURE__*/ React.createElement(LinkIcon, null));
|
|
29
29
|
}
|
|
@@ -8,7 +8,7 @@ import { styles } from './styles';
|
|
|
8
8
|
export function UrlHyperlink(props) {
|
|
9
9
|
const editor = useContentfulEditor();
|
|
10
10
|
const sdk = useSdkContext();
|
|
11
|
-
const { uri
|
|
11
|
+
const { uri } = props.element.data;
|
|
12
12
|
function handleClick(event) {
|
|
13
13
|
event.preventDefault();
|
|
14
14
|
event.stopPropagation();
|
|
@@ -22,13 +22,13 @@ export function UrlHyperlink(props) {
|
|
|
22
22
|
});
|
|
23
23
|
addOrEditLink(editor, sdk, editor.tracking.onViewportAction, p?.path);
|
|
24
24
|
}
|
|
25
|
-
return React.createElement(Tooltip, {
|
|
25
|
+
return /*#__PURE__*/ React.createElement(Tooltip, {
|
|
26
26
|
usePortal: true,
|
|
27
27
|
content: uri,
|
|
28
28
|
targetWrapperClassName: styles.hyperlinkWrapper,
|
|
29
29
|
placement: "bottom",
|
|
30
30
|
maxWidth: "min-content"
|
|
31
|
-
}, React.createElement(TextLink, {
|
|
31
|
+
}, /*#__PURE__*/ React.createElement(TextLink, {
|
|
32
32
|
as: "a",
|
|
33
33
|
href: uri,
|
|
34
34
|
rel: "noopener noreferrer",
|
|
@@ -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,6 +65,7 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
65
65
|
onKeyDown: buildHyperlinkEventHandler(sdk)
|
|
66
66
|
},
|
|
67
67
|
plugins: [
|
|
68
|
+
// URL Hyperlink
|
|
68
69
|
{
|
|
69
70
|
...common,
|
|
70
71
|
key: INLINES.HYPERLINK,
|
|
@@ -82,6 +83,7 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
82
83
|
getNode: getNodeOfType(INLINES.HYPERLINK)
|
|
83
84
|
}
|
|
84
85
|
},
|
|
86
|
+
// Entry Hyperlink
|
|
85
87
|
{
|
|
86
88
|
...common,
|
|
87
89
|
key: INLINES.ENTRY_HYPERLINK,
|
|
@@ -99,6 +101,7 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
99
101
|
getNode: getNodeOfType(INLINES.ENTRY_HYPERLINK)
|
|
100
102
|
}
|
|
101
103
|
},
|
|
104
|
+
// Resource Hyperlink
|
|
102
105
|
{
|
|
103
106
|
...common,
|
|
104
107
|
key: INLINES.RESOURCE_HYPERLINK,
|
|
@@ -116,6 +119,7 @@ export const createHyperlinkPlugin = (sdk)=>{
|
|
|
116
119
|
getNode: getNodeOfType(INLINES.RESOURCE_HYPERLINK)
|
|
117
120
|
}
|
|
118
121
|
},
|
|
122
|
+
// Asset Hyperlink
|
|
119
123
|
{
|
|
120
124
|
...common,
|
|
121
125
|
key: INLINES.ASSET_HYPERLINK,
|