Merge pull request #343 from lfnovo/fix/note-editor-fullscreen-observer-optimization
fix(ui): optimize MutationObserver in NoteEditorDialog
This commit is contained in:
commit
040cfbad88
1 changed files with 4 additions and 2 deletions
|
|
@ -70,12 +70,14 @@ export function NoteEditorDialog({ open, onOpenChange, notebookId, note }: NoteE
|
||||||
}, [open, note, fetchedNote, reset])
|
}, [open, note, fetchedNote, reset])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!open) return
|
||||||
|
|
||||||
const observer = new MutationObserver(() => {
|
const observer = new MutationObserver(() => {
|
||||||
setIsEditorFullscreen(!!document.querySelector('.w-md-editor-fullscreen'))
|
setIsEditorFullscreen(!!document.querySelector('.w-md-editor-fullscreen'))
|
||||||
})
|
})
|
||||||
observer.observe(document.body, {subtree: true, attributes: true, attributeFilter: ['class']})
|
observer.observe(document.body, { subtree: true, attributes: true, attributeFilter: ['class'] })
|
||||||
return () => observer.disconnect()
|
return () => observer.disconnect()
|
||||||
}, [])
|
}, [open])
|
||||||
|
|
||||||
const onSubmit = async (data: CreateNoteFormData) => {
|
const onSubmit = async (data: CreateNoteFormData) => {
|
||||||
if (note) {
|
if (note) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue