#hyperlinks
This commit is contained in:
parent
2fce2d914a
commit
26855ce388
|
|
@ -141,6 +141,10 @@
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
#scrollback .output a {
|
||||
margin-right: 15px;
|
||||
}
|
||||
|
||||
#scrollback .input .content {
|
||||
margin-left: var(--cli-status-width);
|
||||
}
|
||||
|
|
|
|||
24
app/src/js/hyperlink.ts
Normal file
24
app/src/js/hyperlink.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { runCommand } from "./shell.js"
|
||||
import { focusInput } from "./focus.js"
|
||||
|
||||
export function initHyperlink() {
|
||||
window.addEventListener("click", handleClick)
|
||||
}
|
||||
|
||||
function handleClick(e: MouseEvent) {
|
||||
const target = e.target
|
||||
|
||||
if (!(target instanceof HTMLElement)) return
|
||||
|
||||
const a = target.closest("a")
|
||||
if (!a) return
|
||||
|
||||
const href = a.getAttribute("href")
|
||||
if (!href) return
|
||||
|
||||
if (href.startsWith("#")) {
|
||||
e.preventDefault()
|
||||
runCommand(href.slice(1))
|
||||
focusInput()
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ import { initCursor } from "./cursor.js"
|
|||
import { initEditor } from "./editor.js"
|
||||
import { initFocus } from "./focus.js"
|
||||
import { initHistory } from "./history.js"
|
||||
import { initHyperlink } from "./hyperlink.js"
|
||||
import { initInput } from "./input.js"
|
||||
import { initResize } from "./resize.js"
|
||||
import { startVramCounter } from "./vram.js"
|
||||
|
|
@ -13,6 +14,7 @@ initCursor()
|
|||
initFocus()
|
||||
initEditor()
|
||||
initHistory()
|
||||
initHyperlink()
|
||||
initInput()
|
||||
initResize()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user