From a88b35f919ac0b45c9e5a986ce06cf94ca1fc691 Mon Sep 17 00:00:00 2001 From: Alessio Gravili Date: Mon, 26 Feb 2024 15:45:28 -0500 Subject: [PATCH] chore(richtext-*): lint & prettier --- packages/richtext-lexical/README.md | 4 +--- .../src/field/features/BlockQuote/index.ts | 4 ++-- .../field/features/BlockQuote/markdownTransformer.ts | 2 +- .../src/field/features/Blocks/component/index.tsx | 6 +++--- .../src/field/features/Blocks/drawer/index.tsx | 2 +- .../src/field/features/Blocks/index.ts | 10 +++++----- .../src/field/features/Blocks/nodes/BlocksNode.tsx | 2 +- .../Blocks/utils/transformInputFormSchema.ts | 2 +- .../src/field/features/Heading/index.ts | 12 ++++++------ .../field/features/Heading/markdownTransformer.ts | 2 +- .../src/field/features/Link/drawer/baseFields.ts | 12 ++++++------ .../plugins/floatingLinkEditor/LinkEditor/index.tsx | 8 ++++---- .../src/field/features/Paragraph/index.ts | 4 ++-- .../src/field/features/Relationship/index.ts | 6 +++--- .../features/Relationship/nodes/RelationshipNode.tsx | 2 +- .../Upload/component/ExtraFieldsDrawer/index.tsx | 6 +++--- .../src/field/features/Upload/component/index.tsx | 2 +- .../src/field/features/Upload/index.ts | 6 +++--- .../src/field/features/Upload/nodes/UploadNode.tsx | 4 ++-- .../floatingSelectToolbarAlignDropdownSection.ts | 4 ++-- .../src/field/features/align/index.ts | 6 +++--- .../index.ts | 2 +- .../index.ts | 4 ++-- .../field/features/converters/html/field/index.ts | 2 +- .../src/field/features/debug/TestRecorder/index.ts | 2 +- .../features/debug/TestRecorder/plugin/index.scss | 2 -- .../src/field/features/debug/TreeView/index.ts | 2 +- .../src/field/features/format/Bold/index.ts | 2 +- .../features/format/Bold/markdownTransformers.ts | 8 ++++---- .../src/field/features/format/InlineCode/index.ts | 2 +- .../format/InlineCode/markdownTransformers.ts | 2 +- .../src/field/features/format/Italic/index.ts | 2 +- .../features/format/Italic/markdownTransformers.ts | 4 ++-- .../format/common/floatingSelectToolbarSection.ts | 2 +- .../src/field/features/format/strikethrough/index.ts | 2 +- .../format/strikethrough/markdownTransformers.ts | 2 +- .../src/field/features/format/subscript/index.ts | 2 +- .../src/field/features/format/superscript/index.ts | 2 +- .../src/field/features/format/underline/index.ts | 2 +- .../indent/floatingSelectToolbarIndentSection.ts | 2 +- .../src/field/features/indent/index.ts | 6 +++--- .../src/field/features/lists/CheckList/index.ts | 10 +++++----- .../features/lists/CheckList/markdownTransformers.ts | 2 +- .../src/field/features/lists/OrderedList/index.ts | 10 +++++----- .../lists/OrderedList/markdownTransformer.ts | 2 +- .../src/field/features/lists/UnorderedList/index.ts | 10 +++++----- .../lists/UnorderedList/markdownTransformer.ts | 2 +- .../src/field/features/lists/common/markdown.ts | 4 ++-- .../converter/converters/heading.ts | 2 +- .../converter/converters/link.ts | 2 +- .../converter/converters/list.ts | 2 +- .../converter/converters/listItem.ts | 2 +- .../converter/converters/quote.ts | 2 +- .../converter/converters/unknown.ts | 2 +- .../converter/converters/upload.ts | 2 +- .../LexicalPluginToLexical/converter/index.ts | 6 +++--- .../migrations/LexicalPluginToLexical/index.ts | 2 +- .../nodes/unknownConvertedNode/index.tsx | 4 ++-- .../converter/converters/blockquote.ts | 2 +- .../SlateToLexical/converter/converters/heading.ts | 2 +- .../SlateToLexical/converter/converters/indent.ts | 2 +- .../SlateToLexical/converter/converters/link.ts | 2 +- .../SlateToLexical/converter/converters/listItem.ts | 2 +- .../converter/converters/orderedList.ts | 2 +- .../converter/converters/relationship.ts | 2 +- .../SlateToLexical/converter/converters/unknown.ts | 2 +- .../converter/converters/unorderedList.ts | 2 +- .../SlateToLexical/converter/converters/upload.ts | 2 +- .../migrations/SlateToLexical/converter/index.ts | 6 +++--- .../features/migrations/SlateToLexical/index.ts | 2 +- .../nodes/unknownConvertedNode/index.tsx | 4 ++-- packages/richtext-lexical/src/field/index.tsx | 2 +- .../src/field/lexical/config/default.ts | 2 +- .../richtext-lexical/src/populate/defaultValue.ts | 10 +++++----- packages/richtext-slate/README.md | 4 +--- .../richtext-slate/src/field/elements/Button.tsx | 2 +- .../src/field/elements/getCommonBlock.tsx | 2 +- .../src/field/elements/indent/Button.tsx | 6 +++--- .../src/field/elements/li/ListItem.tsx | 3 ++- .../src/field/elements/link/Button/index.tsx | 2 +- .../src/field/elements/link/LinkDrawer/baseFields.ts | 10 +++++----- .../richtext-slate/src/field/elements/link/types.ts | 2 +- .../src/field/elements/ol/OrderedList.tsx | 1 + .../src/field/elements/relationship/Button/index.tsx | 2 +- .../field/elements/relationship/Element/index.tsx | 4 ++-- .../richtext-slate/src/field/elements/toggle.tsx | 2 +- .../richtext-slate/src/field/elements/toggleList.tsx | 4 ++-- .../src/field/elements/ul/UnorderedList.tsx | 1 + .../src/field/elements/upload/Button/index.tsx | 2 +- .../src/field/elements/upload/Element/index.tsx | 2 +- .../richtext-slate/src/field/plugins/withHTML.tsx | 2 +- 91 files changed, 160 insertions(+), 163 deletions(-) diff --git a/packages/richtext-lexical/README.md b/packages/richtext-lexical/README.md index 94eb44718..7aba3b34c 100644 --- a/packages/richtext-lexical/README.md +++ b/packages/richtext-lexical/README.md @@ -18,11 +18,9 @@ import { buildConfig } from 'payload/config' import { lexicalEditor } from '@payloadcms/richtext-lexical' export default buildConfig({ - editor: lexicalEditor({}) + editor: lexicalEditor({}), // ...rest of config }) - ``` More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview). - diff --git a/packages/richtext-lexical/src/field/features/BlockQuote/index.ts b/packages/richtext-lexical/src/field/features/BlockQuote/index.ts index 2b9ffa5e7..49826873f 100644 --- a/packages/richtext-lexical/src/field/features/BlockQuote/index.ts +++ b/packages/richtext-lexical/src/field/features/BlockQuote/index.ts @@ -21,7 +21,7 @@ export const BlockQuoteFeature = (): FeatureProvider => { TextDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Blockquote').then( (module) => module.BlockquoteIcon, ), @@ -72,7 +72,7 @@ export const BlockQuoteFeature = (): FeatureProvider => { options: [ new SlashMenuOption(`blockquote`, { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Blockquote').then( (module) => module.BlockquoteIcon, ), diff --git a/packages/richtext-lexical/src/field/features/BlockQuote/markdownTransformer.ts b/packages/richtext-lexical/src/field/features/BlockQuote/markdownTransformer.ts index 23ae0ec55..f5088c729 100644 --- a/packages/richtext-lexical/src/field/features/BlockQuote/markdownTransformer.ts +++ b/packages/richtext-lexical/src/field/features/BlockQuote/markdownTransformer.ts @@ -3,6 +3,7 @@ import type { ElementTransformer } from '@lexical/markdown' import { $createQuoteNode, $isQuoteNode, QuoteNode } from '@lexical/rich-text' import { $createLineBreakNode } from 'lexical' export const MarkdownTransformer: ElementTransformer = { + type: 'element', dependencies: [QuoteNode], export: (node, exportChildren) => { if (!$isQuoteNode(node)) { @@ -36,5 +37,4 @@ export const MarkdownTransformer: ElementTransformer = { parentNode.replace(node) node.select(0, 0) }, - type: 'element', } diff --git a/packages/richtext-lexical/src/field/features/Blocks/component/index.tsx b/packages/richtext-lexical/src/field/features/Blocks/component/index.tsx index 7b456a917..5080a61ba 100644 --- a/packages/richtext-lexical/src/field/features/Blocks/component/index.tsx +++ b/packages/richtext-lexical/src/field/features/Blocks/component/index.tsx @@ -52,7 +52,7 @@ export const BlockComponent: React.FC = (props) => { const validRelationships = payloadConfig.collections.map((c) => c.slug) || [] const formSchema = transformInputFormSchema( sanitizeFields({ - // @ts-ignore-next-line TODO: Fix this + // @ts-expect-error-next-line TODO: Fix this config: payloadConfig, fields: unsanitizedFormSchema, validRelationships, @@ -75,7 +75,7 @@ export const BlockComponent: React.FC = (props) => { const preferences = await getDocPreferences() const stateFromSchema = await buildStateFromSchema({ - // @ts-ignore-next-line TODO: Fix this + // @ts-expect-error-next-line TODO: Fix this config, data: JSON.parse(JSON.stringify(formData)), fieldSchema: formSchema as any, @@ -86,7 +86,7 @@ export const BlockComponent: React.FC = (props) => { }) if (!initialStateRef.current) { - // @ts-ignore-next-line TODO: Fix this + // @ts-expect-error-next-line TODO: Fix this initialStateRef.current = buildInitialState(JSON.parse(JSON.stringify(formData))) } diff --git a/packages/richtext-lexical/src/field/features/Blocks/drawer/index.tsx b/packages/richtext-lexical/src/field/features/Blocks/drawer/index.tsx index c75d0c3f2..9ebaab86a 100644 --- a/packages/richtext-lexical/src/field/features/Blocks/drawer/index.tsx +++ b/packages/richtext-lexical/src/field/features/Blocks/drawer/index.tsx @@ -79,8 +79,8 @@ export const BlocksDrawerComponent: React.FC = () => { ) const drawerSlug = formatDrawerSlug({ - depth: editDepth, slug: `lexical-rich-text-blocks-` + uuid, + depth: editDepth, }) const blocks = (editorConfig?.resolvedFeatureMap?.get('blocks')?.props as BlocksFeatureProps) diff --git a/packages/richtext-lexical/src/field/features/Blocks/index.ts b/packages/richtext-lexical/src/field/features/Blocks/index.ts index 45cd0e442..9cdbf36fc 100644 --- a/packages/richtext-lexical/src/field/features/Blocks/index.ts +++ b/packages/richtext-lexical/src/field/features/Blocks/index.ts @@ -36,8 +36,8 @@ export const BlocksFeature = (props?: BlocksFeatureProps): FeatureProvider => { modifyOutputSchema: ({ currentSchema, field, interfaceNameDefinitions }) => { const blocksField: BlockField = { name: field?.name + '_lexical_blocks', - blocks: props.blocks, type: 'blocks', + blocks: props.blocks, } // This is only done so that interfaceNameDefinitions sets those block's interfaceNames. // we don't actually use the JSON Schema itself in the generated types yet. @@ -48,16 +48,16 @@ export const BlocksFeature = (props?: BlocksFeatureProps): FeatureProvider => { }, nodes: [ { + type: BlockNode.getType(), node: BlockNode, populationPromises: [blockPopulationPromiseHOC(props)], - type: BlockNode.getType(), validations: [blockValidationHOC(props)], }, ], plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.BlocksPlugin), position: 'normal', }, @@ -72,11 +72,11 @@ export const BlocksFeature = (props?: BlocksFeatureProps): FeatureProvider => { ...props.blocks.map((block) => { return new SlashMenuOption('block-' + block.slug, { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Block').then((module) => module.BlockIcon), displayName: ({ i18n }) => { // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line return getTranslation(block.labels.singular, i18n) }, keywords: ['block', 'blocks', block.slug], diff --git a/packages/richtext-lexical/src/field/features/Blocks/nodes/BlocksNode.tsx b/packages/richtext-lexical/src/field/features/Blocks/nodes/BlocksNode.tsx index 434ced9d8..c2a5cb8eb 100644 --- a/packages/richtext-lexical/src/field/features/Blocks/nodes/BlocksNode.tsx +++ b/packages/richtext-lexical/src/field/features/Blocks/nodes/BlocksNode.tsx @@ -25,7 +25,7 @@ export type BlockFields = { } const BlockComponent = React.lazy(() => - // @ts-ignore-next-line TypeScript being dumb + // @ts-expect-error-next-line TypeScript being dumb import('../component').then((module) => ({ default: module.BlockComponent, })), diff --git a/packages/richtext-lexical/src/field/features/Blocks/utils/transformInputFormSchema.ts b/packages/richtext-lexical/src/field/features/Blocks/utils/transformInputFormSchema.ts index b6337ddd4..ed1564911 100644 --- a/packages/richtext-lexical/src/field/features/Blocks/utils/transformInputFormSchema.ts +++ b/packages/richtext-lexical/src/field/features/Blocks/utils/transformInputFormSchema.ts @@ -18,6 +18,7 @@ export function transformInputFormSchema(formSchema: any, blockFieldWrapperName: ), { name: blockFieldWrapperName, + type: 'group', admin: { hideGutter: true, }, @@ -25,7 +26,6 @@ export function transformInputFormSchema(formSchema: any, blockFieldWrapperName: (field) => !('name' in field) || !['blockName', 'blockType', 'id'].includes(field.name), ), label: '', - type: 'group', }, ] } diff --git a/packages/richtext-lexical/src/field/features/Heading/index.ts b/packages/richtext-lexical/src/field/features/Heading/index.ts index efe49e293..f4211d0b3 100644 --- a/packages/richtext-lexical/src/field/features/Heading/index.ts +++ b/packages/richtext-lexical/src/field/features/Heading/index.ts @@ -22,17 +22,17 @@ type Props = { } const iconImports = { - // @ts-ignore-next-line + // @ts-expect-error-next-line h1: () => import('../../lexical/ui/icons/H1').then((module) => module.H1Icon), - // @ts-ignore-next-line + // @ts-expect-error-next-line h2: () => import('../../lexical/ui/icons/H2').then((module) => module.H2Icon), - // @ts-ignore-next-line + // @ts-expect-error-next-line h3: () => import('../../lexical/ui/icons/H3').then((module) => module.H3Icon), - // @ts-ignore-next-line + // @ts-expect-error-next-line h4: () => import('../../lexical/ui/icons/H4').then((module) => module.H4Icon), - // @ts-ignore-next-line + // @ts-expect-error-next-line h5: () => import('../../lexical/ui/icons/H5').then((module) => module.H5Icon), - // @ts-ignore-next-line + // @ts-expect-error-next-line h6: () => import('../../lexical/ui/icons/H6').then((module) => module.H6Icon), } diff --git a/packages/richtext-lexical/src/field/features/Heading/markdownTransformer.ts b/packages/richtext-lexical/src/field/features/Heading/markdownTransformer.ts index 05e490dc2..115b6b38f 100644 --- a/packages/richtext-lexical/src/field/features/Heading/markdownTransformer.ts +++ b/packages/richtext-lexical/src/field/features/Heading/markdownTransformer.ts @@ -16,6 +16,7 @@ export const MarkdownTransformer: (enabledHeadingSizes: HeadingTagType[]) => Ele const regExp = new RegExp(pattern) return { + type: 'element', dependencies: [HeadingNode], export: (node, exportChildren) => { if (!$isHeadingNode(node)) { @@ -29,6 +30,5 @@ export const MarkdownTransformer: (enabledHeadingSizes: HeadingTagType[]) => Ele const tag = ('h' + match[1].length) as HeadingTagType return $createHeadingNode(tag) }), - type: 'element', } } diff --git a/packages/richtext-lexical/src/field/features/Link/drawer/baseFields.ts b/packages/richtext-lexical/src/field/features/Link/drawer/baseFields.ts index c50c3aeaf..1115b4e41 100644 --- a/packages/richtext-lexical/src/field/features/Link/drawer/baseFields.ts +++ b/packages/richtext-lexical/src/field/features/Link/drawer/baseFields.ts @@ -48,12 +48,13 @@ export const getBaseFields = ( const baseFields = [ { name: 'text', + type: 'text', label: translations['fields:textToDisplay'], required: true, - type: 'text', }, { name: 'fields', + type: 'group', admin: { style: { borderBottom: 0, @@ -65,6 +66,7 @@ export const getBaseFields = ( fields: [ { name: 'linkType', + type: 'radio', admin: { description: translations['fields:chooseBetweenCustomTextOrDocument'], }, @@ -77,13 +79,12 @@ export const getBaseFields = ( }, ], required: true, - type: 'radio', }, { name: 'url', + type: 'text', label: translations['fields:enterURL'], required: true, - type: 'text', validate: (value: string) => { if (value && !validateUrl(value)) { return 'Invalid URL' @@ -91,7 +92,6 @@ export const getBaseFields = ( }, }, ] as Field[], - type: 'group', }, ] @@ -113,6 +113,7 @@ export const getBaseFields = ( }, }, // when admin.hidden is a function we need to dynamically call hidden with the user to know if the collection should be shown + type: 'relationship', filterOptions: !enabledCollections && !disabledCollections ? ({ relationTo, user }) => { @@ -125,14 +126,13 @@ export const getBaseFields = ( label: translations['fields:chooseDocumentToLink'], relationTo: enabledRelations, required: true, - type: 'relationship', }) } baseFields[1].fields.push({ name: 'newTab', - label: translations['fields:openInNewTab'], type: 'checkbox', + label: translations['fields:openInNewTab'], }) return baseFields as Field[] diff --git a/packages/richtext-lexical/src/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.tsx b/packages/richtext-lexical/src/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.tsx index d2f837da1..07d2b21d5 100644 --- a/packages/richtext-lexical/src/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.tsx +++ b/packages/richtext-lexical/src/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.tsx @@ -69,7 +69,7 @@ export function LinkEditor({ const fieldsUnsanitized = transformExtraFields( customFieldSchema, // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config, i18n, enabledCollections, @@ -79,7 +79,7 @@ export function LinkEditor({ const validRelationships = config.collections.map((c) => c.slug) || [] const fields = sanitizeFields({ // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config, fields: fieldsUnsanitized, validRelationships, @@ -94,8 +94,8 @@ export function LinkEditor({ const [isAutoLink, setIsAutoLink] = useState(false) const drawerSlug = formatDrawerSlug({ - depth: editDepth, slug: `lexical-rich-text-link-` + uuid, + depth: editDepth, }) const updateLinkEditor = useCallback(async () => { @@ -152,7 +152,7 @@ export function LinkEditor({ const preferences = await getDocPreferences() const state = await buildStateFromSchema({ // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config, data, fieldSchema, diff --git a/packages/richtext-lexical/src/field/features/Paragraph/index.ts b/packages/richtext-lexical/src/field/features/Paragraph/index.ts index dc1862423..0cae5ae91 100644 --- a/packages/richtext-lexical/src/field/features/Paragraph/index.ts +++ b/packages/richtext-lexical/src/field/features/Paragraph/index.ts @@ -15,7 +15,7 @@ export const ParagraphFeature = (): FeatureProvider => { TextDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Text').then((module) => module.TextIcon), isActive: () => false, key: 'normal-text', @@ -40,7 +40,7 @@ export const ParagraphFeature = (): FeatureProvider => { options: [ new SlashMenuOption('paragraph', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Text').then((module) => module.TextIcon), displayName: 'Paragraph', keywords: ['normal', 'paragraph', 'p', 'text'], diff --git a/packages/richtext-lexical/src/field/features/Relationship/index.ts b/packages/richtext-lexical/src/field/features/Relationship/index.ts index 067fab174..3a200e260 100644 --- a/packages/richtext-lexical/src/field/features/Relationship/index.ts +++ b/packages/richtext-lexical/src/field/features/Relationship/index.ts @@ -33,16 +33,16 @@ export const RelationshipFeature = (props?: RelationshipFeatureProps): FeaturePr return { nodes: [ { + type: RelationshipNode.getType(), node: RelationshipNode, populationPromises: [relationshipPopulationPromise], - type: RelationshipNode.getType(), // TODO: Add validation similar to upload }, ], plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugins').then((module) => { const RelationshipPlugin = module.RelationshipPlugin return import('@payloadcms/ui').then((module2) => @@ -64,7 +64,7 @@ export const RelationshipFeature = (props?: RelationshipFeatureProps): FeaturePr options: [ new SlashMenuOption('relationship', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Relationship').then( (module) => module.RelationshipIcon, ), diff --git a/packages/richtext-lexical/src/field/features/Relationship/nodes/RelationshipNode.tsx b/packages/richtext-lexical/src/field/features/Relationship/nodes/RelationshipNode.tsx index be11a6cc2..15dd9383f 100644 --- a/packages/richtext-lexical/src/field/features/Relationship/nodes/RelationshipNode.tsx +++ b/packages/richtext-lexical/src/field/features/Relationship/nodes/RelationshipNode.tsx @@ -17,7 +17,7 @@ import { import * as React from 'react' const RelationshipComponent = React.lazy(() => - // @ts-ignore-next-line TypeScript being dumb + // @ts-expect-error-next-line TypeScript being dumb import('./components/RelationshipComponent').then((module) => ({ default: module.RelationshipComponent, })), diff --git a/packages/richtext-lexical/src/field/features/Upload/component/ExtraFieldsDrawer/index.tsx b/packages/richtext-lexical/src/field/features/Upload/component/ExtraFieldsDrawer/index.tsx index ed34787c2..ee7185178 100644 --- a/packages/richtext-lexical/src/field/features/Upload/component/ExtraFieldsDrawer/index.tsx +++ b/packages/richtext-lexical/src/field/features/Upload/component/ExtraFieldsDrawer/index.tsx @@ -63,7 +63,7 @@ export const ExtraFieldsUploadDrawer: React.FC< const validRelationships = config.collections.map((c) => c.slug) || [] const fieldSchema = sanitizeFields({ // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config: config, fields: fieldSchemaUnsanitized, validRelationships, @@ -93,7 +93,7 @@ export const ExtraFieldsUploadDrawer: React.FC< const validRelationships = config.collections.map((c) => c.slug) || [] const fieldSchema = sanitizeFields({ // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config: config, fields: fieldSchemaUnsanitized, validRelationships, @@ -103,7 +103,7 @@ export const ExtraFieldsUploadDrawer: React.FC< const preferences = await getDocPreferences() const state = await buildStateFromSchema({ // TODO: fix this - // @ts-ignore-next-line + // @ts-expect-error-next-line config, data: deepCopyObject(fields || {}), fieldSchema, diff --git a/packages/richtext-lexical/src/field/features/Upload/component/index.tsx b/packages/richtext-lexical/src/field/features/Upload/component/index.tsx index 329c85b0f..dcdfe8636 100644 --- a/packages/richtext-lexical/src/field/features/Upload/component/index.tsx +++ b/packages/richtext-lexical/src/field/features/Upload/component/index.tsx @@ -112,7 +112,7 @@ const Component: React.FC = (props) => {
{/* TODO: fix this */} - {/* @ts-ignore-next-line */} + {/* @ts-expect-error-next-line */} {getTranslation(relatedCollection.labels.singular, i18n)}
{editor.isEditable() && ( diff --git a/packages/richtext-lexical/src/field/features/Upload/index.ts b/packages/richtext-lexical/src/field/features/Upload/index.ts index 3c7b2d838..182fca298 100644 --- a/packages/richtext-lexical/src/field/features/Upload/index.ts +++ b/packages/richtext-lexical/src/field/features/Upload/index.ts @@ -33,6 +33,7 @@ export const UploadFeature = (props?: UploadFeatureProps): FeatureProvider => { return { nodes: [ { + type: UploadNode.getType(), converters: { html: { converter: async ({ node }) => { @@ -92,14 +93,13 @@ export const UploadFeature = (props?: UploadFeatureProps): FeatureProvider => { }, node: UploadNode, populationPromises: [uploadPopulationPromiseHOC(props)], - type: UploadNode.getType(), validations: [uploadValidation()], }, ], plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.UploadPlugin), position: 'normal', }, @@ -113,7 +113,7 @@ export const UploadFeature = (props?: UploadFeatureProps): FeatureProvider => { options: [ new SlashMenuOption('upload', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/Upload').then((module) => module.UploadIcon), displayName: 'Upload', keywords: ['upload', 'image', 'file', 'img', 'picture', 'photo', 'media'], diff --git a/packages/richtext-lexical/src/field/features/Upload/nodes/UploadNode.tsx b/packages/richtext-lexical/src/field/features/Upload/nodes/UploadNode.tsx index c8150faef..c486ea266 100644 --- a/packages/richtext-lexical/src/field/features/Upload/nodes/UploadNode.tsx +++ b/packages/richtext-lexical/src/field/features/Upload/nodes/UploadNode.tsx @@ -12,7 +12,7 @@ import { } from 'lexical' import * as React from 'react' -// @ts-ignore-next-line TypeScript being dumb +// @ts-expect-error-next-line TypeScript being dumb const RawUploadComponent = React.lazy(async () => await import('../component')) export interface RawUploadPayload { @@ -104,7 +104,7 @@ export class UploadNode extends DecoratorBlockNode { } decorate(): JSX.Element { - // @ts-ignore-next-line + // @ts-expect-error-next-line return } diff --git a/packages/richtext-lexical/src/field/features/align/floatingSelectToolbarAlignDropdownSection.ts b/packages/richtext-lexical/src/field/features/align/floatingSelectToolbarAlignDropdownSection.ts index e07807235..97aa0de75 100644 --- a/packages/richtext-lexical/src/field/features/align/floatingSelectToolbarAlignDropdownSection.ts +++ b/packages/richtext-lexical/src/field/features/align/floatingSelectToolbarAlignDropdownSection.ts @@ -7,12 +7,12 @@ export const AlignDropdownSectionWithEntries = ( entries: FloatingToolbarSectionEntry[], ): FloatingToolbarSection => { return { + type: 'dropdown', ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/AlignLeft').then((module) => module.AlignLeftIcon), entries, key: 'dropdown-align', order: 2, - type: 'dropdown', } } diff --git a/packages/richtext-lexical/src/field/features/align/index.ts b/packages/richtext-lexical/src/field/features/align/index.ts index 38516d74b..52a5bd97d 100644 --- a/packages/richtext-lexical/src/field/features/align/index.ts +++ b/packages/richtext-lexical/src/field/features/align/index.ts @@ -13,7 +13,7 @@ export const AlignFeature = (): FeatureProvider => { AlignDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/AlignLeft').then((module) => module.AlignLeftIcon), isActive: () => false, key: 'align-left', @@ -27,7 +27,7 @@ export const AlignFeature = (): FeatureProvider => { AlignDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/AlignCenter').then( (module) => module.AlignCenterIcon, ), @@ -43,7 +43,7 @@ export const AlignFeature = (): FeatureProvider => { AlignDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/AlignRight').then( (module) => module.AlignRightIcon, ), diff --git a/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.ts b/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.ts index 0ce010e5a..94e2f688f 100644 --- a/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.ts +++ b/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarFeaturesButtonsSection/index.ts @@ -7,9 +7,9 @@ export const FeaturesSectionWithEntries = ( entries: FloatingToolbarSectionEntry[], ): FloatingToolbarSection => { return { + type: 'buttons', entries, key: 'features', order: 5, - type: 'buttons', } } diff --git a/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarTextDropdownSection/index.ts b/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarTextDropdownSection/index.ts index 9bf0b7b8d..564cab55e 100644 --- a/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarTextDropdownSection/index.ts +++ b/packages/richtext-lexical/src/field/features/common/floatingSelectToolbarTextDropdownSection/index.ts @@ -7,12 +7,12 @@ export const TextDropdownSectionWithEntries = ( entries: FloatingToolbarSectionEntry[], ): FloatingToolbarSection => { return { + type: 'dropdown', ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Text').then((module) => module.TextIcon), entries, key: 'dropdown-text', order: 1, - type: 'dropdown', } } diff --git a/packages/richtext-lexical/src/field/features/converters/html/field/index.ts b/packages/richtext-lexical/src/field/features/converters/html/field/index.ts index 241cc2c30..380916c65 100644 --- a/packages/richtext-lexical/src/field/features/converters/html/field/index.ts +++ b/packages/richtext-lexical/src/field/features/converters/html/field/index.ts @@ -56,6 +56,7 @@ export const lexicalHTML: ( const { name = 'lexicalHTML' } = props return { name: name, + type: 'text', admin: { hidden: true, }, @@ -167,6 +168,5 @@ export const lexicalHTML: ( }, ], }, - type: 'text', } } diff --git a/packages/richtext-lexical/src/field/features/debug/TestRecorder/index.ts b/packages/richtext-lexical/src/field/features/debug/TestRecorder/index.ts index f0f3f1afc..7ecfb68a1 100644 --- a/packages/richtext-lexical/src/field/features/debug/TestRecorder/index.ts +++ b/packages/richtext-lexical/src/field/features/debug/TestRecorder/index.ts @@ -7,7 +7,7 @@ export const TestRecorderFeature = (): FeatureProvider => { plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.TestRecorderPlugin), position: 'bottom', }, diff --git a/packages/richtext-lexical/src/field/features/debug/TestRecorder/plugin/index.scss b/packages/richtext-lexical/src/field/features/debug/TestRecorder/plugin/index.scss index d6f90cdc3..18a8abc21 100644 --- a/packages/richtext-lexical/src/field/features/debug/TestRecorder/plugin/index.scss +++ b/packages/richtext-lexical/src/field/features/debug/TestRecorder/plugin/index.scss @@ -47,5 +47,3 @@ #test-recorder-button-snapshot { margin-right: auto; } - - diff --git a/packages/richtext-lexical/src/field/features/debug/TreeView/index.ts b/packages/richtext-lexical/src/field/features/debug/TreeView/index.ts index 41e6f8424..2a753a975 100644 --- a/packages/richtext-lexical/src/field/features/debug/TreeView/index.ts +++ b/packages/richtext-lexical/src/field/features/debug/TreeView/index.ts @@ -7,7 +7,7 @@ export const TreeViewFeature = (): FeatureProvider => { plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.TreeViewPlugin), position: 'bottom', }, diff --git a/packages/richtext-lexical/src/field/features/format/Bold/index.ts b/packages/richtext-lexical/src/field/features/format/Bold/index.ts index 8d032f953..e2443e7e2 100644 --- a/packages/richtext-lexical/src/field/features/format/Bold/index.ts +++ b/packages/richtext-lexical/src/field/features/format/Bold/index.ts @@ -25,7 +25,7 @@ export const BoldTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Bold').then((module) => module.BoldIcon), isActive: ({ selection }) => { if ($isRangeSelection(selection)) { diff --git a/packages/richtext-lexical/src/field/features/format/Bold/markdownTransformers.ts b/packages/richtext-lexical/src/field/features/format/Bold/markdownTransformers.ts index c944250cb..dca723087 100644 --- a/packages/richtext-lexical/src/field/features/format/Bold/markdownTransformers.ts +++ b/packages/richtext-lexical/src/field/features/format/Bold/markdownTransformers.ts @@ -1,27 +1,27 @@ import type { TextFormatTransformer } from '@lexical/markdown' export const BOLD_ITALIC_STAR: TextFormatTransformer = { + type: 'text-format', format: ['bold', 'italic'], tag: '***', - type: 'text-format', } export const BOLD_ITALIC_UNDERSCORE: TextFormatTransformer = { + type: 'text-format', format: ['bold', 'italic'], intraword: false, tag: '___', - type: 'text-format', } export const BOLD_STAR: TextFormatTransformer = { + type: 'text-format', format: ['bold'], tag: '**', - type: 'text-format', } export const BOLD_UNDERSCORE: TextFormatTransformer = { + type: 'text-format', format: ['bold'], intraword: false, tag: '__', - type: 'text-format', } diff --git a/packages/richtext-lexical/src/field/features/format/InlineCode/index.ts b/packages/richtext-lexical/src/field/features/format/InlineCode/index.ts index ff608567b..9fa8da06f 100644 --- a/packages/richtext-lexical/src/field/features/format/InlineCode/index.ts +++ b/packages/richtext-lexical/src/field/features/format/InlineCode/index.ts @@ -14,7 +14,7 @@ export const InlineCodeTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Code').then((module) => module.CodeIcon), isActive: ({ selection }) => { if ($isRangeSelection(selection)) { diff --git a/packages/richtext-lexical/src/field/features/format/InlineCode/markdownTransformers.ts b/packages/richtext-lexical/src/field/features/format/InlineCode/markdownTransformers.ts index 3a914d711..c31e9582d 100644 --- a/packages/richtext-lexical/src/field/features/format/InlineCode/markdownTransformers.ts +++ b/packages/richtext-lexical/src/field/features/format/InlineCode/markdownTransformers.ts @@ -1,7 +1,7 @@ import type { TextFormatTransformer } from '@lexical/markdown' export const INLINE_CODE: TextFormatTransformer = { + type: 'text-format', format: ['code'], tag: '`', - type: 'text-format', } diff --git a/packages/richtext-lexical/src/field/features/format/Italic/index.ts b/packages/richtext-lexical/src/field/features/format/Italic/index.ts index a76dbc9f9..cdd15dcca 100644 --- a/packages/richtext-lexical/src/field/features/format/Italic/index.ts +++ b/packages/richtext-lexical/src/field/features/format/Italic/index.ts @@ -14,7 +14,7 @@ export const ItalicTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Italic').then((module) => module.ItalicIcon), isActive: ({ selection }) => { if ($isRangeSelection(selection)) { diff --git a/packages/richtext-lexical/src/field/features/format/Italic/markdownTransformers.ts b/packages/richtext-lexical/src/field/features/format/Italic/markdownTransformers.ts index 608b482c4..5698005ff 100644 --- a/packages/richtext-lexical/src/field/features/format/Italic/markdownTransformers.ts +++ b/packages/richtext-lexical/src/field/features/format/Italic/markdownTransformers.ts @@ -1,14 +1,14 @@ import type { TextFormatTransformer } from '@lexical/markdown' export const ITALIC_STAR: TextFormatTransformer = { + type: 'text-format', format: ['italic'], tag: '*', - type: 'text-format', } export const ITALIC_UNDERSCORE: TextFormatTransformer = { + type: 'text-format', format: ['italic'], intraword: false, tag: '_', - type: 'text-format', } diff --git a/packages/richtext-lexical/src/field/features/format/common/floatingSelectToolbarSection.ts b/packages/richtext-lexical/src/field/features/format/common/floatingSelectToolbarSection.ts index 13a07cc59..08601bc29 100644 --- a/packages/richtext-lexical/src/field/features/format/common/floatingSelectToolbarSection.ts +++ b/packages/richtext-lexical/src/field/features/format/common/floatingSelectToolbarSection.ts @@ -7,9 +7,9 @@ export const SectionWithEntries = ( entries: FloatingToolbarSectionEntry[], ): FloatingToolbarSection => { return { + type: 'buttons', entries, key: 'format', order: 4, - type: 'buttons', } } diff --git a/packages/richtext-lexical/src/field/features/format/strikethrough/index.ts b/packages/richtext-lexical/src/field/features/format/strikethrough/index.ts index 198fae35e..949ec80b9 100644 --- a/packages/richtext-lexical/src/field/features/format/strikethrough/index.ts +++ b/packages/richtext-lexical/src/field/features/format/strikethrough/index.ts @@ -14,7 +14,7 @@ export const StrikethroughTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Strikethrough').then( (module) => module.StrikethroughIcon, ), diff --git a/packages/richtext-lexical/src/field/features/format/strikethrough/markdownTransformers.ts b/packages/richtext-lexical/src/field/features/format/strikethrough/markdownTransformers.ts index 9c2dab0a7..01a88390c 100644 --- a/packages/richtext-lexical/src/field/features/format/strikethrough/markdownTransformers.ts +++ b/packages/richtext-lexical/src/field/features/format/strikethrough/markdownTransformers.ts @@ -1,7 +1,7 @@ import type { TextFormatTransformer } from '@lexical/markdown' export const STRIKETHROUGH: TextFormatTransformer = { + type: 'text-format', format: ['strikethrough'], tag: '~~', - type: 'text-format', } diff --git a/packages/richtext-lexical/src/field/features/format/subscript/index.ts b/packages/richtext-lexical/src/field/features/format/subscript/index.ts index eb96dc4e0..962e816f7 100644 --- a/packages/richtext-lexical/src/field/features/format/subscript/index.ts +++ b/packages/richtext-lexical/src/field/features/format/subscript/index.ts @@ -13,7 +13,7 @@ export const SubscriptTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Subscript').then( (module) => module.SubscriptIcon, ), diff --git a/packages/richtext-lexical/src/field/features/format/superscript/index.ts b/packages/richtext-lexical/src/field/features/format/superscript/index.ts index e50340463..0e2939c35 100644 --- a/packages/richtext-lexical/src/field/features/format/superscript/index.ts +++ b/packages/richtext-lexical/src/field/features/format/superscript/index.ts @@ -13,7 +13,7 @@ export const SuperscriptTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Superscript').then( (module) => module.SuperscriptIcon, ), diff --git a/packages/richtext-lexical/src/field/features/format/underline/index.ts b/packages/richtext-lexical/src/field/features/format/underline/index.ts index 9cc4e1df7..d5e4cf26b 100644 --- a/packages/richtext-lexical/src/field/features/format/underline/index.ts +++ b/packages/richtext-lexical/src/field/features/format/underline/index.ts @@ -13,7 +13,7 @@ export const UnderlineTextFeature = (): FeatureProvider => { SectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Underline').then( (module) => module.UnderlineIcon, ), diff --git a/packages/richtext-lexical/src/field/features/indent/floatingSelectToolbarIndentSection.ts b/packages/richtext-lexical/src/field/features/indent/floatingSelectToolbarIndentSection.ts index d026a3f5a..49648413e 100644 --- a/packages/richtext-lexical/src/field/features/indent/floatingSelectToolbarIndentSection.ts +++ b/packages/richtext-lexical/src/field/features/indent/floatingSelectToolbarIndentSection.ts @@ -7,9 +7,9 @@ export const IndentSectionWithEntries = ( entries: FloatingToolbarSectionEntry[], ): FloatingToolbarSection => { return { + type: 'buttons', entries, key: 'indent', order: 3, - type: 'buttons', } } diff --git a/packages/richtext-lexical/src/field/features/indent/index.ts b/packages/richtext-lexical/src/field/features/indent/index.ts index ecfd23818..72b7250a1 100644 --- a/packages/richtext-lexical/src/field/features/indent/index.ts +++ b/packages/richtext-lexical/src/field/features/indent/index.ts @@ -13,7 +13,7 @@ export const IndentFeature = (): FeatureProvider => { IndentSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/IndentDecrease').then( (module) => module.IndentDecreaseIcon, ), @@ -46,7 +46,7 @@ export const IndentFeature = (): FeatureProvider => { IndentSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../lexical/ui/icons/IndentIncrease').then( (module) => module.IndentIncreaseIcon, ), @@ -64,7 +64,7 @@ export const IndentFeature = (): FeatureProvider => { plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.IndentPlugin), position: 'normal', }, diff --git a/packages/richtext-lexical/src/field/features/lists/CheckList/index.ts b/packages/richtext-lexical/src/field/features/lists/CheckList/index.ts index 626676b42..96e5ead1f 100644 --- a/packages/richtext-lexical/src/field/features/lists/CheckList/index.ts +++ b/packages/richtext-lexical/src/field/features/lists/CheckList/index.ts @@ -18,7 +18,7 @@ export const CheckListFeature = (): FeatureProvider => { TextDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Checklist').then( (module) => module.ChecklistIcon, ), @@ -39,24 +39,24 @@ export const CheckListFeature = (): FeatureProvider => { ? [] : [ { + type: ListNode.getType(), converters: { html: ListHTMLConverter, }, node: ListNode, - type: ListNode.getType(), }, { + type: ListItemNode.getType(), converters: { html: ListItemHTMLConverter, }, node: ListItemNode, - type: ListItemNode.getType(), }, ], plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./plugin').then((module) => module.LexicalCheckListPlugin), position: 'normal', }, @@ -70,7 +70,7 @@ export const CheckListFeature = (): FeatureProvider => { options: [ new SlashMenuOption('checklist', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/Checklist').then( (module) => module.ChecklistIcon, ), diff --git a/packages/richtext-lexical/src/field/features/lists/CheckList/markdownTransformers.ts b/packages/richtext-lexical/src/field/features/lists/CheckList/markdownTransformers.ts index c8e7c29d0..2dede1ade 100644 --- a/packages/richtext-lexical/src/field/features/lists/CheckList/markdownTransformers.ts +++ b/packages/richtext-lexical/src/field/features/lists/CheckList/markdownTransformers.ts @@ -5,11 +5,11 @@ import { $isListNode, ListItemNode, ListNode } from '@lexical/list' import { listExport, listReplace } from '../common/markdown' export const CHECK_LIST: ElementTransformer = { + type: 'element', dependencies: [ListNode, ListItemNode], export: (node, exportChildren) => { return $isListNode(node) ? listExport(node, exportChildren, 0) : null }, regExp: /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i, replace: listReplace('check'), - type: 'element', } diff --git a/packages/richtext-lexical/src/field/features/lists/OrderedList/index.ts b/packages/richtext-lexical/src/field/features/lists/OrderedList/index.ts index 9a889f219..845fd99bc 100644 --- a/packages/richtext-lexical/src/field/features/lists/OrderedList/index.ts +++ b/packages/richtext-lexical/src/field/features/lists/OrderedList/index.ts @@ -16,7 +16,7 @@ export const OrderedListFeature = (): FeatureProvider => { TextDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/OrderedList').then( (module) => module.OrderedListIcon, ), @@ -36,18 +36,18 @@ export const OrderedListFeature = (): FeatureProvider => { ? [] : [ { + type: ListNode.getType(), converters: { html: ListHTMLConverter, }, node: ListNode, - type: ListNode.getType(), }, { + type: ListItemNode.getType(), converters: { html: ListItemHTMLConverter, }, node: ListItemNode, - type: ListItemNode.getType(), }, ], plugins: featureProviderMap.has('unorderedList') @@ -55,7 +55,7 @@ export const OrderedListFeature = (): FeatureProvider => { : [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../plugin').then((module) => module.LexicalListPlugin), position: 'normal', }, @@ -69,7 +69,7 @@ export const OrderedListFeature = (): FeatureProvider => { options: [ new SlashMenuOption('orderedlist', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/OrderedList').then( (module) => module.OrderedListIcon, ), diff --git a/packages/richtext-lexical/src/field/features/lists/OrderedList/markdownTransformer.ts b/packages/richtext-lexical/src/field/features/lists/OrderedList/markdownTransformer.ts index ac62d60a9..4205ff230 100644 --- a/packages/richtext-lexical/src/field/features/lists/OrderedList/markdownTransformer.ts +++ b/packages/richtext-lexical/src/field/features/lists/OrderedList/markdownTransformer.ts @@ -5,11 +5,11 @@ import { $isListNode, ListItemNode, ListNode } from '@lexical/list' import { listExport, listReplace } from '../common/markdown' export const ORDERED_LIST: ElementTransformer = { + type: 'element', dependencies: [ListNode, ListItemNode], export: (node, exportChildren) => { return $isListNode(node) ? listExport(node, exportChildren, 0) : null }, regExp: /^(\s*)(\d+)\.\s/, replace: listReplace('number'), - type: 'element', } diff --git a/packages/richtext-lexical/src/field/features/lists/UnorderedList/index.ts b/packages/richtext-lexical/src/field/features/lists/UnorderedList/index.ts index 73e243567..85c969102 100644 --- a/packages/richtext-lexical/src/field/features/lists/UnorderedList/index.ts +++ b/packages/richtext-lexical/src/field/features/lists/UnorderedList/index.ts @@ -16,7 +16,7 @@ export const UnorderedListFeature = (): FeatureProvider => { TextDropdownSectionWithEntries([ { ChildComponent: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/UnorderedList').then( (module) => module.UnorderedListIcon, ), @@ -34,24 +34,24 @@ export const UnorderedListFeature = (): FeatureProvider => { markdownTransformers: [UNORDERED_LIST], nodes: [ { + type: ListNode.getType(), converters: { html: ListHTMLConverter, }, node: ListNode, - type: ListNode.getType(), }, { + type: ListItemNode.getType(), converters: { html: ListItemHTMLConverter, }, node: ListItemNode, - type: ListItemNode.getType(), }, ], plugins: [ { Component: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../plugin').then((module) => module.LexicalListPlugin), position: 'normal', }, @@ -65,7 +65,7 @@ export const UnorderedListFeature = (): FeatureProvider => { options: [ new SlashMenuOption('unorderedlist', { Icon: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('../../../lexical/ui/icons/UnorderedList').then( (module) => module.UnorderedListIcon, ), diff --git a/packages/richtext-lexical/src/field/features/lists/UnorderedList/markdownTransformer.ts b/packages/richtext-lexical/src/field/features/lists/UnorderedList/markdownTransformer.ts index b5368e0a3..ca51588c4 100644 --- a/packages/richtext-lexical/src/field/features/lists/UnorderedList/markdownTransformer.ts +++ b/packages/richtext-lexical/src/field/features/lists/UnorderedList/markdownTransformer.ts @@ -5,11 +5,11 @@ import { $isListNode, ListItemNode, ListNode } from '@lexical/list' import { listExport, listReplace } from '../common/markdown' export const UNORDERED_LIST: ElementTransformer = { + type: 'element', dependencies: [ListNode, ListItemNode], export: (node, exportChildren) => { return $isListNode(node) ? listExport(node, exportChildren, 0) : null }, regExp: /^(\s*)[-*+]\s/, replace: listReplace('bullet'), - type: 'element', } diff --git a/packages/richtext-lexical/src/field/features/lists/common/markdown.ts b/packages/richtext-lexical/src/field/features/lists/common/markdown.ts index bfa841e56..f13afada3 100644 --- a/packages/richtext-lexical/src/field/features/lists/common/markdown.ts +++ b/packages/richtext-lexical/src/field/features/lists/common/markdown.ts @@ -63,8 +63,8 @@ export const listExport = ( listType === 'number' ? `${listNode.getStart() + index}. ` : listType === 'check' - ? `- [${listItemNode.getChecked() ? 'x' : ' '}] ` - : '- ' + ? `- [${listItemNode.getChecked() ? 'x' : ' '}] ` + : '- ' output.push(indent + prefix + exportChildren(listItemNode)) index++ } diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/heading.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/heading.ts index 056279cd5..ec785e5ef 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/heading.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/heading.ts @@ -8,12 +8,12 @@ export const HeadingConverter: LexicalPluginNodeConverter = { converter({ converters, lexicalPluginNode }) { return { ...lexicalPluginNode, + type: 'heading', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any).children || [], parentNodeType: 'heading', }), - type: 'heading', version: 1, } as const as SerializedHeadingNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/link.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/link.ts index 094efe73d..d9a5f393e 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/link.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/link.ts @@ -7,6 +7,7 @@ import { convertLexicalPluginNodesToLexical } from '..' export const LinkConverter: LexicalPluginNodeConverter = { converter({ converters, lexicalPluginNode }) { return { + type: 'link', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any).children || [], @@ -26,7 +27,6 @@ export const LinkConverter: LexicalPluginNodeConverter = { }, format: (lexicalPluginNode as any).format || '', indent: (lexicalPluginNode as any).indent || 0, - type: 'link', version: 2, } as const as SerializedLinkNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/list.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/list.ts index 9a7c41f99..59fb51b27 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/list.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/list.ts @@ -8,6 +8,7 @@ export const ListConverter: LexicalPluginNodeConverter = { converter({ converters, lexicalPluginNode }) { return { ...lexicalPluginNode, + type: 'list', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any).children || [], @@ -15,7 +16,6 @@ export const ListConverter: LexicalPluginNodeConverter = { }), listType: (lexicalPluginNode as any)?.listType || 'number', tag: (lexicalPluginNode as any)?.tag || 'ol', - type: 'list', version: 1, } as const as SerializedListNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/listItem.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/listItem.ts index 4c83af22d..d6b74a858 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/listItem.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/listItem.ts @@ -8,13 +8,13 @@ export const ListItemConverter: LexicalPluginNodeConverter = { converter({ childIndex, converters, lexicalPluginNode }) { return { ...lexicalPluginNode, + type: 'listitem', checked: undefined, children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any)?.children || [], parentNodeType: 'listitem', }), - type: 'listitem', value: childIndex + 1, version: 1, } as const as SerializedListItemNode diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/quote.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/quote.ts index cb6b956f9..4236699a1 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/quote.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/quote.ts @@ -8,12 +8,12 @@ export const QuoteConverter: LexicalPluginNodeConverter = { converter({ converters, lexicalPluginNode }) { return { ...lexicalPluginNode, + type: 'quote', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any).children || [], parentNodeType: 'quote', }), - type: 'quote', version: 1, } as const as SerializedHeadingNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/unknown.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/unknown.ts index d19b01555..8aea58067 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/unknown.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/unknown.ts @@ -6,6 +6,7 @@ import { convertLexicalPluginNodesToLexical } from '..' export const UnknownConverter: LexicalPluginNodeConverter = { converter({ converters, lexicalPluginNode }) { return { + type: 'unknownConverted', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (lexicalPluginNode as any)?.children || [], @@ -18,7 +19,6 @@ export const UnknownConverter: LexicalPluginNodeConverter = { direction: 'ltr', format: '', indent: 0, - type: 'unknownConverted', version: 1, } as const as SerializedUnknownConvertedNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/upload.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/upload.ts index 1a7f4753d..15be24132 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/upload.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/converters/upload.ts @@ -10,10 +10,10 @@ export const UploadConverter: LexicalPluginNodeConverter = { } } return { + type: 'upload', fields, format: (lexicalPluginNode as any)?.format || '', relationTo: (lexicalPluginNode as any)?.rawImagePayload?.relationTo, - type: 'upload', value: { id: (lexicalPluginNode as any)?.rawImagePayload?.value?.id || '', }, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/index.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/index.ts index 14cc19341..6840b8731 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/index.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/converter/index.ts @@ -16,6 +16,7 @@ export function convertLexicalPluginToLexical({ }): SerializedEditorState { return { root: { + type: 'root', children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: lexicalPluginData?.jsonContent?.root?.children || [], @@ -24,7 +25,6 @@ export function convertLexicalPluginToLexical({ direction: lexicalPluginData?.jsonContent?.root?.direction || 'ltr', format: lexicalPluginData?.jsonContent?.root?.format || '', indent: lexicalPluginData?.jsonContent?.root?.indent || 0, - type: 'root', version: 1, }, } @@ -79,13 +79,13 @@ export function convertParagraphNode( ): SerializedParagraphNode { return { ...node, + type: 'paragraph', + children: convertLexicalPluginNodesToLexical({ converters, lexicalPluginNodes: (node as any).children || [], parentNodeType: 'paragraph', }), - - type: 'paragraph', version: 1, } as SerializedParagraphNode } diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/index.ts b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/index.ts index 15cb3719a..e65062a7e 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/index.ts +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/index.ts @@ -44,8 +44,8 @@ export const LexicalPluginToLexicalFeature = (props?: Props): FeatureProvider => }, nodes: [ { - node: UnknownConvertedNode, type: UnknownConvertedNode.getType(), + node: UnknownConvertedNode, }, ], props, diff --git a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx index 758173405..376760cab 100644 --- a/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx +++ b/packages/richtext-lexical/src/field/features/migrations/LexicalPluginToLexical/nodes/unknownConvertedNode/index.tsx @@ -17,7 +17,7 @@ export type SerializedUnknownConvertedNode = Spread< > const Component = React.lazy(() => - // @ts-ignore-next-line TypeScript being dumb + // @ts-expect-error-next-line TypeScript being dumb import('./Component').then((module) => ({ default: module.UnknownConvertedNodeComponent, })), @@ -68,8 +68,8 @@ export class UnknownConvertedNode extends DecoratorNode { exportJSON(): SerializedUnknownConvertedNode { return { - data: this.__data, type: this.getType(), + data: this.__data, version: 1, } } diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/blockquote.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/blockquote.ts index 960f81ddc..eacda1c90 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/blockquote.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/blockquote.ts @@ -7,6 +7,7 @@ import { convertSlateNodesToLexical } from '../index' export const SlateBlockquoteConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'quote', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -16,7 +17,6 @@ export const SlateBlockquoteConverter: SlateNodeConverter = { direction: 'ltr', format: '', indent: 0, - type: 'quote', version: 1, } as const as SerializedQuoteNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/heading.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/heading.ts index ff9f988c7..290c37470 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/heading.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/heading.ts @@ -7,6 +7,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateHeadingConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'heading', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -17,7 +18,6 @@ export const SlateHeadingConverter: SlateNodeConverter = { format: '', indent: 0, tag: slateNode.type as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6', // Slate puts the tag (h1 / h2 / ...) inside of node.type - type: 'heading', version: 1, } as const as SerializedHeadingNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/indent.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/indent.ts index 0aadc1891..5641ca934 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/indent.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/indent.ts @@ -45,11 +45,11 @@ export const SlateIndentConverter: SlateNodeConverter = { const children = node.children.map((child: any) => convertChildren(child, indentLevel + 1)) console.log('slateToLexical > IndentConverter > children', JSON.stringify(children, null, 2)) return { + type: 'paragraph', children: children, direction: 'ltr', format: '', indent: indentLevel, - type: 'paragraph', version: 1, } as const as SerializedParagraphNode } diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/link.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/link.ts index ce780f3f0..91805d782 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/link.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/link.ts @@ -6,6 +6,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateLinkConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'link', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -22,7 +23,6 @@ export const SlateLinkConverter: SlateNodeConverter = { }, format: '', indent: 0, - type: 'link', version: 2, } as const as SerializedLinkNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/listItem.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/listItem.ts index 64365fbaa..d7905871a 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/listItem.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/listItem.ts @@ -7,6 +7,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateListItemConverter: SlateNodeConverter = { converter({ childIndex, converters, slateNode }) { return { + type: 'listitem', checked: undefined, children: convertSlateNodesToLexical({ canContainParagraphs: false, @@ -17,7 +18,6 @@ export const SlateListItemConverter: SlateNodeConverter = { direction: 'ltr', format: '', indent: 0, - type: 'listitem', value: childIndex + 1, version: 1, } as const as SerializedListItemNode diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/orderedList.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/orderedList.ts index 0014d97f4..7d34a27a2 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/orderedList.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/orderedList.ts @@ -7,6 +7,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateOrderedListConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'list', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -19,7 +20,6 @@ export const SlateOrderedListConverter: SlateNodeConverter = { listType: 'number', start: 1, tag: 'ol', - type: 'list', version: 1, } as const as SerializedListNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/relationship.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/relationship.ts index 18406e895..a2be41653 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/relationship.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/relationship.ts @@ -4,9 +4,9 @@ import type { SlateNodeConverter } from '../types' export const SlateRelationshipConverter: SlateNodeConverter = { converter({ slateNode }) { return { + type: 'relationship', format: '', relationTo: slateNode.relationTo, - type: 'relationship', value: { id: slateNode?.value?.id || '', }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unknown.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unknown.ts index 91a4ea890..8f239f122 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unknown.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unknown.ts @@ -6,6 +6,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateUnknownConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'unknownConverted', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -19,7 +20,6 @@ export const SlateUnknownConverter: SlateNodeConverter = { direction: 'ltr', format: '', indent: 0, - type: 'unknownConverted', version: 1, } as const as SerializedUnknownConvertedNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unorderedList.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unorderedList.ts index db530aa19..f68e4428d 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unorderedList.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/unorderedList.ts @@ -7,6 +7,7 @@ import { convertSlateNodesToLexical } from '..' export const SlateUnorderedListConverter: SlateNodeConverter = { converter({ converters, slateNode }) { return { + type: 'list', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -19,7 +20,6 @@ export const SlateUnorderedListConverter: SlateNodeConverter = { listType: 'bullet', start: 1, tag: 'ul', - type: 'list', version: 1, } as const as SerializedListNode }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/upload.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/upload.ts index ba4953462..64f35dabe 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/upload.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/converters/upload.ts @@ -4,12 +4,12 @@ import type { SlateNodeConverter } from '../types' export const SlateUploadConverter: SlateNodeConverter = { converter({ slateNode }) { return { + type: 'upload', fields: { ...slateNode.fields, }, format: '', relationTo: slateNode.relationTo, - type: 'upload', value: { id: slateNode.value?.id || '', }, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/index.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/index.ts index bf52b2ee4..77540de71 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/index.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/converter/index.ts @@ -18,6 +18,7 @@ export function convertSlateToLexical({ }): SerializedEditorState { return { root: { + type: 'root', children: convertSlateNodesToLexical({ canContainParagraphs: true, converters, @@ -27,7 +28,6 @@ export function convertSlateToLexical({ direction: 'ltr', format: '', indent: 0, - type: 'root', version: 1, }, } @@ -85,6 +85,7 @@ export function convertParagraphNode( node: SlateNode, ): SerializedParagraphNode { return { + type: 'paragraph', children: convertSlateNodesToLexical({ canContainParagraphs: false, converters, @@ -94,18 +95,17 @@ export function convertParagraphNode( direction: 'ltr', format: '', indent: 0, - type: 'paragraph', version: 1, } } export function convertTextNode(node: SlateNode): SerializedTextNode { return { + type: 'text', detail: 0, format: convertNodeToFormat(node), mode: 'normal', style: '', text: node.text, - type: 'text', version: 1, } } diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/index.ts b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/index.ts index a3752dd96..21d8573a6 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/index.ts +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/index.ts @@ -44,8 +44,8 @@ export const SlateToLexicalFeature = (props?: Props): FeatureProvider => { }, nodes: [ { - node: UnknownConvertedNode, type: UnknownConvertedNode.getType(), + node: UnknownConvertedNode, }, ], props, diff --git a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/nodes/unknownConvertedNode/index.tsx b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/nodes/unknownConvertedNode/index.tsx index 758173405..376760cab 100644 --- a/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/nodes/unknownConvertedNode/index.tsx +++ b/packages/richtext-lexical/src/field/features/migrations/SlateToLexical/nodes/unknownConvertedNode/index.tsx @@ -17,7 +17,7 @@ export type SerializedUnknownConvertedNode = Spread< > const Component = React.lazy(() => - // @ts-ignore-next-line TypeScript being dumb + // @ts-expect-error-next-line TypeScript being dumb import('./Component').then((module) => ({ default: module.UnknownConvertedNodeComponent, })), @@ -68,8 +68,8 @@ export class UnknownConvertedNode extends DecoratorNode { exportJSON(): SerializedUnknownConvertedNode { return { - data: this.__data, type: this.getType(), + data: this.__data, version: 1, } } diff --git a/packages/richtext-lexical/src/field/index.tsx b/packages/richtext-lexical/src/field/index.tsx index 13a87fde2..76d7fcf7c 100644 --- a/packages/richtext-lexical/src/field/index.tsx +++ b/packages/richtext-lexical/src/field/index.tsx @@ -4,7 +4,7 @@ import React, { Suspense, lazy } from 'react' import type { FieldProps } from '../types' -// @ts-ignore-next-line Just TypeScript being broken // TODO: Open TypeScript issue +// @ts-expect-error-next-line Just TypeScript being broken // TODO: Open TypeScript issue const RichTextEditor = lazy(() => import('./Field')) export const RichTextField: React.FC = (props) => { diff --git a/packages/richtext-lexical/src/field/lexical/config/default.ts b/packages/richtext-lexical/src/field/lexical/config/default.ts index e1d1709b8..5701c104e 100644 --- a/packages/richtext-lexical/src/field/lexical/config/default.ts +++ b/packages/richtext-lexical/src/field/lexical/config/default.ts @@ -46,7 +46,7 @@ export const defaultEditorFeatures: FeatureProvider[] = [ export const defaultEditorConfig: EditorConfig = { features: defaultEditorFeatures, lexical: () => - // @ts-ignore-next-line + // @ts-expect-error-next-line import('./defaultClient').then((module) => { const defaultEditorLexicalConfig = module.defaultEditorLexicalConfig return defaultEditorLexicalConfig diff --git a/packages/richtext-lexical/src/populate/defaultValue.ts b/packages/richtext-lexical/src/populate/defaultValue.ts index 128e00f42..727bb549b 100644 --- a/packages/richtext-lexical/src/populate/defaultValue.ts +++ b/packages/richtext-lexical/src/populate/defaultValue.ts @@ -2,50 +2,50 @@ import type { SerializedEditorState, SerializedParagraphNode, SerializedTextNode export const defaultRichTextValue: SerializedEditorState = { root: { + type: 'root', children: [ { + type: 'paragraph', children: [ { + type: 'text', detail: 0, format: 0, mode: 'normal', style: '', text: '', - type: 'text', version: 1, } as SerializedTextNode, ], direction: null, format: '', indent: 0, - type: 'paragraph', version: 1, } as SerializedParagraphNode, ], direction: null, format: '', indent: 0, - type: 'root', version: 1, }, } export const defaultRichTextValueV2: SerializedEditorState = { root: { + type: 'root', children: [ { + type: 'paragraph', children: [], direction: null, format: '', indent: 0, - type: 'paragraph', version: 1, } as SerializedParagraphNode, ], direction: null, format: '', indent: 0, - type: 'root', version: 1, }, } diff --git a/packages/richtext-slate/README.md b/packages/richtext-slate/README.md index 64534528b..879244e36 100644 --- a/packages/richtext-slate/README.md +++ b/packages/richtext-slate/README.md @@ -18,11 +18,9 @@ import { buildConfig } from 'payload/config' import { slateEditor } from '@payloadcms/richtext-slate' export default buildConfig({ - editor: slateEditor({}) + editor: slateEditor({}), // ...rest of config }) - ``` More detailed usage can be found in the [Payload Docs](https://payloadcms.com/docs/configuration/overview). - diff --git a/packages/richtext-slate/src/field/elements/Button.tsx b/packages/richtext-slate/src/field/elements/Button.tsx index 6927be59c..d2696b1d7 100644 --- a/packages/richtext-slate/src/field/elements/Button.tsx +++ b/packages/richtext-slate/src/field/elements/Button.tsx @@ -14,7 +14,7 @@ import toggleElement from './toggle' export const baseClass = 'rich-text__button' const ElementButton: React.FC = (props) => { - const { children, className, el = 'button', format, onClick, tooltip, type = 'type' } = props + const { type = 'type', children, className, el = 'button', format, onClick, tooltip } = props const editor = useSlate() const [showTooltip, setShowTooltip] = useState(false) diff --git a/packages/richtext-slate/src/field/elements/getCommonBlock.tsx b/packages/richtext-slate/src/field/elements/getCommonBlock.tsx index bd3d06d12..1e11ea4b9 100644 --- a/packages/richtext-slate/src/field/elements/getCommonBlock.tsx +++ b/packages/richtext-slate/src/field/elements/getCommonBlock.tsx @@ -12,7 +12,7 @@ export const getCommonBlock = (editor: Editor, match?: NodeMatch): NodeEnt const [common, path] = Node.common(editor, range.anchor.path, range.focus.path) // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @ts-expect-error if (isBlockElement(editor, common) || Editor.isEditor(common)) { return [common, path] } diff --git a/packages/richtext-slate/src/field/elements/indent/Button.tsx b/packages/richtext-slate/src/field/elements/indent/Button.tsx index 177058122..ace57f4a7 100644 --- a/packages/richtext-slate/src/field/elements/indent/Button.tsx +++ b/packages/richtext-slate/src/field/elements/indent/Button.tsx @@ -164,8 +164,8 @@ export const IndentButton: React.FC = () => { Transforms.wrapNodes( editor, { - children: [], type: isCurrentlyOL ? 'ol' : 'ul', + children: [], }, { match: (node) => Element.isElement(node) && node.type === 'li', @@ -177,8 +177,8 @@ export const IndentButton: React.FC = () => { Transforms.wrapNodes( editor, { - children: [{ children: [], type: 'li' }], type: isCurrentlyOL ? 'ol' : 'ul', + children: [{ type: 'li', children: [] }], }, { match: (node) => Element.isElement(node) && node.type === 'li', @@ -187,7 +187,7 @@ export const IndentButton: React.FC = () => { ) } } else { - Transforms.wrapNodes(editor, { children: [], type: indentType }) + Transforms.wrapNodes(editor, { type: indentType, children: [] }) } } diff --git a/packages/richtext-slate/src/field/elements/li/ListItem.tsx b/packages/richtext-slate/src/field/elements/li/ListItem.tsx index 8a7d3d4d2..2c4d59e6c 100644 --- a/packages/richtext-slate/src/field/elements/li/ListItem.tsx +++ b/packages/richtext-slate/src/field/elements/li/ListItem.tsx @@ -1,10 +1,11 @@ 'use client' +import type { Element } from 'slate' + import React, { isValidElement } from 'react' import { useElement } from '../../providers/ElementProvider' import listTypes from '../listTypes' -import { Element } from 'slate' export const ListItemElement: React.FC = () => { const { attributes, children, element } = useElement() diff --git a/packages/richtext-slate/src/field/elements/link/Button/index.tsx b/packages/richtext-slate/src/field/elements/link/Button/index.tsx index 6cc2184b5..835ded85a 100644 --- a/packages/richtext-slate/src/field/elements/link/Button/index.tsx +++ b/packages/richtext-slate/src/field/elements/link/Button/index.tsx @@ -32,12 +32,12 @@ const insertLink = (editor, fields) => { const data = reduceFieldsToValues(fields, true) const newLink = { + type: 'link', children: [], doc: data.doc, fields: data.fields, // Any custom user-added fields are part of data.fields linkType: data.linkType, newTab: data.newTab, - type: 'link', url: data.url, } diff --git a/packages/richtext-slate/src/field/elements/link/LinkDrawer/baseFields.ts b/packages/richtext-slate/src/field/elements/link/LinkDrawer/baseFields.ts index 8fefa1b7d..6dd9a6d63 100644 --- a/packages/richtext-slate/src/field/elements/link/LinkDrawer/baseFields.ts +++ b/packages/richtext-slate/src/field/elements/link/LinkDrawer/baseFields.ts @@ -18,12 +18,13 @@ const translations = extractTranslations([ export const getBaseFields = (config: Config): Field[] => [ { name: 'text', + type: 'text', label: translations['fields:textToDisplay'], required: true, - type: 'text', }, { name: 'linkType', + type: 'radio', admin: { description: translations['fields:chooseBetweenCustomTextOrDocument'], }, @@ -40,16 +41,15 @@ export const getBaseFields = (config: Config): Field[] => [ }, ], required: true, - type: 'radio', }, { name: 'url', + type: 'text', admin: { condition: ({ linkType }) => linkType !== 'internal', }, label: translations['fields:enterURL'], required: true, - type: 'text', }, { name: 'doc', @@ -59,6 +59,7 @@ export const getBaseFields = (config: Config): Field[] => [ }, }, // when admin.hidden is a function we need to dynamically call hidden with the user to know if the collection should be shown + type: 'relationship', filterOptions: ({ relationTo, user }) => { const hidden = config.collections.find(({ slug }) => slug === relationTo).admin.hidden if (typeof hidden === 'function' && hidden({ user } as { user: User })) { @@ -75,11 +76,10 @@ export const getBaseFields = (config: Config): Field[] => [ }) .map(({ slug }) => slug), required: true, - type: 'relationship', }, { name: 'newTab', - label: translations['fields:openInNewTab'], type: 'checkbox', + label: translations['fields:openInNewTab'], }, ] diff --git a/packages/richtext-slate/src/field/elements/link/types.ts b/packages/richtext-slate/src/field/elements/link/types.ts index 25fa7a4a5..8242f9f0d 100644 --- a/packages/richtext-slate/src/field/elements/link/types.ts +++ b/packages/richtext-slate/src/field/elements/link/types.ts @@ -1,4 +1,4 @@ -import { Element } from 'slate' +import type { Element } from 'slate' export type LinkElementType = Element & { doc: Record diff --git a/packages/richtext-slate/src/field/elements/ol/OrderedList.tsx b/packages/richtext-slate/src/field/elements/ol/OrderedList.tsx index 1f7d726a1..6bbac9f56 100644 --- a/packages/richtext-slate/src/field/elements/ol/OrderedList.tsx +++ b/packages/richtext-slate/src/field/elements/ol/OrderedList.tsx @@ -1,6 +1,7 @@ 'use client' import React from 'react' + import { useElement } from '../../providers/ElementProvider' import './index.scss' diff --git a/packages/richtext-slate/src/field/elements/relationship/Button/index.tsx b/packages/richtext-slate/src/field/elements/relationship/Button/index.tsx index df700786b..adb4ed839 100644 --- a/packages/richtext-slate/src/field/elements/relationship/Button/index.tsx +++ b/packages/richtext-slate/src/field/elements/relationship/Button/index.tsx @@ -16,9 +16,9 @@ const insertRelationship = (editor, { relationTo, value }) => { const text = { text: ' ' } const relationship = { + type: 'relationship', children: [text], relationTo, - type: 'relationship', value, } diff --git a/packages/richtext-slate/src/field/elements/relationship/Element/index.tsx b/packages/richtext-slate/src/field/elements/relationship/Element/index.tsx index 2b1547ad2..d376e8613 100644 --- a/packages/richtext-slate/src/field/elements/relationship/Element/index.tsx +++ b/packages/richtext-slate/src/field/elements/relationship/Element/index.tsx @@ -87,9 +87,9 @@ const Element: React.FC = () => { Transforms.setNodes( editor, { + type: 'relationship', children: [{ text: ' ' }], relationTo: relatedCollection.slug, - type: 'relationship', value: { id: doc.id }, }, { at: elementPath }, @@ -113,9 +113,9 @@ const Element: React.FC = () => { Transforms.setNodes( editor, { + type: 'relationship', children: [{ text: ' ' }], relationTo: collectionSlug, - type: 'relationship', value: { id: docID }, }, { at: elementPath }, diff --git a/packages/richtext-slate/src/field/elements/toggle.tsx b/packages/richtext-slate/src/field/elements/toggle.tsx index 94f829277..3d25dda9e 100644 --- a/packages/richtext-slate/src/field/elements/toggle.tsx +++ b/packages/richtext-slate/src/field/elements/toggle.tsx @@ -19,7 +19,7 @@ const toggleElement = (editor: Editor, format: string, blockType = 'type'): void } if (!isActive && isWithinLI && blockType !== 'textAlign') { - const block = { children: [], type: 'li' } + const block = { type: 'li', children: [] } Transforms.wrapNodes(editor, block, { at: Editor.unhangRange(editor, editor.selection), }) diff --git a/packages/richtext-slate/src/field/elements/toggleList.tsx b/packages/richtext-slate/src/field/elements/toggleList.tsx index d8576be3c..f97ed1201 100644 --- a/packages/richtext-slate/src/field/elements/toggleList.tsx +++ b/packages/richtext-slate/src/field/elements/toggleList.tsx @@ -49,7 +49,7 @@ const toggleList = (editor: Editor, format: string): void => { ) // Otherwise we can assume that we should just activate the list } else { - Transforms.wrapNodes(editor, { children: [], type: format }) + Transforms.wrapNodes(editor, { type: format, children: [] }) const [, parentNodePath] = getCommonBlock( editor, @@ -90,7 +90,7 @@ const toggleList = (editor: Editor, format: string): void => { ) nodesToWrap.forEach(([, path]) => { - Transforms.wrapNodes(editor, { children: [], type: 'li' }, { at: path }) + Transforms.wrapNodes(editor, { type: 'li', children: [] }, { at: path }) }) } diff --git a/packages/richtext-slate/src/field/elements/ul/UnorderedList.tsx b/packages/richtext-slate/src/field/elements/ul/UnorderedList.tsx index fa228cf3b..88dff7bf3 100644 --- a/packages/richtext-slate/src/field/elements/ul/UnorderedList.tsx +++ b/packages/richtext-slate/src/field/elements/ul/UnorderedList.tsx @@ -1,6 +1,7 @@ 'use client' import React from 'react' + import { useElement } from '../../providers/ElementProvider' import './index.scss' diff --git a/packages/richtext-slate/src/field/elements/upload/Button/index.tsx b/packages/richtext-slate/src/field/elements/upload/Button/index.tsx index 0ea9b66b3..a5c82ef43 100644 --- a/packages/richtext-slate/src/field/elements/upload/Button/index.tsx +++ b/packages/richtext-slate/src/field/elements/upload/Button/index.tsx @@ -16,9 +16,9 @@ const insertUpload = (editor, { relationTo, value }) => { const text = { text: ' ' } const upload = { + type: 'upload', children: [text], relationTo, - type: 'upload', value, } diff --git a/packages/richtext-slate/src/field/elements/upload/Element/index.tsx b/packages/richtext-slate/src/field/elements/upload/Element/index.tsx index 221b4889a..07526d5b4 100644 --- a/packages/richtext-slate/src/field/elements/upload/Element/index.tsx +++ b/packages/richtext-slate/src/field/elements/upload/Element/index.tsx @@ -118,9 +118,9 @@ const Element: React.FC = ({ const swapUpload = React.useCallback( ({ collectionSlug, docID }) => { const newNode = { + type: uploadName, children: [{ text: ' ' }], relationTo: collectionSlug, - type: uploadName, value: { id: docID }, } diff --git a/packages/richtext-slate/src/field/plugins/withHTML.tsx b/packages/richtext-slate/src/field/plugins/withHTML.tsx index 663201295..aa02cd4bf 100644 --- a/packages/richtext-slate/src/field/plugins/withHTML.tsx +++ b/packages/richtext-slate/src/field/plugins/withHTML.tsx @@ -3,8 +3,8 @@ import { jsx } from 'slate-hyperscript' const ELEMENT_TAGS = { A: (el) => ({ - newTab: el.getAttribute('target') === '_blank', type: 'link', + newTab: el.getAttribute('target') === '_blank', url: el.getAttribute('href'), }), BLOCKQUOTE: () => ({ type: 'blockquote' }),