Use DOMOutputAdapter to render output into an element:
import { Terminal } from "input-terminal";
import { DOMOutputAdapter } from "input-terminal/dom";
const input = document.getElementById("terminal") as HTMLInputElement;
const outputElement = document.getElementById("output") as HTMLElement;
const terminal = new Terminal({
input,
output: new DOMOutputAdapter(outputElement)
});
terminal.init();
terminal.stdout("This is standard output");
The adapter wraps each value in a <span> and assigns a class based on the output operation:
input-terminal-stdout for stdoutinput-terminal-stderr for stderrEach span also receives data-sequence and data-timestamp attributes. The adapter leaves those values out of the visible text. CSS and scripts can read the attributes when needed.
Calling terminal.clearOutput() removes the output element's child nodes.