click to replay prompt
This commit is contained in:
parent
d99b4d53e1
commit
f828384dba
|
|
@ -7,6 +7,7 @@ import { initHistory } from "./history.js"
|
|||
import { initHyperlink } from "./hyperlink.js"
|
||||
import { initInput } from "./input.js"
|
||||
import { initResize } from "./resize.js"
|
||||
import { initScrollback } from "./scrollback.js"
|
||||
import { startVramCounter } from "./vram.js"
|
||||
import { startConnection } from "./websocket.js"
|
||||
|
||||
|
|
@ -19,6 +20,7 @@ initHistory()
|
|||
initHyperlink()
|
||||
initInput()
|
||||
initResize()
|
||||
initScrollback()
|
||||
|
||||
startConnection()
|
||||
startVramCounter()
|
||||
|
|
@ -2,12 +2,16 @@
|
|||
// The scrollback shows your history of interacting with the shell.
|
||||
// input, output, etc
|
||||
|
||||
import { scrollback, $$ } from "./dom.js"
|
||||
import { randomId } from "../shared/utils.js"
|
||||
import type { CommandOutput } from "../shared/types.js"
|
||||
import { scrollback, cmdInput, $$ } from "./dom.js"
|
||||
import { randomId } from "../shared/utils.js"
|
||||
|
||||
type InputStatus = "waiting" | "streaming" | "ok" | "error"
|
||||
|
||||
export function initScrollback() {
|
||||
window.addEventListener("click", handleInputClick)
|
||||
}
|
||||
|
||||
export function autoScroll() {
|
||||
// requestAnimationFrame(() => scrollback.scrollTop = scrollback.scrollHeight - scrollback.clientHeight)
|
||||
// scrollback.scrollTop = scrollback.scrollHeight - scrollback.clientHeight
|
||||
|
|
@ -63,10 +67,11 @@ export function addOutput(id: string, output: CommandOutput) {
|
|||
item.textContent = content
|
||||
|
||||
const input = document.querySelector(`[data-id="${id}"].input`)
|
||||
if (input instanceof HTMLLIElement)
|
||||
if (input instanceof HTMLLIElement) {
|
||||
input.parentNode!.insertBefore(item, input.nextSibling)
|
||||
else
|
||||
} else {
|
||||
insert(item)
|
||||
}
|
||||
|
||||
autoScroll()
|
||||
}
|
||||
|
|
@ -135,3 +140,13 @@ function processOutput(output: CommandOutput): ["html" | "text", string] {
|
|||
|
||||
return [html ? "html" : "text", content]
|
||||
}
|
||||
|
||||
function handleInputClick(e: MouseEvent) {
|
||||
const target = e.target
|
||||
|
||||
if (!(target instanceof HTMLElement)) return
|
||||
|
||||
if (target.matches(".input .content")) {
|
||||
cmdInput.value = target.textContent
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user