@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,60 @@
|
|
|
1
|
+
import { createDeserializeAstPlugin, createDeserializeHtmlPlugin } from '@udecode/plate-core';
|
|
2
|
+
import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
3
|
+
import { createSoftBreakPlugin, createExitBreakPlugin, createResetNodePlugin } from './Break';
|
|
4
|
+
import { createCommandPalettePlugin } from './CommandPalette';
|
|
5
|
+
import { isCommandPromptPluginEnabled } from './CommandPalette/useCommands';
|
|
6
|
+
import { createDragAndDropPlugin } from './DragAndDrop';
|
|
7
|
+
import { createEmbeddedAssetBlockPlugin, createEmbeddedEntryBlockPlugin } from './EmbeddedEntityBlock';
|
|
8
|
+
import { createEmbeddedEntityInlinePlugin } from './EmbeddedEntityInline';
|
|
9
|
+
import { createEmbeddedResourceBlockPlugin } from './EmbeddedResourceBlock';
|
|
10
|
+
import { createHeadingPlugin } from './Heading';
|
|
11
|
+
import { createHrPlugin } from './Hr';
|
|
12
|
+
import { createHyperlinkPlugin } from './Hyperlink';
|
|
13
|
+
import { createListPlugin } from './List';
|
|
14
|
+
import { createMarksPlugin } from './Marks';
|
|
15
|
+
import { createNormalizerPlugin } from './Normalizer';
|
|
16
|
+
import { createParagraphPlugin } from './Paragraph';
|
|
17
|
+
import { createPasteHTMLPlugin } from './PasteHTML';
|
|
18
|
+
import { createQuotePlugin } from './Quote';
|
|
19
|
+
import { createSelectOnBackspacePlugin } from './SelectOnBackspace';
|
|
20
|
+
import { createTablePlugin } from './Table';
|
|
21
|
+
import { createTextPlugin } from './Text';
|
|
22
|
+
import { createTrackingPlugin } from './Tracking';
|
|
23
|
+
import { createTrailingParagraphPlugin } from './TrailingParagraph';
|
|
24
|
+
import { createVoidsPlugin } from './Voids';
|
|
25
|
+
export const getPlugins = (sdk, onAction, restrictedMarks)=>[
|
|
26
|
+
createDeserializeHtmlPlugin(),
|
|
27
|
+
createDeserializeAstPlugin(),
|
|
28
|
+
createDeserializeDocxPlugin(),
|
|
29
|
+
createTrackingPlugin(onAction),
|
|
30
|
+
createDragAndDropPlugin(),
|
|
31
|
+
...Object.values(isCommandPromptPluginEnabled(sdk)).some(Boolean) ? [
|
|
32
|
+
createCommandPalettePlugin()
|
|
33
|
+
] : [],
|
|
34
|
+
createParagraphPlugin(),
|
|
35
|
+
createListPlugin(),
|
|
36
|
+
createHrPlugin(),
|
|
37
|
+
createHeadingPlugin(),
|
|
38
|
+
createQuotePlugin(),
|
|
39
|
+
createTablePlugin(),
|
|
40
|
+
createEmbeddedEntryBlockPlugin(sdk),
|
|
41
|
+
createEmbeddedAssetBlockPlugin(sdk),
|
|
42
|
+
createEmbeddedResourceBlockPlugin(sdk),
|
|
43
|
+
createHyperlinkPlugin(sdk),
|
|
44
|
+
createEmbeddedEntityInlinePlugin(sdk),
|
|
45
|
+
createMarksPlugin(),
|
|
46
|
+
createTrailingParagraphPlugin(),
|
|
47
|
+
createTextPlugin(restrictedMarks),
|
|
48
|
+
createVoidsPlugin(),
|
|
49
|
+
createSelectOnBackspacePlugin(),
|
|
50
|
+
createPasteHTMLPlugin(),
|
|
51
|
+
createSoftBreakPlugin(),
|
|
52
|
+
createExitBreakPlugin(),
|
|
53
|
+
createResetNodePlugin(),
|
|
54
|
+
createNormalizerPlugin()
|
|
55
|
+
];
|
|
56
|
+
export const disableCorePlugins = {
|
|
57
|
+
deserializeAst: true,
|
|
58
|
+
deserializeHtml: true,
|
|
59
|
+
eventEditor: true
|
|
60
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useContentfulEditorRef } from '../ContentfulEditorProvider';
|
|
3
|
+
export function useLinkTracking() {
|
|
4
|
+
const editor = useContentfulEditorRef();
|
|
5
|
+
return {
|
|
6
|
+
onEntityFetchComplete: useCallback(()=>editor?.tracking.onViewportAction('linkRendered'), [
|
|
7
|
+
editor
|
|
8
|
+
])
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Badge, Flex, Icon, Menu } from '@contentful/f36-components';
|
|
3
|
+
import { AssetIcon, EmbeddedEntryBlockIcon } from '@contentful/f36-icons';
|
|
4
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
5
|
+
import { css } from 'emotion';
|
|
6
|
+
import { useContentfulEditor } from '../../ContentfulEditorProvider';
|
|
7
|
+
import { useSdkContext } from '../../SdkProvider';
|
|
8
|
+
import { selectEntityAndInsert, selectResourceEntityAndInsert } from '../shared/EmbeddedBlockUtil';
|
|
9
|
+
export const styles = {
|
|
10
|
+
icon: css({
|
|
11
|
+
marginRight: '10px'
|
|
12
|
+
})
|
|
13
|
+
};
|
|
14
|
+
export function EmbeddedBlockToolbarIcon({ isDisabled , nodeType , onClose }) {
|
|
15
|
+
const editor = useContentfulEditor();
|
|
16
|
+
const sdk = useSdkContext();
|
|
17
|
+
const handleClick = async (event)=>{
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
if (!editor) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
onClose();
|
|
23
|
+
if (nodeType == BLOCKS.EMBEDDED_RESOURCE) {
|
|
24
|
+
await selectResourceEntityAndInsert(sdk, editor, editor.tracking.onToolbarAction);
|
|
25
|
+
} else {
|
|
26
|
+
await selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onToolbarAction);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const type = getEntityTypeFromNodeType(nodeType);
|
|
30
|
+
const baseClass = `rich-text__${nodeType}`;
|
|
31
|
+
return React.createElement(Menu.Item, {
|
|
32
|
+
disabled: isDisabled,
|
|
33
|
+
className: `${baseClass}-list-item`,
|
|
34
|
+
onClick: handleClick,
|
|
35
|
+
testId: `toolbar-toggle-${nodeType}`
|
|
36
|
+
}, React.createElement(Flex, {
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
flexDirection: "row"
|
|
39
|
+
}, React.createElement(Icon, {
|
|
40
|
+
as: type === 'Asset' ? AssetIcon : EmbeddedEntryBlockIcon,
|
|
41
|
+
className: `rich-text__embedded-entry-list-icon ${styles.icon}`,
|
|
42
|
+
variant: "secondary"
|
|
43
|
+
}), React.createElement("span", null, type, nodeType == BLOCKS.EMBEDDED_RESOURCE && React.createElement(React.Fragment, null, ' ', "(different space)", ' ', React.createElement(Badge, {
|
|
44
|
+
variant: "primary-filled",
|
|
45
|
+
size: "small"
|
|
46
|
+
}, "new")))));
|
|
47
|
+
}
|
|
48
|
+
function getEntityTypeFromNodeType(nodeType) {
|
|
49
|
+
const words = nodeType.toLowerCase().split('-');
|
|
50
|
+
if (words.includes('entry') || words.includes('resource')) {
|
|
51
|
+
return 'Entry';
|
|
52
|
+
}
|
|
53
|
+
if (words.includes('asset')) {
|
|
54
|
+
return 'Asset';
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Node type \`${nodeType}\` has no associated \`entityType\``);
|
|
57
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { BLOCKS, TEXT_CONTAINERS } from '@contentful/rich-text-types';
|
|
2
|
+
import isHotkey from 'is-hotkey';
|
|
3
|
+
import { focus, getNodeEntryFromSelection, insertEmptyParagraph, moveToTheNextChar } from '../../helpers/editor';
|
|
4
|
+
import newEntitySelectorConfigFromRichTextField from '../../helpers/newEntitySelectorConfigFromRichTextField';
|
|
5
|
+
import newResourceEntitySelectorConfigFromRichTextField from '../../helpers/newResourceEntitySelectorConfigFromRichTextField';
|
|
6
|
+
import { watchCurrentSlide } from '../../helpers/sdkNavigatorSlideIn';
|
|
7
|
+
import { getText, getAboveNode, getLastNodeByLevel, insertNodes, setNodes, select, removeNodes } from '../../internal';
|
|
8
|
+
export function getWithEmbeddedBlockEvents(nodeType, sdk) {
|
|
9
|
+
return (editor, { options: { hotkey } })=>(event)=>{
|
|
10
|
+
const [, pathToSelectedElement] = getNodeEntryFromSelection(editor, nodeType);
|
|
11
|
+
if (pathToSelectedElement) {
|
|
12
|
+
const isDelete = event.key === 'Delete';
|
|
13
|
+
const isBackspace = event.key === 'Backspace';
|
|
14
|
+
if (isDelete || isBackspace) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
removeNodes(editor, {
|
|
17
|
+
at: pathToSelectedElement
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (hotkey && isHotkey(hotkey, event)) {
|
|
23
|
+
if (nodeType === BLOCKS.EMBEDDED_RESOURCE) {
|
|
24
|
+
selectResourceEntityAndInsert(sdk, editor, editor.tracking.onShortcutAction);
|
|
25
|
+
} else {
|
|
26
|
+
selectEntityAndInsert(nodeType, sdk, editor, editor.tracking.onShortcutAction);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export async function selectEntityAndInsert(nodeType, sdk, editor, logAction) {
|
|
32
|
+
logAction('openCreateEmbedDialog', {
|
|
33
|
+
nodeType
|
|
34
|
+
});
|
|
35
|
+
const { field , dialogs } = sdk;
|
|
36
|
+
const baseConfig = newEntitySelectorConfigFromRichTextField(field, nodeType);
|
|
37
|
+
const selectEntity = baseConfig.entityType === 'Asset' ? dialogs.selectSingleAsset : dialogs.selectSingleEntry;
|
|
38
|
+
const config = {
|
|
39
|
+
...baseConfig,
|
|
40
|
+
withCreate: true
|
|
41
|
+
};
|
|
42
|
+
const { selection } = editor;
|
|
43
|
+
const rteSlide = watchCurrentSlide(sdk.navigator);
|
|
44
|
+
const entity = await selectEntity(config);
|
|
45
|
+
if (!entity) {
|
|
46
|
+
logAction('cancelCreateEmbedDialog', {
|
|
47
|
+
nodeType
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
select(editor, selection);
|
|
51
|
+
insertBlock(editor, nodeType, entity);
|
|
52
|
+
ensureFollowingParagraph(editor, [
|
|
53
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
54
|
+
BLOCKS.EMBEDDED_ENTRY
|
|
55
|
+
]);
|
|
56
|
+
logAction('insert', {
|
|
57
|
+
nodeType
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
rteSlide.onActive(()=>{
|
|
61
|
+
rteSlide.unwatch();
|
|
62
|
+
focus(editor);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export async function selectResourceEntityAndInsert(sdk, editor, logAction) {
|
|
66
|
+
logAction('openCreateEmbedDialog', {
|
|
67
|
+
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
68
|
+
});
|
|
69
|
+
const { field , dialogs } = sdk;
|
|
70
|
+
const config = newResourceEntitySelectorConfigFromRichTextField(field, BLOCKS.EMBEDDED_RESOURCE);
|
|
71
|
+
const { selection } = editor;
|
|
72
|
+
const entity = await dialogs.selectSingleResourceEntry(config);
|
|
73
|
+
if (!entity) {
|
|
74
|
+
logAction('cancelCreateEmbedDialog', {
|
|
75
|
+
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
select(editor, selection);
|
|
79
|
+
insertBlock(editor, BLOCKS.EMBEDDED_RESOURCE, entity);
|
|
80
|
+
ensureFollowingParagraph(editor, [
|
|
81
|
+
BLOCKS.EMBEDDED_RESOURCE
|
|
82
|
+
]);
|
|
83
|
+
logAction('insert', {
|
|
84
|
+
nodeType: BLOCKS.EMBEDDED_RESOURCE
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function ensureFollowingParagraph(editor, nodeTypes) {
|
|
89
|
+
const entityBlock = getAboveNode(editor, {
|
|
90
|
+
match: {
|
|
91
|
+
type: nodeTypes
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
if (!entityBlock) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const level = entityBlock[1].length - 1;
|
|
98
|
+
const lastNode = getLastNodeByLevel(editor, level);
|
|
99
|
+
const isTextContainer = TEXT_CONTAINERS.includes(lastNode?.[0].type ?? '');
|
|
100
|
+
if (level !== 0 && !isTextContainer) {
|
|
101
|
+
insertEmptyParagraph(editor);
|
|
102
|
+
}
|
|
103
|
+
moveToTheNextChar(editor);
|
|
104
|
+
}
|
|
105
|
+
const getLink = (nodeType, entity)=>{
|
|
106
|
+
if (nodeType === BLOCKS.EMBEDDED_RESOURCE) {
|
|
107
|
+
return {
|
|
108
|
+
urn: entity.sys.urn,
|
|
109
|
+
type: 'ResourceLink',
|
|
110
|
+
linkType: 'Contentful:Entry'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id: entity.sys.id,
|
|
115
|
+
type: 'Link',
|
|
116
|
+
linkType: entity.sys.type
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
const createNode = (nodeType, entity)=>{
|
|
120
|
+
return {
|
|
121
|
+
type: nodeType,
|
|
122
|
+
data: {
|
|
123
|
+
target: {
|
|
124
|
+
sys: getLink(nodeType, entity)
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
{
|
|
129
|
+
text: ''
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
isVoid: true
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
function insertBlock(editor, nodeType, entity) {
|
|
136
|
+
if (!editor?.selection) return;
|
|
137
|
+
const linkedEntityBlock = createNode(nodeType, entity);
|
|
138
|
+
const hasText = editor.selection && !!getText(editor, editor.selection.focus.path);
|
|
139
|
+
if (hasText) {
|
|
140
|
+
insertNodes(editor, linkedEntityBlock);
|
|
141
|
+
} else {
|
|
142
|
+
setNodes(editor, linkedEntityBlock);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AssetCard } from '@contentful/f36-components';
|
|
3
|
+
import { useEntity, useEntityLoader, MissingEntityCard, WrappedAssetCard } from '@contentful/field-editor-reference';
|
|
4
|
+
import areEqual from 'fast-deep-equal';
|
|
5
|
+
const InternalAssetCard = React.memo((props)=>{
|
|
6
|
+
if (props.asset === undefined) {
|
|
7
|
+
return React.createElement(AssetCard, {
|
|
8
|
+
size: "default",
|
|
9
|
+
isLoading: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (props.asset === 'failed') {
|
|
13
|
+
return React.createElement(MissingEntityCard, {
|
|
14
|
+
entityType: "Asset",
|
|
15
|
+
isDisabled: props.isDisabled,
|
|
16
|
+
onRemove: props.onRemove
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return React.createElement(WrappedAssetCard, {
|
|
20
|
+
getEntityScheduledActions: props.loadEntityScheduledActions,
|
|
21
|
+
size: "small",
|
|
22
|
+
isSelected: props.isSelected,
|
|
23
|
+
isDisabled: props.isDisabled,
|
|
24
|
+
localeCode: props.locale,
|
|
25
|
+
defaultLocaleCode: props.sdk.locales.default,
|
|
26
|
+
asset: props.asset,
|
|
27
|
+
onEdit: props.onEdit,
|
|
28
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
29
|
+
isClickable: false
|
|
30
|
+
});
|
|
31
|
+
}, areEqual);
|
|
32
|
+
InternalAssetCard.displayName = 'InternalAssetCard';
|
|
33
|
+
export function FetchingWrappedAssetCard(props) {
|
|
34
|
+
const { onEntityFetchComplete } = props;
|
|
35
|
+
const { data: asset , status } = useEntity('Asset', props.assetId);
|
|
36
|
+
const { getEntityScheduledActions } = useEntityLoader();
|
|
37
|
+
const loadEntityScheduledActions = React.useCallback(()=>getEntityScheduledActions('Asset', props.assetId), [
|
|
38
|
+
getEntityScheduledActions,
|
|
39
|
+
props.assetId
|
|
40
|
+
]);
|
|
41
|
+
React.useEffect(()=>{
|
|
42
|
+
if (status === 'success') {
|
|
43
|
+
onEntityFetchComplete?.();
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
onEntityFetchComplete,
|
|
47
|
+
status
|
|
48
|
+
]);
|
|
49
|
+
return React.createElement(InternalAssetCard, {
|
|
50
|
+
asset: asset,
|
|
51
|
+
sdk: props.sdk,
|
|
52
|
+
isDisabled: props.isDisabled,
|
|
53
|
+
isSelected: props.isSelected,
|
|
54
|
+
loadEntityScheduledActions: loadEntityScheduledActions,
|
|
55
|
+
locale: props.locale,
|
|
56
|
+
onEdit: props.onEdit,
|
|
57
|
+
onRemove: props.onRemove
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { EntryCard } from '@contentful/f36-components';
|
|
3
|
+
import { useEntity, MissingEntityCard, WrappedEntryCard, useEntityLoader } from '@contentful/field-editor-reference';
|
|
4
|
+
import areEqual from 'fast-deep-equal';
|
|
5
|
+
const InternalEntryCard = React.memo((props)=>{
|
|
6
|
+
const { entry , sdk , loadEntityScheduledActions } = props;
|
|
7
|
+
if (entry === undefined) {
|
|
8
|
+
return React.createElement(EntryCard, {
|
|
9
|
+
isLoading: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
if (entry === 'failed') {
|
|
13
|
+
return React.createElement(MissingEntityCard, {
|
|
14
|
+
entityType: "Entry",
|
|
15
|
+
isDisabled: props.isDisabled,
|
|
16
|
+
onRemove: props.onRemove
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const contentType = sdk.space.getCachedContentTypes().find((contentType)=>contentType.sys.id === entry.sys.contentType.sys.id);
|
|
20
|
+
return React.createElement(WrappedEntryCard, {
|
|
21
|
+
size: "default",
|
|
22
|
+
getAsset: props.sdk.space.getAsset,
|
|
23
|
+
getEntityScheduledActions: loadEntityScheduledActions,
|
|
24
|
+
isSelected: props.isSelected,
|
|
25
|
+
isDisabled: props.isDisabled,
|
|
26
|
+
localeCode: props.locale,
|
|
27
|
+
defaultLocaleCode: props.sdk.locales.default,
|
|
28
|
+
contentType: contentType,
|
|
29
|
+
entry: entry,
|
|
30
|
+
onEdit: props.onEdit,
|
|
31
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
32
|
+
isClickable: false
|
|
33
|
+
});
|
|
34
|
+
}, areEqual);
|
|
35
|
+
InternalEntryCard.displayName = 'ReferenceCard';
|
|
36
|
+
export const FetchingWrappedEntryCard = (props)=>{
|
|
37
|
+
const { entryId , onEntityFetchComplete } = props;
|
|
38
|
+
const { data: entry , status } = useEntity('Entry', entryId);
|
|
39
|
+
const { getEntityScheduledActions } = useEntityLoader();
|
|
40
|
+
const loadEntityScheduledActions = React.useCallback(()=>getEntityScheduledActions('Entry', entryId), [
|
|
41
|
+
getEntityScheduledActions,
|
|
42
|
+
entryId
|
|
43
|
+
]);
|
|
44
|
+
React.useEffect(()=>{
|
|
45
|
+
if (status === 'success') {
|
|
46
|
+
onEntityFetchComplete?.();
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
onEntityFetchComplete,
|
|
50
|
+
status
|
|
51
|
+
]);
|
|
52
|
+
return React.createElement(InternalEntryCard, {
|
|
53
|
+
entry: entry,
|
|
54
|
+
sdk: props.sdk,
|
|
55
|
+
locale: props.locale,
|
|
56
|
+
isDisabled: props.isDisabled,
|
|
57
|
+
isSelected: props.isSelected,
|
|
58
|
+
onEdit: props.onEdit,
|
|
59
|
+
onRemove: props.onRemove,
|
|
60
|
+
loadEntityScheduledActions: loadEntityScheduledActions
|
|
61
|
+
});
|
|
62
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { EntryCard } from '@contentful/f36-components';
|
|
3
|
+
import { MissingEntityCard, WrappedEntryCard, useResource } from '@contentful/field-editor-reference';
|
|
4
|
+
import areEqual from 'fast-deep-equal';
|
|
5
|
+
const InternalEntryCard = React.memo((props)=>{
|
|
6
|
+
if (props.status === 'loading') {
|
|
7
|
+
return React.createElement(EntryCard, {
|
|
8
|
+
isLoading: true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
if (!props.data || props.status === 'error') {
|
|
12
|
+
return React.createElement(MissingEntityCard, {
|
|
13
|
+
entityType: "Entry",
|
|
14
|
+
isDisabled: props.isDisabled,
|
|
15
|
+
onRemove: props.onRemove
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const { contentType , resource: entry , space } = props.data;
|
|
19
|
+
return React.createElement(WrappedEntryCard, {
|
|
20
|
+
size: "default",
|
|
21
|
+
getAsset: ()=>Promise.resolve(),
|
|
22
|
+
isSelected: props.isSelected,
|
|
23
|
+
isDisabled: props.isDisabled,
|
|
24
|
+
localeCode: props.data.defaultLocaleCode,
|
|
25
|
+
defaultLocaleCode: props.data.defaultLocaleCode,
|
|
26
|
+
contentType: contentType,
|
|
27
|
+
spaceName: space?.name,
|
|
28
|
+
entry: entry,
|
|
29
|
+
onEdit: props.onEdit,
|
|
30
|
+
onRemove: props.isDisabled ? undefined : props.onRemove,
|
|
31
|
+
isClickable: false,
|
|
32
|
+
getEntityScheduledActions: ()=>Promise.resolve([])
|
|
33
|
+
});
|
|
34
|
+
}, areEqual);
|
|
35
|
+
InternalEntryCard.displayName = 'ReferenceCard';
|
|
36
|
+
export const FetchingWrappedResourceCard = (props)=>{
|
|
37
|
+
const { link , onEntityFetchComplete } = props;
|
|
38
|
+
const { data , status } = useResource(link.linkType, link.urn);
|
|
39
|
+
React.useEffect(()=>{
|
|
40
|
+
if (status === 'success') {
|
|
41
|
+
onEntityFetchComplete?.();
|
|
42
|
+
}
|
|
43
|
+
}, [
|
|
44
|
+
onEntityFetchComplete,
|
|
45
|
+
status
|
|
46
|
+
]);
|
|
47
|
+
return React.createElement(InternalEntryCard, {
|
|
48
|
+
data: data,
|
|
49
|
+
status: status,
|
|
50
|
+
sdk: props.sdk,
|
|
51
|
+
isDisabled: props.isDisabled,
|
|
52
|
+
isSelected: props.isSelected,
|
|
53
|
+
onEdit: props.onEdit,
|
|
54
|
+
onRemove: props.onRemove
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { css } from 'emotion';
|
|
3
|
+
import { IS_CHROME } from '../../helpers/environment';
|
|
4
|
+
const styles = {
|
|
5
|
+
root: css({
|
|
6
|
+
marginBottom: '1.25rem !important',
|
|
7
|
+
display: 'block'
|
|
8
|
+
}),
|
|
9
|
+
container: css({
|
|
10
|
+
display: 'inline-block',
|
|
11
|
+
verticalAlign: 'text-top',
|
|
12
|
+
width: '100%'
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
const isResourceLink = (link)=>!!link.urn;
|
|
16
|
+
export function LinkedBlockWrapper({ attributes , card , children , element }) {
|
|
17
|
+
const link = element.data.target.sys;
|
|
18
|
+
return React.createElement("div", {
|
|
19
|
+
...attributes,
|
|
20
|
+
className: styles.root,
|
|
21
|
+
"data-entity-type": link.linkType,
|
|
22
|
+
"data-entity-id": isResourceLink(link) ? link.urn : link.id,
|
|
23
|
+
contentEditable: IS_CHROME ? undefined : false,
|
|
24
|
+
draggable: IS_CHROME ? true : undefined
|
|
25
|
+
}, React.createElement("div", {
|
|
26
|
+
contentEditable: IS_CHROME ? false : undefined,
|
|
27
|
+
draggable: IS_CHROME ? true : undefined,
|
|
28
|
+
className: styles.container
|
|
29
|
+
}, card), children);
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Button, Tooltip } from '@contentful/f36-components';
|
|
3
|
+
import tokens from '@contentful/f36-tokens';
|
|
4
|
+
import { css, cx } from 'emotion';
|
|
5
|
+
const styles = {
|
|
6
|
+
button: css({
|
|
7
|
+
height: '30px',
|
|
8
|
+
width: '30px',
|
|
9
|
+
marginLeft: tokens.spacing2Xs,
|
|
10
|
+
marginRight: tokens.spacing2Xs
|
|
11
|
+
}),
|
|
12
|
+
tooltip: css({
|
|
13
|
+
zIndex: Number(tokens.zIndexTooltip)
|
|
14
|
+
})
|
|
15
|
+
};
|
|
16
|
+
export function ToolbarButton(props) {
|
|
17
|
+
const { title , testId , isActive , children , className , isDisabled =false } = props;
|
|
18
|
+
const handleClick = (event)=>{
|
|
19
|
+
event.preventDefault();
|
|
20
|
+
props.onClick();
|
|
21
|
+
};
|
|
22
|
+
const button = React.createElement(Button, {
|
|
23
|
+
className: cx(styles.button, className),
|
|
24
|
+
isDisabled: isDisabled,
|
|
25
|
+
startIcon: children,
|
|
26
|
+
onClick: handleClick,
|
|
27
|
+
testId: testId,
|
|
28
|
+
variant: isActive ? 'secondary' : 'transparent',
|
|
29
|
+
size: "small"
|
|
30
|
+
});
|
|
31
|
+
if (title) {
|
|
32
|
+
return React.createElement(Tooltip, {
|
|
33
|
+
className: styles.tooltip,
|
|
34
|
+
placement: "bottom",
|
|
35
|
+
content: title
|
|
36
|
+
}, button);
|
|
37
|
+
}
|
|
38
|
+
return button;
|
|
39
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
3
|
+
import { createFakeCMAAdapter } from '@contentful/field-editor-test-utils';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
import { configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
6
|
+
import publishedAsset from '../__fixtures__/published_asset.json';
|
|
7
|
+
import { FetchingWrappedAssetCard } from '../FetchingWrappedAssetCard';
|
|
8
|
+
configure({
|
|
9
|
+
testIdAttribute: 'data-test-id'
|
|
10
|
+
});
|
|
11
|
+
let sdk;
|
|
12
|
+
beforeEach(()=>{
|
|
13
|
+
sdk = {
|
|
14
|
+
locales: {
|
|
15
|
+
default: 'en-US'
|
|
16
|
+
},
|
|
17
|
+
cmaAdapter: createFakeCMAAdapter({
|
|
18
|
+
Asset: {
|
|
19
|
+
get: jest.fn().mockResolvedValue(publishedAsset)
|
|
20
|
+
},
|
|
21
|
+
ScheduledAction: {
|
|
22
|
+
getMany: jest.fn().mockResolvedValue({
|
|
23
|
+
items: [],
|
|
24
|
+
total: 0
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
space: {
|
|
29
|
+
getEntityScheduledActions: jest.fn().mockResolvedValue([])
|
|
30
|
+
},
|
|
31
|
+
navigator: {
|
|
32
|
+
onSlideInNavigation: jest.fn()
|
|
33
|
+
},
|
|
34
|
+
ids: {
|
|
35
|
+
space: 'space-id',
|
|
36
|
+
environment: 'environment-id'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
test('some dropdown actions should be disabled', async ()=>{
|
|
41
|
+
const { getByTestId , queryByTestId } = render(React.createElement(EntityProvider, {
|
|
42
|
+
sdk: sdk
|
|
43
|
+
}, React.createElement(FetchingWrappedAssetCard, {
|
|
44
|
+
sdk: sdk,
|
|
45
|
+
assetId: "asset-id",
|
|
46
|
+
locale: "en-US",
|
|
47
|
+
onEdit: ()=>{},
|
|
48
|
+
onRemove: ()=>{},
|
|
49
|
+
isDisabled: true,
|
|
50
|
+
isSelected: true
|
|
51
|
+
})));
|
|
52
|
+
await waitFor(()=>expect(getByTestId('cf-ui-asset').textContent).toBe('asset title'));
|
|
53
|
+
fireEvent.click(getByTestId('cf-ui-card-actions'));
|
|
54
|
+
await waitFor(()=>{
|
|
55
|
+
expect(getByTestId('card-action-edit')).not.toBeDisabled();
|
|
56
|
+
expect(queryByTestId('card-action-remove')).toBeNull();
|
|
57
|
+
expect(getByTestId('card-action-download')).not.toBeDisabled();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
3
|
+
import { createFakeCMAAdapter } from '@contentful/field-editor-test-utils';
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
import { configure, fireEvent, render, waitFor } from '@testing-library/react';
|
|
6
|
+
import publishedCT from '../__fixtures__/published_content_type.json';
|
|
7
|
+
import publishedEntry from '../__fixtures__/published_entry.json';
|
|
8
|
+
import { FetchingWrappedEntryCard } from '../FetchingWrappedEntryCard';
|
|
9
|
+
configure({
|
|
10
|
+
testIdAttribute: 'data-test-id'
|
|
11
|
+
});
|
|
12
|
+
let sdk;
|
|
13
|
+
beforeEach(()=>{
|
|
14
|
+
sdk = {
|
|
15
|
+
locales: {
|
|
16
|
+
default: 'en-US'
|
|
17
|
+
},
|
|
18
|
+
cmaAdapter: createFakeCMAAdapter({
|
|
19
|
+
Entry: {
|
|
20
|
+
get: jest.fn().mockResolvedValue(publishedEntry)
|
|
21
|
+
},
|
|
22
|
+
ScheduledAction: {
|
|
23
|
+
getMany: jest.fn().mockResolvedValue({
|
|
24
|
+
items: [],
|
|
25
|
+
total: 0
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
space: {
|
|
30
|
+
getEntityScheduledActions: jest.fn().mockResolvedValue([]),
|
|
31
|
+
getCachedContentTypes: jest.fn().mockReturnValue([
|
|
32
|
+
publishedCT
|
|
33
|
+
])
|
|
34
|
+
},
|
|
35
|
+
navigator: {
|
|
36
|
+
onSlideInNavigation: jest.fn()
|
|
37
|
+
},
|
|
38
|
+
ids: {
|
|
39
|
+
space: 'space-id',
|
|
40
|
+
environment: 'environment-id'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
test('some dropdown actions should be disabled/removed', async ()=>{
|
|
45
|
+
const { getByTestId , queryByTestId } = render(React.createElement(EntityProvider, {
|
|
46
|
+
sdk: sdk
|
|
47
|
+
}, React.createElement(FetchingWrappedEntryCard, {
|
|
48
|
+
sdk: sdk,
|
|
49
|
+
entryId: "entry-id",
|
|
50
|
+
locale: "en-US",
|
|
51
|
+
onEdit: ()=>{},
|
|
52
|
+
onRemove: ()=>{},
|
|
53
|
+
isDisabled: true,
|
|
54
|
+
isSelected: true
|
|
55
|
+
})));
|
|
56
|
+
await waitFor(()=>expect(getByTestId('title').textContent).toBe('The best article ever'));
|
|
57
|
+
fireEvent.click(getByTestId('cf-ui-card-actions'));
|
|
58
|
+
await waitFor(()=>{
|
|
59
|
+
expect(getByTestId('edit')).not.toBeDisabled();
|
|
60
|
+
expect(queryByTestId('delete')).toBeNull();
|
|
61
|
+
});
|
|
62
|
+
});
|