Browse Source

refac: note revision history

Timothy Jaeryang Baek 3 months ago
parent
commit
74cafce4d2

+ 4 - 0
src/lib/components/notes/NoteEditor.svelte

@@ -665,6 +665,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
 	};
 
 	const insertHandler = (content) => {
+		insertNoteVersion(note);
 		inputElement?.insertContent(content);
 	};
 
@@ -1075,6 +1076,9 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
 				{files}
 				onInsert={insertHandler}
 				onStop={stopResponseHandler}
+				insertNoteHandler={() => {
+					insertNoteVersion(note);
+				}}
 				scrollToBottomHandler={scrollToBottom}
 			/>
 		{:else if selectedPanel === 'settings'}

+ 7 - 0
src/lib/components/notes/NoteEditor/Chat.svelte

@@ -40,6 +40,8 @@
 
 	export let onInsert = (content) => {};
 	export let onStop = () => {};
+
+	export let insertNoteHandler = () => {};
 	export let scrollToBottomHandler = () => {};
 
 	let loaded = false;
@@ -253,6 +255,11 @@ Based on the user's instruction, update and enhance the existing notes by incorp
 			scrollToBottom();
 
 			loading = true;
+
+			if (editorEnabled) {
+				insertNoteHandler();
+			}
+
 			await chatCompletionHandler();
 			messages = messages.map((message) => {
 				message.done = true;