@contentful/field-editor-rich-text 3.4.22 → 3.6.0
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 +59 -0
- package/dist/cjs/RichTextEditor.js +170 -0
- package/dist/cjs/RichTextEditor.styles.js +66 -0
- package/dist/cjs/SdkProvider.js +69 -0
- package/dist/cjs/Toolbar/_tests_/toolbar.test.js +152 -0
- package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +92 -0
- package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +69 -0
- package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +29 -0
- package/dist/cjs/Toolbar/index.js +222 -0
- package/dist/cjs/__fixtures__/FakeSdk.js +183 -0
- package/dist/cjs/__fixtures__/asset/index.js +37 -0
- package/dist/cjs/__fixtures__/content-type/index.js +16 -0
- package/dist/cjs/__fixtures__/entry/index.js +33 -0
- package/dist/cjs/__fixtures__/fixtures.js +71 -0
- package/dist/cjs/__fixtures__/locale/index.js +40 -0
- package/dist/cjs/__fixtures__/space/index.js +16 -0
- package/dist/cjs/constants/Schema.js +172 -0
- package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +348 -0
- package/dist/cjs/dialogs/openRichTextDialog.js +64 -0
- package/dist/cjs/dialogs/renderRichTextDialog.js +63 -0
- package/dist/cjs/helpers/__tests__/extractNodes.test.js +299 -0
- package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +68 -0
- package/dist/cjs/helpers/__tests__/validations.test.js +49 -0
- package/dist/cjs/helpers/editor.js +276 -0
- package/dist/cjs/helpers/environment.js +20 -0
- package/dist/cjs/helpers/extractNodes.js +27 -0
- package/dist/cjs/helpers/formatDateAndTime.js +45 -0
- package/dist/cjs/helpers/getAllowedResourcesForNodeType.js +25 -0
- package/dist/cjs/helpers/getLinkedContentTypeIdsForNodeType.js +24 -0
- package/dist/cjs/helpers/newEntitySelectorConfigFromRichTextField.js +33 -0
- package/dist/cjs/helpers/newResourceEntitySelectorConfigFromRichTextField.js +21 -0
- package/dist/cjs/helpers/nodeFactory.js +51 -0
- package/dist/cjs/helpers/removeInternalMarks.js +26 -0
- package/dist/cjs/helpers/sanitizeIncomingSlateDoc.js +33 -0
- package/dist/cjs/helpers/sdkNavigatorSlideIn.js +57 -0
- package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +209 -0
- package/dist/cjs/helpers/transformers.js +61 -0
- package/dist/cjs/helpers/validations.js +56 -0
- package/dist/cjs/index.js +66 -0
- package/dist/cjs/internal/constants.js +51 -0
- package/dist/cjs/internal/hooks.js +65 -0
- package/dist/cjs/internal/index.js +21 -0
- package/dist/cjs/internal/misc.js +103 -0
- package/dist/cjs/internal/queries.js +407 -0
- package/dist/cjs/internal/transforms.js +195 -0
- package/dist/cjs/internal/types/editor.js +4 -0
- package/dist/cjs/internal/types/index.js +19 -0
- package/dist/cjs/internal/types/plugins.js +4 -0
- package/dist/cjs/plugins/Break/createExitBreakPlugin.js +26 -0
- package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +36 -0
- package/dist/cjs/plugins/Break/createResetNodePlugin.js +32 -0
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.js +23 -0
- package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +47 -0
- package/dist/cjs/plugins/Break/index.js +20 -0
- package/dist/cjs/plugins/CommandPalette/components/CommandList.js +167 -0
- package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +103 -0
- package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +69 -0
- package/dist/cjs/plugins/CommandPalette/constants.js +11 -0
- package/dist/cjs/plugins/CommandPalette/createCommandPalettePlugin.js +24 -0
- package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +138 -0
- package/dist/cjs/plugins/CommandPalette/index.js +11 -0
- package/dist/cjs/plugins/CommandPalette/onKeyDown.js +51 -0
- package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +83 -0
- package/dist/cjs/plugins/CommandPalette/useCommands.js +222 -0
- package/dist/cjs/plugins/CommandPalette/utils/createInlineEntryNode.js +30 -0
- package/dist/cjs/plugins/CommandPalette/utils/fetchAssets.js +31 -0
- package/dist/cjs/plugins/CommandPalette/utils/fetchEntries.js +39 -0
- package/dist/cjs/plugins/CommandPalette/utils/insertBlock.js +42 -0
- package/dist/cjs/plugins/CommandPalette/utils/trimLeadingSlash.js +16 -0
- package/dist/cjs/plugins/DragAndDrop/index.js +55 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +111 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +68 -0
- package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +158 -0
- package/dist/cjs/plugins/EmbeddedEntityInline/Util.js +30 -0
- package/dist/cjs/plugins/EmbeddedEntityInline/index.js +222 -0
- package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +54 -0
- package/dist/cjs/plugins/EmbeddedResourceBlock/index.js +55 -0
- package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +117 -0
- package/dist/cjs/plugins/Heading/components/Heading.js +127 -0
- package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +173 -0
- package/dist/cjs/plugins/Heading/createHeadingPlugin.js +102 -0
- package/dist/cjs/plugins/Heading/index.js +19 -0
- package/dist/cjs/plugins/Hr/index.js +193 -0
- package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +282 -0
- package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +25 -0
- package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +94 -0
- package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +78 -0
- package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +86 -0
- package/dist/cjs/plugins/Hyperlink/components/styles.js +36 -0
- package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +178 -0
- package/dist/cjs/plugins/Hyperlink/index.js +20 -0
- package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +95 -0
- package/dist/cjs/plugins/Hyperlink/utils.js +43 -0
- package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +47 -0
- package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +77 -0
- package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +64 -0
- package/dist/cjs/plugins/List/components/List.js +108 -0
- package/dist/cjs/plugins/List/components/ListItem.js +73 -0
- package/dist/cjs/plugins/List/components/ToolbarListButton.js +86 -0
- package/dist/cjs/plugins/List/createListPlugin.js +76 -0
- package/dist/cjs/plugins/List/index.js +19 -0
- package/dist/cjs/plugins/List/insertListBreak.js +60 -0
- package/dist/cjs/plugins/List/insertListFragment.js +98 -0
- package/dist/cjs/plugins/List/onKeyDownList.js +46 -0
- package/dist/cjs/plugins/List/transforms/insertListItem.js +92 -0
- package/dist/cjs/plugins/List/transforms/moveListItemDown.js +47 -0
- package/dist/cjs/plugins/List/transforms/moveListItems.js +56 -0
- package/dist/cjs/plugins/List/transforms/moveListItems.test.js +72 -0
- package/dist/cjs/plugins/List/transforms/toggleList.js +141 -0
- package/dist/cjs/plugins/List/transforms/toggleList.spec.js +139 -0
- package/dist/cjs/plugins/List/transforms/unwrapList.js +38 -0
- package/dist/cjs/plugins/List/utils.js +122 -0
- package/dist/cjs/plugins/List/withList.js +32 -0
- package/dist/cjs/plugins/Marks/Bold.js +119 -0
- package/dist/cjs/plugins/Marks/Code.js +122 -0
- package/dist/cjs/plugins/Marks/Italic.js +114 -0
- package/dist/cjs/plugins/Marks/Subscript.js +109 -0
- package/dist/cjs/plugins/Marks/Superscript.js +107 -0
- package/dist/cjs/plugins/Marks/Underline.js +106 -0
- package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +105 -0
- package/dist/cjs/plugins/Marks/helpers.js +48 -0
- package/dist/cjs/plugins/Marks/index.js +27 -0
- package/dist/cjs/plugins/Normalizer/baseRules.js +38 -0
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.js +15 -0
- package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +117 -0
- package/dist/cjs/plugins/Normalizer/index.js +19 -0
- package/dist/cjs/plugins/Normalizer/types.js +4 -0
- package/dist/cjs/plugins/Normalizer/utils.js +39 -0
- package/dist/cjs/plugins/Normalizer/withNormalizer.js +88 -0
- package/dist/cjs/plugins/Paragraph/Paragraph.js +70 -0
- package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +125 -0
- package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +73 -0
- package/dist/cjs/plugins/Paragraph/index.js +18 -0
- package/dist/cjs/plugins/Paragraph/utils.js +24 -0
- package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +63 -0
- package/dist/cjs/plugins/PasteHTML/index.js +18 -0
- package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +54 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeAnchors.js +43 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeHTML.js +50 -0
- package/dist/cjs/plugins/PasteHTML/utils/sanitizeSheets.js +44 -0
- package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +78 -0
- package/dist/cjs/plugins/Quote/components/Quote.js +69 -0
- package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +72 -0
- package/dist/cjs/plugins/Quote/createQuotePlugin.js +57 -0
- package/dist/cjs/plugins/Quote/index.js +19 -0
- package/dist/cjs/plugins/Quote/shouldResetQuote.js +40 -0
- package/dist/cjs/plugins/Quote/toggleQuote.js +56 -0
- package/dist/cjs/plugins/Quote/withQuote.js +48 -0
- package/dist/cjs/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +21 -0
- package/dist/cjs/plugins/SelectOnBackspace/index.js +18 -0
- package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +92 -0
- package/dist/cjs/plugins/Table/__tests__/helpers.test.js +18 -0
- package/dist/cjs/plugins/Table/actions/addColumn.js +63 -0
- package/dist/cjs/plugins/Table/actions/addRow.js +57 -0
- package/dist/cjs/plugins/Table/actions/index.js +20 -0
- package/dist/cjs/plugins/Table/actions/setHeader.js +34 -0
- package/dist/cjs/plugins/Table/components/Cell.js +79 -0
- package/dist/cjs/plugins/Table/components/HeaderCell.js +82 -0
- package/dist/cjs/plugins/Table/components/Row.js +69 -0
- package/dist/cjs/plugins/Table/components/Table.js +76 -0
- package/dist/cjs/plugins/Table/components/TableActions.js +175 -0
- package/dist/cjs/plugins/Table/components/ToolbarButton.js +73 -0
- package/dist/cjs/plugins/Table/createTablePlugin.js +119 -0
- package/dist/cjs/plugins/Table/helpers.js +152 -0
- package/dist/cjs/plugins/Table/index.js +19 -0
- package/dist/cjs/plugins/Table/insertTableFragment.js +50 -0
- package/dist/cjs/plugins/Table/onKeyDownTable.js +62 -0
- package/dist/cjs/plugins/Table/tableTracking.js +64 -0
- package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +79 -0
- package/dist/cjs/plugins/Text/createTextPlugin.js +137 -0
- package/dist/cjs/plugins/Text/index.js +18 -0
- package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +101 -0
- package/dist/cjs/plugins/Tracking/index.js +18 -0
- package/dist/cjs/plugins/Tracking/utils.js +64 -0
- package/dist/cjs/plugins/TrailingParagraph/index.js +20 -0
- package/dist/cjs/plugins/Voids/createVoidsPlugin.js +31 -0
- package/dist/cjs/plugins/Voids/index.js +18 -0
- package/dist/cjs/plugins/Voids/transformVoid.js +29 -0
- package/dist/cjs/plugins/index.js +78 -0
- package/dist/cjs/plugins/links-tracking.js +20 -0
- package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +114 -0
- package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +170 -0
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +113 -0
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +116 -0
- package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +110 -0
- package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +45 -0
- package/dist/cjs/plugins/shared/ToolbarButton.js +93 -0
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +107 -0
- package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +110 -0
- package/dist/cjs/prepareDocument.js +86 -0
- package/dist/cjs/test-utils/assertOutput.js +31 -0
- package/dist/cjs/test-utils/createEditor.js +31 -0
- package/dist/cjs/test-utils/hyperscript.d.js +1 -0
- package/dist/cjs/test-utils/index.js +21 -0
- package/dist/cjs/test-utils/jsx.js +159 -0
- package/dist/cjs/test-utils/mockPlugin.js +16 -0
- package/dist/cjs/test-utils/randomId.js +13 -0
- package/dist/cjs/test-utils/setEmptyDataAttribute.js +21 -0
- package/dist/cjs/test-utils/validation.js +127 -0
- package/dist/cjs/useOnValueChanged.js +58 -0
- package/dist/esm/ContentfulEditorProvider.js +29 -0
- package/dist/esm/RichTextEditor.js +108 -0
- package/dist/esm/RichTextEditor.styles.js +51 -0
- package/dist/esm/SdkProvider.js +7 -0
- package/dist/esm/Toolbar/_tests_/toolbar.test.js +104 -0
- package/dist/esm/Toolbar/components/EmbedEntityWidget.js +43 -0
- package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +20 -0
- package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +14 -0
- package/dist/esm/Toolbar/index.js +168 -0
- package/dist/esm/__fixtures__/FakeSdk.js +173 -0
- package/dist/esm/__fixtures__/asset/index.js +6 -0
- package/dist/esm/__fixtures__/content-type/index.js +2 -0
- package/dist/esm/__fixtures__/entry/index.js +5 -0
- package/dist/esm/__fixtures__/fixtures.js +6 -0
- package/dist/esm/__fixtures__/locale/index.js +15 -0
- package/dist/esm/__fixtures__/space/index.js +2 -0
- package/dist/esm/constants/Schema.js +162 -0
- package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +283 -0
- package/dist/esm/dialogs/openRichTextDialog.js +15 -0
- package/dist/esm/dialogs/renderRichTextDialog.js +14 -0
- package/dist/esm/helpers/__tests__/extractNodes.test.js +295 -0
- package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +64 -0
- package/dist/esm/helpers/__tests__/validations.test.js +45 -0
- package/dist/esm/helpers/editor.js +198 -0
- package/dist/esm/helpers/environment.js +2 -0
- package/dist/esm/helpers/extractNodes.js +17 -0
- package/dist/esm/helpers/formatDateAndTime.js +19 -0
- package/dist/esm/helpers/getAllowedResourcesForNodeType.js +10 -0
- package/dist/esm/helpers/getLinkedContentTypeIdsForNodeType.js +9 -0
- package/dist/esm/helpers/newEntitySelectorConfigFromRichTextField.js +18 -0
- package/dist/esm/helpers/newResourceEntitySelectorConfigFromRichTextField.js +6 -0
- package/dist/esm/helpers/nodeFactory.js +24 -0
- package/dist/esm/helpers/removeInternalMarks.js +16 -0
- package/dist/esm/helpers/sanitizeIncomingSlateDoc.js +23 -0
- package/dist/esm/helpers/sdkNavigatorSlideIn.js +42 -0
- package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +200 -0
- package/dist/esm/helpers/transformers.js +34 -0
- package/dist/esm/helpers/validations.js +24 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/internal/constants.js +2 -0
- package/dist/esm/internal/hooks.js +5 -0
- package/dist/esm/internal/index.js +4 -0
- package/dist/esm/internal/misc.js +28 -0
- package/dist/esm/internal/queries.js +182 -0
- package/dist/esm/internal/transforms.js +75 -0
- package/dist/esm/internal/types/editor.js +1 -0
- package/dist/esm/internal/types/index.js +2 -0
- package/dist/esm/internal/types/plugins.js +1 -0
- package/dist/esm/plugins/Break/createExitBreakPlugin.js +16 -0
- package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +32 -0
- package/dist/esm/plugins/Break/createResetNodePlugin.js +22 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.js +13 -0
- package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +43 -0
- package/dist/esm/plugins/Break/index.js +3 -0
- package/dist/esm/plugins/CommandPalette/components/CommandList.js +113 -0
- package/dist/esm/plugins/CommandPalette/components/CommandList.styles.js +88 -0
- package/dist/esm/plugins/CommandPalette/components/CommandPrompt.js +20 -0
- package/dist/esm/plugins/CommandPalette/constants.js +1 -0
- package/dist/esm/plugins/CommandPalette/createCommandPalettePlugin.js +14 -0
- package/dist/esm/plugins/CommandPalette/hooks/useCommandList.js +84 -0
- package/dist/esm/plugins/CommandPalette/index.js +1 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.js +36 -0
- package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +40 -0
- package/dist/esm/plugins/CommandPalette/useCommands.js +204 -0
- package/dist/esm/plugins/CommandPalette/utils/createInlineEntryNode.js +20 -0
- package/dist/esm/plugins/CommandPalette/utils/fetchAssets.js +21 -0
- package/dist/esm/plugins/CommandPalette/utils/fetchEntries.js +29 -0
- package/dist/esm/plugins/CommandPalette/utils/insertBlock.js +32 -0
- package/dist/esm/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -0
- package/dist/esm/plugins/DragAndDrop/index.js +45 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +62 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/index.js +50 -0
- package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +104 -0
- package/dist/esm/plugins/EmbeddedEntityInline/Util.js +20 -0
- package/dist/esm/plugins/EmbeddedEntityInline/index.js +160 -0
- package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +39 -0
- package/dist/esm/plugins/EmbeddedResourceBlock/index.js +45 -0
- package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +113 -0
- package/dist/esm/plugins/Heading/components/Heading.js +73 -0
- package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +119 -0
- package/dist/esm/plugins/Heading/createHeadingPlugin.js +87 -0
- package/dist/esm/plugins/Heading/index.js +2 -0
- package/dist/esm/plugins/Hr/index.js +125 -0
- package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +220 -0
- package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +21 -0
- package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +45 -0
- package/dist/esm/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +29 -0
- package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +37 -0
- package/dist/esm/plugins/Hyperlink/components/styles.js +21 -0
- package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +124 -0
- package/dist/esm/plugins/Hyperlink/index.js +2 -0
- package/dist/esm/plugins/Hyperlink/useEntityInfo.js +85 -0
- package/dist/esm/plugins/Hyperlink/utils.js +25 -0
- package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +43 -0
- package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +73 -0
- package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +60 -0
- package/dist/esm/plugins/List/components/List.js +46 -0
- package/dist/esm/plugins/List/components/ListItem.js +19 -0
- package/dist/esm/plugins/List/components/ToolbarListButton.js +37 -0
- package/dist/esm/plugins/List/createListPlugin.js +66 -0
- package/dist/esm/plugins/List/index.js +2 -0
- package/dist/esm/plugins/List/insertListBreak.js +50 -0
- package/dist/esm/plugins/List/insertListFragment.js +88 -0
- package/dist/esm/plugins/List/onKeyDownList.js +31 -0
- package/dist/esm/plugins/List/transforms/insertListItem.js +82 -0
- package/dist/esm/plugins/List/transforms/moveListItemDown.js +37 -0
- package/dist/esm/plugins/List/transforms/moveListItems.js +46 -0
- package/dist/esm/plugins/List/transforms/moveListItems.test.js +68 -0
- package/dist/esm/plugins/List/transforms/toggleList.js +132 -0
- package/dist/esm/plugins/List/transforms/toggleList.spec.js +135 -0
- package/dist/esm/plugins/List/transforms/unwrapList.js +28 -0
- package/dist/esm/plugins/List/utils.js +89 -0
- package/dist/esm/plugins/List/withList.js +22 -0
- package/dist/esm/plugins/Marks/Bold.js +59 -0
- package/dist/esm/plugins/Marks/Code.js +59 -0
- package/dist/esm/plugins/Marks/Italic.js +54 -0
- package/dist/esm/plugins/Marks/Subscript.js +46 -0
- package/dist/esm/plugins/Marks/Superscript.js +44 -0
- package/dist/esm/plugins/Marks/Underline.js +46 -0
- package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +51 -0
- package/dist/esm/plugins/Marks/helpers.js +25 -0
- package/dist/esm/plugins/Marks/index.js +17 -0
- package/dist/esm/plugins/Normalizer/baseRules.js +28 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.js +5 -0
- package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +113 -0
- package/dist/esm/plugins/Normalizer/index.js +2 -0
- package/dist/esm/plugins/Normalizer/types.js +1 -0
- package/dist/esm/plugins/Normalizer/utils.js +18 -0
- package/dist/esm/plugins/Normalizer/withNormalizer.js +73 -0
- package/dist/esm/plugins/Paragraph/Paragraph.js +16 -0
- package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +121 -0
- package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +58 -0
- package/dist/esm/plugins/Paragraph/index.js +1 -0
- package/dist/esm/plugins/Paragraph/utils.js +6 -0
- package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +42 -0
- package/dist/esm/plugins/PasteHTML/index.js +1 -0
- package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +50 -0
- package/dist/esm/plugins/PasteHTML/utils/sanitizeAnchors.js +33 -0
- package/dist/esm/plugins/PasteHTML/utils/sanitizeHTML.js +40 -0
- package/dist/esm/plugins/PasteHTML/utils/sanitizeSheets.js +34 -0
- package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +74 -0
- package/dist/esm/plugins/Quote/components/Quote.js +15 -0
- package/dist/esm/plugins/Quote/components/ToolbarQuoteButton.js +23 -0
- package/dist/esm/plugins/Quote/createQuotePlugin.js +47 -0
- package/dist/esm/plugins/Quote/index.js +2 -0
- package/dist/esm/plugins/Quote/shouldResetQuote.js +30 -0
- package/dist/esm/plugins/Quote/toggleQuote.js +33 -0
- package/dist/esm/plugins/Quote/withQuote.js +38 -0
- package/dist/esm/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +11 -0
- package/dist/esm/plugins/SelectOnBackspace/index.js +1 -0
- package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +88 -0
- package/dist/esm/plugins/Table/__tests__/helpers.test.js +14 -0
- package/dist/esm/plugins/Table/actions/addColumn.js +45 -0
- package/dist/esm/plugins/Table/actions/addRow.js +39 -0
- package/dist/esm/plugins/Table/actions/index.js +3 -0
- package/dist/esm/plugins/Table/actions/setHeader.js +24 -0
- package/dist/esm/plugins/Table/components/Cell.js +25 -0
- package/dist/esm/plugins/Table/components/HeaderCell.js +28 -0
- package/dist/esm/plugins/Table/components/Row.js +15 -0
- package/dist/esm/plugins/Table/components/Table.js +22 -0
- package/dist/esm/plugins/Table/components/TableActions.js +118 -0
- package/dist/esm/plugins/Table/components/ToolbarButton.js +24 -0
- package/dist/esm/plugins/Table/createTablePlugin.js +109 -0
- package/dist/esm/plugins/Table/helpers.js +116 -0
- package/dist/esm/plugins/Table/index.js +2 -0
- package/dist/esm/plugins/Table/insertTableFragment.js +40 -0
- package/dist/esm/plugins/Table/onKeyDownTable.js +52 -0
- package/dist/esm/plugins/Table/tableTracking.js +46 -0
- package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +75 -0
- package/dist/esm/plugins/Text/createTextPlugin.js +127 -0
- package/dist/esm/plugins/Text/index.js +1 -0
- package/dist/esm/plugins/Tracking/createTrackingPlugin.js +83 -0
- package/dist/esm/plugins/Tracking/index.js +1 -0
- package/dist/esm/plugins/Tracking/utils.js +10 -0
- package/dist/esm/plugins/TrailingParagraph/index.js +10 -0
- package/dist/esm/plugins/Voids/createVoidsPlugin.js +21 -0
- package/dist/esm/plugins/Voids/index.js +1 -0
- package/dist/esm/plugins/Voids/transformVoid.js +19 -0
- package/dist/esm/plugins/index.js +60 -0
- package/dist/esm/plugins/links-tracking.js +10 -0
- package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +57 -0
- package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +144 -0
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +59 -0
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +62 -0
- package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +56 -0
- package/dist/esm/plugins/shared/LinkedBlockWrapper.js +30 -0
- package/dist/esm/plugins/shared/ToolbarButton.js +39 -0
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +59 -0
- package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +62 -0
- package/dist/esm/prepareDocument.js +57 -0
- package/dist/esm/test-utils/assertOutput.js +21 -0
- package/dist/esm/test-utils/createEditor.js +21 -0
- package/dist/esm/test-utils/hyperscript.d.js +0 -0
- package/dist/esm/test-utils/index.js +4 -0
- package/dist/esm/test-utils/jsx.js +149 -0
- package/dist/esm/test-utils/mockPlugin.js +6 -0
- package/dist/esm/test-utils/randomId.js +3 -0
- package/dist/esm/test-utils/setEmptyDataAttribute.js +11 -0
- package/dist/esm/test-utils/validation.js +112 -0
- package/dist/esm/useOnValueChanged.js +43 -0
- package/dist/{ContentfulEditorProvider.d.ts → types/ContentfulEditorProvider.d.ts} +9 -9
- package/dist/{RichTextEditor.d.ts → types/RichTextEditor.d.ts} +21 -20
- package/dist/{RichTextEditor.styles.d.ts → types/RichTextEditor.styles.d.ts} +7 -7
- package/dist/{SdkProvider.d.ts → types/SdkProvider.d.ts} +7 -7
- package/dist/types/Toolbar/_tests_/toolbar.test.d.ts +1 -0
- package/dist/{Toolbar → types/Toolbar}/components/EmbedEntityWidget.d.ts +6 -5
- package/dist/{Toolbar → types/Toolbar}/components/EmbeddedEntityDropdownButton.d.ts +9 -9
- package/dist/{Toolbar → types/Toolbar}/components/StickyToolbarWrapper.d.ts +7 -7
- package/dist/types/Toolbar/index.d.ts +6 -0
- package/dist/types/__fixtures__/FakeSdk.d.ts +8 -0
- package/dist/types/__fixtures__/asset/index.d.ts +6 -0
- package/dist/types/__fixtures__/content-type/index.d.ts +2 -0
- package/dist/types/__fixtures__/entry/index.d.ts +5 -0
- package/dist/types/__fixtures__/fixtures.d.ts +6 -0
- package/dist/types/__fixtures__/locale/index.d.ts +42 -0
- package/dist/types/__fixtures__/space/index.d.ts +2 -0
- package/dist/{constants → types/constants}/Schema.d.ts +111 -111
- package/dist/{dialogs → types/dialogs}/HypelinkDialog/HyperlinkDialog.d.ts +63 -54
- package/dist/{dialogs → types/dialogs}/openRichTextDialog.d.ts +2 -2
- package/dist/{dialogs → types/dialogs}/renderRichTextDialog.d.ts +3 -2
- package/dist/types/helpers/__tests__/extractNodes.test.d.ts +1 -0
- package/dist/types/helpers/__tests__/removeInternalMarks.test.d.ts +2 -0
- package/dist/types/helpers/__tests__/validations.test.d.ts +1 -0
- package/dist/{helpers → types/helpers}/editor.d.ts +40 -40
- package/dist/{helpers → types/helpers}/environment.d.ts +2 -2
- package/dist/{helpers → types/helpers}/extractNodes.d.ts +5 -5
- package/dist/{helpers → types/helpers}/formatDateAndTime.d.ts +15 -15
- package/dist/types/helpers/getAllowedResourcesForNodeType.d.ts +25 -0
- package/dist/{helpers → types/helpers}/getLinkedContentTypeIdsForNodeType.d.ts +26 -26
- package/dist/{helpers → types/helpers}/newEntitySelectorConfigFromRichTextField.d.ts +14 -14
- package/dist/types/helpers/newResourceEntitySelectorConfigFromRichTextField.d.ts +16 -0
- package/dist/{helpers → types/helpers}/nodeFactory.d.ts +24 -24
- package/dist/{helpers → types/helpers}/removeInternalMarks.d.ts +1 -1
- package/dist/{helpers → types/helpers}/sanitizeIncomingSlateDoc.d.ts +6 -6
- package/dist/{helpers → types/helpers}/sdkNavigatorSlideIn.d.ts +16 -16
- package/dist/types/helpers/sdkNavigatorSlideIn.spec.d.ts +1 -0
- package/dist/{helpers → types/helpers}/transformers.d.ts +7 -7
- package/dist/{helpers → types/helpers}/validations.d.ts +10 -10
- package/dist/{index.d.ts → types/index.d.ts} +4 -4
- package/dist/{internal → types/internal}/constants.d.ts +1 -1
- package/dist/{internal → types/internal}/hooks.d.ts +4 -4
- package/dist/{internal → types/internal}/index.d.ts +4 -4
- package/dist/{internal → types/internal}/misc.d.ts +37 -37
- package/dist/{internal → types/internal}/queries.d.ts +78 -78
- package/dist/{internal → types/internal}/transforms.d.ts +33 -33
- package/dist/types/internal/types/editor.d.ts +51 -0
- package/dist/{internal → types/internal}/types/index.d.ts +2 -2
- package/dist/{internal → types/internal}/types/plugins.d.ts +12 -12
- package/dist/{plugins → types/plugins}/Break/createExitBreakPlugin.d.ts +2 -2
- package/dist/types/plugins/Break/createExitBreakPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Break/createResetNodePlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Break/createSoftBreakPlugin.d.ts +2 -2
- package/dist/types/plugins/Break/createSoftBreakPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Break/index.d.ts +5 -5
- package/dist/{plugins → types/plugins}/CommandPalette/components/CommandList.d.ts +8 -7
- package/dist/{plugins → types/plugins}/CommandPalette/components/CommandList.styles.d.ts +14 -14
- package/dist/{plugins → types/plugins}/CommandPalette/components/CommandPrompt.d.ts +5 -4
- package/dist/{plugins → types/plugins}/CommandPalette/constants.d.ts +1 -1
- package/dist/{plugins → types/plugins}/CommandPalette/createCommandPalettePlugin.d.ts +13 -13
- package/dist/{plugins → types/plugins}/CommandPalette/hooks/useCommandList.d.ts +4 -4
- package/dist/{plugins → types/plugins}/CommandPalette/index.d.ts +1 -1
- package/dist/{plugins → types/plugins}/CommandPalette/onKeyDown.d.ts +2 -2
- package/dist/types/plugins/CommandPalette/onKeyDown.spec.d.ts +1 -0
- package/dist/{plugins → types/plugins}/CommandPalette/useCommands.d.ts +19 -19
- package/dist/{plugins → types/plugins}/CommandPalette/utils/createInlineEntryNode.d.ts +16 -16
- package/dist/{plugins → types/plugins}/CommandPalette/utils/fetchAssets.d.ts +8 -8
- package/dist/{plugins → types/plugins}/CommandPalette/utils/fetchEntries.d.ts +9 -9
- package/dist/{plugins → types/plugins}/CommandPalette/utils/insertBlock.d.ts +1 -1
- package/dist/{plugins → types/plugins}/CommandPalette/utils/trimLeadingSlash.d.ts +7 -7
- package/dist/{plugins → types/plugins}/DragAndDrop/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/EmbeddedEntityBlock/LinkedEntityBlock.d.ts +19 -19
- package/dist/{plugins → types/plugins}/EmbeddedEntityBlock/index.d.ts +4 -5
- package/dist/{plugins → types/plugins}/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.d.ts +13 -13
- package/dist/{plugins → types/plugins}/EmbeddedEntityInline/Util.d.ts +16 -16
- package/dist/{plugins → types/plugins}/EmbeddedEntityInline/index.d.ts +10 -9
- package/dist/types/plugins/EmbeddedResourceBlock/LinkedResourceBlock.d.ts +18 -0
- package/dist/types/plugins/EmbeddedResourceBlock/index.d.ts +3 -0
- package/dist/types/plugins/Heading/__tests__/createHeadingPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Heading/components/Heading.d.ts +10 -10
- package/dist/{plugins → types/plugins}/Heading/components/ToolbarHeadingButton.d.ts +5 -4
- package/dist/{plugins → types/plugins}/Heading/createHeadingPlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Heading/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Hr/index.d.ts +11 -11
- package/dist/{plugins → types/plugins}/Hyperlink/HyperlinkModal.d.ts +17 -16
- package/dist/types/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Hyperlink/components/EntityHyperlink.d.ts +21 -20
- package/dist/{plugins → types/plugins}/Hyperlink/components/ToolbarHyperlinkButton.d.ts +6 -5
- package/dist/{plugins → types/plugins}/Hyperlink/components/UrlHyperlink.d.ts +22 -21
- package/dist/{plugins → types/plugins}/Hyperlink/components/styles.d.ts +4 -4
- package/dist/{plugins → types/plugins}/Hyperlink/createHyperlinkPlugin.d.ts +3 -3
- package/dist/{plugins → types/plugins}/Hyperlink/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Hyperlink/useEntityInfo.d.ts +16 -16
- package/dist/{plugins → types/plugins}/Hyperlink/utils.d.ts +5 -5
- package/dist/types/plugins/List/__tests__/createListPlugin.test.d.ts +1 -0
- package/dist/types/plugins/List/__tests__/insertListBreak.test.d.ts +1 -0
- package/dist/types/plugins/List/__tests__/insertListFragment.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/List/components/List.d.ts +4 -3
- package/dist/{plugins → types/plugins}/List/components/ListItem.d.ts +3 -2
- package/dist/{plugins → types/plugins}/List/components/ToolbarListButton.d.ts +5 -4
- package/dist/{plugins → types/plugins}/List/createListPlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/List/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/List/insertListBreak.d.ts +2 -2
- package/dist/{plugins → types/plugins}/List/insertListFragment.d.ts +2 -2
- package/dist/{plugins → types/plugins}/List/onKeyDownList.d.ts +7 -7
- package/dist/{plugins → types/plugins}/List/transforms/insertListItem.d.ts +5 -5
- package/dist/{plugins → types/plugins}/List/transforms/moveListItemDown.d.ts +6 -6
- package/dist/{plugins → types/plugins}/List/transforms/moveListItems.d.ts +6 -6
- package/dist/types/plugins/List/transforms/moveListItems.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/List/transforms/toggleList.d.ts +4 -4
- package/dist/types/plugins/List/transforms/toggleList.spec.d.ts +1 -0
- package/dist/{plugins → types/plugins}/List/transforms/unwrapList.d.ts +4 -4
- package/dist/{plugins → types/plugins}/List/utils.d.ts +14 -14
- package/dist/{plugins → types/plugins}/List/withList.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Marks/Bold.d.ts +11 -10
- package/dist/{plugins → types/plugins}/Marks/Code.d.ts +17 -16
- package/dist/{plugins → types/plugins}/Marks/Italic.d.ts +11 -10
- package/dist/{plugins → types/plugins}/Marks/Subscript.d.ts +17 -16
- package/dist/{plugins → types/plugins}/Marks/Superscript.d.ts +17 -16
- package/dist/{plugins → types/plugins}/Marks/Underline.d.ts +11 -10
- package/dist/{plugins → types/plugins}/Marks/components/MarkToolbarButton.d.ts +13 -13
- package/dist/{plugins → types/plugins}/Marks/helpers.d.ts +4 -4
- package/dist/{plugins → types/plugins}/Marks/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Normalizer/baseRules.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Normalizer/createNormalizerPlugin.d.ts +2 -2
- package/dist/types/plugins/Normalizer/createNormalizerPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Normalizer/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Normalizer/types.d.ts +38 -38
- package/dist/{plugins → types/plugins}/Normalizer/utils.d.ts +5 -5
- package/dist/{plugins → types/plugins}/Normalizer/withNormalizer.d.ts +2 -2
- package/dist/types/plugins/Paragraph/Paragraph.d.ts +3 -0
- package/dist/types/plugins/Paragraph/__tests__/createParagraphPlugin.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Paragraph/createParagraphPlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Paragraph/index.d.ts +1 -1
- package/dist/{plugins → types/plugins}/Paragraph/utils.d.ts +2 -2
- package/dist/{plugins → types/plugins}/PasteHTML/createPasteHTMLPlugin.d.ts +8 -8
- package/dist/{plugins → types/plugins}/PasteHTML/index.d.ts +1 -1
- package/dist/types/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/PasteHTML/utils/sanitizeAnchors.d.ts +19 -19
- package/dist/{plugins → types/plugins}/PasteHTML/utils/sanitizeHTML.d.ts +1 -1
- package/dist/{plugins → types/plugins}/PasteHTML/utils/sanitizeSheets.d.ts +4 -4
- package/dist/types/plugins/Quote/__test__/createQuotePlugin.test.d.ts +1 -0
- package/dist/types/plugins/Quote/components/Quote.d.ts +3 -0
- package/dist/{plugins → types/plugins}/Quote/components/ToolbarQuoteButton.d.ts +5 -4
- package/dist/{plugins → types/plugins}/Quote/createQuotePlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Quote/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Quote/shouldResetQuote.d.ts +8 -8
- package/dist/{plugins → types/plugins}/Quote/toggleQuote.d.ts +4 -4
- package/dist/{plugins → types/plugins}/Quote/withQuote.d.ts +2 -2
- package/dist/{plugins → types/plugins}/SelectOnBackspace/createSelectOnBackspacePlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/SelectOnBackspace/index.d.ts +1 -1
- package/dist/types/plugins/Table/__tests__/createTablePlugin.test.d.ts +1 -0
- package/dist/types/plugins/Table/__tests__/helpers.test.d.ts +1 -0
- package/dist/{plugins → types/plugins}/Table/actions/addColumn.d.ts +7 -7
- package/dist/{plugins → types/plugins}/Table/actions/addRow.d.ts +3 -3
- package/dist/{plugins → types/plugins}/Table/actions/index.d.ts +3 -3
- package/dist/{plugins → types/plugins}/Table/actions/setHeader.d.ts +2 -2
- package/dist/types/plugins/Table/components/Cell.d.ts +3 -0
- package/dist/{plugins → types/plugins}/Table/components/HeaderCell.d.ts +3 -2
- package/dist/types/plugins/Table/components/Row.d.ts +3 -0
- package/dist/{plugins → types/plugins}/Table/components/Table.d.ts +3 -2
- package/dist/types/plugins/Table/components/TableActions.d.ts +5 -0
- package/dist/{plugins → types/plugins}/Table/components/ToolbarButton.d.ts +5 -4
- package/dist/{plugins → types/plugins}/Table/createTablePlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Table/helpers.d.ts +15 -15
- package/dist/{plugins → types/plugins}/Table/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Table/insertTableFragment.d.ts +3 -3
- package/dist/{plugins → types/plugins}/Table/onKeyDownTable.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Table/tableTracking.d.ts +4 -4
- package/dist/types/plugins/Text/__tests__/createTextPlugin.test.d.ts +2 -0
- package/dist/{plugins → types/plugins}/Text/createTextPlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Text/index.d.ts +1 -1
- package/dist/{plugins → types/plugins}/Tracking/createTrackingPlugin.d.ts +12 -12
- package/dist/{plugins → types/plugins}/Tracking/index.d.ts +1 -1
- package/dist/{plugins → types/plugins}/Tracking/utils.d.ts +2 -2
- package/dist/{plugins → types/plugins}/TrailingParagraph/index.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Voids/createVoidsPlugin.d.ts +2 -2
- package/dist/{plugins → types/plugins}/Voids/index.d.ts +1 -1
- package/dist/{plugins → types/plugins}/Voids/transformVoid.d.ts +5 -5
- package/dist/{plugins → types/plugins}/index.d.ts +6 -6
- package/dist/types/plugins/links-tracking.d.ts +3 -0
- package/dist/types/plugins/shared/EmbeddedBlockToolbarIcon.d.ts +11 -0
- package/dist/types/plugins/shared/EmbeddedBlockUtil.d.ts +8 -0
- package/dist/{plugins → types/plugins}/shared/FetchingWrappedAssetCard.d.ts +14 -13
- package/dist/{plugins → types/plugins}/shared/FetchingWrappedEntryCard.d.ts +14 -13
- package/dist/types/plugins/shared/FetchingWrappedResourceCard.d.ts +14 -0
- package/dist/types/plugins/shared/LinkedBlockWrapper.d.ts +25 -0
- package/dist/{plugins → types/plugins}/shared/ToolbarButton.d.ts +12 -11
- package/dist/types/plugins/shared/__tests__/FetchingWrappedAssetCard.test.d.ts +1 -0
- package/dist/types/plugins/shared/__tests__/FetchingWrappedEntryCard.test.d.ts +1 -0
- package/dist/{prepareDocument.d.ts → types/prepareDocument.d.ts} +19 -19
- package/dist/{test-utils → types/test-utils}/assertOutput.d.ts +7 -7
- package/dist/{test-utils → types/test-utils}/createEditor.d.ts +31 -31
- package/dist/{test-utils → types/test-utils}/index.d.ts +4 -4
- package/dist/{test-utils → types/test-utils}/jsx.d.ts +28 -28
- package/dist/{test-utils → types/test-utils}/mockPlugin.d.ts +2 -2
- package/dist/{test-utils → types/test-utils}/randomId.d.ts +4 -4
- package/dist/{test-utils → types/test-utils}/setEmptyDataAttribute.d.ts +6 -6
- package/dist/{test-utils → types/test-utils}/validation.d.ts +1 -1
- package/dist/{useOnValueChanged.d.ts → types/useOnValueChanged.d.ts} +8 -8
- package/package.json +30 -24
- package/dist/Toolbar/index.d.ts +0 -5
- package/dist/field-editor-rich-text.cjs.development.js +0 -7133
- package/dist/field-editor-rich-text.cjs.development.js.map +0 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +0 -163
- package/dist/field-editor-rich-text.cjs.production.min.js.map +0 -1
- package/dist/field-editor-rich-text.esm.js +0 -7123
- package/dist/field-editor-rich-text.esm.js.map +0 -1
- package/dist/index.js +0 -8
- package/dist/internal/types/editor.d.ts +0 -51
- package/dist/plugins/EmbeddedEntityBlock/ToolbarIcon.d.ts +0 -10
- package/dist/plugins/EmbeddedEntityBlock/Util.d.ts +0 -4
- package/dist/plugins/Paragraph/Paragraph.d.ts +0 -2
- package/dist/plugins/Quote/components/Quote.d.ts +0 -2
- package/dist/plugins/Table/components/Cell.d.ts +0 -2
- package/dist/plugins/Table/components/Row.d.ts +0 -2
- package/dist/plugins/Table/components/TableActions.d.ts +0 -4
- package/dist/plugins/links-tracking.d.ts +0 -3
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { entityHelpers } from '@contentful/field-editor-shared';
|
|
3
|
+
import { getEntityInfo } from './utils';
|
|
4
|
+
async function fetchAllData({ sdk , entityId , entityType , localeCode , defaultLocaleCode }) {
|
|
5
|
+
let contentType;
|
|
6
|
+
const getEntity = entityType === 'Entry' ? sdk.space.getEntry : sdk.space.getAsset;
|
|
7
|
+
const entity = await getEntity(entityId);
|
|
8
|
+
if (entity.sys.contentType) {
|
|
9
|
+
const contentTypeId = entity.sys.contentType.sys.id;
|
|
10
|
+
contentType = sdk.space.getCachedContentTypes().find((ct)=>ct.sys.id === contentTypeId);
|
|
11
|
+
}
|
|
12
|
+
const entityTitle = entityType === 'Entry' ? entityHelpers.getEntryTitle({
|
|
13
|
+
entry: entity,
|
|
14
|
+
contentType,
|
|
15
|
+
localeCode,
|
|
16
|
+
defaultLocaleCode,
|
|
17
|
+
defaultTitle: 'Untitled'
|
|
18
|
+
}) : entityHelpers.getAssetTitle({
|
|
19
|
+
asset: entity,
|
|
20
|
+
localeCode,
|
|
21
|
+
defaultLocaleCode,
|
|
22
|
+
defaultTitle: 'Untitled'
|
|
23
|
+
});
|
|
24
|
+
const entityDescription = entityHelpers.getEntityDescription({
|
|
25
|
+
entity,
|
|
26
|
+
contentType,
|
|
27
|
+
localeCode,
|
|
28
|
+
defaultLocaleCode
|
|
29
|
+
});
|
|
30
|
+
const jobs = await sdk.space.getEntityScheduledActions(entityType, entityId);
|
|
31
|
+
const entityStatus = entityHelpers.getEntryStatus(entity.sys);
|
|
32
|
+
return {
|
|
33
|
+
jobs,
|
|
34
|
+
entity,
|
|
35
|
+
entityTitle,
|
|
36
|
+
entityDescription,
|
|
37
|
+
entityStatus,
|
|
38
|
+
contentTypeName: contentType ? contentType.name : ''
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function useRequestStatus({ sdk , target , onEntityFetchComplete }) {
|
|
42
|
+
const [requestStatus, setRequestStatus] = useState({
|
|
43
|
+
type: 'loading'
|
|
44
|
+
});
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
if (target) {
|
|
47
|
+
fetchAllData({
|
|
48
|
+
sdk,
|
|
49
|
+
entityId: target?.sys?.id,
|
|
50
|
+
entityType: target?.sys?.linkType,
|
|
51
|
+
localeCode: sdk.field.locale,
|
|
52
|
+
defaultLocaleCode: sdk.locales.default
|
|
53
|
+
}).then((entityInfo)=>{
|
|
54
|
+
setRequestStatus({
|
|
55
|
+
type: 'success',
|
|
56
|
+
data: entityInfo
|
|
57
|
+
});
|
|
58
|
+
}).catch((e)=>{
|
|
59
|
+
console.log(e);
|
|
60
|
+
setRequestStatus({
|
|
61
|
+
type: 'error',
|
|
62
|
+
error: e
|
|
63
|
+
});
|
|
64
|
+
}).finally(()=>{
|
|
65
|
+
onEntityFetchComplete?.();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}, [
|
|
69
|
+
sdk,
|
|
70
|
+
target,
|
|
71
|
+
onEntityFetchComplete
|
|
72
|
+
]);
|
|
73
|
+
return requestStatus;
|
|
74
|
+
}
|
|
75
|
+
export function useEntityInfo(props) {
|
|
76
|
+
const status = useRequestStatus(props);
|
|
77
|
+
const { linkType } = props.target.sys;
|
|
78
|
+
if (status.type === 'loading') {
|
|
79
|
+
return `Loading ${linkType.toLowerCase()}...`;
|
|
80
|
+
}
|
|
81
|
+
if (status.type === 'error') {
|
|
82
|
+
return `${linkType} missing or inaccessible`;
|
|
83
|
+
}
|
|
84
|
+
return getEntityInfo(status.data);
|
|
85
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getScheduleTooltipContent } from '@contentful/field-editor-reference';
|
|
2
|
+
import { isAncestorEmpty } from '@udecode/plate-core';
|
|
3
|
+
import { getText } from '../../internal/queries';
|
|
4
|
+
export const hasText = (editor, entry)=>{
|
|
5
|
+
const [node, path] = entry;
|
|
6
|
+
return !isAncestorEmpty(editor, node) && getText(editor, path).trim() !== '';
|
|
7
|
+
};
|
|
8
|
+
function truncate(str, length) {
|
|
9
|
+
if (typeof str === 'string' && str.length > length) {
|
|
10
|
+
return str && str.substr(0, length + 1).replace(/(\s+\S(?=\S)|\s*)\.?.$/, '…');
|
|
11
|
+
}
|
|
12
|
+
return str;
|
|
13
|
+
}
|
|
14
|
+
export function getEntityInfo(data) {
|
|
15
|
+
if (!data) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
const { entityTitle , contentTypeName , entityStatus , jobs } = data;
|
|
19
|
+
const title = truncate(entityTitle, 60) || 'Untitled';
|
|
20
|
+
const scheduledActions = jobs.length > 0 ? getScheduleTooltipContent({
|
|
21
|
+
job: jobs[0],
|
|
22
|
+
jobsCount: jobs.length
|
|
23
|
+
}) : '';
|
|
24
|
+
return `${contentTypeName || 'Asset'} "${title}", ${entityStatus} ${scheduledActions}`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { assertOutput, jsx } from '../../../test-utils';
|
|
2
|
+
describe('normalization', ()=>{
|
|
3
|
+
it('wraps orphaned list items in a list', ()=>{
|
|
4
|
+
const input = jsx("editor", null, jsx("hli", null, jsx("hp", null, "Item")), jsx("hp", null));
|
|
5
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"))), jsx("hp", null, jsx("htext", null)));
|
|
6
|
+
assertOutput({
|
|
7
|
+
input,
|
|
8
|
+
expected
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
it('adds empty paragraph to empty list items', ()=>{
|
|
12
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null)), jsx("hp", null));
|
|
13
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("htext", null)))), jsx("hp", null, jsx("htext", null)));
|
|
14
|
+
assertOutput({
|
|
15
|
+
input,
|
|
16
|
+
expected
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
it('replaces invalid list items with text', ()=>{
|
|
20
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"), jsx("htd", null, jsx("hp", null, jsx("htext", {
|
|
21
|
+
bold: true
|
|
22
|
+
}, "bold text"))), jsx("htd", null, jsx("hp", null, "Take a look at this ", jsx("hlink", {
|
|
23
|
+
uri: "https://google.com"
|
|
24
|
+
}, "link"))))), jsx("hp", null));
|
|
25
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item"), jsx("hp", null, jsx("htext", {
|
|
26
|
+
bold: true
|
|
27
|
+
}, "bold text")), jsx("hp", null, "Take a look at this ", jsx("hlink", {
|
|
28
|
+
uri: "https://google.com"
|
|
29
|
+
}, "link"), jsx("htext", null)))), jsx("hp", null, jsx("htext", null)));
|
|
30
|
+
assertOutput({
|
|
31
|
+
input,
|
|
32
|
+
expected
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
it('replaces list items with nested lists as a first child', ()=>{
|
|
36
|
+
const input = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1.1")))), jsx("hli", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.2"))))), jsx("hp", null, jsx("htext", null)));
|
|
37
|
+
const expected = jsx("editor", null, jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.1"), jsx("hul", null, jsx("hli", null, jsx("hp", null, "Item 2.1.1")))), jsx("hli", null, jsx("hp", null, "Item 2.2"))), jsx("hp", null, jsx("htext", null)));
|
|
38
|
+
assertOutput({
|
|
39
|
+
input,
|
|
40
|
+
expected
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx, assertOutput, createTestEditor } from '../../../test-utils';
|
|
2
|
+
describe('insert line break', ()=>{
|
|
3
|
+
const tests = [
|
|
4
|
+
{
|
|
5
|
+
title: 'at the start of a li',
|
|
6
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1"))),
|
|
7
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hp", null, "p1")))
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
title: 'at the end of a li',
|
|
11
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1", jsx("cursor", null)))),
|
|
12
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: 'at the middle of a li',
|
|
16
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ", jsx("cursor", null), "me"))),
|
|
17
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ")), jsx("hli", null, jsx("hp", null, jsx("cursor", null), "me")))
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: 'at the start of a li with multiple p',
|
|
21
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1"), jsx("hp", null, "p2"))),
|
|
22
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2")))
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: 'at the start of the second p of a li',
|
|
26
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, jsx("cursor", null), "p2"))),
|
|
27
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null)), jsx("hp", null, "p2")))
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: 'at the end of a li with multiple p',
|
|
31
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2", jsx("cursor", null)))),
|
|
32
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1"), jsx("hp", null, "p2")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'at the middle of a li with multiple p',
|
|
36
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ", jsx("cursor", null), "me"), jsx("hp", null, "move me"))),
|
|
37
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "split ")), jsx("hli", null, jsx("hp", null, jsx("cursor", null), "me"), jsx("hp", null, "move me")))
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'at the start of a li with heading',
|
|
41
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, jsx("cursor", null), "p1"))),
|
|
42
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null))), jsx("hli", null, jsx("hh1", null, "p1")))
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: 'at the end of a li with heading',
|
|
46
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "p1", jsx("cursor", null)))),
|
|
47
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "p1")), jsx("hli", null, jsx("hp", null, jsx("cursor", null))))
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: 'at the middle of a li with heading',
|
|
51
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "split ", jsx("cursor", null), "me"))),
|
|
52
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hh1", null, "split ")), jsx("hli", null, jsx("hh1", null, jsx("cursor", null), "me")))
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'at a li with nested list',
|
|
56
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "item 1")), jsx("hli", null, jsx("hp", null, "item 2", jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "sub list"))))),
|
|
57
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "item 1")), jsx("hli", null, jsx("hp", null, "item 2")), jsx("hli", null, jsx("hp", null, jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "sub list")))))
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
61
|
+
for (const t of tests){
|
|
62
|
+
test(t.title, ()=>{
|
|
63
|
+
const { editor } = createTestEditor({
|
|
64
|
+
input: render(t.input)
|
|
65
|
+
});
|
|
66
|
+
editor.insertBreak();
|
|
67
|
+
assertOutput({
|
|
68
|
+
editor,
|
|
69
|
+
expected: render(t.expected)
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx, assertOutput, createTestEditor } from '../../../test-utils';
|
|
2
|
+
describe('insert fragment', ()=>{
|
|
3
|
+
const tests = [
|
|
4
|
+
{
|
|
5
|
+
title: 'text wrapped in li > p',
|
|
6
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
7
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hp", null, "world"))),
|
|
8
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world")))
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: 'text wrapped in li > h*',
|
|
12
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
13
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hh1", null, "world"))),
|
|
14
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world")))
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
title: 'single li with only asset card',
|
|
18
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello", jsx("cursor", null), "world"))),
|
|
19
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hembed", {
|
|
20
|
+
type: "Asset",
|
|
21
|
+
id: "asset-id"
|
|
22
|
+
}))),
|
|
23
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello"), jsx("hembed", {
|
|
24
|
+
type: "Asset",
|
|
25
|
+
id: "asset-id"
|
|
26
|
+
}), jsx("hp", null, "world")))
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: 'two paragraphs',
|
|
30
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
31
|
+
fragment: jsx("fragment", null, jsx("hp", null, "world"), jsx("hp", null, "line 2")),
|
|
32
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world"), jsx("hp", null, "line 2")))
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'two headings',
|
|
36
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
37
|
+
fragment: jsx("fragment", null, jsx("hh1", null, "world"), jsx("hh1", null, "line 2")),
|
|
38
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello world"), jsx("hh1", null, "line 2")))
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: 'two paragraphs wrapped in a li',
|
|
42
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello ", jsx("cursor", null)))),
|
|
43
|
+
fragment: jsx("fragment", null, jsx("hli", null, jsx("hp", null, "world"), jsx("hp", null, "line 2"))),
|
|
44
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "hello "), jsx("hul", null, jsx("hli", null, jsx("hp", null, "world"), jsx("hp", null, "line 2")))))
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
48
|
+
for (const t of tests){
|
|
49
|
+
test(t.title, ()=>{
|
|
50
|
+
const { editor } = createTestEditor({
|
|
51
|
+
input: render(t.input)
|
|
52
|
+
});
|
|
53
|
+
editor.insertFragment(t.fragment);
|
|
54
|
+
assertOutput({
|
|
55
|
+
editor,
|
|
56
|
+
expected: render(t.expected)
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import tokens from '@contentful/f36-tokens';
|
|
3
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
4
|
+
import { css, cx } from 'emotion';
|
|
5
|
+
const baseStyle = css`
|
|
6
|
+
padding: 0;
|
|
7
|
+
margin: 0 0 1.25rem 1.25rem;
|
|
8
|
+
|
|
9
|
+
div:first-child {
|
|
10
|
+
margin: 0;
|
|
11
|
+
line-height: ${tokens.lineHeightDefault};
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
const styles = {
|
|
15
|
+
[BLOCKS.UL_LIST]: css`
|
|
16
|
+
list-style-type: disc;
|
|
17
|
+
ul {
|
|
18
|
+
list-style-type: circle;
|
|
19
|
+
ul {
|
|
20
|
+
list-style-type: square;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
[BLOCKS.OL_LIST]: css`
|
|
25
|
+
list-style-type: decimal;
|
|
26
|
+
ol {
|
|
27
|
+
list-style-type: upper-alpha;
|
|
28
|
+
ol {
|
|
29
|
+
list-style-type: lower-roman;
|
|
30
|
+
ol {
|
|
31
|
+
list-style-type: lower-alpha;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`
|
|
36
|
+
};
|
|
37
|
+
function createList(Tag, block) {
|
|
38
|
+
return function List(props) {
|
|
39
|
+
return React.createElement(Tag, {
|
|
40
|
+
...props.attributes,
|
|
41
|
+
className: cx(baseStyle, styles[block])
|
|
42
|
+
}, props.children);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export const ListUL = createList('ul', BLOCKS.UL_LIST);
|
|
46
|
+
export const ListOL = createList('ol', BLOCKS.OL_LIST);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import tokens from '@contentful/f36-tokens';
|
|
3
|
+
import { css } from 'emotion';
|
|
4
|
+
const style = css`
|
|
5
|
+
margin: 0;
|
|
6
|
+
list-style: inherit;
|
|
7
|
+
margin-top: ${tokens.spacingXs};
|
|
8
|
+
|
|
9
|
+
ol,
|
|
10
|
+
ul {
|
|
11
|
+
margin: 0 0 0 ${tokens.spacingL};
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
export function ListItem(props) {
|
|
15
|
+
return React.createElement("li", {
|
|
16
|
+
...props.attributes,
|
|
17
|
+
className: style
|
|
18
|
+
}, props.children);
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ListBulletedIcon, ListNumberedIcon } from '@contentful/f36-icons';
|
|
3
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
4
|
+
import { useContentfulEditor } from '../../../ContentfulEditorProvider';
|
|
5
|
+
import { focus } from '../../../helpers/editor';
|
|
6
|
+
import { isNodeTypeEnabled } from '../../../helpers/validations';
|
|
7
|
+
import { useSdkContext } from '../../../SdkProvider';
|
|
8
|
+
import { ToolbarButton } from '../../shared/ToolbarButton';
|
|
9
|
+
import { toggleList } from '../transforms/toggleList';
|
|
10
|
+
import { isListTypeActive } from '../utils';
|
|
11
|
+
export function ToolbarListButton(props) {
|
|
12
|
+
const sdk = useSdkContext();
|
|
13
|
+
const editor = useContentfulEditor();
|
|
14
|
+
function handleClick(type) {
|
|
15
|
+
return ()=>{
|
|
16
|
+
if (!editor?.selection) return;
|
|
17
|
+
toggleList(editor, {
|
|
18
|
+
type
|
|
19
|
+
});
|
|
20
|
+
focus(editor);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!editor) return null;
|
|
24
|
+
return React.createElement(React.Fragment, null, isNodeTypeEnabled(sdk.field, BLOCKS.UL_LIST) && React.createElement(ToolbarButton, {
|
|
25
|
+
title: "UL",
|
|
26
|
+
testId: "ul-toolbar-button",
|
|
27
|
+
onClick: handleClick(BLOCKS.UL_LIST),
|
|
28
|
+
isActive: isListTypeActive(editor, BLOCKS.UL_LIST),
|
|
29
|
+
isDisabled: props.isDisabled
|
|
30
|
+
}, React.createElement(ListBulletedIcon, null)), isNodeTypeEnabled(sdk.field, BLOCKS.OL_LIST) && React.createElement(ToolbarButton, {
|
|
31
|
+
title: "OL",
|
|
32
|
+
testId: "ol-toolbar-button",
|
|
33
|
+
onClick: handleClick(BLOCKS.OL_LIST),
|
|
34
|
+
isActive: isListTypeActive(editor, BLOCKS.OL_LIST),
|
|
35
|
+
isDisabled: props.isDisabled
|
|
36
|
+
}, React.createElement(ListNumberedIcon, null)));
|
|
37
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BLOCKS, LIST_ITEM_BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { createListPlugin as createPlateListPlugin, ELEMENT_LI, ELEMENT_UL, ELEMENT_OL, ELEMENT_LIC } from '@udecode/plate-list';
|
|
3
|
+
import { transformParagraphs, transformWrapIn } from '../../helpers/transformers';
|
|
4
|
+
import { ListOL, ListUL } from './components/List';
|
|
5
|
+
import { ListItem } from './components/ListItem';
|
|
6
|
+
import { onKeyDownList } from './onKeyDownList';
|
|
7
|
+
import { isNonEmptyListItem, hasListAsDirectParent, insertParagraphAsChild, normalizeOrphanedListItem, firstNodeIsNotList, replaceNodeWithListItems } from './utils';
|
|
8
|
+
import { withList } from './withList';
|
|
9
|
+
export const createListPlugin = ()=>createPlateListPlugin({
|
|
10
|
+
normalizer: [
|
|
11
|
+
{
|
|
12
|
+
match: {
|
|
13
|
+
type: [
|
|
14
|
+
BLOCKS.UL_LIST,
|
|
15
|
+
BLOCKS.OL_LIST
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
validChildren: [
|
|
19
|
+
BLOCKS.LIST_ITEM
|
|
20
|
+
],
|
|
21
|
+
transform: transformWrapIn(BLOCKS.LIST_ITEM)
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
overrideByKey: {
|
|
25
|
+
[ELEMENT_UL]: {
|
|
26
|
+
type: BLOCKS.UL_LIST,
|
|
27
|
+
component: ListUL,
|
|
28
|
+
handlers: {
|
|
29
|
+
onKeyDown: onKeyDownList
|
|
30
|
+
},
|
|
31
|
+
withOverrides: withList
|
|
32
|
+
},
|
|
33
|
+
[ELEMENT_OL]: {
|
|
34
|
+
type: BLOCKS.OL_LIST,
|
|
35
|
+
component: ListOL,
|
|
36
|
+
handlers: {
|
|
37
|
+
onKeyDown: onKeyDownList
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
[ELEMENT_LIC]: {
|
|
41
|
+
type: BLOCKS.PARAGRAPH
|
|
42
|
+
},
|
|
43
|
+
[ELEMENT_LI]: {
|
|
44
|
+
type: BLOCKS.LIST_ITEM,
|
|
45
|
+
component: ListItem,
|
|
46
|
+
normalizer: [
|
|
47
|
+
{
|
|
48
|
+
validNode: hasListAsDirectParent,
|
|
49
|
+
transform: normalizeOrphanedListItem
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
validNode: isNonEmptyListItem,
|
|
53
|
+
transform: insertParagraphAsChild
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
validChildren: LIST_ITEM_BLOCKS,
|
|
57
|
+
transform: transformParagraphs
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
validNode: firstNodeIsNotList,
|
|
61
|
+
transform: replaceNodeWithListItems
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TEXT_CONTAINERS } from '@contentful/rich-text-types';
|
|
2
|
+
import { ELEMENT_DEFAULT, getPluginType, isBlockAboveEmpty, mockPlugin } from '@udecode/plate-core';
|
|
3
|
+
import { getListItemEntry, moveListItemUp, unwrapList, ELEMENT_LI } from '@udecode/plate-list';
|
|
4
|
+
import { onKeyDownResetNode, SIMULATE_BACKSPACE } from '@udecode/plate-reset-node';
|
|
5
|
+
import { insertListItem } from './transforms/insertListItem';
|
|
6
|
+
const listBreak = (editor)=>{
|
|
7
|
+
if (!editor.selection) return false;
|
|
8
|
+
const res = getListItemEntry(editor, {});
|
|
9
|
+
let moved;
|
|
10
|
+
if (res) {
|
|
11
|
+
const { list , listItem } = res;
|
|
12
|
+
const childNode = listItem[0].children[0];
|
|
13
|
+
if (isBlockAboveEmpty(editor) && listItem[0].children.length === 1 && TEXT_CONTAINERS.includes(childNode.type)) {
|
|
14
|
+
moved = moveListItemUp(editor, {
|
|
15
|
+
list,
|
|
16
|
+
listItem
|
|
17
|
+
});
|
|
18
|
+
if (moved) return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const didReset = onKeyDownResetNode(editor, mockPlugin({
|
|
22
|
+
options: {
|
|
23
|
+
rules: [
|
|
24
|
+
{
|
|
25
|
+
types: [
|
|
26
|
+
getPluginType(editor, ELEMENT_LI)
|
|
27
|
+
],
|
|
28
|
+
defaultType: getPluginType(editor, ELEMENT_DEFAULT),
|
|
29
|
+
predicate: ()=>!moved && isBlockAboveEmpty(editor),
|
|
30
|
+
onReset: (_editor)=>unwrapList(_editor)
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}))(SIMULATE_BACKSPACE);
|
|
35
|
+
if (didReset) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (!moved) {
|
|
39
|
+
const inserted = insertListItem(editor);
|
|
40
|
+
if (inserted) return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
export const insertListBreak = (editor)=>{
|
|
45
|
+
const { insertBreak } = editor;
|
|
46
|
+
return ()=>{
|
|
47
|
+
if (listBreak(editor)) return;
|
|
48
|
+
insertBreak();
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { TEXT_CONTAINERS, BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { findNode } from '@udecode/plate-core';
|
|
3
|
+
import { isBlockNode, isAncestorPath, getCommonNode, getNodeTexts, getParentPath, getDescendantNodeByPath } from '../../internal/queries';
|
|
4
|
+
import { insertNodes } from '../../internal/transforms';
|
|
5
|
+
const getFirstAncestorOfType = (root, entry)=>{
|
|
6
|
+
let ancestor = getParentPath(entry[1]);
|
|
7
|
+
while(getDescendantNodeByPath(root, ancestor).type !== BLOCKS.LIST_ITEM){
|
|
8
|
+
ancestor = getParentPath(ancestor);
|
|
9
|
+
}
|
|
10
|
+
return [
|
|
11
|
+
getDescendantNodeByPath(root, ancestor),
|
|
12
|
+
ancestor
|
|
13
|
+
];
|
|
14
|
+
};
|
|
15
|
+
const isListRoot = (node)=>[
|
|
16
|
+
BLOCKS.UL_LIST,
|
|
17
|
+
BLOCKS.OL_LIST
|
|
18
|
+
].includes(node.type);
|
|
19
|
+
const trimList = (listRoot)=>{
|
|
20
|
+
if (!isListRoot(listRoot)) {
|
|
21
|
+
return [
|
|
22
|
+
listRoot
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
const textEntries = Array.from(getNodeTexts(listRoot));
|
|
26
|
+
const commonAncestorEntry = textEntries.reduce((commonAncestor, textEntry)=>isAncestorPath(commonAncestor[1], textEntry[1]) ? commonAncestor : getCommonNode(listRoot, textEntry[1], commonAncestor[1]), getFirstAncestorOfType(listRoot, textEntries[0]));
|
|
27
|
+
return isListRoot(commonAncestorEntry[0]) ? commonAncestorEntry[0].children : [
|
|
28
|
+
commonAncestorEntry[0]
|
|
29
|
+
];
|
|
30
|
+
};
|
|
31
|
+
const trimLiWrapper = (nodes)=>{
|
|
32
|
+
if (nodes.length !== 1) {
|
|
33
|
+
return nodes;
|
|
34
|
+
}
|
|
35
|
+
const node = nodes[0];
|
|
36
|
+
if (node.type !== BLOCKS.LIST_ITEM || node.children.length !== 1) {
|
|
37
|
+
return nodes;
|
|
38
|
+
}
|
|
39
|
+
return node.children;
|
|
40
|
+
};
|
|
41
|
+
const unwrapTextContainerAtStart = (nodes)=>{
|
|
42
|
+
const node = nodes[0];
|
|
43
|
+
if (TEXT_CONTAINERS.includes(node.type)) {
|
|
44
|
+
return [
|
|
45
|
+
...node.children,
|
|
46
|
+
...nodes.slice(1)
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
return nodes;
|
|
50
|
+
};
|
|
51
|
+
export const insertListFragment = (editor)=>{
|
|
52
|
+
const { insertFragment } = editor;
|
|
53
|
+
return (fragment)=>{
|
|
54
|
+
if (!editor.selection) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const liEntry = findNode(editor, {
|
|
58
|
+
match: {
|
|
59
|
+
type: BLOCKS.LIST_ITEM
|
|
60
|
+
},
|
|
61
|
+
mode: 'lowest'
|
|
62
|
+
});
|
|
63
|
+
if (liEntry) {
|
|
64
|
+
const nodes = unwrapTextContainerAtStart(trimLiWrapper(fragment.flatMap((node)=>trimList(node))));
|
|
65
|
+
let firstBlockIndex = nodes.findIndex((node)=>isBlockNode(editor, node));
|
|
66
|
+
if (firstBlockIndex < 0) {
|
|
67
|
+
firstBlockIndex = nodes.length;
|
|
68
|
+
}
|
|
69
|
+
const inlines = nodes.slice(0, firstBlockIndex);
|
|
70
|
+
const blocks = nodes.slice(firstBlockIndex);
|
|
71
|
+
insertNodes(editor, inlines, {
|
|
72
|
+
at: editor.selection,
|
|
73
|
+
select: true
|
|
74
|
+
});
|
|
75
|
+
return insertNodes(editor, blocks, {
|
|
76
|
+
at: editor.selection,
|
|
77
|
+
select: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const filtered = isListRoot(fragment[0]) ? [
|
|
81
|
+
{
|
|
82
|
+
text: ''
|
|
83
|
+
},
|
|
84
|
+
...fragment
|
|
85
|
+
] : fragment;
|
|
86
|
+
return insertFragment(filtered);
|
|
87
|
+
};
|
|
88
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import isHotkey from 'is-hotkey';
|
|
2
|
+
import castArray from 'lodash/castArray';
|
|
3
|
+
import { getAboveNode } from '../../internal/queries';
|
|
4
|
+
import { moveListItems } from './transforms/moveListItems';
|
|
5
|
+
import { toggleList } from './transforms/toggleList';
|
|
6
|
+
export const onKeyDownList = (editor, { type , options: { hotkey } })=>(e)=>{
|
|
7
|
+
if (e.key === 'Tab' && editor.selection) {
|
|
8
|
+
const listSelected = getAboveNode(editor, {
|
|
9
|
+
at: editor.selection,
|
|
10
|
+
match: {
|
|
11
|
+
type
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (listSelected) {
|
|
15
|
+
e.preventDefault();
|
|
16
|
+
moveListItems(editor, {
|
|
17
|
+
increase: !e.shiftKey
|
|
18
|
+
});
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!hotkey) return;
|
|
23
|
+
const hotkeys = castArray(hotkey);
|
|
24
|
+
for (const _hotkey of hotkeys){
|
|
25
|
+
if (isHotkey(_hotkey)(e)) {
|
|
26
|
+
toggleList(editor, {
|
|
27
|
+
type
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|