diff options
| author | bobzel <zzzman@gmail.com> | 2021-02-12 14:53:37 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2021-02-12 14:53:37 -0500 |
| commit | ffeada4e258e1786536b579b17798932bf4b8a8a (patch) | |
| tree | 988051b380aafe5d6f25792d5106d9cd247e613b /src/client/views/pdf/Annotation.tsx | |
| parent | d30f5b4855a0ad500cc5784260128ecc269f6450 (diff) | |
fixed bejhavior of Annotations when clicked to use FollowLink so that behavior is consistent. previously in a lightbox links within a pdf woud unnecessarily open the the PDF in its context
Diffstat (limited to 'src/client/views/pdf/Annotation.tsx')
| -rw-r--r-- | src/client/views/pdf/Annotation.tsx | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index cd32c2c3a..4e3721e2b 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -9,42 +9,30 @@ import { LinkManager } from "../../util/LinkManager"; import { undoBatch } from "../../util/UndoManager"; import "./Annotation.scss"; import { AnchorMenu } from "./AnchorMenu"; +import { FieldViewProps, FieldView } from "../nodes/FieldView"; -interface IAnnotationProps { +interface IAnnotationProps extends FieldViewProps { anno: Doc; - addDocTab: (document: Doc, where: string) => boolean; - pinToPres: (document: Doc, unpin?: boolean) => void; - focus: (doc: Doc) => void; - select: (isCtrlPressed: boolean) => void; dataDoc: Doc; fieldKey: string; showInfo: (anno: Opt<Doc>) => void; } - @observer export class Annotation extends React.Component<IAnnotationProps> { render() { return DocListCast(this.props.anno.annotations).map(a => - <RegionAnnotation {...this.props} showInfo={this.props.showInfo} select={this.props.select} pinToPres={this.props.pinToPres} document={a} x={NumCast(a.x)} y={NumCast(a.y)} width={a[WidthSym]()} height={a[HeightSym]()} key={a[Id]} />); + <RegionAnnotation {...this.props} showInfo={this.props.showInfo} document={a} x={NumCast(a.x)} y={NumCast(a.y)} width={a[WidthSym]()} height={a[HeightSym]()} key={a[Id]} />); } } -interface IRegionAnnotationProps { - anno: Doc; +interface IRegionAnnotationProps extends IAnnotationProps { x: number; y: number; width: number; height: number; - addDocTab: (document: Doc, where: string) => boolean; - pinToPres: (document: Doc, unpin: boolean) => void; - select: (isCtrlPressed: boolean) => void; document: Doc; - dataDoc: Doc; - fieldKey: string; - showInfo: (anno: Opt<Doc>) => void; } - @observer class RegionAnnotation extends React.Component<IRegionAnnotationProps> { private _reactionDisposer?: IReactionDisposer; @@ -90,8 +78,7 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { @undoBatch pinToPres = () => { const group = FieldValue(Cast(this.props.document.group, Doc)); - const isPinned = group && Doc.isDocPinned(group) ? true : false; - group && this.props.pinToPres(group, isPinned); + group && this.props.pinToPres(group); } @undoBatch @@ -115,13 +102,9 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { AnchorMenu.Instance.jumpTo(e.clientX, e.clientY, true); e.stopPropagation(); } - else if (e.button === 0) { - e.persist(); + else if (e.button === 0 && this.props.document.group instanceof Doc) { e.stopPropagation(); - PromiseValue(this.props.document.group).then(annoGroup => annoGroup instanceof Doc && - LinkManager.traverseLink(undefined, annoGroup, (doc, followLinkLocation) => this.props.addDocTab(doc, e.ctrlKey ? "add" : followLinkLocation), false, undefined, - () => this.props.select(false)) - ); + LinkManager.FollowLink(undefined, this.props.document.group, this.props, false); } } |
