mirror of
https://github.com/heyman/heynote.git
synced 2025-08-14 08:48:36 +02:00
Refactor the way we handle copy/cut/paste in Emacs mode
Previously we listened for the key bindings for copy, cut and paste in the Electron main process, and triggered the event using copy(), paste() and cut() methods on win.webContent. Now this is fully handled within the renderer process using the window.navigator.clipboard API. This will make it simpler to implement fully customizable key bindings.
This commit is contained in:
36
tests/emacs-clipboard-keys.spec.js
Normal file
36
tests/emacs-clipboard-keys.spec.js
Normal file
@ -0,0 +1,36 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
import { HeynotePage } from "./test-utils.js";
|
||||
|
||||
let heynotePage
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
heynotePage = new HeynotePage(page)
|
||||
await heynotePage.goto()
|
||||
});
|
||||
|
||||
|
||||
test("test emacs copy/pase/cut key bindings", async ({ page, browserName }) => {
|
||||
if (browserName !== "chromium") {
|
||||
// This test only works in Chromium due to accessing the clipboard
|
||||
test.skip()
|
||||
}
|
||||
await page.locator("css=.status-block.settings").click()
|
||||
//await page.locator("css=li.tab-editing").click()
|
||||
await page.locator("css=select.keymap").selectOption("emacs")
|
||||
await page.locator("css=select.metaKey").selectOption("alt")
|
||||
await page.locator("body").press("Escape")
|
||||
|
||||
await page.locator("body").pressSequentially("test")
|
||||
await page.locator("body").press(heynotePage.isMac ? "Meta+A" : "Control+A")
|
||||
await page.locator("body").press("Alt+W")
|
||||
expect(await heynotePage.getBlockContent(0)).toBe("test")
|
||||
await page.locator("body").press("Control+Y")
|
||||
expect(await heynotePage.getBlockContent(0)).toBe("testtest")
|
||||
|
||||
await page.locator("body").press(heynotePage.isMac ? "Meta+A" : "Control+A")
|
||||
await page.locator("body").press("Control+W")
|
||||
expect(await heynotePage.getBlockContent(0)).toBe("")
|
||||
await page.locator("body").press("Control+Y")
|
||||
await page.locator("body").press("Control+Y")
|
||||
expect(await heynotePage.getBlockContent(0)).toBe("testtesttesttest")
|
||||
})
|
Reference in New Issue
Block a user