From 555d67a31adbe7e6d42f7f7805ba1348e6d505f6 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 24 Jan 2023 17:05:25 -0500 Subject: stopped storing presCollection in PresBox in favor of computing it. added anchor menu option for viewing linked trail. fixed showing slected slides in presbox when link with up is used. --- src/client/views/pdf/AnchorMenu.tsx | 145 ++++++++++++++++-------------------- src/client/views/pdf/Annotation.tsx | 7 -- 2 files changed, 66 insertions(+), 86 deletions(-) (limited to 'src/client/views/pdf') diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index 2fb795b06..9af686d83 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -11,13 +11,13 @@ import { AntimodeMenu, AntimodeMenuProps } from '../AntimodeMenu'; import { LinkPopup } from '../linking/LinkPopup'; import { ButtonDropdown } from '../nodes/formattedText/RichTextMenu'; import './AnchorMenu.scss'; -import { truncate } from 'lodash'; @observer export class AnchorMenu extends AntimodeMenu { static Instance: AnchorMenu; private _disposer: IReactionDisposer | undefined; + private _disposer2: IReactionDisposer | undefined; private _commentCont = React.createRef(); private _palette = [ 'rgba(208, 2, 27, 0.8)', @@ -37,9 +37,6 @@ export class AnchorMenu extends AntimodeMenu { 'rgba(0, 0, 0, 0.8)', ]; - @observable private _keyValue: string = ''; - @observable private _valueValue: string = ''; - @observable private _added: boolean = false; @observable private highlightColor: string = 'rgba(245, 230, 95, 0.616)'; @observable private _showLinkPopup: boolean = false; @@ -56,9 +53,9 @@ export class AnchorMenu extends AntimodeMenu { public Highlight: (color: string, isTargetToggler: boolean) => Opt = (color: string, isTargetToggler: boolean) => undefined; public GetAnchor: (savedAnnotations: Opt>, addAsAnnotation: boolean) => Opt = (savedAnnotations: Opt>, addAsAnnotation: boolean) => undefined; public Delete: () => void = unimplementedFunction; - public AddTag: (key: string, value: string) => boolean = returnFalse; public PinToPres: () => void = unimplementedFunction; public MakeTargetToggle: () => void = unimplementedFunction; + public ShowTargetTrail: () => void = unimplementedFunction; public IsTargetToggler: () => boolean = returnFalse; public get Active() { return this._left > 0; @@ -71,7 +68,17 @@ export class AnchorMenu extends AntimodeMenu { AnchorMenu.Instance._canFade = false; } + componentWillUnmount() { + this._disposer?.(); + this._disposer2?.(); + } + componentDidMount() { + this._disposer2 = reaction( + () => this._opacity, + opacity => !opacity && (this._showLinkPopup = false), + { fireImmediately: true } + ); this._disposer = reaction( () => SelectionManager.Views(), selected => { @@ -175,82 +182,62 @@ export class AnchorMenu extends AntimodeMenu { this.highlightColor = Utils.colorString(col); }; - @action keyChanged = (e: React.ChangeEvent) => { - this._keyValue = e.currentTarget.value; - }; - @action valueChanged = (e: React.ChangeEvent) => { - this._valueValue = e.currentTarget.value; - }; - @action addTag = (e: React.PointerEvent) => { - if (this._keyValue.length > 0 && this._valueValue.length > 0) { - this._added = this.AddTag(this._keyValue, this._valueValue); - setTimeout( - action(() => (this._added = false)), - 1000 - ); - } - }; - render() { const buttons = - this.Status === 'marquee' - ? [ - this.highlighter, - - {'Drag to Place Annotation'}}> - - , - AnchorMenu.Instance.OnAudio === unimplementedFunction ? ( - <> - ) : ( - {'Click to Record Annotation'}}> - - - ), - {'Find document to link to selected text'}}> - - , - , - AnchorMenu.Instance.StartCropDrag === unimplementedFunction ? ( - <> - ) : ( - {'Click/Drag to create cropped image'}}> - - - ), - ] - : [ - {'Remove Link Anchor'}}> - - , - {'Pin to Presentation'}}> - - , - {'make target visibility toggle on click'}}> - - , - //
- // - // - //
, - // , - ]; + this.Status === 'marquee' ? ( + <> + {this.highlighter} + Drag to Place Annotation}> + + + {AnchorMenu.Instance.OnAudio === unimplementedFunction ? null : ( + Click to Record Annotation}> + + + )} + Find document to link to selected text}> + + + , + {AnchorMenu.Instance.StartCropDrag === unimplementedFunction ? null : ( + Click/Drag to create cropped image}> + + + )} + + ) : ( + <> + Remove Link Anchor}> + + + Pin to Presentation}> + + + Show Linked Trail}> + + + make target visibility toggle on click}> + + + + ); return this.getElement(buttons); } diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index d8e44ae9d..0a8c69881 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -65,7 +65,6 @@ class RegionAnnotation extends React.Component { AnchorMenu.Instance.Status = 'annotation'; AnchorMenu.Instance.Delete = this.deleteAnnotation.bind(this); AnchorMenu.Instance.Pinned = false; - AnchorMenu.Instance.AddTag = this.addTag.bind(this); AnchorMenu.Instance.PinToPres = this.pinToPres; AnchorMenu.Instance.MakeTargetToggle = this.makeTargretToggle; AnchorMenu.Instance.IsTargetToggler = this.isTargetToggler; @@ -77,12 +76,6 @@ class RegionAnnotation extends React.Component { } }; - addTag = (key: string, value: string): boolean => { - const valNum = parseInt(value); - this.annoTextRegion[key] = isNaN(valNum) ? value : valNum; - return true; - }; - render() { const brushed = this.annoTextRegion && Doc.isBrushedHighlightedDegree(this.annoTextRegion); return ( -- cgit v1.2.3-70-g09d2