diff options
author | bobzel <zzzman@gmail.com> | 2023-01-24 17:05:25 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-01-24 17:05:25 -0500 |
commit | 555d67a31adbe7e6d42f7f7805ba1348e6d505f6 (patch) | |
tree | 1bf2f5264d9c87cfc3ada1024470686bf0d2494b /src/client/util/DocumentManager.ts | |
parent | a83e575638a0efe81da7aa0204edd33bb8a6bb2f (diff) |
stopped storing presCollection in PresBox in favor of computing it. added anchor menu option for viewing linked trail. fixed showing slected slides in presbox when link with up is used.
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r-- | src/client/util/DocumentManager.ts | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 70fe7f2c0..aa09fb005 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -5,7 +5,7 @@ import { listSpec } from '../../fields/Schema'; import { Cast, DocCast, StrCast } from '../../fields/Types'; import { AudioField } from '../../fields/URLField'; import { returnFalse } from '../../Utils'; -import { DocumentType } from '../documents/DocumentTypes'; +import { CollectionViewType, DocumentType } from '../documents/DocumentTypes'; import { CollectionDockingView } from '../views/collections/CollectionDockingView'; import { CollectionFreeFormView } from '../views/collections/collectionFreeForm'; import { CollectionView } from '../views/collections/CollectionView'; @@ -32,11 +32,15 @@ export class DocumentManager { private constructor() {} private _viewRenderedCbs: { doc: Doc; func: (dv: DocumentView) => any }[] = []; - public AddViewRenderedCb = (doc: Doc, func: (dv: DocumentView) => any) => { - const dv = this.getDocumentViewById(doc[Id]); - this._viewRenderedCbs.push({ doc, func }); - if (dv) { - this.callAddViewFuncs(dv); + public AddViewRenderedCb = (doc: Opt<Doc>, func: (dv: DocumentView) => any) => { + if (doc) { + const dv = this.getDocumentViewById(doc[Id]); + this._viewRenderedCbs.push({ doc, func }); + if (dv) { + this.callAddViewFuncs(dv); + } + } else { + func(undefined as any); } }; callAddViewFuncs = (view: DocumentView) => { @@ -190,6 +194,16 @@ export class DocumentManager { return toReturn; } + static GetContextPath(doc: Opt<Doc>) { + if (!doc) return []; + const srcContext = Cast(doc.context, Doc, null) ?? Cast(Cast(doc.annotationOn, Doc, null)?.context, Doc, null); + var containerDocContext = srcContext ? [srcContext] : []; + while (containerDocContext.length && containerDocContext[0]?.context && DocCast(containerDocContext[0].context)?.viewType !== CollectionViewType.Docking && !DocumentManager.Instance.getDocumentView(containerDocContext[0])) { + containerDocContext = [Cast(containerDocContext[0].context, Doc, null), ...containerDocContext]; + } + return containerDocContext; + } + static playAudioAnno(doc: Doc) { const anno = Cast(doc[Doc.LayoutFieldKey(doc) + '-audioAnnotations'], listSpec(AudioField), null)?.lastElement(); if (anno) { |