aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/DocumentManager.ts6
-rw-r--r--src/client/util/LinkManager.ts10
-rw-r--r--src/client/util/SharingManager.tsx1
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/nodes/LinkDocPreview.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx2
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx2
-rw-r--r--src/client/views/pdf/PDFViewer.tsx29
8 files changed, 38 insertions, 16 deletions
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index ce4e1e378..178daf5f0 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -10,6 +10,8 @@ import { DocumentView } from '../views/nodes/DocumentView';
import { LinkManager } from './LinkManager';
import { Scripting } from './Scripting';
import { SelectionManager } from './SelectionManager';
+import { LinkDocPreview } from '../views/nodes/LinkDocPreview';
+import { FormattedTextBoxComment } from '../views/nodes/formattedText/FormattedTextBoxComment';
export type CreateViewFunc = (doc: Doc, followLinkLocation: string, finished?: () => void) => void;
@@ -187,7 +189,7 @@ export class DocumentManager {
highlight();
} else { // otherwise try to get a view of the context of the target
const targetDocContextView = getFirstDocView(targetDocContext);
- targetDocContext._scrollY = NumCast(targetDocContext._scrollTop, 0); // this will force PDFs to activate and load their annotations / allow scrolling
+ targetDocContext._scrollY = targetDocContext._scrollPY = NumCast(targetDocContext._scrollTop, 0); // this will force PDFs to activate and load their annotations / allow scrolling
if (targetDocContextView) { // we found a context view and aren't forced to create a new one ... focus on the context first..
targetDocContext._viewTransition = "transform 500ms";
targetDocContextView.props.focus(targetDocContextView.props.Document, willZoom);
@@ -224,6 +226,8 @@ export class DocumentManager {
}
public async FollowLink(link: Opt<Doc>, doc: Doc, createViewFunc: CreateViewFunc, zoom = false, currentContext?: Doc, finished?: () => void, traverseBacklink?: boolean) {
+ LinkDocPreview.TargetDoc = undefined;
+ FormattedTextBoxComment.linkDoc = undefined;
const linkDocs = link ? [link] : DocListCast(doc.links);
const firstDocs = linkDocs.filter(linkDoc => Doc.AreProtosEqual(linkDoc.anchor1 as Doc, doc) || Doc.AreProtosEqual((linkDoc.anchor1 as Doc).annotationOn as Doc, doc)); // link docs where 'doc' is anchor1
const secondDocs = linkDocs.filter(linkDoc => Doc.AreProtosEqual(linkDoc.anchor2 as Doc, doc) || Doc.AreProtosEqual((linkDoc.anchor2 as Doc).annotationOn as Doc, doc)); // link docs where 'doc' is anchor2
diff --git a/src/client/util/LinkManager.ts b/src/client/util/LinkManager.ts
index a2bb16dfc..56b6cb8a9 100644
--- a/src/client/util/LinkManager.ts
+++ b/src/client/util/LinkManager.ts
@@ -3,6 +3,7 @@ import { List } from "../../fields/List";
import { listSpec } from "../../fields/Schema";
import { Cast, StrCast } from "../../fields/Types";
import { SharingManager } from "./SharingManager";
+import { computedFn } from "mobx-utils";
/*
* link doc:
@@ -59,13 +60,18 @@ export class LinkManager {
});
return related;
}
- // finds all links that contain the given anchor
- public getAllRelatedLinks(anchor: Doc): Doc[] {
+
+ relatedLinker = computedFn(function realtedLinker(this: any, anchor: Doc) {
const related = LinkManager.Instance.getAllDirectLinks(anchor);
DocListCast(anchor[Doc.LayoutFieldKey(anchor) + "-annotations"]).map(anno => {
related.push(...LinkManager.Instance.getAllRelatedLinks(anno));
});
return related;
+ }.bind(this));
+
+ // finds all links that contain the given anchor
+ public getAllRelatedLinks(anchor: Doc): Doc[] {
+ return this.relatedLinker(anchor);
}
public deleteAllLinksOnAnchor(anchor: Doc) {
diff --git a/src/client/util/SharingManager.tsx b/src/client/util/SharingManager.tsx
index e789a7867..6c1ec6091 100644
--- a/src/client/util/SharingManager.tsx
+++ b/src/client/util/SharingManager.tsx
@@ -92,7 +92,6 @@ export class SharingManager extends React.Component<{}> {
// }
public open = (target?: DocumentView, target_doc?: Doc) => {
- runInAction(() => this.users = []);
this.populateUsers();
runInAction(() => {
this.targetDocView = target;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 382929861..5236fab27 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -901,7 +901,7 @@ export class CollectionFreeFormView extends CollectionSubView<PanZoomDocument, P
scrollTo = NumCast(doc.y);
}
if (curScroll !== scrollTo) {
- this.props.Document._scrollY = scrollTo;
+ this.props.Document._scrollPY = this.props.Document._scrollY = scrollTo;
delay = Math.abs(scrollTo - curScroll) > 5 ? 1000 : 0;
!dontCenter && delay && this.props.focus(this.props.Document);
afterFocus && setTimeout(afterFocus, delay);
diff --git a/src/client/views/nodes/LinkDocPreview.tsx b/src/client/views/nodes/LinkDocPreview.tsx
index d14157c09..8f9cb5b0e 100644
--- a/src/client/views/nodes/LinkDocPreview.tsx
+++ b/src/client/views/nodes/LinkDocPreview.tsx
@@ -64,7 +64,7 @@ export class LinkDocPreview extends React.Component<Props> {
this._toolTipText = "";
LinkDocPreview.TargetDoc = this._targetDoc = target;
if (anchor !== this._targetDoc && anchor && this._targetDoc) {
- this._targetDoc._scrollY = NumCast(anchor?.y);
+ this._targetDoc._scrollPY = NumCast(anchor?.y);
}
});
}
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index a5bcf988a..8078a29b7 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -1429,7 +1429,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
const self = this;
return new Plugin({
view(newView) {
- self.props.isSelected(true) && RichTextMenu.Instance && (RichTextMenu.Instance.view = newView);
+ runInAction(() => self.props.isSelected(true) && RichTextMenu.Instance && (RichTextMenu.Instance.view = newView));
return self.menuPlugin = new RichTextMenuPlugin({ editorProps: this.props });
}
});
diff --git a/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx b/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx
index 5183e193b..f96fda861 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBoxComment.tsx
@@ -260,7 +260,7 @@ export class FormattedTextBoxComment {
const anchor = FieldValue(Doc.AreProtosEqual(FieldValue(Cast(linkDoc.anchor1, Doc)), textBox.dataDoc) ? Cast(linkDoc.anchor2, Doc) : (Cast(linkDoc.anchor1, Doc)) || linkDoc);
const target = anchor?.annotationOn ? await DocCastAsync(anchor.annotationOn) : anchor;
if (anchor !== target && anchor && target) {
- target._scrollY = NumCast(anchor?.y);
+ target._scrollPY = NumCast(anchor?.y);
}
if (target?.author) {
FormattedTextBoxComment.showCommentbox("", view, nbef);
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 606d3e550..78b95b385 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -179,12 +179,25 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
(scrollY) => {
if (scrollY !== undefined) {
(this._showCover || this._showWaiting) && this.setupPdfJsViewer();
- if ((this.props.renderDepth === -1 || (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc)) && this._mainCont.current) {
- smoothScroll(1000, this._mainCont.current, scrollY || 0);
- } else if (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc) { // wait for mainCont and try again to scroll
- setTimeout(() => this._mainCont.current && smoothScroll(1000, this._mainCont.current, scrollY || 0), 250);
+ if (this.props.renderDepth !== -1 && !LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc) {
+ const delay = this._mainCont.current ? 0 : 250; // wait for mainCont and try again to scroll
+ setTimeout(() => this._mainCont.current && smoothScroll(1000, this._mainCont.current, Math.abs(scrollY || 0)), delay);
+ setTimeout(() => { this.Document._scrollTop = scrollY; this.Document._scrollY = undefined; }, 1000 + delay);
+ }
+ }
+ },
+ { fireImmediately: true }
+ );
+ this._disposers.scrollPY = reaction(
+ () => Cast(this.Document._scrollPY, "number", null),
+ (scrollY) => {
+ if (scrollY !== undefined) {
+ (this._showCover || this._showWaiting) && this.setupPdfJsViewer();
+ if (this.props.renderDepth === -1 && scrollY >= 0) {
+ if (!this._mainCont.current) setTimeout(() => smoothScroll(1000, this._mainCont.current!, scrollY || 0));
+ else smoothScroll(1000, this._mainCont.current, scrollY || 0);
+ this.Document._scrollPY = undefined;
}
- setTimeout(() => { this.Document._scrollTop = scrollY; this.Document._scrollY = undefined; }, 1000);
}
},
{ fireImmediately: true }
@@ -387,12 +400,12 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
@action
onScroll = (e: React.UIEvent<HTMLElement>) => {
if (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc) {
- this.Document._scrollY === undefined && (this.layoutDoc._scrollTop = this._mainCont.current!.scrollTop);
this.pageDelay && clearTimeout(this.pageDelay);
this.pageDelay = setTimeout(() => {
+ this.Document._scrollY === undefined && (this.layoutDoc._scrollTop = this._mainCont.current!.scrollTop);
this.pageDelay = undefined;
- this._pdfViewer && (this.Document._curPage = this._pdfViewer.currentPageNumber);
- }, 250);
+ //this._pdfViewer && (this.Document._curPage = this._pdfViewer.currentPageNumber);
+ }, 1000);
}
}