From 75fa8e7e798566962d88fc3012c41c3179580e39 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 10 Sep 2020 10:59:58 -0400 Subject: fixed following links on text hyperlink to use same code as linkMenu. fixed hyperlink delete button --- src/client/util/DocumentManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/util/DocumentManager.ts') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 420b29559..37d639a07 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -109,7 +109,7 @@ export class DocumentManager { const pairs = DocumentManager.Instance.DocumentViews.reduce((pairs, dv) => { const linksList = DocListCast(dv.props.Document.links); pairs.push(...linksList.reduce((pairs, link) => { - const linkToDoc = link && LinkManager.Instance.getOppositeAnchor(link, dv.props.Document); + const linkToDoc = link && LinkManager.getOppositeAnchor(link, dv.props.Document); linkToDoc && DocumentManager.Instance.getDocumentViews(linkToDoc).map(docView1 => { if (dv.props.Document.type !== DocumentType.LINK || dv.props.LayoutTemplateString !== docView1.props.LayoutTemplateString) { pairs.push({ a: dv, b: docView1, l: link }); -- cgit v1.2.3-70-g09d2 From d673482563d161171568682d745996598228baf2 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 10 Sep 2020 11:57:01 -0400 Subject: fixiing behavior of following link to target in a PDF that hasn't loaded its contents yet... need to wait. also fixed pdf titltes in lod view --- src/client/util/DocumentManager.ts | 16 ++++++++++++---- src/client/views/linking/LinkMenuItem.tsx | 2 +- src/client/views/nodes/PDFBox.scss | 4 ++-- src/client/views/pdf/PDFViewer.tsx | 6 +++++- 4 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/client/util/DocumentManager.ts') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 37d639a07..5e43ab39a 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -177,7 +177,7 @@ export class DocumentManager { highlight(); } else { // otherwise try to get a view of the context of the target const targetDocContextView = getFirstDocView(targetDocContext); - targetDocContext._scrollY = 0; // this will force PDFs to activate and load their annotations / allow scrolling + targetDocContext._scrollY = 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); @@ -192,11 +192,19 @@ export class DocumentManager { if (retryDocView) { // we found the target in the context retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context } else { // 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.props.Document); - targetDoc.layout && createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target + setTimeout(() => { + const retryDocView = getFirstDocView(targetDoc); // test again for the target view snce we presumably created the context above by focusing on it + if (retryDocView) { // we found the target in the context + retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context + } else { // 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.props.Document); + // targetDoc.layout && createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target + } + highlight(); + }, 2000) } highlight(); - }, 0); + }, 250); } } else { // there's no context view so we need to create one first and try again createViewFunc(targetDocContext); // so first we create the target, but don't pass finished because we still need to create the target diff --git a/src/client/views/linking/LinkMenuItem.tsx b/src/client/views/linking/LinkMenuItem.tsx index 32fc407f6..d3fbf39a2 100644 --- a/src/client/views/linking/LinkMenuItem.tsx +++ b/src/client/views/linking/LinkMenuItem.tsx @@ -166,7 +166,7 @@ export class LinkMenuItem extends React.Component { }); } } else { - DocumentManager.Instance.FollowLink(linkDoc, this.props.sourceDoc, doc => addDocTab(doc, "add:right"), false); + DocumentManager.Instance.FollowLink(linkDoc, sourceDoc, doc => addDocTab(doc, "add:right"), false); } linkDoc.linksToAnnotation && Hypothesis.scrollToAnnotation(StrCast(linkDoc.annotationId), destinationDoc); diff --git a/src/client/views/nodes/PDFBox.scss b/src/client/views/nodes/PDFBox.scss index 174bf8eff..2d88246c2 100644 --- a/src/client/views/nodes/PDFBox.scss +++ b/src/client/views/nodes/PDFBox.scss @@ -187,8 +187,8 @@ color: lightgray; margin-top: auto; margin-bottom: auto; - transform-origin: 50% 50%; - width: 100%; + transform-origin: 40% 40%; + width: 125%; transform: rotate(40deg) scale(0.8); font-size: 80; padding: 5%; diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index 4e28116c7..79bd190c5 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -175,7 +175,11 @@ export class PDFViewer extends ViewBoxAnnotatableComponent { if (scrollY !== undefined) { (this._showCover || this._showWaiting) && this.setupPdfJsViewer(); - (this.props.renderDepth === -1 || (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc)) && this._mainCont.current && smoothScroll(1000, this._mainCont.current, (this.Document._scrollY || 0)); + if ((this.props.renderDepth === -1 || (!LinkDocPreview.TargetDoc && !FormattedTextBoxComment.linkDoc)) && this._mainCont.current) { + smoothScroll(1000, this._mainCont.current, (this.Document._scrollY || 0)); + } else { + console.log("Waiting for preview"); + } setTimeout(() => this.Document._scrollY = undefined, 1000); } }, -- cgit v1.2.3-70-g09d2 From e4017046bba5af099be31c2f18edc7bc45c12c4d Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 10 Sep 2020 12:09:52 -0400 Subject: better fix for following links to pdfs --- src/client/util/DocumentManager.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/client/util/DocumentManager.ts') diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts index 5e43ab39a..f41c5e4cb 100644 --- a/src/client/util/DocumentManager.ts +++ b/src/client/util/DocumentManager.ts @@ -187,24 +187,21 @@ export class DocumentManager { targetDocContext._currentTimecode = targetDoc.displayTimecode; finished?.(); } else { // no timecode means we need to find the context view and focus on our target - setTimeout(() => { + const findView = (delay: number) => { const retryDocView = getFirstDocView(targetDoc); // test again for the target view snce we presumably created the context above by focusing on it if (retryDocView) { // we found the target in the context retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context - } else { // we didn't find the target, so it must have moved out of the context. Go back to just creating it. - setTimeout(() => { - const retryDocView = getFirstDocView(targetDoc); // test again for the target view snce we presumably created the context above by focusing on it - if (retryDocView) { // we found the target in the context - retryDocView.props.focus(targetDoc, willZoom, undefined, focusAndFinish); // focus on the target in the context - } else { // 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.props.Document); - // targetDoc.layout && createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target - } - highlight(); - }, 2000) + highlight(); } - highlight(); - }, 250); + if (delay > 2500) { + // 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.props.Document); + // targetDoc.layout && createViewFunc(Doc.BrushDoc(targetDoc), finished); // create a new view of the target + } else { + setTimeout(() => findView(delay + 250), 250); + } + } + findView(0); } } else { // there's no context view so we need to create one first and try again createViewFunc(targetDocContext); // so first we create the target, but don't pass finished because we still need to create the target -- cgit v1.2.3-70-g09d2