@payloadcms/richtext-lexical 4.0.0-internal.5f0cd13 → 4.0.0-internal.688c4d0

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.
Files changed (156) hide show
  1. package/dist/@types/assets.d.js +2 -0
  2. package/dist/@types/assets.d.js.map +1 -0
  3. package/dist/cell/rscEntry.d.ts.map +1 -1
  4. package/dist/cell/rscEntry.js +5 -5
  5. package/dist/cell/rscEntry.js.map +1 -1
  6. package/dist/exports/client/Field-VYBSMSRY.js +2 -0
  7. package/dist/exports/client/Field-VYBSMSRY.js.map +7 -0
  8. package/dist/exports/client/bundled.css +1 -1
  9. package/dist/exports/client/chunk-5VIL27GI.js +2 -0
  10. package/dist/exports/client/chunk-5VIL27GI.js.map +7 -0
  11. package/dist/exports/client/chunk-ESITTE3C.js +2 -0
  12. package/dist/exports/client/chunk-ESITTE3C.js.map +7 -0
  13. package/dist/exports/client/chunk-UD4DQ4AK.js +2 -0
  14. package/dist/exports/client/chunk-UD4DQ4AK.js.map +7 -0
  15. package/dist/exports/client/{component-HKTAZ77E.js → component-PHZQBOJE.js} +2 -2
  16. package/dist/exports/client/componentInline-H24N7GUG.js +2 -0
  17. package/dist/exports/client/index.d.ts +1 -0
  18. package/dist/exports/client/index.d.ts.map +1 -1
  19. package/dist/exports/client/index.js +25 -25
  20. package/dist/exports/client/index.js.map +4 -4
  21. package/dist/exports/server/rsc.browser.d.ts +11 -0
  22. package/dist/exports/server/rsc.browser.d.ts.map +1 -0
  23. package/dist/exports/server/rsc.browser.js +10 -0
  24. package/dist/exports/server/rsc.browser.js.map +1 -0
  25. package/dist/features/blocks/client/component/index.d.ts +1 -0
  26. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  27. package/dist/features/blocks/client/component/index.js +16 -8
  28. package/dist/features/blocks/client/component/index.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/index.d.ts +1 -0
  30. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  31. package/dist/features/blocks/client/componentInline/index.js +15 -7
  32. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  33. package/dist/features/blocks/client/index.d.ts.map +1 -1
  34. package/dist/features/blocks/client/index.js +4 -2
  35. package/dist/features/blocks/client/index.js.map +1 -1
  36. package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -1
  37. package/dist/features/blocks/premade/CodeBlock/Component/Block.js +1 -0
  38. package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
  39. package/dist/features/blocks/server/index.d.ts.map +1 -1
  40. package/dist/features/blocks/server/index.js +6 -8
  41. package/dist/features/blocks/server/index.js.map +1 -1
  42. package/dist/features/blocks/server/schema.d.ts +5 -5
  43. package/dist/features/blocks/server/schema.d.ts.map +1 -1
  44. package/dist/features/blocks/server/schema.js +26 -23
  45. package/dist/features/blocks/server/schema.js.map +1 -1
  46. package/dist/features/converters/lexicalToHtml/async/types.d.ts +13 -15
  47. package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
  48. package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
  49. package/dist/features/converters/lexicalToHtml/sync/types.d.ts +13 -15
  50. package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
  51. package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
  52. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -2
  53. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  54. package/dist/features/converters/lexicalToJSX/Component/index.js +5 -4
  55. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  56. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +12 -14
  57. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  58. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  59. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts +12 -14
  60. package/dist/features/converters/lexicalToPlaintext/sync/types.d.ts.map +1 -1
  61. package/dist/features/converters/lexicalToPlaintext/sync/types.js.map +1 -1
  62. package/dist/features/experimental_table/server/schema.d.ts.map +1 -1
  63. package/dist/features/experimental_table/server/schema.js +6 -3
  64. package/dist/features/experimental_table/server/schema.js.map +1 -1
  65. package/dist/features/link/server/schema.d.ts.map +1 -1
  66. package/dist/features/link/server/schema.js +10 -7
  67. package/dist/features/link/server/schema.js.map +1 -1
  68. package/dist/features/relationship/server/schema.d.ts.map +1 -1
  69. package/dist/features/relationship/server/schema.js +5 -8
  70. package/dist/features/relationship/server/schema.js.map +1 -1
  71. package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
  72. package/dist/features/upload/client/component/index.css +2 -2
  73. package/dist/features/upload/server/schema.d.ts +4 -4
  74. package/dist/features/upload/server/schema.d.ts.map +1 -1
  75. package/dist/features/upload/server/schema.js +34 -18
  76. package/dist/features/upload/server/schema.js.map +1 -1
  77. package/dist/field/bundled.css +1 -1
  78. package/dist/field/clientEntry.d.ts +29 -0
  79. package/dist/field/clientEntry.d.ts.map +1 -0
  80. package/dist/field/clientEntry.js +86 -0
  81. package/dist/field/clientEntry.js.map +1 -0
  82. package/dist/field/index.css +13 -12
  83. package/dist/field/index.js +1 -1
  84. package/dist/field/index.js.map +1 -1
  85. package/dist/field/rscEntry.d.ts.map +1 -1
  86. package/dist/field/rscEntry.js +2 -0
  87. package/dist/field/rscEntry.js.map +1 -1
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +47 -4
  90. package/dist/index.js.map +1 -1
  91. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  92. package/dist/lexical/LexicalEditor.js +36 -2
  93. package/dist/lexical/LexicalEditor.js.map +1 -1
  94. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  95. package/dist/lexical/LexicalProvider.js +22 -7
  96. package/dist/lexical/LexicalProvider.js.map +1 -1
  97. package/dist/lexical/config/client/loader.d.ts.map +1 -1
  98. package/dist/lexical/config/client/loader.js +5 -1
  99. package/dist/lexical/config/client/loader.js.map +1 -1
  100. package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
  101. package/dist/types/builtInNodes.d.ts.map +1 -1
  102. package/dist/types/builtInNodes.js +17 -17
  103. package/dist/types/builtInNodes.js.map +1 -1
  104. package/dist/types/index.d.ts +16 -16
  105. package/dist/types/index.d.ts.map +1 -1
  106. package/dist/types/index.js.map +1 -1
  107. package/dist/types/jsonSchemaHelpers.d.ts +2 -0
  108. package/dist/types/jsonSchemaHelpers.d.ts.map +1 -1
  109. package/dist/types/jsonSchemaHelpers.js +7 -3
  110. package/dist/types/jsonSchemaHelpers.js.map +1 -1
  111. package/dist/types/nodeTypes.d.ts +51 -9
  112. package/dist/types/nodeTypes.d.ts.map +1 -1
  113. package/dist/types/nodeTypes.js +3 -3
  114. package/dist/types/nodeTypes.js.map +1 -1
  115. package/dist/types/schema.d.ts.map +1 -1
  116. package/dist/types/schema.js +12 -2
  117. package/dist/types/schema.js.map +1 -1
  118. package/dist/utilities/applyBaseFilterToFields.d.ts.map +1 -1
  119. package/dist/utilities/applyBaseFilterToFields.js +1 -2
  120. package/dist/utilities/applyBaseFilterToFields.js.map +1 -1
  121. package/dist/utilities/buildEditorState.d.ts +17 -3
  122. package/dist/utilities/buildEditorState.d.ts.map +1 -1
  123. package/dist/utilities/buildEditorState.js +8 -0
  124. package/dist/utilities/buildEditorState.js.map +1 -1
  125. package/dist/utilities/buildInitialState.d.ts +2 -1
  126. package/dist/utilities/buildInitialState.d.ts.map +1 -1
  127. package/dist/utilities/buildInitialState.js.map +1 -1
  128. package/dist/utilities/fieldsDrawer/Drawer.d.ts.map +1 -1
  129. package/dist/utilities/fieldsDrawer/Drawer.js +19 -10
  130. package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
  131. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts +4 -1
  132. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  133. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -7
  134. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  135. package/dist/utilities/fieldsDrawer/index.css +16 -0
  136. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts +29 -0
  137. package/dist/utilities/fieldsDrawer/useDrawerSubmit.d.ts.map +1 -0
  138. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js +97 -0
  139. package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -0
  140. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  141. package/dist/utilities/generateImportMap.js +7 -3
  142. package/dist/utilities/generateImportMap.js.map +1 -1
  143. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js +1 -1
  144. package/dist/utilities/upgradeLexicalData/upgradeDocumentFieldsRecursively.js.map +1 -1
  145. package/package.json +9 -8
  146. package/dist/exports/client/Field-G5Z2HM5Y.js +0 -2
  147. package/dist/exports/client/Field-G5Z2HM5Y.js.map +0 -7
  148. package/dist/exports/client/chunk-6QWQ7JV4.js +0 -2
  149. package/dist/exports/client/chunk-6QWQ7JV4.js.map +0 -7
  150. package/dist/exports/client/chunk-INBEEENE.js +0 -2
  151. package/dist/exports/client/chunk-INBEEENE.js.map +0 -7
  152. package/dist/exports/client/chunk-UAKNDD6R.js +0 -2
  153. package/dist/exports/client/chunk-UAKNDD6R.js.map +0 -7
  154. package/dist/exports/client/componentInline-D3A6OW76.js +0 -2
  155. /package/dist/exports/client/{component-HKTAZ77E.js.map → component-PHZQBOJE.js.map} +0 -0
  156. /package/dist/exports/client/{componentInline-D3A6OW76.js.map → componentInline-H24N7GUG.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n DecoratorNode,\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type { BlockComponentContextType } from '../features/blocks/client/component/BlockContent.js'\nexport type { BlockComponentContextType }\nimport type { BlockComponentProps } from '../features/blocks/client/component/index.js'\nimport type { InlineBlockComponentContextType } from '../features/blocks/client/componentInline/index.js'\nimport type {\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../features/converters/lexicalToJSX/converter/types.js'\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from '../features/typesClient.js'\nimport type { FeatureProviderServer } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { InitialLexicalFormState } from '../utilities/buildInitialState.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\n\n/**\n * Base constraint for serialized Lexical node types.\n * Used as the generic constraint for node map types.\n * Extends the base SerializedLexicalNode with optional type for flexibility.\n */\nexport type SerializedNodeBase = { type?: string }\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapValue<TNode extends SerializedNodeBase = SerializedLexicalNode> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\ntype SharedViewMapBlockEditorProps<TNode extends SerializedBlockNode | SerializedInlineBlockNode> =\n {\n /**\n * True when rendering in the admin editor.\n */\n isEditor: true\n /**\n * False when rendering in the admin editor.\n */\n isJSXConverter: false\n } & Pick<BlockComponentProps<TNode['fields']>, 'className' | 'formData' | 'nodeKey'>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockEditorProps<TNode extends SerializedBlockNode> = {\n /**\n * Hook to access block UI components (BlockCollapsible, EditButton, etc.).\n * Call this inside your component to get the context values.\n * Passed as a prop so you don't need to import from @payloadcms/richtext-lexical/client.\n */\n useBlockComponentContext: () => BlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapInlineBlockEditorProps<TNode extends SerializedInlineBlockNode> = {\n useInlineBlockComponentContext: () => InlineBlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in JSX converter mode (frontend).\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockJSXConverterProps<\n TNode extends SerializedBlockNode | SerializedInlineBlockNode =\n | SerializedBlockNode\n | SerializedInlineBlockNode,\n> = {\n /**\n * Index of this node among its siblings.\n */\n childIndex: number\n /**\n * Available JSX converters for nested content.\n */\n converters: JSXConverters\n /**\n * The block's form data (field values).\n */\n formData: TNode['fields']\n /**\n * False when rendering via JSX converter (frontend).\n */\n isEditor: false\n /**\n * True when rendering via JSX converter (frontend).\n */\n isJSXConverter: true\n /**\n * The serialized block node.\n */\n node: TNode\n /**\n * Function to convert child nodes to JSX.\n */\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n /**\n * The parent node in the tree.\n */\n parent: SerializedLexicalNodeWithParent\n}\n\n/**\n * Props passed to a custom Block component in a view map.\n * This is a discriminated union - use `isEditor` to narrow the type.\n *\n * When `isEditor` is true, you're in the admin editor with access to `blockContext`.\n * When `isEditor` is false, you're in the frontend JSX converter with `nodesToJSX`.\n *\n * @example\n * ```tsx\n * const MyBlock: React.FC<ViewMapBlockComponentProps> = (props) => {\n * if (props.isEditor) {\n * // Admin editor - blockContext available\n * const { BlockCollapsible, EditButton } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * // Frontend - readonly render\n * return <div>{props.formData.title}</div>\n * }\n * ```\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockComponentProps<TNode extends SerializedBlockNode = SerializedBlockNode> =\n | ViewMapBlockEditorProps<TNode>\n | ViewMapBlockJSXConverterProps<TNode>\n\nexport type ViewMapInlineBlockComponentProps<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = ViewMapBlockJSXConverterProps<TNode> | ViewMapInlineBlockEditorProps<TNode>\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapBlockValue<TNode extends SerializedBlockNode = SerializedBlockNode> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * Block: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\nexport type NodeMapInlineBlockValue<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * InlineBlock: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends SerializedNodeBase =\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 // The index signature must include NodeMapBlockValue in the nested blockSlug mapping because\n // 'blocks' and 'inlineBlocks' properties use NodeMapBlockValue (which adds Block/Label props).\n // TypeScript requires that intersection properties be assignable to index signatures.\n [key: string]:\n | {\n [blockSlug: string]: NodeMapBlockValue<any> | NodeMapInlineBlockValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapBlockValue<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: NodeMapInlineBlockValue<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type ClientFeaturesMap = {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n}\n\nexport type LexicalEditorViewMap<\n TNodes extends SerializedNodeBase =\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 [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n /**\n * Transform the client features for this view.\n * Receives the full clientFeatures map and should return a (potentially modified) map.\n * Can be used to remove features or add new ones per-view.\n *\n * @example Remove toolbars\n * ```ts\n * filterFeatures: (features) => {\n * const { toolbarFixed, toolbarInline, ...rest } = features\n * return rest\n * }\n * ```\n */\n filterFeatures?: (clientFeatures: ClientFeaturesMap) => ClientFeaturesMap\n /**\n * Lexical editor configuration. Can be an object or a function that receives the default config.\n * Using a function avoids needing to import defaultEditorLexicalConfig.\n *\n * @example\n * ```ts\n * lexical: (defaultConfig) => ({\n * ...defaultConfig,\n * theme: { ...defaultConfig.theme, paragraph: 'my-paragraph' },\n * })\n * ```\n */\n lexical?: ((defaultConfig: LexicalEditorConfig) => LexicalEditorConfig) | LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: ClientFeaturesMap\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState: InitialLexicalFormState\n lexicalEditorConfig: LexicalEditorConfig | undefined // Undefined if default lexical editor config should be used\n views?: LexicalEditorViewMap\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAmiBA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["import type {\n DecoratorNode,\n EditorConfig,\n LexicalEditor,\n EditorConfig as LexicalEditorConfig,\n LexicalNode,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n ClientField,\n DefaultServerCellComponentProps,\n LabelFunction,\n PayloadComponent,\n RichTextAdapter,\n RichTextField,\n RichTextFieldClient,\n RichTextFieldClientProps,\n SanitizedConfig,\n ServerFieldBase,\n StaticLabel,\n} from 'payload'\n\nimport type { BlockComponentContextType } from '../features/blocks/client/component/BlockContent.js'\nexport type { BlockComponentContextType }\nimport type { BlockComponentProps } from '../features/blocks/client/component/index.js'\nimport type { InlineBlockComponentContextType } from '../features/blocks/client/componentInline/index.js'\nimport type {\n JSXConverterArgs,\n JSXConverters,\n SerializedLexicalNodeWithParent,\n} from '../features/converters/lexicalToJSX/converter/types.js'\nimport type {\n BaseClientFeatureProps,\n FeatureProviderProviderClient,\n} from '../features/typesClient.js'\nimport type { FeatureProviderServer } from '../features/typesServer.js'\nimport type { SanitizedServerEditorConfig } from '../lexical/config/types.js'\nimport type { InitialLexicalFormState } from '../utilities/buildInitialState.js'\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from './nodeTypes.js'\n\n/**\n * Base constraint for serialized Lexical node types.\n * Used as the generic constraint for node map types.\n * Extends the base SerializedLexicalNode with optional type for flexibility.\n */\nexport type SerializedNodeBase = { type?: string }\n\nexport type LexicalFieldAdminProps = {\n /**\n * Controls if the add block button should be hidden. @default false\n */\n hideAddBlockButton?: boolean\n /**\n * Controls if the draggable block element should be hidden. @default false\n */\n hideDraggableBlockElement?: boolean\n /**\n * Controls if the gutter (padding to the left & gray vertical line) should be hidden. @default false\n */\n hideGutter?: boolean\n /**\n * Controls if the insert paragraph at the end button should be hidden. @default false\n */\n hideInsertParagraphAtEnd?: boolean\n /**\n * Changes the placeholder text in the editor if no content is present.\n */\n placeholder?: LabelFunction | StaticLabel\n}\n\nexport type LexicalFieldAdminClientProps = {\n placeholder?: string\n} & Omit<LexicalFieldAdminProps, 'placeholder'>\n\nexport type FeaturesInput =\n | (({\n defaultFeatures,\n rootFeatures,\n }: {\n /**\n * This opinionated array contains all \"recommended\" default features.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ defaultFeatures }) => [...defaultFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n defaultFeatures: FeatureProviderServer<any, any, any>[]\n /**\n * This array contains all features that are enabled in the root richText editor (the one defined in the payload.config.ts).\n * If this field is the root richText editor, or if the root richText editor is not a lexical editor, this array will be empty.\n *\n * @Example\n *\n * ```ts\n * editor: lexicalEditor({\n * features: ({ rootFeatures }) => [...rootFeatures, FixedToolbarFeature()],\n * })\n * ```\n */\n rootFeatures: FeatureProviderServer<any, any, any>[]\n }) => FeatureProviderServer<any, any, any>[])\n | FeatureProviderServer<any, any, any>[]\n\ntype WithinEditorArgs = {\n config: EditorConfig\n editor: LexicalEditor\n node: LexicalNode\n}\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapValue<TNode extends SerializedNodeBase = SerializedLexicalNode> = {\n /**\n * Provide a react component to render the node.\n *\n * **JSX Converter:** Always works. Takes priority over `html`.\n *\n * **Lexical Editor:** Only works for DecoratorNodes (renders in `decorate` method). Takes priority over `html` and `createDOM`.\n */\n Component?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n node: {\n _originalDecorate?: (editor: LexicalEditor, config: EditorConfig) => React.ReactNode\n } & DecoratorNode<React.ReactNode>\n } & Omit<WithinEditorArgs, 'node'>),\n ) => React.ReactNode\n /**\n * Provide a function to create the DOM element for the node.\n *\n * **JSX Converter:** Not used (only `Component` and `html` work).\n *\n * **Lexical Editor:** Always works (renders in `createDOM` method).\n * - For ElementNodes: This is the standard way to customize rendering.\n * - For DecoratorNodes: When combined with `html`, the DOM gets custom structure while `decorate` renders the `html` content.\n */\n createDOM?: (args: WithinEditorArgs) => HTMLElement\n /**\n * Provide HTML string or function to render the node.\n *\n * **JSX Converter:** Always works (ignored if `Component` is provided).\n *\n * **Lexical Editor behavior depends on node type:**\n *\n * - **ElementNodes:** `html` is used in `createDOM` to generate the DOM structure.\n *\n * - **DecoratorNodes (have both `createDOM` and `decorate`):**\n * - If only `html` is provided: `createDOM` uses `html` to create DOM, `decorate` returns `null`\n * - If `html` + `Component`: `createDOM` uses `html`, `decorate` uses `Component`\n * - If `html` + `createDOM`: Custom `createDOM` creates structure, `decorate` renders `html` content\n * - If `html` + `Component` + `createDOM`: Custom `createDOM` creates structure, `decorate` uses `Component` (html ignored in editor)\n */\n html?: (\n args:\n | ({\n isEditor: false\n isJSXConverter: true\n } & JSXConverterArgs<TNode>)\n | ({\n isEditor: true\n isJSXConverter: false\n } & WithinEditorArgs),\n ) => string\n}\n\ntype SharedViewMapBlockEditorProps<TNode extends SerializedBlockNode | SerializedInlineBlockNode> =\n {\n /**\n * True when rendering in the admin editor.\n */\n isEditor: true\n /**\n * False when rendering in the admin editor.\n */\n isJSXConverter: false\n } & Pick<BlockComponentProps<TNode['fields']>, 'className' | 'formData' | 'nodeKey'>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockEditorProps<TNode extends SerializedBlockNode> = {\n /**\n * Hook to access block UI components (BlockCollapsible, EditButton, etc.).\n * Call this inside your component to get the context values.\n * Passed as a prop so you don't need to import from @payloadcms/richtext-lexical/client.\n */\n useBlockComponentContext: () => BlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in editor mode.\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapInlineBlockEditorProps<TNode extends SerializedInlineBlockNode> = {\n useInlineBlockComponentContext: () => InlineBlockComponentContextType\n} & SharedViewMapBlockEditorProps<TNode>\n\n/**\n * Props passed to a custom Block component in JSX converter mode (frontend).\n * Use `isEditor` to discriminate between editor and JSX converter modes.\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockJSXConverterProps<\n TNode extends SerializedBlockNode | SerializedInlineBlockNode =\n | SerializedBlockNode\n | SerializedInlineBlockNode,\n> = {\n /**\n * Index of this node among its siblings.\n */\n childIndex: number\n /**\n * Available JSX converters for nested content.\n */\n converters: JSXConverters\n /**\n * The block's form data (field values).\n */\n formData: TNode['fields']\n /**\n * False when rendering via JSX converter (frontend).\n */\n isEditor: false\n /**\n * True when rendering via JSX converter (frontend).\n */\n isJSXConverter: true\n /**\n * The serialized block node.\n */\n node: TNode\n /**\n * Function to convert child nodes to JSX.\n */\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n /**\n * The parent node in the tree.\n */\n parent: SerializedLexicalNodeWithParent\n}\n\n/**\n * Props passed to a custom Block component in a view map.\n * This is a discriminated union - use `isEditor` to narrow the type.\n *\n * When `isEditor` is true, you're in the admin editor with access to `blockContext`.\n * When `isEditor` is false, you're in the frontend JSX converter with `nodesToJSX`.\n *\n * @example\n * ```tsx\n * const MyBlock: React.FC<ViewMapBlockComponentProps> = (props) => {\n * if (props.isEditor) {\n * // Admin editor - blockContext available\n * const { BlockCollapsible, EditButton } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * // Frontend - readonly render\n * return <div>{props.formData.title}</div>\n * }\n * ```\n *\n * @experimental - This API is experimental and may change in a minor release.\n */\nexport type ViewMapBlockComponentProps<TNode extends SerializedBlockNode = SerializedBlockNode> =\n | ViewMapBlockEditorProps<TNode>\n | ViewMapBlockJSXConverterProps<TNode>\n\nexport type ViewMapInlineBlockComponentProps<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = ViewMapBlockJSXConverterProps<TNode> | ViewMapInlineBlockEditorProps<TNode>\n\n/**\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type NodeMapBlockValue<TNode extends SerializedBlockNode = SerializedBlockNode> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * Block: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\nexport type NodeMapInlineBlockValue<\n TNode extends SerializedInlineBlockNode = SerializedInlineBlockNode,\n> = {\n /**\n * A React component that replaces the entire block, including the header/collapsible.\n * Works for both admin editor and frontend JSX conversion.\n *\n * Use `isEditor` to discriminate between modes:\n * - Editor mode: `blockContext` is available with UI components (BlockCollapsible, EditButton, etc.)\n * - JSX converter mode: `nodesToJSX` is available for rendering nested content\n *\n * @example\n * ```tsx\n * InlineBlock: (props) => {\n * if (props.isEditor) {\n * const { BlockCollapsible } = props.blockContext\n * return <BlockCollapsible>{props.formData.title}</BlockCollapsible>\n * }\n * return <div>{props.formData.title}</div>\n * }\n * ```\n */\n Block?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n /**\n * A React component that replaces the block label.\n * Use `useBlockComponentContext()` hook to access block context.\n */\n Label?: React.FC<ViewMapInlineBlockComponentProps<TNode>>\n} & Pick<NodeMapValue<TNode>, 'Component' | 'createDOM' | 'html'>\n\n/**\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type LexicalEditorNodeMap<\n TNodes extends SerializedNodeBase =\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 // The index signature must include NodeMapBlockValue in the nested blockSlug mapping because\n // 'blocks' and 'inlineBlocks' properties use NodeMapBlockValue (which adds Block/Label props).\n // TypeScript requires that intersection properties be assignable to index signatures.\n [key: string]:\n | {\n [blockSlug: string]: NodeMapBlockValue<any> | NodeMapInlineBlockValue<any>\n }\n | NodeMapValue<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: NodeMapValue<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in (Extract<TNodes, { type: 'block' }> &\n SerializedBlockNode)['fields']['blockType']]?: NodeMapBlockValue<\n Extract<\n Extract<TNodes, { type: 'block' }> & SerializedBlockNode,\n { fields: { blockType: K } }\n >\n >\n }\n inlineBlocks?: {\n [K in (Extract<TNodes, { type: 'inlineBlock' }> &\n SerializedInlineBlockNode)['fields']['blockType']]?: NodeMapInlineBlockValue<\n Extract<\n Extract<TNodes, { type: 'inlineBlock' }> & SerializedInlineBlockNode,\n { fields: { blockType: K } }\n >\n >\n }\n unknown?: NodeMapValue<SerializedLexicalNode>\n}\n\n/**\n * A map of views, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\nexport type ClientFeaturesMap = {\n [featureKey: string]: {\n clientFeatureProps?: BaseClientFeatureProps<Record<string, any>>\n clientFeatureProvider?: FeatureProviderProviderClient<any, any>\n }\n}\n\nexport type LexicalEditorViewMap<\n TNodes extends SerializedNodeBase =\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 [viewKey: string]: {\n admin?: LexicalFieldAdminClientProps\n /**\n * Transform the client features for this view.\n * Receives the full clientFeatures map and should return a (potentially modified) map.\n * Can be used to remove features or add new ones per-view.\n *\n * @example Remove toolbars\n * ```ts\n * filterFeatures: (features) => {\n * const { toolbarFixed, toolbarInline, ...rest } = features\n * return rest\n * }\n * ```\n */\n filterFeatures?: (clientFeatures: ClientFeaturesMap) => ClientFeaturesMap\n /**\n * Lexical editor configuration. Can be an object or a function that receives the default config.\n * Using a function avoids needing to import defaultEditorLexicalConfig.\n *\n * @example\n * ```ts\n * lexical: (defaultConfig) => ({\n * ...defaultConfig,\n * theme: { ...defaultConfig.theme, paragraph: 'my-paragraph' },\n * })\n * ```\n */\n lexical?: ((defaultConfig: LexicalEditorConfig) => LexicalEditorConfig) | LexicalEditorConfig\n nodes: LexicalEditorNodeMap<TNodes>\n }\n}\n\n/**\n * @todo rename to LexicalEditorArgs in 4.0, since these are arguments for the lexicalEditor function\n */\nexport type LexicalEditorProps = {\n admin?: LexicalFieldAdminProps\n features?: FeaturesInput\n lexical?: LexicalEditorConfig\n /**\n * A path to a LexicalEditorViewMap, which can be used to render the editor in different ways.\n *\n * In order to override the default view, you can add a `default` key to the map.\n *\n * @experimental - This API is experimental and may change in a minor release.\n * @internal\n */\n views?: PayloadComponent\n}\n\nexport type LexicalRichTextAdapter = {\n editorConfig: SanitizedServerEditorConfig\n features: FeatureProviderServer<any, any, any>[]\n} & RichTextAdapter<SerializedEditorState, AdapterProps>\n\nexport type LexicalRichTextAdapterProvider =\n /**\n * This is being called during the payload sanitization process\n */\n ({\n config,\n isRoot,\n parentIsLocalized,\n }: {\n config: SanitizedConfig\n isRoot?: boolean\n parentIsLocalized: boolean\n }) => Promise<LexicalRichTextAdapter>\n\nexport type SingleFeatureClientSchemaMap = {\n [key: string]: ClientField[]\n}\nexport type FeatureClientSchemaMap = {\n [featureKey: string]: SingleFeatureClientSchemaMap\n}\n\nexport type LexicalRichTextFieldProps = {\n admin?: LexicalFieldAdminClientProps\n // clientFeatures is added through the rsc field\n clientFeatures: ClientFeaturesMap\n /**\n * Part of the import map that contains client components for all lexical features of this field that\n * have been added through `feature.componentImports`.\n */\n featureClientImportMap?: Record<string, any>\n featureClientSchemaMap: FeatureClientSchemaMap\n initialLexicalFormState?: InitialLexicalFormState\n lexicalEditorConfig?: LexicalEditorConfig // Undefined if default lexical editor config should be used\n views?: LexicalEditorViewMap\n} & Pick<ServerFieldBase, 'permissions'> &\n RichTextFieldClientProps<SerializedEditorState, AdapterProps, object>\n\nexport type LexicalRichTextCellProps = DefaultServerCellComponentProps<\n RichTextFieldClient<SerializedEditorState, AdapterProps, object>,\n SerializedEditorState\n>\n\nexport type AdapterProps = {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport type GeneratedFeatureProviderComponent = {\n clientFeature: FeatureProviderProviderClient<any, any>\n clientFeatureProps: BaseClientFeatureProps<object>\n}\n\nexport type LexicalRichTextField = RichTextField<SerializedEditorState, AdapterProps>\n"],"mappings":"AAyhBA","ignoreList":[]}
@@ -3,6 +3,8 @@ import type { JSONSchema4 } from 'json-schema';
3
3
  export declare const formatSchema: JSONSchema4;
4
4
  /** `direction` property shared by every element node. */
5
5
  export declare const directionSchema: JSONSchema4;
6
+ /** `version` property shared by every Lexical node. */
7
+ export declare const versionSchema: JSONSchema4;
6
8
  type ElementNodeSchemaOptions = {
7
9
  nodeType: string;
8
10
  properties?: {
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSchemaHelpers.d.ts","sourceRoot":"","sources":["../../src/types/jsonSchemaHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,oFAAoF;AACpF,eAAO,MAAM,YAAY,EAAE,WAI1B,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,eAAe,EAAE,WAG7B,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,2DAM/B;IAAE,YAAY,EAAE,WAAW,CAAA;CAAE,GAAG,wBAAwB,KAAG,WAc5D,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,WAAW,CAAA"}
1
+ {"version":3,"file":"jsonSchemaHelpers.d.ts","sourceRoot":"","sources":["../../src/types/jsonSchemaHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,oFAAoF;AACpF,eAAO,MAAM,YAAY,EAAE,WAK1B,CAAA;AAED,yDAAyD;AACzD,eAAO,MAAM,eAAe,EAAE,WAG7B,CAAA;AAED,uDAAuD;AACvD,eAAO,MAAM,aAAa,EAAE,WAG3B,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAA;IACzC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,2DAM/B;IAAE,YAAY,EAAE,WAAW,CAAA;CAAE,GAAG,wBAAwB,KAAG,WAc5D,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,WAAW,CAAA"}
@@ -1,5 +1,6 @@
1
1
  /** `format` property shared by every element node (Lexical `ElementFormatType`). */export const formatSchema = {
2
2
  type: 'string',
3
+ description: 'How this element is aligned. Empty string means no explicit alignment.',
3
4
  enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''],
4
5
  tsType: 'LexicalElementFormat'
5
6
  };
@@ -13,6 +14,11 @@ export const directionSchema = {
13
14
  }],
14
15
  tsType: 'LexicalElementDirection'
15
16
  };
17
+ /** `version` property shared by every Lexical node. */
18
+ export const versionSchema = {
19
+ type: 'integer',
20
+ description: "Lexical's internal serialization version for this node type."
21
+ };
16
22
  /**
17
23
  * Builds the JSON Schema for a Lexical element node - merges the shared
18
24
  * element-base shape (children/direction/format/indent/version) with the
@@ -41,9 +47,7 @@ export const elementNodeSchema = ({
41
47
  indent: {
42
48
  type: 'integer'
43
49
  },
44
- version: {
45
- type: 'integer'
46
- },
50
+ version: versionSchema,
47
51
  ...properties
48
52
  },
49
53
  required: ['children', 'direction', 'format', 'indent', 'type', 'version', ...required],
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSchemaHelpers.js","names":["formatSchema","type","enum","tsType","directionSchema","oneOf","elementNodeSchema","nodeType","nodeUnionRef","properties","required","additionalProperties","const","children","items","direction","format","indent","version"],"sources":["../../src/types/jsonSchemaHelpers.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/** `format` property shared by every element node (Lexical `ElementFormatType`). */\nexport const formatSchema: JSONSchema4 = {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''],\n tsType: 'LexicalElementFormat',\n}\n\n/** `direction` property shared by every element node. */\nexport const directionSchema: JSONSchema4 = {\n oneOf: [{ type: 'string', enum: ['ltr', 'rtl'] }, { type: 'null' }],\n tsType: 'LexicalElementDirection',\n}\n\ntype ElementNodeSchemaOptions = {\n nodeType: string\n properties?: { [k: string]: JSONSchema4 }\n required?: string[]\n /** TS helper-type expression — emitted verbatim by json-schema-to-typescript. */\n tsType?: string\n}\n\n/**\n * Builds the JSON Schema for a Lexical element node - merges the shared\n * element-base shape (children/direction/format/indent/version) with the\n * node-specific bits a feature provides.\n */\nexport const elementNodeSchema = ({\n nodeType,\n nodeUnionRef,\n properties = {},\n required = [],\n tsType,\n}: { nodeUnionRef: JSONSchema4 } & ElementNodeSchemaOptions): JSONSchema4 => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', const: nodeType },\n children: { type: 'array', items: nodeUnionRef },\n direction: directionSchema,\n format: formatSchema,\n indent: { type: 'integer' },\n version: { type: 'integer' },\n ...properties,\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version', ...required],\n ...(tsType ? { tsType } : {}),\n})\n\n/**\n * `elementNodeSchema` HOC type, so that features don't have to pass `nodeUnionRef` every time.\n */\nexport type ElementNodeSchemaFn = (opts: ElementNodeSchemaOptions) => JSONSchema4\n"],"mappings":"AAEA,oFACA,OAAO,MAAMA,YAAA,GAA4B;EACvCC,IAAA,EAAM;EACNC,IAAA,EAAM,CAAC,QAAQ,SAAS,UAAU,SAAS,OAAO,WAAW,GAAG;EAChEC,MAAA,EAAQ;AACV;AAEA;AACA,OAAO,MAAMC,eAAA,GAA+B;EAC1CC,KAAA,EAAO,CAAC;IAAEJ,IAAA,EAAM;IAAUC,IAAA,EAAM,CAAC,OAAO;EAAO,GAAG;IAAED,IAAA,EAAM;EAAO,EAAE;EACnEE,MAAA,EAAQ;AACV;AAUA;;;;;AAKA,OAAO,MAAMG,iBAAA,GAAoBA,CAAC;EAChCC,QAAQ;EACRC,YAAY;EACZC,UAAA,GAAa,CAAC,CAAC;EACfC,QAAA,GAAW,EAAE;EACbP;AAAM,CACmD,MAAmB;EAC5EF,IAAA,EAAM;EACNU,oBAAA,EAAsB;EACtBF,UAAA,EAAY;IACVR,IAAA,EAAM;MAAEA,IAAA,EAAM;MAAUW,KAAA,EAAOL;IAAS;IACxCM,QAAA,EAAU;MAAEZ,IAAA,EAAM;MAASa,KAAA,EAAON;IAAa;IAC/CO,SAAA,EAAWX,eAAA;IACXY,MAAA,EAAQhB,YAAA;IACRiB,MAAA,EAAQ;MAAEhB,IAAA,EAAM;IAAU;IAC1BiB,OAAA,EAAS;MAAEjB,IAAA,EAAM;IAAU;IAC3B,GAAGQ;EACL;EACAC,QAAA,EAAU,CAAC,YAAY,aAAa,UAAU,UAAU,QAAQ,W,GAAcA,QAAA,CAAS;EACvF,IAAIP,MAAA,GAAS;IAAEA;EAAO,IAAI,CAAC,CAAC;AAC9B","ignoreList":[]}
1
+ {"version":3,"file":"jsonSchemaHelpers.js","names":["formatSchema","type","description","enum","tsType","directionSchema","oneOf","versionSchema","elementNodeSchema","nodeType","nodeUnionRef","properties","required","additionalProperties","const","children","items","direction","format","indent","version"],"sources":["../../src/types/jsonSchemaHelpers.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\n\n/** `format` property shared by every element node (Lexical `ElementFormatType`). */\nexport const formatSchema: JSONSchema4 = {\n type: 'string',\n description: 'How this element is aligned. Empty string means no explicit alignment.',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''],\n tsType: 'LexicalElementFormat',\n}\n\n/** `direction` property shared by every element node. */\nexport const directionSchema: JSONSchema4 = {\n oneOf: [{ type: 'string', enum: ['ltr', 'rtl'] }, { type: 'null' }],\n tsType: 'LexicalElementDirection',\n}\n\n/** `version` property shared by every Lexical node. */\nexport const versionSchema: JSONSchema4 = {\n type: 'integer',\n description: \"Lexical's internal serialization version for this node type.\",\n}\n\ntype ElementNodeSchemaOptions = {\n nodeType: string\n properties?: { [k: string]: JSONSchema4 }\n required?: string[]\n /** TS helper-type expression — emitted verbatim by json-schema-to-typescript. */\n tsType?: string\n}\n\n/**\n * Builds the JSON Schema for a Lexical element node - merges the shared\n * element-base shape (children/direction/format/indent/version) with the\n * node-specific bits a feature provides.\n */\nexport const elementNodeSchema = ({\n nodeType,\n nodeUnionRef,\n properties = {},\n required = [],\n tsType,\n}: { nodeUnionRef: JSONSchema4 } & ElementNodeSchemaOptions): JSONSchema4 => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n type: { type: 'string', const: nodeType },\n children: { type: 'array', items: nodeUnionRef },\n direction: directionSchema,\n format: formatSchema,\n indent: { type: 'integer' },\n version: versionSchema,\n ...properties,\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version', ...required],\n ...(tsType ? { tsType } : {}),\n})\n\n/**\n * `elementNodeSchema` HOC type, so that features don't have to pass `nodeUnionRef` every time.\n */\nexport type ElementNodeSchemaFn = (opts: ElementNodeSchemaOptions) => JSONSchema4\n"],"mappings":"AAEA,oFACA,OAAO,MAAMA,YAAA,GAA4B;EACvCC,IAAA,EAAM;EACNC,WAAA,EAAa;EACbC,IAAA,EAAM,CAAC,QAAQ,SAAS,UAAU,SAAS,OAAO,WAAW,GAAG;EAChEC,MAAA,EAAQ;AACV;AAEA;AACA,OAAO,MAAMC,eAAA,GAA+B;EAC1CC,KAAA,EAAO,CAAC;IAAEL,IAAA,EAAM;IAAUE,IAAA,EAAM,CAAC,OAAO;EAAO,GAAG;IAAEF,IAAA,EAAM;EAAO,EAAE;EACnEG,MAAA,EAAQ;AACV;AAEA;AACA,OAAO,MAAMG,aAAA,GAA6B;EACxCN,IAAA,EAAM;EACNC,WAAA,EAAa;AACf;AAUA;;;;;AAKA,OAAO,MAAMM,iBAAA,GAAoBA,CAAC;EAChCC,QAAQ;EACRC,YAAY;EACZC,UAAA,GAAa,CAAC,CAAC;EACfC,QAAA,GAAW,EAAE;EACbR;AAAM,CACmD,MAAmB;EAC5EH,IAAA,EAAM;EACNY,oBAAA,EAAsB;EACtBF,UAAA,EAAY;IACVV,IAAA,EAAM;MAAEA,IAAA,EAAM;MAAUa,KAAA,EAAOL;IAAS;IACxCM,QAAA,EAAU;MAAEd,IAAA,EAAM;MAASe,KAAA,EAAON;IAAa;IAC/CO,SAAA,EAAWZ,eAAA;IACXa,MAAA,EAAQlB,YAAA;IACRmB,MAAA,EAAQ;MAAElB,IAAA,EAAM;IAAU;IAC1BmB,OAAA,EAASb,aAAA;IACT,GAAGI;EACL;EACAC,QAAA,EAAU,CAAC,YAAY,aAAa,UAAU,UAAU,QAAQ,W,GAAcA,QAAA,CAAS;EACvF,IAAIR,MAAA,GAAS;IAAEA;EAAO,IAAI,CAAC,CAAC;AAC9B","ignoreList":[]}
@@ -62,25 +62,67 @@ export interface LexicalRichText<TNode> {
62
62
  export type { SerializedAutoLinkNode, SerializedBlockNode, SerializedHeadingNode, SerializedHorizontalRuleNode, SerializedInlineBlockNode, SerializedLinkNode, SerializedListItemNode, SerializedListNode, SerializedQuoteNode, SerializedRelationshipNode, SerializedTableCellNode, SerializedTableNode, SerializedTableRowNode, SerializedUploadNode, };
63
63
  /** `SerializedEditorState` with nodes narrowed by `type`. No type-casting needed. */
64
64
  export type TypedEditorState<TNode extends SerializedLexicalNode = SerializedLexicalNode> = LexicalRichText<TNode>;
65
+ /**
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}.
70
+ */
71
+ export type RichTextNodes<TRichText> = NonNullable<TRichText> extends LexicalRichText<infer TNode> ? TNode : never;
65
72
  /**
66
73
  * All node types included by default in a lexical editor. Self-recursive —
67
74
  * each element node's `children` is `DefaultNodeTypes` again, no depth limit.
68
- * To compose your own union including the defaults, see {@link DefaultNodeTypesOf}.
75
+ * To compose your own union including the defaults, see {@link WithDefaultNodes}.
69
76
  */
70
77
  export type DefaultNodeTypes = SerializedAutoLinkNode<DefaultNodeTypes> | SerializedHeadingNode<DefaultNodeTypes> | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode<DefaultNodeTypes> | SerializedListItemNode<DefaultNodeTypes> | SerializedListNode<DefaultNodeTypes> | SerializedParagraphNode<DefaultNodeTypes> | SerializedQuoteNode<DefaultNodeTypes> | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
71
78
  /**
72
- * Default node types, parameterised by the union to use for element children.
73
- * Use to mix custom nodes with the defaults:
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:
74
81
  *
75
82
  * ```ts
76
- * type MyNodes = DefaultNodeTypesOf<MyNodes> | SerializedBlockNode<MyNodes>
83
+ * type MyNodes = WithDefaultNodes<SerializedBlockNode<MyBlockData>>
77
84
  * ```
85
+ *
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.
78
88
  */
79
- export type DefaultNodeTypesOf<TNodes extends SerializedLexicalNode> = SerializedAutoLinkNode<TNodes> | SerializedHeadingNode<TNodes> | SerializedHorizontalRuleNode | SerializedLineBreakNode | SerializedLinkNode<TNodes> | SerializedListItemNode<TNodes> | SerializedListNode<TNodes> | SerializedParagraphNode<TNodes> | SerializedQuoteNode<TNodes> | SerializedRelationshipNode | SerializedTabNode | SerializedTextNode | SerializedUploadNode;
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'>;
94
+ /**
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.
105
+ */
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
+ }
80
122
  /**
81
- * Like `TypedEditorState` but includes all default node types. Pass extra
82
- * node types as a generic to union them at the top level; for nodes that
83
- * should also nest inside default containers, use {@link DefaultNodeTypesOf}.
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.
84
126
  */
85
- export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = [TAdditionalNodeTypes] extends null ? TypedEditorState<DefaultNodeTypes> : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>;
127
+ export type DefaultTypedEditorState<TAdditionalNodeTypes extends null | SerializedLexicalNode = null> = TypedEditorState<WithDefaultNodes<NonNullable<TAdditionalNodeTypes>>>;
86
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,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC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AAA;IACrF,cAAc,EAAE,4BAA4B,CAAA;IAC5C,SAAS,EAAE,uBAAuB,CAAA;IAClC,IAAI,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC,CAAA;IAC/E,IAAI,EAAE,qBAAqB,CAAC,kBAAkB,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"}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Like `TypedEditorState` but includes all default node types. Pass extra
3
- * node types as a generic to union them at the top level; for nodes that
4
- * should also nest inside default containers, use {@link DefaultNodeTypesOf}.
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.
5
5
  */export {};
6
6
  //# sourceMappingURL=nodeTypes.js.map
@@ -1 +1 @@
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 * 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 DefaultNodeTypesOf}.\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 * Default node types, parameterised by the union to use for element children.\n * Use to mix custom nodes with the defaults:\n *\n * ```ts\n * type MyNodes = DefaultNodeTypesOf<MyNodes> | SerializedBlockNode<MyNodes>\n * ```\n */\nexport type DefaultNodeTypesOf<TNodes extends SerializedLexicalNode> =\n | SerializedAutoLinkNode<TNodes>\n | SerializedHeadingNode<TNodes>\n | SerializedHorizontalRuleNode\n | SerializedLineBreakNode\n | SerializedLinkNode<TNodes>\n | SerializedListItemNode<TNodes>\n | SerializedListNode<TNodes>\n | SerializedParagraphNode<TNodes>\n | SerializedQuoteNode<TNodes>\n | SerializedRelationshipNode\n | SerializedTabNode\n | SerializedTextNode\n | SerializedUploadNode\n\n/**\n * Like `TypedEditorState` but includes all default node types. Pass extra\n * node types as a generic to union them at the top level; for nodes that\n * should also nest inside default containers, use {@link DefaultNodeTypesOf}.\n */\nexport type DefaultTypedEditorState<\n TAdditionalNodeTypes extends null | SerializedLexicalNode = null,\n> = [TAdditionalNodeTypes] extends null\n ? TypedEditorState<DefaultNodeTypes>\n : TypedEditorState<DefaultNodeTypes | NonNullable<TAdditionalNodeTypes>>\n"],"mappings":"AAqJA;;;;GAKA","ignoreList":[]}
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":"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,CAyExC,CAAA"}
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"}
@@ -29,7 +29,7 @@ export const getFieldToJSONSchema = ({
29
29
  elementNodeSchema: args => elementNodeSchema({
30
30
  ...args,
31
31
  nodeUnionRef: {
32
- $ref: `#/definitions/${NODE_UNION_NAME_PLACEHOLDER}`
32
+ $ref: `#/$defs/${NODE_UNION_NAME_PLACEHOLDER}`
33
33
  }
34
34
  }),
35
35
  field,
@@ -51,7 +51,17 @@ export const getFieldToJSONSchema = ({
51
51
  const nodeUnionJson = JSON.stringify({
52
52
  oneOf: nodeSchemas
53
53
  });
54
- const hash = createHash('sha256').update(nodeUnionJson).digest('hex').slice(0, 8).toUpperCase();
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();
55
65
  const nodeUnionName = `LexicalNodes_${hash}`;
56
66
  // Replacing the hash resolves the union name and any feature-derived
57
67
  // sibling names in one pass.
@@ -1 +1 @@
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","hash","update","digest","slice","toUpperCase","replacePlaceholder","schemaString","parse","replaceAll","oldKey","schema","entries","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: `#/definitions/${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 const hash = createHash('sha256').update(nodeUnionJson).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,CACtB;IACC;IAEAA,qBAAA,CAAsBC,GAAG,CAACjB,wBAAA;IAE1B,MAAMkB,kBAAA,GAAqC;MACzCP,sBAAA;MACAC,MAAA;MACA;MACAN,iBAAA,EAAoBa,IAAA,IAClBb,iBAAA,CAAkB;QAChB,GAAGa,IAAI;QACPC,YAAA,EAAc;UACZC,IAAA,EAAM,iBAAiBb,2BAAA;QACzB;MACF;MACFK,KAAA;MACAC,IAAA;MACAC,wBAAA;MACAO,aAAA,EAAed,2BAAA;MACfQ;IACF;IAEA,MAAMO,WAAA,GAA6B;IACjC;IACAlB,kBAAA,CAAmBa,kBAAA,GACnBd,iBAAA,CAAkBc,kBAAA,GAClBjB,uBAAA,CAAwBiB,kBAAA,GACxBhB,uBAAA,CAAwBgB,kBAAA;IACxB;OACGR,YAAA,CAAac,QAAQ,CAACC,KAAK,CAC3BC,MAAM,CAAEC,IAAA,IAASA,IAAA,CAAKC,UAAU,EAChCC,GAAG,CAAEF,IAAA,IAASA,IAAA,CAAKC,UAAU,CAAEV,kBAAA,GACnC;IACD,MAAMY,yBAAA,GAA4B3B,kBAAA,CAAmBe,kBAAA;IAErD;IACA;IACA;IACA;IACA,MAAMa,aAAA,GAAgBC,IAAA,CAAKC,SAAS,CAAC;MAAEC,KAAA,EAAOX;IAAY;IAE1D,MAAMY,IAAA,GAAOpC,UAAA,CAAW,UAAUqC,MAAM,CAACL,aAAA,EAAeM,MAAM,CAAC,OAAOC,KAAK,CAAC,GAAG,GAAGC,WAAW;IAC7F,MAAMjB,aAAA,GAAgB,gBAAgBa,IAAA,EAAM;IAE5C;IACA;IACA,MAAMK,kBAAA,GAAsBC,YAAA,IAC1BT,IAAA,CAAKU,KAAK,CAACD,YAAA,CAAaE,UAAU,CAACpC,2BAAA,EAA6B4B,IAAA;IAElE;IACA;IACA,KAAK,MAAM,CAACS,MAAA,EAAQC,MAAA,CAAO,IAAI,C,GAAI9B,wBAAA,CAAyB+B,OAAO,GAAG,EAAE;MACtE,MAAMC,MAAA,GAASH,MAAA,CAAOD,UAAU,CAACpC,2BAAA,EAA6B4B,IAAA;MAC9D,MAAMa,cAAA,GAAiBR,kBAAA,CAAmBR,IAAA,CAAKC,SAAS,CAACY,MAAA;MACzD,IAAIE,MAAA,KAAWH,MAAA,EAAQ;QACrB7B,wBAAA,CAAyBkC,MAAM,CAACL,MAAA;MAClC;MACA7B,wBAAA,CAAyBmC,GAAG,CAACH,MAAA,EAAQC,cAAA;IACvC;IAEAjC,wBAAA,CAAyBmC,GAAG,CAAC5B,aAAA,EAAekB,kBAAA,CAAmBT,aAAA;IAE/D,OAAOS,kBAAA,CAAmBR,IAAA,CAAKC,SAAS,CAACH,yBAAA;EAC3C;AACF","ignoreList":[]}
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,CACtB;IACC;IAEAA,qBAAA,CAAsBC,GAAG,CAACjB,wBAAA;IAE1B,MAAMkB,kBAAA,GAAqC;MACzCP,sBAAA;MACAC,MAAA;MACA;MACAN,iBAAA,EAAoBa,IAAA,IAClBb,iBAAA,CAAkB;QAChB,GAAGa,IAAI;QACPC,YAAA,EAAc;UACZC,IAAA,EAAM,WAAWb,2BAAA;QACnB;MACF;MACFK,KAAA;MACAC,IAAA;MACAC,wBAAA;MACAO,aAAA,EAAed,2BAAA;MACfQ;IACF;I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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 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIvE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAiGzF"}
1
+ {"version":3,"file":"applyBaseFilterToFields.d.ts","sourceRoot":"","sources":["../../src/utilities/applyBaseFilterToFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAa,MAAM,SAAS,CAAA;AAIhE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,eAAe,GAAG,KAAK,EAAE,CAgGzF"}
@@ -77,10 +77,9 @@ export function applyBaseFilterToFields(fields, config) {
77
77
  }
78
78
  // Handle blocks
79
79
  if (field.type === 'blocks') {
80
- const blocks = field.blockReferences ?? field.blocks ?? [];
81
80
  return {
82
81
  ...field,
83
- blocks: blocks.map(block => {
82
+ blocks: field.blocks.map(block => {
84
83
  if (typeof block === 'string') {
85
84
  return block;
86
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","blockReferences","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Block, Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n const blocks = (field.blockReferences ?? field.blocks ?? []) as Block[]\n return {\n ...field,\n blocks: blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,IAAA,IAC3BF,qBAAA,IAAyB;QAEhC;QACA,IAAIM,cAAA,KAAmB,OAAO;UAC5B,OAAO;QACT;QAEA;QACA,MAAMC,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MwB,eAAe,IAAIxB,KAAA,CAAMuB,MAAM,IAAI,EAAE;MAC3D,OAAO;QACL,GAAGvB,KAAK;QACRuB,MAAA,EAAQA,MAAA,CAAOxB,GAAG,CAAE0B,KAAA;UAClB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR5B,MAAA,EAAQD,uBAAA,CAAwB6B,KAAA,CAAM5B,MAAM,EAAEC,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;AACF","ignoreList":[]}
1
+ {"version":3,"file":"applyBaseFilterToFields.js","names":["combineWhereConstraints","applyBaseFilterToFields","fields","config","map","field","type","relationshipField","originalFilterOptions","filterOptions","args","relationTo","req","user","originalResult","admin","collections","find","slug","hidden","baseFilter","baseListFilter","baseFilterResult","limit","page","sort","tabs","tab","blocks","block"],"sources":["../../src/utilities/applyBaseFilterToFields.ts"],"sourcesContent":["import type { Field, SanitizedConfig, TypedUser } from 'payload'\n\nimport { combineWhereConstraints } from 'payload/shared'\n\n/**\n * Recursively applies baseFilter from collection config to relationship fields\n * within blocks. This ensures that relationship drawers in blocks respect\n * collection-level filters like multi-tenant filtering.\n *\n * Based on the fix from PR #13229 for LinkFeature\n */\nexport function applyBaseFilterToFields(fields: Field[], config: SanitizedConfig): Field[] {\n return fields.map((field) => {\n // Handle relationship fields\n if (field.type === 'relationship') {\n const relationshipField = field\n\n // Store the original filterOptions\n const originalFilterOptions = relationshipField.filterOptions\n\n // Create new filterOptions that includes baseFilter\n relationshipField.filterOptions = async (args) => {\n const { relationTo, req, user } = args\n\n // Call original filterOptions if it exists\n const originalResult =\n typeof originalFilterOptions === 'function'\n ? await originalFilterOptions(args)\n : (originalFilterOptions ?? true)\n\n // If original filter returns false, respect that\n if (originalResult === false) {\n return false\n }\n\n // Get the collection's admin config\n const admin = config.collections.find(({ slug }) => slug === relationTo)?.admin\n\n // Check if collection is hidden\n const hidden = admin?.hidden\n if (typeof hidden === 'function' && hidden({ user } as { user: TypedUser })) {\n return false\n }\n\n // Apply baseFilter (with backwards compatibility for baseListFilter)\n const baseFilter = admin?.baseFilter ?? admin?.baseListFilter\n const baseFilterResult = await baseFilter?.({\n limit: 0,\n page: 1,\n req,\n sort: 'id',\n })\n\n // If no baseFilter, return original result\n if (!baseFilterResult) {\n return originalResult\n }\n\n // If original result is true, just return the baseFilter\n if (originalResult === true) {\n return baseFilterResult\n }\n\n // Combine original and baseFilter results\n return combineWhereConstraints([originalResult, baseFilterResult], 'and')\n }\n\n return relationshipField\n }\n\n // Recursively process nested fields\n if ('fields' in field && field.fields) {\n return {\n ...field,\n fields: applyBaseFilterToFields(field.fields, config),\n }\n }\n\n // Handle tabs\n if (field.type === 'tabs' && 'tabs' in field) {\n return {\n ...field,\n tabs: field.tabs.map((tab) => ({\n ...tab,\n fields: applyBaseFilterToFields(tab.fields, config),\n })),\n }\n }\n\n // Handle blocks\n if (field.type === 'blocks') {\n return {\n ...field,\n blocks: field.blocks.map((block) => {\n if (typeof block === 'string') {\n return block\n }\n return {\n ...block,\n fields: applyBaseFilterToFields(block.fields, config),\n }\n }),\n }\n }\n\n return field\n })\n}\n"],"mappings":"AAEA,SAASA,uBAAuB,QAAQ;AAExC;;;;;;;AAOA,OAAO,SAASC,wBAAwBC,MAAe,EAAEC,MAAuB;EAC9E,OAAOD,MAAA,CAAOE,GAAG,CAAEC,KAAA;IACjB;IACA,IAAIA,KAAA,CAAMC,IAAI,KAAK,gBAAgB;MACjC,MAAMC,iBAAA,GAAoBF,KAAA;MAE1B;MACA,MAAMG,qBAAA,GAAwBD,iBAAA,CAAkBE,aAAa;MAE7D;MACAF,iBAAA,CAAkBE,aAAa,GAAG,MAAOC,IAAA;QACvC,MAAM;UAAEC,UAAU;UAAEC,GAAG;UAAEC;QAAI,CAAE,GAAGH,IAAA;QAElC;QACA,MAAMI,cAAA,GACJ,OAAON,qBAAA,KAA0B,aAC7B,MAAMA,qBAAA,CAAsBE,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C9C;MACF;IACF;IAEA;IACA,IAAIE,KAAA,CAAMC,IAAI,KAAK,UAAU;MAC3B,OAAO;QACL,GAAGD,KAAK;QACRuB,MAAA,EAAQvB,KAAA,CAAMuB,MAAM,CAACxB,GAAG,CAAEyB,KAAA;UACxB,IAAI,OAAOA,KAAA,KAAU,UAAU;YAC7B,OAAOA,KAAA;UACT;UACA,OAAO;YACL,GAAGA,KAAK;YACR3B,MAAA,EAAQD,uBAAA,CAAwB4B,KAAA,CAAM3B,MAAM,EAAEC,MAAA;UAChD;QACF;MACF;IACF;IAEA,OAAOE,KAAA;EACT;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>['root']['children'];
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,qBAAqB,EAAE,EAChE,KAAK,EACL,IAAI,GACL,EAAE;IACD,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAuDtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,gBAAgB,CAAC,gBAAgB,CAC1C,CAAA"}
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<T extends SerializedLexicalNode>({\n nodes,\n text,\n}: {\n nodes?: TypedEditorState<T>['root']['children']\n text?: string\n}): TypedEditorState<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<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 buildDefaultEdit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+ {"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
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4D1C"}
1
+ {"version":3,"file":"buildInitialState.d.ts","sourceRoot":"","sources":["../../src/utilities/buildInitialState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,SAAS,EACT,SAAS,EACT,cAAc,EACd,aAAa,EACb,yBAAyB,EAC1B,MAAM,SAAS,CAAA;AAMhB,MAAM,MAAM,uBAAuB,GAAG;IACpC,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;QAClB,SAAS,CAAC,EAAE,SAAS,CAAA;KACtB,CAAA;CACF,CAAA;AAED,KAAK,KAAK,GAAG;IACX,OAAO,EAAE;QACP,oBAAoB,EAAE,oBAAoB,CAAA;QAC1C,cAAc,EAAE,MAAM,CAAA;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,YAAY,CAAC,EAAE,GAAG,CAAA;QAClB,KAAK,EAAE,aAAa,CAAA;QACpB,cAAc,EAAE,cAAc,CAAA;QAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;QACpB,sBAAsB,EAAE,MAAM,CAAA;QAC9B,SAAS,EAAE,SAAS,CAAA;QACpB,WAAW,CAAC,EAAE,yBAAyB,CAAA;QACvC,WAAW,EAAE,mBAAmB,CAAA;QAChC,eAAe,EAAE,iBAAiB,CAAA;QAClC,aAAa,EAAE,GAAG,CAAA;QAClB,GAAG,EAAE,cAAc,CAAA;KACpB,CAAA;IACD,YAAY,CAAC,EAAE,uBAAuB,CAAA;IACtC,QAAQ,EAAE,qBAAqB,EAAE,CAAA;CAClC,CAAA;AAED,wBAAsB,iBAAiB,CAAC,EACtC,OAAO,EACP,YAAY,EAAE,oBAAoB,EAClC,QAAQ,GACT,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA4D1C"}