import React = require("react"); import "./PDFMenu.scss"; import { observable, action, } from "mobx"; import { observer } from "mobx-react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { unimplementedFunction, returnFalse } from "../../../Utils"; import AntimodeMenu from "../AntimodeMenu"; import { Doc, Opt } from "../../../new_fields/Doc"; @observer export default class PDFMenu extends AntimodeMenu { static Instance: PDFMenu; private _commentCont = React.createRef(); @observable private _keyValue: string = ""; @observable private _valueValue: string = ""; @observable private _added: boolean = false; @observable public Highlighting: boolean = false; @observable public Status: "pdf" | "annotation" | "" = ""; public StartDrag: (e: PointerEvent, ele: HTMLElement) => void = unimplementedFunction; public Highlight: (color: string) => Opt = (color: string) => undefined; public Delete: () => void = unimplementedFunction; public AddTag: (key: string, value: string) => boolean = returnFalse; public PinToPres: () => void = unimplementedFunction; public Marquee: { left: number; top: number; width: number; height: number; } | undefined; constructor(props: Readonly<{}>) { super(props); PDFMenu.Instance = this; } 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) { 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(); } @action togglePin = (e: React.MouseEvent) => { this.Pinned = !this.Pinned; !this.Pinned && (this.Highlighting = false); } @action highlightClicked = (e: React.MouseEvent) => { if (!this.Highlight("rgba(245, 230, 95, 0.616)") && this.Pinned) { // yellowish highlight color for a marker type highlight this.Highlighting = !this.Highlighting; } } 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) => { 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 === "pdf" ? [ , , ] : [ , ,
, , ]; return this.getElement(buttons); } }