diff --git a/.eslintignore b/.eslintignore index d23f6b89..aeca9114 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,5 @@ coverage/ +dist/ shared/pdf_viewer.js shared/pdf.js shared/pdf.worker.js diff --git a/.gitignore b/.gitignore index 65f40509..2454f461 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules/ coverage/ sandbox/shared web/shared -dist/ web-dist/ npm-debug.log .DS_Store diff --git a/dist/pdf-annotate.js b/dist/pdf-annotate.js new file mode 100644 index 00000000..ec294869 --- /dev/null +++ b/dist/pdf-annotate.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}h(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&h(t,"error",e,n)}(t,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function l(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function d(t,e,n,r){var o,i,a,u;if(l(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function y(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)i(c,this,e);else{var l=c.length,s=v(c,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},u.prototype.listeners=function(t){return y(this,t,!0)},u.prototype.rawListeners=function(t){return y(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},u.prototype.listenerCount=m,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){"use strict";function r(t){throw new Error(t+" is not implemented")}n.r(e);var o=n(0),i=n.n(o),a=/[A-Z]/g,u=["viewBox"];function c(t,e){Object.keys(e).forEach((function(n){t.setAttribute(function(t){return-1===u.indexOf(t)&&(t=t.replace(a,(function(t){return"-"+t.toLowerCase()}))),t}(n),e[n])}))}var l=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function s(t){return l.test(t)&&(t="#".concat(t)),t}function d(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return c(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function f(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function q(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height,o=0,i=0;if(["line","path"].indexOf(t.tagName.toLowerCase())>-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var u=function(t){var e=t;for(;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),c=u.offsetLeft,l=u.offsetTop;return{top:e.top-l+i,left:e.left-c+o,bottom:e.bottom-l-i,right:e.right-c-o,width:n,height:r}}function F(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function z(t,e,n){var r=[1,0,0,1,0,0];r=h(r=g(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a,u=k(n);return r=v(r,u.x,u.y),o=t,a=(i=r)[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function X(t,e,n){var r=[1,0,0,1,0,0];r=h(r=g(r,(n=n||H(e).viewport).scale,n.scale),n.rotation);var o,i,a=k(n);return r=v(r,a.x,a.y),i=r,[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function Y(t,e){var n={},r=H(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function U(){P.parentNode||document.head.appendChild(P)}function Q(){P.parentNode&&P.parentNode.removeChild(P)}function H(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}P.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",P.setAttribute("data-pdf-annotate-user-select","true");var D,W=new i.a;function $(){W.emit.apply(W,arguments)}function J(){W.on.apply(W,arguments)}function V(){W.removeListener.apply(W,arguments)}function G(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function K(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};G(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))}var e,n,o;return e=t,(n=[{key:"__getAnnotations",value:function(t,e){r("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){r("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){r("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){r("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){r("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){r("getComments")}},{key:"__addComment",value:function(t,e,n){r("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return $("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){r("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&$("comment:delete",e,n),t}))}}}])&&K(e.prototype,n),o&&K(e,o),Object.defineProperty(e,"prototype",{writable:!1}),t}(),tt=/[xy]/g;function et(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function nt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(tt,et)}function rt(t){return(rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function ot(t,e){for(var n=0;n-1){var i=st(t);i.splice(o,1),dt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(st(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:nt(),annotation:e,content:n},a=st(t);a.push(i),dt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){if(!(st(t).filter((function(t){return t.uuid===e}))[0]||{}))return r("Could not find annotation");for(var o=-1,i=st(t),a=0,u=i.length;a-1&&(i.splice(o,1),dt(t,i)),n(!0)}))},t}return e=i,n&&ot(e.prototype,n),r&&ot(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(Z);function st(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function dt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function ft(t,e){for(var n=-1,r=st(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return vt(this,i),(t=o.call(this,{getAnnotations:function(t,e){return new Promise((function(n,r){var o=St(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}))._userId=e,t._globalEdit=n,t.getAnnotation=function(e,n){return Promise.resolve(Et(e,t._userId)[Lt(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=nt(),r.page=n,r.userId=t._userId;var a=Et(e,t._userId);a.push(r),Ct(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=Et(e,r.userId);a[Lt(e,r.userId,n)]=r,Ct(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=St(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=Lt(e,i.userId,n);if(a>-1){var u=Et(e,i.userId);u.splice(a,1),Ct(e,i.userId,u)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(Et(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:nt(),annotation:n,content:r,userId:t._userId},u=Et(e,t._userId);u.push(a),Ct(e,t._userId,u),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=St(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,u=Et(e,i.userId),c=0,l=u.length;c-1&&(u.splice(a,1),Ct(e,i.userId,u)),r(!0)}))},t}return e=i,(n=[{key:"userId",get:function(){return this._userId}}])&&ht(e.prototype,n),r&&ht(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(Z);function St(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,yt(JSON.parse(localStorage.getItem(localStorage.key(r)))));return e}function Et(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function Ct(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function Lt(t,e,n){for(var r=-1,o=Et(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&n+Ot.offsetHeight0&&r+Ot.offsetWidth-1&&(a="cx",u="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var c=z([Pt,Rt],o),l=z([Ot.offsetLeft,Ot.offsetTop],o),s={x:l[0]-c[0],y:l[1]-c[1]};"textbox"===r&&(n=[n[0].firstChild]),_t(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(u),10);0!==s.y&&(o+=s.y,e.setAttribute(u,o),t.rectangles&&n1&&(n=M(t,e))){var r=H(n),o=r.documentId,i=r.pageNumber;Cn.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Ht,color:Dt,lines:Vt}).then((function(t){Wt&&n.removeChild(Wt),N(n,t)}))}}(t.clientX,t.clientY)}function Zt(t){M(t.clientX,t.clientY)&&Jt&&function(t,e){var n=M(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=z([t-r.left,e-r.top],n);if(o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),Vt.push(o),Vt.length<=1)return;Wt&&n.removeChild(Wt);Wt=N(n,{type:"drawing",color:Dt,width:Ht,lines:Vt})}(t.clientX,t.clientY)}function te(t){27===t.keyCode&&(Vt=null,Wt.parentNode.removeChild(Wt),document.removeEventListener("pointermove",Zt),document.removeEventListener("pointerup",Kt))}var ee,ne,re,oe,ie,ae,ue=!1;function ce(t){var e=T(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=R(e),o=H(r).documentId,i=e.getAttribute("data-pdf-annotate-id");Cn.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){re=null,oe=[];var e=X([t.cx,t.cy],r),n=r.getBoundingClientRect();ae=e[0]+n.left,ie=e[1]+n.top,document.addEventListener("mousemove",se),document.addEventListener("mouseup",le)}}))}}}function le(t){var e;if(oe.length>1&&(e=M(t.clientX,t.clientY))){var n=H(e),r=n.documentId,o=n.pageNumber;Cn.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:ee,color:ne,lines:oe}).then((function(t){re&&e.removeChild(re),N(e,t)}))}document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",le)}function se(t){!function(t,e){var n=M(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=z([t-r.left,e-r.top],n);if(oe.length<2)return void oe.push(o);oe[1]=o;re&&n.removeChild(re);re=N(n,{type:"arrow",color:ne,width:ee,lines:oe})}(0===oe.length?ae:t.clientX,0===oe.length?ie:t.clientY)}function de(t){27===t.keyCode&&(oe=null,re.parentNode.removeChild(re),document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",le))}function fe(t){return function(t){if(Array.isArray(t))return pe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return pe(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return pe(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function pe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(we.style.left,10),e=parseInt(we.style.top,10),n=we.value.trim(),r=M(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=H(r),a=i.documentId,u=i.pageNumber,c=Object.assign({type:"point"},Y(r,{x:t-o.left,y:e-o.top}));Cn.getStoreAdapter().addAnnotation(a,u,c).then((function(t){Cn.getStoreAdapter().addComment(a,t.uuid,n),N(r,t)}))}Le()}function Le(){we.removeEventListener("blur",Se),we.removeEventListener("keyup",Ee),document.body.removeChild(we),we=null}function Ie(t){return function(t){if(Array.isArray(t))return _e(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return _e(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _e(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _e(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))qe(ke,Ie(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===ke&&Oe){var n=Oe.parentNode.querySelector(It.annotationSvgQuery()).getBoundingClientRect();qe(ke,[{top:parseInt(Oe.style.top,10)+n.top,left:parseInt(Oe.style.left,10)+n.left,width:parseInt(Oe.style.width,10),height:parseInt(Oe.style.height,10)}]),Oe.parentNode.removeChild(Oe),Oe=null,document.removeEventListener("mousemove",Me),Q()}}function Be(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),Oe&&Oe.parentNode&&(Oe.parentNode.removeChild(Oe),Oe=null,document.removeEventListener("mousemove",Me)))}function qe(t,e,n){var r,o=M(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),0!==(r={type:t,color:n,rectangles:Ie(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=z(r,e,n),o=z(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))}).rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var u=H(o),c=u.documentId,l=u.pageNumber;Cn.getStoreAdapter().addAnnotation(c,l,r).then((function(t){N(o,t)}))}}}var Fe,ze=!1,Xe=10,Ye="0000FF";function Ue(t){var e=M(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=z([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r:r},u=H(t),c=u.documentId,l=u.pageNumber;Cn.getStoreAdapter().addAnnotation(c,l,a).then((function(e){N(t,e)}))}(e,Fe,{x:t.clientX-n.left,y:t.clientY-n.top},Xe,Ye)}}var Qe,He=!1,De=localStorage.getItem("text/size")||12,We=localStorage.getItem("text/color")||"#000000";function $e(t){!Qe&&M(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((Qe=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),Qe.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),Qe.style.border="3px solid ".concat("#00BFFF"),Qe.style.borderRadius="3px",Qe.style.position="fixed",Qe.style.top="".concat(t.clientY,"px"),Qe.style.left="".concat(t.clientX,"px"),Qe.style.fontSize="".concat(De,"px"),Qe.style.zIndex="41",Qe.addEventListener("blur",Je),Qe.addEventListener("keyup",Ve),document.body.appendChild(Qe),Qe.focus())}function Je(){Ge()}function Ve(t){27===t.keyCode?Ke():13!==t.keyCode||t.shiftKey||Ge()}function Ge(){var t=Qe.value?Qe.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(Qe.style.left,10),n=parseInt(Qe.style.top,10),r=M(e,n);if(!r)return;var o=De,i=H(r),a=i.documentId,u=i.pageNumber,c=i.viewport,l=1/c.scale,s=r.getBoundingClientRect(),d=z([e-s.left,n-s.top+o],r,c),f={type:"textbox",size:De*l,color:We,content:t,x:d[0],y:d[1],rotation:-c.rotation};Cn.getStoreAdapter().addAnnotation(a,u,f).then((function(t){N(r,t)}))}Ke()}function Ke(){Qe&&(Qe.removeEventListener("blur",Je),Qe.removeEventListener("keyup",Ve),document.body.removeChild(Qe),Qe=null)}function Ze(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function tn(t){return function(t){if(Array.isArray(t))return en(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return en(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function en(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(c.innerHTML=l.join(""),u+Y(a,{width:c.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),c.parentNode.removeChild(c),!0}function rn(t){return function(t){if(Array.isArray(t))return on(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return on(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return on(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function on(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n div"));n=F(o,{y:n}).y+i.top,e=F(o,{x:e}).x+i.left;for(var u=0,c=a.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];nn(Ze("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),nn(Ze("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";an(Ze("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],u=void 0!==t.y?t.y:t.lines[0][1];an(Ze("Unlabeled drawing",t.uuid),a,u,t.page);break;case"circle":case"fillcircle":case"emptycircle":var c=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];an(Ze("Unlabeled drawing",t.uuid),c,l,t.page)}ln.includes(t.type)&&cn(t.documentId,t.uuid)}(t,e+1)}))}))}function vn(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=new Array(e);n\n \n \n';function An(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var u=r+i,c=o+a;if(c>8)break;n<=u/c?(i=u,a=c):(r=u,o=c)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Ht=Math.round(100*parseFloat(t))/100,Dt=e},disablePoint:function(){xe&&(xe=!1,document.removeEventListener("mouseup",Ae))},enablePoint:function(){xe||(xe=!0,document.addEventListener("mouseup",Ae))},disableRect:function(){Pe&&(Pe=!1,document.removeEventListener("mouseup",Te),document.removeEventListener("mousedown",Re),document.removeEventListener("keyup",Be))},enableRect:function(t){ke=t,Pe||(Pe=!0,document.addEventListener("mouseup",Te),document.addEventListener("mousedown",Re),document.addEventListener("keyup",Be))},disableCircle:function(){ze&&(ze=!1,document.removeEventListener("mouseup",Ue))},enableCircle:function(t){Fe=t,ze||(ze=!0,document.addEventListener("mouseup",Ue))},setCircle:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";Xe=parseInt(t,10),Ye=e},addCircle:function(t,e){var n=Fe;Fe=t,Ue(e),Fe=n},disableArrow:function(){ue&&(ue=!1,document.removeEventListener("mousedown",ce),document.removeEventListener("keyup",de),Q())},enableArrow:function(){ue||(ue=!0,document.addEventListener("mousedown",ce),document.addEventListener("keyup",de),U())},setArrow:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";ee=parseInt(t,10),ne=e},disableEraser:function(){document.removeEventListener("pointermove",ge),document.removeEventListener("pointerdown",ve),document.removeEventListener("pointerup",he)},enableEraser:function(){document.addEventListener("pointermove",ge),document.addEventListener("pointerdown",ve),document.addEventListener("pointerup",he)},disableText:function(){He&&(He=!1,document.removeEventListener("mouseup",$e))},enableText:function(){He||(He=!0,document.addEventListener("mouseup",$e))},setText:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";De=parseInt(t,10),We=e},createPage:function(t){var e=document.createElement("div");e.innerHTML=xn;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),Cn.getAnnotations(n,t)]).then((function(e){var n=bn(e,2),r=n[0],u=n[1],c=document.getElementById("pageContainer".concat(t)),l=c.querySelector(It.annotationClassQuery()),s=c.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),d=(i+r.rotate)%360,f=r.getViewport({scale:o,rotation:d}),p=function(t,e,n){var r=document.getElementById("pageContainer".concat(t)),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(It.annotationClassQuery()),a=r.querySelector(".canvasWrapper"),u=r.querySelector(It.textClassQuery()),c=(f=n,p=window.devicePixelRatio||1,y=f.webkitBackingStorePixelRatio||f.mozBackingStorePixelRatio||f.msBackingStorePixelRatio||f.oBackingStorePixelRatio||f.backingStorePixelRatio||1,m=p/y,{sx:m,sy:m,scaled:1!==m}),l=c.scaled?[c.sx,0,0,c.sy,0,0]:null,s=An(c.sx),d=An(c.sy);var f,p,y,m;return r.style.visibility="",o.width=Sn(e.width*c.sx,s[0]),o.height=Sn(e.height*c.sy,d[0]),o.style.width=Sn(e.width,s[1])+"px",o.style.height=Sn(e.height,s[1])+"px",i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),r.style.width="".concat(e.width,"px"),r.style.height="".concat(e.height,"px"),a.style.width="".concat(e.width,"px"),a.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l}(t,f,s);return Promise.all([r.render({canvasContext:s,viewport:f,transform:p}).promise,Cn.render(l,f,u)]).then((function(){return r.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=c.querySelector(It.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,f,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{mn(u.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return c.setAttribute("data-loaded","true"),[r,u]}))}))}},Cn={findAnnotationAtPoint:T,findSVGContainer:R,convertToScreenPoint:X,StoreAdapter:Z,LocalStoreAdapter:lt,LocalUserStoreAdapter:At,__storeAdapter:new Z,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:En,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?j(t,r,e):N(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:It,uuid:nt};e.default=Cn}])})); +//# sourceMappingURL=pdf-annotate.js.map \ No newline at end of file diff --git a/dist/pdf-annotate.js.map b/dist/pdf-annotate.js.map new file mode 100644 index 00000000..55014caf --- /dev/null +++ b/dist/pdf-annotate.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","this","once","emitter","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","abstractFunction","UPPER_REGEX","BLACKLIST","setAttributes","node","attributes","forEach","setAttribute","indexOf","replace","match","toLowerCase","keyCase","REGEX_HASHLESS_HEX","normalizeColor","color","test","createRect","rect","document","createElementNS","x","y","width","height","renderText","a","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","renderCircle","circle","cx","cy","createCircle","stroke","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","renderArrow","u","arrow","p1","p2","pt0","unitX","unitZ","unitY","thickness","A","B","C","D","G","F","E","points","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","renderRect","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","SIZE","viewBox","renderPoint","join","renderPath","uuid","filter","transformChild","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","getOffsetAnnotationRect","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","offsetLeft","offsetTop","getOffset","scaleUp","result","getMetadata","convertToSvgPoint","xform","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","definition","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","random","LocalStoreAdapter","_StoreAdapter","_inherits","_super","_createSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","_toConsumableArray","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","getElementById","keyTest","keyCode","preventDefault","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","insertComment","removeComment","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleRadius","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textSize","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","_slicedToArray","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","wrapper","outputScale","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","sx","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","UI","data","removeAttribute","_this$getStoreAdapter"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,IARxB,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ,EAAoBO,EAAIR,EAGxBC,EAAoBQ,EAAI,SAASd,EAASe,EAAMC,GAC3CV,EAAoBW,EAAEjB,EAASe,IAClCG,OAAOC,eAAenB,EAASe,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEV,EAAoBgB,EAAI,SAAStB,GACX,oBAAXuB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAenB,EAASuB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAenB,EAAS,aAAc,CAAEyB,OAAO,KAQvDnB,EAAoBoB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQnB,EAAoBmB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA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X,EAAIoX,gBAAgB,0BAGfD,GAKLnX,EAAI9G,aAAa,6BAA8Bie,EAAKlT,YACpDjE,EAAI9G,aAAa,yBAA0Bie,EAAKjT,YAG3C3N,MAAM8Z,QAAQ8G,EAAKrS,cAA4C,IAA5BqS,EAAKrS,YAAY1P,QAKzD+hB,EAAKrS,YAAY7L,SAAQ,SAACoB,GACxB,IAAItB,EAAOiH,EAAID,cAAc,0BAA4B1F,EAAEkH,KAAO,MAC9DxI,EACF0I,EAAezB,EAAKjH,EAAM2G,GAG1BhE,EAAYsE,EAAK3F,EAAGqF,WAIxBvM,EAAQ6M,IAdC7M,EAAQ6M,KATfA,EAAIvE,UAAY,GACTtI,EAAQ6M,QD+DnBgG,eAAc,SAAC/B,EAAYC,GAAY,IAAAmT,EACrC,OAAOA,EAAAtkB,KAAKiW,mBAAkBhD,eAAc/T,MAAAolB,EAAI3jB,YAGlDoV,UAEAvH,SE3FawH","file":"pdf-annotate.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/**\r\n * Throw an Error for an abstract function that hasn't been implemented.\r\n *\r\n * @param {String} name The name of the abstract function\r\n */\r\nexport default function abstractFunction(name) {\r\n throw new Error(name + ' is not implemented');\r\n}\r\n","const UPPER_REGEX = /[A-Z]/g;\r\n\r\n// Don't convert these attributes from camelCase to hyphenated-attributes\r\nconst BLACKLIST = [\r\n 'viewBox'\r\n];\r\n\r\nlet keyCase = (key) => {\r\n if (BLACKLIST.indexOf(key) === -1) {\r\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\r\n }\r\n return key;\r\n};\r\n\r\n/**\r\n * Set attributes for a node from a map\r\n *\r\n * @param {Node} node The node to set attributes on\r\n * @param {Object} attributes The map of key/value pairs to use for attributes\r\n */\r\nexport default function setAttributes(node, attributes) {\r\n Object.keys(attributes).forEach((key) => {\r\n node.setAttribute(keyCase(key), attributes[key]);\r\n });\r\n}\r\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\r\n\r\n/**\r\n * Normalize a color value\r\n *\r\n * @param {String} color The color to normalize\r\n * @return {String}\r\n */\r\nexport default function normalizeColor(color) {\r\n if (REGEX_HASHLESS_HEX.test(color)) {\r\n color = `#${color}`;\r\n }\r\n return color;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGRectElements from an annotation definition.\r\n * This is used for anntations of type `area` and `highlight`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\r\n */\r\nexport default function renderRect(a) {\r\n if (a.type === 'highlight') {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n fill: normalizeColor(a.color || '#ff0'),\r\n fillOpacity: 0.2\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n group.appendChild(createRect(r));\r\n });\r\n\r\n return group;\r\n }\r\n else {\r\n let rect = createRect(a);\r\n setAttributes(rect, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n fill: 'none'\r\n });\r\n\r\n return rect;\r\n }\r\n}\r\n\r\nfunction createRect(r) {\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n\r\n setAttributes(rect, {\r\n x: r.x,\r\n y: r.y,\r\n width: r.width,\r\n height: r.height\r\n });\r\n\r\n return rect;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Wrap each line of given text in a `` element and append these\r\n * lines to the given SVGTextElement\r\n *\r\n * @param {SVGTextElement} textElement A text element to hold the split text\r\n * @param {String} textContent String to render with line breaks\r\n */\r\nfunction insertLineBreaks(textElement, textContent) {\r\n const lines = (textContent || '').split('\\n');\r\n // can't use dy attribute here since we want empty lines to take up space as well,\r\n // so we will update y manually based on font size\r\n const x = textElement.getAttribute('x');\r\n let y = Number(textElement.getAttribute('y'));\r\n const size = Number(textElement.getAttribute('font-size'));\r\n for (const line of lines) {\r\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\r\n tspan.setAttribute('y', y.toString());\r\n tspan.setAttribute('x', x);\r\n tspan.innerHTML = line;\r\n textElement.appendChild(tspan);\r\n\r\n y += size;\r\n }\r\n}\r\n\r\n/**\r\n * Create SVGTextElement from an annotation definition.\r\n * This is used for anntations of type `textbox`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGTextElement} A text to be rendered\r\n */\r\nexport default function renderText(a) {\r\n // Text should be rendered at 0 degrees relative to\r\n // document rotation\r\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r\n setAttributes(text, {\r\n x: a.x,\r\n y: a.y,\r\n fill: normalizeColor(a.color || '#000'),\r\n fontSize: a.size,\r\n transform: `rotate(${a.rotation})`,\r\n style: 'white-space: pre'\r\n });\r\n\r\n insertLineBreaks(text, a.content);\r\n\r\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n g.appendChild(text);\r\n\r\n return g;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create an SVGCircleElement from an annotation definition.\r\n * This is used for annotations of type `circle`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\r\n */\r\nexport default function renderCircle(a) {\r\n let circle = createCircle(a);\r\n let color = normalizeColor(a.color || '#f00');\r\n\r\n if (a.type === 'circle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 5\r\n });\r\n }\r\n if (a.type === 'emptycircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 2\r\n });\r\n }\r\n\r\n if (a.type === 'fillcircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: color,\r\n 'stroke-width': 5\r\n });\r\n }\r\n\r\n return circle;\r\n}\r\n\r\nfunction createCircle(a) {\r\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\r\n setAttributes(circle, {\r\n cx: a.cx,\r\n cy: a.cy,\r\n r: a.r\r\n });\r\n\r\n return circle;\r\n}\r\n","// Transform point by matrix\r\n//\r\nexport function applyTransform(p, m) {\r\n return [\r\n p[0] * m[0] + p[1] * m[2] + m[4],\r\n p[0] * m[1] + p[1] * m[3] + m[5]\r\n ];\r\n};\r\n\r\n// Transform point by matrix inverse\r\n//\r\nexport function applyInverseTransform(p, m) {\r\n let d = m[0] * m[3] - m[1] * m[2];\r\n return [\r\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\r\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\r\n ];\r\n};\r\n\r\n// Concatenates two transformation matrices together and returns the result.\r\nexport function transform(m1, m2) {\r\n return [\r\n m1[0] * m2[0] + m1[2] * m2[1],\r\n m1[1] * m2[0] + m1[3] * m2[1],\r\n m1[0] * m2[2] + m1[2] * m2[3],\r\n m1[1] * m2[2] + m1[3] * m2[3],\r\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\r\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\r\n ];\r\n};\r\n\r\nexport function translate(m, x, y) {\r\n return [\r\n m[0],\r\n m[1],\r\n m[2],\r\n m[3],\r\n m[0] * x + m[2] * y + m[4],\r\n m[1] * x + m[3] * y + m[5]\r\n ];\r\n};\r\n\r\nexport function rotate(m, angle) {\r\n angle = angle * Math.PI / 180;\r\n\r\n let cosValue = Math.cos(angle);\r\n let sinValue = Math.sin(angle);\r\n\r\n return [\r\n m[0] * cosValue + m[2] * sinValue,\r\n m[1] * cosValue + m[3] * sinValue,\r\n m[0] * (-sinValue) + m[2] * cosValue,\r\n m[1] * (-sinValue) + m[3] * cosValue,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function scale(m, x, y) {\r\n return [\r\n m[0] * x,\r\n m[1] * x,\r\n m[2] * y,\r\n m[3] * y,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function makePoint(x, y, z) {\r\n return { x: x, y: y, z: z };\r\n};\r\n\r\nexport function makeVector(xcoord, ycoord, zcoord) {\r\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\r\n};\r\n\r\nexport function makeVectorFromPoints(pt1, pt2) {\r\n let xcoord = pt2.x - pt1.x;\r\n let ycoord = pt2.y - pt1.y;\r\n let zcoord = pt2.z - pt1.z;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function addVector(pt, v) {\r\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\r\n};\r\n\r\nexport function multiplyVector(v, scalar) {\r\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\r\n};\r\n\r\nexport function magnitude(v) {\r\n return Math.sqrt(\r\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\r\n );\r\n};\r\n\r\nexport function negateVector(v) {\r\n return multiplyVector(v, -1);\r\n};\r\n\r\nexport function unitVector(v) {\r\n let mag = magnitude(v);\r\n let xcoord = v.xcoord / mag;\r\n let ycoord = v.ycoord / mag;\r\n let zcoord = v.zcoord / mag;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function crossProduct(u, v) {\r\n //\r\n // u X v = < u2*v3 - u3*v2,\r\n // u3*v1 - u1*v3,\r\n // u1*v2 - u2*v1 >\r\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\r\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\r\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\nimport {\r\n makePoint, makeVector, makeVectorFromPoints,\r\n magnitude, unitVector, crossProduct,\r\n addVector, multiplyVector, negateVector\r\n} from '../utils/mathUtils';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderArrow(a) {\r\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\r\n\r\n if (a.lines.length === 2) {\r\n let p1 = a.lines[0];\r\n let p2 = a.lines[a.lines.length - 1];\r\n\r\n let arrowLength = 40;\r\n let pt0 = makePoint(p1[0], p1[1], 0);\r\n let pt1 = makePoint(p2[0], p2[1], 0);\r\n let x = makeVectorFromPoints(pt0, pt1);\r\n let unitX = unitVector(x);\r\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\r\n x = makeVectorFromPoints(pt0, pt1);\r\n let unitZ = makeVector(0, 0, 1);\r\n let unitY = unitVector(crossProduct(unitX, unitZ));\r\n let thickness = a.width || 10;\r\n\r\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\r\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let C = addVector(B, multiplyVector(unitY, thickness));\r\n let D = pt1;\r\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\r\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\r\n\r\n let points = '' +\r\n A.x + ',' + A.y + ' ' +\r\n B.x + ',' + B.y + ' ' +\r\n C.x + ',' + C.y + ' ' +\r\n D.x + ',' + D.y + ' ' +\r\n E.x + ',' + E.y + ' ' +\r\n F.x + ',' + F.y + ' ' +\r\n G.x + ',' + G.y;\r\n\r\n setAttributes(arrow, {\r\n points: points,\r\n stroke: normalizeColor(a.color || '#000'),\r\n fill: normalizeColor(a.color || '#000')\r\n });\r\n }\r\n\r\n return arrow;\r\n}\r\n","import renderLine from './renderLine';\r\nimport renderPath from './renderPath';\r\nimport renderPoint from './renderPoint';\r\nimport renderRect from './renderRect';\r\nimport renderText from './renderText';\r\nimport renderCircle from './renderCircle';\r\nimport renderArrow from './renderArrow';\r\n\r\nconst isFirefox = /firefox/i.test(navigator.userAgent);\r\n\r\n/**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n *\r\n * @param {Object} viewport The viewport data from the page\r\n * @return {Object}\r\n */\r\nexport function getTranslation(viewport) {\r\n let x;\r\n let y;\r\n\r\n // Modulus 360 on the rotation so that we only\r\n // have to worry about four possible values.\r\n switch (viewport.rotation % 360) {\r\n case 0:\r\n x = y = 0;\r\n break;\r\n case 90:\r\n x = 0;\r\n y = (viewport.width / viewport.scale) * -1;\r\n break;\r\n case 180:\r\n x = (viewport.width / viewport.scale) * -1;\r\n y = (viewport.height / viewport.scale) * -1;\r\n break;\r\n case 270:\r\n x = (viewport.height / viewport.scale) * -1;\r\n y = 0;\r\n break;\r\n }\r\n\r\n return { x, y };\r\n}\r\n\r\n/**\r\n * Transform the rotation and scale of a node using SVG's native transform attribute.\r\n *\r\n * @param {Node} node The node to be transformed\r\n * @param {Object} viewport The page's viewport data\r\n * @return {Node}\r\n */\r\nfunction transform(node, viewport) {\r\n let trans = getTranslation(viewport);\r\n\r\n // Let SVG natively transform the element\r\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\r\n\r\n // Manually adjust x/y for nested SVG nodes\r\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\r\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\r\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\r\n\r\n let x = parseInt(node.getAttribute('x', 10));\r\n let y = parseInt(node.getAttribute('y', 10));\r\n let width = parseInt(node.getAttribute('width'), 10);\r\n let height = parseInt(node.getAttribute('height'), 10);\r\n let path = node.querySelector('path');\r\n let svg = path.parentNode;\r\n\r\n // Scale width/height\r\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\r\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\r\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\r\n });\r\n\r\n // Transform path but keep scale at 100% since it will be handled natively\r\n transform(path, Object.assign({}, viewport, { scale: 1 }));\r\n\r\n switch (viewport.rotation % 360) {\r\n case 90:\r\n node.setAttribute('x', viewport.width - y - width);\r\n node.setAttribute('y', x);\r\n svg.setAttribute('x', 1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n case 180:\r\n node.setAttribute('x', viewport.width - x - width);\r\n node.setAttribute('y', viewport.height - y - height);\r\n svg.setAttribute('y', 2);\r\n break;\r\n case 270:\r\n node.setAttribute('x', y);\r\n node.setAttribute('y', viewport.height - x - height);\r\n svg.setAttribute('x', -1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Append an annotation as a child of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element to append the annotation to\r\n * @param {Object} annotation The annotation definition to render and append\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was created and appended by this function\r\n */\r\nexport function appendChild(svg, annotation, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n let child;\r\n switch (annotation.type) {\r\n case 'area':\r\n case 'highlight':\r\n child = renderRect(annotation);\r\n break;\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n child = renderCircle(annotation);\r\n break;\r\n case 'strikeout':\r\n child = renderLine(annotation);\r\n break;\r\n case 'point':\r\n child = renderPoint(annotation);\r\n break;\r\n case 'textbox':\r\n child = renderText(annotation);\r\n break;\r\n case 'drawing':\r\n child = renderPath(annotation);\r\n break;\r\n case 'arrow':\r\n child = renderArrow(annotation);\r\n break;\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip appending/transforming if node doesn't exist.\r\n if (child) {\r\n // Set attributes\r\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\r\n child.setAttribute('aria-hidden', true);\r\n\r\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\r\n Object.keys(annotation).filter((key) => {\r\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\r\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\r\n }).forEach((key) => {\r\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\r\n });\r\n\r\n svg.appendChild(transform(child, viewport));\r\n }\r\n\r\n return child;\r\n}\r\n\r\n/**\r\n * Transform a child annotation of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element with the child annotation\r\n * @param {Object} child The SVG child to transform\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was transformed by this function\r\n */\r\nexport function transformChild(svg, child, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip transforming if node doesn't exist.\r\n if (child) {\r\n child = transform(child, viewport);\r\n }\r\n\r\n return child;\r\n}\r\n\r\nexport default {\r\n /**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n */\r\n getTranslation,\r\n\r\n /**\r\n * Append an SVG child for an annotation\r\n */\r\n appendChild,\r\n\r\n /**\r\n * Transform an existing SVG child\r\n */\r\n transformChild\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGLineElements from an annotation definition.\r\n * This is used for anntations of type `strikeout`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement} A group of all lines to be rendered\r\n */\r\nexport default function renderLine(a) {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n strokeWidth: 1\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\r\n\r\n setAttributes(line, {\r\n x1: r.x,\r\n y1: r.y,\r\n x2: r.x + r.width,\r\n y2: r.y\r\n });\r\n\r\n group.appendChild(line);\r\n });\r\n\r\n return group;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\n\r\nconst SIZE = 25;\r\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\r\n\r\n/**\r\n * Create SVGElement from an annotation definition.\r\n * This is used for anntations of type `comment`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGElement} A svg to be rendered\r\n */\r\nexport default function renderPoint(a) {\r\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n setAttributes(outerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: a.x,\r\n y: a.y\r\n });\r\n\r\n setAttributes(innerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: 0,\r\n y: (SIZE * 0.05) * -1,\r\n viewBox: '0 0 1000 1000'\r\n });\r\n\r\n setAttributes(rect, {\r\n width: SIZE,\r\n height: SIZE,\r\n stroke: '#000',\r\n fill: '#ff0'\r\n });\r\n\r\n setAttributes(path, {\r\n d: D,\r\n strokeWidth: 50,\r\n stroke: '#000',\r\n fill: '#fff'\r\n });\r\n\r\n innerSVG.appendChild(path);\r\n outerSVG.appendChild(rect);\r\n outerSVG.appendChild(innerSVG);\r\n\r\n return outerSVG;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderPath(a) {\r\n let d = [];\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n if (a.lines.length > 0) {\r\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\r\n for (let i = 1, l = a.lines.length; i < l; i++) {\r\n let p1 = a.lines[i];\r\n let p2 = a.lines[i + 1];\r\n if (p2) {\r\n d.push(`L${p1[0]} ${p1[1]}`);\r\n }\r\n }\r\n }\r\n\r\n /*\r\n\r\n if(a.lines.length>2) {\r\n var p1 = a.lines[0];\r\n var p2 = a.lines[a.lines.length-1];\r\n\r\n var p3 = []; //arrow\r\n var p4 = [];\r\n var p0 = []; //arrow intersection\r\n\r\n if (p2) {\r\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\r\n\r\n var deltaX = 3;\r\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\r\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\r\n\r\n p3[0] = p0[0] + deltaX;\r\n p3[1] = p0[1] + k*deltaX;\r\n\r\n p4[0] = p0[0] - deltaX;\r\n p4[1] = p0[1] - k*deltaX;\r\n\r\n if(Math.abs(p2[1]-p1[1]) < 20) {\r\n\r\n p3[0] = p0[0] ;\r\n p3[1] = p0[1] + deltaX*1;\r\n\r\n p4[0] = p0[0] ;\r\n p4[1] = p0[1] - deltaX*1;\r\n\r\n }\r\n\r\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\r\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\r\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\r\n }\r\n } */\r\n\r\n setAttributes(path, {\r\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\r\n stroke: normalizeColor(a.color || '#000'),\r\n strokeWidth: a.width || 1,\r\n fill: 'none'\r\n });\r\n\r\n return path;\r\n}\r\n","import { getTranslation } from '../render/appendChild';\r\nimport {\r\n applyTransform,\r\n applyInverseTransform,\r\n translate,\r\n rotate,\r\n scale\r\n} from '../utils/mathUtils';\r\n\r\nexport const BORDER_COLOR = '#00BFFF';\r\n\r\nconst userSelectStyleSheet = document.createElement('style');\r\nuserSelectStyleSheet.innerHTML = `\r\nbody {\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n}\r\n`;\r\n\r\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\r\n\r\n/**\r\n * Find the SVGElement that contains all the annotations for a page\r\n *\r\n * @param {Element} node An annotation within that container\r\n * @return {SVGElement} The container SVG or null if it can't be found\r\n */\r\nexport function findSVGContainer(node) {\r\n let parentNode = node;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\r\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\r\n return parentNode;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an SVGElement container at a given point\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {SVGElement} The container SVG or null if one can't be found\r\n */\r\nexport function findSVGAtPoint(x, y) {\r\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\r\n\r\n for (let i = 0, l = elements.length; i < l; i++) {\r\n let el = elements[i];\r\n let rect = el.getBoundingClientRect();\r\n\r\n if (pointIntersectsRect(x, y, rect)) {\r\n return el;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an Element that represents an annotation at a given point.\r\n *\r\n * IMPORTANT: Requires the annotation layer to be the top most element so\r\n * either use z-ordering or make it the leaf container.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {Element} The annotation element or null if one can't be found\r\n */\r\nexport function findAnnotationAtPoint(x, y) {\r\n let el = null;\r\n let candidate = document.elementFromPoint(x, y);\r\n while (!el && candidate && candidate !== document) {\r\n let type = candidate.getAttribute('data-pdf-annotate-type');\r\n if (type) {\r\n el = candidate;\r\n }\r\n candidate = candidate.parentNode;\r\n }\r\n return el;\r\n}\r\n\r\n/**\r\n * Determine if a point intersects a rect\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\r\n * @return {Boolean} True if a collision occurs, otherwise false\r\n */\r\nexport function pointIntersectsRect(x, y, rect) {\r\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\r\n}\r\n\r\n/**\r\n * Get the rect of an annotation element accounting for offset.\r\n *\r\n * @param {Element} el The element to get the rect of\r\n * @return {Object} The dimensions of the element\r\n */\r\nexport function getOffsetAnnotationRect(el) {\r\n let rect = el.getBoundingClientRect();\r\n let { width, height } = rect;\r\n let extraOffsetWidth = 0;\r\n let extraOffsetHeight = 0;\r\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\r\n let bbox = el.getBBox();\r\n extraOffsetWidth = (rect.width - bbox.width) / 2;\r\n extraOffsetHeight = (rect.height - bbox.height) / 2;\r\n width = bbox.width;\r\n height = bbox.height;\r\n }\r\n let { offsetLeft, offsetTop } = getOffset(el);\r\n return {\r\n top: rect.top - offsetTop + extraOffsetHeight,\r\n left: rect.left - offsetLeft + extraOffsetWidth,\r\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\r\n right: rect.right - offsetLeft - extraOffsetWidth,\r\n width: width,\r\n height: height\r\n };\r\n}\r\n\r\n/**\r\n * Adjust scale from normalized scale (100%) to rendered scale.\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled up\r\n */\r\nexport function scaleUp(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] * viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\nexport function convertToSvgRect(rect, svg, viewport) {\r\n let pt1 = [rect.x, rect.y];\r\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\r\n\r\n pt1 = convertToSvgPoint(pt1, svg, viewport);\r\n pt2 = convertToSvgPoint(pt2, svg, viewport);\r\n\r\n return {\r\n x: Math.min(pt1[0], pt2[0]),\r\n y: Math.min(pt1[1], pt2[1]),\r\n width: Math.abs(pt2[0] - pt1[0]),\r\n height: Math.abs(pt2[1] - pt1[1])\r\n };\r\n}\r\n\r\nexport function convertToSvgPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyInverseTransform(pt, xform);\r\n}\r\n\r\nexport function convertToScreenPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyTransform(pt, xform);\r\n}\r\n\r\n/**\r\n * Adjust scale from rendered scale to a normalized scale (100%).\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled down\r\n */\r\nexport function scaleDown(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] / viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the scroll position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the scroll position for\r\n * @return {Object} The scrollTop and scrollLeft position\r\n */\r\nexport function getScroll(el) {\r\n let scrollTop = 0;\r\n let scrollLeft = 0;\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n scrollTop += parentNode.scrollTop;\r\n scrollLeft += parentNode.scrollLeft;\r\n }\r\n\r\n return { scrollTop, scrollLeft };\r\n}\r\n\r\n/**\r\n * Get the offset position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the offset position for\r\n * @return {Object} The offsetTop and offsetLeft position\r\n */\r\nexport function getOffset(el) {\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\r\n break;\r\n }\r\n }\r\n\r\n let rect = parentNode.getBoundingClientRect();\r\n\r\n return { offsetLeft: rect.left, offsetTop: rect.top };\r\n}\r\n\r\n/**\r\n * Disable user ability to select text on page\r\n */\r\nexport function disableUserSelect() {\r\n if (!userSelectStyleSheet.parentNode) {\r\n document.head.appendChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Enable user ability to select text on page\r\n */\r\nexport function enableUserSelect() {\r\n if (userSelectStyleSheet.parentNode) {\r\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Get the metadata for a SVG container\r\n *\r\n * @param {SVGElement} svg The SVG container to get metadata for\r\n */\r\nexport function getMetadata(svg) {\r\n return {\r\n documentId: svg.getAttribute('data-pdf-annotate-document'),\r\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\r\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\r\n };\r\n}\r\n","import EventEmitter from 'events';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGAtPoint\r\n} from './utils';\r\n\r\nconst emitter = new EventEmitter();\r\n\r\nlet clickNode;\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\ndocument.addEventListener('click', function handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n\r\n // Emit annotation:blur if clickNode is no longer clicked\r\n if (clickNode && clickNode !== target) {\r\n emitter.emit('annotation:blur', clickNode);\r\n }\r\n\r\n // Emit annotation:click if target was clicked\r\n if (target) {\r\n emitter.emit('annotation:click', target);\r\n }\r\n\r\n clickNode = target;\r\n});\r\n\r\n// let mouseOverNode;\r\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\r\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n//\r\n// // Emit annotation:mouseout if target was mouseout'd\r\n// if (mouseOverNode && !target) {\r\n// emitter.emit('annotation:mouseout', mouseOverNode);\r\n// }\r\n//\r\n// // Emit annotation:mouseover if target was mouseover'd\r\n// if (target && mouseOverNode !== target) {\r\n// emitter.emit('annotation:mouseover', target);\r\n// }\r\n//\r\n// mouseOverNode = target;\r\n// });\r\n\r\nexport function fireEvent() { emitter.emit(...arguments); };\r\nexport function addEventListener() { emitter.on(...arguments); };\r\nexport function removeEventListener() { emitter.removeListener(...arguments); };\r\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\r\n/* eslint valid-jsdoc: 0 */\r\n\r\nimport abstractFunction from '../utils/abstractFunction';\r\nimport { fireEvent } from '../UI/event';\r\n\r\n// Adapter should never be invoked publicly\r\nexport default class StoreAdapter {\r\n /**\r\n * Create a new StoreAdapter instance\r\n *\r\n * @param {Object} [definition] The definition to use for overriding abstract methods\r\n */\r\n constructor(definition = {}) {\r\n // Copy each function from definition if it is a function we know about\r\n Object.keys(definition).forEach((key) => {\r\n if (typeof definition[key] === 'function' &&\r\n typeof this[key] === 'function') {\r\n this[key] = definition[key];\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Get all the annotations for a given document and page number.\r\n *\r\n * @param {String} documentId The ID for the document the annotations belong to\r\n * @param {Number} pageNumber The number of the page the annotations belong to\r\n * @return {Promise} Promise that returns with list of annotations for document and page\r\n */\r\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\r\n get getAnnotations() { return this.__getAnnotations; }\r\n set getAnnotations(fn) {\r\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\r\n return fn(...arguments).then((annotations) => {\r\n // TODO may be best to have this happen on the server\r\n if (annotations.annotations) {\r\n annotations.annotations.forEach((a) => {\r\n a.documentId = documentId;\r\n });\r\n }\r\n return annotations;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get the definition for a specific annotation.\r\n *\r\n * @param {String} documentId The ID for the document the annotation belongs to\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns the requested annotation\r\n */\r\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\r\n\r\n /**\r\n * Add an annotation\r\n *\r\n * @param {String} documentId The ID for the document to add the annotation to\r\n * @param {String} pageNumber The page number to add the annotation to\r\n * @param {Object} annotation The definition for the new annotation\r\n * @return {Promise} Promise that returns with the added annotation\r\n */\r\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\r\n get addAnnotation() { return this.__addAnnotation; }\r\n set addAnnotation(fn) {\r\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:add', documentId, pageNumber, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Edit an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} pageNumber the page number of the annotation\r\n * @param {Object} annotation The definition of the modified annotation\r\n * @return {Promise} Promise that returns with the edited annotation\r\n */\r\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\r\n get editAnnotation() { return this.__editAnnotation; }\r\n set editAnnotation(fn) {\r\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:edit', documentId, annotationId, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with boolean if annotation was deleted\r\n */\r\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\r\n get deleteAnnotation() { return this.__deleteAnnotation; }\r\n set deleteAnnotation(fn) {\r\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('annotation:delete', documentId, annotationId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get all the comments for an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with comments for annotation\r\n */\r\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\r\n\r\n /**\r\n * Add a new comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @param {Object} content The definition of the comment\r\n * @return {Promise} Promise that returns with the added comment\r\n */\r\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\r\n get addComment() { return this.__addComment; }\r\n set addComment(fn) {\r\n this.__addComment = function addComment(documentId, annotationId, content) {\r\n return fn(...arguments).then((comment) => {\r\n fireEvent('comment:add', documentId, annotationId, comment);\r\n return comment;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete a comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} commentId The ID for the comment\r\n * @return {Promise} Promise that returns with boolean if comment was deleted\r\n */\r\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\r\n get deleteComment() { return this.__deleteComment; }\r\n set deleteComment(fn) {\r\n this.__deleteComment = function deleteComment(documentId, commentId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('comment:delete', documentId, commentId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n}\r\n","const REGEXP = /[xy]/g;\r\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\r\n\r\nfunction replacement(c) {\r\n let r = Math.random() * 16 | 0;\r\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n}\r\n\r\n/**\r\n * Generate a univierally unique identifier\r\n *\r\n * @return {String} A UUID\r\n */\r\nexport default function uuid() {\r\n return PATTERN.replace(REGEXP, replacement);\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalStoreAdapter extends StoreAdapter {\r\n constructor() {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId);\r\n annotations[findAnnotation(documentId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = findAnnotation(documentId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content\r\n };\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n}\r\n\r\nfunction getAnnotations(documentId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, annotations) {\r\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage and associated user id\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalUserStoreAdapter extends StoreAdapter {\r\n constructor(userId = 'user', globalEdit = false) {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAllAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this._userId = userId;\r\n this._globalEdit = globalEdit;\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n annotation.userId = this._userId;\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n reject('Non-matching userId');\r\n }\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = findAnnotation(documentId, annotation.userId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content,\r\n userId: this._userId\r\n };\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, comment.userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, comment.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n\r\n get userId() {\r\n return this._userId;\r\n }\r\n}\r\n\r\nfunction getAllAnnotations(documentId) {\r\n let all_annotations = [];\r\n let re = new RegExp(`${documentId}/(.*)/annotations`);\r\n for (let i = 0; i < localStorage.length; i++) {\r\n if (localStorage.key(i).search(re) > -1) {\r\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\r\n }\r\n }\r\n return all_annotations;\r\n}\r\n\r\nfunction getAnnotations(documentId, userId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, userId, annotations) {\r\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} userId User id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, userId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","export default {\r\n annotationLayerName: 'annotationLayer',\r\n textLayerName: 'textLayer',\r\n annotationSvgQuery: function() {\r\n return 'svg.' + this.annotationLayerName;\r\n },\r\n annotationClassQuery: function() {\r\n return '.' + this.annotationLayerName;\r\n },\r\n textClassQuery: function() {\r\n return '.' + this.textLayerName;\r\n }\r\n};\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport {\r\n addEventListener,\r\n removeEventListener\r\n} from './event';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGContainer,\r\n findSVGAtPoint,\r\n getOffsetAnnotationRect,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet isDragging = false;\r\nlet overlay;\r\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\r\nconst OVERLAY_BORDER_SIZE = 3;\r\n\r\n/**\r\n * Create an overlay for editing an annotation.\r\n *\r\n * @param {Element} target The annotation element to apply overlay for\r\n */\r\nfunction createEditOverlay(target) {\r\n destroyEditOverlay();\r\n\r\n overlay = document.createElement('div');\r\n let anchor = document.createElement('a');\r\n let parentNode = findSVGContainer(target).parentNode;\r\n let id = target.getAttribute('data-pdf-annotate-id');\r\n let rect = getOffsetAnnotationRect(target);\r\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\r\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\r\n\r\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\r\n overlay.setAttribute('data-target-id', id);\r\n overlay.style.boxSizing = 'content-box';\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${styleTop}px`;\r\n overlay.style.left = `${styleLeft}px`;\r\n overlay.style.width = `${rect.width}px`;\r\n overlay.style.height = `${rect.height}px`;\r\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\r\n overlay.style.zIndex = 20100;\r\n\r\n anchor.innerHTML = '×';\r\n anchor.setAttribute('href', 'javascript://');\r\n anchor.style.background = '#fff';\r\n anchor.style.borderRadius = '20px';\r\n anchor.style.border = '1px solid #bbb';\r\n anchor.style.color = '#bbb';\r\n anchor.style.fontSize = '16px';\r\n anchor.style.padding = '2px';\r\n anchor.style.textAlign = 'center';\r\n anchor.style.textDecoration = 'none';\r\n anchor.style.position = 'absolute';\r\n anchor.style.top = '-13px';\r\n anchor.style.right = '-13px';\r\n anchor.style.width = '25px';\r\n anchor.style.height = '25px';\r\n\r\n overlay.appendChild(anchor);\r\n parentNode.appendChild(overlay);\r\n document.addEventListener('click', handleDocumentClick);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n anchor.addEventListener('click', deleteAnnotation);\r\n anchor.addEventListener('mouseover', () => {\r\n anchor.style.color = '#35A4DC';\r\n anchor.style.borderColor = '#999';\r\n anchor.style.boxShadow = '0 1px 1px #ccc';\r\n });\r\n anchor.addEventListener('mouseout', () => {\r\n anchor.style.color = '#bbb';\r\n anchor.style.borderColor = '#bbb';\r\n anchor.style.boxShadow = '';\r\n });\r\n overlay.addEventListener('mouseover', () => {\r\n if (!isDragging) { anchor.style.display = ''; }\r\n });\r\n overlay.addEventListener('mouseout', () => {\r\n anchor.style.display = 'none';\r\n });\r\n}\r\n\r\n/**\r\n * Destroy the edit overlay if it exists.\r\n */\r\nfunction destroyEditOverlay() {\r\n if (overlay) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n }\r\n\r\n document.removeEventListener('click', handleDocumentClick);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Delete currently selected annotation\r\n */\r\nfunction deleteAnnotation() {\r\n if (!overlay) {\r\n return;\r\n }\r\n\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n\r\n destroyEditOverlay();\r\n}\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\r\n\r\n // Remove current overlay\r\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\r\n if (overlay) {\r\n if (isDragging || e.target === overlay) {\r\n return;\r\n }\r\n\r\n destroyEditOverlay();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\r\n let keyTest;\r\n if (e.key) {\r\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\r\n }\r\n else {\r\n keyTest = e.keyCode === 8 || e.keyCode === 46;\r\n }\r\n if (overlay && keyTest &&\r\n e.target.nodeName.toLowerCase() !== 'textarea' &&\r\n e.target.nodeName.toLowerCase() !== 'input') {\r\n e.preventDefault();\r\n deleteAnnotation();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n if (e.target !== overlay) {\r\n return;\r\n }\r\n\r\n // Highlight and strikeout annotations are bound to text within the document.\r\n // It doesn't make sense to allow repositioning these types of annotations.\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n\r\n if (type === 'highlight' || type === 'strikeout') { return; }\r\n\r\n isDragging = true;\r\n dragOffsetX = e.clientX;\r\n dragOffsetY = e.clientY;\r\n dragStartX = overlay.offsetLeft;\r\n dragStartY = overlay.offsetTop;\r\n\r\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\r\n overlay.style.cursor = 'move';\r\n overlay.querySelector('a').style.display = 'none';\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let parentNode = overlay.parentNode;\r\n let rect = parentNode.getBoundingClientRect();\r\n let y = (dragStartY + (e.clientY - dragOffsetY));\r\n let x = (dragStartX + (e.clientX - dragOffsetX));\r\n let minY = 0;\r\n let maxY = rect.height;\r\n let minX = 0;\r\n let maxX = rect.width;\r\n\r\n if (y > minY && y + overlay.offsetHeight < maxY) {\r\n overlay.style.top = `${y}px`;\r\n }\r\n\r\n if (x > minX && x + overlay.offsetWidth < maxX) {\r\n overlay.style.left = `${x}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target[0].getAttribute('data-pdf-annotate-type');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n overlay.querySelector('a').style.display = '';\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n let attribX = 'x';\r\n let attribY = 'y';\r\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n attribX = 'cx';\r\n attribY = 'cy';\r\n }\r\n\r\n if (type === 'point') {\r\n // Broken\r\n /*\r\n [...target].forEach((t, i) => {\r\n let moveTo = {\r\n x: overlay.offsetLeft + 3,\r\n y: overlay.offsetTop + 3\r\n };\r\n t.setAttribute(attribX, moveTo.x);\r\n t.setAttribute(attribY, moveTo.y);\r\n annotation[attribX] = moveTo.x;\r\n annotation[attribY] = moveTo.y;\r\n });\r\n */\r\n return;\r\n }\r\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n if (type === 'textbox') {\r\n target = [target[0].firstChild];\r\n }\r\n\r\n [...target].forEach((t, i) => {\r\n let modelX = parseInt(t.getAttribute(attribX), 10);\r\n let modelY = parseInt(t.getAttribute(attribY), 10);\r\n if (modelDelta.y !== 0) {\r\n modelY = modelY + modelDelta.y;\r\n\r\n t.setAttribute(attribY, modelY);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].y = modelY;\r\n }\r\n else if (annotation[attribY]) {\r\n annotation[attribY] = modelY;\r\n }\r\n }\r\n if (modelDelta.x !== 0) {\r\n modelX = modelX + modelDelta.x;\r\n\r\n t.setAttribute(attribX, modelX);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].x = modelX;\r\n }\r\n else if (annotation[attribX]) {\r\n annotation[attribX] = modelX;\r\n }\r\n }\r\n });\r\n }\r\n else if (type === 'strikeout') {\r\n return;\r\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\r\n // [...target].forEach(target, (t, i) => {\r\n // if (deltaY !== 0) {\r\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\r\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\r\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\r\n // }\r\n // if (deltaX !== 0) {\r\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\r\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\r\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\r\n // }\r\n // });\r\n }\r\n else if (type === 'drawing' || type === 'arrow') {\r\n // Do nothing as currently broken\r\n /*\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n annotation.lines.forEach((line, i) => {\r\n let [x, y] = annotation.lines[i];\r\n annotation.lines[i][0] = x + modelDelta.x;\r\n annotation.lines[i][1] = y + modelDelta.y;\r\n });\r\n\r\n target[0].parentNode.removeChild(target[0]);\r\n appendChild(svg, annotation);\r\n */\r\n return;\r\n }\r\n\r\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\r\n });\r\n\r\n setTimeout(() => {\r\n isDragging = false;\r\n }, 0);\r\n\r\n overlay.style.background = '';\r\n overlay.style.cursor = '';\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle annotation.click event\r\n *\r\n * @param {Element} e The annotation element that was clicked\r\n */\r\nfunction handleAnnotationClick(target) {\r\n createEditOverlay(target);\r\n}\r\n\r\n/**\r\n * Enable edit mode behavior.\r\n */\r\nexport function enableEdit() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n addEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n/**\r\n * Disable edit mode behavior.\r\n */\r\nexport function disableEdit() {\r\n destroyEditOverlay();\r\n\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n removeEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _candraw = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines = [];\r\n\r\n/**\r\n * Handle document.touchdown or document.pointerdown event\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerdown(e) {\r\n path = null;\r\n lines = [];\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n _candraw = true;\r\n e.preventDefault();\r\n}\r\n\r\n/**\r\n * Handle document.pointerup event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerup(e) {\r\n saveToStorage(e.clientX, e.clientY);\r\n}\r\n\r\nfunction saveToStorage(x, y) {\r\n if (!_candraw) {\r\n return;\r\n }\r\n _candraw = false;\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'drawing',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointermove(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\r\n return;\r\n }\r\n savePoint(e.clientX, e.clientY);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event to be handled\r\n * } e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n point[0] = point[0].toFixed(2);\r\n point[1] = point[1].toFixed(2);\r\n lines.push(point);\r\n\r\n if (lines.length <= 1) {\r\n return;\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'drawing',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setPen(penSize = 1, penColor = '000000') {\r\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Return pen attributes of the pen\r\n *\r\n * @return {Object} Object with size and color\r\n */\r\nexport function getPen() {\r\n return {\r\n size: _penSize,\r\n color: _penColor\r\n };\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enablePen() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\r\n document.addEventListener('pointerdown', handleDocumentPointerdown);\r\n document.addEventListener('pointermove', handleDocumentPointermove);\r\n document.addEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disablePen() {\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n findSVGContainer,\r\n getMetadata,\r\n convertToSvgPoint,\r\n convertToScreenPoint,\r\n findAnnotationAtPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Handle document.mousedown event\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n if (target === null) {\r\n return;\r\n }\r\n\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\r\n return;\r\n }\r\n\r\n let svg = findSVGContainer(target);\r\n let { documentId } = getMetadata(svg);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n if (annotation) {\r\n path = null;\r\n lines = [];\r\n\r\n let point = convertToScreenPoint([\r\n annotation.cx,\r\n annotation.cy\r\n ], svg);\r\n\r\n let rect = svg.getBoundingClientRect();\r\n\r\n originX = point[0] + rect.left;\r\n originY = point[1] + rect.top;\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'arrow',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let x = lines.length === 0 ? originX : e.clientX;\r\n let y = lines.length === 0 ? originY : e.clientY;\r\n\r\n savePoint(x, y);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n\r\n if (lines.length < 2) {\r\n lines.push(point);\r\n return;\r\n }\r\n else {\r\n lines[1] = point; // update end point\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'arrow',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setArrow(penSize = 10, penColor = '0000FF') {\r\n _penSize = parseInt(penSize, 10);\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enableArrow() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disableArrow() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport {\r\n findAnnotationAtPoint,\r\n getMetadata\r\n} from './utils';\r\n\r\nlet _canerase = false;\r\nlet previousPoint = null;\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentDown(e) {\r\n _canerase = true;\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentUp(e) {\r\n _canerase = false;\r\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentMouseMove(e) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n // This algorithm attempts to get the various points between the last\r\n // PointerEvent and this one\r\n let check = [];\r\n let diffX = Math.abs(previousPoint[0] - e.clientX);\r\n let diffY = Math.abs(previousPoint[1] - e.clientY);\r\n if (diffX >= 1 || diffY >= 1) {\r\n let maxSteps = Math.round(Math.max(diffX, diffY));\r\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\r\n let smallerTest = diffX < diffY;\r\n let startPoint = [\r\n Math.min(previousPoint[0], e.clientX),\r\n Math.min(previousPoint[1], e.clientY)\r\n ];\r\n for (let i = 0; i < maxSteps; i++) {\r\n if (smallerTest) {\r\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\r\n }\r\n else {\r\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\r\n }\r\n }\r\n }\r\n for (let point of check) {\r\n erase(findAnnotationAtPoint(point[0], point[1]));\r\n }\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\nfunction erase(target) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n if (target) {\r\n let { documentId } = getMetadata(target.parentElement);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport function enableEraser() {\r\n document.addEventListener('pointermove', handleDocumentMouseMove);\r\n document.addEventListener('pointerdown', handleDocumentDown);\r\n document.addEventListener('pointerup', handleDocumentUp);\r\n}\r\n\r\nexport function disableEraser() {\r\n document.removeEventListener('pointermove', handleDocumentMouseMove);\r\n document.removeEventListener('pointerdown', handleDocumentDown);\r\n document.removeEventListener('pointerup', handleDocumentUp);\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n scaleDown\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n input = document.createElement('input');\r\n input.setAttribute('id', 'pdf-annotate-point-input');\r\n input.setAttribute('placeholder', 'Enter comment');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'absolute';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n savePoint();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13) {\r\n savePoint();\r\n }\r\n}\r\n\r\n/**\r\n * Save a new point annotation from input\r\n */\r\nfunction savePoint() {\r\n if (input.value.trim().length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let content = input.value.trim();\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n let annotation = Object.assign({\r\n type: 'point'\r\n }, scaleDown(svg, {\r\n x: clientX - rect.left,\r\n y: clientY - rect.top\r\n }));\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n PDFJSAnnotate.getStoreAdapter().addComment(\r\n documentId,\r\n annotation.uuid,\r\n content\r\n );\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input element\r\n */\r\nfunction closeInput() {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n}\r\n\r\n/**\r\n * Enable point annotation behavior\r\n */\r\nexport function enablePoint() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable point annotation behavior\r\n */\r\nexport function disablePoint() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgRect\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet overlay;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Get the current window selection as rects\r\n *\r\n * @return {Array} An Array of rects\r\n */\r\nfunction getSelectionRects() {\r\n try {\r\n let selection = window.getSelection();\r\n let range = selection.getRangeAt(0);\r\n let rects = range.getClientRects();\r\n\r\n if (rects.length > 0 &&\r\n rects[0].width > 0 &&\r\n rects[0].height > 0) {\r\n return rects;\r\n }\r\n }\r\n catch (e) {}\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let svg;\r\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n originY = e.clientY;\r\n originX = e.clientX;\r\n\r\n overlay = document.createElement('div');\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${originY - rect.top}px`;\r\n overlay.style.left = `${originX - rect.left}px`;\r\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = '3px';\r\n svg.parentNode.appendChild(overlay);\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n\r\n if (originX + (e.clientX - originX) < rect.right) {\r\n overlay.style.width = `${e.clientX - originX}px`;\r\n }\r\n\r\n if (originY + (e.clientY - originY) < rect.bottom) {\r\n overlay.style.height = `${e.clientY - originY}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let rects;\r\n if (_type !== 'area' && (rects = getSelectionRects())) {\r\n saveRect(_type, [...rects].map((r) => {\r\n return {\r\n top: r.top,\r\n left: r.left,\r\n width: r.width,\r\n height: r.height\r\n };\r\n }));\r\n }\r\n else if (_type === 'area' && overlay) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n saveRect(_type, [{\r\n top: parseInt(overlay.style.top, 10) + rect.top,\r\n left: parseInt(overlay.style.left, 10) + rect.left,\r\n width: parseInt(overlay.style.width, 10),\r\n height: parseInt(overlay.style.height, 10)\r\n }]);\r\n\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n enableUserSelect();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n let selection = window.getSelection();\r\n selection.removeAllRanges();\r\n if (overlay && overlay.parentNode) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Save a rect annotation\r\n *\r\n * @param {String} type The type of rect (area, highlight, strikeout)\r\n * @param {Array} rects The rects to use for annotation\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveRect(type, rects, color) {\r\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\r\n let annotation;\r\n\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let boundingRect = svg.getBoundingClientRect();\r\n\r\n if (!color) {\r\n if (type === 'highlight') {\r\n color = 'FFFF00';\r\n }\r\n else if (type === 'strikeout') {\r\n color = 'FF0000';\r\n }\r\n }\r\n\r\n // Initialize the annotation\r\n annotation = {\r\n type,\r\n color,\r\n rectangles: [...rects].map((r) => {\r\n let offset = 0;\r\n\r\n if (type === 'strikeout') {\r\n offset = r.height / 2;\r\n }\r\n\r\n return convertToSvgRect({\r\n y: (r.top + offset) - boundingRect.top,\r\n x: r.left - boundingRect.left,\r\n width: r.width,\r\n height: r.height\r\n }, svg);\r\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\r\n };\r\n\r\n // Short circuit if no rectangles exist\r\n if (annotation.rectangles.length === 0) {\r\n return;\r\n }\r\n\r\n // Special treatment for area as it only supports a single rect\r\n if (type === 'area') {\r\n let rect = annotation.rectangles[0];\r\n delete annotation.rectangles;\r\n annotation.x = rect.x;\r\n annotation.y = rect.y;\r\n annotation.width = rect.width;\r\n annotation.height = rect.height;\r\n }\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable rect behavior\r\n */\r\nexport function enableRect(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n/**\r\n * Disable rect behavior\r\n */\r\nexport function disableRect() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet _circleRadius = 10;\r\nlet _circleColor = '0000FF';\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} circleRadius The radius of the circle\r\n * @param {String} circleColor The color of the circle\r\n */\r\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\r\n _circleRadius = parseInt(circleRadius, 10);\r\n _circleColor = circleColor;\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg = findSVGAtPoint(e.clientX, e.clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let rect = svg.getBoundingClientRect();\r\n saveCircle(svg, _type, {\r\n x: e.clientX - rect.left,\r\n y: e.clientY - rect.top\r\n }, _circleRadius, _circleColor);\r\n}\r\n\r\n/**\r\n * Save a circle annotation\r\n *\r\n * @param {SVGElement} svg\r\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\r\n * @param {Object} pt The point to use for annotation\r\n * @param {float} radius\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveCircle(svg, type, pt, radius, color) {\r\n // Initialize the annotation\r\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\r\n let annotation = {\r\n type,\r\n color,\r\n cx: svg_pt[0],\r\n cy: svg_pt[1],\r\n r: radius\r\n };\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable circle behavior\r\n */\r\nexport function enableCircle(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable circle behavior\r\n */\r\nexport function disableCircle() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\nexport function addCircle(type, e) {\r\n let oldType = _type;\r\n _type = type;\r\n handleDocumentMouseup(e);\r\n _type = oldType;\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\nlet _textSize = localStorage.getItem(`text/size`) || 12;\r\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n if (!e.srcElement.classList.contains('annotationLayer')) {\r\n return;\r\n }\r\n input = document.createElement('textarea');\r\n input.setAttribute('id', 'pdf-annotate-text-input');\r\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'fixed';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n input.style.fontSize = `${_textSize}px`;\r\n input.style.zIndex = '41';\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n saveText();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13 && !e.shiftKey) {\r\n saveText();\r\n }\r\n}\r\n\r\n/**\r\n * Save a text annotation from input\r\n */\r\nfunction saveText() {\r\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\r\n if (value.length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let height = _textSize;\r\n let { documentId, pageNumber, viewport } = getMetadata(svg);\r\n let scale = 1 / viewport.scale;\r\n let rect = svg.getBoundingClientRect();\r\n let pt = convertToSvgPoint([\r\n clientX - rect.left,\r\n clientY - rect.top + height], svg, viewport);\r\n let annotation = {\r\n type: 'textbox',\r\n size: _textSize * scale,\r\n color: _textColor,\r\n content: value,\r\n x: pt[0],\r\n y: pt[1],\r\n rotation: -viewport.rotation\r\n };\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input\r\n */\r\nfunction closeInput() {\r\n if (input) {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n }\r\n}\r\n\r\n/**\r\n * Set the text attributes\r\n *\r\n * @param {Number} textSize The size of the text\r\n * @param {String} textColor The color of the text\r\n */\r\nexport function setText(textSize = 12, textColor = '000000') {\r\n _textSize = parseInt(textSize, 10);\r\n _textColor = textColor;\r\n}\r\n\r\n/**\r\n * Enable text behavior\r\n */\r\nexport function enableText() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable text behavior\r\n */\r\nexport function disableText() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","/**\r\n * Create a node that is only visible to screen readers\r\n *\r\n * @param {String} content The text content that should be read by screen reader\r\n * @param {String} [annotationId] The ID of the annotation assocaited\r\n * @return {Element} An Element that is only visible to screen readers\r\n */\r\nexport default function createScreenReaderOnly(content, annotationId) {\r\n let node = document.createElement('div');\r\n let text = document.createTextNode(content);\r\n node.appendChild(text);\r\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\r\n node.style.position = 'absolute';\r\n node.style.left = '-10000px';\r\n node.style.top = 'auto';\r\n node.style.width = '1px';\r\n node.style.height = '1px';\r\n node.style.overflow = 'hidden';\r\n return node;\r\n}\r\n","import config from '../config';\r\nimport {\r\n pointIntersectsRect,\r\n scaleUp,\r\n scaleDown\r\n} from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will only insert within an element amidst it's text content.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\r\n const OFFSET_ADJUST = 2;\r\n\r\n // If inserting before adjust `x` by looking for element a few px to the right\r\n // Otherwise adjust a few px to the left\r\n // This is to allow a little tolerance by searching within the box, instead\r\n // of getting a false negative by testing right on the border.\r\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\r\n\r\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\r\n if (!node) {\r\n return false;\r\n }\r\n\r\n // Now that node has been found inverse the adjustment for `x`.\r\n // This is done to accomodate tolerance by cutting off on the outside of the\r\n // text boundary, instead of missing a character by cutting off within.\r\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\r\n\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\r\n let temp = node.cloneNode(true);\r\n let head = temp.innerHTML.split('');\r\n let tail = [];\r\n\r\n // Insert temp off screen\r\n temp.style.position = 'absolute';\r\n temp.style.top = '-10000px';\r\n temp.style.left = '-10000px';\r\n document.body.appendChild(temp);\r\n\r\n while (head.length) {\r\n // Don't insert within HTML tags\r\n if (head[head.length - 1] === '>') {\r\n while (head.length) {\r\n tail.unshift(head.pop());\r\n if (tail[0] === '<') {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Check if width of temp based on current head value satisfies x\r\n temp.innerHTML = head.join('');\r\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\r\n if (left + width <= x) {\r\n break;\r\n }\r\n tail.unshift(head.pop());\r\n }\r\n\r\n // Update original node with new markup, including element to be inserted\r\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\r\n temp.parentNode.removeChild(temp);\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Get a text layer element at a given point on a page\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page to limit elements to\r\n * @return {Element} First text layer element found at the point\r\n */\r\nfunction textLayerElementFromPoint(x, y, pageNumber) {\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\r\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\r\n })[0];\r\n}\r\n","import config from '../config';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will try to insert between elements if possible.\r\n * It will however use `insertElementWithinElement` if it is more accurate.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\r\n // Try and use most accurate method of inserting within an element\r\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\r\n return true;\r\n }\r\n\r\n // Fall back to inserting between elements\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\r\n\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n\r\n // Find the best node to insert before\r\n for (let i = 0, l = nodes.length; i < l; i++) {\r\n let n = nodes[i];\r\n let r = n.getBoundingClientRect();\r\n if (y <= r.top) {\r\n n.parentNode.insertBefore(el, n);\r\n return true;\r\n }\r\n }\r\n\r\n // If all else fails try to append to the bottom\r\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\r\n if (textLayer) {\r\n let textRect = textLayer.getBoundingClientRect();\r\n if (pointIntersectsRect(x, y, textRect)) {\r\n textLayer.appendChild(el);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n","/**\r\n * Insert a comment into the DOM to be available by screen reader\r\n *\r\n * @param {Object} comment The comment to be inserted\r\n */\r\nexport default function insertScreenReaderComment(comment) {\r\n if (!comment) {\r\n return;\r\n }\r\n\r\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\r\n if (list) {\r\n let item = document.createElement('li');\r\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\r\n item.appendChild(document.createTextNode(`${comment.content}`));\r\n list.appendChild(item);\r\n }\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\n\r\n/**\r\n * Insert the comments into the DOM to be available by screen reader\r\n *\r\n * Example output:\r\n *
\r\n *
Begin highlight 1
\r\n *
    \r\n *
  1. Foo
  2. \r\n *
  3. Bar
  4. \r\n *
  5. Baz
  6. \r\n *
  7. Qux
  8. \r\n *
\r\n *
\r\n *
Some highlighted text goes here...
\r\n *
End highlight 1
\r\n *\r\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of the annotation\r\n * @param {Array} [comments] Optionally preloaded comments to be rendered\r\n * @return {Promise} Promise that once has comments, render them for screen reader\r\n */\r\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\r\n let promise;\r\n\r\n if (Array.isArray(comments)) {\r\n promise = Promise.resolve(comments);\r\n }\r\n else {\r\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\r\n }\r\n\r\n return promise.then((comments) => {\r\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\r\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\r\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n if (node) {\r\n let list = document.createElement('ol');\r\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n list.setAttribute('aria-label', 'Comments');\r\n node.appendChild(list);\r\n comments.forEach(insertScreenReaderComment);\r\n }\r\n });\r\n}\r\n","import createScreenReaderOnly from './createScreenReaderOnly';\r\nimport insertElementWithinChildren from './insertElementWithinChildren';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\n\r\n// Annotation types that support comments\r\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\r\n\r\n/**\r\n * Insert a hint into the DOM for screen readers for a specific annotation.\r\n *\r\n * @param {Object} annotation The annotation to insert a hint for\r\n * @param {Number} num The number of the annotation out of all annotations of the same type\r\n */\r\nexport default function insertScreenReaderHint(annotation, num = 0) {\r\n switch (annotation.type) {\r\n case 'highlight':\r\n case 'strikeout':\r\n let rects = annotation.rectangles;\r\n let first = rects[0];\r\n let last = rects[rects.length - 1];\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\r\n first.x, first.y, annotation.page, true\r\n );\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\r\n last.x + last.width, last.y, annotation.page, false\r\n );\r\n break;\r\n\r\n case 'textbox':\r\n case 'point':\r\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\r\n annotation.x, annotation.y, annotation.page\r\n );\r\n break;\r\n\r\n case 'drawing':\r\n case 'area':\r\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\r\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x, y, annotation.page\r\n );\r\n break;\r\n\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\r\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x2, y2, annotation.page\r\n );\r\n break;\r\n }\r\n\r\n // Include comments in screen reader hint\r\n if (COMMENT_TYPES.includes(annotation.type)) {\r\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\r\n }\r\n}\r\n","import renderScreenReaderHints from './renderScreenReaderHints';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\nimport { addEventListener } from '../UI/event';\r\nimport PDFJSAnnotate from '../PDFJSAnnotate';\r\n\r\n/**\r\n * Initialize the event handlers for keeping screen reader hints synced with data\r\n */\r\nexport default function initEventHandlers() {\r\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\r\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\r\n });\r\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\r\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\r\n });\r\n addEventListener('annotation:delete', removeAnnotation);\r\n addEventListener('comment:add', insertComment);\r\n addEventListener('comment:delete', removeComment);\r\n}\r\n\r\n/**\r\n * Reorder the annotation numbers by annotation type\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {Number} pageNumber The page number of the annotations\r\n * @param {Strig} type The annotation type\r\n */\r\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\r\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\r\n .then((annotations) => {\r\n return annotations.annotations.filter((a) => {\r\n return a.type === type;\r\n });\r\n })\r\n .then((annotations) => {\r\n annotations.forEach((a) => {\r\n removeAnnotation(documentId, a.uuid);\r\n });\r\n\r\n return annotations;\r\n })\r\n .then(renderScreenReaderHints);\r\n}\r\n\r\n/**\r\n * Remove the screen reader hint for an annotation\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The Id of the annotation\r\n */\r\nfunction removeAnnotation(documentId, annotationId) {\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\r\n}\r\n\r\n/**\r\n * Insert a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of tha assocated annotation\r\n * @param {Object} comment The comment to insert a hint for\r\n */\r\nfunction insertComment(documentId, annotationId, comment) {\r\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n let promise;\r\n\r\n if (!list) {\r\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\r\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n return true;\r\n });\r\n }\r\n else {\r\n promise = Promise.resolve(true);\r\n }\r\n\r\n promise.then(() => {\r\n insertScreenReaderComment(comment);\r\n });\r\n}\r\n\r\n/**\r\n * Remove a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} commentId The ID of the comment\r\n */\r\nfunction removeComment(documentId, commentId) {\r\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\r\n}\r\n\r\n/**\r\n * Remove an element from the DOM by it's ID if it exists\r\n *\r\n * @param {String} elementId The ID of the element to be removed\r\n */\r\nfunction removeElementById(elementId) {\r\n let el = document.getElementById(elementId);\r\n if (el) {\r\n el.parentNode.removeChild(el);\r\n }\r\n}\r\n","import insertScreenReaderHint from './insertScreenReaderHint';\r\nimport initEventHandlers from './initEventHandlers';\r\n\r\n// TODO This is not the right place for this to live\r\ninitEventHandlers();\r\n\r\n/**\r\n * Insert hints into the DOM for screen readers.\r\n *\r\n * @param {Array} annotations The annotations that hints are inserted for\r\n */\r\nexport default function renderScreenReaderHints(annotations) {\r\n annotations = Array.isArray(annotations) ? annotations : [];\r\n\r\n // Insert hints for each type\r\n Object.keys(SORT_TYPES).forEach((type) => {\r\n let sortBy = SORT_TYPES[type];\r\n annotations\r\n .filter((a) => a.type === type)\r\n .sort(sortBy)\r\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\r\n });\r\n}\r\n\r\n// Sort annotations first by y, then by x.\r\n// This allows hints to be injected in the order they appear,\r\n// which makes numbering them easier.\r\nfunction sortByPoint(a, b) {\r\n if (a.y < b.y) {\r\n return a.x - b.x;\r\n }\r\n else {\r\n return 1;\r\n }\r\n}\r\n\r\n// Sort annotation by it's first rectangle\r\nfunction sortByRectPoint(a, b) {\r\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\r\n}\r\n\r\n// Sort annotation by it's first line\r\nfunction sortByLinePoint(a, b) {\r\n let lineA = a.lines[0];\r\n let lineB = b.lines[0];\r\n return sortByPoint(\r\n {x: lineA[0], y: lineA[1]},\r\n {x: lineB[0], y: lineB[1]}\r\n );\r\n}\r\n\r\n// Arrange supported types and associated sort methods\r\nconst SORT_TYPES = {\r\n 'highlight': sortByRectPoint,\r\n 'strikeout': sortByRectPoint,\r\n 'drawing': sortByLinePoint,\r\n 'textbox': sortByPoint,\r\n 'point': sortByPoint,\r\n 'area': sortByPoint\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\r\n\r\n// Template for creating a new page\r\nconst PAGE_TEMPLATE = `\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n`;\r\n\r\n/**\r\n * Create a new page to be appended to the DOM.\r\n *\r\n * @param {Number} pageNumber The page number that is being created\r\n * @return {HTMLElement}\r\n */\r\nexport function createPage(pageNumber) {\r\n let temp = document.createElement('div');\r\n temp.innerHTML = PAGE_TEMPLATE;\r\n\r\n let page = temp.children[0];\r\n let canvas = page.querySelector('canvas');\r\n\r\n page.setAttribute('id', `pageContainer${pageNumber}`);\r\n page.setAttribute('data-page-number', pageNumber);\r\n\r\n canvas.mozOpaque = true;\r\n canvas.setAttribute('id', `page${pageNumber}`);\r\n\r\n return page;\r\n}\r\n\r\n/**\r\n * Render a page that has already been created.\r\n *\r\n * @param {Number} pageNumber The page number to be rendered\r\n * @param {Object} renderOptions The options for rendering\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: [pdfPage, annotations]\r\n * - rejected: Error\r\n */\r\nexport function renderPage(pageNumber, renderOptions) {\r\n let {\r\n documentId,\r\n pdfDocument,\r\n scale,\r\n rotate\r\n } = renderOptions;\r\n\r\n const eventBus = new pdfjsViewer.EventBus();\r\n\r\n // Load the page and annotations\r\n return Promise.all([\r\n pdfDocument.getPage(pageNumber),\r\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\r\n ]).then(([pdfPage, annotations]) => {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let canvasContext = canvas.getContext('2d', {alpha: false});\r\n let totalRotation = (rotate + pdfPage.rotate) % 360;\r\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\r\n let transform = scalePage(pageNumber, viewport, canvasContext);\r\n\r\n // Render the page\r\n return Promise.all([\r\n pdfPage.render({ canvasContext, viewport, transform }).promise,\r\n PDFJSAnnotate.render(svg, viewport, annotations)\r\n ]).then(() => {\r\n // Text content is needed for a11y, but is also necessary for creating\r\n // highlight and strikeout annotations which require selecting text.\r\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\r\n return new Promise((resolve, reject) => {\r\n // Render text layer for a11y of text content\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\r\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\r\n textLayer,\r\n pageNumber - 1,\r\n viewport,\r\n false,\r\n eventBus\r\n );\r\n textLayerBuilder.setTextContent(textContent);\r\n textLayerBuilder.render();\r\n\r\n // Enable a11y for annotations\r\n // Timeout is needed to wait for `textLayerBuilder.render`\r\n setTimeout(() => {\r\n try {\r\n renderScreenReaderHints(annotations.annotations);\r\n resolve();\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n });\r\n });\r\n });\r\n }).then(() => {\r\n // Indicate that the page was loaded\r\n page.setAttribute('data-loaded', 'true');\r\n\r\n return [pdfPage, annotations];\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Scale the elements of a page.\r\n *\r\n * @param {Number} pageNumber The page number to be scaled\r\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\r\n * @param {Object} context The canvas context that the PDF page is rendered to\r\n * @return {Array} The transform data for rendering the PDF page\r\n */\r\nfunction scalePage(pageNumber, viewport, context) {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let wrapper = page.querySelector('.canvasWrapper');\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let outputScale = getOutputScale(context);\r\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\r\n let sfx = approximateFraction(outputScale.sx);\r\n let sfy = approximateFraction(outputScale.sy);\r\n\r\n // Adjust width/height for scale\r\n page.style.visibility = '';\r\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\r\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\r\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\r\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\r\n svg.setAttribute('width', viewport.width);\r\n svg.setAttribute('height', viewport.height);\r\n svg.style.width = `${viewport.width}px`;\r\n svg.style.height = `${viewport.height}px`;\r\n page.style.width = `${viewport.width}px`;\r\n page.style.height = `${viewport.height}px`;\r\n wrapper.style.width = `${viewport.width}px`;\r\n wrapper.style.height = `${viewport.height}px`;\r\n textLayer.style.width = `${viewport.width}px`;\r\n textLayer.style.height = `${viewport.height}px`;\r\n\r\n return transform;\r\n}\r\n\r\n/**\r\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\r\n *\r\n * @param {Number} x Positive float number\r\n * @return {Array} Estimated fraction: the first array item is a numerator,\r\n * the second one is a denominator.\r\n */\r\nfunction approximateFraction(x) {\r\n // Fast path for int numbers or their inversions.\r\n if (Math.floor(x) === x) {\r\n return [x, 1];\r\n }\r\n\r\n const xinv = 1 / x;\r\n const limit = 8;\r\n if (xinv > limit) {\r\n return [1, limit];\r\n }\r\n else if (Math.floor(xinv) === xinv) {\r\n return [1, xinv];\r\n }\r\n\r\n const x_ = x > 1 ? xinv : x;\r\n\r\n // a/b and c/d are neighbours in Farey sequence.\r\n let a = 0; let b = 1; let c = 1; let d = 1;\r\n\r\n // Limit search to order 8.\r\n while (true) {\r\n // Generating next term in sequence (order of q).\r\n let p = a + c; let q = b + d;\r\n if (q > limit) {\r\n break;\r\n }\r\n if (x_ <= p / q) {\r\n c = p; d = q;\r\n }\r\n else {\r\n a = p; b = q;\r\n }\r\n }\r\n\r\n // Select closest of neighbours to x.\r\n if (x_ - a / b < c / d - x_) {\r\n return x_ === x ? [a, b] : [b, a];\r\n }\r\n else {\r\n return x_ === x ? [c, d] : [d, c];\r\n }\r\n}\r\n\r\nfunction getOutputScale(ctx) {\r\n let devicePixelRatio = window.devicePixelRatio || 1;\r\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\r\n ctx.mozBackingStorePixelRatio ||\r\n ctx.msBackingStorePixelRatio ||\r\n ctx.oBackingStorePixelRatio ||\r\n ctx.backingStorePixelRatio || 1;\r\n let pixelRatio = devicePixelRatio / backingStoreRatio;\r\n return {\r\n sx: pixelRatio,\r\n sy: pixelRatio,\r\n scaled: pixelRatio !== 1\r\n };\r\n}\r\n\r\nfunction roundToDivide(x, div) {\r\n let r = x % div;\r\n return r === 0 ? x : Math.round(x - r + div);\r\n}\r\n","import { addEventListener, removeEventListener, fireEvent } from './event';\r\nimport { disableEdit, enableEdit } from './edit';\r\nimport { disablePen, enablePen, setPen } from './pen';\r\nimport { disableArrow, enableArrow, setArrow } from './arrow';\r\nimport { disableEraser, enableEraser } from './eraser';\r\nimport { disablePoint, enablePoint } from './point';\r\nimport { disableRect, enableRect } from './rect';\r\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\r\nimport { disableText, enableText, setText } from './text';\r\nimport { createPage, renderPage } from './page';\r\n\r\nexport default {\r\n addEventListener,\r\n removeEventListener,\r\n fireEvent,\r\n\r\n disableEdit,\r\n enableEdit,\r\n\r\n disablePen,\r\n enablePen,\r\n setPen,\r\n\r\n disablePoint,\r\n enablePoint,\r\n\r\n disableRect,\r\n enableRect,\r\n\r\n disableCircle,\r\n enableCircle,\r\n setCircle,\r\n addCircle,\r\n\r\n disableArrow,\r\n enableArrow,\r\n setArrow,\r\n\r\n disableEraser,\r\n enableEraser,\r\n\r\n disableText,\r\n enableText,\r\n setText,\r\n\r\n createPage,\r\n renderPage\r\n};\r\n","import StoreAdapter from './adapter/StoreAdapter';\r\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\r\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\r\nimport render from './render';\r\nimport UI from './UI';\r\nimport config from './config';\r\nimport uuid from './utils/uuid';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint\r\n} from './UI/utils';\r\n\r\nexport default {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint,\r\n\r\n /**\r\n * Abstract class that needs to be defined so PDFJSAnnotate\r\n * knows how to communicate with your server.\r\n */\r\n StoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage.\r\n */\r\n LocalStoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\r\n * to a specific user\r\n */\r\n LocalUserStoreAdapter,\r\n\r\n /**\r\n * Abstract instance of StoreAdapter\r\n */\r\n __storeAdapter: new StoreAdapter(),\r\n\r\n /**\r\n * Getter for the underlying StoreAdapter property\r\n *\r\n * @return {StoreAdapter}\r\n */\r\n getStoreAdapter() {\r\n return this.__storeAdapter;\r\n },\r\n\r\n /**\r\n * Setter for the underlying StoreAdapter property\r\n *\r\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\r\n */\r\n setStoreAdapter(adapter) {\r\n // TODO this throws an error when bundled\r\n // if (!(adapter instanceof StoreAdapter)) {\r\n // throw new Error('adapter must be an instance of StoreAdapter');\r\n // }\r\n\r\n this.__storeAdapter = adapter;\r\n },\r\n\r\n /**\r\n * UI is a helper for instrumenting UI interactions for creating,\r\n * editing, and deleting annotations in the browser.\r\n */\r\n UI,\r\n\r\n /**\r\n * Render the annotations for a page in the PDF Document\r\n *\r\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\r\n * @param {PageViewport} viewport The PDFPage.getViewport data\r\n * @param {Object} data The StoreAdapter.getAnnotations data\r\n * @return {Promise}\r\n */\r\n render,\r\n\r\n /**\r\n * Convenience method for getting annotation data\r\n *\r\n * @alias StoreAdapter.getAnnotations\r\n * @param {String} documentId The ID of the document\r\n * @param {String} pageNumber The page number\r\n * @return {Promise}\r\n */\r\n getAnnotations(documentId, pageNumber) {\r\n return this.getStoreAdapter().getAnnotations(...arguments);\r\n },\r\n\r\n config,\r\n\r\n uuid\r\n};\r\n","import { appendChild, transformChild } from './appendChild';\r\n\r\n/**\r\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\r\n *\r\n * @param {SVGElement} svg The SVG element to render the annotations to\r\n * @param {Object} viewport The page viewport data\r\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: SVGElement\r\n * - rejected: Error\r\n */\r\nexport default function render(svg, viewport, data) {\r\n return new Promise((resolve, reject) => {\r\n // Reset the content of the SVG\r\n svg.setAttribute('data-pdf-annotate-container', true);\r\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\r\n svg.removeAttribute('data-pdf-annotate-document');\r\n svg.removeAttribute('data-pdf-annotate-page');\r\n\r\n // If there's no data nothing can be done\r\n if (!data) {\r\n svg.innerHTML = '';\r\n return resolve(svg);\r\n }\r\n\r\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\r\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\r\n\r\n // Make sure annotations is an array\r\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\r\n return resolve(svg);\r\n }\r\n\r\n // Append or transform annotation to svg\r\n data.annotations.forEach((a) => {\r\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\r\n if (node) {\r\n transformChild(svg, node, viewport);\r\n }\r\n else {\r\n appendChild(svg, a, viewport);\r\n }\r\n });\r\n\r\n resolve(svg);\r\n });\r\n}\r\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\r\n\r\nexport default PDFJSAnnotate;\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pdf-annotate.min.js b/dist/pdf-annotate.min.js new file mode 100644 index 00000000..8dd179b4 --- /dev/null +++ b/dist/pdf-annotate.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.PDFAnnotate=e():t.PDFAnnotate=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=1)}([function(t,e,n){"use strict";var r,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};r=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,t.exports.once=function(t,e){return new Promise((function(n,r){function o(n){t.removeListener(e,i),r(n)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),n([].slice.call(arguments))}h(t,e,i,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&h(t,"error",e,n)}(t,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function l(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function s(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function d(t,e,n,r){var o,i,a,u;if(l(n),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),i=t._events),a=i[e]),void 0===a)a=i[e]=n,++t._eventsCount;else if("function"==typeof a?a=i[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(o=s(t))>0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,u=c,console&&console.warn&&console.warn(u)}return t}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function y(t,e,n){var r=t._events;if(void 0===r)return[];var o=r[e];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)i(c,this,e);else{var l=c.length,s=v(c,l);for(n=0;n=0;i--)if(n[i]===e||n[i].listener===e){a=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},u.prototype.listeners=function(t){return y(this,t,!0)},u.prototype.rawListeners=function(t){return y(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):m.call(t,e)},u.prototype.listenerCount=m,u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]}},function(t,e,n){"use strict";function r(t){throw new Error(t+" is not implemented")}n.r(e);var o=n(0),i=n.n(o),a=/[A-Z]/g,u=["viewBox"];function c(t,e){Object.keys(e).forEach((function(n){t.setAttribute(function(t){return-1===u.indexOf(t)&&(t=t.replace(a,(function(t){return"-"+t.toLowerCase()}))),t}(n),e[n])}))}var l=/^([a-f0-9]{6}|[a-f0-9]{3})$/i;function s(t){return l.test(t)&&(t="#".concat(t)),t}var d=25;function f(t){var e=document.createElementNS("http://www.w3.org/2000/svg","rect");return c(e,{x:t.x,y:t.y,width:t.width,height:t.height}),e}function p(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0){e.push("M".concat(t.lines[0][0]," ").concat(t.lines[0][1]));for(var r=1,o=t.lines.length;r=n.top&&e<=n.bottom&&t>=n.left&&t<=n.right}function F(t){var e=t.getBoundingClientRect(),n=e.width,r=e.height,o=0,i=0;if(["line","path"].indexOf(t.tagName.toLowerCase())>-1&&t.getBBox){var a=t.getBBox();o=(e.width-a.width)/2,i=(e.height-a.height)/2,n=a.width,r=a.height}var u=function(t){var e=t;for(;(e=e.parentNode)&&e!==document&&"SVG"!==e.nodeName.toUpperCase(););var n=e.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}(t),c=u.offsetLeft,l=u.offsetTop;return{top:e.top-l+i,left:e.left-c+o,bottom:e.bottom-l-i,right:e.right-c-o,width:n,height:r}}function X(t,e){var n={},r=W(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]*r.scale})),n}function Y(t,e,n){var r=[1,0,0,1,0,0];r=g(r=b(r,(n=n||W(e).viewport).scale,n.scale),n.rotation);var o,i,a,u=O(n);return r=h(r,u.x,u.y),o=t,a=(i=r)[0]*i[3]-i[1]*i[2],[(o[0]*i[3]-o[1]*i[2]+i[2]*i[5]-i[4]*i[3])/a,(-o[0]*i[1]+o[1]*i[0]+i[4]*i[1]-i[5]*i[0])/a]}function U(t,e,n){var r=[1,0,0,1,0,0];r=g(r=b(r,(n=n||W(e).viewport).scale,n.scale),n.rotation);var o,i,a=O(n);return r=h(r,a.x,a.y),i=r,[(o=t)[0]*i[0]+o[1]*i[2]+i[4],o[0]*i[1]+o[1]*i[3]+i[5]]}function Q(t,e){var n={},r=W(t).viewport;return Object.keys(e).forEach((function(t){n[t]=e[t]/r.scale})),n}function H(){M.parentNode||document.head.appendChild(M)}function D(){M.parentNode&&M.parentNode.removeChild(M)}function W(t){return{documentId:t.getAttribute("data-pdf-annotate-document"),pageNumber:parseInt(t.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(t.getAttribute("data-pdf-annotate-viewport"))}}M.innerHTML="\nbody {\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n",M.setAttribute("data-pdf-annotate-user-select","true");var $,J=new i.a;function V(){J.emit.apply(J,arguments)}function G(){J.on.apply(J,arguments)}function K(){J.removeListener.apply(J,arguments)}function Z(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function tt(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};Z(this,t),Object.keys(n).forEach((function(t){"function"==typeof n[t]&&"function"==typeof e[t]&&(e[t]=n[t])}))}var e,n,o;return e=t,n=[{key:"__getAnnotations",value:function(t,e){r("getAnnotations")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(t){this.__getAnnotations=function(e,n){return t.apply(void 0,arguments).then((function(t){return t.annotations&&t.annotations.forEach((function(t){t.documentId=e})),t}))}}},{key:"getAnnotation",value:function(t,e){r("getAnnotation")}},{key:"__addAnnotation",value:function(t,e,n){r("addAnnotation")}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(t){this.__addAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("annotation:add",e,n,t),t}))}}},{key:"__editAnnotation",value:function(t,e,n){r("editAnnotation")}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(t){this.__editAnnotation=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("annotation:edit",e,n,t),t}))}}},{key:"__deleteAnnotation",value:function(t,e){r("deleteAnnotation")}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(t){this.__deleteAnnotation=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&V("annotation:delete",e,n),t}))}}},{key:"getComments",value:function(t,e){r("getComments")}},{key:"__addComment",value:function(t,e,n){r("addComment")}},{key:"addComment",get:function(){return this.__addComment},set:function(t){this.__addComment=function(e,n,r){return t.apply(void 0,arguments).then((function(t){return V("comment:add",e,n,t),t}))}}},{key:"__deleteComment",value:function(t,e){r("deleteComment")}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(t){this.__deleteComment=function(e,n){return t.apply(void 0,arguments).then((function(t){return t&&V("comment:delete",e,n),t}))}}}],n&&tt(e.prototype,n),o&&tt(e,o),Object.defineProperty(e,"prototype",{writable:!1}),t}(),nt=/[xy]/g;function rt(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)}function ot(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(nt,rt)}function it(t){return it="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},it(t)}function at(t,e){for(var n=0;n-1){var i=ft(t);i.splice(o,1),pt(t,i)}n(!0)}))},t.getComments=function(t,e){return new Promise((function(n,r){n(ft(t).filter((function(t){return"Comment"===t.class&&t.annotation===e})))}))},t.addComment=function(t,e,n){return new Promise((function(r,o){var i={class:"Comment",uuid:ot(),annotation:e,content:n},a=ft(t);a.push(i),pt(t,a),r(i)}))},t.deleteComment=function(t,e){return new Promise((function(n,r){var o=ft(t).filter((function(t){return t.uuid===e}))[0]||{};if(!o)return r("Could not find annotation");for(var i=-1,a=ft(t),u=0,c=a.length;u-1&&(a.splice(i,1),pt(t,a)),n(!0)}))},t}return e=i,n&&at(e.prototype,n),r&&at(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(et);function ft(t){return JSON.parse(localStorage.getItem("".concat(t,"/annotations")))||[]}function pt(t,e){localStorage.setItem("".concat(t,"/annotations"),JSON.stringify(e))}function yt(t,e){for(var n=-1,r=ft(t),o=0,i=r.length;ot.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&void 0!==arguments[0]?arguments[0]:"user",n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return gt(this,i),(t=o.call(this,{getAnnotations:function(t,e){return new Promise((function(n,r){var o=Ct(t).filter((function(t){return t.page===e&&"Annotation"===t.class}));n({documentId:t,pageNumber:e,annotations:o})}))}}))._userId=e,t._globalEdit=n,t.getAnnotation=function(e,n){return Promise.resolve(Lt(e,t._userId)[_t(e,t._userId,n)])},t.addAnnotation=function(e,n,r){return new Promise((function(o,i){r.class="Annotation",r.uuid=ot(),r.page=n,r.userId=t._userId;var a=Lt(e,t._userId);a.push(r),It(e,t._userId,a),o(r)}))},t.editAnnotation=function(e,n,r){return new Promise((function(o,i){!t._globalEdit&&r.userId&&r.userId!==t._userId&&i("Non-matching userId");var a=Lt(e,r.userId);a[_t(e,r.userId,n)]=r,It(e,r.userId,a),o(r)}))},t.deleteAnnotation=function(e,n){return new Promise((function(r,o){var i=Ct(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");var a=_t(e,i.userId,n);if(a>-1){var u=Lt(e,i.userId);u.splice(a,1),It(e,i.userId,u)}r(!0)}))},t.getComments=function(e,n){return new Promise((function(r,o){r(Lt(e,t._userId).filter((function(t){return"Comment"===t.class&&t.annotation===n})))}))},t.addComment=function(e,n,r){return new Promise((function(o,i){var a={class:"Comment",uuid:ot(),annotation:n,content:r,userId:t._userId},u=Lt(e,t._userId);u.push(a),It(e,t._userId,u),o(a)}))},t.deleteComment=function(e,n){return new Promise((function(r,o){var i=Ct(e).filter((function(t){return t.uuid===n}))[0]||{};if(!i)return o("Could not find annotation");if(!t._globalEdit&&i.userId&&i.userId!==t._userId)return o("Non-matching userId");for(var a=-1,u=Lt(e,i.userId),c=0,l=u.length;c-1&&(u.splice(a,1),It(e,i.userId,u)),r(!0)}))},t}return e=i,(n=[{key:"userId",get:function(){return this._userId}}])&&bt(e.prototype,n),r&&bt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),i}(et);function Ct(t){for(var e=[],n=new RegExp("".concat(t,"/(.*)/annotations")),r=0;r-1&&e.push.apply(e,vt(JSON.parse(localStorage.getItem(localStorage.key(r)))));return e}function Lt(t,e){return JSON.parse(localStorage.getItem("".concat(t,"/").concat(e,"/annotations")))||[]}function It(t,e,n){localStorage.setItem("".concat(t,"/").concat(e,"/annotations"),JSON.stringify(n))}function _t(t,e,n){for(var r=-1,o=Lt(t,e),i=0,a=o.length;it.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&n+jt.offsetHeight0&&r+jt.offsetWidth-1&&(a="cx",u="cy"),"point"!==r){if(["area","highlight","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var c=Y([Mt,Tt],o),l=Y([jt.offsetLeft,jt.offsetTop],o),s={x:l[0]-c[0],y:l[1]-c[1]};"textbox"===r&&(n=[n[0].firstChild]),Ot(n).forEach((function(e,n){var r=parseInt(e.getAttribute(a),10),o=parseInt(e.getAttribute(u),10);0!==s.y&&(o+=s.y,e.setAttribute(u,o),t.rectangles&&n1&&(n=B(t,e))){var r=W(n),o=r.documentId,i=r.pageNumber;In.getStoreAdapter().addAnnotation(o,i,{type:"drawing",width:Wt,color:$t,lines:Kt}).then((function(t){Jt&&n.removeChild(Jt),j(n,t)}))}}(t.clientX,t.clientY)}function ee(t){B(t.clientX,t.clientY)&&Gt&&function(t,e){var n=B(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=Y([t-r.left,e-r.top],n);if(o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),Kt.push(o),Kt.length<=1)return;Jt&&n.removeChild(Jt);Jt=j(n,{type:"drawing",color:$t,width:Wt,lines:Kt})}(t.clientX,t.clientY)}function ne(t){27===t.keyCode&&(Kt=null,Jt.parentNode.removeChild(Jt),document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",te))}var re,oe,ie,ae,ue,ce,le=!1;function se(t){var e=q(t.clientX,t.clientY);if(null!==e){var n=e.getAttribute("data-pdf-annotate-type");if("circle"===n||"fillcircle"===n||"emptycircle"===n){var r=T(e),o=W(r).documentId,i=e.getAttribute("data-pdf-annotate-id");In.getStoreAdapter().getAnnotation(o,i).then((function(t){if(t){ie=null,ae=[];var e=U([t.cx,t.cy],r),n=r.getBoundingClientRect();ce=e[0]+n.left,ue=e[1]+n.top,document.addEventListener("mousemove",fe),document.addEventListener("mouseup",de)}}))}}}function de(t){var e;if(ae.length>1&&(e=B(t.clientX,t.clientY))){var n=W(e),r=n.documentId,o=n.pageNumber;In.getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:re,color:oe,lines:ae}).then((function(t){ie&&e.removeChild(ie),j(e,t)}))}document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",de)}function fe(t){!function(t,e){var n=B(t,e);if(!n)return;var r=n.getBoundingClientRect(),o=Y([t-r.left,e-r.top],n);if(ae.length<2)return void ae.push(o);ae[1]=o;ie&&n.removeChild(ie);ie=j(n,{type:"arrow",color:oe,width:re,lines:ae})}(0===ae.length?ce:t.clientX,0===ae.length?ue:t.clientY)}function pe(t){27===t.keyCode&&(ae=null,ie.parentNode.removeChild(ie),document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",de))}function ye(t){return function(t){if(Array.isArray(t))return me(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return me(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return me(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function me(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n=1||r>=1)for(var o=Math.round(Math.max(n,r)),i=Math.min(n,r)/o,a=n0){var t=parseInt(Ae.style.left,10),e=parseInt(Ae.style.top,10),n=Ae.value.trim(),r=B(t,e);if(!r)return;var o=r.getBoundingClientRect(),i=W(r),a=i.documentId,u=i.pageNumber,c=Object.assign({type:"point"},Q(r,{x:t-o.left,y:e-o.top}));In.getStoreAdapter().addAnnotation(a,u,c).then((function(t){In.getStoreAdapter().addComment(a,t.uuid,n),j(r,t)}))}_e()}function _e(){Ae.removeEventListener("blur",Ce),Ae.removeEventListener("keyup",Le),document.body.removeChild(Ae),Ae=null}function ke(t){return function(t){if(Array.isArray(t))return Oe(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return Oe(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Oe(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Oe(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n0&&t[0].width>0&&t[0].height>0)return t}catch(t){}return null}()))Fe(Ne,ke(e).map((function(t){return{top:t.top,left:t.left,width:t.width,height:t.height}})));else if("area"===Ne&&je){var n=je.parentNode.querySelector(kt.annotationSvgQuery()).getBoundingClientRect();Fe(Ne,[{top:parseInt(je.style.top,10)+n.top,left:parseInt(je.style.left,10)+n.left,width:parseInt(je.style.width,10),height:parseInt(je.style.height,10)}]),je.parentNode.removeChild(je),je=null,document.removeEventListener("mousemove",Be),D()}}function ze(t){27===t.keyCode&&(window.getSelection().removeAllRanges(),je&&je.parentNode&&(je.parentNode.removeChild(je),je=null,document.removeEventListener("mousemove",Be)))}function Fe(t,e,n){var r,o=B(e[0].left,e[0].top);if(o){var i=o.getBoundingClientRect();if(n||("highlight"===t?n="FFFF00":"strikeout"===t&&(n="FF0000")),r={type:t,color:n,rectangles:ke(e).map((function(e){var n=0;return"strikeout"===t&&(n=e.height/2),function(t,e,n){var r=[t.x,t.y],o=[t.x+t.width,t.y+t.height];return r=Y(r,e,n),o=Y(o,e,n),{x:Math.min(r[0],o[0]),y:Math.min(r[1],o[1]),width:Math.abs(o[0]-r[0]),height:Math.abs(o[1]-r[1])}}({y:e.top+n-i.top,x:e.left-i.left,width:e.width,height:e.height},o)})).filter((function(t){return t.width>0&&t.height>0&&t.x>-1&&t.y>-1}))},0!==r.rectangles.length){if("area"===t){var a=r.rectangles[0];delete r.rectangles,r.x=a.x,r.y=a.y,r.width=a.width,r.height=a.height}var u=W(o),c=u.documentId,l=u.pageNumber;In.getStoreAdapter().addAnnotation(c,l,r).then((function(t){j(o,t)}))}}}var Xe,Ye=!1,Ue=10,Qe="0000FF";function He(t){var e=B(t.clientX,t.clientY);if(e){var n=e.getBoundingClientRect();!function(t,e,n,r,o){var i=Y([n.x,n.y],t),a={type:e,color:o,cx:i[0],cy:i[1],r:r},u=W(t),c=u.documentId,l=u.pageNumber;In.getStoreAdapter().addAnnotation(c,l,a).then((function(e){j(t,e)}))}(e,Xe,{x:t.clientX-n.left,y:t.clientY-n.top},Ue,Qe)}}var De,We=!1,$e=localStorage.getItem("text/size")||12,Je=localStorage.getItem("text/color")||"#000000";function Ve(t){!De&&B(t.clientX,t.clientY)&&t.srcElement.classList.contains("annotationLayer")&&((De=document.createElement("textarea")).setAttribute("id","pdf-annotate-text-input"),De.setAttribute("placeholder","Enter text... SHIFT + ENTER for new line"),De.style.border="3px solid ".concat(R),De.style.borderRadius="3px",De.style.position="fixed",De.style.top="".concat(t.clientY,"px"),De.style.left="".concat(t.clientX,"px"),De.style.fontSize="".concat($e,"px"),De.style.zIndex="41",De.addEventListener("blur",Ge),De.addEventListener("keyup",Ke),document.body.appendChild(De),De.focus())}function Ge(){Ze()}function Ke(t){27===t.keyCode?tn():13!==t.keyCode||t.shiftKey||Ze()}function Ze(){var t=De.value?De.value.replace(/ +$/,""):"";if(t.length>0){var e=parseInt(De.style.left,10),n=parseInt(De.style.top,10),r=B(e,n);if(!r)return;var o=$e,i=W(r),a=i.documentId,u=i.pageNumber,c=i.viewport,l=1/c.scale,s=r.getBoundingClientRect(),d=Y([e-s.left,n-s.top+o],r,c),f={type:"textbox",size:$e*l,color:Je,content:t,x:d[0],y:d[1],rotation:-c.rotation};In.getStoreAdapter().addAnnotation(a,u,f).then((function(t){j(r,t)}))}tn()}function tn(){De&&(De.removeEventListener("blur",Ge),De.removeEventListener("keyup",Ke),document.body.removeChild(De),De=null)}function en(t,e){var n=document.createElement("div"),r=document.createTextNode(t);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-".concat(e)),n.style.position="absolute",n.style.left="-10000px",n.style.top="auto",n.style.width="1px",n.style.height="1px",n.style.overflow="hidden",n}function nn(t){return function(t){if(Array.isArray(t))return rn(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return rn(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rn(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rn(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n"===l[l.length-1])for(;l.length&&(s.unshift(l.pop()),"<"!==s[0]););if(c.innerHTML=l.join(""),u+Q(a,{width:c.getBoundingClientRect().width}).width<=e)break;s.unshift(l.pop())}return i.innerHTML=l.join("")+t.outerHTML+s.join(""),c.parentNode.removeChild(c),!0}function an(t){return function(t){if(Array.isArray(t))return un(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return un(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return un(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function un(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n div"));n=X(o,{y:n}).y+i.top,e=X(o,{x:e}).x+i.left;for(var u=0,c=a.length;u1&&void 0!==arguments[1]?arguments[1]:0;switch(t.type){case"highlight":case"strikeout":var n=t.rectangles,r=n[0],o=n[n.length-1];on(en("Begin ".concat(t.type," annotation ").concat(e),t.uuid),r.x,r.y,t.page,!0),on(en("End ".concat(t.type," annotation ").concat(e),"".concat(t.uuid,"-end")),o.x+o.width,o.y,t.page,!1);break;case"textbox":case"point":var i="textbox"===t.type?" (content: ".concat(t.content,")"):"";cn(en("".concat(t.type," annotation ").concat(e).concat(i),t.uuid),t.x,t.y,t.page);break;case"drawing":case"area":var a=void 0!==t.x?t.x:t.lines[0][0],u=void 0!==t.y?t.y:t.lines[0][1];cn(en("Unlabeled drawing",t.uuid),a,u,t.page);break;case"circle":case"fillcircle":case"emptycircle":var c=void 0!==t.cx?t.cx:t.lines[0][0],l=void 0!==t.cy?t.cy:t.lines[0][1];cn(en("Unlabeled drawing",t.uuid),c,l,t.page)}dn.includes(t.type)&&sn(t.documentId,t.uuid)}(t,e+1)}))}))}function gn(t,e){return t.yt.length)&&(e=t.length);for(var n=0,r=new Array(e);n\n \n \n';function En(t){if(Math.floor(t)===t)return[t,1];var e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];for(var n=t>1?e:t,r=0,o=1,i=1,a=1;;){var u=r+i,c=o+a;if(c>8)break;n<=u/c?(i=u,a=c):(r=u,o=c)}return n-r/o0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";Wt=Math.round(100*parseFloat(t))/100,$t=e},disablePoint:function(){Se&&(Se=!1,document.removeEventListener("mouseup",Ee))},enablePoint:function(){Se||(Se=!0,document.addEventListener("mouseup",Ee))},disableRect:function(){Me&&(Me=!1,document.removeEventListener("mouseup",qe),document.removeEventListener("mousedown",Te),document.removeEventListener("keyup",ze))},enableRect:function(t){Ne=t,Me||(Me=!0,document.addEventListener("mouseup",qe),document.addEventListener("mousedown",Te),document.addEventListener("keyup",ze))},disableCircle:function(){Ye&&(Ye=!1,document.removeEventListener("mouseup",He))},enableCircle:function(t){Xe=t,Ye||(Ye=!0,document.addEventListener("mouseup",He))},setCircle:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";Ue=parseInt(t,10),Qe=e},addCircle:function(t,e){var n=Xe;Xe=t,He(e),Xe=n},disableArrow:function(){le&&(le=!1,document.removeEventListener("mousedown",se),document.removeEventListener("keyup",pe),D())},enableArrow:function(){le||(le=!0,document.addEventListener("mousedown",se),document.addEventListener("keyup",pe),H())},setArrow:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";re=parseInt(t,10),oe=e},disableEraser:function(){document.removeEventListener("pointermove",we),document.removeEventListener("pointerdown",ge),document.removeEventListener("pointerup",be)},enableEraser:function(){document.addEventListener("pointermove",we),document.addEventListener("pointerdown",ge),document.addEventListener("pointerup",be)},disableText:function(){We&&(We=!1,document.removeEventListener("mouseup",Ve))},enableText:function(){We||(We=!0,document.addEventListener("mouseup",Ve))},setText:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";$e=parseInt(t,10),Je=e},createPage:function(t){var e=document.createElement("div");e.innerHTML=Sn;var n=e.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer".concat(t)),n.setAttribute("data-page-number",t),r.mozOpaque=!0,r.setAttribute("id","page".concat(t)),n},renderPage:function(t,e){var n=e.documentId,r=e.pdfDocument,o=e.scale,i=e.rotate,a=new pdfjsViewer.EventBus;return Promise.all([r.getPage(t),In.getAnnotations(n,t)]).then((function(e){var n=xn(e,2),r=n[0],u=n[1],c=document.getElementById("pageContainer".concat(t)),l=c.querySelector(kt.annotationClassQuery()),s=c.querySelector(".canvasWrapper canvas").getContext("2d",{alpha:!1}),d=(i+r.rotate)%360,f=r.getViewport({scale:o,rotation:d}),p=function(t,e,n){var r=document.getElementById("pageContainer".concat(t)),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(kt.annotationClassQuery()),a=r.querySelector(".canvasWrapper"),u=r.querySelector(kt.textClassQuery()),c=(f=n,p=window.devicePixelRatio||1,y=f.webkitBackingStorePixelRatio||f.mozBackingStorePixelRatio||f.msBackingStorePixelRatio||f.oBackingStorePixelRatio||f.backingStorePixelRatio||1,m=p/y,{sx:m,sy:m,scaled:1!==m}),l=c.scaled?[c.sx,0,0,c.sy,0,0]:null,s=En(c.sx),d=En(c.sy);var f,p,y,m;return r.style.visibility="",o.width=Cn(e.width*c.sx,s[0]),o.height=Cn(e.height*c.sy,d[0]),o.style.width=Cn(e.width,s[1])+"px",o.style.height=Cn(e.height,s[1])+"px",i.setAttribute("width",e.width),i.setAttribute("height",e.height),i.style.width="".concat(e.width,"px"),i.style.height="".concat(e.height,"px"),r.style.width="".concat(e.width,"px"),r.style.height="".concat(e.height,"px"),a.style.width="".concat(e.width,"px"),a.style.height="".concat(e.height,"px"),u.style.width="".concat(e.width,"px"),u.style.height="".concat(e.height,"px"),l}(t,f,s);return Promise.all([r.render({canvasContext:s,viewport:f,transform:p}).promise,In.render(l,f,u)]).then((function(){return r.getTextContent({normalizeWhitespace:!0}).then((function(e){return new Promise((function(n,r){var o=c.querySelector(kt.textClassQuery()),i=(new pdfjsViewer.DefaultTextLayerFactory).createTextLayerBuilder(o,t-1,f,!1,a);i.setTextContent(e),i.render(),setTimeout((function(){try{hn(u.annotations),n()}catch(t){r(t)}}))}))}))})).then((function(){return c.setAttribute("data-loaded","true"),[r,u]}))}))}},In={findAnnotationAtPoint:q,findSVGContainer:T,convertToScreenPoint:U,StoreAdapter:et,LocalStoreAdapter:dt,LocalUserStoreAdapter:Et,__storeAdapter:new et,getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(t){this.__storeAdapter=t},UI:Ln,render:function(t,e,n){return new Promise((function(r,o){return t.setAttribute("data-pdf-annotate-container",!0),t.setAttribute("data-pdf-annotate-viewport",JSON.stringify(e)),t.removeAttribute("data-pdf-annotate-document"),t.removeAttribute("data-pdf-annotate-page"),n?(t.setAttribute("data-pdf-annotate-document",n.documentId),t.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach((function(n){var r=t.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?P(t,r,e):j(t,n,e)})),void r(t)):r(t)):(t.innerHTML="",r(t))}))},getAnnotations:function(t,e){var n;return(n=this.getStoreAdapter()).getAnnotations.apply(n,arguments)},config:kt,uuid:ot};e.default=In}])})); +//# sourceMappingURL=pdf-annotate.min.js.map \ No newline at end of file diff --git a/dist/pdf-annotate.min.js.map b/dist/pdf-annotate.min.js.map new file mode 100644 index 00000000..429e9f8c --- /dev/null +++ b/dist/pdf-annotate.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://PDFAnnotate/webpack/universalModuleDefinition","webpack://PDFAnnotate/webpack/bootstrap","webpack://PDFAnnotate/./node_modules/events/events.js","webpack://PDFAnnotate/./src/utils/abstractFunction.js","webpack://PDFAnnotate/./src/utils/setAttributes.js","webpack://PDFAnnotate/./src/utils/normalizeColor.js","webpack://PDFAnnotate/./src/render/renderPoint.js","webpack://PDFAnnotate/./src/render/renderRect.js","webpack://PDFAnnotate/./src/render/renderText.js","webpack://PDFAnnotate/./src/render/renderCircle.js","webpack://PDFAnnotate/./src/utils/mathUtils.js","webpack://PDFAnnotate/./src/render/renderArrow.js","webpack://PDFAnnotate/./src/render/appendChild.js","webpack://PDFAnnotate/./src/render/renderLine.js","webpack://PDFAnnotate/./src/render/renderPath.js","webpack://PDFAnnotate/./src/UI/utils.js","webpack://PDFAnnotate/./src/UI/event.js","webpack://PDFAnnotate/./src/adapter/StoreAdapter.js","webpack://PDFAnnotate/./src/utils/uuid.js","webpack://PDFAnnotate/./src/adapter/LocalStoreAdapter.js","webpack://PDFAnnotate/./src/adapter/LocalUserStoreAdapter.js","webpack://PDFAnnotate/./src/config.js","webpack://PDFAnnotate/./src/UI/edit.js","webpack://PDFAnnotate/./src/UI/pen.js","webpack://PDFAnnotate/./src/UI/arrow.js","webpack://PDFAnnotate/./src/UI/eraser.js","webpack://PDFAnnotate/./src/UI/point.js","webpack://PDFAnnotate/./src/UI/rect.js","webpack://PDFAnnotate/./src/UI/circle.js","webpack://PDFAnnotate/./src/UI/text.js","webpack://PDFAnnotate/./src/a11y/createScreenReaderOnly.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinElement.js","webpack://PDFAnnotate/./src/a11y/insertElementWithinChildren.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderComment.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderComments.js","webpack://PDFAnnotate/./src/a11y/insertScreenReaderHint.js","webpack://PDFAnnotate/./src/a11y/initEventHandlers.js","webpack://PDFAnnotate/./src/a11y/renderScreenReaderHints.js","webpack://PDFAnnotate/./src/UI/page.js","webpack://PDFAnnotate/./src/UI/index.js","webpack://PDFAnnotate/./src/PDFJSAnnotate.js","webpack://PDFAnnotate/./src/render/index.js","webpack://PDFAnnotate/./index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ReflectOwnKeys","R","Reflect","ReflectApply","apply","target","receiver","args","Function","ownKeys","getOwnPropertySymbols","getOwnPropertyNames","concat","NumberIsNaN","Number","isNaN","EventEmitter","init","this","once","emitter","Promise","resolve","reject","errorListener","err","removeListener","resolver","slice","arguments","eventTargetAgnosticAddListener","handler","flags","on","addErrorHandlerIfEventEmitter","_events","undefined","_eventsCount","_maxListeners","defaultMaxListeners","checkListener","listener","TypeError","_getMaxListeners","that","_addListener","type","prepend","events","existing","warning","newListener","emit","unshift","push","length","warned","w","Error","String","count","console","warn","onceWrapper","fired","wrapFn","_onceWrap","state","wrapped","_listeners","unwrap","evlistener","arr","ret","Array","unwrapListeners","arrayClone","listenerCount","copy","addEventListener","wrapListener","arg","removeEventListener","set","RangeError","getPrototypeOf","setMaxListeners","getMaxListeners","doError","error","er","message","context","len","listeners","addListener","prependListener","prependOnceListener","list","position","originalListener","shift","index","pop","spliceOne","off","removeAllListeners","keys","rawListeners","eventNames","abstractFunction","UPPER_REGEX","BLACKLIST","setAttributes","node","attributes","forEach","setAttribute","indexOf","replace","match","toLowerCase","keyCase","REGEX_HASHLESS_HEX","normalizeColor","color","test","SIZE","createRect","rect","document","createElementNS","x","y","width","height","renderText","a","text","fill","fontSize","size","transform","rotation","style","textElement","textContent","_step","lines","split","getAttribute","_iterator","_createForOfIteratorHelper","done","line","tspan","toString","innerHTML","appendChild","e","f","insertLineBreaks","content","g","renderCircle","circle","cx","cy","createCircle","stroke","translate","rotate","angle","Math","PI","cosValue","cos","sinValue","sin","scale","makePoint","z","makeVector","xcoord","ycoord","zcoord","makeVectorFromPoints","pt1","pt2","addVector","pt","v","multiplyVector","scalar","magnitude","sqrt","pow","negateVector","unitVector","mag","renderArrow","u","arrow","p1","p2","pt0","unitX","unitZ","unitY","thickness","A","B","C","D","G","F","E","points","isFirefox","navigator","userAgent","getTranslation","viewport","trans","nodeName","parseInt","path","querySelector","svg","parentNode","assign","annotation","child","group","JSON","parse","fillOpacity","rectangles","renderRect","strokeWidth","x1","y1","x2","y2","outerSVG","innerSVG","viewBox","renderPoint","join","renderPath","uuid","filter","transformChild","BORDER_COLOR","userSelectStyleSheet","createElement","findSVGContainer","toUpperCase","findSVGAtPoint","elements","querySelectorAll","el","pointIntersectsRect","getBoundingClientRect","findAnnotationAtPoint","candidate","elementFromPoint","top","bottom","left","right","getOffsetAnnotationRect","extraOffsetWidth","extraOffsetHeight","tagName","getBBox","bbox","_getOffset","offsetLeft","offsetTop","getOffset","scaleUp","result","getMetadata","convertToSvgPoint","xform","offset","convertToScreenPoint","scaleDown","disableUserSelect","head","enableUserSelect","removeChild","documentId","pageNumber","clickNode","fireEvent","clientX","clientY","StoreAdapter","_this","definition","_classCallCheck","__getAnnotations","fn","then","annotations","annotationId","__addAnnotation","__editAnnotation","__deleteAnnotation","success","__addComment","comment","commentId","__deleteComment","REGEXP","replacement","random","LocalStoreAdapter","_StoreAdapter","_inherits","_super","_createSuper","getAnnotations","page","getAnnotation","findAnnotation","addAnnotation","updateAnnotations","editAnnotation","deleteAnnotation","splice","getComments","addComment","class","deleteComment","localStorage","getItem","setItem","stringify","LocalUserStoreAdapter","userId","globalEdit","getAllAnnotations","_userId","_globalEdit","all_annotations","re","RegExp","search","_toConsumableArray","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","_enabled","isDragging","destroyEditOverlay","handleDocumentClick","handleDocumentKeyup","handleDocumentMousedown","handleDocumentMousemove","handleDocumentMouseup","config","PDFJSAnnotate","getStoreAdapter","getElementById","keyTest","keyCode","preventDefault","background","cursor","display","maxY","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","modelX","modelY","setTimeout","handleAnnotationClick","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","padding","textAlign","textDecoration","borderColor","boxShadow","createEditOverlay","_penSize","_penColor","_candraw","handleDocumentPointerdown","handleDocumentPointerup","_getMetadata","saveToStorage","handleDocumentPointermove","point","toFixed","savePoint","originY","originX","_getMetadata2","_canerase","previousPoint","handleDocumentDown","handleDocumentUp","erase","handleDocumentMouseMove","check","diffX","abs","diffY","maxSteps","round","max","subStepSize","min","smallerTest","startPoint","_i","_check","parentElement","input","handleInputBlur","handleInputKeyup","body","focus","closeInput","trim","_type","rects","getSelection","getRangeAt","getClientRects","getSelectionRects","saveRect","map","removeAllRanges","boundingRect","convertToSvgRect","_circleRadius","_circleColor","radius","svg_pt","saveCircle","_textSize","_textColor","srcElement","classList","contains","saveText","shiftKey","createScreenReaderOnly","createTextNode","overflow","insertElementWithinElement","insertBefore","textLayerElementFromPoint","temp","cloneNode","tail","outerHTML","insertElementWithinChildren","nodes","textLayer","insertScreenReaderComment","item","renderScreenReaderComments","comments","isArray","COMMENT_TYPES","reorderAnnotationsByType","removeAnnotation","renderScreenReaderHints","removeElementById","insertComment","removeComment","elementId","SORT_TYPES","sortBy","sort","num","first","last","includes","insertScreenReaderHint","sortByPoint","b","sortByRectPoint","lineA","lineB","PAGE_TEMPLATE","approximateFraction","floor","xinv","x_","q","roundToDivide","div","disableEdit","enableEdit","disablePen","enablePen","setPen","penSize","penColor","parseFloat","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","circleRadius","circleColor","addCircle","oldType","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","textSize","textColor","createPage","children","canvas","mozOpaque","renderPage","renderOptions","pdfDocument","eventBus","pdfjsViewer","EventBus","all","getPage","_ref","_ref2","_slicedToArray","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","wrapper","outputScale","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","sx","sy","scaled","sfx","sfy","visibility","scalePage","render","promise","getTextContent","normalizeWhitespace","textLayerBuilder","DefaultTextLayerFactory","createTextLayerBuilder","setTextContent","__storeAdapter","setStoreAdapter","adapter","U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","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"PDFAnnotate\"] = factory();\n\telse\n\t\troot[\"PDFAnnotate\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n'use strict';\n\nvar R = typeof Reflect === 'object' ? Reflect : null\nvar ReflectApply = R && typeof R.apply === 'function'\n ? R.apply\n : function ReflectApply(target, receiver, args) {\n return Function.prototype.apply.call(target, receiver, args);\n }\n\nvar ReflectOwnKeys\nif (R && typeof R.ownKeys === 'function') {\n ReflectOwnKeys = R.ownKeys\n} else if (Object.getOwnPropertySymbols) {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target)\n .concat(Object.getOwnPropertySymbols(target));\n };\n} else {\n ReflectOwnKeys = function ReflectOwnKeys(target) {\n return Object.getOwnPropertyNames(target);\n };\n}\n\nfunction ProcessEmitWarning(warning) {\n if (console && console.warn) console.warn(warning);\n}\n\nvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n return value !== value;\n}\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\nmodule.exports = EventEmitter;\nmodule.exports.once = once;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._eventsCount = 0;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nvar defaultMaxListeners = 10;\n\nfunction checkListener(listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n}\n\nObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n enumerable: true,\n get: function() {\n return defaultMaxListeners;\n },\n set: function(arg) {\n if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n }\n defaultMaxListeners = arg;\n }\n});\n\nEventEmitter.init = function() {\n\n if (this._events === undefined ||\n this._events === Object.getPrototypeOf(this)._events) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n }\n this._maxListeners = n;\n return this;\n};\n\nfunction _getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return _getMaxListeners(this);\n};\n\nEventEmitter.prototype.emit = function emit(type) {\n var args = [];\n for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n var doError = (type === 'error');\n\n var events = this._events;\n if (events !== undefined)\n doError = (doError && events.error === undefined);\n else if (!doError)\n return false;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n var er;\n if (args.length > 0)\n er = args[0];\n if (er instanceof Error) {\n // Note: The comments on the `throw` lines are intentional, they show\n // up in Node's output if this results in an unhandled exception.\n throw er; // Unhandled 'error' event\n }\n // At least give some kind of context to the user\n var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n err.context = er;\n throw err; // Unhandled 'error' event\n }\n\n var handler = events[type];\n\n if (handler === undefined)\n return false;\n\n if (typeof handler === 'function') {\n ReflectApply(handler, this, args);\n } else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n ReflectApply(listeners[i], this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n checkListener(listener);\n\n events = target._events;\n if (events === undefined) {\n events = target._events = Object.create(null);\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener !== undefined) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (existing === undefined) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] =\n prepend ? [listener, existing] : [existing, listener];\n // If we've already got an array, just append.\n } else if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n\n // Check for listener leak\n m = _getMaxListeners(target);\n if (m > 0 && existing.length > m && !existing.warned) {\n existing.warned = true;\n // No error code for this since it is a Warning\n // eslint-disable-next-line no-restricted-syntax\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + String(type) + ' listeners ' +\n 'added. Use emitter.setMaxListeners() to ' +\n 'increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n ProcessEmitWarning(w);\n }\n }\n\n return target;\n}\n\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction onceWrapper() {\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n if (arguments.length === 0)\n return this.listener.call(this.target);\n return this.listener.apply(this.target, arguments);\n }\n}\n\nfunction _onceWrap(target, type, listener) {\n var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n var wrapped = onceWrapper.bind(state);\n wrapped.listener = listener;\n state.wrapFn = wrapped;\n return wrapped;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n checkListener(listener);\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n checkListener(listener);\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// Emits a 'removeListener' event if and only if the listener was removed.\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n checkListener(listener);\n\n events = this._events;\n if (events === undefined)\n return this;\n\n list = events[type];\n if (list === undefined)\n return this;\n\n if (list === listener || list.listener === listener) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length - 1; i >= 0; i--) {\n if (list[i] === listener || list[i].listener === listener) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (position === 0)\n list.shift();\n else {\n spliceOne(list, position);\n }\n\n if (list.length === 1)\n events[type] = list[0];\n\n if (events.removeListener !== undefined)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events, i;\n\n events = this._events;\n if (events === undefined)\n return this;\n\n // not listening for removeListener, no need to emit\n if (events.removeListener === undefined) {\n if (arguments.length === 0) {\n this._events = Object.create(null);\n this._eventsCount = 0;\n } else if (events[type] !== undefined) {\n if (--this._eventsCount === 0)\n this._events = Object.create(null);\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n var key;\n for (i = 0; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = Object.create(null);\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners !== undefined) {\n // LIFO order\n for (i = listeners.length - 1; i >= 0; i--) {\n this.removeListener(type, listeners[i]);\n }\n }\n\n return this;\n };\n\nfunction _listeners(target, type, unwrap) {\n var events = target._events;\n\n if (events === undefined)\n return [];\n\n var evlistener = events[type];\n if (evlistener === undefined)\n return [];\n\n if (typeof evlistener === 'function')\n return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n return unwrap ?\n unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n}\n\nEventEmitter.prototype.listeners = function listeners(type) {\n return _listeners(this, type, true);\n};\n\nEventEmitter.prototype.rawListeners = function rawListeners(type) {\n return _listeners(this, type, false);\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events !== undefined) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener !== undefined) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n};\n\nfunction arrayClone(arr, n) {\n var copy = new Array(n);\n for (var i = 0; i < n; ++i)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction spliceOne(list, index) {\n for (; index + 1 < list.length; index++)\n list[index] = list[index + 1];\n list.pop();\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nfunction once(emitter, name) {\n return new Promise(function (resolve, reject) {\n function errorListener(err) {\n emitter.removeListener(name, resolver);\n reject(err);\n }\n\n function resolver() {\n if (typeof emitter.removeListener === 'function') {\n emitter.removeListener('error', errorListener);\n }\n resolve([].slice.call(arguments));\n };\n\n eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n if (name !== 'error') {\n addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n }\n });\n}\n\nfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n if (typeof emitter.on === 'function') {\n eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n }\n}\n\nfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n if (typeof emitter.on === 'function') {\n if (flags.once) {\n emitter.once(name, listener);\n } else {\n emitter.on(name, listener);\n }\n } else if (typeof emitter.addEventListener === 'function') {\n // EventTarget does not have `error` event semantics like Node\n // EventEmitters, we do not listen for `error` events here.\n emitter.addEventListener(name, function wrapListener(arg) {\n // IE does not have builtin `{ once: true }` support so we\n // have to do it manually.\n if (flags.once) {\n emitter.removeEventListener(name, wrapListener);\n }\n listener(arg);\n });\n } else {\n throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n }\n}\n","/**\r\n * Throw an Error for an abstract function that hasn't been implemented.\r\n *\r\n * @param {String} name The name of the abstract function\r\n */\r\nexport default function abstractFunction(name) {\r\n throw new Error(name + ' is not implemented');\r\n}\r\n","const UPPER_REGEX = /[A-Z]/g;\r\n\r\n// Don't convert these attributes from camelCase to hyphenated-attributes\r\nconst BLACKLIST = [\r\n 'viewBox'\r\n];\r\n\r\nlet keyCase = (key) => {\r\n if (BLACKLIST.indexOf(key) === -1) {\r\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\r\n }\r\n return key;\r\n};\r\n\r\n/**\r\n * Set attributes for a node from a map\r\n *\r\n * @param {Node} node The node to set attributes on\r\n * @param {Object} attributes The map of key/value pairs to use for attributes\r\n */\r\nexport default function setAttributes(node, attributes) {\r\n Object.keys(attributes).forEach((key) => {\r\n node.setAttribute(keyCase(key), attributes[key]);\r\n });\r\n}\r\n","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\r\n\r\n/**\r\n * Normalize a color value\r\n *\r\n * @param {String} color The color to normalize\r\n * @return {String}\r\n */\r\nexport default function normalizeColor(color) {\r\n if (REGEX_HASHLESS_HEX.test(color)) {\r\n color = `#${color}`;\r\n }\r\n return color;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\n\r\nconst SIZE = 25;\r\nconst D = 'M499.968 214.336q-113.832 0 -212.877 38.781t-157.356 104.625 -58.311 142.29q0 62.496 39.897 119.133t112.437 97.929l48.546 27.9 -15.066 53.568q-13.392 50.778 -39.06 95.976 84.816 -35.154 153.45 -95.418l23.994 -21.204 31.806 3.348q38.502 4.464 72.54 4.464 113.832 0 212.877 -38.781t157.356 -104.625 58.311 -142.29 -58.311 -142.29 -157.356 -104.625 -212.877 -38.781z';\r\n\r\n/**\r\n * Create SVGElement from an annotation definition.\r\n * This is used for anntations of type `comment`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGElement} A svg to be rendered\r\n */\r\nexport default function renderPoint(a) {\r\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n setAttributes(outerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: a.x,\r\n y: a.y\r\n });\r\n\r\n setAttributes(innerSVG, {\r\n width: SIZE,\r\n height: SIZE,\r\n x: 0,\r\n y: (SIZE * 0.05) * -1,\r\n viewBox: '0 0 1000 1000'\r\n });\r\n\r\n setAttributes(rect, {\r\n width: SIZE,\r\n height: SIZE,\r\n stroke: '#000',\r\n fill: '#ff0'\r\n });\r\n\r\n setAttributes(path, {\r\n d: D,\r\n strokeWidth: 50,\r\n stroke: '#000',\r\n fill: '#fff'\r\n });\r\n\r\n innerSVG.appendChild(path);\r\n outerSVG.appendChild(rect);\r\n outerSVG.appendChild(innerSVG);\r\n\r\n return outerSVG;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGRectElements from an annotation definition.\r\n * This is used for anntations of type `area` and `highlight`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\r\n */\r\nexport default function renderRect(a) {\r\n if (a.type === 'highlight') {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n fill: normalizeColor(a.color || '#ff0'),\r\n fillOpacity: 0.2\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n group.appendChild(createRect(r));\r\n });\r\n\r\n return group;\r\n }\r\n else {\r\n let rect = createRect(a);\r\n setAttributes(rect, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n fill: 'none'\r\n });\r\n\r\n return rect;\r\n }\r\n}\r\n\r\nfunction createRect(r) {\r\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\r\n\r\n setAttributes(rect, {\r\n x: r.x,\r\n y: r.y,\r\n width: r.width,\r\n height: r.height\r\n });\r\n\r\n return rect;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Wrap each line of given text in a `` element and append these\r\n * lines to the given SVGTextElement\r\n *\r\n * @param {SVGTextElement} textElement A text element to hold the split text\r\n * @param {String} textContent String to render with line breaks\r\n */\r\nfunction insertLineBreaks(textElement, textContent) {\r\n const lines = (textContent || '').split('\\n');\r\n // can't use dy attribute here since we want empty lines to take up space as well,\r\n // so we will update y manually based on font size\r\n const x = textElement.getAttribute('x');\r\n let y = Number(textElement.getAttribute('y'));\r\n const size = Number(textElement.getAttribute('font-size'));\r\n for (const line of lines) {\r\n const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan');\r\n tspan.setAttribute('y', y.toString());\r\n tspan.setAttribute('x', x);\r\n tspan.innerHTML = line;\r\n textElement.appendChild(tspan);\r\n\r\n y += size;\r\n }\r\n}\r\n\r\n/**\r\n * Create SVGTextElement from an annotation definition.\r\n * This is used for anntations of type `textbox`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGTextElement} A text to be rendered\r\n */\r\nexport default function renderText(a) {\r\n // Text should be rendered at 0 degrees relative to\r\n // document rotation\r\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\r\n setAttributes(text, {\r\n x: a.x,\r\n y: a.y,\r\n fill: normalizeColor(a.color || '#000'),\r\n fontSize: a.size,\r\n transform: `rotate(${a.rotation})`,\r\n style: 'white-space: pre'\r\n });\r\n\r\n insertLineBreaks(text, a.content);\r\n\r\n let g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n g.appendChild(text);\r\n\r\n return g;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create an SVGCircleElement from an annotation definition.\r\n * This is used for annotations of type `circle`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\r\n */\r\nexport default function renderCircle(a) {\r\n let circle = createCircle(a);\r\n let color = normalizeColor(a.color || '#f00');\r\n\r\n if (a.type === 'circle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 5\r\n });\r\n }\r\n if (a.type === 'emptycircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: 'none',\r\n 'stroke-width': 2\r\n });\r\n }\r\n\r\n if (a.type === 'fillcircle') {\r\n setAttributes(circle, {\r\n stroke: color,\r\n fill: color,\r\n 'stroke-width': 5\r\n });\r\n }\r\n\r\n return circle;\r\n}\r\n\r\nfunction createCircle(a) {\r\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\r\n setAttributes(circle, {\r\n cx: a.cx,\r\n cy: a.cy,\r\n r: a.r\r\n });\r\n\r\n return circle;\r\n}\r\n","// Transform point by matrix\r\n//\r\nexport function applyTransform(p, m) {\r\n return [\r\n p[0] * m[0] + p[1] * m[2] + m[4],\r\n p[0] * m[1] + p[1] * m[3] + m[5]\r\n ];\r\n};\r\n\r\n// Transform point by matrix inverse\r\n//\r\nexport function applyInverseTransform(p, m) {\r\n let d = m[0] * m[3] - m[1] * m[2];\r\n return [\r\n (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d,\r\n (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d\r\n ];\r\n};\r\n\r\n// Concatenates two transformation matrices together and returns the result.\r\nexport function transform(m1, m2) {\r\n return [\r\n m1[0] * m2[0] + m1[2] * m2[1],\r\n m1[1] * m2[0] + m1[3] * m2[1],\r\n m1[0] * m2[2] + m1[2] * m2[3],\r\n m1[1] * m2[2] + m1[3] * m2[3],\r\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\r\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\r\n ];\r\n};\r\n\r\nexport function translate(m, x, y) {\r\n return [\r\n m[0],\r\n m[1],\r\n m[2],\r\n m[3],\r\n m[0] * x + m[2] * y + m[4],\r\n m[1] * x + m[3] * y + m[5]\r\n ];\r\n};\r\n\r\nexport function rotate(m, angle) {\r\n angle = angle * Math.PI / 180;\r\n\r\n let cosValue = Math.cos(angle);\r\n let sinValue = Math.sin(angle);\r\n\r\n return [\r\n m[0] * cosValue + m[2] * sinValue,\r\n m[1] * cosValue + m[3] * sinValue,\r\n m[0] * (-sinValue) + m[2] * cosValue,\r\n m[1] * (-sinValue) + m[3] * cosValue,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function scale(m, x, y) {\r\n return [\r\n m[0] * x,\r\n m[1] * x,\r\n m[2] * y,\r\n m[3] * y,\r\n m[4],\r\n m[5]\r\n ];\r\n};\r\n\r\nexport function makePoint(x, y, z) {\r\n return { x: x, y: y, z: z };\r\n};\r\n\r\nexport function makeVector(xcoord, ycoord, zcoord) {\r\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord };\r\n};\r\n\r\nexport function makeVectorFromPoints(pt1, pt2) {\r\n let xcoord = pt2.x - pt1.x;\r\n let ycoord = pt2.y - pt1.y;\r\n let zcoord = pt2.z - pt1.z;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function addVector(pt, v) {\r\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\r\n};\r\n\r\nexport function multiplyVector(v, scalar) {\r\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\r\n};\r\n\r\nexport function magnitude(v) {\r\n return Math.sqrt(\r\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\r\n );\r\n};\r\n\r\nexport function negateVector(v) {\r\n return multiplyVector(v, -1);\r\n};\r\n\r\nexport function unitVector(v) {\r\n let mag = magnitude(v);\r\n let xcoord = v.xcoord / mag;\r\n let ycoord = v.ycoord / mag;\r\n let zcoord = v.zcoord / mag;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n\r\nexport function crossProduct(u, v) {\r\n //\r\n // u X v = < u2*v3 - u3*v2,\r\n // u3*v1 - u1*v3,\r\n // u1*v2 - u2*v1 >\r\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\r\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\r\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\r\n return makeVector(xcoord, ycoord, zcoord);\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\nimport {\r\n makePoint, makeVector, makeVectorFromPoints,\r\n magnitude, unitVector, crossProduct,\r\n addVector, multiplyVector, negateVector\r\n} from '../utils/mathUtils';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderArrow(a) {\r\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\r\n\r\n if (a.lines.length === 2) {\r\n let p1 = a.lines[0];\r\n let p2 = a.lines[a.lines.length - 1];\r\n\r\n let arrowLength = 40;\r\n let pt0 = makePoint(p1[0], p1[1], 0);\r\n let pt1 = makePoint(p2[0], p2[1], 0);\r\n let x = makeVectorFromPoints(pt0, pt1);\r\n let unitX = unitVector(x);\r\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\r\n x = makeVectorFromPoints(pt0, pt1);\r\n let unitZ = makeVector(0, 0, 1);\r\n let unitY = unitVector(crossProduct(unitX, unitZ));\r\n let thickness = a.width || 10;\r\n\r\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5));\r\n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let C = addVector(B, multiplyVector(unitY, thickness));\r\n let D = pt1;\r\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5));\r\n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0));\r\n let E = addVector(F, multiplyVector(negateVector(unitY), thickness));\r\n\r\n let points = '' +\r\n A.x + ',' + A.y + ' ' +\r\n B.x + ',' + B.y + ' ' +\r\n C.x + ',' + C.y + ' ' +\r\n D.x + ',' + D.y + ' ' +\r\n E.x + ',' + E.y + ' ' +\r\n F.x + ',' + F.y + ' ' +\r\n G.x + ',' + G.y;\r\n\r\n setAttributes(arrow, {\r\n points: points,\r\n stroke: normalizeColor(a.color || '#000'),\r\n fill: normalizeColor(a.color || '#000')\r\n });\r\n }\r\n\r\n return arrow;\r\n}\r\n","import renderLine from './renderLine';\r\nimport renderPath from './renderPath';\r\nimport renderPoint from './renderPoint';\r\nimport renderRect from './renderRect';\r\nimport renderText from './renderText';\r\nimport renderCircle from './renderCircle';\r\nimport renderArrow from './renderArrow';\r\n\r\nconst isFirefox = /firefox/i.test(navigator.userAgent);\r\n\r\n/**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n *\r\n * @param {Object} viewport The viewport data from the page\r\n * @return {Object}\r\n */\r\nexport function getTranslation(viewport) {\r\n let x;\r\n let y;\r\n\r\n // Modulus 360 on the rotation so that we only\r\n // have to worry about four possible values.\r\n switch (viewport.rotation % 360) {\r\n case 0:\r\n x = y = 0;\r\n break;\r\n case 90:\r\n x = 0;\r\n y = (viewport.width / viewport.scale) * -1;\r\n break;\r\n case 180:\r\n x = (viewport.width / viewport.scale) * -1;\r\n y = (viewport.height / viewport.scale) * -1;\r\n break;\r\n case 270:\r\n x = (viewport.height / viewport.scale) * -1;\r\n y = 0;\r\n break;\r\n }\r\n\r\n return { x, y };\r\n}\r\n\r\n/**\r\n * Transform the rotation and scale of a node using SVG's native transform attribute.\r\n *\r\n * @param {Node} node The node to be transformed\r\n * @param {Object} viewport The page's viewport data\r\n * @return {Node}\r\n */\r\nfunction transform(node, viewport) {\r\n let trans = getTranslation(viewport);\r\n\r\n // Let SVG natively transform the element\r\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\r\n\r\n // Manually adjust x/y for nested SVG nodes\r\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\r\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\r\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\r\n\r\n let x = parseInt(node.getAttribute('x', 10));\r\n let y = parseInt(node.getAttribute('y', 10));\r\n let width = parseInt(node.getAttribute('width'), 10);\r\n let height = parseInt(node.getAttribute('height'), 10);\r\n let path = node.querySelector('path');\r\n let svg = path.parentNode;\r\n\r\n // Scale width/height\r\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\r\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\r\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\r\n });\r\n\r\n // Transform path but keep scale at 100% since it will be handled natively\r\n transform(path, Object.assign({}, viewport, { scale: 1 }));\r\n\r\n switch (viewport.rotation % 360) {\r\n case 90:\r\n node.setAttribute('x', viewport.width - y - width);\r\n node.setAttribute('y', x);\r\n svg.setAttribute('x', 1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n case 180:\r\n node.setAttribute('x', viewport.width - x - width);\r\n node.setAttribute('y', viewport.height - y - height);\r\n svg.setAttribute('y', 2);\r\n break;\r\n case 270:\r\n node.setAttribute('x', y);\r\n node.setAttribute('y', viewport.height - x - height);\r\n svg.setAttribute('x', -1);\r\n svg.setAttribute('y', 0);\r\n break;\r\n }\r\n }\r\n\r\n return node;\r\n}\r\n\r\n/**\r\n * Append an annotation as a child of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element to append the annotation to\r\n * @param {Object} annotation The annotation definition to render and append\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was created and appended by this function\r\n */\r\nexport function appendChild(svg, annotation, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n let child;\r\n switch (annotation.type) {\r\n case 'area':\r\n case 'highlight':\r\n child = renderRect(annotation);\r\n break;\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n child = renderCircle(annotation);\r\n break;\r\n case 'strikeout':\r\n child = renderLine(annotation);\r\n break;\r\n case 'point':\r\n child = renderPoint(annotation);\r\n break;\r\n case 'textbox':\r\n child = renderText(annotation);\r\n break;\r\n case 'drawing':\r\n child = renderPath(annotation);\r\n break;\r\n case 'arrow':\r\n child = renderArrow(annotation);\r\n break;\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip appending/transforming if node doesn't exist.\r\n if (child) {\r\n // Set attributes\r\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\r\n child.setAttribute('aria-hidden', true);\r\n\r\n // Dynamically set any other attributes associated with annotation that is not related to drawing it\r\n Object.keys(annotation).filter((key) => {\r\n return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page',\r\n 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1;\r\n }).forEach((key) => {\r\n child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]);\r\n });\r\n\r\n svg.appendChild(transform(child, viewport));\r\n }\r\n\r\n return child;\r\n}\r\n\r\n/**\r\n * Transform a child annotation of an SVG.\r\n *\r\n * @param {SVGElement} svg The SVG element with the child annotation\r\n * @param {Object} child The SVG child to transform\r\n * @param {Object} viewport The page's viewport data\r\n * @return {SVGElement} A node that was transformed by this function\r\n */\r\nexport function transformChild(svg, child, viewport) {\r\n if (!viewport) {\r\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\r\n }\r\n\r\n // If no type was provided for an annotation it will result in node being null.\r\n // Skip transforming if node doesn't exist.\r\n if (child) {\r\n child = transform(child, viewport);\r\n }\r\n\r\n return child;\r\n}\r\n\r\nexport default {\r\n /**\r\n * Get the x/y translation to be used for transforming the annotations\r\n * based on the rotation of the viewport.\r\n */\r\n getTranslation,\r\n\r\n /**\r\n * Append an SVG child for an annotation\r\n */\r\n appendChild,\r\n\r\n /**\r\n * Transform an existing SVG child\r\n */\r\n transformChild\r\n};\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGLineElements from an annotation definition.\r\n * This is used for anntations of type `strikeout`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGGElement} A group of all lines to be rendered\r\n */\r\nexport default function renderLine(a) {\r\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\r\n setAttributes(group, {\r\n stroke: normalizeColor(a.color || '#f00'),\r\n strokeWidth: 1\r\n });\r\n\r\n a.rectangles.forEach((r) => {\r\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\r\n\r\n setAttributes(line, {\r\n x1: r.x,\r\n y1: r.y,\r\n x2: r.x + r.width,\r\n y2: r.y\r\n });\r\n\r\n group.appendChild(line);\r\n });\r\n\r\n return group;\r\n}\r\n","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\r\n\r\n/**\r\n * Create SVGPathElement from an annotation definition.\r\n * This is used for anntations of type `drawing`.\r\n *\r\n * @param {Object} a The annotation definition\r\n * @return {SVGPathElement} The path to be rendered\r\n */\r\nexport default function renderPath(a) {\r\n let d = [];\r\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\r\n\r\n if (a.lines.length > 0) {\r\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\r\n for (let i = 1, l = a.lines.length; i < l; i++) {\r\n let p1 = a.lines[i];\r\n let p2 = a.lines[i + 1];\r\n if (p2) {\r\n d.push(`L${p1[0]} ${p1[1]}`);\r\n }\r\n }\r\n }\r\n\r\n /*\r\n\r\n if(a.lines.length>2) {\r\n var p1 = a.lines[0];\r\n var p2 = a.lines[a.lines.length-1];\r\n\r\n var p3 = []; //arrow\r\n var p4 = [];\r\n var p0 = []; //arrow intersection\r\n\r\n if (p2) {\r\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\r\n\r\n var deltaX = 3;\r\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\r\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\r\n\r\n p3[0] = p0[0] + deltaX;\r\n p3[1] = p0[1] + k*deltaX;\r\n\r\n p4[0] = p0[0] - deltaX;\r\n p4[1] = p0[1] - k*deltaX;\r\n\r\n if(Math.abs(p2[1]-p1[1]) < 20) {\r\n\r\n p3[0] = p0[0] ;\r\n p3[1] = p0[1] + deltaX*1;\r\n\r\n p4[0] = p0[0] ;\r\n p4[1] = p0[1] - deltaX*1;\r\n\r\n }\r\n\r\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\r\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\r\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\r\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\r\n }\r\n } */\r\n\r\n setAttributes(path, {\r\n d: `${d.join(' ')}`, // `${d.join(' ')}Z`,\r\n stroke: normalizeColor(a.color || '#000'),\r\n strokeWidth: a.width || 1,\r\n fill: 'none'\r\n });\r\n\r\n return path;\r\n}\r\n","import { getTranslation } from '../render/appendChild';\r\nimport {\r\n applyTransform,\r\n applyInverseTransform,\r\n translate,\r\n rotate,\r\n scale\r\n} from '../utils/mathUtils';\r\n\r\nexport const BORDER_COLOR = '#00BFFF';\r\n\r\nconst userSelectStyleSheet = document.createElement('style');\r\nuserSelectStyleSheet.innerHTML = `\r\nbody {\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n}\r\n`;\r\n\r\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\r\n\r\n/**\r\n * Find the SVGElement that contains all the annotations for a page\r\n *\r\n * @param {Element} node An annotation within that container\r\n * @return {SVGElement} The container SVG or null if it can't be found\r\n */\r\nexport function findSVGContainer(node) {\r\n let parentNode = node;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\r\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\r\n return parentNode;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an SVGElement container at a given point\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {SVGElement} The container SVG or null if one can't be found\r\n */\r\nexport function findSVGAtPoint(x, y) {\r\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\r\n\r\n for (let i = 0, l = elements.length; i < l; i++) {\r\n let el = elements[i];\r\n let rect = el.getBoundingClientRect();\r\n\r\n if (pointIntersectsRect(x, y, rect)) {\r\n return el;\r\n }\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Find an Element that represents an annotation at a given point.\r\n *\r\n * IMPORTANT: Requires the annotation layer to be the top most element so\r\n * either use z-ordering or make it the leaf container.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @return {Element} The annotation element or null if one can't be found\r\n */\r\nexport function findAnnotationAtPoint(x, y) {\r\n let el = null;\r\n let candidate = document.elementFromPoint(x, y);\r\n while (!el && candidate && candidate !== document) {\r\n let type = candidate.getAttribute('data-pdf-annotate-type');\r\n if (type) {\r\n el = candidate;\r\n }\r\n candidate = candidate.parentNode;\r\n }\r\n return el;\r\n}\r\n\r\n/**\r\n * Determine if a point intersects a rect\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Object} rect The points of a rect (likely from getBoundingClientRect)\r\n * @return {Boolean} True if a collision occurs, otherwise false\r\n */\r\nexport function pointIntersectsRect(x, y, rect) {\r\n return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\r\n}\r\n\r\n/**\r\n * Get the rect of an annotation element accounting for offset.\r\n *\r\n * @param {Element} el The element to get the rect of\r\n * @return {Object} The dimensions of the element\r\n */\r\nexport function getOffsetAnnotationRect(el) {\r\n let rect = el.getBoundingClientRect();\r\n let { width, height } = rect;\r\n let extraOffsetWidth = 0;\r\n let extraOffsetHeight = 0;\r\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\r\n let bbox = el.getBBox();\r\n extraOffsetWidth = (rect.width - bbox.width) / 2;\r\n extraOffsetHeight = (rect.height - bbox.height) / 2;\r\n width = bbox.width;\r\n height = bbox.height;\r\n }\r\n let { offsetLeft, offsetTop } = getOffset(el);\r\n return {\r\n top: rect.top - offsetTop + extraOffsetHeight,\r\n left: rect.left - offsetLeft + extraOffsetWidth,\r\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\r\n right: rect.right - offsetLeft - extraOffsetWidth,\r\n width: width,\r\n height: height\r\n };\r\n}\r\n\r\n/**\r\n * Adjust scale from normalized scale (100%) to rendered scale.\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled up\r\n */\r\nexport function scaleUp(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] * viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\nexport function convertToSvgRect(rect, svg, viewport) {\r\n let pt1 = [rect.x, rect.y];\r\n let pt2 = [rect.x + rect.width, rect.y + rect.height];\r\n\r\n pt1 = convertToSvgPoint(pt1, svg, viewport);\r\n pt2 = convertToSvgPoint(pt2, svg, viewport);\r\n\r\n return {\r\n x: Math.min(pt1[0], pt2[0]),\r\n y: Math.min(pt1[1], pt2[1]),\r\n width: Math.abs(pt2[0] - pt1[0]),\r\n height: Math.abs(pt2[1] - pt1[1])\r\n };\r\n}\r\n\r\nexport function convertToSvgPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyInverseTransform(pt, xform);\r\n}\r\n\r\nexport function convertToScreenPoint(pt, svg, viewport) {\r\n viewport = viewport || getMetadata(svg).viewport;\r\n\r\n let xform = [ 1, 0, 0, 1, 0, 0 ];\r\n xform = scale(xform, viewport.scale, viewport.scale);\r\n xform = rotate(xform, viewport.rotation);\r\n\r\n let offset = getTranslation(viewport);\r\n xform = translate(xform, offset.x, offset.y);\r\n\r\n return applyTransform(pt, xform);\r\n}\r\n\r\n/**\r\n * Adjust scale from rendered scale to a normalized scale (100%).\r\n *\r\n * @param {SVGElement} svg The SVG to gather metadata from\r\n * @param {Object} rect A map of numeric values to scale\r\n * @return {Object} A copy of `rect` with values scaled down\r\n */\r\nexport function scaleDown(svg, rect) {\r\n let result = {};\r\n let { viewport } = getMetadata(svg);\r\n\r\n Object.keys(rect).forEach((key) => {\r\n result[key] = rect[key] / viewport.scale;\r\n });\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the scroll position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the scroll position for\r\n * @return {Object} The scrollTop and scrollLeft position\r\n */\r\nexport function getScroll(el) {\r\n let scrollTop = 0;\r\n let scrollLeft = 0;\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n scrollTop += parentNode.scrollTop;\r\n scrollLeft += parentNode.scrollLeft;\r\n }\r\n\r\n return { scrollTop, scrollLeft };\r\n}\r\n\r\n/**\r\n * Get the offset position of an element, accounting for parent elements\r\n *\r\n * @param {Element} el The element to get the offset position for\r\n * @return {Object} The offsetTop and offsetLeft position\r\n */\r\nexport function getOffset(el) {\r\n let parentNode = el;\r\n\r\n while ((parentNode = parentNode.parentNode) &&\r\n parentNode !== document) {\r\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\r\n break;\r\n }\r\n }\r\n\r\n let rect = parentNode.getBoundingClientRect();\r\n\r\n return { offsetLeft: rect.left, offsetTop: rect.top };\r\n}\r\n\r\n/**\r\n * Disable user ability to select text on page\r\n */\r\nexport function disableUserSelect() {\r\n if (!userSelectStyleSheet.parentNode) {\r\n document.head.appendChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Enable user ability to select text on page\r\n */\r\nexport function enableUserSelect() {\r\n if (userSelectStyleSheet.parentNode) {\r\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\r\n }\r\n}\r\n\r\n/**\r\n * Get the metadata for a SVG container\r\n *\r\n * @param {SVGElement} svg The SVG container to get metadata for\r\n */\r\nexport function getMetadata(svg) {\r\n return {\r\n documentId: svg.getAttribute('data-pdf-annotate-document'),\r\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\r\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\r\n };\r\n}\r\n","import EventEmitter from 'events';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGAtPoint\r\n} from './utils';\r\n\r\nconst emitter = new EventEmitter();\r\n\r\nlet clickNode;\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\ndocument.addEventListener('click', function handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n\r\n // Emit annotation:blur if clickNode is no longer clicked\r\n if (clickNode && clickNode !== target) {\r\n emitter.emit('annotation:blur', clickNode);\r\n }\r\n\r\n // Emit annotation:click if target was clicked\r\n if (target) {\r\n emitter.emit('annotation:click', target);\r\n }\r\n\r\n clickNode = target;\r\n});\r\n\r\n// let mouseOverNode;\r\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\r\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n//\r\n// // Emit annotation:mouseout if target was mouseout'd\r\n// if (mouseOverNode && !target) {\r\n// emitter.emit('annotation:mouseout', mouseOverNode);\r\n// }\r\n//\r\n// // Emit annotation:mouseover if target was mouseover'd\r\n// if (target && mouseOverNode !== target) {\r\n// emitter.emit('annotation:mouseover', target);\r\n// }\r\n//\r\n// mouseOverNode = target;\r\n// });\r\n\r\nexport function fireEvent() { emitter.emit(...arguments); };\r\nexport function addEventListener() { emitter.on(...arguments); };\r\nexport function removeEventListener() { emitter.removeListener(...arguments); };\r\n","// Disable JSDoc as it cannot really deal with the odd way that the functions are defined\r\n/* eslint valid-jsdoc: 0 */\r\n\r\nimport abstractFunction from '../utils/abstractFunction';\r\nimport { fireEvent } from '../UI/event';\r\n\r\n// Adapter should never be invoked publicly\r\nexport default class StoreAdapter {\r\n /**\r\n * Create a new StoreAdapter instance\r\n *\r\n * @param {Object} [definition] The definition to use for overriding abstract methods\r\n */\r\n constructor(definition = {}) {\r\n // Copy each function from definition if it is a function we know about\r\n Object.keys(definition).forEach((key) => {\r\n if (typeof definition[key] === 'function' &&\r\n typeof this[key] === 'function') {\r\n this[key] = definition[key];\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Get all the annotations for a given document and page number.\r\n *\r\n * @param {String} documentId The ID for the document the annotations belong to\r\n * @param {Number} pageNumber The number of the page the annotations belong to\r\n * @return {Promise} Promise that returns with list of annotations for document and page\r\n */\r\n __getAnnotations(documentId, pageNumber) { abstractFunction('getAnnotations'); }\r\n get getAnnotations() { return this.__getAnnotations; }\r\n set getAnnotations(fn) {\r\n this.__getAnnotations = function getAnnotations(documentId, pageNumber) {\r\n return fn(...arguments).then((annotations) => {\r\n // TODO may be best to have this happen on the server\r\n if (annotations.annotations) {\r\n annotations.annotations.forEach((a) => {\r\n a.documentId = documentId;\r\n });\r\n }\r\n return annotations;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get the definition for a specific annotation.\r\n *\r\n * @param {String} documentId The ID for the document the annotation belongs to\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns the requested annotation\r\n */\r\n getAnnotation(documentId, annotationId) { abstractFunction('getAnnotation'); }\r\n\r\n /**\r\n * Add an annotation\r\n *\r\n * @param {String} documentId The ID for the document to add the annotation to\r\n * @param {String} pageNumber The page number to add the annotation to\r\n * @param {Object} annotation The definition for the new annotation\r\n * @return {Promise} Promise that returns with the added annotation\r\n */\r\n __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\r\n get addAnnotation() { return this.__addAnnotation; }\r\n set addAnnotation(fn) {\r\n this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:add', documentId, pageNumber, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Edit an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} pageNumber the page number of the annotation\r\n * @param {Object} annotation The definition of the modified annotation\r\n * @return {Promise} Promise that returns with the edited annotation\r\n */\r\n __editAnnotation(documentId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\r\n get editAnnotation() { return this.__editAnnotation; }\r\n set editAnnotation(fn) {\r\n this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:edit', documentId, annotationId, annotation);\r\n return annotation;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with boolean if annotation was deleted\r\n */\r\n __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); }\r\n get deleteAnnotation() { return this.__deleteAnnotation; }\r\n set deleteAnnotation(fn) {\r\n this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('annotation:delete', documentId, annotationId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Get all the comments for an annotation\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @return {Promise} Promise that returns with comments for annotation\r\n */\r\n getComments(documentId, annotationId) { abstractFunction('getComments'); }\r\n\r\n /**\r\n * Add a new comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} annotationId The ID for the annotation\r\n * @param {Object} content The definition of the comment\r\n * @return {Promise} Promise that returns with the added comment\r\n */\r\n __addComment(documentId, annotationId, content) { abstractFunction('addComment'); }\r\n get addComment() { return this.__addComment; }\r\n set addComment(fn) {\r\n this.__addComment = function addComment(documentId, annotationId, content) {\r\n return fn(...arguments).then((comment) => {\r\n fireEvent('comment:add', documentId, annotationId, comment);\r\n return comment;\r\n });\r\n };\r\n }\r\n\r\n /**\r\n * Delete a comment\r\n *\r\n * @param {String} documentId The ID for the document\r\n * @param {String} commentId The ID for the comment\r\n * @return {Promise} Promise that returns with boolean if comment was deleted\r\n */\r\n __deleteComment(documentId, commentId) { abstractFunction('deleteComment'); }\r\n get deleteComment() { return this.__deleteComment; }\r\n set deleteComment(fn) {\r\n this.__deleteComment = function deleteComment(documentId, commentId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('comment:delete', documentId, commentId);\r\n }\r\n return success;\r\n });\r\n };\r\n }\r\n}\r\n","const REGEXP = /[xy]/g;\r\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\r\n\r\nfunction replacement(c) {\r\n let r = Math.random() * 16 | 0;\r\n let v = c === 'x' ? r : (r & 0x3 | 0x8);\r\n return v.toString(16);\r\n}\r\n\r\n/**\r\n * Generate a univierally unique identifier\r\n *\r\n * @return {String} A UUID\r\n */\r\nexport default function uuid() {\r\n return PATTERN.replace(REGEXP, replacement);\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalStoreAdapter extends StoreAdapter {\r\n constructor() {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId)[findAnnotation(documentId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId);\r\n annotations[findAnnotation(documentId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = findAnnotation(documentId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content\r\n };\r\n\r\n let annotations = getAnnotations(documentId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n}\r\n\r\nfunction getAnnotations(documentId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, annotations) {\r\n localStorage.setItem(`${documentId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","import uuid from '../utils/uuid';\r\nimport StoreAdapter from './StoreAdapter';\r\n\r\n// StoreAdapter for working with localStorage and associated user id\r\n// This is ideal for testing, examples, and prototyping\r\nexport default class LocalUserStoreAdapter extends StoreAdapter {\r\n constructor(userId = 'user', globalEdit = false) {\r\n super({\r\n getAnnotations(documentId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAllAnnotations(documentId).filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n }\r\n });\r\n\r\n this._userId = userId;\r\n this._globalEdit = globalEdit;\r\n\r\n this.getAnnotation = (documentId, annotationId) => {\r\n return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]);\r\n };\r\n\r\n this.addAnnotation = (documentId, pageNumber, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n annotation.class = 'Annotation';\r\n annotation.uuid = uuid();\r\n annotation.page = pageNumber;\r\n annotation.userId = this._userId;\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.editAnnotation = (documentId, annotationId, annotation) => {\r\n return new Promise((resolve, reject) => {\r\n if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n reject('Non-matching userId');\r\n }\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation;\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n resolve(annotation);\r\n });\r\n };\r\n\r\n this.deleteAnnotation = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {};\r\n if (!annotation) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = findAnnotation(documentId, annotation.userId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId, annotation.userId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, annotation.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n\r\n this.getComments = (documentId, annotationId) => {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId, this._userId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n };\r\n\r\n this.addComment = (documentId, annotationId, content) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = {\r\n class: 'Comment',\r\n uuid: uuid(),\r\n annotation: annotationId,\r\n content: content,\r\n userId: this._userId\r\n };\r\n\r\n let annotations = getAnnotations(documentId, this._userId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, this._userId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n };\r\n\r\n this.deleteComment = (documentId, commentId) => {\r\n return new Promise((resolve, reject) => {\r\n let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {};\r\n if (!comment) {\r\n return reject('Could not find annotation');\r\n }\r\n else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) {\r\n return reject('Non-matching userId');\r\n }\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, comment.userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === commentId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n if (index > -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, comment.userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n };\r\n }\r\n\r\n get userId() {\r\n return this._userId;\r\n }\r\n}\r\n\r\nfunction getAllAnnotations(documentId) {\r\n let all_annotations = [];\r\n let re = new RegExp(`${documentId}/(.*)/annotations`);\r\n for (let i = 0; i < localStorage.length; i++) {\r\n if (localStorage.key(i).search(re) > -1) {\r\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\r\n }\r\n }\r\n return all_annotations;\r\n}\r\n\r\nfunction getAnnotations(documentId, userId) {\r\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\r\n}\r\n\r\nfunction updateAnnotations(documentId, userId, annotations) {\r\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\r\n}\r\n/**\r\n *\r\n * @param {String} documentId Document id of the annotation\r\n * @param {String} userId User id of the annotation\r\n * @param {String} annotationId The id of the annotation\r\n *\r\n * This function finds all the annotation made by one user.\r\n *\r\n * @return {int} The index of the annotation in localstorage\r\n */\r\nfunction findAnnotation(documentId, userId, annotationId) {\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, userId);\r\n for (let i = 0, l = annotations.length; i < l; i++) {\r\n if (annotations[i].uuid === annotationId) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n return index;\r\n}\r\n","export default {\r\n annotationLayerName: 'annotationLayer',\r\n textLayerName: 'textLayer',\r\n annotationSvgQuery: function() {\r\n return 'svg.' + this.annotationLayerName;\r\n },\r\n annotationClassQuery: function() {\r\n return '.' + this.annotationLayerName;\r\n },\r\n textClassQuery: function() {\r\n return '.' + this.textLayerName;\r\n }\r\n};\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport {\r\n addEventListener,\r\n removeEventListener\r\n} from './event';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGContainer,\r\n findSVGAtPoint,\r\n getOffsetAnnotationRect,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet isDragging = false;\r\nlet overlay;\r\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\r\nconst OVERLAY_BORDER_SIZE = 3;\r\n\r\n/**\r\n * Create an overlay for editing an annotation.\r\n *\r\n * @param {Element} target The annotation element to apply overlay for\r\n */\r\nfunction createEditOverlay(target) {\r\n destroyEditOverlay();\r\n\r\n overlay = document.createElement('div');\r\n let anchor = document.createElement('a');\r\n let parentNode = findSVGContainer(target).parentNode;\r\n let id = target.getAttribute('data-pdf-annotate-id');\r\n let rect = getOffsetAnnotationRect(target);\r\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\r\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\r\n\r\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\r\n overlay.setAttribute('data-target-id', id);\r\n overlay.style.boxSizing = 'content-box';\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${styleTop}px`;\r\n overlay.style.left = `${styleLeft}px`;\r\n overlay.style.width = `${rect.width}px`;\r\n overlay.style.height = `${rect.height}px`;\r\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\r\n overlay.style.zIndex = 20100;\r\n\r\n anchor.innerHTML = '×';\r\n anchor.setAttribute('href', 'javascript://');\r\n anchor.style.background = '#fff';\r\n anchor.style.borderRadius = '20px';\r\n anchor.style.border = '1px solid #bbb';\r\n anchor.style.color = '#bbb';\r\n anchor.style.fontSize = '16px';\r\n anchor.style.padding = '2px';\r\n anchor.style.textAlign = 'center';\r\n anchor.style.textDecoration = 'none';\r\n anchor.style.position = 'absolute';\r\n anchor.style.top = '-13px';\r\n anchor.style.right = '-13px';\r\n anchor.style.width = '25px';\r\n anchor.style.height = '25px';\r\n\r\n overlay.appendChild(anchor);\r\n parentNode.appendChild(overlay);\r\n document.addEventListener('click', handleDocumentClick);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n anchor.addEventListener('click', deleteAnnotation);\r\n anchor.addEventListener('mouseover', () => {\r\n anchor.style.color = '#35A4DC';\r\n anchor.style.borderColor = '#999';\r\n anchor.style.boxShadow = '0 1px 1px #ccc';\r\n });\r\n anchor.addEventListener('mouseout', () => {\r\n anchor.style.color = '#bbb';\r\n anchor.style.borderColor = '#bbb';\r\n anchor.style.boxShadow = '';\r\n });\r\n overlay.addEventListener('mouseover', () => {\r\n if (!isDragging) { anchor.style.display = ''; }\r\n });\r\n overlay.addEventListener('mouseout', () => {\r\n anchor.style.display = 'none';\r\n });\r\n}\r\n\r\n/**\r\n * Destroy the edit overlay if it exists.\r\n */\r\nfunction destroyEditOverlay() {\r\n if (overlay) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n }\r\n\r\n document.removeEventListener('click', handleDocumentClick);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Delete currently selected annotation\r\n */\r\nfunction deleteAnnotation() {\r\n if (!overlay) {\r\n return;\r\n }\r\n\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n\r\n destroyEditOverlay();\r\n}\r\n\r\n/**\r\n * Handle document.click event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentClick(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\r\n\r\n // Remove current overlay\r\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\r\n if (overlay) {\r\n if (isDragging || e.target === overlay) {\r\n return;\r\n }\r\n\r\n destroyEditOverlay();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\r\n let keyTest;\r\n if (e.key) {\r\n keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace';\r\n }\r\n else {\r\n keyTest = e.keyCode === 8 || e.keyCode === 46;\r\n }\r\n if (overlay && keyTest &&\r\n e.target.nodeName.toLowerCase() !== 'textarea' &&\r\n e.target.nodeName.toLowerCase() !== 'input') {\r\n e.preventDefault();\r\n deleteAnnotation();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n if (e.target !== overlay) {\r\n return;\r\n }\r\n\r\n // Highlight and strikeout annotations are bound to text within the document.\r\n // It doesn't make sense to allow repositioning these types of annotations.\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n\r\n if (type === 'highlight' || type === 'strikeout') { return; }\r\n\r\n isDragging = true;\r\n dragOffsetX = e.clientX;\r\n dragOffsetY = e.clientY;\r\n dragStartX = overlay.offsetLeft;\r\n dragStartY = overlay.offsetTop;\r\n\r\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\r\n overlay.style.cursor = 'move';\r\n overlay.querySelector('a').style.display = 'none';\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let parentNode = overlay.parentNode;\r\n let rect = parentNode.getBoundingClientRect();\r\n let y = (dragStartY + (e.clientY - dragOffsetY));\r\n let x = (dragStartX + (e.clientX - dragOffsetX));\r\n let minY = 0;\r\n let maxY = rect.height;\r\n let minX = 0;\r\n let maxX = rect.width;\r\n\r\n if (y > minY && y + overlay.offsetHeight < maxY) {\r\n overlay.style.top = `${y}px`;\r\n }\r\n\r\n if (x > minX && x + overlay.offsetWidth < maxX) {\r\n overlay.style.left = `${x}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let type = target[0].getAttribute('data-pdf-annotate-type');\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n overlay.querySelector('a').style.display = '';\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n let attribX = 'x';\r\n let attribY = 'y';\r\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n attribX = 'cx';\r\n attribY = 'cy';\r\n }\r\n\r\n if (type === 'point') {\r\n // Broken\r\n /*\r\n [...target].forEach((t, i) => {\r\n let moveTo = {\r\n x: overlay.offsetLeft + 3,\r\n y: overlay.offsetTop + 3\r\n };\r\n t.setAttribute(attribX, moveTo.x);\r\n t.setAttribute(attribY, moveTo.y);\r\n annotation[attribX] = moveTo.x;\r\n annotation[attribY] = moveTo.y;\r\n });\r\n */\r\n return;\r\n }\r\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n if (type === 'textbox') {\r\n target = [target[0].firstChild];\r\n }\r\n\r\n [...target].forEach((t, i) => {\r\n let modelX = parseInt(t.getAttribute(attribX), 10);\r\n let modelY = parseInt(t.getAttribute(attribY), 10);\r\n if (modelDelta.y !== 0) {\r\n modelY = modelY + modelDelta.y;\r\n\r\n t.setAttribute(attribY, modelY);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].y = modelY;\r\n }\r\n else if (annotation[attribY]) {\r\n annotation[attribY] = modelY;\r\n }\r\n }\r\n if (modelDelta.x !== 0) {\r\n modelX = modelX + modelDelta.x;\r\n\r\n t.setAttribute(attribX, modelX);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].x = modelX;\r\n }\r\n else if (annotation[attribX]) {\r\n annotation[attribX] = modelX;\r\n }\r\n }\r\n });\r\n }\r\n else if (type === 'strikeout') {\r\n return;\r\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\r\n // [...target].forEach(target, (t, i) => {\r\n // if (deltaY !== 0) {\r\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\r\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\r\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\r\n // }\r\n // if (deltaX !== 0) {\r\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\r\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\r\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\r\n // }\r\n // });\r\n }\r\n else if (type === 'drawing' || type === 'arrow') {\r\n // Do nothing as currently broken\r\n /*\r\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\r\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\r\n let modelDelta = {\r\n x: modelEnd[0] - modelStart[0],\r\n y: modelEnd[1] - modelStart[1]\r\n };\r\n\r\n annotation.lines.forEach((line, i) => {\r\n let [x, y] = annotation.lines[i];\r\n annotation.lines[i][0] = x + modelDelta.x;\r\n annotation.lines[i][1] = y + modelDelta.y;\r\n });\r\n\r\n target[0].parentNode.removeChild(target[0]);\r\n appendChild(svg, annotation);\r\n */\r\n return;\r\n }\r\n\r\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation);\r\n });\r\n\r\n setTimeout(() => {\r\n isDragging = false;\r\n }, 0);\r\n\r\n overlay.style.background = '';\r\n overlay.style.cursor = '';\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n enableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle annotation.click event\r\n *\r\n * @param {Element} e The annotation element that was clicked\r\n */\r\nfunction handleAnnotationClick(target) {\r\n createEditOverlay(target);\r\n}\r\n\r\n/**\r\n * Enable edit mode behavior.\r\n */\r\nexport function enableEdit() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n addEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n/**\r\n * Disable edit mode behavior.\r\n */\r\nexport function disableEdit() {\r\n destroyEditOverlay();\r\n\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n removeEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _candraw = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines = [];\r\n\r\n/**\r\n * Handle document.touchdown or document.pointerdown event\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerdown(e) {\r\n path = null;\r\n lines = [];\r\n if (!findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n _candraw = true;\r\n e.preventDefault();\r\n}\r\n\r\n/**\r\n * Handle document.pointerup event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerup(e) {\r\n saveToStorage(e.clientX, e.clientY);\r\n}\r\n\r\nfunction saveToStorage(x, y) {\r\n if (!_candraw) {\r\n return;\r\n }\r\n _candraw = false;\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'drawing',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {PointerEvent} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointermove(e) {\r\n if (!findSVGAtPoint(e.clientX, e.clientY) || !_candraw) {\r\n return;\r\n }\r\n savePoint(e.clientX, e.clientY);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {KeyboardEvent} e The DOM event to be handled\r\n * } e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n point[0] = point[0].toFixed(2);\r\n point[1] = point[1].toFixed(2);\r\n lines.push(point);\r\n\r\n if (lines.length <= 1) {\r\n return;\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'drawing',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen, rounded to 2 decimal places\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setPen(penSize = 1, penColor = '000000') {\r\n _penSize = Math.round(parseFloat(penSize) * 1e2) / 1e2;\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Return pen attributes of the pen\r\n *\r\n * @return {Object} Object with size and color\r\n */\r\nexport function getPen() {\r\n return {\r\n size: _penSize,\r\n color: _penColor\r\n };\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enablePen() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\r\n document.addEventListener('pointerdown', handleDocumentPointerdown);\r\n document.addEventListener('pointermove', handleDocumentPointermove);\r\n document.addEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disablePen() {\r\n if (!_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = false;\r\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\r\n document.removeEventListener('pointermove', handleDocumentPointermove);\r\n document.removeEventListener('pointerup', handleDocumentPointerup);\r\n\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n findSVGContainer,\r\n getMetadata,\r\n convertToSvgPoint,\r\n convertToScreenPoint,\r\n findAnnotationAtPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _penSize;\r\nlet _penColor;\r\nlet path;\r\nlet lines;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Handle document.mousedown event\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\r\n if (target === null) {\r\n return;\r\n }\r\n\r\n let type = target.getAttribute('data-pdf-annotate-type');\r\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\r\n return;\r\n }\r\n\r\n let svg = findSVGContainer(target);\r\n let { documentId } = getMetadata(svg);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => {\r\n if (annotation) {\r\n path = null;\r\n lines = [];\r\n\r\n let point = convertToScreenPoint([\r\n annotation.cx,\r\n annotation.cy\r\n ], svg);\r\n\r\n let rect = svg.getBoundingClientRect();\r\n\r\n originX = point[0] + rect.left;\r\n originY = point[1] + rect.top;\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, {\r\n type: 'arrow',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }).then((annotation) => {\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let x = lines.length === 0 ? originX : e.clientX;\r\n let y = lines.length === 0 ? originY : e.clientY;\r\n\r\n savePoint(x, y);\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n lines = null;\r\n path.parentNode.removeChild(path);\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n }\r\n}\r\n\r\n/**\r\n * Save a point to the line being drawn.\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n */\r\nfunction savePoint(x, y) {\r\n let svg = findSVGAtPoint(x, y);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let point = convertToSvgPoint([\r\n x - rect.left,\r\n y - rect.top\r\n ], svg);\r\n\r\n if (lines.length < 2) {\r\n lines.push(point);\r\n return;\r\n }\r\n else {\r\n lines[1] = point; // update end point\r\n }\r\n\r\n if (path) {\r\n svg.removeChild(path);\r\n }\r\n\r\n path = appendChild(svg, {\r\n type: 'arrow',\r\n color: _penColor,\r\n width: _penSize,\r\n lines\r\n });\r\n}\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} penSize The size of the lines drawn by the pen\r\n * @param {String} penColor The color of the lines drawn by the pen\r\n */\r\nexport function setArrow(penSize = 10, penColor = '0000FF') {\r\n _penSize = parseInt(penSize, 10);\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enableArrow() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Disable the pen behavior\r\n */\r\nexport function disableArrow() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n enableUserSelect();\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport {\r\n findAnnotationAtPoint,\r\n getMetadata\r\n} from './utils';\r\n\r\nlet _canerase = false;\r\nlet previousPoint = null;\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentDown(e) {\r\n _canerase = true;\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentUp(e) {\r\n _canerase = false;\r\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\r\n}\r\n\r\n/**\r\n *\r\n * @param {PointerEvent} e DOM event to handle\r\n */\r\nfunction handleDocumentMouseMove(e) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n // This algorithm attempts to get the various points between the last\r\n // PointerEvent and this one\r\n let check = [];\r\n let diffX = Math.abs(previousPoint[0] - e.clientX);\r\n let diffY = Math.abs(previousPoint[1] - e.clientY);\r\n if (diffX >= 1 || diffY >= 1) {\r\n let maxSteps = Math.round(Math.max(diffX, diffY));\r\n let subStepSize = Math.min(diffX, diffY) / maxSteps;\r\n let smallerTest = diffX < diffY;\r\n let startPoint = [\r\n Math.min(previousPoint[0], e.clientX),\r\n Math.min(previousPoint[1], e.clientY)\r\n ];\r\n for (let i = 0; i < maxSteps; i++) {\r\n if (smallerTest) {\r\n check.push([Math.round(startPoint[0] + (subStepSize * i)), Math.round(startPoint[1] + i)]);\r\n }\r\n else {\r\n check.push([Math.round(startPoint[0] + i), Math.round(startPoint[1] + (subStepSize * i))]);\r\n }\r\n }\r\n }\r\n for (let point of check) {\r\n erase(findAnnotationAtPoint(point[0], point[1]));\r\n }\r\n previousPoint = [e.clientX, e.clientY];\r\n}\r\n\r\nfunction erase(target) {\r\n if (!_canerase) {\r\n return;\r\n }\r\n\r\n if (target) {\r\n let { documentId } = getMetadata(target.parentElement);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => {\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n });\r\n }\r\n}\r\n\r\nexport function enableEraser() {\r\n document.addEventListener('pointermove', handleDocumentMouseMove);\r\n document.addEventListener('pointerdown', handleDocumentDown);\r\n document.addEventListener('pointerup', handleDocumentUp);\r\n}\r\n\r\nexport function disableEraser() {\r\n document.removeEventListener('pointermove', handleDocumentMouseMove);\r\n document.removeEventListener('pointerdown', handleDocumentDown);\r\n document.removeEventListener('pointerup', handleDocumentUp);\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n scaleDown\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} The DOM event to be handled\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n\r\n input = document.createElement('input');\r\n input.setAttribute('id', 'pdf-annotate-point-input');\r\n input.setAttribute('placeholder', 'Enter comment');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'absolute';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n savePoint();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13) {\r\n savePoint();\r\n }\r\n}\r\n\r\n/**\r\n * Save a new point annotation from input\r\n */\r\nfunction savePoint() {\r\n if (input.value.trim().length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let content = input.value.trim();\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n let annotation = Object.assign({\r\n type: 'point'\r\n }, scaleDown(svg, {\r\n x: clientX - rect.left,\r\n y: clientY - rect.top\r\n }));\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n PDFJSAnnotate.getStoreAdapter().addComment(\r\n documentId,\r\n annotation.uuid,\r\n content\r\n );\r\n\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input element\r\n */\r\nfunction closeInput() {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n}\r\n\r\n/**\r\n * Enable point annotation behavior\r\n */\r\nexport function enablePoint() {\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable point annotation behavior\r\n */\r\nexport function disablePoint() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n disableUserSelect,\r\n enableUserSelect,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgRect\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet overlay;\r\nlet originY;\r\nlet originX;\r\n\r\n/**\r\n * Get the current window selection as rects\r\n *\r\n * @return {Array} An Array of rects\r\n */\r\nfunction getSelectionRects() {\r\n try {\r\n let selection = window.getSelection();\r\n let range = selection.getRangeAt(0);\r\n let rects = range.getClientRects();\r\n\r\n if (rects.length > 0 &&\r\n rects[0].width > 0 &&\r\n rects[0].height > 0) {\r\n return rects;\r\n }\r\n }\r\n catch (e) {}\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Handle document.mousedown event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousedown(e) {\r\n let svg;\r\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\r\n return;\r\n }\r\n\r\n let rect = svg.getBoundingClientRect();\r\n originY = e.clientY;\r\n originX = e.clientX;\r\n\r\n overlay = document.createElement('div');\r\n overlay.style.position = 'absolute';\r\n overlay.style.top = `${originY - rect.top}px`;\r\n overlay.style.left = `${originX - rect.left}px`;\r\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\r\n overlay.style.borderRadius = '3px';\r\n svg.parentNode.appendChild(overlay);\r\n\r\n document.addEventListener('mousemove', handleDocumentMousemove);\r\n disableUserSelect();\r\n}\r\n\r\n/**\r\n * Handle document.mousemove event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMousemove(e) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n\r\n if (originX + (e.clientX - originX) < rect.right) {\r\n overlay.style.width = `${e.clientX - originX}px`;\r\n }\r\n\r\n if (originY + (e.clientY - originY) < rect.bottom) {\r\n overlay.style.height = `${e.clientY - originY}px`;\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let rects;\r\n if (_type !== 'area' && (rects = getSelectionRects())) {\r\n saveRect(_type, [...rects].map((r) => {\r\n return {\r\n top: r.top,\r\n left: r.left,\r\n width: r.width,\r\n height: r.height\r\n };\r\n }));\r\n }\r\n else if (_type === 'area' && overlay) {\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let rect = svg.getBoundingClientRect();\r\n saveRect(_type, [{\r\n top: parseInt(overlay.style.top, 10) + rect.top,\r\n left: parseInt(overlay.style.left, 10) + rect.left,\r\n width: parseInt(overlay.style.width, 10),\r\n height: parseInt(overlay.style.height, 10)\r\n }]);\r\n\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n enableUserSelect();\r\n }\r\n}\r\n\r\n/**\r\n * Handle document.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n // Cancel rect if Esc is pressed\r\n if (e.keyCode === 27) {\r\n let selection = window.getSelection();\r\n selection.removeAllRanges();\r\n if (overlay && overlay.parentNode) {\r\n overlay.parentNode.removeChild(overlay);\r\n overlay = null;\r\n document.removeEventListener('mousemove', handleDocumentMousemove);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Save a rect annotation\r\n *\r\n * @param {String} type The type of rect (area, highlight, strikeout)\r\n * @param {Array} rects The rects to use for annotation\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveRect(type, rects, color) {\r\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\r\n let annotation;\r\n\r\n if (!svg) {\r\n return;\r\n }\r\n\r\n let boundingRect = svg.getBoundingClientRect();\r\n\r\n if (!color) {\r\n if (type === 'highlight') {\r\n color = 'FFFF00';\r\n }\r\n else if (type === 'strikeout') {\r\n color = 'FF0000';\r\n }\r\n }\r\n\r\n // Initialize the annotation\r\n annotation = {\r\n type,\r\n color,\r\n rectangles: [...rects].map((r) => {\r\n let offset = 0;\r\n\r\n if (type === 'strikeout') {\r\n offset = r.height / 2;\r\n }\r\n\r\n return convertToSvgRect({\r\n y: (r.top + offset) - boundingRect.top,\r\n x: r.left - boundingRect.left,\r\n width: r.width,\r\n height: r.height\r\n }, svg);\r\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\r\n };\r\n\r\n // Short circuit if no rectangles exist\r\n if (annotation.rectangles.length === 0) {\r\n return;\r\n }\r\n\r\n // Special treatment for area as it only supports a single rect\r\n if (type === 'area') {\r\n let rect = annotation.rectangles[0];\r\n delete annotation.rectangles;\r\n annotation.x = rect.x;\r\n annotation.y = rect.y;\r\n annotation.width = rect.width;\r\n annotation.height = rect.height;\r\n }\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable rect behavior\r\n */\r\nexport function enableRect(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n document.addEventListener('mousedown', handleDocumentMousedown);\r\n document.addEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n/**\r\n * Disable rect behavior\r\n */\r\nexport function disableRect() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n document.removeEventListener('mousedown', handleDocumentMousedown);\r\n document.removeEventListener('keyup', handleDocumentKeyup);\r\n}\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet _type;\r\nlet _circleRadius = 10;\r\nlet _circleColor = '0000FF';\r\n\r\n/**\r\n * Set the attributes of the pen.\r\n *\r\n * @param {Number} circleRadius The radius of the circle\r\n * @param {String} circleColor The color of the circle\r\n */\r\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\r\n _circleRadius = parseInt(circleRadius, 10);\r\n _circleColor = circleColor;\r\n}\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n let svg = findSVGAtPoint(e.clientX, e.clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let rect = svg.getBoundingClientRect();\r\n saveCircle(svg, _type, {\r\n x: e.clientX - rect.left,\r\n y: e.clientY - rect.top\r\n }, _circleRadius, _circleColor);\r\n}\r\n\r\n/**\r\n * Save a circle annotation\r\n *\r\n * @param {SVGElement} svg\r\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\r\n * @param {Object} pt The point to use for annotation\r\n * @param {float} radius\r\n * @param {String} color The color of the rects\r\n */\r\nfunction saveCircle(svg, type, pt, radius, color) {\r\n // Initialize the annotation\r\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg);\r\n let annotation = {\r\n type,\r\n color,\r\n cx: svg_pt[0],\r\n cy: svg_pt[1],\r\n r: radius\r\n };\r\n\r\n let { documentId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n}\r\n\r\n/**\r\n * Enable circle behavior\r\n */\r\nexport function enableCircle(type) {\r\n _type = type;\r\n\r\n if (_enabled) { return; }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable circle behavior\r\n */\r\nexport function disableCircle() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\nexport function addCircle(type, e) {\r\n let oldType = _type;\r\n _type = type;\r\n handleDocumentMouseup(e);\r\n _type = oldType;\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport { appendChild } from '../render/appendChild';\r\nimport {\r\n BORDER_COLOR,\r\n findSVGAtPoint,\r\n getMetadata,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet input;\r\nlet _textSize = localStorage.getItem(`text/size`) || 12;\r\nlet _textColor = localStorage.getItem(`text/color`) || '#000000';\r\n\r\n/**\r\n * Handle document.mouseup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleDocumentMouseup(e) {\r\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\r\n return;\r\n }\r\n if (!e.srcElement.classList.contains('annotationLayer')) {\r\n return;\r\n }\r\n input = document.createElement('textarea');\r\n input.setAttribute('id', 'pdf-annotate-text-input');\r\n input.setAttribute('placeholder', 'Enter text... SHIFT + ENTER for new line');\r\n input.style.border = `3px solid ${BORDER_COLOR}`;\r\n input.style.borderRadius = '3px';\r\n input.style.position = 'fixed';\r\n input.style.top = `${e.clientY}px`;\r\n input.style.left = `${e.clientX}px`;\r\n input.style.fontSize = `${_textSize}px`;\r\n input.style.zIndex = '41';\r\n input.addEventListener('blur', handleInputBlur);\r\n input.addEventListener('keyup', handleInputKeyup);\r\n\r\n document.body.appendChild(input);\r\n input.focus();\r\n}\r\n\r\n/**\r\n * Handle input.blur event\r\n */\r\nfunction handleInputBlur() {\r\n saveText();\r\n}\r\n\r\n/**\r\n * Handle input.keyup event\r\n *\r\n * @param {Event} e The DOM event to handle\r\n */\r\nfunction handleInputKeyup(e) {\r\n if (e.keyCode === 27) {\r\n closeInput();\r\n }\r\n else if (e.keyCode === 13 && !e.shiftKey) {\r\n saveText();\r\n }\r\n}\r\n\r\n/**\r\n * Save a text annotation from input\r\n */\r\nfunction saveText() {\r\n let value = (input.value) ? input.value.replace(/ +$/, '') : '';\r\n if (value.length > 0) {\r\n let clientX = parseInt(input.style.left, 10);\r\n let clientY = parseInt(input.style.top, 10);\r\n let svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let height = _textSize;\r\n let { documentId, pageNumber, viewport } = getMetadata(svg);\r\n let scale = 1 / viewport.scale;\r\n let rect = svg.getBoundingClientRect();\r\n let pt = convertToSvgPoint([\r\n clientX - rect.left,\r\n clientY - rect.top + height], svg, viewport);\r\n let annotation = {\r\n type: 'textbox',\r\n size: _textSize * scale,\r\n color: _textColor,\r\n content: value,\r\n x: pt[0],\r\n y: pt[1],\r\n rotation: -viewport.rotation\r\n };\r\n\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)\r\n .then((annotation) => {\r\n appendChild(svg, annotation);\r\n });\r\n }\r\n\r\n closeInput();\r\n}\r\n\r\n/**\r\n * Close the input\r\n */\r\nfunction closeInput() {\r\n if (input) {\r\n input.removeEventListener('blur', handleInputBlur);\r\n input.removeEventListener('keyup', handleInputKeyup);\r\n document.body.removeChild(input);\r\n input = null;\r\n }\r\n}\r\n\r\n/**\r\n * Set the text attributes\r\n *\r\n * @param {Number} textSize The size of the text\r\n * @param {String} textColor The color of the text\r\n */\r\nexport function setText(textSize = 12, textColor = '000000') {\r\n _textSize = parseInt(textSize, 10);\r\n _textColor = textColor;\r\n}\r\n\r\n/**\r\n * Enable text behavior\r\n */\r\nexport function enableText() {\r\n if (_enabled) {\r\n return;\r\n }\r\n\r\n _enabled = true;\r\n document.addEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n/**\r\n * Disable text behavior\r\n */\r\nexport function disableText() {\r\n if (!_enabled) { return; }\r\n\r\n _enabled = false;\r\n document.removeEventListener('mouseup', handleDocumentMouseup);\r\n}\r\n\r\n","/**\r\n * Create a node that is only visible to screen readers\r\n *\r\n * @param {String} content The text content that should be read by screen reader\r\n * @param {String} [annotationId] The ID of the annotation assocaited\r\n * @return {Element} An Element that is only visible to screen readers\r\n */\r\nexport default function createScreenReaderOnly(content, annotationId) {\r\n let node = document.createElement('div');\r\n let text = document.createTextNode(content);\r\n node.appendChild(text);\r\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\r\n node.style.position = 'absolute';\r\n node.style.left = '-10000px';\r\n node.style.top = 'auto';\r\n node.style.width = '1px';\r\n node.style.height = '1px';\r\n node.style.overflow = 'hidden';\r\n return node;\r\n}\r\n","import config from '../config';\r\nimport {\r\n pointIntersectsRect,\r\n scaleUp,\r\n scaleDown\r\n} from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will only insert within an element amidst it's text content.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\r\n const OFFSET_ADJUST = 2;\r\n\r\n // If inserting before adjust `x` by looking for element a few px to the right\r\n // Otherwise adjust a few px to the left\r\n // This is to allow a little tolerance by searching within the box, instead\r\n // of getting a false negative by testing right on the border.\r\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\r\n\r\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\r\n if (!node) {\r\n return false;\r\n }\r\n\r\n // Now that node has been found inverse the adjustment for `x`.\r\n // This is done to accomodate tolerance by cutting off on the outside of the\r\n // text boundary, instead of missing a character by cutting off within.\r\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\r\n\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\r\n let temp = node.cloneNode(true);\r\n let head = temp.innerHTML.split('');\r\n let tail = [];\r\n\r\n // Insert temp off screen\r\n temp.style.position = 'absolute';\r\n temp.style.top = '-10000px';\r\n temp.style.left = '-10000px';\r\n document.body.appendChild(temp);\r\n\r\n while (head.length) {\r\n // Don't insert within HTML tags\r\n if (head[head.length - 1] === '>') {\r\n while (head.length) {\r\n tail.unshift(head.pop());\r\n if (tail[0] === '<') {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n // Check if width of temp based on current head value satisfies x\r\n temp.innerHTML = head.join('');\r\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\r\n if (left + width <= x) {\r\n break;\r\n }\r\n tail.unshift(head.pop());\r\n }\r\n\r\n // Update original node with new markup, including element to be inserted\r\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\r\n temp.parentNode.removeChild(temp);\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Get a text layer element at a given point on a page\r\n *\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page to limit elements to\r\n * @return {Element} First text layer element found at the point\r\n */\r\nfunction textLayerElementFromPoint(x, y, pageNumber) {\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\r\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\r\n })[0];\r\n}\r\n","import config from '../config';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport { pointIntersectsRect, scaleUp } from '../UI/utils';\r\n\r\n/**\r\n * Insert an element at a point within the document.\r\n * This algorithm will try to insert between elements if possible.\r\n * It will however use `insertElementWithinElement` if it is more accurate.\r\n *\r\n * @param {Element} el The element to be inserted\r\n * @param {Number} x The x coordinate of the point\r\n * @param {Number} y The y coordinate of the point\r\n * @param {Number} pageNumber The page number to limit elements to\r\n * @return {Boolean} True if element was able to be inserted, otherwise false\r\n */\r\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\r\n // Try and use most accurate method of inserting within an element\r\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\r\n return true;\r\n }\r\n\r\n // Fall back to inserting between elements\r\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\r\n let rect = svg.getBoundingClientRect();\r\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\r\n\r\n y = scaleUp(svg, {y}).y + rect.top;\r\n x = scaleUp(svg, {x}).x + rect.left;\r\n\r\n // Find the best node to insert before\r\n for (let i = 0, l = nodes.length; i < l; i++) {\r\n let n = nodes[i];\r\n let r = n.getBoundingClientRect();\r\n if (y <= r.top) {\r\n n.parentNode.insertBefore(el, n);\r\n return true;\r\n }\r\n }\r\n\r\n // If all else fails try to append to the bottom\r\n let textLayer = svg.parentNode.querySelector(config.textClassQuery());\r\n if (textLayer) {\r\n let textRect = textLayer.getBoundingClientRect();\r\n if (pointIntersectsRect(x, y, textRect)) {\r\n textLayer.appendChild(el);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n}\r\n","/**\r\n * Insert a comment into the DOM to be available by screen reader\r\n *\r\n * @param {Object} comment The comment to be inserted\r\n */\r\nexport default function insertScreenReaderComment(comment) {\r\n if (!comment) {\r\n return;\r\n }\r\n\r\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\r\n if (list) {\r\n let item = document.createElement('li');\r\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\r\n item.appendChild(document.createTextNode(`${comment.content}`));\r\n list.appendChild(item);\r\n }\r\n}\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\n\r\n/**\r\n * Insert the comments into the DOM to be available by screen reader\r\n *\r\n * Example output:\r\n *
\r\n *
Begin highlight 1
\r\n *
    \r\n *
  1. Foo
  2. \r\n *
  3. Bar
  4. \r\n *
  5. Baz
  6. \r\n *
  7. Qux
  8. \r\n *
\r\n *
\r\n *
Some highlighted text goes here...
\r\n *
End highlight 1
\r\n *\r\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of the annotation\r\n * @param {Array} [comments] Optionally preloaded comments to be rendered\r\n * @return {Promise} Promise that once has comments, render them for screen reader\r\n */\r\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\r\n let promise;\r\n\r\n if (Array.isArray(comments)) {\r\n promise = Promise.resolve(comments);\r\n }\r\n else {\r\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\r\n }\r\n\r\n return promise.then((comments) => {\r\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\r\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\r\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n if (node) {\r\n let list = document.createElement('ol');\r\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n list.setAttribute('aria-label', 'Comments');\r\n node.appendChild(list);\r\n comments.forEach(insertScreenReaderComment);\r\n }\r\n });\r\n}\r\n","import createScreenReaderOnly from './createScreenReaderOnly';\r\nimport insertElementWithinChildren from './insertElementWithinChildren';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\n\r\n// Annotation types that support comments\r\nconst COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle'];\r\n\r\n/**\r\n * Insert a hint into the DOM for screen readers for a specific annotation.\r\n *\r\n * @param {Object} annotation The annotation to insert a hint for\r\n * @param {Number} num The number of the annotation out of all annotations of the same type\r\n */\r\nexport default function insertScreenReaderHint(annotation, num = 0) {\r\n switch (annotation.type) {\r\n case 'highlight':\r\n case 'strikeout':\r\n let rects = annotation.rectangles;\r\n let first = rects[0];\r\n let last = rects[rects.length - 1];\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\r\n first.x, first.y, annotation.page, true\r\n );\r\n\r\n insertElementWithinElement(\r\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\r\n last.x + last.width, last.y, annotation.page, false\r\n );\r\n break;\r\n\r\n case 'textbox':\r\n case 'point':\r\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\r\n annotation.x, annotation.y, annotation.page\r\n );\r\n break;\r\n\r\n case 'drawing':\r\n case 'area':\r\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\r\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x, y, annotation.page\r\n );\r\n break;\r\n\r\n case 'circle':\r\n case 'fillcircle':\r\n case 'emptycircle':\r\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\r\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\r\n\r\n insertElementWithinChildren(\r\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\r\n x2, y2, annotation.page\r\n );\r\n break;\r\n }\r\n\r\n // Include comments in screen reader hint\r\n if (COMMENT_TYPES.includes(annotation.type)) {\r\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\r\n }\r\n}\r\n","import renderScreenReaderHints from './renderScreenReaderHints';\r\nimport insertScreenReaderComment from './insertScreenReaderComment';\r\nimport renderScreenReaderComments from './renderScreenReaderComments';\r\nimport { addEventListener } from '../UI/event';\r\nimport PDFJSAnnotate from '../PDFJSAnnotate';\r\n\r\n/**\r\n * Initialize the event handlers for keeping screen reader hints synced with data\r\n */\r\nexport default function initEventHandlers() {\r\n addEventListener('annotation:add', (documentId, pageNumber, annotation) => {\r\n reorderAnnotationsByType(documentId, pageNumber, annotation.type);\r\n });\r\n addEventListener('annotation:edit', (documentId, annotationId, annotation) => {\r\n reorderAnnotationsByType(documentId, annotation.page, annotation.type);\r\n });\r\n addEventListener('annotation:delete', removeAnnotation);\r\n addEventListener('comment:add', insertComment);\r\n addEventListener('comment:delete', removeComment);\r\n}\r\n\r\n/**\r\n * Reorder the annotation numbers by annotation type\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {Number} pageNumber The page number of the annotations\r\n * @param {Strig} type The annotation type\r\n */\r\nfunction reorderAnnotationsByType(documentId, pageNumber, type) {\r\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber)\r\n .then((annotations) => {\r\n return annotations.annotations.filter((a) => {\r\n return a.type === type;\r\n });\r\n })\r\n .then((annotations) => {\r\n annotations.forEach((a) => {\r\n removeAnnotation(documentId, a.uuid);\r\n });\r\n\r\n return annotations;\r\n })\r\n .then(renderScreenReaderHints);\r\n}\r\n\r\n/**\r\n * Remove the screen reader hint for an annotation\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The Id of the annotation\r\n */\r\nfunction removeAnnotation(documentId, annotationId) {\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\r\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\r\n}\r\n\r\n/**\r\n * Insert a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} annotationId The ID of tha assocated annotation\r\n * @param {Object} comment The comment to insert a hint for\r\n */\r\nfunction insertComment(documentId, annotationId, comment) {\r\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n let promise;\r\n\r\n if (!list) {\r\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\r\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\r\n return true;\r\n });\r\n }\r\n else {\r\n promise = Promise.resolve(true);\r\n }\r\n\r\n promise.then(() => {\r\n insertScreenReaderComment(comment);\r\n });\r\n}\r\n\r\n/**\r\n * Remove a screen reader hint for a comment\r\n *\r\n * @param {String} documentId The ID of the document\r\n * @param {String} commentId The ID of the comment\r\n */\r\nfunction removeComment(documentId, commentId) {\r\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\r\n}\r\n\r\n/**\r\n * Remove an element from the DOM by it's ID if it exists\r\n *\r\n * @param {String} elementId The ID of the element to be removed\r\n */\r\nfunction removeElementById(elementId) {\r\n let el = document.getElementById(elementId);\r\n if (el) {\r\n el.parentNode.removeChild(el);\r\n }\r\n}\r\n","import insertScreenReaderHint from './insertScreenReaderHint';\r\nimport initEventHandlers from './initEventHandlers';\r\n\r\n// TODO This is not the right place for this to live\r\ninitEventHandlers();\r\n\r\n/**\r\n * Insert hints into the DOM for screen readers.\r\n *\r\n * @param {Array} annotations The annotations that hints are inserted for\r\n */\r\nexport default function renderScreenReaderHints(annotations) {\r\n annotations = Array.isArray(annotations) ? annotations : [];\r\n\r\n // Insert hints for each type\r\n Object.keys(SORT_TYPES).forEach((type) => {\r\n let sortBy = SORT_TYPES[type];\r\n annotations\r\n .filter((a) => a.type === type)\r\n .sort(sortBy)\r\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\r\n });\r\n}\r\n\r\n// Sort annotations first by y, then by x.\r\n// This allows hints to be injected in the order they appear,\r\n// which makes numbering them easier.\r\nfunction sortByPoint(a, b) {\r\n if (a.y < b.y) {\r\n return a.x - b.x;\r\n }\r\n else {\r\n return 1;\r\n }\r\n}\r\n\r\n// Sort annotation by it's first rectangle\r\nfunction sortByRectPoint(a, b) {\r\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\r\n}\r\n\r\n// Sort annotation by it's first line\r\nfunction sortByLinePoint(a, b) {\r\n let lineA = a.lines[0];\r\n let lineB = b.lines[0];\r\n return sortByPoint(\r\n {x: lineA[0], y: lineA[1]},\r\n {x: lineB[0], y: lineB[1]}\r\n );\r\n}\r\n\r\n// Arrange supported types and associated sort methods\r\nconst SORT_TYPES = {\r\n 'highlight': sortByRectPoint,\r\n 'strikeout': sortByRectPoint,\r\n 'drawing': sortByLinePoint,\r\n 'textbox': sortByPoint,\r\n 'point': sortByPoint,\r\n 'area': sortByPoint\r\n};\r\n\r\n","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\r\n\r\n// Template for creating a new page\r\nconst PAGE_TEMPLATE = `\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n`;\r\n\r\n/**\r\n * Create a new page to be appended to the DOM.\r\n *\r\n * @param {Number} pageNumber The page number that is being created\r\n * @return {HTMLElement}\r\n */\r\nexport function createPage(pageNumber) {\r\n let temp = document.createElement('div');\r\n temp.innerHTML = PAGE_TEMPLATE;\r\n\r\n let page = temp.children[0];\r\n let canvas = page.querySelector('canvas');\r\n\r\n page.setAttribute('id', `pageContainer${pageNumber}`);\r\n page.setAttribute('data-page-number', pageNumber);\r\n\r\n canvas.mozOpaque = true;\r\n canvas.setAttribute('id', `page${pageNumber}`);\r\n\r\n return page;\r\n}\r\n\r\n/**\r\n * Render a page that has already been created.\r\n *\r\n * @param {Number} pageNumber The page number to be rendered\r\n * @param {Object} renderOptions The options for rendering\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: [pdfPage, annotations]\r\n * - rejected: Error\r\n */\r\nexport function renderPage(pageNumber, renderOptions) {\r\n let {\r\n documentId,\r\n pdfDocument,\r\n scale,\r\n rotate\r\n } = renderOptions;\r\n\r\n const eventBus = new pdfjsViewer.EventBus();\r\n\r\n // Load the page and annotations\r\n return Promise.all([\r\n pdfDocument.getPage(pageNumber),\r\n PDFJSAnnotate.getAnnotations(documentId, pageNumber)\r\n ]).then(([pdfPage, annotations]) => {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let canvasContext = canvas.getContext('2d', {alpha: false});\r\n let totalRotation = (rotate + pdfPage.rotate) % 360;\r\n let viewport = pdfPage.getViewport({scale: scale, rotation: totalRotation});\r\n let transform = scalePage(pageNumber, viewport, canvasContext);\r\n\r\n // Render the page\r\n return Promise.all([\r\n pdfPage.render({ canvasContext, viewport, transform }).promise,\r\n PDFJSAnnotate.render(svg, viewport, annotations)\r\n ]).then(() => {\r\n // Text content is needed for a11y, but is also necessary for creating\r\n // highlight and strikeout annotations which require selecting text.\r\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\r\n return new Promise((resolve, reject) => {\r\n // Render text layer for a11y of text content\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let textLayerFactory = new pdfjsViewer.DefaultTextLayerFactory();\r\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(\r\n textLayer,\r\n pageNumber - 1,\r\n viewport,\r\n false,\r\n eventBus\r\n );\r\n textLayerBuilder.setTextContent(textContent);\r\n textLayerBuilder.render();\r\n\r\n // Enable a11y for annotations\r\n // Timeout is needed to wait for `textLayerBuilder.render`\r\n setTimeout(() => {\r\n try {\r\n renderScreenReaderHints(annotations.annotations);\r\n resolve();\r\n }\r\n catch (e) {\r\n reject(e);\r\n }\r\n });\r\n });\r\n });\r\n }).then(() => {\r\n // Indicate that the page was loaded\r\n page.setAttribute('data-loaded', 'true');\r\n\r\n return [pdfPage, annotations];\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Scale the elements of a page.\r\n *\r\n * @param {Number} pageNumber The page number to be scaled\r\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\r\n * @param {Object} context The canvas context that the PDF page is rendered to\r\n * @return {Array} The transform data for rendering the PDF page\r\n */\r\nfunction scalePage(pageNumber, viewport, context) {\r\n let page = document.getElementById(`pageContainer${pageNumber}`);\r\n let canvas = page.querySelector('.canvasWrapper canvas');\r\n let svg = page.querySelector(config.annotationClassQuery());\r\n let wrapper = page.querySelector('.canvasWrapper');\r\n let textLayer = page.querySelector(config.textClassQuery());\r\n let outputScale = getOutputScale(context);\r\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\r\n let sfx = approximateFraction(outputScale.sx);\r\n let sfy = approximateFraction(outputScale.sy);\r\n\r\n // Adjust width/height for scale\r\n page.style.visibility = '';\r\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\r\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\r\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\r\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\r\n svg.setAttribute('width', viewport.width);\r\n svg.setAttribute('height', viewport.height);\r\n svg.style.width = `${viewport.width}px`;\r\n svg.style.height = `${viewport.height}px`;\r\n page.style.width = `${viewport.width}px`;\r\n page.style.height = `${viewport.height}px`;\r\n wrapper.style.width = `${viewport.width}px`;\r\n wrapper.style.height = `${viewport.height}px`;\r\n textLayer.style.width = `${viewport.width}px`;\r\n textLayer.style.height = `${viewport.height}px`;\r\n\r\n return transform;\r\n}\r\n\r\n/**\r\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\r\n *\r\n * @param {Number} x Positive float number\r\n * @return {Array} Estimated fraction: the first array item is a numerator,\r\n * the second one is a denominator.\r\n */\r\nfunction approximateFraction(x) {\r\n // Fast path for int numbers or their inversions.\r\n if (Math.floor(x) === x) {\r\n return [x, 1];\r\n }\r\n\r\n const xinv = 1 / x;\r\n const limit = 8;\r\n if (xinv > limit) {\r\n return [1, limit];\r\n }\r\n else if (Math.floor(xinv) === xinv) {\r\n return [1, xinv];\r\n }\r\n\r\n const x_ = x > 1 ? xinv : x;\r\n\r\n // a/b and c/d are neighbours in Farey sequence.\r\n let a = 0; let b = 1; let c = 1; let d = 1;\r\n\r\n // Limit search to order 8.\r\n while (true) {\r\n // Generating next term in sequence (order of q).\r\n let p = a + c; let q = b + d;\r\n if (q > limit) {\r\n break;\r\n }\r\n if (x_ <= p / q) {\r\n c = p; d = q;\r\n }\r\n else {\r\n a = p; b = q;\r\n }\r\n }\r\n\r\n // Select closest of neighbours to x.\r\n if (x_ - a / b < c / d - x_) {\r\n return x_ === x ? [a, b] : [b, a];\r\n }\r\n else {\r\n return x_ === x ? [c, d] : [d, c];\r\n }\r\n}\r\n\r\nfunction getOutputScale(ctx) {\r\n let devicePixelRatio = window.devicePixelRatio || 1;\r\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\r\n ctx.mozBackingStorePixelRatio ||\r\n ctx.msBackingStorePixelRatio ||\r\n ctx.oBackingStorePixelRatio ||\r\n ctx.backingStorePixelRatio || 1;\r\n let pixelRatio = devicePixelRatio / backingStoreRatio;\r\n return {\r\n sx: pixelRatio,\r\n sy: pixelRatio,\r\n scaled: pixelRatio !== 1\r\n };\r\n}\r\n\r\nfunction roundToDivide(x, div) {\r\n let r = x % div;\r\n return r === 0 ? x : Math.round(x - r + div);\r\n}\r\n","import { addEventListener, removeEventListener, fireEvent } from './event';\r\nimport { disableEdit, enableEdit } from './edit';\r\nimport { disablePen, enablePen, setPen } from './pen';\r\nimport { disableArrow, enableArrow, setArrow } from './arrow';\r\nimport { disableEraser, enableEraser } from './eraser';\r\nimport { disablePoint, enablePoint } from './point';\r\nimport { disableRect, enableRect } from './rect';\r\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\r\nimport { disableText, enableText, setText } from './text';\r\nimport { createPage, renderPage } from './page';\r\n\r\nexport default {\r\n addEventListener,\r\n removeEventListener,\r\n fireEvent,\r\n\r\n disableEdit,\r\n enableEdit,\r\n\r\n disablePen,\r\n enablePen,\r\n setPen,\r\n\r\n disablePoint,\r\n enablePoint,\r\n\r\n disableRect,\r\n enableRect,\r\n\r\n disableCircle,\r\n enableCircle,\r\n setCircle,\r\n addCircle,\r\n\r\n disableArrow,\r\n enableArrow,\r\n setArrow,\r\n\r\n disableEraser,\r\n enableEraser,\r\n\r\n disableText,\r\n enableText,\r\n setText,\r\n\r\n createPage,\r\n renderPage\r\n};\r\n","import StoreAdapter from './adapter/StoreAdapter';\r\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\r\nimport LocalUserStoreAdapter from './adapter/LocalUserStoreAdapter';\r\nimport render from './render';\r\nimport UI from './UI';\r\nimport config from './config';\r\nimport uuid from './utils/uuid';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint\r\n} from './UI/utils';\r\n\r\nexport default {\r\n findAnnotationAtPoint,\r\n findSVGContainer,\r\n convertToScreenPoint,\r\n\r\n /**\r\n * Abstract class that needs to be defined so PDFJSAnnotate\r\n * knows how to communicate with your server.\r\n */\r\n StoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage.\r\n */\r\n LocalStoreAdapter,\r\n\r\n /**\r\n * Implementation of StoreAdapter that stores annotation data to localStorage particular\r\n * to a specific user\r\n */\r\n LocalUserStoreAdapter,\r\n\r\n /**\r\n * Abstract instance of StoreAdapter\r\n */\r\n __storeAdapter: new StoreAdapter(),\r\n\r\n /**\r\n * Getter for the underlying StoreAdapter property\r\n *\r\n * @return {StoreAdapter}\r\n */\r\n getStoreAdapter() {\r\n return this.__storeAdapter;\r\n },\r\n\r\n /**\r\n * Setter for the underlying StoreAdapter property\r\n *\r\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\r\n */\r\n setStoreAdapter(adapter) {\r\n // TODO this throws an error when bundled\r\n // if (!(adapter instanceof StoreAdapter)) {\r\n // throw new Error('adapter must be an instance of StoreAdapter');\r\n // }\r\n\r\n this.__storeAdapter = adapter;\r\n },\r\n\r\n /**\r\n * UI is a helper for instrumenting UI interactions for creating,\r\n * editing, and deleting annotations in the browser.\r\n */\r\n UI,\r\n\r\n /**\r\n * Render the annotations for a page in the PDF Document\r\n *\r\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\r\n * @param {PageViewport} viewport The PDFPage.getViewport data\r\n * @param {Object} data The StoreAdapter.getAnnotations data\r\n * @return {Promise}\r\n */\r\n render,\r\n\r\n /**\r\n * Convenience method for getting annotation data\r\n *\r\n * @alias StoreAdapter.getAnnotations\r\n * @param {String} documentId The ID of the document\r\n * @param {String} pageNumber The page number\r\n * @return {Promise}\r\n */\r\n getAnnotations(documentId, pageNumber) {\r\n return this.getStoreAdapter().getAnnotations(...arguments);\r\n },\r\n\r\n config,\r\n\r\n uuid\r\n};\r\n","import { appendChild, transformChild } from './appendChild';\r\n\r\n/**\r\n * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG\r\n *\r\n * @param {SVGElement} svg The SVG element to render the annotations to\r\n * @param {Object} viewport The page viewport data\r\n * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations\r\n * @return {Promise} Settled once rendering has completed\r\n * A settled Promise will be either:\r\n * - fulfilled: SVGElement\r\n * - rejected: Error\r\n */\r\nexport default function render(svg, viewport, data) {\r\n return new Promise((resolve, reject) => {\r\n // Reset the content of the SVG\r\n svg.setAttribute('data-pdf-annotate-container', true);\r\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\r\n svg.removeAttribute('data-pdf-annotate-document');\r\n svg.removeAttribute('data-pdf-annotate-page');\r\n\r\n // If there's no data nothing can be done\r\n if (!data) {\r\n svg.innerHTML = '';\r\n return resolve(svg);\r\n }\r\n\r\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\r\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\r\n\r\n // Make sure annotations is an array\r\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\r\n return resolve(svg);\r\n }\r\n\r\n // Append or transform annotation to svg\r\n data.annotations.forEach((a) => {\r\n let node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\r\n if (node) {\r\n transformChild(svg, node, viewport);\r\n }\r\n else {\r\n appendChild(svg, a, viewport);\r\n }\r\n });\r\n\r\n resolve(svg);\r\n });\r\n}\r\n","import PDFJSAnnotate from './src/PDFJSAnnotate';\r\n\r\nexport default PDFJSAnnotate;\r\n"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index ef209449..137880ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@submitty/pdf-annotate.js", - "version": "24.6.5", + "version": "24.6.6", "description": "Annotation layer for pdf.js", "main": "index.js", "types": "types", @@ -11,7 +11,6 @@ "startindocker": "./scripts/web-docker", "build": "webpack && MINIFY=1 webpack", "codecov": "codecov", - "prepublishOnly": "npm run build && npm run types", "types": "tsc" }, "repository": {