@contentful/field-editor-rich-text 3.4.21 → 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/CHANGELOG.md +0 -946
- package/dist/Toolbar/index.d.ts +0 -5
- package/dist/field-editor-rich-text.cjs.development.js +0 -7210
- 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 -7200
- 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/List/transforms/deleteBackwardList.d.ts +0 -2
- 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,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "Table", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return Table;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
+
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
13
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
14
|
+
const _emotion = require("emotion");
|
|
15
|
+
function _interop_require_default(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
}
|
|
59
|
+
const style = (0, _emotion.css)`
|
|
60
|
+
margin-bottom: 1.5em;
|
|
61
|
+
border-collapse: collapse;
|
|
62
|
+
border-radius: 5px;
|
|
63
|
+
border-style: hidden;
|
|
64
|
+
box-shadow: 0 0 0 1px ${_f36tokens.default.gray400};
|
|
65
|
+
width: 100%;
|
|
66
|
+
table-layout: fixed;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
`;
|
|
69
|
+
const Table = (props)=>{
|
|
70
|
+
return _react.createElement("div", {
|
|
71
|
+
"data-block-type": _richtexttypes.BLOCKS.TABLE
|
|
72
|
+
}, _react.createElement("table", {
|
|
73
|
+
className: style,
|
|
74
|
+
...props.attributes
|
|
75
|
+
}, _react.createElement("tbody", null, props.children)));
|
|
76
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
styles: function() {
|
|
13
|
+
return styles;
|
|
14
|
+
},
|
|
15
|
+
TableActions: function() {
|
|
16
|
+
return TableActions;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
20
|
+
const _f36components = require("@contentful/f36-components");
|
|
21
|
+
const _f36icons = require("@contentful/f36-icons");
|
|
22
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
23
|
+
const _platetable = require("@udecode/plate-table");
|
|
24
|
+
const _emotion = require("emotion");
|
|
25
|
+
const _ContentfulEditorProvider = require("../../../ContentfulEditorProvider");
|
|
26
|
+
const _editor = require("../../../helpers/editor");
|
|
27
|
+
const _internal = require("../../../internal");
|
|
28
|
+
const _hooks = require("../../../internal/hooks");
|
|
29
|
+
const _queries = require("../../../internal/queries");
|
|
30
|
+
const _actions = require("../actions");
|
|
31
|
+
const _helpers = require("../helpers");
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
33
|
+
if (typeof WeakMap !== "function") return null;
|
|
34
|
+
var cacheBabelInterop = new WeakMap();
|
|
35
|
+
var cacheNodeInterop = new WeakMap();
|
|
36
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
37
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
38
|
+
})(nodeInterop);
|
|
39
|
+
}
|
|
40
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
41
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
45
|
+
return {
|
|
46
|
+
default: obj
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
50
|
+
if (cache && cache.has(obj)) {
|
|
51
|
+
return cache.get(obj);
|
|
52
|
+
}
|
|
53
|
+
var newObj = {};
|
|
54
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
|
+
for(var key in obj){
|
|
56
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
57
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
58
|
+
if (desc && (desc.get || desc.set)) {
|
|
59
|
+
Object.defineProperty(newObj, key, desc);
|
|
60
|
+
} else {
|
|
61
|
+
newObj[key] = obj[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
newObj.default = obj;
|
|
66
|
+
if (cache) {
|
|
67
|
+
cache.set(obj, newObj);
|
|
68
|
+
}
|
|
69
|
+
return newObj;
|
|
70
|
+
}
|
|
71
|
+
const styles = {
|
|
72
|
+
topRight: (0, _emotion.css)({
|
|
73
|
+
position: 'absolute',
|
|
74
|
+
top: '6px',
|
|
75
|
+
right: '5px'
|
|
76
|
+
})
|
|
77
|
+
};
|
|
78
|
+
const getCurrentTableSize = (editor)=>{
|
|
79
|
+
const [table] = (0, _editor.getNodeEntryFromSelection)(editor, _richtexttypes.BLOCKS.TABLE);
|
|
80
|
+
return table ? (0, _editor.getTableSize)(table) : null;
|
|
81
|
+
};
|
|
82
|
+
const TableActions = ()=>{
|
|
83
|
+
const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
|
|
84
|
+
const isDisabled = (0, _hooks.useReadOnly)();
|
|
85
|
+
const [isOpen, setOpen] = _react.useState(false);
|
|
86
|
+
const [isHeaderEnabled, setHeaderEnabled] = _react.useState(false);
|
|
87
|
+
const close = _react.useCallback(()=>{
|
|
88
|
+
setOpen(false);
|
|
89
|
+
}, []);
|
|
90
|
+
_react.useEffect(()=>{
|
|
91
|
+
setHeaderEnabled(Boolean(editor && (0, _helpers.isTableHeaderEnabled)(editor)));
|
|
92
|
+
}, [
|
|
93
|
+
editor
|
|
94
|
+
]);
|
|
95
|
+
const canInsertRowAbove = _react.useMemo(()=>{
|
|
96
|
+
if (!editor) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const headerCell = (0, _queries.getAboveNode)(editor, {
|
|
100
|
+
match: {
|
|
101
|
+
type: _richtexttypes.BLOCKS.TABLE_HEADER_CELL
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return !headerCell;
|
|
105
|
+
}, [
|
|
106
|
+
editor
|
|
107
|
+
]);
|
|
108
|
+
const toggleHeader = _react.useCallback(()=>{
|
|
109
|
+
close();
|
|
110
|
+
if (!editor) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const value = !isHeaderEnabled;
|
|
114
|
+
setHeaderEnabled(value);
|
|
115
|
+
(0, _actions.setHeader)(editor, value);
|
|
116
|
+
}, [
|
|
117
|
+
editor,
|
|
118
|
+
close,
|
|
119
|
+
isHeaderEnabled
|
|
120
|
+
]);
|
|
121
|
+
const action = _react.useCallback((cb, type, element)=>()=>{
|
|
122
|
+
if (!editor?.selection) return;
|
|
123
|
+
close();
|
|
124
|
+
const tableSize = getCurrentTableSize(editor);
|
|
125
|
+
(0, _internal.withoutNormalizing)(editor, ()=>{
|
|
126
|
+
cb(editor, {
|
|
127
|
+
header: isHeaderEnabled
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
const actionName = `${type}Table${element === 'Table' ? '' : element}`;
|
|
131
|
+
editor.tracking.onViewportAction(actionName, {
|
|
132
|
+
tableSize
|
|
133
|
+
});
|
|
134
|
+
}, [
|
|
135
|
+
editor,
|
|
136
|
+
isHeaderEnabled,
|
|
137
|
+
close
|
|
138
|
+
]);
|
|
139
|
+
if (isDisabled) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return _react.createElement(_f36components.Menu, {
|
|
143
|
+
placement: "left",
|
|
144
|
+
isOpen: isOpen,
|
|
145
|
+
onOpen: ()=>{
|
|
146
|
+
setOpen(true);
|
|
147
|
+
},
|
|
148
|
+
onClose: close
|
|
149
|
+
}, _react.createElement(_f36components.Menu.Trigger, null, _react.createElement(_f36components.IconButton, {
|
|
150
|
+
size: "small",
|
|
151
|
+
variant: "transparent",
|
|
152
|
+
tabIndex: -1,
|
|
153
|
+
className: styles.topRight,
|
|
154
|
+
icon: _react.createElement(_f36icons.ChevronDownIcon, null),
|
|
155
|
+
"aria-label": "Open table menu",
|
|
156
|
+
testId: "cf-table-actions-button"
|
|
157
|
+
})), _react.createElement(_f36components.Menu.List, null, _react.createElement(_f36components.Menu.Item, {
|
|
158
|
+
onClick: action(_actions.addRowAbove, 'insert', 'Row'),
|
|
159
|
+
disabled: !canInsertRowAbove
|
|
160
|
+
}, "Add row above"), _react.createElement(_f36components.Menu.Item, {
|
|
161
|
+
onClick: action(_actions.addRowBelow, 'insert', 'Row')
|
|
162
|
+
}, "Add row below"), _react.createElement(_f36components.Menu.Item, {
|
|
163
|
+
onClick: action(_actions.addColumnLeft, 'insert', 'Column')
|
|
164
|
+
}, "Add column left"), _react.createElement(_f36components.Menu.Item, {
|
|
165
|
+
onClick: action(_actions.addColumnRight, 'insert', 'Column')
|
|
166
|
+
}, "Add column right"), _react.createElement(_f36components.Menu.Divider, null), _react.createElement(_f36components.Menu.Item, {
|
|
167
|
+
onClick: toggleHeader
|
|
168
|
+
}, isHeaderEnabled ? 'Disable table header' : 'Enable table header'), _react.createElement(_f36components.Menu.Divider, null), _react.createElement(_f36components.Menu.Item, {
|
|
169
|
+
onClick: action(_platetable.deleteRow, 'remove', 'Row')
|
|
170
|
+
}, "Delete row"), _react.createElement(_f36components.Menu.Item, {
|
|
171
|
+
onClick: action(_platetable.deleteColumn, 'remove', 'Column')
|
|
172
|
+
}, "Delete column"), _react.createElement(_f36components.Menu.Item, {
|
|
173
|
+
onClick: action(_platetable.deleteTable, 'remove', 'Table')
|
|
174
|
+
}, "Delete table")));
|
|
175
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "ToolbarTableButton", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return ToolbarTableButton;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
12
|
+
const _f36icons = require("@contentful/f36-icons");
|
|
13
|
+
const _ContentfulEditorProvider = require("../../../ContentfulEditorProvider");
|
|
14
|
+
const _editor = require("../../../helpers/editor");
|
|
15
|
+
const _ToolbarButton = require("../../shared/ToolbarButton");
|
|
16
|
+
const _helpers = require("./../helpers");
|
|
17
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
18
|
+
if (typeof WeakMap !== "function") return null;
|
|
19
|
+
var cacheBabelInterop = new WeakMap();
|
|
20
|
+
var cacheNodeInterop = new WeakMap();
|
|
21
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
22
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
23
|
+
})(nodeInterop);
|
|
24
|
+
}
|
|
25
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
26
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
30
|
+
return {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
35
|
+
if (cache && cache.has(obj)) {
|
|
36
|
+
return cache.get(obj);
|
|
37
|
+
}
|
|
38
|
+
var newObj = {};
|
|
39
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
40
|
+
for(var key in obj){
|
|
41
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
42
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
43
|
+
if (desc && (desc.get || desc.set)) {
|
|
44
|
+
Object.defineProperty(newObj, key, desc);
|
|
45
|
+
} else {
|
|
46
|
+
newObj[key] = obj[key];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
newObj.default = obj;
|
|
51
|
+
if (cache) {
|
|
52
|
+
cache.set(obj, newObj);
|
|
53
|
+
}
|
|
54
|
+
return newObj;
|
|
55
|
+
}
|
|
56
|
+
function ToolbarTableButton(props) {
|
|
57
|
+
const editor = (0, _ContentfulEditorProvider.useContentfulEditor)();
|
|
58
|
+
const isActive = editor && (0, _helpers.isTableActive)(editor);
|
|
59
|
+
async function handleClick() {
|
|
60
|
+
if (!editor) return;
|
|
61
|
+
editor.tracking.onToolbarAction('insertTable');
|
|
62
|
+
(0, _helpers.insertTableAndFocusFirstCell)(editor);
|
|
63
|
+
(0, _editor.focus)(editor);
|
|
64
|
+
}
|
|
65
|
+
if (!editor) return null;
|
|
66
|
+
return _react.createElement(_ToolbarButton.ToolbarButton, {
|
|
67
|
+
title: "Table",
|
|
68
|
+
testId: "table-toolbar-button",
|
|
69
|
+
onClick: handleClick,
|
|
70
|
+
isActive: !!isActive,
|
|
71
|
+
isDisabled: props.isDisabled
|
|
72
|
+
}, _react.createElement(_f36icons.TableIcon, null));
|
|
73
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "createTablePlugin", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return createTablePlugin;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
12
|
+
const _platetable = require("@udecode/plate-table");
|
|
13
|
+
const _editor = require("../../helpers/editor");
|
|
14
|
+
const _transformers = require("../../helpers/transformers");
|
|
15
|
+
const _queries = require("../../internal/queries");
|
|
16
|
+
const _transforms = require("../../internal/transforms");
|
|
17
|
+
const _Cell = require("./components/Cell");
|
|
18
|
+
const _HeaderCell = require("./components/HeaderCell");
|
|
19
|
+
const _Row = require("./components/Row");
|
|
20
|
+
const _Table = require("./components/Table");
|
|
21
|
+
const _helpers = require("./helpers");
|
|
22
|
+
const _insertTableFragment = require("./insertTableFragment");
|
|
23
|
+
const _onKeyDownTable = require("./onKeyDownTable");
|
|
24
|
+
const _tableTracking = require("./tableTracking");
|
|
25
|
+
const createTablePlugin = ()=>(0, _platetable.createTablePlugin)({
|
|
26
|
+
type: _richtexttypes.BLOCKS.TABLE,
|
|
27
|
+
handlers: {
|
|
28
|
+
onKeyDown: _onKeyDownTable.onKeyDownTable
|
|
29
|
+
},
|
|
30
|
+
withOverrides: (editor, plugin)=>{
|
|
31
|
+
const { normalizeNode } = editor;
|
|
32
|
+
(0, _platetable.withTable)(editor, plugin);
|
|
33
|
+
editor.normalizeNode = normalizeNode;
|
|
34
|
+
(0, _tableTracking.addTableTrackingEvents)(editor);
|
|
35
|
+
editor.insertFragment = (0, _insertTableFragment.insertTableFragment)(editor);
|
|
36
|
+
return editor;
|
|
37
|
+
},
|
|
38
|
+
overrideByKey: {
|
|
39
|
+
[_platetable.ELEMENT_TABLE]: {
|
|
40
|
+
type: _richtexttypes.BLOCKS.TABLE,
|
|
41
|
+
component: _Table.Table,
|
|
42
|
+
normalizer: [
|
|
43
|
+
{
|
|
44
|
+
validNode: _helpers.isNotEmpty
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
validNode: (editor, [, path])=>{
|
|
48
|
+
const isNestedTable = !!(0, _queries.getBlockAbove)(editor, {
|
|
49
|
+
at: path,
|
|
50
|
+
match: {
|
|
51
|
+
type: [
|
|
52
|
+
_richtexttypes.BLOCKS.TABLE_CELL,
|
|
53
|
+
_richtexttypes.BLOCKS.TABLE_HEADER_CELL
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return (0, _editor.isRootLevel)(path) || isNestedTable;
|
|
58
|
+
},
|
|
59
|
+
transform: _transformers.transformLift
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
validChildren: _richtexttypes.CONTAINERS[_richtexttypes.BLOCKS.TABLE]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
[_platetable.ELEMENT_TR]: {
|
|
67
|
+
type: _richtexttypes.BLOCKS.TABLE_ROW,
|
|
68
|
+
component: _Row.Row,
|
|
69
|
+
normalizer: [
|
|
70
|
+
{
|
|
71
|
+
validChildren: _richtexttypes.CONTAINERS[_richtexttypes.BLOCKS.TABLE_ROW],
|
|
72
|
+
transform: (0, _transformers.transformWrapIn)(_richtexttypes.BLOCKS.TABLE_CELL)
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
validNode: _helpers.isNotEmpty
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
validNode: (editor, [, path])=>{
|
|
79
|
+
const parent = (0, _queries.getParentNode)(editor, path)?.[0];
|
|
80
|
+
return parent && parent.type === _richtexttypes.BLOCKS.TABLE;
|
|
81
|
+
},
|
|
82
|
+
transform: (0, _transformers.transformWrapIn)(_richtexttypes.BLOCKS.TABLE)
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
validNode: (editor, entry)=>{
|
|
86
|
+
return (0, _helpers.getNoOfMissingTableCellsInRow)(editor, entry) === 0;
|
|
87
|
+
},
|
|
88
|
+
transform: (editor, entry)=>{
|
|
89
|
+
const howMany = (0, _helpers.getNoOfMissingTableCellsInRow)(editor, entry);
|
|
90
|
+
const at = (0, _queries.getNextPath)((0, _queries.getLastChildPath)(entry));
|
|
91
|
+
(0, _transforms.insertNodes)(editor, (0, _helpers.createEmptyTableCells)(howMany), {
|
|
92
|
+
at
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
[_platetable.ELEMENT_TH]: {
|
|
99
|
+
type: _richtexttypes.BLOCKS.TABLE_HEADER_CELL,
|
|
100
|
+
component: _HeaderCell.HeaderCell,
|
|
101
|
+
normalizer: [
|
|
102
|
+
{
|
|
103
|
+
validChildren: _richtexttypes.CONTAINERS[_richtexttypes.BLOCKS.TABLE_HEADER_CELL],
|
|
104
|
+
transform: (0, _tableTracking.withInvalidCellChildrenTracking)(_transformers.transformParagraphs)
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
[_platetable.ELEMENT_TD]: {
|
|
109
|
+
type: _richtexttypes.BLOCKS.TABLE_CELL,
|
|
110
|
+
component: _Cell.Cell,
|
|
111
|
+
normalizer: [
|
|
112
|
+
{
|
|
113
|
+
validChildren: _richtexttypes.CONTAINERS[_richtexttypes.BLOCKS.TABLE_CELL],
|
|
114
|
+
transform: (0, _tableTracking.withInvalidCellChildrenTracking)(_transformers.transformParagraphs)
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
insertTableAndFocusFirstCell: function() {
|
|
13
|
+
return insertTableAndFocusFirstCell;
|
|
14
|
+
},
|
|
15
|
+
isTableActive: function() {
|
|
16
|
+
return isTableActive;
|
|
17
|
+
},
|
|
18
|
+
isTableHeaderEnabled: function() {
|
|
19
|
+
return isTableHeaderEnabled;
|
|
20
|
+
},
|
|
21
|
+
replaceEmptyParagraphWithTable: function() {
|
|
22
|
+
return replaceEmptyParagraphWithTable;
|
|
23
|
+
},
|
|
24
|
+
getNoOfMissingTableCellsInRow: function() {
|
|
25
|
+
return getNoOfMissingTableCellsInRow;
|
|
26
|
+
},
|
|
27
|
+
createEmptyTableCells: function() {
|
|
28
|
+
return createEmptyTableCells;
|
|
29
|
+
},
|
|
30
|
+
isNotEmpty: function() {
|
|
31
|
+
return isNotEmpty;
|
|
32
|
+
},
|
|
33
|
+
isTable: function() {
|
|
34
|
+
return isTable;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
38
|
+
const _platetable = require("@udecode/plate-table");
|
|
39
|
+
const _editor = require("../../helpers/editor");
|
|
40
|
+
const _internal = require("../../internal");
|
|
41
|
+
const _queries = require("../../internal/queries");
|
|
42
|
+
const _transforms = require("../../internal/transforms");
|
|
43
|
+
function insertTableAndFocusFirstCell(editor) {
|
|
44
|
+
const table = {
|
|
45
|
+
type: _richtexttypes.BLOCKS.TABLE,
|
|
46
|
+
data: {},
|
|
47
|
+
children: [
|
|
48
|
+
(0, _platetable.getEmptyRowNode)(editor, {
|
|
49
|
+
colCount: 2,
|
|
50
|
+
header: true
|
|
51
|
+
}),
|
|
52
|
+
(0, _platetable.getEmptyRowNode)(editor, {
|
|
53
|
+
colCount: 2
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
(0, _transforms.insertNodes)(editor, table);
|
|
58
|
+
if (editor.selection) {
|
|
59
|
+
const tableEntry = (0, _queries.getBlockAbove)(editor, {
|
|
60
|
+
match: {
|
|
61
|
+
type: _richtexttypes.BLOCKS.TABLE
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (!tableEntry) return;
|
|
65
|
+
(0, _internal.selectEditor)(editor, {
|
|
66
|
+
at: (0, _queries.getStartPoint)(editor, tableEntry[1])
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
replaceEmptyParagraphWithTable(editor);
|
|
70
|
+
}
|
|
71
|
+
function isTableActive(editor) {
|
|
72
|
+
const tableElements = [
|
|
73
|
+
_platetable.ELEMENT_TABLE,
|
|
74
|
+
_platetable.ELEMENT_TH,
|
|
75
|
+
_platetable.ELEMENT_TR,
|
|
76
|
+
_platetable.ELEMENT_TD
|
|
77
|
+
];
|
|
78
|
+
return tableElements.some((el)=>(0, _editor.isBlockSelected)(editor, el));
|
|
79
|
+
}
|
|
80
|
+
function isTableHeaderEnabled(editor) {
|
|
81
|
+
const tableItem = (0, _queries.getAboveNode)(editor, {
|
|
82
|
+
match: {
|
|
83
|
+
type: _richtexttypes.BLOCKS.TABLE
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
if (!tableItem) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const firstRow = (0, _queries.getChildren)(tableItem)[0];
|
|
90
|
+
if (!firstRow) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return (0, _queries.getChildren)(firstRow).every(([node])=>{
|
|
94
|
+
return node.type === _richtexttypes.BLOCKS.TABLE_HEADER_CELL;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function replaceEmptyParagraphWithTable(editor) {
|
|
98
|
+
const tablePath = (0, _editor.getAncestorPathFromSelection)(editor);
|
|
99
|
+
if (!tablePath || (0, _queries.isFirstChildPath)(tablePath)) return;
|
|
100
|
+
const previousPath = (0, _queries.getPreviousPath)(tablePath);
|
|
101
|
+
if (!previousPath) return;
|
|
102
|
+
const [nodes] = (0, _queries.getNodeEntries)(editor, {
|
|
103
|
+
at: previousPath,
|
|
104
|
+
match: (node)=>node.type === _richtexttypes.BLOCKS.PARAGRAPH
|
|
105
|
+
});
|
|
106
|
+
if (!nodes) return;
|
|
107
|
+
const [previousNode] = nodes;
|
|
108
|
+
const isPreviousNodeTextEmpty = (0, _queries.isAncestorEmpty)(editor, previousNode);
|
|
109
|
+
if (isPreviousNodeTextEmpty) {
|
|
110
|
+
(0, _transforms.moveNodes)(editor, {
|
|
111
|
+
at: tablePath,
|
|
112
|
+
to: previousPath
|
|
113
|
+
});
|
|
114
|
+
(0, _transforms.removeNodes)(editor, {
|
|
115
|
+
at: tablePath
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const getNoOfMissingTableCellsInRow = (editor, rowEntry)=>{
|
|
120
|
+
const [, rowPath] = rowEntry;
|
|
121
|
+
const parent = (0, _queries.getParentNode)(editor, rowPath);
|
|
122
|
+
if (!parent) {
|
|
123
|
+
throw new Error('table rows must be wrapped in a table node');
|
|
124
|
+
}
|
|
125
|
+
const tableWidth = Math.max(...(0, _queries.getChildren)(parent).map((entry)=>(0, _queries.getChildren)(entry).length));
|
|
126
|
+
const rowWidth = (0, _queries.getChildren)(rowEntry).length;
|
|
127
|
+
return tableWidth - rowWidth;
|
|
128
|
+
};
|
|
129
|
+
const createEmptyTableCells = (count)=>{
|
|
130
|
+
const emptyTableCell = {
|
|
131
|
+
type: _richtexttypes.BLOCKS.TABLE_CELL,
|
|
132
|
+
data: {},
|
|
133
|
+
children: [
|
|
134
|
+
{
|
|
135
|
+
type: _richtexttypes.BLOCKS.PARAGRAPH,
|
|
136
|
+
data: {},
|
|
137
|
+
children: [
|
|
138
|
+
{
|
|
139
|
+
text: ''
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
};
|
|
145
|
+
return new Array(count).fill(emptyTableCell);
|
|
146
|
+
};
|
|
147
|
+
const isNotEmpty = (_, entry)=>{
|
|
148
|
+
return (0, _queries.getChildren)(entry).length !== 0;
|
|
149
|
+
};
|
|
150
|
+
const isTable = (node)=>{
|
|
151
|
+
return (0, _queries.isElement)(node) && node.type === _richtexttypes.BLOCKS.TABLE;
|
|
152
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./createTablePlugin"), exports);
|
|
6
|
+
_export_star(require("./components/ToolbarButton"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "insertTableFragment", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return insertTableFragment;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
12
|
+
const _editor = require("../../helpers/editor");
|
|
13
|
+
const _queries = require("../../internal/queries");
|
|
14
|
+
const _helpers = require("./helpers");
|
|
15
|
+
const trimUnnecessaryTableWrapper = (node)=>{
|
|
16
|
+
if (!(0, _queries.isElement)(node)) {
|
|
17
|
+
return [
|
|
18
|
+
node
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
if (node.type !== _richtexttypes.BLOCKS.TABLE || node.children?.length !== 1) {
|
|
22
|
+
return [
|
|
23
|
+
node
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
const row = node.children[0];
|
|
27
|
+
if (row?.children?.length !== 1) {
|
|
28
|
+
return [
|
|
29
|
+
node
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
const cell = row.children[0];
|
|
33
|
+
return cell.children;
|
|
34
|
+
};
|
|
35
|
+
const insertTableFragment = (editor)=>{
|
|
36
|
+
const { insertFragment } = editor;
|
|
37
|
+
return (fragments)=>{
|
|
38
|
+
if (!editor.selection) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
fragments = fragments.flatMap(trimUnnecessaryTableWrapper);
|
|
42
|
+
const isInsertingTable = fragments.some((fragment)=>(0, _helpers.isTable)(fragment));
|
|
43
|
+
const isTableFirstFragment = fragments.findIndex((fragment)=>(0, _helpers.isTable)(fragment)) === 0;
|
|
44
|
+
const currentLineHasText = (0, _queries.getText)(editor, editor.selection?.focus.path) !== '';
|
|
45
|
+
if (isInsertingTable && isTableFirstFragment && currentLineHasText) {
|
|
46
|
+
(0, _editor.insertEmptyParagraph)(editor);
|
|
47
|
+
}
|
|
48
|
+
return insertFragment(fragments);
|
|
49
|
+
};
|
|
50
|
+
};
|