Skip to content

Commit dde3ebd

Browse files
committed
feat(pages): bind backspace to go backwards
1 parent 3420b2b commit dde3ebd

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

apps/client/src/code/pages/composables/use-keyboard-shortcuts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ export function useKeyboardShortcuts() {
149149
return true;
150150
}
151151

152+
if (event.code === 'Backspace' && activeElem == null) {
153+
await internals.pages.goBackward();
154+
return true;
155+
}
152156
if (event.code === 'Backspace' && activeElem != null) {
153157
await page.editing.start(activeElem);
154158
page.editing.react.editor?.commands.deleteSelection();

apps/client/src/code/pages/pages.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class Pages {
109109
}
110110

111111
async setupPage(pageId: string) {
112-
internals.pages.react.page?.deactivate();
112+
this.react.page?.deactivate();
113113

114114
let page;
115115

@@ -121,7 +121,7 @@ export class Pages {
121121
this.pageCache.add(page);
122122
}
123123

124-
internals.pages.react.page = page;
124+
this.react.page = page;
125125

126126
pagesStore().loading = false;
127127

@@ -231,6 +231,22 @@ export class Pages {
231231
}
232232
}
233233

234+
async goBackward() {
235+
await this.goToPage(
236+
this.react.pathPageIds[
237+
this.react.pathPageIds.indexOf(this.react.pageId!) - 1
238+
],
239+
);
240+
}
241+
242+
async goForward() {
243+
await this.goToPage(
244+
this.react.pathPageIds[
245+
this.react.pathPageIds.indexOf(this.react.pageId!) + 1
246+
],
247+
);
248+
}
249+
234250
destroy() {
235251
for (const page of this.pageCache.react.cache) {
236252
page.destroy();

apps/client/src/layouts/PagesLayout/MainContent/DisplayUI/DisplayLeftBtns.vue

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:disable="
88
internals.pages.react.pageId === internals.pages.react.pathPageIds[0]
99
"
10-
@click="goBackward()"
10+
@click="internals.pages.goBackward()"
1111
>
1212
<q-tooltip
1313
anchor="center right"
@@ -29,7 +29,7 @@
2929
internals.pages.react.pageId ===
3030
internals.pages.react.pathPageIds.at(-1)
3131
"
32-
@click="goForward()"
32+
@click="internals.pages.goForward()"
3333
>
3434
<q-tooltip
3535
anchor="center right"
@@ -88,24 +88,6 @@
8888
import TakeScreenshotDialog from '../../MainToolbar/TakeScreenshotDialog.vue';
8989
9090
const page = computed(() => internals.pages.react.page);
91-
92-
async function goBackward() {
93-
await internals.pages.goToPage(
94-
internals.pages.react.pathPageIds[
95-
internals.pages.react.pathPageIds.indexOf(internals.pages.react.pageId!) -
96-
1
97-
],
98-
);
99-
}
100-
101-
async function goForward() {
102-
await internals.pages.goToPage(
103-
internals.pages.react.pathPageIds[
104-
internals.pages.react.pathPageIds.indexOf(internals.pages.react.pageId!) +
105-
1
106-
],
107-
);
108-
}
10991
</script>
11092

11193
<style lang="scss" scoped>

0 commit comments

Comments
 (0)