Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| onError: (error) => onError(error, newEditor), | ||
| readOnly: true, | ||
| theme, | ||
| serializer: new BaseSerializer<>(), |
There was a problem hiding this comment.
I kind of accidentally left this in here - probably should plumb it through props or something?
| * | ||
| */ | ||
|
|
||
| import {initializeUnitTest} from '../../../../lexical/src/__tests__/utils'; |
There was a problem hiding this comment.
should be able to use absolute path here
| }); | ||
| } | ||
|
|
||
| export function $deserializeRoot< |
There was a problem hiding this comment.
This shouldn't mutate the existing editor state, or trigger an update. It should return a fresh new EditorState with the nodes added in.
| 'Serializer not defined. You can pass a new serializer via EditorConfig -> createEditor({ serializer })', | ||
| ); | ||
| } | ||
| return editor.getEditorState().read(() => { |
There was a problem hiding this comment.
It should allow to pass in an editorState as an argument too.
|
|
||
| export function $serializeRootNode<SerializedNode>( | ||
| node: RootNode, | ||
| serializeChild: (node: LexicalNode) => SerializedNode, |
There was a problem hiding this comment.
Not sure we should be passing this to $serializeRootNode, children should be handled by the serializer directly, as if we have deep = false then we might only want the root node and none of its children (for collab).
| pendingEditorState._flushSync = true; | ||
| editor._dirtyType = FULL_RECONCILE; | ||
| editor._compositionKey = null; | ||
| editor.update(() => { |
There was a problem hiding this comment.
Should we being any update in $serializeRoot. Isn't the intention to return a fresh EditorState?
|
I also think it's important that each |
Shouldn't it be the responsibility of each node to understand whether to process children? |
|
I don't think so. Its children should be formed by the tree logic. This is important if certain children should be skipped or re-ordered etc |
| // No need .deserialize already does that | ||
| // $getRoot().markDirty(); // Create pendingEditorState | ||
| const serializedRootNode = json; | ||
| return createEditorState(editor, (pendingEditorState: EditorState) => { |
There was a problem hiding this comment.
Make it should be called internalCreateEditorState, so people don't use it elsewhere lol
|
|
||
| export function createEditorState( | ||
| editor: LexicalEditor, | ||
| updateFn: (pendingEditorState: EditorState) => void, |
There was a problem hiding this comment.
Instead of passing in pendingEditorState, you could have the expectation for it to return the RootNode instead?
createRootFn: () => RootNode
No description provided.