mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
🐛 fix(editor-canvas): re-check editor init state before subscribing (#15686)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,14 @@ const useIsEditorInit = (editor?: IEditor) => {
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
|
||||
// The editor may have initialized between render and this effect
|
||||
// (the Editor canvas mounts earlier and emits 'initialized' synchronously),
|
||||
// so re-check before subscribing to avoid missing the event forever.
|
||||
if (editor.getLexicalEditor()) {
|
||||
setEditInit(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const onInit = () => {
|
||||
setEditInit(true);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user