@contentful/field-editor-rich-text 3.15.0 → 3.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ContentfulEditorProvider.js +8 -8
- package/dist/cjs/RichTextEditor.js +22 -20
- package/dist/cjs/RichTextEditor.styles.js +2 -1
- package/dist/cjs/SdkProvider.js +7 -5
- package/dist/cjs/SyncEditorChanges.js +15 -6
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +17 -15
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +14 -10
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +10 -8
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +2 -2
- package/dist/cjs/Toolbar/index.js +33 -30
- package/dist/cjs/__fixtures__/FakeSdk.js +3 -3
- package/dist/cjs/__fixtures__/asset/index.js +10 -10
- package/dist/cjs/__fixtures__/content-type/index.js +1 -1
- package/dist/cjs/__fixtures__/entry/index.js +7 -7
- package/dist/cjs/__fixtures__/fixtures.js +8 -6
- package/dist/cjs/__fixtures__/locale/index.js +2 -2
- package/dist/cjs/__fixtures__/space/index.js +1 -1
- package/dist/cjs/constants/Schema.js +1 -0
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +43 -38
- package/dist/cjs/dialogs/openRichTextDialog.js +6 -4
- package/dist/cjs/dialogs/renderRichTextDialog.js +6 -4
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +10 -10
- package/dist/cjs/helpers/callbacks.js +3 -3
- package/dist/cjs/helpers/config.js +2 -2
- package/dist/cjs/helpers/editor.js +53 -44
- package/dist/cjs/helpers/environment.js +3 -3
- package/dist/cjs/helpers/formatDateAndTime.js +5 -4
- package/dist/cjs/helpers/getAllowedResourcesForNodeType.js +22 -5
- package/dist/cjs/helpers/getLinkedContentTypeIdsForNodeType.js +29 -5
- package/dist/cjs/helpers/nodeFactory.js +6 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +14 -6
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +3 -2
- package/dist/cjs/helpers/toSlateValue.js +14 -3
- package/dist/cjs/helpers/transformers.js +5 -5
- package/dist/cjs/helpers/validations.js +12 -9
- package/dist/cjs/index.js +7 -5
- package/dist/cjs/internal/constants.js +4 -2
- package/dist/cjs/internal/hooks.js +8 -6
- package/dist/cjs/internal/misc.js +15 -12
- package/dist/cjs/internal/queries.js +115 -108
- package/dist/cjs/internal/transforms.js +51 -48
- package/dist/cjs/internal/types/editor.js +3 -1
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +4 -3
- package/dist/cjs/plugins/Break/createResetNodePlugin.js +1 -0
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +3 -3
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +35 -33
- package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +1 -1
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +7 -5
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +7 -3
- package/dist/cjs/plugins/CommandPalette/onKeyDown.js +6 -1
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +6 -4
- package/dist/cjs/plugins/CommandPalette/useCommands.js +3 -3
- package/dist/cjs/plugins/CommandPalette/utils/fetchEntries.js +2 -0
- package/dist/cjs/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
- package/dist/cjs/plugins/DragAndDrop/index.js +9 -1
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +10 -8
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +19 -17
- package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +9 -7
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +5 -5
- package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +13 -11
- package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +5 -5
- package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
- package/dist/cjs/plugins/Heading/components/Heading.js +13 -10
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +19 -11
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +7 -2
- package/dist/cjs/plugins/Hr/index.js +19 -14
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +32 -28
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +8 -6
- package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +8 -6
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +6 -4
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +7 -5
- package/dist/cjs/plugins/Hyperlink/components/styles.js +1 -1
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +10 -4
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +6 -3
- package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +6 -4
- package/dist/cjs/plugins/Hyperlink/utils.js +4 -4
- package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +13 -13
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +29 -25
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +22 -22
- package/dist/cjs/plugins/List/components/List.js +9 -7
- package/dist/cjs/plugins/List/components/ListItem.js +6 -4
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +7 -5
- package/dist/cjs/plugins/List/createListPlugin.js +4 -0
- package/dist/cjs/plugins/List/insertListBreak.js +13 -4
- package/dist/cjs/plugins/List/insertListFragment.js +18 -5
- package/dist/cjs/plugins/List/onKeyDownList.js +7 -4
- package/dist/cjs/plugins/List/transforms/insertListItem.js +17 -2
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +8 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.js +7 -2
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +15 -14
- package/dist/cjs/plugins/List/transforms/toggleList.js +8 -3
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/cjs/plugins/List/transforms/unwrapList.js +7 -2
- package/dist/cjs/plugins/List/utils.js +12 -11
- package/dist/cjs/plugins/List/withList.js +6 -2
- package/dist/cjs/plugins/Marks/Bold.js +9 -7
- package/dist/cjs/plugins/Marks/Code.js +15 -7
- package/dist/cjs/plugins/Marks/Italic.js +9 -7
- package/dist/cjs/plugins/Marks/Subscript.js +10 -8
- package/dist/cjs/plugins/Marks/Superscript.js +10 -8
- package/dist/cjs/plugins/Marks/Underline.js +6 -4
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +9 -7
- package/dist/cjs/plugins/Marks/helpers.js +5 -5
- package/dist/cjs/plugins/Normalizer/baseRules.js +2 -0
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/cjs/plugins/Normalizer/utils.js +4 -3
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +23 -3
- package/dist/cjs/plugins/Paragraph/Paragraph.js +6 -4
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +3 -2
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -6
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeAnchors.js +9 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
- package/dist/cjs/plugins/Quote/components/Quote.js +6 -4
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +6 -4
- package/dist/cjs/plugins/Quote/createQuotePlugin.js +1 -0
- package/dist/cjs/plugins/Quote/toggleQuote.js +5 -5
- package/dist/cjs/plugins/Quote/withQuote.js +4 -2
- package/dist/cjs/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
- package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +4 -4
- package/dist/cjs/plugins/Table/actions/addColumn.js +5 -4
- package/dist/cjs/plugins/Table/actions/addRow.js +6 -3
- package/dist/cjs/plugins/Table/components/Cell.js +7 -5
- package/dist/cjs/plugins/Table/components/HeaderCell.js +7 -5
- package/dist/cjs/plugins/Table/components/Row.js +6 -4
- package/dist/cjs/plugins/Table/components/Table.js +8 -6
- package/dist/cjs/plugins/Table/components/TableActions.js +19 -16
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +7 -4
- package/dist/cjs/plugins/Table/createTablePlugin.js +11 -1
- package/dist/cjs/plugins/Table/helpers.js +16 -12
- package/dist/cjs/plugins/Table/insertTableFragment.js +15 -2
- package/dist/cjs/plugins/Table/onKeyDownTable.js +10 -2
- package/dist/cjs/plugins/Table/tableTracking.js +6 -6
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
- package/dist/cjs/plugins/Text/createTextPlugin.js +22 -5
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +5 -4
- package/dist/cjs/plugins/Tracking/utils.js +6 -3
- package/dist/cjs/plugins/Voids/createVoidsPlugin.js +5 -0
- package/dist/cjs/plugins/Voids/transformVoid.js +1 -0
- package/dist/cjs/plugins/index.js +15 -3
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +12 -10
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +16 -6
- package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +10 -8
- package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +9 -5
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +13 -11
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +14 -12
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +14 -11
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +8 -4
- package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +10 -6
- package/dist/cjs/plugins/shared/ResourceNewBadge.js +5 -3
- package/dist/cjs/plugins/shared/ToolbarButton.js +8 -6
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +10 -5
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +11 -6
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +15 -13
- package/dist/cjs/plugins/shared/utils.js +4 -1
- package/dist/cjs/test-utils/assertOutput.js +1 -0
- package/dist/cjs/test-utils/hyperscript.d.js +1 -0
- package/dist/cjs/test-utils/randomId.js +3 -1
- package/dist/cjs/test-utils/validation.js +8 -5
- package/dist/esm/ContentfulEditorProvider.js +4 -1
- package/dist/esm/RichTextEditor.js +13 -13
- package/dist/esm/RichTextEditor.styles.js +1 -0
- package/dist/esm/SdkProvider.js +2 -2
- package/dist/esm/SyncEditorChanges.js +18 -3
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +12 -12
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +10 -8
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +6 -6
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
- package/dist/esm/Toolbar/index.js +28 -27
- package/dist/esm/__fixtures__/FakeSdk.js +3 -3
- package/dist/esm/constants/Schema.js +1 -0
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +34 -31
- package/dist/esm/dialogs/openRichTextDialog.js +2 -2
- package/dist/esm/dialogs/renderRichTextDialog.js +2 -2
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +10 -10
- package/dist/esm/helpers/callbacks.js +1 -1
- package/dist/esm/helpers/config.js +9 -1
- package/dist/esm/helpers/editor.js +22 -6
- package/dist/esm/helpers/extractNodes.js +3 -1
- package/dist/esm/helpers/formatDateAndTime.js +11 -2
- package/dist/esm/helpers/getAllowedResourcesForNodeType.js +19 -2
- package/dist/esm/helpers/getLinkedContentTypeIdsForNodeType.js +26 -2
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +20 -6
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +1 -0
- package/dist/esm/helpers/toSlateValue.js +17 -3
- package/dist/esm/helpers/validations.js +5 -1
- package/dist/esm/internal/misc.js +23 -2
- package/dist/esm/internal/queries.js +11 -2
- package/dist/esm/internal/transforms.js +14 -3
- package/dist/esm/internal/types/editor.js +3 -1
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +4 -3
- package/dist/esm/plugins/Break/createResetNodePlugin.js +1 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +3 -3
- package/dist/esm/plugins/CommandPalette/components/CommandList.js +30 -30
- package/dist/esm/plugins/CommandPalette/components/CommandPrompt.js +2 -2
- package/dist/esm/plugins/CommandPalette/createCommandPalettePlugin.js +11 -1
- package/dist/esm/plugins/CommandPalette/hooks/useCommandList.js +2 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.js +5 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +2 -2
- package/dist/esm/plugins/CommandPalette/useCommands.js +3 -3
- package/dist/esm/plugins/CommandPalette/utils/fetchEntries.js +2 -0
- package/dist/esm/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
- package/dist/esm/plugins/DragAndDrop/index.js +9 -1
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +6 -6
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +14 -14
- package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +5 -5
- package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +4 -4
- package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +9 -9
- package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +4 -4
- package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
- package/dist/esm/plugins/Heading/components/Heading.js +8 -7
- package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +14 -8
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +6 -1
- package/dist/esm/plugins/Hr/index.js +8 -5
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +25 -23
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +4 -4
- package/dist/esm/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +2 -2
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +3 -3
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +5 -1
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +6 -3
- package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +2 -2
- package/dist/esm/plugins/Hyperlink/utils.js +1 -1
- package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +13 -13
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +29 -25
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +22 -22
- package/dist/esm/plugins/List/components/List.js +1 -1
- package/dist/esm/plugins/List/components/ListItem.js +1 -1
- package/dist/esm/plugins/List/components/ToolbarListButton.js +3 -3
- package/dist/esm/plugins/List/createListPlugin.js +4 -0
- package/dist/esm/plugins/List/insertListBreak.js +13 -4
- package/dist/esm/plugins/List/insertListFragment.js +18 -5
- package/dist/esm/plugins/List/onKeyDownList.js +5 -2
- package/dist/esm/plugins/List/transforms/insertListItem.js +20 -3
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +8 -2
- package/dist/esm/plugins/List/transforms/moveListItems.js +7 -2
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +15 -14
- package/dist/esm/plugins/List/transforms/toggleList.js +8 -3
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +28 -28
- package/dist/esm/plugins/List/transforms/unwrapList.js +7 -2
- package/dist/esm/plugins/List/utils.js +7 -2
- package/dist/esm/plugins/List/withList.js +6 -2
- package/dist/esm/plugins/Marks/Bold.js +2 -2
- package/dist/esm/plugins/Marks/Code.js +8 -2
- package/dist/esm/plugins/Marks/Italic.js +2 -2
- package/dist/esm/plugins/Marks/Subscript.js +2 -2
- package/dist/esm/plugins/Marks/Superscript.js +2 -2
- package/dist/esm/plugins/Marks/Underline.js +2 -2
- package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +4 -4
- package/dist/esm/plugins/Marks/helpers.js +1 -1
- package/dist/esm/plugins/Normalizer/baseRules.js +4 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
- package/dist/esm/plugins/Normalizer/utils.js +1 -0
- package/dist/esm/plugins/Normalizer/withNormalizer.js +22 -2
- package/dist/esm/plugins/Paragraph/Paragraph.js +1 -1
- package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
- package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +2 -1
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -3
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
- package/dist/esm/plugins/PasteHTML/utils/sanitizeAnchors.js +27 -1
- package/dist/esm/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
- package/dist/esm/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
- package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
- package/dist/esm/plugins/Quote/components/Quote.js +1 -1
- package/dist/esm/plugins/Quote/components/ToolbarQuoteButton.js +2 -2
- package/dist/esm/plugins/Quote/createQuotePlugin.js +1 -0
- package/dist/esm/plugins/Quote/shouldResetQuote.js +6 -1
- package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
- package/dist/esm/plugins/Quote/withQuote.js +4 -2
- package/dist/esm/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
- package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +4 -4
- package/dist/esm/plugins/Table/actions/addColumn.js +2 -1
- package/dist/esm/plugins/Table/actions/addRow.js +3 -0
- package/dist/esm/plugins/Table/components/Cell.js +2 -2
- package/dist/esm/plugins/Table/components/HeaderCell.js +2 -2
- package/dist/esm/plugins/Table/components/Row.js +1 -1
- package/dist/esm/plugins/Table/components/Table.js +3 -3
- package/dist/esm/plugins/Table/components/TableActions.js +12 -11
- package/dist/esm/plugins/Table/components/ToolbarButton.js +3 -2
- package/dist/esm/plugins/Table/createTablePlugin.js +11 -1
- package/dist/esm/plugins/Table/helpers.js +10 -1
- package/dist/esm/plugins/Table/insertTableFragment.js +15 -2
- package/dist/esm/plugins/Table/onKeyDownTable.js +10 -2
- package/dist/esm/plugins/Table/tableTracking.js +6 -6
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
- package/dist/esm/plugins/Text/createTextPlugin.js +22 -5
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +2 -1
- package/dist/esm/plugins/Tracking/utils.js +1 -0
- package/dist/esm/plugins/Voids/createVoidsPlugin.js +5 -0
- package/dist/esm/plugins/Voids/transformVoid.js +4 -1
- package/dist/esm/plugins/index.js +12 -0
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +15 -5
- package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +5 -5
- package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +8 -4
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +8 -8
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +9 -9
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +9 -8
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +7 -3
- package/dist/esm/plugins/shared/LinkedInlineWrapper.js +5 -3
- package/dist/esm/plugins/shared/ResourceNewBadge.js +1 -1
- package/dist/esm/plugins/shared/ToolbarButton.js +3 -3
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -2
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +5 -2
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +8 -8
- package/dist/esm/plugins/shared/utils.js +4 -1
- package/dist/esm/test-utils/assertOutput.js +1 -0
- package/dist/esm/test-utils/hyperscript.d.js +1 -0
- package/dist/esm/test-utils/jsx.js +5 -1
- package/dist/esm/test-utils/randomId.js +3 -1
- package/dist/esm/test-utils/setEmptyDataAttribute.js +4 -1
- package/dist/esm/test-utils/validation.js +7 -4
- package/package.json +3 -3
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "Cell", {
|
|
|
8
8
|
return Cell;
|
|
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 _slatereact = require("slate-react");
|
|
15
15
|
const _TableActions = require("./TableActions");
|
|
@@ -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)) {
|
|
@@ -71,9 +73,9 @@ const style = (0, _emotion.css)`
|
|
|
71
73
|
`;
|
|
72
74
|
const Cell = (props)=>{
|
|
73
75
|
const isSelected = (0, _slatereact.useSelected)();
|
|
74
|
-
return _react.createElement("td", {
|
|
76
|
+
return /*#__PURE__*/ _react.createElement("td", {
|
|
75
77
|
...props.attributes,
|
|
76
78
|
...props.element.data,
|
|
77
79
|
className: style
|
|
78
|
-
}, isSelected && _react.createElement(_TableActions.TableActions, null), props.children);
|
|
80
|
+
}, isSelected && /*#__PURE__*/ _react.createElement(_TableActions.TableActions, null), props.children);
|
|
79
81
|
};
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "HeaderCell", {
|
|
|
8
8
|
return HeaderCell;
|
|
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 _slatereact = require("slate-react");
|
|
15
15
|
const _TableActions = require("./TableActions");
|
|
@@ -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)) {
|
|
@@ -74,9 +76,9 @@ const style = (0, _emotion.css)`
|
|
|
74
76
|
`;
|
|
75
77
|
const HeaderCell = (props)=>{
|
|
76
78
|
const isSelected = (0, _slatereact.useSelected)();
|
|
77
|
-
return _react.createElement("th", {
|
|
79
|
+
return /*#__PURE__*/ _react.createElement("th", {
|
|
78
80
|
...props.attributes,
|
|
79
81
|
...props.element.data,
|
|
80
82
|
className: style
|
|
81
|
-
}, isSelected && _react.createElement(_TableActions.TableActions, null), props.children);
|
|
83
|
+
}, isSelected && /*#__PURE__*/ _react.createElement(_TableActions.TableActions, null), props.children);
|
|
82
84
|
};
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "Row", {
|
|
|
8
8
|
return Row;
|
|
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
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
@@ -37,7 +37,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
37
37
|
if (cache && cache.has(obj)) {
|
|
38
38
|
return cache.get(obj);
|
|
39
39
|
}
|
|
40
|
-
var newObj = {
|
|
40
|
+
var newObj = {
|
|
41
|
+
__proto__: null
|
|
42
|
+
};
|
|
41
43
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
42
44
|
for(var key in obj){
|
|
43
45
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -63,7 +65,7 @@ const style = (0, _emotion.css)`
|
|
|
63
65
|
background-color: transparent !important;
|
|
64
66
|
}
|
|
65
67
|
`;
|
|
66
|
-
const Row = (props)
|
|
68
|
+
const Row = (props)=>/*#__PURE__*/ _react.createElement("tr", {
|
|
67
69
|
...props.attributes,
|
|
68
70
|
className: style
|
|
69
71
|
}, props.children);
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "Table", {
|
|
|
8
8
|
return Table;
|
|
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 _richtexttypes = require("@contentful/rich-text-types");
|
|
14
14
|
const _emotion = require("emotion");
|
|
15
15
|
function _interop_require_default(obj) {
|
|
@@ -38,7 +38,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
38
38
|
if (cache && cache.has(obj)) {
|
|
39
39
|
return cache.get(obj);
|
|
40
40
|
}
|
|
41
|
-
var newObj = {
|
|
41
|
+
var newObj = {
|
|
42
|
+
__proto__: null
|
|
43
|
+
};
|
|
42
44
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
45
|
for(var key in obj){
|
|
44
46
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -67,10 +69,10 @@ const style = (0, _emotion.css)`
|
|
|
67
69
|
overflow: hidden;
|
|
68
70
|
`;
|
|
69
71
|
const Table = (props)=>{
|
|
70
|
-
return _react.createElement("div", {
|
|
72
|
+
return /*#__PURE__*/ _react.createElement("div", {
|
|
71
73
|
"data-block-type": _richtexttypes.BLOCKS.TABLE
|
|
72
|
-
}, _react.createElement("table", {
|
|
74
|
+
}, /*#__PURE__*/ _react.createElement("table", {
|
|
73
75
|
className: style,
|
|
74
76
|
...props.attributes
|
|
75
|
-
}, _react.createElement("tbody", null, props.children)));
|
|
77
|
+
}, /*#__PURE__*/ _react.createElement("tbody", null, props.children)));
|
|
76
78
|
};
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
styles: function() {
|
|
13
|
-
return styles;
|
|
14
|
-
},
|
|
15
12
|
TableActions: function() {
|
|
16
13
|
return TableActions;
|
|
14
|
+
},
|
|
15
|
+
styles: function() {
|
|
16
|
+
return styles;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
20
|
const _f36components = require("@contentful/f36-components");
|
|
21
21
|
const _f36icons = require("@contentful/f36-icons");
|
|
22
22
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
@@ -50,7 +50,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
50
50
|
if (cache && cache.has(obj)) {
|
|
51
51
|
return cache.get(obj);
|
|
52
52
|
}
|
|
53
|
-
var newObj = {
|
|
53
|
+
var newObj = {
|
|
54
|
+
__proto__: null
|
|
55
|
+
};
|
|
54
56
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
57
|
for(var key in obj){
|
|
56
58
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -127,6 +129,7 @@ const TableActions = ()=>{
|
|
|
127
129
|
header: isHeaderEnabled
|
|
128
130
|
});
|
|
129
131
|
});
|
|
132
|
+
// Tracking
|
|
130
133
|
const actionName = `${type}Table${element === 'Table' ? '' : element}`;
|
|
131
134
|
editor.tracking.onViewportAction(actionName, {
|
|
132
135
|
tableSize
|
|
@@ -139,37 +142,37 @@ const TableActions = ()=>{
|
|
|
139
142
|
if (isDisabled) {
|
|
140
143
|
return null;
|
|
141
144
|
}
|
|
142
|
-
return _react.createElement(_f36components.Menu, {
|
|
145
|
+
return /*#__PURE__*/ _react.createElement(_f36components.Menu, {
|
|
143
146
|
placement: "left",
|
|
144
147
|
isOpen: isOpen,
|
|
145
148
|
onOpen: ()=>{
|
|
146
149
|
setOpen(true);
|
|
147
150
|
},
|
|
148
151
|
onClose: close
|
|
149
|
-
}, _react.createElement(_f36components.Menu.Trigger, null, _react.createElement(_f36components.IconButton, {
|
|
152
|
+
}, /*#__PURE__*/ _react.createElement(_f36components.Menu.Trigger, null, /*#__PURE__*/ _react.createElement(_f36components.IconButton, {
|
|
150
153
|
size: "small",
|
|
151
154
|
variant: "transparent",
|
|
152
155
|
tabIndex: -1,
|
|
153
156
|
className: styles.topRight,
|
|
154
|
-
icon: _react.createElement(_f36icons.ChevronDownIcon, null),
|
|
157
|
+
icon: /*#__PURE__*/ _react.createElement(_f36icons.ChevronDownIcon, null),
|
|
155
158
|
"aria-label": "Open table menu",
|
|
156
159
|
testId: "cf-table-actions-button"
|
|
157
|
-
})), _react.createElement(_f36components.Menu.List, null, _react.createElement(_f36components.Menu.Item, {
|
|
160
|
+
})), /*#__PURE__*/ _react.createElement(_f36components.Menu.List, null, /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
158
161
|
onClick: action(_actions.addRowAbove, 'insert', 'Row'),
|
|
159
162
|
disabled: !canInsertRowAbove
|
|
160
|
-
}, "Add row above"), _react.createElement(_f36components.Menu.Item, {
|
|
163
|
+
}, "Add row above"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
161
164
|
onClick: action(_actions.addRowBelow, 'insert', 'Row')
|
|
162
|
-
}, "Add row below"), _react.createElement(_f36components.Menu.Item, {
|
|
165
|
+
}, "Add row below"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
163
166
|
onClick: action(_actions.addColumnLeft, 'insert', 'Column')
|
|
164
|
-
}, "Add column left"), _react.createElement(_f36components.Menu.Item, {
|
|
167
|
+
}, "Add column left"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
165
168
|
onClick: action(_actions.addColumnRight, 'insert', 'Column')
|
|
166
|
-
}, "Add column right"), _react.createElement(_f36components.Menu.Divider, null), _react.createElement(_f36components.Menu.Item, {
|
|
169
|
+
}, "Add column right"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Divider, null), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
167
170
|
onClick: toggleHeader
|
|
168
|
-
}, isHeaderEnabled ? 'Disable table header' : 'Enable table header'), _react.createElement(_f36components.Menu.Divider, null), _react.createElement(_f36components.Menu.Item, {
|
|
171
|
+
}, isHeaderEnabled ? 'Disable table header' : 'Enable table header'), /*#__PURE__*/ _react.createElement(_f36components.Menu.Divider, null), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
169
172
|
onClick: action(_platetable.deleteRow, 'remove', 'Row')
|
|
170
|
-
}, "Delete row"), _react.createElement(_f36components.Menu.Item, {
|
|
173
|
+
}, "Delete row"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
171
174
|
onClick: action(_platetable.deleteColumn, 'remove', 'Column')
|
|
172
|
-
}, "Delete column"), _react.createElement(_f36components.Menu.Item, {
|
|
175
|
+
}, "Delete column"), /*#__PURE__*/ _react.createElement(_f36components.Menu.Item, {
|
|
173
176
|
onClick: action(_platetable.deleteTable, 'remove', 'Table')
|
|
174
177
|
}, "Delete table")));
|
|
175
178
|
};
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "ToolbarTableButton", {
|
|
|
8
8
|
return ToolbarTableButton;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
11
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
12
|
const _f36icons = require("@contentful/f36-icons");
|
|
13
13
|
const _ContentfulEditorProvider = require("../../../ContentfulEditorProvider");
|
|
14
14
|
const _editor = require("../../../helpers/editor");
|
|
@@ -35,7 +35,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
35
35
|
if (cache && cache.has(obj)) {
|
|
36
36
|
return cache.get(obj);
|
|
37
37
|
}
|
|
38
|
-
var newObj = {
|
|
38
|
+
var newObj = {
|
|
39
|
+
__proto__: null
|
|
40
|
+
};
|
|
39
41
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
42
|
for(var key in obj){
|
|
41
43
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -63,11 +65,12 @@ function ToolbarTableButton(props) {
|
|
|
63
65
|
(0, _editor.focus)(editor);
|
|
64
66
|
}
|
|
65
67
|
if (!editor) return null;
|
|
66
|
-
return _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
68
|
+
return /*#__PURE__*/ _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
67
69
|
title: "Table",
|
|
68
70
|
testId: "table-toolbar-button",
|
|
69
71
|
onClick: handleClick,
|
|
72
|
+
// TODO: active state looks off since the button will be disabled. Do we still need it?
|
|
70
73
|
isActive: !!isActive,
|
|
71
74
|
isDisabled: props.isDisabled
|
|
72
|
-
}, _react.createElement(_f36icons.TableIcon, null));
|
|
75
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.TableIcon, null));
|
|
73
76
|
}
|
|
@@ -25,11 +25,15 @@ const _tableTracking = require("./tableTracking");
|
|
|
25
25
|
const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
26
26
|
type: _richtexttypes.BLOCKS.TABLE,
|
|
27
27
|
handlers: {
|
|
28
|
+
// @ts-expect-error
|
|
28
29
|
onKeyDown: _onKeyDownTable.onKeyDownTable
|
|
29
30
|
},
|
|
30
31
|
withOverrides: (editor, plugin)=>{
|
|
31
|
-
const { normalizeNode
|
|
32
|
+
const { normalizeNode } = editor;
|
|
33
|
+
// injects important fixes from plate's original table plugin
|
|
32
34
|
(0, _platetable.withTable)(editor, plugin);
|
|
35
|
+
// Resets all normalization rules added by @udecode/plate-table as
|
|
36
|
+
// they conflict with our own
|
|
33
37
|
editor.normalizeNode = normalizeNode;
|
|
34
38
|
(0, _tableTracking.addTableTrackingEvents)(editor);
|
|
35
39
|
editor.insertFragment = (0, _insertTableFragment.insertTableFragment)(editor);
|
|
@@ -44,7 +48,10 @@ const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
|
44
48
|
validNode: _helpers.isNotEmpty
|
|
45
49
|
},
|
|
46
50
|
{
|
|
51
|
+
// Move to root level unless nested
|
|
47
52
|
validNode: (editor, [, path])=>{
|
|
53
|
+
// Nested tables are handled by another normalization
|
|
54
|
+
// rule in a the table cell level
|
|
48
55
|
const isNestedTable = !!(0, _queries.getBlockAbove)(editor, {
|
|
49
56
|
at: path,
|
|
50
57
|
match: {
|
|
@@ -72,9 +79,11 @@ const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
|
72
79
|
transform: (0, _transformers.transformWrapIn)(_richtexttypes.BLOCKS.TABLE_CELL)
|
|
73
80
|
},
|
|
74
81
|
{
|
|
82
|
+
// Remove empty rows
|
|
75
83
|
validNode: _helpers.isNotEmpty
|
|
76
84
|
},
|
|
77
85
|
{
|
|
86
|
+
// Parent must be a table
|
|
78
87
|
validNode: (editor, [, path])=>{
|
|
79
88
|
const parent = (0, _queries.getParentNode)(editor, path)?.[0];
|
|
80
89
|
return parent && parent.type === _richtexttypes.BLOCKS.TABLE;
|
|
@@ -82,6 +91,7 @@ const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
|
82
91
|
transform: (0, _transformers.transformWrapIn)(_richtexttypes.BLOCKS.TABLE)
|
|
83
92
|
},
|
|
84
93
|
{
|
|
94
|
+
// ensure consistent number of cells in each row
|
|
85
95
|
validNode: (editor, entry)=>{
|
|
86
96
|
return (0, _helpers.getNoOfMissingTableCellsInRow)(editor, entry) === 0;
|
|
87
97
|
},
|
|
@@ -9,9 +9,21 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
createEmptyTableCells: function() {
|
|
13
|
+
return createEmptyTableCells;
|
|
14
|
+
},
|
|
15
|
+
getNoOfMissingTableCellsInRow: function() {
|
|
16
|
+
return getNoOfMissingTableCellsInRow;
|
|
17
|
+
},
|
|
12
18
|
insertTableAndFocusFirstCell: function() {
|
|
13
19
|
return insertTableAndFocusFirstCell;
|
|
14
20
|
},
|
|
21
|
+
isNotEmpty: function() {
|
|
22
|
+
return isNotEmpty;
|
|
23
|
+
},
|
|
24
|
+
isTable: function() {
|
|
25
|
+
return isTable;
|
|
26
|
+
},
|
|
15
27
|
isTableActive: function() {
|
|
16
28
|
return isTableActive;
|
|
17
29
|
},
|
|
@@ -20,18 +32,6 @@ _export(exports, {
|
|
|
20
32
|
},
|
|
21
33
|
replaceEmptyParagraphWithTable: function() {
|
|
22
34
|
return replaceEmptyParagraphWithTable;
|
|
23
|
-
},
|
|
24
|
-
getNoOfMissingTableCellsInRow: function() {
|
|
25
|
-
return getNoOfMissingTableCellsInRow;
|
|
26
|
-
},
|
|
27
|
-
createEmptyTableCells: function() {
|
|
28
|
-
return createEmptyTableCells;
|
|
29
|
-
},
|
|
30
|
-
isNotEmpty: function() {
|
|
31
|
-
return isNotEmpty;
|
|
32
|
-
},
|
|
33
|
-
isTable: function() {
|
|
34
|
-
return isTable;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
@@ -107,10 +107,12 @@ function replaceEmptyParagraphWithTable(editor) {
|
|
|
107
107
|
const [previousNode] = nodes;
|
|
108
108
|
const isPreviousNodeTextEmpty = (0, _queries.isAncestorEmpty)(editor, previousNode);
|
|
109
109
|
if (isPreviousNodeTextEmpty) {
|
|
110
|
+
// Switch table with previous empty paragraph
|
|
110
111
|
(0, _transforms.moveNodes)(editor, {
|
|
111
112
|
at: tablePath,
|
|
112
113
|
to: previousPath
|
|
113
114
|
});
|
|
115
|
+
// Remove previous paragraph that now is under the table
|
|
114
116
|
(0, _transforms.removeNodes)(editor, {
|
|
115
117
|
at: tablePath
|
|
116
118
|
});
|
|
@@ -119,9 +121,11 @@ function replaceEmptyParagraphWithTable(editor) {
|
|
|
119
121
|
const getNoOfMissingTableCellsInRow = (editor, rowEntry)=>{
|
|
120
122
|
const [, rowPath] = rowEntry;
|
|
121
123
|
const parent = (0, _queries.getParentNode)(editor, rowPath);
|
|
124
|
+
// This is ensured by normalization. The error is here just in case
|
|
122
125
|
if (!parent) {
|
|
123
126
|
throw new Error('table rows must be wrapped in a table node');
|
|
124
127
|
}
|
|
128
|
+
// The longest table row determines its width
|
|
125
129
|
const tableWidth = Math.max(...(0, _queries.getChildren)(parent).map((entry)=>(0, _queries.getChildren)(entry).length));
|
|
126
130
|
const rowWidth = (0, _queries.getChildren)(rowEntry).length;
|
|
127
131
|
return tableWidth - rowWidth;
|
|
@@ -12,18 +12,29 @@ const _richtexttypes = require("@contentful/rich-text-types");
|
|
|
12
12
|
const _editor = require("../../helpers/editor");
|
|
13
13
|
const _queries = require("../../internal/queries");
|
|
14
14
|
const _helpers = require("./helpers");
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Removes table wrappers when pasting a single table cell
|
|
17
|
+
*
|
|
18
|
+
* In Plate/Slate, copying the content of a table cell wraps
|
|
19
|
+
* it in a <table><tr><td>{content}</td></tr></table> even
|
|
20
|
+
* when copying partial cell content.
|
|
21
|
+
*
|
|
22
|
+
* That's really annoying as there is no way to remove the table
|
|
23
|
+
* wrappers in that case.
|
|
24
|
+
*/ const trimUnnecessaryTableWrapper = (node)=>{
|
|
16
25
|
if (!(0, _queries.isElement)(node)) {
|
|
17
26
|
return [
|
|
18
27
|
node
|
|
19
28
|
];
|
|
20
29
|
}
|
|
30
|
+
// must be a table with a single row
|
|
21
31
|
if (node.type !== _richtexttypes.BLOCKS.TABLE || node.children?.length !== 1) {
|
|
22
32
|
return [
|
|
23
33
|
node
|
|
24
34
|
];
|
|
25
35
|
}
|
|
26
36
|
const row = node.children[0];
|
|
37
|
+
// the row must contain a single cell
|
|
27
38
|
if (row?.children?.length !== 1) {
|
|
28
39
|
return [
|
|
29
40
|
node
|
|
@@ -33,12 +44,14 @@ const trimUnnecessaryTableWrapper = (node)=>{
|
|
|
33
44
|
return cell.children;
|
|
34
45
|
};
|
|
35
46
|
const insertTableFragment = (editor)=>{
|
|
36
|
-
const { insertFragment
|
|
47
|
+
const { insertFragment } = editor;
|
|
37
48
|
return (fragments)=>{
|
|
38
49
|
if (!editor.selection) {
|
|
39
50
|
return;
|
|
40
51
|
}
|
|
41
52
|
fragments = fragments.flatMap(trimUnnecessaryTableWrapper);
|
|
53
|
+
// We need to make sure we have a new, empty and clean paragraph in order to paste tables as-is due to how Slate behaves
|
|
54
|
+
// More info: https://github.com/ianstormtaylor/slate/pull/4489 and https://github.com/ianstormtaylor/slate/issues/4542
|
|
42
55
|
const isInsertingTable = fragments.some((fragment)=>(0, _helpers.isTable)(fragment));
|
|
43
56
|
const isTableFirstFragment = fragments.findIndex((fragment)=>(0, _helpers.isTable)(fragment)) === 0;
|
|
44
57
|
const currentLineHasText = (0, _queries.getText)(editor, editor.selection?.focus.path) !== '';
|
|
@@ -17,8 +17,12 @@ const _actions = require("./actions");
|
|
|
17
17
|
const onKeyDownTable = (editor, plugin)=>{
|
|
18
18
|
const defaultHandler = (0, _platetable.onKeyDownTable)(editor, plugin);
|
|
19
19
|
return (event)=>{
|
|
20
|
+
// This fixes `Cannot resolve a Slate point from DOM point:
|
|
21
|
+
// [object HTMLDivElement]` when typing while the cursor is before table
|
|
20
22
|
const windowSelection = window.getSelection();
|
|
21
23
|
if (windowSelection) {
|
|
24
|
+
// @ts-expect-error
|
|
25
|
+
// this attribute comes from `plugins/Table/components/Table.tsx`
|
|
22
26
|
const blockType = windowSelection.anchorNode.attributes?.['data-block-type']?.value;
|
|
23
27
|
const isBeforeTable = blockType === _richtexttypes.BLOCKS.TABLE;
|
|
24
28
|
if (isBeforeTable) {
|
|
@@ -40,10 +44,11 @@ const onKeyDownTable = (editor, plugin)=>{
|
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
47
|
+
// TODO clean this up
|
|
43
48
|
if (event.key === 'Backspace') {
|
|
44
49
|
const entry = (0, _platetable.getTableEntries)(editor, {});
|
|
45
50
|
if (entry) {
|
|
46
|
-
const { table
|
|
51
|
+
const { table, row, cell } = entry;
|
|
47
52
|
const cellText = (0, _queries.getText)(editor, cell[1]);
|
|
48
53
|
const isFirstCell = (0, _queries.isFirstChild)(row[1]);
|
|
49
54
|
const isFirstRow = (0, _queries.isFirstChild)(table[1]);
|
|
@@ -54,15 +59,18 @@ const onKeyDownTable = (editor, plugin)=>{
|
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
}
|
|
62
|
+
// Pressing Tab on the last cell creates a new row
|
|
63
|
+
// Otherwise, jumping between cells is handled in the defaultKeyDownTable
|
|
57
64
|
if (event.key === 'Tab' && !event.shiftKey) {
|
|
58
65
|
event.preventDefault();
|
|
59
66
|
const entry = (0, _platetable.getTableEntries)(editor, {});
|
|
60
67
|
if (entry) {
|
|
61
|
-
const { table
|
|
68
|
+
const { table, row, cell } = entry;
|
|
62
69
|
const isLastCell = (0, _queries.isLastChildPath)(row, cell[1]);
|
|
63
70
|
const isLastRow = (0, _queries.isLastChildPath)(table, row[1]);
|
|
64
71
|
if (isLastRow && isLastCell) {
|
|
65
72
|
(0, _actions.addRowBelow)(editor);
|
|
73
|
+
// skip default handler
|
|
66
74
|
return;
|
|
67
75
|
} else {
|
|
68
76
|
defaultHandler(event);
|
|
@@ -20,22 +20,22 @@ const _richtexttypes = require("@contentful/rich-text-types");
|
|
|
20
20
|
const _queries = require("../../internal/queries");
|
|
21
21
|
const _Tracking = require("../../plugins/Tracking");
|
|
22
22
|
function hasTables(nodes) {
|
|
23
|
-
return nodes.some(({ type
|
|
23
|
+
return nodes.some(({ type })=>{
|
|
24
24
|
return type === _richtexttypes.BLOCKS.TABLE;
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
const isTableHeaderCell = ({ type
|
|
27
|
+
const isTableHeaderCell = ({ type })=>type === _richtexttypes.BLOCKS.TABLE_HEADER_CELL;
|
|
28
28
|
function hasHeadersOutsideFirstRow(nodes) {
|
|
29
|
-
return nodes.filter(({ type
|
|
29
|
+
return nodes.filter(({ type })=>type === _richtexttypes.BLOCKS.TABLE).flatMap(({ children })=>children.slice(1)).some(({ children })=>children.some(isTableHeaderCell));
|
|
30
30
|
}
|
|
31
31
|
function addTableTrackingEvents(editor) {
|
|
32
|
-
const { insertData
|
|
32
|
+
const { insertData } = editor;
|
|
33
33
|
editor.insertData = (data)=>{
|
|
34
34
|
const html = data.getData('text/html');
|
|
35
35
|
if (html) {
|
|
36
|
-
const { children: markupBefore
|
|
36
|
+
const { children: markupBefore } = editor;
|
|
37
37
|
insertData(data);
|
|
38
|
-
const { children: markupAfter
|
|
38
|
+
const { children: markupAfter } = editor;
|
|
39
39
|
setTimeout(()=>{
|
|
40
40
|
if (hasTables(markupBefore)) return;
|
|
41
41
|
if (hasTables(markupAfter)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
/** @jsx jsx */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
@@ -7,21 +7,22 @@ describe('delete backward', ()=>{
|
|
|
7
7
|
const tests = [
|
|
8
8
|
{
|
|
9
9
|
title: 'deletes a character of the text inside li',
|
|
10
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1", (0, _testutils.jsx)("cursor", null)))),
|
|
11
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p", (0, _testutils.jsx)("cursor", null))))
|
|
10
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
11
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))))
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
title: 'does not delete the very first paragraph',
|
|
15
|
-
input: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "text")),
|
|
16
|
-
expected: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "text"))
|
|
15
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text")),
|
|
16
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text"))
|
|
17
17
|
}
|
|
18
18
|
];
|
|
19
|
-
const render = (children)
|
|
19
|
+
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
20
20
|
for (const t of tests){
|
|
21
21
|
test(t.title, ()=>{
|
|
22
|
-
const { editor
|
|
22
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
23
23
|
input: render(t.input)
|
|
24
24
|
});
|
|
25
|
+
// Equivalent of pressing backspace
|
|
25
26
|
editor.deleteBackward('character');
|
|
26
27
|
(0, _testutils.assertOutput)({
|
|
27
28
|
editor,
|
|
@@ -34,31 +35,32 @@ describe('delete forward', ()=>{
|
|
|
34
35
|
const tests = [
|
|
35
36
|
{
|
|
36
37
|
title: 'deletes a character of the text inside li',
|
|
37
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p1"))),
|
|
38
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "1")))
|
|
38
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "p1"))),
|
|
39
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "1")))
|
|
39
40
|
},
|
|
40
41
|
{
|
|
41
42
|
title: 'deletes the first paragraph when followed by another paragraph',
|
|
42
|
-
input: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "text")),
|
|
43
|
-
expected: (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "text")
|
|
43
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "text")),
|
|
44
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "text")
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
47
|
title: 'deletes the first paragraph when followed by li',
|
|
47
|
-
input: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1")))),
|
|
48
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p1")))
|
|
48
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1")))),
|
|
49
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "p1")))
|
|
49
50
|
},
|
|
50
51
|
{
|
|
51
52
|
title: 'deletes the first paragraph when followed by a blockquote',
|
|
52
|
-
input: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hquote", null, (0, _testutils.jsx)("hp", null, "p1"))),
|
|
53
|
-
expected: (0, _testutils.jsx)("hquote", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p1"))
|
|
53
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1"))),
|
|
54
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hquote", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "p1"))
|
|
54
55
|
}
|
|
55
56
|
];
|
|
56
|
-
const render = (children)
|
|
57
|
+
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
57
58
|
for (const t of tests){
|
|
58
59
|
test(t.title, ()=>{
|
|
59
|
-
const { editor
|
|
60
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
60
61
|
input: render(t.input)
|
|
61
62
|
});
|
|
63
|
+
// Equivalent of pressing backspace
|
|
62
64
|
editor.deleteForward('character');
|
|
63
65
|
(0, _testutils.assertOutput)({
|
|
64
66
|
editor,
|
|
@@ -15,6 +15,9 @@ function createTextPlugin(restrictedMarks = []) {
|
|
|
15
15
|
return {
|
|
16
16
|
key: 'TextPlugin',
|
|
17
17
|
handlers: {
|
|
18
|
+
// Triple selection in a non-Firefox browser undesirably selects
|
|
19
|
+
// the start of the next block. Editor.unhangRange helps removing
|
|
20
|
+
// the extra block at the end.
|
|
18
21
|
onMouseUp: (editor)=>()=>{
|
|
19
22
|
if (!editor.selection) {
|
|
20
23
|
return;
|
|
@@ -23,9 +26,16 @@ function createTextPlugin(restrictedMarks = []) {
|
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
withOverrides: (editor)=>{
|
|
26
|
-
|
|
29
|
+
// Reverts the change made upstream that caused the cursor
|
|
30
|
+
// to be trapped inside inline elements.
|
|
31
|
+
//
|
|
32
|
+
// Reverts https://github.com/ianstormtaylor/slate/pull/4578/
|
|
33
|
+
// Related https://github.com/ianstormtaylor/slate/issues/4704
|
|
34
|
+
const { insertText } = editor;
|
|
27
35
|
editor.insertText = (text)=>{
|
|
28
|
-
const { selection
|
|
36
|
+
const { selection } = editor;
|
|
37
|
+
// If the cursor is at the end of an inline, move it outside
|
|
38
|
+
// before inserting
|
|
29
39
|
if (selection && (0, _queries.isRangeCollapsed)(selection)) {
|
|
30
40
|
const inlinePath = (0, _queries.getAboveNode)(editor, {
|
|
31
41
|
match: (n)=>(0, _queries.isInline)(editor, n),
|
|
@@ -41,7 +51,8 @@ function createTextPlugin(restrictedMarks = []) {
|
|
|
41
51
|
}
|
|
42
52
|
return insertText(text);
|
|
43
53
|
};
|
|
44
|
-
|
|
54
|
+
// When pressing delete instead of backspace
|
|
55
|
+
const { deleteForward, deleteBackward } = editor;
|
|
45
56
|
editor.deleteBackward = (unit)=>{
|
|
46
57
|
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
47
58
|
};
|
|
@@ -77,8 +88,9 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
77
88
|
if (entry) {
|
|
78
89
|
const [paragraphOrHeading, path] = entry;
|
|
79
90
|
const isTextEmpty = (0, _queries.isAncestorEmpty)(editor, paragraphOrHeading);
|
|
91
|
+
// We ignore paragraphs/headings that are children of ul, ol, blockquote, tables, etc
|
|
80
92
|
const isRootLevel = path.length === 1;
|
|
81
|
-
const hasSiblings = editor.children.length > 1;
|
|
93
|
+
const hasSiblings = editor.children.length > 1; // prevent editor from losing focus
|
|
82
94
|
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
83
95
|
(0, _transforms.removeNodes)(editor, {
|
|
84
96
|
at: path
|
|
@@ -112,7 +124,11 @@ function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
|
112
124
|
deleteFunction(unit);
|
|
113
125
|
}
|
|
114
126
|
}
|
|
115
|
-
|
|
127
|
+
/**
|
|
128
|
+
* To be compatible with the old behavior we need to treat each 2 consecutive
|
|
129
|
+
* line breaks as a new paragraph when pasting as plain text (also known as
|
|
130
|
+
* paste and match style in macOS)
|
|
131
|
+
*/ function fixPasteAsPlainText(editor) {
|
|
116
132
|
editor.insertTextData = (data)=>{
|
|
117
133
|
const text = data.getData('text/plain');
|
|
118
134
|
if (!text) {
|
|
@@ -121,6 +137,7 @@ function fixPasteAsPlainText(editor) {
|
|
|
121
137
|
const lines = text.split(/\n{2}/);
|
|
122
138
|
let split = false;
|
|
123
139
|
for (const line of lines){
|
|
140
|
+
// empty lines
|
|
124
141
|
if (/^(\r\n?|\n)$/.test(line)) {
|
|
125
142
|
continue;
|
|
126
143
|
}
|