aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-06 19:46:43 -0500
committerbobzel <zzzman@gmail.com>2025-03-06 19:46:43 -0500
commit1ab6f6c87b746e0c2898694216db50d5faadf7f5 (patch)
tree84349c4bcbdfa0a53c4937421867e7665e7da663 /src/client/views/GlobalKeyHandler.ts
parent5ad858090f3006631062877d90120e3cc505fada (diff)
a bunch of changes to improve how docs are selected automatically when created.
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index b200aff65..2d342d1b1 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -23,7 +23,6 @@ import { CollectionFreeFormDocumentView } from './nodes/CollectionFreeFormDocume
import { DocumentLinksButton } from './nodes/DocumentLinksButton';
import { DocumentView } from './nodes/DocumentView';
import { OpenWhereMod } from './nodes/OpenWhere';
-import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox';
import { AnchorMenu } from './pdf/AnchorMenu';
const modifiers = ['control', 'meta', 'shift', 'alt'];
@@ -75,7 +74,6 @@ export class KeyManager {
public handle = action((e: KeyboardEvent) => {
// accumulate buffer of characters to insert in a new text note. once the note is created, it will stop keyboard events from reaching this function.
- if (FormattedTextBox.SelectOnLoadChar) FormattedTextBox.SelectOnLoadChar += e.key === 'Enter' ? '\n' : e.key;
const keyname = e.key && e.key.toLowerCase();
this.handleGreedy(/* keyname */);
@@ -106,6 +104,10 @@ export class KeyManager {
};
private unmodified = action((keyname: string, e: KeyboardEvent) => {
+ const nothing = {
+ stopPropagation: false,
+ preventDefault: false,
+ };
switch (keyname) {
case 'u':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
@@ -169,17 +171,14 @@ export class KeyManager {
return { stopPropagation: true, preventDefault: true };
}
break;
- case 'arrowleft': return (e.target as any).type !== 'text' && this.nudge(-1, 0, 'nudge left') // if target is an input box, then we don't want to nudge any Docs since we're justing moving within the text itself.
- case 'arrowright': return (e.target as any).type !== 'text' && this.nudge( 1, 0, 'nudge right');
- case 'arrowup': return (e.target as any).type !== 'text' && this.nudge(0, -1, 'nudge up');
- case 'arrowdown': return (e.target as any).type !== 'text' && this.nudge(0, 1, 'nudge down');
+ case 'arrowleft': return (e.target as HTMLInputElement)?.type !== 'text' ? this.nudge(-1, 0, 'nudge left') : nothing; // if target is an input box, then we don't want to nudge any Docs since we're justing moving within the text itself.
+ case 'arrowright': return (e.target as HTMLInputElement)?.type !== 'text' ? this.nudge( 1, 0, 'nudge right') : nothing;
+ case 'arrowup': return (e.target as HTMLInputElement)?.type !== 'text' ? this.nudge(0, -1, 'nudge up') : nothing;
+ case 'arrowdown': return (e.target as HTMLInputElement | null)?.type !== 'text'? this.nudge(0, 1, 'nudge down'): nothing;
default:
} // prettier-ignore
- return {
- stopPropagation: false,
- preventDefault: false,
- };
+ return nothing;
});
private shift = action((keyname: string) => {