Skip to content

Commit

Permalink
[lexical-react] remove editor__DEPRECATED that has been deprecated fo…
Browse files Browse the repository at this point in the history
…r two years (#6494)
  • Loading branch information
etrepum committed Aug 13, 2024
1 parent 43caf29 commit 21e50ad
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
.ts-temp
**/.docusaurus
/playwright-report
test-results
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ flow-typed
.prettierignore
**/.docusaurus
/playwright-report
test-results
1 change: 0 additions & 1 deletion packages/lexical-react/flow/LexicalComposer.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type InitialEditorStateType =
| ((editor: LexicalEditor) => void);

export type InitialConfigType = $ReadOnly<{
editor__DEPRECATED?: LexicalEditor | null,
editable?: boolean,
namespace: string,
nodes?: $ReadOnlyArray<Class<LexicalNode> | LexicalNodeReplacement>,
Expand Down
1 change: 0 additions & 1 deletion packages/lexical-react/flow/LexicalContentEditable.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export type PlaceholderProps =

export type Props = $ReadOnly<{
...HTMLDivElementDOMProps,
editor__DEPRECATED?: LexicalEditor;
ariaActiveDescendant?: string,
ariaAutoComplete?: string,
ariaControls?: string,
Expand Down
26 changes: 9 additions & 17 deletions packages/lexical-react/src/LexicalComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export type InitialEditorStateType =
| ((editor: LexicalEditor) => void);

export type InitialConfigType = Readonly<{
editor__DEPRECATED?: LexicalEditor | null;
namespace: string;
nodes?: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;
onError: (error: Error, editor: LexicalEditor) => void;
Expand All @@ -59,7 +58,6 @@ export function LexicalComposer({initialConfig, children}: Props): JSX.Element {
const {
theme,
namespace,
editor__DEPRECATED: initialEditor,
nodes,
onError,
editorState: initialEditorState,
Expand All @@ -71,21 +69,15 @@ export function LexicalComposer({initialConfig, children}: Props): JSX.Element {
theme,
);

let editor = initialEditor || null;

if (editor === null) {
const newEditor = createEditor({
editable: initialConfig.editable,
html,
namespace,
nodes,
onError: (error) => onError(error, newEditor),
theme,
});
initializeEditor(newEditor, initialEditorState);

editor = newEditor;
}
const editor = createEditor({
editable: initialConfig.editable,
html,
namespace,
nodes,
onError: (error) => onError(error, editor),
theme,
});
initializeEditor(editor, initialEditorState);

return [editor, context];
},
Expand Down
11 changes: 4 additions & 7 deletions packages/lexical-react/src/LexicalContentEditable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import {forwardRef, Ref, useLayoutEffect, useState} from 'react';
import {ContentEditableElement} from './shared/LexicalContentEditableElement';
import {useCanShowPlaceholder} from './shared/useCanShowPlaceholder';

export type Props = Omit<ElementProps, 'editor'> & {
editor__DEPRECATED?: LexicalEditor;
} & (
export type Props = Omit<ElementProps, 'editor'> &
(
| {
'aria-placeholder'?: void;
placeholder?: null;
Expand All @@ -36,10 +35,8 @@ function ContentEditableImpl(
props: Props,
ref: Ref<HTMLDivElement>,
): JSX.Element {
const {placeholder, editor__DEPRECATED, ...rest} = props;
// editor__DEPRECATED will always be defined for non MLC surfaces
// eslint-disable-next-line react-hooks/rules-of-hooks
const editor = editor__DEPRECATED || useLexicalComposerContext()[0];
const {placeholder, ...rest} = props;
const [editor] = useLexicalComposerContext();

return (
<>
Expand Down

0 comments on commit 21e50ad

Please sign in to comment.