@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,116 @@
|
|
|
1
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { ELEMENT_TABLE, ELEMENT_TH, ELEMENT_TD, ELEMENT_TR, getEmptyRowNode } from '@udecode/plate-table';
|
|
3
|
+
import { isBlockSelected, getAncestorPathFromSelection } from '../../helpers/editor';
|
|
4
|
+
import { selectEditor } from '../../internal';
|
|
5
|
+
import { getBlockAbove, getStartPoint, getAboveNode, getChildren, isFirstChildPath, isAncestorEmpty, getParentNode, isElement, getNodeEntries, getPreviousPath } from '../../internal/queries';
|
|
6
|
+
import { insertNodes, removeNodes, moveNodes } from '../../internal/transforms';
|
|
7
|
+
export function insertTableAndFocusFirstCell(editor) {
|
|
8
|
+
const table = {
|
|
9
|
+
type: BLOCKS.TABLE,
|
|
10
|
+
data: {},
|
|
11
|
+
children: [
|
|
12
|
+
getEmptyRowNode(editor, {
|
|
13
|
+
colCount: 2,
|
|
14
|
+
header: true
|
|
15
|
+
}),
|
|
16
|
+
getEmptyRowNode(editor, {
|
|
17
|
+
colCount: 2
|
|
18
|
+
})
|
|
19
|
+
]
|
|
20
|
+
};
|
|
21
|
+
insertNodes(editor, table);
|
|
22
|
+
if (editor.selection) {
|
|
23
|
+
const tableEntry = getBlockAbove(editor, {
|
|
24
|
+
match: {
|
|
25
|
+
type: BLOCKS.TABLE
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (!tableEntry) return;
|
|
29
|
+
selectEditor(editor, {
|
|
30
|
+
at: getStartPoint(editor, tableEntry[1])
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
replaceEmptyParagraphWithTable(editor);
|
|
34
|
+
}
|
|
35
|
+
export function isTableActive(editor) {
|
|
36
|
+
const tableElements = [
|
|
37
|
+
ELEMENT_TABLE,
|
|
38
|
+
ELEMENT_TH,
|
|
39
|
+
ELEMENT_TR,
|
|
40
|
+
ELEMENT_TD
|
|
41
|
+
];
|
|
42
|
+
return tableElements.some((el)=>isBlockSelected(editor, el));
|
|
43
|
+
}
|
|
44
|
+
export function isTableHeaderEnabled(editor) {
|
|
45
|
+
const tableItem = getAboveNode(editor, {
|
|
46
|
+
match: {
|
|
47
|
+
type: BLOCKS.TABLE
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (!tableItem) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const firstRow = getChildren(tableItem)[0];
|
|
54
|
+
if (!firstRow) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return getChildren(firstRow).every(([node])=>{
|
|
58
|
+
return node.type === BLOCKS.TABLE_HEADER_CELL;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
export function replaceEmptyParagraphWithTable(editor) {
|
|
62
|
+
const tablePath = getAncestorPathFromSelection(editor);
|
|
63
|
+
if (!tablePath || isFirstChildPath(tablePath)) return;
|
|
64
|
+
const previousPath = getPreviousPath(tablePath);
|
|
65
|
+
if (!previousPath) return;
|
|
66
|
+
const [nodes] = getNodeEntries(editor, {
|
|
67
|
+
at: previousPath,
|
|
68
|
+
match: (node)=>node.type === BLOCKS.PARAGRAPH
|
|
69
|
+
});
|
|
70
|
+
if (!nodes) return;
|
|
71
|
+
const [previousNode] = nodes;
|
|
72
|
+
const isPreviousNodeTextEmpty = isAncestorEmpty(editor, previousNode);
|
|
73
|
+
if (isPreviousNodeTextEmpty) {
|
|
74
|
+
moveNodes(editor, {
|
|
75
|
+
at: tablePath,
|
|
76
|
+
to: previousPath
|
|
77
|
+
});
|
|
78
|
+
removeNodes(editor, {
|
|
79
|
+
at: tablePath
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const getNoOfMissingTableCellsInRow = (editor, rowEntry)=>{
|
|
84
|
+
const [, rowPath] = rowEntry;
|
|
85
|
+
const parent = getParentNode(editor, rowPath);
|
|
86
|
+
if (!parent) {
|
|
87
|
+
throw new Error('table rows must be wrapped in a table node');
|
|
88
|
+
}
|
|
89
|
+
const tableWidth = Math.max(...getChildren(parent).map((entry)=>getChildren(entry).length));
|
|
90
|
+
const rowWidth = getChildren(rowEntry).length;
|
|
91
|
+
return tableWidth - rowWidth;
|
|
92
|
+
};
|
|
93
|
+
export const createEmptyTableCells = (count)=>{
|
|
94
|
+
const emptyTableCell = {
|
|
95
|
+
type: BLOCKS.TABLE_CELL,
|
|
96
|
+
data: {},
|
|
97
|
+
children: [
|
|
98
|
+
{
|
|
99
|
+
type: BLOCKS.PARAGRAPH,
|
|
100
|
+
data: {},
|
|
101
|
+
children: [
|
|
102
|
+
{
|
|
103
|
+
text: ''
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
return new Array(count).fill(emptyTableCell);
|
|
110
|
+
};
|
|
111
|
+
export const isNotEmpty = (_, entry)=>{
|
|
112
|
+
return getChildren(entry).length !== 0;
|
|
113
|
+
};
|
|
114
|
+
export const isTable = (node)=>{
|
|
115
|
+
return isElement(node) && node.type === BLOCKS.TABLE;
|
|
116
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { insertEmptyParagraph } from '../../helpers/editor';
|
|
3
|
+
import { getText, isElement } from '../../internal/queries';
|
|
4
|
+
import { isTable } from './helpers';
|
|
5
|
+
const trimUnnecessaryTableWrapper = (node)=>{
|
|
6
|
+
if (!isElement(node)) {
|
|
7
|
+
return [
|
|
8
|
+
node
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
if (node.type !== BLOCKS.TABLE || node.children?.length !== 1) {
|
|
12
|
+
return [
|
|
13
|
+
node
|
|
14
|
+
];
|
|
15
|
+
}
|
|
16
|
+
const row = node.children[0];
|
|
17
|
+
if (row?.children?.length !== 1) {
|
|
18
|
+
return [
|
|
19
|
+
node
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
const cell = row.children[0];
|
|
23
|
+
return cell.children;
|
|
24
|
+
};
|
|
25
|
+
export const insertTableFragment = (editor)=>{
|
|
26
|
+
const { insertFragment } = editor;
|
|
27
|
+
return (fragments)=>{
|
|
28
|
+
if (!editor.selection) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
fragments = fragments.flatMap(trimUnnecessaryTableWrapper);
|
|
32
|
+
const isInsertingTable = fragments.some((fragment)=>isTable(fragment));
|
|
33
|
+
const isTableFirstFragment = fragments.findIndex((fragment)=>isTable(fragment)) === 0;
|
|
34
|
+
const currentLineHasText = getText(editor, editor.selection?.focus.path) !== '';
|
|
35
|
+
if (isInsertingTable && isTableFirstFragment && currentLineHasText) {
|
|
36
|
+
insertEmptyParagraph(editor);
|
|
37
|
+
}
|
|
38
|
+
return insertFragment(fragments);
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { getTableEntries, onKeyDownTable as defaultKeyDownTable } from '@udecode/plate-table';
|
|
3
|
+
import { insertEmptyParagraph } from '../../helpers/editor';
|
|
4
|
+
import { blurEditor } from '../../internal/misc';
|
|
5
|
+
import { getAboveNode, isLastChildPath } from '../../internal/queries';
|
|
6
|
+
import { addRowBelow } from './actions';
|
|
7
|
+
export const onKeyDownTable = (editor, plugin)=>{
|
|
8
|
+
const defaultHandler = defaultKeyDownTable(editor, plugin);
|
|
9
|
+
return (event)=>{
|
|
10
|
+
const windowSelection = window.getSelection();
|
|
11
|
+
if (windowSelection) {
|
|
12
|
+
const blockType = windowSelection.anchorNode.attributes?.['data-block-type']?.value;
|
|
13
|
+
const isBeforeTable = blockType === BLOCKS.TABLE;
|
|
14
|
+
if (isBeforeTable) {
|
|
15
|
+
if (event.key === 'Enter') {
|
|
16
|
+
const above = getAboveNode(editor, {
|
|
17
|
+
match: {
|
|
18
|
+
type: BLOCKS.TABLE
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
if (!above) return;
|
|
22
|
+
const [, tablePath] = above;
|
|
23
|
+
insertEmptyParagraph(editor, {
|
|
24
|
+
at: tablePath,
|
|
25
|
+
select: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
const entry = getTableEntries(editor, {});
|
|
36
|
+
if (entry) {
|
|
37
|
+
const { table , row , cell } = entry;
|
|
38
|
+
const isLastCell = isLastChildPath(row, cell[1]);
|
|
39
|
+
const isLastRow = isLastChildPath(table, row[1]);
|
|
40
|
+
if (isLastRow && isLastCell) {
|
|
41
|
+
addRowBelow(editor);
|
|
42
|
+
return;
|
|
43
|
+
} else {
|
|
44
|
+
defaultHandler(event);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (event.key === 'Escape') {
|
|
49
|
+
blurEditor(editor);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { isElement } from '../../internal/queries';
|
|
3
|
+
import { getPastingSource } from '../../plugins/Tracking';
|
|
4
|
+
function hasTables(nodes) {
|
|
5
|
+
return nodes.some(({ type })=>{
|
|
6
|
+
return type === BLOCKS.TABLE;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
const isTableHeaderCell = ({ type })=>type === BLOCKS.TABLE_HEADER_CELL;
|
|
10
|
+
function hasHeadersOutsideFirstRow(nodes) {
|
|
11
|
+
return nodes.filter(({ type })=>type === BLOCKS.TABLE).flatMap(({ children })=>children.slice(1)).some(({ children })=>children.some(isTableHeaderCell));
|
|
12
|
+
}
|
|
13
|
+
export function addTableTrackingEvents(editor) {
|
|
14
|
+
const { insertData } = editor;
|
|
15
|
+
editor.insertData = (data)=>{
|
|
16
|
+
const html = data.getData('text/html');
|
|
17
|
+
if (html) {
|
|
18
|
+
const { children: markupBefore } = editor;
|
|
19
|
+
insertData(data);
|
|
20
|
+
const { children: markupAfter } = editor;
|
|
21
|
+
setTimeout(()=>{
|
|
22
|
+
if (hasTables(markupBefore)) return;
|
|
23
|
+
if (hasTables(markupAfter)) {
|
|
24
|
+
editor.tracking.onViewportAction('paste', {
|
|
25
|
+
tablePasted: true,
|
|
26
|
+
source: getPastingSource(data),
|
|
27
|
+
hasHeadersOutsideFirstRow: hasHeadersOutsideFirstRow(markupAfter)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}, 1);
|
|
31
|
+
} else {
|
|
32
|
+
insertData(data);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export const withInvalidCellChildrenTracking = (transformer)=>{
|
|
37
|
+
return (editor, childEntry)=>{
|
|
38
|
+
const [node] = childEntry;
|
|
39
|
+
if (isElement(node)) {
|
|
40
|
+
editor.tracking?.onViewportAction('invalidTablePaste', {
|
|
41
|
+
nodeType: node.type
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return transformer(editor, childEntry);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx, assertOutput, createTestEditor } from '../../../test-utils';
|
|
2
|
+
describe('delete backward', ()=>{
|
|
3
|
+
const tests = [
|
|
4
|
+
{
|
|
5
|
+
title: 'deletes a character of the text inside li',
|
|
6
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1", jsx("cursor", null)))),
|
|
7
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, "p", jsx("cursor", null))))
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by another paragraph',
|
|
11
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hp", null, "text")),
|
|
12
|
+
expected: jsx("hp", null, jsx("cursor", null), "text")
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by li',
|
|
16
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")))),
|
|
17
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1")))
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by a blockquote',
|
|
21
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hquote", null, jsx("hp", null, "p1"))),
|
|
22
|
+
expected: jsx("hquote", null, jsx("hp", null, jsx("cursor", null), "p1"))
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
26
|
+
for (const t of tests){
|
|
27
|
+
test(t.title, ()=>{
|
|
28
|
+
const { editor } = createTestEditor({
|
|
29
|
+
input: render(t.input)
|
|
30
|
+
});
|
|
31
|
+
editor.deleteBackward('character');
|
|
32
|
+
assertOutput({
|
|
33
|
+
editor,
|
|
34
|
+
expected: render(t.expected)
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
describe('delete forward', ()=>{
|
|
40
|
+
const tests = [
|
|
41
|
+
{
|
|
42
|
+
title: 'deletes a character of the text inside li',
|
|
43
|
+
input: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1"))),
|
|
44
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "1")))
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by another paragraph',
|
|
48
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hp", null, "text")),
|
|
49
|
+
expected: jsx("hp", null, jsx("cursor", null), "text")
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by li',
|
|
53
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hul", null, jsx("hli", null, jsx("hp", null, "p1")))),
|
|
54
|
+
expected: jsx("hul", null, jsx("hli", null, jsx("hp", null, jsx("cursor", null), "p1")))
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: 'deletes the empty paragraph at the beginning of the RTE followed by a blockquote',
|
|
58
|
+
input: jsx("fragment", null, jsx("hp", null, jsx("cursor", null)), jsx("hquote", null, jsx("hp", null, "p1"))),
|
|
59
|
+
expected: jsx("hquote", null, jsx("hp", null, jsx("cursor", null), "p1"))
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
const render = (children)=>jsx("editor", null, children, jsx("hp", null, jsx("htext", null)));
|
|
63
|
+
for (const t of tests){
|
|
64
|
+
test(t.title, ()=>{
|
|
65
|
+
const { editor } = createTestEditor({
|
|
66
|
+
input: render(t.input)
|
|
67
|
+
});
|
|
68
|
+
editor.deleteForward('character');
|
|
69
|
+
assertOutput({
|
|
70
|
+
editor,
|
|
71
|
+
expected: render(t.expected)
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { BLOCKS, TEXT_CONTAINERS } from '@contentful/rich-text-types';
|
|
2
|
+
import { getAboveNode, isAncestorEmpty, getNodeEntries, getPointBefore, isInline, isEndPoint, getPointAfter, isRangeCollapsed, queryNode, isText } from '../../internal/queries';
|
|
3
|
+
import { setSelection, select, removeNodes, splitNodes, unhangRange, unsetNodes } from '../../internal/transforms';
|
|
4
|
+
export function createTextPlugin(restrictedMarks = []) {
|
|
5
|
+
return {
|
|
6
|
+
key: 'TextPlugin',
|
|
7
|
+
handlers: {
|
|
8
|
+
onMouseUp: (editor)=>()=>{
|
|
9
|
+
if (!editor.selection) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
setSelection(editor, unhangRange(editor, editor.selection));
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
withOverrides: (editor)=>{
|
|
16
|
+
const { insertText } = editor;
|
|
17
|
+
editor.insertText = (text)=>{
|
|
18
|
+
const { selection } = editor;
|
|
19
|
+
if (selection && isRangeCollapsed(selection)) {
|
|
20
|
+
const inlinePath = getAboveNode(editor, {
|
|
21
|
+
match: (n)=>isInline(editor, n),
|
|
22
|
+
mode: 'highest'
|
|
23
|
+
})?.[1];
|
|
24
|
+
if (inlinePath && isEndPoint(editor, selection.anchor, inlinePath)) {
|
|
25
|
+
const point = getPointAfter(editor, inlinePath);
|
|
26
|
+
setSelection(editor, {
|
|
27
|
+
anchor: point,
|
|
28
|
+
focus: point
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return insertText(text);
|
|
33
|
+
};
|
|
34
|
+
const { deleteForward , deleteBackward } = editor;
|
|
35
|
+
editor.deleteBackward = (unit)=>{
|
|
36
|
+
deleteEmptyParagraph(unit, editor, deleteBackward);
|
|
37
|
+
};
|
|
38
|
+
editor.deleteForward = (unit)=>{
|
|
39
|
+
deleteEmptyParagraph(unit, editor, deleteForward);
|
|
40
|
+
};
|
|
41
|
+
fixPasteAsPlainText(editor);
|
|
42
|
+
return editor;
|
|
43
|
+
},
|
|
44
|
+
normalizer: [
|
|
45
|
+
{
|
|
46
|
+
match: isText,
|
|
47
|
+
transform: (editor, [, path])=>{
|
|
48
|
+
unsetNodes(editor, restrictedMarks, {
|
|
49
|
+
at: path
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
validNode: (_editor, [node])=>{
|
|
53
|
+
return !restrictedMarks.some((mark)=>{
|
|
54
|
+
return mark in node;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function deleteEmptyParagraph(unit, editor, deleteFunction) {
|
|
62
|
+
const entry = getAboveNode(editor, {
|
|
63
|
+
match: {
|
|
64
|
+
type: TEXT_CONTAINERS
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (entry) {
|
|
68
|
+
const [paragraphOrHeading, path] = entry;
|
|
69
|
+
const isTextEmpty = isAncestorEmpty(editor, paragraphOrHeading);
|
|
70
|
+
const isRootLevel = path.length === 1;
|
|
71
|
+
const hasSiblings = editor.children.length > 1;
|
|
72
|
+
if (isTextEmpty && isRootLevel && hasSiblings) {
|
|
73
|
+
removeNodes(editor, {
|
|
74
|
+
at: path
|
|
75
|
+
});
|
|
76
|
+
const prevNode = getPointBefore(editor, editor.selection, {
|
|
77
|
+
unit
|
|
78
|
+
});
|
|
79
|
+
if (prevNode) {
|
|
80
|
+
const [prevCell] = getNodeEntries(editor, {
|
|
81
|
+
match: (node)=>queryNode([
|
|
82
|
+
node,
|
|
83
|
+
prevNode.path
|
|
84
|
+
], {
|
|
85
|
+
allow: [
|
|
86
|
+
BLOCKS.EMBEDDED_ASSET,
|
|
87
|
+
BLOCKS.EMBEDDED_ENTRY,
|
|
88
|
+
BLOCKS.HR
|
|
89
|
+
]
|
|
90
|
+
}),
|
|
91
|
+
at: prevNode
|
|
92
|
+
});
|
|
93
|
+
if (prevCell) {
|
|
94
|
+
select(editor, prevNode);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
deleteFunction(unit);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
deleteFunction(unit);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function fixPasteAsPlainText(editor) {
|
|
105
|
+
editor.insertTextData = (data)=>{
|
|
106
|
+
const text = data.getData('text/plain');
|
|
107
|
+
if (!text) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const lines = text.split(/\n{2}/);
|
|
111
|
+
let split = false;
|
|
112
|
+
for (const line of lines){
|
|
113
|
+
if (/^(\r\n?|\n)$/.test(line)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (split) {
|
|
117
|
+
splitNodes(editor, {
|
|
118
|
+
always: true
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
editor.insertText(line);
|
|
122
|
+
split = true;
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createTextPlugin';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { getCharacterCount } from './utils';
|
|
2
|
+
const actionOrigin = {
|
|
3
|
+
TOOLBAR: 'toolbar-icon',
|
|
4
|
+
SHORTCUT: 'shortcut',
|
|
5
|
+
VIEWPORT: 'viewport-interaction',
|
|
6
|
+
SHORTCUT_OR_VIEWPORT: 'shortcut-or-viewport',
|
|
7
|
+
COMMAND_PALETTE: 'command-palette'
|
|
8
|
+
};
|
|
9
|
+
export function getPastingSource(data) {
|
|
10
|
+
const textHtml = data.getData('text/html');
|
|
11
|
+
const doc = new DOMParser().parseFromString(textHtml, 'text/html');
|
|
12
|
+
if (doc.querySelector('[id*="docs-internal-guid"]')) {
|
|
13
|
+
return 'Google Docs';
|
|
14
|
+
}
|
|
15
|
+
if (doc.querySelector('google-sheets-html-origin') || doc.querySelector('[data-sheets-value]')) {
|
|
16
|
+
return 'Google Spreadsheets';
|
|
17
|
+
}
|
|
18
|
+
if (doc.querySelector('meta[content*="Microsoft Excel"]')) {
|
|
19
|
+
return 'Microsoft Excel';
|
|
20
|
+
}
|
|
21
|
+
if (doc.querySelector('meta[content*="Microsoft Word"]')) {
|
|
22
|
+
return 'Microsoft Word';
|
|
23
|
+
}
|
|
24
|
+
if (doc.querySelector('[style*="Arial_MSFontService"]') && (doc.querySelector('.TextRun') || doc.querySelector('.OutlineElement'))) {
|
|
25
|
+
return 'Microsoft Word Online';
|
|
26
|
+
}
|
|
27
|
+
if (doc.querySelector('meta[content="Cocoa HTML Writer"]')) {
|
|
28
|
+
return 'Apple Notes';
|
|
29
|
+
}
|
|
30
|
+
if (doc.querySelector('[style*="Slack-Lato, Slack-Fractions"]')) {
|
|
31
|
+
return 'Slack';
|
|
32
|
+
}
|
|
33
|
+
return 'Unknown';
|
|
34
|
+
}
|
|
35
|
+
export const createTrackingPlugin = (onAction)=>{
|
|
36
|
+
const trackingActions = {
|
|
37
|
+
onViewportAction: (actionName, data = {})=>onAction(actionName, {
|
|
38
|
+
origin: actionOrigin.VIEWPORT,
|
|
39
|
+
...data
|
|
40
|
+
}),
|
|
41
|
+
onShortcutAction: (actionName, data = {})=>onAction(actionName, {
|
|
42
|
+
origin: actionOrigin.SHORTCUT,
|
|
43
|
+
...data
|
|
44
|
+
}),
|
|
45
|
+
onShortcutOrViewportAction: (actionName, data = {})=>onAction(actionName, {
|
|
46
|
+
origin: actionOrigin.SHORTCUT_OR_VIEWPORT,
|
|
47
|
+
...data
|
|
48
|
+
}),
|
|
49
|
+
onToolbarAction: (actionName, data = {})=>onAction(actionName, {
|
|
50
|
+
origin: actionOrigin.TOOLBAR,
|
|
51
|
+
...data
|
|
52
|
+
}),
|
|
53
|
+
onCommandPaletteAction: (actionName, data = {})=>onAction(actionName, {
|
|
54
|
+
origin: actionOrigin.COMMAND_PALETTE,
|
|
55
|
+
...data
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
key: 'TrackingPlugin',
|
|
60
|
+
withOverrides: (editor)=>{
|
|
61
|
+
const { insertData } = editor;
|
|
62
|
+
editor.tracking = trackingActions;
|
|
63
|
+
editor.insertData = (data)=>{
|
|
64
|
+
const isCopyAndPaste = data.types.length !== 0;
|
|
65
|
+
if (isCopyAndPaste) {
|
|
66
|
+
const characterCountSelection = window.getSelection()?.toString().length;
|
|
67
|
+
const characterCountBefore = getCharacterCount(editor);
|
|
68
|
+
setTimeout(()=>{
|
|
69
|
+
const characterCountAfter = getCharacterCount(editor);
|
|
70
|
+
trackingActions.onShortcutOrViewportAction('paste', {
|
|
71
|
+
characterCountAfter,
|
|
72
|
+
characterCountBefore,
|
|
73
|
+
characterCountSelection,
|
|
74
|
+
source: getPastingSource(data)
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
insertData(data);
|
|
79
|
+
};
|
|
80
|
+
return editor;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createTrackingPlugin';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as contentfulSlateJSAdapter from '@contentful/contentful-slatejs-adapter';
|
|
2
|
+
import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';
|
|
3
|
+
import Schema from '../../constants/Schema';
|
|
4
|
+
export function getCharacterCount(editor) {
|
|
5
|
+
const document = contentfulSlateJSAdapter.toContentfulDocument({
|
|
6
|
+
document: editor.children,
|
|
7
|
+
schema: Schema
|
|
8
|
+
});
|
|
9
|
+
return documentToPlainTextString(document).length;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BLOCKS } from '@contentful/rich-text-types';
|
|
2
|
+
import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
|
|
3
|
+
export const createTrailingParagraphPlugin = ()=>{
|
|
4
|
+
return createTrailingBlockPlugin({
|
|
5
|
+
options: {
|
|
6
|
+
type: BLOCKS.PARAGRAPH,
|
|
7
|
+
level: 0
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isRootLevel } from '../../helpers/editor';
|
|
2
|
+
import { isFirstChildPath } from '../../internal/queries';
|
|
3
|
+
export const createVoidsPlugin = ()=>({
|
|
4
|
+
key: 'VoidsPlugin',
|
|
5
|
+
exitBreak: [
|
|
6
|
+
{
|
|
7
|
+
hotkey: 'enter',
|
|
8
|
+
before: true,
|
|
9
|
+
query: {
|
|
10
|
+
filter: ([node, path])=>isRootLevel(path) && isFirstChildPath(path) && !!node.isVoid
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
hotkey: 'enter',
|
|
15
|
+
level: -2,
|
|
16
|
+
query: {
|
|
17
|
+
filter: ([node, path])=>!(isRootLevel(path) && isFirstChildPath(path)) && !!node.isVoid
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createVoidsPlugin';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { insertNodes, removeNodes } from '../../internal/transforms';
|
|
2
|
+
export const transformVoid = (editor, [node, path])=>{
|
|
3
|
+
const validVoid = {
|
|
4
|
+
...node,
|
|
5
|
+
children: [
|
|
6
|
+
{
|
|
7
|
+
text: ''
|
|
8
|
+
}
|
|
9
|
+
]
|
|
10
|
+
};
|
|
11
|
+
removeNodes(editor, {
|
|
12
|
+
at: path
|
|
13
|
+
});
|
|
14
|
+
insertNodes(editor, [
|
|
15
|
+
validVoid
|
|
16
|
+
], {
|
|
17
|
+
at: path
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createDeserializeAstPlugin, createDeserializeHtmlPlugin } from '@udecode/plate-core';
|
|
2
|
+
import { createDeserializeDocxPlugin } from '@udecode/plate-serializer-docx';
|
|
3
|
+
import { createSoftBreakPlugin, createExitBreakPlugin, createResetNodePlugin } from './Break';
|
|
4
|
+
import { createCommandPalettePlugin } from './CommandPalette';
|
|
5
|
+
import { isCommandPromptPluginEnabled } from './CommandPalette/useCommands';
|
|
6
|
+
import { createDragAndDropPlugin } from './DragAndDrop';
|
|
7
|
+
import { createEmbeddedAssetBlockPlugin, createEmbeddedEntryBlockPlugin } from './EmbeddedEntityBlock';
|
|
8
|
+
import { createEmbeddedEntityInlinePlugin } from './EmbeddedEntityInline';
|
|
9
|
+
import { createHeadingPlugin } from './Heading';
|
|
10
|
+
import { createHrPlugin } from './Hr';
|
|
11
|
+
import { createHyperlinkPlugin } from './Hyperlink';
|
|
12
|
+
import { createListPlugin } from './List';
|
|
13
|
+
import { createMarksPlugin } from './Marks';
|
|
14
|
+
import { createNormalizerPlugin } from './Normalizer';
|
|
15
|
+
import { createParagraphPlugin } from './Paragraph';
|
|
16
|
+
import { createPasteHTMLPlugin } from './PasteHTML';
|
|
17
|
+
import { createQuotePlugin } from './Quote';
|
|
18
|
+
import { createSelectOnBackspacePlugin } from './SelectOnBackspace';
|
|
19
|
+
import { createTablePlugin } from './Table';
|
|
20
|
+
import { createTextPlugin } from './Text';
|
|
21
|
+
import { createTrackingPlugin } from './Tracking';
|
|
22
|
+
import { createTrailingParagraphPlugin } from './TrailingParagraph';
|
|
23
|
+
import { createVoidsPlugin } from './Voids';
|
|
24
|
+
export const getPlugins = (sdk, onAction, restrictedMarks)=>[
|
|
25
|
+
createDeserializeHtmlPlugin(),
|
|
26
|
+
createDeserializeAstPlugin(),
|
|
27
|
+
createDeserializeDocxPlugin(),
|
|
28
|
+
createTrackingPlugin(onAction),
|
|
29
|
+
createDragAndDropPlugin(),
|
|
30
|
+
...Object.values(isCommandPromptPluginEnabled(sdk)).some(Boolean) ? [
|
|
31
|
+
createCommandPalettePlugin()
|
|
32
|
+
] : [],
|
|
33
|
+
createParagraphPlugin(),
|
|
34
|
+
createListPlugin(),
|
|
35
|
+
createHrPlugin(),
|
|
36
|
+
createHeadingPlugin(),
|
|
37
|
+
createQuotePlugin(),
|
|
38
|
+
createTablePlugin(),
|
|
39
|
+
createEmbeddedEntryBlockPlugin(sdk),
|
|
40
|
+
createEmbeddedAssetBlockPlugin(sdk),
|
|
41
|
+
createHyperlinkPlugin(sdk),
|
|
42
|
+
createEmbeddedEntityInlinePlugin(sdk),
|
|
43
|
+
createMarksPlugin(),
|
|
44
|
+
createTrailingParagraphPlugin(),
|
|
45
|
+
createTextPlugin(restrictedMarks),
|
|
46
|
+
createVoidsPlugin(),
|
|
47
|
+
createSelectOnBackspacePlugin(),
|
|
48
|
+
createPasteHTMLPlugin(),
|
|
49
|
+
createSoftBreakPlugin(),
|
|
50
|
+
createExitBreakPlugin(),
|
|
51
|
+
createResetNodePlugin(),
|
|
52
|
+
createNormalizerPlugin()
|
|
53
|
+
];
|
|
54
|
+
export const disableCorePlugins = {
|
|
55
|
+
deserializeAst: true,
|
|
56
|
+
deserializeHtml: true,
|
|
57
|
+
eventEditor: true
|
|
58
|
+
};
|