diff --git a/package-lock.json b/package-lock.json index 3b15cb1..db06df2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,6 +34,7 @@ "svelte-highlight": "^7.2.1", "svelte-local-storage-store": "^0.4.0", "svelte-markdown": "^0.2.3", + "svelte-modals": "^1.2.1", "svelte-spa-router": "^3.3.0", "svelte-use-click-outside": "^1.0.0", "tslib": "^2.5.0", @@ -4186,6 +4187,15 @@ "integrity": "sha512-vSSbKZFbNktrQ15v7o1EaH78EbWV+sPQbPjHG+Cp8CaNcPFUEfjZ0Iml/V0bFDwsTlYe8o6XC5Hfdp91cqPV2g==", "dev": true }, + "node_modules/svelte-modals": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/svelte-modals/-/svelte-modals-1.2.1.tgz", + "integrity": "sha512-7MEKUx5wb5YppkXWFGeRlYM5FMGEnpix39u9Y6GtCNTMXRDZ7DB2Z50IYLMRTMW5lOsCdtJgFbB0E3iZMKmsAA==", + "dev": true, + "peerDependencies": { + "svelte": "^3.0.0" + } + }, "node_modules/svelte-preprocess": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/svelte-preprocess/-/svelte-preprocess-5.0.3.tgz", diff --git a/package.json b/package.json index f65ad40..04c3e36 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "svelte-highlight": "^7.2.1", "svelte-local-storage-store": "^0.4.0", "svelte-markdown": "^0.2.3", + "svelte-modals": "^1.2.1", "svelte-spa-router": "^3.3.0", "svelte-use-click-outside": "^1.0.0", "tslib": "^2.5.0", diff --git a/src/App.svelte b/src/App.svelte index 0e2c734..ee62ee6 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -8,6 +8,7 @@ import Chat from './lib/Chat.svelte' import NewChat from './lib/NewChat.svelte' import { chatsStorage, apiKeyStorage } from './lib/Storage.svelte' + import { Modals, closeModal } from 'svelte-modals' // The definition of the routes with some conditions const routes = { @@ -31,7 +32,6 @@ } - + + + +
+ + + diff --git a/src/app.scss b/src/app.scss index 5658593..f16b743 100644 --- a/src/app.scss +++ b/src/app.scss @@ -60,7 +60,7 @@ html { } @media screen and (min-width: 1024px) { - .modal-card { + .modal-card.wide { width: 960px !important; } } diff --git a/src/lib/Chat.svelte b/src/lib/Chat.svelte index 65f70c5..559c488 100644 --- a/src/lib/Chat.svelte +++ b/src/lib/Chat.svelte @@ -40,6 +40,8 @@ import { autoGrowInputOnEvent, sizeTextElements } from './Util.svelte' import ChatSettingsModal from './ChatSettingsModal.svelte' import Footer from './Footer.svelte' + import { openModal } from 'svelte-modals' + import PromptInput from './PromptInput.svelte' // This makes it possible to override the OpenAI API base URL in the .env file const apiBase = import.meta.env.VITE_API_BASE || 'https://api.openai.com' @@ -51,7 +53,7 @@ let updatingMessage: string = '' let input: HTMLTextAreaElement // let settings: HTMLDivElement - let chatNameSettings: HTMLFormElement + // let chatNameSettings: HTMLFormElement let recognition: any = null let recording = false @@ -469,24 +471,16 @@ } } - const showChatNameSettings = () => { - chatNameSettings.classList.add('is-active'); - (chatNameSettings.querySelector('#settings-chat-name') as HTMLInputElement).focus(); - (chatNameSettings.querySelector('#settings-chat-name') as HTMLInputElement).select() - } - - const saveChatNameSettings = () => { - const newChatName = (chatNameSettings.querySelector('#settings-chat-name') as HTMLInputElement).value - // save if changed - if (newChatName && newChatName !== chat.name) { - chat.name = newChatName - chatsStorage.set($chatsStorage) - } - closeChatNameSettings() - } - - const closeChatNameSettings = () => { - chatNameSettings.classList.remove('is-active') + function promptRename () { + openModal(PromptInput, { + title: 'Enter Name for Chat', + label: 'Name', + value: chat.name, + onSubmit: (value) => { + chat.name = (value || '').trim() || chat.name + $checkStateChange++ + } + }) } const recordToggle = () => { @@ -503,48 +497,13 @@ - - -