Skip to content

Nested Editor - how children editor trigger parent edtor update? #6832

Closed Answered by emsurezhang
emsurezhang asked this question in Q&A
Discussion options

You must be logged in to vote

I found there is a function getNearestEditorFromDOMNode which can help me got parent Editor from DOM.
so I write AutoSavingPlugin for both parent editor and child editor.

parent editor

  1. autosave by OnChangePlugin;
  2. add 'UPDATE_BY_CHILD_COMMAND' COMMAND;

child editor

  1. got RootElement 's parent DOM node;
  2. call getNearestEditorFromDOMNode;
  3. got parent Editor and dispatch 'UPDATE_BY_CHILD_COMMAND' trigger parent saving function.
import { useDebouncedCallback } from "./useDebouncedCallback";
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
import { EditorState, LexicalEditor, getNearestEditorFromDOMNode, LexicalCommand, createCommand, COMMAND_PRIORITY_EDITOR } from "lexica…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by emsurezhang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant