This commit is contained in:
Timothy Jaeryang Baek 2025-07-12 02:17:52 +04:00
parent 3c80219808
commit baa1a44397
2 changed files with 22 additions and 14 deletions

View file

@ -123,7 +123,7 @@
let dragged = false;
let loading = false;
let enhancing = false;
let editing = false;
let streaming = false;
let stopResponseFlag = false;
@ -190,6 +190,11 @@
return false;
}
const onEdited = async () => {
if (!editor) return;
editor.commands.setContent(note.data.content.html);
};
async function enhanceNoteHandler() {
if (selectedModelId === '') {
toast.error($i18n.t('Please select a model.'));
@ -205,12 +210,11 @@
return;
}
enhancing = true;
insertNoteVersion(note);
editing = true;
await enhanceCompletionHandler(model);
editing = false;
enhancing = false;
onEdited();
versionIdx = null;
}
@ -591,7 +595,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
controller.abort('User: Stop Response');
}
enhancing = false;
editing = false;
streaming = false;
break;
}
@ -930,7 +934,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
class=" flex-1 w-full h-full overflow-auto px-3.5 pb-20 relative pt-2.5"
id="note-content-container"
>
{#if enhancing}
{#if editing}
<div
class="w-full h-full fixed top-0 left-0 {streaming
? ''
@ -985,7 +989,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
user={$user}
link={true}
placeholder={$i18n.t('Write something...')}
editable={versionIdx === null && !enhancing}
editable={versionIdx === null && !editing}
onChange={(content) => {
note.data.content.html = content.html;
note.data.content.md = content.md;
@ -1100,7 +1104,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
</Tooltip> -->
<Tooltip content={$i18n.t('Enhance')} placement="top">
{#if enhancing}
{#if editing}
<button
class="p-2 flex justify-center items-center hover:bg-gray-50 dark:hover:bg-gray-800 rounded-full transition shrink-0"
on:click={() => {
@ -1116,7 +1120,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
on:click={() => {
enhanceNoteHandler();
}}
disabled={enhancing}
disabled={editing}
type="button"
>
<SparklesSolid />
@ -1135,12 +1139,13 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
bind:selectedModelId
bind:messages
bind:note
bind:enhancing
bind:editing
bind:streaming
bind:stopResponseFlag
{files}
onInsert={insertHandler}
onStop={stopResponseHandler}
{onEdited}
insertNoteHandler={() => {
insertNoteVersion(note);
}}

View file

@ -56,7 +56,7 @@
const i18n = getContext('i18n');
export let enhancing = false;
export let editing = false;
export let streaming = false;
export let stopResponseFlag = false;
@ -67,6 +67,7 @@
export let onInsert = (content) => {};
export let onStop = () => {};
export let onEdited = () => {};
export let insertNoteHandler = () => {};
export let scrollToBottomHandler = () => {};
@ -205,9 +206,11 @@ Based on the user's instruction, update and enhance the existing notes by incorp
}
if (editorEnabled) {
enhancing = false;
editing = false;
streaming = false;
onEdited();
}
break;
}
@ -233,7 +236,7 @@ Based on the user's instruction, update and enhance the existing notes by incorp
continue;
} else {
if (editorEnabled) {
enhancing = true;
editing = true;
streaming = true;
enhancedContent.md += deltaContent;