Skip to content

Commit

Permalink
Update error message and docs (facebook#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegreatercurve authored Jun 22, 2022
1 parent 49875cc commit c5307bf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/lexical-markdown/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ editor.update(() => {

It can also be used for initializing editor's state from markdown string. Here's an example with react `<RichTextPlugin>`
```jsx
<LexicalComposer initialEditorState={() => {
$convertFromMarkdownString(markdown, TRANSFORMERS);
}}>
<LexicalComposer initialConfig={{
editorState: () => $convertFromMarkdownString(markdown, TRANSFORMERS)
}}>
<RichTextPlugin />
</LexicalComposer>
```
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-react/src/LexicalPlainTextPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {useDecorators} from './shared/useDecorators';
import {usePlainTextSetup} from './shared/usePlainTextSetup';

const deprecatedInitialEditorStateWarning = warnOnlyOnce(
'initialEditorState on PlainTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.',
'`initialEditorState` on `PlainTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.',
);

export function PlainTextPlugin({
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-react/src/LexicalRichTextPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {useDecorators} from './shared/useDecorators';
import {useRichTextSetup} from './shared/useRichTextSetup';

const deprecatedInitialEditorStateWarning = warnOnlyOnce(
'initialEditorState on RichTextPlugin is deprecated and will be removed soon. Use LexicalComposer initialEditorState instead.',
'`initialEditorState` on `RichTextPlugin` is deprecated and will be removed soon. Use the `initialConfig.editorState` prop on the `LexicalComposer` instead.',
);

export function RichTextPlugin({
Expand Down
6 changes: 4 additions & 2 deletions packages/lexical-website-new/docs/concepts/editor-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ For React it could be something following:
const initialEditorState = await loadContent();
const editorStateRef = useRef();

<LexicalComposer initialEditorState={initialEditorState}>
<LexicalComposer initialConfig={{
editorState: initialEditorState
}}>
<LexicalRichTextPlugin />
<LexicalOnChangePlugin onChange={editorState => editorStateRef.current = editorState} />
<Button label="Save" onPress={() => {
Expand All @@ -58,7 +60,7 @@ const editorStateRef = useRef();
</LexicalComposer>
```

Note that Lexical uses `initialEditorState` only once (when it's being initialized) and passing different value later
Note that Lexical uses `initialConfig.editorState` only once (when it's being initialized) and passing different value later
won't be reflected in editor. See "Update state" below for proper ways of updating editor state.

## Updating state
Expand Down

0 comments on commit c5307bf

Please sign in to comment.