@contentful/field-editor-rich-text 3.4.22 → 3.5.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 +87 -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 +52 -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/getLinkedContentTypeIdsForNodeType.js +24 -0
- package/dist/cjs/helpers/newEntitySelectorConfigFromRichTextField.js +33 -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 +54 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +128 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/ToolbarIcon.js +106 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/Util.js +108 -0
- package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +100 -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 +221 -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 +93 -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 +179 -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 +136 -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 +76 -0
- package/dist/cjs/plugins/links-tracking.js +29 -0
- package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +113 -0
- package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +116 -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 +38 -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 +48 -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/getLinkedContentTypeIdsForNodeType.js +9 -0
- package/dist/esm/helpers/newEntitySelectorConfigFromRichTextField.js +18 -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 +44 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +79 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/ToolbarIcon.js +49 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/Util.js +85 -0
- package/dist/esm/plugins/EmbeddedEntityBlock/index.js +74 -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 +159 -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 +44 -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 +125 -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 +126 -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 +58 -0
- package/dist/esm/plugins/links-tracking.js +14 -0
- package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +59 -0
- package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +62 -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/{helpers → types/helpers}/getLinkedContentTypeIdsForNodeType.d.ts +26 -26
- package/dist/{helpers → types/helpers}/newEntitySelectorConfigFromRichTextField.d.ts +14 -14
- 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 +20 -19
- package/dist/{plugins → types/plugins}/EmbeddedEntityBlock/ToolbarIcon.d.ts +11 -10
- package/dist/{plugins → types/plugins}/EmbeddedEntityBlock/Util.d.ts +4 -4
- package/dist/{plugins → types/plugins}/EmbeddedEntityBlock/index.d.ts +5 -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/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/{plugins → types/plugins}/links-tracking.d.ts +3 -3
- package/dist/{plugins → types/plugins}/shared/FetchingWrappedAssetCard.d.ts +14 -13
- package/dist/{plugins → types/plugins}/shared/FetchingWrappedEntryCard.d.ts +14 -13
- 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 +27 -21
- 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/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
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { createFakeCMAAdapter, createFakeFieldAPI, createFakeLocalesAPI, createFakeSpaceAPI } from '@contentful/field-editor-test-utils';
|
|
2
|
+
import { assets, contentTypes, entries, locales as localesFixtures, spaces } from './fixtures';
|
|
3
|
+
const newLink = (linkType, id)=>({
|
|
4
|
+
sys: {
|
|
5
|
+
id,
|
|
6
|
+
linkType,
|
|
7
|
+
type: 'Link'
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
export function newReferenceEditorFakeSdk(props) {
|
|
11
|
+
const rawInitialValue = window.localStorage.getItem('initialValue');
|
|
12
|
+
const initialValue = rawInitialValue ? JSON.parse(rawInitialValue) : props?.initialValue;
|
|
13
|
+
const rawValidations = window.localStorage.getItem('fieldValidations');
|
|
14
|
+
const validations = rawValidations ? JSON.parse(rawValidations) : props?.validations;
|
|
15
|
+
const customizeMock = (field)=>{
|
|
16
|
+
return validations ? {
|
|
17
|
+
...field,
|
|
18
|
+
validations
|
|
19
|
+
} : field;
|
|
20
|
+
};
|
|
21
|
+
const [field, mitt] = createFakeFieldAPI(customizeMock, initialValue);
|
|
22
|
+
const space = createFakeSpaceAPI();
|
|
23
|
+
const locales = createFakeLocalesAPI();
|
|
24
|
+
const entryLinks = [
|
|
25
|
+
newLink('Entry', entries.published.sys.id),
|
|
26
|
+
newLink('Entry', entries.changed.sys.id),
|
|
27
|
+
newLink('Entry', entries.empty.sys.id)
|
|
28
|
+
];
|
|
29
|
+
const assetLinks = [
|
|
30
|
+
newLink('Asset', assets.published.sys.id),
|
|
31
|
+
newLink('Asset', assets.changed.sys.id),
|
|
32
|
+
newLink('Asset', assets.empty.sys.id)
|
|
33
|
+
];
|
|
34
|
+
let selectorCounter = 0;
|
|
35
|
+
const delay = (ms)=>{
|
|
36
|
+
return new Promise((resolve)=>setTimeout(resolve, ms));
|
|
37
|
+
};
|
|
38
|
+
const localizeContentTypes = (contentTypes)=>{
|
|
39
|
+
return contentTypes.map((contentType)=>({
|
|
40
|
+
...contentType,
|
|
41
|
+
fields: contentType.fields.map((field)=>({
|
|
42
|
+
...field,
|
|
43
|
+
localized: true
|
|
44
|
+
}))
|
|
45
|
+
}));
|
|
46
|
+
};
|
|
47
|
+
const sdk = {
|
|
48
|
+
field,
|
|
49
|
+
locales,
|
|
50
|
+
cmaAdapter: createFakeCMAAdapter({
|
|
51
|
+
Entry: {
|
|
52
|
+
get: async ({ entryId })=>{
|
|
53
|
+
if (props?.fetchDelay) {
|
|
54
|
+
await delay(props.fetchDelay);
|
|
55
|
+
}
|
|
56
|
+
if (entryId === entries.empty.sys.id) {
|
|
57
|
+
return entries.empty;
|
|
58
|
+
}
|
|
59
|
+
if (entryId === entries.published.sys.id) {
|
|
60
|
+
return entries.published;
|
|
61
|
+
}
|
|
62
|
+
if (entryId === entries.changed.sys.id) {
|
|
63
|
+
return entries.changed;
|
|
64
|
+
}
|
|
65
|
+
return Promise.reject({});
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
Asset: {
|
|
69
|
+
get: async ({ assetId })=>{
|
|
70
|
+
if (props?.fetchDelay) {
|
|
71
|
+
await delay(props.fetchDelay);
|
|
72
|
+
}
|
|
73
|
+
if (assetId === assets.empty.sys.id) {
|
|
74
|
+
return assets.empty;
|
|
75
|
+
}
|
|
76
|
+
if (assetId === assets.published.sys.id) {
|
|
77
|
+
return assets.published;
|
|
78
|
+
}
|
|
79
|
+
if (assetId === assets.changed.sys.id) {
|
|
80
|
+
return assets.changed;
|
|
81
|
+
}
|
|
82
|
+
return Promise.reject({});
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
Space: {
|
|
86
|
+
get: async (params)=>{
|
|
87
|
+
if (params.spaceId === spaces.indifferent.sys.id) {
|
|
88
|
+
return spaces.indifferent;
|
|
89
|
+
}
|
|
90
|
+
return Promise.reject({});
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
ContentType: {
|
|
94
|
+
get: async ({ contentTypeId })=>{
|
|
95
|
+
if (contentTypeId === contentTypes.published.sys.id) {
|
|
96
|
+
return contentTypes.published;
|
|
97
|
+
}
|
|
98
|
+
return Promise.reject({});
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
Locale: {
|
|
102
|
+
getMany: async ()=>localesFixtures.list
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
space: {
|
|
106
|
+
...space,
|
|
107
|
+
getCachedContentTypes () {
|
|
108
|
+
return localizeContentTypes(space.getCachedContentTypes());
|
|
109
|
+
},
|
|
110
|
+
getContentTypes () {
|
|
111
|
+
return Promise.resolve(space.getContentTypes().then((response)=>{
|
|
112
|
+
return {
|
|
113
|
+
...response,
|
|
114
|
+
items: localizeContentTypes(response.items)
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
},
|
|
118
|
+
async getEntityScheduledActions () {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
dialogs: {
|
|
123
|
+
selectSingleAsset: async ()=>{
|
|
124
|
+
selectorCounter++;
|
|
125
|
+
return assetLinks[selectorCounter % assetLinks.length];
|
|
126
|
+
},
|
|
127
|
+
selectMultipleAssets: async ()=>{
|
|
128
|
+
selectorCounter++;
|
|
129
|
+
return selectorCounter % 2 ? assetLinks.slice(0, 2) : [
|
|
130
|
+
assetLinks[2]
|
|
131
|
+
];
|
|
132
|
+
},
|
|
133
|
+
selectSingleEntry: async ()=>{
|
|
134
|
+
selectorCounter++;
|
|
135
|
+
return entryLinks[selectorCounter % entryLinks.length];
|
|
136
|
+
},
|
|
137
|
+
selectMultipleEntries: async ()=>{
|
|
138
|
+
selectorCounter++;
|
|
139
|
+
return selectorCounter % 2 ? entryLinks.slice(0, 2) : [
|
|
140
|
+
entryLinks[2]
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
navigator: {
|
|
145
|
+
openNewAsset: async ()=>({
|
|
146
|
+
entity: newLink('Asset', assets.empty.sys.id)
|
|
147
|
+
}),
|
|
148
|
+
openAsset: async ()=>{
|
|
149
|
+
alert('open Asset in slide in');
|
|
150
|
+
return {};
|
|
151
|
+
},
|
|
152
|
+
openNewEntry: async ()=>({
|
|
153
|
+
entity: newLink('Entry', entries.empty.sys.id)
|
|
154
|
+
}),
|
|
155
|
+
openEntry: async ()=>{
|
|
156
|
+
alert('open entry in slide in');
|
|
157
|
+
return {};
|
|
158
|
+
},
|
|
159
|
+
onSlideInNavigation: ()=>()=>({})
|
|
160
|
+
},
|
|
161
|
+
access: {
|
|
162
|
+
can: async ()=>true
|
|
163
|
+
},
|
|
164
|
+
ids: {
|
|
165
|
+
space: 'space-id',
|
|
166
|
+
environment: 'environment-id'
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return [
|
|
170
|
+
sdk,
|
|
171
|
+
mitt
|
|
172
|
+
];
|
|
173
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import changed from './changed_asset.json';
|
|
2
|
+
import created from './created_asset.json';
|
|
3
|
+
import empty from './empty_asset.json';
|
|
4
|
+
import invalid from './invalid_asset.json';
|
|
5
|
+
import published from './published_asset.json';
|
|
6
|
+
export { changed, empty, published, invalid, created };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import englishDefault from './english_default_locale.json';
|
|
2
|
+
import german from './german_locale.json';
|
|
3
|
+
const list = {
|
|
4
|
+
sys: {
|
|
5
|
+
type: 'Array'
|
|
6
|
+
},
|
|
7
|
+
total: 2,
|
|
8
|
+
skip: 0,
|
|
9
|
+
limit: 100,
|
|
10
|
+
items: [
|
|
11
|
+
englishDefault,
|
|
12
|
+
german
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
export { englishDefault, german, list };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { BLOCKS, INLINES, TOP_LEVEL_BLOCKS, VOID_BLOCKS, CONTAINERS } from '@contentful/rich-text-types';
|
|
2
|
+
const inlines = Object.values(INLINES).map((type)=>({
|
|
3
|
+
type
|
|
4
|
+
}));
|
|
5
|
+
export default {
|
|
6
|
+
document: {
|
|
7
|
+
nodes: [
|
|
8
|
+
{
|
|
9
|
+
types: TOP_LEVEL_BLOCKS.map((type)=>({
|
|
10
|
+
type
|
|
11
|
+
}))
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
blocks: {
|
|
16
|
+
[BLOCKS.PARAGRAPH]: {
|
|
17
|
+
nodes: [
|
|
18
|
+
{
|
|
19
|
+
match: [
|
|
20
|
+
...inlines,
|
|
21
|
+
{
|
|
22
|
+
object: 'text'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
[BLOCKS.HEADING_1]: {
|
|
29
|
+
nodes: [
|
|
30
|
+
{
|
|
31
|
+
match: [
|
|
32
|
+
...inlines,
|
|
33
|
+
{
|
|
34
|
+
object: 'text'
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
[BLOCKS.HEADING_2]: {
|
|
41
|
+
nodes: [
|
|
42
|
+
{
|
|
43
|
+
match: [
|
|
44
|
+
...inlines,
|
|
45
|
+
{
|
|
46
|
+
object: 'text'
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
[BLOCKS.HEADING_3]: {
|
|
53
|
+
nodes: [
|
|
54
|
+
{
|
|
55
|
+
match: [
|
|
56
|
+
...inlines,
|
|
57
|
+
{
|
|
58
|
+
object: 'text'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
[BLOCKS.HEADING_4]: {
|
|
65
|
+
nodes: [
|
|
66
|
+
{
|
|
67
|
+
match: [
|
|
68
|
+
...inlines,
|
|
69
|
+
{
|
|
70
|
+
object: 'text'
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
[BLOCKS.HEADING_5]: {
|
|
77
|
+
nodes: [
|
|
78
|
+
{
|
|
79
|
+
match: [
|
|
80
|
+
...inlines,
|
|
81
|
+
{
|
|
82
|
+
object: 'text'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
[BLOCKS.HEADING_6]: {
|
|
89
|
+
nodes: [
|
|
90
|
+
{
|
|
91
|
+
match: [
|
|
92
|
+
...inlines,
|
|
93
|
+
{
|
|
94
|
+
object: 'text'
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
...VOID_BLOCKS.reduce((blocks, nodeType)=>({
|
|
101
|
+
...blocks,
|
|
102
|
+
[nodeType]: {
|
|
103
|
+
isVoid: true
|
|
104
|
+
}
|
|
105
|
+
}), {}),
|
|
106
|
+
[BLOCKS.QUOTE]: {
|
|
107
|
+
nodes: [
|
|
108
|
+
{
|
|
109
|
+
match: [
|
|
110
|
+
CONTAINERS[BLOCKS.QUOTE].map((type)=>({
|
|
111
|
+
type
|
|
112
|
+
}))
|
|
113
|
+
],
|
|
114
|
+
min: 1
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
normalize: (editor, error)=>{
|
|
118
|
+
if (error.code === 'child_type_invalid') {
|
|
119
|
+
return editor.unwrapBlockByKey(error.node.key, BLOCKS.QUOTE);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
inlines: {
|
|
125
|
+
[INLINES.HYPERLINK]: {
|
|
126
|
+
nodes: [
|
|
127
|
+
{
|
|
128
|
+
match: [
|
|
129
|
+
{
|
|
130
|
+
object: 'text'
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
[INLINES.ENTRY_HYPERLINK]: {
|
|
137
|
+
nodes: [
|
|
138
|
+
{
|
|
139
|
+
match: [
|
|
140
|
+
{
|
|
141
|
+
object: 'text'
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
[INLINES.ASSET_HYPERLINK]: {
|
|
148
|
+
nodes: [
|
|
149
|
+
{
|
|
150
|
+
match: [
|
|
151
|
+
{
|
|
152
|
+
object: 'text'
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
[INLINES.EMBEDDED_ENTRY]: {
|
|
159
|
+
isVoid: true
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
import * as React from 'react';
|
|
15
|
+
import { Button, Form, FormControl, FormLabel, ModalContent, ModalControls, Select, TextInput, TextLink } from '@contentful/f36-components';
|
|
16
|
+
import tokens from '@contentful/f36-tokens';
|
|
17
|
+
import { EntityProvider } from '@contentful/field-editor-reference';
|
|
18
|
+
import { css } from 'emotion';
|
|
19
|
+
import PropTypes from 'prop-types';
|
|
20
|
+
import { FetchingWrappedAssetCard } from '../../plugins/shared/FetchingWrappedAssetCard';
|
|
21
|
+
import { FetchingWrappedEntryCard } from '../../plugins/shared/FetchingWrappedEntryCard';
|
|
22
|
+
export const LINK_TYPES = {
|
|
23
|
+
URI: 'uri',
|
|
24
|
+
ENTRY: 'Entry',
|
|
25
|
+
ASSET: 'Asset'
|
|
26
|
+
};
|
|
27
|
+
function isFeaturingEntitySelector(entitySelectorConfigs = {}) {
|
|
28
|
+
return !!entitySelectorConfigs.Entry || !!entitySelectorConfigs.Asset;
|
|
29
|
+
}
|
|
30
|
+
function entityToLink(entity) {
|
|
31
|
+
const { id , type } = entity.sys;
|
|
32
|
+
return {
|
|
33
|
+
sys: {
|
|
34
|
+
id,
|
|
35
|
+
type: 'Link',
|
|
36
|
+
linkType: type
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var _React_Component;
|
|
41
|
+
export class HyperlinkDialog extends (_React_Component = React.Component) {
|
|
42
|
+
setTargetEntity(type, entity) {
|
|
43
|
+
this.setState((state)=>({
|
|
44
|
+
entityLinks: {
|
|
45
|
+
...state.entityLinks,
|
|
46
|
+
[type]: entity ? entityToLink(entity) : undefined
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
getValue() {
|
|
51
|
+
const { text , type , uri } = this.state;
|
|
52
|
+
const value = {
|
|
53
|
+
type
|
|
54
|
+
};
|
|
55
|
+
if (text) {
|
|
56
|
+
value.text = text;
|
|
57
|
+
}
|
|
58
|
+
if (type === LINK_TYPES.URI) {
|
|
59
|
+
value.uri = uri;
|
|
60
|
+
} else {
|
|
61
|
+
value.target = this.state.entityLinks[type];
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
isLinkComplete() {
|
|
66
|
+
const { text , type , uri , target } = this.getValue();
|
|
67
|
+
const requiresText = !this.props.hideText;
|
|
68
|
+
if (requiresText && !text) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return type === LINK_TYPES.URI && uri || target;
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
const { labels } = this.props;
|
|
75
|
+
return React.createElement(EntityProvider, {
|
|
76
|
+
sdk: this.props.sdk
|
|
77
|
+
}, React.createElement(React.Fragment, null, React.createElement(ModalContent, null, this.renderFields()), React.createElement(ModalControls, null, React.createElement(Button, {
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: ()=>this.props.onClose(null),
|
|
80
|
+
variant: "secondary",
|
|
81
|
+
testId: "cancel-cta",
|
|
82
|
+
size: "small"
|
|
83
|
+
}, "Cancel"), React.createElement(Button, {
|
|
84
|
+
type: "submit",
|
|
85
|
+
variant: "positive",
|
|
86
|
+
onClick: this.handleSubmit,
|
|
87
|
+
isDisabled: !this.isLinkComplete(),
|
|
88
|
+
testId: "confirm-cta",
|
|
89
|
+
size: "small"
|
|
90
|
+
}, labels.confirm))));
|
|
91
|
+
}
|
|
92
|
+
renderFields() {
|
|
93
|
+
const { hideText , allowedHyperlinkTypes , entitySelectorConfigs } = this.props;
|
|
94
|
+
const { uri , text , type } = this.state;
|
|
95
|
+
const isUriInputAutoFocused = type === LINK_TYPES.URI && (hideText || !!text);
|
|
96
|
+
return React.createElement(Form, null, hideText ? null : React.createElement(FormControl, {
|
|
97
|
+
id: "link-text",
|
|
98
|
+
isRequired: true
|
|
99
|
+
}, React.createElement(FormControl.Label, null, "Link text"), React.createElement(TextInput, {
|
|
100
|
+
testId: "link-text-input",
|
|
101
|
+
name: "link-text",
|
|
102
|
+
value: text || '',
|
|
103
|
+
onChange: (e)=>this.setState({
|
|
104
|
+
text: e.target.value
|
|
105
|
+
}),
|
|
106
|
+
autoFocus: !isUriInputAutoFocused
|
|
107
|
+
})), isFeaturingEntitySelector(entitySelectorConfigs) && React.createElement(FormControl, {
|
|
108
|
+
id: "link-type",
|
|
109
|
+
name: "link-type"
|
|
110
|
+
}, React.createElement(FormControl.Label, null, "Link type"), React.createElement(Select, {
|
|
111
|
+
value: type,
|
|
112
|
+
onChange: (e)=>this.setState({
|
|
113
|
+
type: e.target.value
|
|
114
|
+
}),
|
|
115
|
+
testId: "link-type-select"
|
|
116
|
+
}, allowedHyperlinkTypes.includes(LINK_TYPES.URI) || type === LINK_TYPES.URI ? React.createElement(Select.Option, {
|
|
117
|
+
value: LINK_TYPES.URI
|
|
118
|
+
}, "URL") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ENTRY) || type === LINK_TYPES.ENTRY ? React.createElement(Select.Option, {
|
|
119
|
+
value: LINK_TYPES.ENTRY
|
|
120
|
+
}, "Entry") : null, allowedHyperlinkTypes.includes(LINK_TYPES.ASSET) || type === LINK_TYPES.ASSET ? React.createElement(Select.Option, {
|
|
121
|
+
value: LINK_TYPES.ASSET
|
|
122
|
+
}, "Asset") : null)), type === LINK_TYPES.URI ? React.createElement(FormControl, {
|
|
123
|
+
id: "link-uri",
|
|
124
|
+
isRequired: true
|
|
125
|
+
}, React.createElement(FormControl.Label, null, "Link target"), React.createElement(TextInput, {
|
|
126
|
+
testId: "link-target-input",
|
|
127
|
+
name: "link-uri",
|
|
128
|
+
value: uri || '',
|
|
129
|
+
placeholder: "https://",
|
|
130
|
+
onChange: (e)=>this.setState({
|
|
131
|
+
uri: e.target.value
|
|
132
|
+
}),
|
|
133
|
+
autoFocus: isUriInputAutoFocused
|
|
134
|
+
}), React.createElement(FormControl.HelpText, null, "A protocol may be required, e.g. https://")) : this.renderEntityField());
|
|
135
|
+
}
|
|
136
|
+
renderEntityField() {
|
|
137
|
+
const { type , entityLinks } = this.state;
|
|
138
|
+
const resetEntity = ()=>this.setTargetEntity(type, null);
|
|
139
|
+
const entityLink = entityLinks[type];
|
|
140
|
+
const isEntitySelectorVisible = !entityLink;
|
|
141
|
+
return React.createElement("div", null, React.createElement(FormLabel, {
|
|
142
|
+
required: true,
|
|
143
|
+
htmlFor: ""
|
|
144
|
+
}, "Link target"), !isEntitySelectorVisible && React.createElement(TextLink, {
|
|
145
|
+
as: "button",
|
|
146
|
+
className: css({
|
|
147
|
+
marginLeft: tokens.spacingS
|
|
148
|
+
}),
|
|
149
|
+
onClick: resetEntity
|
|
150
|
+
}, "Remove selection"), entityLink && React.createElement("div", null, type === LINK_TYPES.ENTRY && React.createElement(FetchingWrappedEntryCard, {
|
|
151
|
+
sdk: this.props.sdk,
|
|
152
|
+
locale: this.props.entitySelectorConfigs.Entry.locale,
|
|
153
|
+
entryId: entityLink.sys.id,
|
|
154
|
+
isDisabled: true,
|
|
155
|
+
isSelected: false
|
|
156
|
+
}), type == LINK_TYPES.ASSET && React.createElement(FetchingWrappedAssetCard, {
|
|
157
|
+
sdk: this.props.sdk,
|
|
158
|
+
locale: this.props.entitySelectorConfigs.Asset.locale,
|
|
159
|
+
assetId: entityLink.sys.id,
|
|
160
|
+
isDisabled: true,
|
|
161
|
+
isSelected: false
|
|
162
|
+
})), isEntitySelectorVisible && this.renderEntitySelector(type, isEntitySelectorVisible));
|
|
163
|
+
}
|
|
164
|
+
renderEntitySelector(type) {
|
|
165
|
+
return React.createElement("div", {
|
|
166
|
+
className: css({
|
|
167
|
+
marginTop: tokens.spacingS
|
|
168
|
+
})
|
|
169
|
+
}, type === LINK_TYPES.ENTRY && React.createElement(TextLink, {
|
|
170
|
+
as: "button",
|
|
171
|
+
onClick: this.selectEntry
|
|
172
|
+
}, "Select entry"), type === LINK_TYPES.ASSET && React.createElement(TextLink, {
|
|
173
|
+
as: "button",
|
|
174
|
+
onClick: this.selectAsset
|
|
175
|
+
}, "Select asset"));
|
|
176
|
+
}
|
|
177
|
+
constructor(props){
|
|
178
|
+
super(props);
|
|
179
|
+
_define_property(this, "handleSubmit", (event)=>{
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
this.props.onClose(this.getValue());
|
|
182
|
+
});
|
|
183
|
+
_define_property(this, "selectEntry", async ()=>{
|
|
184
|
+
const { locale , contentTypes } = this.props.entitySelectorConfigs.Entry;
|
|
185
|
+
const entry = await this.props.sdk.dialogs.selectSingleEntry({
|
|
186
|
+
locale,
|
|
187
|
+
contentTypes
|
|
188
|
+
});
|
|
189
|
+
this.setTargetEntity(LINK_TYPES.ENTRY, entry);
|
|
190
|
+
});
|
|
191
|
+
_define_property(this, "selectAsset", async ()=>{
|
|
192
|
+
const { locale } = this.props.entitySelectorConfigs.Asset;
|
|
193
|
+
const asset = await this.props.sdk.dialogs.selectSingleAsset({
|
|
194
|
+
locale
|
|
195
|
+
});
|
|
196
|
+
this.setTargetEntity(LINK_TYPES.ASSET, asset);
|
|
197
|
+
});
|
|
198
|
+
const { text , type , uri , target } = props.value;
|
|
199
|
+
const isEntityLink = Boolean(target);
|
|
200
|
+
const entityLinks = {
|
|
201
|
+
[LINK_TYPES.ENTRY]: null,
|
|
202
|
+
[LINK_TYPES.ASSET]: null
|
|
203
|
+
};
|
|
204
|
+
let linkType = type;
|
|
205
|
+
if (isEntityLink) {
|
|
206
|
+
linkType = target.sys.linkType;
|
|
207
|
+
entityLinks[linkType] = target;
|
|
208
|
+
} else if (props.allowedHyperlinkTypes.includes(LINK_TYPES.URI)) {
|
|
209
|
+
linkType = LINK_TYPES.URI;
|
|
210
|
+
} else {
|
|
211
|
+
linkType = props.allowedHyperlinkTypes[0];
|
|
212
|
+
}
|
|
213
|
+
this.state = {
|
|
214
|
+
text,
|
|
215
|
+
uri,
|
|
216
|
+
entityLinks,
|
|
217
|
+
type: linkType
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
_define_property(HyperlinkDialog, "propTypes", {
|
|
222
|
+
sdk: PropTypes.object.isRequired,
|
|
223
|
+
labels: PropTypes.shape({
|
|
224
|
+
title: PropTypes.string,
|
|
225
|
+
confirm: PropTypes.string
|
|
226
|
+
}),
|
|
227
|
+
value: PropTypes.shape({
|
|
228
|
+
text: PropTypes.string,
|
|
229
|
+
uri: PropTypes.string,
|
|
230
|
+
target: PropTypes.object,
|
|
231
|
+
type: PropTypes.oneOf([
|
|
232
|
+
'uri',
|
|
233
|
+
'Entry',
|
|
234
|
+
'Asset'
|
|
235
|
+
])
|
|
236
|
+
}),
|
|
237
|
+
entitySelectorConfigs: PropTypes.object,
|
|
238
|
+
allowedHyperlinkTypes: PropTypes.arrayOf(PropTypes.oneOf([
|
|
239
|
+
LINK_TYPES.ENTRY,
|
|
240
|
+
LINK_TYPES.ASSET,
|
|
241
|
+
LINK_TYPES.URI
|
|
242
|
+
])),
|
|
243
|
+
hideText: PropTypes.bool,
|
|
244
|
+
onClose: PropTypes.func.isRequired
|
|
245
|
+
});
|
|
246
|
+
_define_property(HyperlinkDialog, "defaultProps", {
|
|
247
|
+
labels: {
|
|
248
|
+
title: 'Insert link',
|
|
249
|
+
confirm: 'Insert link'
|
|
250
|
+
},
|
|
251
|
+
value: {},
|
|
252
|
+
hideText: false,
|
|
253
|
+
entitySelectorConfigs: {},
|
|
254
|
+
allowedHyperlinkTypes: [
|
|
255
|
+
LINK_TYPES.ENTRY,
|
|
256
|
+
LINK_TYPES.ASSET,
|
|
257
|
+
LINK_TYPES.URI
|
|
258
|
+
]
|
|
259
|
+
});
|
|
260
|
+
export const openHyperlinkDialog = (dialogs, { value , showTextInput , allowedHyperlinkTypes , entitySelectorConfigs })=>{
|
|
261
|
+
const isNew = !(value.uri || value.target);
|
|
262
|
+
const props = {
|
|
263
|
+
labels: {
|
|
264
|
+
title: isNew ? 'Insert hyperlink' : 'Edit hyperlink',
|
|
265
|
+
confirm: isNew ? 'Insert' : 'Update'
|
|
266
|
+
},
|
|
267
|
+
value,
|
|
268
|
+
hideText: !showTextInput,
|
|
269
|
+
allowedHyperlinkTypes,
|
|
270
|
+
entitySelectorConfigs
|
|
271
|
+
};
|
|
272
|
+
return dialogs.openCurrent({
|
|
273
|
+
title: props.labels.title,
|
|
274
|
+
width: 'large',
|
|
275
|
+
shouldCloseOnEscapePress: true,
|
|
276
|
+
shouldCloseOnOverlayClick: true,
|
|
277
|
+
allowHeightOverflow: true,
|
|
278
|
+
parameters: {
|
|
279
|
+
type: 'rich-text-hyperlink-dialog',
|
|
280
|
+
...props
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ModalDialogLauncher } from '@contentful/field-editor-shared';
|
|
3
|
+
import { HyperlinkDialog } from './HypelinkDialog/HyperlinkDialog';
|
|
4
|
+
export const openRichTextDialog = (sdk)=>(options)=>{
|
|
5
|
+
if (options.parameters?.type === 'rich-text-hyperlink-dialog') {
|
|
6
|
+
return ModalDialogLauncher.openDialog(options, ({ onClose })=>{
|
|
7
|
+
return React.createElement(HyperlinkDialog, {
|
|
8
|
+
...options.parameters,
|
|
9
|
+
onClose: onClose,
|
|
10
|
+
sdk: sdk
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return Promise.reject();
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HyperlinkDialog } from './HypelinkDialog/HyperlinkDialog';
|
|
3
|
+
export const renderRichTextDialog = (sdk)=>{
|
|
4
|
+
const parameters = sdk.parameters.invocation;
|
|
5
|
+
if (parameters?.type === 'rich-text-hyperlink-dialog') {
|
|
6
|
+
sdk.window.startAutoResizer();
|
|
7
|
+
return React.createElement(HyperlinkDialog, {
|
|
8
|
+
...parameters,
|
|
9
|
+
onClose: sdk.close,
|
|
10
|
+
sdk: sdk
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return React.createElement("div", null);
|
|
14
|
+
};
|