diff options
author | Lionel Han <47760119+IGoByJoe@users.noreply.github.com> | 2020-06-29 14:42:36 -0700 |
---|---|---|
committer | Lionel Han <47760119+IGoByJoe@users.noreply.github.com> | 2020-06-29 14:42:36 -0700 |
commit | 2646aa86bc6d676e848028601f9a4fedeefe35be (patch) | |
tree | 42d208346a283f788268c9d74de7dcc835bd84a6 /src/client/util/SelectionManager.ts | |
parent | 992a65ec6f828dda0adcd3cd121896f07f64af87 (diff) | |
parent | 73bbc602fb964c82999faccfdde8eeca6fbf08c4 (diff) |
pull
Diffstat (limited to 'src/client/util/SelectionManager.ts')
-rw-r--r-- | src/client/util/SelectionManager.ts | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts index eb905d237..024532f90 100644 --- a/src/client/util/SelectionManager.ts +++ b/src/client/util/SelectionManager.ts @@ -3,6 +3,8 @@ import { Doc } from "../../fields/Doc"; import { DocumentView } from "../views/nodes/DocumentView"; import { computedFn } from "mobx-utils"; import { List } from "../../fields/List"; +import { Scripting } from "./Scripting"; +import { DocumentManager } from "./DocumentManager"; export namespace SelectionManager { @@ -10,17 +12,12 @@ export namespace SelectionManager { @observable IsDragging: boolean = false; SelectedDocuments: ObservableMap<DocumentView, boolean> = new ObservableMap(); - clearSelection() { - if (window.getSelection) { window.getSelection()?.removeAllRanges(); } - else if (document.getSelection()) { document.getSelection()?.empty(); } - } @action SelectDoc(docView: DocumentView, ctrlPressed: boolean): void { // if doc is not in SelectedDocuments, add it if (!manager.SelectedDocuments.get(docView)) { if (!ctrlPressed) { this.DeselectAll(); - this.clearSelection(); } manager.SelectedDocuments.set(docView, true); @@ -86,3 +83,9 @@ export namespace SelectionManager { } } + +Scripting.addGlobal(function selectDoc(doc: any) { + const view = DocumentManager.Instance.getDocumentView(doc); + view && SelectionManager.SelectDoc(view, false); + //Doc.UserDoc().activeSelection = new List([doc]); +});
\ No newline at end of file |