@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 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTransformer.js","names":["createHeadlessEditor","$convertFromMarkdownString","$convertToMarkdownString","extractPropsFromJSXPropsString","propsToJSXString","$createBlockNode","$isBlockNode","BlockNode","createTagRegexes","tagName","escapedTagName","replace","regExpEnd","RegExp","regExpStart","getBlockMarkdownTransformers","blocks","length","transformers","block","jsx","regex","slug","push","allNodes","allTransformers","type","dependencies","export","node","getFields","blockType","toLowerCase","nodeFields","lexicalToMarkdown","getLexicalToMarkdown","exportResult","fields","children","props","customEndRegex","customStartRegex","rootNode","openMatch","closeMatch","linesInBetween","import","line","child","getTextContent","childrenString","join","trim","propsString","markdownToLexical","getMarkdownToLexical","blockFields","htmlToLexical","blockName","append","markdown","headlessEditor","nodes","update","discrete","editorJSON","getEditorState","toJSON","editorState","setEditorState","parseEditorState","e","console","error","read"],"sources":["../../../../src/features/blocks/client/markdownTransformer.ts"],"sourcesContent":["import type { MultilineElementTransformer, Transformer } from '@lexical/markdown'\nimport type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState } from 'lexical'\nimport type { ClientBlock } from 'payload'\n\nimport { createHeadlessEditor } from '@lexical/headless'\nimport { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown'\n\nimport { extractPropsFromJSXPropsString } from '../../../utilities/jsx/extractPropsFromJSXPropsString.js'\nimport { propsToJSXString } from '../../../utilities/jsx/jsx.js'\nimport { $createBlockNode, $isBlockNode, BlockNode } from './nodes/BlocksNode.js'\n\nfunction createTagRegexes(tagName: string) {\n const escapedTagName = tagName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n return {\n regExpEnd: new RegExp(`</(${escapedTagName})\\\\s*>|<${escapedTagName}[^>]*?/>`, 'i'),\n regExpStart: new RegExp(`<(${escapedTagName})([^>]*?)\\\\s*(/?)>`, 'i'),\n }\n}\nexport const getBlockMarkdownTransformers = ({\n blocks,\n}: {\n blocks: ClientBlock[]\n}): ((props: {\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n allTransformers: Transformer[]\n}) => MultilineElementTransformer)[] => {\n if (!blocks?.length) {\n return []\n }\n\n const transformers: ((props: {\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n allTransformers: Transformer[]\n }) => MultilineElementTransformer)[] = []\n\n for (const block of blocks) {\n if (!block.jsx) {\n continue\n }\n const regex = createTagRegexes(block.slug)\n transformers.push(({ allNodes, allTransformers }) => ({\n type: 'multiline-element',\n dependencies: [BlockNode],\n export: (node) => {\n if (!$isBlockNode(node)) {\n return null\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 if (exportResult?.children?.length) {\n return `<${nodeFields.blockType}${exportResult.props ? ' ' + propsToJSXString({ props: exportResult.props }) : ''}>\\n ${exportResult.children}\\n</${nodeFields.blockType}>`\n }\n\n return `<${nodeFields.blockType}${exportResult.props ? ' ' + propsToJSXString({ props: exportResult.props }) : ''}/>`\n },\n regExpEnd: block.jsx?.customEndRegex ?? regex.regExpEnd,\n regExpStart: block.jsx?.customStartRegex ?? regex.regExpStart,\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 const childrenString = linesInBetween.join('\\n').trim()\n\n const propsString: null | string = openMatch?.length > 2 ? openMatch[2]?.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 = $createBlockNode({\n blockType: block.slug,\n ...blockFields,\n blockName: blockFields.blockName || '',\n })\n if (node) {\n rootNode.append(node)\n }\n\n return\n }\n return false // Run next transformer\n },\n }))\n }\n\n return transformers\n}\n\nexport function getMarkdownToLexical(\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>,\n allTransformers: Transformer[],\n): (args: { markdown: string }) => SerializedEditorState {\n const markdownToLexical = ({ markdown }: { markdown: string }): SerializedEditorState => {\n const headlessEditor = createHeadlessEditor({\n nodes: allNodes,\n })\n\n headlessEditor.update(\n () => {\n $convertFromMarkdownString(markdown, allTransformers)\n },\n { discrete: true },\n )\n\n const editorJSON = headlessEditor.getEditorState().toJSON()\n\n return editorJSON\n }\n return markdownToLexical\n}\n\nexport function getLexicalToMarkdown(\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>,\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: allNodes,\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":"AAIA,SAASA,oBAAoB,QAAQ;AACrC,SAASC,0BAA0B,EAAEC,wBAAwB,QAAQ;AAErE,SAASC,8BAA8B,QAAQ;AAC/C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,QAAQ;AAE1D,SAASC,iBAAiBC,OAAe;EACvC,MAAMC,cAAA,GAAiBD,OAAA,CAAQE,OAAO,CAAC,uBAAuB;EAC9D,OAAO;IACLC,SAAA,EAAW,IAAIC,MAAA,CAAO,MAAMH,cAAA,WAAyBA,cAAA,UAAwB,EAAE;IAC/EI,WAAA,EAAa,IAAID,MAAA,CAAO,KAAKH,cAAA,oBAAkC,EAAE;EACnE;AACF;AACA,OAAO,MAAMK,4BAAA,GAA+BA,CAAC;EAC3CC;AAAM,CAGP;EAIC,IAAI,CAACA,MAAA,EAAQC,MAAA,EAAQ;IACnB,OAAO,EAAE;EACX;EAEA,MAAMC,YAAA,GAGiC,EAAE;EAEzC,KAAK,MAAMC,KAAA,IAASH,MAAA,EAAQ;IAC1B,IAAI,CAACG,KAAA,CAAMC,GAAG,EAAE;MACd;IACF;IACA,MAAMC,KAAA,GAAQb,gBAAA,CAAiBW,KAAA,CAAMG,IAAI;IACzCJ,YAAA,CAAaK,IAAI,CAAC,CAAC;MAAEC,QAAQ;MAAEC;IAAe,CAAE,MAAM;MACpDC,IAAA,EAAM;MACNC,YAAA,EAAc,CAACpB,SAAA,CAAU;MACzBqB,MAAA,EAASC,IA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D,KAAA,EAAOtC;IACT;IAEAqC,cAAA,CAAeE,MAAM,CACnB;MACE9D,0BAAA,CAA2B2D,QAAA,EAAUnC,eAAA;IACvC,GACA;MAAEuC,QAAA,EAAU;IAAK;IAGnB,MAAMC,UAAA,GAAaJ,cAAA,CAAeK,cAAc,GAAGC,MAAM;IAEzD,OAAOF,UAAA;EACT;EACA,OAAOX,iBAAA;AACT;AAEA,OAAO,SAASnB,qBACdX,QAA4D,EAC5DC,eAA8B;EAE9B,MAAMS,iBAAA,GAAoBA,CAAC;IAAEkC;EAAW,CAAwC;IAC9E,MAAMP,cAAA,GAAiB7D,oBAAA,CAAqB;MAC1C8D,KAAA,EAAOtC;IACT;IAEA,IAAI;MACFqC,cAAA,CAAeQ,cAAc,CAACR,cAAA,CAAeS,gBAAgB,CAACF,WAAA,GAAqB;MAAA;IACrF,EAAE,OAAOG,CAAA,EAAG;MACVC,OAAA,CAAQC,KAAK,CAAC,oDAAoDF,CAAA;IACpE;IAEA,IAAIX,QAAA,GAAmB;IACvBC,cAAA,CAAeK,cAAc,GAAGQ,IAAI,CAAC;MACnCd,QAAA,GAAW1D,wBAAA,CAAyBuB,eAAA;IACtC;IAEA,OAAOmC,QAAA;EACT;EACA,OAAO1B,iBAAA;AACT","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PluginComponent } from '../../../typesClient.js';
|
|
2
2
|
import type { BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js';
|
|
3
|
-
import type { BlocksFeatureClientProps } from '../index.js';
|
|
4
3
|
export type InsertBlockPayload = BlockFieldsOptionalID;
|
|
5
|
-
export declare const BlocksPlugin: PluginComponent
|
|
4
|
+
export declare const BlocksPlugin: PluginComponent;
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAe,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAQ1F,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAEtD,eAAO,MAAM,YAAY,EAAE,eAoF1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParentOrThrow","getChildren","filter","node","length","remove","fields","node_0","setFields","inlineBlockNode","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParentOrThrow","getChildren","filter","node","length","remove","fields","node_0","setFields","inlineBlockNode","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParentOrThrow()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleDrawer])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAClB;AACP,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAKpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SAASC,oBAAoB,EAAEC,2BAA2B,QAAQ;AAIlE,OAAO,MAAMC,YAAA,GAAgCA,CAAA;EAAA,MAAAC,CAAA,GAAA3B,EAAA;EAC3C,OAAA4B,MAAA,IAAiB3B,yBAAA;EAEjB,OAAA4B,aAAA,EAAAC,gBAAA,IAA0Cb,QAAA,KAAwB;EAElE;IAAAc;EAAA,IAAiBb,sBAAA;EACjB,MAAAc,SAAA,GAAkB1B,YAAA;EAGV,MAAA2B,EAAA,iCAA8B,GAAGF,IAAA;EAAA,IAAAG,EAAA;EAAA,IAAA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,2BAAA,EAAAgC,MAAA;QAAA,IAGQ5B,aAAA;UACF,MAAA6B,MAAA,GAAalD,aAAA,CAAcqB,aAAA;UAAA,IAEvB,CAACyB,MAAA,KAAS/B,kBAAA,CAAmB+B,MAAA;YAAA;UAAA;UAIjCA,MAAA,CAAAK,SAAA,CAAeF,MAAA;UAEf3B,gBAAA,KAAiB;UAAA;QAAA;QAInB,MAAA8B,eAAA,GAAwBtC,sBAAA,CAAuBmC,MAAA;QAC/C9C,YAAA,EAAciD,eAAA,CAAgB;QAAA,IAC1B9C,mBAAA,CAAoB8C,eAAA,CAAAT,gBAAA,CAAgC;UACtDhD,kBAAA,CAAmByD,eAAA,EAAArD,oBAAiB,EAAAsD,SAAA,CAA+B;QAAA;QAAA;MAAA,GAAA9C,uBAKvE;IAAA;IAGNY,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,aAAA;IAAAF,CAAA,MAAAY,EAAA;EAAA;IAAAA,EAAA,GAAAZ,CAAA;EAAA;EAAA,IAAAmC,EAAA;EAAA,IAAAnC,CAAA,QAAAC,MAAA,IAAAD,CAAA,QAAAE,aAAA,IAAAF,CAAA,QAAAW,YAAA;IAAGwB,EAAA,IAAClC,MAAA,EAAQC,aAAA,EAAeS,YAAA;IAAaX,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,aAAA;IAAAF,CAAA,MAAAW,YAAA;IAAAX,CAAA,MAAAmC,EAAA;EAAA;IAAAA,EAAA,GAAAnC,CAAA;EAAA;EAlExCX,SAAA,CAAUuB,EAkEV,EAAGuB,EAAqC;EAAA;AAAA,CAG1C","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Block } from 'payload';
|
|
2
|
-
import type { BlocksFeatureClientProps } from '../client/index.js';
|
|
3
2
|
export type BlocksFeatureProps = {
|
|
4
3
|
blocks?: Block[];
|
|
5
4
|
inlineBlocks?: Block[];
|
|
6
5
|
};
|
|
7
|
-
export declare const BlocksFeature: import("../../typesServer.js").FeatureProviderProviderServer<BlocksFeatureProps, BlocksFeatureProps,
|
|
6
|
+
export declare const BlocksFeature: import("../../typesServer.js").FeatureProviderProviderServer<BlocksFeatureProps, BlocksFeatureProps, undefined>;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAuC,MAAM,SAAS,CAAA;AAazE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,iHAwMxB,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { createServerFeature } from '../../../utilities/createServerFeature.js';
|
|
|
3
3
|
import { createNode } from '../../typeUtilities.js';
|
|
4
4
|
import { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js';
|
|
5
5
|
import { i18n } from './i18n.js';
|
|
6
|
+
import { getBlockMarkdownTransformers } from './markdownTransformer.js';
|
|
6
7
|
import { ServerBlockNode } from './nodes/BlocksNode.js';
|
|
7
8
|
import { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js';
|
|
8
9
|
import { blockValidationHOC } from './validate.js';
|
|
@@ -13,11 +14,6 @@ export const BlocksFeature = createServerFeature({
|
|
|
13
14
|
parentIsLocalized,
|
|
14
15
|
props
|
|
15
16
|
}) => {
|
|
16
|
-
// Build clientProps
|
|
17
|
-
const clientProps = {
|
|
18
|
-
clientBlockSlugs: [],
|
|
19
|
-
clientInlineBlockSlugs: []
|
|
20
|
-
};
|
|
21
17
|
const validRelationships = _config.collections.map(c => c.slug) || [];
|
|
22
18
|
const sanitized = await sanitizeFields({
|
|
23
19
|
config: _config,
|
|
@@ -36,11 +32,8 @@ export const BlocksFeature = createServerFeature({
|
|
|
36
32
|
});
|
|
37
33
|
props.blocks = sanitized[0].blocks;
|
|
38
34
|
props.inlineBlocks = sanitized[1].blocks;
|
|
39
|
-
clientProps.clientBlockSlugs = props.blocks.map(block => block.slug);
|
|
40
|
-
clientProps.clientInlineBlockSlugs = props.inlineBlocks.map(block => block.slug);
|
|
41
35
|
return {
|
|
42
36
|
ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',
|
|
43
|
-
clientFeatureProps: clientProps,
|
|
44
37
|
generatedTypes: {
|
|
45
38
|
modifyOutputSchema: ({
|
|
46
39
|
collectionIDFieldTypes,
|
|
@@ -137,6 +130,10 @@ export const BlocksFeature = createServerFeature({
|
|
|
137
130
|
return schemaMap;
|
|
138
131
|
},
|
|
139
132
|
i18n,
|
|
133
|
+
markdownTransformers: getBlockMarkdownTransformers({
|
|
134
|
+
blocks: props.blocks,
|
|
135
|
+
inlineBlocks: props.inlineBlocks
|
|
136
|
+
}),
|
|
140
137
|
nodes: [createNode({
|
|
141
138
|
// @ts-expect-error - TODO: fix this
|
|
142
139
|
getSubFields: ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fieldsToJSONSchema","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","clientProps","clientBlockSlugs","clientInlineBlockSlugs","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","block","ClientFeature","clientFeatureProps","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","generateSchemaMap","schemaMap","Map","blockFields","admin","components","unshift","Block","BlockLabel","Label","set","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, Field, FieldSchemaMap } from 'payload'\n\nimport { fieldsToJSONSchema, sanitizeFields } from 'payload'\n\nimport type { BlocksFeatureClientProps } from '../client/index.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<\n BlocksFeatureProps,\n BlocksFeatureProps,\n BlocksFeatureClientProps\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n clientBlockSlugs: [],\n clientInlineBlockSlugs: [],\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n clientProps.clientBlockSlugs = props.blocks.map((block) => block.slug)\n clientProps.clientInlineBlockSlugs = props.inlineBlocks.map((block) => block.slug)\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n clientFeatureProps: clientProps,\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: BlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n })\n }\n\n if (fields.length) {\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config)\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,cAAc,QAAQ;AAInD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,IAAI,QAAQ;AACrB,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AAOnC,OAAO,MAAMC,aAAA,GAAgBP,mBAAA,CAI3B;EACAQ,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAA,EAAQC,OAAO;IAAE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ACAkC,yBAAA,EAA2B,CAACvD,yBAAA,CAA0BW,KAAA,CAAMc,YAAY,EAAE;QAC1E0B,IAAA,EAAMhD,qBAAA;QACNqD,WAAA,EAAa,CAACpD,kBAAA,CAAmBO,KAAA,CAAMc,YAAY;MACrD,GACD;MACDgC,2BAAA,EAA6B9C;IAC/B;EACF;EACA+C,GAAA,EAAK;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["fieldsToJSONSchema","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","getBlockMarkdownTransformers","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","ClientFeature","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","generateSchemaMap","schemaMap","Map","block","blockFields","admin","components","unshift","Block","BlockLabel","Label","set","markdownTransformers","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, FieldSchemaMap } from 'payload'\n\nimport { fieldsToJSONSchema, sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { getBlockMarkdownTransformers } from './markdownTransformer.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<BlocksFeatureProps, BlocksFeatureProps>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: BlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n })\n }\n\n if (fields.length) {\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config)\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n markdownTransformers: getBlockMarkdownTransformers({\n blocks: props.blocks,\n inlineBlocks: props.inlineBlocks,\n }),\n\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,cAAc,QAAQ;AAEnD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,IAAI,QAAQ;AACrB,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AAOnC,OAAO,MAAMC,aAAA,GAAgBR,mBAAA,CAA4D;EACvFS,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAA,EAAQC,OAAO;IAAEC,MAAM;IAAEC,iBAAiB;IAAEC;EAAK,CAAE;IACnE,MAAMC,kBAAA,GAAqBJ,OAAA,CAAQK,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEvE,MAAMC,SAAA,GAAY,MAAMrB,cAAA,CAAe;MACrCW,MAAA,EAAQC,OAAA;MACRU,MAAA,EAAQ,CACN;QACEC,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQV,KAAA,CAAMU,MAAM,IAAI;MAC1B,GACA;QACEF,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQV,KAAA,CAAMW,YAAY,IAAI;MAChC,EACD;MACDZ,iBAAA;MACAa,+BAAA,EAAiCd,MAAA;MACjCG;IACF;IAEAD,KAAA,CAAMU,MAAM,GAAGJ,SAAU,CAAC,EAAE,CAAiBI,MAAM;IACnDV,KAAA,CAAMW,YAAY,GAAGL,SAAU,CAAC,EAAE,CAAiBI,MAAM;IAEzD,OAAO;MACLG,aAAA,EAAe;MACfC,cAAA,EAAgB;QACdC,k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OAAO,EAAE;UACX;UAEA,MAAM2B,SAAA,GAAYD,IAAA,CAAK9B,MAAM,CAAC+B,SAAS;UAEvC,MAAMb,KAAA,GAAQzB,KAAA,CAAMW,YAAY,EAAE4B,IAAA,CAAMd,KAAA,IAAUA,KAAA,CAAMpB,IAAI,KAAKiC,SAAA;UACjE,OAAOb,KAAA,EAAOlB,MAAA;QAChB;QACAiC,gBAAA,EAAkBA,CAAC;UAAEH;QAAI,CAAE;UACzB,OAAOA,IAAA,EAAM9B,MAAA;QACf;QACAkC,yBAAA,EAA2B,CAACrD,yBAAA,CAA0BY,KAAA,CAAMW,YAAY,EAAE;QAC1E0B,IAAA,EAAM7C,qBAAA;QACNkD,WAAA,EAAa,CAACjD,kBAAA,CAAmBO,KAAA,CAAMW,YAAY;MACrD,GACD;MACDgC,2BAAA,EAA6B3C;IAC/B;EACF;EACA4C,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function linesFromStartToContentAndPropsString({ isEndOptional, lines, regexpEndRegex, startLineIndex, startMatch, trimChildren, }: {
|
|
2
|
+
isEndOptional?: boolean;
|
|
3
|
+
lines: string[];
|
|
4
|
+
regexpEndRegex?: RegExp;
|
|
5
|
+
startLineIndex: number;
|
|
6
|
+
startMatch: RegExpMatchArray;
|
|
7
|
+
trimChildren?: boolean;
|
|
8
|
+
}): {
|
|
9
|
+
/**
|
|
10
|
+
* The matched string after the end match, in the same line as the end match. Useful for inline matches.
|
|
11
|
+
*/
|
|
12
|
+
afterEndLine: string;
|
|
13
|
+
/**
|
|
14
|
+
* The matched string before the start match, in the same line as the start match. Useful for inline matches.
|
|
15
|
+
*/
|
|
16
|
+
beforeStartLine: string;
|
|
17
|
+
content: string;
|
|
18
|
+
endLineIndex: number;
|
|
19
|
+
endlineLastCharIndex: number;
|
|
20
|
+
propsString: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=linesFromMatchToContentAndPropsString.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linesFromMatchToContentAndPropsString.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/linesFromMatchToContentAndPropsString.ts"],"names":[],"mappings":"AAAA,wBAAgB,qCAAqC,CAAC,EACpD,aAAa,EACb,KAAK,EACL,cAAc,EACd,cAAc,EACd,UAAU,EACV,YAAY,GACb,EAAE;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,gBAAgB,CAAA;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG;IACF;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;CACpB,CAmJA"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
export function linesFromStartToContentAndPropsString({
|
|
2
|
+
isEndOptional,
|
|
3
|
+
lines,
|
|
4
|
+
regexpEndRegex,
|
|
5
|
+
startLineIndex,
|
|
6
|
+
startMatch,
|
|
7
|
+
trimChildren
|
|
8
|
+
}) {
|
|
9
|
+
let propsString = '';
|
|
10
|
+
let content = '';
|
|
11
|
+
const linesCopy = lines.slice(startLineIndex);
|
|
12
|
+
let isWithinContent = false // If false => is within prop
|
|
13
|
+
;
|
|
14
|
+
let contentSubTagStartAmount = 0;
|
|
15
|
+
let bracketCount = 0;
|
|
16
|
+
let quoteChar = null;
|
|
17
|
+
let isSelfClosing = false;
|
|
18
|
+
let isWithinCodeBlockAmount = 0;
|
|
19
|
+
const beforeStartLine = linesCopy[0].slice(0, startMatch.index);
|
|
20
|
+
let endlineLastCharIndex = 0;
|
|
21
|
+
let endLineIndex = startLineIndex;
|
|
22
|
+
mainLoop: for (let lineIndex = 0; lineIndex < linesCopy.length; lineIndex++) {
|
|
23
|
+
const line = trimChildren ? linesCopy[lineIndex].trim() : linesCopy[lineIndex];
|
|
24
|
+
let amountOfBeginningSpacesRemoved = 0;
|
|
25
|
+
if (trimChildren) {
|
|
26
|
+
for (let i = 0; i < linesCopy[lineIndex].length; i++) {
|
|
27
|
+
if (linesCopy[lineIndex][i] === ' ') {
|
|
28
|
+
amountOfBeginningSpacesRemoved++;
|
|
29
|
+
} else {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
let charIndex = 0;
|
|
35
|
+
if (lineIndex === 0) {
|
|
36
|
+
charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved // We need to also loop over the ">" in something like "<InlineCode>" in order to later set isWithinContent to true
|
|
37
|
+
;
|
|
38
|
+
}
|
|
39
|
+
while (charIndex < line.length) {
|
|
40
|
+
const char = line[charIndex];
|
|
41
|
+
const nextChar = line[charIndex + 1];
|
|
42
|
+
if (!isWithinContent) {
|
|
43
|
+
if (char === '{' && !quoteChar) {
|
|
44
|
+
bracketCount++;
|
|
45
|
+
} else if (char === '}' && !quoteChar) {
|
|
46
|
+
bracketCount--;
|
|
47
|
+
} else if ((char === '"' || char === "'") && !quoteChar) {
|
|
48
|
+
quoteChar = char;
|
|
49
|
+
} else if (char === quoteChar) {
|
|
50
|
+
quoteChar = null;
|
|
51
|
+
}
|
|
52
|
+
if (char === '/' && nextChar === '>' && bracketCount === 0 && !quoteChar) {
|
|
53
|
+
isSelfClosing = true;
|
|
54
|
+
endLineIndex = lineIndex;
|
|
55
|
+
endlineLastCharIndex = charIndex + 2;
|
|
56
|
+
break mainLoop;
|
|
57
|
+
} else if (char === '>' && bracketCount === 0 && !quoteChar) {
|
|
58
|
+
isWithinContent = true;
|
|
59
|
+
charIndex++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
propsString += char;
|
|
63
|
+
} else {
|
|
64
|
+
if (char === '`') {
|
|
65
|
+
isWithinCodeBlockAmount++;
|
|
66
|
+
}
|
|
67
|
+
if (isWithinCodeBlockAmount % 2 === 0) {
|
|
68
|
+
if (char === '<' && nextChar === '/') {
|
|
69
|
+
contentSubTagStartAmount--;
|
|
70
|
+
if (contentSubTagStartAmount < 0) {
|
|
71
|
+
if (content[content.length - 1] === '\n') {
|
|
72
|
+
content = content.slice(0, -1) // Remove the last newline
|
|
73
|
+
;
|
|
74
|
+
}
|
|
75
|
+
endLineIndex = lineIndex;
|
|
76
|
+
// Calculate endlineLastCharIndex by finding ">" in line
|
|
77
|
+
for (let i = charIndex; i < line.length; i++) {
|
|
78
|
+
if (line[i] === '>') {
|
|
79
|
+
endlineLastCharIndex = i + 1;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
break mainLoop;
|
|
84
|
+
}
|
|
85
|
+
} else if (char === '/' && nextChar === '>') {
|
|
86
|
+
contentSubTagStartAmount--;
|
|
87
|
+
if (contentSubTagStartAmount < 0) {
|
|
88
|
+
if (content[content.length - 1] === '\n') {
|
|
89
|
+
content = content.slice(0, -1) // Remove the last newline
|
|
90
|
+
;
|
|
91
|
+
}
|
|
92
|
+
endLineIndex = lineIndex;
|
|
93
|
+
endlineLastCharIndex = charIndex + 2;
|
|
94
|
+
break mainLoop;
|
|
95
|
+
}
|
|
96
|
+
} else if (char === '<' && nextChar !== '/') {
|
|
97
|
+
contentSubTagStartAmount++;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
content += char;
|
|
101
|
+
}
|
|
102
|
+
charIndex++;
|
|
103
|
+
}
|
|
104
|
+
if (isWithinContent) {
|
|
105
|
+
if (content?.length > 0 && lineIndex > 0) {
|
|
106
|
+
content += '\n';
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
propsString += '\n';
|
|
110
|
+
}
|
|
111
|
+
if (regexpEndRegex && contentSubTagStartAmount < 0) {
|
|
112
|
+
// If 0 and in same line where it got lowered to 0 then this is not the match we are looking for
|
|
113
|
+
const match = line.match(regexpEndRegex);
|
|
114
|
+
if (match?.index !== undefined) {
|
|
115
|
+
endLineIndex = lineIndex;
|
|
116
|
+
endlineLastCharIndex = match.index + match[0].length - 1;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (lineIndex === linesCopy.length - 1 && !isEndOptional && !isSelfClosing) {
|
|
121
|
+
throw new Error('End match not found for lines ' + lines.join('\n'));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Replace all \n with spaces
|
|
125
|
+
propsString = propsString.replace(/\n/g, ' ').trim();
|
|
126
|
+
const afterEndLine = linesCopy[endLineIndex].trim().slice(endlineLastCharIndex);
|
|
127
|
+
return {
|
|
128
|
+
afterEndLine,
|
|
129
|
+
beforeStartLine,
|
|
130
|
+
content,
|
|
131
|
+
endLineIndex: startLineIndex + endLineIndex,
|
|
132
|
+
endlineLastCharIndex,
|
|
133
|
+
propsString
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=linesFromMatchToContentAndPropsString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linesFromMatchToContentAndPropsString.js","names":["linesFromStartToContentAndPropsString","isEndOptional","lines","regexpEndRegex","startLineIndex","startMatch","trimChildren","propsString","content","linesCopy","slice","isWithinContent","contentSubTagStartAmount","bracketCount","quoteChar","isSelfClosing","isWithinCodeBlockAmount","beforeStartLine","index","endlineLastCharIndex","endLineIndex","mainLoop","lineIndex","length","line","trim","amountOfBeginningSpacesRemoved","i","charIndex","char","nextChar","match","undefined","Error","join","replace","afterEndLine"],"sources":["../../../../src/features/blocks/server/linesFromMatchToContentAndPropsString.ts"],"sourcesContent":["export function linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren,\n}: {\n isEndOptional?: boolean\n lines: string[]\n regexpEndRegex?: RegExp\n startLineIndex: number\n startMatch: RegExpMatchArray\n trimChildren?: boolean\n}): {\n /**\n * The matched string after the end match, in the same line as the end match. Useful for inline matches.\n */\n afterEndLine: string\n /**\n * The matched string before the start match, in the same line as the start match. Useful for inline matches.\n */\n beforeStartLine: string\n content: string\n endLineIndex: number\n endlineLastCharIndex: number\n propsString: string\n} {\n let propsString = ''\n let content = ''\n const linesCopy = lines.slice(startLineIndex)\n\n let isWithinContent = false // If false => is within prop\n let contentSubTagStartAmount = 0\n\n let bracketCount = 0\n let quoteChar: null | string = null\n let isSelfClosing = false\n let isWithinCodeBlockAmount = 0\n\n const beforeStartLine = linesCopy[0].slice(0, startMatch.index)\n let endlineLastCharIndex = 0\n\n let endLineIndex = startLineIndex\n\n mainLoop: for (let lineIndex = 0; lineIndex < linesCopy.length; lineIndex++) {\n const line = trimChildren ? linesCopy[lineIndex].trim() : linesCopy[lineIndex]\n let amountOfBeginningSpacesRemoved = 0\n if (trimChildren) {\n for (let i = 0; i < linesCopy[lineIndex].length; i++) {\n if (linesCopy[lineIndex][i] === ' ') {\n amountOfBeginningSpacesRemoved++\n } else {\n break\n }\n }\n }\n\n let charIndex = 0\n\n if (lineIndex === 0) {\n charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved // We need to also loop over the \">\" in something like \"<InlineCode>\" in order to later set isWithinContent to true\n }\n\n while (charIndex < line.length) {\n const char = line[charIndex]\n const nextChar = line[charIndex + 1]\n\n if (!isWithinContent) {\n if (char === '{' && !quoteChar) {\n bracketCount++\n } else if (char === '}' && !quoteChar) {\n bracketCount--\n } else if ((char === '\"' || char === \"'\") && !quoteChar) {\n quoteChar = char\n } else if (char === quoteChar) {\n quoteChar = null\n }\n\n if (char === '/' && nextChar === '>' && bracketCount === 0 && !quoteChar) {\n isSelfClosing = true\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n\n break mainLoop\n } else if (char === '>' && bracketCount === 0 && !quoteChar) {\n isWithinContent = true\n charIndex++\n continue\n }\n\n propsString += char\n } else {\n if (char === '`') {\n isWithinCodeBlockAmount++\n }\n\n if (isWithinCodeBlockAmount % 2 === 0) {\n if (char === '<' && nextChar === '/') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n // Calculate endlineLastCharIndex by finding \">\" in line\n for (let i = charIndex; i < line.length; i++) {\n if (line[i] === '>') {\n endlineLastCharIndex = i + 1\n\n break\n }\n }\n break mainLoop\n }\n } else if (char === '/' && nextChar === '>') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n break mainLoop\n }\n } else if (char === '<' && nextChar !== '/') {\n contentSubTagStartAmount++\n }\n }\n\n content += char\n }\n\n charIndex++\n }\n\n if (isWithinContent) {\n if (content?.length > 0 && lineIndex > 0) {\n content += '\\n'\n }\n } else {\n propsString += '\\n'\n }\n\n if (regexpEndRegex && contentSubTagStartAmount < 0) {\n // If 0 and in same line where it got lowered to 0 then this is not the match we are looking for\n const match = line.match(regexpEndRegex)\n if (match?.index !== undefined) {\n endLineIndex = lineIndex\n endlineLastCharIndex = match.index + match[0].length - 1\n break\n }\n }\n\n if (lineIndex === linesCopy.length - 1 && !isEndOptional && !isSelfClosing) {\n throw new Error('End match not found for lines ' + lines.join('\\n'))\n }\n }\n\n // Replace all \\n with spaces\n propsString = propsString.replace(/\\n/g, ' ').trim()\n\n const afterEndLine = linesCopy[endLineIndex].trim().slice(endlineLastCharIndex)\n\n return {\n afterEndLine,\n beforeStartLine,\n content,\n endLineIndex: startLineIndex + endLineIndex,\n endlineLastCharIndex,\n propsString,\n }\n}\n"],"mappings":"AAAA,OAAO,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KAAA,CAAM,mCAAmC/B,KAAA,CAAMgC,IAAI,CAAC;IAChE;EACF;EAEA;EACA3B,WAAA,GAAcA,WAAA,CAAY4B,OAAO,CAAC,OAAO,KAAKV,IAAI;EAElD,MAAMW,YAAA,GAAe3B,SAAS,CAACW,YAAA,CAAa,CAACK,IAAI,GAAGf,KAAK,CAACS,oBAAA;EAE1D,OAAO;IACLiB,YAAA;IACAnB,eAAA;IACAT,OAAA;IACAY,YAAA,EAAchB,cAAA,GAAiBgB,YAAA;IAC/BD,oBAAA;IACAZ;EACF;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MultilineElementTransformer, TextMatchTransformer, Transformer } from '@lexical/markdown';
|
|
2
|
+
import type { SerializedEditorState } from 'lexical';
|
|
3
|
+
import type { Block } from 'payload';
|
|
4
|
+
import type { NodeWithHooks } from '../../typesServer.js';
|
|
5
|
+
export declare function createTagRegexes(tagName: string): {
|
|
6
|
+
regExpEnd: RegExp;
|
|
7
|
+
regExpStart: RegExp;
|
|
8
|
+
};
|
|
9
|
+
export declare const getBlockMarkdownTransformers: ({ blocks, inlineBlocks, }: {
|
|
10
|
+
blocks: Block[];
|
|
11
|
+
inlineBlocks: Block[];
|
|
12
|
+
}) => ((props: {
|
|
13
|
+
allNodes: Array<NodeWithHooks>;
|
|
14
|
+
allTransformers: Transformer[];
|
|
15
|
+
}) => MultilineElementTransformer | TextMatchTransformer)[];
|
|
16
|
+
export declare function getMarkdownToLexical(allNodes: Array<NodeWithHooks>, allTransformers: Transformer[]): (args: {
|
|
17
|
+
markdown: string;
|
|
18
|
+
}) => SerializedEditorState;
|
|
19
|
+
export declare function getLexicalToMarkdown(allNodes: Array<NodeWithHooks>, allTransformers: Transformer[]): (args: {
|
|
20
|
+
editorState: Record<string, any>;
|
|
21
|
+
}) => string;
|
|
22
|
+
//# sourceMappingURL=markdownTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownTransformer.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/markdownTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,WAAW,EACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAe,qBAAqB,EAAyB,MAAM,SAAS,CAAA;AACxF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAMpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAczD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM;;;EAiB/C;AACD,eAAO,MAAM,4BAA4B,8BAGtC;IACD,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,YAAY,EAAE,KAAK,EAAE,CAAA;CACtB,KAAG,CAAC,CAAC,KAAK,EAAE;IACX,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;IAC9B,eAAe,EAAE,WAAW,EAAE,CAAA;CAC/B,KAAK,2BAA2B,GAAG,oBAAoB,CAAC,EA+BxD,CAAA;AA6WD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,EAC9B,eAAe,EAAE,WAAW,EAAE,GAC7B,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,KAAK,qBAAqB,CAkBvD;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC,EAC9B,eAAe,EAAE,WAAW,EAAE,GAC7B,CAAC,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAAE,KAAK,MAAM,CAsBxD"}
|