diff options
| author | bobzel <zzzman@gmail.com> | 2021-01-20 18:35:58 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2021-01-20 18:35:58 -0500 |
| commit | 68785a97178d229935c0429791081d7c09312dc3 (patch) | |
| tree | 8260fb1c23ad3f145146b3102cd294fb85ca1044 /src/client/views/pdf | |
| parent | 8538a83baf57d7015b62b4ebc22d2bd7318f9d16 (diff) | |
moved PDFMenu to AnchorMenu. added AnchorMenu to formattedTextBox. Fixed following links from text box huyperlinks when there are multiple different huypertext links on the document.
Diffstat (limited to 'src/client/views/pdf')
| -rw-r--r-- | src/client/views/pdf/AnchorMenu.scss (renamed from src/client/views/pdf/PDFMenu.scss) | 2 | ||||
| -rw-r--r-- | src/client/views/pdf/AnchorMenu.tsx (renamed from src/client/views/pdf/PDFMenu.tsx) | 12 | ||||
| -rw-r--r-- | src/client/views/pdf/Annotation.tsx | 20 | ||||
| -rw-r--r-- | src/client/views/pdf/PDFViewer.tsx | 18 |
4 files changed, 27 insertions, 25 deletions
diff --git a/src/client/views/pdf/PDFMenu.scss b/src/client/views/pdf/AnchorMenu.scss index fa43a99b2..b7afb26a5 100644 --- a/src/client/views/pdf/PDFMenu.scss +++ b/src/client/views/pdf/AnchorMenu.scss @@ -1,4 +1,4 @@ -.pdfMenu-addTag { +.anchorMenu-addTag { display: grid; width: 200px; padding: 5px; diff --git a/src/client/views/pdf/PDFMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx index 603e26021..e2bd5a73d 100644 --- a/src/client/views/pdf/PDFMenu.tsx +++ b/src/client/views/pdf/AnchorMenu.tsx @@ -8,11 +8,11 @@ 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 "./PDFMenu.scss"; +import "./AnchorMenu.scss"; @observer -export class PDFMenu extends AntimodeMenu<AntimodeMenuProps> { - static Instance: PDFMenu; +export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> { + static Instance: AnchorMenu; private _commentCont = React.createRef<HTMLButtonElement>(); private _palette = [ @@ -54,8 +54,8 @@ export class PDFMenu extends AntimodeMenu<AntimodeMenuProps> { constructor(props: Readonly<{}>) { super(props); - PDFMenu.Instance = this; - PDFMenu.Instance._canFade = false; + AnchorMenu.Instance = this; + AnchorMenu.Instance._canFade = false; } pointerDown = (e: React.PointerEvent) => { @@ -144,7 +144,7 @@ export class PDFMenu extends AntimodeMenu<AntimodeMenuProps> { <FontAwesomeIcon icon="thumbtack" size="lg" /> </button> </Tooltip>, - // <div key="7" className="pdfMenu-addTag" > + // <div key="7" className="anchorMenu-addTag" > // <input onChange={this.keyChanged} placeholder="Key" style={{ gridColumn: 1 }} /> // <input onChange={this.valueChanged} placeholder="Value" style={{ gridColumn: 3 }} /> // </div>, diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx index 5ef57f986..85dd65901 100644 --- a/src/client/views/pdf/Annotation.tsx +++ b/src/client/views/pdf/Annotation.tsx @@ -8,7 +8,7 @@ import { BoolCast, Cast, FieldValue, NumCast, PromiseValue, StrCast } from "../. import { LinkManager } from "../../util/LinkManager"; import { undoBatch } from "../../util/UndoManager"; import "./Annotation.scss"; -import { PDFMenu } from "./PDFMenu"; +import { AnchorMenu } from "./AnchorMenu"; interface IAnnotationProps { anno: Doc; @@ -84,7 +84,7 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { DocListCast(group.annotations).forEach(anno => anno.delete = true); } - PDFMenu.Instance.fadeOut(true); + AnchorMenu.Instance.fadeOut(true); } @undoBatch @@ -105,14 +105,14 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> { @action onPointerDown = (e: React.PointerEvent) => { if (e.button === 2 || e.ctrlKey) { - PDFMenu.Instance.Status = "annotation"; - PDFMenu.Instance.Delete = this.deleteAnnotation.bind(this); - PDFMenu.Instance.Pinned = false; - PDFMenu.Instance.AddTag = this.addTag.bind(this); - PDFMenu.Instance.PinToPres = this.pinToPres; - PDFMenu.Instance.MakePushpin = this.makePushpin; - PDFMenu.Instance.IsPushpin = this.isPushpin; - PDFMenu.Instance.jumpTo(e.clientX, e.clientY, true); + 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.MakePushpin = this.makePushpin; + AnchorMenu.Instance.IsPushpin = this.isPushpin; + AnchorMenu.Instance.jumpTo(e.clientX, e.clientY, true); e.stopPropagation(); } else if (e.button === 0) { diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx index f9139220b..f2052d454 100644 --- a/src/client/views/pdf/PDFViewer.tsx +++ b/src/client/views/pdf/PDFViewer.tsx @@ -26,7 +26,7 @@ import { FieldViewProps } from "../nodes/FieldView"; import { FormattedTextBoxComment } from "../nodes/formattedText/FormattedTextBoxComment"; import { LinkDocPreview } from "../nodes/LinkDocPreview"; import { Annotation } from "./Annotation"; -import { PDFMenu } from "./PDFMenu"; +import { AnchorMenu } from "./AnchorMenu"; import "./PDFViewer.scss"; const pdfjs = require('pdfjs-dist/es5/build/pdf.js'); import React = require("react"); @@ -137,7 +137,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu if (!selected) { this._savedAnnotations.values().forEach(v => v.forEach(a => a.remove())); this._savedAnnotations.keys().forEach(k => this._savedAnnotations.setValue(k, [])); - PDFMenu.Instance.fadeOut(true); + AnchorMenu.Instance.fadeOut(true); } (SelectionManager.Views().length === 1) && this.setupPdfJsViewer(); }, @@ -384,30 +384,32 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu this._setPreviewCursor?.(e.clientX, e.clientY, true); } if (!e.altKey && e.button === 0 && this.active(true)) { - if (e.target && (e.target as any).parentElement.className !== "textLayer") { + if (e.target && ((e.target as any).className.includes("endOfContent") || ((e.target as any).parentElement.className !== "textLayer"))) { this._marqueeing = [e.clientX, e.clientY]; // if texLayer is hit, then we select text instead of using a marquee } else { // clear out old marquees and initialize menu for new selection - PDFMenu.Instance.Status = "marquee"; - PDFMenu.Instance.fadeOut(true); + AnchorMenu.Instance.Status = "marquee"; + AnchorMenu.Instance.fadeOut(true); this._savedAnnotations.values().forEach(v => v.forEach(a => a.remove())); this._savedAnnotations.clear(); this._styleRule = addStyleSheetRule(PDFViewer._annotationStyle, "pdfAnnotation", { "pointer-events": "none" }); - document.addEventListener("pointermove", this.onSelectMove); document.addEventListener("pointerup", this.onSelectEnd); } + document.addEventListener("pointermove", this.onSelectMove); } } @action finishMarquee = () => { this._marqueeing = undefined; + document.removeEventListener("pointermove", this.onSelectMove); this.props.select(false); } @action onSelectMove = (e: PointerEvent): void => { - if (e.target && (e.target as any).parentElement === this._mainCont.current) e.stopPropagation(); + // if (e.target && (e.target as any).parentElement === this._mainCont.current) + e.stopPropagation(); } @action @@ -421,7 +423,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu if (sel?.type === "Range") { const selRange = sel.getRangeAt(0); this.createTextAnnotation(sel, selRange); - PDFMenu.Instance.jumpTo(e.clientX, e.clientY); + AnchorMenu.Instance.jumpTo(e.clientX, e.clientY); } } |
