Add basic key bindings for note creator
This commit is contained in:
parent
56ab7c2613
commit
02aed54ca3
1 changed files with 20 additions and 1 deletions
|
|
@ -21,6 +21,24 @@ function updateTextareaHeight() {
|
||||||
input.value.style.height = "0px";
|
input.value.style.height = "0px";
|
||||||
input.value.style.height = `${input.value.scrollHeight}px`;
|
input.value.style.height = `${input.value.scrollHeight}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onInput() {
|
||||||
|
updateTextareaHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onKeyPress(ev: KeyboardEvent) {
|
||||||
|
if (ev.key === "Escape") {
|
||||||
|
emit("close");
|
||||||
|
ev.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.key === "Enter" && !ev.shiftKey) {
|
||||||
|
emit("finish", text.value);
|
||||||
|
ev.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -38,7 +56,8 @@ function updateTextareaHeight() {
|
||||||
v-model="text"
|
v-model="text"
|
||||||
class="z-1 flex-1 resize-none bg-neutral-100 px-1 outline-none"
|
class="z-1 flex-1 resize-none bg-neutral-100 px-1 outline-none"
|
||||||
autofocus
|
autofocus
|
||||||
@input="updateTextareaHeight()"
|
@input="onInput"
|
||||||
|
@keypress="onKeyPress"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
|
||||||
<div class="ml-0.5 flex h-6 items-center">
|
<div class="ml-0.5 flex h-6 items-center">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue