aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes
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/views/nodes
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/views/nodes')
-rw-r--r--src/client/views/nodes/LinkDocPreview.tsx4
-rw-r--r--src/client/views/nodes/PDFBox.tsx14
-rw-r--r--src/client/views/nodes/WebBox.tsx5
3 files changed, 18 insertions, 5 deletions
diff --git a/src/client/views/nodes/LinkDocPreview.tsx b/src/client/views/nodes/LinkDocPreview.tsx
index 488ce493c..7bd5d14d2 100644
--- a/src/client/views/nodes/LinkDocPreview.tsx
+++ b/src/client/views/nodes/LinkDocPreview.tsx
@@ -3,7 +3,7 @@ import { Tooltip } from '@material-ui/core';
import { action, computed, observable } from 'mobx';
import { observer } from "mobx-react";
import wiki from "wikijs";
-import { Doc, DocListCast, HeightSym, Opt, WidthSym } from "../../../fields/Doc";
+import { Doc, DocListCast, HeightSym, Opt, WidthSym, DocCastAsync } from "../../../fields/Doc";
import { NumCast, StrCast } from "../../../fields/Types";
import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse, setupMoveUpEvents, Utils } from "../../../Utils";
import { DocServer } from '../../DocServer';
@@ -45,7 +45,7 @@ export class LinkDocPreview extends React.Component<LinkDocPreviewProps> {
if (anchor1 && anchor2) {
linkTarget = Doc.AreProtosEqual(anchor1, this._linkSrc) || Doc.AreProtosEqual(anchor1?.annotationOn as Doc, this._linkSrc) ? anchor2 : anchor1;
}
- this._targetDoc = linkTarget?.annotationOn as Doc ?? linkTarget;
+ linkTarget && DocCastAsync(linkTarget.annotationOn).then(action(anno => this._targetDoc = anno));
this._toolTipText = "";
}
componentDidUpdate(props: any) {
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index c20d958ff..b941c07f6 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -80,7 +80,11 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum
}
}
- scrollFocus = (doc: Doc, smooth: boolean) => this._pdfViewer?.scrollFocus(doc, smooth);
+ initialScrollTarget: Opt<Doc>;
+ scrollFocus = (doc: Doc, smooth: boolean) => {
+ this.initialScrollTarget = doc;
+ return this._pdfViewer?.scrollFocus(doc, smooth);
+ }
getAnchor = () => this.rootDoc;
componentWillUnmount() { this._selectReactionDisposer?.(); }
componentDidMount() {
@@ -128,7 +132,13 @@ export class PDFBox extends ViewBoxAnnotatableComponent<FieldViewProps, PdfDocum
});
whenActiveChanged = action((isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive));
- setPdfViewer = (pdfViewer: PDFViewer) => { this._pdfViewer = pdfViewer; };
+ setPdfViewer = (pdfViewer: PDFViewer) => {
+ this._pdfViewer = pdfViewer;
+ if (this.initialScrollTarget) {
+ this.scrollFocus(this.initialScrollTarget, false);
+ this.initialScrollTarget = undefined;
+ }
+ };
searchStringChanged = (e: React.ChangeEvent<HTMLInputElement>) => this._searchString = e.currentTarget.value;
settingsPanel() {
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index abda0ed3a..663a8b8e4 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -30,6 +30,7 @@ import { DocAfterFocusFunc } from "./DocumentView";
import { FieldView, FieldViewProps } from './FieldView';
import "./WebBox.scss";
import React = require("react");
+import { LinkDocPreview } from "./LinkDocPreview";
const htmlToText = require("html-to-text");
type WebDocument = makeInterface<[typeof documentSchema]>;
@@ -119,7 +120,9 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
this._initialScroll !== undefined && (this._initialScroll = scrollTo);
this._ignoreScroll = true;
this.goTo(scrollTo, focusSpeed = smooth ? 500 : 0);
- this.layoutDoc._scrollTop = scrollTo;
+ if (!LinkDocPreview.LinkInfo) {
+ this.layoutDoc._scrollTop = scrollTo;
+ }
this._ignoreScroll = false;
}
} else {