From a134e65fd086e8ca35796101c2fc6fc70a747160 Mon Sep 17 00:00:00 2001 From: Chris Lozac'h Date: Mon, 27 Apr 2020 21:55:11 -0700 Subject: [PATCH 1/3] Revert "Remove unsafe-vela from CSP #41" This reverts commit 20ad9560b7cfaf71adf65dbc3645b3554c2ab598. --- src/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.json b/src/manifest.json index 4e04090c..deb52400 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -6,7 +6,7 @@ "icons": { "128": "assets/icon-128.png" }, - "content_security_policy": "script-src 'self'; object-src 'self'", + "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", "permissions": [ "activeTab", "alarms", From 790f1e6962a48e4ef3fe62c1f077eaa31b1c5039 Mon Sep 17 00:00:00 2001 From: Chris Lozac'h Date: Thu, 30 Apr 2020 23:56:44 -0700 Subject: [PATCH 2/3] When hitting Enter/Return after editing a title, start a new block at the top Problem: Moving from title editing to block editing currently requires the mouse. Solution: This mod provides a means of getting from title to blocks without leaving the keyboard. --- src/ts/contentScripts/dispatcher/index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ts/contentScripts/dispatcher/index.ts b/src/ts/contentScripts/dispatcher/index.ts index 21c3656b..480629e7 100644 --- a/src/ts/contentScripts/dispatcher/index.ts +++ b/src/ts/contentScripts/dispatcher/index.ts @@ -20,6 +20,17 @@ const dispatchMap = new Map([ browser.runtime.onMessage.addListener((command) => dispatchMap.get(command)?.()); +document.addEventListener('keydown', ev => { + const enter = 'Enter'; + const isExitingTitle = (ev: KeyboardEvent) => { + return ev.target.parentElement instanceof HTMLHeadingElement; + } + + if (ev.key === enter && isExitingTitle(ev)) { + Roam.createBlockAtTop(); + } +}); + document.addEventListener('keyup', ev => { if (ev.key === guard) replaceFuzzyDate(); }); \ No newline at end of file From d4de248901fe43199d7db96721b05c25cf005bb2 Mon Sep 17 00:00:00 2001 From: Chris Lozac'h Date: Fri, 1 May 2020 12:14:14 -0700 Subject: [PATCH 3/3] When hitting Enter/Return with no blocks selected, start a new block at the top Problem: When no blocks are currently selected, Roam requires a mouse click to begin editing. Solution: This mod allows block editing without leaving the keyboard. --- src/ts/contentScripts/dispatcher/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ts/contentScripts/dispatcher/index.ts b/src/ts/contentScripts/dispatcher/index.ts index 480629e7..ffb88e25 100644 --- a/src/ts/contentScripts/dispatcher/index.ts +++ b/src/ts/contentScripts/dispatcher/index.ts @@ -25,8 +25,11 @@ document.addEventListener('keydown', ev => { const isExitingTitle = (ev: KeyboardEvent) => { return ev.target.parentElement instanceof HTMLHeadingElement; } + const isNoBlockSelected = (ev: KeyboardEvent) => { + return ev.target instanceof HTMLBodyElement; + } - if (ev.key === enter && isExitingTitle(ev)) { + if (ev.key === enter && (isExitingTitle(ev) || isNoBlockSelected(ev))) { Roam.createBlockAtTop(); } });