Add keyboard shortcuts for resizing editors

This commit is contained in:
Quinten Kock 2025-11-13 23:59:38 +01:00
parent 26c56b13a3
commit 55aac46630
1 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,8 @@ export class Editor {
return true; return true;
}, },
}, },
{ key: "Alt--", run: () => this.changeWidth(-100) },
{ key: "Alt-=", run: () => this.changeWidth(100) },
]); ]);
this.view = new EditorView({ this.view = new EditorView({
doc: file.rootState.val.doc, doc: file.rootState.val.doc,
@ -128,6 +130,12 @@ export class Editor {
this.view.focus(); this.view.focus();
} }
changeWidth(increment: number) {
const w = parseInt(window.getComputedStyle(this.view.dom).width, 10);
this.view.dom.style.width = (w + increment) + 'px';
return true;
}
close() { close() {
if (this.deleteFn) { if (this.deleteFn) {
this.file.removeEditor(this, this.deleteFn); this.file.removeEditor(this, this.deleteFn);