aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DocumentManager.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-02-12 16:45:06 -0500
committerbobzel <zzzman@gmail.com>2021-02-12 16:45:06 -0500
commit926665e2367ff6a201a48618df6f7985ddbcb4b0 (patch)
tree53d2771855ba763851ec1da5cce7f6357d42e373 /src/client/util/DocumentManager.ts
parentffeada4e258e1786536b579b17798932bf4b8a8a (diff)
fixed previewing/scrollingto targets in web boxes and PDFs. fixed following link to textanchor when rtf doc is not displayed.
Diffstat (limited to 'src/client/util/DocumentManager.ts')
-rw-r--r--src/client/util/DocumentManager.ts20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 5b4917a30..d2251583c 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -141,7 +141,7 @@ export class DocumentManager {
finished?: () => void,
): Promise<void> => {
const getFirstDocView = LightboxView.LightboxDoc ? DocumentManager.Instance.getLightboxDocumentView : DocumentManager.Instance.getFirstDocumentView;
- const docView = getFirstDocView(targetDoc, originatingDoc);
+ let docView = getFirstDocView(targetDoc, originatingDoc);
const highlight = () => {
const finalDocView = getFirstDocView(targetDoc);
finalDocView && Doc.linkFollowHighlight(finalDocView.rootDoc);
@@ -159,19 +159,17 @@ export class DocumentManager {
finished?.();
return false;
};
- let annotatedDoc = Cast(targetDoc.annotationOn, Doc, null);
+ const annotatedDoc = Cast(targetDoc.annotationOn, Doc, null);
+ const rtfView = annotatedDoc && getFirstDocView(annotatedDoc);
const contextDocs = docContext ? await DocListCastAsync(docContext.data) : undefined;
const contextDoc = contextDocs?.find(doc => Doc.AreProtosEqual(doc, targetDoc) || Doc.AreProtosEqual(doc, annotatedDoc)) ? docContext : undefined;
const targetDocContext = contextDoc || annotatedDoc;
const targetDocContextView = targetDocContext && getFirstDocView(targetDocContext);
- if (!docView && annotatedDoc && annotatedDoc !== originatingDoc?.context && targetDoc.type === DocumentType.TEXTANCHOR) {
- const first = getFirstDocView(annotatedDoc);
- if (first) {
- annotatedDoc = first.rootDoc;
- first.focus(targetDoc, false);
- }
- } else if (docView && (targetDocContextView || !targetDocContext)) { // we have a docView already and aren't forced to create a new one ... just focus on the document. TODO move into view if necessary otherwise just highlight?
- docView.props.focus(docView.rootDoc, willZoom, undefined, (didFocus: boolean) =>
+ if (!docView && targetDoc.type === DocumentType.TEXTANCHOR && rtfView) {
+ rtfView.focus(targetDoc, false);
+ }
+ else if (docView) {
+ docView.props.focus(targetDoc, willZoom, undefined, (didFocus: boolean) =>
new Promise<boolean>(res => {
focusAndFinish(didFocus);
res();
@@ -205,7 +203,7 @@ export class DocumentManager {
// we didn't find the target, so it must have moved out of the context. Go back to just creating it.
if (closeContextIfNotFound) targetDocContextView.props.removeDocument?.(targetDocContextView.rootDoc);
if (targetDoc.layout) { // there will no layout for a TEXTANCHOR type document
- Doc.SetInPlace(targetDoc, "annotationOn", undefined, false);
+ // Doc.SetInPlace(targetDoc, "annotationOn", undefined, false);
createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target
}
} else {