-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove paying subscription mention from docstring (#653)
- Loading branch information
Showing
3 changed files
with
27 additions
and
24 deletions.
There are no files selected for viewing
47 changes: 25 additions & 22 deletions
47
js/src/lib/components/InferenceWidget/shared/WidgetTextarea/WidgetTextarea.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
<script> | ||
import { tick } from "svelte"; | ||
import WidgetLabel from "../WidgetLabel/WidgetLabel.svelte"; | ||
export let label: string = ""; | ||
export let placeholder: string = "Your sentence here..."; | ||
export let value: string; | ||
let textAreaEl: HTMLTextAreaElement; | ||
const HEIGHT_LIMIT = 500 as const; | ||
async function resize() { | ||
if (!!textAreaEl) { | ||
textAreaEl.style.height = "0px"; | ||
await tick(); | ||
textAreaEl.style.height = | ||
Math.min(textAreaEl.scrollHeight, HEIGHT_LIMIT) + "px"; | ||
} | ||
} | ||
// hack to handle FireFox contenteditable bug | ||
let innterHTML: string; | ||
let spanEl: HTMLSpanElement; | ||
const REGEX_SPAN = /<span .+>(.*)<\/span>/gms; | ||
$: { | ||
value; | ||
resize(); | ||
if (spanEl && innterHTML && REGEX_SPAN.test(innterHTML)) { | ||
innterHTML = innterHTML.replace(REGEX_SPAN, (_, txt) => { | ||
return txt; | ||
}); | ||
spanEl.blur(); | ||
} | ||
} | ||
</script> | ||
|
||
<WidgetLabel {label}> | ||
<svelte:fragment slot="after"> | ||
<textarea | ||
bind:this={textAreaEl} | ||
bind:value | ||
<span | ||
bind:textContent={value} | ||
bind:innerHTML={innterHTML} | ||
bind:this={spanEl} | ||
class="{label | ||
? 'mt-1.5' | ||
: ''} block w-full border border-gray-200 rounded-lg shadow-inner outline-none focus:ring-1 focus:ring-inset focus:ring-indigo-200 focus:shadow-inner dark:bg-gray-925" | ||
{placeholder} | ||
: ''} block overflow-auto resize-y py-2 px-3 w-full min-h-[42px] max-h-[500px] border border-gray-200 rounded-lg shadow-inner outline-none focus:ring-1 focus:ring-inset focus:ring-indigo-200 focus:shadow-inner dark:bg-gray-925" | ||
role="textbox" | ||
contenteditable | ||
style="--placeholder: '{placeholder}'" | ||
/> | ||
</svelte:fragment> | ||
</WidgetLabel> | ||
|
||
<style> | ||
span[contenteditable]:empty::before { | ||
content: var(--placeholder); | ||
color: rgba(156, 163, 175); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters