diff --git a/src/lib/components/notes/NoteEditor.svelte b/src/lib/components/notes/NoteEditor.svelte
index 3b6d58d7ad..9382ccc1d1 100644
--- a/src/lib/components/notes/NoteEditor.svelte
+++ b/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;
diff --git a/src/lib/components/notes/NoteEditor/Chat.svelte b/src/lib/components/notes/NoteEditor/Chat.svelte
index d9d86b597d..12eac0fb69 100644
--- a/src/lib/components/notes/NoteEditor/Chat.svelte
+++ b/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 = ``;
- 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 = ``;
+ scrollToBottomHandler();
+ responseMessage.content = ``;
messages = messages;
} else {
messageContent += deltaContent;