From 241b97f0b450a2e4ddb762e373f56ae8ae253235 Mon Sep 17 00:00:00 2001 From: rhysd Date: Thu, 20 Apr 2017 14:47:48 +0900 Subject: [PATCH] add 'open-in-browser' key shortcut --- README.md | 17 +++++++++-------- renderer/key_handler.ts | 5 +++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f6389a1..f518df4 100644 --- a/README.md +++ b/README.md @@ -118,14 +118,15 @@ to know what you're doing. Object whose key is a key sequence and whose value is an action name. -| Action Name | Description | Default Key | -|-----------------|---------------------------------|-------------| -| `scroll-down` | Scroll down window | `j` | -| `scroll-up` | Scroll up window | `k` | -| `scroll-top` | Scroll up to top of window | `i` | -| `scroll-bottom` | Scroll down to bottom of window | `m` | -| `next-account` | Switch to next account | N/A | -| `prev-account` | Switch to previous account | N/A | +| Action Name | Description | Default Key | +|-------------------|---------------------------------|-------------| +| `scroll-down` | Scroll down window | `j` | +| `scroll-up` | Scroll up window | `k` | +| `scroll-top` | Scroll up to top of window | `i` | +| `scroll-bottom` | Scroll down to bottom of window | `m` | +| `next-account` | Switch to next account | N/A | +| `prev-account` | Switch to previous account | N/A | +| `open-in-browser` | Open current page in browser | N/A | If an action name starts with `/`, it will navigate to the path. For example, if you set `"/web/timelines/home"` to some key shortcut and you input the key, diff --git a/renderer/key_handler.ts b/renderer/key_handler.ts index 62a0f7c..32e627d 100644 --- a/renderer/key_handler.ts +++ b/renderer/key_handler.ts @@ -3,6 +3,8 @@ import * as Mousetrap from 'mousetrap'; import * as Ipc from './ipc'; import log from './log'; import {Config, Account} from '../main/config'; +import r from './require'; +const shell = r('electron').remote.shell; function scrollable() { const scrollable = document.querySelector('.scrollable'); @@ -49,6 +51,9 @@ const ShortcutActions = { 'prev-account': () => { Ipc.send('mstdn:prev-account'); }, + 'open-in-browser': () => { + shell.openExternal(window.location.href); + } } as {[action: string]: () => void}; export default function setupKeymaps(