FEATURE: Support keyboard back/forward navigation on DiscourseHub (#12028)

This commit is contained in:
Penar Musaraj 2021-02-10 11:25:32 -05:00 committed by GitHub
parent 1a159de36f
commit f2de7842bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { isAppWebview } from "discourse/lib/utilities";
import { later, run, schedule, throttle } from "@ember/runloop";
import {
nextTopicUrl,
@ -22,6 +23,10 @@ const DEFAULT_BINDINGS = {
C: { handler: "focusComposer" },
"ctrl+f": { handler: "showPageSearch", anonymous: true },
"command+f": { handler: "showPageSearch", anonymous: true },
"command+left": { handler: "webviewKeyboardBack" },
"command+[": { handler: "webviewKeyboardBack" },
"command+right": { handler: "webviewKeyboardForward" },
"command+]": { handler: "webviewKeyboardForward" },
"mod+p": { handler: "printTopic", anonymous: true },
d: { postAction: "deletePost" },
e: { postAction: "editPost" },
@ -788,4 +793,16 @@ export default {
toggleAdminActions() {
this.appEvents.trigger("topic:toggle-actions");
},
webviewKeyboardBack() {
if (isAppWebview()) {
window.history.back();
}
},
webviewKeyboardForward() {
if (isAppWebview()) {
window.history.forward();
}
},
};