Spaces:
Sleeping
Sleeping
Download src/lib/putTextInInput.ts from network01/ai-comic-factory: direct link, hf CLI and curl.
- Browser
- Download file 455 Bytes
-
https://huggingface.co/spaces/network01/ai-comic-factory/resolve/main/src/lib/putTextInInput.ts
- Command line
-
hf download hf://spaces/network01/ai-comic-factory/src/lib/putTextInInput.ts
-
curl -L -o putTextInInput.ts https://huggingface.co/spaces/network01/ai-comic-factory/resolve/main/src/lib/putTextInInput.ts
455 Bytes
| export function putTextInInput(input?: HTMLInputElement, text: string = "") { | |
| if (!input) { return } | |
| const nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor( | |
| window.HTMLInputElement.prototype, | |
| "value" | |
| )?.set; | |
| // fallback | |
| if (!nativeTextAreaValueSetter) { | |
| input.value = text | |
| return | |
| } | |
| nativeTextAreaValueSetter.call(input, text) | |
| const event = new Event('input', { bubbles: true }); | |
| input.dispatchEvent(event) | |
| } |