chore: upgrade lexical & make linting/formatting consistent with web codebase (#2144)
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
import {FunctionComponent} from 'react';
|
||||
import {LexicalComposer} from '@lexical/react/LexicalComposer';
|
||||
import BlocksEditorTheme from '../Lexical/Theme/Theme';
|
||||
import {BlockEditorNodes} from '../Lexical/Nodes/AllNodes';
|
||||
import {Klass, LexicalNode} from 'lexical';
|
||||
import { FunctionComponent } from 'react'
|
||||
import { LexicalComposer } from '@lexical/react/LexicalComposer'
|
||||
import BlocksEditorTheme from '../Lexical/Theme/Theme'
|
||||
import { BlockEditorNodes } from '../Lexical/Nodes/AllNodes'
|
||||
import { Klass, LexicalNode } from 'lexical'
|
||||
|
||||
type BlocksEditorComposerProps = {
|
||||
initialValue: string | undefined;
|
||||
children: React.ReactNode;
|
||||
nodes?: Array<Klass<LexicalNode>>;
|
||||
readonly?: boolean;
|
||||
};
|
||||
initialValue: string | undefined
|
||||
children: React.ReactNode
|
||||
nodes?: Array<Klass<LexicalNode>>
|
||||
readonly?: boolean
|
||||
}
|
||||
|
||||
export const BlocksEditorComposer: FunctionComponent<
|
||||
BlocksEditorComposerProps
|
||||
> = ({initialValue, children, readonly, nodes = []}) => {
|
||||
export const BlocksEditorComposer: FunctionComponent<BlocksEditorComposerProps> = ({
|
||||
initialValue,
|
||||
children,
|
||||
readonly,
|
||||
nodes = [],
|
||||
}) => {
|
||||
return (
|
||||
<LexicalComposer
|
||||
initialConfig={{
|
||||
@@ -21,11 +24,11 @@ export const BlocksEditorComposer: FunctionComponent<
|
||||
theme: BlocksEditorTheme,
|
||||
editable: !readonly,
|
||||
onError: (error: Error) => console.error(error),
|
||||
editorState:
|
||||
initialValue && initialValue.length > 0 ? initialValue : undefined,
|
||||
editorState: initialValue && initialValue.length > 0 ? initialValue : undefined,
|
||||
nodes: [...nodes, ...BlockEditorNodes],
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
<>{children}</>
|
||||
</LexicalComposer>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user