@payloadcms/richtext-lexical 4.0.0-internal.1f9ae9a → 4.0.0-internal.293e026
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/@types/assets.d.js +2 -0
- package/dist/@types/assets.d.js.map +1 -0
- package/dist/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +5 -5
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/Field-VYBSMSRY.js +2 -0
- package/dist/exports/client/Field-VYBSMSRY.js.map +7 -0
- package/dist/exports/client/{RelationshipComponent-RZL743CS.js → RelationshipComponent-YCPAKOL7.js} +1 -1
- package/dist/exports/client/RelationshipComponent-YCPAKOL7.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-5VIL27GI.js +2 -0
- package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
- package/dist/exports/client/chunk-ESITTE3C.js +2 -0
- package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
- package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
- package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
- package/dist/exports/client/{component-CVM4OESA.js → component-PHZQBOJE.js} +2 -2
- package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
- package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +25 -25
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.browser.d.ts +11 -0
- package/dist/exports/server/rsc.browser.d.ts.map +1 -0
- package/dist/exports/server/rsc.browser.js +10 -0
- package/dist/exports/server/rsc.browser.js.map +1 -0
- package/dist/features/blockquote/server/index.d.ts +1 -4
- package/dist/features/blockquote/server/index.d.ts.map +1 -1
- package/dist/features/blockquote/server/index.js +2 -0
- package/dist/features/blockquote/server/index.js.map +1 -1
- package/dist/features/blockquote/server/schema.d.ts +8 -0
- package/dist/features/blockquote/server/schema.d.ts.map +1 -0
- package/dist/features/blockquote/server/schema.js +15 -0
- package/dist/features/blockquote/server/schema.js.map +1 -0
- package/dist/features/blocks/client/component/index.d.ts +2 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +16 -8
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +15 -7
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +4 -2
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/markdownTransformer.js +4 -4
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.d.ts +1 -1
- 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/premade/CodeBlock/Component/Block.d.ts.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts +1 -2
- package/dist/features/blocks/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/blocks/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts +1 -0
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +24 -72
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/markdownTransformer.js +4 -4
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +1 -18
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +2 -10
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/schema.d.ts +45 -0
- package/dist/features/blocks/server/schema.d.ts.map +1 -0
- package/dist/features/blocks/server/schema.js +139 -0
- package/dist/features/blocks/server/schema.js.map +1 -0
- package/dist/features/blocks/server/validate.d.ts +1 -2
- package/dist/features/blocks/server/validate.d.ts.map +1 -1
- package/dist/features/blocks/server/validate.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.d.ts +14 -15
- package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts +14 -15
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts +4 -2
- package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
- package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/upload.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
- package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
- package/dist/features/experimental_table/server/index.d.ts +1 -6
- package/dist/features/experimental_table/server/index.d.ts.map +1 -1
- package/dist/features/experimental_table/server/index.js +4 -0
- package/dist/features/experimental_table/server/index.js.map +1 -1
- package/dist/features/experimental_table/server/schema.d.ts +27 -0
- package/dist/features/experimental_table/server/schema.d.ts.map +1 -0
- package/dist/features/experimental_table/server/schema.js +107 -0
- package/dist/features/experimental_table/server/schema.js.map +1 -0
- package/dist/features/heading/server/index.d.ts +2 -4
- package/dist/features/heading/server/index.d.ts.map +1 -1
- package/dist/features/heading/server/index.js +2 -0
- package/dist/features/heading/server/index.js.map +1 -1
- package/dist/features/heading/server/schema.d.ts +10 -0
- package/dist/features/heading/server/schema.d.ts.map +1 -0
- package/dist/features/heading/server/schema.js +37 -0
- package/dist/features/heading/server/schema.js.map +1 -0
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/client/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/horizontalRule/server/index.d.ts +1 -0
- package/dist/features/horizontalRule/server/index.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/index.js +2 -0
- package/dist/features/horizontalRule/server/index.js.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts +1 -5
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.d.ts.map +1 -1
- package/dist/features/horizontalRule/server/nodes/HorizontalRuleNode.js.map +1 -1
- package/dist/features/horizontalRule/server/schema.d.ts +7 -0
- package/dist/features/horizontalRule/server/schema.d.ts.map +1 -0
- package/dist/features/horizontalRule/server/schema.js +25 -0
- package/dist/features/horizontalRule/server/schema.js.map +1 -0
- package/dist/features/link/client/index.d.ts.map +1 -1
- package/dist/features/link/client/index.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts +1 -1
- package/dist/features/link/client/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/types.js.map +1 -1
- package/dist/features/link/client/plugins/link/index.js.map +1 -1
- package/dist/features/link/markdownTransformer.d.ts +1 -1
- package/dist/features/link/markdownTransformer.d.ts.map +1 -1
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/link/markdownTransformer.spec.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.d.ts +3 -3
- package/dist/features/link/nodes/AutoLinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +2 -1
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.d.ts +3 -3
- package/dist/features/link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +2 -1
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/link/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/link/server/index.d.ts +2 -1
- package/dist/features/link/server/index.d.ts.map +1 -1
- package/dist/features/link/server/index.js +3 -0
- package/dist/features/link/server/index.js.map +1 -1
- package/dist/features/link/server/schema.d.ts +32 -0
- package/dist/features/link/server/schema.d.ts.map +1 -0
- package/dist/features/link/server/schema.js +169 -0
- package/dist/features/link/server/schema.js.map +1 -0
- package/dist/features/link/server/validate.d.ts +1 -1
- package/dist/features/link/server/validate.d.ts.map +1 -1
- package/dist/features/link/server/validate.js.map +1 -1
- package/dist/features/lists/checklist/server/index.d.ts.map +1 -1
- package/dist/features/lists/checklist/server/index.js +3 -0
- package/dist/features/lists/checklist/server/index.js.map +1 -1
- package/dist/features/lists/orderedList/server/index.d.ts.map +1 -1
- package/dist/features/lists/orderedList/server/index.js +3 -0
- package/dist/features/lists/orderedList/server/index.js.map +1 -1
- package/dist/features/lists/plugin/index.d.ts +0 -9
- package/dist/features/lists/plugin/index.d.ts.map +1 -1
- package/dist/features/lists/plugin/index.js.map +1 -1
- package/dist/features/lists/shared/schema.d.ts +18 -0
- package/dist/features/lists/shared/schema.d.ts.map +1 -0
- package/dist/features/lists/shared/schema.js +62 -0
- package/dist/features/lists/shared/schema.js.map +1 -0
- package/dist/features/lists/unorderedList/server/index.d.ts.map +1 -1
- package/dist/features/lists/unorderedList/server/index.js +3 -0
- package/dist/features/lists/unorderedList/server/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts +1 -1
- package/dist/features/relationship/client/plugins/index.d.ts.map +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.d.ts.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.js +9 -40
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/relationship/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/relationship/server/index.d.ts +1 -0
- package/dist/features/relationship/server/index.d.ts.map +1 -1
- package/dist/features/relationship/server/index.js +2 -0
- package/dist/features/relationship/server/index.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +1 -10
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/server/schema.d.ts +28 -0
- package/dist/features/relationship/server/schema.d.ts.map +1 -0
- package/dist/features/relationship/server/schema.js +80 -0
- package/dist/features/relationship/server/schema.js.map +1 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts +23 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.d.ts.map +1 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js +34 -0
- package/dist/features/relationship/shared/filterEnabledRelationshipCollections.js.map +1 -0
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/typesServer.d.ts +17 -40
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.css +2 -2
- package/dist/features/upload/client/component/index.d.ts +1 -1
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.d.ts +1 -1
- package/dist/features/upload/client/plugin/index.d.ts.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.d.ts +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.d.ts.map +1 -1
- package/dist/features/upload/server/graphQLPopulationPromise.js.map +1 -1
- package/dist/features/upload/server/index.d.ts +1 -0
- package/dist/features/upload/server/index.d.ts.map +1 -1
- package/dist/features/upload/server/index.js +3 -2
- package/dist/features/upload/server/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +1 -55
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/server/nodes/conversions.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/conversions.js.map +1 -1
- package/dist/features/upload/server/schema.d.ts +52 -0
- package/dist/features/upload/server/schema.d.ts.map +1 -0
- package/dist/features/upload/server/schema.js +129 -0
- package/dist/features/upload/server/schema.js.map +1 -0
- package/dist/features/upload/server/validate.d.ts +1 -1
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Diff/converters/upload/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/clientEntry.d.ts +29 -0
- package/dist/field/clientEntry.d.ts.map +1 -0
- package/dist/field/clientEntry.js +86 -0
- package/dist/field/clientEntry.js.map +1 -0
- package/dist/field/index.css +9 -12
- package/dist/field/index.js +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +2 -0
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +47 -4
- package/dist/index.js.map +1 -1
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +36 -2
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/lexical/LexicalProvider.js +22 -7
- package/dist/lexical/LexicalProvider.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +5 -1
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/lexical/config/server/sanitize.js +9 -11
- package/dist/lexical/config/server/sanitize.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/types/builtInNodes.d.ts +14 -0
- package/dist/types/builtInNodes.d.ts.map +1 -0
- package/dist/types/builtInNodes.js +203 -0
- package/dist/types/builtInNodes.js.map +1 -0
- package/dist/types/index.d.ts +16 -17
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/jsonSchemaHelpers.d.ts +30 -0
- package/dist/types/jsonSchemaHelpers.d.ts.map +1 -0
- package/dist/types/jsonSchemaHelpers.js +58 -0
- package/dist/types/jsonSchemaHelpers.js.map +1 -0
- package/dist/types/nodeTypes.d.ts +115 -61
- package/dist/types/nodeTypes.d.ts.map +1 -1
- package/dist/types/nodeTypes.js +3 -2
- package/dist/types/nodeTypes.js.map +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/dist/types/schema.js +67 -65
- package/dist/types/schema.js.map +1 -1
- package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
- package/dist/utilities/applyBaseFilterToFields.js +1 -2
- package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts +17 -3
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js +8 -0
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/dist/utilities/buildInitialState.d.ts +2 -1
- package/dist/utilities/buildInitialState.d.ts.map +1 -1
- package/dist/utilities/buildInitialState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/index.css +12 -0
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +7 -3
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
- package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
- package/package.json +8 -7
- package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
- package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
- package/dist/exports/client/RelationshipComponent-RZL743CS.js.map +0 -7
- package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
- package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
- package/dist/exports/client/chunk-FEJXFRL7.js +0 -2
- package/dist/exports/client/chunk-FEJXFRL7.js.map +0 -7
- package/dist/exports/client/chunk-INBEEENE.js +0 -2
- package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
- package/dist/exports/client/component-CVM4OESA.js.map +0 -7
- package/dist/exports/client/componentInline-JJZ2NKW2.js +0 -2
- package/dist/features/link/nodes/types.d.ts +0 -27
- package/dist/features/link/nodes/types.d.ts.map +0 -1
- package/dist/features/link/nodes/types.js +0 -2
- package/dist/features/link/nodes/types.js.map +0 -1
- /package/dist/exports/client/{componentInline-JJZ2NKW2.js.map → componentInline-H24N7GUG.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,
|
|
1
|
+
{"version":3,"file":"InlineBlocksNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,aAAa,EACb,WAAW,EACX,OAAO,EACR,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAIhC,OAAO,EAAyB,aAAa,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAEhF,qBAAa,qBAAsB,SAAQ,aAAa,CAAC,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC;IACjF,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,iBAAiB,CAAA;gBAEf,EACV,WAAW,EACX,MAAM,EACN,GAAG,GACJ,EAAE;QACD,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,EAAE,iBAAiB,CAAA;QACzB,GAAG,CAAC,EAAE,OAAO,CAAA;KACd;WAMe,KAAK,CAAC,IAAI,EAAE,qBAAqB,GAAG,qBAAqB;WAQzD,OAAO,IAAI,MAAM;WAIjB,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI;WAIpD,UAAU,CAAC,cAAc,EAAE,yBAAyB,GAAG,qBAAqB;IAK5F,MAAM,CAAC,QAAQ,IAAI,KAAK;IAIxB,SAAS;IAIA,SAAS,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW;IAM7C,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI;IAIzE,SAAS,IAAI,eAAe;IAS5B,UAAU,IAAI,yBAAyB;IAQhD,cAAc,IAAI,MAAM;IAIxB,SAAS,IAAI,iBAAiB;IAIrB,cAAc,IAAI,MAAM;IAIxB,QAAQ;IAIjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,sBAAsB,CAAC,EAAE,OAAO,GAAG,IAAI;IAQnE,SAAS,IAAI,OAAO;CAG9B;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,GACvC,qBAAqB,CASvB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,qBAAqB,GAAG,SAAS,GAC3D,IAAI,IAAI,qBAAqB,CAE/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineBlocksNode.js","names":["addClassNamesToElement","ObjectID","$applyNodeReplacement","DecoratorNode","ServerInlineBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","key","clone","node","__key","getType","importDOM","importJSON","serializedNode","$createServerInlineBlockNode","isInline","canIndent","createDOM","config","element","document","createElement","theme","inlineBlock","decorate","editor","exportDOM","classList","add","text","createTextNode","getTextContent","append","exportJSON","type","getFields","version","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","updateDOM","id","default","toHexString","$isServerInlineBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n
|
|
1
|
+
{"version":3,"file":"InlineBlocksNode.js","names":["addClassNamesToElement","ObjectID","$applyNodeReplacement","DecoratorNode","ServerInlineBlockNode","__cacheBuster","__fields","constructor","cacheBuster","fields","key","clone","node","__key","getType","importDOM","importJSON","serializedNode","$createServerInlineBlockNode","isInline","canIndent","createDOM","config","element","document","createElement","theme","inlineBlock","decorate","editor","exportDOM","classList","add","text","createTextNode","getTextContent","append","exportJSON","type","getFields","version","getCacheBuster","getLatest","setFields","preventFormStateUpdate","writable","getWritable","updateDOM","id","default","toHexString","$isServerInlineBlockNode"],"sources":["../../../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],"sourcesContent":["import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n} from 'lexical'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport ObjectID from 'bson-objectid'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\n\nimport type { InlineBlockFields, SerializedInlineBlockNode } from '../schema.js'\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, config?.theme?.inlineBlock)\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return $applyNodeReplacement(\n new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n }),\n )\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],"mappings":"AAWA,SAASA,sBAAsB,QAAQ;AACvC,OAAOC,QAAA,MAAc;AACrB,SAASC,qBAAqB,EAAEC,aAAa,QAAQ;AAIrD,OAAO,MAAMC,qBAAA,SAA8BD,aAAA;EACzCE,aAAA;EACAC,QAAA;EAEAC,YAAY;IACVC,WAAW;IACXC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACA,GAAA;IACN,IAAI,CAACJ,QAAQ,GAAGG,MAAA;IAChB,IAAI,CAACJ,aAAa,GAAGG,WAAA,IAAe;EACtC;EAEA,OAAgBG,MAAMC,IAA2B,EAAyB;IACxE,OAAO,IAAI,IAAI,CAAC;MACdJ,WAAA,EAAaI,IAAA,CAAKP,aAAa;MAC/BI,MAAA,EAAQG,IAAA,CAAKN,QAAQ;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AAMC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAASvC,QAAQ,GAAGG,MAAA;IACpB,IAAI,CAACmC,sBAAA,EAAwB;MAC3BC,QAAA,CAASxC,aAAa;IACxB;EACF;EAES0C,UAAA,EAAqB;IAC5B,OAAO;EACT;AACF;AAEA,OAAO,SAAS7B,6BACdT,MAAwC;EAExC,OAAOP,qBAAA,CACL,IAAIE,qBAAA,CAAsB;IACxBK,MAAA,EAAQ;MACN,GAAGA,MAAM;MACTuC,EAAA,EAAIvC,MAAA,EAAQuC,EAAA,IAAM,IAAI/C,QAAA,CAASgD,OAAO,GAAGC,WAAW;IACtD;EACF;AAEJ;AAEA,OAAO,SAASC,yBACdvC,IAA4D;EAE5D,OAAOA,IAAA,YAAgBR,qBAAA;AACzB","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Block, JsonObject } from 'payload';
|
|
2
|
+
import type { LexicalElementFormat } from '../../../types/nodeTypes.js';
|
|
3
|
+
import type { JSONSchemaFn } from '../../typesServer.js';
|
|
4
|
+
type BaseBlockFields<TFields extends JsonObject = JsonObject> = {
|
|
5
|
+
blockName?: null | string;
|
|
6
|
+
blockType: string;
|
|
7
|
+
} & TFields;
|
|
8
|
+
export type BlockFields<TFields extends JsonObject = JsonObject> = {
|
|
9
|
+
id: string;
|
|
10
|
+
} & BaseBlockFields<TFields>;
|
|
11
|
+
export type BlockFieldsOptionalID<TFields extends JsonObject = JsonObject> = {
|
|
12
|
+
id?: string;
|
|
13
|
+
} & BaseBlockFields<TFields>;
|
|
14
|
+
export type InlineBlockFields<TFields extends JsonObject = JsonObject> = {
|
|
15
|
+
blockType: string;
|
|
16
|
+
id: string;
|
|
17
|
+
} & TFields;
|
|
18
|
+
export type SerializedBlockNode<TFields extends {
|
|
19
|
+
blockType: string;
|
|
20
|
+
} = {
|
|
21
|
+
blockType: string;
|
|
22
|
+
}> = TFields extends unknown ? {
|
|
23
|
+
fields: {
|
|
24
|
+
blockName?: null | string;
|
|
25
|
+
id: string;
|
|
26
|
+
} & Omit<TFields, 'blockName' | 'id'>;
|
|
27
|
+
format: LexicalElementFormat;
|
|
28
|
+
type: 'block';
|
|
29
|
+
version: number;
|
|
30
|
+
} : never;
|
|
31
|
+
export type SerializedInlineBlockNode<TFields extends {
|
|
32
|
+
blockType: string;
|
|
33
|
+
} = {
|
|
34
|
+
blockType: string;
|
|
35
|
+
}> = TFields extends unknown ? {
|
|
36
|
+
fields: {
|
|
37
|
+
id: string;
|
|
38
|
+
} & Omit<TFields, 'id'>;
|
|
39
|
+
type: 'inlineBlock';
|
|
40
|
+
version: number;
|
|
41
|
+
} : never;
|
|
42
|
+
export declare const createBlockNodeJSONSchema: (blockConfigs: Block[]) => JSONSchemaFn;
|
|
43
|
+
export declare const createInlineBlockNodeJSONSchema: (inlineBlockConfigs: Block[]) => JSONSchemaFn;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAIhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AACvE,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxE,KAAK,eAAe,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI;IAC9D,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;CAClB,GAAG,OAAO,CAAA;AAEX,MAAM,MAAM,WAAW,CAAC,OAAO,SAAS,UAAU,GAAG,UAAU,IAAI;IACjE,EAAE,EAAE,MAAM,CAAA;CACX,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;AAE5B,MAAM,MAAM,qBAAqB,C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ieldsToJSONSchema, flattenAllFields, registerBlockInterface } from 'payload';
|
|
2
|
+
import { formatSchema } from '../../../types/jsonSchemaHelpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* MUST stay byte-for-byte in sync with the runtime `SerializedBlockNode` and
|
|
5
|
+
* `SerializedInlineBlockNode` declared above.
|
|
6
|
+
*/
|
|
7
|
+
const BLOCK_NODES_TS = `export type SerializedBlockNode<TFields extends { blockType: string }> = TFields extends unknown ? {
|
|
8
|
+
type: 'block';
|
|
9
|
+
format: LexicalElementFormat;
|
|
10
|
+
version: number;
|
|
11
|
+
fields: { id: string; blockName?: string | null } & Omit<TFields, 'id' | 'blockName'>;
|
|
12
|
+
} : never;
|
|
13
|
+
export type SerializedInlineBlockNode<TFields extends { blockType: string }> = TFields extends unknown ? {
|
|
14
|
+
type: 'inlineBlock';
|
|
15
|
+
version: number;
|
|
16
|
+
fields: { id: string } & Omit<TFields, 'id'>;
|
|
17
|
+
} : never;`;
|
|
18
|
+
/**
|
|
19
|
+
* JSON Schema for one block's `fields:` payload. Strips Payload's auto-added
|
|
20
|
+
* `id`/`blockName` and re-adds them with strict runtime types: required
|
|
21
|
+
* non-null `id`, optional `blockName?: string | null` (omitted for inline
|
|
22
|
+
* blocks). Registers the interface through `registerBlockInterface` (shared with
|
|
23
|
+
* payload core) and returns its collision-safe name.
|
|
24
|
+
*/
|
|
25
|
+
const buildBlockFieldsSchema = (block, args, {
|
|
26
|
+
isInlineBlock
|
|
27
|
+
}) => {
|
|
28
|
+
const flattened = flattenAllFields({
|
|
29
|
+
fields: block.fields
|
|
30
|
+
});
|
|
31
|
+
const userFieldsSchema = args.config ? fieldsToJSONSchema({
|
|
32
|
+
collectionIDFieldTypes: args.collectionIDFieldTypes,
|
|
33
|
+
config: args.config,
|
|
34
|
+
fields: flattened,
|
|
35
|
+
i18n: args.i18n,
|
|
36
|
+
interfaceNameDefinitions: args.interfaceNameDefinitions,
|
|
37
|
+
typeStringDefinitions: args.typeStringDefinitions
|
|
38
|
+
}) : {
|
|
39
|
+
properties: {},
|
|
40
|
+
required: []
|
|
41
|
+
};
|
|
42
|
+
const {
|
|
43
|
+
id: _stripId,
|
|
44
|
+
blockName: _stripBlockName,
|
|
45
|
+
...userOnlyProperties
|
|
46
|
+
} = userFieldsSchema.properties ?? {};
|
|
47
|
+
const userOnlyRequired = (userFieldsSchema.required ?? []).filter(r => r !== 'id' && r !== 'blockName');
|
|
48
|
+
const properties = {
|
|
49
|
+
id: {
|
|
50
|
+
type: 'string'
|
|
51
|
+
},
|
|
52
|
+
blockType: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
const: block.slug
|
|
55
|
+
},
|
|
56
|
+
...userOnlyProperties
|
|
57
|
+
};
|
|
58
|
+
const required = ['id', 'blockType', ...userOnlyRequired];
|
|
59
|
+
if (!isInlineBlock) {
|
|
60
|
+
properties.blockName = {
|
|
61
|
+
type: ['string', 'null']
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const fieldsSchema = {
|
|
65
|
+
type: 'object',
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
properties,
|
|
68
|
+
required
|
|
69
|
+
};
|
|
70
|
+
return registerBlockInterface(block, fieldsSchema, args.interfaceNameDefinitions);
|
|
71
|
+
};
|
|
72
|
+
export const createBlockNodeJSONSchema = blockConfigs => args => {
|
|
73
|
+
args.typeStringDefinitions.add(BLOCK_NODES_TS);
|
|
74
|
+
const definitionNames = blockConfigs.map(block => buildBlockFieldsSchema(block, args, {
|
|
75
|
+
isInlineBlock: false
|
|
76
|
+
}));
|
|
77
|
+
const fieldsSchema = definitionNames.length === 0 ? {
|
|
78
|
+
type: 'object',
|
|
79
|
+
additionalProperties: true
|
|
80
|
+
} : definitionNames.length === 1 ? {
|
|
81
|
+
$ref: `#/$defs/${definitionNames[0]}`
|
|
82
|
+
} : {
|
|
83
|
+
oneOf: definitionNames.map(name => ({
|
|
84
|
+
$ref: `#/$defs/${name}`
|
|
85
|
+
}))
|
|
86
|
+
};
|
|
87
|
+
const tsType = definitionNames.length > 0 ? `SerializedBlockNode<${definitionNames.join(' | ')}>` : `SerializedBlockNode<{ blockType: string }>`;
|
|
88
|
+
return {
|
|
89
|
+
type: 'object',
|
|
90
|
+
additionalProperties: false,
|
|
91
|
+
properties: {
|
|
92
|
+
type: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
const: 'block'
|
|
95
|
+
},
|
|
96
|
+
fields: fieldsSchema,
|
|
97
|
+
format: formatSchema,
|
|
98
|
+
version: {
|
|
99
|
+
type: 'integer'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
required: ['fields', 'format', 'type', 'version'],
|
|
103
|
+
tsType
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export const createInlineBlockNodeJSONSchema = inlineBlockConfigs => args => {
|
|
107
|
+
args.typeStringDefinitions.add(BLOCK_NODES_TS);
|
|
108
|
+
const definitionNames = inlineBlockConfigs.map(block => buildBlockFieldsSchema(block, args, {
|
|
109
|
+
isInlineBlock: true
|
|
110
|
+
}));
|
|
111
|
+
const fieldsSchema = definitionNames.length === 0 ? {
|
|
112
|
+
type: 'object',
|
|
113
|
+
additionalProperties: true
|
|
114
|
+
} : definitionNames.length === 1 ? {
|
|
115
|
+
$ref: `#/$defs/${definitionNames[0]}`
|
|
116
|
+
} : {
|
|
117
|
+
oneOf: definitionNames.map(name => ({
|
|
118
|
+
$ref: `#/$defs/${name}`
|
|
119
|
+
}))
|
|
120
|
+
};
|
|
121
|
+
const tsType = definitionNames.length > 0 ? `SerializedInlineBlockNode<${definitionNames.join(' | ')}>` : `SerializedInlineBlockNode<{ blockType: string }>`;
|
|
122
|
+
return {
|
|
123
|
+
type: 'object',
|
|
124
|
+
additionalProperties: false,
|
|
125
|
+
properties: {
|
|
126
|
+
type: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
const: 'inlineBlock'
|
|
129
|
+
},
|
|
130
|
+
fields: fieldsSchema,
|
|
131
|
+
version: {
|
|
132
|
+
type: 'integer'
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
required: ['fields', 'type', 'version'],
|
|
136
|
+
tsType
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":["fieldsToJSONSchema","flattenAllFields","registerBlockInterface","formatSchema","BLOCK_NODES_TS","buildBlockFieldsSchema","block","args","isInlineBlock","flattened","fields","userFieldsSchema","config","collectionIDFieldTypes","i18n","interfaceNameDefinitions","typeStringDefinitions","properties","required","id","_stripId","blockName","_stripBlockName","userOnlyProperties","userOnlyRequired","filter","r","type","blockType","const","slug","fieldsSchema","additionalProperties","createBlockNodeJSONSchema","blockConfigs","add","definitionNames","map","length","$ref","oneOf","name","tsType","join","format","version","createInlineBlockNodeJSONSchema","inlineBlockConfigs"],"sources":["../../../../src/features/blocks/server/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type { Block, JsonObject } from 'payload'\n\nimport { fieldsToJSONSchema, flattenAllFields, registerBlockInterface } from 'payload'\n\nimport type { LexicalElementFormat } from '../../../types/nodeTypes.js'\nimport type { JSONSchemaArgs, JSONSchemaFn } from '../../typesServer.js'\n\nimport { formatSchema } from '../../../types/jsonSchemaHelpers.js'\n\ntype BaseBlockFields<TFields extends JsonObject = JsonObject> = {\n blockName?: null | string\n blockType: string\n} & TFields\n\nexport type BlockFields<TFields extends JsonObject = JsonObject> = {\n id: string\n} & BaseBlockFields<TFields>\n\nexport type BlockFieldsOptionalID<TFields extends JsonObject = JsonObject> = {\n id?: string\n} & BaseBlockFields<TFields>\n\nexport type InlineBlockFields<TFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TFields\n\n// Distributive (`TFields extends unknown ?`) so `SerializedBlockNode<A | B>` expands to\n// `SerializedBlockNode<A> | SerializedBlockNode<B>` - i.e. a discriminated union where each block\n// keeps its own fields. Without this, `Omit<A | B, ...>` collapses to the blocks' common keys and\n// every block-specific field is lost. Lets users write either form interchangeably.\nexport type SerializedBlockNode<TFields extends { blockType: string } = { blockType: string }> =\n TFields extends unknown\n ? {\n fields: { blockName?: null | string; id: string } & Omit<TFields, 'blockName' | 'id'>\n format: LexicalElementFormat\n type: 'block'\n version: number\n }\n : never\n\nexport type SerializedInlineBlockNode<\n TFields extends { blockType: string } = { blockType: string },\n> = TFields extends unknown\n ? {\n fields: { id: string } & Omit<TFields, 'id'>\n type: 'inlineBlock'\n version: number\n }\n : never\n\n/**\n * MUST stay byte-for-byte in sync with the runtime `SerializedBlockNode` and\n * `SerializedInlineBlockNode` declared above.\n */\nconst BLOCK_NODES_TS = `export type SerializedBlockNode<TFields extends { blockType: string }> = TFields extends unknown ? {\n type: 'block';\n format: LexicalElementFormat;\n version: number;\n fields: { id: string; blockName?: string | null } & Omit<TFields, 'id' | 'blockName'>;\n} : never;\nexport type SerializedInlineBlockNode<TFields extends { blockType: string }> = TFields extends unknown ? {\n type: 'inlineBlock';\n version: number;\n fields: { id: string } & Omit<TFields, 'id'>;\n} : never;`\n\n/**\n * JSON Schema for one block's `fields:` payload. Strips Payload's auto-added\n * `id`/`blockName` and re-adds them with strict runtime types: required\n * non-null `id`, optional `blockName?: string | null` (omitted for inline\n * blocks). Registers the interface through `registerBlockInterface` (shared with\n * payload core) and returns its collision-safe name.\n */\nconst buildBlockFieldsSchema = (\n block: Block,\n args: JSONSchemaArgs,\n { isInlineBlock }: { isInlineBlock: boolean },\n): string => {\n const flattened = flattenAllFields({ fields: block.fields })\n const userFieldsSchema = args.config\n ? fieldsToJSONSchema({\n collectionIDFieldTypes: args.collectionIDFieldTypes,\n config: args.config,\n fields: flattened,\n i18n: args.i18n,\n interfaceNameDefinitions: args.interfaceNameDefinitions,\n typeStringDefinitions: args.typeStringDefinitions,\n })\n : { properties: {}, required: [] }\n\n const {\n id: _stripId,\n blockName: _stripBlockName,\n ...userOnlyProperties\n } = (userFieldsSchema.properties ?? {}) as { [k: string]: JSONSchema4 }\n const userOnlyRequired = (userFieldsSchema.required ?? []).filter(\n (r) => r !== 'id' && r !== 'blockName',\n )\n\n const properties: { [k: string]: JSONSchema4 } = {\n id: { type: 'string' },\n blockType: { type: 'string', const: block.slug },\n ...userOnlyProperties,\n }\n const required = ['id', 'blockType', ...userOnlyRequired]\n\n if (!isInlineBlock) {\n properties.blockName = { type: ['string', 'null'] }\n }\n\n const fieldsSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties,\n required,\n }\n\n return registerBlockInterface(block, fieldsSchema, args.interfaceNameDefinitions)\n}\n\nexport const createBlockNodeJSONSchema =\n (blockConfigs: Block[]): JSONSchemaFn =>\n (args) => {\n args.typeStringDefinitions.add(BLOCK_NODES_TS)\n const definitionNames = blockConfigs.map((block) =>\n buildBlockFieldsSchema(block, args, { isInlineBlock: false }),\n )\n\n const fieldsSchema: JSONSchema4 =\n definitionNames.length === 0\n ? { type: 'object', additionalProperties: true }\n : definitionNames.length === 1\n ? { $ref: `#/$defs/${definitionNames[0]!}` }\n : { oneOf: definitionNames.map((name) => ({ $ref: `#/$defs/${name}` })) }\n\n const tsType =\n definitionNames.length > 0\n ? `SerializedBlockNode<${definitionNames.join(' | ')}>`\n : `SerializedBlockNode<{ blockType: string }>`\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', const: 'block' },\n fields: fieldsSchema,\n format: formatSchema,\n version: { type: 'integer' },\n },\n required: ['fields', 'format', 'type', 'version'],\n tsType,\n }\n }\n\nexport const createInlineBlockNodeJSONSchema =\n (inlineBlockConfigs: Block[]): JSONSchemaFn =>\n (args) => {\n args.typeStringDefinitions.add(BLOCK_NODES_TS)\n const definitionNames = inlineBlockConfigs.map((block) =>\n buildBlockFieldsSchema(block, args, { isInlineBlock: true }),\n )\n\n const fieldsSchema: JSONSchema4 =\n definitionNames.length === 0\n ? { type: 'object', additionalProperties: true }\n : definitionNames.length === 1\n ? { $ref: `#/$defs/${definitionNames[0]!}` }\n : { oneOf: definitionNames.map((name) => ({ $ref: `#/$defs/${name}` })) }\n\n const tsType =\n definitionNames.length > 0\n ? `SerializedInlineBlockNode<${definitionNames.join(' | ')}>`\n : `SerializedInlineBlockNode<{ blockType: string }>`\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', const: 'inlineBlock' },\n fields: fieldsSchema,\n version: { type: 'integer' },\n },\n required: ['fields', 'type', 'version'],\n tsType,\n }\n }\n"],"mappings":"AAGA,SAASA,kBAAkB,EAAEC,gBAAgB,EAAEC,sBAAsB,QAAQ;AAK7E,SAASC,YAAY,QAAQ;AA4C7B;;;;AAIA,MAAMC,cAAA,GAAiB;;;;;;;;;;WAUZ;AAEX;;;;;;;AAOA,MAAMC,sBAAA,GAAyBA,CAC7BC,KAAA,EACAC,IAAA,EACA;EAAEC;AAAa,CAA8B;EAE7C,MAAMC,SAAA,GAAYR,gBAAA,CAAiB;IAAES,MAAA,EAAQJ,KAAA,CAAMI;EAAO;EAC1D,MAAMC,gBAAA,GAAmBJ,IAAA,CAAKK,MAAM,GAChCZ,kBAAA,CAAmB;IACjBa,sBAAA,EAAwBN,IAAA,CAAKM,sBAAsB;IACnDD,MAAA,EAAQL,IAAA,CAAKK,MAAM;IACnBF,MAAA,EAAQD,SAAA;IACRK,IAAA,EAAMP,IAAA,CAAKO,IAAI;IACfC,wBAAA,EAA0BR,IAAA,CAAKQ,wBAAwB;IACvDC,qBAAA,EAAuBT,IAAA,CAAKS;EAC9B,KACA;IAAEC,UAAA,EAAY,CAAC;IAAGC,QAAA,EAAU;EAAG;EAEnC,MAAM;IACJC,EAAA,EAAIC,QAAQ;IACZC,SAAA,EAAWC,eAAe;IAC1B,GAAGC;EAAA,CACJ,GAAIZ,gBAAA,CAAiBM,UAAU,IAAI,CAAC;EACrC,MAAMO,gBAAA,GAAmB,CAACb,gBAAA,CAAiBO,QAAQ,IAAI,EAAE,EAAEO,MAAM,CAC9DC,CAAA,IAAMA,CAAA,KAAM,QAAQA,C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","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Block } from 'payload';
|
|
2
2
|
import type { NodeValidation } from '../../typesServer.js';
|
|
3
|
-
import type { SerializedBlockNode } from './
|
|
4
|
-
import type { SerializedInlineBlockNode } from './nodes/InlineBlocksNode.js';
|
|
3
|
+
import type { SerializedBlockNode, SerializedInlineBlockNode } from './schema.js';
|
|
5
4
|
/**
|
|
6
5
|
* Runs validation for blocks. This function will determine if the rich text field itself is valid. It does not handle
|
|
7
6
|
* block field error paths - this is done by the `beforeChangeTraverseFields` call in the `beforeChange` hook, called from the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAe,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAe,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE9F;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,KAAK,EAAE,KACd,cAAc,CAAC,mBAAmB,GAAG,yBAAyB,CAqDhE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","names":["fieldSchemasToFormState","blockValidationHOC","blocks","node","validation","blockFieldData","fields","options","id","collectionSlug","data","operation","preferences","req","block","find","slug","blockType","result","documentData","fieldSchemaMap","undefined","initialBlockData","permissions","renderAllFields","schemaPath","errorPathsSet","Set","fieldKey","fieldState","errorPaths","length","errorPath","add","Array","from","join"],"sources":["../../../../src/features/blocks/server/validate.ts"],"sourcesContent":["import type { Block } from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { NodeValidation } from '../../typesServer.js'\nimport type { BlockFields, SerializedBlockNode
|
|
1
|
+
{"version":3,"file":"validate.js","names":["fieldSchemasToFormState","blockValidationHOC","blocks","node","validation","blockFieldData","fields","options","id","collectionSlug","data","operation","preferences","req","block","find","slug","blockType","result","documentData","fieldSchemaMap","undefined","initialBlockData","permissions","renderAllFields","schemaPath","errorPathsSet","Set","fieldKey","fieldState","errorPaths","length","errorPath","add","Array","from","join"],"sources":["../../../../src/features/blocks/server/validate.ts"],"sourcesContent":["import type { Block } from 'payload'\n\nimport { fieldSchemasToFormState } from '@payloadcms/ui/forms/fieldSchemasToFormState'\n\nimport type { NodeValidation } from '../../typesServer.js'\nimport type { BlockFields, SerializedBlockNode, SerializedInlineBlockNode } from './schema.js'\n\n/**\n * Runs validation for blocks. This function will determine if the rich text field itself is valid. It does not handle\n * block field error paths - this is done by the `beforeChangeTraverseFields` call in the `beforeChange` hook, called from the\n * rich text adapter.\n */\nexport const blockValidationHOC = (\n blocks: Block[],\n): NodeValidation<SerializedBlockNode | SerializedInlineBlockNode> => {\n return async ({ node, validation }) => {\n const blockFieldData = node.fields ?? ({} as BlockFields)\n\n const {\n options: { id, collectionSlug, data, operation, preferences, req },\n } = validation\n\n // find block\n const block = blocks.find((block) => block.slug === blockFieldData.blockType)\n\n // validate block\n if (!block) {\n return `Block ${blockFieldData.blockType} not found`\n }\n\n /**\n * Run fieldSchemasToFormState as that properly validates block and block sub-fields\n */\n\n const result = await fieldSchemasToFormState({\n id,\n collectionSlug,\n data: blockFieldData,\n documentData: data,\n fields: block.fields,\n fieldSchemaMap: undefined,\n initialBlockData: blockFieldData,\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n permissions: {},\n preferences,\n renderAllFields: false,\n req,\n schemaPath: '',\n })\n\n const errorPathsSet = new Set<string>()\n for (const fieldKey in result) {\n const fieldState = result[fieldKey]\n if (fieldState?.errorPaths?.length) {\n for (const errorPath of fieldState.errorPaths) {\n errorPathsSet.add(errorPath)\n }\n }\n }\n const errorPaths = Array.from(errorPathsSet)\n\n if (errorPaths.length) {\n return 'The following fields are invalid: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAKxC;;;;;AAKA,OAAO,MAAMC,kBAAA,GACXC,MAAA;EAEA,OAAO,OAAO;IAAEC,IAAI;IAAEC;EAAU,CAAE;IAChC,MAAMC,cAAA,GAAiBF,IAAA,CAAKG,MAAM,IAAK,CAAC;IAExC,MAAM;MACJC,OAAA,EAAS;QAAEC,EAAE;QAAEC,cAAc;QAAEC,IAAI;QAAEC,SAAS;QAAEC,WAAW;QAAEC;MAAG;IAAE,CACnE,GAAGT,UAAA;IAEJ;IACA,MAAMU,KAAA,GAAQZ,MAAA,CAAOa,IAAI,CAAED,KAAA,IAAUA,KAAA,CAAME,IAAI,KAAKX,cAAA,CAAeY,SAAS;IAE5E;IACA,IAAI,CAACH,KAAA,EAAO;MACV,OAAO,SAAST,cAAA,CAAeY,SAAS,YAAY;IACtD;IAEA;;;IAIA,MAAMC,MAAA,GAAS,MAAMlB,uBAAA,CAAwB;MAC3CQ,EAAA;MACAC,cAAA;MACAC,IAAA,EAAML,cAAA;MACNc,YAAA,EAAcT,IAAA;MACdJ,MAAA,EAAQQ,KAAA,CAAMR,MAAM;MACpBc,cAAA,EAAgBC,SAAA;MAChBC,gBAAA,EAAkBjB,cAAA;MAClBM,SAAA,EAAWA,SAAA,KAAc,YAAYA,SAAA,KAAc,WAAWA,SAAA,GAAY;MAC1EY,WAAA,EAAa,CAAC;MACdX,WAAA;MACAY,eAAA,EAAiB;MACjBX,GAAA;MACAY,UAAA,EAAY;IACd;IAEA,MAAMC,aAAA,GAAgB,IAAIC,GAAA;IAC1B,KAAK,MAAMC,QAAA,IAAYV,MAAA,EAAQ;MAC7B,MAAMW,UAAA,GAAaX,MAAM,CAACU,QAAA,CAAS;MACnC,IAAIC,UAAA,EAAYC,UAAA,EAAYC,MAAA,EAAQ;QAClC,KAAK,MAAMC,SAAA,IAAaH,UAAA,CAAWC,UAAU,EAAE;UAC7CJ,aAAA,CAAcO,GAAG,CAACD,SAAA;QACpB;MACF;IACF;IACA,MAAMF,UAAA,GAAaI,KAAA,CAAMC,IAAI,CAACT,aAAA;IAE9B,IAAII,UAAA,CAAWC,MAAM,EAAE;MACrB,OAAO,uCAAuCD,UAAA,CAAWM,IAAI,CAAC;IAChE;IAEA,OAAO;EACT;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":["escapeHTML","UploadHTMLConverterAsync","upload","node","populate","providedStyleTag","uploadNode","uploadDoc","undefined","value","id","collectionSlug","relationTo","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","String","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/async/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport escapeHTML from 'escape-html'\n\nimport type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/
|
|
1
|
+
{"version":3,"file":"upload.js","names":["escapeHTML","UploadHTMLConverterAsync","upload","node","populate","providedStyleTag","uploadNode","uploadDoc","undefined","value","id","collectionSlug","relationTo","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","String","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/async/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport escapeHTML from 'escape-html'\n\nimport type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/schema.js'\nimport type { HTMLConvertersAsync } from '../types.js'\n\nexport const UploadHTMLConverterAsync: HTMLConvertersAsync<SerializedUploadNode> = {\n upload: async ({ node, populate, providedStyleTag }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n if (!populate) {\n return ''\n }\n uploadDoc = await populate<FileData & TypeWithID>({\n id: uploadNode.value,\n collectionSlug: uploadNode.relationTo,\n })\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = escapeHTML(\n (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || '',\n )\n\n const url = escapeHTML(uploadDoc.url ?? '')\n\n // 1) If upload is NOT an image, return a link\n if (!uploadDoc.mimeType.startsWith('image')) {\n return `<a${providedStyleTag} href=\"${url}\" rel=\"noopener noreferrer\">${escapeHTML(uploadDoc.filename ?? '')}</a>`\n }\n\n // 2) If image has no different sizes, return a simple <img />\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return `\n <img${providedStyleTag}\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n }\n\n // 3) If image has different sizes, build a <picture> element with <source> tags\n let pictureHTML = ''\n\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSize\n\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n\n pictureHTML += `\n <source\n media=\"(max-width: ${escapeHTML(String(imageSize.width))}px)\"\n srcset=\"${escapeHTML(imageSize.url)}\"\n type=\"${escapeHTML(imageSize.mimeType)}\"\n />\n `\n }\n\n pictureHTML += `\n <img\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n\n return `<picture${providedStyleTag}>${pictureHTML}</picture>`\n },\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AAMvB,OAAO,MAAMC,wBAAA,GAAsE;EACjFC,MAAA,EAAQ,MAAAA,CAAO;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAgB,CAAE;IACjD,MAAMC,UAAA,GAAaH,IAAA;IAEnB,IAAII,SAAA,GAAiDC,SAAA;IAErD;IACA,IAAI,OAAOF,UAAA,CAAWG,KAAK,KAAK,UAAU;MACxC,IAAI,CAACL,QAAA,EAAU;QACb,OAAO;MACT;MACAG,SAAA,GAAY,MAAMH,QAAA,CAAgC;QAChDM,EAAA,EAAIJ,UAAA,CAAWG,KAAK;QACpBE,cAAA,EAAgBL,UAAA,CAAWM;MAC7B;IACF,OAAO;MACLL,SAAA,GAAYD,UAAA,CAAWG,KAAK;IAC9B;IAEA,IAAI,CAACF,SAAA,EAAW;MACd,OAAO;IACT;IAEA,MAAMM,GAAA,GAAMb,UAAA,CACVG,IAAC,CAAKW,MAAM,EAAED,GAAA,IAAmBN,SAAA,EAAgCM,GAAA,IAAO;IAG1E,MAAME,GAAA,GAAMf,UAAA,CAAWO,SAAA,CAAUQ,GAAG,IAAI;IAExC;IACA,IAAI,CAACR,SAAA,CAAUS,QAAQ,CAACC,UAAU,CAAC,UAAU;MAC3C,OAAO,KAAKZ,gBAAA,UAA0BU,GAAA,+BAAkCf,UAAA,CAAWO,SAAA,CAAUW,QAAQ,IAAI,SAAS;IACpH;IAEA;IACA,IAAI,CAACX,SAAA,CAAUY,KAAK,IAAI,CAACC,MAAA,CAAOC,IAAI,CAACd,SAAA,CAAUY,KAAK,EAAEG,MAAM,EAAE;MAC5D,OAAO;cACCjB,gBAAA;iBACGQ,GAAA;oBACGb,UAAA,CAAWuB,MAAA,CAAOhB,SAAA,CAAUiB,MAAM,IAAI;iBACzCT,GAAA;mBACEf,UAAA,CAAWuB,MAAA,CAAOhB,SAAA,CAAUkB,KAAK,IAAI;;OAEjD;IACH;IAEA;IACA,IAAIC,WAAA,GAAc;IAElB,KAAK,MAAMC,IAAA,IAAQpB,SAAA,CAAUY,KAAK,EAAE;MAClC,MAAMS,SAAA,GAAYrB,SAAA,CAAUY,KAAK,CAACQ,IAAA,CAAK;MAEvC,IACE,CAACC,SAAA,IACD,CAACA,SAAA,CAAUH,KAAK,IAChB,CAACG,SAAA,CAAUJ,MAAM,IACjB,CAACI,SAAA,CAAUZ,QAAQ,IACnB,CAACY,SAAA,CAAUC,QAAQ,IACnB,CAACD,SAAA,CAAUV,QAAQ,IACnB,CAACU,SAAA,CAAUb,GAAG,EACd;QACA;MACF;MAEAW,WAAA,IAAe;;+BAEU1B,UAAA,CAAWuB,MAAA,CAAOK,SAAA,CAAUH,KAAK;oBAC5CzB,UAAA,CAAW4B,SAAA,CAAUb,GAAG;kBAC1Bf,UAAA,CAAW4B,SAAA,CAAUZ,QAAQ;;OAExC;IACH;IAEAU,WAAA,IAAe;;eAEJb,GAAA;kBACGb,UAAA,CAAWuB,MAAA,CAAOhB,SAAA,CAAUiB,MAAM,IAAI;eACzCT,GAAA;iBACEf,UAAA,CAAWuB,MAAA,CAAOhB,SAAA,CAAUkB,KAAK,IAAI;;KAEjD;IAED,OAAO,WAAWpB,gBAAA,IAAoBqB,WAAA,YAAuB;EAC/D;AACF","ignoreList":[]}
|
|
@@ -46,26 +46,24 @@ export type HTMLConvertersAsync<T extends {
|
|
|
46
46
|
}>>;
|
|
47
47
|
} & {
|
|
48
48
|
blocks?: {
|
|
49
|
-
[K in Extract<
|
|
49
|
+
[K in Extract<T, {
|
|
50
50
|
type: 'block';
|
|
51
|
-
}>
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
}>['fields']['blockType']]?: HTMLConverterAsync<Extract<T, {
|
|
52
|
+
fields: {
|
|
53
|
+
blockType: K;
|
|
54
|
+
};
|
|
54
55
|
type: 'block';
|
|
55
|
-
}
|
|
56
|
-
blockType: K;
|
|
57
|
-
}>> : SerializedBlockNode>;
|
|
56
|
+
}>>;
|
|
58
57
|
};
|
|
59
58
|
inlineBlocks?: {
|
|
60
|
-
[K in Extract<
|
|
59
|
+
[K in Extract<T, {
|
|
61
60
|
type: 'inlineBlock';
|
|
62
|
-
}>
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
}>['fields']['blockType']]?: HTMLConverterAsync<Extract<T, {
|
|
62
|
+
fields: {
|
|
63
|
+
blockType: K;
|
|
64
|
+
};
|
|
65
65
|
type: 'inlineBlock';
|
|
66
|
-
}
|
|
67
|
-
blockType: K;
|
|
68
|
-
}>> : SerializedInlineBlockNode>;
|
|
66
|
+
}>>;
|
|
69
67
|
};
|
|
70
68
|
unknown?: HTMLConverterAsync<SerializedLexicalNode>;
|
|
71
69
|
};
|
|
@@ -74,10 +72,11 @@ export type HTMLConvertersFunctionAsync<T extends {
|
|
|
74
72
|
type?: string;
|
|
75
73
|
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
76
74
|
blockName?: null | string;
|
|
75
|
+
blockType: string;
|
|
77
76
|
}> | SerializedInlineBlockNode<{
|
|
78
77
|
blockName?: null | string;
|
|
79
78
|
blockType: string;
|
|
80
79
|
}>> = (args: {
|
|
81
|
-
defaultConverters: HTMLConvertersAsync<
|
|
80
|
+
defaultConverters: HTMLConvertersAsync<T>;
|
|
82
81
|
}) => HTMLConvertersAsync<T>;
|
|
83
82
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml/async/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,C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CAAA;AAEV,MAAM,MAAM,mBAAmB,CAC7B,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,IAC7E;IACF,CAAC,GAAG,EAAE,MAAM,GACR;QACE,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;KAC7C,GACD,kBAAkB,CAAC,GAAG,CAAC,GACvB,SAAS,CAAA;CACd,GAAG;KACD,QAAQ,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,kBAAkB,CACzF,OAAO,CAAC,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC,CAC/B;CACF,GAAG;IACF,MAAM,CAAC,EAAE;SACN,CAAC,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml/async/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAErD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oBAAoB,CAAA;AACzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,cAAc,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,CAAC,EAAE,kBAAkB,CAAC,qBAAqB,CAAC,CAAA;CACpD,CAAA;AAED,MAAM,MAAM,2BAA2B,CACrC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,IAC7E,CAAC,IAAI,EAAE;IAAE,iBAAiB,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAA;CAAE,KAAK,mBAAmB,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToHtml/async/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type { SelectType, TypeWithID } from 'payload'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../types/nodeTypes.js'\nimport type { SerializedLexicalNodeWithParent } from '../shared/types.js'\nexport type HTMLPopulateArguments = {\n collectionSlug: string\n id: number | string\n select?: SelectType\n}\n\nexport type HTMLPopulateFn = <TData extends object = TypeWithID>(\n args: HTMLPopulateArguments,\n) => Promise<TData | undefined>\n\nexport type HTMLConverterAsync<\n T extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> =\n | ((args: {\n childIndex: number\n converters: HTMLConvertersAsync\n node: T\n nodesToHTML: (args: {\n converters?: HTMLConvertersAsync\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => Promise<string[]>\n parent: SerializedLexicalNodeWithParent\n populate?: HTMLPopulateFn\n providedCSSString: string\n providedStyleTag: string\n }) => Promise<string> | string)\n | string\n\nexport type HTMLConvertersAsync<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: HTMLConverterAsync<any>\n }\n | HTMLConverterAsync<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: HTMLConverterAsync<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToHtml/async/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\nimport type { SelectType, TypeWithID } from 'payload'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../types/nodeTypes.js'\nimport type { SerializedLexicalNodeWithParent } from '../shared/types.js'\nexport type HTMLPopulateArguments = {\n collectionSlug: string\n id: number | string\n select?: SelectType\n}\n\nexport type HTMLPopulateFn = <TData extends object = TypeWithID>(\n args: HTMLPopulateArguments,\n) => Promise<TData | undefined>\n\nexport type HTMLConverterAsync<\n T extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> =\n | ((args: {\n childIndex: number\n converters: HTMLConvertersAsync\n node: T\n nodesToHTML: (args: {\n converters?: HTMLConvertersAsync\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => Promise<string[]>\n parent: SerializedLexicalNodeWithParent\n populate?: HTMLPopulateFn\n providedCSSString: string\n providedStyleTag: string\n }) => Promise<string> | string)\n | string\n\nexport type HTMLConvertersAsync<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: HTMLConverterAsync<any>\n }\n | HTMLConverterAsync<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: HTMLConverterAsync<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<T, { type: 'block' }>['fields']['blockType']]?: HTMLConverterAsync<\n Extract<T, { fields: { blockType: K }; type: 'block' }>\n >\n }\n inlineBlocks?: {\n [K in Extract<T, { type: 'inlineBlock' }>['fields']['blockType']]?: HTMLConverterAsync<\n Extract<T, { fields: { blockType: K }; type: 'inlineBlock' }>\n >\n }\n unknown?: HTMLConverterAsync<SerializedLexicalNode>\n}\n\nexport type HTMLConvertersFunctionAsync<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }>\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>,\n> = (args: { defaultConverters: HTMLConvertersAsync<T> }) => HTMLConvertersAsync<T>\n"],"mappings":"AAsEA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":["escapeHTML","UploadHTMLConverter","upload","node","providedStyleTag","uploadNode","uploadDoc","undefined","value","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","String","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport escapeHTML from 'escape-html'\n\nimport type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/
|
|
1
|
+
{"version":3,"file":"upload.js","names":["escapeHTML","UploadHTMLConverter","upload","node","providedStyleTag","uploadNode","uploadDoc","undefined","value","alt","fields","url","mimeType","startsWith","filename","sizes","Object","keys","length","String","height","width","pictureHTML","size","imageSize","filesize"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/upload.ts"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport escapeHTML from 'escape-html'\n\nimport type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'\nimport type { UploadDataImproved } from '../../../../upload/server/schema.js'\nimport type { HTMLConverters } from '../types.js'\n\nexport const UploadHTMLConverter: HTMLConverters<SerializedUploadNode> = {\n upload: ({ node, providedStyleTag }) => {\n const uploadNode = node as UploadDataImproved\n\n let uploadDoc: (FileData & TypeWithID) | undefined = undefined\n\n // If there's no valid upload data, populate return an empty string\n if (typeof uploadNode.value !== 'object') {\n return ''\n } else {\n uploadDoc = uploadNode.value as unknown as FileData & TypeWithID\n }\n\n if (!uploadDoc) {\n return ''\n }\n\n const alt = escapeHTML(\n (node.fields?.alt as string) || (uploadDoc as { alt?: string })?.alt || '',\n )\n\n const url = escapeHTML(uploadDoc.url ?? '')\n\n // 1) If upload is NOT an image, return a link\n if (!uploadDoc.mimeType.startsWith('image')) {\n return `<a${providedStyleTag} href=\"${url}\" rel=\"noopener noreferrer\">${escapeHTML(uploadDoc.filename ?? '')}</a>`\n }\n\n // 2) If image has no different sizes, return a simple <img />\n if (!uploadDoc.sizes || !Object.keys(uploadDoc.sizes).length) {\n return `\n <img${providedStyleTag}\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n }\n\n // 3) If image has different sizes, build a <picture> element with <source> tags\n let pictureHTML = ''\n\n for (const size in uploadDoc.sizes) {\n const imageSize = uploadDoc.sizes[size] as FileSize\n\n if (\n !imageSize ||\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n\n pictureHTML += `\n <source\n media=\"(max-width: ${escapeHTML(String(imageSize.width))}px)\"\n srcset=\"${escapeHTML(imageSize.url)}\"\n type=\"${escapeHTML(imageSize.mimeType)}\"\n />\n `\n }\n\n pictureHTML += `\n <img\n alt=\"${alt}\"\n height=\"${escapeHTML(String(uploadDoc.height ?? ''))}\"\n src=\"${url}\"\n width=\"${escapeHTML(String(uploadDoc.width ?? ''))}\"\n />\n `\n\n return `<picture${providedStyleTag}>${pictureHTML}</picture>`\n },\n}\n"],"mappings":"AAEA,OAAOA,UAAA,MAAgB;AAMvB,OAAO,MAAMC,mBAAA,GAA4D;EACvEC,MAAA,EAAQA,CAAC;IAAEC,IAAI;IAAEC;EAAgB,CAAE;IACjC,MAAMC,UAAA,GAAaF,IAAA;IAEnB,IAAIG,SAAA,GAAiDC,SAAA;IAErD;IACA,IAAI,OAAOF,UAAA,CAAWG,KAAK,KAAK,UAAU;MACxC,OAAO;IACT,OAAO;MACLF,SAAA,GAAYD,UAAA,CAAWG,KAAK;IAC9B;IAEA,IAAI,CAACF,SAAA,EAAW;MACd,OAAO;IACT;IAEA,MAAMG,GAAA,GAAMT,UAAA,CACVG,IAAC,CAAKO,MAAM,EAAED,GAAA,IAAmBH,SAAA,EAAgCG,GAAA,IAAO;IAG1E,MAAME,GAAA,GAAMX,UAAA,CAAWM,SAAA,CAAUK,GAAG,IAAI;IAExC;IACA,IAAI,CAACL,SAAA,CAAUM,QAAQ,CAACC,UAAU,CAAC,UAAU;MAC3C,OAAO,KAAKT,gBAAA,UAA0BO,GAAA,+BAAkCX,UAAA,CAAWM,SAAA,CAAUQ,QAAQ,IAAI,SAAS;IACpH;IAEA;IACA,IAAI,CAACR,SAAA,CAAUS,KAAK,IAAI,CAACC,MAAA,CAAOC,IAAI,CAACX,SAAA,CAAUS,KAAK,EAAEG,MAAM,EAAE;MAC5D,OAAO;cACCd,gBAAA;iBACGK,GAAA;oBACGT,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUc,MAAM,IAAI;iBACzCT,GAAA;mBACEX,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUe,KAAK,IAAI;;OAEjD;IACH;IAEA;IACA,IAAIC,WAAA,GAAc;IAElB,KAAK,MAAMC,IAAA,IAAQjB,SAAA,CAAUS,KAAK,EAAE;MAClC,MAAMS,SAAA,GAAYlB,SAAA,CAAUS,KAAK,CAACQ,IAAA,CAAK;MAEvC,IACE,CAACC,SAAA,IACD,CAACA,SAAA,CAAUH,KAAK,IAChB,CAACG,SAAA,CAAUJ,MAAM,IACjB,CAACI,SAAA,CAAUZ,QAAQ,IACnB,CAACY,SAAA,CAAUC,QAAQ,IACnB,CAACD,SAAA,CAAUV,QAAQ,IACnB,CAACU,SAAA,CAAUb,GAAG,EACd;QACA;MACF;MAEAW,WAAA,IAAe;;+BAEUtB,UAAA,CAAWmB,MAAA,CAAOK,SAAA,CAAUH,KAAK;oBAC5CrB,UAAA,CAAWwB,SAAA,CAAUb,GAAG;kBAC1BX,UAAA,CAAWwB,SAAA,CAAUZ,QAAQ;;OAExC;IACH;IAEAU,WAAA,IAAe;;eAEJb,GAAA;kBACGT,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUc,MAAM,IAAI;eACzCT,GAAA;iBACEX,UAAA,CAAWmB,MAAA,CAAOb,SAAA,CAAUe,KAAK,IAAI;;KAEjD;IAED,OAAO,WAAWjB,gBAAA,IAAoBkB,WAAA,YAAuB;EAC/D;AACF","ignoreList":[]}
|
|
@@ -38,26 +38,24 @@ export type HTMLConverters<T extends {
|
|
|
38
38
|
}>>;
|
|
39
39
|
} & {
|
|
40
40
|
blocks?: {
|
|
41
|
-
[K in Extract<
|
|
41
|
+
[K in Extract<T, {
|
|
42
42
|
type: 'block';
|
|
43
|
-
}>
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
}>['fields']['blockType']]?: HTMLConverter<Extract<T, {
|
|
44
|
+
fields: {
|
|
45
|
+
blockType: K;
|
|
46
|
+
};
|
|
46
47
|
type: 'block';
|
|
47
|
-
}
|
|
48
|
-
blockType: K;
|
|
49
|
-
}>> : SerializedBlockNode>;
|
|
48
|
+
}>>;
|
|
50
49
|
};
|
|
51
50
|
inlineBlocks?: {
|
|
52
|
-
[K in Extract<
|
|
51
|
+
[K in Extract<T, {
|
|
53
52
|
type: 'inlineBlock';
|
|
54
|
-
}>
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
}>['fields']['blockType']]?: HTMLConverter<Extract<T, {
|
|
54
|
+
fields: {
|
|
55
|
+
blockType: K;
|
|
56
|
+
};
|
|
57
57
|
type: 'inlineBlock';
|
|
58
|
-
}
|
|
59
|
-
blockType: K;
|
|
60
|
-
}>> : SerializedInlineBlockNode>;
|
|
58
|
+
}>>;
|
|
61
59
|
};
|
|
62
60
|
unknown?: HTMLConverter<SerializedLexicalNode>;
|
|
63
61
|
};
|
|
@@ -66,10 +64,11 @@ export type HTMLConvertersFunction<T extends {
|
|
|
66
64
|
type?: string;
|
|
67
65
|
} = DefaultNodeTypes | SerializedBlockNode<{
|
|
68
66
|
blockName?: null | string;
|
|
67
|
+
blockType: string;
|
|
69
68
|
}> | SerializedInlineBlockNode<{
|
|
70
69
|
blockName?: null | string;
|
|
71
70
|
blockType: string;
|
|
72
71
|
}>> = (args: {
|
|
73
|
-
defaultConverters: HTMLConverters<
|
|
72
|
+
defaultConverters: HTMLConverters<T>;
|
|
74
73
|
}) => HTMLConverters<T>;
|
|
75
74
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToHtml/sync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,g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AAA;IACD,YAAY,CAAC,EAAE;SACZ,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE;YAAE,IAAI,EAAE,aAAa,CAAA;SAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,aAAa,CAC/E,OAAO,CAAC,CAAC,EAAE;YAAE,MAAM,EAAE;gBAAE,SAAS,EAAE,CAAC,CAAA;aAAE,CAAC;YAAC,IAAI,EAAE,aAAa,CAAA;SAAE,CAAC,CAC9D;KACF,CAAA;IACD,OAAO,CAAC,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,IAC7E,CAAC,IAAI,EAAE;IAAE,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC,CAAA;CAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToHtml/sync/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../types/nodeTypes.js'\nimport type { SerializedLexicalNodeWithParent } from '../shared/types.js'\n\nexport type HTMLConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =\n\n | ((args: {\n childIndex: number\n converters: HTMLConverters\n node: T\n nodesToHTML: (args: {\n converters?: HTMLConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => string[]\n parent: SerializedLexicalNodeWithParent\n providedCSSString: string\n providedStyleTag: string\n }) => string)\n | string\n\nexport type HTMLConverters<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: HTMLConverter<any>\n }\n | HTMLConverter<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: HTMLConverter<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToHtml/sync/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../types/nodeTypes.js'\nimport type { SerializedLexicalNodeWithParent } from '../shared/types.js'\n\nexport type HTMLConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =\n\n | ((args: {\n childIndex: number\n converters: HTMLConverters\n node: T\n nodesToHTML: (args: {\n converters?: HTMLConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => string[]\n parent: SerializedLexicalNodeWithParent\n providedCSSString: string\n providedStyleTag: string\n }) => string)\n | string\n\nexport type HTMLConverters<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: HTMLConverter<any>\n }\n | HTMLConverter<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: HTMLConverter<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<T, { type: 'block' }>['fields']['blockType']]?: HTMLConverter<\n Extract<T, { fields: { blockType: K }; type: 'block' }>\n >\n }\n inlineBlocks?: {\n [K in Extract<T, { type: 'inlineBlock' }>['fields']['blockType']]?: HTMLConverter<\n Extract<T, { fields: { blockType: K }; type: 'inlineBlock' }>\n >\n }\n unknown?: HTMLConverter<SerializedLexicalNode>\n}\n\nexport type HTMLConvertersFunction<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }>\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>,\n> = (args: { defaultConverters: HTMLConverters<T> }) => HTMLConverters<T>\n"],"mappings":"AA0DA","ignoreList":[]}
|
|
@@ -5,10 +5,12 @@ import type { JSXConverters } from '../converter/types.js';
|
|
|
5
5
|
import { type ConvertLexicalToJSXArgs } from '../converter/index.js';
|
|
6
6
|
export type JSXConvertersFunction<T extends SerializedNodeBase = DefaultNodeTypes | SerializedBlockNode<{
|
|
7
7
|
blockName?: null | string;
|
|
8
|
+
blockType: string;
|
|
8
9
|
}> | SerializedInlineBlockNode<{
|
|
9
10
|
blockName?: null | string;
|
|
11
|
+
blockType: string;
|
|
10
12
|
}>> = (args: {
|
|
11
|
-
defaultConverters: JSXConverters<
|
|
13
|
+
defaultConverters: JSXConverters<T>;
|
|
12
14
|
}) => JSXConverters<T>;
|
|
13
15
|
type RichTextProps<TNodes extends SerializedNodeBase = SerializedNodeBase> = {
|
|
14
16
|
/**
|
|
@@ -18,7 +20,7 @@ type RichTextProps<TNodes extends SerializedNodeBase = SerializedNodeBase> = {
|
|
|
18
20
|
/**
|
|
19
21
|
* Custom converters to transform your nodes to JSX. Can be an object or a function that receives the default converters.
|
|
20
22
|
*/
|
|
21
|
-
converters?: JSXConverters | JSXConvertersFunction
|
|
23
|
+
converters?: JSXConverters<TNodes> | JSXConvertersFunction<TNodes>;
|
|
22
24
|
/**
|
|
23
25
|
* If true, removes the container div wrapper.
|
|
24
26
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAuB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEzF,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,kBAAkB,GACxB,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/Component/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,OAAO,EAAuB,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AAEzF,MAAM,MAAM,qBAAqB,CAC/B,CAAC,SAAS,kBAAkB,GACxB,gBAAgB,GAChB,mBAAmB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACrE,yBAAyB,CAAC;IAAE,SAAS,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,IAC7E,CAAC,IAAI,EAAE;IAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAAE,KAAK,aAAa,CAAC,CAAC,CAAC,CAAA;AAEvE,KAAK,aAAa,CAAC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB,IAAI;IAC3E;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAA;IAElE;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,eAAe,GAAG,kBAAkB,GAAG,SAAS,CAAC,CAAA;AAEpG,wBAAgB,QAAQ,CAAC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB,EAAE,EAC/E,SAAS,EACT,UAAU,EACV,IAAI,EAAE,WAAW,EACjB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,OAAO,GACR,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,SAAS,CAoCzC"}
|
|
@@ -14,14 +14,15 @@ export function RichText({
|
|
|
14
14
|
if (!editorState) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
+
const baseConverters = converters;
|
|
17
18
|
let finalConverters = {};
|
|
18
|
-
if (
|
|
19
|
-
if (typeof
|
|
20
|
-
finalConverters =
|
|
19
|
+
if (baseConverters) {
|
|
20
|
+
if (typeof baseConverters === 'function') {
|
|
21
|
+
finalConverters = baseConverters({
|
|
21
22
|
defaultConverters: defaultJSXConverters
|
|
22
23
|
});
|
|
23
24
|
} else {
|
|
24
|
-
finalConverters =
|
|
25
|
+
finalConverters = baseConverters;
|
|
25
26
|
}
|
|
26
27
|
} else {
|
|
27
28
|
finalConverters = defaultJSXConverters;
|