-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow saving Monaco viewstates so they can be restored on re-open. #42
Conversation
if (appStateFile == null) { | ||
return; | ||
} | ||
|
||
await appStateFile.update(appState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No logic changed here. Just doing some cleanup.
useEffect(() => { | ||
store.on("editor.boldSelectedText", boldSelectedText); | ||
store.on("editor.italicSelectedText", italicSelectedText); | ||
store.on("editor.setModelViewState", setModelViewState); | ||
|
||
return () => { | ||
store.off("editor.boldSelectedText", boldSelectedText); | ||
store.off("editor.italicSelectedText", italicSelectedText); | ||
store.off("editor.setModelViewState", setModelViewState); | ||
}; | ||
}, [store]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks our pattern of subscribing to events at the bottom of the component but I'm not sure of a better way forward.
Depending on the situation we may trigger setModelViewState
on the first render so if we set up the listener at the bottom of the component the store throws an error due to not finding the listener.
Maybe we just leave as-is for now? I don't think it's worth changing the pattern yet.
// dragenter and dragover have to be cancelled in order for the drop event | ||
// to work on a div. | ||
const dragEnter = (ev: DragEvent) => { | ||
ev.stopPropagation(); | ||
ev.preventDefault(); | ||
}; | ||
const dragOver = (ev: DragEvent) => { | ||
ev.stopPropagation(); | ||
ev.preventDefault(); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were pulled into the useEffect
hook to avoid regenerating them each render.
deepUpdate
now handles objects with circular references pointing to parents, and also can ignore specific paths.cache
in the front end store that lets us save data without triggering re-renders.setModel()
on Monaco to improve performance.Editor
component.