From f9ec063ac57061b0b6ee9df901773401f98f87e6 Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Tue, 5 Mar 2019 10:35:11 -0500 Subject: object structure --- src/views/nodes/Annotation.tsx | 26 ++++- src/views/nodes/PDFNode.tsx | 254 ++++++++++++++++++++++------------------- 2 files changed, 160 insertions(+), 120 deletions(-) (limited to 'src') diff --git a/src/views/nodes/Annotation.tsx b/src/views/nodes/Annotation.tsx index 0ba05ba3d..a2c7be1a8 100644 --- a/src/views/nodes/Annotation.tsx +++ b/src/views/nodes/Annotation.tsx @@ -9,6 +9,8 @@ interface IProps{ X: number; Y: number; Highlights: any[]; + Annotations: any[]; + CurrAnno: any[]; } @@ -43,7 +45,22 @@ export class Annotation extends React.Component { */ @action onRemove = (e:any) => { - + let index:number = -1; + //finding the highlight in the highlight array + this.props.Highlights.forEach((e) => { + for (let i = 0; i < e.spans.length; i++){ + if (e.spans[i] == this.props.Span){ + index = this.props.Highlights.indexOf(e); + this.props.Highlights.splice(index, 1); + } + } + }) + + //removing from CurrAnno and Annotation array + this.props.Annotations.splice(index, 1); + this.props.CurrAnno.pop() + + //removing span from div if(this.props.Span.parentElement){ let nodesArray = this.props.Span.parentElement.childNodes; nodesArray.forEach((e) => { @@ -55,13 +72,12 @@ export class Annotation extends React.Component { } }) e.remove(); - - - } } }) } + + } render() { @@ -75,7 +91,7 @@ export class Annotation extends React.Component { transform: `translate(${this.props.X}px, ${this.props.Y}px)`, }}> -
+
@@ -402,19 +423,21 @@ export class PDFNode extends React.Component { this._mainDiv.current.childNodes.forEach((element) => { if (element.nodeName == "DIV"){ element.childNodes[0].childNodes.forEach((e) => { + if (e.nodeName == "CANVAS"){ + this._pdfCanvas = e; //@ts-ignore this._pdfContext = e.getContext("2d") - } + + } + }) } }) } this.numPage = page.transport.numPages - if (this.stickiesPerPage == null){ //only runs once, when stickiesPerPage is null - this.stickiesPerPage = [...Array(this.numPage)].map(() => Array(1)); - this.annotationsPerPage = [...Array(this.numPage).map(()=> Array(1))]; - this.highlightsPerPage = [...Array(this.numPage).map(() => Array(1))]; + if (this.perPage.length == 0){ //Makes sure it only runs once + this.perPage = [...Array(this.numPage)] } } } @@ -423,4 +446,5 @@ export class PDFNode extends React.Component {
); } + } \ No newline at end of file -- cgit v1.2.3-70-g09d2