aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/LinkManager.ts
diff options
context:
space:
mode:
authorFawn <fangrui_tong@brown.edu>2019-06-19 22:27:21 -0400
committerFawn <fangrui_tong@brown.edu>2019-06-19 22:27:21 -0400
commitc5e401cb0a7fec2279ceecbc8d1429dcdd2f04b9 (patch)
treed7e3b77890c3c4f3be0dca1da9c4aae71ecaead7 /src/client/util/LinkManager.ts
parentf362dbfc237536c6c4a8c6d088c3dc818080f7c2 (diff)
buttons on cut links functional except for when dragged from link menu
Diffstat (limited to 'src/client/util/LinkManager.ts')
-rw-r--r--src/client/util/LinkManager.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index 23ba9d2e4..544f2edda 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -1,4 +1,4 @@
-import { observable } from "mobx";
+import { observable, action } from "mobx";
import { StrCast, Cast } from "../../new_fields/Types";
import { Doc, DocListCast } from "../../new_fields/Doc";
import { listSpec } from "../../new_fields/Schema";
@@ -32,6 +32,7 @@ export class LinkManager {
@observable public allLinks: Array<Doc> = []; // list of link docs
@observable public groupMetadataKeys: Map<string, Array<string>> = new Map();
// map of group type to list of its metadata keys; serves as a dictionary of groups to what kind of metadata it hodls
+ @observable public linkProxies: Array<Doc> = []; // list of linkbutton docs - used to visualize link when an anchors are not in the same context
// finds all links that contain the given anchor
public findAllRelatedLinks(anchor: Doc): Array<Doc> {
@@ -134,4 +135,16 @@ export class LinkManager {
}
}
+ @action
+ public addLinkProxy(proxy: Doc) {
+ LinkManager.Instance.linkProxies.push(proxy);
+ }
+
+ public findLinkProxy(sourceViewId: string, targetViewId: string): Doc | undefined {
+ let index = LinkManager.Instance.linkProxies.findIndex(p => {
+ return StrCast(p.sourceViewId) === sourceViewId && StrCast(p.targetViewId) === targetViewId;
+ });
+ return index > -1 ? LinkManager.Instance.linkProxies[index] : undefined;
+ }
+
} \ No newline at end of file