From 9bd001a14bc3abe70f31a5b9b550bdc8ffc5d22a Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 7 Jul 2025 19:26:12 +0400 Subject: [PATCH] feat: note chat --- src/lib/components/channel/Channel.svelte | 2 +- .../components/channel/MessageInput.svelte | 172 +++++++----- src/lib/components/channel/Thread.svelte | 2 +- src/lib/components/notes/NoteEditor.svelte | 92 ++++--- .../components/notes/NoteEditor/Chat.svelte | 257 ++++++++++++++++++ .../notes/NoteEditor/Chat/Message.svelte | 52 ++++ .../notes/NoteEditor/Chat/Messages.svelte | 20 ++ .../notes/NoteEditor/Settings.svelte | 42 +++ src/lib/components/notes/NotePanel.svelte | 6 +- src/lib/components/playground/Chat.svelte | 65 +---- 10 files changed, 545 insertions(+), 165 deletions(-) create mode 100644 src/lib/components/notes/NoteEditor/Chat.svelte create mode 100644 src/lib/components/notes/NoteEditor/Chat/Message.svelte create mode 100644 src/lib/components/notes/NoteEditor/Chat/Messages.svelte create mode 100644 src/lib/components/notes/NoteEditor/Settings.svelte diff --git a/src/lib/components/channel/Channel.svelte b/src/lib/components/channel/Channel.svelte index 1b1ca25de1..57e66b6844 100644 --- a/src/lib/components/channel/Channel.svelte +++ b/src/lib/components/channel/Channel.svelte @@ -246,7 +246,7 @@ {/if} -
+
{}; + export let onChange: Function = (e) => {}; + export let onStop: Function = (e) => {}; - export let onSubmit: Function; - export let onChange: Function; export let scrollEnd = true; export let scrollToBottom: Function = () => {}; + export let acceptFiles = true; + const screenCaptureHandler = async () => { try { // Request screen media @@ -260,7 +265,7 @@ const onDrop = async (e) => { e.preventDefault(); - if (e.dataTransfer?.files) { + if (e.dataTransfer?.files && acceptFiles) { const inputFiles = Array.from(e.dataTransfer?.files); if (inputFiles && inputFiles.length > 0) { console.log(inputFiles); @@ -330,27 +335,30 @@ - { - if (inputFiles && inputFiles.length > 0) { - inputFilesHandler(Array.from(inputFiles)); - } else { - toast.error($i18n.t(`File not found.`)); - } +{#if acceptFiles} + { + if (inputFiles && inputFiles.length > 0) { + inputFilesHandler(Array.from(inputFiles)); + } else { + toast.error($i18n.t(`File not found.`)); + } + + filesInputElement.value = ''; + }} + /> +{/if} - filesInputElement.value = ''; - }} -/>
@@ -492,7 +500,7 @@
- { - filesInputElement.click(); - }} - > - - + + + {/if} +
@@ -620,31 +632,57 @@ {/if}
-
- - - -
+ + + + + +
+ {:else} +
+ + + +
+ {/if}
diff --git a/src/lib/components/channel/Thread.svelte b/src/lib/components/channel/Thread.svelte index 0b328dc236..89247fe586 100644 --- a/src/lib/components/channel/Thread.svelte +++ b/src/lib/components/channel/Thread.svelte @@ -196,7 +196,7 @@ }} /> -
+
diff --git a/src/lib/components/notes/NoteEditor.svelte b/src/lib/components/notes/NoteEditor.svelte index ff6a1faef9..2db1b33a84 100644 --- a/src/lib/components/notes/NoteEditor.svelte +++ b/src/lib/components/notes/NoteEditor.svelte @@ -99,6 +99,8 @@ let displayMediaRecord = false; let showPanel = false; + let selectedPanel = 'chat'; + let showDeleteConfirm = false; let dragged = false; @@ -677,6 +679,9 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings, import { PaneGroup, Pane, PaneResizer } from 'paneforge'; import XMark from '../icons/XMark.svelte'; import MenuLines from '../icons/MenuLines.svelte'; + import ChatBubbleOval from '../icons/ChatBubbleOval.svelte'; + import Settings from './NoteEditor/Settings.svelte'; + import Chat from './NoteEditor/Chat.svelte'; @@ -709,7 +714,7 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
+ + + + + + +
@@ -998,36 +1032,10 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
-
-
- -
- -
Settings
-
- -
-
-
Model
- -
- -
-
-
+ {#if selectedPanel === 'chat'} + + {:else if selectedPanel === 'settings'} + + {/if}
diff --git a/src/lib/components/notes/NoteEditor/Chat.svelte b/src/lib/components/notes/NoteEditor/Chat.svelte new file mode 100644 index 0000000000..27b26e0b88 --- /dev/null +++ b/src/lib/components/notes/NoteEditor/Chat.svelte @@ -0,0 +1,257 @@ + + +
+
+ +
+ +
+
+ {$i18n.t('Chat')} +
+ +
+ + ({$i18n.t('Experimental')}) + +
+
+
+ +
+
+
+
+ + +
+ +
+ +
+
+
+
+
+
+
diff --git a/src/lib/components/notes/NoteEditor/Chat/Message.svelte b/src/lib/components/notes/NoteEditor/Chat/Message.svelte new file mode 100644 index 0000000000..d3e686312b --- /dev/null +++ b/src/lib/components/notes/NoteEditor/Chat/Message.svelte @@ -0,0 +1,52 @@ + + +
+
+
+ {$i18n.t(message.role)} +
+
+ +
+ + +