aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-05-10 16:09:04 -0400
committerbobzel <zzzman@gmail.com>2022-05-10 16:09:04 -0400
commit35a68e69f6a995496a090a1e2291a9f18387411f (patch)
tree7252baae6b5ee401ea186c2fda53ffeb09986a6c /src/client/views/GlobalKeyHandler.ts
parentf072a9f2c1ad69eb8ae4242fa5d2e18bbd94f6ef (diff)
fixed shift-clicking to add to doc decorations selection
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index 914802041..767efdbc2 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -1,5 +1,5 @@
import { random } from "lodash";
-import { action, observable } from "mobx";
+import { action, observable, runInAction } from "mobx";
import { DateField } from "../../fields/DateField";
import { Doc, DocListCast } from "../../fields/Doc";
import { Id } from "../../fields/FieldSymbols";
@@ -30,7 +30,7 @@ import { DocumentLinksButton } from "./nodes/DocumentLinksButton";
import { AnchorMenu } from "./pdf/AnchorMenu";
const modifiers = ["control", "meta", "shift", "alt"];
-type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo | Promise<KeyControlInfo>;
+type KeyHandler = (keycode: string, e: KeyboardEvent) => KeyControlInfo;
type KeyControlInfo = {
preventDefault: boolean,
stopPropagation: boolean
@@ -39,7 +39,6 @@ type KeyControlInfo = {
export class KeyManager {
public static Instance: KeyManager = new KeyManager();
private router = new Map<string, KeyHandler>();
- @observable ShiftPressed = false;
constructor() {
const isMac = navigator.platform.toLowerCase().indexOf("mac") >= 0;
@@ -53,11 +52,11 @@ export class KeyManager {
}
public unhandle = action((e: KeyboardEvent) => {
- if (e.key?.toLowerCase() === "shift") KeyManager.Instance.ShiftPressed = false;
+ if (e.key?.toLowerCase() === "shift") runInAction(() => DocumentDecorations.Instance.AddToSelection = false);
});
- public handle = action(async (e: KeyboardEvent) => {
- if (e.key?.toLowerCase() === "shift" && e.ctrlKey && e.altKey) KeyManager.Instance.ShiftPressed = true;
+ public handle = action((e: KeyboardEvent) => {
+ if (e.key?.toLowerCase() === "shift") DocumentDecorations.Instance.AddToSelection = true;
//if (!Doc.UserDoc().noviceMode && e.key.toLocaleLowerCase() === "shift") DocServer.UPDATE_SERVER_CACHE(true);
const keyname = e.key && e.key.toLowerCase();
this.handleGreedy(keyname);
@@ -74,7 +73,7 @@ export class KeyManager {
return;
}
- const control = await handleConstrained(keyname, e);
+ const control = handleConstrained(keyname, e);
control.stopPropagation && e.stopPropagation();
control.preventDefault && e.preventDefault();
@@ -173,7 +172,7 @@ export class KeyManager {
};
});
- private shift = action(async (keyname: string) => {
+ private shift = action((keyname: string) => {
const stopPropagation = false;
const preventDefault = false;
@@ -334,9 +333,7 @@ export class KeyManager {
}
}
- async printClipboard() {
- const text: string = await navigator.clipboard.readText();
- }
+ getClipboard() { return navigator.clipboard.readText(); }
private ctrl_shift = action((keyname: string) => {
const stopPropagation = true;