@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,44 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
/* eslint-disable react/no-unknown-property */ /** @jsx jsx */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _testutils = require("../../../test-utils");
|
|
6
6
|
describe('normalization', ()=>{
|
|
7
7
|
it('wraps orphaned list items in a list', ()=>{
|
|
8
|
-
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item")), (0, _testutils.jsx)("hp", null));
|
|
9
|
-
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
8
|
+
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
9
|
+
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
10
10
|
(0, _testutils.assertOutput)({
|
|
11
11
|
input,
|
|
12
12
|
expected
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
it('adds empty paragraph to empty list items', ()=>{
|
|
16
|
-
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null)), (0, _testutils.jsx)("hp", null));
|
|
17
|
-
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
16
|
+
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
17
|
+
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
18
18
|
(0, _testutils.assertOutput)({
|
|
19
19
|
input,
|
|
20
20
|
expected
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
it('replaces invalid list items with text', ()=>{
|
|
24
|
-
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item"), (0, _testutils.jsx)("htd", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", {
|
|
24
|
+
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item"), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
25
25
|
bold: true
|
|
26
|
-
}, "bold text"))), (0, _testutils.jsx)("htd", null, (0, _testutils.jsx)("hp", null, "Take a look at this ", (0, _testutils.jsx)("hlink", {
|
|
26
|
+
}, "bold text"))), /*#__PURE__*/ (0, _testutils.jsx)("htd", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Take a look at this ", /*#__PURE__*/ (0, _testutils.jsx)("hlink", {
|
|
27
27
|
uri: "https://google.com"
|
|
28
|
-
}, "link"))))), (0, _testutils.jsx)("hp", null));
|
|
29
|
-
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item"), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", {
|
|
28
|
+
}, "link"))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null));
|
|
29
|
+
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", {
|
|
30
30
|
bold: true
|
|
31
|
-
}, "bold text")), (0, _testutils.jsx)("hp", null, "Take a look at this ", (0, _testutils.jsx)("hlink", {
|
|
31
|
+
}, "bold text")), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Take a look at this ", /*#__PURE__*/ (0, _testutils.jsx)("hlink", {
|
|
32
32
|
uri: "https://google.com"
|
|
33
|
-
}, "link"), (0, _testutils.jsx)("htext", null)))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
33
|
+
}, "link"), /*#__PURE__*/ (0, _testutils.jsx)("htext", null)))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
34
34
|
(0, _testutils.assertOutput)({
|
|
35
35
|
input,
|
|
36
36
|
expected
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
it('replaces list items with nested lists as a first child', ()=>{
|
|
40
|
-
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 1.1")))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.2"))))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
41
|
-
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 1.1")))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Item 2.2"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
40
|
+
const input = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.2"))))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
41
|
+
const expected = /*#__PURE__*/ (0, _testutils.jsx)("editor", null, /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1"), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.1.1")))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "Item 2.2"))), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
42
42
|
(0, _testutils.assertOutput)({
|
|
43
43
|
input,
|
|
44
44
|
expected
|
|
@@ -1,72 +1,76 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
/** @jsx jsx */ "use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
const _testutils = require("../../../test-utils");
|
|
6
6
|
describe('insert line break', ()=>{
|
|
7
7
|
const tests = [
|
|
8
|
+
// single p
|
|
8
9
|
{
|
|
9
10
|
title: 'at the start of a li',
|
|
10
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p1"))),
|
|
11
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1")))
|
|
11
|
+
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"))),
|
|
12
|
+
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))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1")))
|
|
12
13
|
},
|
|
13
14
|
{
|
|
14
15
|
title: 'at the end of a li',
|
|
15
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1", (0, _testutils.jsx)("cursor", null)))),
|
|
16
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))))
|
|
16
|
+
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)))),
|
|
17
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))))
|
|
17
18
|
},
|
|
18
19
|
{
|
|
19
20
|
title: 'at the middle of a li',
|
|
20
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "split ", (0, _testutils.jsx)("cursor", null), "me"))),
|
|
21
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "split ")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "me")))
|
|
21
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "split ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me"))),
|
|
22
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "split ")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me")))
|
|
22
23
|
},
|
|
24
|
+
// multi p
|
|
23
25
|
{
|
|
24
26
|
title: 'at the start of a li with multiple p',
|
|
25
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p1"), (0, _testutils.jsx)("hp", null, "p2"))),
|
|
26
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, "p2")))
|
|
27
|
+
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"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p2"))),
|
|
28
|
+
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))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p2")))
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
title: 'at the start of the second p of a li',
|
|
30
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "p2"))),
|
|
31
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "p2")))
|
|
32
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "p2"))),
|
|
33
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p2")))
|
|
32
34
|
},
|
|
33
35
|
{
|
|
34
36
|
title: 'at the end of a li with multiple p',
|
|
35
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null)))),
|
|
36
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, "p2")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))))
|
|
37
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p2", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
38
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p1"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "p2")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))))
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
title: 'at the middle of a li with multiple p',
|
|
40
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "split ", (0, _testutils.jsx)("cursor", null), "me"), (0, _testutils.jsx)("hp", null, "move me"))),
|
|
41
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "split ")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null), "me"), (0, _testutils.jsx)("hp", null, "move me")))
|
|
42
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "split ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "move me"))),
|
|
43
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "split ")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "move me")))
|
|
42
44
|
},
|
|
45
|
+
// with headings
|
|
43
46
|
{
|
|
44
47
|
title: 'at the start of a li with heading',
|
|
45
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, (0, _testutils.jsx)("cursor", null), "p1"))),
|
|
46
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "p1")))
|
|
48
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", 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))), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "p1")))
|
|
47
50
|
},
|
|
48
51
|
{
|
|
49
52
|
title: 'at the end of a li with heading',
|
|
50
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "p1", (0, _testutils.jsx)("cursor", null)))),
|
|
51
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("cursor", null))))
|
|
53
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "p1", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
54
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "p1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null))))
|
|
52
55
|
},
|
|
53
56
|
{
|
|
54
57
|
title: 'at the middle of a li with heading',
|
|
55
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "split ", (0, _testutils.jsx)("cursor", null), "me"))),
|
|
56
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "split ")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, (0, _testutils.jsx)("cursor", null), "me")))
|
|
58
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "split ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me"))),
|
|
59
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "split ")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "me")))
|
|
57
60
|
},
|
|
58
61
|
{
|
|
59
62
|
title: 'at a li with nested list',
|
|
60
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "item 1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "item 2", (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "sub list"))))),
|
|
61
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "item 1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "item 2")), (0, _testutils.jsx)("hli", 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, "sub list")))))
|
|
63
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item 1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item 2", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "sub list"))))),
|
|
64
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item 1")), /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "item 2")), /*#__PURE__*/ (0, _testutils.jsx)("hli", 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, "sub list")))))
|
|
62
65
|
}
|
|
63
66
|
];
|
|
64
|
-
const render = (children)
|
|
67
|
+
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
65
68
|
for (const t of tests){
|
|
66
69
|
test(t.title, ()=>{
|
|
67
|
-
const { editor
|
|
70
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
68
71
|
input: render(t.input)
|
|
69
72
|
});
|
|
73
|
+
// Equivalent of pressing ENTER
|
|
70
74
|
editor.insertBreak();
|
|
71
75
|
(0, _testutils.assertOutput)({
|
|
72
76
|
editor,
|
|
@@ -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,51 +7,51 @@ describe('insert fragment', ()=>{
|
|
|
7
7
|
const tests = [
|
|
8
8
|
{
|
|
9
9
|
title: 'text wrapped in li > p',
|
|
10
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello ", (0, _testutils.jsx)("cursor", null)))),
|
|
11
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "world"))),
|
|
12
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello world")))
|
|
10
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
11
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "world"))),
|
|
12
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello world")))
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
title: 'text wrapped in li > h*',
|
|
16
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello ", (0, _testutils.jsx)("cursor", null)))),
|
|
17
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hh1", null, "world"))),
|
|
18
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello world")))
|
|
16
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
17
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "world"))),
|
|
18
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello world")))
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
title: 'single li with only asset card',
|
|
22
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello", (0, _testutils.jsx)("cursor", null), "world"))),
|
|
23
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hembed", {
|
|
22
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null), "world"))),
|
|
23
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
24
24
|
type: "Asset",
|
|
25
25
|
id: "asset-id"
|
|
26
26
|
}))),
|
|
27
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello"), (0, _testutils.jsx)("hembed", {
|
|
27
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello"), /*#__PURE__*/ (0, _testutils.jsx)("hembed", {
|
|
28
28
|
type: "Asset",
|
|
29
29
|
id: "asset-id"
|
|
30
|
-
}), (0, _testutils.jsx)("hp", null, "world")))
|
|
30
|
+
}), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "world")))
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
title: 'two paragraphs',
|
|
34
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello ", (0, _testutils.jsx)("cursor", null)))),
|
|
35
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hp", null, "world"), (0, _testutils.jsx)("hp", null, "line 2")),
|
|
36
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello world"), (0, _testutils.jsx)("hp", null, "line 2")))
|
|
34
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
35
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "world"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "line 2")),
|
|
36
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello world"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "line 2")))
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
title: 'two headings',
|
|
40
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello ", (0, _testutils.jsx)("cursor", null)))),
|
|
41
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hh1", null, "world"), (0, _testutils.jsx)("hh1", null, "line 2")),
|
|
42
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello world"), (0, _testutils.jsx)("hh1", null, "line 2")))
|
|
40
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
41
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "world"), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "line 2")),
|
|
42
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello world"), /*#__PURE__*/ (0, _testutils.jsx)("hh1", null, "line 2")))
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
title: 'two paragraphs wrapped in a li',
|
|
46
|
-
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello ", (0, _testutils.jsx)("cursor", null)))),
|
|
47
|
-
fragment: (0, _testutils.jsx)("fragment", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "world"), (0, _testutils.jsx)("hp", null, "line 2"))),
|
|
48
|
-
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "hello "), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "world"), (0, _testutils.jsx)("hp", null, "line 2")))))
|
|
46
|
+
input: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello ", /*#__PURE__*/ (0, _testutils.jsx)("cursor", null)))),
|
|
47
|
+
fragment: /*#__PURE__*/ (0, _testutils.jsx)("fragment", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "world"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "line 2"))),
|
|
48
|
+
expected: /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "hello "), /*#__PURE__*/ (0, _testutils.jsx)("hul", null, /*#__PURE__*/ (0, _testutils.jsx)("hli", null, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "world"), /*#__PURE__*/ (0, _testutils.jsx)("hp", null, "line 2")))))
|
|
49
49
|
}
|
|
50
50
|
];
|
|
51
|
-
const render = (children)
|
|
51
|
+
const render = (children)=>/*#__PURE__*/ (0, _testutils.jsx)("editor", null, children, /*#__PURE__*/ (0, _testutils.jsx)("hp", null, /*#__PURE__*/ (0, _testutils.jsx)("htext", null)));
|
|
52
52
|
for (const t of tests){
|
|
53
53
|
test(t.title, ()=>{
|
|
54
|
-
const { editor
|
|
54
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
55
55
|
input: render(t.input)
|
|
56
56
|
});
|
|
57
57
|
editor.insertFragment(t.fragment);
|
|
@@ -9,15 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
ListUL: function() {
|
|
13
|
-
return ListUL;
|
|
14
|
-
},
|
|
15
12
|
ListOL: function() {
|
|
16
13
|
return ListOL;
|
|
14
|
+
},
|
|
15
|
+
ListUL: function() {
|
|
16
|
+
return ListUL;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
const _react = _interop_require_wildcard(require("react"));
|
|
20
|
-
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
19
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
20
|
+
const _f36tokens = /*#__PURE__*/ _interop_require_default(require("@contentful/f36-tokens"));
|
|
21
21
|
const _richtexttypes = require("@contentful/rich-text-types");
|
|
22
22
|
const _emotion = require("emotion");
|
|
23
23
|
function _interop_require_default(obj) {
|
|
@@ -46,7 +46,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
46
46
|
if (cache && cache.has(obj)) {
|
|
47
47
|
return cache.get(obj);
|
|
48
48
|
}
|
|
49
|
-
var newObj = {
|
|
49
|
+
var newObj = {
|
|
50
|
+
__proto__: null
|
|
51
|
+
};
|
|
50
52
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
51
53
|
for(var key in obj){
|
|
52
54
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -98,7 +100,7 @@ const styles = {
|
|
|
98
100
|
};
|
|
99
101
|
function createList(Tag, block) {
|
|
100
102
|
return function List(props) {
|
|
101
|
-
return _react.createElement(Tag, {
|
|
103
|
+
return /*#__PURE__*/ _react.createElement(Tag, {
|
|
102
104
|
...props.attributes,
|
|
103
105
|
className: (0, _emotion.cx)(baseStyle, styles[block])
|
|
104
106
|
}, props.children);
|
|
@@ -8,8 +8,8 @@ Object.defineProperty(exports, "ListItem", {
|
|
|
8
8
|
return ListItem;
|
|
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)) {
|
|
@@ -66,7 +68,7 @@ const style = (0, _emotion.css)`
|
|
|
66
68
|
}
|
|
67
69
|
`;
|
|
68
70
|
function ListItem(props) {
|
|
69
|
-
return _react.createElement("li", {
|
|
71
|
+
return /*#__PURE__*/ _react.createElement("li", {
|
|
70
72
|
...props.attributes,
|
|
71
73
|
className: style
|
|
72
74
|
}, props.children);
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "ToolbarListButton", {
|
|
|
8
8
|
return ToolbarListButton;
|
|
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 _richtexttypes = require("@contentful/rich-text-types");
|
|
14
14
|
const _ContentfulEditorProvider = require("../../../ContentfulEditorProvider");
|
|
@@ -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)) {
|
|
@@ -70,17 +72,17 @@ function ToolbarListButton(props) {
|
|
|
70
72
|
};
|
|
71
73
|
}
|
|
72
74
|
if (!editor) return null;
|
|
73
|
-
return _react.createElement(_react.Fragment, null, (0, _validations.isNodeTypeEnabled)(sdk.field, _richtexttypes.BLOCKS.UL_LIST) && _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
75
|
+
return /*#__PURE__*/ _react.createElement(_react.Fragment, null, (0, _validations.isNodeTypeEnabled)(sdk.field, _richtexttypes.BLOCKS.UL_LIST) && /*#__PURE__*/ _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
74
76
|
title: "UL",
|
|
75
77
|
testId: "ul-toolbar-button",
|
|
76
78
|
onClick: handleClick(_richtexttypes.BLOCKS.UL_LIST),
|
|
77
79
|
isActive: (0, _utils.isListTypeActive)(editor, _richtexttypes.BLOCKS.UL_LIST),
|
|
78
80
|
isDisabled: props.isDisabled
|
|
79
|
-
}, _react.createElement(_f36icons.ListBulletedIcon, null)), (0, _validations.isNodeTypeEnabled)(sdk.field, _richtexttypes.BLOCKS.OL_LIST) && _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
81
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.ListBulletedIcon, null)), (0, _validations.isNodeTypeEnabled)(sdk.field, _richtexttypes.BLOCKS.OL_LIST) && /*#__PURE__*/ _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
80
82
|
title: "OL",
|
|
81
83
|
testId: "ol-toolbar-button",
|
|
82
84
|
onClick: handleClick(_richtexttypes.BLOCKS.OL_LIST),
|
|
83
85
|
isActive: (0, _utils.isListTypeActive)(editor, _richtexttypes.BLOCKS.OL_LIST),
|
|
84
86
|
isDisabled: props.isDisabled
|
|
85
|
-
}, _react.createElement(_f36icons.ListNumberedIcon, null)));
|
|
87
|
+
}, /*#__PURE__*/ _react.createElement(_f36icons.ListNumberedIcon, null)));
|
|
86
88
|
}
|
|
@@ -38,6 +38,8 @@ const createListPlugin = ()=>(0, _platelist.createListPlugin)({
|
|
|
38
38
|
handlers: {
|
|
39
39
|
onKeyDown: _onKeyDownList.onKeyDownList
|
|
40
40
|
},
|
|
41
|
+
// The withList is added on ELEMENT_UL plugin in upstream code
|
|
42
|
+
// so we need to override it here
|
|
41
43
|
withOverrides: _withList.withList
|
|
42
44
|
},
|
|
43
45
|
[_platelist.ELEMENT_OL]: {
|
|
@@ -47,12 +49,14 @@ const createListPlugin = ()=>(0, _platelist.createListPlugin)({
|
|
|
47
49
|
onKeyDown: _onKeyDownList.onKeyDownList
|
|
48
50
|
}
|
|
49
51
|
},
|
|
52
|
+
// ELEMENT_LIC is a child of li, Slate does ul > li > lic + ul
|
|
50
53
|
[_platelist.ELEMENT_LIC]: {
|
|
51
54
|
type: _richtexttypes.BLOCKS.PARAGRAPH
|
|
52
55
|
},
|
|
53
56
|
[_platelist.ELEMENT_LI]: {
|
|
54
57
|
type: _richtexttypes.BLOCKS.LIST_ITEM,
|
|
55
58
|
component: _ListItem.ListItem,
|
|
59
|
+
// @ts-expect-error
|
|
56
60
|
normalizer: [
|
|
57
61
|
{
|
|
58
62
|
validNode: _utils.hasListAsDirectParent,
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Credit: Copied & modified version from Plate's list plugin to support
|
|
3
|
+
* list items with multiple children.
|
|
4
|
+
*
|
|
5
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
6
|
+
*/ "use strict";
|
|
2
7
|
Object.defineProperty(exports, "__esModule", {
|
|
3
8
|
value: true
|
|
4
9
|
});
|
|
@@ -17,9 +22,11 @@ const listBreak = (editor)=>{
|
|
|
17
22
|
if (!editor.selection) return false;
|
|
18
23
|
const res = (0, _platelist.getListItemEntry)(editor, {});
|
|
19
24
|
let moved;
|
|
25
|
+
// If selection is in a li
|
|
20
26
|
if (res) {
|
|
21
|
-
const { list
|
|
27
|
+
const { list, listItem } = res;
|
|
22
28
|
const childNode = listItem[0].children[0];
|
|
29
|
+
// If selected li is empty, move it up.
|
|
23
30
|
if ((0, _platecommon.isBlockAboveEmpty)(editor) && listItem[0].children.length === 1 && _richtexttypes.TEXT_CONTAINERS.includes(childNode.type)) {
|
|
24
31
|
moved = (0, _platelist.moveListItemUp)(editor, {
|
|
25
32
|
list,
|
|
@@ -45,14 +52,16 @@ const listBreak = (editor)=>{
|
|
|
45
52
|
if (didReset) {
|
|
46
53
|
return true;
|
|
47
54
|
}
|
|
48
|
-
|
|
55
|
+
/**
|
|
56
|
+
* If selection is in li > p, insert li.
|
|
57
|
+
*/ if (!moved) {
|
|
49
58
|
const inserted = (0, _insertListItem.insertListItem)(editor);
|
|
50
59
|
if (inserted) return true;
|
|
51
60
|
}
|
|
52
61
|
return false;
|
|
53
62
|
};
|
|
54
63
|
const insertListBreak = (editor)=>{
|
|
55
|
-
const { insertBreak
|
|
64
|
+
const { insertBreak } = editor;
|
|
56
65
|
return ()=>{
|
|
57
66
|
if (listBreak(editor)) return;
|
|
58
67
|
insertBreak();
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Credit: Modified version of Plate's list plugin
|
|
3
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4
|
+
*/ "use strict";
|
|
2
5
|
Object.defineProperty(exports, "__esModule", {
|
|
3
6
|
value: true
|
|
4
7
|
});
|
|
@@ -26,19 +29,26 @@ const isListRoot = (node)=>[
|
|
|
26
29
|
_richtexttypes.BLOCKS.UL_LIST,
|
|
27
30
|
_richtexttypes.BLOCKS.OL_LIST
|
|
28
31
|
].includes(node.type);
|
|
29
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Removes the "empty" leading lis. Empty in this context means lis only with other lis as children.
|
|
34
|
+
*
|
|
35
|
+
* @returns If argument is not a list root, returns it, otherwise returns ul[] or li[].
|
|
36
|
+
*/ const trimList = (listRoot)=>{
|
|
30
37
|
if (!isListRoot(listRoot)) {
|
|
31
38
|
return [
|
|
32
39
|
listRoot
|
|
33
40
|
];
|
|
34
41
|
}
|
|
35
42
|
const textEntries = Array.from((0, _queries.getNodeTexts)(listRoot));
|
|
36
|
-
const commonAncestorEntry = textEntries.reduce((commonAncestor, textEntry)=>(0, _queries.isAncestorPath)(commonAncestor[1], textEntry[1]) ? commonAncestor : (0, _queries.getCommonNode)(listRoot, textEntry[1], commonAncestor[1]),
|
|
43
|
+
const commonAncestorEntry = textEntries.reduce((commonAncestor, textEntry)=>(0, _queries.isAncestorPath)(commonAncestor[1], textEntry[1]) ? commonAncestor : (0, _queries.getCommonNode)(listRoot, textEntry[1], commonAncestor[1]), // any list item would do, we grab the first one
|
|
44
|
+
getFirstAncestorOfType(listRoot, textEntries[0]));
|
|
37
45
|
return isListRoot(commonAncestorEntry[0]) ? commonAncestorEntry[0].children : [
|
|
38
46
|
commonAncestorEntry[0]
|
|
39
47
|
];
|
|
40
48
|
};
|
|
41
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Removes leading li when pasting a single li with a single child.
|
|
51
|
+
*/ const trimLiWrapper = (nodes)=>{
|
|
42
52
|
if (nodes.length !== 1) {
|
|
43
53
|
return nodes;
|
|
44
54
|
}
|
|
@@ -59,7 +69,7 @@ const unwrapTextContainerAtStart = (nodes)=>{
|
|
|
59
69
|
return nodes;
|
|
60
70
|
};
|
|
61
71
|
const insertListFragment = (editor)=>{
|
|
62
|
-
const { insertFragment
|
|
72
|
+
const { insertFragment } = editor;
|
|
63
73
|
return (fragment)=>{
|
|
64
74
|
if (!editor.selection) {
|
|
65
75
|
return;
|
|
@@ -78,6 +88,9 @@ const insertListFragment = (editor)=>{
|
|
|
78
88
|
}
|
|
79
89
|
const inlines = nodes.slice(0, firstBlockIndex);
|
|
80
90
|
const blocks = nodes.slice(firstBlockIndex);
|
|
91
|
+
// Two calls to insertNodes are required here. Otherwise, all blocks
|
|
92
|
+
// after a text or inline element occurrence will be unwrapped for
|
|
93
|
+
// some reason.
|
|
81
94
|
(0, _transforms.insertNodes)(editor, inlines, {
|
|
82
95
|
at: editor.selection,
|
|
83
96
|
select: true
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Credit: Modified version of Plate's list plugin
|
|
3
|
+
* See: https://github.com/udecode/plate/blob/main/packages/nodes/list
|
|
4
|
+
*/ "use strict";
|
|
2
5
|
Object.defineProperty(exports, "__esModule", {
|
|
3
6
|
value: true
|
|
4
7
|
});
|
|
@@ -8,8 +11,8 @@ Object.defineProperty(exports, "onKeyDownList", {
|
|
|
8
11
|
return onKeyDownList;
|
|
9
12
|
}
|
|
10
13
|
});
|
|
11
|
-
const _ishotkey = _interop_require_default(require("is-hotkey"));
|
|
12
|
-
const _castArray = _interop_require_default(require("lodash/castArray"));
|
|
14
|
+
const _ishotkey = /*#__PURE__*/ _interop_require_default(require("is-hotkey"));
|
|
15
|
+
const _castArray = /*#__PURE__*/ _interop_require_default(require("lodash/castArray"));
|
|
13
16
|
const _queries = require("../../internal/queries");
|
|
14
17
|
const _moveListItems = require("./transforms/moveListItems");
|
|
15
18
|
const _toggleList = require("./transforms/toggleList");
|
|
@@ -18,7 +21,7 @@ function _interop_require_default(obj) {
|
|
|
18
21
|
default: obj
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
|
-
const onKeyDownList = (editor, { type
|
|
24
|
+
const onKeyDownList = (editor, { type, options: { hotkey } })=>(e)=>{
|
|
22
25
|
if (e.key === 'Tab' && editor.selection) {
|
|
23
26
|
const listSelected = (0, _queries.getAboveNode)(editor, {
|
|
24
27
|
at: editor.selection,
|
|
@@ -12,7 +12,9 @@ const _richtexttypes = require("@contentful/rich-text-types");
|
|
|
12
12
|
const _internal = require("../../../internal");
|
|
13
13
|
const _queries = require("../../../internal/queries");
|
|
14
14
|
const _transforms = require("../../../internal/transforms");
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Build a new list item node while preserving marks
|
|
17
|
+
*/ const emptyListItemNode = (editor, withChildren = false)=>{
|
|
16
18
|
let children = [];
|
|
17
19
|
if (withChildren) {
|
|
18
20
|
const marks = (0, _queries.getMarks)(editor) || {};
|
|
@@ -39,6 +41,7 @@ const insertListItem = (editor)=>{
|
|
|
39
41
|
if (!editor.selection) {
|
|
40
42
|
return false;
|
|
41
43
|
}
|
|
44
|
+
// Naming it paragraph for simplicity but can be a heading as well
|
|
42
45
|
const paragraph = (0, _queries.getAboveNode)(editor, {
|
|
43
46
|
match: {
|
|
44
47
|
type: _richtexttypes.TEXT_CONTAINERS
|
|
@@ -56,23 +59,33 @@ const insertListItem = (editor)=>{
|
|
|
56
59
|
if (listItemNode.type !== _richtexttypes.BLOCKS.LIST_ITEM) {
|
|
57
60
|
return false;
|
|
58
61
|
}
|
|
62
|
+
// We are in a li>p (or heading)
|
|
59
63
|
(0, _internal.withoutNormalizing)(editor, ()=>{
|
|
60
64
|
if (!editor.selection) {
|
|
61
65
|
return;
|
|
62
66
|
}
|
|
67
|
+
// Check the cursor position in the current paragraph
|
|
63
68
|
const isAtStart = (0, _queries.isSelectionAtBlockStart)(editor);
|
|
64
69
|
const isAtEnd = (0, _queries.isSelectionAtBlockEnd)(editor);
|
|
65
70
|
const isAtStartOfListItem = isAtStart && (0, _queries.isFirstChildPath)(paragraphPath);
|
|
66
71
|
const shouldSplit = !isAtStart && !isAtEnd;
|
|
72
|
+
// Split the current paragraph content if necessary
|
|
67
73
|
if (shouldSplit) {
|
|
68
74
|
(0, _transforms.splitNodes)(editor);
|
|
69
75
|
}
|
|
76
|
+
// Insert the new li
|
|
70
77
|
const newListItemPath = isAtStartOfListItem ? listItemPath : (0, _queries.getNextPath)(listItemPath);
|
|
71
|
-
(0, _transforms.insertNodes)(editor,
|
|
78
|
+
(0, _transforms.insertNodes)(editor, // Add an empty paragraph to the new li if We will not move some
|
|
79
|
+
// paragraphs over there.
|
|
80
|
+
emptyListItemNode(editor, !shouldSplit), {
|
|
72
81
|
at: newListItemPath
|
|
73
82
|
});
|
|
83
|
+
// Move children *after* selection to the new li
|
|
74
84
|
const fromPath = isAtStart ? paragraphPath : (0, _queries.getNextPath)(paragraphPath);
|
|
75
85
|
const fromStartIndex = fromPath[fromPath.length - 1] || 0;
|
|
86
|
+
// On split we don't add paragraph to the new li so we move
|
|
87
|
+
// content to the very beginning. Otherwise, account for the empty
|
|
88
|
+
// paragraph at the beginning by moving the content after
|
|
76
89
|
const toPath = newListItemPath.concat([
|
|
77
90
|
shouldSplit ? 0 : 1
|
|
78
91
|
]);
|
|
@@ -83,10 +96,12 @@ const insertListItem = (editor)=>{
|
|
|
83
96
|
fromStartIndex
|
|
84
97
|
});
|
|
85
98
|
}
|
|
99
|
+
// Move cursor to the start of the new li
|
|
86
100
|
(0, _transforms.select)(editor, newListItemPath);
|
|
87
101
|
(0, _transforms.collapseSelection)(editor, {
|
|
88
102
|
edge: 'start'
|
|
89
103
|
});
|
|
90
104
|
});
|
|
105
|
+
// Returning True skips processing other editor.insertBreak handlers
|
|
91
106
|
return true;
|
|
92
107
|
};
|