From cc75a03d89a4b553a53b55404464cd2ca93d9b48 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 22 Nov 2023 11:52:57 -0500 Subject: fixed more issues with rotation. restrutured how MarqueeAnnotator works to be simpler and more correct. --- src/client/views/pdf/Annotation.tsx | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/client/views/pdf/Annotation.tsx') diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index 38e4f65b6..e1e87763c 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -12,12 +12,13 @@ import { FieldViewProps } from '../nodes/FieldView'; import { AnchorMenu } from './AnchorMenu'; import './Annotation.scss'; import { LinkManager } from '../../util/LinkManager'; +import { Rect } from 'react-measure'; interface IAnnotationProps extends FieldViewProps { anno: Doc; dataDoc: Doc; fieldKey: string; - showInfo: (anno: Opt) => void; + showInfo?: (anno: Opt) => void; pointerEvents?: () => Opt; } @observer @@ -69,18 +70,24 @@ class RegionAnnotation extends React.Component { } }; + @action + onContextMenu = (e: React.MouseEvent) => { + AnchorMenu.Instance.Status = 'annotation'; + AnchorMenu.Instance.Delete = this.deleteAnnotation.bind(this); + AnchorMenu.Instance.Pinned = false; + AnchorMenu.Instance.PinToPres = this.pinToPres; + AnchorMenu.Instance.MakeTargetToggle = this.makeTargretToggle; + AnchorMenu.Instance.IsTargetToggler = this.isTargetToggler; + AnchorMenu.Instance.ShowTargetTrail = () => this.showTargetTrail(this.annoTextRegion); + AnchorMenu.Instance.jumpTo(e.clientX, e.clientY, true); + e.stopPropagation(); + e.preventDefault(); + }; @action onPointerDown = (e: React.PointerEvent) => { if (e.button === 2 || e.ctrlKey) { - AnchorMenu.Instance.Status = 'annotation'; - AnchorMenu.Instance.Delete = this.deleteAnnotation.bind(this); - AnchorMenu.Instance.Pinned = false; - AnchorMenu.Instance.PinToPres = this.pinToPres; - AnchorMenu.Instance.MakeTargetToggle = this.makeTargretToggle; - AnchorMenu.Instance.IsTargetToggler = this.isTargetToggler; - AnchorMenu.Instance.ShowTargetTrail = () => this.showTargetTrail(this.annoTextRegion); - AnchorMenu.Instance.jumpTo(e.clientX, e.clientY, true); e.stopPropagation(); + e.preventDefault(); } else if (e.button === 0) { e.stopPropagation(); LinkFollower.FollowLink(undefined, this.annoTextRegion, false); @@ -102,13 +109,14 @@ class RegionAnnotation extends React.Component { ref={this._mainCont} onPointerEnter={action(() => { Doc.BrushDoc(this.props.anno); - this.props.showInfo(this.props.anno); + this.props.showInfo?.(this.props.anno); })} onPointerLeave={action(() => { Doc.UnBrushDoc(this.props.anno); - this.props.showInfo(undefined); + this.props.showInfo?.(undefined); })} onPointerDown={this.onPointerDown} + onContextMenu={this.onContextMenu} style={{ left: NumCast(this.props.document.x), top: NumCast(this.props.document.y), -- cgit v1.2.3-70-g09d2