aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-05-30 03:30:12 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2025-05-30 03:30:12 -0400
commit29e5bbe68e02fe1d86e960a634d0580c37612254 (patch)
treee88585946a58feb988e3a3bb45dd2a9a09fea4c3 /src/client/util/DocumentManager.ts
parentf92a02ec5d676359cb268a35d30e5bf9886199c1 (diff)
parent49fb76f1c54fb8fc4e76bdcf675719d41bfc36aa (diff)
Merge branch 'master' into Template-Changes
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index e33449782..1c2ffab1b 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -2,7 +2,6 @@ import { Howl } from 'howler';
import { action, computed, makeObservable, observable, ObservableSet, observe } from 'mobx';
import { Doc, Opt } from '../../fields/Doc';
import { Animation, DocData } from '../../fields/DocSymbols';
-import { Id } from '../../fields/FieldSymbols';
import { listSpec } from '../../fields/Schema';
import { Cast, DocCast, NumCast, StrCast } from '../../fields/Types';
import { AudioField } from '../../fields/URLField';
@@ -108,16 +107,16 @@ export class DocumentManager {
});
// gets all views
- public getDocumentViewsById(id: string) {
+ public getAllDocumentViews(doc: Doc) {
const toReturn: DocumentView[] = [];
DocumentManager.Instance.DocumentViews.forEach(view => {
- if (view.Document[Id] === id) {
+ if (view.Document === doc) {
toReturn.push(view);
}
});
if (toReturn.length === 0) {
DocumentManager.Instance.DocumentViews.forEach(view => {
- if (view.Document[DocData]?.[Id] === id) {
+ if (view.Document[DocData] === doc) {
toReturn.push(view);
}
});
@@ -125,10 +124,6 @@ export class DocumentManager {
return toReturn;
}
- public getAllDocumentViews(doc: Doc) {
- return this.getDocumentViewsById(doc[Id]);
- }
-
public getDocumentView(target: Doc | undefined, preferredCollection?: DocumentView): DocumentView | undefined {
const docViewArray = DocumentManager.Instance.DocumentViews;
const passes = !target ? [] : preferredCollection ? [preferredCollection, undefined] : [undefined];
@@ -178,17 +173,17 @@ export class DocumentManager {
while (
containerDocContext.length &&
DocCast(containerDocContext[0]?.embedContainer) &&
- DocCast(containerDocContext[0].embedContainer)?._type_collection !== CollectionViewType.Docking &&
+ DocCast(containerDocContext[0].embedContainer)!._type_collection !== CollectionViewType.Docking &&
(includeExistingViews || !DocumentManager.Instance.getDocumentView(containerDocContext[0]))
) {
- containerDocContext = [Cast(containerDocContext[0].embedContainer, Doc, null), ...containerDocContext];
+ containerDocContext = [DocCast(containerDocContext[0].embedContainer)!, ...containerDocContext];
}
return containerDocContext;
}
static _howl: Howl;
static playAudioAnno(doc: Doc) {
- const anno = Cast(doc[Doc.LayoutFieldKey(doc) + '_audioAnnotations'], listSpec(AudioField), null)?.lastElement();
+ const anno = Cast(doc[Doc.LayoutDataKey(doc) + '_audioAnnotations'], listSpec(AudioField), null)?.lastElement();
if (anno) {
this._howl?.stop();
if (anno instanceof AudioField) {
@@ -253,9 +248,9 @@ export class DocumentManager {
finished?: (changed: boolean) => void // func called after focusing on target with flag indicating whether anything needed to be done.
) => {
const options = optionsIn;
- Doc.RemoveDocFromList(Doc.MyRecentlyClosed, undefined, targetDoc);
+ Doc.MyRecentlyClosed && Doc.RemoveDocFromList(Doc.MyRecentlyClosed, undefined, targetDoc);
const docContextPath = DocumentManager.GetContextPath(targetDoc, true);
- if (docContextPath.some(doc => doc.hidden)) options.toggleTarget = false;
+ if (docContextPath.some(doc => doc !== targetDoc && doc.hidden)) options.toggleTarget = false;
let activatedTab = false;
if (DocumentView.activateTabView(docContextPath[0])) {
options.toggleTarget = false;
@@ -277,8 +272,9 @@ export class DocumentManager {
}));
if (options.openLocation?.includes(OpenWhere.lightbox)) {
// even if we found the document view, if the target is a lightbox, we try to open it in the lightbox to preserve lightbox semantics (eg, there's only one active doc in the lightbox)
- const target = DocCast(targetDoc.annotationOn, targetDoc);
+ const target = DocCast(targetDoc.annotationOn, targetDoc)!;
const compView = this.getDocumentView(DocCast(target.embedContainer))?.ComponentView;
+ options.didMove = target.hidden || options.didMove ? true : false;
if ((compView?.addDocTab ?? compView?._props.addDocTab)?.(target, options.openLocation)) {
await new Promise<void>(waitres => {
setTimeout(() => waitres());
@@ -354,7 +350,7 @@ export class DocumentManager {
// bcz: should this delay be an options parameter?
setTimeout(() => {
Doc.linkFollowHighlight(viewSpec ? [docView.Document, viewSpec] : docView.Document, undefined, options.effect);
- const zoomableText = StrCast(targetDoc.text_html, StrCast(targetDoc.ai_firefly_prompt));
+ const zoomableText = StrCast(targetDoc.text_html, StrCast(targetDoc.ai_prompt));
if (options.zoomTextSelections && Doc.IsUnhighlightTimerSet() && contextView && zoomableText) {
// if the docView is a text anchor, the contextView is the PDF/Web/Text doc
contextView.setTextHtmlOverlay(zoomableText, options.effect);