mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-18 19:29:11 -05:00
refac
This commit is contained in:
@@ -302,6 +302,8 @@
|
||||
let bubbleMenuElement: Element | null = null;
|
||||
let element: Element | null = null;
|
||||
|
||||
let pendingUpdate = null;
|
||||
|
||||
const options = {
|
||||
throwOnError: false
|
||||
};
|
||||
@@ -866,10 +868,19 @@
|
||||
content: collaboration ? undefined : content,
|
||||
autofocus: messageInput ? true : false,
|
||||
onTransaction: () => {
|
||||
// force re-render so `editor.isActive` works as expected
|
||||
editor = editor;
|
||||
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();
|
||||
jsonValue = editor.getJSON();
|
||||
|
||||
@@ -1234,6 +1245,10 @@
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (pendingUpdate) {
|
||||
cancelAnimationFrame(pendingUpdate);
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
provider.destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user