aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/GlobalKeyHandler.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-21 14:55:48 -0500
committerbobzel <zzzman@gmail.com>2023-12-21 14:55:48 -0500
commit1caba64ee0f32ee8af79263cd4ef2a8bc5d5146e (patch)
tree0fa0e957d1f342fdc6ed4a4b43f5dddfddb1298a /src/client/views/GlobalKeyHandler.ts
parent02eb7da95df283606d4275a22d9451cef371c3b5 (diff)
parent2691b951d96f2ce7652acbea9e340b61737b3b57 (diff)
Merge branch 'moreUpgrading' into dataViz-annotations
Diffstat (limited to 'src/client/views/GlobalKeyHandler.ts')
-rw-r--r--src/client/views/GlobalKeyHandler.ts54
1 files changed, 20 insertions, 34 deletions
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index 87f81fe76..4015fb321 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -1,5 +1,5 @@
import { random } from 'lodash';
-import { action, runInAction } from 'mobx';
+import { action } from 'mobx';
import { Doc, DocListCast } from '../../fields/Doc';
import { Id } from '../../fields/FieldSymbols';
import { InkTool } from '../../fields/InkField';
@@ -15,7 +15,6 @@ import { SnappingManager } from '../util/SnappingManager';
import { UndoManager } from '../util/UndoManager';
import { CollectionDockingView } from './collections/CollectionDockingView';
import { CollectionFreeFormView } from './collections/collectionFreeForm';
-import { CollectionFreeFormViewChrome } from './collections/CollectionMenu';
import { CollectionStackedTimeline } from './collections/CollectionStackedTimeline';
import { ContextMenu } from './ContextMenu';
import { DocumentDecorations } from './DocumentDecorations';
@@ -91,8 +90,8 @@ export class KeyManager {
});
nudge = (x: number, y: number, label: string) => {
- const nudgeable = SelectionManager.Views().some(dv => dv.CollectionFreeFormDocumentView?.nudge);
- nudgeable && UndoManager.RunInBatch(() => SelectionManager.Views().map(dv => dv.CollectionFreeFormDocumentView?.nudge(x, y)), label);
+ const nudgeable = SelectionManager.Views.some(dv => dv.CollectionFreeFormDocumentView?.nudge);
+ nudgeable && UndoManager.RunInBatch(() => SelectionManager.Views.map(dv => dv.CollectionFreeFormDocumentView?.nudge(x, y)), label);
return { stopPropagation: nudgeable, preventDefault: nudgeable };
};
@@ -100,18 +99,18 @@ export class KeyManager {
switch (keyname) {
case 'u':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- const ungroupings = SelectionManager.Views();
+ const ungroupings = SelectionManager.Views;
UndoManager.RunInBatch(() => ungroupings.map(dv => (dv.layoutDoc.group = undefined)), 'ungroup');
SelectionManager.DeselectAll();
}
break;
case 'g':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- const selected = SelectionManager.Views();
+ const selected = SelectionManager.Views;
const collectionView = selected.reduce((col, dv) => (col === null || dv.CollectionFreeFormView === col ? dv.CollectionFreeFormView : undefined), null as null | undefined | CollectionFreeFormView);
if (collectionView) {
UndoManager.RunInBatch(() =>
- collectionView._marqueeViewRef.current?.collection(e, true, SelectionManager.Docs())
+ collectionView._marqueeViewRef.current?.collection(e, true, SelectionManager.Docs)
, 'grouping');
break;
}
@@ -127,7 +126,7 @@ export class KeyManager {
Doc.ActiveTool = InkTool.None;
DragManager.CompleteWindowDrag?.(true);
var doDeselect = true;
- if (SnappingManager.GetIsDragging()) {
+ if (SnappingManager.IsDragging) {
DragManager.AbortDrag();
} else if (CollectionDockingView.Instance?.HasFullScreen) {
CollectionDockingView.Instance?.CloseFullScreen();
@@ -146,7 +145,6 @@ export class KeyManager {
SharingManager.Instance.close();
if (!GroupManager.Instance.isOpen) SettingsManager.Instance.close();
GroupManager.Instance.close();
- CollectionFreeFormViewChrome.Instance?.clearKeepPrimitiveMode();
window.getSelection()?.empty();
document.body.focus();
break;
@@ -184,14 +182,14 @@ export class KeyManager {
case 'arrowdown': return this.nudge(0, 10, 'nudge down');
case 'u' :
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
- UndoManager.RunInBatch(() => SelectionManager.Docs().forEach(doc => (doc.group = undefined)), 'unggroup');
+ UndoManager.RunInBatch(() => SelectionManager.Docs.forEach(doc => (doc.group = undefined)), 'unggroup');
SelectionManager.DeselectAll();
}
break;
case 'g':
if (document.activeElement?.tagName !== 'INPUT' && document.activeElement?.tagName !== 'TEXTAREA') {
const randomGroup = random(0, 1000);
- UndoManager.RunInBatch(() => SelectionManager.Docs().forEach(doc => (doc.group = randomGroup)), 'group');
+ UndoManager.RunInBatch(() => SelectionManager.Docs.forEach(doc => (doc.group = randomGroup)), 'group');
SelectionManager.DeselectAll();
}
break;
@@ -210,7 +208,7 @@ export class KeyManager {
switch (keyname) {
case 'ƒ':
case 'f':
- const dv = SelectionManager.Views()?.[0];
+ const dv = SelectionManager.Views?.[0];
UndoManager.RunInBatch(() => dv.CollectionFreeFormDocumentView?.float(), 'float');
}
@@ -258,8 +256,8 @@ export class KeyManager {
}
break;
case 'f':
- if (SelectionManager.Views().length === 1 && SelectionManager.Views()[0].ComponentView?.search) {
- SelectionManager.Views()[0].ComponentView?.search?.('', false, false);
+ if (SelectionManager.Views.length === 1 && SelectionManager.Views[0].ComponentView?.search) {
+ SelectionManager.Views[0].ComponentView?.search?.('', false, false);
} else {
const searchBtn = DocListCast(Doc.MyLeftSidebarMenu.data).find(d => d.target === Doc.MySearcher);
if (searchBtn) {
@@ -301,17 +299,11 @@ export class KeyManager {
preventDefault = false;
break;
case 'x':
- if (SelectionManager.Views().length) {
+ if (SelectionManager.Views.length) {
const bds = DocumentDecorations.Instance.Bounds;
- const pt = SelectionManager.Views()[0]
- .props.ScreenToLocalTransform()
- .transformPoint(bds.x + (bds.r - bds.x) / 2, bds.y + (bds.b - bds.y) / 2);
- const text =
- `__DashDocId(${pt?.[0] || 0},${pt?.[1] || 0}):` +
- SelectionManager.Views()
- .map(dv => dv.Document[Id])
- .join(':');
- SelectionManager.Views().length && navigator.clipboard.writeText(text);
+ const pt = SelectionManager.Views[0].props.ScreenToLocalTransform().transformPoint(bds.x + (bds.r - bds.x) / 2, bds.y + (bds.b - bds.y) / 2);
+ const text = `__DashDocId(${pt?.[0] || 0},${pt?.[1] || 0}):` + SelectionManager.Views.map(dv => dv.Document[Id]).join(':');
+ SelectionManager.Views.length && navigator.clipboard.writeText(text);
DocumentDecorations.Instance.onCloseClick(true);
stopPropagation = false;
preventDefault = false;
@@ -320,15 +312,9 @@ export class KeyManager {
case 'c':
if ((document.activeElement as any)?.type !== 'text' && !AnchorMenu.Instance.Active && DocumentDecorations.Instance.Bounds.r - DocumentDecorations.Instance.Bounds.x > 2) {
const bds = DocumentDecorations.Instance.Bounds;
- const pt = SelectionManager.Views()[0]
- .props.ScreenToLocalTransform()
- .transformPoint(bds.x + (bds.r - bds.x) / 2, bds.y + (bds.b - bds.y) / 2);
- const text =
- `__DashCloneId(${pt?.[0] || 0},${pt?.[1] || 0}):` +
- SelectionManager.Views()
- .map(dv => dv.Document[Id])
- .join(':');
- SelectionManager.Views().length && navigator.clipboard.writeText(text);
+ const pt = SelectionManager.Views[0].props.ScreenToLocalTransform().transformPoint(bds.x + (bds.r - bds.x) / 2, bds.y + (bds.b - bds.y) / 2);
+ const text = `__DashCloneId(${pt?.[0] || 0},${pt?.[1] || 0}):` + SelectionManager.Views.map(dv => dv.Document[Id]).join(':');
+ SelectionManager.Views.length && navigator.clipboard.writeText(text);
stopPropagation = false;
}
preventDefault = false;
@@ -346,7 +332,7 @@ export class KeyManager {
if (!plain) return;
const clone = plain.startsWith('__DashCloneId(');
const docids = plain.split(':'); // hack! docids[0] is the top left of the selection rectangle
- const addDocument = SelectionManager.Views().lastElement()?.ComponentView?.addDocument;
+ const addDocument = SelectionManager.Views.lastElement()?.ComponentView?.addDocument;
if (addDocument && (plain.startsWith('__DashDocId(') || clone)) {
Doc.Paste(docids.slice(1), clone, addDocument);
}