Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/migration-guide/v4.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,36 @@ The deprecated `HTMLConverterFeature`, `lexicalHTML`, and the per-node `converte

Custom nodes that define `converters.html` should export their converters instead.

### RichText adapter `outputSchema` renamed to `jsonSchema`

The optional `outputSchema` function on rich-text editor adapters (`RichTextAdapter`) has been renamed to `jsonSchema` — it returns JSON Schema, not TypeScript, so the old name was misleading. Same arguments, same `JSONSchema4` return value.

```diff
myAdapter: RichTextAdapter = {
- outputSchema: ({ collectionIDFieldTypes, config, field, i18n, interfaceNameDefinitions, isRequired }) => {
+ jsonSchema: ({ collectionIDFieldTypes, config, field, i18n, interfaceNameDefinitions, isRequired }) => {
// return JSONSchema4
},
}
```

`@payloadcms/richtext-lexical` is updated. Only custom third-party adapters need attention.

### Lexical: feature `generatedTypes.modifyOutputSchema` renamed to `modifyJSONSchema`

If you authored a custom lexical feature that hooks into type generation, rename `generatedTypes.modifyOutputSchema` to `modifyJSONSchema` (and its sanitized counterpart `modifyOutputSchemas` to `modifyJSONSchemas`) — it operates on JSON Schema, matching the adapter rename above.

```diff
createServerFeature({
feature: () => ({
generatedTypes: {
- modifyOutputSchema: ({ currentSchema, interfaceNameDefinitions }) => currentSchema,
+ modifyJSONSchema: ({ currentSchema, interfaceNameDefinitions }) => currentSchema,
},
}),
})
```

### Field `typescriptSchema` renamed to `jsonSchema`

`typescriptSchema` accepted JSON Schema, not TypeScript, so the name lied. Renamed to `jsonSchema`. Same shape, same array of `({ jsonSchema }) => JSONSchema4` transforms.
Expand Down
2 changes: 1 addition & 1 deletion packages/payload/src/admin/RichText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ type RichTextAdapterBase<
* `json-schema-to-typescript` which is used to generate types for this richtext field
* payload-types.ts)
*/
outputSchema?: (args: {
jsonSchema?: (args: {
collectionIDFieldTypes: { [key: string]: 'number' | 'string' }
config?: SanitizedConfig
field: RichTextField<Value, AdapterProps, ExtraFieldProperties>
Expand Down
4 changes: 2 additions & 2 deletions packages/payload/src/utilities/configToJSONSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ export function fieldsToJSONSchema(
if (typeof field.editor === 'function') {
throw new Error('Attempted to access unsanitized rich text editor.')
}
if (field.editor.outputSchema) {
if (field.editor.jsonSchema) {
fieldSchema = {
...baseFieldSchema,
...field.editor.outputSchema({
...field.editor.jsonSchema({
collectionIDFieldTypes,
config,
field,
Expand Down
2 changes: 1 addition & 1 deletion packages/richtext-lexical/src/cell/rscEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Link } from '@payloadcms/ui'
import { formatAdminURL } from 'payload/shared'
import React from 'react'

import type { LexicalRichTextCellProps } from '../types.js'
import type { LexicalRichTextCellProps } from '../types/index.js'

function recurseEditorState(
editorState: SerializedLexicalNode[],
Expand Down
2 changes: 1 addition & 1 deletion packages/richtext-lexical/src/exports/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export type {
ViewMapBlockComponentProps,
ViewMapBlockEditorProps,
ViewMapBlockJSXConverterProps,
} from '../../types.js'
} from '../../types/index.js'
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SerializedLexicalNode } from 'lexical'

import { QuoteNode } from '@lexical/rich-text'

import type { StronglyTypedElementNode } from '../../../nodeTypes.js'
import type { StronglyTypedElementNode } from '../../../types/nodeTypes.js'

import { createServerFeature } from '../../../utilities/createServerFeature.js'
import { createNode } from '../../typeUtilities.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from
import React, { useCallback, useEffect, useMemo, useRef } from 'react'
import { v4 as uuid } from 'uuid'

import type { ViewMapBlockComponentProps } from '../../../../types.js'
import type { ViewMapBlockComponentProps } from '../../../../types/index.js'
import type { BlockFields } from '../../server/nodes/BlocksNode.js'

import './index.css'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from
import React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'
import { v4 as uuid } from 'uuid'

import type { ViewMapInlineBlockComponentProps } from '../../../../types.js'
import type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'
import type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'
import type { BlockComponentProps } from '../component/index.js'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'lexical'
import React, { type JSX } from 'react'

import type { ViewMapBlockComponentProps } from '../../../../types.js'
import type { ViewMapBlockComponentProps } from '../../../../types/index.js'
import type { BlockFieldsOptionalID, SerializedBlockNode } from '../../server/nodes/BlocksNode.js'

import { ServerBlockNode } from '../../server/nodes/BlocksNode.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'lexical'
import React, { type JSX } from 'react'

import type { ViewMapInlineBlockComponentProps } from '../../../../types.js'
import type { ViewMapInlineBlockComponentProps } from '../../../../types/index.js'
import type {
InlineBlockFields,
SerializedInlineBlockNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const BlocksFeature = createServerFeature<BlocksFeatureProps, BlocksFeatu
return {
ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',
generatedTypes: {
modifyOutputSchema: ({
modifyJSONSchema: ({
collectionIDFieldTypes,
config,
currentSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
type NodeKey,
} from 'lexical'

import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'
import type { StronglyTypedLeafNode } from '../../../../types/nodeTypes.js'

type BaseBlockFields<TBlockFields extends JsonObject = JsonObject> = {
/** Block form data */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { addClassNamesToElement } from '@lexical/utils'
import ObjectID from 'bson-objectid'
import { $applyNodeReplacement, DecoratorNode } from 'lexical'

import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'
import type { StronglyTypedLeafNode } from '../../../../types/nodeTypes.js'

export type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {
blockType: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createHeadlessEditor } from '@lexical/headless'
import { $getRoot, $getSelection, type SerializedLexicalNode } from 'lexical'

import type { SanitizedServerEditorConfig } from '../../../lexical/config/types.js'
import type { DefaultNodeTypes, TypedEditorState } from '../../../nodeTypes.js'
import type { DefaultNodeTypes, TypedEditorState } from '../../../types/nodeTypes.js'

import { getEnabledNodes } from '../../../lexical/nodes/index.js'
import { $generateNodesFromDOM } from '../../../lexical-proxy/@lexical-html.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedQuoteNode } from '../../../../../nodeTypes.js'
import type { SerializedQuoteNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

export const BlockquoteHTMLConverterAsync: HTMLConvertersAsync<SerializedQuoteNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHeadingNode } from '../../../../../nodeTypes.js'
import type { SerializedHeadingNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

const ALLOWED_HEADING_TAGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHorizontalRuleNode } from '../../../../../nodeTypes.js'
import type { SerializedHorizontalRuleNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'
export const HorizontalRuleHTMLConverterAsync: HTMLConvertersAsync<SerializedHorizontalRuleNode> = {
horizontalrule: '<hr />',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedLineBreakNode } from '../../../../../nodeTypes.js'
import type { SerializedLineBreakNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

export const LinebreakHTMLConverterAsync: HTMLConvertersAsync<SerializedLineBreakNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import escapeHTML from 'escape-html'
import { sanitizeUrl } from 'payload/shared'

import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'
import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync, HTMLPopulateFn } from '../types.js'

export const LinkHTMLConverterAsync: (args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { v4 as uuidv4 } from 'uuid'

import type { SerializedListItemNode, SerializedListNode } from '../../../../../nodeTypes.js'
import type { SerializedListItemNode, SerializedListNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

const ALLOWED_LIST_TAGS = new Set(['ol', 'ul'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedParagraphNode } from '../../../../../nodeTypes.js'
import type { SerializedParagraphNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

export const ParagraphHTMLConverterAsync: HTMLConvertersAsync<SerializedParagraphNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedTabNode } from '../../../../../nodeTypes.js'
import type { SerializedTabNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

export const TabHTMLConverterAsync: HTMLConvertersAsync<SerializedTabNode> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
SerializedTableCellNode,
SerializedTableNode,
SerializedTableRowNode,
} from '../../../../../nodeTypes.js'
} from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

import { isSafeCssColor } from '../../shared/cssColors.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import escapeHTML from 'escape-html'

import type { SerializedTextNode } from '../../../../../nodeTypes.js'
import type { SerializedTextNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from '../types.js'

import { NodeFormat } from '../../../../../lexical/utils/nodeFormat.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FileData, FileSize, TypeWithID } from 'payload'

import escapeHTML from 'escape-html'

import type { SerializedUploadNode } from '../../../../../nodeTypes.js'
import type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'
import type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'
import type { HTMLConvertersAsync } from '../types.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DefaultNodeTypes } from '../../../../nodeTypes.js'
import type { DefaultNodeTypes } from '../../../../types/nodeTypes.js'
import type { HTMLConvertersAsync } from './types.js'

import { BlockquoteHTMLConverterAsync } from './converters/blockquote.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
DefaultNodeTypes,
SerializedBlockNode,
SerializedInlineBlockNode,
} from '../../../../nodeTypes.js'
} from '../../../../types/nodeTypes.js'
import type { SerializedLexicalNodeWithParent } from '../shared/types.js'
export type HTMLPopulateArguments = {
collectionSlug: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import type { SerializedLexicalNode } from 'lexical'

import type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../nodeTypes.js'
import type { SerializedBlockNode, SerializedInlineBlockNode } from '../../../../types/nodeTypes.js'
import type { HTMLConverterAsync, HTMLConvertersAsync } from '../async/types.js'
import type { HTMLConverter, HTMLConverters } from '../sync/types.js'
import type { ProvidedCSS } from './types.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedQuoteNode } from '../../../../../nodeTypes.js'
import type { SerializedQuoteNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

export const BlockquoteHTMLConverter: HTMLConverters<SerializedQuoteNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHeadingNode } from '../../../../../nodeTypes.js'
import type { SerializedHeadingNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

const ALLOWED_HEADING_TAGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHorizontalRuleNode } from '../../../../../nodeTypes.js'
import type { SerializedHorizontalRuleNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'
export const HorizontalRuleHTMLConverter: HTMLConverters<SerializedHorizontalRuleNode> = {
horizontalrule: '<hr />',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedLineBreakNode } from '../../../../../nodeTypes.js'
import type { SerializedLineBreakNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

export const LinebreakHTMLConverter: HTMLConverters<SerializedLineBreakNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import escapeHTML from 'escape-html'
import { sanitizeUrl } from 'payload/shared'

import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'
import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

export const LinkHTMLConverter: (args: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { v4 as uuidv4 } from 'uuid'

import type { SerializedListItemNode, SerializedListNode } from '../../../../../nodeTypes.js'
import type { SerializedListItemNode, SerializedListNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

const ALLOWED_LIST_TAGS = new Set(['ol', 'ul'])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedParagraphNode } from '../../../../../nodeTypes.js'
import type { SerializedParagraphNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

export const ParagraphHTMLConverter: HTMLConverters<SerializedParagraphNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedTabNode } from '../../../../../nodeTypes.js'
import type { SerializedTabNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

export const TabHTMLConverter: HTMLConverters<SerializedTabNode> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
SerializedTableCellNode,
SerializedTableNode,
SerializedTableRowNode,
} from '../../../../../nodeTypes.js'
} from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

import { isSafeCssColor } from '../../shared/cssColors.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import escapeHTML from 'escape-html'

import type { SerializedTextNode } from '../../../../../nodeTypes.js'
import type { SerializedTextNode } from '../../../../../types/nodeTypes.js'
import type { HTMLConverters } from '../types.js'

import { NodeFormat } from '../../../../../lexical/utils/nodeFormat.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FileData, FileSize, TypeWithID } from 'payload'

import escapeHTML from 'escape-html'

import type { SerializedUploadNode } from '../../../../../nodeTypes.js'
import type { SerializedUploadNode } from '../../../../../types/nodeTypes.js'
import type { UploadDataImproved } from '../../../../upload/server/nodes/UploadNode.js'
import type { HTMLConverters } from '../types.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DefaultNodeTypes } from '../../../../nodeTypes.js'
import type { DefaultNodeTypes } from '../../../../types/nodeTypes.js'
import type { HTMLConverters } from './types.js'

import { BlockquoteHTMLConverter } from './converters/blockquote.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
DefaultNodeTypes,
SerializedBlockNode,
SerializedInlineBlockNode,
} from '../../../../nodeTypes.js'
} from '../../../../types/nodeTypes.js'
import type { SerializedLexicalNodeWithParent } from '../shared/types.js'

export type HTMLConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react'

import type { SerializedNodeBase } from '../../../../types/index.js'
import type {
DefaultNodeTypes,
SerializedBlockNode,
SerializedInlineBlockNode,
} from '../../../../nodeTypes.js'
import type { SerializedNodeBase } from '../../../../types.js'
} from '../../../../types/nodeTypes.js'
import type { JSXConverters } from '../converter/types.js'

import { defaultJSXConverters } from '../converter/defaultConverters.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedQuoteNode } from '../../../../../nodeTypes.js'
import type { SerializedQuoteNode } from '../../../../../types/nodeTypes.js'
import type { JSXConverters } from '../types.js'

export const BlockquoteJSXConverter: JSXConverters<SerializedQuoteNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHeadingNode } from '../../../../../nodeTypes.js'
import type { SerializedHeadingNode } from '../../../../../types/nodeTypes.js'
import type { JSXConverters } from '../types.js'

export const HeadingJSXConverter: JSXConverters<SerializedHeadingNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedHorizontalRuleNode } from '../../../../../nodeTypes.js'
import type { SerializedHorizontalRuleNode } from '../../../../../types/nodeTypes.js'
import type { JSXConverters } from '../types.js'
export const HorizontalRuleJSXConverter: JSXConverters<SerializedHorizontalRuleNode> = {
horizontalrule: <hr />,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedLineBreakNode } from '../../../../../nodeTypes.js'
import type { SerializedLineBreakNode } from '../../../../../types/nodeTypes.js'
import type { JSXConverters } from '../types.js'

export const LinebreakJSXConverter: JSXConverters<SerializedLineBreakNode> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'
import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../types/nodeTypes.js'
import type { JSXConverters } from '../types.js'

export const LinkJSXConverter: (args: {
Expand Down
Loading
Loading