File size: 25,081 Bytes
2d4e8f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 |
<script lang="ts">
import { onMount, tick } from "svelte";
import { BlockTitle, IconButton, IconButtonWrapper } from "@gradio/atoms";
import { Copy, Check, Send, Plus, Trash } from "@gradio/icons";
import { fade } from "svelte/transition";
import { BaseDropdown, BaseDropdownOptions } from "@gradio/dropdown";
import { Gradio } from "@gradio/utils";
import type { DialogueLine } from "./utils";
import Switch from "./Switch.svelte";
import type { DialogueEvents, DialogueProps } from "./types";
const props = $props();
const gradio: Gradio<DialogueEvents, DialogueProps> = props.gradio;
let checked = $derived(false);
let disabled = $derived(!gradio.shared.interactive);
let dialogue_lines: DialogueLine[] = $state([]);
$effect(() => {
if (
gradio.props.value &&
gradio.props.value.length &&
typeof gradio.props.value !== "string"
) {
dialogue_lines = [...gradio.props.value];
} else if (gradio.props.value && typeof gradio.props.value !== "string") {
dialogue_lines = [
{
speaker: `${gradio.props.speakers.length ? gradio.props.speakers[0] : ""}`,
text: ""
}
];
} else if (typeof gradio.props.value === "string") {
textbox_value = gradio.props.value;
checked = true;
}
});
let buttons = $derived(gradio.props.buttons || ["copy"]);
let old_value = $state(gradio.props.value);
$effect(() => {
if (old_value != gradio.props.value) {
old_value = gradio.props.value;
gradio.dispatch("change");
}
});
let dialogue_container_element: HTMLDivElement;
let showTagMenu = $state(false);
let currentLineIndex = $state(-1);
let selectedOptionIndex = $state(0);
let filtered_tags: string[] = $state([]);
let input_elements: (HTMLInputElement | HTMLTextAreaElement)[] = $state([]);
let textarea_element: HTMLTextAreaElement;
let offset_from_top = $state(0);
let copied = $state(false);
let timer: any;
let textbox_value = $state("");
let hoveredSpeaker: string | null = $state(null);
let is_unformatting = $state(false);
let is_formatting = $state(false);
const defaultColorNames = [
"red",
"green",
"blue",
"yellow",
"purple",
"teal",
"orange",
"cyan",
"lime",
"pink"
];
const colorNameToHex: Record<string, string> = {
red: "rgba(254, 202, 202, 0.7)",
green: "rgba(209, 250, 229, 0.7)",
blue: "rgba(219, 234, 254, 0.7)",
yellow: "rgba(254, 243, 199, 0.7)",
purple: "rgba(233, 213, 255, 0.7)",
teal: "rgba(204, 251, 241, 0.7)",
orange: "rgba(254, 215, 170, 0.7)",
cyan: "rgba(207, 250, 254, 0.7)",
lime: "rgba(217, 249, 157, 0.7)",
pink: "rgba(252, 231, 243, 0.7)"
};
let speakerColors: Record<string, string> = $derived.by(() => {
let _speakerColors: Record<string, string> = {};
if (gradio.props.color_map) {
_speakerColors = { ...gradio.props.color_map };
} else {
_speakerColors = {};
gradio.props.speakers.forEach((speaker, index) => {
const colorName = defaultColorNames[index % defaultColorNames.length];
_speakerColors[speaker] = colorNameToHex[colorName];
});
}
return _speakerColors;
});
function add_line(index: number): void {
const newSpeaker =
gradio.props.speakers.length > 0 ? gradio.props.speakers[0] : "";
dialogue_lines = [
...dialogue_lines.slice(0, index + 1),
{ speaker: newSpeaker, text: "" },
...dialogue_lines.slice(index + 1)
];
tick().then(() => {
if (input_elements[index + 1]) {
input_elements[index + 1].focus();
}
});
gradio.props.value = [...dialogue_lines];
}
function delete_line(index: number): void {
dialogue_lines = [
...dialogue_lines.slice(0, index),
...dialogue_lines.slice(index + 1)
];
gradio.props.value = [...dialogue_lines];
}
function update_line(
index: number,
key: keyof DialogueLine,
value: string
): void {
dialogue_lines[index][key] = value;
dialogue_lines = [...dialogue_lines];
gradio.props.value = [...dialogue_lines];
}
function handle_input(event: Event, index: number): void {
const input = (event.target as HTMLInputElement) || HTMLTextAreaElement;
if (input && !input_elements[index]) {
input_elements[index] = input;
}
const cursor_position = input.selectionStart || 0;
const text = input.value;
let show_menu = false;
let position_reference_index = -1;
if (text[cursor_position - 1] === ":") {
currentLineIndex = index;
position_reference_index = cursor_position;
const search_text = get_tag_search_text(text, cursor_position);
filtered_tags = gradio.props.tags.filter(
(tag) =>
search_text === "" ||
tag.toLowerCase().includes(search_text.toLowerCase())
);
show_menu = filtered_tags.length > 0;
selectedOptionIndex = 0;
} else {
const lastColonIndex = text.lastIndexOf(":", cursor_position - 1);
if (
lastColonIndex >= 0 &&
!text.substring(lastColonIndex + 1, cursor_position).includes(" ")
) {
currentLineIndex = index;
position_reference_index = lastColonIndex + 1; // Position menu relative to the start of the potential tag
const searchText = text.substring(lastColonIndex + 1, cursor_position);
filtered_tags = gradio.props.tags.filter(
(tag) =>
searchText === "" ||
tag.toLowerCase().includes(searchText.toLowerCase())
);
show_menu = filtered_tags.length > 0;
selectedOptionIndex = 0;
}
}
if (show_menu && position_reference_index !== -1) {
showTagMenu = true;
const input_rect = input.getBoundingClientRect();
// Position menu below the current input by calculating the distance from the top of the container
// and use 1.5 times the input height.
if (dialogue_container_element) {
const container_rect =
dialogue_container_element.getBoundingClientRect();
offset_from_top =
container_rect.top + input_rect.height * (index + 1.5);
}
} else {
showTagMenu = false;
}
gradio.dispatch("input");
}
function get_tag_search_text(text: string, cursorPosition: number): string {
const lastColonIndex = text.lastIndexOf(":", cursorPosition - 1);
if (lastColonIndex >= 0) {
return text.substring(lastColonIndex + 1, cursorPosition);
}
return "";
}
async function insert_selected_tag(): Promise<void> {
const tag = filtered_tags[selectedOptionIndex];
if (tag) {
let text;
let currentInput;
if (checked) {
currentInput = textarea_element;
text = textbox_value;
} else {
currentInput = input_elements[currentLineIndex];
text = dialogue_lines[currentLineIndex].text;
}
const cursorPosition = currentInput?.selectionStart || 0;
const lastColonIndex = text.lastIndexOf(":", cursorPosition - 1);
if (lastColonIndex >= 0) {
const beforeColon = text.substring(0, lastColonIndex);
const afterCursor = text.substring(cursorPosition);
if (checked) {
// plain text mode: don't filter speaker tags
const newText = `${beforeColon}${tag} ${afterCursor}`;
textbox_value = newText;
if (gradio.props.speakers.length === 0) {
gradio.props.value = newText;
} else {
gradio.props.value = await gradio.shared.server.unformat({
text: newText
});
}
tick().then(() => {
if (textarea_element) {
const newCursorPosition = beforeColon.length + tag.length + 1;
textarea_element.setSelectionRange(
newCursorPosition,
newCursorPosition
);
textarea_element.focus();
}
});
} else {
// dialogue line mode
const filteredBeforeColon = beforeColon
.replace(/\[S\d+\]/g, "")
.trim();
const newText = `${filteredBeforeColon}${tag} ${afterCursor}`;
update_line(currentLineIndex, "text", newText);
tick().then(() => {
const updatedInput = input_elements[currentLineIndex];
if (updatedInput) {
const newCursorPosition =
filteredBeforeColon.length + tag.length + 1;
updatedInput.setSelectionRange(
newCursorPosition,
newCursorPosition
);
updatedInput.focus();
}
});
}
}
showTagMenu = false;
selectedOptionIndex = 0;
}
}
async function insert_tag(e: CustomEvent): Promise<void> {
const tag = gradio.props.tags[e.detail.target.dataset.index];
if (tag) {
let text;
let currentInput;
if (checked) {
currentInput = textarea_element;
text = textbox_value;
} else {
currentInput = input_elements[currentLineIndex];
text = dialogue_lines[currentLineIndex].text;
}
const cursorPosition = currentInput?.selectionStart || 0;
const lastColonIndex = text.lastIndexOf(":", cursorPosition - 1);
if (lastColonIndex >= 0) {
const beforeColon = text.substring(0, lastColonIndex);
const afterCursor = text.substring(cursorPosition);
if (checked) {
// plain text mode: don't filter speaker tags
const newText = `${beforeColon}${tag} ${afterCursor}`;
textbox_value = newText;
if (gradio.props.speakers.length === 0) {
gradio.props.value = newText;
} else {
gradio.props.value = await gradio.shared.server.unformat({
text: newText
});
}
tick().then(() => {
if (textarea_element) {
const newCursorPosition = beforeColon.length + tag.length + 1;
textarea_element.setSelectionRange(
newCursorPosition,
newCursorPosition
);
textarea_element.focus();
}
});
} else {
// dialogue line mode
const filteredBeforeColon = beforeColon
.replace(/\[S\d+\]/g, "")
.trim();
const newText = `${filteredBeforeColon}${tag} ${afterCursor}`;
update_line(currentLineIndex, "text", newText);
tick().then(() => {
const updatedInput = input_elements[currentLineIndex];
if (updatedInput) {
const newCursorPosition =
filteredBeforeColon.length + tag.length + 1;
updatedInput.setSelectionRange(
newCursorPosition,
newCursorPosition
);
updatedInput.focus();
}
});
}
}
showTagMenu = false;
selectedOptionIndex = 0;
}
}
function handle_click_outside(event: MouseEvent): void {
if (showTagMenu) {
const target = event.target as Node;
const tagMenu = document.getElementById("tag-menu");
if (tagMenu && !tagMenu.contains(target)) {
showTagMenu = false;
}
}
}
async function value_to_string(
value: DialogueLine[] | string
): Promise<string> {
if (typeof value === "string") {
return value;
}
return await gradio.shared.server.format(value);
}
async function handle_copy(): Promise<void> {
if ("clipboard" in navigator) {
const text = await value_to_string(gradio.props.value);
await navigator.clipboard.writeText(text);
copy_feedback();
}
}
function copy_feedback(): void {
copied = true;
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
copied = false;
}, 1000);
}
async function handle_submit(): Promise<void> {
if (checked) {
gradio.props.value = await gradio.shared.server.unformat({
text: textbox_value
});
}
gradio.dispatch("submit");
}
onMount(async () => {
if (typeof gradio.props.value === "string") {
textbox_value = gradio.props.value;
} else if (gradio.props.value && gradio.props.value.length > 0) {
const formatted = await value_to_string(gradio.props.value);
textbox_value = formatted;
} else {
textbox_value = "";
}
});
</script>
<svelte:window on:click={handle_click_outside} />
<label class:container={gradio.shared.container}>
{#if gradio.shared.show_label && buttons.includes("copy")}
<IconButtonWrapper>
<IconButton
Icon={copied ? Check : Copy}
on:click={handle_copy}
label={copied ? "Copied" : "Copy"}
/>
</IconButtonWrapper>
{/if}
<BlockTitle show_label={gradio.shared.show_label} info={gradio.props.info}
>{gradio.shared.label || "Dialogue"}</BlockTitle
>
{#if gradio.props.ui_mode === "both"}
<div
class="switch-container top-switch"
class:switch-disabled={is_formatting || is_unformatting}
>
<Switch
label="Plain Text"
bind:checked
disabled={is_formatting || is_unformatting}
on:click={async (e) => {
if (!e.detail.checked) {
is_unformatting = true;
try {
gradio.props.value = await gradio.shared.server.unformat({
text: textbox_value
});
dialogue_lines = [...(gradio.props.value as DialogueLine[])];
} finally {
is_unformatting = false;
}
} else {
is_formatting = true;
try {
textbox_value = await value_to_string(dialogue_lines);
} finally {
is_formatting = false;
}
}
}}
/>
</div>
{/if}
{#if !checked && gradio.props.ui_mode !== "text"}
<div
class="dialogue-container"
bind:this={dialogue_container_element}
class:loading={is_unformatting}
>
{#if is_unformatting}
<div class="loading-overlay" transition:fade={{ duration: 200 }}>
<div class="loading-spinner"></div>
<div class="loading-text">Converting to dialogue format...</div>
</div>
{/if}
{#each dialogue_lines as line, i}
<div
class="dialogue-line"
style="--speaker-bg-color: {disabled &&
(hoveredSpeaker === null || hoveredSpeaker === line.speaker)
? speakerColors[line.speaker] || 'transparent'
: 'transparent'}"
>
<div
class="speaker-column"
role="button"
tabindex="0"
on:mouseenter={() => disabled && (hoveredSpeaker = line.speaker)}
on:mouseleave={() => disabled && (hoveredSpeaker = null)}
>
{#if disabled}
<textarea
bind:value={line.speaker}
{disabled}
rows="1"
readonly
/>
{:else}
{@const dd_props = new Gradio({
shared_props: {
container: true,
show_label: false,
interactive: true,
label: ""
},
props: {
value: line.speaker,
choices: gradio.props.speakers.map((s) => [s, s])
}
})}
<BaseDropdown
on_change={() =>
update_line(i, "speaker", dd_props.props.value as string)}
gradio={dd_props}
/>
{/if}
</div>
<div class="text-column">
<div class="input-container">
<textarea
bind:value={line.text}
placeholder={gradio.props.placeholder}
{disabled}
on:input={(event) => handle_input(event, i)}
on:focus={(event) => handle_input(event, i)}
on:keydown={(event) => {
if (event.key === "Escape" && showTagMenu) {
showTagMenu = false;
selectedOptionIndex = 0;
event.preventDefault();
} else if (showTagMenu && currentLineIndex === i) {
if (event.key === "ArrowDown") {
selectedOptionIndex = Math.min(
selectedOptionIndex + 1,
filtered_tags.length - 1
);
event.preventDefault();
} else if (event.key === "ArrowUp") {
selectedOptionIndex = Math.max(
selectedOptionIndex - 1,
0
);
event.preventDefault();
} else if (event.key === "Enter") {
if (filtered_tags[selectedOptionIndex]) {
insert_selected_tag();
}
event.preventDefault();
}
}
}}
bind:this={input_elements[i]}
rows="1"
></textarea>
{#if showTagMenu && currentLineIndex === i}
<div
id="tag-menu"
class="tag-menu"
transition:fade={{ duration: 100 }}
>
<BaseDropdownOptions
choices={gradio.props.tags.map((s, i) => [s, i])}
filtered_indices={filtered_tags.map((s) =>
gradio.props.tags.indexOf(s)
)}
active_index={filtered_tags.map((s) =>
gradio.props.tags.indexOf(s)
)[selectedOptionIndex]}
show_options={true}
on:change={(e) => insert_tag(e)}
{offset_from_top}
from_top={true}
/>
</div>
{/if}
</div>
</div>
{#if gradio.props.max_lines == undefined || (gradio.props.max_lines && i < gradio.props.max_lines - 1)}
<div class:action-column={i == 0} class:hidden={disabled}>
<button
class="add-button"
on:click={() => add_line(i)}
aria-label="Add new line"
{disabled}
>
<Plus />
</button>
</div>
{/if}
<div class="action-column" class:hidden={disabled || i == 0}>
<button
class="delete-button"
on:click={() => delete_line(i)}
aria-label="Remove current line"
{disabled}
>
<Trash />
</button>
</div>
</div>
{/each}
</div>
{:else if checked || gradio.props.ui_mode !== "dialogue"}
<div class="textarea-container" class:loading={is_formatting}>
{#if is_formatting}
<div class="loading-overlay" transition:fade={{ duration: 200 }}>
<div class="loading-spinner"></div>
<div class="loading-text">Converting to plain text...</div>
</div>
{/if}
<textarea
data-testid="textbox"
bind:value={textbox_value}
placeholder={gradio.props.placeholder}
rows={5}
{disabled}
on:input={(event) => {
handle_input(event, 0);
gradio.props.value = textbox_value;
}}
on:focus={(event) => handle_input(event, 0)}
on:keydown={(event) => {
if (event.key === "Escape" && showTagMenu) {
showTagMenu = false;
selectedOptionIndex = 0;
event.preventDefault();
} else if (showTagMenu) {
if (event.key === "ArrowDown") {
selectedOptionIndex = Math.min(
selectedOptionIndex + 1,
filtered_tags.length - 1
);
event.preventDefault();
} else if (event.key === "ArrowUp") {
selectedOptionIndex = Math.max(selectedOptionIndex - 1, 0);
event.preventDefault();
} else if (event.key === "Enter") {
if (filtered_tags[selectedOptionIndex]) {
insert_selected_tag();
}
event.preventDefault();
}
}
}}
bind:this={textarea_element}
/>
{#if showTagMenu}
<div
id="tag-menu"
class="tag-menu-plain-text"
transition:fade={{ duration: 100 }}
>
<BaseDropdownOptions
choices={gradio.props.tags.map((s, i) => [s, i])}
filtered_indices={filtered_tags.map((s) =>
gradio.props.tags.indexOf(s)
)}
active_index={filtered_tags.map((s) =>
gradio.props.tags.indexOf(s)
)[selectedOptionIndex]}
show_options={true}
on:change={(e) => insert_tag(e)}
/>
</div>
{/if}
</div>
{/if}
{#if gradio.props.submit_btn && !disabled}
<div class="submit-container">
<button class="submit-button" on:click={handle_submit} {disabled}>
{#if typeof gradio.props.submit_btn === "string"}
{gradio.props.submit_btn}
{:else}
<Send />
{/if}
</button>
</div>
{/if}
</label>
<style>
label {
display: block;
width: 100%;
}
.input-container {
display: flex;
position: relative;
align-items: flex-end;
}
.dialogue-container {
border: none;
border-radius: var(--input-radius);
background: var(--input-background-fill);
padding: var(--spacing-md);
margin-bottom: var(--spacing-sm);
position: relative;
}
.dialogue-line {
display: flex;
align-items: center;
margin-bottom: var(--spacing-sm);
}
.dialogue-line:has(.action-column.hidden) .text-column {
margin-right: 0;
}
.speaker-column {
flex: 0 0 150px;
margin-right: var(--spacing-sm);
display: flex;
align-items: center;
}
.speaker-column textarea {
background: var(--speaker-bg-color);
transition: background-color 0.2s ease;
border: 1px solid var(--border-color-primary);
border-radius: var(--radius-sm);
padding: var(--input-padding);
color: var(--body-text-color);
font-weight: var(--input-text-weight);
font-size: var(--input-text-size);
line-height: var(--line-sm);
resize: none;
width: 100%;
box-sizing: border-box;
height: auto;
min-height: 30px;
max-height: none;
margin-top: 0px;
margin-bottom: 0px;
z-index: 1;
display: block;
position: relative;
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
overflow: hidden;
}
.text-column {
flex: 1;
margin-right: var(--spacing-sm);
}
.text-column textarea {
width: 100%;
padding: var(--spacing-sm);
border: 1px solid var(--border-color-primary);
border-radius: var(--radius-sm);
color: var(--body-text-color);
background: var(--speaker-bg-color);
transition: background-color 0.2s ease;
height: auto;
min-height: 30px;
max-height: none;
flex-grow: 1;
margin-top: 0px;
margin-bottom: 0px;
resize: none;
z-index: 1;
display: block;
position: relative;
padding: var(--input-padding);
width: 100%;
color: var(--body-text-color);
font-weight: var(--input-text-weight);
font-size: var(--input-text-size);
line-height: var(--line-sm);
white-space: pre-wrap;
word-wrap: break-word;
overflow-wrap: break-word;
overflow: hidden;
box-sizing: border-box;
}
.text-column textarea {
color: var(--body-text-color);
}
.dialogue-line[style*="--speaker-bg-color: rgba"] .text-column textarea,
.dialogue-line[style*="--speaker-bg-color: rgba"] .speaker-column textarea {
color: black;
}
textarea {
flex-grow: 1;
outline: none !important;
margin-top: 0px;
margin-bottom: 0px;
resize: none;
z-index: 1;
display: block;
position: relative;
outline: none !important;
background: var(--input-background-fill);
padding: var(--input-padding);
width: 100%;
color: var(--body-text-color);
font-weight: var(--input-text-weight);
font-size: var(--input-text-size);
line-height: var(--line-sm);
box-shadow: var(--input-shadow);
border: var(--input-border-width) solid var(--input-border-color);
border-radius: var(--input-radius);
}
textarea:disabled {
-webkit-opacity: 1;
opacity: 1;
}
textarea:focus {
box-shadow: var(--input-shadow-focus);
border-color: var(--input-border-color-focus);
background: var(--input-background-fill-focus);
}
textarea::placeholder {
color: var(--input-placeholder-color);
}
.action-column {
display: flex;
justify-content: center;
}
.add-button {
display: flex;
justify-content: center;
align-items: center;
width: 25px;
height: 25px;
border: none;
background: transparent;
cursor: pointer;
}
.delete-button {
display: flex;
justify-content: center;
align-items: center;
width: 15px;
height: 15px;
}
.add-button:hover {
color: var(--color-accent);
}
.switch-container {
display: flex;
justify-content: flex-start;
transition: opacity 0.2s ease-in-out;
}
.switch-container.switch-disabled {
opacity: 0.6;
pointer-events: none;
}
.switch-container.top-switch {
margin-bottom: var(--spacing-sm);
justify-content: flex-end;
}
.submit-container {
display: flex;
justify-content: flex-end;
margin-top: var(--spacing-sm);
}
.submit-container button[disabled] {
cursor: not-allowed;
}
.submit-button {
border: none;
text-align: center;
text-decoration: none;
font-size: 14px;
cursor: pointer;
border-radius: 15px;
min-width: 30px;
height: 30px;
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
background: var(--button-secondary-background-fill);
color: var(--button-secondary-text-color);
}
.submit-button:hover {
background: var(--button-secondary-background-fill-hover);
}
.submit-button:active {
box-shadow: var(--button-shadow-active);
}
.submit-button :global(svg) {
height: 22px;
width: 22px;
}
.tag-menu {
position: absolute;
width: 100%;
top: 100%;
left: 0;
}
.tag-menu-plain-text {
position: relative;
width: 100%;
}
.tag-menu-plain-text :global(.options) {
position: static !important;
width: 100% !important;
max-height: none !important;
top: auto !important;
bottom: auto !important;
}
.hidden {
display: none;
}
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--input-background-fill);
opacity: 0.95;
backdrop-filter: blur(2px);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 10;
border-radius: var(--input-radius);
}
.loading-spinner {
width: 24px;
height: 24px;
border: 2px solid var(--border-color-primary);
border-top: 2px solid var(--color-accent);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-bottom: var(--spacing-sm);
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loading-text {
color: var(--body-text-color);
font-size: var(--text-sm);
font-weight: 500;
opacity: 0.8;
}
.dialogue-container.loading,
.textarea-container.loading {
position: relative;
opacity: 0.7;
transition: opacity 0.3s ease-in-out;
}
.dialogue-container,
.textarea-container {
transition: opacity 0.3s ease-in-out;
}
</style>
|