aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/pdf/Annotation.tsx39
-rw-r--r--src/client/views/pdf/Page.tsx8
2 files changed, 15 insertions, 32 deletions
diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx
index 947f5a2e8..2610f6c6e 100644
--- a/src/client/views/pdf/Annotation.tsx
+++ b/src/client/views/pdf/Annotation.tsx
@@ -9,7 +9,7 @@ import { DocumentManager } from "../../util/DocumentManager";
import { PresentationView } from "../presentationview/PresentationView";
import PDFMenu from "./PDFMenu";
import "./Annotation.scss";
-import { AnnotationTypes, scale } from "./PDFViewer";
+import { scale } from "./PDFViewer";
interface IAnnotationProps {
anno: Doc;
@@ -22,17 +22,8 @@ interface IAnnotationProps {
export default class Annotation extends React.Component<IAnnotationProps> {
render() {
- let annotationDocs = DocListCast(this.props.anno.annotations);
- let res = annotationDocs.map(a => {
- let type = NumCast(a.type);
- switch (type) {
- case AnnotationTypes.Region:
- return <RegionAnnotation addDocTab={this.props.addDocTab} document={a} fieldExtensionDoc={this.props.fieldExtensionDoc} scrollTo={this.props.scrollTo} ParentIndex={this.props.ParentIndex} index={this.props.index} x={NumCast(a.x)} y={NumCast(a.y)} width={a[WidthSym]()} height={a[HeightSym]()} key={a[Id]} />;
- default:
- return <div></div>;
- }
- });
- return res;
+ return DocListCast(this.props.anno.annotations).map(a => (
+ <RegionAnnotation {...this.props} document={a} x={NumCast(a.x)} y={NumCast(a.y)} width={a[WidthSym]()} height={a[HeightSym]()} key={a[Id]} />));
}
}
@@ -51,8 +42,6 @@ interface IRegionAnnotationProps {
@observer
class RegionAnnotation extends React.Component<IRegionAnnotationProps> {
- @observable private _backgroundColor: string = "red";
-
private _reactionDisposer?: IReactionDisposer;
private _scrollDisposer?: IReactionDisposer;
private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
@@ -60,13 +49,13 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> {
componentDidMount() {
this._reactionDisposer = reaction(
() => this.props.document.delete,
- () => this.props.document.delete && this._mainCont.current && (this._mainCont.current.style.display = "none"),
+ (del) => del && this._mainCont.current && (this._mainCont.current.style.display = "none"),
{ fireImmediately: true }
);
this._scrollDisposer = reaction(
() => this.props.ParentIndex(),
- () => this.props.ParentIndex() === this.props.index && this.props.scrollTo && this.props.scrollTo(this.props.y * scale)
+ (ind) => ind === this.props.index && this.props.scrollTo && this.props.scrollTo(this.props.y * scale)
);
}
@@ -129,15 +118,13 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> {
}
render() {
- return (
- <div className="pdfAnnotation" onPointerDown={this.onPointerDown} ref={this._mainCont}
- style={{
- top: this.props.y * scale,
- left: this.props.x * scale,
- width: this.props.width * scale,
- height: this.props.height * scale,
- backgroundColor: this.props.ParentIndex() === this.props.index ? "green" : StrCast(this.props.document.color)
- }} />
- );
+ return (<div className="pdfAnnotation" onPointerDown={this.onPointerDown} ref={this._mainCont}
+ style={{
+ top: this.props.y * scale,
+ left: this.props.x * scale,
+ width: this.props.width * scale,
+ height: this.props.height * scale,
+ backgroundColor: this.props.ParentIndex() === this.props.index ? "green" : StrCast(this.props.document.color)
+ }} />);
}
} \ No newline at end of file
diff --git a/src/client/views/pdf/Page.tsx b/src/client/views/pdf/Page.tsx
index fd4fbfb21..a1f807f13 100644
--- a/src/client/views/pdf/Page.tsx
+++ b/src/client/views/pdf/Page.tsx
@@ -198,16 +198,13 @@ export default class Page extends React.Component<IPageProps> {
onSelectEnd = (e: PointerEvent): void => {
if (this._marqueeing) {
this._marqueeing = false;
- if (this._marquee.current) {
+ if (this._marquee.current) { // make a copy of the marquee
let copy = document.createElement("div");
- // make a copy of the marquee
let style = this._marquee.current.style;
copy.style.left = style.left;
copy.style.top = style.top;
copy.style.width = style.width;
copy.style.height = style.height;
-
- // apply the appropriate background, opacity, and transform
copy.style.border = style.border;
copy.style.opacity = style.opacity;
copy.className = "pdfPage-annotationBox";
@@ -293,7 +290,6 @@ export default class Page extends React.Component<IPageProps> {
}}>
</div>
<div className="pdfPage-textlayer" ref={this._textLayer} />
- </div>
- );
+ </div>);
}
} \ No newline at end of file