Add cmd-k to delete current line
All checks were successful
Build / build (push) Successful in 2m31s

This commit is contained in:
Leon Mika 2026-03-14 21:52:13 +11:00
parent 3e8d101eec
commit d64779f660
10 changed files with 166 additions and 0 deletions

View file

@ -0,0 +1,42 @@
import { Controller } from "@hotwired/stimulus"
export class PromptController extends Controller {
static targets = [
"label",
"input",
];
connect() {
this._callback = null;
window.runtime.EventsOn("prompt-request", (data) => {
this.prompt(data.label, (res) => {
window.runtime.EventsEmit("prompt-response", res);
});
});
}
prompt(label, callback) {
this._callback = callback;
this.labelTarget.textContent = label;
this.inputTarget.value = "";
this.element.showModal();
this.inputTarget.focus();
}
submit(ev) {
ev.preventDefault();
let value = this.inputTarget.value;
this.element.close();
if (this._callback) {
this._callback(value);
this._callback = null;
}
}
dismiss(ev) {
ev.preventDefault();
this._callback = null;
this.element.close();
}
}