@payloadcms/richtext-lexical 3.0.0-beta.134 → 3.0.0-beta.135
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/exports/client/Field-KKSJXHR7.js +2 -0
- package/dist/exports/client/Field-KKSJXHR7.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-QPPOQTHD.js +2 -0
- package/dist/exports/client/{chunk-OOBB5GCO.js.map → chunk-QPPOQTHD.js.map} +3 -3
- package/dist/exports/client/index.js +15 -13
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/ast/mdx.d.ts +7 -0
- package/dist/exports/server/ast/mdx.d.ts.map +1 -0
- package/dist/exports/server/ast/mdx.js +37 -0
- package/dist/exports/server/ast/mdx.js.map +1 -0
- package/dist/exports/shared.d.ts +4 -0
- package/dist/exports/shared.d.ts.map +1 -0
- package/dist/exports/shared.js +4 -0
- package/dist/exports/shared.js.map +1 -0
- package/dist/features/blocks/client/index.d.ts +1 -5
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +138 -154
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdownTransformer.d.ts +16 -0
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdownTransformer.js +144 -0
- package/dist/features/blocks/client/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/client/plugin/index.d.ts +1 -2
- package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +1 -2
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +5 -8
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts +22 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js +136 -0
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts +22 -0
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/markdownTransformer.js +400 -0
- package/dist/features/blocks/server/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/client/index.d.ts.map +1 -1
- package/dist/features/experimental_table/client/index.js +2 -0
- package/dist/features/experimental_table/client/index.js.map +1 -1
- package/dist/features/experimental_table/markdownTransformer.d.ts +5 -0
- package/dist/features/experimental_table/markdownTransformer.d.ts.map +1 -0
- package/dist/features/experimental_table/markdownTransformer.js +127 -0
- package/dist/features/experimental_table/markdownTransformer.js.map +1 -0
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +2 -0
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/typesClient.d.ts +11 -2
- package/dist/features/typesClient.d.ts.map +1 -1
- package/dist/features/typesClient.js.map +1 -1
- package/dist/features/typesServer.d.ts +6 -2
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +68 -164
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +23 -14
- package/dist/field/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts +6 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +6 -0
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/client/sanitize.js +15 -2
- package/dist/lexical/config/client/sanitize.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +15 -2
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/nodes/index.d.ts +4 -0
- package/dist/lexical/nodes/index.d.ts.map +1 -1
- package/dist/lexical/nodes/index.js +8 -1
- package/dist/lexical/nodes/index.js.map +1 -1
- package/dist/lexical-proxy/@lexical-headless.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-headless.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-headless.js +2 -0
- package/dist/lexical-proxy/@lexical-headless.js.map +1 -0
- package/dist/lexical-proxy/@lexical-link.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-link.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-link.js +2 -0
- package/dist/lexical-proxy/@lexical-link.js.map +1 -0
- package/dist/lexical-proxy/@lexical-list.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-list.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-list.js +2 -0
- package/dist/lexical-proxy/@lexical-list.js.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-mark.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-mark.js +2 -0
- package/dist/lexical-proxy/@lexical-mark.js.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-markdown.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-markdown.js +2 -0
- package/dist/lexical-proxy/@lexical-markdown.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoEmbedPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoFocusPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalAutoLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalBlockWithAlignableContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCharacterLimitPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCheckListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClearEditorPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalClickableLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalCollaborationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalComposerContext.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContentEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalContextMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDecoratorBlockNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalDraggableBlockPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalEditorRefPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalErrorBoundary.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHashtagPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHistoryPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRuleNode.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalHorizontalRulePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalLinkPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalListPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalMarkdownShortcutPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNestedComposer.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeEventPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalNodeMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalOnChangePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalPlainTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalRichTextPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTabIndentationPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContents.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTableOfContentsPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTablePlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTreeView.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js +2 -0
- package/dist/lexical-proxy/@lexical-react/LexicalTypeaheadMenuPlugin.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalEditable.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalIsTextContentEmpty.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalNodeSelection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalSubscription.js.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js +2 -0
- package/dist/lexical-proxy/@lexical-react/useLexicalTextEntity.js.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-rich-text.js +2 -0
- package/dist/lexical-proxy/@lexical-rich-text.js.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-selection.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-selection.js +2 -0
- package/dist/lexical-proxy/@lexical-selection.js.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts +2 -0
- package/dist/lexical-proxy/@lexical-utils.d.ts.map +1 -0
- package/dist/lexical-proxy/@lexical-utils.js +2 -0
- package/dist/lexical-proxy/@lexical-utils.js.map +1 -0
- package/dist/lexical-proxy/lexical.d.ts +2 -0
- package/dist/lexical-proxy/lexical.d.ts.map +1 -0
- package/dist/lexical-proxy/lexical.js +2 -0
- package/dist/lexical-proxy/lexical.js.map +1 -0
- package/dist/utilities/createClientFeature.d.ts +5 -0
- package/dist/utilities/createClientFeature.d.ts.map +1 -1
- package/dist/utilities/createClientFeature.js +6 -0
- package/dist/utilities/createClientFeature.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +3 -2
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts +52 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.d.ts.map +1 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +79 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts +12 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.d.ts.map +1 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js +125 -0
- package/dist/utilities/jsx/extractPropsFromJSXPropsString.js.map +1 -0
- package/dist/utilities/jsx/jsx.d.ts +26 -0
- package/dist/utilities/jsx/jsx.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.js +105 -0
- package/dist/utilities/jsx/jsx.js.map +1 -0
- package/dist/utilities/jsx/jsx.spec.d.ts +2 -0
- package/dist/utilities/jsx/jsx.spec.d.ts.map +1 -0
- package/dist/utilities/jsx/jsx.spec.js +142 -0
- package/dist/utilities/jsx/jsx.spec.js.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts +11 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.d.ts.map +1 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js +61 -0
- package/dist/utilities/jsx/lexicalMarkdownCopy.js.map +1 -0
- package/package.json +284 -7
- package/dist/exports/client/Field-S5G27AVI.js +0 -2
- package/dist/exports/client/Field-S5G27AVI.js.map +0 -7
- package/dist/exports/client/chunk-OOBB5GCO.js +0 -2
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { createHeadlessEditor } from '@lexical/headless';
|
|
2
|
+
import { $convertToMarkdownString } from '@lexical/markdown';
|
|
3
|
+
import { $parseSerializedNode } from 'lexical';
|
|
4
|
+
import { getEnabledNodesFromServerNodes } from '../../../lexical/nodes/index.js';
|
|
5
|
+
import { extractPropsFromJSXPropsString } from '../../../utilities/jsx/extractPropsFromJSXPropsString.js';
|
|
6
|
+
import { propsToJSXString } from '../../../utilities/jsx/jsx.js';
|
|
7
|
+
import { $convertFromMarkdownString } from '../../../utilities/jsx/lexicalMarkdownCopy.js';
|
|
8
|
+
import { linesFromStartToContentAndPropsString } from './linesFromMatchToContentAndPropsString.js';
|
|
9
|
+
import { $createServerBlockNode, $isServerBlockNode, ServerBlockNode } from './nodes/BlocksNode.js';
|
|
10
|
+
import { $createServerInlineBlockNode, $isServerInlineBlockNode, ServerInlineBlockNode } from './nodes/InlineBlocksNode.js';
|
|
11
|
+
export function createTagRegexes(tagName) {
|
|
12
|
+
const escapedTagName = tagName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
13
|
+
// Regex components
|
|
14
|
+
const openingTag = `<${escapedTagName}`;
|
|
15
|
+
const closingTag = `</${escapedTagName}`;
|
|
16
|
+
const optionalWhitespace = `\\s*`;
|
|
17
|
+
const mandatoryClosingBracket = `>`;
|
|
18
|
+
// Assembled regex patterns
|
|
19
|
+
const startPattern = `${openingTag}(?=\\s|>|$)` // Only match the tag name
|
|
20
|
+
;
|
|
21
|
+
const endPattern = `${closingTag}${optionalWhitespace}${mandatoryClosingBracket}`;
|
|
22
|
+
return {
|
|
23
|
+
regExpEnd: new RegExp(endPattern, 'i'),
|
|
24
|
+
regExpStart: new RegExp(startPattern, 'i')
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export const getBlockMarkdownTransformers = ({
|
|
28
|
+
blocks,
|
|
29
|
+
inlineBlocks
|
|
30
|
+
}) => {
|
|
31
|
+
if (!blocks?.length && !inlineBlocks?.length) {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
let transformers = [];
|
|
35
|
+
if (blocks?.length) {
|
|
36
|
+
for (const block of blocks) {
|
|
37
|
+
const transformer = getMarkdownTransformerForBlock(block, false);
|
|
38
|
+
if (transformer) {
|
|
39
|
+
transformers = transformers.concat(transformer);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (inlineBlocks?.length) {
|
|
44
|
+
for (const block of inlineBlocks) {
|
|
45
|
+
const transformer = getMarkdownTransformerForBlock(block, true);
|
|
46
|
+
if (transformer) {
|
|
47
|
+
transformers = transformers.concat(transformer);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return transformers;
|
|
52
|
+
};
|
|
53
|
+
function getMarkdownTransformerForBlock(block, isInlineBlock) {
|
|
54
|
+
if (!block.jsx) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const regex = createTagRegexes(block.slug);
|
|
58
|
+
const toReturn = [];
|
|
59
|
+
if (isInlineBlock) {
|
|
60
|
+
toReturn.push(({
|
|
61
|
+
allNodes,
|
|
62
|
+
allTransformers
|
|
63
|
+
}) => ({
|
|
64
|
+
type: 'text-match',
|
|
65
|
+
dependencies: [ServerInlineBlockNode],
|
|
66
|
+
export: node => {
|
|
67
|
+
if (!$isServerInlineBlockNode(node)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const nodeFields = node.getFields();
|
|
74
|
+
const lexicalToMarkdown = getLexicalToMarkdown(allNodes, allTransformers);
|
|
75
|
+
const exportResult = block.jsx.export({
|
|
76
|
+
fields: nodeFields,
|
|
77
|
+
lexicalToMarkdown
|
|
78
|
+
});
|
|
79
|
+
if (exportResult === false) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
if (typeof exportResult === 'string') {
|
|
83
|
+
return exportResult;
|
|
84
|
+
}
|
|
85
|
+
const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0;
|
|
86
|
+
const props = exportResult.props ?? {};
|
|
87
|
+
if (exportResult?.children?.length) {
|
|
88
|
+
return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({
|
|
89
|
+
props
|
|
90
|
+
}) : ''}>${exportResult.children}</${nodeFields.blockType}>`;
|
|
91
|
+
}
|
|
92
|
+
return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({
|
|
93
|
+
props
|
|
94
|
+
}) : ''}/>`;
|
|
95
|
+
},
|
|
96
|
+
getEndIndex: (node, match) => {
|
|
97
|
+
const {
|
|
98
|
+
endlineLastCharIndex
|
|
99
|
+
} = linesFromStartToContentAndPropsString({
|
|
100
|
+
isEndOptional: false,
|
|
101
|
+
lines: [node.getTextContent()],
|
|
102
|
+
regexpEndRegex: regex.regExpEnd,
|
|
103
|
+
startLineIndex: 0,
|
|
104
|
+
startMatch: match,
|
|
105
|
+
trimChildren: false
|
|
106
|
+
});
|
|
107
|
+
return endlineLastCharIndex;
|
|
108
|
+
},
|
|
109
|
+
importRegExp: block.jsx?.customStartRegex ?? regex.regExpStart,
|
|
110
|
+
regExp: /___ignoreignoreignore___/g,
|
|
111
|
+
replace(node, match) {
|
|
112
|
+
const {
|
|
113
|
+
content,
|
|
114
|
+
propsString
|
|
115
|
+
} = linesFromStartToContentAndPropsString({
|
|
116
|
+
isEndOptional: false,
|
|
117
|
+
lines: [node.getTextContent()],
|
|
118
|
+
regexpEndRegex: regex.regExpEnd,
|
|
119
|
+
startLineIndex: 0,
|
|
120
|
+
startMatch: {
|
|
121
|
+
...match,
|
|
122
|
+
index: 0
|
|
123
|
+
},
|
|
124
|
+
trimChildren: false
|
|
125
|
+
});
|
|
126
|
+
if (!block?.jsx?.import) {
|
|
127
|
+
// No multiline transformer handled this line successfully
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers);
|
|
131
|
+
const blockFields = block.jsx.import({
|
|
132
|
+
children: content,
|
|
133
|
+
closeMatch: null,
|
|
134
|
+
htmlToLexical: null,
|
|
135
|
+
markdownToLexical,
|
|
136
|
+
openMatch: match,
|
|
137
|
+
props: propsString ? extractPropsFromJSXPropsString({
|
|
138
|
+
propsString
|
|
139
|
+
}) : {}
|
|
140
|
+
});
|
|
141
|
+
if (blockFields === false) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const inlineBlockNode = $createServerInlineBlockNode({
|
|
145
|
+
blockType: block.slug,
|
|
146
|
+
...blockFields
|
|
147
|
+
});
|
|
148
|
+
node.replace(inlineBlockNode);
|
|
149
|
+
}
|
|
150
|
+
}));
|
|
151
|
+
return toReturn;
|
|
152
|
+
}
|
|
153
|
+
toReturn.push(({
|
|
154
|
+
allNodes,
|
|
155
|
+
allTransformers
|
|
156
|
+
}) => ({
|
|
157
|
+
dependencies: [ServerBlockNode],
|
|
158
|
+
export: node => {
|
|
159
|
+
if (!$isServerBlockNode(node)) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const nodeFields = node.getFields();
|
|
166
|
+
const lexicalToMarkdown = getLexicalToMarkdown(allNodes, allTransformers);
|
|
167
|
+
const exportResult = block.jsx.export({
|
|
168
|
+
fields: nodeFields,
|
|
169
|
+
lexicalToMarkdown
|
|
170
|
+
});
|
|
171
|
+
if (exportResult === false) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
if (typeof exportResult === 'string') {
|
|
175
|
+
return exportResult;
|
|
176
|
+
}
|
|
177
|
+
const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0;
|
|
178
|
+
const props = exportResult.props ?? {};
|
|
179
|
+
if (exportResult?.children?.length) {
|
|
180
|
+
const children = exportResult.children;
|
|
181
|
+
let sanitizedChildren = '';
|
|
182
|
+
// Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child
|
|
183
|
+
if (children.includes('\n')) {
|
|
184
|
+
for (const child of children.split('\n')) {
|
|
185
|
+
let sanitizedChild = '';
|
|
186
|
+
if (!block?.jsx?.doNotTrimChildren && child !== '') {
|
|
187
|
+
sanitizedChild = ' ';
|
|
188
|
+
}
|
|
189
|
+
sanitizedChild += child + '\n';
|
|
190
|
+
sanitizedChildren += sanitizedChild;
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
sanitizedChildren = (block?.jsx?.doNotTrimChildren ? '' : ' ') + children + '\n';
|
|
194
|
+
}
|
|
195
|
+
return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({
|
|
196
|
+
props
|
|
197
|
+
}) : ''}>\n${sanitizedChildren}</${nodeFields.blockType}>`;
|
|
198
|
+
}
|
|
199
|
+
return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({
|
|
200
|
+
props
|
|
201
|
+
}) : ''}/>`;
|
|
202
|
+
},
|
|
203
|
+
handleImportAfterStartMatch: block.jsx?.customEndRegex ? undefined : ({
|
|
204
|
+
lines,
|
|
205
|
+
rootNode,
|
|
206
|
+
startLineIndex,
|
|
207
|
+
startMatch,
|
|
208
|
+
transformer
|
|
209
|
+
}) => {
|
|
210
|
+
const regexpEndRegex = typeof transformer.regExpEnd === 'object' && 'regExp' in transformer.regExpEnd ? transformer.regExpEnd.regExp : transformer.regExpEnd;
|
|
211
|
+
const isEndOptional = transformer.regExpEnd && typeof transformer.regExpEnd === 'object' && 'optional' in transformer.regExpEnd ? transformer.regExpEnd.optional : !transformer.regExpEnd;
|
|
212
|
+
const {
|
|
213
|
+
afterEndLine,
|
|
214
|
+
beforeStartLine,
|
|
215
|
+
content: unsanitizedContent,
|
|
216
|
+
endLineIndex,
|
|
217
|
+
propsString
|
|
218
|
+
} = linesFromStartToContentAndPropsString({
|
|
219
|
+
isEndOptional,
|
|
220
|
+
lines,
|
|
221
|
+
regexpEndRegex,
|
|
222
|
+
startLineIndex,
|
|
223
|
+
startMatch,
|
|
224
|
+
trimChildren: false
|
|
225
|
+
});
|
|
226
|
+
let content = '';
|
|
227
|
+
if (block?.jsx?.doNotTrimChildren) {
|
|
228
|
+
content = unsanitizedContent.endsWith('\n') ? unsanitizedContent.slice(0, -1) : unsanitizedContent;
|
|
229
|
+
} else {
|
|
230
|
+
// Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child
|
|
231
|
+
if (unsanitizedContent.includes('\n')) {
|
|
232
|
+
const split = unsanitizedContent.split('\n');
|
|
233
|
+
let index = 0;
|
|
234
|
+
for (const child of split) {
|
|
235
|
+
index++;
|
|
236
|
+
if (child.startsWith(' ')) {
|
|
237
|
+
content += child.slice(2);
|
|
238
|
+
} else {
|
|
239
|
+
// If one child is misaligned, skip aligning completely, unless it's just empty
|
|
240
|
+
if (child === '') {
|
|
241
|
+
content += child;
|
|
242
|
+
} else {
|
|
243
|
+
content = unsanitizedContent.endsWith('\n') ? unsanitizedContent.slice(0, -1) : unsanitizedContent;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
content += index === split.length ? '' : '\n';
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
content = (!unsanitizedContent.startsWith(' ') ? unsanitizedContent : unsanitizedContent.slice(2)) + '\n';
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (!block?.jsx?.import) {
|
|
254
|
+
// No multiline transformer handled this line successfully
|
|
255
|
+
return [false, startLineIndex];
|
|
256
|
+
}
|
|
257
|
+
const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers);
|
|
258
|
+
const blockFields = block.jsx.import({
|
|
259
|
+
children: content,
|
|
260
|
+
closeMatch: null,
|
|
261
|
+
htmlToLexical: null,
|
|
262
|
+
markdownToLexical,
|
|
263
|
+
openMatch: startMatch,
|
|
264
|
+
props: propsString ? extractPropsFromJSXPropsString({
|
|
265
|
+
propsString
|
|
266
|
+
}) : {}
|
|
267
|
+
});
|
|
268
|
+
if (blockFields === false) {
|
|
269
|
+
return [false, startLineIndex];
|
|
270
|
+
}
|
|
271
|
+
const node = $createServerBlockNode({
|
|
272
|
+
blockType: block.slug,
|
|
273
|
+
...blockFields
|
|
274
|
+
});
|
|
275
|
+
if (node) {
|
|
276
|
+
// Now handle beforeStartLine and afterEndLine. If those are not empty, we need to add them as text nodes before and after the block node.
|
|
277
|
+
// However, those themselves can contain other markdown matches, so we need to parse them as well.
|
|
278
|
+
// Example where this is needed: "Hello <InlineCode>inline code</InlineCode> test."
|
|
279
|
+
let prevNodes = null;
|
|
280
|
+
let nextNodes = null;
|
|
281
|
+
// TODO: Might not need this prevNodes and nextNodes handling if inline nodes are handled by textmatch transformers
|
|
282
|
+
if (beforeStartLine?.length) {
|
|
283
|
+
prevNodes = markdownToLexical({
|
|
284
|
+
markdown: beforeStartLine
|
|
285
|
+
})?.root?.children ?? [];
|
|
286
|
+
if (prevNodes?.length) {
|
|
287
|
+
rootNode.append($parseSerializedNode(prevNodes[0]));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
rootNode.append(node);
|
|
291
|
+
if (afterEndLine?.length) {
|
|
292
|
+
nextNodes = markdownToLexical({
|
|
293
|
+
markdown: afterEndLine
|
|
294
|
+
})?.root?.children ?? [];
|
|
295
|
+
const lastChild = rootNode.getChildren()[rootNode.getChildren().length - 1];
|
|
296
|
+
const children = $parseSerializedNode(nextNodes[0])?.getChildren();
|
|
297
|
+
if (children?.length) {
|
|
298
|
+
for (const child of children) {
|
|
299
|
+
lastChild.append(child);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return [true, endLineIndex];
|
|
305
|
+
},
|
|
306
|
+
regExpEnd: block.jsx?.customEndRegex ?? regex.regExpEnd,
|
|
307
|
+
regExpStart: block.jsx?.customStartRegex ?? regex.regExpStart,
|
|
308
|
+
// This replace is ONLY run for ``` code blocks (so any blocks with custom start and end regexes). For others, we use the special JSX handling above:
|
|
309
|
+
type: 'multiline-element',
|
|
310
|
+
replace: (rootNode, children, openMatch, closeMatch, linesInBetween) => {
|
|
311
|
+
if (block?.jsx?.import) {
|
|
312
|
+
if (!linesInBetween) {
|
|
313
|
+
// convert children to linesInBetween
|
|
314
|
+
let line = '';
|
|
315
|
+
if (children) {
|
|
316
|
+
for (const child of children) {
|
|
317
|
+
line += child.getTextContent();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
linesInBetween = [line];
|
|
321
|
+
}
|
|
322
|
+
let childrenString = '';
|
|
323
|
+
if (block?.jsx?.doNotTrimChildren) {
|
|
324
|
+
// Do not trim, but remove empty lines
|
|
325
|
+
childrenString = linesInBetween.filter(line => line.trim().length > 0).join('\n');
|
|
326
|
+
} else {
|
|
327
|
+
childrenString = linesInBetween.join('\n').trim();
|
|
328
|
+
}
|
|
329
|
+
const propsString = openMatch?.length > 1 ? openMatch[1]?.trim() : null;
|
|
330
|
+
const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers);
|
|
331
|
+
const blockFields = block.jsx.import({
|
|
332
|
+
children: childrenString,
|
|
333
|
+
closeMatch: closeMatch,
|
|
334
|
+
htmlToLexical: null,
|
|
335
|
+
markdownToLexical,
|
|
336
|
+
openMatch: openMatch,
|
|
337
|
+
props: propsString ? extractPropsFromJSXPropsString({
|
|
338
|
+
propsString
|
|
339
|
+
}) : {}
|
|
340
|
+
});
|
|
341
|
+
if (blockFields === false) {
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
const node = $createServerBlockNode({
|
|
345
|
+
blockType: block.slug,
|
|
346
|
+
...blockFields
|
|
347
|
+
});
|
|
348
|
+
if (node) {
|
|
349
|
+
rootNode.append(node);
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
return false // Run next transformer
|
|
354
|
+
;
|
|
355
|
+
}
|
|
356
|
+
}));
|
|
357
|
+
return toReturn;
|
|
358
|
+
}
|
|
359
|
+
export function getMarkdownToLexical(allNodes, allTransformers) {
|
|
360
|
+
const markdownToLexical = ({
|
|
361
|
+
markdown
|
|
362
|
+
}) => {
|
|
363
|
+
const headlessEditor = createHeadlessEditor({
|
|
364
|
+
nodes: getEnabledNodesFromServerNodes({
|
|
365
|
+
nodes: allNodes
|
|
366
|
+
})
|
|
367
|
+
});
|
|
368
|
+
headlessEditor.update(() => {
|
|
369
|
+
$convertFromMarkdownString(markdown, allTransformers);
|
|
370
|
+
}, {
|
|
371
|
+
discrete: true
|
|
372
|
+
});
|
|
373
|
+
return headlessEditor.getEditorState().toJSON();
|
|
374
|
+
};
|
|
375
|
+
return markdownToLexical;
|
|
376
|
+
}
|
|
377
|
+
export function getLexicalToMarkdown(allNodes, allTransformers) {
|
|
378
|
+
const lexicalToMarkdown = ({
|
|
379
|
+
editorState
|
|
380
|
+
}) => {
|
|
381
|
+
const headlessEditor = createHeadlessEditor({
|
|
382
|
+
nodes: getEnabledNodesFromServerNodes({
|
|
383
|
+
nodes: allNodes
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
try {
|
|
387
|
+
headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState)) // This should commit the editor state immediately
|
|
388
|
+
;
|
|
389
|
+
} catch (e) {
|
|
390
|
+
console.error('getLexicalToMarkdown: ERROR parsing editor state', e);
|
|
391
|
+
}
|
|
392
|
+
let markdown = '';
|
|
393
|
+
headlessEditor.getEditorState().read(() => {
|
|
394
|
+
markdown = $convertToMarkdownString(allTransformers);
|
|
395
|
+
});
|
|
396
|
+
return markdown;
|
|
397
|
+
};
|
|
398
|
+
return lexicalToMarkdown;
|
|
399
|
+
}
|
|
400
|
+
//# sourceMappingURL=markdownTransformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["createHeadlessEditor","$convertToMarkdownString","$parseSerializedNode","getEnabledNodesFromServerNodes","extractPropsFromJSXPropsString","propsToJSXString","$convertFromMarkdownString","linesFromStartToContentAndPropsString","$createServerBlockNode","$isServerBlockNode","ServerBlockNode","$createServerInlineBlockNode","$isServerInlineBlockNode","ServerInlineBlockNode","createTagRegexes","tagName","escapedTagName","replace","openingTag","closingTag","optionalWhitespace","mandatoryClosingBracket","startPattern","endPattern","regExpEnd","RegExp","regExpStart","getBlockMarkdownTransformers","blocks","inlineBlocks","length","transformers","block","transformer","getMarkdownTransformerForBlock","concat","isInlineBlock","jsx","regex","slug","toReturn","push","allNodes","allTransformers","type","dependencies","export","node","getFields","blockType","toLowerCase","nodeFields","lexicalToMarkdown","getLexicalToMarkdown","exportResult","fields","hasProps","props","Object","keys","children","getEndIndex","match","endlineLastCharIndex","isEndOptional","lines","getTextContent","regexpEndRegex","startLineIndex","startMatch","trimChildren","importRegExp","customStartRegex","regExp","content","propsString","index","import","markdownToLexical","getMarkdownToLexical","blockFields","closeMatch","htmlToLexical","openMatch","inlineBlockNode","sanitizedChildren","includes","child","split","sanitizedChild","doNotTrimChildren","handleImportAfterStartMatch","customEndRegex","undefined","rootNode","optional","afterEndLine","beforeStartLine","unsanitizedContent","endLineIndex","endsWith","slice","startsWith","prevNodes","nextNodes","markdown","root","append","lastChild","getChildren","linesInBetween","line","childrenString","filter","trim","join","headlessEditor","nodes","update","discrete","getEditorState","toJSON","editorState","setEditorState","parseEditorState","e","console","error","read"],"sources":["../../../../src/features/blocks/server/markdownTransformer.ts"],"sourcesContent":["import type {\n MultilineElementTransformer,\n TextMatchTransformer,\n Transformer,\n} from '@lexical/markdown'\nimport type { ElementNode, SerializedEditorState, SerializedLexicalNode } from 'lexical'\nimport type { Block } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { $convertToMarkdownString } from '@lexical/markdown'\nimport { $parseSerializedNode } from 'lexical'\n\nimport type { NodeWithHooks } from '../../typesServer.js'\n\nimport { getEnabledNodesFromServerNodes } from '../../../lexical/nodes/index.js'\nimport { extractPropsFromJSXPropsString } from '../../../utilities/jsx/extractPropsFromJSXPropsString.js'\nimport { propsToJSXString } from '../../../utilities/jsx/jsx.js'\nimport { $convertFromMarkdownString } from '../../../utilities/jsx/lexicalMarkdownCopy.js'\nimport { linesFromStartToContentAndPropsString } from './linesFromMatchToContentAndPropsString.js'\nimport { $createServerBlockNode, $isServerBlockNode, ServerBlockNode } from './nodes/BlocksNode.js'\nimport {\n $createServerInlineBlockNode,\n $isServerInlineBlockNode,\n ServerInlineBlockNode,\n} from './nodes/InlineBlocksNode.js'\n\nexport function createTagRegexes(tagName: string) {\n const escapedTagName = tagName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n // Regex components\n const openingTag = `<${escapedTagName}`\n const closingTag = `</${escapedTagName}`\n const optionalWhitespace = `\\\\s*`\n const mandatoryClosingBracket = `>`\n\n // Assembled regex patterns\n const startPattern = `${openingTag}(?=\\\\s|>|$)` // Only match the tag name\n const endPattern = `${closingTag}${optionalWhitespace}${mandatoryClosingBracket}`\n\n return {\n regExpEnd: new RegExp(endPattern, 'i'),\n regExpStart: new RegExp(startPattern, 'i'),\n }\n}\nexport const getBlockMarkdownTransformers = ({\n blocks,\n inlineBlocks,\n}: {\n blocks: Block[]\n inlineBlocks: Block[]\n}): ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n}) => MultilineElementTransformer | TextMatchTransformer)[] => {\n if (!blocks?.length && !inlineBlocks?.length) {\n return []\n }\n\n let transformers: ((props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer)[] = []\n\n if (blocks?.length) {\n for (const block of blocks) {\n const transformer = getMarkdownTransformerForBlock(block, false)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n if (inlineBlocks?.length) {\n for (const block of inlineBlocks) {\n const transformer = getMarkdownTransformerForBlock(block, true)\n\n if (transformer) {\n transformers = transformers.concat(transformer)\n }\n }\n }\n\n return transformers\n}\n\nfunction getMarkdownTransformerForBlock(\n block: Block,\n isInlineBlock: boolean,\n): Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n> | null {\n if (!block.jsx) {\n return null\n }\n const regex = createTagRegexes(block.slug)\n const toReturn: Array<\n (props: {\n allNodes: Array<NodeWithHooks>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer | TextMatchTransformer\n > = []\n\n if (isInlineBlock) {\n toReturn.push(({ allNodes, allTransformers }) => ({\n type: 'text-match',\n dependencies: [ServerInlineBlockNode],\n export: (node) => {\n if (!$isServerInlineBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(allNodes, allTransformers)\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>${exportResult.children}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n getEndIndex: (node, match) => {\n const { endlineLastCharIndex } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: match,\n trimChildren: false,\n })\n\n return endlineLastCharIndex\n },\n importRegExp: block.jsx?.customStartRegex ?? regex.regExpStart,\n regExp: /___ignoreignoreignore___/g,\n replace(node, match) {\n const { content, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines: [node.getTextContent()],\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: 0,\n startMatch: {\n ...match,\n index: 0,\n },\n trimChildren: false,\n })\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return\n }\n\n const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers)\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: match,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return\n }\n\n const inlineBlockNode = $createServerInlineBlockNode({\n blockType: block.slug,\n ...(blockFields as any),\n })\n\n node.replace(inlineBlockNode)\n },\n }))\n\n return toReturn\n }\n\n toReturn.push(({ allNodes, allTransformers }) => ({\n dependencies: [ServerBlockNode],\n export: (node) => {\n if (!$isServerBlockNode(node)) {\n return null\n }\n\n if (node.getFields()?.blockType?.toLowerCase() !== block.slug.toLowerCase()) {\n return null\n }\n\n const nodeFields = node.getFields()\n const lexicalToMarkdown = getLexicalToMarkdown(allNodes, allTransformers)\n\n const exportResult = block.jsx!.export({\n fields: nodeFields,\n lexicalToMarkdown,\n })\n if (exportResult === false) {\n return null\n }\n if (typeof exportResult === 'string') {\n return exportResult\n }\n\n const hasProps = exportResult.props && Object.keys(exportResult.props)?.length > 0\n const props = exportResult.props ?? {}\n\n if (exportResult?.children?.length) {\n const children = exportResult.children\n let sanitizedChildren = ''\n\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (children.includes('\\n')) {\n for (const child of children.split('\\n')) {\n let sanitizedChild = ''\n if (!block?.jsx?.doNotTrimChildren && child !== '') {\n sanitizedChild = ' '\n }\n sanitizedChild += child + '\\n'\n\n sanitizedChildren += sanitizedChild\n }\n } else {\n sanitizedChildren = (block?.jsx?.doNotTrimChildren ? '' : ' ') + children + '\\n'\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}>\\n${sanitizedChildren}</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${hasProps ? ' ' + propsToJSXString({ props }) : ''}/>`\n },\n handleImportAfterStartMatch: block.jsx?.customEndRegex\n ? undefined\n : ({ lines, rootNode, startLineIndex, startMatch, transformer }) => {\n const regexpEndRegex: RegExp | undefined =\n typeof transformer.regExpEnd === 'object' && 'regExp' in transformer.regExpEnd\n ? transformer.regExpEnd.regExp\n : transformer.regExpEnd\n\n const isEndOptional =\n transformer.regExpEnd &&\n typeof transformer.regExpEnd === 'object' &&\n 'optional' in transformer.regExpEnd\n ? transformer.regExpEnd.optional\n : !transformer.regExpEnd\n\n const {\n afterEndLine,\n beforeStartLine,\n content: unsanitizedContent,\n endLineIndex,\n propsString,\n } = linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren: false,\n })\n\n let content = ''\n\n if (block?.jsx?.doNotTrimChildren) {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n } else {\n // Ensure it has a leftpad of at least 2 spaces. The data is saved without those spaces, so we can just blindly add it to every child\n if (unsanitizedContent.includes('\\n')) {\n const split = unsanitizedContent.split('\\n')\n let index = 0\n for (const child of split) {\n index++\n\n if (child.startsWith(' ')) {\n content += child.slice(2)\n } else {\n // If one child is misaligned, skip aligning completely, unless it's just empty\n if (child === '') {\n content += child\n } else {\n content = unsanitizedContent.endsWith('\\n')\n ? unsanitizedContent.slice(0, -1)\n : unsanitizedContent\n break\n }\n }\n\n content += index === split.length ? '' : '\\n'\n }\n } else {\n content =\n (!unsanitizedContent.startsWith(' ')\n ? unsanitizedContent\n : unsanitizedContent.slice(2)) + '\\n'\n }\n }\n\n if (!block?.jsx?.import) {\n // No multiline transformer handled this line successfully\n return [false, startLineIndex]\n }\n\n const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers)\n\n const blockFields = block.jsx.import({\n children: content,\n closeMatch: null,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: startMatch,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return [false, startLineIndex]\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n // Now handle beforeStartLine and afterEndLine. If those are not empty, we need to add them as text nodes before and after the block node.\n // However, those themselves can contain other markdown matches, so we need to parse them as well.\n // Example where this is needed: \"Hello <InlineCode>inline code</InlineCode> test.\"\n let prevNodes: null | SerializedLexicalNode[] = null\n let nextNodes: null | SerializedLexicalNode[] = null\n // TODO: Might not need this prevNodes and nextNodes handling if inline nodes are handled by textmatch transformers\n\n if (beforeStartLine?.length) {\n prevNodes = markdownToLexical({ markdown: beforeStartLine })?.root?.children ?? []\n\n if (prevNodes?.length) {\n rootNode.append($parseSerializedNode(prevNodes[0]))\n }\n }\n\n rootNode.append(node)\n\n if (afterEndLine?.length) {\n nextNodes = markdownToLexical({ markdown: afterEndLine })?.root?.children ?? []\n const lastChild = rootNode.getChildren()[rootNode.getChildren().length - 1]\n\n const children = ($parseSerializedNode(nextNodes[0]) as ElementNode)?.getChildren()\n if (children?.length) {\n for (const child of children) {\n ;(lastChild as ElementNode).append(child)\n }\n }\n }\n }\n\n return [true, endLineIndex]\n },\n regExpEnd: block.jsx?.customEndRegex ?? regex.regExpEnd,\n regExpStart: block.jsx?.customStartRegex ?? regex.regExpStart,\n // This replace is ONLY run for ``` code blocks (so any blocks with custom start and end regexes). For others, we use the special JSX handling above:\n type: 'multiline-element',\n replace: (rootNode, children, openMatch, closeMatch, linesInBetween) => {\n if (block?.jsx?.import) {\n if (!linesInBetween) {\n // convert children to linesInBetween\n let line = ''\n if (children) {\n for (const child of children) {\n line += child.getTextContent()\n }\n }\n\n linesInBetween = [line]\n }\n\n let childrenString = ''\n if (block?.jsx?.doNotTrimChildren) {\n // Do not trim, but remove empty lines\n childrenString = linesInBetween.filter((line) => line.trim().length > 0).join('\\n')\n } else {\n childrenString = linesInBetween.join('\\n').trim()\n }\n\n const propsString: null | string = openMatch?.length > 1 ? openMatch[1]?.trim() : null\n\n const markdownToLexical = getMarkdownToLexical(allNodes, allTransformers)\n\n const blockFields = block.jsx.import({\n children: childrenString,\n closeMatch: closeMatch as RegExpMatchArray,\n htmlToLexical: null, // TODO\n markdownToLexical,\n openMatch: openMatch as RegExpMatchArray,\n props: propsString\n ? extractPropsFromJSXPropsString({\n propsString,\n })\n : {},\n })\n if (blockFields === false) {\n return false\n }\n\n const node = $createServerBlockNode({\n blockType: block.slug,\n ...blockFields,\n } as any)\n\n if (node) {\n rootNode.append(node)\n }\n\n return\n }\n return false // Run next transformer\n },\n }))\n\n return toReturn\n}\n\nexport function getMarkdownToLexical(\n allNodes: Array<NodeWithHooks>,\n allTransformers: Transformer[],\n): (args: { markdown: string }) => SerializedEditorState {\n const markdownToLexical = ({ markdown }: { markdown: string }): SerializedEditorState => {\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n })\n\n headlessEditor.update(\n () => {\n $convertFromMarkdownString(markdown, allTransformers)\n },\n { discrete: true },\n )\n\n return headlessEditor.getEditorState().toJSON()\n }\n return markdownToLexical\n}\n\nexport function getLexicalToMarkdown(\n allNodes: Array<NodeWithHooks>,\n allTransformers: Transformer[],\n): (args: { editorState: Record<string, any> }) => string {\n const lexicalToMarkdown = ({ editorState }: { editorState: Record<string, any> }): string => {\n const headlessEditor = createHeadlessEditor({\n nodes: getEnabledNodesFromServerNodes({\n nodes: allNodes,\n }),\n })\n\n try {\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState as any)) // This should commit the editor state immediately\n } catch (e) {\n console.error('getLexicalToMarkdown: ERROR parsing editor state', e)\n }\n\n let markdown: string = ''\n headlessEditor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(allTransformers)\n })\n\n return markdown\n }\n return lexicalToMarkdown\n}\n"],"mappings":"AAQA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,wBAAwB,QAAQ;AACzC,SAASC,oBAAoB,QAAQ;AAIrC,SAASC,8BAA8B,QAAQ;AAC/C,SAASC,8BAA8B,QAAQ;AAC/C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,qCAAqC,QAAQ;AACtD,SAASC,sBAAsB,EAAEC,kBAAkB,EAAEC,eAAe,QAAQ;AAC5E,SACEC,4BAA4B,EAC5BC,wBAAwB,EACxBC,qBAAqB,QAChB;AAEP,OAAO,SAASC,iBAAiBC,OAAe;EAC9C,MAAMC,cAAA,GAAiBD,OAAA,CAAQE,OAAO,CAAC,uBAAuB;EAE9D;EACA,MAAMC,UAAA,GAAa,IAAIF,cAAA,EAAgB;EACvC,MAAMG,UAAA,GAAa,KAAKH,cAAA,EAAgB;EACxC,MAAMI,kBAAA,GAAqB,MAAM;EACjC,MAAMC,uBAAA,GAA0B,GAAG;EAEnC;EACA,MAAMC,YAAA,GAAe,GAAGJ,UAAA,aAAuB,CAAC;EAAA;EAChD,MAAMK,UA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A,OAAOrD,iBAAA;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/experimental_table/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/experimental_table/client/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,kBAAkB,8EAmD7B,CAAA"}
|
|
@@ -5,11 +5,13 @@ import { TableIcon } from '../../../lexical/ui/icons/Table/index.js';
|
|
|
5
5
|
import { createClientFeature } from '../../../utilities/createClientFeature.js';
|
|
6
6
|
import { slashMenuBasicGroupWithItems } from '../../shared/slashMenu/basicGroup.js';
|
|
7
7
|
import { toolbarAddDropdownGroupWithItems } from '../../shared/toolbar/addDropdownGroup.js';
|
|
8
|
+
import { TableMarkdownTransformer } from '../markdownTransformer.js';
|
|
8
9
|
import { TableActionMenuPlugin } from './plugins/TableActionMenuPlugin/index.js';
|
|
9
10
|
import { TableCellResizerPlugin } from './plugins/TableCellResizerPlugin/index.js';
|
|
10
11
|
import { TableHoverActionsPlugin } from './plugins/TableHoverActionsPlugin/index.js';
|
|
11
12
|
import { OPEN_TABLE_DRAWER_COMMAND, TableContext, TablePlugin } from './plugins/TablePlugin/index.js';
|
|
12
13
|
export const TableFeatureClient = createClientFeature({
|
|
14
|
+
markdownTransformers: [TableMarkdownTransformer],
|
|
13
15
|
nodes: [TableNode, TableCellNode, TableRowNode],
|
|
14
16
|
plugins: [{
|
|
15
17
|
Component: TablePlugin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","TableIcon","createClientFeature","slashMenuBasicGroupWithItems","toolbarAddDropdownGroupWithItems","TableActionMenuPlugin","TableCellResizerPlugin","TableHoverActionsPlugin","OPEN_TABLE_DRAWER_COMMAND","TableContext","TablePlugin","TableFeatureClient","nodes","plugins","Component","position","providers","slashMenu","groups","Icon","key","keywords","label","onSelect","editor","dispatchCommand","toolbarFixed","ChildComponent"],"sources":["../../../../src/features/experimental_table/client/index.ts"],"sourcesContent":["'use client'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\n\nimport { TableIcon } from '../../../lexical/ui/icons/Table/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { slashMenuBasicGroupWithItems } from '../../shared/slashMenu/basicGroup.js'\nimport { toolbarAddDropdownGroupWithItems } from '../../shared/toolbar/addDropdownGroup.js'\nimport { TableActionMenuPlugin } from './plugins/TableActionMenuPlugin/index.js'\nimport { TableCellResizerPlugin } from './plugins/TableCellResizerPlugin/index.js'\nimport { TableHoverActionsPlugin } from './plugins/TableHoverActionsPlugin/index.js'\nimport {\n OPEN_TABLE_DRAWER_COMMAND,\n TableContext,\n TablePlugin,\n} from './plugins/TablePlugin/index.js'\n\nexport const TableFeatureClient = createClientFeature({\n nodes: [TableNode, TableCellNode, TableRowNode],\n plugins: [\n {\n Component: TablePlugin,\n position: 'normal',\n },\n {\n Component: TableCellResizerPlugin,\n position: 'normal',\n },\n {\n Component: TableActionMenuPlugin,\n position: 'floatingAnchorElem',\n },\n {\n Component: TableHoverActionsPlugin,\n position: 'floatingAnchorElem',\n },\n ],\n providers: [TableContext],\n slashMenu: {\n groups: [\n slashMenuBasicGroupWithItems([\n {\n Icon: TableIcon,\n key: 'table',\n keywords: ['table'],\n label: 'Table',\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OPEN_TABLE_DRAWER_COMMAND, {})\n },\n },\n ]),\n ],\n },\n toolbarFixed: {\n groups: [\n toolbarAddDropdownGroupWithItems([\n {\n ChildComponent: TableIcon,\n key: 'table',\n label: 'Table',\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OPEN_TABLE_DRAWER_COMMAND, {})\n },\n },\n ]),\n ],\n },\n})\n"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AAEvD,SAASC,SAAS,QAAQ;AAC1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,gCAAgC,QAAQ;AACjD,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,uBAAuB,QAAQ;AACxC,SACEC,yBAAyB,EACzBC,YAAY,EACZC,WAAW,QACN;AAEP,OAAO,MAAMC,kBAAA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["TableCellNode","TableNode","TableRowNode","TableIcon","createClientFeature","slashMenuBasicGroupWithItems","toolbarAddDropdownGroupWithItems","TableMarkdownTransformer","TableActionMenuPlugin","TableCellResizerPlugin","TableHoverActionsPlugin","OPEN_TABLE_DRAWER_COMMAND","TableContext","TablePlugin","TableFeatureClient","markdownTransformers","nodes","plugins","Component","position","providers","slashMenu","groups","Icon","key","keywords","label","onSelect","editor","dispatchCommand","toolbarFixed","ChildComponent"],"sources":["../../../../src/features/experimental_table/client/index.ts"],"sourcesContent":["'use client'\n\nimport { TableCellNode, TableNode, TableRowNode } from '@lexical/table'\n\nimport { TableIcon } from '../../../lexical/ui/icons/Table/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { slashMenuBasicGroupWithItems } from '../../shared/slashMenu/basicGroup.js'\nimport { toolbarAddDropdownGroupWithItems } from '../../shared/toolbar/addDropdownGroup.js'\nimport { TableMarkdownTransformer } from '../markdownTransformer.js'\nimport { TableActionMenuPlugin } from './plugins/TableActionMenuPlugin/index.js'\nimport { TableCellResizerPlugin } from './plugins/TableCellResizerPlugin/index.js'\nimport { TableHoverActionsPlugin } from './plugins/TableHoverActionsPlugin/index.js'\nimport {\n OPEN_TABLE_DRAWER_COMMAND,\n TableContext,\n TablePlugin,\n} from './plugins/TablePlugin/index.js'\n\nexport const TableFeatureClient = createClientFeature({\n markdownTransformers: [TableMarkdownTransformer],\n nodes: [TableNode, TableCellNode, TableRowNode],\n plugins: [\n {\n Component: TablePlugin,\n position: 'normal',\n },\n {\n Component: TableCellResizerPlugin,\n position: 'normal',\n },\n {\n Component: TableActionMenuPlugin,\n position: 'floatingAnchorElem',\n },\n {\n Component: TableHoverActionsPlugin,\n position: 'floatingAnchorElem',\n },\n ],\n providers: [TableContext],\n slashMenu: {\n groups: [\n slashMenuBasicGroupWithItems([\n {\n Icon: TableIcon,\n key: 'table',\n keywords: ['table'],\n label: 'Table',\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OPEN_TABLE_DRAWER_COMMAND, {})\n },\n },\n ]),\n ],\n },\n toolbarFixed: {\n groups: [\n toolbarAddDropdownGroupWithItems([\n {\n ChildComponent: TableIcon,\n key: 'table',\n label: 'Table',\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OPEN_TABLE_DRAWER_COMMAND, {})\n },\n },\n ]),\n ],\n },\n})\n"],"mappings":"AAAA;;AAEA,SAASA,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AAEvD,SAASC,SAAS,QAAQ;AAC1B,SAASC,mBAAmB,QAAQ;AACpC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,gCAAgC,QAAQ;AACjD,SAASC,wBAAwB,QAAQ;AACzC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,uBAAuB,QAAQ;AACxC,SACEC,yBAAyB,EACzBC,YAAY,EACZC,WAAW,QACN;AAEP,OAAO,MAAMC,kBAAA,GAAqBV,mBAAA,CAAoB;EACpDW,oBAAA,EAAsB,CAACR,wBAAA,CAAyB;EAChDS,KAAA,EAAO,CAACf,SAAA,EAAWD,aAAA,EAAeE,YAAA,CAAa;EAC/Ce,OAAA,EAAS,CACP;IACEC,SAAA,EAAWL,WAAA;IACXM,QAAA,EAAU;EACZ,GACA;IACED,SAAA,EAAWT,sBAAA;IACXU,QAAA,EAAU;EACZ,GACA;IACED,SAAA,EAAWV,qBAAA;IACXW,QAAA,EAAU;EACZ,GACA;IACED,SAAA,EAAWR,uBAAA;IACXS,QAAA,EAAU;EACZ,EACD;EACDC,SAAA,EAAW,CAACR,YAAA,CAAa;EACzBS,SAAA,EAAW;IACTC,MAAA,EAAQ,CACNjB,4BAAA,CAA6B,CAC3B;MACEkB,IAAA,EAAMpB,SAAA;MACNqB,GAAA,EAAK;MACLC,QAAA,EAAU,CAAC,QAAQ;MACnBC,KAAA,EAAO;MACPC,QAAA,EAAUA,CAAC;QAAEC;MAAM,CAAE;QACnBA,MAAA,CAAOC,eAAe,CAAClB,yBAAA,EAA2B,CAAC;MACrD;IACF,EACD;EAEL;EACAmB,YAAA,EAAc;IACZR,MAAA,EAAQ,CACNhB,gCAAA,CAAiC,CAC/B;MACEyB,cAAA,EAAgB5B,SAAA;MAChBqB,GAAA,EAAK;MACLE,KAAA,EAAO;MACPC,QAAA,EAAUA,CAAC;QAAEC;MAAM,CAAE;QACnBA,MAAA,CAAOC,eAAe,CAAClB,yBAAA,EAA2B,CAAC;MACrD;IACF,EACD;EAEL;AACF","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../src/features/experimental_table/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAuBxE,eAAO,MAAM,wBAAwB,EAAE,CAAC,KAAK,EAAE;IAC7C,eAAe,EAAE,WAAW,EAAE,CAAA;CAC/B,KAAK,kBA0HJ,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
|
|
2
|
+
import { $createTableCellNode, $createTableNode, $createTableRowNode, $isTableCellNode, $isTableNode, $isTableRowNode, TableCellHeaderStates, TableCellNode, TableNode, TableRowNode } from '@lexical/table';
|
|
3
|
+
import { $isParagraphNode, $isTextNode } from 'lexical';
|
|
4
|
+
// Very primitive table setup
|
|
5
|
+
const TABLE_ROW_REG_EXP = /^\|(.+)\|\s?$/;
|
|
6
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
|
7
|
+
const TABLE_ROW_DIVIDER_REG_EXP = /^(\| ?:?-*:? ?)+\|\s?$/;
|
|
8
|
+
export const TableMarkdownTransformer = ({
|
|
9
|
+
allTransformers
|
|
10
|
+
}) => ({
|
|
11
|
+
type: 'element',
|
|
12
|
+
dependencies: [TableNode, TableRowNode, TableCellNode],
|
|
13
|
+
export: node => {
|
|
14
|
+
if (!$isTableNode(node)) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const output = [];
|
|
18
|
+
for (const row of node.getChildren()) {
|
|
19
|
+
const rowOutput = [];
|
|
20
|
+
if (!$isTableRowNode(row)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
let isHeaderRow = false;
|
|
24
|
+
for (const cell of row.getChildren()) {
|
|
25
|
+
// It's TableCellNode, so it's just to make flow happy
|
|
26
|
+
if ($isTableCellNode(cell)) {
|
|
27
|
+
rowOutput.push($convertToMarkdownString(allTransformers, cell).replace(/\n/g, '\\n'));
|
|
28
|
+
if (cell.__headerState === TableCellHeaderStates.ROW) {
|
|
29
|
+
isHeaderRow = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
output.push(`| ${rowOutput.join(' | ')} |`);
|
|
34
|
+
if (isHeaderRow) {
|
|
35
|
+
output.push(`| ${rowOutput.map(_ => '---').join(' | ')} |`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return output.join('\n');
|
|
39
|
+
},
|
|
40
|
+
regExp: TABLE_ROW_REG_EXP,
|
|
41
|
+
replace: (parentNode, _1, match) => {
|
|
42
|
+
// Header row
|
|
43
|
+
if (TABLE_ROW_DIVIDER_REG_EXP.test(match[0])) {
|
|
44
|
+
const table = parentNode.getPreviousSibling();
|
|
45
|
+
if (!table || !$isTableNode(table)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const rows = table.getChildren();
|
|
49
|
+
const lastRow = rows[rows.length - 1];
|
|
50
|
+
if (!lastRow || !$isTableRowNode(lastRow)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Add header state to row cells
|
|
54
|
+
lastRow.getChildren().forEach(cell => {
|
|
55
|
+
if (!$isTableCellNode(cell)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
cell.setHeaderStyles(TableCellHeaderStates.ROW, TableCellHeaderStates.ROW);
|
|
59
|
+
});
|
|
60
|
+
// Remove line
|
|
61
|
+
parentNode.remove();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const matchCells = mapToTableCells(match[0], allTransformers);
|
|
65
|
+
if (matchCells == null) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const rows = [matchCells];
|
|
69
|
+
let sibling = parentNode.getPreviousSibling();
|
|
70
|
+
let maxCells = matchCells.length;
|
|
71
|
+
while (sibling) {
|
|
72
|
+
if (!$isParagraphNode(sibling)) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
if (sibling.getChildrenSize() !== 1) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
const firstChild = sibling.getFirstChild();
|
|
79
|
+
if (!$isTextNode(firstChild)) {
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
const cells = mapToTableCells(firstChild.getTextContent(), allTransformers);
|
|
83
|
+
if (cells == null) {
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
maxCells = Math.max(maxCells, cells.length);
|
|
87
|
+
rows.unshift(cells);
|
|
88
|
+
const previousSibling = sibling.getPreviousSibling();
|
|
89
|
+
sibling.remove();
|
|
90
|
+
sibling = previousSibling;
|
|
91
|
+
}
|
|
92
|
+
const table = $createTableNode();
|
|
93
|
+
for (const cells of rows) {
|
|
94
|
+
const tableRow = $createTableRowNode();
|
|
95
|
+
table.append(tableRow);
|
|
96
|
+
for (let i = 0; i < maxCells; i++) {
|
|
97
|
+
tableRow.append(i < cells.length ? cells[i] : $createTableCell('', allTransformers));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const previousSibling = parentNode.getPreviousSibling();
|
|
101
|
+
if ($isTableNode(previousSibling) && getTableColumnsSize(previousSibling) === maxCells) {
|
|
102
|
+
previousSibling.append(...table.getChildren());
|
|
103
|
+
parentNode.remove();
|
|
104
|
+
} else {
|
|
105
|
+
parentNode.replace(table);
|
|
106
|
+
}
|
|
107
|
+
table.selectEnd();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
function getTableColumnsSize(table) {
|
|
111
|
+
const row = table.getFirstChild();
|
|
112
|
+
return $isTableRowNode(row) ? row.getChildrenSize() : 0;
|
|
113
|
+
}
|
|
114
|
+
const $createTableCell = (textContent, allTransformers) => {
|
|
115
|
+
textContent = textContent.replace(/\\n/g, '\n');
|
|
116
|
+
const cell = $createTableCellNode(TableCellHeaderStates.NO_STATUS);
|
|
117
|
+
$convertFromMarkdownString(textContent, allTransformers, cell);
|
|
118
|
+
return cell;
|
|
119
|
+
};
|
|
120
|
+
const mapToTableCells = (textContent, allTransformers) => {
|
|
121
|
+
const match = textContent.match(TABLE_ROW_REG_EXP);
|
|
122
|
+
if (!match || !match[1]) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return match[1].split('|').map(text => $createTableCell(text, allTransformers));
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=markdownTransformer.js.map
|