|
@@ -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);
|
|
|
}}
|