@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,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _testutils = require("../../../test-utils");
|
|
6
|
+
const _moveListItems = require("./moveListItems");
|
|
7
|
+
describe('moving list items (up/down)', ()=>{
|
|
8
|
+
const renderEditor = (children)=>(0, _testutils.jsx)("editor", null, children, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
9
|
+
const assertTab = (t, shift = false)=>{
|
|
10
|
+
test(t.title, ()=>{
|
|
11
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
12
|
+
input: renderEditor(t.input)
|
|
13
|
+
});
|
|
14
|
+
(0, _moveListItems.moveListItems)(editor, {
|
|
15
|
+
increase: !shift
|
|
16
|
+
});
|
|
17
|
+
(0, _testutils.assertOutput)({
|
|
18
|
+
editor,
|
|
19
|
+
expected: renderEditor(t.expected)
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const tests = [
|
|
24
|
+
{
|
|
25
|
+
title: 'single paragraph',
|
|
26
|
+
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null)))),
|
|
27
|
+
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null))))))
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
title: 'multiple paragraphs',
|
|
31
|
+
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, "p2")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p3", (0, _testutils.jsx)("cursor", null)))),
|
|
32
|
+
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hp", null, "p2"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p3", (0, _testutils.jsx)("cursor", null))))))
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: 'multiple elements',
|
|
36
|
+
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "a"), (0, _testutils.jsx)("hp", null, "b"), (0, _testutils.jsx)("hquote", null, (0, _testutils.jsx)("hp", null, "quote"))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "c", (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "d"), (0, _testutils.jsx)("hembed", {
|
|
37
|
+
type: "Asset",
|
|
38
|
+
id: "asset-id"
|
|
39
|
+
}))),
|
|
40
|
+
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "a"), (0, _testutils.jsx)("hp", null, "b"), (0, _testutils.jsx)("hquote", null, (0, _testutils.jsx)("hp", null, "quote")), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "c", (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hp", null, "d"), (0, _testutils.jsx)("hembed", {
|
|
41
|
+
type: "Asset",
|
|
42
|
+
id: "asset-id"
|
|
43
|
+
})))))
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: 'with a sub-list',
|
|
47
|
+
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "sub p1")))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null)))),
|
|
48
|
+
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "sub p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null))))))
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: 'with a sub-list as non-last child',
|
|
52
|
+
input: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "sub p1"))), (0, _testutils.jsx)("hembed", {
|
|
53
|
+
type: "Entry",
|
|
54
|
+
id: "entry-id"
|
|
55
|
+
})), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null)))),
|
|
56
|
+
expected: (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "sub p1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "p2", (0, _testutils.jsx)("cursor", null)))), (0, _testutils.jsx)("hembed", {
|
|
57
|
+
type: "Entry",
|
|
58
|
+
id: "entry-id"
|
|
59
|
+
})))
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
describe('move down (aka. tab)', ()=>{
|
|
63
|
+
tests.forEach((t)=>assertTab(t));
|
|
64
|
+
});
|
|
65
|
+
describe('move up (aka. shift+tab)', ()=>{
|
|
66
|
+
tests.map((t)=>({
|
|
67
|
+
...t,
|
|
68
|
+
input: t.expected,
|
|
69
|
+
expected: t.input
|
|
70
|
+
})).forEach((t)=>assertTab(t, true));
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "toggleList", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return toggleList;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
12
|
+
const _platelist = require("@udecode/plate-list");
|
|
13
|
+
const _constants = require("../../../internal/constants");
|
|
14
|
+
const _misc = require("../../../internal/misc");
|
|
15
|
+
const _queries = require("../../../internal/queries");
|
|
16
|
+
const _transforms = require("../../../internal/transforms");
|
|
17
|
+
const _unwrapList = require("./unwrapList");
|
|
18
|
+
const listTypes = [
|
|
19
|
+
_richtexttypes.BLOCKS.UL_LIST,
|
|
20
|
+
_richtexttypes.BLOCKS.OL_LIST
|
|
21
|
+
];
|
|
22
|
+
const toggleList = (editor, { type })=>(0, _misc.withoutNormalizing)(editor, ()=>{
|
|
23
|
+
if (!editor.selection) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if ((0, _queries.isRangeCollapsed)(editor.selection) || !(0, _queries.isRangeAcrossBlocks)(editor)) {
|
|
27
|
+
const res = (0, _platelist.getListItemEntry)(editor);
|
|
28
|
+
if (res) {
|
|
29
|
+
const { list } = res;
|
|
30
|
+
if (list[0].type !== type) {
|
|
31
|
+
(0, _transforms.setNodes)(editor, {
|
|
32
|
+
type
|
|
33
|
+
}, {
|
|
34
|
+
at: editor.selection,
|
|
35
|
+
match: (n)=>listTypes.includes(n.type),
|
|
36
|
+
mode: 'lowest'
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
(0, _unwrapList.unwrapList)(editor);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
const list = {
|
|
43
|
+
type,
|
|
44
|
+
children: [],
|
|
45
|
+
data: {}
|
|
46
|
+
};
|
|
47
|
+
(0, _transforms.wrapNodes)(editor, list);
|
|
48
|
+
const nodes = [
|
|
49
|
+
...(0, _queries.getNodeEntries)(editor, {
|
|
50
|
+
match: {
|
|
51
|
+
type: (0, _queries.getPluginType)(editor, _constants.ELEMENT_DEFAULT)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
];
|
|
55
|
+
const listItem = {
|
|
56
|
+
type: _richtexttypes.BLOCKS.LIST_ITEM,
|
|
57
|
+
children: [],
|
|
58
|
+
data: {}
|
|
59
|
+
};
|
|
60
|
+
for (const [, path] of nodes){
|
|
61
|
+
(0, _transforms.wrapNodes)(editor, listItem, {
|
|
62
|
+
at: path
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
const [startPoint, endPoint] = (0, _queries.getRangeEdges)(editor.selection);
|
|
68
|
+
const commonEntry = (0, _queries.getCommonNode)(editor, startPoint.path, endPoint.path);
|
|
69
|
+
if (listTypes.includes(commonEntry[0].type) || commonEntry[0].type === _richtexttypes.BLOCKS.LIST_ITEM) {
|
|
70
|
+
let listType = commonEntry[0].type;
|
|
71
|
+
if (commonEntry[0].type === _richtexttypes.BLOCKS.LIST_ITEM) {
|
|
72
|
+
listType = ((0, _queries.getParentNode)(editor, commonEntry[1])?.[0])?.type;
|
|
73
|
+
}
|
|
74
|
+
if (listType !== type) {
|
|
75
|
+
const startList = (0, _queries.findNode)(editor, {
|
|
76
|
+
at: (0, _queries.getRangeStart)(editor.selection),
|
|
77
|
+
match: {
|
|
78
|
+
type: listTypes
|
|
79
|
+
},
|
|
80
|
+
mode: 'lowest'
|
|
81
|
+
});
|
|
82
|
+
const endList = (0, _queries.findNode)(editor, {
|
|
83
|
+
at: (0, _queries.getRangeEnd)(editor.selection),
|
|
84
|
+
match: {
|
|
85
|
+
type: listTypes
|
|
86
|
+
},
|
|
87
|
+
mode: 'lowest'
|
|
88
|
+
});
|
|
89
|
+
if (!startList || !endList) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const rangeLength = Math.min(startList[1].length, endList[1].length);
|
|
93
|
+
(0, _transforms.setNodes)(editor, {
|
|
94
|
+
type
|
|
95
|
+
}, {
|
|
96
|
+
at: editor.selection,
|
|
97
|
+
match: (n, path)=>listTypes.includes(n.type) && path.length >= rangeLength,
|
|
98
|
+
mode: 'all'
|
|
99
|
+
});
|
|
100
|
+
} else {
|
|
101
|
+
(0, _unwrapList.unwrapList)(editor);
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
const rootPathLength = commonEntry[1].length;
|
|
105
|
+
const nodes = Array.from((0, _queries.getNodeEntries)(editor, {
|
|
106
|
+
mode: 'all'
|
|
107
|
+
})).filter(([, path])=>path.length === rootPathLength + 1).reverse();
|
|
108
|
+
nodes.forEach((n)=>{
|
|
109
|
+
if (listTypes.includes(n[0].type)) {
|
|
110
|
+
(0, _transforms.setNodes)(editor, {
|
|
111
|
+
type
|
|
112
|
+
}, {
|
|
113
|
+
at: n[1]
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
(0, _transforms.setNodes)(editor, {
|
|
117
|
+
type: (0, _queries.getPluginType)(editor, _platelist.ELEMENT_LIC)
|
|
118
|
+
}, {
|
|
119
|
+
at: n[1]
|
|
120
|
+
});
|
|
121
|
+
const listItem = {
|
|
122
|
+
type: _richtexttypes.BLOCKS.LIST_ITEM,
|
|
123
|
+
children: [],
|
|
124
|
+
data: {}
|
|
125
|
+
};
|
|
126
|
+
(0, _transforms.wrapNodes)(editor, listItem, {
|
|
127
|
+
at: n[1]
|
|
128
|
+
});
|
|
129
|
+
const list = {
|
|
130
|
+
type,
|
|
131
|
+
children: [],
|
|
132
|
+
data: {}
|
|
133
|
+
};
|
|
134
|
+
(0, _transforms.wrapNodes)(editor, list, {
|
|
135
|
+
at: n[1]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
6
|
+
const _testutils = require("../../../test-utils");
|
|
7
|
+
const _toggleList = require("./toggleList");
|
|
8
|
+
describe('toggle on', ()=>{
|
|
9
|
+
it('should turn a p to list', ()=>{
|
|
10
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hp", null, "1", (0, _testutils.jsx)("cursor", null)));
|
|
11
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1", (0, _testutils.jsx)("cursor", null)))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
12
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
13
|
+
input
|
|
14
|
+
});
|
|
15
|
+
(0, _toggleList.toggleList)(editor, {
|
|
16
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
17
|
+
});
|
|
18
|
+
(0, _testutils.assertOutput)({
|
|
19
|
+
editor,
|
|
20
|
+
expected
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it('should turn a p with a selection to list', ()=>{
|
|
24
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hp", null, "Planetas ", (0, _testutils.jsx)("anchor", null), "mori in", (0, _testutils.jsx)("focus", null), " gandavum!"));
|
|
25
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "Planetas ", (0, _testutils.jsx)("anchor", null), "mori in", (0, _testutils.jsx)("focus", null), " gandavum!"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
26
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
27
|
+
input
|
|
28
|
+
});
|
|
29
|
+
(0, _toggleList.toggleList)(editor, {
|
|
30
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
31
|
+
});
|
|
32
|
+
(0, _testutils.assertOutput)({
|
|
33
|
+
editor,
|
|
34
|
+
expected
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it('should turn multiple p to list', ()=>{
|
|
38
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1"), (0, _testutils.jsx)("hp", null, "2"), (0, _testutils.jsx)("hp", null, "3", (0, _testutils.jsx)("focus", null)));
|
|
39
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "2")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "3", (0, _testutils.jsx)("focus", null)))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
40
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
41
|
+
input
|
|
42
|
+
});
|
|
43
|
+
(0, _toggleList.toggleList)(editor, {
|
|
44
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
45
|
+
});
|
|
46
|
+
(0, _testutils.assertOutput)({
|
|
47
|
+
editor,
|
|
48
|
+
expected
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe('toggle off', ()=>{
|
|
53
|
+
it('should split a simple list to two', ()=>{
|
|
54
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "2", (0, _testutils.jsx)("cursor", null))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "3"))));
|
|
55
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"))), (0, _testutils.jsx)("hp", null, "2", (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "3"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
56
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
57
|
+
input
|
|
58
|
+
});
|
|
59
|
+
(0, _toggleList.toggleList)(editor, {
|
|
60
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
61
|
+
});
|
|
62
|
+
(0, _testutils.assertOutput)({
|
|
63
|
+
editor,
|
|
64
|
+
expected
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
it('should split a nested list', ()=>{
|
|
68
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "12", (0, _testutils.jsx)("cursor", null))), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "13"))))));
|
|
69
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11"))))), (0, _testutils.jsx)("hp", null, "12", (0, _testutils.jsx)("cursor", null)), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "13"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
70
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
71
|
+
input
|
|
72
|
+
});
|
|
73
|
+
(0, _toggleList.toggleList)(editor, {
|
|
74
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
75
|
+
});
|
|
76
|
+
(0, _testutils.assertOutput)({
|
|
77
|
+
editor,
|
|
78
|
+
expected
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it('should turn a list to multiple p', ()=>{
|
|
82
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "2")), (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "3", (0, _testutils.jsx)("focus", null)))));
|
|
83
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1"), (0, _testutils.jsx)("hp", null, "2"), (0, _testutils.jsx)("hp", null, "3", (0, _testutils.jsx)("focus", null)));
|
|
84
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
85
|
+
input
|
|
86
|
+
});
|
|
87
|
+
(0, _toggleList.toggleList)(editor, {
|
|
88
|
+
type: _richtexttypes.BLOCKS.UL_LIST
|
|
89
|
+
});
|
|
90
|
+
(0, _testutils.assertOutput)({
|
|
91
|
+
editor,
|
|
92
|
+
expected
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('toggle over', ()=>{
|
|
97
|
+
it('should toggle different list types', ()=>{
|
|
98
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1", (0, _testutils.jsx)("cursor", null)))));
|
|
99
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hol", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
100
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
101
|
+
input
|
|
102
|
+
});
|
|
103
|
+
(0, _toggleList.toggleList)(editor, {
|
|
104
|
+
type: _richtexttypes.BLOCKS.OL_LIST
|
|
105
|
+
});
|
|
106
|
+
(0, _testutils.assertOutput)({
|
|
107
|
+
editor,
|
|
108
|
+
expected
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
it('should only toggle the nested list', ()=>{
|
|
112
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11", (0, _testutils.jsx)("cursor", null)))))));
|
|
113
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "1"), (0, _testutils.jsx)("hol", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11", (0, _testutils.jsx)("cursor", null)))))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
114
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
115
|
+
input
|
|
116
|
+
});
|
|
117
|
+
(0, _toggleList.toggleList)(editor, {
|
|
118
|
+
type: _richtexttypes.BLOCKS.OL_LIST
|
|
119
|
+
});
|
|
120
|
+
(0, _testutils.assertOutput)({
|
|
121
|
+
editor,
|
|
122
|
+
expected
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
it('should only toggle everything that is selected', ()=>{
|
|
126
|
+
const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1"), (0, _testutils.jsx)("hul", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11", (0, _testutils.jsx)("focus", null)))))));
|
|
127
|
+
const expected = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hol", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("anchor", null), "1"), (0, _testutils.jsx)("hol", null, (0, _testutils.jsx)("hli", null, (0, _testutils.jsx)("hp", null, "11", (0, _testutils.jsx)("focus", null)))))), (0, _testutils.jsx)("hp", null, (0, _testutils.jsx)("htext", null)));
|
|
128
|
+
const { editor } = (0, _testutils.createTestEditor)({
|
|
129
|
+
input
|
|
130
|
+
});
|
|
131
|
+
(0, _toggleList.toggleList)(editor, {
|
|
132
|
+
type: _richtexttypes.BLOCKS.OL_LIST
|
|
133
|
+
});
|
|
134
|
+
(0, _testutils.assertOutput)({
|
|
135
|
+
editor,
|
|
136
|
+
expected
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "unwrapList", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return unwrapList;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
12
|
+
const _internal = require("../../../internal");
|
|
13
|
+
const _queries = require("../../../internal/queries");
|
|
14
|
+
const _transforms = require("../../../internal/transforms");
|
|
15
|
+
function hasUnliftedListItems(editor, at) {
|
|
16
|
+
return (0, _queries.getNodeEntries)(editor, {
|
|
17
|
+
at,
|
|
18
|
+
match: (node, path)=>(0, _queries.isElement)(node) && node.type === _richtexttypes.BLOCKS.LIST_ITEM && path.length >= 2
|
|
19
|
+
}).next().done;
|
|
20
|
+
}
|
|
21
|
+
const unwrapList = (editor, { at } = {})=>{
|
|
22
|
+
(0, _internal.withoutNormalizing)(editor, ()=>{
|
|
23
|
+
do {
|
|
24
|
+
(0, _transforms.liftNodes)(editor, {
|
|
25
|
+
at,
|
|
26
|
+
match: (node)=>(0, _queries.isElement)(node) && node.type === _richtexttypes.BLOCKS.LIST_ITEM,
|
|
27
|
+
mode: 'lowest'
|
|
28
|
+
});
|
|
29
|
+
}while (!hasUnliftedListItems(editor, at))
|
|
30
|
+
(0, _transforms.unwrapNodes)(editor, {
|
|
31
|
+
at,
|
|
32
|
+
match: {
|
|
33
|
+
type: _richtexttypes.BLOCKS.LIST_ITEM
|
|
34
|
+
},
|
|
35
|
+
split: false
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
hasListAsDirectParent: function() {
|
|
13
|
+
return hasListAsDirectParent;
|
|
14
|
+
},
|
|
15
|
+
normalizeOrphanedListItem: function() {
|
|
16
|
+
return normalizeOrphanedListItem;
|
|
17
|
+
},
|
|
18
|
+
isNonEmptyListItem: function() {
|
|
19
|
+
return isNonEmptyListItem;
|
|
20
|
+
},
|
|
21
|
+
firstNodeIsNotList: function() {
|
|
22
|
+
return firstNodeIsNotList;
|
|
23
|
+
},
|
|
24
|
+
insertParagraphAsChild: function() {
|
|
25
|
+
return insertParagraphAsChild;
|
|
26
|
+
},
|
|
27
|
+
replaceNodeWithListItems: function() {
|
|
28
|
+
return replaceNodeWithListItems;
|
|
29
|
+
},
|
|
30
|
+
isListTypeActive: function() {
|
|
31
|
+
return isListTypeActive;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
35
|
+
const _queries = require("../../internal/queries");
|
|
36
|
+
const _transforms = require("../../internal/transforms");
|
|
37
|
+
const isList = (node)=>[
|
|
38
|
+
_richtexttypes.BLOCKS.OL_LIST,
|
|
39
|
+
_richtexttypes.BLOCKS.UL_LIST
|
|
40
|
+
].includes(node.type);
|
|
41
|
+
const hasListAsDirectParent = (editor, [, path])=>{
|
|
42
|
+
const [parentNode] = (0, _queries.getParentNode)(editor, path) || [];
|
|
43
|
+
return isList(parentNode);
|
|
44
|
+
};
|
|
45
|
+
const getNearestListAncestor = (editor, path)=>{
|
|
46
|
+
return (0, _queries.getAboveNode)(editor, {
|
|
47
|
+
at: path,
|
|
48
|
+
mode: 'lowest',
|
|
49
|
+
match: isList
|
|
50
|
+
}) || [];
|
|
51
|
+
};
|
|
52
|
+
const normalizeOrphanedListItem = (editor, [, path])=>{
|
|
53
|
+
const [parentList] = getNearestListAncestor(editor, path);
|
|
54
|
+
const parentListType = parentList?.type;
|
|
55
|
+
(0, _transforms.wrapNodes)(editor, {
|
|
56
|
+
type: parentListType || _richtexttypes.BLOCKS.UL_LIST,
|
|
57
|
+
children: [],
|
|
58
|
+
data: {}
|
|
59
|
+
}, {
|
|
60
|
+
at: path
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const isNonEmptyListItem = (_, entry)=>{
|
|
64
|
+
const listItemChildren = (0, _queries.getChildren)(entry);
|
|
65
|
+
return listItemChildren.length !== 0;
|
|
66
|
+
};
|
|
67
|
+
const firstNodeIsNotList = (_editor, [node])=>{
|
|
68
|
+
if (node.children.length === 1) {
|
|
69
|
+
const firstNode = node.children[0];
|
|
70
|
+
return !(0, _queries.isText)(firstNode) && !isList(firstNode);
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
const insertParagraphAsChild = (editor, [, path])=>{
|
|
75
|
+
(0, _transforms.insertNodes)(editor, [
|
|
76
|
+
{
|
|
77
|
+
type: _richtexttypes.BLOCKS.PARAGRAPH,
|
|
78
|
+
data: {},
|
|
79
|
+
children: [
|
|
80
|
+
{
|
|
81
|
+
text: ''
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
], {
|
|
86
|
+
at: path.concat([
|
|
87
|
+
0
|
|
88
|
+
])
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const replaceNodeWithListItems = (editor, entry)=>{
|
|
92
|
+
const [node, path] = entry;
|
|
93
|
+
(0, _transforms.removeNodes)(editor, {
|
|
94
|
+
at: path
|
|
95
|
+
});
|
|
96
|
+
(0, _transforms.insertNodes)(editor, node.children[0].children, {
|
|
97
|
+
at: path
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
const isListTypeActive = (editor, type)=>{
|
|
101
|
+
const { selection } = editor;
|
|
102
|
+
if (!selection) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if ((0, _queries.isRangeExpanded)(selection)) {
|
|
106
|
+
const [start, end] = (0, _queries.getRangeEdges)(selection);
|
|
107
|
+
const node = (0, _queries.getCommonNode)(editor, start.path, end.path);
|
|
108
|
+
if (node[0].type === type) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const listNode = (0, _queries.getBlockAbove)(editor, {
|
|
113
|
+
match: {
|
|
114
|
+
type: [
|
|
115
|
+
_richtexttypes.BLOCKS.OL_LIST,
|
|
116
|
+
_richtexttypes.BLOCKS.UL_LIST
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
mode: 'lowest'
|
|
120
|
+
});
|
|
121
|
+
return listNode?.[0].type === type;
|
|
122
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "withList", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return withList;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
12
|
+
const _platelist = require("@udecode/plate-list");
|
|
13
|
+
const _insertListBreak = require("./insertListBreak");
|
|
14
|
+
const _insertListFragment = require("./insertListFragment");
|
|
15
|
+
const validLiChildrenTypes = _richtexttypes.LIST_ITEM_BLOCKS;
|
|
16
|
+
const withList = (editor)=>{
|
|
17
|
+
const { deleteForward , deleteFragment } = editor;
|
|
18
|
+
editor.deleteForward = (unit)=>{
|
|
19
|
+
if ((0, _platelist.deleteForwardList)(editor)) return;
|
|
20
|
+
deleteForward(unit);
|
|
21
|
+
};
|
|
22
|
+
editor.deleteFragment = ()=>{
|
|
23
|
+
if ((0, _platelist.deleteFragmentList)(editor)) return;
|
|
24
|
+
deleteFragment();
|
|
25
|
+
};
|
|
26
|
+
editor.insertBreak = (0, _insertListBreak.insertListBreak)(editor);
|
|
27
|
+
editor.insertFragment = (0, _insertListFragment.insertListFragment)(editor);
|
|
28
|
+
editor.normalizeNode = (0, _platelist.normalizeList)(editor, {
|
|
29
|
+
validLiChildrenTypes
|
|
30
|
+
});
|
|
31
|
+
return editor;
|
|
32
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
ToolbarBoldButton: function() {
|
|
13
|
+
return ToolbarBoldButton;
|
|
14
|
+
},
|
|
15
|
+
Bold: function() {
|
|
16
|
+
return Bold;
|
|
17
|
+
},
|
|
18
|
+
createBoldPlugin: function() {
|
|
19
|
+
return createBoldPlugin;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _react = _interop_require_wildcard(require("react"));
|
|
23
|
+
const _f36icons = require("@contentful/f36-icons");
|
|
24
|
+
const _richtexttypes = require("@contentful/rich-text-types");
|
|
25
|
+
const _platebasicmarks = require("@udecode/plate-basic-marks");
|
|
26
|
+
const _emotion = require("emotion");
|
|
27
|
+
const _queries = require("../../internal/queries");
|
|
28
|
+
const _MarkToolbarButton = require("./components/MarkToolbarButton");
|
|
29
|
+
const _helpers = require("./helpers");
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
31
|
+
if (typeof WeakMap !== "function") return null;
|
|
32
|
+
var cacheBabelInterop = new WeakMap();
|
|
33
|
+
var cacheNodeInterop = new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
35
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
+
})(nodeInterop);
|
|
37
|
+
}
|
|
38
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
39
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
+
return {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
+
if (cache && cache.has(obj)) {
|
|
49
|
+
return cache.get(obj);
|
|
50
|
+
}
|
|
51
|
+
var newObj = {};
|
|
52
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
|
+
for(var key in obj){
|
|
54
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
+
if (desc && (desc.get || desc.set)) {
|
|
57
|
+
Object.defineProperty(newObj, key, desc);
|
|
58
|
+
} else {
|
|
59
|
+
newObj[key] = obj[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
newObj.default = obj;
|
|
64
|
+
if (cache) {
|
|
65
|
+
cache.set(obj, newObj);
|
|
66
|
+
}
|
|
67
|
+
return newObj;
|
|
68
|
+
}
|
|
69
|
+
const ToolbarBoldButton = (0, _MarkToolbarButton.createMarkToolbarButton)({
|
|
70
|
+
title: 'Bold',
|
|
71
|
+
mark: _richtexttypes.MARKS.BOLD,
|
|
72
|
+
icon: _react.createElement(_f36icons.FormatBoldIcon, null)
|
|
73
|
+
});
|
|
74
|
+
const styles = {
|
|
75
|
+
bold: (0, _emotion.css)({
|
|
76
|
+
fontWeight: 600
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
function Bold(props) {
|
|
80
|
+
return _react.createElement("strong", {
|
|
81
|
+
...props.attributes,
|
|
82
|
+
className: styles.bold
|
|
83
|
+
}, props.children);
|
|
84
|
+
}
|
|
85
|
+
const isGoogleBoldWrapper = (el)=>el.id.startsWith('docs-internal-guid') && el.nodeName === 'B';
|
|
86
|
+
const createBoldPlugin = ()=>(0, _platebasicmarks.createBoldPlugin)({
|
|
87
|
+
type: _richtexttypes.MARKS.BOLD,
|
|
88
|
+
component: Bold,
|
|
89
|
+
options: {
|
|
90
|
+
hotkey: [
|
|
91
|
+
'mod+b'
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
handlers: {
|
|
95
|
+
onKeyDown: (0, _helpers.buildMarkEventHandler)(_richtexttypes.MARKS.BOLD)
|
|
96
|
+
},
|
|
97
|
+
deserializeHtml: {
|
|
98
|
+
rules: [
|
|
99
|
+
{
|
|
100
|
+
validNodeName: [
|
|
101
|
+
'STRONG',
|
|
102
|
+
'B'
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
validStyle: {
|
|
107
|
+
fontWeight: [
|
|
108
|
+
'600',
|
|
109
|
+
'700',
|
|
110
|
+
'bold'
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
query: (el)=>{
|
|
116
|
+
return !isGoogleBoldWrapper(el) && !(0, _queries.someHtmlElement)(el, (node)=>node.style.fontWeight === 'normal');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|