Fix so that Enter can be recorded in RecordKeyInput for custom key bindings

This commit is contained in:
Jonatan Heyman 2026-02-03 15:34:33 +01:00
parent 1f7558d54a
commit 51ee9e3416
4 changed files with 29 additions and 6 deletions

View File

@ -26,6 +26,7 @@ Heynote now includes a lightweight drawing tool for adding quick, freehand annot
- New lines in a Plaintext, Math and SQL blocks now inherits the indentation from the previous line
(other languages should already have this behaviour for new lines)
- Add support for [Mermaid](https://mermaid.js.org/) blocks
- Fix issue not being able to record the Enter key when creating custom key bindings
## v2.7.2

View File

@ -97,7 +97,7 @@
ref="keys"
/>
</div>
<div class="field">
<div class="field command-field">
<label>Command</label>
<AutoComplete
dropdown

View File

@ -43,9 +43,7 @@
event.preventDefault()
//console.log("event", event, event.code, keyName(event))
if (event.key === "Enter") {
this.$emit("enter")
} else if (event.key === "Escape") {
if (event.key === "Escape") {
if (this.keys.length > 0) {
this.keys = []
} else {

View File

@ -20,7 +20,7 @@ test("add custom key binding", async ({page}) => {
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog")).toBeVisible()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog input.keys")).toBeFocused()
await page.locator("body").press("Control+Shift+H")
await page.locator("body").press("Enter")
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .command-field input").click()
await page.locator("body").pressSequentially("language")
await page.locator(".p-autocomplete-list li.p-autocomplete-option.p-focus").click()
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .save").click()
@ -36,6 +36,30 @@ test("add custom key binding", async ({page}) => {
)
})
test("add enter as custom key binding", async ({page}) => {
await page.locator("css=.status-block.settings").click()
await page.locator("css=.overlay .settings .dialog .sidebar li.tab-keyboard-bindings").click()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings")).toBeVisible()
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-keybinding").click()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog")).toBeVisible()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog input.keys")).toBeFocused()
await page.locator("body").press("Control+Enter")
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .command-field input").click()
await page.locator("body").pressSequentially("language")
await page.locator(".p-autocomplete-list li.p-autocomplete-option.p-focus").click()
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .save").click()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings table tr.keybind-user")).toHaveCount(1)
expect((await heynotePage.getSettings()).keyBindings).toEqual([{key:"Ctrl-Enter", command:"openLanguageSelector"}])
await page.locator("css=.overlay .settings .dialog .bottom-bar .close").click()
await page.locator("body").press("Control+Enter")
await expect(page.locator("css=.language-selector .items > li.selected")).toBeVisible()
await page.locator("body").press("Escape")
await expect(page.locator("css=.status .status-block.lang")).toHaveAttribute(
"title",
"Change language for current block (Ctrl+Enter)"
)
})
test("delete custom key binding", async ({page}) => {
await page.locator("css=.status-block.settings").click()
await page.locator("css=.overlay .settings .dialog .sidebar li.tab-keyboard-bindings").click()
@ -44,7 +68,7 @@ test("delete custom key binding", async ({page}) => {
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog")).toBeVisible()
await expect(page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog input.keys")).toBeFocused()
await page.locator("body").press("Control+Shift+H")
await page.locator("body").press("Enter")
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .command-field input").click()
await page.locator("body").pressSequentially("language")
await page.locator(".p-autocomplete-list li.p-autocomplete-option.p-focus").click()
await page.locator("css=.settings .tab-content.tab-keyboard-bindings .add-key-binding-dialog .save").click()