Fixed some stupid shit

This commit is contained in:
Caleb Owens 2024-05-31 22:00:08 +02:00
parent 509b72409d
commit 0b36e4bcc4
5 changed files with 17 additions and 23 deletions

View File

@ -1,8 +1,5 @@
<script lang="ts">
import { PromptService } from '$lib/ai/promptService';
import SectionCard from '$lib/components/SectionCard.svelte';
import Icon from '../Icon.svelte';
import Section from '$lib/components/settings/Section.svelte';
import Content from '$lib/components/AIPromptEdit/Content.svelte';
import Button from '$lib/components/Button.svelte';
import { getContext } from '$lib/utils/context';
@ -56,7 +53,7 @@
}}
/>
{#each $userPrompts as prompt, index}
{#each $userPrompts as prompt}
<Content
bind:prompt
displayMode="writable"

View File

@ -2,9 +2,7 @@
import { MessageRole, type UserPrompt } from '$lib/ai/types';
import DialogBubble from '$lib/components/AIPromptEdit/DialogBubble.svelte';
import Button from '$lib/components/Button.svelte';
import ExpandableSectionCard from '$lib/components/ExpandableSectionCard.svelte';
import Icon from '$lib/components/Icon.svelte';
import TextArea from '$lib/components/TextArea.svelte';
import TextBox from '$lib/components/TextBox.svelte';
import { createEventDispatcher } from 'svelte';
@ -125,7 +123,6 @@
bind:promptMessage
editing={isInEditing}
isLast={index + 1 == promptMessages.length || promptMessages.length == 1}
autofocus={index + 1 == promptMessages.length - 1 || promptMessages.length == 1}
disableRemove={promptMessages.length == 1}
on:addExample={addExample}
on:removeLastExample={removeLastExample}

View File

@ -1,14 +1,11 @@
<script lang="ts">
import { onMount } from 'svelte';
import { MessageRole } from '$lib/ai/types';
import Button from '$lib/components/Button.svelte';
import Icon from '$lib/components/Icon.svelte';
import TextArea from '$lib/components/TextArea.svelte';
import { useAutoHeight } from '$lib/utils/useAutoHeight';
import { useResize } from '$lib/utils/useResize';
import Button from '$lib/components/Button.svelte';
import { createEventDispatcher } from 'svelte';
import { MessageRole } from '$lib/ai/types';
import { marked } from 'marked';
import { createEventDispatcher } from 'svelte';
export let disableRemove = false;
export let isError = false;
@ -22,19 +19,22 @@
addExample: void;
input: string;
}>();
let textareaElement: HTMLTextAreaElement;
let textareaElement: HTMLTextAreaElement | undefined;
const focusTextareaOnMount = () => {
function focusTextareaOnMount(
textareaElement: HTMLTextAreaElement | undefined,
autofocus: boolean,
editing: boolean
) {
if (textareaElement && autofocus && editing) {
textareaElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
textareaElement.focus();
}
};
}
// $: if (editing && textareaElement) {
// useAutoHeight(textareaElement);
// focusTextareaOnMount();
// }
$: focusTextareaOnMount(textareaElement, autofocus, editing);
$: if (textareaElement) useAutoHeight(textareaElement);
</script>
<div
@ -70,7 +70,7 @@
useAutoHeight(e.currentTarget);
}}
use:useResize={() => {
useAutoHeight(textareaElement);
if (textareaElement) useAutoHeight(textareaElement);
}}
/>
{:else}

View File

@ -1,8 +1,8 @@
<script lang="ts">
import { pxToRem } from '$lib/utils/pxToRem';
import { createEventDispatcher } from 'svelte';
import { useAutoHeight } from '$lib/utils/useAutoHeight';
import { useResize } from '$lib/utils/useResize';
import { createEventDispatcher } from 'svelte';
export let value: string | undefined;
export let placeholder: string | undefined = undefined;

View File

@ -5,7 +5,6 @@
import AiPromptEdit from '$lib/components/AIPromptEdit/AIPromptEdit.svelte';
import InfoMessage from '$lib/components/InfoMessage.svelte';
import RadioButton from '$lib/components/RadioButton.svelte';
import Section from '$lib/components/settings/Section.svelte';
import SectionCard from '$lib/components/SectionCard.svelte';
import Select from '$lib/components/Select.svelte';
import SelectItem from '$lib/components/SelectItem.svelte';
@ -13,6 +12,7 @@
import TextBox from '$lib/components/TextBox.svelte';
import WelcomeSigninAction from '$lib/components/WelcomeSigninAction.svelte';
import ContentWrapper from '$lib/components/settings/ContentWrapper.svelte';
import Section from '$lib/components/settings/Section.svelte';
import { UserService } from '$lib/stores/user';
import { getContext } from '$lib/utils/context';
import { onMount, tick } from 'svelte';