mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 12:25:20 +00:00
enh: expand input
This commit is contained in:
parent
3af96c9d4e
commit
205c711120
4 changed files with 139 additions and 5 deletions
|
|
@ -88,6 +88,8 @@
|
||||||
import ValvesModal from '../workspace/common/ValvesModal.svelte';
|
import ValvesModal from '../workspace/common/ValvesModal.svelte';
|
||||||
import PageEdit from '../icons/PageEdit.svelte';
|
import PageEdit from '../icons/PageEdit.svelte';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
import InputModal from '../common/InputModal.svelte';
|
||||||
|
import Expand from '../icons/Expand.svelte';
|
||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
|
@ -420,6 +422,8 @@
|
||||||
|
|
||||||
let inputFiles;
|
let inputFiles;
|
||||||
|
|
||||||
|
let showInputModal = false;
|
||||||
|
|
||||||
let dragged = false;
|
let dragged = false;
|
||||||
let shiftKey = false;
|
let shiftKey = false;
|
||||||
|
|
||||||
|
|
@ -984,6 +988,20 @@
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<InputModal
|
||||||
|
bind:show={showInputModal}
|
||||||
|
bind:value={prompt}
|
||||||
|
bind:inputContent
|
||||||
|
onChange={(content) => {
|
||||||
|
console.log(content);
|
||||||
|
chatInputElement?.setContent(content?.json ?? null);
|
||||||
|
}}
|
||||||
|
onClose={async () => {
|
||||||
|
await tick();
|
||||||
|
chatInputElement?.focus();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
{#if loaded}
|
{#if loaded}
|
||||||
<div class="w-full font-primary">
|
<div class="w-full font-primary">
|
||||||
<div class=" mx-auto inset-x-0 bg-transparent flex justify-center">
|
<div class=" mx-auto inset-x-0 bg-transparent flex justify-center">
|
||||||
|
|
@ -1210,7 +1228,7 @@
|
||||||
|
|
||||||
<div class="px-2.5">
|
<div class="px-2.5">
|
||||||
<div
|
<div
|
||||||
class="scrollbar-hidden rtl:text-right ltr:text-left bg-transparent dark:text-gray-100 outline-hidden w-full pb-1 px-1 resize-none h-fit max-h-96 overflow-auto {files.length ===
|
class="scrollbar-hidden rtl:text-right ltr:text-left bg-transparent dark:text-gray-100 outline-hidden w-full pb-1 px-1 resize-none h-fit max-h-96 overflow-auto relative {files.length ===
|
||||||
0
|
0
|
||||||
? atSelectedModel !== undefined
|
? atSelectedModel !== undefined
|
||||||
? 'pt-1.5'
|
? 'pt-1.5'
|
||||||
|
|
@ -1218,12 +1236,30 @@
|
||||||
: ''}"
|
: ''}"
|
||||||
id="chat-input-container"
|
id="chat-input-container"
|
||||||
>
|
>
|
||||||
|
{#if prompt.split('\n').length > 2}
|
||||||
|
<div class="absolute top-0 right-0 z-20">
|
||||||
|
<div class="mt-2.5">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="p-1 rounded-lg hover:bg-gray-100/50 dark:hover:bg-gray-800/50"
|
||||||
|
aria-label="Expand input"
|
||||||
|
on:click={async () => {
|
||||||
|
showInputModal = true;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Expand />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if suggestions}
|
{#if suggestions}
|
||||||
{#key $settings?.richTextInput ?? true}
|
{#key $settings?.richTextInput ?? true}
|
||||||
{#key $settings?.showFormattingToolbar ?? false}
|
{#key $settings?.showFormattingToolbar ?? false}
|
||||||
<RichTextInput
|
<RichTextInput
|
||||||
bind:this={chatInputElement}
|
bind:this={chatInputElement}
|
||||||
id="chat-input"
|
id="chat-input"
|
||||||
|
editable={!showInputModal}
|
||||||
onChange={(content) => {
|
onChange={(content) => {
|
||||||
prompt = content.md;
|
prompt = content.md;
|
||||||
inputContent = content;
|
inputContent = content;
|
||||||
|
|
|
||||||
79
src/lib/components/common/InputModal.svelte
Normal file
79
src/lib/components/common/InputModal.svelte
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { onMount, getContext } from 'svelte';
|
||||||
|
import { settings } from '$lib/stores';
|
||||||
|
|
||||||
|
import Drawer from './Drawer.svelte';
|
||||||
|
import RichTextInput from './RichTextInput.svelte';
|
||||||
|
|
||||||
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
export let id = 'input-modal';
|
||||||
|
|
||||||
|
export let show = false;
|
||||||
|
export let value = null;
|
||||||
|
export let inputContent = null;
|
||||||
|
|
||||||
|
export let autocomplete = false;
|
||||||
|
export let generateAutoCompletion = null;
|
||||||
|
|
||||||
|
export let onChange = () => {};
|
||||||
|
export let onClose = () => {};
|
||||||
|
|
||||||
|
let inputElement;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Drawer bind:show>
|
||||||
|
<div class="flex h-full min-h-screen flex-col">
|
||||||
|
<div
|
||||||
|
class=" sticky top-0 z-30 flex justify-between bg-white px-4.5 pt-3 pb-3 dark:bg-gray-900 dark:text-gray-100"
|
||||||
|
>
|
||||||
|
<div class=" font-primary self-center text-lg">
|
||||||
|
{$i18n.t('Input')}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="self-center"
|
||||||
|
aria-label="Close"
|
||||||
|
onclick={() => {
|
||||||
|
show = false;
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
class="h-5 w-5"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex w-full px-4 dark:text-gray-200 min-h-full flex-1">
|
||||||
|
<div class="flex-1 w-full min-h-full">
|
||||||
|
<RichTextInput
|
||||||
|
bind:this={inputElement}
|
||||||
|
{id}
|
||||||
|
onChange={(content) => {
|
||||||
|
value = content.md;
|
||||||
|
inputContent = content;
|
||||||
|
|
||||||
|
onChange(content);
|
||||||
|
}}
|
||||||
|
json={true}
|
||||||
|
value={inputContent?.json}
|
||||||
|
html={inputContent?.html}
|
||||||
|
richText={$settings?.richTextInput ?? true}
|
||||||
|
messageInput={true}
|
||||||
|
showFormattingToolbar={$settings?.showFormattingToolbar ?? false}
|
||||||
|
floatingMenuPlacement={'top-start'}
|
||||||
|
insertPromptAsRichText={$settings?.insertPromptAsRichText ?? false}
|
||||||
|
{autocomplete}
|
||||||
|
{generateAutoCompletion}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Drawer>
|
||||||
|
|
@ -169,7 +169,7 @@
|
||||||
|
|
||||||
export let documentId = '';
|
export let documentId = '';
|
||||||
|
|
||||||
export let className = 'input-prose';
|
export let className = 'input-prose min-h-fit';
|
||||||
export let placeholder = $i18n.t('Type here...');
|
export let placeholder = $i18n.t('Type here...');
|
||||||
let _placeholder = placeholder;
|
let _placeholder = placeholder;
|
||||||
|
|
||||||
|
|
@ -1156,7 +1156,5 @@
|
||||||
|
|
||||||
<div
|
<div
|
||||||
bind:this={element}
|
bind:this={element}
|
||||||
class="relative w-full min-w-full h-full min-h-fit {className} {!editable
|
class="relative w-full min-w-full h-full {className} {!editable ? 'cursor-not-allowed' : ''}"
|
||||||
? 'cursor-not-allowed'
|
|
||||||
: ''}"
|
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
21
src/lib/components/icons/Expand.svelte
Normal file
21
src/lib/components/icons/Expand.svelte
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<script lang="ts">
|
||||||
|
export let className = 'w-4 h-4';
|
||||||
|
export let strokeWidth = '1.5';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg
|
||||||
|
class={className}
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
stroke-width={strokeWidth}
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path d="M9 9L4 4M4 4V8M4 4H8" stroke-linecap="round" stroke-linejoin="round"></path><path
|
||||||
|
d="M15 9L20 4M20 4V8M20 4H16"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
></path><path d="M9 15L4 20M4 20V16M4 20H8" stroke-linecap="round" stroke-linejoin="round"
|
||||||
|
></path><path d="M15 15L20 20M20 20V16M20 20H16" stroke-linecap="round" stroke-linejoin="round"
|
||||||
|
></path></svg
|
||||||
|
>
|
||||||
Loading…
Reference in a new issue