@payloadcms/richtext-lexical 4.0.0-canary.0 → 4.0.0-internal.183b315
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-XIJE2UCQ.js → chunk-ZYXHC5CY.js} +2 -2
- package/dist/exports/client/chunk-ZYXHC5CY.js.map +7 -0
- package/dist/exports/client/{component-KESPRYJR.js → component-PHZQBOJE.js} +1 -1
- package/dist/exports/client/component-PHZQBOJE.js.map +7 -0
- package/dist/exports/client/componentInline-R3EPNYWF.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 +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +1 -1
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -1
- package/dist/features/blocks/client/componentInline/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 +20 -66
- 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.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/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/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +7 -3
- package/dist/utilities/generateImportMap.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-XIJE2UCQ.js.map +0 -7
- package/dist/exports/client/component-KESPRYJR.js.map +0 -7
- package/dist/exports/client/componentInline-R2RSJX4K.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-R2RSJX4K.js.map → componentInline-R3EPNYWF.js.map} +0 -0
|
@@ -1,74 +1,128 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { SerializedQuoteNode } from '../features/blockquote/server/
|
|
3
|
-
import type { SerializedBlockNode } from '../features/blocks/server/
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
|
|
1
|
+
import type { SerializedLexicalNode } from 'lexical';
|
|
2
|
+
import type { SerializedQuoteNode } from '../features/blockquote/server/schema.js';
|
|
3
|
+
import type { SerializedBlockNode, SerializedInlineBlockNode } from '../features/blocks/server/schema.js';
|
|
4
|
+
import type { SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode } from '../features/experimental_table/server/schema.js';
|
|
5
|
+
import type { SerializedHeadingNode } from '../features/heading/server/schema.js';
|
|
6
|
+
import type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/schema.js';
|
|
7
|
+
import type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/server/schema.js';
|
|
8
|
+
import type { SerializedListItemNode, SerializedListNode } from '../features/lists/shared/schema.js';
|
|
9
|
+
import type { SerializedRelationshipNode } from '../features/relationship/server/schema.js';
|
|
10
|
+
import type { SerializedUploadNode } from '../features/upload/server/schema.js';
|
|
11
|
+
/** @internal Core Lexical types — see @payloadcms/richtext-lexical. */
|
|
12
|
+
export type LexicalElementFormat = '' | 'center' | 'end' | 'justify' | 'left' | 'right' | 'start';
|
|
13
|
+
export type LexicalElementDirection = ('ltr' | 'rtl') | null;
|
|
14
|
+
export interface SerializedLexicalElementBase<TChildren> {
|
|
15
|
+
children: TChildren[];
|
|
16
|
+
direction: LexicalElementDirection;
|
|
17
|
+
format: LexicalElementFormat;
|
|
18
|
+
indent: number;
|
|
19
|
+
textFormat?: number;
|
|
20
|
+
textStyle?: string;
|
|
21
|
+
version: number;
|
|
22
|
+
}
|
|
23
|
+
export type LexicalTextMode = 'normal' | 'segmented' | 'token';
|
|
24
|
+
export interface SerializedTextNode {
|
|
25
|
+
detail: number;
|
|
26
|
+
format: number;
|
|
27
|
+
mode: LexicalTextMode;
|
|
28
|
+
style: string;
|
|
29
|
+
text: string;
|
|
30
|
+
type: 'text';
|
|
31
|
+
version: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SerializedTabNode {
|
|
34
|
+
detail: number;
|
|
35
|
+
format: number;
|
|
36
|
+
mode: LexicalTextMode;
|
|
37
|
+
style: string;
|
|
38
|
+
text: string;
|
|
39
|
+
type: 'tab';
|
|
40
|
+
version: number;
|
|
41
|
+
}
|
|
42
|
+
export interface SerializedLineBreakNode {
|
|
43
|
+
type: 'linebreak';
|
|
44
|
+
version: number;
|
|
45
|
+
}
|
|
46
|
+
export interface SerializedParagraphNode<TChildren extends SerializedLexicalNode = SerializedLexicalNode> extends SerializedLexicalElementBase<TChildren> {
|
|
47
|
+
textFormat: number;
|
|
48
|
+
textStyle: string;
|
|
49
|
+
type: 'paragraph';
|
|
50
|
+
}
|
|
51
|
+
/** Shape of a Lexical `richText` field. */
|
|
52
|
+
export interface LexicalRichText<TNode> {
|
|
53
|
+
root: {
|
|
54
|
+
children: TNode[];
|
|
55
|
+
direction: LexicalElementDirection;
|
|
56
|
+
format: LexicalElementFormat;
|
|
57
|
+
indent: number;
|
|
58
|
+
type: 'root';
|
|
59
|
+
version: number;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export type { SerializedAutoLinkNode, SerializedBlockNode, SerializedHeadingNode, SerializedHorizontalRuleNode, SerializedInlineBlockNode, SerializedLinkNode, SerializedListItemNode, SerializedListNode, SerializedQuoteNode, SerializedRelationshipNode, SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode, SerializedUploadNode, };
|
|
63
|
+
/** `SerializedEditorState` with nodes narrowed by `type`. No type-casting needed. */
|
|
64
|
+
export type TypedEditorState<TNode extends SerializedLexicalNode = SerializedLexicalNode> = LexicalRichText<TNode>;
|
|
12
65
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* @param TType - The node type string (e.g., 'heading')
|
|
18
|
-
* @param TChildren - The type for children (defaults to SerializedLexicalNode)
|
|
66
|
+
* The node union of a generated `richText` field. Pass the field type — e.g.
|
|
67
|
+
* `RichTextNodes<Post['richText']>` — to type an individual node you build for that editor (for
|
|
68
|
+
* example a single block, or a `.map()` of nodes). To build a whole editor state, prefer passing
|
|
69
|
+
* the field type straight to {@link buildEditorState}.
|
|
19
70
|
*/
|
|
20
|
-
export type
|
|
21
|
-
children: TChildren[];
|
|
22
|
-
type: TType;
|
|
23
|
-
} & Omit<TBase, 'children' | 'type'>;
|
|
71
|
+
export type RichTextNodes<TRichText> = NonNullable<TRichText> extends LexicalRichText<infer TNode> ? TNode : never;
|
|
24
72
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param TBase - The base Lexical node type (e.g., _SerializedTextNode)
|
|
29
|
-
* @param TType - The node type string (e.g., 'text')
|
|
73
|
+
* All node types included by default in a lexical editor. Self-recursive —
|
|
74
|
+
* each element node's `children` is `DefaultNodeTypes` again, no depth limit.
|
|
75
|
+
* To compose your own union including the defaults, see {@link WithDefaultNodes}.
|
|
30
76
|
*/
|
|
31
|
-
export type
|
|
32
|
-
type: TType;
|
|
33
|
-
} & Omit<TBase, 'children' | 'type'>;
|
|
34
|
-
export type { SerializedAutoLinkNode, SerializedBlockNode, SerializedHeadingNode, SerializedHorizontalRuleNode, SerializedInlineBlockNode, SerializedLinkNode, SerializedListItemNode, SerializedListNode, SerializedQuoteNode, SerializedRelationshipNode, SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode, SerializedUploadNode, };
|
|
35
|
-
export type SerializedParagraphNode<T extends SerializedLexicalNode = SerializedLexicalNode> = {
|
|
36
|
-
textFormat: number;
|
|
37
|
-
} & StronglyTypedElementNode<SerializedElementNode, 'paragraph', T>;
|
|
38
|
-
export type SerializedTextNode = StronglyTypedLeafNode<_SerializedTextNode, 'text'>;
|
|
39
|
-
export type SerializedTabNode = StronglyTypedLeafNode<_SerializedTabNode, 'tab'>;
|
|
40
|
-
export type SerializedLineBreakNode = StronglyTypedLeafNode<_SerializedLineBreakNode, 'linebreak'>;
|
|
77
|
+
export type DefaultNodeTypes = SerializedAutoLinkNode<DefaultNodeTypes> | SerializedHeadingNode<DefaultNodeTypes> | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode<DefaultNodeTypes> | SerializedListItemNode<DefaultNodeTypes> | SerializedListNode<DefaultNodeTypes> | SerializedParagraphNode<DefaultNodeTypes> | SerializedQuoteNode<DefaultNodeTypes> | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
|
|
41
78
|
/**
|
|
42
|
-
*
|
|
79
|
+
* The built-in lexical nodes, plus your own - with your nodes threaded into every container's
|
|
80
|
+
* `children`, not just the top level. Pass your custom node(s) as the generic:
|
|
43
81
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* - `'children' extends keyof T`: Only adds children to container nodes; respects leaf nodes that use `Omit<_, 'children'>`
|
|
48
|
-
* - `Depth`: Limits recursion to prevent infinite types (default: 4 levels)
|
|
82
|
+
* ```ts
|
|
83
|
+
* type MyNodes = WithDefaultNodes<SerializedBlockNode<MyBlockData>>
|
|
84
|
+
* ```
|
|
49
85
|
*
|
|
50
|
-
*
|
|
86
|
+
* Built by flattening {@link DefaultNodeRegistry} (`Registry[keyof Registry]`); see that interface
|
|
87
|
+
* for why the node set lives in a registry instead of being written as a plain union type.
|
|
51
88
|
*/
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
89
|
+
export type WithDefaultNodes<TCustom extends SerializedLexicalNode = never> = DefaultNodeRegistry<TCustom>[keyof DefaultNodeRegistry<TCustom>];
|
|
90
|
+
/** @internal Re-types an element node's `children` to the recursive node union. */
|
|
91
|
+
type WithRecursiveChildren<TNode, TCustom extends SerializedLexicalNode> = {
|
|
92
|
+
children: WithDefaultNodes<TCustom>[];
|
|
93
|
+
} & Omit<TNode, 'children'>;
|
|
57
94
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
95
|
+
* @internal The set of default nodes, generic over the user's custom node(s). {@link WithDefaultNodes}
|
|
96
|
+
* flattens it into the node union with `Registry[keyof Registry]`.
|
|
97
|
+
*
|
|
98
|
+
* Why a registry interface instead of writing the union directly? The union has to be self-referential:
|
|
99
|
+
* every element node's `children` is the same node union (so custom nodes nest inside containers too).
|
|
100
|
+
* A generic *type alias* can't reference itself that way - `type N<T> = SerializedParagraphNode<N<T>> | ...`
|
|
101
|
+
* is a `TS2456` circular reference, because instantiating a type alias resolves its type argument
|
|
102
|
+
* eagerly. An *interface* resolves its members lazily, so the self-reference inside `children: ...[]`
|
|
103
|
+
* is allowed - the recursion is legal precisely because it lives inside this interface. Reusing the
|
|
104
|
+
* real node interfaces (re-typing only `children`) keeps each entry in sync with its node's real shape.
|
|
67
105
|
*/
|
|
68
|
-
|
|
106
|
+
interface DefaultNodeRegistry<TCustom extends SerializedLexicalNode> {
|
|
107
|
+
autolink: WithRecursiveChildren<SerializedAutoLinkNode<SerializedLexicalNode>, TCustom>;
|
|
108
|
+
custom: TCustom;
|
|
109
|
+
heading: WithRecursiveChildren<SerializedHeadingNode<SerializedLexicalNode>, TCustom>;
|
|
110
|
+
horizontalrule: SerializedHorizontalRuleNode;
|
|
111
|
+
linebreak: SerializedLineBreakNode;
|
|
112
|
+
link: WithRecursiveChildren<SerializedLinkNode<SerializedLexicalNode>, TCustom>;
|
|
113
|
+
list: WithRecursiveChildren<SerializedListNode<SerializedLexicalNode>, TCustom>;
|
|
114
|
+
listitem: WithRecursiveChildren<SerializedListItemNode<SerializedLexicalNode>, TCustom>;
|
|
115
|
+
paragraph: WithRecursiveChildren<SerializedParagraphNode<SerializedLexicalNode>, TCustom>;
|
|
116
|
+
quote: WithRecursiveChildren<SerializedQuoteNode<SerializedLexicalNode>, TCustom>;
|
|
117
|
+
relationship: SerializedRelationshipNode;
|
|
118
|
+
tab: SerializedTabNode;
|
|
119
|
+
text: SerializedTextNode;
|
|
120
|
+
upload: SerializedUploadNode;
|
|
121
|
+
}
|
|
69
122
|
/**
|
|
70
|
-
* Like `TypedEditorState
|
|
71
|
-
*
|
|
123
|
+
* Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a
|
|
124
|
+
* generic to add your own; they're threaded into every container's `children` (via
|
|
125
|
+
* {@link WithDefaultNodes}), not just allowed at the top level.
|
|
72
126
|
*/
|
|
73
|
-
export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> =
|
|
127
|
+
export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = TypedEditorState<WithDefaultNodes<NonNullable<TAdditionalNodeTypes>>>;
|
|
74
128
|
//# sourceMappingURL=nodeTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTypes.d.ts","sourceRoot":"","sources":["../../src/types/nodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"nodeTypes.d.ts","sourceRoot":"","sources":["../../src/types/nodeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAA;AAClF,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,iDAAiD,CAAA;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CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IAC/E,QAAQ,EAAE,qBAAqB,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACvF,SAAS,EAAE,qBAAqB,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACzF,KAAK,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IACjF,YAAY,EAAE,0BAA0B,CAAA;IACxC,GAAG,EAAE,iBAAiB,CAAA;IACtB,IAAI,EAAE,kBAAkB,CAAA;IACxB,MAAM,EAAE,oBAAoB,CAAA;CAC7B;AAED;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,CACjC,oBAAoB,SAAS,IAAI,GAAG,qBAAqB,GAAG,IAAI,IAC9D,gBAAgB,CAAC,gBAAgB,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/types/nodeTypes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Like `TypedEditorState
|
|
3
|
-
*
|
|
2
|
+
* Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a
|
|
3
|
+
* generic to add your own; they're threaded into every container's `children` (via
|
|
4
|
+
* {@link WithDefaultNodes}), not just allowed at the top level.
|
|
4
5
|
*/export {};
|
|
5
6
|
//# sourceMappingURL=nodeTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeTypes.js","names":[],"sources":["../../src/types/nodeTypes.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"nodeTypes.js","names":[],"sources":["../../src/types/nodeTypes.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type { SerializedQuoteNode } from '../features/blockquote/server/schema.js'\nimport type {\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../features/blocks/server/schema.js'\nimport type {\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n} from '../features/experimental_table/server/schema.js'\nimport type { SerializedHeadingNode } from '../features/heading/server/schema.js'\nimport type { SerializedHorizontalRuleNode } from '../features/horizontalRule/server/schema.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from '../features/link/server/schema.js'\nimport type { SerializedListItemNode, SerializedListNode } from '../features/lists/shared/schema.js'\nimport type { SerializedRelationshipNode } from '../features/relationship/server/schema.js'\nimport type { SerializedUploadNode } from '../features/upload/server/schema.js'\n\n// The declarations below must stay byte-for-byte aligned with the TS source\n// strings Payload appends to `payload-types.ts` — twins live in\n// `types/builtInNodes.ts` and per-feature `schema.ts`.\n\n/** @internal Core Lexical types — see @payloadcms/richtext-lexical. */\nexport type LexicalElementFormat = '' | 'center' | 'end' | 'justify' | 'left' | 'right' | 'start'\nexport type LexicalElementDirection = ('ltr' | 'rtl') | null\n\nexport interface SerializedLexicalElementBase<TChildren> {\n children: TChildren[]\n direction: LexicalElementDirection\n format: LexicalElementFormat\n indent: number\n textFormat?: number\n textStyle?: string\n version: number\n}\n\nexport type LexicalTextMode = 'normal' | 'segmented' | 'token'\n\nexport interface SerializedTextNode {\n detail: number\n format: number\n mode: LexicalTextMode\n style: string\n text: string\n type: 'text'\n version: number\n}\n\nexport interface SerializedTabNode {\n detail: number\n format: number\n mode: LexicalTextMode\n style: string\n text: string\n type: 'tab'\n version: number\n}\n\nexport interface SerializedLineBreakNode {\n type: 'linebreak'\n version: number\n}\n\nexport interface SerializedParagraphNode<\n TChildren extends SerializedLexicalNode = SerializedLexicalNode,\n> extends SerializedLexicalElementBase<TChildren> {\n textFormat: number\n textStyle: string\n type: 'paragraph'\n}\n\n/** Shape of a Lexical `richText` field. */\nexport interface LexicalRichText<TNode> {\n root: {\n children: TNode[]\n direction: LexicalElementDirection\n format: LexicalElementFormat\n indent: number\n type: 'root'\n version: number\n }\n}\n\nexport type {\n SerializedAutoLinkNode,\n SerializedBlockNode,\n SerializedHeadingNode,\n SerializedHorizontalRuleNode,\n SerializedInlineBlockNode,\n SerializedLinkNode,\n SerializedListItemNode,\n SerializedListNode,\n SerializedQuoteNode,\n SerializedRelationshipNode,\n SerializedTableCellNode,\n SerializedTableNode,\n SerializedTableRowNode,\n SerializedUploadNode,\n}\n\n/** `SerializedEditorState` with nodes narrowed by `type`. No type-casting needed. */\nexport type TypedEditorState<TNode extends SerializedLexicalNode = SerializedLexicalNode> =\n LexicalRichText<TNode>\n\n/**\n * The node union of a generated `richText` field. Pass the field type — e.g.\n * `RichTextNodes<Post['richText']>` — to type an individual node you build for that editor (for\n * example a single block, or a `.map()` of nodes). To build a whole editor state, prefer passing\n * the field type straight to {@link buildEditorState}.\n */\nexport type RichTextNodes<TRichText> =\n NonNullable<TRichText> extends LexicalRichText<infer TNode> ? TNode : never\n\n/**\n * All node types included by default in a lexical editor. Self-recursive —\n * each element node's `children` is `DefaultNodeTypes` again, no depth limit.\n * To compose your own union including the defaults, see {@link WithDefaultNodes}.\n */\nexport type DefaultNodeTypes =\n | SerializedAutoLinkNode<DefaultNodeTypes>\n //| SerializedBlockNode // Not included by default\n | SerializedHeadingNode<DefaultNodeTypes>\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode<DefaultNodeTypes>\n | SerializedListItemNode<DefaultNodeTypes>\n | SerializedListNode<DefaultNodeTypes>\n | SerializedParagraphNode<DefaultNodeTypes>\n | SerializedQuoteNode<DefaultNodeTypes>\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\n/**\n * The built-in lexical nodes, plus your own - with your nodes threaded into every container's\n * `children`, not just the top level. Pass your custom node(s) as the generic:\n *\n * ```ts\n * type MyNodes = WithDefaultNodes<SerializedBlockNode<MyBlockData>>\n * ```\n *\n * Built by flattening {@link DefaultNodeRegistry} (`Registry[keyof Registry]`); see that interface\n * for why the node set lives in a registry instead of being written as a plain union type.\n */\nexport type WithDefaultNodes<TCustom extends SerializedLexicalNode = never> =\n DefaultNodeRegistry<TCustom>[keyof DefaultNodeRegistry<TCustom>]\n\n/** @internal Re-types an element node's `children` to the recursive node union. */\ntype WithRecursiveChildren<TNode, TCustom extends SerializedLexicalNode> = {\n children: WithDefaultNodes<TCustom>[]\n} & Omit<TNode, 'children'>\n\n/**\n * @internal The set of default nodes, generic over the user's custom node(s). {@link WithDefaultNodes}\n * flattens it into the node union with `Registry[keyof Registry]`.\n *\n * Why a registry interface instead of writing the union directly? The union has to be self-referential:\n * every element node's `children` is the same node union (so custom nodes nest inside containers too).\n * A generic *type alias* can't reference itself that way - `type N<T> = SerializedParagraphNode<N<T>> | ...`\n * is a `TS2456` circular reference, because instantiating a type alias resolves its type argument\n * eagerly. An *interface* resolves its members lazily, so the self-reference inside `children: ...[]`\n * is allowed - the recursion is legal precisely because it lives inside this interface. Reusing the\n * real node interfaces (re-typing only `children`) keeps each entry in sync with its node's real shape.\n */\ninterface DefaultNodeRegistry<TCustom extends SerializedLexicalNode> {\n autolink: WithRecursiveChildren<SerializedAutoLinkNode<SerializedLexicalNode>, TCustom>\n custom: TCustom\n heading: WithRecursiveChildren<SerializedHeadingNode<SerializedLexicalNode>, TCustom>\n horizontalrule: SerializedHorizontalRuleNode\n linebreak: SerializedLineBreakNode\n link: WithRecursiveChildren<SerializedLinkNode<SerializedLexicalNode>, TCustom>\n list: WithRecursiveChildren<SerializedListNode<SerializedLexicalNode>, TCustom>\n listitem: WithRecursiveChildren<SerializedListItemNode<SerializedLexicalNode>, TCustom>\n paragraph: WithRecursiveChildren<SerializedParagraphNode<SerializedLexicalNode>, TCustom>\n quote: WithRecursiveChildren<SerializedQuoteNode<SerializedLexicalNode>, TCustom>\n relationship: SerializedRelationshipNode\n tab: SerializedTabNode\n text: SerializedTextNode\n upload: SerializedUploadNode\n}\n\n/**\n * Like `TypedEditorState`, but pre-filled with every default node type. Pass extra node types as a\n * generic to add your own; they're threaded into every container's `children` (via\n * {@link WithDefaultNodes}), not just allowed at the top level.\n */\nexport type DefaultTypedEditorState<\n TAdditionalNodeTypes extends null | SerializedLexicalNode = null,\n> = TypedEditorState<WithDefaultNodes<NonNullable<TAdditionalNodeTypes>>>\n"],"mappings":"AAuLA;;;;GAKA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/types/schema.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAqBxD,eAAO,MAAM,oBAAoB,EAAE,CAAC,IAAI,EAAE;IACxC,YAAY,EAAE,2BAA2B,CAAA;CAC1C,KAAK,sBAAsB,CAAC,YAAY,CAsFxC,CAAA"}
|
package/dist/types/schema.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import { CORE_LEXICAL_TYPE_STRING, lineBreakNodeJSONSchema, paragraphNodeJSONSchema, rootNodeJSONSchema, tabNodeJSONSchema, textNodeJSONSchema } from './builtInNodes.js';
|
|
3
|
+
import { elementNodeSchema } from './jsonSchemaHelpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* The node-union name is a hash of its own schema (so identical editors dedupe).
|
|
6
|
+
* Since the schema references the union name, we use a placeholder during build
|
|
7
|
+
* and substitute the real hash once everything's assembled. Features can derive
|
|
8
|
+
* sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.
|
|
9
|
+
*/
|
|
10
|
+
const NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__';
|
|
11
|
+
const NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`;
|
|
2
12
|
export const getFieldToJSONSchema = ({
|
|
3
13
|
editorConfig
|
|
4
14
|
}) => {
|
|
@@ -8,74 +18,66 @@ export const getFieldToJSONSchema = ({
|
|
|
8
18
|
field,
|
|
9
19
|
i18n,
|
|
10
20
|
interfaceNameDefinitions,
|
|
11
|
-
|
|
21
|
+
typeStringDefinitions
|
|
12
22
|
}) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
properties: {
|
|
24
|
-
type: {
|
|
25
|
-
type: 'string'
|
|
26
|
-
},
|
|
27
|
-
children: {
|
|
28
|
-
type: 'array',
|
|
29
|
-
items: {
|
|
30
|
-
type: 'object',
|
|
31
|
-
additionalProperties: true,
|
|
32
|
-
properties: {
|
|
33
|
-
type: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
tsType: 'any'
|
|
36
|
-
},
|
|
37
|
-
version: {
|
|
38
|
-
type: 'integer'
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
required: ['type', 'version']
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
direction: {
|
|
45
|
-
oneOf: [{
|
|
46
|
-
enum: ['ltr', 'rtl']
|
|
47
|
-
}, {
|
|
48
|
-
type: 'null'
|
|
49
|
-
}]
|
|
50
|
-
},
|
|
51
|
-
format: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
enum: ['left', 'start', 'center', 'right', 'end', 'justify', '']
|
|
54
|
-
},
|
|
55
|
-
indent: {
|
|
56
|
-
type: 'integer'
|
|
57
|
-
},
|
|
58
|
-
version: {
|
|
59
|
-
type: 'integer'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
required: ['children', 'direction', 'format', 'indent', 'type', 'version']
|
|
23
|
+
// Step 1: build the schema for every node type allowed in this field.
|
|
24
|
+
typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING);
|
|
25
|
+
const nodeJsonSchemaArgs = {
|
|
26
|
+
collectionIDFieldTypes,
|
|
27
|
+
config,
|
|
28
|
+
// Each element node needs its children typed using the union node type recursively
|
|
29
|
+
elementNodeSchema: args => elementNodeSchema({
|
|
30
|
+
...args,
|
|
31
|
+
nodeUnionRef: {
|
|
32
|
+
$ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
|
|
63
33
|
}
|
|
64
|
-
},
|
|
65
|
-
|
|
34
|
+
}),
|
|
35
|
+
field,
|
|
36
|
+
i18n,
|
|
37
|
+
interfaceNameDefinitions,
|
|
38
|
+
nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,
|
|
39
|
+
typeStringDefinitions
|
|
66
40
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
41
|
+
const nodeSchemas = [
|
|
42
|
+
// Add built-in node schemas
|
|
43
|
+
textNodeJSONSchema(nodeJsonSchemaArgs), tabNodeJSONSchema(nodeJsonSchemaArgs), lineBreakNodeJSONSchema(nodeJsonSchemaArgs), paragraphNodeJSONSchema(nodeJsonSchemaArgs),
|
|
44
|
+
// Add feature node schemas
|
|
45
|
+
...editorConfig.features.nodes.filter(node => node.jsonSchema).map(node => node.jsonSchema(nodeJsonSchemaArgs))];
|
|
46
|
+
const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs);
|
|
47
|
+
// Step 2: get the final node union name, then replace the placeholder
|
|
48
|
+
// in both the union members and the root node.
|
|
49
|
+
//
|
|
50
|
+
// See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.
|
|
51
|
+
const nodeUnionJson = JSON.stringify({
|
|
52
|
+
oneOf: nodeSchemas
|
|
53
|
+
});
|
|
54
|
+
// Features can register per-editor definitions during node-schema build (e.g. a link node's
|
|
55
|
+
// custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node
|
|
56
|
+
// union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same
|
|
57
|
+
// nodes but different feature config (e.g. different custom link fields) would otherwise hash
|
|
58
|
+
// identically and overwrite each other's definition. To avoid that, include that content into the hash too.
|
|
59
|
+
const pendingDefinitions = [...interfaceNameDefinitions.entries()].filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER)).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
60
|
+
const hashInput = pendingDefinitions.length ? JSON.stringify({
|
|
61
|
+
definitions: pendingDefinitions,
|
|
62
|
+
oneOf: nodeSchemas
|
|
63
|
+
}) : nodeUnionJson;
|
|
64
|
+
const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase();
|
|
65
|
+
const nodeUnionName = `LexicalNodes_${hash}`;
|
|
66
|
+
// Replacing the hash resolves the union name and any feature-derived
|
|
67
|
+
// sibling names in one pass.
|
|
68
|
+
const replacePlaceholder = schemaString => JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash));
|
|
69
|
+
// Resolve placeholders left in feature-registered definitions so Map keys
|
|
70
|
+
// and `$ref` targets line up.
|
|
71
|
+
for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {
|
|
72
|
+
const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash);
|
|
73
|
+
const resolvedSchema = replacePlaceholder(JSON.stringify(schema));
|
|
74
|
+
if (newKey !== oldKey) {
|
|
75
|
+
interfaceNameDefinitions.delete(oldKey);
|
|
76
|
+
}
|
|
77
|
+
interfaceNameDefinitions.set(newKey, resolvedSchema);
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson));
|
|
80
|
+
return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder));
|
|
79
81
|
};
|
|
80
82
|
};
|
|
81
83
|
//# sourceMappingURL=schema.js.map
|
package/dist/types/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":["
|
|
1
|
+
{"version":3,"file":"schema.js","names":["createHash","CORE_LEXICAL_TYPE_STRING","lineBreakNodeJSONSchema","paragraphNodeJSONSchema","rootNodeJSONSchema","tabNodeJSONSchema","textNodeJSONSchema","elementNodeSchema","NODE_UNION_HASH_PLACEHOLDER","NODE_UNION_NAME_PLACEHOLDER","getFieldToJSONSchema","editorConfig","collectionIDFieldTypes","config","field","i18n","interfaceNameDefinitions","typeStringDefinitions","add","nodeJsonSchemaArgs","args","nodeUnionRef","$ref","nodeUnionName","nodeSchemas","features","nodes","filter","node","jsonSchema","map","rootSchemaWithPlaceholder","nodeUnionJson","JSON","stringify","oneOf","pendingDefinitions","entries","key","includes","sort","a","b","hashInput","length","definitions","hash","update","digest","slice","toUpperCase","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","newKey","resolvedSchema","delete","set"],"sources":["../../src/types/schema.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\nimport { createHash } from 'crypto'\n\nimport type { JSONSchemaArgs } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextAdapter } from './index.js'\n\nimport {\n CORE_LEXICAL_TYPE_STRING,\n lineBreakNodeJSONSchema,\n paragraphNodeJSONSchema,\n rootNodeJSONSchema,\n tabNodeJSONSchema,\n textNodeJSONSchema,\n} from './builtInNodes.js'\nimport { elementNodeSchema } from './jsonSchemaHelpers.js'\n\n/**\n * The node-union name is a hash of its own schema (so identical editors dedupe).\n * Since the schema references the union name, we use a placeholder during build\n * and substitute the real hash once everything's assembled. Features can derive\n * sibling names (e.g. `LexicalLinkFields_<hash>`) using the bare hash placeholder.\n */\nconst NODE_UNION_HASH_PLACEHOLDER = '__LEXICAL_NODE_UNION_HASH__'\nconst NODE_UNION_NAME_PLACEHOLDER = `LexicalNodes_${NODE_UNION_HASH_PLACEHOLDER}`\n\nexport const getFieldToJSONSchema: (args: {\n editorConfig: SanitizedServerEditorConfig\n}) => LexicalRichTextAdapter['jsonSchema'] = ({ editorConfig }) => {\n return ({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n typeStringDefinitions,\n }) => {\n // Step 1: build the schema for every node type allowed in this field.\n\n typeStringDefinitions.add(CORE_LEXICAL_TYPE_STRING)\n\n const nodeJsonSchemaArgs: JSONSchemaArgs = {\n collectionIDFieldTypes,\n config,\n // Each element node needs its children typed using the union node type recursively\n elementNodeSchema: (args) =>\n elementNodeSchema({\n ...args,\n nodeUnionRef: {\n $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`,\n },\n }),\n field,\n i18n,\n interfaceNameDefinitions,\n nodeUnionName: NODE_UNION_NAME_PLACEHOLDER,\n typeStringDefinitions,\n }\n\n const nodeSchemas: JSONSchema4[] = [\n // Add built-in node schemas\n textNodeJSONSchema(nodeJsonSchemaArgs),\n tabNodeJSONSchema(nodeJsonSchemaArgs),\n lineBreakNodeJSONSchema(nodeJsonSchemaArgs),\n paragraphNodeJSONSchema(nodeJsonSchemaArgs),\n // Add feature node schemas\n ...editorConfig.features.nodes\n .filter((node) => node.jsonSchema)\n .map((node) => node.jsonSchema!(nodeJsonSchemaArgs)),\n ]\n const rootSchemaWithPlaceholder = rootNodeJSONSchema(nodeJsonSchemaArgs)\n\n // Step 2: get the final node union name, then replace the placeholder\n // in both the union members and the root node.\n //\n // See JSDocs for `NODE_UNION_NAME_PLACEHOLDER` for why we use a placeholder and hashing.\n const nodeUnionJson = JSON.stringify({ oneOf: nodeSchemas })\n\n // Features can register per-editor definitions during node-schema build (e.g. a link node's\n // custom `LexicalLinkFields_<hash>`), keyed by the not-yet-resolved hash placeholder. The node\n // union only `$ref`s them, so their content isn't in `nodeUnionJson` - two editors with the same\n // nodes but different feature config (e.g. different custom link fields) would otherwise hash\n // identically and overwrite each other's definition. To avoid that, include that content into the hash too.\n const pendingDefinitions = [...interfaceNameDefinitions.entries()]\n .filter(([key]) => key.includes(NODE_UNION_HASH_PLACEHOLDER))\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\n const hashInput = pendingDefinitions.length\n ? JSON.stringify({ definitions: pendingDefinitions, oneOf: nodeSchemas })\n : nodeUnionJson\n\n const hash = createHash('sha256').update(hashInput).digest('hex').slice(0, 8).toUpperCase()\n const nodeUnionName = `LexicalNodes_${hash}`\n\n // Replacing the hash resolves the union name and any feature-derived\n // sibling names in one pass.\n const replacePlaceholder = (schemaString: string) =>\n JSON.parse(schemaString.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)) as JSONSchema4\n\n // Resolve placeholders left in feature-registered definitions so Map keys\n // and `$ref` targets line up.\n for (const [oldKey, schema] of [...interfaceNameDefinitions.entries()]) {\n const newKey = oldKey.replaceAll(NODE_UNION_HASH_PLACEHOLDER, hash)\n const resolvedSchema = replacePlaceholder(JSON.stringify(schema))\n if (newKey !== oldKey) {\n interfaceNameDefinitions.delete(oldKey)\n }\n interfaceNameDefinitions.set(newKey, resolvedSchema)\n }\n\n interfaceNameDefinitions.set(nodeUnionName, replacePlaceholder(nodeUnionJson))\n\n return replacePlaceholder(JSON.stringify(rootSchemaWithPlaceholder))\n }\n}\n"],"mappings":"AAEA,SAASA,UAAU,QAAQ;AAM3B,SACEC,wBAAwB,EACxBC,uBAAuB,EACvBC,uBAAuB,EACvBC,kBAAkB,EAClBC,iBAAiB,EACjBC,kBAAkB,QACb;AACP,SAASC,iBAAiB,QAAQ;AAElC;;;;;;AAMA,MAAMC,2BAAA,GAA8B;AACpC,MAAMC,2BAAA,GAA8B,gBAAgBD,2BAAA,EAA6B;AAEjF,OAAO,MAAME,oBAAA,GAEgCA,CAAC;EAAEC;AAAY,CAAE;EAC5D,OAAO,CAAC;IACNC,sBAAsB;IACtBC,MAAM;IACNC,KAAK;IACLC,IAAI;IACJC,wBAAwB;IACxBC;EAAqB,C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MAAoBD,KAAA,EAAOX;IAAY,KACrEQ,aAAA;IAEJ,MAAMc,IAAA,GAAO9C,UAAA,CAAW,UAAU+C,MAAM,CAACJ,SAAA,EAAWK,MAAM,CAAC,OAAOC,KAAK,CAAC,GAAG,GAAGC,WAAW;IACzF,MAAM3B,aAAA,GAAgB,gBAAgBuB,IAAA,EAAM;IAE5C;IACA;IACA,MAAMK,kBAAA,GAAsBC,YAAA,IAC1BnB,IAAA,CAAKoB,KAAK,CAACD,YAAA,CAAaE,UAAU,CAAC9C,2BAAA,EAA6BsC,IAAA;IAElE;IACA;IACA,KAAK,MAAM,CAACS,MAAA,EAAQC,MAAA,CAAO,IAAI,C,GAAIxC,wBAAA,CAAyBqB,OAAO,GAAG,EAAE;MACtE,MAAMoB,MAAA,GAASF,MAAA,CAAOD,UAAU,CAAC9C,2BAAA,EAA6BsC,IAAA;MAC9D,MAAMY,cAAA,GAAiBP,kBAAA,CAAmBlB,IAAA,CAAKC,SAAS,CAACsB,MAAA;MACzD,IAAIC,MAAA,KAAWF,MAAA,EAAQ;QACrBvC,wBAAA,CAAyB2C,MAAM,CAACJ,MAAA;MAClC;MACAvC,wBAAA,CAAyB4C,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEA1C,wBAAA,CAAyB4C,GAAG,CAACrC,aAAA,EAAe4B,kBAAA,CAAmBnB,aAAA;IAE/D,OAAOmB,kBAAA,CAAmBlB,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { SerializedLexicalNode } from 'lexical';
|
|
2
2
|
import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a
|
|
5
|
+
* generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.
|
|
6
|
+
*/
|
|
7
|
+
type BuildNodes<T> = NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode> ? TNode : Extract<NonNullable<T>, SerializedLexicalNode>;
|
|
3
8
|
/**
|
|
4
9
|
* Helper to build lexical editor state JSON from text and/or nodes.
|
|
5
10
|
*
|
|
@@ -36,11 +41,19 @@ import type { DefaultNodeTypes, TypedEditorState } from '../types/nodeTypes.js';
|
|
|
36
41
|
* ],
|
|
37
42
|
* })
|
|
38
43
|
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* passing a generated `richText` field type — the result is exactly that field's type:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
|
|
51
|
+
* ```
|
|
39
52
|
*/
|
|
40
|
-
export declare function buildEditorState<T extends SerializedLexicalNode>({ nodes, text, }: {
|
|
41
|
-
nodes?: TypedEditorState<T
|
|
53
|
+
export declare function buildEditorState<T extends null | SerializedLexicalNode | TypedEditorState<SerializedLexicalNode> | undefined = DefaultNodeTypes>({ nodes, text, }: {
|
|
54
|
+
nodes?: TypedEditorState<BuildNodes<T>>['root']['children'];
|
|
42
55
|
text?: string;
|
|
43
|
-
}): TypedEditorState<T
|
|
56
|
+
}): TypedEditorState<BuildNodes<T>>;
|
|
44
57
|
/**
|
|
45
58
|
*
|
|
46
59
|
* Alias for `buildEditorState<DefaultNodeTypes>`
|
|
@@ -49,4 +62,5 @@ export declare function buildEditorState<T extends SerializedLexicalNode>({ node
|
|
|
49
62
|
* @internal
|
|
50
63
|
*/
|
|
51
64
|
export declare const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes>;
|
|
65
|
+
export {};
|
|
52
66
|
//# sourceMappingURL=buildEditorState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B
|
|
1
|
+
{"version":3,"file":"buildEditorState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildEditorState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAE9B;;;GAGG;AACH,KAAK,UAAU,CAAC,CAAC,IACf,WAAW,CAAC,CAAC,CAAC,SAAS,gBAAgB,CAAC,MAAM,KAAK,SAAS,qBAAqB,CAAC,GAC9E,KAAK,GACL,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,SACG,IAAI,GACJ,qBAAqB,GACrB,gBAAgB,CAAC,qBAAqB,CAAC,GACvC,SAAS,GAAG,gBAAgB,EAChC,EACA,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAuDlC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
|
|
@@ -34,6 +34,14 @@
|
|
|
34
34
|
* ],
|
|
35
35
|
* })
|
|
36
36
|
* ```
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* passing a generated `richText` field type — the result is exactly that field's type:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })
|
|
44
|
+
* ```
|
|
37
45
|
*/export function buildEditorState({
|
|
38
46
|
nodes,
|
|
39
47
|
text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n */\nexport function buildEditorState
|
|
1
|
+
{"version":3,"file":"buildEditorState.js","names":["buildEditorState","nodes","text","editorJSON","root","type","children","direction","format","indent","version","push","detail","mode","style","textFormat","textStyle","length","buildDefaultEditorState"],"sources":["../../src/utilities/buildEditorState.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n DefaultTypedEditorState,\n TypedEditorState,\n} from '../types/nodeTypes.js'\n\n/**\n * The node union to build with. Accepts either a node union directly (e.g. `DefaultNodeTypes`) or a\n * generated `richText` field type (e.g. `Post['richText']`), whose nodes are extracted automatically.\n */\ntype BuildNodes<T> =\n NonNullable<T> extends TypedEditorState<infer TNode extends SerializedLexicalNode>\n ? TNode\n : Extract<NonNullable<T>, SerializedLexicalNode>\n\n/**\n * Helper to build lexical editor state JSON from text and/or nodes.\n *\n * @param nodes - The nodes to include in the editor state. If you pass the `text` argument, this will append your nodes after the first paragraph node.\n * @param text - The text content to include in the editor state. This will create a paragraph node with a text node for you and set that as the first node.\n * @returns The constructed editor state JSON.\n *\n * @example\n *\n * just passing text:\n *\n * ```ts\n * const editorState = buildEditorState<DefaultNodeTypes>({ text: 'Hello world' }) // result typed as DefaultTypedEditorState\n * ```\n *\n * @example\n *\n * passing nodes:\n *\n * ```ts\n * const editorState = // result typed as TypedEditorState<DefaultNodeTypes | SerializedBlockNode> (or TypedEditorState<SerializedBlockNode>)\n * buildEditorState<DefaultNodeTypes | SerializedBlockNode>({ // or just buildEditorState<SerializedBlockNode> if you *only* want to allow block nodes\n * nodes: [\n * {\n * type: 'block',\n * fields: {\n * id: 'id',\n * blockName: 'Cool block',\n * blockType: 'myBlock',\n * },\n * format: 'left',\n * version: 1,\n * }\n * ],\n * })\n * ```\n *\n * @example\n *\n * passing a generated `richText` field type — the result is exactly that field's type:\n *\n * ```ts\n * post.richText = buildEditorState<Post['richText']>({ text: 'Hello world' })\n * ```\n */\nexport function buildEditorState<\n T extends\n | null\n | SerializedLexicalNode\n | TypedEditorState<SerializedLexicalNode>\n | undefined = DefaultNodeTypes,\n>({\n nodes,\n text,\n}: {\n nodes?: TypedEditorState<BuildNodes<T>>['root']['children']\n text?: string\n}): TypedEditorState<BuildNodes<T>> {\n const editorJSON: DefaultTypedEditorState = {\n root: {\n type: 'root',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n\n if (text) {\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [\n {\n type: 'text',\n detail: 0,\n format: 0,\n mode: 'normal',\n style: '',\n text,\n version: 1,\n },\n ],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n if (nodes?.length) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n editorJSON.root.children.push(...(nodes as any))\n }\n\n if (editorJSON.root.children.length === 0) {\n // An error will be thrown if the root node has no children\n editorJSON.root.children.push({\n type: 'paragraph',\n children: [],\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n })\n }\n\n return editorJSON as TypedEditorState<BuildNodes<T>>\n}\n\n/**\n *\n * Alias for `buildEditorState<DefaultNodeTypes>`\n *\n * @experimental this API may change or be removed in a minor release\n * @internal\n */\nexport const buildDefaultEditorState: typeof buildEditorState<DefaultNodeTypes> =\n buildEditorState<DefaultNodeTypes>\n"],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CA,OAAO,SAASA,iBAMd;EACAC,KAAK;EACLC;AAAI,CAIL;EACC,MAAMC,UAAA,GAAsC;IAC1CC,IAAA,EAAM;MACJC,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRC,OAAA,EAAS;IACX;EACF;EAEA,IAAIR,IAAA,EAAM;IACRC,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,CACR;QACED,IAAA,EAAM;QACNO,MAAA,EAAQ;QACRJ,MAAA,EAAQ;QACRK,IAAA,EAAM;QACNC,KAAA,EAAO;QACPZ,IAAA;QACAQ,OAAA,EAAS;MACX,EACD;MACDH,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,IAAIT,KAAA,EAAOgB,MAAA,EAAQ;IACjB;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,IAAKV,KAAA;EACpC;EAEA,IAAIE,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACW,MAAM,KAAK,GAAG;IACzC;IACAd,UAAA,CAAWC,IAAI,CAACE,QAAQ,CAACK,IAAI,CAAC;MAC5BN,IAAA,EAAM;MACNC,QAAA,EAAU,EAAE;MACZC,SAAA,EAAW;MACXC,MAAA,EAAQ;MACRC,MAAA,EAAQ;MACRM,UAAA,EAAY;MACZC,SAAA,EAAW;MACXN,OAAA,EAAS;IACX;EACF;EAEA,OAAOP,UAAA;AACT;AAEA;;;;;;;AAOA,OAAO,MAAMe,uBAAA,GACXlB,gBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SerializedLexicalNode } from 'lexical';
|
|
2
|
-
import type { ClientFieldSchemaMap, DocumentPreferences, FieldSchemaMap, FormState, Operation, PayloadRequest, RichTextField, SanitizedFieldPermissions } from 'payload';
|
|
2
|
+
import type { ClientFieldSchemaMap, ComponentRenderer, DocumentPreferences, FieldSchemaMap, FormState, Operation, PayloadRequest, RichTextField, SanitizedFieldPermissions } from 'payload';
|
|
3
3
|
export type InitialLexicalFormState = {
|
|
4
4
|
[nodeID: string]: {
|
|
5
5
|
[key: string]: any;
|
|
@@ -19,6 +19,7 @@ type Props = {
|
|
|
19
19
|
operation: Operation;
|
|
20
20
|
permissions?: SanitizedFieldPermissions;
|
|
21
21
|
preferences: DocumentPreferences;
|
|
22
|
+
renderComponent: ComponentRenderer;
|
|
22
23
|
renderFieldFn: any;
|
|
23
24
|
req: PayloadRequest;
|
|
24
25
|
};
|