Timothy Jaeryang Baek 2 hónapja
szülő
commit
c94ce71ca3

+ 10 - 6
src/lib/components/notes/NoteEditor.svelte

@@ -1193,23 +1193,27 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
 							bind:value={note.data.content.json}
 							html={note.data?.content?.html}
 							documentId={`note:${note.id}`}
-							{files}
 							collaboration={true}
 							socket={$socket}
 							user={$user}
 							link={true}
 							image={true}
+							{files}
 							placeholder={$i18n.t('Write something...')}
 							editable={versionIdx === null && !editing}
 							onSelectionUpdate={({ editor }) => {
 								const { from, to } = editor.state.selection;
 								const selectedText = editor.state.doc.textBetween(from, to, ' ');
 
-								selectedContent = {
-									text: selectedText,
-									from: from,
-									to: to
-								};
+								if (selectedText.length === 0) {
+									selectedContent = null;
+								} else {
+									selectedContent = {
+										text: selectedText,
+										from: from,
+										to: to
+									};
+								}
 							}}
 							onChange={(content) => {
 								note.data.content.html = content.html;

+ 4 - 5
src/lib/components/notes/NoteEditor/Chat.svelte

@@ -232,7 +232,7 @@ Based on the user's instruction, update and enhance the existing notes or select
 								if (editEnabled) {
 									responseMessage.content = `<status title="${$i18n.t('Edited')}" done="true" />`;
 
-									if (selectedContent && editor) {
+									if (selectedContent && selectedContent?.text && editor) {
 										editor.commands.insertContentAt(
 											{
 												from: selectedContent.from,
@@ -262,16 +262,15 @@ Based on the user's instruction, update and enhance the existing notes or select
 										enhancedContent.md += deltaContent;
 										enhancedContent.html = marked.parse(enhancedContent.md);
 
-										if (!selectedContent) {
+										if (!selectedContent || !selectedContent?.text) {
 											note.data.content.md = enhancedContent.md;
 											note.data.content.html = enhancedContent.html;
 											note.data.content.json = null;
-
-											scrollToBottomHandler();
 										}
 
-										responseMessage.content = `<status title="${$i18n.t('Editing')}" done="false" />`;
+										scrollToBottomHandler();
 
+										responseMessage.content = `<status title="${$i18n.t('Editing')}" done="false" />`;
 										messages = messages;
 									} else {
 										messageContent += deltaContent;