Files
aigc-home/calliope-web/src/lib/components/prompt-tools/PromptEditor.svelte
T

40 lines
913 B
Svelte

<script lang="ts">
import { untrack } from "svelte";
import { page } from "$app/state";
import { promptTool } from "./state.svelte";
import ToolButtons from "./ToolButtons.svelte";
import ResultBand from "./ResultBand.svelte";
let {
value = $bindable(),
identity,
label = "提示词",
rows = 2,
placeholder = "",
}: {
value?: string;
identity: string;
label?: string;
rows?: number;
placeholder?: string;
} = $props();
const tool = promptTool(
() => value ?? "",
() => `${page.url.pathname}|${identity}`,
(v) => (value = v),
untrack(() => label),
);
</script>
<div class="prompt-editor">
<div class="prompt-editor-label">
<span>{label}</span><ToolButtons {tool} />
</div>
<textarea
class="a-input mono"
bind:value
{rows}
{placeholder}
oninput={() => tool.edit()}
></textarea><ResultBand {tool} />
</div>