Use lexical in the command line

This commit is contained in:
Jorge Manrubia
2025-07-01 12:15:02 +02:00
parent 939d68b941
commit 0f7b45ab38
5 changed files with 38 additions and 17 deletions
@@ -2,6 +2,7 @@ import { Controller } from "@hotwired/stimulus"
import { HttpStatus } from "helpers/http_helpers"
import { isMultiLineString } from "helpers/text_helpers";
import { marked } from "marked"
import { nextFrame } from "helpers/timing_helpers";
export default class extends Controller {
static targets = [ "input", "form", "output", "confirmation", "recentCommands" ]
@@ -14,9 +15,11 @@ export default class extends Controller {
// Actions
focus() {
this.inputTarget.setSelectionRange(this.inputTarget.value.length, this.inputTarget.value.length)
async focus() {
await nextFrame()
this.inputTarget.focus()
this.inputTarget.selection.placeCursorAtTheEnd()
}
executeCommand(event) {
@@ -38,6 +41,11 @@ export default class extends Controller {
this.#hideOutput()
}
submitCommand() {
this.formTarget.requestSubmit()
this.#reset()
}
handleKeyPress(event) {
if (this.waitingForConfirmationValue) {
this.#handleConfirmationKey(event.key.toLowerCase())
@@ -175,8 +183,7 @@ export default class extends Controller {
this.inputTarget.value = this.originalInputValue
this.confirmationTarget.value = "confirmed"
this.#hideOutput()
this.formTarget.requestSubmit()
this.#reset()
this.submitCommand()
}
#showOutput(markdown) {