@payloadcms/richtext-lexical 3.0.0-beta.133 → 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-2CYU43GM.js +2 -0
- package/dist/exports/client/chunk-2CYU43GM.js.map +7 -0
- package/dist/exports/client/chunk-C7S3V4EB.js +2 -0
- package/dist/exports/client/chunk-C7S3V4EB.js.map +7 -0
- 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/chunk-U7O7EYCP.js +2 -0
- package/dist/exports/client/chunk-U7O7EYCP.js.map +7 -0
- package/dist/exports/client/component-H3EYQ5KG.js +2 -0
- package/dist/exports/client/{component-YICNYPTU.js.map → component-H3EYQ5KG.js.map} +1 -1
- package/dist/exports/client/componentInline-ZGO3K4TA.js +2 -0
- package/dist/exports/client/componentInline-ZGO3K4TA.js.map +7 -0
- package/dist/exports/client/index.d.ts +7 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- 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/component/BlockContent.d.ts +34 -9
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +63 -158
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +11 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +37 -0
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.d.ts +3 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.js +22 -0
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts +3 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts.map +1 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js +22 -0
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -0
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +242 -63
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +5 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +28 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts +3 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts.map +1 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +22 -0
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -0
- package/dist/features/blocks/client/componentInline/index.d.ts +13 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +219 -43
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- 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 -157
- 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/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/commands.d.ts +0 -4
- package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
- package/dist/features/blocks/client/plugin/commands.js +0 -1
- package/dist/features/blocks/client/plugin/commands.js.map +1 -1
- 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 +28 -135
- 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 +33 -10
- 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 +12 -19
- 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 +10 -21
- 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/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +23 -1
- package/dist/field/rscEntry.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/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +9 -18
- package/dist/lexical/LexicalProvider.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.js +15 -14
- 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/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +27 -0
- package/dist/utilities/buildInitialState.d.ts.map +1 -0
- package/dist/utilities/buildInitialState.js +53 -0
- package/dist/utilities/buildInitialState.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/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -5
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +8 -8
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.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-GWJ72IYP.js +0 -2
- package/dist/exports/client/Field-GWJ72IYP.js.map +0 -7
- package/dist/exports/client/chunk-D7PD5DUW.js +0 -2
- package/dist/exports/client/chunk-D7PD5DUW.js.map +0 -7
- package/dist/exports/client/chunk-OOBB5GCO.js +0 -2
- package/dist/exports/client/chunk-XDEGE6I5.js +0 -2
- package/dist/exports/client/chunk-XDEGE6I5.js.map +0 -7
- package/dist/exports/client/chunk-YGRKYSDC.js +0 -2
- package/dist/exports/client/chunk-YGRKYSDC.js.map +0 -7
- package/dist/exports/client/component-KLNTKKNE.js +0 -2
- package/dist/exports/client/component-KLNTKKNE.js.map +0 -7
- package/dist/exports/client/component-YICNYPTU.js +0 -2
- package/dist/exports/client/componentInline-6RPSMLNJ.js +0 -2
- package/dist/exports/client/componentInline-6RPSMLNJ.js.map +0 -7
- package/dist/features/blocks/client/component/FormSavePlugin.d.ts +0 -11
- package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +0 -1
- package/dist/features/blocks/client/component/FormSavePlugin.js +0 -53
- package/dist/features/blocks/client/component/FormSavePlugin.js.map +0 -1
|
@@ -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":"
|
|
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,61 +1,44 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { c as _c } from "react/compiler-runtime";
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
4
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
|
|
6
5
|
import { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils';
|
|
7
|
-
import {
|
|
8
|
-
import { formatDrawerSlug, useEditDepth, useTranslation } from '@payloadcms/ui';
|
|
6
|
+
import { formatDrawerSlug, useEditDepth } from '@payloadcms/ui';
|
|
9
7
|
import { $createParagraphNode, $getNodeByKey, $getPreviousSelection, $getSelection, $insertNodes, $isParagraphNode, $isRangeSelection, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR } from 'lexical';
|
|
10
|
-
import
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
11
9
|
import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
|
|
12
|
-
import { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js';
|
|
13
10
|
import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
|
|
14
11
|
import { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js';
|
|
15
12
|
import { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
|
|
16
|
-
import { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND
|
|
13
|
+
import { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js';
|
|
17
14
|
export const BlocksPlugin = () => {
|
|
18
|
-
const $ = _c(
|
|
15
|
+
const $ = _c(10);
|
|
19
16
|
const [editor] = useLexicalComposerContext();
|
|
20
|
-
const [blockFields, setBlockFields] = useState(null);
|
|
21
|
-
const [blockType, setBlockType] = useState("");
|
|
22
17
|
const [targetNodeKey, setTargetNodeKey] = useState(null);
|
|
23
|
-
const {
|
|
24
|
-
i18n,
|
|
25
|
-
t
|
|
26
|
-
} = useTranslation();
|
|
27
|
-
const {
|
|
28
|
-
fieldProps: t0
|
|
29
|
-
} = useEditorConfigContext();
|
|
30
|
-
const {
|
|
31
|
-
featureClientSchemaMap,
|
|
32
|
-
schemaPath
|
|
33
|
-
} = t0;
|
|
34
18
|
const {
|
|
35
19
|
uuid
|
|
36
20
|
} = useEditorConfigContext();
|
|
37
21
|
const editDepth = useEditDepth();
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
if ($[0] !==
|
|
41
|
-
|
|
42
|
-
slug:
|
|
22
|
+
const t0 = `lexical-inlineBlocks-create-` + uuid;
|
|
23
|
+
let t1;
|
|
24
|
+
if ($[0] !== t0 || $[1] !== editDepth) {
|
|
25
|
+
t1 = formatDrawerSlug({
|
|
26
|
+
slug: t0,
|
|
43
27
|
depth: editDepth
|
|
44
28
|
});
|
|
45
|
-
$[0] =
|
|
29
|
+
$[0] = t0;
|
|
46
30
|
$[1] = editDepth;
|
|
47
|
-
$[2] =
|
|
31
|
+
$[2] = t1;
|
|
48
32
|
} else {
|
|
49
|
-
|
|
33
|
+
t1 = $[2];
|
|
50
34
|
}
|
|
51
|
-
const drawerSlug =
|
|
35
|
+
const drawerSlug = t1;
|
|
52
36
|
const {
|
|
53
37
|
toggleDrawer
|
|
54
38
|
} = useLexicalDrawer(drawerSlug, true);
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
t3 = () => {
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[3] !== editor || $[4] !== targetNodeKey) {
|
|
41
|
+
t2 = () => {
|
|
59
42
|
if (!editor.hasNodes([BlockNode])) {
|
|
60
43
|
throw new Error("BlocksPlugin: BlocksNode not registered on editor");
|
|
61
44
|
}
|
|
@@ -91,115 +74,25 @@ export const BlocksPlugin = () => {
|
|
|
91
74
|
$wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd();
|
|
92
75
|
}
|
|
93
76
|
return true;
|
|
94
|
-
}, COMMAND_PRIORITY_EDITOR), editor.registerCommand(OPEN_INLINE_BLOCK_DRAWER_COMMAND, t5 => {
|
|
95
|
-
const {
|
|
96
|
-
fields: fields_0,
|
|
97
|
-
nodeKey
|
|
98
|
-
} = t5;
|
|
99
|
-
setBlockFields(fields_0 ?? null);
|
|
100
|
-
setTargetNodeKey(nodeKey ?? null);
|
|
101
|
-
setBlockType(fields_0?.blockType ?? "");
|
|
102
|
-
if (nodeKey) {
|
|
103
|
-
toggleDrawer();
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
let rangeSelection;
|
|
107
|
-
rangeSelection = null;
|
|
108
|
-
editor.getEditorState().read(() => {
|
|
109
|
-
const selection_0 = $getSelection();
|
|
110
|
-
if ($isRangeSelection(selection_0)) {
|
|
111
|
-
rangeSelection = selection_0;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
if (rangeSelection) {
|
|
115
|
-
toggleDrawer();
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
118
77
|
}, COMMAND_PRIORITY_EDITOR));
|
|
119
78
|
};
|
|
120
|
-
t4 = [editor, targetNodeKey, toggleDrawer];
|
|
121
79
|
$[3] = editor;
|
|
122
80
|
$[4] = targetNodeKey;
|
|
123
|
-
$[5] =
|
|
124
|
-
$[6] = t3;
|
|
125
|
-
$[7] = t4;
|
|
126
|
-
} else {
|
|
127
|
-
t3 = $[6];
|
|
128
|
-
t4 = $[7];
|
|
129
|
-
}
|
|
130
|
-
useEffect(t3, t4);
|
|
131
|
-
if (!blockFields) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockFields?.blockType}`;
|
|
135
|
-
const clientSchemaMap = featureClientSchemaMap.blocks;
|
|
136
|
-
const blocksField = clientSchemaMap[schemaFieldsPath][0];
|
|
137
|
-
const clientBlock = blocksField.blocks[0];
|
|
138
|
-
if (!blocksField) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
let t5;
|
|
142
|
-
if ($[8] !== clientBlock || $[9] !== i18n) {
|
|
143
|
-
t5 = clientBlock?.labels?.singular ? getTranslation(clientBlock?.labels?.singular, i18n) : clientBlock?.slug;
|
|
144
|
-
$[8] = clientBlock;
|
|
145
|
-
$[9] = i18n;
|
|
146
|
-
$[10] = t5;
|
|
81
|
+
$[5] = t2;
|
|
147
82
|
} else {
|
|
148
|
-
|
|
83
|
+
t2 = $[5];
|
|
149
84
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[13] = t7;
|
|
158
|
-
} else {
|
|
159
|
-
t7 = $[13];
|
|
160
|
-
}
|
|
161
|
-
let t8;
|
|
162
|
-
if ($[14] !== t7 || $[15] !== t || $[16] !== t6 || $[17] !== clientBlock?.fields || $[18] !== blockType || $[19] !== editor || $[20] !== blockFields || $[21] !== drawerSlug || $[22] !== schemaPath) {
|
|
163
|
-
let t9;
|
|
164
|
-
if ($[24] !== blockType || $[25] !== editor) {
|
|
165
|
-
t9 = (_fields, data) => {
|
|
166
|
-
if (!data) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
data.blockType = blockType;
|
|
170
|
-
editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data);
|
|
171
|
-
};
|
|
172
|
-
$[24] = blockType;
|
|
173
|
-
$[25] = editor;
|
|
174
|
-
$[26] = t9;
|
|
175
|
-
} else {
|
|
176
|
-
t9 = $[26];
|
|
177
|
-
}
|
|
178
|
-
t8 = _jsx(FieldsDrawer, {
|
|
179
|
-
data: blockFields,
|
|
180
|
-
drawerSlug,
|
|
181
|
-
drawerTitle: t(t6, {
|
|
182
|
-
label: t7
|
|
183
|
-
}),
|
|
184
|
-
featureKey: "blocks",
|
|
185
|
-
fieldMapOverride: clientBlock?.fields,
|
|
186
|
-
handleDrawerSubmit: t9,
|
|
187
|
-
schemaPath,
|
|
188
|
-
schemaPathSuffix: `lexical_inline_blocks.${blockFields?.blockType}.fields`
|
|
189
|
-
});
|
|
190
|
-
$[14] = t7;
|
|
191
|
-
$[15] = t;
|
|
192
|
-
$[16] = t6;
|
|
193
|
-
$[17] = clientBlock?.fields;
|
|
194
|
-
$[18] = blockType;
|
|
195
|
-
$[19] = editor;
|
|
196
|
-
$[20] = blockFields;
|
|
197
|
-
$[21] = drawerSlug;
|
|
198
|
-
$[22] = schemaPath;
|
|
199
|
-
$[23] = t8;
|
|
85
|
+
let t3;
|
|
86
|
+
if ($[6] !== editor || $[7] !== targetNodeKey || $[8] !== toggleDrawer) {
|
|
87
|
+
t3 = [editor, targetNodeKey, toggleDrawer];
|
|
88
|
+
$[6] = editor;
|
|
89
|
+
$[7] = targetNodeKey;
|
|
90
|
+
$[8] = toggleDrawer;
|
|
91
|
+
$[9] = t3;
|
|
200
92
|
} else {
|
|
201
|
-
|
|
93
|
+
t3 = $[9];
|
|
202
94
|
}
|
|
203
|
-
|
|
95
|
+
useEffect(t2, t3);
|
|
96
|
+
return null;
|
|
204
97
|
};
|
|
205
98
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","getTranslation","formatDrawerSlug","useEditDepth","useTranslation","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","React","useEffect","useState","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","OPEN_INLINE_BLOCK_DRAWER_COMMAND","BlocksPlugin","$","editor","blockFields","setBlockFields","blockType","setBlockType","targetNodeKey","setTargetNodeKey","i18n","t","fieldProps","t0","featureClientSchemaMap","schemaPath","uuid","editDepth","t1","t2","slug","depth","drawerSlug","toggleDrawer","t3","t4","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParentOrThrow","getChildren","filter","node","length","remove","fields","node_0","setFields","inlineBlockNode","selectEnd","t5","fields_0","nodeKey","rangeSelection","getEditorState","read","selection_0","schemaFieldsPath","clientSchemaMap","blocks","blocksField","clientBlock","labels","singular","blockDisplayName","t6","id","t7","t8","t9","_fields","data","dispatchCommand","_jsx","drawerTitle","label","featureKey","fieldMapOverride","handleDrawerSubmit","schemaPathSuffix"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDrawerSlug, useEditDepth, useTranslation } 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 type RangeSelection,\n} from 'lexical'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\nimport type { BlocksFeatureClientProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport {\n INSERT_BLOCK_COMMAND,\n INSERT_INLINE_BLOCK_COMMAND,\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n} from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n const [blockFields, setBlockFields] = useState<BlockFields | null>(null)\n const [blockType, setBlockType] = useState<string>('' as any)\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n const { i18n, t } = useTranslation<string, any>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\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 editor.registerCommand(\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n ({ fields, nodeKey }) => {\n setBlockFields((fields as BlockFields) ?? null)\n setTargetNodeKey(nodeKey ?? null)\n setBlockType(fields?.blockType ?? ('' as any))\n\n if (nodeKey) {\n toggleDrawer()\n return true\n }\n\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n //setLastSelection(rangeSelection)\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleDrawer])\n\n if (!blockFields) {\n return null\n }\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockFields?.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[schemaFieldsPath][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n if (!blocksField) {\n return null\n }\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels?.singular, i18n)\n : clientBlock?.slug\n\n return (\n <FieldsDrawer\n data={blockFields}\n drawerSlug={drawerSlug}\n drawerTitle={t(`lexical:blocks:inlineBlocks:${blockFields?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n featureKey=\"blocks\"\n fieldMapOverride={clientBlock?.fields}\n handleDrawerSubmit={(_fields, data) => {\n if (!data) {\n return\n }\n\n data.blockType = blockType\n\n editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data)\n }}\n schemaPath={schemaPath}\n schemaPathSuffix={`lexical_inline_blocks.${blockFields?.blockType}.fields`}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,cAAc,QAAQ;AAC/D,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAElB;AACP,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AAM3C,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAC7B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SACEC,oBAAoB,EACpBC,2BAA2B,EAC3BC,gCAAgC,QAC3B;AAIP,OAAO,MAAMC,YAAA,GAA0DA,CAAA;EAAA,MAAAC,CAAA,GAAAhC,EAAA;EACrE,OAAAiC,MAAA,IAAiBhC,yBAAA;EACjB,OAAAiC,WAAA,EAAAC,cAAA,IAAsCf,QAAA,KAA6B;EACnE,OAAAgB,SAAA,EAAAC,YAAA,IAAkCjB,QAAA,CAAiB;EACnD,OAAAkB,aAAA,EAAAC,gBAAA,IAA0CnB,QAAA,KAAwB;EAClE;IAAAoB,IAAA;IAAAC;EAAA,IAAoBjC,cAAA;EACpB;IAAAkC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C;;;;;;;;;;;;;;SAlB5E4D,E;CAqBJ","ignoreList":[]}
|
|
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,IAAAP,CAAA,QAAAM,EAAA,IAAAN,CAAA,QAAAK,SAAA;IADtBE,EAAA,GAAA7B,gBAAA;MAAA8B,IAAA,EACXF,EAAiC;MAAAG,KAAA,EAChCJ;IAAA,CACT;IAAAL,CAAA,MAAAM,EAAA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AIjCA,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,
|
|
@@ -85,8 +78,21 @@ export const BlocksFeature = createServerFeature({
|
|
|
85
78
|
const schemaMap = new Map();
|
|
86
79
|
if (props?.blocks?.length) {
|
|
87
80
|
for (const block of props.blocks) {
|
|
81
|
+
const blockFields = [...block.fields];
|
|
82
|
+
if (block?.admin?.components) {
|
|
83
|
+
blockFields.unshift({
|
|
84
|
+
name: `_components`,
|
|
85
|
+
type: 'ui',
|
|
86
|
+
admin: {
|
|
87
|
+
components: {
|
|
88
|
+
Block: block.admin?.components?.Block,
|
|
89
|
+
BlockLabel: block.admin?.components?.Label
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
88
94
|
schemaMap.set(`lexical_blocks.${block.slug}.fields`, {
|
|
89
|
-
fields:
|
|
95
|
+
fields: blockFields
|
|
90
96
|
});
|
|
91
97
|
schemaMap.set(`lexical_blocks.${block.slug}`, {
|
|
92
98
|
name: `lexical_blocks_${block.slug}`,
|
|
@@ -98,8 +104,21 @@ export const BlocksFeature = createServerFeature({
|
|
|
98
104
|
if (props?.inlineBlocks?.length) {
|
|
99
105
|
// To generate block schemaMap which generates things like the componentMap for admin.Label
|
|
100
106
|
for (const block of props.inlineBlocks) {
|
|
107
|
+
const blockFields = [...block.fields];
|
|
108
|
+
if (block?.admin?.components) {
|
|
109
|
+
blockFields.unshift({
|
|
110
|
+
name: `_components`,
|
|
111
|
+
type: 'ui',
|
|
112
|
+
admin: {
|
|
113
|
+
components: {
|
|
114
|
+
Block: block.admin?.components?.Block,
|
|
115
|
+
BlockLabel: block.admin?.components?.Label
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
101
120
|
schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {
|
|
102
|
-
fields:
|
|
121
|
+
fields: blockFields
|
|
103
122
|
});
|
|
104
123
|
schemaMap.set(`lexical_inline_blocks.${block.slug}`, {
|
|
105
124
|
name: `lexical_inline_blocks_${block.slug}`,
|
|
@@ -111,6 +130,10 @@ export const BlocksFeature = createServerFeature({
|
|
|
111
130
|
return schemaMap;
|
|
112
131
|
},
|
|
113
132
|
i18n,
|
|
133
|
+
markdownTransformers: getBlockMarkdownTransformers({
|
|
134
|
+
blocks: props.blocks,
|
|
135
|
+
inlineBlocks: props.inlineBlocks
|
|
136
|
+
}),
|
|
114
137
|
nodes: [createNode({
|
|
115
138
|
// @ts-expect-error - TODO: fix this
|
|
116
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","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 schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: block.fields,\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 schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: block.fields,\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;IAAEC,MAAM;IAAEC,iBAAiB;IAAEC;EAAK,CAAE;IACnE;IACA,MAAMC,WAAA,GAAwC;MAC5CC,gBAAA,EAAkB,EAAE;MACpBC,sBAAA,EAAwB;IAC1B;IACA,MAAMC,kBAAA,GAAqBP,OAAA,CAAQQ,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEvE,MAAMC,SAAA,GAAY,MAAMvB,cAAA,CAAe;MACrCU,MAAA,EAAQC,OAAA;MACRa,MAAA,EAAQ,CACN;QACEC,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQb,KAAA,CAAMa,MAAM,IAAI;MAC1B,GACA;QACEF,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQb,K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BAAA,EAA2B,CAAChD,yBAAA,CAA0BW,KAAA,CAAMc,YAAY,EAAE;QAC1EmB,IAAA,EAAMzC,qBAAA;QACN8C,WAAA,EAAa,CAAC7C,kBAAA,CAAmBO,KAAA,CAAMc,YAAY;MACrD,GACD;MACDyB,2BAAA,EAA6BvC;IAC/B;EACF;EACAwC,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,kBAAA,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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,SAASA,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