From 45c2bf0a22ae83a65d91f11934e1c21770b897c7 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 15 Sep 2020 12:06:15 -0400 Subject: simplifying menus for annotations. added target toggle option to PDFmenu --- src/client/views/pdf/PDFMenu.tsx | 89 ++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 53 deletions(-) (limited to 'src/client/views/pdf/PDFMenu.tsx') diff --git a/src/client/views/pdf/PDFMenu.tsx b/src/client/views/pdf/PDFMenu.tsx index c5ed75980..1a5b14e07 100644 --- a/src/client/views/pdf/PDFMenu.tsx +++ b/src/client/views/pdf/PDFMenu.tsx @@ -1,15 +1,15 @@ import React = require("react"); import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { Tooltip } from "@material-ui/core"; import { action, computed, observable } from "mobx"; import { observer } from "mobx-react"; import { ColorState } from "react-color"; import { Doc, Opt } from "../../../fields/Doc"; -import { returnFalse, unimplementedFunction, Utils } from "../../../Utils"; +import { returnFalse, setupMoveUpEvents, unimplementedFunction, Utils } from "../../../Utils"; import { AntimodeMenu, AntimodeMenuProps } from "../AntimodeMenu"; import { ButtonDropdown } from "../nodes/formattedText/RichTextMenu"; import "./PDFMenu.scss"; - @observer export class PDFMenu extends AntimodeMenu { static Instance: PDFMenu; @@ -46,6 +46,8 @@ export class PDFMenu extends AntimodeMenu { public Delete: () => void = unimplementedFunction; public AddTag: (key: string, value: string) => boolean = returnFalse; public PinToPres: () => void = unimplementedFunction; + public MakePushpin: () => void = unimplementedFunction; + public IsPushpin: () => boolean = returnFalse; public Marquee: { left: number; top: number; width: number; height: number; } | undefined; public get Active() { return this._left > 0; } @@ -57,31 +59,10 @@ export class PDFMenu extends AntimodeMenu { } pointerDown = (e: React.PointerEvent) => { - document.removeEventListener("pointermove", this.pointerMove); - document.addEventListener("pointermove", this.pointerMove); - document.removeEventListener("pointerup", this.pointerUp); - document.addEventListener("pointerup", this.pointerUp); - - e.stopPropagation(); - e.preventDefault(); - } - - pointerMove = (e: PointerEvent) => { - e.stopPropagation(); - e.preventDefault(); - - if (!this._dragging) { + setupMoveUpEvents(this, e, (e: PointerEvent) => { this.StartDrag(e, this._commentCont.current!); - this._dragging = true; - } - } - - pointerUp = (e: PointerEvent) => { - this._dragging = false; - document.removeEventListener("pointermove", this.pointerMove); - document.removeEventListener("pointerup", this.pointerUp); - e.stopPropagation(); - e.preventDefault(); + return true; + }, returnFalse, returnFalse); } @action @@ -93,7 +74,7 @@ export class PDFMenu extends AntimodeMenu { @computed get highlighter() { const button = - ; @@ -112,12 +93,13 @@ export class PDFMenu extends AntimodeMenu { ; return ( - + {"Click to Highlight"}}> + + ); } - @action - changeHighlightColor = (color: string, e: React.PointerEvent) => { + @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: "", @@ -127,25 +109,11 @@ export class PDFMenu extends AntimodeMenu { this.highlightColor = Utils.colorString(col); } - deleteClicked = (e: React.PointerEvent) => { - this.Delete(); - } - - @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) => { + @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); } } @@ -154,13 +122,28 @@ export class PDFMenu extends AntimodeMenu { const buttons = this.Status === "pdf" ? [ this.highlighter, - , + + {"Drag to Place Annotation"}}> + + , ] : [ - , - , + {"Remove Link Anchor"}}> + + , + {"Pin to Presentation"}}> + + , + {"toggle pushpin behavior"}}> + + , //
// // -- cgit v1.2.3-70-g09d2