aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index b72a3189d..9e190ad02 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -1,19 +1,21 @@
import { action, observable, runInAction } from 'mobx';
import { Doc, DocListCast, DocListCastAsync, Opt } from '../../fields/Doc';
import { Id } from '../../fields/FieldSymbols';
-import { Cast, NumCast, StrCast } from '../../fields/Types';
+import { Cast } from '../../fields/Types';
import { returnFalse } from '../../Utils';
import { DocumentType } from '../documents/DocumentTypes';
import { CollectionDockingView } from '../views/collections/CollectionDockingView';
import { CollectionView } from '../views/collections/CollectionView';
import { LightboxView } from '../views/LightboxView';
import { DocumentView, ViewAdjustment } from '../views/nodes/DocumentView';
+import { LinkAnchorBox } from '../views/nodes/LinkAnchorBox';
import { Scripting } from './Scripting';
export class DocumentManager {
//global holds all of the nodes (regardless of which collection they're in)
@observable public DocumentViews: DocumentView[] = [];
+ @observable public LinkAnchorBoxViews: DocumentView[] = [];
@observable public RecordingEvent = 0;
@observable public LinkedDocumentViews: { a: DocumentView, b: DocumentView, l: Doc }[] = [];
@@ -26,23 +28,24 @@ export class DocumentManager {
@action
public AddView = (view: DocumentView) => {
//console.log("MOUNT " + view.props.Document.title + "/" + view.props.LayoutTemplateString);
- if (view.props.LayoutTemplateString?.includes("LinkAnchorBox")) {
+ if (view.props.LayoutTemplateString?.includes(LinkAnchorBox.name)) {
const viewAnchorIndex = view.props.LayoutTemplateString.includes("anchor2") ? "anchor2" : "anchor1";
- view.props.LayoutTemplateString && DocListCast(view.rootDoc.links).forEach(link => {
- DocumentManager.Instance.DocumentViews?.filter(dv => Doc.AreProtosEqual(dv.rootDoc, link) && !dv.props.LayoutTemplateString?.includes(viewAnchorIndex)).
- forEach(otherView => {
- this.LinkedDocumentViews.push(
- {
- a: viewAnchorIndex === "anchor2" ? otherView : view,
- b: viewAnchorIndex === "anchor2" ? view : otherView,
- l: link
- });
- });
+ DocListCast(view.rootDoc.links).forEach(link => {
+ this.LinkAnchorBoxViews?.filter(dv => Doc.AreProtosEqual(dv.rootDoc, link) && !dv.props.LayoutTemplateString?.includes(viewAnchorIndex)).
+ forEach(otherView => this.LinkedDocumentViews.push(
+ {
+ a: viewAnchorIndex === "anchor2" ? otherView : view,
+ b: viewAnchorIndex === "anchor2" ? view : otherView,
+ l: link
+ })
+ );
});
+ this.LinkAnchorBoxViews.push(view);
// this.LinkedDocumentViews.forEach(view => console.log(" LV = " + view.a.props.Document.title + "/" + view.a.props.LayoutTemplateString + " --> " +
// view.b.props.Document.title + "/" + view.b.props.LayoutTemplateString));
+ } else {
+ this.DocumentViews.push(view);
}
- this.DocumentViews.push(view);
}
public RemoveView = action((view: DocumentView) => {
this.LinkedDocumentViews.slice().forEach(action(pair => {
@@ -52,8 +55,13 @@ export class DocumentManager {
}
}));
- const index = this.DocumentViews.indexOf(view);
- index !== -1 && this.DocumentViews.splice(index, 1);
+ if (view.props.LayoutTemplateString?.includes(LinkAnchorBox.name)) {
+ const index = this.LinkAnchorBoxViews.indexOf(view);
+ this.LinkAnchorBoxViews.splice(index, 1);
+ } else {
+ const index = this.DocumentViews.indexOf(view);
+ index !== -1 && this.DocumentViews.splice(index, 1);
+ }
});
//gets all views