From 2c833fe4e7915b8219c6b48abb596e4359744750 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 21 Jul 2022 10:49:52 -0400 Subject: fixed hiding marquee options menu when clicking on background. --- .../collections/collectionFreeForm/MarqueeView.tsx | 17 +- src/client/views/pdf/AnchorMenu.tsx | 264 ++++++++++++--------- 2 files changed, 157 insertions(+), 124 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 4513ffb39..65a11cbcb 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -277,8 +277,8 @@ export class MarqueeView extends React.Component { this.hideMarquee(); MarqueeOptionsMenu.Instance.fadeOut(true); - document.removeEventListener('pointerdown', hideMarquee); - document.removeEventListener('wheel', hideMarquee); + document.removeEventListener('pointerdown', hideMarquee, true); + document.removeEventListener('wheel', hideMarquee, true); }; if (PresBox.startMarquee) { this.pinWithView(); @@ -292,8 +292,8 @@ export class MarqueeView extends React.Component { - this._visible = true; - }; - + showMarquee = () => (this._visible = true); @action - hideMarquee = () => { - this._visible = false; - }; + hideMarquee = () => (this._visible = false); @undoBatch @action diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index 29d068817..1a1120b6c 100644 --- a/src/client/views/pdf/AnchorMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -1,16 +1,16 @@ -import React = require("react"); -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { Tooltip } from "@material-ui/core"; -import { action, computed, observable, IReactionDisposer, reaction, ObservableMap } from "mobx"; -import { observer } from "mobx-react"; -import { ColorState } from "react-color"; -import { Doc, Opt } from "../../../fields/Doc"; -import { returnFalse, setupMoveUpEvents, unimplementedFunction, Utils } from "../../../Utils"; -import { AntimodeMenu, AntimodeMenuProps } from "../AntimodeMenu"; -import { ButtonDropdown } from "../nodes/formattedText/RichTextMenu"; -import "./AnchorMenu.scss"; -import { SelectionManager } from "../../util/SelectionManager"; -import { LinkPopup } from "../linking/LinkPopup"; +import React = require('react'); +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Tooltip } from '@material-ui/core'; +import { action, computed, IReactionDisposer, observable, ObservableMap, reaction } from 'mobx'; +import { observer } from 'mobx-react'; +import { ColorState } from 'react-color'; +import { Doc, Opt } from '../../../fields/Doc'; +import { returnFalse, setupMoveUpEvents, unimplementedFunction, Utils } from '../../../Utils'; +import { SelectionManager } from '../../util/SelectionManager'; +import { AntimodeMenu, AntimodeMenuProps } from '../AntimodeMenu'; +import { LinkPopup } from '../linking/LinkPopup'; +import { ButtonDropdown } from '../nodes/formattedText/RichTextMenu'; +import './AnchorMenu.scss'; @observer export class AnchorMenu extends AntimodeMenu { @@ -19,30 +19,31 @@ export class AnchorMenu extends AntimodeMenu { private _disposer: IReactionDisposer | undefined; private _commentCont = React.createRef(); private _palette = [ - "rgba(208, 2, 27, 0.8)", - "rgba(238, 0, 0, 0.8)", - "rgba(245, 166, 35, 0.8)", - "rgba(248, 231, 28, 0.8)", - "rgba(245, 230, 95, 0.616)", - "rgba(139, 87, 42, 0.8)", - "rgba(126, 211, 33, 0.8)", - "rgba(65, 117, 5, 0.8)", - "rgba(144, 19, 254, 0.8)", - "rgba(238, 169, 184, 0.8)", - "rgba(224, 187, 228, 0.8)", - "rgba(225, 223, 211, 0.8)", - "rgba(255, 255, 255, 0.8)", - "rgba(155, 155, 155, 0.8)", - "rgba(0, 0, 0, 0.8)"]; - - @observable private _keyValue: string = ""; - @observable private _valueValue: string = ""; + 'rgba(208, 2, 27, 0.8)', + 'rgba(238, 0, 0, 0.8)', + 'rgba(245, 166, 35, 0.8)', + 'rgba(248, 231, 28, 0.8)', + 'rgba(245, 230, 95, 0.616)', + 'rgba(139, 87, 42, 0.8)', + 'rgba(126, 211, 33, 0.8)', + 'rgba(65, 117, 5, 0.8)', + 'rgba(144, 19, 254, 0.8)', + 'rgba(238, 169, 184, 0.8)', + 'rgba(224, 187, 228, 0.8)', + 'rgba(225, 223, 211, 0.8)', + 'rgba(255, 255, 255, 0.8)', + 'rgba(155, 155, 155, 0.8)', + '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 highlightColor: string = 'rgba(245, 230, 95, 0.616)'; @observable private _showLinkPopup: boolean = false; @observable public Highlighting: boolean = false; - @observable public Status: "marquee" | "annotation" | "" = ""; + @observable public Status: 'marquee' | 'annotation' | '' = ''; public onMakeAnchor: () => Opt = () => undefined; // Method to get anchor from text search @@ -57,7 +58,9 @@ export class AnchorMenu extends AntimodeMenu { public PinToPres: () => void = unimplementedFunction; public MakePushpin: () => void = unimplementedFunction; public IsPushpin: () => boolean = returnFalse; - public get Active() { return this._left > 0; } + public get Active() { + return this._left > 0; + } constructor(props: Readonly<{}>) { super(props); @@ -67,26 +70,40 @@ export class AnchorMenu extends AntimodeMenu { } componentDidMount() { - this._disposer = reaction(() => SelectionManager.Views(), + this._disposer = reaction( + () => SelectionManager.Views(), selected => { this._showLinkPopup = false; AnchorMenu.Instance.fadeOut(true); - }); + } + ); } pointerDown = (e: React.PointerEvent) => { - setupMoveUpEvents(this, e, (e: PointerEvent) => { - this.StartDrag(e, this._commentCont.current!); - return true; - }, returnFalse, e => this.OnClick?.(e)); - } + setupMoveUpEvents( + this, + e, + (e: PointerEvent) => { + this.StartDrag(e, this._commentCont.current!); + return true; + }, + returnFalse, + e => this.OnClick?.(e) + ); + }; cropDown = (e: React.PointerEvent) => { - setupMoveUpEvents(this, e, (e: PointerEvent) => { - this.StartCropDrag(e, this._commentCont.current!); - return true; - }, returnFalse, e => this.OnCrop?.(e)); - } + setupMoveUpEvents( + this, + e, + (e: PointerEvent) => { + this.StartCropDrag(e, this._commentCont.current!); + return true; + }, + returnFalse, + e => this.OnCrop?.(e) + ); + }; @action highlightClicked = (e: React.MouseEvent) => { @@ -94,41 +111,45 @@ export class AnchorMenu extends AntimodeMenu { this.Highlighting = !this.Highlighting; } AnchorMenu.Instance.fadeOut(true); - } + }; @action toggleLinkPopup = (e: React.MouseEvent) => { //ignore the potential null type error because this method cannot be called unless the user selects text and clicks the link button //change popup visibility field to visible this._showLinkPopup = !this._showLinkPopup; - } + }; @computed get highlighter() { - const button = + const button = ( ; + + ); - const dropdownContent = + const dropdownContent = (

Change highlighter color:

{this._palette.map(color => { if (color) { - return this.highlightColor === color ? - : - ; + return this.highlightColor === color ? ( + + ) : ( + + ); } })}
-
; + + ); return ( - {"Click to Highlight"}}> + {'Click to Highlight'}}>
- +
); @@ -136,70 +157,87 @@ export class AnchorMenu extends AntimodeMenu { @action changeHighlightColor = (color: string, e: React.PointerEvent) => { const col: ColorState = { - hex: color, hsl: { a: 0, h: 0, s: 0, l: 0, source: "" }, hsv: { a: 0, h: 0, s: 0, v: 0, source: "" }, - rgb: { a: 0, r: 0, b: 0, g: 0, source: "" }, oldHue: 0, source: "", + hex: color, + hsl: { a: 0, h: 0, s: 0, l: 0, source: '' }, + hsv: { a: 0, h: 0, s: 0, v: 0, source: '' }, + rgb: { a: 0, r: 0, b: 0, g: 0, source: '' }, + oldHue: 0, + source: '', }; e.preventDefault(); e.stopPropagation(); 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 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); + setTimeout( + action(() => (this._added = false)), + 1000 + ); } - } + }; render() { - const buttons = this.Status === "marquee" ? - [ - this.highlighter, - - {"Drag to Place Annotation"}}> - - , - //NOTE: link popup is currently in progress - {"Find document to link to selected text"}}> - - , - , - AnchorMenu.Instance.StartCropDrag === unimplementedFunction ? <> : {"Click/Drag to create cropped image"}}> - - , - ] : [ - {"Remove Link Anchor"}}> - - , - {"Pin to Presentation"}}> - - , - {"toggle pushpin behavior"}}> - - , - //
- // - // - //
, - // , - ]; + const buttons = + this.Status === 'marquee' + ? [ + this.highlighter, + + {'Drag to Place Annotation'}}> + + , + //NOTE: link popup is currently in progress + {'Find document to link to selected text'}}> + + , + , + AnchorMenu.Instance.StartCropDrag === unimplementedFunction ? ( + <> + ) : ( + {'Click/Drag to create cropped image'}}> + + + ), + ] + : [ + {'Remove Link Anchor'}}> + + , + {'Pin to Presentation'}}> + + , + {'toggle pushpin behavior'}}> + + , + //
+ // + // + //
, + // , + ]; return this.getElement(buttons); } -} \ No newline at end of file +} -- cgit v1.2.3-70-g09d2