refac
This commit is contained in:
1 parent
ee3b82926b
commit
794b97025d
1 file changed
+17
-2
@@ -302,6 +302,8 @@
|
|||||||
let bubbleMenuElement: Element | null = null;
|
let bubbleMenuElement: Element | null = null;
|
||||||
let element: Element | null = null;
|
let element: Element | null = null;
|
||||||
|
|
||||||
|
let pendingUpdate = null;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
throwOnError: false
|
throwOnError: false
|
||||||
};
|
};
|
||||||
@@ -866,10 +868,19 @@
|
|||||||
content: collaboration ? undefined : content,
|
content: collaboration ? undefined : content,
|
||||||
autofocus: messageInput ? true : false,
|
autofocus: messageInput ? true : false,
|
||||||
onTransaction: () => {
|
onTransaction: () => {
|
||||||
// force re-render so `editor.isActive` works as expected
|
|
||||||
editor = editor;
|
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
|
|
||||||
|
// Defer Svelte reactivity trigger to rAF so we don't interleave
|
||||||
|
// DOM reads/writes with ProseMirror's updateStateInner.
|
||||||
|
if (!pendingUpdate) {
|
||||||
|
pendingUpdate = requestAnimationFrame(() => {
|
||||||
|
pendingUpdate = null;
|
||||||
|
if (editor && !editor.isDestroyed) {
|
||||||
|
editor = editor;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
htmlValue = editor.getHTML();
|
htmlValue = editor.getHTML();
|
||||||
jsonValue = editor.getJSON();
|
jsonValue = editor.getJSON();
|
||||||
|
|
||||||
@@ -1234,6 +1245,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
if (pendingUpdate) {
|
||||||
|
cancelAnimationFrame(pendingUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
if (provider) {
|
if (provider) {
|
||||||
provider.destroy();
|
provider.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user