diff --git a/.gitignore b/.gitignore index d4c4395f..7e146feb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ dist/pdf-annotate.js dist/pdf-annotate.js.map dist/pdf-annotate.min.js dist/pdf-annotate.min.js.map +.DS_Store +.idea/ diff --git a/.travis.yml b/.travis.yml index 53b84704..7fa36954 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ node_js: - '10' addons: + chrome: stable firefox: latest install: @@ -17,7 +18,8 @@ before_script: - sh -e /etc/init.d/xvfb start script: - - npm run-script build + - npm test + - npm run build #after_script: # - npm run coveralls diff --git a/dist/pdf-annotate.js b/dist/pdf-annotate.js index f263314a..d672b015 100644 --- a/dist/pdf-annotate.js +++ b/dist/pdf-annotate.js @@ -7,7 +7,7 @@ exports["PDFAnnotate"] = factory(); else root["PDFAnnotate"] = factory(); -})(this, function() { +})(typeof self !== 'undefined' ? self : this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -16,21 +16,21 @@ return /******/ (function(modules) { // webpackBootstrap /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) +/******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; -/******/ +/******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded -/******/ module.loaded = true; +/******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; @@ -43,4928 +43,5174 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(0); +/******/ return __webpack_require__(__webpack_require__.s = 15); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.default = _PDFJSAnnotate2.default; - module.exports = exports['default']; - -/***/ }, +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _StoreAdapter = __webpack_require__(8); + +var _StoreAdapter2 = _interopRequireDefault(_StoreAdapter); + +var _LocalStoreAdapter = __webpack_require__(27); + +var _LocalStoreAdapter2 = _interopRequireDefault(_LocalStoreAdapter); + +var _render = __webpack_require__(28); + +var _render2 = _interopRequireDefault(_render); + +var _UI = __webpack_require__(32); + +var _UI2 = _interopRequireDefault(_UI); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _uuid = __webpack_require__(10); + +var _uuid2 = _interopRequireDefault(_uuid); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = { + findAnnotationAtPoint: _utils.findAnnotationAtPoint, + findSVGContainer: _utils.findSVGContainer, + convertToScreenPoint: _utils.convertToScreenPoint, + + /** + * Abstract class that needs to be defined so PDFJSAnnotate + * knows how to communicate with your server. + */ + StoreAdapter: _StoreAdapter2.default, + + /** + * Implementation of StoreAdapter that stores annotation data to localStorage. + */ + LocalStoreAdapter: _LocalStoreAdapter2.default, + + /** + * Abstract instance of StoreAdapter + */ + __storeAdapter: new _StoreAdapter2.default(), + + /** + * Getter for the underlying StoreAdapter property + * + * @return {StoreAdapter} + */ + getStoreAdapter: function getStoreAdapter() { + return this.__storeAdapter; + }, + + + /** + * Setter for the underlying StoreAdapter property + * + * @param {StoreAdapter} adapter The StoreAdapter implementation to be used. + */ + setStoreAdapter: function setStoreAdapter(adapter) { + // TODO this throws an error when bundled + // if (!(adapter instanceof StoreAdapter)) { + // throw new Error('adapter must be an instance of StoreAdapter'); + // } + + this.__storeAdapter = adapter; + }, + + + /** + * UI is a helper for instrumenting UI interactions for creating, + * editing, and deleting annotations in the browser. + */ + UI: _UI2.default, + + /** + * Render the annotations for a page in the PDF Document + * + * @param {SVGElement} svg The SVG element that annotations should be rendered to + * @param {PageViewport} viewport The PDFPage.getViewport data + * @param {Object} data The StoreAdapter.getAnnotations data + * @return {Promise} + */ + render: _render2.default, + + /** + * Convenience method for getting annotation data + * + * @alias StoreAdapter.getAnnotations + * @param {String} documentId The ID of the document + * @param {String} pageNumber The page number + * @return {Promise} + */ + getAnnotations: function getAnnotations(documentId, userId, pageNumber) { + var _getStoreAdapter; + + return (_getStoreAdapter = this.getStoreAdapter()).getAnnotations.apply(_getStoreAdapter, arguments); + }, + + + config: _config2.default, + + uuid: _uuid2.default +}; +module.exports = exports['default']; + +/***/ }), /* 1 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _StoreAdapter = __webpack_require__(2); - - var _StoreAdapter2 = _interopRequireDefault(_StoreAdapter); - - var _LocalStoreAdapter = __webpack_require__(20); - - var _LocalStoreAdapter2 = _interopRequireDefault(_LocalStoreAdapter); - - var _render = __webpack_require__(22); - - var _render2 = _interopRequireDefault(_render); - - var _UI = __webpack_require__(32); - - var _UI2 = _interopRequireDefault(_UI); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _uuid = __webpack_require__(21); - - var _uuid2 = _interopRequireDefault(_uuid); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.default = { - findAnnotationAtPoint: _utils.findAnnotationAtPoint, - findSVGContainer: _utils.findSVGContainer, - convertToScreenPoint: _utils.convertToScreenPoint, - - /** - * Abstract class that needs to be defined so PDFJSAnnotate - * knows how to communicate with your server. - */ - StoreAdapter: _StoreAdapter2.default, - - /** - * Implementation of StoreAdapter that stores annotation data to localStorage. - */ - LocalStoreAdapter: _LocalStoreAdapter2.default, - - /** - * Abstract instance of StoreAdapter - */ - __storeAdapter: new _StoreAdapter2.default(), - - /** - * Getter for the underlying StoreAdapter property - * - * @return {StoreAdapter} - */ - getStoreAdapter: function getStoreAdapter() { - return this.__storeAdapter; - }, - - - /** - * Setter for the underlying StoreAdapter property - * - * @param {StoreAdapter} adapter The StoreAdapter implementation to be used. - */ - setStoreAdapter: function setStoreAdapter(adapter) { - // TODO this throws an error when bundled - // if (!(adapter instanceof StoreAdapter)) { - // throw new Error('adapter must be an instance of StoreAdapter'); - // } - - this.__storeAdapter = adapter; - }, - - - /** - * UI is a helper for instrumenting UI interactions for creating, - * editing, and deleting annotations in the browser. - */ - UI: _UI2.default, - - /** - * Render the annotations for a page in the PDF Document - * - * @param {SVGElement} svg The SVG element that annotations should be rendered to - * @param {PageViewport} viewport The PDFPage.getViewport data - * @param {Object} data The StoreAdapter.getAnnotations data - * @return {Promise} - */ - render: _render2.default, - - /** - * Convenience method for getting annotation data - * - * @alias StoreAdapter.getAnnotations - * @param {String} documentId The ID of the document - * @param {String} pageNumber The page number - * @return {Promise} - */ - getAnnotations: function getAnnotations(documentId, userId, pageNumber) { - var _getStoreAdapter; - - return (_getStoreAdapter = this.getStoreAdapter()).getAnnotations.apply(_getStoreAdapter, arguments); - }, - - - config: _config2.default, - - uuid: _uuid2.default - }; - module.exports = exports['default']; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _abstractFunction = __webpack_require__(3); - - var _abstractFunction2 = _interopRequireDefault(_abstractFunction); - - var _event = __webpack_require__(4); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - // Adapter should never be invoked publicly - var StoreAdapter = function () { - /** - * Create a new StoreAdapter instance - * - * @param {Object} [definition] The definition to use for overriding abstract methods - */ - function StoreAdapter() { - var _this = this; - - var definition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - _classCallCheck(this, StoreAdapter); - - // Copy each function from definition if it is a function we know about - Object.keys(definition).forEach(function (key) { - if (typeof definition[key] === 'function' && typeof _this[key] === 'function') { - _this[key] = definition[key]; - } - }); - } - - /** - * Get all the annotations for a given document and page number. - * - * @param {String} documentId The ID for the document the annotations belong to - * @param {String} userId The user makeing changes to this document - * @param {Number} pageNumber The number of the page the annotations belong to - * @return {Promise} - */ - - - _createClass(StoreAdapter, [{ - key: '__getAnnotations', - value: function __getAnnotations(documentId, userId, pageNumber) { - (0, _abstractFunction2.default)('getAnnotations'); - } - }, { - key: 'getAnnotation', - - - /** - * Get the definition for a specific annotation. - * - * @param {String} documentId The ID for the document the annotation belongs to - * @param {String} annotationId The ID for the annotation - * @return {Promise} - */ - value: function getAnnotation(documentId, annotationId) { - (0, _abstractFunction2.default)('getAnnotation'); - } - - /** - * Add an annotation - * - * @param {String} documentId The ID for the document to add the annotation to - * @param {String} pageNumber The page number to add the annotation to - * @param {Object} annotation The definition for the new annotation - * @return {Promise} - */ - - }, { - key: '__addAnnotation', - value: function __addAnnotation(documentId, userId, pageNumber, annotation) { - (0, _abstractFunction2.default)('addAnnotation'); - } - }, { - key: '__editAnnotation', - - - /** - * Edit an annotation - * - * @param {String} documentId The ID for the document - * @param {String} pageNumber the page number of the annotation - * @param {Object} annotation The definition of the modified annotation - * @return {Promise} - */ - value: function __editAnnotation(documentId, pageNumber, annotation) { - (0, _abstractFunction2.default)('editAnnotation'); - } - }, { - key: '__deleteAnnotation', - - - /** - * Delete an annotation - * - * @param {String} documentId The ID for the document - * @param {String} annotationId The ID for the annotation - * @return {Promise} - */ - value: function __deleteAnnotation(documentId, annotationId) { - (0, _abstractFunction2.default)('deleteAnnotation'); - } - }, { - key: 'getComments', - - - /** - * Get all the comments for an annotation - * - * @param {String} documentId The ID for the document - * @param {String} annotationId The ID for the annotation - * @return {Promise} - */ - value: function getComments(documentId, annotationId) { - (0, _abstractFunction2.default)('getComments'); - } - - /** - * Add a new comment - * - * @param {String} documentId The ID for the document - * @param {String} annotationId The ID for the annotation - * @param {Object} content The definition of the comment - * @return {Promise} - */ - - }, { - key: '__addComment', - value: function __addComment(documentId, annotationId, content) { - (0, _abstractFunction2.default)('addComment'); - } - }, { - key: '__deleteComment', - - - /** - * Delete a comment - * - * @param {String} documentId The ID for the document - * @param {String} commentId The ID for the comment - * @return {Promise} - */ - value: function __deleteComment(documentId, commentId) { - (0, _abstractFunction2.default)('deleteComment'); - } - }, { - key: 'getAnnotations', - get: function get() { - return this.__getAnnotations; - }, - set: function set(fn) { - this.__getAnnotations = function getAnnotations(documentId, userId, pageNumber) { - return fn.apply(undefined, arguments).then(function (annotations) { - // TODO may be best to have this happen on the server - if (annotations.annotations) { - annotations.annotations.forEach(function (a) { - a.documentId = documentId; - }); - } - return annotations; - }); - }; - } - }, { - key: 'addAnnotation', - get: function get() { - return this.__addAnnotation; - }, - set: function set(fn) { - this.__addAnnotation = function addAnnotation(documentId, userId, pageNumber, annotation) { - return fn.apply(undefined, arguments).then(function (annotation) { - (0, _event.fireEvent)('annotation:add', documentId, userId, pageNumber, annotation); - return annotation; - }); - }; - } - }, { - key: 'editAnnotation', - get: function get() { - return this.__editAnnotation; - }, - set: function set(fn) { - this.__editAnnotation = function editAnnotation(documentId, annotationId, annotation) { - return fn.apply(undefined, arguments).then(function (annotation) { - (0, _event.fireEvent)('annotation:edit', documentId, annotationId, annotation); - return annotation; - }); - }; - } - }, { - key: 'deleteAnnotation', - get: function get() { - return this.__deleteAnnotation; - }, - set: function set(fn) { - this.__deleteAnnotation = function deleteAnnotation(documentId, userId, annotationId) { - return fn.apply(undefined, arguments).then(function (success) { - if (success) { - (0, _event.fireEvent)('annotation:delete', documentId, userId, annotationId); - } - return success; - }); - }; - } - }, { - key: 'addComment', - get: function get() { - return this.__addComment; - }, - set: function set(fn) { - this.__addComment = function addComment(documentId, annotationId, content) { - return fn.apply(undefined, arguments).then(function (comment) { - (0, _event.fireEvent)('comment:add', documentId, annotationId, comment); - return comment; - }); - }; - } - }, { - key: 'deleteComment', - get: function get() { - return this.__deleteComment; - }, - set: function set(fn) { - this.__deleteComment = function deleteComment(documentId, commentId) { - return fn.apply(undefined, arguments).then(function (success) { - if (success) { - (0, _event.fireEvent)('comment:delete', documentId, commentId); - } - return success; - }); - }; - } - }]); - - return StoreAdapter; - }(); - - exports.default = StoreAdapter; - module.exports = exports['default']; - -/***/ }, -/* 3 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = abstractFunction; - /** - * Throw an Error for an abstract function that hasn't been implemented. - * - * @param {String} name The name of the abstract function - */ - function abstractFunction(name) { - throw new Error(name + ' is not implemented'); - } - module.exports = exports['default']; +/***/ (function(module, exports, __webpack_require__) { -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.fireEvent = fireEvent; - exports.addEventListener = addEventListener; - exports.removeEventListener = removeEventListener; - - var _events = __webpack_require__(5); - - var _events2 = _interopRequireDefault(_events); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var emitter = new _events2.default(); - - var clickNode = void 0; - - /** - * Handle document.click event - * - * @param {Event} e The DOM event to be handled - */ - document.addEventListener('click', function handleDocumentClick(e) { - if (!(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { - return; - } - - var target = (0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY); - - // Emit annotation:blur if clickNode is no longer clicked - if (clickNode && clickNode !== target) { - emitter.emit('annotation:blur', clickNode); - } - - // Emit annotation:click if target was clicked - if (target) { - emitter.emit('annotation:click', target); - } - - clickNode = target; - }); - - // let mouseOverNode; - // document.addEventListener('mousemove', function handleDocumentMousemove(e) { - // let target = findAnnotationAtPoint(e.clientX, e.clientY); - // - // // Emit annotation:mouseout if target was mouseout'd - // if (mouseOverNode && !target) { - // emitter.emit('annotation:mouseout', mouseOverNode); - // } - // - // // Emit annotation:mouseover if target was mouseover'd - // if (target && mouseOverNode !== target) { - // emitter.emit('annotation:mouseover', target); - // } - // - // mouseOverNode = target; - // }); - - function fireEvent() { - emitter.emit.apply(emitter, arguments); - }; - function addEventListener() { - emitter.on.apply(emitter, arguments); - }; - function removeEventListener() { - emitter.removeListener.apply(emitter, arguments); - }; - -/***/ }, -/* 5 */ -/***/ function(module, exports) { - - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; - } - module.exports = EventEmitter; - - // Backwards-compat with node 0.10.x - EventEmitter.EventEmitter = EventEmitter; - - EventEmitter.prototype._events = undefined; - EventEmitter.prototype._maxListeners = undefined; - - // By default EventEmitters will print a warning if more than 10 listeners are - // added to it. This is a useful default which helps finding memory leaks. - EventEmitter.defaultMaxListeners = 10; - - // Obviously not all Emitters should be limited to 10. This function allows - // that to be increased. Set to zero for unlimited. - EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; - }; - - EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; - }; - - EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; - }; - - EventEmitter.prototype.on = EventEmitter.prototype.addListener; - - EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; - }; - - // emits a 'removeListener' event iff the listener was removed - EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; - }; - - EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; - }; - - EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; - }; - - EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; - }; - - EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); - }; - - function isFunction(arg) { - return typeof arg === 'function'; - } - - function isNumber(arg) { - return typeof arg === 'number'; - } - - function isObject(arg) { - return typeof arg === 'object' && arg !== null; - } - - function isUndefined(arg) { - return arg === void 0; - } +"use strict"; -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.BORDER_COLOR = undefined; - exports.findSVGContainer = findSVGContainer; - exports.findSVGAtPoint = findSVGAtPoint; - exports.findAnnotationAtPoint = findAnnotationAtPoint; - exports.pointIntersectsRect = pointIntersectsRect; - exports.getOffsetAnnotationRect = getOffsetAnnotationRect; - exports.scaleUp = scaleUp; - exports.convertToSvgRect = convertToSvgRect; - exports.convertToSvgPoint = convertToSvgPoint; - exports.convertToScreenPoint = convertToScreenPoint; - exports.scaleDown = scaleDown; - exports.getScroll = getScroll; - exports.getOffset = getOffset; - exports.disableUserSelect = disableUserSelect; - exports.enableUserSelect = enableUserSelect; - exports.getMetadata = getMetadata; - - var _createStylesheet = __webpack_require__(7); - - var _createStylesheet2 = _interopRequireDefault(_createStylesheet); - - var _appendChild = __webpack_require__(8); - - var _mathUtils = __webpack_require__(19); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var BORDER_COLOR = exports.BORDER_COLOR = '#00BFFF'; - - var userSelectStyleSheet = (0, _createStylesheet2.default)({ - body: { - '-webkit-user-select': 'none', - '-moz-user-select': 'none', - '-ms-user-select': 'none', - 'user-select': 'none' - } - }); - userSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true'); - - /** - * Find the SVGElement that contains all the annotations for a page - * - * @param {Element} node An annotation within that container - * @return {SVGElement} The container SVG or null if it can't be found - */ - function findSVGContainer(node) { - var parentNode = node; - - while ((parentNode = parentNode.parentNode) && parentNode !== document) { - if (parentNode.nodeName.toUpperCase() === 'SVG' && parentNode.getAttribute('data-pdf-annotate-container') === 'true') { - return parentNode; - } - } - - return null; - } - - /** - * Find an SVGElement container at a given point - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @return {SVGElement} The container SVG or null if one can't be found - */ - function findSVGAtPoint(x, y) { - var elements = document.querySelectorAll('svg[data-pdf-annotate-container="true"]'); - - for (var i = 0, l = elements.length; i < l; i++) { - var el = elements[i]; - var rect = el.getBoundingClientRect(); - - if (pointIntersectsRect(x, y, rect)) { - return el; - } - } - - return null; - } - - /** - * Find an Element that represents an annotation at a given point. - * - * IMPORTANT: Requires the annotation layer to be the top most element so - * either use z-ordering or make it the leaf container. - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @return {Element} The annotation element or null if one can't be found - */ - function findAnnotationAtPoint(x, y) { - var el = null; - var candidate = document.elementFromPoint(x, y); - while (!el && candidate && candidate !== document) { - var type = candidate.getAttribute('data-pdf-annotate-type'); - if (type) { - el = candidate; - } - candidate = candidate.parentNode; - } - return el; - } - - /** - * Determine if a point intersects a rect - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @param {Object} rect The points of a rect (likely from getBoundingClientRect) - * @return {Boolean} True if a collision occurs, otherwise false - */ - function pointIntersectsRect(x, y, rect) { - return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right; - } - - /** - * Get the rect of an annotation element accounting for offset. - * - * @param {Element} el The element to get the rect of - * @return {Object} The dimensions of the element - */ - function getOffsetAnnotationRect(el) { - var rect = el.getBoundingClientRect(); - - var _getOffset = getOffset(el), - offsetLeft = _getOffset.offsetLeft, - offsetTop = _getOffset.offsetTop; - - return { - top: rect.top - offsetTop, - left: rect.left - offsetLeft, - right: rect.right - offsetLeft, - bottom: rect.bottom - offsetTop, - width: rect.width, - height: rect.height - }; - } - - /** - * Adjust scale from normalized scale (100%) to rendered scale. - * - * @param {SVGElement} svg The SVG to gather metadata from - * @param {Object} rect A map of numeric values to scale - * @return {Object} A copy of `rect` with values scaled up - */ - function scaleUp(svg, rect) { - var result = {}; - - var _getMetadata = getMetadata(svg), - viewport = _getMetadata.viewport; - - Object.keys(rect).forEach(function (key) { - result[key] = rect[key] * viewport.scale; - }); - - return result; - } - - function convertToSvgRect(rect, svg, viewport) { - var pt1 = [rect.x, rect.y]; - var pt2 = [rect.x + rect.width, rect.y + rect.height]; - - pt1 = convertToSvgPoint(pt1, svg, viewport); - pt2 = convertToSvgPoint(pt2, svg, viewport); - - return { - x: Math.min(pt1[0], pt2[0]), - y: Math.min(pt1[1], pt2[1]), - width: Math.abs(pt2[0] - pt1[0]), - height: Math.abs(pt2[1] - pt1[1]) - }; - } - - function convertToSvgPoint(pt, svg, viewport) { - var result = {}; - viewport = viewport || getMetadata(svg).viewport; - - var xform = [1, 0, 0, 1, 0, 0]; - xform = (0, _mathUtils.scale)(xform, viewport.scale, viewport.scale); - xform = (0, _mathUtils.rotate)(xform, viewport.rotation); - - var offset = (0, _appendChild.getTranslation)(viewport); - xform = (0, _mathUtils.translate)(xform, offset.x, offset.y); - - return (0, _mathUtils.applyInverseTransform)(pt, xform); - } - - function convertToScreenPoint(pt, svg, viewport) { - var result = {}; - viewport = viewport || getMetadata(svg).viewport; - - var xform = [1, 0, 0, 1, 0, 0]; - xform = (0, _mathUtils.scale)(xform, viewport.scale, viewport.scale); - xform = (0, _mathUtils.rotate)(xform, viewport.rotation); - - var offset = (0, _appendChild.getTranslation)(viewport); - xform = (0, _mathUtils.translate)(xform, offset.x, offset.y); - - return (0, _mathUtils.applyTransform)(pt, xform); - } - - /** - * Adjust scale from rendered scale to a normalized scale (100%). - * - * @param {SVGElement} svg The SVG to gather metadata from - * @param {Object} rect A map of numeric values to scale - * @return {Object} A copy of `rect` with values scaled down - */ - function scaleDown(svg, rect) { - var result = {}; - - var _getMetadata2 = getMetadata(svg), - viewport = _getMetadata2.viewport; - - Object.keys(rect).forEach(function (key) { - result[key] = rect[key] / viewport.scale; - }); - - return result; - } - - /** - * Get the scroll position of an element, accounting for parent elements - * - * @param {Element} el The element to get the scroll position for - * @return {Object} The scrollTop and scrollLeft position - */ - function getScroll(el) { - var scrollTop = 0; - var scrollLeft = 0; - var parentNode = el; - - while ((parentNode = parentNode.parentNode) && parentNode !== document) { - scrollTop += parentNode.scrollTop; - scrollLeft += parentNode.scrollLeft; - } - - return { scrollTop: scrollTop, scrollLeft: scrollLeft }; - } - - /** - * Get the offset position of an element, accounting for parent elements - * - * @param {Element} el The element to get the offset position for - * @return {Object} The offsetTop and offsetLeft position - */ - function getOffset(el) { - var parentNode = el; - - while ((parentNode = parentNode.parentNode) && parentNode !== document) { - if (parentNode.nodeName.toUpperCase() === 'SVG') { - break; - } - } - - var rect = parentNode.getBoundingClientRect(); - - return { offsetLeft: rect.left, offsetTop: rect.top }; - } - - /** - * Disable user ability to select text on page - */ - function disableUserSelect() { - if (!userSelectStyleSheet.parentNode) { - document.head.appendChild(userSelectStyleSheet); - } - } - - /** - * Enable user ability to select text on page - */ - function enableUserSelect() { - if (userSelectStyleSheet.parentNode) { - userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet); - } - } - - /** - * Get the metadata for a SVG container - * - * @param {SVGElement} svg The SVG container to get metadata for - */ - function getMetadata(svg) { - return { - documentId: svg.getAttribute('data-pdf-annotate-document'), - userId: svg.getAttribute('data-pdf-annotate-user'), - pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10), - viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')) - }; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.BORDER_COLOR = undefined; +exports.findSVGContainer = findSVGContainer; +exports.findSVGAtPoint = findSVGAtPoint; +exports.findAnnotationAtPoint = findAnnotationAtPoint; +exports.pointIntersectsRect = pointIntersectsRect; +exports.getOffsetAnnotationRect = getOffsetAnnotationRect; +exports.scaleUp = scaleUp; +exports.convertToSvgRect = convertToSvgRect; +exports.convertToSvgPoint = convertToSvgPoint; +exports.convertToScreenPoint = convertToScreenPoint; +exports.scaleDown = scaleDown; +exports.getScroll = getScroll; +exports.getOffset = getOffset; +exports.disableUserSelect = disableUserSelect; +exports.enableUserSelect = enableUserSelect; +exports.getMetadata = getMetadata; -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - module.exports = function createStyleSheet(blocks) { - var style = document.createElement('style'); - var text = Object.keys(blocks).map(function (selector) { - return processRuleSet(selector, blocks[selector]); - }).join('\n'); - - style.setAttribute('type', 'text/css'); - style.appendChild(document.createTextNode(text)); - - return style; - } - - function processRuleSet(selector, block) { - return selector + ' {\n' + processDeclarationBlock(block) + '\n}'; - } - - function processDeclarationBlock(block) { - return Object.keys(block).map(function (prop) { - return processDeclaration(prop, block[prop]); - }).join('\n'); - } - - function processDeclaration(prop, value) { - if (!isNaN(value) && value != 0) { - value = value + 'px'; - } - - return hyphenate(prop) + ': ' + value + ';'; - } - - function hyphenate(prop) { - return prop.replace(/[A-Z]/g, function (match) { - return '-' + match.toLowerCase(); - }); - } +var _createStylesheet = __webpack_require__(18); +var _createStylesheet2 = _interopRequireDefault(_createStylesheet); -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.getTranslation = getTranslation; - exports.appendChild = appendChild; - exports.transformChild = transformChild; - - var _objectAssign = __webpack_require__(9); - - var _objectAssign2 = _interopRequireDefault(_objectAssign); - - var _renderLine = __webpack_require__(10); - - var _renderLine2 = _interopRequireDefault(_renderLine); - - var _renderPath = __webpack_require__(13); - - var _renderPath2 = _interopRequireDefault(_renderPath); - - var _renderPoint = __webpack_require__(14); - - var _renderPoint2 = _interopRequireDefault(_renderPoint); - - var _renderRect = __webpack_require__(15); - - var _renderRect2 = _interopRequireDefault(_renderRect); - - var _renderText = __webpack_require__(16); - - var _renderText2 = _interopRequireDefault(_renderText); - - var _renderCircle = __webpack_require__(17); - - var _renderCircle2 = _interopRequireDefault(_renderCircle); - - var _renderArrow = __webpack_require__(18); - - var _renderArrow2 = _interopRequireDefault(_renderArrow); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var isFirefox = /firefox/i.test(navigator.userAgent); - - /** - * Get the x/y translation to be used for transforming the annotations - * based on the rotation of the viewport. - * - * @param {Object} viewport The viewport data from the page - * @return {Object} - */ - function getTranslation(viewport) { - var x = void 0; - var y = void 0; - - // Modulus 360 on the rotation so that we only - // have to worry about four possible values. - switch (viewport.rotation % 360) { - case 0: - x = y = 0; - break; - case 90: - x = 0; - y = viewport.width / viewport.scale * -1; - break; - case 180: - x = viewport.width / viewport.scale * -1; - y = viewport.height / viewport.scale * -1; - break; - case 270: - x = viewport.height / viewport.scale * -1; - y = 0; - break; - } - - return { x: x, y: y }; - } - - /** - * Transform the rotation and scale of a node using SVG's native transform attribute. - * - * @param {Node} node The node to be transformed - * @param {Object} viewport The page's viewport data - * @return {Node} - */ - function transform(node, viewport) { - var trans = getTranslation(viewport); - - // Let SVG natively transform the element - node.setAttribute('transform', 'scale(' + viewport.scale + ') rotate(' + viewport.rotation + ') translate(' + trans.x + ', ' + trans.y + ')'); - - // Manually adjust x/y for nested SVG nodes - if (!isFirefox && node.nodeName.toLowerCase() === 'svg') { - node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale); - node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale); - - var x = parseInt(node.getAttribute('x', 10)); - var y = parseInt(node.getAttribute('y', 10)); - var width = parseInt(node.getAttribute('width'), 10); - var height = parseInt(node.getAttribute('height'), 10); - var path = node.querySelector('path'); - var svg = path.parentNode; - - // Scale width/height - [node, svg, path, node.querySelector('rect')].forEach(function (n) { - n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale); - n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale); - }); - - // Transform path but keep scale at 100% since it will be handled natively - transform(path, (0, _objectAssign2.default)({}, viewport, { scale: 1 })); - - switch (viewport.rotation % 360) { - case 90: - node.setAttribute('x', viewport.width - y - width); - node.setAttribute('y', x); - svg.setAttribute('x', 1); - svg.setAttribute('y', 0); - break; - case 180: - node.setAttribute('x', viewport.width - x - width); - node.setAttribute('y', viewport.height - y - height); - svg.setAttribute('y', 2); - break; - case 270: - node.setAttribute('x', y); - node.setAttribute('y', viewport.height - x - height); - svg.setAttribute('x', -1); - svg.setAttribute('y', 0); - break; - } - } - - return node; - } - - /** - * Append an annotation as a child of an SVG. - * - * @param {SVGElement} svg The SVG element to append the annotation to - * @param {Object} annotation The annotation definition to render and append - * @param {Object} viewport The page's viewport data - * @return {SVGElement} A node that was created and appended by this function - */ - function appendChild(svg, annotation, viewport) { - if (!viewport) { - viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')); - } - - var child = void 0; - switch (annotation.type) { - case 'area': - case 'highlight': - child = (0, _renderRect2.default)(annotation); - break; - case 'circle': - case 'fillcircle': - case 'emptycircle': - child = (0, _renderCircle2.default)(annotation); - break; - case 'strikeout': - child = (0, _renderLine2.default)(annotation); - break; - case 'point': - child = (0, _renderPoint2.default)(annotation); - break; - case 'textbox': - child = (0, _renderText2.default)(annotation); - break; - case 'drawing': - child = (0, _renderPath2.default)(annotation); - break; - case 'arrow': - child = (0, _renderArrow2.default)(annotation); - break; - } - - // If no type was provided for an annotation it will result in node being null. - // Skip appending/transforming if node doesn't exist. - if (child) { - // Set attributes - child.setAttribute('data-pdf-annotate-id', annotation.uuid); - child.setAttribute('data-pdf-annotate-type', annotation.type); - child.setAttribute('data-pdf-annotate-userId', annotation.userId); - child.setAttribute('aria-hidden', true); - - svg.appendChild(transform(child, viewport)); - } - - return child; - } - - /** - * Transform a child annotation of an SVG. - * - * @param {SVGElement} svg The SVG element with the child annotation - * @param {Object} child The SVG child to transform - * @param {Object} viewport The page's viewport data - * @return {SVGElement} A node that was transformed by this function - */ - function transformChild(svg, child, viewport) { - if (!viewport) { - viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')); - } - - // If no type was provided for an annotation it will result in node being null. - // Skip transforming if node doesn't exist. - if (child) { - child = transform(child, viewport); - } - - return child; - } - - exports.default = { - /** - * Get the x/y translation to be used for transforming the annotations - * based on the rotation of the viewport. - */ - getTranslation: getTranslation, - - /** - * Append an SVG child for an annotation - */ - appendChild: appendChild, - - /** - * Transform an existing SVG child - */ - transformChild: transformChild - }; - -/***/ }, -/* 9 */ -/***/ function(module, exports) { - - /* - object-assign - (c) Sindre Sorhus - @license MIT - */ - - 'use strict'; - /* eslint-disable no-unused-vars */ - var getOwnPropertySymbols = Object.getOwnPropertySymbols; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var propIsEnumerable = Object.prototype.propertyIsEnumerable; - - function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); - } - - function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line no-new-wrappers - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (err) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } - } - - module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (getOwnPropertySymbols) { - symbols = getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; - }; +var _appendChild = __webpack_require__(2); +var _mathUtils = __webpack_require__(9); -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderLine; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create SVGLineElements from an annotation definition. - * This is used for anntations of type `strikeout`. - * - * @param {Object} a The annotation definition - * @return {SVGGElement} A group of all lines to be rendered - */ - function renderLine(a) { - var group = document.createElementNS('http://www.w3.org/2000/svg', 'g'); - (0, _setAttributes2.default)(group, { - stroke: (0, _normalizeColor2.default)(a.color || '#f00'), - strokeWidth: 1 - }); - - a.rectangles.forEach(function (r) { - var line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); - - (0, _setAttributes2.default)(line, { - x1: r.x, - y1: r.y, - x2: r.x + r.width, - y2: r.y - }); - - group.appendChild(line); - }); - - return group; - } - module.exports = exports['default']; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/***/ }, -/* 11 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = setAttributes; - var UPPER_REGEX = /[A-Z]/g; - - // Don't convert these attributes from camelCase to hyphenated-attributes - var BLACKLIST = ['viewBox']; - - var keyCase = function keyCase(key) { - if (BLACKLIST.indexOf(key) === -1) { - key = key.replace(UPPER_REGEX, function (match) { - return '-' + match.toLowerCase(); - }); - } - return key; - }; - - /** - * Set attributes for a node from a map - * - * @param {Node} node The node to set attributes on - * @param {Object} attributes The map of key/value pairs to use for attributes - */ - function setAttributes(node, attributes) { - Object.keys(attributes).forEach(function (key) { - node.setAttribute(keyCase(key), attributes[key]); - }); - } - module.exports = exports['default']; +var BORDER_COLOR = exports.BORDER_COLOR = '#00BFFF'; -/***/ }, -/* 12 */ -/***/ function(module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = normalizeColor; - var REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i; - - /** - * Normalize a color value - * - * @param {String} color The color to normalize - * @return {String} - */ - function normalizeColor(color) { - if (REGEX_HASHLESS_HEX.test(color)) { - color = "#" + color; - } - return color; - } - module.exports = exports["default"]; +var userSelectStyleSheet = (0, _createStylesheet2.default)({ + body: { + '-webkit-user-select': 'none', + '-moz-user-select': 'none', + '-ms-user-select': 'none', + 'user-select': 'none' + } +}); +userSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true'); -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderPath; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create SVGPathElement from an annotation definition. - * This is used for anntations of type `drawing`. - * - * @param {Object} a The annotation definition - * @return {SVGPathElement} The path to be rendered - */ - function renderPath(a) { - var d = []; - var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - - for (var i = 0, l = a.lines.length; i < l; i++) { - var p1 = a.lines[i]; - var p2 = a.lines[i + 1]; - if (p2) { - d.push('M' + p1[0] + ' ' + p1[1] + ' ' + p2[0] + ' ' + p2[1]); - } - } - - /* - - if(a.lines.length>2) { - var p1 = a.lines[0]; - var p2 = a.lines[a.lines.length-1]; - - var p3 = []; //arrow - var p4 = []; - var p0 = []; //arrow intersection - - - - if (p2) { - var k = -(p2[0]-p1[0])/(p2[1]-p1[1]); - - var deltaX = 3; - p0[0] = p1[0]+0.8*(p2[0]-p1[0]); - p0[1] = p1[1]+0.8*(p2[1]-p1[1]); - - p3[0] = p0[0] + deltaX; - p3[1] = p0[1] + k*deltaX; - - p4[0] = p0[0] - deltaX; - p4[1] = p0[1] - k*deltaX; - - if(Math.abs(p2[1]-p1[1]) < 20) { - - p3[0] = p0[0] ; - p3[1] = p0[1] + deltaX*1; - - p4[0] = p0[0] ; - p4[1] = p0[1] - deltaX*1; - - } - - d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`); - //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`); - d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`); - d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`); - d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`); - } - }*/ - - (0, _setAttributes2.default)(path, { - d: d.join(' ') + 'Z', - stroke: (0, _normalizeColor2.default)(a.color || '#000'), - strokeWidth: a.width || 1, - fill: 'none' - }); - - return path; - } - module.exports = exports['default']; +/** + * Find the SVGElement that contains all the annotations for a page + * + * @param {Element} node An annotation within that container + * @return {SVGElement} The container SVG or null if it can't be found + */ +function findSVGContainer(node) { + var parentNode = node; -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderPoint; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var SIZE = 25; - var 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'; - - /** - * Create SVGElement from an annotation definition. - * This is used for anntations of type `comment`. - * - * @param {Object} a The annotation definition - * @return {SVGElement} A svg to be rendered - */ - function renderPoint(a) { - var outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - var innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); - var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - - (0, _setAttributes2.default)(outerSVG, { - width: SIZE, - height: SIZE, - x: a.x, - y: a.y - }); - - (0, _setAttributes2.default)(innerSVG, { - width: SIZE, - height: SIZE, - x: 0, - y: SIZE * 0.05 * -1, - viewBox: '0 0 1000 1000' - }); - - (0, _setAttributes2.default)(rect, { - width: SIZE, - height: SIZE, - stroke: '#000', - fill: '#ff0' - }); - - (0, _setAttributes2.default)(path, { - d: D, - strokeWidth: 50, - stroke: '#000', - fill: '#fff' - }); - - innerSVG.appendChild(path); - outerSVG.appendChild(rect); - outerSVG.appendChild(innerSVG); - - return outerSVG; - } - module.exports = exports['default']; + while ((parentNode = parentNode.parentNode) && parentNode !== document) { + if (parentNode.nodeName.toUpperCase() === 'SVG' && parentNode.getAttribute('data-pdf-annotate-container') === 'true') { + return parentNode; + } + } -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderRect; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create SVGRectElements from an annotation definition. - * This is used for anntations of type `area` and `highlight`. - * - * @param {Object} a The annotation definition - * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered - */ - function renderRect(a) { - if (a.type === 'highlight') { - var group = document.createElementNS('http://www.w3.org/2000/svg', 'g'); - (0, _setAttributes2.default)(group, { - fill: (0, _normalizeColor2.default)(a.color || '#ff0'), - fillOpacity: 0.2 - }); - - a.rectangles.forEach(function (r) { - group.appendChild(createRect(r)); - }); - - return group; - } else { - var rect = createRect(a); - (0, _setAttributes2.default)(rect, { - stroke: (0, _normalizeColor2.default)(a.color || '#f00'), - fill: 'none' - }); - - return rect; - } - } - - function createRect(r) { - var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); - - (0, _setAttributes2.default)(rect, { - x: r.x, - y: r.y, - width: r.width, - height: r.height - }); - - return rect; - } - module.exports = exports['default']; + return null; +} -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderText; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create SVGTextElement from an annotation definition. - * This is used for anntations of type `textbox`. - * - * @param {Object} a The annotation definition - * @return {SVGTextElement} A text to be rendered - */ - function renderText(a) { - - // Text should be rendered at 0 degrees relative to - // document rotation - var text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - var x = a.x; - var y = a.y; - - (0, _setAttributes2.default)(text, { - x: x, - y: y, - fill: (0, _normalizeColor2.default)(a.color || '#000'), - fontSize: a.size, - transform: 'rotate(' + a.rotation + ', ' + x + ', ' + y + ')' - }); - text.innerHTML = a.content; - - var g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); - g.appendChild(text); - - return g; - } - module.exports = exports['default']; +/** + * Find an SVGElement container at a given point + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @return {SVGElement} The container SVG or null if one can't be found + */ +function findSVGAtPoint(x, y) { + var elements = document.querySelectorAll('svg[data-pdf-annotate-container="true"]'); -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderCircle; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create an SVGCircleElement from an annotation definition. - * This is used for annotations of type `circle`. - * - * @param {Object} a The annotation definition - * @return {SVGGElement|SVGCircleElement} A circle to be rendered - */ - function renderCircle(a) { - var circle = createCircle(a); - var color = (0, _normalizeColor2.default)(a.color || '#f00'); - - if (a.type === 'circle') (0, _setAttributes2.default)(circle, { - stroke: color, - fill: 'none', - 'stroke-width': 5 - }); - if (a.type === 'emptycircle') (0, _setAttributes2.default)(circle, { - stroke: color, - fill: 'none', - 'stroke-width': 2 - }); - - if (a.type === 'fillcircle') (0, _setAttributes2.default)(circle, { - stroke: color, - fill: color, - 'stroke-width': 5 - }); - - return circle; - } - - function createCircle(a) { - var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); - (0, _setAttributes2.default)(circle, { - cx: a.cx, - cy: a.cy, - r: a.r - }); - - return circle; - } - module.exports = exports['default']; + for (var i = 0, l = elements.length; i < l; i++) { + var el = elements[i]; + var rect = el.getBoundingClientRect(); -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderArrow; - - var _setAttributes = __webpack_require__(11); - - var _setAttributes2 = _interopRequireDefault(_setAttributes); - - var _normalizeColor = __webpack_require__(12); - - var _normalizeColor2 = _interopRequireDefault(_normalizeColor); - - var _mathUtils = __webpack_require__(19); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Create SVGPathElement from an annotation definition. - * This is used for anntations of type `drawing`. - * - * @param {Object} a The annotation definition - * @return {SVGPathElement} The path to be rendered - */ - function renderArrow(a) { - var d = []; - var arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon'); - - if (a.lines.length == 2) { - var p1 = a.lines[0]; - var p2 = a.lines[a.lines.length - 1]; - - var arrowLength = 40; - var pt0 = (0, _mathUtils.makePoint)(p1[0], p1[1], 0); - var pt1 = (0, _mathUtils.makePoint)(p2[0], p2[1], 0); - var x = (0, _mathUtils.makeVectorFromPoints)(pt0, pt1); - var unitX = (0, _mathUtils.unitVector)(x); - pt1 = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)(unitX, arrowLength)); - x = (0, _mathUtils.makeVectorFromPoints)(pt0, pt1); - var unitZ = (0, _mathUtils.makeVector)(0, 0, 1); - var unitY = (0, _mathUtils.unitVector)((0, _mathUtils.crossProduct)(unitX, unitZ)); - var thickness = a.width || 10; - - var A = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)(unitY, thickness * 0.5)); - var B = (0, _mathUtils.addVector)(A, (0, _mathUtils.multiplyVector)(unitX, (0, _mathUtils.magnitude)(x) - thickness * 2.0)); - var C = (0, _mathUtils.addVector)(B, (0, _mathUtils.multiplyVector)(unitY, thickness)); - var D = pt1; - var G = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)((0, _mathUtils.negateVector)(unitY), thickness * 0.5)); - var F = (0, _mathUtils.addVector)(G, (0, _mathUtils.multiplyVector)(unitX, (0, _mathUtils.magnitude)(x) - thickness * 2.0)); - var E = (0, _mathUtils.addVector)(F, (0, _mathUtils.multiplyVector)((0, _mathUtils.negateVector)(unitY), thickness)); - - var points = '' + A.x + ',' + A.y + ' ' + B.x + ',' + B.y + ' ' + C.x + ',' + C.y + ' ' + D.x + ',' + D.y + ' ' + E.x + ',' + E.y + ' ' + F.x + ',' + F.y + ' ' + G.x + ',' + G.y; - - (0, _setAttributes2.default)(arrow, { - points: points, - stroke: (0, _normalizeColor2.default)(a.color || '#000'), - fill: (0, _normalizeColor2.default)(a.color || '#000') - }); - } - - return arrow; - } - module.exports = exports['default']; + if (pointIntersectsRect(x, y, rect)) { + return el; + } + } -/***/ }, -/* 19 */ -/***/ function(module, exports) { - - "use strict"; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.applyTransform = applyTransform; - exports.applyInverseTransform = applyInverseTransform; - exports.transform = transform; - exports.translate = translate; - exports.rotate = rotate; - exports.scale = scale; - exports.makePoint = makePoint; - exports.makeVector = makeVector; - exports.makeVectorFromPoints = makeVectorFromPoints; - exports.addVector = addVector; - exports.multiplyVector = multiplyVector; - exports.magnitude = magnitude; - exports.negateVector = negateVector; - exports.unitVector = unitVector; - exports.crossProduct = crossProduct; - // Transform point by matrix - // - function applyTransform(p, m) { - var xt = p[0] * m[0] + p[1] * m[2] + m[4]; - var yt = p[0] * m[1] + p[1] * m[3] + m[5]; - return [xt, yt]; - }; - - // Transform point by matrix inverse - // - function applyInverseTransform(p, m) { - var d = m[0] * m[3] - m[1] * m[2]; - var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; - var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; - return [xt, yt]; - }; - - // Concatenates two transformation matrices together and returns the result. - function transform(m1, m2) { - return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]]; - }; - - function translate(m, x, y) { - return [m[0], m[1], m[2], m[3], m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]; - }; - - function rotate(m, angle) { - angle = angle * Math.PI / 180; - - var cosValue = Math.cos(angle); - var sinValue = Math.sin(angle); - - return [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]]; - }; - - function scale(m, x, y) { - return [m[0] * x, m[1] * x, m[2] * y, m[3] * y, m[4], m[5]]; - }; - - function getInverseTransform(m) { - var d = m[0] * m[3] - m[1] * m[2]; - return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d]; - }; - - function makePoint(x, y, z) { - return { x: x, y: y, z: z }; - } - - function makeVector(xcoord, ycoord, zcoord) { - return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord }; - } - - function makeVectorFromPoints(pt1, pt2) { - var xcoord = pt2.x - pt1.x; - var ycoord = pt2.y - pt1.y; - var zcoord = pt2.z - pt1.z; - return makeVector(xcoord, ycoord, zcoord); - } - - function addVector(pt, v) { - return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord); - } - - function multiplyVector(v, scalar) { - return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar); - } - - function magnitude(v) { - return Math.sqrt(Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)); - } - - function negateVector(v) { - return multiplyVector(v, -1); - } - - function unitVector(v) { - var mag = magnitude(v); - var xcoord = v.xcoord / mag; - var ycoord = v.ycoord / mag; - var zcoord = v.zcoord / mag; - return makeVector(xcoord, ycoord, zcoord); - } - - function crossProduct(u, v) { - // - // u X v = < u2*v3 - u3*v2, - // u3*v1 - u1*v3, - // u1*v2 - u2*v1 > - var xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord; - var ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord; - var zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord; - return makeVector(xcoord, ycoord, zcoord); - } + return null; +} -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _uuid = __webpack_require__(21); - - var _uuid2 = _interopRequireDefault(_uuid); - - var _StoreAdapter2 = __webpack_require__(2); - - var _StoreAdapter3 = _interopRequireDefault(_StoreAdapter2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - // StoreAdapter for working with localStorage - // This is ideal for testing, examples, and prototyping - var LocalStoreAdapter = function (_StoreAdapter) { - _inherits(LocalStoreAdapter, _StoreAdapter); - - function LocalStoreAdapter() { - var userId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "user"; - - _classCallCheck(this, LocalStoreAdapter); - - var _this = _possibleConstructorReturn(this, (LocalStoreAdapter.__proto__ || Object.getPrototypeOf(LocalStoreAdapter)).call(this, { - getAnnotations: function getAnnotations(documentId, userId, pageNumber) { - return new Promise(function (resolve, reject) { - var annotations = getAllAnnotations().filter(function (i) { - return i.page === pageNumber && i.class === 'Annotation'; - }); - - resolve({ - documentId: documentId, - userId: userId, - pageNumber: pageNumber, - annotations: annotations - }); - }); - }, - getAnnotation: function getAnnotation(documentId, annotationId) { - return Promise.resolve(getAnnotations(documentId, userId)[findAnnotation(documentId, userId, annotationId)]); - }, - addAnnotation: function addAnnotation(documentId, userId, pageNumber, annotation) { - return new Promise(function (resolve, reject) { - annotation.class = 'Annotation'; - annotation.uuid = (0, _uuid2.default)(); - annotation.page = pageNumber; - annotation.userId = userId; - - var annotations = getAnnotations(documentId, userId); - annotations.push(annotation); - updateAnnotations(documentId, userId, annotations); - - resolve(annotation); - }); - }, - editAnnotation: function editAnnotation(documentId, userId, annotationId, annotation) { - return new Promise(function (resolve, reject) { - var annotations = getAnnotations(documentId, userId); - annotations[findAnnotation(documentId, userId, annotationId)] = annotation; - updateAnnotations(documentId, userId, annotations); - - resolve(annotation); - }); - }, - deleteAnnotation: function deleteAnnotation(documentId, userId, annotationId) { - return new Promise(function (resolve, reject) { - var index = findAnnotation(documentId, userId, annotationId); - if (index > -1) { - var annotations = getAnnotations(documentId, userId); - annotations.splice(index, 1); - updateAnnotations(documentId, userId, annotations); - } - - resolve(true); - }); - }, - getComments: function getComments(documentId, userId, annotationId) { - return new Promise(function (resolve, reject) { - resolve(getAnnotations(documentId, userId).filter(function (i) { - return i.class === 'Comment' && i.annotation === annotationId; - })); - }); - }, - addComment: function addComment(documentId, userId, annotationId, content) { - return new Promise(function (resolve, reject) { - var comment = { - class: 'Comment', - uuid: (0, _uuid2.default)(), - annotation: annotationId, - content: content - }; - - var annotations = getAnnotations(documentId, userId); - annotations.push(comment); - updateAnnotations(documentId, userId, annotations); - - resolve(comment); - }); - }, - deleteComment: function deleteComment(documentId, userId, commentId) { - return new Promise(function (resolve, reject) { - getAnnotations(documentId, userId); - var index = -1; - var annotations = getAnnotations(documentId, userId); - for (var i = 0, l = annotations.length; i < l; i++) { - if (annotations[i].uuid === commentId) { - index = i; - break; - } - } - - if (index > -1) { - annotations.splice(index, 1); - updateAnnotations(documentId, userId, annotations); - } - - resolve(true); - }); - } - })); - - _this._userId = userId; - return _this; - } - - _createClass(LocalStoreAdapter, [{ - key: 'userId', - get: function get() { - return this._userId; - } - }]); - - return LocalStoreAdapter; - }(_StoreAdapter3.default); - - exports.default = LocalStoreAdapter; - - - function getAllAnnotations() { - var all_annotations = []; - for (var i = 0; i < localStorage.length; i++) { - if (localStorage.key(i).includes('annotations')) { - all_annotations.push.apply(all_annotations, _toConsumableArray(JSON.parse(localStorage.getItem(localStorage.key(i))))); - } - } - return all_annotations; - } - - function getAnnotations(documentId, userId) { - return JSON.parse(localStorage.getItem(documentId + '/' + userId + '/annotations')) || []; - } - - function updateAnnotations(documentId, userId, annotations) { - localStorage.setItem(documentId + '/' + userId + '/annotations', JSON.stringify(annotations)); - } - /** - * - * @param {String} documentId Document id of the annotation - * @param {String} userId User id of the annotation - * @param {String} annotationId The id of the annotation - * - * This function finds all the annotation made by one user. - * - * @return {int} The index of the annotation in localstorage - */ - function findAnnotation(documentId, userId, annotationId) { - var index = -1; - var annotations = getAnnotations(documentId, userId); - for (var i = 0, l = annotations.length; i < l; i++) { - if (annotations[i].uuid === annotationId) { - index = i; - break; - } - } - return index; - } - module.exports = exports['default']; +/** + * Find an Element that represents an annotation at a given point. + * + * IMPORTANT: Requires the annotation layer to be the top most element so + * either use z-ordering or make it the leaf container. + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @return {Element} The annotation element or null if one can't be found + */ +function findAnnotationAtPoint(x, y) { + var el = null; + var candidate = document.elementFromPoint(x, y); + while (!el && candidate && candidate !== document) { + var type = candidate.getAttribute('data-pdf-annotate-type'); + if (type) { + el = candidate; + } + candidate = candidate.parentNode; + } + return el; +} -/***/ }, -/* 21 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = uuid; - var REGEXP = /[xy]/g; - var PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; - - function replacement(c) { - var r = Math.random() * 16 | 0; - var v = c == 'x' ? r : r & 0x3 | 0x8; - return v.toString(16); - } - - /** - * Generate a univierally unique identifier - * - * @return {String} - */ - function uuid() { - return PATTERN.replace(REGEXP, replacement); - } - module.exports = exports['default']; +/** + * Determine if a point intersects a rect + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @param {Object} rect The points of a rect (likely from getBoundingClientRect) + * @return {Boolean} True if a collision occurs, otherwise false + */ +function pointIntersectsRect(x, y, rect) { + return y >= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right; +} -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = render; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _appendChild = __webpack_require__(8); - - var _renderScreenReaderHints = __webpack_require__(23); - - var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG - * - * @param {SVGElement} svg The SVG element to render the annotations to - * @param {Object} viewport The page viewport data - * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations - * @return {Promise} Settled once rendering has completed - * A settled Promise will be either: - * - fulfilled: SVGElement - * - rejected: Error - */ - function render(svg, viewport, data) { - return new Promise(function (resolve, reject) { - // Reset the content of the SVG - svg.setAttribute('data-pdf-annotate-container', true); - svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport)); - svg.removeAttribute('data-pdf-annotate-document'); - svg.removeAttribute('data-pdf-annotate-page'); - - // If there's no data nothing can be done - if (!data) { - svg.innerHTML = ''; - return resolve(svg); - } - - svg.setAttribute('data-pdf-annotate-document', data.documentId); - svg.setAttribute('data-pdf-annotate-user', data.userId); - svg.setAttribute('data-pdf-annotate-page', data.pageNumber); - - // Make sure annotations is an array - if (!Array.isArray(data.annotations) || data.annotations.length === 0) { - return resolve(svg); - } - - // Append or transform annotation to svg - data.annotations.forEach(function (a) { - var node = svg.querySelector('[data-pdf-annotate-id="' + a.uuid + '"]'); - if (node) { - (0, _appendChild.transformChild)(svg, node, viewport); - } else { - (0, _appendChild.appendChild)(svg, a, viewport); - } - }); - - resolve(svg); - }); - } - module.exports = exports['default']; +/** + * Get the rect of an annotation element accounting for offset. + * + * @param {Element} el The element to get the rect of + * @return {Object} The dimensions of the element + */ +function getOffsetAnnotationRect(el) { + var rect = el.getBoundingClientRect(); + var width = rect.width, + height = rect.height; -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderScreenReaderHints; - - var _insertScreenReaderHint = __webpack_require__(24); - - var _insertScreenReaderHint2 = _interopRequireDefault(_insertScreenReaderHint); - - var _initEventHandlers = __webpack_require__(31); - - var _initEventHandlers2 = _interopRequireDefault(_initEventHandlers); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - // TODO This is not the right place for this to live - (0, _initEventHandlers2.default)(); - - /** - * Insert hints into the DOM for screen readers. - * - * @param {Array} annotations The annotations that hints are inserted for - */ - function renderScreenReaderHints(annotations) { - annotations = Array.isArray(annotations) ? annotations : []; - - // Insert hints for each type - Object.keys(SORT_TYPES).forEach(function (type) { - var sortBy = SORT_TYPES[type]; - annotations.filter(function (a) { - return a.type === type; - }).sort(sortBy).forEach(function (a, i) { - return (0, _insertScreenReaderHint2.default)(a, i + 1); - }); - }); - } - - // Sort annotations first by y, then by x. - // This allows hints to be injected in the order they appear, - // which makes numbering them easier. - function sortByPoint(a, b) { - if (a.y < b.y) { - return a.x - b.x; - } else { - return 1; - } - } - - // Sort annotation by it's first rectangle - function sortByRectPoint(a, b) { - return sortByPoint(a.rectangles[0], b.rectangles[0]); - } - - // Sort annotation by it's first line - function sortByLinePoint(a, b) { - var lineA = a.lines[0]; - var lineB = b.lines[0]; - return sortByPoint({ x: lineA[0], y: lineA[1] }, { x: lineB[0], y: lineB[1] }); - } - - // Arrange supported types and associated sort methods - var SORT_TYPES = { - 'highlight': sortByRectPoint, - 'strikeout': sortByRectPoint, - 'drawing': sortByLinePoint, - 'textbox': sortByPoint, - 'point': sortByPoint, - 'area': sortByPoint - }; - module.exports = exports['default']; - -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = insertScreenReaderHint; - - var _createScreenReaderOnly = __webpack_require__(25); - - var _createScreenReaderOnly2 = _interopRequireDefault(_createScreenReaderOnly); - - var _insertElementWithinChildren = __webpack_require__(26); - - var _insertElementWithinChildren2 = _interopRequireDefault(_insertElementWithinChildren); - - var _insertElementWithinElement = __webpack_require__(28); - - var _insertElementWithinElement2 = _interopRequireDefault(_insertElementWithinElement); - - var _renderScreenReaderComments = __webpack_require__(29); - - var _renderScreenReaderComments2 = _interopRequireDefault(_renderScreenReaderComments); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - // Annotation types that support comments - var COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle']; - - /** - * Insert a hint into the DOM for screen readers for a specific annotation. - * - * @param {Object} annotation The annotation to insert a hint for - * @param {Number} num The number of the annotation out of all annotations of the same type - */ - function insertScreenReaderHint(annotation) { - var num = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - - switch (annotation.type) { - case 'highlight': - case 'strikeout': - var rects = annotation.rectangles; - var first = rects[0]; - var last = rects[rects.length - 1]; - - (0, _insertElementWithinElement2.default)((0, _createScreenReaderOnly2.default)('Begin ' + annotation.type + ' annotation ' + num, annotation.uuid), first.x, first.y, annotation.page, true); - - (0, _insertElementWithinElement2.default)((0, _createScreenReaderOnly2.default)('End ' + annotation.type + ' annotation ' + num, annotation.uuid + '-end'), last.x + last.width, last.y, annotation.page, false); - break; - - case 'textbox': - case 'point': - var text = annotation.type === 'textbox' ? ' (content: ' + annotation.content + ')' : ''; - - (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)(annotation.type + ' annotation ' + num + text, annotation.uuid), annotation.x, annotation.y, annotation.page); - break; - - case 'drawing': - case 'area': - var x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0]; - var y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1]; - - (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)('Unlabeled drawing', annotation.uuid), x, y, annotation.page); - break; - - case 'circle': - case 'fillcircle': - case 'emptycircle': - var x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0]; - var y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1]; - - (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)('Unlabeled drawing', annotation.uuid), x2, y2, annotation.page); - break; - } - - // Include comments in screen reader hint - if (COMMENT_TYPES.includes(annotation.type)) { - (0, _renderScreenReaderComments2.default)(annotation.documentId, annotation.uuid); - } - } - module.exports = exports['default']; + var extraOffsetWidth = 0; + var extraOffsetHeight = 0; + if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) { + var bbox = el.getBBox(); + extraOffsetWidth = (rect.width - bbox.width) / 2; + extraOffsetHeight = (rect.height - bbox.height) / 2; + width = bbox.width; + height = bbox.height; + } -/***/ }, -/* 25 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = createScreenReaderOnly; - /** - * Create a node that is only visible to screen readers - * - * @param {String} content The text content that should be read by screen reader - * @param {String} [annotationId] The ID of the annotation assocaited - * @return {Element} An Element that is only visible to screen readers - */ - function createScreenReaderOnly(content, annotationId) { - var node = document.createElement('div'); - var text = document.createTextNode(content); - node.appendChild(text); - node.setAttribute('id', 'pdf-annotate-screenreader-' + annotationId); - node.style.position = 'absolute'; - node.style.left = '-10000px'; - node.style.top = 'auto'; - node.style.width = '1px'; - node.style.height = '1px'; - node.style.overflow = 'hidden'; - return node; - } - module.exports = exports['default']; + var _getOffset = getOffset(el), + offsetLeft = _getOffset.offsetLeft, + offsetTop = _getOffset.offsetTop; -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = insertElementWithinChildren; - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _insertElementWithinElement = __webpack_require__(28); - - var _insertElementWithinElement2 = _interopRequireDefault(_insertElementWithinElement); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - /** - * Insert an element at a point within the document. - * This algorithm will try to insert between elements if possible. - * It will however use `insertElementWithinElement` if it is more accurate. - * - * @param {Element} el The element to be inserted - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @param {Number} pageNumber The page number to limit elements to - * @return {Boolean} True if element was able to be inserted, otherwise false - */ - function insertElementWithinChildren(el, x, y, pageNumber) { - // Try and use most accurate method of inserting within an element - if ((0, _insertElementWithinElement2.default)(el, x, y, pageNumber, true)) { - return true; - } - - // Fall back to inserting between elements - var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); - var rect = svg.getBoundingClientRect(); - var nodes = [].concat(_toConsumableArray(svg.parentNode.querySelectorAll(_config2.default.textClassQuery() + ' > div'))); - - y = (0, _utils.scaleUp)(svg, { y: y }).y + rect.top; - x = (0, _utils.scaleUp)(svg, { x: x }).x + rect.left; - - // Find the best node to insert before - for (var i = 0, l = nodes.length; i < l; i++) { - var n = nodes[i]; - var r = n.getBoundingClientRect(); - if (y <= r.top) { - n.parentNode.insertBefore(el, n); - return true; - } - } - - // If all else fails try to append to the bottom - var textLayer = svg.parentNode.querySelector(_config2.default.textClassQuery()); - if (textLayer) { - var textRect = textLayer.getBoundingClientRect(); - if ((0, _utils.pointIntersectsRect)(x, y, textRect)) { - textLayer.appendChild(el); - return true; - } - } - - return false; - } - module.exports = exports['default']; + return { + top: rect.top - offsetTop + extraOffsetHeight, + left: rect.left - offsetLeft + extraOffsetWidth, + bottom: rect.bottom - offsetTop - extraOffsetHeight, + right: rect.right - offsetLeft - extraOffsetWidth, + width: width, + height: height + }; +} -/***/ }, -/* 27 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = { - annotationLayerName: 'annotationLayer', - textLayerName: 'textLayer', - annotationSvgQuery: function annotationSvgQuery() { - return 'svg.' + this.annotationLayerName; - }, - annotationClassQuery: function annotationClassQuery() { - return '.' + this.annotationLayerName; - }, - textClassQuery: function textClassQuery() { - return '.' + this.textLayerName; - } - }; - module.exports = exports['default']; - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = insertElementWithinElement; - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - /** - * Insert an element at a point within the document. - * This algorithm will only insert within an element amidst it's text content. - * - * @param {Element} el The element to be inserted - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @param {Number} pageNumber The page number to limit elements to - * @param {Boolean} insertBefore Whether the element is to be inserted before or after x - * @return {Boolean} True if element was able to be inserted, otherwise false - */ - function insertElementWithinElement(el, x, y, pageNumber, insertBefore) { - var OFFSET_ADJUST = 2; - - // If inserting before adjust `x` by looking for element a few px to the right - // Otherwise adjust a few px to the left - // This is to allow a little tolerance by searching within the box, instead - // of getting a false negative by testing right on the border. - x = Math.max(x + OFFSET_ADJUST * (insertBefore ? 1 : -1), 0); - - var node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber); - if (!node) { - return false; - } - - // Now that node has been found inverse the adjustment for `x`. - // This is done to accomodate tolerance by cutting off on the outside of the - // text boundary, instead of missing a character by cutting off within. - x = x + OFFSET_ADJUST * (insertBefore ? -1 : 1); - - var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); - var left = (0, _utils.scaleDown)(svg, { left: node.getBoundingClientRect().left }).left - svg.getBoundingClientRect().left; - var temp = node.cloneNode(true); - var head = temp.innerHTML.split(''); - var tail = []; - - // Insert temp off screen - temp.style.position = 'absolute'; - temp.style.top = '-10000px'; - temp.style.left = '-10000px'; - document.body.appendChild(temp); - - while (head.length) { - // Don't insert within HTML tags - if (head[head.length - 1] === '>') { - while (head.length) { - tail.unshift(head.pop()); - if (tail[0] === '<') { - break; - } - } - } - - // Check if width of temp based on current head value satisfies x - temp.innerHTML = head.join(''); - var width = (0, _utils.scaleDown)(svg, { width: temp.getBoundingClientRect().width }).width; - if (left + width <= x) { - break; - } - tail.unshift(head.pop()); - } - - // Update original node with new markup, including element to be inserted - node.innerHTML = head.join('') + el.outerHTML + tail.join(''); - temp.parentNode.removeChild(temp); - - return true; - } - - /** - * Get a text layer element at a given point on a page - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - * @param {Number} pageNumber The page to limit elements to - * @return {Element} First text layer element found at the point - */ - function textLayerElementFromPoint(x, y, pageNumber) { - var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); - var rect = svg.getBoundingClientRect(); - y = (0, _utils.scaleUp)(svg, { y: y }).y + rect.top; - x = (0, _utils.scaleUp)(svg, { x: x }).x + rect.left; - return [].concat(_toConsumableArray(svg.parentNode.querySelectorAll(_config2.default.textClassQuery() + ' [data-canvas-width]'))).filter(function (el) { - return (0, _utils.pointIntersectsRect)(x, y, el.getBoundingClientRect()); - })[0]; - } - module.exports = exports['default']; +/** + * Adjust scale from normalized scale (100%) to rendered scale. + * + * @param {SVGElement} svg The SVG to gather metadata from + * @param {Object} rect A map of numeric values to scale + * @return {Object} A copy of `rect` with values scaled up + */ +function scaleUp(svg, rect) { + var result = {}; -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = renderScreenReaderComments; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _insertScreenReaderComment = __webpack_require__(30); - - var _insertScreenReaderComment2 = _interopRequireDefault(_insertScreenReaderComment); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Insert the comments into the DOM to be available by screen reader - * - * Example output: - *
- *
Begin highlight 1
- *
    - *
  1. Foo
  2. - *
  3. Bar
  4. - *
  5. Baz
  6. - *
  7. Qux
  8. - *
- *
- *
Some highlighted text goes here...
- *
End highlight 1
- * - * NOTE: `screenReaderOnly` is not a real class, just used for brevity - * - * @param {String} documentId The ID of the document - * @param {String} annotationId The ID of the annotation - * @param {Array} [comments] Optionally preloaded comments to be rendered - * @return {Promise} - */ - function renderScreenReaderComments(documentId, annotationId, comments) { - var promise = void 0; - - if (Array.isArray(comments)) { - promise = Promise.resolve(comments); - } else { - promise = _PDFJSAnnotate2.default.getStoreAdapter().getComments(documentId, annotationId); - } - - return promise.then(function (comments) { - // Node needs to be found by querying DOM as it may have been inserted as innerHTML - // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`). - var node = document.getElementById('pdf-annotate-screenreader-' + annotationId); - if (node) { - var list = document.createElement('ol'); - list.setAttribute('id', 'pdf-annotate-screenreader-comment-list-' + annotationId); - list.setAttribute('aria-label', 'Comments'); - node.appendChild(list); - comments.forEach(_insertScreenReaderComment2.default); - } - }); - } - module.exports = exports['default']; + var _getMetadata = getMetadata(svg), + viewport = _getMetadata.viewport; -/***/ }, -/* 30 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = insertScreenReaderComment; - /** - * Insert a comment into the DOM to be available by screen reader - * - * @param {Object} comment The comment to be inserted - */ - function insertScreenReaderComment(comment) { - if (!comment) { - return; - } - - var list = document.querySelector('#pdf-annotate-screenreader-' + comment.annotation + ' ol'); - if (list) { - var item = document.createElement('li'); - item.setAttribute('id', 'pdf-annotate-screenreader-comment-' + comment.uuid); - item.appendChild(document.createTextNode('' + comment.content)); - list.appendChild(item); - } - } - module.exports = exports['default']; + Object.keys(rect).forEach(function (key) { + result[key] = rect[key] * viewport.scale; + }); -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = initEventHandlers; - - var _insertScreenReaderHint = __webpack_require__(24); - - var _insertScreenReaderHint2 = _interopRequireDefault(_insertScreenReaderHint); - - var _renderScreenReaderHints = __webpack_require__(23); - - var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); - - var _insertScreenReaderComment = __webpack_require__(30); - - var _insertScreenReaderComment2 = _interopRequireDefault(_insertScreenReaderComment); - - var _renderScreenReaderComments = __webpack_require__(29); - - var _renderScreenReaderComments2 = _interopRequireDefault(_renderScreenReaderComments); - - var _event = __webpack_require__(4); - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - /** - * Initialize the event handlers for keeping screen reader hints synced with data - */ - function initEventHandlers() { - (0, _event.addEventListener)('annotation:add', function (documentId, userId, pageNumber, annotation) { - reorderAnnotationsByType(documentId, userId, pageNumber, annotation.type); - }); - (0, _event.addEventListener)('annotation:edit', function (documentId, userId, annotationId, annotation) { - reorderAnnotationsByType(documentId, userId, annotation.page, annotation.type); - }); - (0, _event.addEventListener)('annotation:delete', removeAnnotation); - (0, _event.addEventListener)('comment:add', insertComment); - (0, _event.addEventListener)('comment:delete', removeComment); - } - - /** - * Reorder the annotation numbers by annotation type - * - * @param {String} documentId The ID of the document - * @param {String} userId The ID of the user - * @param {Number} pageNumber The page number of the annotations - * @param {Strig} type The annotation type - */ - function reorderAnnotationsByType(documentId, userId, pageNumber, type) { - _PDFJSAnnotate2.default.getStoreAdapter().getAnnotations(documentId, userId, pageNumber).then(function (annotations) { - return annotations.annotations.filter(function (a) { - return a.type === type; - }); - }).then(function (annotations) { - annotations.forEach(function (a) { - removeAnnotation(documentId, a.uuid); - }); - - return annotations; - }).then(_renderScreenReaderHints2.default); - } - - /** - * Remove the screen reader hint for an annotation - * - * @param {String} documentId The ID of the document - * @param {String} annotationId The Id of the annotation - */ - function removeAnnotation(documentId, annotationId) { - removeElementById('pdf-annotate-screenreader-' + annotationId); - removeElementById('pdf-annotate-screenreader-' + annotationId + '-end'); - } - - /** - * Insert a screen reader hint for a comment - * - * @param {String} documentId The ID of the document - * @param {String} annotationId The ID of tha assocated annotation - * @param {Object} comment The comment to insert a hint for - */ - function insertComment(documentId, annotationId, comment) { - var list = document.querySelector('pdf-annotate-screenreader-comment-list-' + annotationId); - var promise = void 0; - - if (!list) { - promise = (0, _renderScreenReaderComments2.default)(documentId, annotationId, []).then(function () { - list = document.querySelector('pdf-annotate-screenreader-comment-list-' + annotationId); - return true; - }); - } else { - promise = Promise.resolve(true); - } - - promise.then(function () { - (0, _insertScreenReaderComment2.default)(comment); - }); - } - - /** - * Remove a screen reader hint for a comment - * - * @param {String} documentId The ID of the document - * @param {String} commentId The ID of the comment - */ - function removeComment(documentId, commentId) { - removeElementById('pdf-annotate-screenreader-comment-' + commentId); - } - - /** - * Remove an element from the DOM by it's ID if it exists - * - * @param {String} elementID The ID of the element to be removed - */ - function removeElementById(elementId) { - var el = document.getElementById(elementId); - if (el) { - el.parentNode.removeChild(el); - } - } - module.exports = exports['default']; + return result; +} -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _event = __webpack_require__(4); - - var _edit = __webpack_require__(33); - - var _pen = __webpack_require__(34); - - var _eraser = __webpack_require__(35); - - var _arrow = __webpack_require__(36); - - var _point = __webpack_require__(37); - - var _rect = __webpack_require__(38); - - var _circle = __webpack_require__(39); - - var _text = __webpack_require__(40); - - var _page = __webpack_require__(41); - - exports.default = { - addEventListener: _event.addEventListener, removeEventListener: _event.removeEventListener, fireEvent: _event.fireEvent, - disableEdit: _edit.disableEdit, enableEdit: _edit.enableEdit, - disablePen: _pen.disablePen, enablePen: _pen.enablePen, setPen: _pen.setPen, - enableEraser: _eraser.enableEraser, disableEraser: _eraser.disableEraser, - disablePoint: _point.disablePoint, enablePoint: _point.enablePoint, - disableRect: _rect.disableRect, enableRect: _rect.enableRect, - disableCircle: _circle.disableCircle, enableCircle: _circle.enableCircle, setCircle: _circle.setCircle, addCircle: _circle.addCircle, - disableArrow: _arrow.disableArrow, enableArrow: _arrow.enableArrow, setArrow: _arrow.setArrow, - disableText: _text.disableText, enableText: _text.enableText, setText: _text.setText, - createPage: _page.createPage, renderPage: _page.renderPage - }; - module.exports = exports['default']; - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - exports.enableEdit = enableEdit; - exports.disableEdit = disableEdit; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _appendChild = __webpack_require__(8); - - var _event = __webpack_require__(4); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - var _enabled = false; - var isDragging = false, - overlay = void 0; - var dragOffsetX = void 0, - dragOffsetY = void 0, - dragStartX = void 0, - dragStartY = void 0; - var OVERLAY_BORDER_SIZE = 3; - - /** - * Create an overlay for editing an annotation. - * - * @param {Element} target The annotation element to apply overlay for - */ - function createEditOverlay(target) { - destroyEditOverlay(); - - overlay = document.createElement('div'); - var anchor = document.createElement('a'); - var parentNode = (0, _utils.findSVGContainer)(target).parentNode; - var id = target.getAttribute('data-pdf-annotate-id'); - var rect = (0, _utils.getOffsetAnnotationRect)(target); - var styleLeft = rect.left - OVERLAY_BORDER_SIZE; - var styleTop = rect.top - OVERLAY_BORDER_SIZE; - - overlay.setAttribute('id', 'pdf-annotate-edit-overlay'); - overlay.setAttribute('data-target-id', id); - overlay.style.boxSizing = 'content-box'; - overlay.style.position = 'absolute'; - overlay.style.top = styleTop + 'px'; - overlay.style.left = styleLeft + 'px'; - overlay.style.width = rect.width + 'px'; - overlay.style.height = rect.height + 'px'; - overlay.style.border = OVERLAY_BORDER_SIZE + 'px solid ' + _utils.BORDER_COLOR; - overlay.style.borderRadius = OVERLAY_BORDER_SIZE + 'px'; - overlay.style.zIndex = 20100; - - anchor.innerHTML = '×'; - anchor.setAttribute('href', 'javascript://'); - anchor.style.background = '#fff'; - anchor.style.borderRadius = '20px'; - anchor.style.border = '1px solid #bbb'; - anchor.style.color = '#bbb'; - anchor.style.fontSize = '16px'; - anchor.style.padding = '2px'; - anchor.style.textAlign = 'center'; - anchor.style.textDecoration = 'none'; - anchor.style.position = 'absolute'; - anchor.style.top = '-13px'; - anchor.style.right = '-13px'; - anchor.style.width = '25px'; - anchor.style.height = '25px'; - - overlay.appendChild(anchor); - parentNode.appendChild(overlay); - document.addEventListener('click', handleDocumentClick); - document.addEventListener('keyup', handleDocumentKeyup); - document.addEventListener('mousedown', handleDocumentMousedown); - anchor.addEventListener('click', deleteAnnotation); - anchor.addEventListener('mouseover', function () { - anchor.style.color = '#35A4DC'; - anchor.style.borderColor = '#999'; - anchor.style.boxShadow = '0 1px 1px #ccc'; - }); - anchor.addEventListener('mouseout', function () { - anchor.style.color = '#bbb'; - anchor.style.borderColor = '#bbb'; - anchor.style.boxShadow = ''; - }); - overlay.addEventListener('mouseover', function () { - if (!isDragging) { - anchor.style.display = ''; - } - }); - overlay.addEventListener('mouseout', function () { - anchor.style.display = 'none'; - }); - } - - /** - * Destroy the edit overlay if it exists. - */ - function destroyEditOverlay() { - if (overlay) { - overlay.parentNode.removeChild(overlay); - overlay = null; - } - - document.removeEventListener('click', handleDocumentClick); - document.removeEventListener('keyup', handleDocumentKeyup); - document.removeEventListener('mousedown', handleDocumentMousedown); - document.removeEventListener('mousemove', handleDocumentMousemove); - document.removeEventListener('mouseup', handleDocumentMouseup); - (0, _utils.enableUserSelect)(); - } - - /** - * Delete currently selected annotation - */ - function deleteAnnotation() { - if (!overlay) { - return; - } - - var annotationId = overlay.getAttribute('data-target-id'); - var nodes = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); - var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId; - - [].concat(_toConsumableArray(nodes)).forEach(function (n) { - n.parentNode.removeChild(n); - }); - - _PDFJSAnnotate2.default.getStoreAdapter().deleteAnnotation(documentId, annotationId); - - destroyEditOverlay(); - } - - /** - * Handle document.click event - * - * @param {Event} e The DOM event that needs to be handled - */ - function handleDocumentClick(e) { - if (!(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { - return; - } - - // Remove current overlay - var overlay = document.getElementById('pdf-annotate-edit-overlay'); - if (overlay) { - if (isDragging || e.target === overlay) { - return; - } - - destroyEditOverlay(); - } - } - - /** - * Handle document.keyup event - * - * @param {Event} e The DOM event that needs to be handled - */ - function handleDocumentKeyup(e) { - if (overlay && e.keyCode === 46 && e.target.nodeName.toLowerCase() !== 'textarea' && e.target.nodeName.toLowerCase() !== 'input') { - deleteAnnotation(); - } - } - - /** - * Handle document.mousedown event - * - * @param {Event} e The DOM event that needs to be handled - */ - function handleDocumentMousedown(e) { - if (e.target !== overlay) { - return; - } - - // Highlight and strikeout annotations are bound to text within the document. - // It doesn't make sense to allow repositioning these types of annotations. - var annotationId = overlay.getAttribute('data-target-id'); - var target = document.querySelector('[data-pdf-annotate-id="' + annotationId + '"]'); - var type = target.getAttribute('data-pdf-annotate-type'); - - if (type === 'highlight' || type === 'strikeout') { - return; - } - - isDragging = true; - dragOffsetX = e.clientX; - dragOffsetY = e.clientY; - dragStartX = overlay.offsetLeft; - dragStartY = overlay.offsetTop; - - overlay.style.background = 'rgba(255, 255, 255, 0.7)'; - overlay.style.cursor = 'move'; - overlay.querySelector('a').style.display = 'none'; - - document.addEventListener('mousemove', handleDocumentMousemove); - document.addEventListener('mouseup', handleDocumentMouseup); - (0, _utils.disableUserSelect)(); - } - - /** - * Handle document.mousemove event - * - * @param {Event} e The DOM event that needs to be handled - */ - function handleDocumentMousemove(e) { - var annotationId = overlay.getAttribute('data-target-id'); - var parentNode = overlay.parentNode; - var rect = parentNode.getBoundingClientRect(); - var y = dragStartY + (e.clientY - dragOffsetY); - var x = dragStartX + (e.clientX - dragOffsetX); - var minY = 0; - var maxY = rect.height; - var minX = 0; - var maxX = rect.width; - - if (y > minY && y + overlay.offsetHeight < maxY) { - overlay.style.top = y + 'px'; - } - - if (x > minX && x + overlay.offsetWidth < maxX) { - overlay.style.left = x + 'px'; - } - } - - /** - * Handle document.mouseup event - * - * @param {Event} e The DOM event that needs to be handled - */ - function handleDocumentMouseup(e) { - var annotationId = overlay.getAttribute('data-target-id'); - var target = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); - var type = target[0].getAttribute('data-pdf-annotate-type'); - var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); - - var _getMetadata2 = (0, _utils.getMetadata)(svg), - documentId = _getMetadata2.documentId, - userId = _getMetadata2.userId; - - overlay.querySelector('a').style.display = ''; - - _PDFJSAnnotate2.default.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then(function (annotation) { - var attribX = 'x'; - var attribY = 'y'; - if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { - attribX = 'cx'; - attribY = 'cy'; - } - if (['area', 'highlight', 'point', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { - var modelStart = (0, _utils.convertToSvgPoint)([dragStartX, dragStartY], svg); - var modelEnd = (0, _utils.convertToSvgPoint)([overlay.offsetLeft, overlay.offsetTop], svg); - var modelDelta = { - x: modelEnd[0] - modelStart[0], - y: modelEnd[1] - modelStart[1] - }; - - if (type === 'textbox') { - target = [target[0].firstChild]; - } - - [].concat(_toConsumableArray(target)).forEach(function (t, i) { - var modelX = parseInt(t.getAttribute(attribX), 10); - var modelY = parseInt(t.getAttribute(attribY), 10); - if (modelDelta.y !== 0) { - modelY = modelY + modelDelta.y; - var viewY = modelY; - - if (type === 'point') { - viewY = (0, _utils.scaleUp)(svg, { viewY: viewY }).viewY; - } - - t.setAttribute(attribY, viewY); - if (annotation.rectangles && i < annotation.rectangles.length) { - annotation.rectangles[i].y = modelY; - } else if (annotation[attribY]) { - annotation[attribY] = modelY; - } - } - if (modelDelta.x !== 0) { - modelX = modelX + modelDelta.x; - var viewX = modelX; - - if (type === 'point') { - viewX = (0, _utils.scaleUp)(svg, { viewX: viewX }).viewX; - } - - t.setAttribute(attribX, viewX); - if (annotation.rectangles && i < annotation.rectangles.length) { - annotation.rectangles[i].x = modelX; - } else if (annotation[attribX]) { - annotation[attribX] = modelX; - } - } - }); - // } else if (type === 'strikeout') { - // let { deltaX, deltaY } = getDelta('x1', 'y1'); - // [...target].forEach(target, (t, i) => { - // if (deltaY !== 0) { - // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY); - // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY); - // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10); - // } - // if (deltaX !== 0) { - // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX); - // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX); - // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10); - // } - // }); - } else if (type === 'drawing' || type === 'arrow') { - var _modelStart = (0, _utils.convertToSvgPoint)([dragStartX, dragStartY], svg); - var _modelEnd = (0, _utils.convertToSvgPoint)([overlay.offsetLeft, overlay.offsetTop], svg); - var _modelDelta = { - x: _modelEnd[0] - _modelStart[0], - y: _modelEnd[1] - _modelStart[1] - }; - - annotation.lines.forEach(function (line, i) { - var _annotation$lines$i = _slicedToArray(annotation.lines[i], 2), - x = _annotation$lines$i[0], - y = _annotation$lines$i[1]; - - annotation.lines[i][0] = x + _modelDelta.x; - annotation.lines[i][1] = y + _modelDelta.y; - }); - - target[0].parentNode.removeChild(target[0]); - (0, _appendChild.appendChild)(svg, annotation); - } - - _PDFJSAnnotate2.default.getStoreAdapter().editAnnotation(documentId, annotationId, annotation); - }); - - setTimeout(function () { - isDragging = false; - }, 0); - - overlay.style.background = ''; - overlay.style.cursor = ''; - - document.removeEventListener('mousemove', handleDocumentMousemove); - document.removeEventListener('mouseup', handleDocumentMouseup); - (0, _utils.enableUserSelect)(); - } - - /** - * Handle annotation.click event - * - * @param {Element} e The annotation element that was clicked - */ - function handleAnnotationClick(target) { - createEditOverlay(target); - } - - /** - * Enable edit mode behavior. - */ - function enableEdit() { - if (_enabled) { - return; - } - - _enabled = true; - (0, _event.addEventListener)('annotation:click', handleAnnotationClick); - }; - - /** - * Disable edit mode behavior. - */ - function disableEdit() { - destroyEditOverlay(); - - if (!_enabled) { - return; - } - - _enabled = false; - (0, _event.removeEventListener)('annotation:click', handleAnnotationClick); - }; - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.setPen = setPen; - exports.enablePen = enablePen; - exports.disablePen = disablePen; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var _enabled = false; - var _candraw = false; - var _penSize = void 0; - var _penColor = void 0; - var path = void 0; - var lines = []; - - var isFirefox = /firefox/i.test(navigator.userAgent); - - /** - * Handle document.touchdown or document.pointerdown event - */ - function handleDocumentPointerdown(e) { - e.preventDefault(); - path = null; - lines = []; - _candraw = true; - } - - /** - * Handle document.touchup or document.pointerup event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentPointerupChrome(e) { - saveToStorage(e.changedTouches[0].clientX, e.changedTouches[0].clientY); - } - - function handleDocumentPointerup(e) { - saveToStorage(e.clientX, e.clientY); - } - - function saveToStorage(x, y) { - _candraw = false; - var svg = void 0; - if (lines.length > 1 && (svg = (0, _utils.findSVGAtPoint)(x, y))) { - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId, - pageNumber = _getMetadata.pageNumber; - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, { - type: 'drawing', - width: _penSize, - color: _penColor, - lines: lines - }).then(function (annotation) { - if (path) { - svg.removeChild(path); - } - - (0, _appendChild.appendChild)(svg, annotation); - }); - } - } - - /** - * Handle document.mousemove event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentPointermove(e) { - if (!e.srcElement.classList.contains('annotationLayer')) { - return; - } - if (_candraw) { - savePoint(e.clientX, e.clientY); - } - } - - function handleDocumentPointermoveChrome(e) { - if (!e.srcElement.classList.contains('annotationLayer')) { - return; - } - if (_candraw) { - savePoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY); - } - } - - /** - * Handle document.keyup event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentKeyup(e) { - // Cancel rect if Esc is pressed - if (e.keyCode === 27) { - lines = null; - path.parentNode.removeChild(path); - document.removeEventListener('pointermove', handleDocumentPointermove); - document.removeEventListener('pointerup', handleDocumentPointerup); - } - } - - /** - * Save a point to the line being drawn. - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - */ - function savePoint(x, y) { - var svg = (0, _utils.findSVGAtPoint)(x, y); - if (!svg) { - return; - } - - var rect = svg.getBoundingClientRect(); - var point = (0, _utils.convertToSvgPoint)([x - rect.left, y - rect.top], svg); - point[0] = point[0].toFixed(2); - point[1] = point[1].toFixed(2); - lines.push(point); - - if (lines.length <= 1) { - return; - } - - if (path) { - svg.removeChild(path); - } - - path = (0, _appendChild.appendChild)(svg, { - type: 'drawing', - color: _penColor, - width: _penSize, - lines: lines - }); - } - - /** - * Set the attributes of the pen. - * - * @param {Number} penSize The size of the lines drawn by the pen - * @param {String} penColor The color of the lines drawn by the pen - */ - function setPen() { - var penSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var penColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '000000'; - - _penSize = parseInt(penSize, 10); - _penColor = penColor; - } - - /** - * Enable the pen behavior - */ - function enablePen() { - if (_enabled) { - return; - } - - _enabled = true; - // Chrome and Firefox has different behaviors with how pen works, so we need different events. - if (!isFirefox) { - document.addEventListener('touchstart', handleDocumentPointerdown); - document.addEventListener('touchmove', handleDocumentPointermoveChrome); - document.addEventListener('touchend', handleDocumentPointerupChrome); - document.addEventListener('mousedown', handleDocumentPointerdown); - document.addEventListener('mousemove', handleDocumentPointermove); - document.addEventListener('mouseup', handleDocumentPointerup); - } else { - document.addEventListener('pointerdown', handleDocumentPointerdown); - document.addEventListener('pointermove', handleDocumentPointermove); - document.addEventListener('pointerup', handleDocumentPointerup); - } - document.addEventListener('keyup', handleDocumentKeyup); - (0, _utils.disableUserSelect)(); - } - - /** - * Disable the pen behavior - */ - function disablePen() { - if (!_enabled) { - return; - } - - _enabled = false; - if (!isFirefox) { - document.removeEventListener('touchstart', handleDocumentPointerdown); - document.removeEventListener('touchmove', handleDocumentPointermoveChrome); - document.removeEventListener('touchend', handleDocumentPointerupChrome); - document.removeEventListener('mousedown', handleDocumentPointerdown); - document.removeEventListener('mousemove', handleDocumentPointermove); - document.removeEventListener('mouseup', handleDocumentPointerup); - } else { - document.removeEventListener('pointerdown', handleDocumentPointerdown); - document.removeEventListener('pointermove', handleDocumentPointermove); - document.removeEventListener('pointerup', handleDocumentPointerup); - } - document.removeEventListener('keyup', handleDocumentKeyup); - (0, _utils.enableUserSelect)(); - } +function convertToSvgRect(rect, svg, viewport) { + var pt1 = [rect.x, rect.y]; + var pt2 = [rect.x + rect.width, rect.y + rect.height]; -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.enableEraser = enableEraser; - exports.disableEraser = disableEraser; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - var _canerase = false; - var userId = "user"; - - function handleDocumentDown(e) { - _canerase = true; - } - - function handleDocumentUp(e) { - _canerase = false; - } - - function handleDocumentTouchMove(e) { - erase((0, _utils.findAnnotationAtPoint)(e.changedTouches[0].clientX, e.changedTouches[0].clientY)); - } - - function handleDocumentMouseMove(e) { - erase((0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY)); - } - - function erase(target) { - if (_canerase) { - if (target && target.getAttribute('data-pdf-annotate-userId') == userId) { - var _getMetadata = (0, _utils.getMetadata)(target.parentElement), - documentId = _getMetadata.documentId; - - var annotationId = target.getAttribute('data-pdf-annotate-id'); - var nodes = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); - [].concat(_toConsumableArray(nodes)).forEach(function (n) { - n.parentNode.removeChild(n); - }); - - _PDFJSAnnotate2.default.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId); - } - } - } - - function enableEraser() { - userId = _PDFJSAnnotate2.default.getStoreAdapter().userId; - document.addEventListener('mousemove', handleDocumentMouseMove); - document.addEventListener('mousedown', handleDocumentDown); - document.addEventListener('mouseup', handleDocumentUp); - document.addEventListener('touchstart', handleDocumentDown); - document.addEventListener('touchmove', handleDocumentTouchMove); - document.addEventListener('touchend', handleDocumentUp); - } - - function disableEraser() { - document.removeEventListener('mousemove', handleDocumentMouseMove); - document.removeEventListener('mousedown', handleDocumentDown); - document.removeEventListener('mouseup', handleDocumentUp); - document.removeEventListener('touchstart', handleDocumentDown); - document.removeEventListener('touchmove', handleDocumentTouchMove); - document.removeEventListener('touchend', handleDocumentUp); - } + pt1 = convertToSvgPoint(pt1, svg, viewport); + pt2 = convertToSvgPoint(pt2, svg, viewport); -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.setArrow = setArrow; - exports.enableArrow = enableArrow; - exports.disableArrow = disableArrow; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var _enabled = false; - var _penSize = void 0; - var _penColor = void 0; - var path = void 0; - var lines = void 0; - var originY = void 0; - var originX = void 0; - - /** - * Handle document.mousedown event - */ - function handleDocumentMousedown(e) { - var target = (0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY); - if (target === null) return; - - var type = target.getAttribute('data-pdf-annotate-type'); - if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') { - return; - } - - var svg = (0, _utils.findSVGContainer)(target); - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId; - - var annotationId = target.getAttribute('data-pdf-annotate-id'); - - var event = e; - _PDFJSAnnotate2.default.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then(function (annotation) { - if (annotation) { - path = null; - lines = []; - - var point = (0, _utils.convertToScreenPoint)([annotation.cx, annotation.cy], svg); - - var rect = svg.getBoundingClientRect(); - - originX = point[0] + rect.left; - originY = point[1] + rect.top; - - document.addEventListener('mousemove', handleDocumentMousemove); - document.addEventListener('mouseup', handleDocumentMouseup); - } - }); - } - - /** - * Handle document.mouseup event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentMouseup(e) { - var svg = void 0; - if (lines.length > 1 && (svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY))) { - var _getMetadata2 = (0, _utils.getMetadata)(svg), - documentId = _getMetadata2.documentId, - pageNumber = _getMetadata2.pageNumber; - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, pageNumber, { - type: 'arrow', - width: _penSize, - color: _penColor, - lines: lines - }).then(function (annotation) { - if (path) { - svg.removeChild(path); - } - - (0, _appendChild.appendChild)(svg, annotation); - }); - } - - document.removeEventListener('mousemove', handleDocumentMousemove); - document.removeEventListener('mouseup', handleDocumentMouseup); - } - - /** - * Handle document.mousemove event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentMousemove(e) { - var x = lines.length === 0 ? originX : e.clientX; - var y = lines.length === 0 ? originY : e.clientY; - - savePoint(x, y); - } - - /** - * Handle document.keyup event - * - * @param {Event} e The DOM event to be handled - */ - function handleDocumentKeyup(e) { - // Cancel rect if Esc is pressed - if (e.keyCode === 27) { - lines = null; - path.parentNode.removeChild(path); - document.removeEventListener('mousemove', handleDocumentMousemove); - document.removeEventListener('mouseup', handleDocumentMouseup); - } - } - - /** - * Save a point to the line being drawn. - * - * @param {Number} x The x coordinate of the point - * @param {Number} y The y coordinate of the point - */ - function savePoint(x, y) { - var svg = (0, _utils.findSVGAtPoint)(x, y); - if (!svg) { - return; - } - - var rect = svg.getBoundingClientRect(); - var point = (0, _utils.convertToSvgPoint)([x - rect.left, y - rect.top], svg); - - if (lines.length < 2) { - lines.push(point); - return; - } else { - lines[1] = point; // update end point - } - - if (path) { - svg.removeChild(path); - } - - path = (0, _appendChild.appendChild)(svg, { - type: 'arrow', - color: _penColor, - width: _penSize, - lines: lines - }); - } - - /** - * Set the attributes of the pen. - * - * @param {Number} penSize The size of the lines drawn by the pen - * @param {String} penColor The color of the lines drawn by the pen - */ - function setArrow() { - var penSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; - var penColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0000FF'; - - _penSize = parseInt(penSize, 10); - _penColor = penColor; - } - - /** - * Enable the pen behavior - */ - function enableArrow() { - if (_enabled) { - return; - } - - _enabled = true; - document.addEventListener('mousedown', handleDocumentMousedown); - document.addEventListener('keyup', handleDocumentKeyup); - (0, _utils.disableUserSelect)(); - } - - /** - * Disable the pen behavior - */ - function disableArrow() { - if (!_enabled) { - return; - } - - _enabled = false; - document.removeEventListener('mousedown', handleDocumentMousedown); - document.removeEventListener('keyup', handleDocumentKeyup); - (0, _utils.enableUserSelect)(); - } + return { + x: Math.min(pt1[0], pt2[0]), + y: Math.min(pt1[1], pt2[1]), + width: Math.abs(pt2[0] - pt1[0]), + height: Math.abs(pt2[1] - pt1[1]) + }; +} -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.enablePoint = enablePoint; - exports.disablePoint = disablePoint; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var _enabled = false; - var input = void 0; - - /** - * Handle document.mouseup event - * - * @param {Event} The DOM event to be handled - */ - function handleDocumentMouseup(e) { - if (input || !(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { - return; - } - - input = document.createElement('input'); - input.setAttribute('id', 'pdf-annotate-point-input'); - input.setAttribute('placeholder', 'Enter comment'); - input.style.border = '3px solid ' + _utils.BORDER_COLOR; - input.style.borderRadius = '3px'; - input.style.position = 'absolute'; - input.style.top = e.clientY + 'px'; - input.style.left = e.clientX + 'px'; - - input.addEventListener('blur', handleInputBlur); - input.addEventListener('keyup', handleInputKeyup); - - document.body.appendChild(input); - input.focus(); - } - - /** - * Handle input.blur event - */ - function handleInputBlur() { - savePoint(); - } - - /** - * Handle input.keyup event - * - * @param {Event} e The DOM event to handle - */ - function handleInputKeyup(e) { - if (e.keyCode === 27) { - closeInput(); - } else if (e.keyCode === 13) { - savePoint(); - } - } - - /** - * Save a new point annotation from input - */ - function savePoint() { - if (input.value.trim().length > 0) { - var clientX = parseInt(input.style.left, 10); - var clientY = parseInt(input.style.top, 10); - var content = input.value.trim(); - var svg = (0, _utils.findSVGAtPoint)(clientX, clientY); - if (!svg) { - return; - } - - var rect = svg.getBoundingClientRect(); - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId, - pageNumber = _getMetadata.pageNumber; - - var annotation = Object.assign({ - type: 'point' - }, (0, _utils.scaleDown)(svg, { - x: clientX - rect.left, - y: clientY - rect.top - })); - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { - _PDFJSAnnotate2.default.getStoreAdapter().addComment(documentId, annotation.uuid, content); - - (0, _appendChild.appendChild)(svg, annotation); - }); - } - - closeInput(); - } - - /** - * Close the input element - */ - function closeInput() { - input.removeEventListener('blur', handleInputBlur); - input.removeEventListener('keyup', handleInputKeyup); - document.body.removeChild(input); - input = null; - } - - /** - * Enable point annotation behavior - */ - function enablePoint() { - if (_enabled) { - return; - } - - _enabled = true; - document.addEventListener('mouseup', handleDocumentMouseup); - } - - /** - * Disable point annotation behavior - */ - function disablePoint() { - if (!_enabled) { - return; - } - - _enabled = false; - document.removeEventListener('mouseup', handleDocumentMouseup); - } +function convertToSvgPoint(pt, svg, viewport) { + var result = {}; + viewport = viewport || getMetadata(svg).viewport; -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.enableRect = enableRect; - exports.disableRect = disableRect; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - var _enabled = false; - var _type = void 0; - var overlay = void 0; - var originY = void 0; - var originX = void 0; - - /** - * Get the current window selection as rects - * - * @return {Array} An Array of rects - */ - function getSelectionRects() { - try { - var selection = window.getSelection(); - var range = selection.getRangeAt(0); - var rects = range.getClientRects(); - - if (rects.length > 0 && rects[0].width > 0 && rects[0].height > 0) { - return rects; - } - } catch (e) {} - - return null; - } - - /** - * Handle document.mousedown event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentMousedown(e) { - var svg = void 0; - if (_type !== 'area' || !(svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY))) { - return; - } - - var rect = svg.getBoundingClientRect(); - originY = e.clientY; - originX = e.clientX; - - overlay = document.createElement('div'); - overlay.style.position = 'absolute'; - overlay.style.top = originY - rect.top + 'px'; - overlay.style.left = originX - rect.left + 'px'; - overlay.style.border = '3px solid ' + _utils.BORDER_COLOR; - overlay.style.borderRadius = '3px'; - svg.parentNode.appendChild(overlay); - - document.addEventListener('mousemove', handleDocumentMousemove); - (0, _utils.disableUserSelect)(); - } - - /** - * Handle document.mousemove event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentMousemove(e) { - var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); - var rect = svg.getBoundingClientRect(); - - if (originX + (e.clientX - originX) < rect.right) { - overlay.style.width = e.clientX - originX + 'px'; - } - - if (originY + (e.clientY - originY) < rect.bottom) { - overlay.style.height = e.clientY - originY + 'px'; - } - } - - /** - * Handle document.mouseup event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentMouseup(e) { - var rects = void 0; - if (_type !== 'area' && (rects = getSelectionRects())) { - var svg = (0, _utils.findSVGAtPoint)(rects[0].left, rects[0].top); - saveRect(_type, [].concat(_toConsumableArray(rects)).map(function (r) { - return { - top: r.top, - left: r.left, - width: r.width, - height: r.height - }; - })); - } else if (_type === 'area' && overlay) { - var _svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); - var rect = _svg.getBoundingClientRect(); - saveRect(_type, [{ - top: parseInt(overlay.style.top, 10) + rect.top, - left: parseInt(overlay.style.left, 10) + rect.left, - width: parseInt(overlay.style.width, 10), - height: parseInt(overlay.style.height, 10) - }]); - - overlay.parentNode.removeChild(overlay); - overlay = null; - - document.removeEventListener('mousemove', handleDocumentMousemove); - (0, _utils.enableUserSelect)(); - } - } - - /** - * Handle document.keyup event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentKeyup(e) { - // Cancel rect if Esc is pressed - if (e.keyCode === 27) { - var selection = window.getSelection(); - selection.removeAllRanges(); - if (overlay && overlay.parentNode) { - overlay.parentNode.removeChild(overlay); - overlay = null; - document.removeEventListener('mousemove', handleDocumentMousemove); - } - } - } - - /** - * Save a rect annotation - * - * @param {String} type The type of rect (area, highlight, strikeout) - * @param {Array} rects The rects to use for annotation - * @param {String} color The color of the rects - */ - function saveRect(type, rects, color) { - var svg = (0, _utils.findSVGAtPoint)(rects[0].left, rects[0].top); - var annotation = void 0; - - if (!svg) { - return; - } - - var boundingRect = svg.getBoundingClientRect(); - - if (!color) { - if (type === 'highlight') { - color = 'FFFF00'; - } else if (type === 'strikeout') { - color = 'FF0000'; - } - } - - // Initialize the annotation - annotation = { - type: type, - color: color, - rectangles: [].concat(_toConsumableArray(rects)).map(function (r) { - var offset = 0; - - if (type === 'strikeout') { - offset = r.height / 2; - } - - return (0, _utils.convertToSvgRect)({ - y: r.top + offset - boundingRect.top, - x: r.left - boundingRect.left, - width: r.width, - height: r.height - }, svg); - }).filter(function (r) { - return r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1; - }) - }; - - // Short circuit if no rectangles exist - if (annotation.rectangles.length === 0) { - return; - } - - // Special treatment for area as it only supports a single rect - if (type === 'area') { - var rect = annotation.rectangles[0]; - delete annotation.rectangles; - annotation.x = rect.x; - annotation.y = rect.y; - annotation.width = rect.width; - annotation.height = rect.height; - } - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId, - pageNumber = _getMetadata.pageNumber; - - // Add the annotation - - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { - (0, _appendChild.appendChild)(svg, annotation); - }); - } - - /** - * Enable rect behavior - */ - function enableRect(type) { - _type = type; - - if (_enabled) { - return; - } - - _enabled = true; - document.addEventListener('mouseup', handleDocumentMouseup); - document.addEventListener('mousedown', handleDocumentMousedown); - document.addEventListener('keyup', handleDocumentKeyup); - } - - /** - * Disable rect behavior - */ - function disableRect() { - if (!_enabled) { - return; - } - - _enabled = false; - document.removeEventListener('mouseup', handleDocumentMouseup); - document.removeEventListener('mousedown', handleDocumentMousedown); - document.removeEventListener('keyup', handleDocumentKeyup); - } + var xform = [1, 0, 0, 1, 0, 0]; + xform = (0, _mathUtils.scale)(xform, viewport.scale, viewport.scale); + xform = (0, _mathUtils.rotate)(xform, viewport.rotation); -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.setCircle = setCircle; - exports.enableCircle = enableCircle; - exports.disableCircle = disableCircle; - exports.addCircle = addCircle; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var _enabled = false; - var _type = void 0; - var _circleRadius = 10; - var _circleColor = '0000FF'; - - /** - * Set the attributes of the pen. - * - * @param {Number} circleRadius The radius of the circle - * @param {String} circleColor The color of the circle - */ - function setCircle() { - var circleRadius = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; - var circleColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0000FF'; - - _circleRadius = parseInt(circleRadius, 10); - _circleColor = circleColor; - } - - /** - * Handle document.mouseup event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentMouseup(e) { - var svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY); - if (!svg) { - return; - } - var rect = svg.getBoundingClientRect(); - saveCircle(svg, _type, { - x: e.clientX - rect.left, - y: e.clientY - rect.top - }, _circleRadius, _circleColor); - } - - /** - * Save a circle annotation - * - * @param {String} type The type of circle (circle, emptycircle, fillcircle) - * @param {Object} pt The point to use for annotation - * @param {String} color The color of the rects - */ - function saveCircle(svg, type, pt, radius, color) { - // Initialize the annotation - var svg_pt = (0, _utils.convertToSvgPoint)([pt.x, pt.y], svg); - var annotation = { - type: type, - color: color, - cx: svg_pt[0], - cy: svg_pt[1], - r: radius - }; - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId, - pageNumber = _getMetadata.pageNumber; - - // Add the annotation - - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { - (0, _appendChild.appendChild)(svg, annotation); - }); - } - - /** - * Enable circle behavior - */ - function enableCircle(type) { - _type = type; - - if (_enabled) { - return; - } - - _enabled = true; - document.addEventListener('mouseup', handleDocumentMouseup); - } - - /** - * Disable circle behavior - */ - function disableCircle() { - if (!_enabled) { - return; - } - - _enabled = false; - document.removeEventListener('mouseup', handleDocumentMouseup); - } - - function addCircle(type, e) { - var oldType = _type; - _type = type; - handleDocumentMouseup(e); - _type = oldType; - } + var offset = (0, _appendChild.getTranslation)(viewport); + xform = (0, _mathUtils.translate)(xform, offset.x, offset.y); -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.setText = setText; - exports.enableText = enableText; - exports.disableText = disableText; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _appendChild = __webpack_require__(8); - - var _utils = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - var _enabled = false; - var input = void 0; - var _textSize = void 0; - var _textColor = void 0; - - /** - * Handle document.mouseup event - * - * @param {Event} e The DOM event to handle - */ - function handleDocumentMouseup(e) { - if (input || !(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { - return; - } - if (!e.srcElement.classList.contains('annotationLayer')) { - return; - } - input = document.createElement('input'); - input.setAttribute('id', 'pdf-annotate-text-input'); - input.setAttribute('placeholder', 'Enter text'); - input.style.border = '3px solid ' + _utils.BORDER_COLOR; - input.style.borderRadius = '3px'; - input.style.position = 'absolute'; - input.style.top = e.clientY + 'px'; - input.style.left = e.clientX + 'px'; - input.style.fontSize = _textSize + 'px'; - input.style.zIndex = "41"; - input.addEventListener('blur', handleInputBlur); - input.addEventListener('keyup', handleInputKeyup); - - document.body.appendChild(input); - input.focus(); - } - - /** - * Handle input.blur event - */ - function handleInputBlur() { - saveText(); - } - - /** - * Handle input.keyup event - * - * @param {Event} e The DOM event to handle - */ - function handleInputKeyup(e) { - if (e.keyCode === 27) { - closeInput(); - } else if (e.keyCode === 13) { - saveText(); - } - } - - /** - * Save a text annotation from input - */ - function saveText() { - if (input.value.trim().length > 0) { - var clientX = parseInt(input.style.left, 10); - var clientY = parseInt(input.style.top, 10); - var svg = (0, _utils.findSVGAtPoint)(clientX, clientY); - if (!svg) { - return; - } - var height = _textSize; - - var _getMetadata = (0, _utils.getMetadata)(svg), - documentId = _getMetadata.documentId, - userId = _getMetadata.userId, - pageNumber = _getMetadata.pageNumber, - viewport = _getMetadata.viewport; - - var scale = 1 / viewport.scale; - var rect = svg.getBoundingClientRect(); - var pt = (0, _utils.convertToSvgPoint)([clientX - rect.left, clientY - rect.top + height], svg, viewport); - var annotation = { - type: 'textbox', - size: _textSize * scale, - color: _textColor, - content: input.value.trim(), - x: pt[0], - y: pt[1], - rotation: -viewport.rotation - }; - - _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { - (0, _appendChild.appendChild)(svg, annotation); - }); - } - - closeInput(); - } - - /** - * Close the input - */ - function closeInput() { - if (input) { - input.removeEventListener('blur', handleInputBlur); - input.removeEventListener('keyup', handleInputKeyup); - document.body.removeChild(input); - input = null; - } - } - - /** - * Set the text attributes - * - * @param {Number} textSize The size of the text - * @param {String} textColor The color of the text - */ - function setText() { - var textSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 12; - var textColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '000000'; - - _textSize = parseInt(textSize, 10); - _textColor = textColor; - } - - /** - * Enable text behavior - */ - function enableText() { - if (_enabled) { - return; - } - - _enabled = true; - document.addEventListener('mouseup', handleDocumentMouseup); - } - - /** - * Disable text behavior - */ - function disableText() { - if (!_enabled) { - return; - } - - _enabled = false; - document.removeEventListener('mouseup', handleDocumentMouseup); - } + return (0, _mathUtils.applyInverseTransform)(pt, xform); +} -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); - - exports.createPage = createPage; - exports.renderPage = renderPage; - - var _PDFJSAnnotate = __webpack_require__(1); - - var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); - - var _config = __webpack_require__(27); - - var _config2 = _interopRequireDefault(_config); - - var _renderScreenReaderHints = __webpack_require__(23); - - var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - // Template for creating a new page - var PAGE_TEMPLATE = '\n \n'; - - /** - * Create a new page to be appended to the DOM. - * - * @param {Number} pageNumber The page number that is being created - * @return {HTMLElement} - */ - function createPage(pageNumber) { - var temp = document.createElement('div'); - temp.innerHTML = PAGE_TEMPLATE; - - var page = temp.children[0]; - var canvas = page.querySelector('canvas'); - - page.setAttribute('id', 'pageContainer' + pageNumber); - page.setAttribute('data-page-number', pageNumber); - - canvas.mozOpaque = true; - canvas.setAttribute('id', 'page' + pageNumber); - - return page; - } - - /** - * Render a page that has already been created. - * - * @param {Number} pageNumber The page number to be rendered - * @param {Object} renderOptions The options for rendering - * @return {Promise} Settled once rendering has completed - * A settled Promise will be either: - * - fulfilled: [pdfPage, annotations] - * - rejected: Error - */ - function renderPage(pageNumber, renderOptions) { - var documentId = renderOptions.documentId, - userId = renderOptions.userId, - pdfDocument = renderOptions.pdfDocument, - scale = renderOptions.scale, - rotate = renderOptions.rotate; - - // Load the page and annotations - - return Promise.all([pdfDocument.getPage(pageNumber), _PDFJSAnnotate2.default.getAnnotations(documentId, userId, pageNumber)]).then(function (_ref) { - var _ref2 = _slicedToArray(_ref, 2), - pdfPage = _ref2[0], - annotations = _ref2[1]; - - var page = document.getElementById('pageContainer' + pageNumber); - var svg = page.querySelector(_config2.default.annotationClassQuery()); - var canvas = page.querySelector('.canvasWrapper canvas'); - var canvasContext = canvas.getContext('2d', { alpha: false }); - var totalRotation = (rotate + pdfPage.rotate) % 360; - var viewport = pdfPage.getViewport(scale, totalRotation); - var transform = scalePage(pageNumber, viewport, canvasContext); - - // Render the page - return Promise.all([pdfPage.render({ canvasContext: canvasContext, viewport: viewport, transform: transform }), _PDFJSAnnotate2.default.render(svg, viewport, annotations)]).then(function () { - // Text content is needed for a11y, but is also necessary for creating - // highlight and strikeout annotations which require selecting text. - return pdfPage.getTextContent({ normalizeWhitespace: true }).then(function (textContent) { - return new Promise(function (resolve, reject) { - // Render text layer for a11y of text content - var textLayer = page.querySelector(_config2.default.textClassQuery()); - var textLayerFactory = new PDFJS.DefaultTextLayerFactory(); - var textLayerBuilder = textLayerFactory.createTextLayerBuilder(textLayer, pageNumber - 1, viewport); - textLayerBuilder.setTextContent(textContent); - textLayerBuilder.render(); - - // Enable a11y for annotations - // Timeout is needed to wait for `textLayerBuilder.render` - setTimeout(function () { - try { - (0, _renderScreenReaderHints2.default)(annotations.annotations); - resolve(); - } catch (e) { - reject(e); - } - }); - }); - }); - }).then(function () { - // Indicate that the page was loaded - page.setAttribute('data-loaded', 'true'); - - return [pdfPage, annotations]; - }); - }); - } - - /** - * Scale the elements of a page. - * - * @param {Number} pageNumber The page number to be scaled - * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate)) - * @param {Object} context The canvas context that the PDF page is rendered to - * @return {Array} The transform data for rendering the PDF page - */ - function scalePage(pageNumber, viewport, context) { - var page = document.getElementById('pageContainer' + pageNumber); - var canvas = page.querySelector('.canvasWrapper canvas'); - var svg = page.querySelector(_config2.default.annotationClassQuery()); - var wrapper = page.querySelector('.canvasWrapper'); - var textLayer = page.querySelector(_config2.default.textClassQuery()); - var outputScale = getOutputScale(context); - var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; - var sfx = approximateFraction(outputScale.sx); - var sfy = approximateFraction(outputScale.sy); - - // Adjust width/height for scale - page.style.visibility = ''; - canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]); - canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]); - canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px'; - canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px'; - svg.setAttribute('width', viewport.width); - svg.setAttribute('height', viewport.height); - svg.style.width = viewport.width + 'px'; - svg.style.height = viewport.height + 'px'; - page.style.width = viewport.width + 'px'; - page.style.height = viewport.height + 'px'; - wrapper.style.width = viewport.width + 'px'; - wrapper.style.height = viewport.height + 'px'; - textLayer.style.width = viewport.width + 'px'; - textLayer.style.height = viewport.height + 'px'; - - return transform; - } - - /** - * Approximates a float number as a fraction using Farey sequence (max order of 8). - * - * @param {Number} x Positive float number - * @return {Array} Estimated fraction: the first array item is a numerator, - * the second one is a denominator. - */ - function approximateFraction(x) { - // Fast path for int numbers or their inversions. - if (Math.floor(x) === x) { - return [x, 1]; - } - - var xinv = 1 / x; - var limit = 8; - if (xinv > limit) { - return [1, limit]; - } else if (Math.floor(xinv) === xinv) { - return [1, xinv]; - } - - var x_ = x > 1 ? xinv : x; - - // a/b and c/d are neighbours in Farey sequence. - var a = 0, - b = 1, - c = 1, - d = 1; - - // Limit search to order 8. - while (true) { - // Generating next term in sequence (order of q). - var p = a + c, - q = b + d; - if (q > limit) { - break; - } - if (x_ <= p / q) { - c = p;d = q; - } else { - a = p;b = q; - } - } - - // Select closest of neighbours to x. - if (x_ - a / b < c / d - x_) { - return x_ === x ? [a, b] : [b, a]; - } else { - return x_ === x ? [c, d] : [d, c]; - } - } - - function getOutputScale(ctx) { - var devicePixelRatio = window.devicePixelRatio || 1; - var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1; - var pixelRatio = devicePixelRatio / backingStoreRatio; - return { - sx: pixelRatio, - sy: pixelRatio, - scaled: pixelRatio !== 1 - }; - } - - function roundToDivide(x, div) { - var r = x % div; - return r === 0 ? x : Math.round(x - r + div); - } +function convertToScreenPoint(pt, svg, viewport) { + var result = {}; + viewport = viewport || getMetadata(svg).viewport; + + var xform = [1, 0, 0, 1, 0, 0]; + xform = (0, _mathUtils.scale)(xform, viewport.scale, viewport.scale); + xform = (0, _mathUtils.rotate)(xform, viewport.rotation); + + var offset = (0, _appendChild.getTranslation)(viewport); + xform = (0, _mathUtils.translate)(xform, offset.x, offset.y); + + return (0, _mathUtils.applyTransform)(pt, xform); +} + +/** + * Adjust scale from rendered scale to a normalized scale (100%). + * + * @param {SVGElement} svg The SVG to gather metadata from + * @param {Object} rect A map of numeric values to scale + * @return {Object} A copy of `rect` with values scaled down + */ +function scaleDown(svg, rect) { + var result = {}; + + var _getMetadata2 = getMetadata(svg), + viewport = _getMetadata2.viewport; + + Object.keys(rect).forEach(function (key) { + result[key] = rect[key] / viewport.scale; + }); + + return result; +} + +/** + * Get the scroll position of an element, accounting for parent elements + * + * @param {Element} el The element to get the scroll position for + * @return {Object} The scrollTop and scrollLeft position + */ +function getScroll(el) { + var scrollTop = 0; + var scrollLeft = 0; + var parentNode = el; + + while ((parentNode = parentNode.parentNode) && parentNode !== document) { + scrollTop += parentNode.scrollTop; + scrollLeft += parentNode.scrollLeft; + } + + return { scrollTop: scrollTop, scrollLeft: scrollLeft }; +} + +/** + * Get the offset position of an element, accounting for parent elements + * + * @param {Element} el The element to get the offset position for + * @return {Object} The offsetTop and offsetLeft position + */ +function getOffset(el) { + var parentNode = el; + + while ((parentNode = parentNode.parentNode) && parentNode !== document) { + if (parentNode.nodeName.toUpperCase() === 'SVG') { + break; + } + } + + var rect = parentNode.getBoundingClientRect(); + + return { offsetLeft: rect.left, offsetTop: rect.top }; +} + +/** + * Disable user ability to select text on page + */ +function disableUserSelect() { + if (!userSelectStyleSheet.parentNode) { + document.head.appendChild(userSelectStyleSheet); + } +} + +/** + * Enable user ability to select text on page + */ +function enableUserSelect() { + if (userSelectStyleSheet.parentNode) { + userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet); + } +} + +/** + * Get the metadata for a SVG container + * + * @param {SVGElement} svg The SVG container to get metadata for + */ +function getMetadata(svg) { + return { + documentId: svg.getAttribute('data-pdf-annotate-document'), + userId: svg.getAttribute('data-pdf-annotate-user'), + pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10), + viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')) + }; +} + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getTranslation = getTranslation; +exports.appendChild = appendChild; +exports.transformChild = transformChild; + +var _objectAssign = __webpack_require__(19); + +var _objectAssign2 = _interopRequireDefault(_objectAssign); + +var _renderLine = __webpack_require__(20); + +var _renderLine2 = _interopRequireDefault(_renderLine); + +var _renderPath = __webpack_require__(21); + +var _renderPath2 = _interopRequireDefault(_renderPath); + +var _renderPoint = __webpack_require__(22); + +var _renderPoint2 = _interopRequireDefault(_renderPoint); + +var _renderRect = __webpack_require__(23); + +var _renderRect2 = _interopRequireDefault(_renderRect); + +var _renderText = __webpack_require__(24); + +var _renderText2 = _interopRequireDefault(_renderText); + +var _renderCircle = __webpack_require__(25); + +var _renderCircle2 = _interopRequireDefault(_renderCircle); + +var _renderArrow = __webpack_require__(26); + +var _renderArrow2 = _interopRequireDefault(_renderArrow); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var isFirefox = /firefox/i.test(navigator.userAgent); + +/** + * Get the x/y translation to be used for transforming the annotations + * based on the rotation of the viewport. + * + * @param {Object} viewport The viewport data from the page + * @return {Object} + */ +function getTranslation(viewport) { + var x = void 0; + var y = void 0; + + // Modulus 360 on the rotation so that we only + // have to worry about four possible values. + switch (viewport.rotation % 360) { + case 0: + x = y = 0; + break; + case 90: + x = 0; + y = viewport.width / viewport.scale * -1; + break; + case 180: + x = viewport.width / viewport.scale * -1; + y = viewport.height / viewport.scale * -1; + break; + case 270: + x = viewport.height / viewport.scale * -1; + y = 0; + break; + } + + return { x: x, y: y }; +} + +/** + * Transform the rotation and scale of a node using SVG's native transform attribute. + * + * @param {Node} node The node to be transformed + * @param {Object} viewport The page's viewport data + * @return {Node} + */ +function transform(node, viewport) { + var trans = getTranslation(viewport); + + // Let SVG natively transform the element + node.setAttribute('transform', 'scale(' + viewport.scale + ') rotate(' + viewport.rotation + ') translate(' + trans.x + ', ' + trans.y + ')'); + + // Manually adjust x/y for nested SVG nodes + if (!isFirefox && node.nodeName.toLowerCase() === 'svg') { + node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale); + node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale); + + var x = parseInt(node.getAttribute('x', 10)); + var y = parseInt(node.getAttribute('y', 10)); + var width = parseInt(node.getAttribute('width'), 10); + var height = parseInt(node.getAttribute('height'), 10); + var path = node.querySelector('path'); + var svg = path.parentNode; + + // Scale width/height + [node, svg, path, node.querySelector('rect')].forEach(function (n) { + n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale); + n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale); + }); + + // Transform path but keep scale at 100% since it will be handled natively + transform(path, (0, _objectAssign2.default)({}, viewport, { scale: 1 })); + + switch (viewport.rotation % 360) { + case 90: + node.setAttribute('x', viewport.width - y - width); + node.setAttribute('y', x); + svg.setAttribute('x', 1); + svg.setAttribute('y', 0); + break; + case 180: + node.setAttribute('x', viewport.width - x - width); + node.setAttribute('y', viewport.height - y - height); + svg.setAttribute('y', 2); + break; + case 270: + node.setAttribute('x', y); + node.setAttribute('y', viewport.height - x - height); + svg.setAttribute('x', -1); + svg.setAttribute('y', 0); + break; + } + } + + return node; +} + +/** + * Append an annotation as a child of an SVG. + * + * @param {SVGElement} svg The SVG element to append the annotation to + * @param {Object} annotation The annotation definition to render and append + * @param {Object} viewport The page's viewport data + * @return {SVGElement} A node that was created and appended by this function + */ +function appendChild(svg, annotation, viewport) { + if (!viewport) { + viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')); + } + + var child = void 0; + switch (annotation.type) { + case 'area': + case 'highlight': + child = (0, _renderRect2.default)(annotation); + break; + case 'circle': + case 'fillcircle': + case 'emptycircle': + child = (0, _renderCircle2.default)(annotation); + break; + case 'strikeout': + child = (0, _renderLine2.default)(annotation); + break; + case 'point': + child = (0, _renderPoint2.default)(annotation); + break; + case 'textbox': + child = (0, _renderText2.default)(annotation); + break; + case 'drawing': + child = (0, _renderPath2.default)(annotation); + break; + case 'arrow': + child = (0, _renderArrow2.default)(annotation); + break; + } + + // If no type was provided for an annotation it will result in node being null. + // Skip appending/transforming if node doesn't exist. + if (child) { + // Set attributes + child.setAttribute('data-pdf-annotate-id', annotation.uuid); + child.setAttribute('data-pdf-annotate-type', annotation.type); + child.setAttribute('data-pdf-annotate-userId', annotation.userId); + child.setAttribute('aria-hidden', true); + + svg.appendChild(transform(child, viewport)); + } + + return child; +} + +/** + * Transform a child annotation of an SVG. + * + * @param {SVGElement} svg The SVG element with the child annotation + * @param {Object} child The SVG child to transform + * @param {Object} viewport The page's viewport data + * @return {SVGElement} A node that was transformed by this function + */ +function transformChild(svg, child, viewport) { + if (!viewport) { + viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')); + } + + // If no type was provided for an annotation it will result in node being null. + // Skip transforming if node doesn't exist. + if (child) { + child = transform(child, viewport); + } + + return child; +} + +exports.default = { + /** + * Get the x/y translation to be used for transforming the annotations + * based on the rotation of the viewport. + */ + getTranslation: getTranslation, + + /** + * Append an SVG child for an annotation + */ + appendChild: appendChild, + + /** + * Transform an existing SVG child + */ + transformChild: transformChild +}; + +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = { + annotationLayerName: 'annotationLayer', + textLayerName: 'textLayer', + annotationSvgQuery: function annotationSvgQuery() { + return 'svg.' + this.annotationLayerName; + }, + annotationClassQuery: function annotationClassQuery() { + return '.' + this.annotationLayerName; + }, + textClassQuery: function textClassQuery() { + return '.' + this.textLayerName; + } +}; +module.exports = exports['default']; + +/***/ }), +/* 4 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = setAttributes; +var UPPER_REGEX = /[A-Z]/g; + +// Don't convert these attributes from camelCase to hyphenated-attributes +var BLACKLIST = ['viewBox']; + +var keyCase = function keyCase(key) { + if (BLACKLIST.indexOf(key) === -1) { + key = key.replace(UPPER_REGEX, function (match) { + return '-' + match.toLowerCase(); + }); + } + return key; +}; + +/** + * Set attributes for a node from a map + * + * @param {Node} node The node to set attributes on + * @param {Object} attributes The map of key/value pairs to use for attributes + */ +function setAttributes(node, attributes) { + Object.keys(attributes).forEach(function (key) { + node.setAttribute(keyCase(key), attributes[key]); + }); +} +module.exports = exports['default']; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = normalizeColor; +var REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i; + +/** + * Normalize a color value + * + * @param {String} color The color to normalize + * @return {String} + */ +function normalizeColor(color) { + if (REGEX_HASHLESS_HEX.test(color)) { + color = "#" + color; + } + return color; +} +module.exports = exports["default"]; + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.fireEvent = fireEvent; +exports.addEventListener = addEventListener; +exports.removeEventListener = removeEventListener; + +var _events = __webpack_require__(17); + +var _events2 = _interopRequireDefault(_events); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var emitter = new _events2.default(); + +var clickNode = void 0; + +/** + * Handle document.click event + * + * @param {Event} e The DOM event to be handled + */ +document.addEventListener('click', function handleDocumentClick(e) { + if (!(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { + return; + } + + var target = (0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY); + + // Emit annotation:blur if clickNode is no longer clicked + if (clickNode && clickNode !== target) { + emitter.emit('annotation:blur', clickNode); + } + + // Emit annotation:click if target was clicked + if (target) { + emitter.emit('annotation:click', target); + } + + clickNode = target; +}); + +// let mouseOverNode; +// document.addEventListener('mousemove', function handleDocumentMousemove(e) { +// let target = findAnnotationAtPoint(e.clientX, e.clientY); +// +// // Emit annotation:mouseout if target was mouseout'd +// if (mouseOverNode && !target) { +// emitter.emit('annotation:mouseout', mouseOverNode); +// } +// +// // Emit annotation:mouseover if target was mouseover'd +// if (target && mouseOverNode !== target) { +// emitter.emit('annotation:mouseover', target); +// } +// +// mouseOverNode = target; +// }); + +function fireEvent() { + emitter.emit.apply(emitter, arguments); +}; +function addEventListener() { + emitter.on.apply(emitter, arguments); +}; +function removeEventListener() { + emitter.removeListener.apply(emitter, arguments); +}; + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderScreenReaderHints; + +var _insertScreenReaderHint = __webpack_require__(11); + +var _insertScreenReaderHint2 = _interopRequireDefault(_insertScreenReaderHint); + +var _initEventHandlers = __webpack_require__(31); + +var _initEventHandlers2 = _interopRequireDefault(_initEventHandlers); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// TODO This is not the right place for this to live +(0, _initEventHandlers2.default)(); + +/** + * Insert hints into the DOM for screen readers. + * + * @param {Array} annotations The annotations that hints are inserted for + */ +function renderScreenReaderHints(annotations) { + annotations = Array.isArray(annotations) ? annotations : []; + + // Insert hints for each type + Object.keys(SORT_TYPES).forEach(function (type) { + var sortBy = SORT_TYPES[type]; + annotations.filter(function (a) { + return a.type === type; + }).sort(sortBy).forEach(function (a, i) { + return (0, _insertScreenReaderHint2.default)(a, i + 1); + }); + }); +} + +// Sort annotations first by y, then by x. +// This allows hints to be injected in the order they appear, +// which makes numbering them easier. +function sortByPoint(a, b) { + if (a.y < b.y) { + return a.x - b.x; + } else { + return 1; + } +} + +// Sort annotation by it's first rectangle +function sortByRectPoint(a, b) { + return sortByPoint(a.rectangles[0], b.rectangles[0]); +} + +// Sort annotation by it's first line +function sortByLinePoint(a, b) { + var lineA = a.lines[0]; + var lineB = b.lines[0]; + return sortByPoint({ x: lineA[0], y: lineA[1] }, { x: lineB[0], y: lineB[1] }); +} + +// Arrange supported types and associated sort methods +var SORT_TYPES = { + 'highlight': sortByRectPoint, + 'strikeout': sortByRectPoint, + 'drawing': sortByLinePoint, + 'textbox': sortByPoint, + 'point': sortByPoint, + 'area': sortByPoint +}; +module.exports = exports['default']; + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _abstractFunction = __webpack_require__(16); + +var _abstractFunction2 = _interopRequireDefault(_abstractFunction); + +var _event = __webpack_require__(6); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +// Adapter should never be invoked publicly +var StoreAdapter = function () { + /** + * Create a new StoreAdapter instance + * + * @param {Object} [definition] The definition to use for overriding abstract methods + */ + function StoreAdapter() { + var _this = this; + + var definition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + _classCallCheck(this, StoreAdapter); + + // Copy each function from definition if it is a function we know about + Object.keys(definition).forEach(function (key) { + if (typeof definition[key] === 'function' && typeof _this[key] === 'function') { + _this[key] = definition[key]; + } + }); + } + + /** + * Get all the annotations for a given document and page number. + * + * @param {String} documentId The ID for the document the annotations belong to + * @param {String} userId The user makeing changes to this document + * @param {Number} pageNumber The number of the page the annotations belong to + * @return {Promise} + */ + + + _createClass(StoreAdapter, [{ + key: '__getAnnotations', + value: function __getAnnotations(documentId, userId, pageNumber) { + (0, _abstractFunction2.default)('getAnnotations'); + } + }, { + key: 'getAnnotation', + + + /** + * Get the definition for a specific annotation. + * + * @param {String} documentId The ID for the document the annotation belongs to + * @param {String} userId + * @param {String} annotationId The ID for the annotation + * @return {Promise} + */ + value: function getAnnotation(documentId, userId, annotationId) { + (0, _abstractFunction2.default)('getAnnotation'); + } + + /** + * Add an annotation + * + * @param {String} documentId The ID for the document to add the annotation to + * @param {String} userId The ID of the user + * @param {String} pageNumber The page number to add the annotation to + * @param {Object} annotation The definition for the new annotation + * @return {Promise} + */ + + }, { + key: '__addAnnotation', + value: function __addAnnotation(documentId, userId, pageNumber, annotation) { + (0, _abstractFunction2.default)('addAnnotation'); + } + }, { + key: '__editAnnotation', + + + /** + * Edit an annotation + * + * @param {String} documentId The ID for the document + * @param {String} userId The Id of the user + * @param {String} pageNumber the page number of the annotation + * @param {Object} annotation The definition of the modified annotation + * @return {Promise} + */ + value: function __editAnnotation(documentId, userId, pageNumber, annotation) { + (0, _abstractFunction2.default)('editAnnotation'); + } + }, { + key: '__deleteAnnotation', + + + /** + * Delete an annotation + * + * @param {String} documentId The ID for the document + * @param {String} userId + * @param {String} annotationId The ID for the annotation + * @return {Promise} + */ + value: function __deleteAnnotation(documentId, userId, annotationId) { + (0, _abstractFunction2.default)('deleteAnnotation'); + } + }, { + key: 'getComments', + + + /** + * Get all the comments for an annotation + * + * @param {String} documentId The ID for the document + * @param {String} userId + * @param {String} annotationId The ID for the annotation + * @return {Promise} + */ + value: function getComments(documentId, userId, annotationId) { + (0, _abstractFunction2.default)('getComments'); + } + + /** + * Add a new comment + * + * @param {String} documentId The ID for the document + * @param {String} userId + * @param {String} annotationId The ID for the annotation + * @param {Object} content The definition of the comment + * @return {Promise} + */ + + }, { + key: '__addComment', + value: function __addComment(documentId, userId, annotationId, content) { + (0, _abstractFunction2.default)('addComment'); + } + }, { + key: '__deleteComment', + + + /** + * Delete a comment + * + * @param {String} documentId The ID for the document + * @param {String} userId + * @param {String} commentId The ID for the comment + * @return {Promise} + */ + value: function __deleteComment(documentId, userId, commentId) { + (0, _abstractFunction2.default)('deleteComment'); + } + }, { + key: 'getAnnotations', + get: function get() { + return this.__getAnnotations; + }, + set: function set(fn) { + this.__getAnnotations = function getAnnotations(documentId, userId, pageNumber) { + return fn.apply(undefined, arguments).then(function (annotations) { + // TODO may be best to have this happen on the server + if (annotations.annotations) { + annotations.annotations.forEach(function (a) { + a.documentId = documentId; + }); + } + return annotations; + }); + }; + } + }, { + key: 'addAnnotation', + get: function get() { + return this.__addAnnotation; + }, + set: function set(fn) { + this.__addAnnotation = function addAnnotation(documentId, userId, pageNumber, annotation) { + return fn.apply(undefined, arguments).then(function (annotation) { + (0, _event.fireEvent)('annotation:add', documentId, userId, pageNumber, annotation); + return annotation; + }); + }; + } + }, { + key: 'editAnnotation', + get: function get() { + return this.__editAnnotation; + }, + set: function set(fn) { + this.__editAnnotation = function editAnnotation(documentId, userId, annotationId, annotation) { + return fn.apply(undefined, arguments).then(function (annotation) { + (0, _event.fireEvent)('annotation:edit', documentId, userId, annotationId, annotation); + return annotation; + }); + }; + } + }, { + key: 'deleteAnnotation', + get: function get() { + return this.__deleteAnnotation; + }, + set: function set(fn) { + this.__deleteAnnotation = function deleteAnnotation(documentId, userId, annotationId) { + return fn.apply(undefined, arguments).then(function (success) { + if (success) { + (0, _event.fireEvent)('annotation:delete', documentId, userId, annotationId); + } + return success; + }); + }; + } + }, { + key: 'addComment', + get: function get() { + return this.__addComment; + }, + set: function set(fn) { + this.__addComment = function addComment(documentId, userId, annotationId, content) { + return fn.apply(undefined, arguments).then(function (comment) { + (0, _event.fireEvent)('comment:add', documentId, userId, annotationId, comment); + return comment; + }); + }; + } + }, { + key: 'deleteComment', + get: function get() { + return this.__deleteComment; + }, + set: function set(fn) { + this.__deleteComment = function deleteComment(documentId, userId, commentId) { + return fn.apply(undefined, arguments).then(function (success) { + if (success) { + (0, _event.fireEvent)('comment:delete', documentId, commentId); + } + return success; + }); + }; + } + }]); + + return StoreAdapter; +}(); + +exports.default = StoreAdapter; +module.exports = exports['default']; + +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.applyTransform = applyTransform; +exports.applyInverseTransform = applyInverseTransform; +exports.transform = transform; +exports.translate = translate; +exports.rotate = rotate; +exports.scale = scale; +exports.makePoint = makePoint; +exports.makeVector = makeVector; +exports.makeVectorFromPoints = makeVectorFromPoints; +exports.addVector = addVector; +exports.multiplyVector = multiplyVector; +exports.magnitude = magnitude; +exports.negateVector = negateVector; +exports.unitVector = unitVector; +exports.crossProduct = crossProduct; +// Transform point by matrix +// +function applyTransform(p, m) { + var xt = p[0] * m[0] + p[1] * m[2] + m[4]; + var yt = p[0] * m[1] + p[1] * m[3] + m[5]; + return [xt, yt]; +}; + +// Transform point by matrix inverse +// +function applyInverseTransform(p, m) { + var d = m[0] * m[3] - m[1] * m[2]; + var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; + var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; + return [xt, yt]; +}; + +// Concatenates two transformation matrices together and returns the result. +function transform(m1, m2) { + return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]]; +}; + +function translate(m, x, y) { + return [m[0], m[1], m[2], m[3], m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]; +}; + +function rotate(m, angle) { + angle = angle * Math.PI / 180; + + var cosValue = Math.cos(angle); + var sinValue = Math.sin(angle); + + return [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]]; +}; + +function scale(m, x, y) { + return [m[0] * x, m[1] * x, m[2] * y, m[3] * y, m[4], m[5]]; +}; + +function getInverseTransform(m) { + var d = m[0] * m[3] - m[1] * m[2]; + return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d]; +}; + +function makePoint(x, y, z) { + return { x: x, y: y, z: z }; +} + +function makeVector(xcoord, ycoord, zcoord) { + return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord }; +} + +function makeVectorFromPoints(pt1, pt2) { + var xcoord = pt2.x - pt1.x; + var ycoord = pt2.y - pt1.y; + var zcoord = pt2.z - pt1.z; + return makeVector(xcoord, ycoord, zcoord); +} + +function addVector(pt, v) { + return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord); +} + +function multiplyVector(v, scalar) { + return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar); +} + +function magnitude(v) { + return Math.sqrt(Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)); +} + +function negateVector(v) { + return multiplyVector(v, -1); +} + +function unitVector(v) { + var mag = magnitude(v); + var xcoord = v.xcoord / mag; + var ycoord = v.ycoord / mag; + var zcoord = v.zcoord / mag; + return makeVector(xcoord, ycoord, zcoord); +} + +function crossProduct(u, v) { + // + // u X v = < u2*v3 - u3*v2, + // u3*v1 - u1*v3, + // u1*v2 - u2*v1 > + var xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord; + var ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord; + var zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord; + return makeVector(xcoord, ycoord, zcoord); +} + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = uuid; +var REGEXP = /[xy]/g; +var PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; + +function replacement(c) { + var r = Math.random() * 16 | 0; + var v = c == 'x' ? r : r & 0x3 | 0x8; + return v.toString(16); +} + +/** + * Generate a univierally unique identifier + * + * @return {String} + */ +function uuid() { + return PATTERN.replace(REGEXP, replacement); +} +module.exports = exports['default']; + +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = insertScreenReaderHint; + +var _createScreenReaderOnly = __webpack_require__(29); + +var _createScreenReaderOnly2 = _interopRequireDefault(_createScreenReaderOnly); + +var _insertElementWithinChildren = __webpack_require__(30); + +var _insertElementWithinChildren2 = _interopRequireDefault(_insertElementWithinChildren); + +var _insertElementWithinElement = __webpack_require__(12); + +var _insertElementWithinElement2 = _interopRequireDefault(_insertElementWithinElement); + +var _renderScreenReaderComments = __webpack_require__(13); + +var _renderScreenReaderComments2 = _interopRequireDefault(_renderScreenReaderComments); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Annotation types that support comments +var COMMENT_TYPES = ['highlight', 'point', 'area', 'circle', 'emptycircle', 'fillcircle']; + +/** + * Insert a hint into the DOM for screen readers for a specific annotation. + * + * @param {Object} annotation The annotation to insert a hint for + * @param {Number} num The number of the annotation out of all annotations of the same type + */ +function insertScreenReaderHint(annotation) { + var num = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; + + switch (annotation.type) { + case 'highlight': + case 'strikeout': + var rects = annotation.rectangles; + var first = rects[0]; + var last = rects[rects.length - 1]; + + (0, _insertElementWithinElement2.default)((0, _createScreenReaderOnly2.default)('Begin ' + annotation.type + ' annotation ' + num, annotation.uuid), first.x, first.y, annotation.page, true); + + (0, _insertElementWithinElement2.default)((0, _createScreenReaderOnly2.default)('End ' + annotation.type + ' annotation ' + num, annotation.uuid + '-end'), last.x + last.width, last.y, annotation.page, false); + break; + + case 'textbox': + case 'point': + var text = annotation.type === 'textbox' ? ' (content: ' + annotation.content + ')' : ''; + + (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)(annotation.type + ' annotation ' + num + text, annotation.uuid), annotation.x, annotation.y, annotation.page); + break; + + case 'drawing': + case 'area': + var x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0]; + var y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1]; + + (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)('Unlabeled drawing', annotation.uuid), x, y, annotation.page); + break; + + case 'circle': + case 'fillcircle': + case 'emptycircle': + var x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0]; + var y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1]; + + (0, _insertElementWithinChildren2.default)((0, _createScreenReaderOnly2.default)('Unlabeled drawing', annotation.uuid), x2, y2, annotation.page); + break; + } + + // Include comments in screen reader hint + if (COMMENT_TYPES.includes(annotation.type)) { + (0, _renderScreenReaderComments2.default)(annotation.documentId, annotation.uuid); + } +} +module.exports = exports['default']; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = insertElementWithinElement; + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +/** + * Insert an element at a point within the document. + * This algorithm will only insert within an element amidst it's text content. + * + * @param {Element} el The element to be inserted + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @param {Number} pageNumber The page number to limit elements to + * @param {Boolean} insertBefore Whether the element is to be inserted before or after x + * @return {Boolean} True if element was able to be inserted, otherwise false + */ +function insertElementWithinElement(el, x, y, pageNumber, insertBefore) { + var OFFSET_ADJUST = 2; + + // If inserting before adjust `x` by looking for element a few px to the right + // Otherwise adjust a few px to the left + // This is to allow a little tolerance by searching within the box, instead + // of getting a false negative by testing right on the border. + x = Math.max(x + OFFSET_ADJUST * (insertBefore ? 1 : -1), 0); + + var node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber); + if (!node) { + return false; + } + + // Now that node has been found inverse the adjustment for `x`. + // This is done to accomodate tolerance by cutting off on the outside of the + // text boundary, instead of missing a character by cutting off within. + x = x + OFFSET_ADJUST * (insertBefore ? -1 : 1); + + var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); + var left = (0, _utils.scaleDown)(svg, { left: node.getBoundingClientRect().left }).left - svg.getBoundingClientRect().left; + var temp = node.cloneNode(true); + var head = temp.innerHTML.split(''); + var tail = []; + + // Insert temp off screen + temp.style.position = 'absolute'; + temp.style.top = '-10000px'; + temp.style.left = '-10000px'; + document.body.appendChild(temp); + + while (head.length) { + // Don't insert within HTML tags + if (head[head.length - 1] === '>') { + while (head.length) { + tail.unshift(head.pop()); + if (tail[0] === '<') { + break; + } + } + } + + // Check if width of temp based on current head value satisfies x + temp.innerHTML = head.join(''); + var width = (0, _utils.scaleDown)(svg, { width: temp.getBoundingClientRect().width }).width; + if (left + width <= x) { + break; + } + tail.unshift(head.pop()); + } + + // Update original node with new markup, including element to be inserted + node.innerHTML = head.join('') + el.outerHTML + tail.join(''); + temp.parentNode.removeChild(temp); + + return true; +} + +/** + * Get a text layer element at a given point on a page + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @param {Number} pageNumber The page to limit elements to + * @return {Element} First text layer element found at the point + */ +function textLayerElementFromPoint(x, y, pageNumber) { + var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); + var rect = svg.getBoundingClientRect(); + y = (0, _utils.scaleUp)(svg, { y: y }).y + rect.top; + x = (0, _utils.scaleUp)(svg, { x: x }).x + rect.left; + return [].concat(_toConsumableArray(svg.parentNode.querySelectorAll(_config2.default.textClassQuery() + ' [data-canvas-width]'))).filter(function (el) { + return (0, _utils.pointIntersectsRect)(x, y, el.getBoundingClientRect()); + })[0]; +} +module.exports = exports['default']; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderScreenReaderComments; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _insertScreenReaderComment = __webpack_require__(14); + +var _insertScreenReaderComment2 = _interopRequireDefault(_insertScreenReaderComment); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Insert the comments into the DOM to be available by screen reader + * + * Example output: + *
+ *
Begin highlight 1
+ *
    + *
  1. Foo
  2. + *
  3. Bar
  4. + *
  5. Baz
  6. + *
  7. Qux
  8. + *
+ *
+ *
Some highlighted text goes here...
+ *
End highlight 1
+ * + * NOTE: `screenReaderOnly` is not a real class, just used for brevity + * + * @param {String} documentId The ID of the document + * @param {String} annotationId The ID of the annotation + * @param {Array} [comments] Optionally preloaded comments to be rendered + * @return {Promise} + */ +function renderScreenReaderComments(documentId, annotationId, comments) { + var promise = void 0; + + if (Array.isArray(comments)) { + promise = Promise.resolve(comments); + } else { + promise = _PDFJSAnnotate2.default.getStoreAdapter().getComments(documentId, annotationId); + } + + return promise.then(function (comments) { + // Node needs to be found by querying DOM as it may have been inserted as innerHTML + // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`). + var node = document.getElementById('pdf-annotate-screenreader-' + annotationId); + if (node) { + var list = document.createElement('ol'); + list.setAttribute('id', 'pdf-annotate-screenreader-comment-list-' + annotationId); + list.setAttribute('aria-label', 'Comments'); + node.appendChild(list); + comments.forEach(_insertScreenReaderComment2.default); + } + }); +} +module.exports = exports['default']; + +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = insertScreenReaderComment; +/** + * Insert a comment into the DOM to be available by screen reader + * + * @param {Object} comment The comment to be inserted + */ +function insertScreenReaderComment(comment) { + if (!comment) { + return; + } + + var list = document.querySelector('#pdf-annotate-screenreader-' + comment.annotation + ' ol'); + if (list) { + var item = document.createElement('li'); + item.setAttribute('id', 'pdf-annotate-screenreader-comment-' + comment.uuid); + item.appendChild(document.createTextNode('' + comment.content)); + list.appendChild(item); + } +} +module.exports = exports['default']; + +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = _PDFJSAnnotate2.default; +module.exports = exports['default']; + +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = abstractFunction; +/** + * Throw an Error for an abstract function that hasn't been implemented. + * + * @param {String} name The name of the abstract function + */ +function abstractFunction(name) { + throw new Error(name + ' is not implemented'); +} +module.exports = exports['default']; + +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +var R = typeof Reflect === 'object' ? Reflect : null +var ReflectApply = R && typeof R.apply === 'function' + ? R.apply + : function ReflectApply(target, receiver, args) { + return Function.prototype.apply.call(target, receiver, args); + } + +var ReflectOwnKeys +if (R && typeof R.ownKeys === 'function') { + ReflectOwnKeys = R.ownKeys +} else if (Object.getOwnPropertySymbols) { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target) + .concat(Object.getOwnPropertySymbols(target)); + }; +} else { + ReflectOwnKeys = function ReflectOwnKeys(target) { + return Object.getOwnPropertyNames(target); + }; +} + +function ProcessEmitWarning(warning) { + if (console && console.warn) console.warn(warning); +} + +var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) { + return value !== value; +} + +function EventEmitter() { + EventEmitter.init.call(this); +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._eventsCount = 0; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +var defaultMaxListeners = 10; + +Object.defineProperty(EventEmitter, 'defaultMaxListeners', { + enumerable: true, + get: function() { + return defaultMaxListeners; + }, + set: function(arg) { + if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) { + throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.'); + } + defaultMaxListeners = arg; + } +}); + +EventEmitter.init = function() { + + if (this._events === undefined || + this._events === Object.getPrototypeOf(this)._events) { + this._events = Object.create(null); + this._eventsCount = 0; + } + + this._maxListeners = this._maxListeners || undefined; +}; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { + if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) { + throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.'); + } + this._maxListeners = n; + return this; +}; + +function $getMaxListeners(that) { + if (that._maxListeners === undefined) + return EventEmitter.defaultMaxListeners; + return that._maxListeners; +} + +EventEmitter.prototype.getMaxListeners = function getMaxListeners() { + return $getMaxListeners(this); +}; + +EventEmitter.prototype.emit = function emit(type) { + var args = []; + for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); + var doError = (type === 'error'); + + var events = this._events; + if (events !== undefined) + doError = (doError && events.error === undefined); + else if (!doError) + return false; + + // If there is no 'error' event listener then throw. + if (doError) { + var er; + if (args.length > 0) + er = args[0]; + if (er instanceof Error) { + // Note: The comments on the `throw` lines are intentional, they show + // up in Node's output if this results in an unhandled exception. + throw er; // Unhandled 'error' event + } + // At least give some kind of context to the user + var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : '')); + err.context = er; + throw err; // Unhandled 'error' event + } + + var handler = events[type]; + + if (handler === undefined) + return false; + + if (typeof handler === 'function') { + ReflectApply(handler, this, args); + } else { + var len = handler.length; + var listeners = arrayClone(handler, len); + for (var i = 0; i < len; ++i) + ReflectApply(listeners[i], this, args); + } + + return true; +}; + +function _addListener(target, type, listener, prepend) { + var m; + var events; + var existing; + + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + + events = target._events; + if (events === undefined) { + events = target._events = Object.create(null); + target._eventsCount = 0; + } else { + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (events.newListener !== undefined) { + target.emit('newListener', type, + listener.listener ? listener.listener : listener); + + // Re-assign `events` because a newListener handler could have caused the + // this._events to be assigned to a new object + events = target._events; + } + existing = events[type]; + } + + if (existing === undefined) { + // Optimize the case of one listener. Don't need the extra array object. + existing = events[type] = listener; + ++target._eventsCount; + } else { + if (typeof existing === 'function') { + // Adding the second element, need to change to array. + existing = events[type] = + prepend ? [listener, existing] : [existing, listener]; + // If we've already got an array, just append. + } else if (prepend) { + existing.unshift(listener); + } else { + existing.push(listener); + } + + // Check for listener leak + m = $getMaxListeners(target); + if (m > 0 && existing.length > m && !existing.warned) { + existing.warned = true; + // No error code for this since it is a Warning + // eslint-disable-next-line no-restricted-syntax + var w = new Error('Possible EventEmitter memory leak detected. ' + + existing.length + ' ' + String(type) + ' listeners ' + + 'added. Use emitter.setMaxListeners() to ' + + 'increase limit'); + w.name = 'MaxListenersExceededWarning'; + w.emitter = target; + w.type = type; + w.count = existing.length; + ProcessEmitWarning(w); + } + } + + return target; +} + +EventEmitter.prototype.addListener = function addListener(type, listener) { + return _addListener(this, type, listener, false); +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.prependListener = + function prependListener(type, listener) { + return _addListener(this, type, listener, true); + }; + +function onceWrapper() { + var args = []; + for (var i = 0; i < arguments.length; i++) args.push(arguments[i]); + if (!this.fired) { + this.target.removeListener(this.type, this.wrapFn); + this.fired = true; + ReflectApply(this.listener, this.target, args); + } +} + +function _onceWrap(target, type, listener) { + var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener }; + var wrapped = onceWrapper.bind(state); + wrapped.listener = listener; + state.wrapFn = wrapped; + return wrapped; +} + +EventEmitter.prototype.once = function once(type, listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + this.on(type, _onceWrap(this, type, listener)); + return this; +}; + +EventEmitter.prototype.prependOnceListener = + function prependOnceListener(type, listener) { + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + this.prependListener(type, _onceWrap(this, type, listener)); + return this; + }; + +// Emits a 'removeListener' event if and only if the listener was removed. +EventEmitter.prototype.removeListener = + function removeListener(type, listener) { + var list, events, position, i, originalListener; + + if (typeof listener !== 'function') { + throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener); + } + + events = this._events; + if (events === undefined) + return this; + + list = events[type]; + if (list === undefined) + return this; + + if (list === listener || list.listener === listener) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else { + delete events[type]; + if (events.removeListener) + this.emit('removeListener', type, list.listener || listener); + } + } else if (typeof list !== 'function') { + position = -1; + + for (i = list.length - 1; i >= 0; i--) { + if (list[i] === listener || list[i].listener === listener) { + originalListener = list[i].listener; + position = i; + break; + } + } + + if (position < 0) + return this; + + if (position === 0) + list.shift(); + else { + spliceOne(list, position); + } + + if (list.length === 1) + events[type] = list[0]; + + if (events.removeListener !== undefined) + this.emit('removeListener', type, originalListener || listener); + } + + return this; + }; + +EventEmitter.prototype.off = EventEmitter.prototype.removeListener; + +EventEmitter.prototype.removeAllListeners = + function removeAllListeners(type) { + var listeners, events, i; + + events = this._events; + if (events === undefined) + return this; + + // not listening for removeListener, no need to emit + if (events.removeListener === undefined) { + if (arguments.length === 0) { + this._events = Object.create(null); + this._eventsCount = 0; + } else if (events[type] !== undefined) { + if (--this._eventsCount === 0) + this._events = Object.create(null); + else + delete events[type]; + } + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + var keys = Object.keys(events); + var key; + for (i = 0; i < keys.length; ++i) { + key = keys[i]; + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = Object.create(null); + this._eventsCount = 0; + return this; + } + + listeners = events[type]; + + if (typeof listeners === 'function') { + this.removeListener(type, listeners); + } else if (listeners !== undefined) { + // LIFO order + for (i = listeners.length - 1; i >= 0; i--) { + this.removeListener(type, listeners[i]); + } + } + + return this; + }; + +function _listeners(target, type, unwrap) { + var events = target._events; + + if (events === undefined) + return []; + + var evlistener = events[type]; + if (evlistener === undefined) + return []; + + if (typeof evlistener === 'function') + return unwrap ? [evlistener.listener || evlistener] : [evlistener]; + + return unwrap ? + unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length); +} + +EventEmitter.prototype.listeners = function listeners(type) { + return _listeners(this, type, true); +}; + +EventEmitter.prototype.rawListeners = function rawListeners(type) { + return _listeners(this, type, false); +}; + +EventEmitter.listenerCount = function(emitter, type) { + if (typeof emitter.listenerCount === 'function') { + return emitter.listenerCount(type); + } else { + return listenerCount.call(emitter, type); + } +}; + +EventEmitter.prototype.listenerCount = listenerCount; +function listenerCount(type) { + var events = this._events; + + if (events !== undefined) { + var evlistener = events[type]; + + if (typeof evlistener === 'function') { + return 1; + } else if (evlistener !== undefined) { + return evlistener.length; + } + } + + return 0; +} + +EventEmitter.prototype.eventNames = function eventNames() { + return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : []; +}; + +function arrayClone(arr, n) { + var copy = new Array(n); + for (var i = 0; i < n; ++i) + copy[i] = arr[i]; + return copy; +} + +function spliceOne(list, index) { + for (; index + 1 < list.length; index++) + list[index] = list[index + 1]; + list.pop(); +} + +function unwrapListeners(arr) { + var ret = new Array(arr.length); + for (var i = 0; i < ret.length; ++i) { + ret[i] = arr[i].listener || arr[i]; + } + return ret; +} + + +/***/ }), +/* 18 */ +/***/ (function(module, exports) { + +module.exports = function createStyleSheet(blocks) { + var style = document.createElement('style'); + var text = Object.keys(blocks).map(function (selector) { + return processRuleSet(selector, blocks[selector]); + }).join('\n'); + + style.setAttribute('type', 'text/css'); + style.appendChild(document.createTextNode(text)); + + return style; +} + +function processRuleSet(selector, block) { + return selector + ' {\n' + processDeclarationBlock(block) + '\n}'; +} + +function processDeclarationBlock(block) { + return Object.keys(block).map(function (prop) { + return processDeclaration(prop, block[prop]); + }).join('\n'); +} + +function processDeclaration(prop, value) { + if (!isNaN(value) && value != 0) { + value = value + 'px'; + } + + return hyphenate(prop) + ': ' + value + ';'; +} + +function hyphenate(prop) { + return prop.replace(/[A-Z]/g, function (match) { + return '-' + match.toLowerCase(); + }); +} + + +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + + +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; + + +/***/ }), +/* 20 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderLine; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create SVGLineElements from an annotation definition. + * This is used for anntations of type `strikeout`. + * + * @param {Object} a The annotation definition + * @return {SVGGElement} A group of all lines to be rendered + */ +function renderLine(a) { + var group = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + (0, _setAttributes2.default)(group, { + stroke: (0, _normalizeColor2.default)(a.color || '#f00'), + strokeWidth: 1 + }); + + a.rectangles.forEach(function (r) { + var line = document.createElementNS('http://www.w3.org/2000/svg', 'line'); + + (0, _setAttributes2.default)(line, { + x1: r.x, + y1: r.y, + x2: r.x + r.width, + y2: r.y + }); + + group.appendChild(line); + }); + + return group; +} +module.exports = exports['default']; + +/***/ }), +/* 21 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderPath; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create SVGPathElement from an annotation definition. + * This is used for anntations of type `drawing`. + * + * @param {Object} a The annotation definition + * @return {SVGPathElement} The path to be rendered + */ +function renderPath(a) { + var d = []; + var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + + if (a.lines.length > 0) { + d.push('M' + a.lines[0][0] + ' ' + a.lines[0][1]); + for (var i = 1, l = a.lines.length; i < l; i++) { + var p1 = a.lines[i]; + var p2 = a.lines[i + 1]; + if (p2) { + d.push('L' + p1[0] + ' ' + p1[1]); + } + } + } + + /* + + if(a.lines.length>2) { + var p1 = a.lines[0]; + var p2 = a.lines[a.lines.length-1]; + + var p3 = []; //arrow + var p4 = []; + var p0 = []; //arrow intersection + + + + if (p2) { + var k = -(p2[0]-p1[0])/(p2[1]-p1[1]); + + var deltaX = 3; + p0[0] = p1[0]+0.8*(p2[0]-p1[0]); + p0[1] = p1[1]+0.8*(p2[1]-p1[1]); + + p3[0] = p0[0] + deltaX; + p3[1] = p0[1] + k*deltaX; + + p4[0] = p0[0] - deltaX; + p4[1] = p0[1] - k*deltaX; + + if(Math.abs(p2[1]-p1[1]) < 20) { + + p3[0] = p0[0] ; + p3[1] = p0[1] + deltaX*1; + + p4[0] = p0[0] ; + p4[1] = p0[1] - deltaX*1; + + } + + d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`); + //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`); + d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`); + d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`); + d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`); + } + }*/ + + (0, _setAttributes2.default)(path, { + d: '' + d.join(' '), //`${d.join(' ')}Z`, + stroke: (0, _normalizeColor2.default)(a.color || '#000'), + strokeWidth: a.width || 1, + fill: 'none' + }); + + return path; +} +module.exports = exports['default']; + +/***/ }), +/* 22 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderPoint; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var SIZE = 25; +var 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'; + +/** + * Create SVGElement from an annotation definition. + * This is used for anntations of type `comment`. + * + * @param {Object} a The annotation definition + * @return {SVGElement} A svg to be rendered + */ +function renderPoint(a) { + var outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + var innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + var path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + + (0, _setAttributes2.default)(outerSVG, { + width: SIZE, + height: SIZE, + x: a.x, + y: a.y + }); + + (0, _setAttributes2.default)(innerSVG, { + width: SIZE, + height: SIZE, + x: 0, + y: SIZE * 0.05 * -1, + viewBox: '0 0 1000 1000' + }); + + (0, _setAttributes2.default)(rect, { + width: SIZE, + height: SIZE, + stroke: '#000', + fill: '#ff0' + }); + + (0, _setAttributes2.default)(path, { + d: D, + strokeWidth: 50, + stroke: '#000', + fill: '#fff' + }); + + innerSVG.appendChild(path); + outerSVG.appendChild(rect); + outerSVG.appendChild(innerSVG); + + return outerSVG; +} +module.exports = exports['default']; + +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderRect; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create SVGRectElements from an annotation definition. + * This is used for anntations of type `area` and `highlight`. + * + * @param {Object} a The annotation definition + * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered + */ +function renderRect(a) { + if (a.type === 'highlight') { + var group = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + (0, _setAttributes2.default)(group, { + fill: (0, _normalizeColor2.default)(a.color || '#ff0'), + fillOpacity: 0.2 + }); + + a.rectangles.forEach(function (r) { + group.appendChild(createRect(r)); + }); + + return group; + } else { + var rect = createRect(a); + (0, _setAttributes2.default)(rect, { + stroke: (0, _normalizeColor2.default)(a.color || '#f00'), + fill: 'none' + }); + + return rect; + } +} + +function createRect(r) { + var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); + + (0, _setAttributes2.default)(rect, { + x: r.x, + y: r.y, + width: r.width, + height: r.height + }); + + return rect; +} +module.exports = exports['default']; + +/***/ }), +/* 24 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderText; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create SVGTextElement from an annotation definition. + * This is used for anntations of type `textbox`. + * + * @param {Object} a The annotation definition + * @return {SVGTextElement} A text to be rendered + */ +function renderText(a) { + + // Text should be rendered at 0 degrees relative to + // document rotation + var text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + (0, _setAttributes2.default)(text, { + x: a.x, + y: a.y, + fill: (0, _normalizeColor2.default)(a.color || '#000'), + fontSize: a.size, + transform: 'rotate(' + a.rotation + ')' + }); + text.innerHTML = a.content; + + var g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); + g.appendChild(text); + + return g; +} +module.exports = exports['default']; + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderCircle; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create an SVGCircleElement from an annotation definition. + * This is used for annotations of type `circle`. + * + * @param {Object} a The annotation definition + * @return {SVGGElement|SVGCircleElement} A circle to be rendered + */ +function renderCircle(a) { + var circle = createCircle(a); + var color = (0, _normalizeColor2.default)(a.color || '#f00'); + + if (a.type === 'circle') (0, _setAttributes2.default)(circle, { + stroke: color, + fill: 'none', + 'stroke-width': 5 + }); + if (a.type === 'emptycircle') (0, _setAttributes2.default)(circle, { + stroke: color, + fill: 'none', + 'stroke-width': 2 + }); + + if (a.type === 'fillcircle') (0, _setAttributes2.default)(circle, { + stroke: color, + fill: color, + 'stroke-width': 5 + }); + + return circle; +} + +function createCircle(a) { + var circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle'); + (0, _setAttributes2.default)(circle, { + cx: a.cx, + cy: a.cy, + r: a.r + }); + + return circle; +} +module.exports = exports['default']; + +/***/ }), +/* 26 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = renderArrow; + +var _setAttributes = __webpack_require__(4); + +var _setAttributes2 = _interopRequireDefault(_setAttributes); + +var _normalizeColor = __webpack_require__(5); + +var _normalizeColor2 = _interopRequireDefault(_normalizeColor); + +var _mathUtils = __webpack_require__(9); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Create SVGPathElement from an annotation definition. + * This is used for anntations of type `drawing`. + * + * @param {Object} a The annotation definition + * @return {SVGPathElement} The path to be rendered + */ +function renderArrow(a) { + var d = []; + var arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon'); + + if (a.lines.length == 2) { + var p1 = a.lines[0]; + var p2 = a.lines[a.lines.length - 1]; + + var arrowLength = 40; + var pt0 = (0, _mathUtils.makePoint)(p1[0], p1[1], 0); + var pt1 = (0, _mathUtils.makePoint)(p2[0], p2[1], 0); + var x = (0, _mathUtils.makeVectorFromPoints)(pt0, pt1); + var unitX = (0, _mathUtils.unitVector)(x); + pt1 = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)(unitX, arrowLength)); + x = (0, _mathUtils.makeVectorFromPoints)(pt0, pt1); + var unitZ = (0, _mathUtils.makeVector)(0, 0, 1); + var unitY = (0, _mathUtils.unitVector)((0, _mathUtils.crossProduct)(unitX, unitZ)); + var thickness = a.width || 10; + + var A = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)(unitY, thickness * 0.5)); + var B = (0, _mathUtils.addVector)(A, (0, _mathUtils.multiplyVector)(unitX, (0, _mathUtils.magnitude)(x) - thickness * 2.0)); + var C = (0, _mathUtils.addVector)(B, (0, _mathUtils.multiplyVector)(unitY, thickness)); + var D = pt1; + var G = (0, _mathUtils.addVector)(pt0, (0, _mathUtils.multiplyVector)((0, _mathUtils.negateVector)(unitY), thickness * 0.5)); + var F = (0, _mathUtils.addVector)(G, (0, _mathUtils.multiplyVector)(unitX, (0, _mathUtils.magnitude)(x) - thickness * 2.0)); + var E = (0, _mathUtils.addVector)(F, (0, _mathUtils.multiplyVector)((0, _mathUtils.negateVector)(unitY), thickness)); + + var points = '' + A.x + ',' + A.y + ' ' + B.x + ',' + B.y + ' ' + C.x + ',' + C.y + ' ' + D.x + ',' + D.y + ' ' + E.x + ',' + E.y + ' ' + F.x + ',' + F.y + ' ' + G.x + ',' + G.y; + + (0, _setAttributes2.default)(arrow, { + points: points, + stroke: (0, _normalizeColor2.default)(a.color || '#000'), + fill: (0, _normalizeColor2.default)(a.color || '#000') + }); + } + + return arrow; +} +module.exports = exports['default']; + +/***/ }), +/* 27 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +var _uuid = __webpack_require__(10); + +var _uuid2 = _interopRequireDefault(_uuid); + +var _StoreAdapter2 = __webpack_require__(8); + +var _StoreAdapter3 = _interopRequireDefault(_StoreAdapter2); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// StoreAdapter for working with localStorage +// This is ideal for testing, examples, and prototyping +var LocalStoreAdapter = function (_StoreAdapter) { + _inherits(LocalStoreAdapter, _StoreAdapter); + + function LocalStoreAdapter() { + var userId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "user"; + + _classCallCheck(this, LocalStoreAdapter); + + var _this = _possibleConstructorReturn(this, (LocalStoreAdapter.__proto__ || Object.getPrototypeOf(LocalStoreAdapter)).call(this, { + getAnnotations: function getAnnotations(documentId, userId, pageNumber) { + return new Promise(function (resolve, reject) { + var annotations = getAllAnnotations().filter(function (i) { + return i.page === pageNumber && i.class === 'Annotation'; + }); + + resolve({ + documentId: documentId, + userId: userId, + pageNumber: pageNumber, + annotations: annotations + }); + }); + }, + getAnnotation: function getAnnotation(documentId, userId, annotationId) { + return Promise.resolve(getAnnotations(documentId, userId)[findAnnotation(documentId, userId, annotationId)]); + }, + addAnnotation: function addAnnotation(documentId, userId, pageNumber, annotation) { + return new Promise(function (resolve, reject) { + annotation.class = 'Annotation'; + annotation.uuid = (0, _uuid2.default)(); + annotation.page = pageNumber; + annotation.userId = userId; + + var annotations = getAnnotations(documentId, userId); + annotations.push(annotation); + updateAnnotations(documentId, userId, annotations); + + resolve(annotation); + }); + }, + editAnnotation: function editAnnotation(documentId, userId, annotationId, annotation) { + return new Promise(function (resolve, reject) { + var annotations = getAnnotations(documentId, userId); + annotations[findAnnotation(documentId, userId, annotationId)] = annotation; + updateAnnotations(documentId, userId, annotations); + resolve(annotation); + }); + }, + deleteAnnotation: function deleteAnnotation(documentId, userId, annotationId) { + return new Promise(function (resolve, reject) { + var index = findAnnotation(documentId, userId, annotationId); + if (index > -1) { + var annotations = getAnnotations(documentId, userId); + annotations.splice(index, 1); + updateAnnotations(documentId, userId, annotations); + } + + resolve(true); + }); + }, + getComments: function getComments(documentId, userId, annotationId) { + return new Promise(function (resolve, reject) { + resolve(getAnnotations(documentId, userId).filter(function (i) { + return i.class === 'Comment' && i.annotation === annotationId; + })); + }); + }, + addComment: function addComment(documentId, userId, annotationId, content) { + return new Promise(function (resolve, reject) { + var comment = { + class: 'Comment', + uuid: (0, _uuid2.default)(), + annotation: annotationId, + content: content, + userId: userId + }; + + var annotations = getAnnotations(documentId, userId); + annotations.push(comment); + updateAnnotations(documentId, userId, annotations); + + resolve(comment); + }); + }, + deleteComment: function deleteComment(documentId, userId, commentId) { + return new Promise(function (resolve, reject) { + getAnnotations(documentId, userId); + var index = -1; + var annotations = getAnnotations(documentId, userId); + for (var i = 0, l = annotations.length; i < l; i++) { + if (annotations[i].uuid === commentId) { + index = i; + break; + } + } + + if (index > -1) { + annotations.splice(index, 1); + updateAnnotations(documentId, userId, annotations); + } + + resolve(true); + }); + } + })); + + _this._userId = userId; + return _this; + } + + _createClass(LocalStoreAdapter, [{ + key: 'userId', + get: function get() { + return this._userId; + } + }]); + + return LocalStoreAdapter; +}(_StoreAdapter3.default); + +exports.default = LocalStoreAdapter; + + +function getAllAnnotations() { + var all_annotations = []; + for (var i = 0; i < localStorage.length; i++) { + if (localStorage.key(i).includes('annotations')) { + all_annotations.push.apply(all_annotations, _toConsumableArray(JSON.parse(localStorage.getItem(localStorage.key(i))))); + } + } + return all_annotations; +} + +function getAnnotations(documentId, userId) { + return JSON.parse(localStorage.getItem(documentId + '/' + userId + '/annotations')) || []; +} + +function updateAnnotations(documentId, userId, annotations) { + localStorage.setItem(documentId + '/' + userId + '/annotations', JSON.stringify(annotations)); +} +/** + * + * @param {String} documentId Document id of the annotation + * @param {String} userId User id of the annotation + * @param {String} annotationId The id of the annotation + * + * This function finds all the annotation made by one user. + * + * @return {int} The index of the annotation in localstorage + */ +function findAnnotation(documentId, userId, annotationId) { + var index = -1; + var annotations = getAnnotations(documentId, userId); + for (var i = 0, l = annotations.length; i < l; i++) { + if (annotations[i].uuid === annotationId) { + index = i; + break; + } + } + return index; +} +module.exports = exports['default']; + +/***/ }), +/* 28 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = render; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _appendChild = __webpack_require__(2); + +var _renderScreenReaderHints = __webpack_require__(7); + +var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Render the response from PDFJSAnnotate.getStoreAdapter().getAnnotations to SVG + * + * @param {SVGElement} svg The SVG element to render the annotations to + * @param {Object} viewport The page viewport data + * @param {Object} data The response from PDFJSAnnotate.getStoreAdapter().getAnnotations + * @return {Promise} Settled once rendering has completed + * A settled Promise will be either: + * - fulfilled: SVGElement + * - rejected: Error + */ +function render(svg, viewport, data) { + return new Promise(function (resolve, reject) { + // Reset the content of the SVG + svg.setAttribute('data-pdf-annotate-container', true); + svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport)); + svg.removeAttribute('data-pdf-annotate-document'); + svg.removeAttribute('data-pdf-annotate-page'); + + // If there's no data nothing can be done + if (!data) { + svg.innerHTML = ''; + return resolve(svg); + } + + svg.setAttribute('data-pdf-annotate-document', data.documentId); + svg.setAttribute('data-pdf-annotate-user', data.userId); + svg.setAttribute('data-pdf-annotate-page', data.pageNumber); + + // Make sure annotations is an array + if (!Array.isArray(data.annotations) || data.annotations.length === 0) { + return resolve(svg); + } + + // Append or transform annotation to svg + data.annotations.forEach(function (a) { + var node = svg.querySelector('[data-pdf-annotate-id="' + a.uuid + '"]'); + if (node) { + (0, _appendChild.transformChild)(svg, node, viewport); + } else { + (0, _appendChild.appendChild)(svg, a, viewport); + } + }); + + resolve(svg); + }); +} +module.exports = exports['default']; + +/***/ }), +/* 29 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = createScreenReaderOnly; +/** + * Create a node that is only visible to screen readers + * + * @param {String} content The text content that should be read by screen reader + * @param {String} [annotationId] The ID of the annotation assocaited + * @return {Element} An Element that is only visible to screen readers + */ +function createScreenReaderOnly(content, annotationId) { + var node = document.createElement('div'); + var text = document.createTextNode(content); + node.appendChild(text); + node.setAttribute('id', 'pdf-annotate-screenreader-' + annotationId); + node.style.position = 'absolute'; + node.style.left = '-10000px'; + node.style.top = 'auto'; + node.style.width = '1px'; + node.style.height = '1px'; + node.style.overflow = 'hidden'; + return node; +} +module.exports = exports['default']; + +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = insertElementWithinChildren; + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _insertElementWithinElement = __webpack_require__(12); + +var _insertElementWithinElement2 = _interopRequireDefault(_insertElementWithinElement); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +/** + * Insert an element at a point within the document. + * This algorithm will try to insert between elements if possible. + * It will however use `insertElementWithinElement` if it is more accurate. + * + * @param {Element} el The element to be inserted + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + * @param {Number} pageNumber The page number to limit elements to + * @return {Boolean} True if element was able to be inserted, otherwise false + */ +function insertElementWithinChildren(el, x, y, pageNumber) { + // Try and use most accurate method of inserting within an element + if ((0, _insertElementWithinElement2.default)(el, x, y, pageNumber, true)) { + return true; + } + + // Fall back to inserting between elements + var svg = document.querySelector('svg[data-pdf-annotate-page="' + pageNumber + '"]'); + var rect = svg.getBoundingClientRect(); + var nodes = [].concat(_toConsumableArray(svg.parentNode.querySelectorAll(_config2.default.textClassQuery() + ' > div'))); + + y = (0, _utils.scaleUp)(svg, { y: y }).y + rect.top; + x = (0, _utils.scaleUp)(svg, { x: x }).x + rect.left; + + // Find the best node to insert before + for (var i = 0, l = nodes.length; i < l; i++) { + var n = nodes[i]; + var r = n.getBoundingClientRect(); + if (y <= r.top) { + n.parentNode.insertBefore(el, n); + return true; + } + } + + // If all else fails try to append to the bottom + var textLayer = svg.parentNode.querySelector(_config2.default.textClassQuery()); + if (textLayer) { + var textRect = textLayer.getBoundingClientRect(); + if ((0, _utils.pointIntersectsRect)(x, y, textRect)) { + textLayer.appendChild(el); + return true; + } + } + + return false; +} +module.exports = exports['default']; + +/***/ }), +/* 31 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = initEventHandlers; + +var _insertScreenReaderHint = __webpack_require__(11); + +var _insertScreenReaderHint2 = _interopRequireDefault(_insertScreenReaderHint); + +var _renderScreenReaderHints = __webpack_require__(7); + +var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); + +var _insertScreenReaderComment = __webpack_require__(14); + +var _insertScreenReaderComment2 = _interopRequireDefault(_insertScreenReaderComment); + +var _renderScreenReaderComments = __webpack_require__(13); + +var _renderScreenReaderComments2 = _interopRequireDefault(_renderScreenReaderComments); + +var _event = __webpack_require__(6); + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Initialize the event handlers for keeping screen reader hints synced with data + */ +function initEventHandlers() { + (0, _event.addEventListener)('annotation:add', function (documentId, userId, pageNumber, annotation) { + reorderAnnotationsByType(documentId, userId, pageNumber, annotation.type); + }); + (0, _event.addEventListener)('annotation:edit', function (documentId, userId, annotationId, annotation) { + reorderAnnotationsByType(documentId, userId, annotation.page, annotation.type); + }); + (0, _event.addEventListener)('annotation:delete', removeAnnotation); + (0, _event.addEventListener)('comment:add', insertComment); + (0, _event.addEventListener)('comment:delete', removeComment); +} + +/** + * Reorder the annotation numbers by annotation type + * + * @param {String} documentId The ID of the document + * @param {String} userId The ID of the user + * @param {Number} pageNumber The page number of the annotations + * @param {Strig} type The annotation type + */ +function reorderAnnotationsByType(documentId, userId, pageNumber, type) { + _PDFJSAnnotate2.default.getStoreAdapter().getAnnotations(documentId, userId, pageNumber).then(function (annotations) { + return annotations.annotations.filter(function (a) { + return a.type === type; + }); + }).then(function (annotations) { + annotations.forEach(function (a) { + removeAnnotation(documentId, a.uuid); + }); + + return annotations; + }).then(_renderScreenReaderHints2.default); +} + +/** + * Remove the screen reader hint for an annotation + * + * @param {String} documentId The ID of the document + * @param {String} annotationId The Id of the annotation + */ +function removeAnnotation(documentId, annotationId) { + removeElementById('pdf-annotate-screenreader-' + annotationId); + removeElementById('pdf-annotate-screenreader-' + annotationId + '-end'); +} + +/** + * Insert a screen reader hint for a comment + * + * @param {String} documentId The ID of the document + * @param {String} annotationId The ID of tha assocated annotation + * @param {Object} comment The comment to insert a hint for + */ +function insertComment(documentId, annotationId, comment) { + var list = document.querySelector('pdf-annotate-screenreader-comment-list-' + annotationId); + var promise = void 0; + + if (!list) { + promise = (0, _renderScreenReaderComments2.default)(documentId, annotationId, []).then(function () { + list = document.querySelector('pdf-annotate-screenreader-comment-list-' + annotationId); + return true; + }); + } else { + promise = Promise.resolve(true); + } + + promise.then(function () { + (0, _insertScreenReaderComment2.default)(comment); + }); +} + +/** + * Remove a screen reader hint for a comment + * + * @param {String} documentId The ID of the document + * @param {String} commentId The ID of the comment + */ +function removeComment(documentId, commentId) { + removeElementById('pdf-annotate-screenreader-comment-' + commentId); +} + +/** + * Remove an element from the DOM by it's ID if it exists + * + * @param {String} elementID The ID of the element to be removed + */ +function removeElementById(elementId) { + var el = document.getElementById(elementId); + if (el) { + el.parentNode.removeChild(el); + } +} +module.exports = exports['default']; + +/***/ }), +/* 32 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _event = __webpack_require__(6); + +var _edit = __webpack_require__(33); + +var _pen = __webpack_require__(34); + +var _arrow = __webpack_require__(35); + +var _eraser = __webpack_require__(36); + +var _point = __webpack_require__(37); + +var _rect = __webpack_require__(38); + +var _circle = __webpack_require__(39); + +var _text = __webpack_require__(40); + +var _page = __webpack_require__(41); + +exports.default = { + addEventListener: _event.addEventListener, + removeEventListener: _event.removeEventListener, + fireEvent: _event.fireEvent, + + disableEdit: _edit.disableEdit, + enableEdit: _edit.enableEdit, + + disablePen: _pen.disablePen, + enablePen: _pen.enablePen, + setPen: _pen.setPen, + + disablePoint: _point.disablePoint, + enablePoint: _point.enablePoint, + + disableRect: _rect.disableRect, + enableRect: _rect.enableRect, + + disableCircle: _circle.disableCircle, + enableCircle: _circle.enableCircle, + setCircle: _circle.setCircle, + addCircle: _circle.addCircle, + + disableArrow: _arrow.disableArrow, + enableArrow: _arrow.enableArrow, + setArrow: _arrow.setArrow, + + disableEraser: _eraser.disableEraser, + enableEraser: _eraser.enableEraser, + + disableText: _text.disableText, + enableText: _text.enableText, + setText: _text.setText, + + createPage: _page.createPage, + renderPage: _page.renderPage +}; +module.exports = exports['default']; + +/***/ }), +/* 33 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enableEdit = enableEdit; +exports.disableEdit = disableEdit; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _appendChild = __webpack_require__(2); + +var _event = __webpack_require__(6); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var _enabled = false; +var isDragging = false; +var overlay = void 0; +var dragOffsetX = void 0, + dragOffsetY = void 0, + dragStartX = void 0, + dragStartY = void 0; +var OVERLAY_BORDER_SIZE = 3; + +/** + * Create an overlay for editing an annotation. + * + * @param {Element} target The annotation element to apply overlay for + */ +function createEditOverlay(target) { + destroyEditOverlay(); + + overlay = document.createElement('div'); + var anchor = document.createElement('a'); + var parentNode = (0, _utils.findSVGContainer)(target).parentNode; + var id = target.getAttribute('data-pdf-annotate-id'); + var rect = (0, _utils.getOffsetAnnotationRect)(target); + var styleLeft = rect.left - OVERLAY_BORDER_SIZE; + var styleTop = rect.top - OVERLAY_BORDER_SIZE; + + overlay.setAttribute('id', 'pdf-annotate-edit-overlay'); + overlay.setAttribute('data-target-id', id); + overlay.style.boxSizing = 'content-box'; + overlay.style.position = 'absolute'; + overlay.style.top = styleTop + 'px'; + overlay.style.left = styleLeft + 'px'; + overlay.style.width = rect.width + 'px'; + overlay.style.height = rect.height + 'px'; + overlay.style.border = OVERLAY_BORDER_SIZE + 'px solid ' + _utils.BORDER_COLOR; + overlay.style.borderRadius = OVERLAY_BORDER_SIZE + 'px'; + overlay.style.zIndex = 20100; + + anchor.innerHTML = '×'; + anchor.setAttribute('href', 'javascript://'); + anchor.style.background = '#fff'; + anchor.style.borderRadius = '20px'; + anchor.style.border = '1px solid #bbb'; + anchor.style.color = '#bbb'; + anchor.style.fontSize = '16px'; + anchor.style.padding = '2px'; + anchor.style.textAlign = 'center'; + anchor.style.textDecoration = 'none'; + anchor.style.position = 'absolute'; + anchor.style.top = '-13px'; + anchor.style.right = '-13px'; + anchor.style.width = '25px'; + anchor.style.height = '25px'; + + overlay.appendChild(anchor); + parentNode.appendChild(overlay); + document.addEventListener('click', handleDocumentClick); + document.addEventListener('keyup', handleDocumentKeyup); + document.addEventListener('mousedown', handleDocumentMousedown); + anchor.addEventListener('click', deleteAnnotation); + anchor.addEventListener('mouseover', function () { + anchor.style.color = '#35A4DC'; + anchor.style.borderColor = '#999'; + anchor.style.boxShadow = '0 1px 1px #ccc'; + }); + anchor.addEventListener('mouseout', function () { + anchor.style.color = '#bbb'; + anchor.style.borderColor = '#bbb'; + anchor.style.boxShadow = ''; + }); + overlay.addEventListener('mouseover', function () { + if (!isDragging) { + anchor.style.display = ''; + } + }); + overlay.addEventListener('mouseout', function () { + anchor.style.display = 'none'; + }); +} + +/** + * Destroy the edit overlay if it exists. + */ +function destroyEditOverlay() { + if (overlay) { + overlay.parentNode.removeChild(overlay); + overlay = null; + } + + document.removeEventListener('click', handleDocumentClick); + document.removeEventListener('keyup', handleDocumentKeyup); + document.removeEventListener('mousedown', handleDocumentMousedown); + document.removeEventListener('mousemove', handleDocumentMousemove); + document.removeEventListener('mouseup', handleDocumentMouseup); + (0, _utils.enableUserSelect)(); +} + +/** + * Delete currently selected annotation + */ +function deleteAnnotation() { + if (!overlay) { + return; + } + + var annotationId = overlay.getAttribute('data-target-id'); + var nodes = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); + var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId; + + [].concat(_toConsumableArray(nodes)).forEach(function (n) { + n.parentNode.removeChild(n); + }); + + _PDFJSAnnotate2.default.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId); + + destroyEditOverlay(); +} + +/** + * Handle document.click event + * + * @param {Event} e The DOM event that needs to be handled + */ +function handleDocumentClick(e) { + if (!(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { + return; + } + + // Remove current overlay + var overlay = document.getElementById('pdf-annotate-edit-overlay'); + if (overlay) { + if (isDragging || e.target === overlay) { + return; + } + + destroyEditOverlay(); + } +} + +/** + * Handle document.keyup event + * + * @param {KeyboardEvent} e The DOM event that needs to be handled + */ +function handleDocumentKeyup(e) { + // keyCode is deprecated, so prefer the newer "key" method if possible + var keyTest = void 0; + if (e.key) { + keyTest = e.key.toLowerCase() === "delete" || e.key.toLowerCase() === "backspace"; + } else { + keyTest = e.keyCode === 8 || e.keyCode === 46; + } + if (overlay && keyTest && e.target.nodeName.toLowerCase() !== 'textarea' && e.target.nodeName.toLowerCase() !== 'input') { + e.preventDefault(); + deleteAnnotation(); + } +} + +/** + * Handle document.mousedown event + * + * @param {Event} e The DOM event that needs to be handled + */ +function handleDocumentMousedown(e) { + if (e.target !== overlay) { + return; + } + + // Highlight and strikeout annotations are bound to text within the document. + // It doesn't make sense to allow repositioning these types of annotations. + var annotationId = overlay.getAttribute('data-target-id'); + var target = document.querySelector('[data-pdf-annotate-id="' + annotationId + '"]'); + var type = target.getAttribute('data-pdf-annotate-type'); + + if (type === 'highlight' || type === 'strikeout') { + return; + } + + isDragging = true; + dragOffsetX = e.clientX; + dragOffsetY = e.clientY; + dragStartX = overlay.offsetLeft; + dragStartY = overlay.offsetTop; + + overlay.style.background = 'rgba(255, 255, 255, 0.7)'; + overlay.style.cursor = 'move'; + overlay.querySelector('a').style.display = 'none'; + + document.addEventListener('mousemove', handleDocumentMousemove); + document.addEventListener('mouseup', handleDocumentMouseup); + (0, _utils.disableUserSelect)(); +} + +/** + * Handle document.mousemove event + * + * @param {Event} e The DOM event that needs to be handled + */ +function handleDocumentMousemove(e) { + var annotationId = overlay.getAttribute('data-target-id'); + var parentNode = overlay.parentNode; + var rect = parentNode.getBoundingClientRect(); + var y = dragStartY + (e.clientY - dragOffsetY); + var x = dragStartX + (e.clientX - dragOffsetX); + var minY = 0; + var maxY = rect.height; + var minX = 0; + var maxX = rect.width; + + if (y > minY && y + overlay.offsetHeight < maxY) { + overlay.style.top = y + 'px'; + } + + if (x > minX && x + overlay.offsetWidth < maxX) { + overlay.style.left = x + 'px'; + } +} + +/** + * Handle document.mouseup event + * + * @param {Event} e The DOM event that needs to be handled + */ +function handleDocumentMouseup(e) { + var annotationId = overlay.getAttribute('data-target-id'); + var target = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); + var type = target[0].getAttribute('data-pdf-annotate-type'); + var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); + + var _getMetadata2 = (0, _utils.getMetadata)(svg), + documentId = _getMetadata2.documentId, + userId = _getMetadata2.userId; + + overlay.querySelector('a').style.display = ''; + + _PDFJSAnnotate2.default.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then(function (annotation) { + var attribX = 'x'; + var attribY = 'y'; + if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { + attribX = 'cx'; + attribY = 'cy'; + } + + if (type === 'point') { + // Broken + /* + [...target].forEach((t, i) => { + let moveTo = { + x: overlay.offsetLeft + 3, + y: overlay.offsetTop + 3 + }; + t.setAttribute(attribX, moveTo.x); + t.setAttribute(attribY, moveTo.y); + annotation[attribX] = moveTo.x; + annotation[attribY] = moveTo.y; + }); + */ + return; + } else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { + var modelStart = (0, _utils.convertToSvgPoint)([dragStartX, dragStartY], svg); + var modelEnd = (0, _utils.convertToSvgPoint)([overlay.offsetLeft, overlay.offsetTop], svg); + var modelDelta = { + x: modelEnd[0] - modelStart[0], + y: modelEnd[1] - modelStart[1] + }; + + if (type === 'textbox') { + target = [target[0].firstChild]; + } + + [].concat(_toConsumableArray(target)).forEach(function (t, i) { + var modelX = parseInt(t.getAttribute(attribX), 10); + var modelY = parseInt(t.getAttribute(attribY), 10); + if (modelDelta.y !== 0) { + modelY = modelY + modelDelta.y; + + t.setAttribute(attribY, modelY); + if (annotation.rectangles && i < annotation.rectangles.length) { + annotation.rectangles[i].y = modelY; + } else if (annotation[attribY]) { + annotation[attribY] = modelY; + } + } + if (modelDelta.x !== 0) { + modelX = modelX + modelDelta.x; + + t.setAttribute(attribX, modelX); + if (annotation.rectangles && i < annotation.rectangles.length) { + annotation.rectangles[i].x = modelX; + } else if (annotation[attribX]) { + annotation[attribX] = modelX; + } + } + }); + } else if (type === 'strikeout') { + return; + // let { deltaX, deltaY } = getDelta('x1', 'y1'); + // [...target].forEach(target, (t, i) => { + // if (deltaY !== 0) { + // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY); + // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY); + // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10); + // } + // if (deltaX !== 0) { + // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX); + // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX); + // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10); + // } + // }); + } else if (type === 'drawing' || type === 'arrow') { + // Do nothing as currently broken + /* + let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg); + let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg); + let modelDelta = { + x: modelEnd[0] - modelStart[0], + y: modelEnd[1] - modelStart[1] + }; + annotation.lines.forEach((line, i) => { + let [x, y] = annotation.lines[i]; + annotation.lines[i][0] = x + modelDelta.x; + annotation.lines[i][1] = y + modelDelta.y; + }); + target[0].parentNode.removeChild(target[0]); + appendChild(svg, annotation); + */ + return; + } + + _PDFJSAnnotate2.default.getStoreAdapter().editAnnotation(documentId, userId, annotationId, annotation); + }); + + setTimeout(function () { + isDragging = false; + }, 0); + + overlay.style.background = ''; + overlay.style.cursor = ''; + + document.removeEventListener('mousemove', handleDocumentMousemove); + document.removeEventListener('mouseup', handleDocumentMouseup); + (0, _utils.enableUserSelect)(); +} + +/** + * Handle annotation.click event + * + * @param {Element} e The annotation element that was clicked + */ +function handleAnnotationClick(target) { + createEditOverlay(target); +} + +/** + * Enable edit mode behavior. + */ +function enableEdit() { + if (_enabled) { + return; + } + + _enabled = true; + (0, _event.addEventListener)('annotation:click', handleAnnotationClick); +}; + +/** + * Disable edit mode behavior. + */ +function disableEdit() { + destroyEditOverlay(); + + if (!_enabled) { + return; + } + + _enabled = false; + (0, _event.removeEventListener)('annotation:click', handleAnnotationClick); +}; + +/***/ }), +/* 34 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.setPen = setPen; +exports.enablePen = enablePen; +exports.disablePen = disablePen; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _enabled = false; +var _candraw = false; +var _penSize = void 0; +var _penColor = void 0; +var path = void 0; +var lines = []; + +var isFirefox = /firefox/i.test(navigator.userAgent); + +/** + * Handle document.touchdown or document.pointerdown event + */ +function handleDocumentPointerdown(e) { + e.preventDefault(); + path = null; + lines = []; + _candraw = true; +} + +/** + * Handle document.touchup or document.pointerup event + * + * @param {TouchEvent} e The DOM event to be handled + */ +function handleDocumentPointerupChrome(e) { + saveToStorage(e.changedTouches[0].clientX, e.changedTouches[0].clientY); +} + +function handleDocumentPointerup(e) { + saveToStorage(e.clientX, e.clientY); +} + +function saveToStorage(x, y) { + _candraw = false; + var svg = void 0; + if (lines.length > 1 && (svg = (0, _utils.findSVGAtPoint)(x, y))) { + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId, + pageNumber = _getMetadata.pageNumber; + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, { + type: 'drawing', + width: _penSize, + color: _penColor, + lines: lines + }).then(function (annotation) { + if (path) { + svg.removeChild(path); + } + + (0, _appendChild.appendChild)(svg, annotation); + }); + } +} + +/** + * Handle document.mousemove event + * + * @param {PointerEvent} e The DOM event to be handled + */ +function handleDocumentPointermove(e) { + if (!e.srcElement.classList.contains('annotationLayer')) { + return; + } + if (_candraw) { + savePoint(e.clientX, e.clientY); + } +} + +/** + * Handle document.keyup event + * + * @param {KeyboardEvent} e The DOM event to be handled + * } e The DOM event to be handled + */ +function handleDocumentKeyup(e) { + // Cancel rect if Esc is pressed + if (e.keyCode === 27) { + lines = null; + path.parentNode.removeChild(path); + document.removeEventListener('pointermove', handleDocumentPointermove); + document.removeEventListener('pointerup', handleDocumentPointerup); + } +} + +/** + * Save a point to the line being drawn. + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + */ +function savePoint(x, y) { + var svg = (0, _utils.findSVGAtPoint)(x, y); + if (!svg) { + return; + } + + var rect = svg.getBoundingClientRect(); + var point = (0, _utils.convertToSvgPoint)([x - rect.left, y - rect.top], svg); + point[0] = point[0].toFixed(2); + point[1] = point[1].toFixed(2); + lines.push(point); + + if (lines.length <= 1) { + return; + } + + if (path) { + svg.removeChild(path); + } + + path = (0, _appendChild.appendChild)(svg, { + type: 'drawing', + color: _penColor, + width: _penSize, + lines: lines + }); +} + +/** + * Set the attributes of the pen. + * + * @param {Number} penSize The size of the lines drawn by the pen + * @param {String} penColor The color of the lines drawn by the pen + */ +function setPen() { + var penSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; + var penColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '000000'; + + _penSize = parseInt(penSize, 10); + _penColor = penColor; +} + +/** + * Enable the pen behavior + */ +function enablePen() { + if (_enabled) { + return; + } + + _enabled = true; + // Chrome and Firefox has different behaviors with how pen works, so we need different events. + document.addEventListener('pointerdown', handleDocumentPointerdown); + document.addEventListener('pointermove', handleDocumentPointermove); + document.addEventListener('pointerup', handleDocumentPointerup); + + document.addEventListener('keyup', handleDocumentKeyup); + (0, _utils.disableUserSelect)(); +} + +/** + * Disable the pen behavior + */ +function disablePen() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('pointerdown', handleDocumentPointerdown); + document.removeEventListener('pointermove', handleDocumentPointermove); + document.removeEventListener('pointerup', handleDocumentPointerup); + + document.removeEventListener('keyup', handleDocumentKeyup); + (0, _utils.enableUserSelect)(); +} + +/***/ }), +/* 35 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.setArrow = setArrow; +exports.enableArrow = enableArrow; +exports.disableArrow = disableArrow; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _enabled = false; +var _penSize = void 0; +var _penColor = void 0; +var path = void 0; +var lines = void 0; +var originY = void 0; +var originX = void 0; + +/** + * Handle document.mousedown event + */ +function handleDocumentMousedown(e) { + var target = (0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY); + if (target === null) return; + + var type = target.getAttribute('data-pdf-annotate-type'); + if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') { + return; + } + + var svg = (0, _utils.findSVGContainer)(target); + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId; + + var annotationId = target.getAttribute('data-pdf-annotate-id'); + + var event = e; + _PDFJSAnnotate2.default.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then(function (annotation) { + if (annotation) { + path = null; + lines = []; + + var point = (0, _utils.convertToScreenPoint)([annotation.cx, annotation.cy], svg); + + var rect = svg.getBoundingClientRect(); + + originX = point[0] + rect.left; + originY = point[1] + rect.top; + + document.addEventListener('mousemove', handleDocumentMousemove); + document.addEventListener('mouseup', handleDocumentMouseup); + } + }); +} + +/** + * Handle document.mouseup event + * + * @param {Event} e The DOM event to be handled + */ +function handleDocumentMouseup(e) { + var svg = void 0; + if (lines.length > 1 && (svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY))) { + var _getMetadata2 = (0, _utils.getMetadata)(svg), + documentId = _getMetadata2.documentId, + userId = _getMetadata2.userId, + pageNumber = _getMetadata2.pageNumber; + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, { + type: 'arrow', + width: _penSize, + color: _penColor, + lines: lines + }).then(function (annotation) { + if (path) { + svg.removeChild(path); + } + + (0, _appendChild.appendChild)(svg, annotation); + }); + } + + document.removeEventListener('mousemove', handleDocumentMousemove); + document.removeEventListener('mouseup', handleDocumentMouseup); +} + +/** + * Handle document.mousemove event + * + * @param {Event} e The DOM event to be handled + */ +function handleDocumentMousemove(e) { + var x = lines.length === 0 ? originX : e.clientX; + var y = lines.length === 0 ? originY : e.clientY; + + savePoint(x, y); +} + +/** + * Handle document.keyup event + * + * @param {Event} e The DOM event to be handled + */ +function handleDocumentKeyup(e) { + // Cancel rect if Esc is pressed + if (e.keyCode === 27) { + lines = null; + path.parentNode.removeChild(path); + document.removeEventListener('mousemove', handleDocumentMousemove); + document.removeEventListener('mouseup', handleDocumentMouseup); + } +} + +/** + * Save a point to the line being drawn. + * + * @param {Number} x The x coordinate of the point + * @param {Number} y The y coordinate of the point + */ +function savePoint(x, y) { + var svg = (0, _utils.findSVGAtPoint)(x, y); + if (!svg) { + return; + } + + var rect = svg.getBoundingClientRect(); + var point = (0, _utils.convertToSvgPoint)([x - rect.left, y - rect.top], svg); + + if (lines.length < 2) { + lines.push(point); + return; + } else { + lines[1] = point; // update end point + } + + if (path) { + svg.removeChild(path); + } + + path = (0, _appendChild.appendChild)(svg, { + type: 'arrow', + color: _penColor, + width: _penSize, + lines: lines + }); +} + +/** + * Set the attributes of the pen. + * + * @param {Number} penSize The size of the lines drawn by the pen + * @param {String} penColor The color of the lines drawn by the pen + */ +function setArrow() { + var penSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; + var penColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0000FF'; + + _penSize = parseInt(penSize, 10); + _penColor = penColor; +} + +/** + * Enable the pen behavior + */ +function enableArrow() { + if (_enabled) { + return; + } + + _enabled = true; + document.addEventListener('mousedown', handleDocumentMousedown); + document.addEventListener('keyup', handleDocumentKeyup); + (0, _utils.disableUserSelect)(); +} + +/** + * Disable the pen behavior + */ +function disableArrow() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('mousedown', handleDocumentMousedown); + document.removeEventListener('keyup', handleDocumentKeyup); + (0, _utils.enableUserSelect)(); +} + +/***/ }), +/* 36 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enableEraser = enableEraser; +exports.disableEraser = disableEraser; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var _canerase = false; +var userId = "user"; + +/** + * + * @param {PointerEvent} e + */ +function handleDocumentDown(e) { + _canerase = true; +} + +/** + * + * @param {PointerEvent} e + */ +function handleDocumentUp(e) { + _canerase = false; +} + +/** + * + * @param {PointerEvent} e + */ +function handleDocumentMouseMove(e) { + erase((0, _utils.findAnnotationAtPoint)(e.clientX, e.clientY)); +} + +function erase(target) { + if (_canerase) { + if (target && target.getAttribute('data-pdf-annotate-userId') === userId) { + var _getMetadata = (0, _utils.getMetadata)(target.parentElement), + documentId = _getMetadata.documentId; + + var annotationId = target.getAttribute('data-pdf-annotate-id'); + var nodes = document.querySelectorAll('[data-pdf-annotate-id="' + annotationId + '"]'); + [].concat(_toConsumableArray(nodes)).forEach(function (n) { + n.parentNode.removeChild(n); + }); + + _PDFJSAnnotate2.default.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId); + } + } +} + +function enableEraser() { + userId = _PDFJSAnnotate2.default.getStoreAdapter().userId; + document.addEventListener('pointermove', handleDocumentMouseMove); + document.addEventListener('pointerdown', handleDocumentDown); + document.addEventListener('pointerup', handleDocumentUp); +} + +function disableEraser() { + document.removeEventListener('pointermove', handleDocumentMouseMove); + document.removeEventListener('pointerdown', handleDocumentDown); + document.removeEventListener('pointerup', handleDocumentUp); +} + +/***/ }), +/* 37 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enablePoint = enablePoint; +exports.disablePoint = disablePoint; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _enabled = false; +var input = void 0; + +/** + * Handle document.mouseup event + * + * @param {Event} The DOM event to be handled + */ +function handleDocumentMouseup(e) { + if (input || !(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { + return; + } + + input = document.createElement('input'); + input.setAttribute('id', 'pdf-annotate-point-input'); + input.setAttribute('placeholder', 'Enter comment'); + input.style.border = '3px solid ' + _utils.BORDER_COLOR; + input.style.borderRadius = '3px'; + input.style.position = 'absolute'; + input.style.top = e.clientY + 'px'; + input.style.left = e.clientX + 'px'; + + input.addEventListener('blur', handleInputBlur); + input.addEventListener('keyup', handleInputKeyup); + + document.body.appendChild(input); + input.focus(); +} + +/** + * Handle input.blur event + */ +function handleInputBlur() { + savePoint(); +} + +/** + * Handle input.keyup event + * + * @param {Event} e The DOM event to handle + */ +function handleInputKeyup(e) { + if (e.keyCode === 27) { + closeInput(); + } else if (e.keyCode === 13) { + savePoint(); + } +} + +/** + * Save a new point annotation from input + */ +function savePoint() { + if (input.value.trim().length > 0) { + var clientX = parseInt(input.style.left, 10); + var clientY = parseInt(input.style.top, 10); + var content = input.value.trim(); + var svg = (0, _utils.findSVGAtPoint)(clientX, clientY); + if (!svg) { + return; + } + + var rect = svg.getBoundingClientRect(); + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId, + pageNumber = _getMetadata.pageNumber; + + var annotation = Object.assign({ + type: 'point' + }, (0, _utils.scaleDown)(svg, { + x: clientX - rect.left, + y: clientY - rect.top + })); + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { + _PDFJSAnnotate2.default.getStoreAdapter().addComment(documentId, userId, annotation.uuid, content); + + (0, _appendChild.appendChild)(svg, annotation); + }); + } + + closeInput(); +} + +/** + * Close the input element + */ +function closeInput() { + input.removeEventListener('blur', handleInputBlur); + input.removeEventListener('keyup', handleInputKeyup); + document.body.removeChild(input); + input = null; +} + +/** + * Enable point annotation behavior + */ +function enablePoint() { + if (_enabled) { + return; + } + + _enabled = true; + document.addEventListener('mouseup', handleDocumentMouseup); +} + +/** + * Disable point annotation behavior + */ +function disablePoint() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('mouseup', handleDocumentMouseup); +} + +/***/ }), +/* 38 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.enableRect = enableRect; +exports.disableRect = disableRect; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + +var _enabled = false; +var _type = void 0; +var overlay = void 0; +var originY = void 0; +var originX = void 0; + +/** + * Get the current window selection as rects + * + * @return {Array} An Array of rects + */ +function getSelectionRects() { + try { + var selection = window.getSelection(); + var range = selection.getRangeAt(0); + var rects = range.getClientRects(); + + if (rects.length > 0 && rects[0].width > 0 && rects[0].height > 0) { + return rects; + } + } catch (e) {} + + return null; +} + +/** + * Handle document.mousedown event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentMousedown(e) { + var svg = void 0; + if (_type !== 'area' || !(svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY))) { + return; + } + + var rect = svg.getBoundingClientRect(); + originY = e.clientY; + originX = e.clientX; + + overlay = document.createElement('div'); + overlay.style.position = 'absolute'; + overlay.style.top = originY - rect.top + 'px'; + overlay.style.left = originX - rect.left + 'px'; + overlay.style.border = '3px solid ' + _utils.BORDER_COLOR; + overlay.style.borderRadius = '3px'; + svg.parentNode.appendChild(overlay); + + document.addEventListener('mousemove', handleDocumentMousemove); + (0, _utils.disableUserSelect)(); +} + +/** + * Handle document.mousemove event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentMousemove(e) { + var svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); + var rect = svg.getBoundingClientRect(); + + if (originX + (e.clientX - originX) < rect.right) { + overlay.style.width = e.clientX - originX + 'px'; + } + + if (originY + (e.clientY - originY) < rect.bottom) { + overlay.style.height = e.clientY - originY + 'px'; + } +} + +/** + * Handle document.mouseup event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentMouseup(e) { + var rects = void 0; + if (_type !== 'area' && (rects = getSelectionRects())) { + var svg = (0, _utils.findSVGAtPoint)(rects[0].left, rects[0].top); + saveRect(_type, [].concat(_toConsumableArray(rects)).map(function (r) { + return { + top: r.top, + left: r.left, + width: r.width, + height: r.height + }; + })); + } else if (_type === 'area' && overlay) { + var _svg = overlay.parentNode.querySelector(_config2.default.annotationSvgQuery()); + var rect = _svg.getBoundingClientRect(); + saveRect(_type, [{ + top: parseInt(overlay.style.top, 10) + rect.top, + left: parseInt(overlay.style.left, 10) + rect.left, + width: parseInt(overlay.style.width, 10), + height: parseInt(overlay.style.height, 10) + }]); + + overlay.parentNode.removeChild(overlay); + overlay = null; + + document.removeEventListener('mousemove', handleDocumentMousemove); + (0, _utils.enableUserSelect)(); + } +} + +/** + * Handle document.keyup event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentKeyup(e) { + // Cancel rect if Esc is pressed + if (e.keyCode === 27) { + var selection = window.getSelection(); + selection.removeAllRanges(); + if (overlay && overlay.parentNode) { + overlay.parentNode.removeChild(overlay); + overlay = null; + document.removeEventListener('mousemove', handleDocumentMousemove); + } + } +} + +/** + * Save a rect annotation + * + * @param {String} type The type of rect (area, highlight, strikeout) + * @param {Array} rects The rects to use for annotation + * @param {String} color The color of the rects + */ +function saveRect(type, rects, color) { + var svg = (0, _utils.findSVGAtPoint)(rects[0].left, rects[0].top); + var annotation = void 0; + + if (!svg) { + return; + } + + var boundingRect = svg.getBoundingClientRect(); + + if (!color) { + if (type === 'highlight') { + color = 'FFFF00'; + } else if (type === 'strikeout') { + color = 'FF0000'; + } + } + + // Initialize the annotation + annotation = { + type: type, + color: color, + rectangles: [].concat(_toConsumableArray(rects)).map(function (r) { + var offset = 0; + + if (type === 'strikeout') { + offset = r.height / 2; + } + + return (0, _utils.convertToSvgRect)({ + y: r.top + offset - boundingRect.top, + x: r.left - boundingRect.left, + width: r.width, + height: r.height + }, svg); + }).filter(function (r) { + return r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1; + }) + }; + + // Short circuit if no rectangles exist + if (annotation.rectangles.length === 0) { + return; + } + + // Special treatment for area as it only supports a single rect + if (type === 'area') { + var rect = annotation.rectangles[0]; + delete annotation.rectangles; + annotation.x = rect.x; + annotation.y = rect.y; + annotation.width = rect.width; + annotation.height = rect.height; + } + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId, + pageNumber = _getMetadata.pageNumber; + + // Add the annotation + + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { + (0, _appendChild.appendChild)(svg, annotation); + }); +} + +/** + * Enable rect behavior + */ +function enableRect(type) { + _type = type; + + if (_enabled) { + return; + } + + _enabled = true; + document.addEventListener('mouseup', handleDocumentMouseup); + document.addEventListener('mousedown', handleDocumentMousedown); + document.addEventListener('keyup', handleDocumentKeyup); +} + +/** + * Disable rect behavior + */ +function disableRect() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('mouseup', handleDocumentMouseup); + document.removeEventListener('mousedown', handleDocumentMousedown); + document.removeEventListener('keyup', handleDocumentKeyup); +} + +/***/ }), +/* 39 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.setCircle = setCircle; +exports.enableCircle = enableCircle; +exports.disableCircle = disableCircle; +exports.addCircle = addCircle; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _enabled = false; +var _type = void 0; +var _circleRadius = 10; +var _circleColor = '0000FF'; + +/** + * Set the attributes of the pen. + * + * @param {Number} circleRadius The radius of the circle + * @param {String} circleColor The color of the circle + */ +function setCircle() { + var circleRadius = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 10; + var circleColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0000FF'; + + _circleRadius = parseInt(circleRadius, 10); + _circleColor = circleColor; +} + +/** + * Handle document.mouseup event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentMouseup(e) { + var svg = (0, _utils.findSVGAtPoint)(e.clientX, e.clientY); + if (!svg) { + return; + } + var rect = svg.getBoundingClientRect(); + saveCircle(svg, _type, { + x: e.clientX - rect.left, + y: e.clientY - rect.top + }, _circleRadius, _circleColor); +} + +/** + * Save a circle annotation + * + * @param {SVGElement} svg + * @param {String} type The type of circle (circle, emptycircle, fillcircle) + * @param {Object} pt The point to use for annotation + * @param {float} radius + * @param {String} color The color of the rects + */ +function saveCircle(svg, type, pt, radius, color) { + // Initialize the annotation + var svg_pt = (0, _utils.convertToSvgPoint)([pt.x, pt.y], svg); + var annotation = { + type: type, + color: color, + cx: svg_pt[0], + cy: svg_pt[1], + r: radius + }; + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId, + pageNumber = _getMetadata.pageNumber; + + // Add the annotation + + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { + (0, _appendChild.appendChild)(svg, annotation); + }); +} + +/** + * Enable circle behavior + */ +function enableCircle(type) { + _type = type; + + if (_enabled) { + return; + } + + _enabled = true; + document.addEventListener('mouseup', handleDocumentMouseup); +} + +/** + * Disable circle behavior + */ +function disableCircle() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('mouseup', handleDocumentMouseup); +} + +function addCircle(type, e) { + var oldType = _type; + _type = type; + handleDocumentMouseup(e); + _type = oldType; +} + +/***/ }), +/* 40 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.setText = setText; +exports.enableText = enableText; +exports.disableText = disableText; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _appendChild = __webpack_require__(2); + +var _utils = __webpack_require__(1); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _enabled = false; +var input = void 0; +var _textSize = void 0; +var _textColor = void 0; + +/** + * Handle document.mouseup event + * + * @param {Event} e The DOM event to handle + */ +function handleDocumentMouseup(e) { + if (input || !(0, _utils.findSVGAtPoint)(e.clientX, e.clientY)) { + return; + } + if (!e.srcElement.classList.contains('annotationLayer')) { + return; + } + input = document.createElement('input'); + input.setAttribute('id', 'pdf-annotate-text-input'); + input.setAttribute('placeholder', 'Enter text'); + input.style.border = '3px solid ' + _utils.BORDER_COLOR; + input.style.borderRadius = '3px'; + input.style.position = 'absolute'; + input.style.top = e.clientY + 'px'; + input.style.left = e.clientX + 'px'; + input.style.fontSize = _textSize + 'px'; + input.style.zIndex = "41"; + input.addEventListener('blur', handleInputBlur); + input.addEventListener('keyup', handleInputKeyup); + + document.body.appendChild(input); + input.focus(); +} + +/** + * Handle input.blur event + */ +function handleInputBlur() { + saveText(); +} + +/** + * Handle input.keyup event + * + * @param {Event} e The DOM event to handle + */ +function handleInputKeyup(e) { + if (e.keyCode === 27) { + closeInput(); + } else if (e.keyCode === 13) { + saveText(); + } +} + +/** + * Save a text annotation from input + */ +function saveText() { + if (input.value.trim().length > 0) { + var clientX = parseInt(input.style.left, 10); + var clientY = parseInt(input.style.top, 10); + var svg = (0, _utils.findSVGAtPoint)(clientX, clientY); + if (!svg) { + return; + } + var height = _textSize; + + var _getMetadata = (0, _utils.getMetadata)(svg), + documentId = _getMetadata.documentId, + userId = _getMetadata.userId, + pageNumber = _getMetadata.pageNumber, + viewport = _getMetadata.viewport; + + var scale = 1 / viewport.scale; + var rect = svg.getBoundingClientRect(); + var pt = (0, _utils.convertToSvgPoint)([clientX - rect.left, clientY - rect.top + height], svg, viewport); + var annotation = { + type: 'textbox', + size: _textSize * scale, + color: _textColor, + content: input.value.trim(), + x: pt[0], + y: pt[1], + rotation: -viewport.rotation + }; + + _PDFJSAnnotate2.default.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation).then(function (annotation) { + (0, _appendChild.appendChild)(svg, annotation); + }); + } + + closeInput(); +} + +/** + * Close the input + */ +function closeInput() { + if (input) { + input.removeEventListener('blur', handleInputBlur); + input.removeEventListener('keyup', handleInputKeyup); + document.body.removeChild(input); + input = null; + } +} + +/** + * Set the text attributes + * + * @param {Number} textSize The size of the text + * @param {String} textColor The color of the text + */ +function setText() { + var textSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 12; + var textColor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '000000'; + + _textSize = parseInt(textSize, 10); + _textColor = textColor; +} + +/** + * Enable text behavior + */ +function enableText() { + if (_enabled) { + return; + } + + _enabled = true; + document.addEventListener('mouseup', handleDocumentMouseup); +} + +/** + * Disable text behavior + */ +function disableText() { + if (!_enabled) { + return; + } + + _enabled = false; + document.removeEventListener('mouseup', handleDocumentMouseup); +} + +/***/ }), +/* 41 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); + +exports.createPage = createPage; +exports.renderPage = renderPage; + +var _PDFJSAnnotate = __webpack_require__(0); + +var _PDFJSAnnotate2 = _interopRequireDefault(_PDFJSAnnotate); + +var _config = __webpack_require__(3); + +var _config2 = _interopRequireDefault(_config); + +var _renderScreenReaderHints = __webpack_require__(7); + +var _renderScreenReaderHints2 = _interopRequireDefault(_renderScreenReaderHints); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// Template for creating a new page +var PAGE_TEMPLATE = '\n \n'; + +/** + * Create a new page to be appended to the DOM. + * + * @param {Number} pageNumber The page number that is being created + * @return {HTMLElement} + */ +function createPage(pageNumber) { + var temp = document.createElement('div'); + temp.innerHTML = PAGE_TEMPLATE; + + var page = temp.children[0]; + var canvas = page.querySelector('canvas'); + + page.setAttribute('id', 'pageContainer' + pageNumber); + page.setAttribute('data-page-number', pageNumber); + + canvas.mozOpaque = true; + canvas.setAttribute('id', 'page' + pageNumber); + + return page; +} + +/** + * Render a page that has already been created. + * + * @param {Number} pageNumber The page number to be rendered + * @param {Object} renderOptions The options for rendering + * @return {Promise} Settled once rendering has completed + * A settled Promise will be either: + * - fulfilled: [pdfPage, annotations] + * - rejected: Error + */ +function renderPage(pageNumber, renderOptions) { + var documentId = renderOptions.documentId, + userId = renderOptions.userId, + pdfDocument = renderOptions.pdfDocument, + scale = renderOptions.scale, + rotate = renderOptions.rotate; + + // Load the page and annotations + + return Promise.all([pdfDocument.getPage(pageNumber), _PDFJSAnnotate2.default.getAnnotations(documentId, userId, pageNumber)]).then(function (_ref) { + var _ref2 = _slicedToArray(_ref, 2), + pdfPage = _ref2[0], + annotations = _ref2[1]; + + var page = document.getElementById('pageContainer' + pageNumber); + var svg = page.querySelector(_config2.default.annotationClassQuery()); + var canvas = page.querySelector('.canvasWrapper canvas'); + var canvasContext = canvas.getContext('2d', { alpha: false }); + var totalRotation = (rotate + pdfPage.rotate) % 360; + var viewport = pdfPage.getViewport(scale, totalRotation); + var transform = scalePage(pageNumber, viewport, canvasContext); + + // Render the page + return Promise.all([pdfPage.render({ canvasContext: canvasContext, viewport: viewport, transform: transform }), _PDFJSAnnotate2.default.render(svg, viewport, annotations)]).then(function () { + // Text content is needed for a11y, but is also necessary for creating + // highlight and strikeout annotations which require selecting text. + return pdfPage.getTextContent({ normalizeWhitespace: true }).then(function (textContent) { + return new Promise(function (resolve, reject) { + // Render text layer for a11y of text content + var textLayer = page.querySelector(_config2.default.textClassQuery()); + var textLayerFactory = new PDFJS.DefaultTextLayerFactory(); + var textLayerBuilder = textLayerFactory.createTextLayerBuilder(textLayer, pageNumber - 1, viewport); + textLayerBuilder.setTextContent(textContent); + textLayerBuilder.render(); + + // Enable a11y for annotations + // Timeout is needed to wait for `textLayerBuilder.render` + setTimeout(function () { + try { + (0, _renderScreenReaderHints2.default)(annotations.annotations); + resolve(); + } catch (e) { + reject(e); + } + }); + }); + }); + }).then(function () { + // Indicate that the page was loaded + page.setAttribute('data-loaded', 'true'); + + return [pdfPage, annotations]; + }); + }); +} + +/** + * Scale the elements of a page. + * + * @param {Number} pageNumber The page number to be scaled + * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate)) + * @param {Object} context The canvas context that the PDF page is rendered to + * @return {Array} The transform data for rendering the PDF page + */ +function scalePage(pageNumber, viewport, context) { + var page = document.getElementById('pageContainer' + pageNumber); + var canvas = page.querySelector('.canvasWrapper canvas'); + var svg = page.querySelector(_config2.default.annotationClassQuery()); + var wrapper = page.querySelector('.canvasWrapper'); + var textLayer = page.querySelector(_config2.default.textClassQuery()); + var outputScale = getOutputScale(context); + var transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0]; + var sfx = approximateFraction(outputScale.sx); + var sfy = approximateFraction(outputScale.sy); + + // Adjust width/height for scale + page.style.visibility = ''; + canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]); + canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]); + canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px'; + canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px'; + svg.setAttribute('width', viewport.width); + svg.setAttribute('height', viewport.height); + svg.style.width = viewport.width + 'px'; + svg.style.height = viewport.height + 'px'; + page.style.width = viewport.width + 'px'; + page.style.height = viewport.height + 'px'; + wrapper.style.width = viewport.width + 'px'; + wrapper.style.height = viewport.height + 'px'; + textLayer.style.width = viewport.width + 'px'; + textLayer.style.height = viewport.height + 'px'; + + return transform; +} + +/** + * Approximates a float number as a fraction using Farey sequence (max order of 8). + * + * @param {Number} x Positive float number + * @return {Array} Estimated fraction: the first array item is a numerator, + * the second one is a denominator. + */ +function approximateFraction(x) { + // Fast path for int numbers or their inversions. + if (Math.floor(x) === x) { + return [x, 1]; + } + + var xinv = 1 / x; + var limit = 8; + if (xinv > limit) { + return [1, limit]; + } else if (Math.floor(xinv) === xinv) { + return [1, xinv]; + } + + var x_ = x > 1 ? xinv : x; + + // a/b and c/d are neighbours in Farey sequence. + var a = 0, + b = 1, + c = 1, + d = 1; + + // Limit search to order 8. + while (true) { + // Generating next term in sequence (order of q). + var p = a + c, + q = b + d; + if (q > limit) { + break; + } + if (x_ <= p / q) { + c = p;d = q; + } else { + a = p;b = q; + } + } + + // Select closest of neighbours to x. + if (x_ - a / b < c / d - x_) { + return x_ === x ? [a, b] : [b, a]; + } else { + return x_ === x ? [c, d] : [d, c]; + } +} + +function getOutputScale(ctx) { + var devicePixelRatio = window.devicePixelRatio || 1; + var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1; + var pixelRatio = devicePixelRatio / backingStoreRatio; + return { + sx: pixelRatio, + sy: pixelRatio, + scaled: pixelRatio !== 1 + }; +} + +function roundToDivide(x, div) { + var r = x % div; + return r === 0 ? x : Math.round(x - r + div); +} -/***/ } -/******/ ]) +/***/ }) +/******/ ]); }); -; //# 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 index 1a9ae077..40da38c8 100644 --- a/dist/pdf-annotate.js.map +++ b/dist/pdf-annotate.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 59e89cdaf93308c40d35","webpack:///./index.js","webpack:///./src/PDFJSAnnotate.js","webpack:///./src/adapter/StoreAdapter.js","webpack:///./src/utils/abstractFunction.js","webpack:///./src/UI/event.js","webpack:///./~/events/events.js","webpack:///./src/UI/utils.js","webpack:///./~/create-stylesheet/index.js","webpack:///./src/render/appendChild.js","webpack:///./~/object-assign/index.js","webpack:///./src/render/renderLine.js","webpack:///./src/utils/setAttributes.js","webpack:///./src/utils/normalizeColor.js","webpack:///./src/render/renderPath.js","webpack:///./src/render/renderPoint.js","webpack:///./src/render/renderRect.js","webpack:///./src/render/renderText.js","webpack:///./src/render/renderCircle.js","webpack:///./src/render/renderArrow.js","webpack:///./src/utils/mathUtils.js","webpack:///./src/adapter/LocalStoreAdapter.js","webpack:///./src/utils/uuid.js","webpack:///./src/render/index.js","webpack:///./src/a11y/renderScreenReaderHints.js","webpack:///./src/a11y/insertScreenReaderHint.js","webpack:///./src/a11y/createScreenReaderOnly.js","webpack:///./src/a11y/insertElementWithinChildren.js","webpack:///./src/config.js","webpack:///./src/a11y/insertElementWithinElement.js","webpack:///./src/a11y/renderScreenReaderComments.js","webpack:///./src/a11y/insertScreenReaderComment.js","webpack:///./src/a11y/initEventHandlers.js","webpack:///./src/UI/index.js","webpack:///./src/UI/edit.js","webpack:///./src/UI/pen.js","webpack:///./src/UI/eraser.js","webpack:///./src/UI/arrow.js","webpack:///./src/UI/point.js","webpack:///./src/UI/rect.js","webpack:///./src/UI/circle.js","webpack:///./src/UI/text.js","webpack:///./src/UI/page.js"],"names":["PDFJSAnnotate","findAnnotationAtPoint","findSVGContainer","convertToScreenPoint","StoreAdapter","LocalStoreAdapter","__storeAdapter","getStoreAdapter","setStoreAdapter","adapter","UI","render","getAnnotations","documentId","userId","pageNumber","arguments","config","uuid","definition","Object","keys","forEach","key","annotationId","annotation","content","commentId","__getAnnotations","fn","then","annotations","a","__addAnnotation","addAnnotation","__editAnnotation","editAnnotation","__deleteAnnotation","deleteAnnotation","success","__addComment","addComment","comment","__deleteComment","deleteComment","abstractFunction","name","Error","fireEvent","addEventListener","removeEventListener","emitter","EventEmitter","clickNode","document","handleDocumentClick","e","clientX","clientY","target","emit","on","removeListener","findSVGAtPoint","pointIntersectsRect","getOffsetAnnotationRect","scaleUp","convertToSvgRect","convertToSvgPoint","scaleDown","getScroll","getOffset","disableUserSelect","enableUserSelect","getMetadata","BORDER_COLOR","userSelectStyleSheet","body","setAttribute","node","parentNode","nodeName","toUpperCase","getAttribute","x","y","elements","querySelectorAll","i","l","length","el","rect","getBoundingClientRect","candidate","elementFromPoint","type","top","bottom","left","right","offsetLeft","offsetTop","width","height","svg","result","viewport","scale","pt1","pt2","Math","min","abs","pt","xform","rotation","offset","scrollTop","scrollLeft","head","appendChild","removeChild","parseInt","JSON","parse","getTranslation","transformChild","isFirefox","test","navigator","userAgent","transform","trans","toLowerCase","path","querySelector","n","child","renderLine","group","createElementNS","stroke","color","strokeWidth","rectangles","r","line","x1","y1","x2","y2","setAttributes","UPPER_REGEX","BLACKLIST","keyCase","indexOf","replace","match","attributes","normalizeColor","REGEX_HASHLESS_HEX","renderPath","d","lines","p1","p2","push","join","fill","renderPoint","SIZE","D","outerSVG","innerSVG","viewBox","renderRect","fillOpacity","createRect","renderText","text","fontSize","size","innerHTML","g","renderCircle","circle","createCircle","cx","cy","renderArrow","arrow","arrowLength","pt0","unitX","unitZ","unitY","thickness","A","B","C","G","F","E","points","applyTransform","applyInverseTransform","translate","rotate","makePoint","makeVector","makeVectorFromPoints","addVector","multiplyVector","magnitude","negateVector","unitVector","crossProduct","p","m","xt","yt","m1","m2","angle","PI","cosValue","cos","sinValue","sin","getInverseTransform","z","xcoord","ycoord","zcoord","v","scalar","sqrt","pow","mag","u","Promise","resolve","reject","getAllAnnotations","filter","page","class","getAnnotation","findAnnotation","updateAnnotations","index","splice","getComments","_userId","all_annotations","localStorage","includes","getItem","setItem","stringify","REGEXP","PATTERN","replacement","c","random","toString","data","removeAttribute","Array","isArray","renderScreenReaderHints","SORT_TYPES","sortBy","sort","sortByPoint","b","sortByRectPoint","sortByLinePoint","lineA","lineB","insertScreenReaderHint","COMMENT_TYPES","num","rects","first","last","createScreenReaderOnly","createElement","createTextNode","style","position","overflow","insertElementWithinChildren","nodes","textClassQuery","insertBefore","textLayer","textRect","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","insertElementWithinElement","OFFSET_ADJUST","max","textLayerElementFromPoint","temp","cloneNode","split","tail","unshift","pop","outerHTML","renderScreenReaderComments","comments","promise","getElementById","list","insertScreenReaderComment","item","initEventHandlers","reorderAnnotationsByType","removeAnnotation","insertComment","removeComment","removeElementById","elementId","disableEdit","enableEdit","disablePen","enablePen","setPen","enableEraser","disableEraser","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","addCircle","disableArrow","enableArrow","setArrow","disableText","enableText","setText","createPage","renderPage","_enabled","isDragging","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","OVERLAY_BORDER_SIZE","createEditOverlay","destroyEditOverlay","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","background","padding","textAlign","textDecoration","handleDocumentKeyup","handleDocumentMousedown","borderColor","boxShadow","display","handleDocumentMousemove","handleDocumentMouseup","keyCode","cursor","minY","maxY","minX","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","t","modelX","modelY","viewY","viewX","setTimeout","handleAnnotationClick","_candraw","_penSize","_penColor","handleDocumentPointerdown","preventDefault","handleDocumentPointerupChrome","saveToStorage","changedTouches","handleDocumentPointerup","handleDocumentPointermove","srcElement","classList","contains","savePoint","handleDocumentPointermoveChrome","point","toFixed","penSize","penColor","_canerase","handleDocumentDown","handleDocumentUp","handleDocumentTouchMove","erase","handleDocumentMouseMove","parentElement","originY","originX","event","input","handleInputBlur","handleInputKeyup","focus","closeInput","value","trim","assign","_type","getSelectionRects","selection","window","getSelection","range","getRangeAt","getClientRects","saveRect","map","removeAllRanges","boundingRect","_circleRadius","_circleColor","circleRadius","circleColor","saveCircle","radius","svg_pt","oldType","_textSize","_textColor","saveText","textSize","textColor","PAGE_TEMPLATE","children","canvas","mozOpaque","renderOptions","pdfDocument","all","getPage","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","scalePage","getTextContent","normalizeWhitespace","textContent","textLayerFactory","PDFJS","DefaultTextLayerFactory","textLayerBuilder","createTextLayerBuilder","setTextContent","context","wrapper","outputScale","getOutputScale","scaled","sx","sy","sfx","approximateFraction","sfy","visibility","roundToDivide","floor","xinv","limit","x_","q","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","div","round"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;ACtCA;;;;;;mBAEeA,uB;;;;;;;;;;;;;ACFf;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;mBAMe;AACbC,sDADa;AAEbC,4CAFa;AAGbC,oDAHa;;AAKb;;;;AAIAC,uCATa;;AAWb;;;AAGAC,iDAda;;AAgBb;;;AAGAC,mBAAgB,IAAIF,sBAAJ,EAnBH;;AAqBb;;;;;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AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAiB;AACjB,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA,gBAAe,SAAS;AACxB;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,IAAG;AACH,qBAAoB,SAAS;AAC7B;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,IAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;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AaP,mBAAmBC,iBAApC;AACA,UAAO;AACLd,SAAIoB,UADC;AAELnB,SAAImB,UAFC;AAGLrB,aAAQqB,eAAe;AAHlB,IAAP;AAKD;;AAED,UAASd,aAAT,CAAuB9Z,CAAvB,EAA0B6a,GAA1B,EAA+B;AAC7B,OAAI/W,IAAI9D,IAAI6a,GAAZ;AACA,UAAO/W,MAAM,CAAN,GAAU9D,CAAV,GAAc2B,KAAKmZ,KAAL,CAAW9a,IAAI8D,CAAJ,GAAQ+W,GAAnB,CAArB;AACD,E","file":"dist/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})(this, function() {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \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\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\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.loaded = 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// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 59e89cdaf93308c40d35\n **/","import PDFJSAnnotate from './src/PDFJSAnnotate';\r\n\r\nexport default PDFJSAnnotate;\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./index.js\n **/","import StoreAdapter from './adapter/StoreAdapter';\r\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\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 * 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, userId, pageNumber) {\r\n return this.getStoreAdapter().getAnnotations(...arguments);\r\n },\r\n\r\n config,\r\n\r\n uuid\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/PDFJSAnnotate.js\n **/","import 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 {String} userId The user makeing changes to this document\r\n * @param {Number} pageNumber The number of the page the annotations belong to\r\n * @return {Promise}\r\n */\r\n __getAnnotations(documentId, userId, pageNumber) { abstractFunction('getAnnotations'); }\r\n get getAnnotations() { return this.__getAnnotations; }\r\n set getAnnotations(fn) {\r\n this.__getAnnotations = function getAnnotations(documentId, userId, 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}\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}\r\n */\r\n __addAnnotation(documentId, userId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\r\n get addAnnotation() { return this.__addAnnotation; }\r\n set addAnnotation(fn) {\r\n this.__addAnnotation = function addAnnotation(documentId, userId, pageNumber, annotation) {\r\n return fn(...arguments).then((annotation) => {\r\n fireEvent('annotation:add', documentId, userId, 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}\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}\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, userId, annotationId) {\r\n return fn(...arguments).then((success) => {\r\n if (success) {\r\n fireEvent('annotation:delete', documentId, userId, 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}\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}\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}\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/adapter/StoreAdapter.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/abstractFunction.js\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)) { return; }\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/event.js\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\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\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.\nEventEmitter.defaultMaxListeners = 10;\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(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/events/events.js\n ** module id = 5\n ** module chunks = 0\n **/","import createStyleSheet from 'create-stylesheet';\r\nimport { 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\n\r\nexport const BORDER_COLOR = '#00BFFF';\r\n\r\nconst userSelectStyleSheet = createStyleSheet({\r\n body: {\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\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= 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 { offsetLeft, offsetTop } = getOffset(el);\r\n return {\r\n top: rect.top - offsetTop,\r\n left: rect.left - offsetLeft,\r\n right: rect.right - offsetLeft,\r\n bottom: rect.bottom - offsetTop,\r\n width: rect.width,\r\n height: rect.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 var pt1 = [rect.x, rect.y];\r\n var 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 let result = {};\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 let result = {};\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/**\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 userId: svg.getAttribute('data-pdf-annotate-user'),\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/utils.js\n **/","module.exports = function createStyleSheet(blocks) {\n var style = document.createElement('style');\n var text = Object.keys(blocks).map(function (selector) {\n return processRuleSet(selector, blocks[selector]);\n }).join('\\n');\n \n style.setAttribute('type', 'text/css');\n style.appendChild(document.createTextNode(text));\n\n return style;\n}\n\nfunction processRuleSet(selector, block) {\n return selector + ' {\\n' + processDeclarationBlock(block) + '\\n}';\n}\n\nfunction processDeclarationBlock(block) {\n return Object.keys(block).map(function (prop) {\n return processDeclaration(prop, block[prop]);\n }).join('\\n');\n}\n\nfunction processDeclaration(prop, value) {\n if (!isNaN(value) && value != 0) {\n value = value + 'px';\n }\n\n return hyphenate(prop) + ': ' + value + ';';\n}\n\nfunction hyphenate(prop) {\n return prop.replace(/[A-Z]/g, function (match) {\n return '-' + match.toLowerCase();\n });\n}\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/create-stylesheet/index.js\n ** module id = 7\n ** module chunks = 0\n **/","import objectAssign from 'object-assign';\r\nimport 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, objectAssign({}, 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('data-pdf-annotate-type', annotation.type);\r\n child.setAttribute('data-pdf-annotate-userId', annotation.userId);\r\n child.setAttribute('aria-hidden', true);\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/appendChild.js\n **/","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./~/object-assign/index.js\n ** module id = 9\n ** module chunks = 0\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderLine.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/setAttributes.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/normalizeColor.js\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 \r\n for (let i=0, l=a.lines.length; i2) {\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\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(' ')}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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderPath.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderPoint.js\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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderRect.js\n **/","import setAttributes from '../utils/setAttributes';\r\nimport normalizeColor from '../utils/normalizeColor';\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\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 let x = a.x;\r\n let y = a.y;\r\n\r\n setAttributes(text, {\r\n x: x,\r\n y: y,\r\n fill: normalizeColor(a.color || '#000'),\r\n fontSize: a.size,\r\n transform: `rotate(${a.rotation}, ${x}, ${y})`\r\n });\r\n text.innerHTML = a.content;\r\n\r\n var 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderText.js\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 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 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 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderCircle.js\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 d = [];\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/renderArrow.js\n **/","// Transform point by matrix\r\n//\r\nexport function applyTransform(p, m) {\r\n var xt = p[0] * m[0] + p[1] * m[2] + m[4];\r\n var yt = p[0] * m[1] + p[1] * m[3] + m[5];\r\n return [xt, yt];\r\n};\r\n\r\n// Transform point by matrix inverse\r\n//\r\nexport function applyInverseTransform(p, m) {\r\n var d = m[0] * m[3] - m[1] * m[2];\r\n var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;\r\n var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;\r\n return [xt, yt];\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\n\r\nexport function rotate(m, angle) {\r\n angle = angle * Math.PI / 180;\r\n\r\n var cosValue = Math.cos(angle);\r\n var 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\nfunction getInverseTransform(m) {\r\n var d = m[0] * m[3] - m[1] * m[2];\r\n return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,\r\n (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];\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{\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{\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\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/mathUtils.js\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(userId = \"user\") {\r\n super({\r\n getAnnotations(documentId, userId, pageNumber) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAllAnnotations().filter((i) => {\r\n return i.page === pageNumber && i.class === 'Annotation';\r\n });\r\n\r\n resolve({\r\n documentId,\r\n userId,\r\n pageNumber,\r\n annotations\r\n });\r\n });\r\n },\r\n\r\n getAnnotation(documentId, annotationId) {\r\n return Promise.resolve(getAnnotations(documentId, userId)[findAnnotation(documentId, userId, annotationId)]);\r\n },\r\n\r\n addAnnotation(documentId, userId, 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 = userId;\r\n\r\n let annotations = getAnnotations(documentId, userId);\r\n annotations.push(annotation);\r\n updateAnnotations(documentId, userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n },\r\n\r\n editAnnotation(documentId, userId, annotationId, annotation) {\r\n return new Promise((resolve, reject) => {\r\n let annotations = getAnnotations(documentId, userId);\r\n annotations[findAnnotation(documentId, userId, annotationId)] = annotation;\r\n updateAnnotations(documentId, userId, annotations);\r\n\r\n resolve(annotation);\r\n });\r\n },\r\n\r\n deleteAnnotation(documentId, userId, annotationId) {\r\n return new Promise((resolve, reject) => {\r\n let index = findAnnotation(documentId, userId, annotationId);\r\n if (index > -1) {\r\n let annotations = getAnnotations(documentId, userId);\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n },\r\n\r\n getComments(documentId, userId, annotationId) {\r\n return new Promise((resolve, reject) => {\r\n resolve(getAnnotations(documentId, userId).filter((i) => {\r\n return i.class === 'Comment' && i.annotation === annotationId;\r\n }));\r\n });\r\n },\r\n\r\n addComment(documentId, userId, 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, userId);\r\n annotations.push(comment);\r\n updateAnnotations(documentId, userId, annotations);\r\n\r\n resolve(comment);\r\n });\r\n },\r\n\r\n deleteComment(documentId, userId, commentId) {\r\n return new Promise((resolve, reject) => {\r\n getAnnotations(documentId, userId);\r\n let index = -1;\r\n let annotations = getAnnotations(documentId, userId);\r\n for (let i=0, l=annotations.length; i -1) {\r\n annotations.splice(index, 1);\r\n updateAnnotations(documentId, userId, annotations);\r\n }\r\n\r\n resolve(true);\r\n });\r\n }\r\n });\r\n this._userId = userId;\r\n }\r\n get userId(){\r\n return this._userId;\r\n }\r\n}\r\n\r\nfunction getAllAnnotations(){\r\n let all_annotations = [];\r\n for(let i = 0 ; i < localStorage.length; i++){\r\n if(localStorage.key(i).includes('annotations')){\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 {\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-user', data.userId);\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 var node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\r\n if (node) {\r\n transformChild(svg, node, viewport);\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/render/index.js\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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/renderScreenReaderHints.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/insertScreenReaderHint.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/createScreenReaderOnly.js\n **/","import config from '../config';\r\nimport insertElementWithinElement from './insertElementWithinElement';\r\nimport { pointIntersectsRect } from '../UI/utils';\r\nimport { 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') {\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/insertElementWithinElement.js\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}\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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/renderScreenReaderComments.js\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/insertScreenReaderComment.js\n **/","import insertScreenReaderHint from './insertScreenReaderHint';\r\nimport 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, userId, pageNumber, annotation) => {\r\n reorderAnnotationsByType(documentId, userId, pageNumber, annotation.type);\r\n });\r\n addEventListener('annotation:edit', (documentId, userId, annotationId, annotation) => {\r\n reorderAnnotationsByType(documentId, userId, 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 {String} userId The ID of the user\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, userId, pageNumber, type) {\r\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, userId, 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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/a11y/initEventHandlers.js\n **/","import { addEventListener, removeEventListener, fireEvent } from './event';\r\nimport { disableEdit, enableEdit } from './edit';\r\nimport { disablePen, enablePen, setPen } from './pen';\r\nimport { enableEraser, disableEraser } from './eraser';\r\nimport { disableArrow, enableArrow, setArrow } from './arrow';\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, removeEventListener, fireEvent,\r\n disableEdit, enableEdit,\r\n disablePen, enablePen, setPen,\r\n enableEraser, disableEraser,\r\n disablePoint, enablePoint,\r\n disableRect, enableRect,\r\n disableCircle, enableCircle, setCircle, addCircle,\r\n disableArrow, enableArrow, setArrow,\r\n disableText, enableText, setText,\r\n createPage, renderPage\r\n};\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/index.js\n **/","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport { appendChild } from '../render/appendChild';\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 scaleUp,\r\n convertToSvgPoint\r\n} from './utils';\r\n\r\nlet _enabled = false;\r\nlet isDragging = false, 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) { return; }\r\n\r\n let annotationId = overlay.getAttribute('data-target-id');\r\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\r\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\r\n let { documentId } = getMetadata(svg);\r\n\r\n [...nodes].forEach((n) => {\r\n n.parentNode.removeChild(n);\r\n });\r\n \r\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId);\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 {Event} e The DOM event that needs to be handled\r\n */\r\nfunction handleDocumentKeyup(e) {\r\n if (overlay && e.keyCode === 46 &&\r\n e.target.nodeName.toLowerCase() !== 'textarea' &&\r\n e.target.nodeName.toLowerCase() !== 'input') {\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) { return; }\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 annotationId = overlay.getAttribute('data-target-id');\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, userId } = getMetadata(svg);\r\n \r\n overlay.querySelector('a').style.display = '';\r\n\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, 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 if (['area', 'highlight', 'point', '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 let viewY = modelY;\r\n\r\n if (type === 'point') {\r\n viewY = scaleUp(svg, { viewY }).viewY;\r\n }\r\n\r\n t.setAttribute(attribY, viewY);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].y = modelY;\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 let viewX = modelX;\r\n\r\n if (type === 'point') {\r\n viewX = scaleUp(svg, { viewX }).viewX;\r\n }\r\n\r\n t.setAttribute(attribX, viewX);\r\n if (annotation.rectangles && i < annotation.rectangles.length) {\r\n annotation.rectangles[i].x = modelX;\r\n } else if (annotation[attribX]) {\r\n annotation[attribX] = modelX;\r\n }\r\n }\r\n });\r\n // } else if (type === 'strikeout') {\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 } else if (type === 'drawing' || type === 'arrow') {\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\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) { return; }\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) { return; }\r\n\r\n _enabled = false;\r\n removeEventListener('annotation:click', handleAnnotationClick);\r\n};\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/edit.js\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\nconst isFirefox = /firefox/i.test(navigator.userAgent);\r\n\r\n/**\r\n * Handle document.touchdown or document.pointerdown event\r\n */\r\nfunction handleDocumentPointerdown(e) {\r\n e.preventDefault();\r\n path = null;\r\n lines = [];\r\n _candraw = true;\r\n}\r\n\r\n/**\r\n * Handle document.touchup or document.pointerup event\r\n *\r\n * @param {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointerupChrome(e){\r\n saveToStorage(e.changedTouches[0].clientX, e.changedTouches[0].clientY);\r\n}\r\n\r\nfunction handleDocumentPointerup(e) {\r\n saveToStorage(e.clientX, e.clientY);\r\n}\r\n\r\nfunction saveToStorage(x, y){\r\n _candraw = false;\r\n let svg;\r\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\r\n let { documentId, userId, pageNumber } = getMetadata(svg);\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, {\r\n type: 'drawing',\r\n width: _penSize,\r\n color: _penColor,\r\n lines\r\n }\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 {Event} e The DOM event to be handled\r\n */\r\nfunction handleDocumentPointermove(e) {\r\n if(!e.srcElement.classList.contains('annotationLayer')){\r\n return;\r\n }\r\n if(_candraw){\r\n savePoint(e.clientX, e.clientY);\r\n }\r\n}\r\n\r\nfunction handleDocumentPointermoveChrome(e){\r\n if(!e.srcElement.classList.contains('annotationLayer')){\r\n return;\r\n }\r\n if(_candraw){\r\n savePoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY);\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 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\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 = parseInt(penSize, 10);\r\n _penColor = penColor;\r\n}\r\n\r\n/**\r\n * Enable the pen behavior\r\n */\r\nexport function enablePen() {\r\n if (_enabled) { return; }\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 if (!isFirefox){\r\n document.addEventListener('touchstart', handleDocumentPointerdown);\r\n document.addEventListener('touchmove', handleDocumentPointermoveChrome);\r\n document.addEventListener('touchend', handleDocumentPointerupChrome);\r\n document.addEventListener('mousedown', handleDocumentPointerdown);\r\n document.addEventListener('mousemove', handleDocumentPointermove);\r\n document.addEventListener('mouseup', handleDocumentPointerup);\r\n } else {\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) { return; }\r\n\r\n _enabled = false;\r\n if (!isFirefox){\r\n document.removeEventListener('touchstart', handleDocumentPointerdown);\r\n document.removeEventListener('touchmove', handleDocumentPointermoveChrome);\r\n document.removeEventListener('touchend', handleDocumentPointerupChrome);\r\n document.removeEventListener('mousedown', handleDocumentPointerdown);\r\n document.removeEventListener('mousemove', handleDocumentPointermove);\r\n document.removeEventListener('mouseup', handleDocumentPointerup);\r\n } else {\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\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/pen.js\n **/","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\r\nimport {\r\n findAnnotationAtPoint,\r\n findSVGAtPoint,\r\n getMetadata\r\n} from './utils';\r\n\r\nlet _canerase = false;\r\nlet userId = \"user\";\r\n\r\nfunction handleDocumentDown(e){\r\n _canerase = true;\r\n}\r\n\r\nfunction handleDocumentUp(e){\r\n _canerase = false;\r\n}\r\n\r\nfunction handleDocumentTouchMove(e){\r\n erase(findAnnotationAtPoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY));\r\n}\r\n\r\nfunction handleDocumentMouseMove(e){\r\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\r\n}\r\n\r\nfunction erase(target){\r\n if(_canerase){\r\n if(target && target.getAttribute('data-pdf-annotate-userId') == userId){\r\n let { documentId } = getMetadata(target.parentElement);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\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 PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId);\r\n }\r\n }\r\n}\r\n\r\nexport function enableEraser(){\r\n userId = PDFJSAnnotate.getStoreAdapter().userId;\r\n document.addEventListener('mousemove', handleDocumentMouseMove);\r\n document.addEventListener('mousedown', handleDocumentDown);\r\n document.addEventListener('mouseup', handleDocumentUp);\r\n document.addEventListener('touchstart', handleDocumentDown);\r\n document.addEventListener('touchmove', handleDocumentTouchMove);\r\n document.addEventListener('touchend', handleDocumentUp);\r\n}\r\n\r\nexport function disableEraser(){\r\n document.removeEventListener('mousemove', handleDocumentMouseMove);\r\n document.removeEventListener('mousedown', handleDocumentDown);\r\n document.removeEventListener('mouseup', handleDocumentUp);\r\n document.removeEventListener('touchstart', handleDocumentDown);\r\n document.removeEventListener('touchmove', handleDocumentTouchMove);\r\n document.removeEventListener('touchend', handleDocumentUp);\r\n}\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/eraser.js\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 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, userId } = getMetadata(svg);\r\n let annotationId = target.getAttribute('data-pdf-annotate-id');\r\n\r\n let event = e;\r\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, 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 }\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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/arrow.js\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 } 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, userId, 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\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/point.js\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 } 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 let svg = findSVGAtPoint(rects[0].left, rects[0].top);\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 } 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 } 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, userId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/rect.js\n **/","import PDFJSAnnotate from '../PDFJSAnnotate';\r\nimport config from '../config';\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/**\r\n * Save a circle annotation\r\n *\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 {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, userId, pageNumber } = getMetadata(svg);\r\n\r\n // Add the annotation\r\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, 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}\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/circle.js\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;\r\nlet _textColor;\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('input');\r\n input.setAttribute('id', 'pdf-annotate-text-input');\r\n input.setAttribute('placeholder', 'Enter text');\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 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 } else if (e.keyCode === 13) {\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 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 svg = findSVGAtPoint(clientX, clientY);\r\n if (!svg) {\r\n return;\r\n }\r\n let height = _textSize;\r\n let { documentId, userId, 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: input.value.trim(),\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, userId, 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/**\r\n * Enable text behavior\r\n */\r\nexport function enableText() {\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/**\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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/text.js\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 userId,\r\n pdfDocument,\r\n scale,\r\n rotate\r\n } = renderOptions;\r\n\r\n // Load the page and annotations\r\n return Promise.all([\r\n pdfDocument.getPage(pageNumber),\r\n PDFJSAnnotate.getAnnotations(documentId, userId, 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, 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 }),\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 PDFJS.DefaultTextLayerFactory();\r\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(textLayer, pageNumber -1, viewport);\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 } 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/**\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 } 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, b = 1, c = 1, 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, 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 } 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 } 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\n\n\n/** WEBPACK FOOTER **\n ** ./src/UI/page.js\n **/"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 2b6c5ed9fbef71928c7c","webpack:///./src/PDFJSAnnotate.js","webpack:///./src/UI/utils.js","webpack:///./src/render/appendChild.js","webpack:///./src/config.js","webpack:///./src/utils/setAttributes.js","webpack:///./src/utils/normalizeColor.js","webpack:///./src/UI/event.js","webpack:///./src/a11y/renderScreenReaderHints.js","webpack:///./src/adapter/StoreAdapter.js","webpack:///./src/utils/mathUtils.js","webpack:///./src/utils/uuid.js","webpack:///./src/a11y/insertScreenReaderHint.js","webpack:///./src/a11y/insertElementWithinElement.js","webpack:///./src/a11y/renderScreenReaderComments.js","webpack:///./src/a11y/insertScreenReaderComment.js","webpack:///./index.js","webpack:///./src/utils/abstractFunction.js","webpack:///./node_modules/events/events.js","webpack:///./node_modules/create-stylesheet/index.js","webpack:///./node_modules/object-assign/index.js","webpack:///./src/render/renderLine.js","webpack:///./src/render/renderPath.js","webpack:///./src/render/renderPoint.js","webpack:///./src/render/renderRect.js","webpack:///./src/render/renderText.js","webpack:///./src/render/renderCircle.js","webpack:///./src/render/renderArrow.js","webpack:///./src/adapter/LocalStoreAdapter.js","webpack:///./src/render/index.js","webpack:///./src/a11y/createScreenReaderOnly.js","webpack:///./src/a11y/insertElementWithinChildren.js","webpack:///./src/a11y/initEventHandlers.js","webpack:///./src/UI/index.js","webpack:///./src/UI/edit.js","webpack:///./src/UI/pen.js","webpack:///./src/UI/arrow.js","webpack:///./src/UI/eraser.js","webpack:///./src/UI/point.js","webpack:///./src/UI/rect.js","webpack:///./src/UI/circle.js","webpack:///./src/UI/text.js","webpack:///./src/UI/page.js"],"names":["findAnnotationAtPoint","findSVGContainer","convertToScreenPoint","StoreAdapter","LocalStoreAdapter","__storeAdapter","getStoreAdapter","setStoreAdapter","adapter","UI","render","getAnnotations","documentId","userId","pageNumber","arguments","config","uuid","findSVGAtPoint","pointIntersectsRect","getOffsetAnnotationRect","scaleUp","convertToSvgRect","convertToSvgPoint","scaleDown","getScroll","getOffset","disableUserSelect","enableUserSelect","getMetadata","BORDER_COLOR","userSelectStyleSheet","body","setAttribute","node","parentNode","document","nodeName","toUpperCase","getAttribute","x","y","elements","querySelectorAll","i","l","length","el","rect","getBoundingClientRect","candidate","elementFromPoint","type","top","bottom","left","right","width","height","extraOffsetWidth","extraOffsetHeight","indexOf","tagName","toLowerCase","getBBox","bbox","offsetLeft","offsetTop","svg","result","viewport","Object","keys","forEach","key","scale","pt1","pt2","Math","min","abs","pt","xform","rotation","offset","scrollTop","scrollLeft","head","appendChild","removeChild","parseInt","JSON","parse","getTranslation","transformChild","isFirefox","test","navigator","userAgent","transform","trans","path","querySelector","n","annotation","child","annotationLayerName","textLayerName","annotationSvgQuery","annotationClassQuery","textClassQuery","setAttributes","UPPER_REGEX","BLACKLIST","keyCase","replace","match","attributes","normalizeColor","REGEX_HASHLESS_HEX","color","fireEvent","addEventListener","removeEventListener","emitter","EventEmitter","clickNode","handleDocumentClick","e","clientX","clientY","target","emit","on","removeListener","renderScreenReaderHints","annotations","Array","isArray","SORT_TYPES","sortBy","filter","a","sort","sortByPoint","b","sortByRectPoint","rectangles","sortByLinePoint","lineA","lines","lineB","definition","annotationId","content","commentId","__getAnnotations","fn","then","__addAnnotation","addAnnotation","__editAnnotation","editAnnotation","__deleteAnnotation","deleteAnnotation","success","__addComment","addComment","comment","__deleteComment","deleteComment","applyTransform","applyInverseTransform","translate","rotate","makePoint","makeVector","makeVectorFromPoints","addVector","multiplyVector","magnitude","negateVector","unitVector","crossProduct","p","m","xt","yt","d","m1","m2","angle","PI","cosValue","cos","sinValue","sin","getInverseTransform","z","xcoord","ycoord","zcoord","v","scalar","sqrt","pow","mag","u","REGEXP","PATTERN","replacement","c","r","random","toString","insertScreenReaderHint","COMMENT_TYPES","num","rects","first","last","page","text","x2","cx","y2","cy","includes","insertElementWithinElement","insertBefore","OFFSET_ADJUST","max","textLayerElementFromPoint","temp","cloneNode","innerHTML","split","tail","style","position","unshift","pop","join","outerHTML","renderScreenReaderComments","comments","promise","Promise","resolve","PDFJSAnnotate","getComments","getElementById","list","createElement","insertScreenReaderComment","item","createTextNode","abstractFunction","name","Error","renderLine","group","createElementNS","stroke","strokeWidth","line","x1","y1","renderPath","push","p1","p2","fill","renderPoint","SIZE","D","outerSVG","innerSVG","viewBox","renderRect","fillOpacity","createRect","renderText","fontSize","size","g","renderCircle","circle","createCircle","renderArrow","arrow","arrowLength","pt0","unitX","unitZ","unitY","thickness","A","B","C","G","F","E","points","reject","getAllAnnotations","class","getAnnotation","findAnnotation","updateAnnotations","index","splice","_userId","all_annotations","localStorage","getItem","setItem","stringify","data","removeAttribute","createScreenReaderOnly","overflow","insertElementWithinChildren","nodes","textLayer","textRect","initEventHandlers","reorderAnnotationsByType","removeAnnotation","insertComment","removeComment","removeElementById","elementId","disableEdit","enableEdit","disablePen","enablePen","setPen","disablePoint","enablePoint","disableRect","enableRect","disableCircle","enableCircle","setCircle","addCircle","disableArrow","enableArrow","setArrow","disableEraser","enableEraser","disableText","enableText","setText","createPage","renderPage","_enabled","isDragging","overlay","dragOffsetX","dragOffsetY","dragStartX","dragStartY","OVERLAY_BORDER_SIZE","createEditOverlay","destroyEditOverlay","anchor","id","styleLeft","styleTop","boxSizing","border","borderRadius","zIndex","background","padding","textAlign","textDecoration","handleDocumentKeyup","handleDocumentMousedown","borderColor","boxShadow","display","handleDocumentMousemove","handleDocumentMouseup","keyTest","keyCode","preventDefault","cursor","minY","maxY","minX","maxX","offsetHeight","offsetWidth","attribX","attribY","modelStart","modelEnd","modelDelta","firstChild","t","modelX","modelY","setTimeout","handleAnnotationClick","_candraw","_penSize","_penColor","handleDocumentPointerdown","handleDocumentPointerupChrome","saveToStorage","changedTouches","handleDocumentPointerup","handleDocumentPointermove","srcElement","classList","contains","savePoint","point","toFixed","penSize","penColor","originY","originX","event","_canerase","handleDocumentDown","handleDocumentUp","handleDocumentMouseMove","erase","parentElement","input","handleInputBlur","handleInputKeyup","focus","closeInput","value","trim","assign","_type","getSelectionRects","selection","window","getSelection","range","getRangeAt","getClientRects","saveRect","map","removeAllRanges","boundingRect","_circleRadius","_circleColor","circleRadius","circleColor","saveCircle","radius","svg_pt","oldType","_textSize","_textColor","saveText","textSize","textColor","PAGE_TEMPLATE","children","canvas","mozOpaque","renderOptions","pdfDocument","all","getPage","pdfPage","canvasContext","getContext","alpha","totalRotation","getViewport","scalePage","getTextContent","normalizeWhitespace","textContent","textLayerFactory","PDFJS","DefaultTextLayerFactory","textLayerBuilder","createTextLayerBuilder","setTextContent","context","wrapper","outputScale","getOutputScale","scaled","sx","sy","sfx","approximateFraction","sfy","visibility","roundToDivide","floor","xinv","limit","x_","q","ctx","devicePixelRatio","backingStoreRatio","webkitBackingStorePixelRatio","mozBackingStorePixelRatio","msBackingStorePixelRatio","oBackingStorePixelRatio","backingStorePixelRatio","pixelRatio","div","round"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;;;;;;;AC7DA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;kBAMe;AACbA,qDADa;AAEbC,2CAFa;AAGbC,mDAHa;;AAKb;;;;AAIAC,sCATa;;AAWb;;;AAGAC,gDAda;;AAgBb;;;AAGAC,kBAAgB,IAAIF,sBAAJ,EAnBH;;AAqBb;;;;;AAKAG,iBA1Ba,6BA0BK;AAChB,WAAO,KAAKD,cAAZ;AACD,GA5BY;;;AA8Bb;;;;;AAKAE,iBAnCa,2BAmCGC,OAnCH,EAmCY;AACvB;AACA;AACA;AACA;;AAEA,SAAKH,cAAL,GAAsBG,OAAtB;AACD,GA1CY;;;AA4Cb;;;;AAIAC,kBAhDa;;AAkDb;;;;;;;;AAQAC,0BA1Da;;AA4Db;;;;;;;;AAQAC,gBApEa,0BAoEEC,UApEF,EAoEcC,MApEd,EAoEsBC,UApEtB,EAoEkC;AAAA;;AAC7C,WAAO,yBAAKR,eAAL,IAAuBK,cAAvB,yBAAyCI,SAAzC,CAAP;AACD,GAtEY;;;AAwEbC,0BAxEa;;AA0EbC;AA1Ea,C;;;;;;;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Ac;AACZ;AACD;;AAED,MAAIoF,OAAOxN,SAASkE,aAAT,iCAAqDkE,QAAQhE,UAA7D,SAAX;AACA,MAAIoJ,IAAJ,EAAU;AACR,QAAIG,OAAO3N,SAASyN,aAAT,CAAuB,IAAvB,CAAX;AACAE,SAAK9N,YAAL,CAAkB,IAAlB,yCAA6DuI,QAAQvJ,IAArE;AACA8O,SAAKvK,WAAL,CAAiBpD,SAAS4N,cAAT,MAA2BxF,QAAQd,OAAnC,CAAjB;AACAkG,SAAKpK,WAAL,CAAiBuK,IAAjB;AACD;AACF;;;;;;;;;;;;;;ACjBD;;;;;;kBAEeN,uB;;;;;;;;;;;;;kBCGSQ,gB;AALxB;;;;;AAKe,SAASA,gBAAT,CAA0BC,IAA1B,EAAgC;AAC7C,QAAM,IAAIC,KAAJ,CAAUD,OAAO,qBAAjB,CAAN;AACD;;;;;;;;ACPD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEa;;AAEb;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,sBAAsB;AACvC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA,cAAc;AACd;;AAEA;;AAEA;AACA;;AAEA;AACA;AACA,GAAG;AACH;AACA;AACA,mBAAmB,SAAS;AAC5B;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,sBAAsB;AACvC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,eAAe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA,iCAAiC,QAAQ;AACzC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,mBAAmB,iBAAiB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA,OAAO;AACP;AACA,sCAAsC,QAAQ;AAC9C;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,KAAK;AACL;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,OAAO;AACxB;AACA;AACA;;AAEA;AACA,QAAQ,yBAAyB;AACjC;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,gBAAgB;AACjC;AACA;AACA;AACA;;;;;;;AC/bA;AACA;AACA;AACA;AACA,GAAG;;AAEH;AACA;;AAEA;AACA;;AAEA;AACA,uBAAuB,2CAA2C;AAClE;;AAEA;AACA;AACA;AACA,GAAG;AACH;;AAEA;AACA;AACA;AACA;;AAEA,4CAA4C;AAC5C;;AAEA;AACA;AACA;AACA,GAAG;AACH;;;;;;;;AClCA;AACA;AACA;AACA;AACA;;AAEa;AACb;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;;AAEA;AACA;AACA,iBAAiB,QAAQ;AACzB;AACA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,GAAG;AACH,kCAAkC;AAClC;AACA;AACA;;AAEA;AACA,EAAE;AACF;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA,gBAAgB,sBAAsB;AACtC;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,kBAAkB,oBAAoB;AACtC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;;;;;;;;;;;;kBC/EwBE,U;;AAVxB;;;;AACA;;;;;;AAEA;;;;;;;AAOe,SAASA,UAAT,CAAoBtH,CAApB,EAAuB;AACpC,MAAIuH,QAAQjO,SAASkO,eAAT,CAAyB,4BAAzB,EAAuD,GAAvD,CAAZ;AACA,+BAAcD,KAAd,EAAqB;A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AIxW,IAAI2C,CAAvB;AACA,QAAI6T,IAAIF,KAAR,EAAe;AACb;AACD;AACD,QAAIC,MAAMhU,IAAIiU,CAAd,EAAiB;AACftS,UAAI3B,CAAJ,CAAOI,IAAI6T,CAAJ;AACR,KAFD,MAEO;AACL3W,UAAI0C,CAAJ,CAAOvC,IAAIwW,CAAJ;AACR;AACF;;AAED;AACA,MAAID,KAAK1W,IAAIG,CAAT,GAAakE,IAAIvB,CAAJ,GAAQ4T,EAAzB,EAA6B;AAC3B,WAAOA,OAAOhd,CAAP,GAAW,CAACsG,CAAD,EAAIG,CAAJ,CAAX,GAAoB,CAACA,CAAD,EAAIH,CAAJ,CAA3B;AACD,GAFD,MAEO;AACL,WAAO0W,OAAOhd,CAAP,GAAW,CAAC2K,CAAD,EAAIvB,CAAJ,CAAX,GAAoB,CAACA,CAAD,EAAIuB,CAAJ,CAA3B;AACD;AACF;;AAED,SAASyR,cAAT,CAAwBc,GAAxB,EAA6B;AAC3B,MAAIC,mBAAmBhE,OAAOgE,gBAAP,IAA2B,CAAlD;AACA,MAAIC,oBAAoBF,IAAIG,4BAAJ,IACAH,IAAII,yBADJ,IAEAJ,IAAIK,wBAFJ,IAGAL,IAAIM,uBAHJ,IAIAN,IAAIO,sBAJJ,IAI8B,CAJtD;AAKA,MAAIC,aAAaP,mBAAmBC,iBAApC;AACA,SAAO;AACLd,QAAIoB,UADC;AAELnB,QAAImB,UAFC;AAGLrB,YAAQqB,eAAe;AAHlB,GAAP;AAKD;;AAED,SAASd,aAAT,CAAuB5c,CAAvB,EAA0B2d,GAA1B,EAA+B;AAC7B,MAAI/S,IAAI5K,IAAI2d,GAAZ;AACA,SAAO/S,MAAM,CAAN,GAAU5K,CAAV,GAAcsC,KAAKsb,KAAL,CAAW5d,IAAI4K,CAAJ,GAAQ+S,GAAnB,CAArB;AACD,C","file":"dist/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})(typeof self !== 'undefined' ? self : this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 15);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 2b6c5ed9fbef71928c7c","import StoreAdapter from './adapter/StoreAdapter';\nimport LocalStoreAdapter from './adapter/LocalStoreAdapter';\nimport render from './render';\nimport UI from './UI';\nimport config from './config';\nimport uuid from './utils/uuid';\nimport { \n findAnnotationAtPoint, \n findSVGContainer,\n convertToScreenPoint\n} from './UI/utils';\n\nexport default {\n findAnnotationAtPoint,\n findSVGContainer,\n convertToScreenPoint,\n\n /**\n * Abstract class that needs to be defined so PDFJSAnnotate\n * knows how to communicate with your server.\n */\n StoreAdapter,\n\n /**\n * Implementation of StoreAdapter that stores annotation data to localStorage.\n */\n LocalStoreAdapter,\n\n /**\n * Abstract instance of StoreAdapter\n */\n __storeAdapter: new StoreAdapter(),\n\n /**\n * Getter for the underlying StoreAdapter property\n *\n * @return {StoreAdapter}\n */\n getStoreAdapter() {\n return this.__storeAdapter;\n },\n\n /**\n * Setter for the underlying StoreAdapter property\n *\n * @param {StoreAdapter} adapter The StoreAdapter implementation to be used.\n */\n setStoreAdapter(adapter) {\n // TODO this throws an error when bundled\n // if (!(adapter instanceof StoreAdapter)) {\n // throw new Error('adapter must be an instance of StoreAdapter');\n // }\n\n this.__storeAdapter = adapter;\n },\n\n /**\n * UI is a helper for instrumenting UI interactions for creating,\n * editing, and deleting annotations in the browser.\n */\n UI,\n\n /**\n * Render the annotations for a page in the PDF Document\n *\n * @param {SVGElement} svg The SVG element that annotations should be rendered to\n * @param {PageViewport} viewport The PDFPage.getViewport data\n * @param {Object} data The StoreAdapter.getAnnotations data\n * @return {Promise}\n */\n render,\n\n /**\n * Convenience method for getting annotation data\n *\n * @alias StoreAdapter.getAnnotations\n * @param {String} documentId The ID of the document\n * @param {String} pageNumber The page number\n * @return {Promise}\n */\n getAnnotations(documentId, userId, pageNumber) {\n return this.getStoreAdapter().getAnnotations(...arguments);\n },\n\n config,\n\n uuid\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/PDFJSAnnotate.js","import createStyleSheet from 'create-stylesheet';\nimport { getTranslation } from '../render/appendChild';\nimport {\n applyTransform,\n applyInverseTransform,\n translate,\n rotate,\n scale\n} from '../utils/mathUtils';\n\n\nexport const BORDER_COLOR = '#00BFFF';\n\nconst userSelectStyleSheet = createStyleSheet({\n body: {\n '-webkit-user-select': 'none',\n '-moz-user-select': 'none',\n '-ms-user-select': 'none',\n 'user-select': 'none'\n }\n});\nuserSelectStyleSheet.setAttribute('data-pdf-annotate-user-select', 'true');\n\n/**\n * Find the SVGElement that contains all the annotations for a page\n *\n * @param {Element} node An annotation within that container\n * @return {SVGElement} The container SVG or null if it can't be found\n */\nexport function findSVGContainer(node) {\n let parentNode = node;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG' &&\n parentNode.getAttribute('data-pdf-annotate-container') === 'true') {\n return parentNode;\n }\n }\n\n return null;\n}\n\n/**\n * Find an SVGElement container at a given point\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @return {SVGElement} The container SVG or null if one can't be found\n */\nexport function findSVGAtPoint(x, y) {\n let elements = document.querySelectorAll('svg[data-pdf-annotate-container=\"true\"]');\n\n for (let i=0, l=elements.length; i= rect.top && y <= rect.bottom && x >= rect.left && x <= rect.right;\n}\n\n/**\n * Get the rect of an annotation element accounting for offset.\n *\n * @param {Element} el The element to get the rect of\n * @return {Object} The dimensions of the element\n */\nexport function getOffsetAnnotationRect(el) {\n let rect = el.getBoundingClientRect();\n let { width, height } = rect;\n let extraOffsetWidth = 0;\n let extraOffsetHeight = 0;\n if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) {\n let bbox = el.getBBox();\n extraOffsetWidth = (rect.width - bbox.width) / 2;\n extraOffsetHeight = (rect.height - bbox.height) / 2;\n width = bbox.width;\n height = bbox.height;\n }\n let { offsetLeft, offsetTop } = getOffset(el);\n return {\n top: rect.top - offsetTop + extraOffsetHeight,\n left: rect.left - offsetLeft + extraOffsetWidth,\n bottom: rect.bottom - offsetTop - extraOffsetHeight,\n right: rect.right - offsetLeft - extraOffsetWidth,\n width: width,\n height: height\n };\n}\n\n/**\n * Adjust scale from normalized scale (100%) to rendered scale.\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled up\n */\nexport function scaleUp(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] * viewport.scale;\n });\n\n return result;\n}\n\nexport function convertToSvgRect(rect, svg, viewport) {\n var pt1 = [rect.x, rect.y];\n var pt2 = [rect.x + rect.width, rect.y + rect.height];\n\n pt1 = convertToSvgPoint(pt1, svg, viewport);\n pt2 = convertToSvgPoint(pt2, svg, viewport);\n\n return {\n x: Math.min(pt1[0], pt2[0]),\n y: Math.min(pt1[1], pt2[1]),\n width: Math.abs(pt2[0] - pt1[0]),\n height: Math.abs(pt2[1] - pt1[1])\n };\n}\n\nexport function convertToSvgPoint(pt, svg, viewport) {\n let result = {};\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyInverseTransform(pt, xform);\n}\n\nexport function convertToScreenPoint(pt, svg, viewport) {\n let result = {};\n viewport = viewport || getMetadata(svg).viewport;\n\n let xform = [ 1, 0, 0, 1, 0, 0 ];\n xform = scale(xform, viewport.scale, viewport.scale);\n xform = rotate(xform, viewport.rotation);\n\n let offset = getTranslation(viewport);\n xform = translate(xform, offset.x, offset.y);\n\n return applyTransform(pt, xform);\n}\n\n/**\n * Adjust scale from rendered scale to a normalized scale (100%).\n *\n * @param {SVGElement} svg The SVG to gather metadata from\n * @param {Object} rect A map of numeric values to scale\n * @return {Object} A copy of `rect` with values scaled down\n */\nexport function scaleDown(svg, rect) {\n let result = {};\n let { viewport } = getMetadata(svg);\n\n Object.keys(rect).forEach((key) => {\n result[key] = rect[key] / viewport.scale;\n });\n\n return result;\n}\n\n/**\n * Get the scroll position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the scroll position for\n * @return {Object} The scrollTop and scrollLeft position\n */\nexport function getScroll(el) {\n let scrollTop = 0;\n let scrollLeft = 0;\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n scrollTop += parentNode.scrollTop;\n scrollLeft += parentNode.scrollLeft;\n }\n\n return { scrollTop, scrollLeft };\n}\n\n/**\n * Get the offset position of an element, accounting for parent elements\n *\n * @param {Element} el The element to get the offset position for\n * @return {Object} The offsetTop and offsetLeft position\n */\nexport function getOffset(el) {\n let parentNode = el;\n\n while ((parentNode = parentNode.parentNode) &&\n parentNode !== document) {\n if (parentNode.nodeName.toUpperCase() === 'SVG') {\n break;\n }\n }\n\n let rect = parentNode.getBoundingClientRect();\n\n return { offsetLeft: rect.left, offsetTop: rect.top };\n}\n\n/**\n * Disable user ability to select text on page\n */\nexport function disableUserSelect() {\n if (!userSelectStyleSheet.parentNode) {\n document.head.appendChild(userSelectStyleSheet);\n }\n}\n\n\n/**\n * Enable user ability to select text on page\n */\nexport function enableUserSelect() {\n if (userSelectStyleSheet.parentNode) {\n userSelectStyleSheet.parentNode.removeChild(userSelectStyleSheet);\n }\n}\n\n/**\n * Get the metadata for a SVG container\n *\n * @param {SVGElement} svg The SVG container to get metadata for\n */\nexport function getMetadata(svg) {\n return {\n documentId: svg.getAttribute('data-pdf-annotate-document'),\n userId: svg.getAttribute('data-pdf-annotate-user'),\n pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10),\n viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'))\n };\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/utils.js","import objectAssign from 'object-assign';\nimport renderLine from './renderLine';\nimport renderPath from './renderPath';\nimport renderPoint from './renderPoint';\nimport renderRect from './renderRect';\nimport renderText from './renderText';\nimport renderCircle from './renderCircle';\nimport renderArrow from './renderArrow';\n\nconst isFirefox = /firefox/i.test(navigator.userAgent);\n\n/**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n *\n * @param {Object} viewport The viewport data from the page\n * @return {Object}\n */\nexport function getTranslation(viewport) {\n let x;\n let y;\n\n // Modulus 360 on the rotation so that we only\n // have to worry about four possible values.\n switch(viewport.rotation % 360) {\n case 0:\n x = y = 0;\n break;\n case 90:\n x = 0;\n y = (viewport.width / viewport.scale) * -1;\n break;\n case 180:\n x = (viewport.width / viewport.scale) * -1;\n y = (viewport.height / viewport.scale) * -1;\n break;\n case 270:\n x = (viewport.height / viewport.scale) * -1;\n y = 0;\n break;\n }\n\n return { x, y };\n}\n\n/**\n * Transform the rotation and scale of a node using SVG's native transform attribute.\n *\n * @param {Node} node The node to be transformed\n * @param {Object} viewport The page's viewport data\n * @return {Node}\n */\nfunction transform(node, viewport) {\n let trans = getTranslation(viewport);\n\n // Let SVG natively transform the element\n node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`);\n \n // Manually adjust x/y for nested SVG nodes\n if (!isFirefox && node.nodeName.toLowerCase() === 'svg') {\n node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale);\n node.setAttribute('y', parseInt(node.getAttribute('y'), 10) * viewport.scale);\n\n let x = parseInt(node.getAttribute('x', 10));\n let y = parseInt(node.getAttribute('y', 10));\n let width = parseInt(node.getAttribute('width'), 10);\n let height = parseInt(node.getAttribute('height'), 10);\n let path = node.querySelector('path');\n let svg = path.parentNode;\n \n // Scale width/height\n [node, svg, path, node.querySelector('rect')].forEach((n) => {\n n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale);\n n.setAttribute('height', parseInt(n.getAttribute('height'), 10) * viewport.scale);\n });\n\n // Transform path but keep scale at 100% since it will be handled natively\n transform(path, objectAssign({}, viewport, { scale: 1 }));\n \n switch(viewport.rotation % 360) {\n case 90:\n node.setAttribute('x', viewport.width - y - width);\n node.setAttribute('y', x);\n svg.setAttribute('x', 1);\n svg.setAttribute('y', 0);\n break;\n case 180:\n node.setAttribute('x', viewport.width - x - width);\n node.setAttribute('y', viewport.height - y - height);\n svg.setAttribute('y', 2);\n break;\n case 270:\n node.setAttribute('x', y);\n node.setAttribute('y', viewport.height - x - height);\n svg.setAttribute('x', -1);\n svg.setAttribute('y', 0);\n break;\n }\n }\n\n return node;\n}\n\n/**\n * Append an annotation as a child of an SVG.\n *\n * @param {SVGElement} svg The SVG element to append the annotation to\n * @param {Object} annotation The annotation definition to render and append\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was created and appended by this function\n */\nexport function appendChild(svg, annotation, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n \n let child;\n switch (annotation.type) {\n case 'area':\n case 'highlight':\n child = renderRect(annotation);\n break;\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n child = renderCircle(annotation);\n break;\n case 'strikeout':\n child = renderLine(annotation);\n break;\n case 'point':\n child = renderPoint(annotation);\n break;\n case 'textbox':\n child = renderText(annotation);\n break;\n case 'drawing':\n child = renderPath(annotation);\n break;\n case 'arrow':\n child = renderArrow(annotation);\n break;\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip appending/transforming if node doesn't exist.\n if (child) {\n // Set attributes\n child.setAttribute('data-pdf-annotate-id', annotation.uuid);\n child.setAttribute('data-pdf-annotate-type', annotation.type);\n child.setAttribute('data-pdf-annotate-userId', annotation.userId);\n child.setAttribute('aria-hidden', true);\n\n svg.appendChild(transform(child, viewport));\n }\n\n return child;\n}\n\n/**\n * Transform a child annotation of an SVG.\n *\n * @param {SVGElement} svg The SVG element with the child annotation\n * @param {Object} child The SVG child to transform\n * @param {Object} viewport The page's viewport data\n * @return {SVGElement} A node that was transformed by this function\n */\nexport function transformChild(svg, child, viewport) {\n if (!viewport) {\n viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport'));\n }\n\n // If no type was provided for an annotation it will result in node being null.\n // Skip transforming if node doesn't exist.\n if (child) {\n child = transform(child, viewport);\n }\n\n return child;\n}\n\nexport default {\n /**\n * Get the x/y translation to be used for transforming the annotations\n * based on the rotation of the viewport.\n */\n getTranslation,\n \n /**\n * Append an SVG child for an annotation\n */\n appendChild,\n\n /**\n * Transform an existing SVG child\n */ \n transformChild\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/appendChild.js","export default {\n annotationLayerName: 'annotationLayer',\n textLayerName: 'textLayer',\n annotationSvgQuery: function () {\n return 'svg.' + this.annotationLayerName;\n },\n annotationClassQuery: function () {\n return '.' + this.annotationLayerName;\n },\n textClassQuery: function () {\n return '.' + this.textLayerName;\n } \n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/config.js","const UPPER_REGEX = /[A-Z]/g;\n\n// Don't convert these attributes from camelCase to hyphenated-attributes\nconst BLACKLIST = [\n 'viewBox'\n];\n\nlet keyCase = (key) => {\n if (BLACKLIST.indexOf(key) === -1) {\n key = key.replace(UPPER_REGEX, match => '-' + match.toLowerCase());\n }\n return key;\n}\n\n/**\n * Set attributes for a node from a map\n *\n * @param {Node} node The node to set attributes on\n * @param {Object} attributes The map of key/value pairs to use for attributes\n */\nexport default function setAttributes(node, attributes) {\n Object.keys(attributes).forEach((key) => {\n node.setAttribute(keyCase(key), attributes[key]);\n });\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/setAttributes.js","const REGEX_HASHLESS_HEX = /^([a-f0-9]{6}|[a-f0-9]{3})$/i;\n\n/**\n * Normalize a color value\n *\n * @param {String} color The color to normalize\n * @return {String}\n */\nexport default function normalizeColor(color) {\n if (REGEX_HASHLESS_HEX.test(color)) {\n color = `#${color}`;\n }\n return color;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/normalizeColor.js","import EventEmitter from 'events';\nimport {\n findAnnotationAtPoint,\n findSVGAtPoint\n} from './utils';\n\nconst emitter = new EventEmitter;\n\nlet clickNode;\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event to be handled\n */\ndocument.addEventListener('click', function handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\n\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n\n // Emit annotation:blur if clickNode is no longer clicked\n if (clickNode && clickNode !== target) {\n emitter.emit('annotation:blur', clickNode);\n }\n\n // Emit annotation:click if target was clicked\n if (target) {\n emitter.emit('annotation:click', target);\n }\n\n clickNode = target;\n});\n\n// let mouseOverNode;\n// document.addEventListener('mousemove', function handleDocumentMousemove(e) {\n// let target = findAnnotationAtPoint(e.clientX, e.clientY);\n//\n// // Emit annotation:mouseout if target was mouseout'd\n// if (mouseOverNode && !target) {\n// emitter.emit('annotation:mouseout', mouseOverNode);\n// }\n//\n// // Emit annotation:mouseover if target was mouseover'd\n// if (target && mouseOverNode !== target) {\n// emitter.emit('annotation:mouseover', target);\n// }\n//\n// mouseOverNode = target;\n// });\n\nexport function fireEvent() { emitter.emit(...arguments); };\nexport function addEventListener() { emitter.on(...arguments); };\nexport function removeEventListener() { emitter.removeListener(...arguments); };\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/event.js","import insertScreenReaderHint from './insertScreenReaderHint';\nimport initEventHandlers from './initEventHandlers';\n\n// TODO This is not the right place for this to live\ninitEventHandlers();\n\n/**\n * Insert hints into the DOM for screen readers.\n *\n * @param {Array} annotations The annotations that hints are inserted for\n */\nexport default function renderScreenReaderHints(annotations) {\n annotations = Array.isArray(annotations) ? annotations : [];\n\n // Insert hints for each type\n Object.keys(SORT_TYPES).forEach((type) => {\n let sortBy = SORT_TYPES[type];\n annotations\n .filter((a) => a.type === type)\n .sort(sortBy)\n .forEach((a, i) => insertScreenReaderHint(a, i + 1));\n });\n}\n\n// Sort annotations first by y, then by x.\n// This allows hints to be injected in the order they appear,\n// which makes numbering them easier.\nfunction sortByPoint(a, b) {\n if (a.y < b.y) {\n return a.x - b.x;\n } else {\n return 1;\n }\n}\n\n// Sort annotation by it's first rectangle\nfunction sortByRectPoint(a, b) {\n return sortByPoint(a.rectangles[0], b.rectangles[0]);\n}\n\n// Sort annotation by it's first line\nfunction sortByLinePoint(a, b) {\n let lineA = a.lines[0];\n let lineB = b.lines[0];\n return sortByPoint(\n {x: lineA[0], y: lineA[1]},\n {x: lineB[0], y: lineB[1]}\n );\n}\n\n// Arrange supported types and associated sort methods\nconst SORT_TYPES = {\n 'highlight': sortByRectPoint,\n 'strikeout': sortByRectPoint,\n 'drawing': sortByLinePoint,\n 'textbox': sortByPoint,\n 'point': sortByPoint,\n 'area': sortByPoint\n};\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/renderScreenReaderHints.js","import abstractFunction from '../utils/abstractFunction';\nimport { fireEvent } from '../UI/event';\n\n// Adapter should never be invoked publicly\nexport default class StoreAdapter {\n /**\n * Create a new StoreAdapter instance\n *\n * @param {Object} [definition] The definition to use for overriding abstract methods\n */\n constructor(definition = {}) {\n // Copy each function from definition if it is a function we know about\n Object.keys(definition).forEach((key) => {\n if (typeof definition[key] === 'function' &&\n typeof this[key] === 'function') {\n this[key] = definition[key];\n }\n });\n }\n\n /**\n * Get all the annotations for a given document and page number.\n *\n * @param {String} documentId The ID for the document the annotations belong to\n * @param {String} userId The user makeing changes to this document\n * @param {Number} pageNumber The number of the page the annotations belong to\n * @return {Promise}\n */\n __getAnnotations(documentId, userId, pageNumber) { abstractFunction('getAnnotations'); }\n get getAnnotations() { return this.__getAnnotations; }\n set getAnnotations(fn) {\n this.__getAnnotations = function getAnnotations(documentId, userId, pageNumber) {\n return fn(...arguments).then((annotations) => {\n // TODO may be best to have this happen on the server\n if (annotations.annotations) {\n annotations.annotations.forEach((a) => {\n a.documentId = documentId;\n });\n }\n return annotations;\n });\n };\n }\n\n /**\n * Get the definition for a specific annotation.\n *\n * @param {String} documentId The ID for the document the annotation belongs to\n * @param {String} userId\n * @param {String} annotationId The ID for the annotation\n * @return {Promise}\n */\n getAnnotation(documentId, userId, annotationId) { abstractFunction('getAnnotation'); }\n\n /**\n * Add an annotation\n *\n * @param {String} documentId The ID for the document to add the annotation to\n * @param {String} userId The ID of the user\n * @param {String} pageNumber The page number to add the annotation to\n * @param {Object} annotation The definition for the new annotation\n * @return {Promise}\n */\n __addAnnotation(documentId, userId, pageNumber, annotation) { abstractFunction('addAnnotation'); }\n get addAnnotation() { return this.__addAnnotation; }\n set addAnnotation(fn) {\n this.__addAnnotation = function addAnnotation(documentId, userId, pageNumber, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:add', documentId, userId, pageNumber, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Edit an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} userId The Id of the user\n * @param {String} pageNumber the page number of the annotation\n * @param {Object} annotation The definition of the modified annotation\n * @return {Promise}\n */\n __editAnnotation(documentId, userId, pageNumber, annotation) { abstractFunction('editAnnotation'); }\n get editAnnotation() { return this.__editAnnotation; }\n set editAnnotation(fn) {\n this.__editAnnotation = function editAnnotation(documentId, userId, annotationId, annotation) {\n return fn(...arguments).then((annotation) => {\n fireEvent('annotation:edit', documentId, userId, annotationId, annotation);\n return annotation;\n });\n };\n }\n\n /**\n * Delete an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} userId\n * @param {String} annotationId The ID for the annotation\n * @return {Promise}\n */\n __deleteAnnotation(documentId, userId, annotationId) { abstractFunction('deleteAnnotation'); }\n get deleteAnnotation() { return this.__deleteAnnotation; }\n set deleteAnnotation(fn) {\n this.__deleteAnnotation = function deleteAnnotation(documentId, userId, annotationId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('annotation:delete', documentId, userId, annotationId);\n }\n return success;\n });\n };\n }\n\n /**\n * Get all the comments for an annotation\n *\n * @param {String} documentId The ID for the document\n * @param {String} userId\n * @param {String} annotationId The ID for the annotation\n * @return {Promise}\n */\n getComments(documentId, userId, annotationId) { abstractFunction('getComments'); }\n\n /**\n * Add a new comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} userId\n * @param {String} annotationId The ID for the annotation\n * @param {Object} content The definition of the comment\n * @return {Promise}\n */\n __addComment(documentId, userId, annotationId, content) { abstractFunction('addComment'); }\n get addComment() { return this.__addComment; }\n set addComment(fn) {\n this.__addComment = function addComment(documentId, userId, annotationId, content) {\n return fn(...arguments).then((comment) => {\n fireEvent('comment:add', documentId, userId, annotationId, comment);\n return comment;\n });\n };\n }\n\n /**\n * Delete a comment\n *\n * @param {String} documentId The ID for the document\n * @param {String} userId\n * @param {String} commentId The ID for the comment\n * @return {Promise}\n */\n __deleteComment(documentId, userId, commentId) { abstractFunction('deleteComment'); }\n get deleteComment() { return this.__deleteComment; }\n set deleteComment(fn) {\n this.__deleteComment = function deleteComment(documentId, userId, commentId) {\n return fn(...arguments).then((success) => {\n if (success) {\n fireEvent('comment:delete', documentId, commentId);\n }\n return success;\n });\n };\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/adapter/StoreAdapter.js","// Transform point by matrix\n//\nexport function applyTransform(p, m) {\n var xt = p[0] * m[0] + p[1] * m[2] + m[4];\n var yt = p[0] * m[1] + p[1] * m[3] + m[5];\n return [xt, yt];\n};\n\n// Transform point by matrix inverse\n//\nexport function applyInverseTransform(p, m) {\n var d = m[0] * m[3] - m[1] * m[2];\n var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;\n var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;\n return [xt, yt];\n};\n\n\n// Concatenates two transformation matrices together and returns the result.\nexport function transform(m1, m2) {\n return [\n m1[0] * m2[0] + m1[2] * m2[1],\n m1[1] * m2[0] + m1[3] * m2[1],\n m1[0] * m2[2] + m1[2] * m2[3],\n m1[1] * m2[2] + m1[3] * m2[3],\n m1[0] * m2[4] + m1[2] * m2[5] + m1[4],\n m1[1] * m2[4] + m1[3] * m2[5] + m1[5]\n ];\n};\n\nexport function translate(m, x, y) {\n return [\n m[0],\n m[1],\n m[2],\n m[3],\n m[0] * x + m[2] * y + m[4],\n m[1] * x + m[3] * y + m[5]\n ];\n};\n\n\nexport function rotate(m, angle) {\n angle = angle * Math.PI / 180;\n\n var cosValue = Math.cos(angle);\n var sinValue = Math.sin(angle);\n\n return [\n m[0] * cosValue + m[2] * sinValue,\n m[1] * cosValue + m[3] * sinValue,\n m[0] * (-sinValue) + m[2] * cosValue,\n m[1] * (-sinValue) + m[3] * cosValue,\n m[4],\n m[5]\n ];\n};\n\nexport function scale(m, x, y) {\n return [\n m[0] * x,\n m[1] * x,\n m[2] * y,\n m[3] * y,\n m[4],\n m[5]\n ];\n};\n \nfunction getInverseTransform(m) {\n var d = m[0] * m[3] - m[1] * m[2];\n return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d,\n (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];\n};\n\n\nexport function makePoint(x, y, z) {\n return { x: x, y: y, z: z }\n}\n\nexport function makeVector(xcoord, ycoord, zcoord) {\n return { xcoord: xcoord, ycoord: ycoord, zcoord: zcoord }\n}\n\nexport function makeVectorFromPoints(pt1, pt2)\n{\n let xcoord = pt2.x - pt1.x;\n let ycoord = pt2.y - pt1.y;\n let zcoord = pt2.z - pt1.z;\n return makeVector(xcoord, ycoord, zcoord);\n}\n\nexport function addVector(pt, v) {\n return makePoint(pt.x + v.xcoord, pt.y + v.ycoord, pt.z + v.zcoord);\n}\n\nexport function multiplyVector(v, scalar) {\n return makeVector(v.xcoord * scalar, v.ycoord * scalar, v.zcoord * scalar);\n}\n\nexport function magnitude(v)\n{\n return Math.sqrt(\n Math.pow(v.xcoord, 2) + Math.pow(v.ycoord, 2) + Math.pow(v.zcoord, 2)\n );\n}\n\nexport function negateVector(v) {\n return multiplyVector(v, -1);\n}\n\nexport function unitVector(v) {\n let mag = magnitude(v);\n let xcoord = v.xcoord / mag;\n let ycoord = v.ycoord / mag;\n let zcoord = v.zcoord / mag;\n return makeVector(xcoord, ycoord, zcoord);\n} \n\nexport function crossProduct(u, v) {\n //\n // u X v = < u2*v3 - u3*v2,\n // u3*v1 - u1*v3,\n // u1*v2 - u2*v1 >\n let xcoord = u.ycoord * v.zcoord - u.zcoord * v.ycoord;\n let ycoord = u.zcoord * v.xcoord - u.xcoord * v.zcoord;\n let zcoord = u.xcoord * v.ycoord - u.ycoord * v.xcoord;\n return makeVector(xcoord, ycoord, zcoord);\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/mathUtils.js","const REGEXP = /[xy]/g\nconst PATTERN = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';\n\nfunction replacement(c) {\n let r = Math.random()*16|0;\n let v = c == 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n}\n\n/**\n * Generate a univierally unique identifier\n *\n * @return {String}\n */\nexport default function uuid() {\n return PATTERN.replace(REGEXP, replacement);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/uuid.js","import createScreenReaderOnly from './createScreenReaderOnly';\nimport insertElementWithinChildren from './insertElementWithinChildren';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport renderScreenReaderComments from './renderScreenReaderComments';\n\n// Annotation types that support comments\nconst COMMENT_TYPES = ['highlight', 'point', 'area','circle','emptycircle','fillcircle'];\n\n/**\n * Insert a hint into the DOM for screen readers for a specific annotation.\n *\n * @param {Object} annotation The annotation to insert a hint for\n * @param {Number} num The number of the annotation out of all annotations of the same type\n */\nexport default function insertScreenReaderHint(annotation, num = 0) {\n switch (annotation.type) {\n case 'highlight':\n case 'strikeout':\n let rects = annotation.rectangles;\n let first = rects[0];\n let last = rects[rects.length - 1];\n\n insertElementWithinElement(\n createScreenReaderOnly(`Begin ${annotation.type} annotation ${num}`, annotation.uuid),\n first.x, first.y, annotation.page, true\n );\n\n insertElementWithinElement(\n createScreenReaderOnly(`End ${annotation.type} annotation ${num}`, `${annotation.uuid}-end`),\n last.x + last.width, last.y, annotation.page, false\n );\n break;\n\n case 'textbox':\n case 'point':\n let text = annotation.type === 'textbox' ? ` (content: ${annotation.content})` : '';\n\n insertElementWithinChildren(\n createScreenReaderOnly(`${annotation.type} annotation ${num}${text}`, annotation.uuid),\n annotation.x, annotation.y, annotation.page\n );\n break;\n\n case 'drawing':\n case 'area':\n let x = typeof annotation.x !== 'undefined' ? annotation.x : annotation.lines[0][0];\n let y = typeof annotation.y !== 'undefined' ? annotation.y : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x, y, annotation.page\n );\n break;\n\n case 'circle':\n case 'fillcircle':\n case 'emptycircle':\n let x2 = typeof annotation.cx !== 'undefined' ? annotation.cx : annotation.lines[0][0];\n let y2 = typeof annotation.cy !== 'undefined' ? annotation.cy : annotation.lines[0][1];\n\n insertElementWithinChildren(\n createScreenReaderOnly(`Unlabeled drawing`, annotation.uuid),\n x2, y2, annotation.page\n );\n break;\n }\n\n // Include comments in screen reader hint\n if (COMMENT_TYPES.includes(annotation.type)) {\n renderScreenReaderComments(annotation.documentId, annotation.uuid);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/insertScreenReaderHint.js","import config from '../config'\nimport {\n pointIntersectsRect,\n scaleUp,\n scaleDown\n} from '../UI/utils'; \n\n/**\n * Insert an element at a point within the document.\n * This algorithm will only insert within an element amidst it's text content.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @param {Boolean} insertBefore Whether the element is to be inserted before or after x\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinElement(el, x, y, pageNumber, insertBefore) {\n const OFFSET_ADJUST = 2;\n\n // If inserting before adjust `x` by looking for element a few px to the right\n // Otherwise adjust a few px to the left\n // This is to allow a little tolerance by searching within the box, instead\n // of getting a false negative by testing right on the border.\n x = Math.max(x + (OFFSET_ADJUST * (insertBefore ? 1 : -1)), 0);\n\n let node = textLayerElementFromPoint(x, y + OFFSET_ADJUST, pageNumber);\n if (!node) {\n return false;\n }\n \n // Now that node has been found inverse the adjustment for `x`.\n // This is done to accomodate tolerance by cutting off on the outside of the\n // text boundary, instead of missing a character by cutting off within.\n x = x + (OFFSET_ADJUST * (insertBefore ? -1 : 1));\n\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let left = scaleDown(svg, {left: node.getBoundingClientRect().left}).left - svg.getBoundingClientRect().left;\n let temp = node.cloneNode(true);\n let head = temp.innerHTML.split('');\n let tail = [];\n\n // Insert temp off screen\n temp.style.position = 'absolute';\n temp.style.top = '-10000px';\n temp.style.left = '-10000px';\n document.body.appendChild(temp);\n\n while (head.length) {\n // Don't insert within HTML tags\n if (head[head.length - 1] === '>') {\n while(head.length) {\n tail.unshift(head.pop());\n if (tail[0] === '<') {\n break;\n }\n }\n }\n \n // Check if width of temp based on current head value satisfies x\n temp.innerHTML = head.join('');\n let width = scaleDown(svg, {width: temp.getBoundingClientRect().width}).width;\n if (left + width <= x) {\n break;\n }\n tail.unshift(head.pop());\n }\n \n // Update original node with new markup, including element to be inserted\n node.innerHTML = head.join('') + el.outerHTML + tail.join('');\n temp.parentNode.removeChild(temp);\n\n return true;\n}\n\n/**\n * Get a text layer element at a given point on a page\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page to limit elements to\n * @return {Element} First text layer element found at the point\n */\nfunction textLayerElementFromPoint(x, y, pageNumber) {\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n return [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' [data-canvas-width]')].filter((el) => {\n return pointIntersectsRect(x, y, el.getBoundingClientRect());\n })[0];\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/insertElementWithinElement.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport insertScreenReaderComment from './insertScreenReaderComment';\n\n/**\n * Insert the comments into the DOM to be available by screen reader\n *\n * Example output:\n *
\n *
Begin highlight 1
\n *
    \n *
  1. Foo
  2. \n *
  3. Bar
  4. \n *
  5. Baz
  6. \n *
  7. Qux
  8. \n *
\n *
\n *
Some highlighted text goes here...
\n *
End highlight 1
\n *\n * NOTE: `screenReaderOnly` is not a real class, just used for brevity\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of the annotation\n * @param {Array} [comments] Optionally preloaded comments to be rendered\n * @return {Promise}\n */\nexport default function renderScreenReaderComments(documentId, annotationId, comments) {\n let promise;\n\n if (Array.isArray(comments)) {\n promise = Promise.resolve(comments);\n } else {\n promise = PDFJSAnnotate.getStoreAdapter().getComments(documentId, annotationId);\n }\n\n return promise.then((comments) => {\n // Node needs to be found by querying DOM as it may have been inserted as innerHTML\n // leaving `screenReaderNode` as an invalid reference (see `insertElementWithinElement`).\n let node = document.getElementById(`pdf-annotate-screenreader-${annotationId}`);\n if (node) { \n let list = document.createElement('ol');\n list.setAttribute('id', `pdf-annotate-screenreader-comment-list-${annotationId}`);\n list.setAttribute('aria-label', 'Comments');\n node.appendChild(list);\n comments.forEach(insertScreenReaderComment);\n }\n });\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/renderScreenReaderComments.js","/**\n * Insert a comment into the DOM to be available by screen reader\n *\n * @param {Object} comment The comment to be inserted\n */\nexport default function insertScreenReaderComment(comment) {\n if (!comment) {\n return;\n }\n\n let list = document.querySelector(`#pdf-annotate-screenreader-${comment.annotation} ol`);\n if (list) {\n let item = document.createElement('li');\n item.setAttribute('id', `pdf-annotate-screenreader-comment-${comment.uuid}`);\n item.appendChild(document.createTextNode(`${comment.content}`));\n list.appendChild(item);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/insertScreenReaderComment.js","import PDFJSAnnotate from './src/PDFJSAnnotate';\n\nexport default PDFJSAnnotate;\n\n\n\n// WEBPACK FOOTER //\n// ./index.js","/**\n * Throw an Error for an abstract function that hasn't been implemented.\n *\n * @param {String} name The name of the abstract function\n */\nexport default function abstractFunction(name) {\n throw new Error(name + ' is not implemented');\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils/abstractFunction.js","// 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;\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\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 if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\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 var args = [];\n for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);\n if (!this.fired) {\n this.target.removeListener(this.type, this.wrapFn);\n this.fired = true;\n ReflectApply(this.listener, this.target, args);\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 if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\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 if (typeof listener !== 'function') {\n throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n }\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\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/events/events.js\n// module id = 17\n// module chunks = 0","module.exports = function createStyleSheet(blocks) {\n var style = document.createElement('style');\n var text = Object.keys(blocks).map(function (selector) {\n return processRuleSet(selector, blocks[selector]);\n }).join('\\n');\n \n style.setAttribute('type', 'text/css');\n style.appendChild(document.createTextNode(text));\n\n return style;\n}\n\nfunction processRuleSet(selector, block) {\n return selector + ' {\\n' + processDeclarationBlock(block) + '\\n}';\n}\n\nfunction processDeclarationBlock(block) {\n return Object.keys(block).map(function (prop) {\n return processDeclaration(prop, block[prop]);\n }).join('\\n');\n}\n\nfunction processDeclaration(prop, value) {\n if (!isNaN(value) && value != 0) {\n value = value + 'px';\n }\n\n return hyphenate(prop) + ': ' + value + ';';\n}\n\nfunction hyphenate(prop) {\n return prop.replace(/[A-Z]/g, function (match) {\n return '-' + match.toLowerCase();\n });\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/create-stylesheet/index.js\n// module id = 18\n// module chunks = 0","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/object-assign/index.js\n// module id = 19\n// module chunks = 0","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGLineElements from an annotation definition.\n * This is used for anntations of type `strikeout`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement} A group of all lines to be rendered\n */\nexport default function renderLine(a) {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n stroke: normalizeColor(a.color || '#f00'),\n strokeWidth: 1\n });\n\n a.rectangles.forEach((r) => {\n let line = document.createElementNS('http://www.w3.org/2000/svg', 'line');\n\n setAttributes(line, {\n x1: r.x,\n y1: r.y,\n x2: r.x + r.width,\n y2: r.y,\n });\n\n group.appendChild(line);\n });\n\n return group;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderLine.js","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderPath(a) {\n let d = [];\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n if (a.lines.length > 0) {\n d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`);\n for (let i = 1, l = a.lines.length; i < l; i++) {\n var p1 = a.lines[i];\n var p2 = a.lines[i+1];\n if (p2) {\n d.push(`L${p1[0]} ${p1[1]}`);\n }\n }\n }\n\n/*\n\n if(a.lines.length>2) {\n var p1 = a.lines[0];\n var p2 = a.lines[a.lines.length-1];\n\n var p3 = []; //arrow\n var p4 = [];\n var p0 = []; //arrow intersection\n\n\n\n if (p2) {\n var k = -(p2[0]-p1[0])/(p2[1]-p1[1]);\n\n var deltaX = 3;\n p0[0] = p1[0]+0.8*(p2[0]-p1[0]);\n p0[1] = p1[1]+0.8*(p2[1]-p1[1]);\n\n p3[0] = p0[0] + deltaX;\n p3[1] = p0[1] + k*deltaX;\n\n p4[0] = p0[0] - deltaX;\n p4[1] = p0[1] - k*deltaX;\n\n if(Math.abs(p2[1]-p1[1]) < 20) {\n\n p3[0] = p0[0] ;\n p3[1] = p0[1] + deltaX*1;\n\n p4[0] = p0[0] ;\n p4[1] = p0[1] - deltaX*1;\n\n }\n\n d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n //d.push(`M${p1[0]} ${p1[1]} ${p2[0]} ${p2[1]}`);\n d.push(`M${p2[0]} ${p2[1]} ${p3[0]} ${p3[1]}`);\n d.push(`M${p3[0]} ${p3[1]} ${p4[0]} ${p4[1]}`);\n d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`);\n }\n }*/\n\n setAttributes(path, {\n d: `${d.join(' ')}`,//`${d.join(' ')}Z`,\n stroke: normalizeColor(a.color || '#000'),\n strokeWidth: a.width || 1,\n fill: 'none'\n });\n\n return path;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderPath.js","import setAttributes from '../utils/setAttributes';\n\nconst SIZE = 25;\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';\n\n/**\n * Create SVGElement from an annotation definition.\n * This is used for anntations of type `comment`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGElement} A svg to be rendered\n */\nexport default function renderPoint(a) {\n let outerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let innerSVG = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n let path = document.createElementNS('http://www.w3.org/2000/svg', 'path');\n\n setAttributes(outerSVG, {\n width: SIZE,\n height: SIZE,\n x: a.x,\n y: a.y\n });\n\n setAttributes(innerSVG, {\n width: SIZE,\n height: SIZE,\n x: 0,\n y: (SIZE * 0.05) * -1,\n viewBox: '0 0 1000 1000'\n });\n\n setAttributes(rect, {\n width: SIZE,\n height: SIZE,\n stroke: '#000',\n fill: '#ff0'\n });\n\n setAttributes(path, {\n d: D,\n strokeWidth: 50,\n stroke: '#000',\n fill: '#fff'\n });\n\n innerSVG.appendChild(path);\n outerSVG.appendChild(rect);\n outerSVG.appendChild(innerSVG);\n\n return outerSVG;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderPoint.js","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGRectElements from an annotation definition.\n * This is used for anntations of type `area` and `highlight`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGRectElement} A group of all rects to be rendered\n */\nexport default function renderRect(a) {\n if (a.type === 'highlight') {\n let group = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n setAttributes(group, {\n fill: normalizeColor(a.color || '#ff0'),\n fillOpacity: 0.2\n });\n \n a.rectangles.forEach((r) => {\n group.appendChild(createRect(r));\n });\n\n return group;\n } else {\n let rect = createRect(a);\n setAttributes(rect, {\n stroke: normalizeColor(a.color || '#f00'),\n fill: 'none'\n });\n\n return rect;\n }\n}\n\nfunction createRect(r) {\n let rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');\n\n setAttributes(rect, {\n x: r.x,\n y: r.y,\n width: r.width,\n height: r.height\n });\n\n return rect;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderRect.js","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create SVGTextElement from an annotation definition.\n * This is used for anntations of type `textbox`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGTextElement} A text to be rendered\n */\nexport default function renderText(a) {\n\n // Text should be rendered at 0 degrees relative to\n // document rotation\n let text = document.createElementNS('http://www.w3.org/2000/svg', 'text');\n setAttributes(text, {\n x: a.x,\n y: a.y,\n fill: normalizeColor(a.color || '#000'),\n fontSize: a.size,\n transform: `rotate(${a.rotation})`\n });\n text.innerHTML = a.content;\n\n var g = document.createElementNS('http://www.w3.org/2000/svg', 'g');\n g.appendChild(text);\n\n return g;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderText.js","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\n\n/**\n * Create an SVGCircleElement from an annotation definition.\n * This is used for annotations of type `circle`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGGElement|SVGCircleElement} A circle to be rendered\n */\nexport default function renderCircle(a) {\n let circle = createCircle(a);\n let color = normalizeColor(a.color || '#f00')\n\n if (a.type === 'circle')\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 5\n });\n if (a.type === 'emptycircle')\n setAttributes(circle, {\n stroke: color,\n fill: 'none',\n 'stroke-width': 2\n });\n\n if (a.type === 'fillcircle')\n setAttributes(circle, {\n stroke: color,\n fill: color,\n 'stroke-width': 5\n });\n\n return circle;\n}\n\nfunction createCircle(a) {\n let circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');\n setAttributes(circle, {\n cx: a.cx,\n cy: a.cy,\n r: a.r\n });\n\n return circle;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderCircle.js","import setAttributes from '../utils/setAttributes';\nimport normalizeColor from '../utils/normalizeColor';\nimport { \n makePoint, makeVector, makeVectorFromPoints,\n magnitude, unitVector, crossProduct,\n addVector, multiplyVector, negateVector\n} from '../utils/mathUtils';\n\n/**\n * Create SVGPathElement from an annotation definition.\n * This is used for anntations of type `drawing`.\n *\n * @param {Object} a The annotation definition\n * @return {SVGPathElement} The path to be rendered\n */\nexport default function renderArrow(a) {\n let d = [];\n let arrow = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');\n\n if (a.lines.length == 2) {\n let p1 = a.lines[0];\n let p2 = a.lines[a.lines.length - 1];\n\n let arrowLength = 40;\n let pt0 = makePoint(p1[0], p1[1], 0);\n let pt1 = makePoint(p2[0], p2[1], 0);\n let x = makeVectorFromPoints(pt0, pt1);\n let unitX = unitVector(x);\n pt1 = addVector(pt0, multiplyVector(unitX, arrowLength));\n x = makeVectorFromPoints(pt0, pt1);\n let unitZ = makeVector(0, 0, 1);\n let unitY = unitVector(crossProduct(unitX, unitZ));\n let thickness = a.width || 10;\n\n let A = addVector(pt0, multiplyVector(unitY, thickness * 0.5)); \n let B = addVector(A, multiplyVector(unitX, magnitude(x) - thickness * 2.0)); \n let C = addVector(B, multiplyVector(unitY, thickness)); \n let D = pt1;\n let G = addVector(pt0, multiplyVector(negateVector(unitY), thickness * 0.5)); \n let F = addVector(G, multiplyVector(unitX, magnitude(x) - thickness * 2.0)); \n let E = addVector(F, multiplyVector(negateVector(unitY), thickness)); \n\n let points = '' + \n A.x + ',' + A.y + ' ' +\n B.x + ',' + B.y + ' ' +\n C.x + ',' + C.y + ' ' +\n D.x + ',' + D.y + ' ' +\n E.x + ',' + E.y + ' ' +\n F.x + ',' + F.y + ' ' +\n G.x + ',' + G.y\n\n setAttributes(arrow, {\n points: points,\n stroke: normalizeColor(a.color || '#000'),\n fill: normalizeColor(a.color || '#000')\n });\n }\n\n return arrow;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/renderArrow.js","import uuid from '../utils/uuid';\nimport StoreAdapter from './StoreAdapter';\n\n// StoreAdapter for working with localStorage\n// This is ideal for testing, examples, and prototyping\nexport default class LocalStoreAdapter extends StoreAdapter {\n constructor(userId = \"user\") {\n super({\n getAnnotations(documentId, userId, pageNumber) {\n return new Promise((resolve, reject) => {\n let annotations = getAllAnnotations().filter((i) => {\n return i.page === pageNumber && i.class === 'Annotation';\n });\n\n resolve({\n documentId,\n userId,\n pageNumber,\n annotations\n });\n });\n },\n\n getAnnotation(documentId, userId, annotationId) {\n return Promise.resolve(getAnnotations(documentId, userId)[findAnnotation(documentId, userId, annotationId)]);\n },\n\n addAnnotation(documentId, userId, pageNumber, annotation) {\n return new Promise((resolve, reject) => {\n annotation.class = 'Annotation';\n annotation.uuid = uuid();\n annotation.page = pageNumber;\n annotation.userId = userId;\n\n let annotations = getAnnotations(documentId, userId);\n annotations.push(annotation);\n updateAnnotations(documentId, userId, annotations);\n\n resolve(annotation);\n });\n },\n\n editAnnotation(documentId, userId, annotationId, annotation) {\n return new Promise((resolve, reject) => {\n let annotations = getAnnotations(documentId, userId);\n annotations[findAnnotation(documentId, userId, annotationId)] = annotation;\n updateAnnotations(documentId, userId, annotations);\n resolve(annotation);\n });\n },\n\n deleteAnnotation(documentId, userId, annotationId) {\n return new Promise((resolve, reject) => {\n let index = findAnnotation(documentId, userId, annotationId);\n if (index > -1) {\n let annotations = getAnnotations(documentId, userId);\n annotations.splice(index, 1);\n updateAnnotations(documentId, userId, annotations);\n }\n\n resolve(true);\n });\n },\n\n getComments(documentId, userId, annotationId) {\n return new Promise((resolve, reject) => {\n resolve(getAnnotations(documentId, userId).filter((i) => {\n return i.class === 'Comment' && i.annotation === annotationId;\n }));\n });\n },\n\n addComment(documentId, userId, annotationId, content) {\n return new Promise((resolve, reject) => {\n let comment = {\n class: 'Comment',\n uuid: uuid(),\n annotation: annotationId,\n content: content,\n userId: userId\n };\n\n let annotations = getAnnotations(documentId, userId);\n annotations.push(comment);\n updateAnnotations(documentId, userId, annotations);\n\n resolve(comment);\n });\n },\n\n deleteComment(documentId, userId, commentId) {\n return new Promise((resolve, reject) => {\n getAnnotations(documentId, userId);\n let index = -1;\n let annotations = getAnnotations(documentId, userId);\n for (let i=0, l=annotations.length; i -1) {\n annotations.splice(index, 1);\n updateAnnotations(documentId, userId, annotations);\n }\n\n resolve(true);\n });\n }\n });\n this._userId = userId;\n }\n get userId(){\n return this._userId;\n }\n}\n\nfunction getAllAnnotations(){\n let all_annotations = [];\n for(let i = 0 ; i < localStorage.length; i++){\n if(localStorage.key(i).includes('annotations')){\n all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i))));\n }\n }\n return all_annotations;\n}\n\nfunction getAnnotations(documentId, userId) {\n return JSON.parse(localStorage.getItem(`${documentId}/${userId}/annotations`)) || [];\n}\n\nfunction updateAnnotations(documentId, userId, annotations) {\n localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations));\n}\n/**\n *\n * @param {String} documentId Document id of the annotation\n * @param {String} userId User id of the annotation\n * @param {String} annotationId The id of the annotation\n *\n * This function finds all the annotation made by one user.\n *\n * @return {int} The index of the annotation in localstorage\n */\nfunction findAnnotation(documentId, userId, annotationId) {\n let index = -1;\n let annotations = getAnnotations(documentId, userId);\n for (let i=0, l=annotations.length; i {\n // Reset the content of the SVG\n svg.setAttribute('data-pdf-annotate-container', true);\n svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(viewport));\n svg.removeAttribute('data-pdf-annotate-document');\n svg.removeAttribute('data-pdf-annotate-page');\n\n // If there's no data nothing can be done\n if (!data) {\n svg.innerHTML = ''; \n return resolve(svg);\n }\n\n svg.setAttribute('data-pdf-annotate-document', data.documentId);\n svg.setAttribute('data-pdf-annotate-user', data.userId);\n svg.setAttribute('data-pdf-annotate-page', data.pageNumber);\n \n // Make sure annotations is an array\n if (!Array.isArray(data.annotations) || data.annotations.length === 0) {\n return resolve(svg);\n }\n\n // Append or transform annotation to svg\n data.annotations.forEach((a) => {\n var node = svg.querySelector('[data-pdf-annotate-id=\"' + a.uuid + '\"]');\n if (node) {\n transformChild(svg, node, viewport);\n } else {\n appendChild(svg, a, viewport);\n }\n });\n\n resolve(svg);\n });\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/render/index.js","/**\n * Create a node that is only visible to screen readers\n *\n * @param {String} content The text content that should be read by screen reader\n * @param {String} [annotationId] The ID of the annotation assocaited\n * @return {Element} An Element that is only visible to screen readers\n */\nexport default function createScreenReaderOnly(content, annotationId) {\n let node = document.createElement('div');\n let text = document.createTextNode(content);\n node.appendChild(text);\n node.setAttribute('id', `pdf-annotate-screenreader-${annotationId}`);\n node.style.position = 'absolute';\n node.style.left = '-10000px';\n node.style.top = 'auto';\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.overflow = 'hidden';\n return node;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/createScreenReaderOnly.js","import config from '../config';\nimport insertElementWithinElement from './insertElementWithinElement';\nimport { pointIntersectsRect } from '../UI/utils';\nimport { scaleUp } from '../UI/utils'; \n\n/**\n * Insert an element at a point within the document.\n * This algorithm will try to insert between elements if possible.\n * It will however use `insertElementWithinElement` if it is more accurate.\n *\n * @param {Element} el The element to be inserted\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n * @param {Number} pageNumber The page number to limit elements to\n * @return {Boolean} True if element was able to be inserted, otherwise false\n */\nexport default function insertElementWithinChildren(el, x, y, pageNumber) {\n // Try and use most accurate method of inserting within an element\n if (insertElementWithinElement(el, x, y, pageNumber, true)) {\n return true;\n }\n\n // Fall back to inserting between elements\n let svg = document.querySelector(`svg[data-pdf-annotate-page=\"${pageNumber}\"]`);\n let rect = svg.getBoundingClientRect();\n let nodes = [...svg.parentNode.querySelectorAll(config.textClassQuery() + ' > div')];\n\n y = scaleUp(svg, {y}).y + rect.top;\n x = scaleUp(svg, {x}).x + rect.left;\n\n // Find the best node to insert before\n for (let i=0, l=nodes.length; i {\n reorderAnnotationsByType(documentId, userId, pageNumber, annotation.type);\n });\n addEventListener('annotation:edit', (documentId, userId, annotationId, annotation) => {\n reorderAnnotationsByType(documentId, userId, annotation.page, annotation.type);\n });\n addEventListener('annotation:delete', removeAnnotation);\n addEventListener('comment:add', insertComment);\n addEventListener('comment:delete', removeComment);\n}\n\n/**\n * Reorder the annotation numbers by annotation type\n *\n * @param {String} documentId The ID of the document\n * @param {String} userId The ID of the user\n * @param {Number} pageNumber The page number of the annotations\n * @param {Strig} type The annotation type\n */\nfunction reorderAnnotationsByType(documentId, userId, pageNumber, type) {\n PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, userId, pageNumber)\n .then((annotations) => {\n return annotations.annotations.filter((a) => {\n return a.type === type;\n });\n })\n .then((annotations) => {\n annotations.forEach((a) => {\n removeAnnotation(documentId, a.uuid);\n });\n\n return annotations;\n })\n .then(renderScreenReaderHints);\n}\n\n/**\n * Remove the screen reader hint for an annotation\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The Id of the annotation\n */\nfunction removeAnnotation(documentId, annotationId) {\n removeElementById(`pdf-annotate-screenreader-${annotationId}`);\n removeElementById(`pdf-annotate-screenreader-${annotationId}-end`);\n}\n\n/**\n * Insert a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} annotationId The ID of tha assocated annotation\n * @param {Object} comment The comment to insert a hint for\n */\nfunction insertComment(documentId, annotationId, comment) {\n let list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n let promise;\n\n if (!list) {\n promise = renderScreenReaderComments(documentId, annotationId, []).then(() => {\n list = document.querySelector(`pdf-annotate-screenreader-comment-list-${annotationId}`);\n return true;\n });\n } else {\n promise = Promise.resolve(true);\n }\n\n promise.then(() => {\n insertScreenReaderComment(comment);\n });\n}\n\n/**\n * Remove a screen reader hint for a comment\n *\n * @param {String} documentId The ID of the document\n * @param {String} commentId The ID of the comment\n */\nfunction removeComment(documentId, commentId) {\n removeElementById(`pdf-annotate-screenreader-comment-${commentId}`);\n}\n\n/**\n * Remove an element from the DOM by it's ID if it exists\n *\n * @param {String} elementID The ID of the element to be removed\n */\nfunction removeElementById(elementId) {\n let el = document.getElementById(elementId);\n if (el) {\n el.parentNode.removeChild(el);\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/a11y/initEventHandlers.js","import { addEventListener, removeEventListener, fireEvent } from './event';\nimport { disableEdit, enableEdit } from './edit';\nimport { disablePen, enablePen, setPen } from './pen';\nimport { disableArrow, enableArrow, setArrow } from './arrow';\nimport { disableEraser, enableEraser } from './eraser';\nimport { disablePoint, enablePoint } from './point';\nimport { disableRect, enableRect } from './rect';\nimport { disableCircle, enableCircle, setCircle, addCircle } from './circle';\nimport { disableText, enableText, setText } from './text';\nimport { createPage, renderPage } from './page';\n\nexport default {\n addEventListener,\n removeEventListener,\n fireEvent,\n\n disableEdit,\n enableEdit,\n\n disablePen,\n enablePen,\n setPen,\n\n disablePoint,\n enablePoint,\n\n disableRect,\n enableRect,\n\n disableCircle,\n enableCircle,\n setCircle,\n addCircle,\n\n disableArrow,\n enableArrow,\n setArrow,\n\n disableEraser,\n enableEraser,\n\n disableText,\n enableText,\n setText,\n\n createPage,\n renderPage\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/index.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport { appendChild } from '../render/appendChild';\nimport {\n addEventListener,\n removeEventListener\n} from './event';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGContainer,\n findSVGAtPoint,\n getOffsetAnnotationRect,\n getMetadata,\n scaleUp,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet isDragging = false;\nlet overlay;\nlet dragOffsetX, dragOffsetY, dragStartX, dragStartY;\nconst OVERLAY_BORDER_SIZE = 3;\n\n/**\n * Create an overlay for editing an annotation.\n *\n * @param {Element} target The annotation element to apply overlay for\n */\nfunction createEditOverlay(target) {\n destroyEditOverlay();\n\n overlay = document.createElement('div');\n let anchor = document.createElement('a');\n let parentNode = findSVGContainer(target).parentNode;\n let id = target.getAttribute('data-pdf-annotate-id');\n let rect = getOffsetAnnotationRect(target);\n let styleLeft = rect.left - OVERLAY_BORDER_SIZE;\n let styleTop = rect.top - OVERLAY_BORDER_SIZE;\n\n overlay.setAttribute('id', 'pdf-annotate-edit-overlay');\n overlay.setAttribute('data-target-id', id);\n overlay.style.boxSizing = 'content-box';\n overlay.style.position = 'absolute';\n overlay.style.top = `${styleTop}px`;\n overlay.style.left = `${styleLeft}px`;\n overlay.style.width = `${rect.width}px`;\n overlay.style.height = `${rect.height}px`;\n overlay.style.border = `${OVERLAY_BORDER_SIZE}px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = `${OVERLAY_BORDER_SIZE}px`;\n overlay.style.zIndex = 20100;\n\n anchor.innerHTML = '×';\n anchor.setAttribute('href', 'javascript://');\n anchor.style.background = '#fff';\n anchor.style.borderRadius = '20px';\n anchor.style.border = '1px solid #bbb';\n anchor.style.color = '#bbb';\n anchor.style.fontSize = '16px';\n anchor.style.padding = '2px';\n anchor.style.textAlign = 'center';\n anchor.style.textDecoration = 'none';\n anchor.style.position = 'absolute';\n anchor.style.top = '-13px';\n anchor.style.right = '-13px';\n anchor.style.width = '25px';\n anchor.style.height = '25px';\n\n overlay.appendChild(anchor);\n parentNode.appendChild(overlay);\n document.addEventListener('click', handleDocumentClick);\n document.addEventListener('keyup', handleDocumentKeyup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n anchor.addEventListener('click', deleteAnnotation);\n anchor.addEventListener('mouseover', () => {\n anchor.style.color = '#35A4DC';\n anchor.style.borderColor = '#999';\n anchor.style.boxShadow = '0 1px 1px #ccc';\n });\n anchor.addEventListener('mouseout', () => {\n anchor.style.color = '#bbb';\n anchor.style.borderColor = '#bbb';\n anchor.style.boxShadow = '';\n });\n overlay.addEventListener('mouseover', () => {\n if (!isDragging) { anchor.style.display = ''; }\n });\n overlay.addEventListener('mouseout', () => {\n anchor.style.display = 'none';\n });\n}\n\n/**\n * Destroy the edit overlay if it exists.\n */\nfunction destroyEditOverlay() {\n if (overlay) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n }\n\n document.removeEventListener('click', handleDocumentClick);\n document.removeEventListener('keyup', handleDocumentKeyup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Delete currently selected annotation\n */\nfunction deleteAnnotation() {\n if (!overlay) {\n return;\n }\n\n let annotationId = overlay.getAttribute('data-target-id');\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId, userId } = getMetadata(svg);\n\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId);\n\n destroyEditOverlay();\n}\n\n/**\n * Handle document.click event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentClick(e) {\n if (!findSVGAtPoint(e.clientX, e.clientY)) { return; }\n\n // Remove current overlay\n let overlay = document.getElementById('pdf-annotate-edit-overlay');\n if (overlay) {\n if (isDragging || e.target === overlay) {\n return;\n }\n\n destroyEditOverlay();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event that needs to be handled\n */\nfunction handleDocumentKeyup(e) {\n // keyCode is deprecated, so prefer the newer \"key\" method if possible\n let keyTest;\n if (e.key) {\n keyTest = e.key.toLowerCase() === \"delete\" || e.key.toLowerCase() === \"backspace\";\n }\n else {\n keyTest = e.keyCode === 8 || e.keyCode === 46;\n }\n if (overlay && keyTest &&\n e.target.nodeName.toLowerCase() !== 'textarea' &&\n e.target.nodeName.toLowerCase() !== 'input') {\n e.preventDefault();\n deleteAnnotation();\n }\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousedown(e) {\n if (e.target !== overlay) {\n return;\n }\n\n // Highlight and strikeout annotations are bound to text within the document.\n // It doesn't make sense to allow repositioning these types of annotations.\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelector(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target.getAttribute('data-pdf-annotate-type');\n\n if (type === 'highlight' || type === 'strikeout') { return; }\n\n isDragging = true;\n dragOffsetX = e.clientX;\n dragOffsetY = e.clientY;\n dragStartX = overlay.offsetLeft;\n dragStartY = overlay.offsetTop;\n\n overlay.style.background = 'rgba(255, 255, 255, 0.7)';\n overlay.style.cursor = 'move';\n overlay.querySelector('a').style.display = 'none';\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMousemove(e) {\n let annotationId = overlay.getAttribute('data-target-id');\n let parentNode = overlay.parentNode;\n let rect = parentNode.getBoundingClientRect();\n let y = (dragStartY + (e.clientY - dragOffsetY));\n let x = (dragStartX + (e.clientX - dragOffsetX));\n let minY = 0;\n let maxY = rect.height;\n let minX = 0;\n let maxX = rect.width;\n\n if (y > minY && y + overlay.offsetHeight < maxY) {\n overlay.style.top = `${y}px`;\n }\n\n if (x > minX && x + overlay.offsetWidth < maxX) {\n overlay.style.left = `${x}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event that needs to be handled\n */\nfunction handleDocumentMouseup(e) {\n let annotationId = overlay.getAttribute('data-target-id');\n let target = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n let type = target[0].getAttribute('data-pdf-annotate-type');\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let { documentId, userId } = getMetadata(svg);\n\n overlay.querySelector('a').style.display = '';\n\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => {\n let attribX = 'x';\n let attribY = 'y';\n if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n attribX = 'cx';\n attribY = 'cy';\n }\n\n if (type === 'point') {\n // Broken\n /*\n [...target].forEach((t, i) => {\n let moveTo = {\n x: overlay.offsetLeft + 3,\n y: overlay.offsetTop + 3\n };\n t.setAttribute(attribX, moveTo.x);\n t.setAttribute(attribY, moveTo.y);\n annotation[attribX] = moveTo.x;\n annotation[attribY] = moveTo.y;\n });\n */\n return;\n }\n else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) {\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n if (type === 'textbox') {\n target = [target[0].firstChild];\n }\n\n [...target].forEach((t, i) => {\n let modelX = parseInt(t.getAttribute(attribX), 10);\n let modelY = parseInt(t.getAttribute(attribY), 10);\n if (modelDelta.y !== 0) {\n modelY = modelY + modelDelta.y;\n\n t.setAttribute(attribY, modelY);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].y = modelY;\n }\n else if (annotation[attribY]) {\n annotation[attribY] = modelY;\n }\n }\n if (modelDelta.x !== 0) {\n modelX = modelX + modelDelta.x;\n\n t.setAttribute(attribX, modelX);\n if (annotation.rectangles && i < annotation.rectangles.length) {\n annotation.rectangles[i].x = modelX;\n }\n else if (annotation[attribX]) {\n annotation[attribX] = modelX;\n }\n }\n });\n } else if (type === 'strikeout') {\n return;\n // let { deltaX, deltaY } = getDelta('x1', 'y1');\n // [...target].forEach(target, (t, i) => {\n // if (deltaY !== 0) {\n // t.setAttribute('y1', parseInt(t.getAttribute('y1'), 10) + deltaY);\n // t.setAttribute('y2', parseInt(t.getAttribute('y2'), 10) + deltaY);\n // annotation.rectangles[i].y = parseInt(t.getAttribute('y1'), 10);\n // }\n // if (deltaX !== 0) {\n // t.setAttribute('x1', parseInt(t.getAttribute('x1'), 10) + deltaX);\n // t.setAttribute('x2', parseInt(t.getAttribute('x2'), 10) + deltaX);\n // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10);\n // }\n // });\n }\n else if (type === 'drawing' || type === 'arrow') {\n // Do nothing as currently broken\n /*\n let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg);\n let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg);\n let modelDelta = {\n x: modelEnd[0] - modelStart[0],\n y: modelEnd[1] - modelStart[1]\n };\n\n annotation.lines.forEach((line, i) => {\n let [x, y] = annotation.lines[i];\n annotation.lines[i][0] = x + modelDelta.x;\n annotation.lines[i][1] = y + modelDelta.y;\n });\n\n target[0].parentNode.removeChild(target[0]);\n appendChild(svg, annotation);\n */\n return;\n }\n\n PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, userId, annotationId, annotation);\n });\n\n setTimeout(() => {\n isDragging = false;\n }, 0);\n\n overlay.style.background = '';\n overlay.style.cursor = '';\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n enableUserSelect();\n}\n\n/**\n * Handle annotation.click event\n *\n * @param {Element} e The annotation element that was clicked\n */\nfunction handleAnnotationClick(target) {\n createEditOverlay(target);\n}\n\n/**\n * Enable edit mode behavior.\n */\nexport function enableEdit() {\n if (_enabled) {\n return;\n }\n\n _enabled = true;\n addEventListener('annotation:click', handleAnnotationClick);\n};\n\n/**\n * Disable edit mode behavior.\n */\nexport function disableEdit() {\n destroyEditOverlay();\n\n if (!_enabled) {\n return;\n }\n\n _enabled = false;\n removeEventListener('annotation:click', handleAnnotationClick);\n};\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/edit.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _candraw = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines = [];\n\nconst isFirefox = /firefox/i.test(navigator.userAgent);\n\n/**\n * Handle document.touchdown or document.pointerdown event\n */\nfunction handleDocumentPointerdown(e) {\n e.preventDefault();\n path = null;\n lines = [];\n _candraw = true;\n}\n\n/**\n * Handle document.touchup or document.pointerup event\n *\n * @param {TouchEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointerupChrome(e){\n saveToStorage(e.changedTouches[0].clientX, e.changedTouches[0].clientY);\n}\n\nfunction handleDocumentPointerup(e) {\n saveToStorage(e.clientX, e.clientY);\n}\n\nfunction saveToStorage(x, y) {\n _candraw = false;\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) {\n let { documentId, userId, pageNumber } = getMetadata(svg);\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, {\n type: 'drawing',\n width: _penSize,\n color: _penColor,\n lines\n }\n ).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {PointerEvent} e The DOM event to be handled\n */\nfunction handleDocumentPointermove(e) {\n if (!e.srcElement.classList.contains('annotationLayer')) {\n return;\n }\n if (_candraw) {\n savePoint(e.clientX, e.clientY);\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {KeyboardEvent} e The DOM event to be handled\n * } e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n point[0] = point[0].toFixed(2);\n point[1] = point[1].toFixed(2);\n lines.push(point);\n\n if (lines.length <= 1) {\n return;\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'drawing',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setPen(penSize = 1, penColor = '000000') {\n _penSize = parseInt(penSize, 10);\n _penColor = penColor;\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enablePen() {\n if (_enabled) { return; }\n\n _enabled = true;\n // Chrome and Firefox has different behaviors with how pen works, so we need different events.\n document.addEventListener('pointerdown', handleDocumentPointerdown);\n document.addEventListener('pointermove', handleDocumentPointermove);\n document.addEventListener('pointerup', handleDocumentPointerup);\n\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disablePen() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('pointerdown', handleDocumentPointerdown);\n document.removeEventListener('pointermove', handleDocumentPointermove);\n document.removeEventListener('pointerup', handleDocumentPointerup);\n\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/pen.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n findSVGContainer,\n getMetadata,\n convertToSvgPoint,\n convertToScreenPoint,\n findAnnotationAtPoint\n} from './utils';\n\nlet _enabled = false;\nlet _penSize;\nlet _penColor;\nlet path;\nlet lines;\nlet originY;\nlet originX;\n\n/**\n * Handle document.mousedown event\n */\nfunction handleDocumentMousedown(e) {\n let target = findAnnotationAtPoint(e.clientX, e.clientY);\n if (target === null)\n return;\n\n let type = target.getAttribute('data-pdf-annotate-type');\n if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') {\n return;\n }\n\n let svg = findSVGContainer(target);\n let { documentId, userId } = getMetadata(svg);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n\n let event = e;\n PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => {\n if (annotation) {\n path = null;\n lines = [];\n\n let point = convertToScreenPoint([\n annotation.cx,\n annotation.cy\n ], svg);\n\n let rect = svg.getBoundingClientRect();\n\n originX = point[0] + rect.left;\n originY = point[1] + rect.top;\n\n document.addEventListener('mousemove', handleDocumentMousemove);\n document.addEventListener('mouseup', handleDocumentMouseup);\n }\n });\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n let svg;\n if (lines.length > 1 && (svg = findSVGAtPoint(e.clientX, e.clientY))) {\n let { documentId, userId, pageNumber } = getMetadata(svg);\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, {\n type: 'arrow',\n width: _penSize,\n color: _penColor,\n lines\n }\n ).then((annotation) => {\n if (path) {\n svg.removeChild(path);\n }\n\n appendChild(svg, annotation);\n });\n }\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentMousemove(e) {\n let x = lines.length === 0 ? originX : e.clientX;\n let y = lines.length === 0 ? originY : e.clientY;\n\n savePoint(x, y);\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to be handled\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n lines = null;\n path.parentNode.removeChild(path);\n document.removeEventListener('mousemove', handleDocumentMousemove);\n document.removeEventListener('mouseup', handleDocumentMouseup);\n }\n}\n\n/**\n * Save a point to the line being drawn.\n *\n * @param {Number} x The x coordinate of the point\n * @param {Number} y The y coordinate of the point\n */\nfunction savePoint(x, y) {\n let svg = findSVGAtPoint(x, y);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let point = convertToSvgPoint([\n x - rect.left,\n y - rect.top\n ], svg);\n\n if (lines.length < 2) {\n lines.push(point);\n return;\n } else {\n lines[1] = point; // update end point\n }\n\n if (path) {\n svg.removeChild(path);\n }\n\n path = appendChild(svg, {\n type: 'arrow',\n color: _penColor,\n width: _penSize,\n lines\n });\n}\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} penSize The size of the lines drawn by the pen\n * @param {String} penColor The color of the lines drawn by the pen\n */\nexport function setArrow(penSize = 10, penColor = '0000FF') {\n _penSize = parseInt(penSize, 10);\n _penColor = penColor;\n}\n\n/**\n * Enable the pen behavior\n */\nexport function enableArrow() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n disableUserSelect();\n}\n\n/**\n * Disable the pen behavior\n */\nexport function disableArrow() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n enableUserSelect();\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/arrow.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport {\n findAnnotationAtPoint,\n findSVGAtPoint,\n getMetadata\n} from './utils';\n\nlet _canerase = false;\nlet userId = \"user\";\n\n/**\n *\n * @param {PointerEvent} e\n */\nfunction handleDocumentDown(e) {\n _canerase = true;\n}\n\n/**\n *\n * @param {PointerEvent} e\n */\nfunction handleDocumentUp(e) {\n _canerase = false;\n}\n\n/**\n *\n * @param {PointerEvent} e\n */\nfunction handleDocumentMouseMove(e) {\n erase(findAnnotationAtPoint(e.clientX, e.clientY));\n}\n\nfunction erase(target) {\n if(_canerase){\n if(target && target.getAttribute('data-pdf-annotate-userId') === userId){\n let { documentId } = getMetadata(target.parentElement);\n let annotationId = target.getAttribute('data-pdf-annotate-id');\n let nodes = document.querySelectorAll(`[data-pdf-annotate-id=\"${annotationId}\"]`);\n [...nodes].forEach((n) => {\n n.parentNode.removeChild(n);\n });\n\n PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId);\n }\n }\n}\n\nexport function enableEraser() {\n userId = PDFJSAnnotate.getStoreAdapter().userId;\n document.addEventListener('pointermove', handleDocumentMouseMove);\n document.addEventListener('pointerdown', handleDocumentDown);\n document.addEventListener('pointerup', handleDocumentUp);\n}\n\nexport function disableEraser() {\n document.removeEventListener('pointermove', handleDocumentMouseMove);\n document.removeEventListener('pointerdown', handleDocumentDown);\n document.removeEventListener('pointerup', handleDocumentUp);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/eraser.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n scaleDown\n} from './utils';\n\nlet _enabled = false;\nlet input;\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} The DOM event to be handled\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return\n }\n\n input = document.createElement('input');\n input.setAttribute('id', 'pdf-annotate-point-input');\n input.setAttribute('placeholder', 'Enter comment');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'absolute';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n savePoint();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n } else if (e.keyCode === 13) {\n savePoint();\n }\n}\n\n/**\n * Save a new point annotation from input\n */\nfunction savePoint() {\n if (input.value.trim().length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let content = input.value.trim();\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n let { documentId, userId, pageNumber } = getMetadata(svg);\n let annotation = Object.assign({\n type: 'point'\n }, scaleDown(svg, {\n x: clientX - rect.left,\n y: clientY - rect.top\n })\n );\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)\n .then((annotation) => {\n PDFJSAnnotate.getStoreAdapter().addComment(\n documentId,\n userId,\n annotation.uuid,\n content\n );\n\n appendChild(svg, annotation);\n });\n }\n\n closeInput();\n}\n\n/**\n * Close the input element\n */\nfunction closeInput() {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n}\n\n/**\n * Enable point annotation behavior\n */\nexport function enablePoint() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable point annotation behavior\n */\nexport function disablePoint() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/point.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n disableUserSelect,\n enableUserSelect,\n findSVGAtPoint,\n getMetadata,\n convertToSvgRect\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet overlay;\nlet originY;\nlet originX;\n\n/**\n * Get the current window selection as rects\n *\n * @return {Array} An Array of rects\n */\nfunction getSelectionRects() {\n try {\n let selection = window.getSelection();\n let range = selection.getRangeAt(0);\n let rects = range.getClientRects();\n\n if (rects.length > 0 &&\n rects[0].width > 0 &&\n rects[0].height > 0) {\n return rects;\n }\n } catch (e) {}\n \n return null;\n}\n\n/**\n * Handle document.mousedown event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousedown(e) {\n let svg;\n if (_type !== 'area' || !(svg = findSVGAtPoint(e.clientX, e.clientY))) {\n return;\n }\n\n let rect = svg.getBoundingClientRect();\n originY = e.clientY;\n originX = e.clientX;\n\n overlay = document.createElement('div');\n overlay.style.position = 'absolute';\n overlay.style.top = `${originY - rect.top}px`;\n overlay.style.left = `${originX - rect.left}px`;\n overlay.style.border = `3px solid ${BORDER_COLOR}`;\n overlay.style.borderRadius = '3px';\n svg.parentNode.appendChild(overlay);\n \n document.addEventListener('mousemove', handleDocumentMousemove);\n disableUserSelect();\n}\n\n/**\n * Handle document.mousemove event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMousemove(e) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n\n if (originX + (e.clientX - originX) < rect.right) {\n overlay.style.width = `${e.clientX - originX}px`;\n }\n\n if (originY + (e.clientY - originY) < rect.bottom) {\n overlay.style.height = `${e.clientY - originY}px`;\n }\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let rects;\n if (_type !== 'area' && (rects = getSelectionRects())) {\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\n saveRect(_type, [...rects].map((r) => {\n return {\n top: r.top,\n left: r.left,\n width: r.width,\n height: r.height\n };\n }));\n } else if (_type === 'area' && overlay) {\n let svg = overlay.parentNode.querySelector(config.annotationSvgQuery());\n let rect = svg.getBoundingClientRect();\n saveRect(_type, [{\n top: parseInt(overlay.style.top, 10) + rect.top,\n left: parseInt(overlay.style.left, 10) + rect.left,\n width: parseInt(overlay.style.width, 10),\n height: parseInt(overlay.style.height, 10)\n }]);\n\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n\n document.removeEventListener('mousemove', handleDocumentMousemove);\n enableUserSelect();\n }\n}\n\n/**\n * Handle document.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentKeyup(e) {\n // Cancel rect if Esc is pressed\n if (e.keyCode === 27) {\n let selection = window.getSelection();\n selection.removeAllRanges();\n if (overlay && overlay.parentNode) {\n overlay.parentNode.removeChild(overlay);\n overlay = null;\n document.removeEventListener('mousemove', handleDocumentMousemove);\n }\n }\n}\n\n/**\n * Save a rect annotation\n *\n * @param {String} type The type of rect (area, highlight, strikeout)\n * @param {Array} rects The rects to use for annotation\n * @param {String} color The color of the rects\n */\nfunction saveRect(type, rects, color) {\n let svg = findSVGAtPoint(rects[0].left, rects[0].top);\n let annotation;\n\n if (!svg) {\n return;\n }\n\n let boundingRect = svg.getBoundingClientRect();\n\n if (!color) {\n if (type === 'highlight') {\n color = 'FFFF00';\n } else if (type === 'strikeout') {\n color = 'FF0000';\n }\n }\n\n // Initialize the annotation\n annotation = {\n type,\n color,\n rectangles: [...rects].map((r) => {\n let offset = 0;\n\n if (type === 'strikeout') {\n offset = r.height / 2;\n }\n\n return convertToSvgRect({\n y: (r.top + offset) - boundingRect.top,\n x: r.left - boundingRect.left,\n width: r.width,\n height: r.height\n }, svg);\n }).filter((r) => r.width > 0 && r.height > 0 && r.x > -1 && r.y > -1)\n };\n \n // Short circuit if no rectangles exist\n if (annotation.rectangles.length === 0) {\n return;\n }\n\n // Special treatment for area as it only supports a single rect\n if (type === 'area') {\n let rect = annotation.rectangles[0];\n delete annotation.rectangles;\n annotation.x = rect.x;\n annotation.y = rect.y;\n annotation.width = rect.width;\n annotation.height = rect.height;\n }\n\n let { documentId, userId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable rect behavior\n */\nexport function enableRect(type) {\n _type = type;\n \n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n document.addEventListener('mousedown', handleDocumentMousedown);\n document.addEventListener('keyup', handleDocumentKeyup);\n}\n\n/**\n * Disable rect behavior\n */\nexport function disableRect() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n document.removeEventListener('mousedown', handleDocumentMousedown);\n document.removeEventListener('keyup', handleDocumentKeyup);\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/rect.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport { appendChild } from '../render/appendChild';\nimport {\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet _type;\nlet _circleRadius = 10;\nlet _circleColor = '0000FF';\n\n/**\n * Set the attributes of the pen.\n *\n * @param {Number} circleRadius The radius of the circle\n * @param {String} circleColor The color of the circle\n */\nexport function setCircle(circleRadius = 10, circleColor = '0000FF') {\n _circleRadius = parseInt(circleRadius, 10);\n _circleColor = circleColor;\n}\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n let svg = findSVGAtPoint(e.clientX, e.clientY);\n if (!svg) {\n return;\n }\n let rect = svg.getBoundingClientRect();\n saveCircle(svg, _type, {\n x: e.clientX - rect.left,\n y: e.clientY - rect.top\n }, _circleRadius, _circleColor\n );\n}\n\n/**\n * Save a circle annotation\n *\n * @param {SVGElement} svg\n * @param {String} type The type of circle (circle, emptycircle, fillcircle)\n * @param {Object} pt The point to use for annotation\n * @param {float} radius\n * @param {String} color The color of the rects\n */\nfunction saveCircle(svg, type, pt, radius, color) {\n // Initialize the annotation\n let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg)\n let annotation = {\n type,\n color,\n cx: svg_pt[0],\n cy: svg_pt[1],\n r: radius\n };\n\n let { documentId, userId, pageNumber } = getMetadata(svg);\n\n // Add the annotation\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n}\n\n/**\n * Enable circle behavior\n */\nexport function enableCircle(type) {\n _type = type;\n\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n/**\n * Disable circle behavior\n */\nexport function disableCircle() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\nexport function addCircle(type, e) {\n let oldType = _type;\n _type = type;\n handleDocumentMouseup(e);\n _type = oldType;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/circle.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport { appendChild } from '../render/appendChild';\nimport {\n BORDER_COLOR,\n findSVGAtPoint,\n getMetadata,\n convertToSvgPoint\n} from './utils';\n\nlet _enabled = false;\nlet input;\nlet _textSize;\nlet _textColor;\n\n/**\n * Handle document.mouseup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleDocumentMouseup(e) {\n if (input || !findSVGAtPoint(e.clientX, e.clientY)) {\n return;\n }\n if(!e.srcElement.classList.contains('annotationLayer')){\n return;\n }\n input = document.createElement('input');\n input.setAttribute('id', 'pdf-annotate-text-input');\n input.setAttribute('placeholder', 'Enter text');\n input.style.border = `3px solid ${BORDER_COLOR}`;\n input.style.borderRadius = '3px';\n input.style.position = 'absolute';\n input.style.top = `${e.clientY}px`;\n input.style.left = `${e.clientX}px`;\n input.style.fontSize = `${_textSize}px`;\n input.style.zIndex = \"41\";\n input.addEventListener('blur', handleInputBlur);\n input.addEventListener('keyup', handleInputKeyup);\n\n document.body.appendChild(input);\n input.focus();\n}\n\n/**\n * Handle input.blur event\n */\nfunction handleInputBlur() {\n saveText();\n}\n\n/**\n * Handle input.keyup event\n *\n * @param {Event} e The DOM event to handle\n */\nfunction handleInputKeyup(e) {\n if (e.keyCode === 27) {\n closeInput();\n } else if (e.keyCode === 13) {\n saveText();\n }\n}\n\n/**\n * Save a text annotation from input\n */\nfunction saveText() {\n if (input.value.trim().length > 0) {\n let clientX = parseInt(input.style.left, 10);\n let clientY = parseInt(input.style.top, 10);\n let svg = findSVGAtPoint(clientX, clientY);\n if (!svg) {\n return;\n }\n let height = _textSize;\n let { documentId, userId, pageNumber, viewport } = getMetadata(svg);\n let scale = 1 / viewport.scale;\n let rect = svg.getBoundingClientRect();\n let pt = convertToSvgPoint([\n clientX - rect.left, \n clientY - rect.top + height], svg, viewport);\n let annotation = {\n type: 'textbox',\n size: _textSize * scale,\n color: _textColor,\n content: input.value.trim(),\n x: pt[0],\n y: pt[1],\n rotation: -viewport.rotation\n }\n\n PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation)\n .then((annotation) => {\n appendChild(svg, annotation);\n });\n }\n \n closeInput();\n}\n\n/**\n * Close the input\n */\nfunction closeInput() {\n if (input) {\n input.removeEventListener('blur', handleInputBlur);\n input.removeEventListener('keyup', handleInputKeyup);\n document.body.removeChild(input);\n input = null;\n }\n}\n\n/**\n * Set the text attributes\n *\n * @param {Number} textSize The size of the text\n * @param {String} textColor The color of the text\n */\nexport function setText(textSize = 12, textColor = '000000') {\n _textSize = parseInt(textSize, 10);\n _textColor = textColor;\n}\n\n\n/**\n * Enable text behavior\n */\nexport function enableText() {\n if (_enabled) { return; }\n\n _enabled = true;\n document.addEventListener('mouseup', handleDocumentMouseup);\n}\n\n\n/**\n * Disable text behavior\n */\nexport function disableText() {\n if (!_enabled) { return; }\n\n _enabled = false;\n document.removeEventListener('mouseup', handleDocumentMouseup);\n}\n\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/text.js","import PDFJSAnnotate from '../PDFJSAnnotate';\nimport config from '../config';\nimport renderScreenReaderHints from '../a11y/renderScreenReaderHints';\n\n// Template for creating a new page\nconst PAGE_TEMPLATE = `\n
\n
\n \n
\n
\n \n
\n`;\n\n/**\n * Create a new page to be appended to the DOM.\n *\n * @param {Number} pageNumber The page number that is being created\n * @return {HTMLElement}\n */\nexport function createPage(pageNumber) {\n let temp = document.createElement('div');\n temp.innerHTML = PAGE_TEMPLATE;\n\n let page = temp.children[0];\n let canvas = page.querySelector('canvas');\n\n page.setAttribute('id', `pageContainer${pageNumber}`);\n page.setAttribute('data-page-number', pageNumber);\n\n canvas.mozOpaque = true;\n canvas.setAttribute('id', `page${pageNumber}`);\n\n return page;\n}\n\n/**\n * Render a page that has already been created.\n *\n * @param {Number} pageNumber The page number to be rendered\n * @param {Object} renderOptions The options for rendering\n * @return {Promise} Settled once rendering has completed\n * A settled Promise will be either:\n * - fulfilled: [pdfPage, annotations]\n * - rejected: Error\n */\nexport function renderPage(pageNumber, renderOptions) {\n let {\n documentId,\n userId,\n pdfDocument,\n scale,\n rotate\n } = renderOptions;\n\n // Load the page and annotations\n return Promise.all([\n pdfDocument.getPage(pageNumber),\n PDFJSAnnotate.getAnnotations(documentId, userId, pageNumber)\n ]).then(([pdfPage, annotations]) => {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let svg = page.querySelector(config.annotationClassQuery());\n let canvas = page.querySelector('.canvasWrapper canvas');\n let canvasContext = canvas.getContext('2d', {alpha: false});\n let totalRotation = (rotate + pdfPage.rotate) % 360;\n let viewport = pdfPage.getViewport(scale, totalRotation);\n let transform = scalePage(pageNumber, viewport, canvasContext);\n\n // Render the page\n return Promise.all([\n pdfPage.render({ canvasContext, viewport, transform }),\n PDFJSAnnotate.render(svg, viewport, annotations)\n ]).then(() => {\n // Text content is needed for a11y, but is also necessary for creating\n // highlight and strikeout annotations which require selecting text.\n return pdfPage.getTextContent({normalizeWhitespace: true}).then((textContent) => {\n return new Promise((resolve, reject) => {\n // Render text layer for a11y of text content\n let textLayer = page.querySelector(config.textClassQuery());\n let textLayerFactory = new PDFJS.DefaultTextLayerFactory();\n let textLayerBuilder = textLayerFactory.createTextLayerBuilder(textLayer, pageNumber -1, viewport);\n textLayerBuilder.setTextContent(textContent);\n textLayerBuilder.render();\n\n // Enable a11y for annotations\n // Timeout is needed to wait for `textLayerBuilder.render`\n setTimeout(() => {\n try {\n renderScreenReaderHints(annotations.annotations);\n resolve();\n } catch (e) {\n reject(e);\n }\n });\n });\n });\n }).then(() => {\n // Indicate that the page was loaded\n page.setAttribute('data-loaded', 'true');\n\n return [pdfPage, annotations];\n });\n });\n}\n\n/**\n * Scale the elements of a page.\n *\n * @param {Number} pageNumber The page number to be scaled\n * @param {Object} viewport The viewport of the PDF page (see pdfPage.getViewport(scale, rotate))\n * @param {Object} context The canvas context that the PDF page is rendered to\n * @return {Array} The transform data for rendering the PDF page\n */\nfunction scalePage(pageNumber, viewport, context) {\n let page = document.getElementById(`pageContainer${pageNumber}`);\n let canvas = page.querySelector('.canvasWrapper canvas');\n let svg = page.querySelector(config.annotationClassQuery());\n let wrapper = page.querySelector('.canvasWrapper');\n let textLayer = page.querySelector(config.textClassQuery());\n let outputScale = getOutputScale(context);\n let transform = !outputScale.scaled ? null : [outputScale.sx, 0, 0, outputScale.sy, 0, 0];\n let sfx = approximateFraction(outputScale.sx);\n let sfy = approximateFraction(outputScale.sy);\n\n // Adjust width/height for scale\n page.style.visibility = '';\n canvas.width = roundToDivide(viewport.width * outputScale.sx, sfx[0]);\n canvas.height = roundToDivide(viewport.height * outputScale.sy, sfy[0]);\n canvas.style.width = roundToDivide(viewport.width, sfx[1]) + 'px';\n canvas.style.height = roundToDivide(viewport.height, sfx[1]) + 'px';\n svg.setAttribute('width', viewport.width);\n svg.setAttribute('height', viewport.height);\n svg.style.width = `${viewport.width}px`;\n svg.style.height = `${viewport.height}px`;\n page.style.width = `${viewport.width}px`;\n page.style.height = `${viewport.height}px`;\n wrapper.style.width = `${viewport.width}px`;\n wrapper.style.height = `${viewport.height}px`;\n textLayer.style.width = `${viewport.width}px`;\n textLayer.style.height = `${viewport.height}px`;\n\n return transform;\n}\n\n\n/**\n * Approximates a float number as a fraction using Farey sequence (max order of 8).\n *\n * @param {Number} x Positive float number\n * @return {Array} Estimated fraction: the first array item is a numerator,\n * the second one is a denominator.\n */\nfunction approximateFraction(x) {\n // Fast path for int numbers or their inversions.\n if (Math.floor(x) === x) {\n return [x, 1];\n }\n\n const xinv = 1 / x;\n const limit = 8;\n if (xinv > limit) {\n return [1, limit];\n } else if (Math.floor(xinv) === xinv) {\n return [1, xinv];\n }\n\n const x_ = x > 1 ? xinv : x;\n \n // a/b and c/d are neighbours in Farey sequence.\n let a = 0, b = 1, c = 1, d = 1;\n \n // Limit search to order 8.\n while (true) {\n // Generating next term in sequence (order of q).\n let p = a + c, q = b + d;\n if (q > limit) {\n break;\n }\n if (x_ <= p / q) {\n c = p; d = q;\n } else {\n a = p; b = q;\n }\n }\n\n // Select closest of neighbours to x.\n if (x_ - a / b < c / d - x_) {\n return x_ === x ? [a, b] : [b, a];\n } else {\n return x_ === x ? [c, d] : [d, c];\n }\n}\n\nfunction getOutputScale(ctx) {\n let devicePixelRatio = window.devicePixelRatio || 1;\n let backingStoreRatio = ctx.webkitBackingStorePixelRatio ||\n ctx.mozBackingStorePixelRatio ||\n ctx.msBackingStorePixelRatio ||\n ctx.oBackingStorePixelRatio ||\n ctx.backingStorePixelRatio || 1;\n let pixelRatio = devicePixelRatio / backingStoreRatio;\n return {\n sx: pixelRatio,\n sy: pixelRatio,\n scaled: pixelRatio !== 1\n };\n}\n\nfunction roundToDivide(x, div) {\n let r = x % div;\n return r === 0 ? x : Math.round(x - r + div);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/UI/page.js"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/pdf-annotate.min.js b/dist/pdf-annotate.min.js deleted file mode 100644 index 27e1fe76..00000000 --- a/dist/pdf-annotate.min.js +++ /dev/null @@ -1,8 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PDFAnnotate=t():e.PDFAnnotate=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=r(o);t["default"]=i["default"],e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),i=r(o),a=n(20),u=r(a),d=n(22),s=r(d),c=n(32),l=r(c),f=n(27),p=r(f),v=n(21),h=r(v),m=n(6);t["default"]={findAnnotationAtPoint:m.findAnnotationAtPoint,findSVGContainer:m.findSVGContainer,convertToScreenPoint:m.convertToScreenPoint,StoreAdapter:i["default"],LocalStoreAdapter:u["default"],__storeAdapter:new i["default"],getStoreAdapter:function(){return this.__storeAdapter},setStoreAdapter:function(e){this.__storeAdapter=e},UI:l["default"],render:s["default"],getAnnotations:function(e,t,n){var r;return(r=this.getStoreAdapter()).getAnnotations.apply(r,arguments)},config:p["default"],uuid:h["default"]},e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),Object.keys(n).forEach(function(e){"function"==typeof n[e]&&"function"==typeof t[e]&&(t[e]=n[e])})}return i(e,[{key:"__getAnnotations",value:function(e,t,n){(0,u["default"])("getAnnotations")}},{key:"getAnnotation",value:function(e,t){(0,u["default"])("getAnnotation")}},{key:"__addAnnotation",value:function(e,t,n,r){(0,u["default"])("addAnnotation")}},{key:"__editAnnotation",value:function(e,t,n){(0,u["default"])("editAnnotation")}},{key:"__deleteAnnotation",value:function(e,t){(0,u["default"])("deleteAnnotation")}},{key:"getComments",value:function(e,t){(0,u["default"])("getComments")}},{key:"__addComment",value:function(e,t,n){(0,u["default"])("addComment")}},{key:"__deleteComment",value:function(e,t){(0,u["default"])("deleteComment")}},{key:"getAnnotations",get:function(){return this.__getAnnotations},set:function(e){this.__getAnnotations=function(t,n,r){return e.apply(void 0,arguments).then(function(e){return e.annotations&&e.annotations.forEach(function(e){e.documentId=t}),e})}}},{key:"addAnnotation",get:function(){return this.__addAnnotation},set:function(e){this.__addAnnotation=function(t,n,r,o){return e.apply(void 0,arguments).then(function(e){return(0,d.fireEvent)("annotation:add",t,n,r,e),e})}}},{key:"editAnnotation",get:function(){return this.__editAnnotation},set:function(e){this.__editAnnotation=function(t,n,r){return e.apply(void 0,arguments).then(function(e){return(0,d.fireEvent)("annotation:edit",t,n,e),e})}}},{key:"deleteAnnotation",get:function(){return this.__deleteAnnotation},set:function(e){this.__deleteAnnotation=function(t,n,r){return e.apply(void 0,arguments).then(function(e){return e&&(0,d.fireEvent)("annotation:delete",t,n,r),e})}}},{key:"addComment",get:function(){return this.__addComment},set:function(e){this.__addComment=function(t,n,r){return e.apply(void 0,arguments).then(function(e){return(0,d.fireEvent)("comment:add",t,n,e),e})}}},{key:"deleteComment",get:function(){return this.__deleteComment},set:function(e){this.__deleteComment=function(t,n){return e.apply(void 0,arguments).then(function(e){return e&&(0,d.fireEvent)("comment:delete",t,n),e})}}}]),e}();t["default"]=s,e.exports=t["default"]},function(e,t){"use strict";function n(e){throw new Error(e+" is not implemented")}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){c.emit.apply(c,arguments)}function i(){c.on.apply(c,arguments)}function a(){c.removeListener.apply(c,arguments)}Object.defineProperty(t,"__esModule",{value:!0}),t.fireEvent=o,t.addEventListener=i,t.removeEventListener=a;var u=n(5),d=r(u),s=n(6),c=new d["default"],l=void 0;document.addEventListener("click",function(e){if((0,s.findSVGAtPoint)(e.clientX,e.clientY)){var t=(0,s.findAnnotationAtPoint)(e.clientX,e.clientY);l&&l!==t&&c.emit("annotation:blur",l),t&&c.emit("annotation:click",t),l=t}})},function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function a(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,o,u,d,s;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(n=this._events[e],a(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:u=Array.prototype.slice.call(arguments,1),n.apply(this,u)}else if(i(n))for(u=Array.prototype.slice.call(arguments,1),s=n.slice(),o=s.length,d=0;d0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,o,a,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],a=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(u=a;u-- >0;)if(n[u]===t||n[u].listener&&n[u].listener===t){o=u;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){for(var t=e;(t=t.parentNode)&&t!==document;)if("SVG"===t.nodeName.toUpperCase()&&"true"===t.getAttribute("data-pdf-annotate-container"))return t;return null}function i(e,t){for(var n=document.querySelectorAll('svg[data-pdf-annotate-container="true"]'),r=0,o=n.length;r=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right}function d(e){var t=e.getBoundingClientRect(),n=h(e),r=n.offsetLeft,o=n.offsetTop;return{top:t.top-o,left:t.left-r,right:t.right-r,bottom:t.bottom-o,width:t.width,height:t.height}}function s(e,t){var n={},r=g(e),o=r.viewport;return Object.keys(t).forEach(function(e){n[e]=t[e]*o.scale}),n}function c(e,t,n){var r=[e.x,e.y],o=[e.x+e.width,e.y+e.height];return r=l(r,t,n),o=l(o,t,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])}}function l(e,t,n){n=n||g(t).viewport;var r=[1,0,0,1,0,0];r=(0,w.scale)(r,n.scale,n.scale),r=(0,w.rotate)(r,n.rotation);var o=(0,_.getTranslation)(n);return r=(0,w.translate)(r,o.x,o.y),(0,w.applyInverseTransform)(e,r)}function f(e,t,n){n=n||g(t).viewport;var r=[1,0,0,1,0,0];r=(0,w.scale)(r,n.scale,n.scale),r=(0,w.rotate)(r,n.rotation);var o=(0,_.getTranslation)(n);return r=(0,w.translate)(r,o.x,o.y),(0,w.applyTransform)(e,r)}function p(e,t){var n={},r=g(e),o=r.viewport;return Object.keys(t).forEach(function(e){n[e]=t[e]/o.scale}),n}function v(e){for(var t=0,n=0,r=e;(r=r.parentNode)&&r!==document;)t+=r.scrollTop,n+=r.scrollLeft;return{scrollTop:t,scrollLeft:n}}function h(e){for(var t=e;(t=t.parentNode)&&t!==document&&"SVG"!==t.nodeName.toUpperCase(););var n=t.getBoundingClientRect();return{offsetLeft:n.left,offsetTop:n.top}}function m(){A.parentNode||document.head.appendChild(A)}function y(){A.parentNode&&A.parentNode.removeChild(A)}function g(e){return{documentId:e.getAttribute("data-pdf-annotate-document"),userId:e.getAttribute("data-pdf-annotate-user"),pageNumber:parseInt(e.getAttribute("data-pdf-annotate-page"),10),viewport:JSON.parse(e.getAttribute("data-pdf-annotate-viewport"))}}Object.defineProperty(t,"__esModule",{value:!0}),t.BORDER_COLOR=void 0,t.findSVGContainer=o,t.findSVGAtPoint=i,t.findAnnotationAtPoint=a,t.pointIntersectsRect=u,t.getOffsetAnnotationRect=d,t.scaleUp=s,t.convertToSvgRect=c,t.convertToSvgPoint=l,t.convertToScreenPoint=f,t.scaleDown=p,t.getScroll=v,t.getOffset=h,t.disableUserSelect=m,t.enableUserSelect=y,t.getMetadata=g;var b=n(7),x=r(b),_=n(8),w=n(19),A=(t.BORDER_COLOR="#00BFFF",(0,x["default"])({body:{"-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none"}}));A.setAttribute("data-pdf-annotate-user-select","true")},function(e,t){function n(e,t){return e+" {\n"+r(t)+"\n}"}function r(e){return Object.keys(e).map(function(t){return o(t,e[t])}).join("\n")}function o(e,t){return isNaN(t)||0==t||(t+="px"),i(e)+": "+t+";"}function i(e){return e.replace(/[A-Z]/g,function(e){return"-"+e.toLowerCase()})}e.exports=function(e){var t=document.createElement("style"),r=Object.keys(e).map(function(t){return n(t,e[t])}).join("\n");return t.setAttribute("type","text/css"),t.appendChild(document.createTextNode(r)),t}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=void 0,n=void 0;switch(e.rotation%360){case 0:t=n=0;break;case 90:t=0,n=e.width/e.scale*-1;break;case 180:t=e.width/e.scale*-1,n=e.height/e.scale*-1;break;case 270:t=e.height/e.scale*-1,n=0}return{x:t,y:n}}function i(e,t){var n=o(t);if(e.setAttribute("transform","scale("+t.scale+") rotate("+t.rotation+") translate("+n.x+", "+n.y+")"),!E&&"svg"===e.nodeName.toLowerCase()){e.setAttribute("x",parseInt(e.getAttribute("x"),10)*t.scale),e.setAttribute("y",parseInt(e.getAttribute("y"),10)*t.scale);var r=parseInt(e.getAttribute("x",10)),a=parseInt(e.getAttribute("y",10)),u=parseInt(e.getAttribute("width"),10),d=parseInt(e.getAttribute("height"),10),c=e.querySelector("path"),l=c.parentNode;switch([e,l,c,e.querySelector("rect")].forEach(function(e){e.setAttribute("width",parseInt(e.getAttribute("width"),10)*t.scale),e.setAttribute("height",parseInt(e.getAttribute("height"),10)*t.scale)}),i(c,(0,s["default"])({},t,{scale:1})),t.rotation%360){case 90:e.setAttribute("x",t.width-a-u),e.setAttribute("y",r),l.setAttribute("x",1),l.setAttribute("y",0);break;case 180:e.setAttribute("x",t.width-r-u),e.setAttribute("y",t.height-a-d),l.setAttribute("y",2);break;case 270:e.setAttribute("x",a),e.setAttribute("y",t.height-r-d),l.setAttribute("x",-1),l.setAttribute("y",0)}}return e}function a(e,t,n){n||(n=JSON.parse(e.getAttribute("data-pdf-annotate-viewport")));var r=void 0;switch(t.type){case"area":case"highlight":r=(0,y["default"])(t);break;case"circle":case"fillcircle":case"emptycircle":r=(0,_["default"])(t);break;case"strikeout":r=(0,l["default"])(t);break;case"point":r=(0,h["default"])(t);break;case"textbox":r=(0,b["default"])(t);break;case"drawing":r=(0,p["default"])(t);break;case"arrow":r=(0,A["default"])(t)}return r&&(r.setAttribute("data-pdf-annotate-id",t.uuid),r.setAttribute("data-pdf-annotate-type",t.type),r.setAttribute("data-pdf-annotate-userId",t.userId),r.setAttribute("aria-hidden",!0),e.appendChild(i(r,n))),r}function u(e,t,n){return n||(n=JSON.parse(e.getAttribute("data-pdf-annotate-viewport"))),t&&(t=i(t,n)),t}Object.defineProperty(t,"__esModule",{value:!0}),t.getTranslation=o,t.appendChild=a,t.transformChild=u;var d=n(9),s=r(d),c=n(10),l=r(c),f=n(13),p=r(f),v=n(14),h=r(v),m=n(15),y=r(m),g=n(16),b=r(g),x=n(17),_=r(x),w=n(18),A=r(w),E=/firefox/i.test(navigator.userAgent);t["default"]={getTranslation:o,appendChild:a,transformChild:u}},function(e,t){/* - object-assign - (c) Sindre Sorhus - @license MIT - */ -"use strict";function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(i){return!1}}var o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;e.exports=r()?Object.assign:function(e,t){for(var r,u,d=n(e),s=1;s0&&void 0!==arguments[0]?arguments[0]:"user";i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,{getAnnotations:function(e,t,n){return new Promise(function(r,o){var i=d().filter(function(e){return e.page===n&&"Annotation"===e["class"]});r({documentId:e,userId:t,pageNumber:n,annotations:i})})},getAnnotation:function(t,n){return Promise.resolve(s(t,e)[l(t,e,n)])},addAnnotation:function(e,t,n,r){return new Promise(function(o,i){r["class"]="Annotation",r.uuid=(0,v["default"])(),r.page=n,r.userId=t;var a=s(e,t);a.push(r),c(e,t,a),o(r)})},editAnnotation:function(e,t,n,r){return new Promise(function(o,i){var a=s(e,t);a[l(e,t,n)]=r,c(e,t,a),o(r)})},deleteAnnotation:function(e,t,n){return new Promise(function(r,o){var i=l(e,t,n);if(i>-1){var a=s(e,t);a.splice(i,1),c(e,t,a)}r(!0)})},getComments:function(e,t,n){return new Promise(function(r,o){r(s(e,t).filter(function(e){return"Comment"===e["class"]&&e.annotation===n}))})},addComment:function(e,t,n,r){return new Promise(function(o,i){var a={"class":"Comment",uuid:(0,v["default"])(),annotation:n,content:r},u=s(e,t);u.push(a),c(e,t,u),o(a)})},deleteComment:function(e,t,n){return new Promise(function(r,o){s(e,t);for(var i=-1,a=s(e,t),u=0,d=a.length;u-1&&(a.splice(i,1),c(e,t,a)),r(!0)})}}));return n._userId=e,n}return u(t,e),f(t,[{key:"userId",get:function(){return this._userId}}]),t}(m["default"]);t["default"]=y,e.exports=t["default"]},function(e,t){"use strict";function n(e){var t=16*Math.random()|0,n="x"==e?t:3&t|8;return n.toString(16)}function r(){return i.replace(o,n)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r;var o=/[xy]/g,i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){return new Promise(function(r,o){return e.setAttribute("data-pdf-annotate-container",!0),e.setAttribute("data-pdf-annotate-viewport",JSON.stringify(t)),e.removeAttribute("data-pdf-annotate-document"),e.removeAttribute("data-pdf-annotate-page"),n?(e.setAttribute("data-pdf-annotate-document",n.documentId),e.setAttribute("data-pdf-annotate-user",n.userId),e.setAttribute("data-pdf-annotate-page",n.pageNumber),Array.isArray(n.annotations)&&0!==n.annotations.length?(n.annotations.forEach(function(n){var r=e.querySelector('[data-pdf-annotate-id="'+n.uuid+'"]');r?(0,a.transformChild)(e,r,t):(0,a.appendChild)(e,n,t)}),void r(e)):r(e)):(e.innerHTML="",r(e))})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=n(1),a=(r(i),n(8)),u=n(23);r(u);e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){e=Array.isArray(e)?e:[],Object.keys(f).forEach(function(t){var n=f[t];e.filter(function(e){return e.type===t}).sort(n).forEach(function(e,t){return(0,s["default"])(e,t+1)})})}function i(e,t){return e.y1&&void 0!==arguments[1]?arguments[1]:0;switch(e.type){case"highlight":case"strikeout":var n=e.rectangles,r=n[0],o=n[n.length-1];(0,c["default"])((0,a["default"])("Begin "+e.type+" annotation "+t,e.uuid),r.x,r.y,e.page,!0),(0,c["default"])((0,a["default"])("End "+e.type+" annotation "+t,e.uuid+"-end"),o.x+o.width,o.y,e.page,!1);break;case"textbox":case"point":var i="textbox"===e.type?" (content: "+e.content+")":"";(0,d["default"])((0,a["default"])(e.type+" annotation "+t+i,e.uuid),e.x,e.y,e.page);break;case"drawing":case"area":var u="undefined"!=typeof e.x?e.x:e.lines[0][0],s="undefined"!=typeof e.y?e.y:e.lines[0][1];(0,d["default"])((0,a["default"])("Unlabeled drawing",e.uuid),u,s,e.page);break;case"circle":case"fillcircle":case"emptycircle":var l="undefined"!=typeof e.cx?e.cx:e.lines[0][0],v="undefined"!=typeof e.cy?e.cy:e.lines[0][1];(0,d["default"])((0,a["default"])("Unlabeled drawing",e.uuid),l,v,e.page)}p.includes(e.type)&&(0,f["default"])(e.documentId,e.uuid)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=n(25),a=r(i),u=n(26),d=r(u),s=n(28),c=r(s),l=n(29),f=r(l),p=["highlight","point","area","circle","emptycircle","fillcircle"];e.exports=t["default"]},function(e,t){"use strict";function n(e,t){var n=document.createElement("div"),r=document.createTextNode(e);return n.appendChild(r),n.setAttribute("id","pdf-annotate-screenreader-"+t),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}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t div")));n=(0,c.scaleUp)(i,{y:n}).y+a.top,t=(0,c.scaleUp)(i,{x:t}).x+a.left;for(var l=0,f=d.length;l"===f[f.length-1])for(;f.length&&(p.unshift(f.pop()),"<"!==p[0]););l.innerHTML=f.join("");var v=(0,s.scaleDown)(d,{width:l.getBoundingClientRect().width}).width;if(c+v<=t)break;p.unshift(f.pop())}return u.innerHTML=f.join("")+e.outerHTML+p.join(""),l.parentNode.removeChild(l),!0}function a(e,t,n){var r=document.querySelector('svg[data-pdf-annotate-page="'+n+'"]'),i=r.getBoundingClientRect();return t=(0,s.scaleUp)(r,{y:t}).y+i.top,e=(0,s.scaleUp)(r,{x:e}).x+i.left,[].concat(o(r.parentNode.querySelectorAll(d["default"].textClassQuery()+" [data-canvas-width]"))).filter(function(n){return(0,s.pointIntersectsRect)(e,t,n.getBoundingClientRect())})[0]}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i;var u=n(27),d=r(u),s=n(6);e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t,n){var r=void 0;return r=Array.isArray(n)?Promise.resolve(n):a["default"].getStoreAdapter().getComments(e,t),r.then(function(e){var n=document.getElementById("pdf-annotate-screenreader-"+t);if(n){var r=document.createElement("ol");r.setAttribute("id","pdf-annotate-screenreader-comment-list-"+t),r.setAttribute("aria-label","Comments"),n.appendChild(r),e.forEach(d["default"])}})}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=n(1),a=r(i),u=n(30),d=r(u);e.exports=t["default"]},function(e,t){"use strict";function n(e){if(e){var t=document.querySelector("#pdf-annotate-screenreader-"+e.annotation+" ol");if(t){var n=document.createElement("li");n.setAttribute("id","pdf-annotate-screenreader-comment-"+e.uuid),n.appendChild(document.createTextNode(""+e.content)),t.appendChild(n)}}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=n,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){(0,y.addEventListener)("annotation:add",function(e,t,n,r){i(e,t,n,r.type)}),(0,y.addEventListener)("annotation:edit",function(e,t,n,r){i(e,t,r.page,r.type)}),(0,y.addEventListener)("annotation:delete",a),(0,y.addEventListener)("comment:add",u),(0,y.addEventListener)("comment:delete",d)}function i(e,t,n,r){b["default"].getStoreAdapter().getAnnotations(e,t,n).then(function(e){return e.annotations.filter(function(e){return e.type===r})}).then(function(t){return t.forEach(function(t){a(e,t.uuid)}),t}).then(f["default"])}function a(e,t){s("pdf-annotate-screenreader-"+t),s("pdf-annotate-screenreader-"+t+"-end")}function u(e,t,n){var r=document.querySelector("pdf-annotate-screenreader-comment-list-"+t),o=void 0;o=r?Promise.resolve(!0):(0,m["default"])(e,t,[]).then(function(){return r=document.querySelector("pdf-annotate-screenreader-comment-list-"+t),!0}),o.then(function(){(0,v["default"])(n)})}function d(e,t){s("pdf-annotate-screenreader-comment-"+t)}function s(e){var t=document.getElementById(e);t&&t.parentNode.removeChild(t)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var c=n(24),l=(r(c),n(23)),f=r(l),p=n(30),v=r(p),h=n(29),m=r(h),y=n(4),g=n(1),b=r(g);e.exports=t["default"]},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(4),o=n(33),i=n(34),a=n(35),u=n(36),d=n(37),s=n(38),c=n(39),l=n(40),f=n(41);t["default"]={addEventListener:r.addEventListener,removeEventListener:r.removeEventListener,fireEvent:r.fireEvent,disableEdit:o.disableEdit,enableEdit:o.enableEdit,disablePen:i.disablePen,enablePen:i.enablePen,setPen:i.setPen,enableEraser:a.enableEraser,disableEraser:a.disableEraser,disablePoint:d.disablePoint,enablePoint:d.enablePoint,disableRect:s.disableRect,enableRect:s.enableRect,disableCircle:c.disableCircle,enableCircle:c.enableCircle,setCircle:c.setCircle,addCircle:c.addCircle,disableArrow:u.disableArrow,enableArrow:u.enableArrow,setArrow:u.setArrow,disableText:l.disableText,enableText:l.enableText,setText:l.setText,createPage:f.createPage,renderPage:f.renderPage},e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);ti&&r+C.offsetHeightu&&o+C.offsetWidth-1&&(a="cx",d="cy"),["area","highlight","point","textbox","circle","fillcircle","emptycircle"].indexOf(r)>-1){var s=(0,A.convertToSvgPoint)([k,M],i),c=(0,A.convertToSvgPoint)([C.offsetLeft,C.offsetTop],i),l={x:c[0]-s[0],y:c[1]-s[1]};"textbox"===r&&(n=[n[0].firstChild]),[].concat(o(n)).forEach(function(t,n){var o=parseInt(t.getAttribute(a),10),u=parseInt(t.getAttribute(d),10);if(0!==l.y){u+=l.y;var s=u;"point"===r&&(s=(0,A.scaleUp)(i,{viewY:s}).viewY),t.setAttribute(d,s),e.rectangles&&n1&&(n=(0,g.findSVGAtPoint)(e,t))){var r=(0,g.getMetadata)(n),o=r.documentId,i=r.userId,a=r.pageNumber;m["default"].getStoreAdapter().addAnnotation(o,i,a,{type:"drawing",width:_,color:w,lines:E}).then(function(e){A&&n.removeChild(A),(0,y.appendChild)(n,e)})}}function d(e){e.srcElement.classList.contains("annotationLayer")&&x&&l(e.clientX,e.clientY)}function s(e){e.srcElement.classList.contains("annotationLayer")&&x&&l(e.changedTouches[0].clientX,e.changedTouches[0].clientY)}function c(e){27===e.keyCode&&(E=null,A.parentNode.removeChild(A),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",a))}function l(e,t){var n=(0,g.findSVGAtPoint)(e,t);if(n){var r=n.getBoundingClientRect(),o=(0,g.convertToSvgPoint)([e-r.left,t-r.top],n);o[0]=o[0].toFixed(2),o[1]=o[1].toFixed(2),E.push(o),E.length<=1||(A&&n.removeChild(A),A=(0,y.appendChild)(n,{type:"drawing",color:w,width:_,lines:E}))}}function f(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";_=parseInt(e,10),w=t}function p(){b||(b=!0,L?(document.addEventListener("pointerdown",o),document.addEventListener("pointermove",d),document.addEventListener("pointerup",a)):(document.addEventListener("touchstart",o),document.addEventListener("touchmove",s),document.addEventListener("touchend",i),document.addEventListener("mousedown",o),document.addEventListener("mousemove",d),document.addEventListener("mouseup",a)),document.addEventListener("keyup",c),(0,g.disableUserSelect)())}function v(){b&&(b=!1,L?(document.removeEventListener("pointerdown",o),document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",a)):(document.removeEventListener("touchstart",o),document.removeEventListener("touchmove",s),document.removeEventListener("touchend",i),document.removeEventListener("mousedown",o),document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",a)),document.removeEventListener("keyup",c),(0,g.enableUserSelect)())}Object.defineProperty(t,"__esModule",{value:!0}),t.setPen=f,t.enablePen=p,t.disablePen=v;var h=n(1),m=r(h),y=n(8),g=n(6),b=!1,x=!1,_=void 0,w=void 0,A=void 0,E=[],L=/firefox/i.test(navigator.userAgent)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1&&(t=(0,h.findSVGAtPoint)(e.clientX,e.clientY))){var n=(0,h.getMetadata)(t),r=n.documentId,o=n.pageNumber;p["default"].getStoreAdapter().addAnnotation(r,o,{type:"arrow",width:y,color:g,lines:x}).then(function(e){b&&t.removeChild(b),(0,v.appendChild)(t,e)})}document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i)}function a(e){var t=0===x.length?w:e.clientX,n=0===x.length?_:e.clientY;d(t,n)}function u(e){27===e.keyCode&&(x=null,b.parentNode.removeChild(b), -document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i))}function d(e,t){var n=(0,h.findSVGAtPoint)(e,t);if(n){var r=n.getBoundingClientRect(),o=(0,h.convertToSvgPoint)([e-r.left,t-r.top],n);if(x.length<2)return void x.push(o);x[1]=o,b&&n.removeChild(b),b=(0,v.appendChild)(n,{type:"arrow",color:g,width:y,lines:x})}}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";y=parseInt(e,10),g=t}function c(){m||(m=!0,document.addEventListener("mousedown",o),document.addEventListener("keyup",u),(0,h.disableUserSelect)())}function l(){m&&(m=!1,document.removeEventListener("mousedown",o),document.removeEventListener("keyup",u),(0,h.enableUserSelect)())}Object.defineProperty(t,"__esModule",{value:!0}),t.setArrow=s,t.enableArrow=c,t.disableArrow=l;var f=n(1),p=r(f),v=n(8),h=n(6),m=!1,y=void 0,g=void 0,b=void 0,x=void 0,_=void 0,w=void 0},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){!m&&(0,v.findSVGAtPoint)(e.clientX,e.clientY)&&(m=document.createElement("input"),m.setAttribute("id","pdf-annotate-point-input"),m.setAttribute("placeholder","Enter comment"),m.style.border="3px solid "+v.BORDER_COLOR,m.style.borderRadius="3px",m.style.position="absolute",m.style.top=e.clientY+"px",m.style.left=e.clientX+"px",m.addEventListener("blur",i),m.addEventListener("keyup",a),document.body.appendChild(m),m.focus())}function i(){u()}function a(e){27===e.keyCode?d():13===e.keyCode&&u()}function u(){if(m.value.trim().length>0){var e=parseInt(m.style.left,10),t=parseInt(m.style.top,10),n=m.value.trim(),r=(0,v.findSVGAtPoint)(e,t);if(!r)return;var o=r.getBoundingClientRect(),i=(0,v.getMetadata)(r),a=i.documentId,u=i.userId,s=i.pageNumber,c=Object.assign({type:"point"},(0,v.scaleDown)(r,{x:e-o.left,y:t-o.top}));f["default"].getStoreAdapter().addAnnotation(a,u,s,c).then(function(e){f["default"].getStoreAdapter().addComment(a,e.uuid,n),(0,p.appendChild)(r,e)})}d()}function d(){m.removeEventListener("blur",i),m.removeEventListener("keyup",a),document.body.removeChild(m),m=null}function s(){h||(h=!0,document.addEventListener("mouseup",o))}function c(){h&&(h=!1,document.removeEventListener("mouseup",o))}Object.defineProperty(t,"__esModule",{value:!0}),t.enablePoint=s,t.disablePoint=c;var l=n(1),f=r(l),p=n(8),v=n(6),h=!1,m=void 0},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&n[0].width>0&&n[0].height>0)return n}catch(r){}return null}function a(e){var t=void 0;if("area"===x&&(t=(0,g.findSVGAtPoint)(e.clientX,e.clientY))){var n=t.getBoundingClientRect();w=e.clientY,A=e.clientX,_=document.createElement("div"),_.style.position="absolute",_.style.top=w-n.top+"px",_.style.left=A-n.left+"px",_.style.border="3px solid "+g.BORDER_COLOR,_.style.borderRadius="3px",t.parentNode.appendChild(_),document.addEventListener("mousemove",u),(0,g.disableUserSelect)()}}function u(e){var t=_.parentNode.querySelector(m["default"].annotationSvgQuery()),n=t.getBoundingClientRect();A+(e.clientX-A)0&&e.height>0&&e.x>-1&&e.y>-1})},0!==i.rectangles.length){if("area"===e){var u=i.rectangles[0];delete i.rectangles,i.x=u.x,i.y=u.y,i.width=u.width,i.height=u.height}var d=(0,g.getMetadata)(r),s=d.documentId,c=d.userId,l=d.pageNumber;v["default"].getStoreAdapter().addAnnotation(s,c,l,i).then(function(e){(0,y.appendChild)(r,e)})}}}function l(e){x=e,b||(b=!0,document.addEventListener("mouseup",d),document.addEventListener("mousedown",a),document.addEventListener("keyup",s))}function f(){b&&(b=!1,document.removeEventListener("mouseup",d),document.removeEventListener("mousedown",a),document.removeEventListener("keyup",s))}Object.defineProperty(t,"__esModule",{value:!0}),t.enableRect=l,t.disableRect=f;var p=n(1),v=r(p),h=n(27),m=r(h),y=n(8),g=n(6),b=!1,x=void 0,_=void 0,w=void 0,A=void 0},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0000FF";y=parseInt(e,10),g=t}function i(e){var t=(0,v.findSVGAtPoint)(e.clientX,e.clientY);if(t){var n=t.getBoundingClientRect();a(t,m,{x:e.clientX-n.left,y:e.clientY-n.top},y,g)}}function a(e,t,n,r,o){var i=(0,v.convertToSvgPoint)([n.x,n.y],e),a={type:t,color:o,cx:i[0],cy:i[1],r:r},u=(0,v.getMetadata)(e),d=u.documentId,s=u.userId,c=u.pageNumber;l["default"].getStoreAdapter().addAnnotation(d,s,c,a).then(function(t){(0,p.appendChild)(e,t)})}function u(e){m=e,h||(h=!0,document.addEventListener("mouseup",i))}function d(){h&&(h=!1,document.removeEventListener("mouseup",i))}function s(e,t){var n=m;m=e,i(t),m=n}Object.defineProperty(t,"__esModule",{value:!0}),t.setCircle=o,t.enableCircle=u,t.disableCircle=d,t.addCircle=s;var c=n(1),l=r(c),f=n(27),p=(r(f),n(8)),v=n(6),h=!1,m=void 0,y=10,g="0000FF"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){!y&&(0,h.findSVGAtPoint)(e.clientX,e.clientY)&&e.srcElement.classList.contains("annotationLayer")&&(y=document.createElement("input"),y.setAttribute("id","pdf-annotate-text-input"),y.setAttribute("placeholder","Enter text"),y.style.border="3px solid "+h.BORDER_COLOR,y.style.borderRadius="3px",y.style.position="absolute",y.style.top=e.clientY+"px",y.style.left=e.clientX+"px",y.style.fontSize=g+"px",y.style.zIndex="41",y.addEventListener("blur",i),y.addEventListener("keyup",a),document.body.appendChild(y),y.focus())}function i(){u()}function a(e){27===e.keyCode?d():13===e.keyCode&&u()}function u(){if(y.value.trim().length>0){var e=parseInt(y.style.left,10),t=parseInt(y.style.top,10),n=(0,h.findSVGAtPoint)(e,t);if(!n)return;var r=g,o=(0,h.getMetadata)(n),i=o.documentId,a=o.userId,u=o.pageNumber,s=o.viewport,c=1/s.scale,l=n.getBoundingClientRect(),f=(0,h.convertToSvgPoint)([e-l.left,t-l.top+r],n,s),m={type:"textbox",size:g*c,color:b,content:y.value.trim(),x:f[0],y:f[1],rotation:-s.rotation};p["default"].getStoreAdapter().addAnnotation(i,a,u,m).then(function(e){(0,v.appendChild)(n,e)})}d()}function d(){y&&(y.removeEventListener("blur",i),y.removeEventListener("keyup",a),document.body.removeChild(y),y=null)}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"000000";g=parseInt(e,10),b=t}function c(){m||(m=!0,document.addEventListener("mouseup",o))}function l(){m&&(m=!1,document.removeEventListener("mouseup",o))}Object.defineProperty(t,"__esModule",{value:!0}),t.setText=s,t.enableText=c,t.disableText=l;var f=n(1),p=r(f),v=n(8),h=n(6),m=!1,y=void 0,g=void 0,b=void 0},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=document.createElement("div");t.innerHTML=y;var n=t.children[0],r=n.querySelector("canvas");return n.setAttribute("id","pageContainer"+e),n.setAttribute("data-page-number",e),r.mozOpaque=!0,r.setAttribute("id","page"+e),n}function i(e,t){var n=t.documentId,r=t.userId,o=t.pdfDocument,i=t.scale,u=t.rotate;return Promise.all([o.getPage(e),f["default"].getAnnotations(n,r,e)]).then(function(t){var n=c(t,2),r=n[0],o=n[1],d=document.getElementById("pageContainer"+e),s=d.querySelector(v["default"].annotationClassQuery()),l=d.querySelector(".canvasWrapper canvas"),p=l.getContext("2d",{alpha:!1}),h=(u+r.rotate)%360,y=r.getViewport(i,h),g=a(e,y,p);return Promise.all([r.render({canvasContext:p,viewport:y,transform:g}),f["default"].render(s,y,o)]).then(function(){return r.getTextContent({normalizeWhitespace:!0}).then(function(t){return new Promise(function(n,r){var i=d.querySelector(v["default"].textClassQuery()),a=new PDFJS.DefaultTextLayerFactory,u=a.createTextLayerBuilder(i,e-1,y);u.setTextContent(t),u.render(),setTimeout(function(){try{(0,m["default"])(o.annotations),n()}catch(e){r(e)}})})})}).then(function(){return d.setAttribute("data-loaded","true"),[r,o]})})}function a(e,t,n){var r=document.getElementById("pageContainer"+e),o=r.querySelector(".canvasWrapper canvas"),i=r.querySelector(v["default"].annotationClassQuery()),a=r.querySelector(".canvasWrapper"),c=r.querySelector(v["default"].textClassQuery()),l=d(n),f=l.scaled?[l.sx,0,0,l.sy,0,0]:null,p=u(l.sx),h=u(l.sy);return r.style.visibility="",o.width=s(t.width*l.sx,p[0]),o.height=s(t.height*l.sy,h[0]),o.style.width=s(t.width,p[1])+"px",o.style.height=s(t.height,p[1])+"px",i.setAttribute("width",t.width),i.setAttribute("height",t.height),i.style.width=t.width+"px",i.style.height=t.height+"px",r.style.width=t.width+"px",r.style.height=t.height+"px",a.style.width=t.width+"px",a.style.height=t.height+"px",c.style.width=t.width+"px",c.style.height=t.height+"px",f}function u(e){if(Math.floor(e)===e)return[e,1];var t=1/e,n=8;if(t>n)return[1,n];if(Math.floor(t)===t)return[1,t];for(var r=e>1?t:e,o=0,i=1,a=1,u=1;;){var d=o+a,s=i+u;if(s>n)break;r<=d/s?(a=d,u=s):(o=d,i=s)}return r-o/i must be in the document for IE and recent Firefox versions. - // (otherwise .click() is ignored) - (document.body || document.documentElement).appendChild(a); - a.click(); - a.parentNode.removeChild(a); - } else { - if (window.top === window && - blobUrl.split('#')[0] === window.location.href.split('#')[0]) { - // If _parent == self, then opening an identical URL with different - // location hash will only cause a navigation, not a download. - var padCharacter = blobUrl.indexOf('?') === -1 ? '?' : '&'; - blobUrl = blobUrl.replace(/#|$/, padCharacter + '$&'); - } - window.open(blobUrl, '_parent'); - } - } +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - function DownloadManager() {} +var _base_viewer = __w_pdfjs_require__(21); - DownloadManager.prototype = { - downloadUrl: function DownloadManager_downloadUrl(url, filename) { - if (!PDFJS.isValidUrl(url, true)) { - return; // restricted/invalid URL - } +var _ui_utils = __w_pdfjs_require__(3); - download(url + '#pdfjs.action=download', filename); - }, +var _pdfjsLib = __w_pdfjs_require__(2); - downloadData: function DownloadManager_downloadData(data, filename, - contentType) { - if (navigator.msSaveBlob) { // IE10 and above - return navigator.msSaveBlob(new Blob([data], { type: contentType }), - filename); - } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var blobUrl = PDFJS.createObjectURL(data, contentType); - download(blobUrl, filename); - }, +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - download: function DownloadManager_download(blob, url, filename) { - if (!URL) { - // URL.createObjectURL is not supported - this.downloadUrl(url, filename); - return; - } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - if (navigator.msSaveBlob) { - // IE10 / IE11 - if (!navigator.msSaveBlob(blob, filename)) { - this.downloadUrl(url, filename); +var PDFViewer = function (_BaseViewer) { + _inherits(PDFViewer, _BaseViewer); + + function PDFViewer() { + _classCallCheck(this, PDFViewer); + + return _possibleConstructorReturn(this, (PDFViewer.__proto__ || Object.getPrototypeOf(PDFViewer)).apply(this, arguments)); + } + + _createClass(PDFViewer, [{ + key: '_scrollIntoView', + value: function _scrollIntoView(_ref) { + var pageDiv = _ref.pageDiv, + _ref$pageSpot = _ref.pageSpot, + pageSpot = _ref$pageSpot === undefined ? null : _ref$pageSpot; + + if (!pageSpot && !this.isInPresentationMode) { + var left = pageDiv.offsetLeft + pageDiv.clientLeft; + var right = left + pageDiv.clientWidth; + var _container = this.container, + scrollLeft = _container.scrollLeft, + clientWidth = _container.clientWidth; + + if (this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL || left < scrollLeft || right > scrollLeft + clientWidth) { + pageSpot = { + left: 0, + top: 0 + }; } + } + (0, _ui_utils.scrollIntoView)(pageDiv, pageSpot); + } + }, { + key: '_getVisiblePages', + value: function _getVisiblePages() { + if (!this.isInPresentationMode) { + return (0, _ui_utils.getVisibleElements)(this.container, this._pages, true, this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL); + } + var currentPage = this._pages[this._currentPageNumber - 1]; + var visible = [{ + id: currentPage.id, + view: currentPage + }]; + return { + first: currentPage, + last: currentPage, + views: visible + }; + } + }, { + key: 'update', + value: function update() { + var visible = this._getVisiblePages(); + var visiblePages = visible.views, + numVisiblePages = visiblePages.length; + if (numVisiblePages === 0) { return; } - - var blobUrl = URL.createObjectURL(blob); - download(blobUrl, filename); + this._resizeBuffer(numVisiblePages, visiblePages); + this.renderingQueue.renderHighestPriority(visible); + var currentId = this._currentPageNumber; + var stillFullyVisible = false; + for (var i = 0; i < numVisiblePages; ++i) { + var page = visiblePages[i]; + if (page.percent < 100) { + break; + } + if (page.id === currentId) { + stillFullyVisible = true; + break; + } + } + if (!stillFullyVisible) { + currentId = visiblePages[0].id; + } + if (!this.isInPresentationMode) { + this._setCurrentPageNumber(currentId); + } + this._updateLocation(visible.first); + this.eventBus.dispatch('updateviewarea', { + source: this, + location: this._location + }); } - }; - - return DownloadManager; -})(); - + }, { + key: '_setDocumentViewerElement', + get: function get() { + return (0, _pdfjsLib.shadow)(this, '_setDocumentViewerElement', this.viewer); + } + }, { + key: '_isScrollModeHorizontal', + get: function get() { + return this.isInPresentationMode ? false : this._scrollMode === _base_viewer.ScrollMode.HORIZONTAL; + } + }]); - PDFJS.PDFViewer = PDFViewer; - PDFJS.PDFPageView = PDFPageView; - PDFJS.PDFLinkService = PDFLinkService; - PDFJS.TextLayerBuilder = TextLayerBuilder; - PDFJS.DefaultTextLayerFactory = DefaultTextLayerFactory; - PDFJS.AnnotationLayerBuilder = AnnotationLayerBuilder; - PDFJS.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory; - PDFJS.PDFHistory = PDFHistory; + return PDFViewer; +}(_base_viewer.BaseViewer); - PDFJS.DownloadManager = DownloadManager; - PDFJS.ProgressBar = ProgressBar; -}).call((typeof window === 'undefined') ? this : window); +exports.PDFViewer = PDFViewer; +/***/ }) +/******/ ]); +}); +//# sourceMappingURL=pdf_viewer.js.map \ No newline at end of file diff --git a/src/PDFJSAnnotate.js b/src/PDFJSAnnotate.js index 9bdfa6ca..77e0cc9e 100644 --- a/src/PDFJSAnnotate.js +++ b/src/PDFJSAnnotate.js @@ -78,7 +78,7 @@ export default { * @param {String} pageNumber The page number * @return {Promise} */ - getAnnotations(documentId, userId, pageNumber) { + getAnnotations(documentId, pageNumber) { return this.getStoreAdapter().getAnnotations(...arguments); }, diff --git a/src/UI/arrow.js b/src/UI/arrow.js index b8e66b1c..b6aab8c8 100644 --- a/src/UI/arrow.js +++ b/src/UI/arrow.js @@ -24,8 +24,9 @@ let originX; */ function handleDocumentMousedown(e) { let target = findAnnotationAtPoint(e.clientX, e.clientY); - if (target === null) + if (target === null) { return; + } let type = target.getAttribute('data-pdf-annotate-type'); if (type !== 'circle' && type !== 'fillcircle' && type !== 'emptycircle') { @@ -33,11 +34,10 @@ function handleDocumentMousedown(e) { } let svg = findSVGContainer(target); - let { documentId, userId } = getMetadata(svg); + let { documentId } = getMetadata(svg); let annotationId = target.getAttribute('data-pdf-annotate-id'); - let event = e; - PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => { + PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => { if (annotation) { path = null; lines = []; @@ -50,7 +50,7 @@ function handleDocumentMousedown(e) { let rect = svg.getBoundingClientRect(); originX = point[0] + rect.left; - originY = point[1] + rect.top; + originY = point[1] + rect.top; document.addEventListener('mousemove', handleDocumentMousemove); document.addEventListener('mouseup', handleDocumentMouseup); @@ -69,12 +69,11 @@ function handleDocumentMouseup(e) { let { documentId, pageNumber } = getMetadata(svg); PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, { - type: 'arrow', - width: _penSize, - color: _penColor, - lines - } - ).then((annotation) => { + type: 'arrow', + width: _penSize, + color: _penColor, + lines + }).then((annotation) => { if (path) { svg.removeChild(path); } diff --git a/src/UI/circle.js b/src/UI/circle.js index f880b1ce..b308709c 100644 --- a/src/UI/circle.js +++ b/src/UI/circle.js @@ -35,22 +35,23 @@ function handleDocumentMouseup(e) { } let rect = svg.getBoundingClientRect(); saveCircle(svg, _type, { - x: e.clientX - rect.left, - y: e.clientY - rect.top - }, _circleRadius, _circleColor - ); + x: e.clientX - rect.left, + y: e.clientY - rect.top + }, _circleRadius, _circleColor); } /** * Save a circle annotation * + * @param {SVGElement} svg * @param {String} type The type of circle (circle, emptycircle, fillcircle) * @param {Object} pt The point to use for annotation + * @param {float} radius * @param {String} color The color of the rects */ function saveCircle(svg, type, pt, radius, color) { // Initialize the annotation - let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg) + let svg_pt = convertToSvgPoint([ pt.x, pt.y ], svg); let annotation = { type, color, @@ -59,10 +60,10 @@ function saveCircle(svg, type, pt, radius, color) { r: radius }; - let { documentId, userId, pageNumber } = getMetadata(svg); + let { documentId, pageNumber } = getMetadata(svg); // Add the annotation - PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation) + PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation) .then((annotation) => { appendChild(svg, annotation); }); @@ -73,7 +74,7 @@ function saveCircle(svg, type, pt, radius, color) { */ export function enableCircle(type) { _type = type; - + if (_enabled) { return; } _enabled = true; @@ -94,5 +95,5 @@ export function addCircle(type, e) { let oldType = _type; _type = type; handleDocumentMouseup(e); - _type = oldType; -} \ No newline at end of file + _type = oldType; +} diff --git a/src/UI/edit.js b/src/UI/edit.js index 7ef7e432..ce1535ce 100644 --- a/src/UI/edit.js +++ b/src/UI/edit.js @@ -18,7 +18,8 @@ import { } from './utils'; let _enabled = false; -let isDragging = false, overlay; +let isDragging = false; +let overlay; let dragOffsetX, dragOffsetY, dragStartX, dragStartY; const OVERLAY_BORDER_SIZE = 3; @@ -37,7 +38,7 @@ function createEditOverlay(target) { let rect = getOffsetAnnotationRect(target); let styleLeft = rect.left - OVERLAY_BORDER_SIZE; let styleTop = rect.top - OVERLAY_BORDER_SIZE; - + overlay.setAttribute('id', 'pdf-annotate-edit-overlay'); overlay.setAttribute('data-target-id', id); overlay.style.boxSizing = 'content-box'; @@ -65,7 +66,7 @@ function createEditOverlay(target) { anchor.style.right = '-13px'; anchor.style.width = '25px'; anchor.style.height = '25px'; - + overlay.appendChild(anchor); parentNode.appendChild(overlay); document.addEventListener('click', handleDocumentClick); @@ -111,18 +112,21 @@ function destroyEditOverlay() { * Delete currently selected annotation */ function deleteAnnotation() { - if (!overlay) { return; } + if (!overlay) { + return; + } let annotationId = overlay.getAttribute('data-target-id'); - let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`); let svg = overlay.parentNode.querySelector(config.annotationSvgQuery()); let { documentId } = getMetadata(svg); - [...nodes].forEach((n) => { - n.parentNode.removeChild(n); + PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => { + let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`); + + [...nodes].forEach((n) => { + n.parentNode.removeChild(n); + }); }); - - PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId); destroyEditOverlay(); } @@ -149,12 +153,21 @@ function handleDocumentClick(e) { /** * Handle document.keyup event * - * @param {Event} e The DOM event that needs to be handled + * @param {KeyboardEvent} e The DOM event that needs to be handled */ function handleDocumentKeyup(e) { - if (overlay && e.keyCode === 46 && + // keyCode is deprecated, so prefer the newer "key" method if possible + let keyTest; + if (e.key) { + keyTest = e.key.toLowerCase() === 'delete' || e.key.toLowerCase() === 'backspace'; + } + else { + keyTest = e.keyCode === 8 || e.keyCode === 46; + } + if (overlay && keyTest && e.target.nodeName.toLowerCase() !== 'textarea' && e.target.nodeName.toLowerCase() !== 'input') { + e.preventDefault(); deleteAnnotation(); } } @@ -165,7 +178,9 @@ function handleDocumentKeyup(e) { * @param {Event} e The DOM event that needs to be handled */ function handleDocumentMousedown(e) { - if (e.target !== overlay) { return; } + if (e.target !== overlay) { + return; + } // Highlight and strikeout annotations are bound to text within the document. // It doesn't make sense to allow repositioning these types of annotations. @@ -225,18 +240,35 @@ function handleDocumentMouseup(e) { let target = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`); let type = target[0].getAttribute('data-pdf-annotate-type'); let svg = overlay.parentNode.querySelector(config.annotationSvgQuery()); - let { documentId, userId } = getMetadata(svg); - + let { documentId } = getMetadata(svg); + overlay.querySelector('a').style.display = ''; - PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, userId, annotationId).then((annotation) => { + PDFJSAnnotate.getStoreAdapter().getAnnotation(documentId, annotationId).then((annotation) => { let attribX = 'x'; let attribY = 'y'; if (['circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { attribX = 'cx'; attribY = 'cy'; } - if (['area', 'highlight', 'point', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { + + if (type === 'point') { + // Broken + /* + [...target].forEach((t, i) => { + let moveTo = { + x: overlay.offsetLeft + 3, + y: overlay.offsetTop + 3 + }; + t.setAttribute(attribX, moveTo.x); + t.setAttribute(attribY, moveTo.y); + annotation[attribX] = moveTo.x; + annotation[attribY] = moveTo.y; + }); + */ + return; + } + else if (['area', 'highlight', 'textbox', 'circle', 'fillcircle', 'emptycircle'].indexOf(type) > -1) { let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg); let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg); let modelDelta = { @@ -253,36 +285,29 @@ function handleDocumentMouseup(e) { let modelY = parseInt(t.getAttribute(attribY), 10); if (modelDelta.y !== 0) { modelY = modelY + modelDelta.y; - let viewY = modelY; - - if (type === 'point') { - viewY = scaleUp(svg, { viewY }).viewY; - } - t.setAttribute(attribY, viewY); + t.setAttribute(attribY, modelY); if (annotation.rectangles && i < annotation.rectangles.length) { annotation.rectangles[i].y = modelY; - } else if (annotation[attribY]) { + } + else if (annotation[attribY]) { annotation[attribY] = modelY; } } if (modelDelta.x !== 0) { modelX = modelX + modelDelta.x; - let viewX = modelX; - if (type === 'point') { - viewX = scaleUp(svg, { viewX }).viewX; - } - - t.setAttribute(attribX, viewX); - if (annotation.rectangles && i < annotation.rectangles.length) { + t.setAttribute(attribX, modelX); + if (annotation.rectangles && i < annotation.rectangles.length) { annotation.rectangles[i].x = modelX; - } else if (annotation[attribX]) { + } + else if (annotation[attribX]) { annotation[attribX] = modelX; } } }); - // } else if (type === 'strikeout') { + } else if (type === 'strikeout') { + return; // let { deltaX, deltaY } = getDelta('x1', 'y1'); // [...target].forEach(target, (t, i) => { // if (deltaY !== 0) { @@ -296,7 +321,10 @@ function handleDocumentMouseup(e) { // annotation.rectangles[i].x = parseInt(t.getAttribute('x1'), 10); // } // }); - } else if (type === 'drawing' || type === 'arrow') { + } + else if (type === 'drawing' || type === 'arrow') { + // Do nothing as currently broken + /* let modelStart = convertToSvgPoint([dragStartX, dragStartY], svg); let modelEnd = convertToSvgPoint([overlay.offsetLeft, overlay.offsetTop], svg); let modelDelta = { @@ -312,7 +340,9 @@ function handleDocumentMouseup(e) { target[0].parentNode.removeChild(target[0]); appendChild(svg, annotation); - } + */ + return; + } PDFJSAnnotate.getStoreAdapter().editAnnotation(documentId, annotationId, annotation); }); @@ -341,8 +371,10 @@ function handleAnnotationClick(target) { /** * Enable edit mode behavior. */ -export function enableEdit () { - if (_enabled) { return; } +export function enableEdit() { + if (_enabled) { + return; + } _enabled = true; addEventListener('annotation:click', handleAnnotationClick); @@ -351,10 +383,12 @@ export function enableEdit () { /** * Disable edit mode behavior. */ -export function disableEdit () { +export function disableEdit() { destroyEditOverlay(); - if (!_enabled) { return; } + if (!_enabled) { + return; + } _enabled = false; removeEventListener('annotation:click', handleAnnotationClick); diff --git a/src/UI/eraser.js b/src/UI/eraser.js index d87e51df..32ccf80f 100644 --- a/src/UI/eraser.js +++ b/src/UI/eraser.js @@ -1,60 +1,60 @@ import PDFJSAnnotate from '../PDFJSAnnotate'; -import config from '../config'; import { findAnnotationAtPoint, - findSVGAtPoint, getMetadata } from './utils'; let _canerase = false; -let userId = "user"; -function handleDocumentDown(e){ +/** + * + * @param {PointerEvent} e + */ +function handleDocumentDown(e) { _canerase = true; } -function handleDocumentUp(e){ +/** + * + * @param {PointerEvent} e + */ +function handleDocumentUp(e) { _canerase = false; } -function handleDocumentTouchMove(e){ - erase(findAnnotationAtPoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY)); -} - -function handleDocumentMouseMove(e){ +/** + * + * @param {PointerEvent} e + */ +function handleDocumentMouseMove(e) { erase(findAnnotationAtPoint(e.clientX, e.clientY)); } -function erase(target){ - if(_canerase){ - if(target && target.getAttribute('data-pdf-annotate-userId') == userId){ - let { documentId } = getMetadata(target.parentElement); - let annotationId = target.getAttribute('data-pdf-annotate-id'); +function erase(target) { + if (!_canerase) { + return; + } + + if (target) { + let { documentId } = getMetadata(target.parentElement); + let annotationId = target.getAttribute('data-pdf-annotate-id'); + PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, annotationId).then(() => { let nodes = document.querySelectorAll(`[data-pdf-annotate-id="${annotationId}"]`); [...nodes].forEach((n) => { n.parentNode.removeChild(n); }); - - PDFJSAnnotate.getStoreAdapter().deleteAnnotation(documentId, userId, annotationId); - } + }); } } -export function enableEraser(){ - userId = PDFJSAnnotate.getStoreAdapter().userId; - document.addEventListener('mousemove', handleDocumentMouseMove); - document.addEventListener('mousedown', handleDocumentDown); - document.addEventListener('mouseup', handleDocumentUp); - document.addEventListener('touchstart', handleDocumentDown); - document.addEventListener('touchmove', handleDocumentTouchMove); - document.addEventListener('touchend', handleDocumentUp); +export function enableEraser() { + document.addEventListener('pointermove', handleDocumentMouseMove); + document.addEventListener('pointerdown', handleDocumentDown); + document.addEventListener('pointerup', handleDocumentUp); } -export function disableEraser(){ - document.removeEventListener('mousemove', handleDocumentMouseMove); - document.removeEventListener('mousedown', handleDocumentDown); - document.removeEventListener('mouseup', handleDocumentUp); - document.removeEventListener('touchstart', handleDocumentDown); - document.removeEventListener('touchmove', handleDocumentTouchMove); - document.removeEventListener('touchend', handleDocumentUp); -} \ No newline at end of file +export function disableEraser() { + document.removeEventListener('pointermove', handleDocumentMouseMove); + document.removeEventListener('pointerdown', handleDocumentDown); + document.removeEventListener('pointerup', handleDocumentUp); +} diff --git a/src/UI/event.js b/src/UI/event.js index 5fa7f8be..0ebab5ce 100644 --- a/src/UI/event.js +++ b/src/UI/event.js @@ -4,7 +4,7 @@ import { findSVGAtPoint } from './utils'; -const emitter = new EventEmitter; +const emitter = new EventEmitter(); let clickNode; @@ -14,7 +14,9 @@ let clickNode; * @param {Event} e The DOM event to be handled */ document.addEventListener('click', function handleDocumentClick(e) { - if (!findSVGAtPoint(e.clientX, e.clientY)) { return; } + if (!findSVGAtPoint(e.clientX, e.clientY)) { + return; + } let target = findAnnotationAtPoint(e.clientX, e.clientY); diff --git a/src/UI/index.js b/src/UI/index.js index acf0d749..2795e1c1 100644 --- a/src/UI/index.js +++ b/src/UI/index.js @@ -1,8 +1,8 @@ import { addEventListener, removeEventListener, fireEvent } from './event'; import { disableEdit, enableEdit } from './edit'; import { disablePen, enablePen, setPen } from './pen'; -import { enableEraser, disableEraser } from './eraser'; import { disableArrow, enableArrow, setArrow } from './arrow'; +import { disableEraser, enableEraser } from './eraser'; import { disablePoint, enablePoint } from './point'; import { disableRect, enableRect } from './rect'; import { disableCircle, enableCircle, setCircle, addCircle } from './circle'; @@ -10,14 +10,39 @@ import { disableText, enableText, setText } from './text'; import { createPage, renderPage } from './page'; export default { - addEventListener, removeEventListener, fireEvent, - disableEdit, enableEdit, - disablePen, enablePen, setPen, - enableEraser, disableEraser, - disablePoint, enablePoint, - disableRect, enableRect, - disableCircle, enableCircle, setCircle, addCircle, - disableArrow, enableArrow, setArrow, - disableText, enableText, setText, - createPage, renderPage + addEventListener, + removeEventListener, + fireEvent, + + disableEdit, + enableEdit, + + disablePen, + enablePen, + setPen, + + disablePoint, + enablePoint, + + disableRect, + enableRect, + + disableCircle, + enableCircle, + setCircle, + addCircle, + + disableArrow, + enableArrow, + setArrow, + + disableEraser, + enableEraser, + + disableText, + enableText, + setText, + + createPage, + renderPage }; diff --git a/src/UI/page.js b/src/UI/page.js index 0a54b4e0..717c0d0d 100644 --- a/src/UI/page.js +++ b/src/UI/page.js @@ -48,7 +48,6 @@ export function createPage(pageNumber) { export function renderPage(pageNumber, renderOptions) { let { documentId, - userId, pdfDocument, scale, rotate @@ -57,7 +56,7 @@ export function renderPage(pageNumber, renderOptions) { // Load the page and annotations return Promise.all([ pdfDocument.getPage(pageNumber), - PDFJSAnnotate.getAnnotations(documentId, userId, pageNumber) + PDFJSAnnotate.getAnnotations(documentId, pageNumber) ]).then(([pdfPage, annotations]) => { let page = document.getElementById(`pageContainer${pageNumber}`); let svg = page.querySelector(config.annotationClassQuery()); diff --git a/src/UI/pen.js b/src/UI/pen.js index dba0c7f3..789e917f 100644 --- a/src/UI/pen.js +++ b/src/UI/pen.js @@ -30,7 +30,7 @@ function handleDocumentPointerdown(e) { /** * Handle document.touchup or document.pointerup event * - * @param {Event} e The DOM event to be handled + * @param {TouchEvent} e The DOM event to be handled */ function handleDocumentPointerupChrome(e){ saveToStorage(e.changedTouches[0].clientX, e.changedTouches[0].clientY); @@ -40,18 +40,17 @@ function handleDocumentPointerup(e) { saveToStorage(e.clientX, e.clientY); } -function saveToStorage(x, y){ +function saveToStorage(x, y) { _candraw = false; let svg; if (lines.length > 1 && (svg = findSVGAtPoint(x, y))) { - let { documentId, userId, pageNumber } = getMetadata(svg); - PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, { - type: 'drawing', - width: _penSize, - color: _penColor, - lines - } - ).then((annotation) => { + let { documentId, pageNumber } = getMetadata(svg); + PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, { + type: 'drawing', + width: _penSize, + color: _penColor, + lines + }).then((annotation) => { if (path) { svg.removeChild(path); } @@ -64,30 +63,22 @@ function saveToStorage(x, y){ /** * Handle document.mousemove event * - * @param {Event} e The DOM event to be handled + * @param {PointerEvent} e The DOM event to be handled */ function handleDocumentPointermove(e) { - if(!e.srcElement.classList.contains('annotationLayer')){ + if (!e.srcElement.classList.contains('annotationLayer')) { return; } - if(_candraw){ + if (_candraw) { savePoint(e.clientX, e.clientY); } } -function handleDocumentPointermoveChrome(e){ - if(!e.srcElement.classList.contains('annotationLayer')){ - return; - } - if(_candraw){ - savePoint(e.changedTouches[0].clientX, e.changedTouches[0].clientY); - } -} - /** * Handle document.keyup event * - * @param {Event} e The DOM event to be handled + * @param {KeyboardEvent} e The DOM event to be handled + * } e The DOM event to be handled */ function handleDocumentKeyup(e) { // Cancel rect if Esc is pressed @@ -155,18 +146,10 @@ export function enablePen() { _enabled = true; // Chrome and Firefox has different behaviors with how pen works, so we need different events. - if (!isFirefox){ - document.addEventListener('touchstart', handleDocumentPointerdown); - document.addEventListener('touchmove', handleDocumentPointermoveChrome); - document.addEventListener('touchend', handleDocumentPointerupChrome); - document.addEventListener('mousedown', handleDocumentPointerdown); - document.addEventListener('mousemove', handleDocumentPointermove); - document.addEventListener('mouseup', handleDocumentPointerup); - } else { - document.addEventListener('pointerdown', handleDocumentPointerdown); - document.addEventListener('pointermove', handleDocumentPointermove); - document.addEventListener('pointerup', handleDocumentPointerup); - } + document.addEventListener('pointerdown', handleDocumentPointerdown); + document.addEventListener('pointermove', handleDocumentPointermove); + document.addEventListener('pointerup', handleDocumentPointerup); + document.addEventListener('keyup', handleDocumentKeyup); disableUserSelect(); } @@ -178,18 +161,10 @@ export function disablePen() { if (!_enabled) { return; } _enabled = false; - if (!isFirefox){ - document.removeEventListener('touchstart', handleDocumentPointerdown); - document.removeEventListener('touchmove', handleDocumentPointermoveChrome); - document.removeEventListener('touchend', handleDocumentPointerupChrome); - document.removeEventListener('mousedown', handleDocumentPointerdown); - document.removeEventListener('mousemove', handleDocumentPointermove); - document.removeEventListener('mouseup', handleDocumentPointerup); - } else { - document.removeEventListener('pointerdown', handleDocumentPointerdown); - document.removeEventListener('pointermove', handleDocumentPointermove); - document.removeEventListener('pointerup', handleDocumentPointerup); - } + document.removeEventListener('pointerdown', handleDocumentPointerdown); + document.removeEventListener('pointermove', handleDocumentPointermove); + document.removeEventListener('pointerup', handleDocumentPointerup); + document.removeEventListener('keyup', handleDocumentKeyup); enableUserSelect(); } diff --git a/src/UI/point.js b/src/UI/point.js index cde303f3..7a31336c 100644 --- a/src/UI/point.js +++ b/src/UI/point.js @@ -19,7 +19,7 @@ function handleDocumentMouseup(e) { if (input || !findSVGAtPoint(e.clientX, e.clientY)) { return } - + input = document.createElement('input'); input.setAttribute('id', 'pdf-annotate-point-input'); input.setAttribute('placeholder', 'Enter comment'); @@ -70,16 +70,15 @@ function savePoint() { } let rect = svg.getBoundingClientRect(); - let { documentId, userId, pageNumber } = getMetadata(svg); + let { documentId, pageNumber } = getMetadata(svg); let annotation = Object.assign({ - type: 'point' - }, scaleDown(svg, { - x: clientX - rect.left, - y: clientY - rect.top - }) - ); - - PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation) + type: 'point' + }, scaleDown(svg, { + x: clientX - rect.left, + y: clientY - rect.top + })); + + PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation) .then((annotation) => { PDFJSAnnotate.getStoreAdapter().addComment( documentId, diff --git a/src/UI/rect.js b/src/UI/rect.js index fa7c2af3..8910b635 100644 --- a/src/UI/rect.js +++ b/src/UI/rect.js @@ -195,10 +195,10 @@ function saveRect(type, rects, color) { annotation.height = rect.height; } - let { documentId, userId, pageNumber } = getMetadata(svg); + let { documentId, pageNumber } = getMetadata(svg); // Add the annotation - PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation) + PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation) .then((annotation) => { appendChild(svg, annotation); }); @@ -209,7 +209,7 @@ function saveRect(type, rects, color) { */ export function enableRect(type) { _type = type; - + if (_enabled) { return; } _enabled = true; diff --git a/src/UI/text.js b/src/UI/text.js index 0a295910..2c0c311e 100644 --- a/src/UI/text.js +++ b/src/UI/text.js @@ -21,7 +21,7 @@ function handleDocumentMouseup(e) { if (input || !findSVGAtPoint(e.clientX, e.clientY)) { return; } - if(!e.srcElement.classList.contains('annotationLayer')){ + if (!e.srcElement.classList.contains('annotationLayer')) { return; } input = document.createElement('input'); @@ -56,7 +56,8 @@ function handleInputBlur() { function handleInputKeyup(e) { if (e.keyCode === 27) { closeInput(); - } else if (e.keyCode === 13) { + } + else if (e.keyCode === 13) { saveText(); } } @@ -65,7 +66,8 @@ function handleInputKeyup(e) { * Save a text annotation from input */ function saveText() { - if (input.value.trim().length > 0) { + let value = (input.value) ? input.value.replace(/ +$/, '') : ''; + if (value.length > 0) { let clientX = parseInt(input.style.left, 10); let clientY = parseInt(input.style.top, 10); let svg = findSVGAtPoint(clientX, clientY); @@ -73,28 +75,28 @@ function saveText() { return; } let height = _textSize; - let { documentId, userId, pageNumber, viewport } = getMetadata(svg); + let { documentId, pageNumber, viewport } = getMetadata(svg); let scale = 1 / viewport.scale; let rect = svg.getBoundingClientRect(); let pt = convertToSvgPoint([ - clientX - rect.left, - clientY - rect.top + height], svg, viewport); + clientX - rect.left, + clientY - rect.top + height], svg, viewport); let annotation = { - type: 'textbox', - size: _textSize * scale, - color: _textColor, - content: input.value.trim(), - x: pt[0], - y: pt[1], - rotation: -viewport.rotation - } - - PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, userId, pageNumber, annotation) + type: 'textbox', + size: _textSize * scale, + color: _textColor, + content: input.value, + x: pt[0], + y: pt[1], + rotation: -viewport.rotation + }; + + PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation) .then((annotation) => { appendChild(svg, annotation); }); } - + closeInput(); } @@ -121,18 +123,18 @@ export function setText(textSize = 12, textColor = '000000') { _textColor = textColor; } - /** * Enable text behavior */ export function enableText() { - if (_enabled) { return; } + if (_enabled) { + return; + } _enabled = true; document.addEventListener('mouseup', handleDocumentMouseup); } - /** * Disable text behavior */ diff --git a/src/UI/utils.js b/src/UI/utils.js index fd59d3b2..fc40c757 100644 --- a/src/UI/utils.js +++ b/src/UI/utils.js @@ -1,11 +1,11 @@ import createStyleSheet from 'create-stylesheet'; import { getTranslation } from '../render/appendChild'; -import { - applyTransform, - applyInverseTransform, +import { + applyTransform, + applyInverseTransform, translate, rotate, - scale + scale } from '../utils/mathUtils'; @@ -65,7 +65,7 @@ export function findSVGAtPoint(x, y) { /** * Find an Element that represents an annotation at a given point. - * + * * IMPORTANT: Requires the annotation layer to be the top most element so * either use z-ordering or make it the leaf container. * @@ -76,7 +76,7 @@ export function findSVGAtPoint(x, y) { export function findAnnotationAtPoint(x, y) { let el = null; var candidate = document.elementFromPoint(x, y) - while (!el && candidate && candidate !== document) { + while (!el && candidate && candidate !== document) { let type = candidate.getAttribute('data-pdf-annotate-type'); if (type) { el = candidate; @@ -106,14 +106,24 @@ export function pointIntersectsRect(x, y, rect) { */ export function getOffsetAnnotationRect(el) { let rect = el.getBoundingClientRect(); + let { width, height } = rect; + let extraOffsetWidth = 0; + let extraOffsetHeight = 0; + if (['line', 'path'].indexOf(el.tagName.toLowerCase()) > -1 && el.getBBox) { + let bbox = el.getBBox(); + extraOffsetWidth = (rect.width - bbox.width) / 2; + extraOffsetHeight = (rect.height - bbox.height) / 2; + width = bbox.width; + height = bbox.height; + } let { offsetLeft, offsetTop } = getOffset(el); return { - top: rect.top - offsetTop, - left: rect.left - offsetLeft, - right: rect.right - offsetLeft, - bottom: rect.bottom - offsetTop, - width: rect.width, - height: rect.height + top: rect.top - offsetTop + extraOffsetHeight, + left: rect.left - offsetLeft + extraOffsetWidth, + bottom: rect.bottom - offsetTop - extraOffsetHeight, + right: rect.right - offsetLeft - extraOffsetWidth, + width: width, + height: height }; } @@ -264,7 +274,6 @@ export function enableUserSelect() { export function getMetadata(svg) { return { documentId: svg.getAttribute('data-pdf-annotate-document'), - userId: svg.getAttribute('data-pdf-annotate-user'), pageNumber: parseInt(svg.getAttribute('data-pdf-annotate-page'), 10), viewport: JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')) }; diff --git a/src/a11y/initEventHandlers.js b/src/a11y/initEventHandlers.js index b5d15127..f0243daa 100644 --- a/src/a11y/initEventHandlers.js +++ b/src/a11y/initEventHandlers.js @@ -9,11 +9,11 @@ import PDFJSAnnotate from '../PDFJSAnnotate'; * Initialize the event handlers for keeping screen reader hints synced with data */ export default function initEventHandlers() { - addEventListener('annotation:add', (documentId, userId, pageNumber, annotation) => { - reorderAnnotationsByType(documentId, userId, pageNumber, annotation.type); + addEventListener('annotation:add', (documentId, pageNumber, annotation) => { + reorderAnnotationsByType(documentId, pageNumber, annotation.type); }); - addEventListener('annotation:edit', (documentId, userId, annotationId, annotation) => { - reorderAnnotationsByType(documentId, userId, annotation.page, annotation.type); + addEventListener('annotation:edit', (documentId, annotationId, annotation) => { + reorderAnnotationsByType(documentId, annotation.page, annotation.type); }); addEventListener('annotation:delete', removeAnnotation); addEventListener('comment:add', insertComment); @@ -24,12 +24,11 @@ export default function initEventHandlers() { * Reorder the annotation numbers by annotation type * * @param {String} documentId The ID of the document - * @param {String} userId The ID of the user * @param {Number} pageNumber The page number of the annotations * @param {Strig} type The annotation type */ -function reorderAnnotationsByType(documentId, userId, pageNumber, type) { - PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, userId, pageNumber) +function reorderAnnotationsByType(documentId, pageNumber, type) { + PDFJSAnnotate.getStoreAdapter().getAnnotations(documentId, pageNumber) .then((annotations) => { return annotations.annotations.filter((a) => { return a.type === type; diff --git a/src/a11y/insertElementWithinChildren.js b/src/a11y/insertElementWithinChildren.js index ab440aeb..8684c3bd 100644 --- a/src/a11y/insertElementWithinChildren.js +++ b/src/a11y/insertElementWithinChildren.js @@ -29,7 +29,7 @@ export default function insertElementWithinChildren(el, x, y, pageNumber) { x = scaleUp(svg, {x}).x + rect.left; // Find the best node to insert before - for (let i=0, l=nodes.length; i { - let annotations = getAllAnnotations().filter((i) => { + let annotations = getAllAnnotations(documentId).filter((i) => { return i.page === pageNumber && i.class === 'Annotation'; }); resolve({ documentId, - userId, pageNumber, annotations }); }); - }, - - getAnnotation(documentId, annotationId) { - return Promise.resolve(getAnnotations(documentId, userId)[findAnnotation(documentId, userId, annotationId)]); - }, - - addAnnotation(documentId, userId, pageNumber, annotation) { - return new Promise((resolve, reject) => { - annotation.class = 'Annotation'; - annotation.uuid = uuid(); - annotation.page = pageNumber; - annotation.userId = userId; - - let annotations = getAnnotations(documentId, userId); - annotations.push(annotation); - updateAnnotations(documentId, userId, annotations); - - resolve(annotation); - }); - }, - - editAnnotation(documentId, userId, annotationId, annotation) { - return new Promise((resolve, reject) => { - let annotations = getAnnotations(documentId, userId); - annotations[findAnnotation(documentId, userId, annotationId)] = annotation; - updateAnnotations(documentId, userId, annotations); - - resolve(annotation); - }); - }, - - deleteAnnotation(documentId, userId, annotationId) { - return new Promise((resolve, reject) => { - let index = findAnnotation(documentId, userId, annotationId); - if (index > -1) { - let annotations = getAnnotations(documentId, userId); - annotations.splice(index, 1); - updateAnnotations(documentId, userId, annotations); - } - - resolve(true); - }); - }, - - getComments(documentId, userId, annotationId) { - return new Promise((resolve, reject) => { - resolve(getAnnotations(documentId, userId).filter((i) => { - return i.class === 'Comment' && i.annotation === annotationId; - })); - }); - }, - - addComment(documentId, userId, annotationId, content) { - return new Promise((resolve, reject) => { - let comment = { - class: 'Comment', - uuid: uuid(), - annotation: annotationId, - content: content - }; - - let annotations = getAnnotations(documentId, userId); - annotations.push(comment); - updateAnnotations(documentId, userId, annotations); - - resolve(comment); - }); - }, + } + }); - deleteComment(documentId, userId, commentId) { - return new Promise((resolve, reject) => { - getAnnotations(documentId, userId); - let index = -1; - let annotations = getAnnotations(documentId, userId); - for (let i=0, l=annotations.length; i { + return Promise.resolve(getAnnotations(documentId, this._userId)[findAnnotation(documentId, this._userId, annotationId)]); + }; + + this.addAnnotation = (documentId, pageNumber, annotation) => { + return new Promise((resolve, reject) => { + annotation.class = 'Annotation'; + annotation.uuid = uuid(); + annotation.page = pageNumber; + annotation.userId = this._userId; + + let annotations = getAnnotations(documentId, this._userId); + annotations.push(annotation); + updateAnnotations(documentId, this._userId, annotations); + + resolve(annotation); + }); + }; + + this.editAnnotation = (documentId, annotationId, annotation) => { + return new Promise((resolve, reject) => { + if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) { + reject('Non-matching userId'); + } + let annotations = getAnnotations(documentId, annotation.userId); + annotations[findAnnotation(documentId, annotation.userId, annotationId)] = annotation; + updateAnnotations(documentId, annotation.userId, annotations); + resolve(annotation); + }); + }; + + this.deleteAnnotation = (documentId, annotationId) => { + return new Promise((resolve, reject) => { + let annotation = getAllAnnotations(documentId).filter(i => i.uuid === annotationId)[0] || {}; + if (!annotation) { + return reject('Could not find annotation'); + } + else if (!this._globalEdit && annotation.userId && annotation.userId !== this._userId) { + return reject('Non-matching userId'); + } + let index = findAnnotation(documentId, annotation.userId, annotationId); + if (index > -1) { + let annotations = getAnnotations(documentId, annotation.userId); + annotations.splice(index, 1); + updateAnnotations(documentId, annotation.userId, annotations); + } + + resolve(true); + }); + }; + + this.getComments = (documentId, annotationId) => { + return new Promise((resolve, reject) => { + resolve(getAnnotations(documentId, this._userId).filter((i) => { + return i.class === 'Comment' && i.annotation === annotationId; + })); + }); + }; + + this.addComment = (documentId, annotationId, content) => { + return new Promise((resolve, reject) => { + let comment = { + class: 'Comment', + uuid: uuid(), + annotation: annotationId, + content: content, + userId: this._userId + }; + + let annotations = getAnnotations(documentId, this._userId); + annotations.push(comment); + updateAnnotations(documentId, this._userId, annotations); + + resolve(comment); + }); + }; + + this.deleteComment = (documentId, commentId) => { + return new Promise((resolve, reject) => { + let comment = getAllAnnotations(documentId).filter(i => i.uuid === commentId)[0] || {}; + if (!comment) { + return reject('Could not find annotation'); + } + else if (!this._globalEdit && comment.userId && comment.userId !== this._userId) { + return reject('Non-matching userId'); + } + let index = -1; + let annotations = getAnnotations(documentId, comment.userId); + for (let i = 0, l = annotations.length; i < l; i++) { + if (annotations[i].uuid === commentId) { + index = i; + break; } + } - if (index > -1) { - annotations.splice(index, 1); - updateAnnotations(documentId, userId, annotations); - } + if (index > -1) { + annotations.splice(index, 1); + updateAnnotations(documentId, comment.userId, annotations); + } - resolve(true); - }); - } - }); - this._userId = userId; + resolve(true); + }); + }; } - get userId(){ + + get userId() { return this._userId; } } -function getAllAnnotations(){ +function getAllAnnotations(documentId) { let all_annotations = []; - for(let i = 0 ; i < localStorage.length; i++){ - if(localStorage.key(i).includes('annotations')){ + let re = new RegExp(`${documentId}/(.*)/annotations`); + for (let i = 0; i < localStorage.length; i++) { + if (localStorage.key(i).search(re) > -1) { all_annotations.push(...JSON.parse(localStorage.getItem(localStorage.key(i)))); } } @@ -134,19 +153,19 @@ function updateAnnotations(documentId, userId, annotations) { localStorage.setItem(`${documentId}/${userId}/annotations`, JSON.stringify(annotations)); } /** - * + * * @param {String} documentId Document id of the annotation * @param {String} userId User id of the annotation * @param {String} annotationId The id of the annotation - * + * * This function finds all the annotation made by one user. - * + * * @return {int} The index of the annotation in localstorage */ function findAnnotation(documentId, userId, annotationId) { let index = -1; let annotations = getAnnotations(documentId, userId); - for (let i=0, l=annotations.length; i { // TODO may be best to have this happen on the server if (annotations.annotations) { @@ -59,12 +58,12 @@ export default class StoreAdapter { * @param {Object} annotation The definition for the new annotation * @return {Promise} */ - __addAnnotation(documentId, userId, pageNumber, annotation) { abstractFunction('addAnnotation'); } + __addAnnotation(documentId, pageNumber, annotation) { abstractFunction('addAnnotation'); } get addAnnotation() { return this.__addAnnotation; } set addAnnotation(fn) { - this.__addAnnotation = function addAnnotation(documentId, userId, pageNumber, annotation) { + this.__addAnnotation = function addAnnotation(documentId, pageNumber, annotation) { return fn(...arguments).then((annotation) => { - fireEvent('annotation:add', documentId, userId, pageNumber, annotation); + fireEvent('annotation:add', documentId, pageNumber, annotation); return annotation; }); }; @@ -99,10 +98,10 @@ export default class StoreAdapter { __deleteAnnotation(documentId, annotationId) { abstractFunction('deleteAnnotation'); } get deleteAnnotation() { return this.__deleteAnnotation; } set deleteAnnotation(fn) { - this.__deleteAnnotation = function deleteAnnotation(documentId, userId, annotationId) { + this.__deleteAnnotation = function deleteAnnotation(documentId, annotationId) { return fn(...arguments).then((success) => { if (success) { - fireEvent('annotation:delete', documentId, userId, annotationId); + fireEvent('annotation:delete', documentId, annotationId); } return success; }); diff --git a/src/render/appendChild.js b/src/render/appendChild.js index ba3c09f9..2e2271bb 100644 --- a/src/render/appendChild.js +++ b/src/render/appendChild.js @@ -55,7 +55,7 @@ function transform(node, viewport) { // Let SVG natively transform the element node.setAttribute('transform', `scale(${viewport.scale}) rotate(${viewport.rotation}) translate(${trans.x}, ${trans.y})`); - + // Manually adjust x/y for nested SVG nodes if (!isFirefox && node.nodeName.toLowerCase() === 'svg') { node.setAttribute('x', parseInt(node.getAttribute('x'), 10) * viewport.scale); @@ -67,7 +67,7 @@ function transform(node, viewport) { let height = parseInt(node.getAttribute('height'), 10); let path = node.querySelector('path'); let svg = path.parentNode; - + // Scale width/height [node, svg, path, node.querySelector('rect')].forEach((n) => { n.setAttribute('width', parseInt(n.getAttribute('width'), 10) * viewport.scale); @@ -76,8 +76,8 @@ function transform(node, viewport) { // Transform path but keep scale at 100% since it will be handled natively transform(path, objectAssign({}, viewport, { scale: 1 })); - - switch(viewport.rotation % 360) { + + switch (viewport.rotation % 360) { case 90: node.setAttribute('x', viewport.width - y - width); node.setAttribute('y', x); @@ -113,7 +113,7 @@ export function appendChild(svg, annotation, viewport) { if (!viewport) { viewport = JSON.parse(svg.getAttribute('data-pdf-annotate-viewport')); } - + let child; switch (annotation.type) { case 'area': @@ -147,10 +147,16 @@ export function appendChild(svg, annotation, viewport) { if (child) { // Set attributes child.setAttribute('data-pdf-annotate-id', annotation.uuid); - child.setAttribute('data-pdf-annotate-type', annotation.type); - child.setAttribute('data-pdf-annotate-userId', annotation.userId); child.setAttribute('aria-hidden', true); + // Dynamically set any other attributes associated with annotation that is not related to drawing it + Object.keys(annotation).filter((key) => { + return ['color', 'x', 'y', 'cx', 'cy', 'color', 'documentId', 'lines', 'page', + 'width', 'class', 'content', 'size', 'rotation', 'r'].indexOf(key) === -1 + }).forEach((key) => { + child.setAttribute(`data-pdf-annotate-${key}`, annotation[key]); + }); + svg.appendChild(transform(child, viewport)); } @@ -185,7 +191,7 @@ export default { * based on the rotation of the viewport. */ getTranslation, - + /** * Append an SVG child for an annotation */ @@ -193,6 +199,6 @@ export default { /** * Transform an existing SVG child - */ + */ transformChild } diff --git a/src/render/index.js b/src/render/index.js index 3262fb4d..530aa88d 100644 --- a/src/render/index.js +++ b/src/render/index.js @@ -23,14 +23,13 @@ export default function render(svg, viewport, data) { // If there's no data nothing can be done if (!data) { - svg.innerHTML = ''; + svg.innerHTML = ''; return resolve(svg); } svg.setAttribute('data-pdf-annotate-document', data.documentId); - svg.setAttribute('data-pdf-annotate-user', data.userId); svg.setAttribute('data-pdf-annotate-page', data.pageNumber); - + // Make sure annotations is an array if (!Array.isArray(data.annotations) || data.annotations.length === 0) { return resolve(svg); @@ -38,10 +37,11 @@ export default function render(svg, viewport, data) { // Append or transform annotation to svg data.annotations.forEach((a) => { - var node = svg.querySelector('[data-pdf-annotate-id="' + a.uuid + '"]'); + let node = svg.querySelector('[data-pdf-annotate-id="' + a.uuid + '"]'); if (node) { transformChild(svg, node, viewport); - } else { + } + else { appendChild(svg, a, viewport); } }); diff --git a/src/render/renderPath.js b/src/render/renderPath.js index 722f648b..7f3fa476 100644 --- a/src/render/renderPath.js +++ b/src/render/renderPath.js @@ -11,28 +11,30 @@ import normalizeColor from '../utils/normalizeColor'; export default function renderPath(a) { let d = []; let path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - - - for (let i=0, l=a.lines.length; i 0) { + d.push(`M${a.lines[0][0]} ${a.lines[0][1]}`); + for (let i = 1, l = a.lines.length; i < l; i++) { + var p1 = a.lines[i]; + var p2 = a.lines[i+1]; + if (p2) { + d.push(`L${p1[0]} ${p1[1]}`); + } } } /* - + if(a.lines.length>2) { var p1 = a.lines[0]; var p2 = a.lines[a.lines.length-1]; - var p3 = []; //arrow + var p3 = []; //arrow var p4 = []; var p0 = []; //arrow intersection - + if (p2) { var k = -(p2[0]-p1[0])/(p2[1]-p1[1]); @@ -63,9 +65,9 @@ export default function renderPath(a) { d.push(`M${p4[0]} ${p4[1]} ${p2[0]} ${p2[1]}`); } }*/ - + setAttributes(path, { - d: `${d.join(' ')}Z`, + d: `${d.join(' ')}`,//`${d.join(' ')}Z`, stroke: normalizeColor(a.color || '#000'), strokeWidth: a.width || 1, fill: 'none' diff --git a/src/render/renderText.js b/src/render/renderText.js index 342c6794..afee7473 100644 --- a/src/render/renderText.js +++ b/src/render/renderText.js @@ -13,15 +13,12 @@ export default function renderText(a) { // Text should be rendered at 0 degrees relative to // document rotation let text = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - let x = a.x; - let y = a.y; - setAttributes(text, { - x: x, - y: y, + x: a.x, + y: a.y, fill: normalizeColor(a.color || '#000'), fontSize: a.size, - transform: `rotate(${a.rotation}, ${x}, ${y})` + transform: `rotate(${a.rotation})` }); text.innerHTML = a.content; diff --git a/test/UI/edit.spec.js b/test/UI/edit.spec.js index 9692bd3c..212ad7a2 100644 --- a/test/UI/edit.spec.js +++ b/test/UI/edit.spec.js @@ -1,7 +1,7 @@ -import { equal } from 'assert'; -import simulant from 'simulant'; +import { strictEqual, equal } from 'assert'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; import { enableEdit, disableEdit, destroyEditOverlay } from '../../src/UI/edit'; +import { fireMouseEvent, fireKeyboardEvent } from '../fireEvent'; import mockEditAnnotation from '../mockEditAnnotation'; import mockDeleteAnnotation from '../mockDeleteAnnotation'; import mockSVGContainer from '../mockSVGContainer'; @@ -27,15 +27,15 @@ function findOverlay() { } function simulateMoveOverlay(callback) { - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); - setTimeout(function () { + fireMouseEvent(document, 'click', {clientX: 20, clientY: 18}); + setTimeout(function() { let overlay = findOverlay(); - simulant.fire(overlay, 'mousedown', { clientX: 25, clientY: 25 }); - setTimeout(function () { - simulant.fire(overlay, 'mousemove', { clientX: 50, clientY: 50 }); - setTimeout(function () { - simulant.fire(overlay, 'mouseup', { clientX: 50, clientY: 50 }); - setTimeout(function () { + fireMouseEvent(overlay, 'mousedown', {clientX: 20, clientY: 18}); + setTimeout(function() { + fireMouseEvent(overlay, 'mousemove', { clientX: 50, clientY: 50 }); + setTimeout(function() { + fireMouseEvent(overlay, 'mouseup', { clientX: 50, clientY: 50 }); + setTimeout(function() { let call = editAnnotationSpy.getCall(0); callback(call ? call.args : []); }); @@ -45,7 +45,7 @@ function simulateMoveOverlay(callback) { } function simulateClickAnnotation(callback) { - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); + fireMouseEvent(document, 'click', { clientX: 25, clientY: 25 }); setTimeout(function () { let overlay = findOverlay(); callback(overlay); @@ -96,7 +96,7 @@ describe('UI::edit', function () { enableEdit(); disableEdit(); svg.appendChild(text); - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); + fireMouseEvent(document, 'click', { clientX: 25, clientY: 25 }); setTimeout(function () { equal(findOverlay(), null); @@ -107,8 +107,7 @@ describe('UI::edit', function () { it('should create an overlay when annotation is clicked', function (done) { enableEdit(); svg.appendChild(text); - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); - + fireMouseEvent(document, 'click', { clientX: 25, clientY: 10 }); setTimeout(function () { let overlay = findOverlay(); equal(overlay.nodeName, 'DIV'); @@ -120,11 +119,11 @@ describe('UI::edit', function () { it('should destroy overlay when document is clicked', function (done) { enableEdit(); svg.appendChild(text); - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); + fireMouseEvent(document, 'click', { clientX: 25, clientY: 10 }); setTimeout(function () { equal(findOverlay().nodeName, 'DIV'); - simulant.fire(document, 'click', { clientX: 10, clientY: 10 }); + fireMouseEvent(document, 'click', { clientX: 10, clientY: 10 }); setTimeout(function () { equal(findOverlay(), null); @@ -136,14 +135,31 @@ describe('UI::edit', function () { it('should delete annotation when DELETE is pressed', function (done) { enableEdit(); svg.appendChild(text); - simulant.fire(document, 'click', { clientX: 25, clientY: 25 }); + fireMouseEvent(document, 'click', { clientX: 25, clientY: 10 }); setTimeout(function () { - simulant.fire(document, 'keyup', { keyCode: 46 }); + fireKeyboardEvent(document, 'keyup', { key: 'Delete' }); setTimeout(function () { + strictEqual(deleteAnnotationSpy.called, true); + let args = deleteAnnotationSpy.getCall(0).args; + equal(args[0], 'test-document-id'); + equal(args[1], text.getAttribute('data-pdf-annotate-id')); + done(); + }); + }); + }); + + it('should delete annotation when BACKSPACE is pressed', function (done) { + enableEdit(); + svg.appendChild(text); + fireMouseEvent(document, 'click', { clientX: 25, clientY: 10 }); + setTimeout(function() { + fireKeyboardEvent(document, 'keyup', { key: 'Backspace' }); + + setTimeout(function() { + strictEqual(deleteAnnotationSpy.called, true); let args = deleteAnnotationSpy.getCall(0).args; - equal(deleteAnnotationSpy.called, true); equal(args[0], 'test-document-id'); equal(args[1], text.getAttribute('data-pdf-annotate-id')); done(); @@ -162,7 +178,7 @@ describe('UI::edit', function () { done(); }); }); - + it('should edit rect annotation when overlay moved', function (done) { enableEdit(); svg.appendChild(rect); @@ -188,10 +204,7 @@ describe('UI::edit', function () { enableEdit(); svg.appendChild(path); simulateMoveOverlay(function (args) { - equal(editAnnotationSpy.called, true); - equal(args[0], 'test-document-id'); - equal(args[1], path.getAttribute('data-pdf-annotate-id')); - equal(args[2], DEFAULT_PATH_ANNOTATION); + equal(editAnnotationSpy.called, false); done(); }); }); @@ -200,7 +213,7 @@ describe('UI::edit', function () { enableEdit(); svg.appendChild(rect); simulateClickAnnotation(function (overlay) { - simulant.fire(overlay, 'mouseover', { clientX: 30, clientY: 30 }); + fireMouseEvent(overlay, 'mouseover', { clientX: 30, clientY: 30 }); setTimeout(function () { let a = overlay.querySelector('a'); equal(a.style.display, ''); @@ -213,9 +226,9 @@ describe('UI::edit', function () { enableEdit(); svg.appendChild(rect); simulateClickAnnotation(function (overlay) { - simulant.fire(overlay, 'mouseover', { clientX: 30, clientY: 30 }); + fireMouseEvent(overlay, 'mouseover', { clientX: 30, clientY: 30 }); setTimeout(function () { - simulant.fire(overlay, 'mouseout', { clientX: 10, clientY: 10 }); + fireMouseEvent(overlay, 'mouseout', { clientX: 10, clientY: 10 }); setTimeout(function () { let a = overlay.querySelector('a'); equal(a.style.display, 'none'); diff --git a/test/UI/eraser.spec.js b/test/UI/eraser.spec.js new file mode 100644 index 00000000..be7c3416 --- /dev/null +++ b/test/UI/eraser.spec.js @@ -0,0 +1,91 @@ +import { equal } from 'assert'; +import PDFJSAnnotate from '../../src/PDFJSAnnotate'; +import { firePointerEvent } from '../fireEvent'; +import mockDeleteAnnotation from "../mockDeleteAnnotation"; +import mockGetAnnotations from "../mockGetAnnotations"; +import mockSVGContainer from '../mockSVGContainer'; +import mockTextAnnotation from '../mockTextAnnotation'; +import { enableEraser, disableEraser } from '../../src/UI/eraser'; + +let svg; +let text; +let deleteAnnotationSpy; +let __deleteAnnotation = PDFJSAnnotate.__storeAdapter.deleteAnnotation; +let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; + +function simulateEraserMovement() { + firePointerEvent(svg, 'pointerdown', { + clientX: 10, + clientY: 10, + pointerType: "mouse" + }); + + firePointerEvent(svg, 'pointermove', { + clientX: 25, + clientY: 15, + pointerType: "mouse" + }); + + firePointerEvent(svg, 'pointermove', { + clientX: 30, + clientY: 30, + pointerType: "mouse" + }); + + firePointerEvent(svg, 'pointerup', { + clientX: 30, + clientY: 30, + pointerType: "mouse" + }); +} + +describe('UI::eraser', function () { + beforeEach(function () { + svg = mockSVGContainer(); + svg.style.width = '100px'; + svg.style.height = '100px'; + document.body.appendChild(svg); + text = mockTextAnnotation(); + svg.appendChild(text); + + deleteAnnotationSpy = sinon.spy(); + PDFJSAnnotate.__storeAdapter.deleteAnnotation = mockDeleteAnnotation(deleteAnnotationSpy); + PDFJSAnnotate.__storeAdapter.getAnnotations = mockGetAnnotations(); + }); + + afterEach(function () { + if (svg.parentNode) { + svg.parentNode.removeChild(svg); + } + + disableEraser(); + }); + + after(function () { + PDFJSAnnotate.__storeAdapter.deleteAnnotation = __deleteAnnotation; + PDFJSAnnotate.__storeAdapter.getAnnotations = __getAnnotations; + }); + + it('should do nothing when disabled', function (done) { + enableEraser(); + disableEraser(); + simulateEraserMovement(); + setTimeout(function () { + equal(deleteAnnotationSpy.called, false); + done(); + }, 0); + }); + + it('should create an annotation when enabled', function (done) { + disableEraser(); + enableEraser(); + simulateEraserMovement(); + setTimeout(function () { + equal(deleteAnnotationSpy.called, true); + let args = deleteAnnotationSpy.getCall(0).args; + equal(args[0], 'test-document-id'); + equal(args[1], text.getAttribute('data-pdf-annotate-id')); + done(); + }, 0); + }); +}); diff --git a/test/UI/event.spec.js b/test/UI/event.spec.js index 8e0945af..d5997fd1 100644 --- a/test/UI/event.spec.js +++ b/test/UI/event.spec.js @@ -1,6 +1,6 @@ import { equal } from 'assert'; -import simulant from 'simulant'; import { addEventListener, removeEventListener } from '../../src/UI/event'; +import { fireMouseEvent } from '../fireEvent'; import mockSVGContainer from '../mockSVGContainer'; import mockTextAnnotation from '../mockTextAnnotation'; @@ -31,7 +31,7 @@ describe('UI::event', function () { afterEach(function () { // Blur to reset internal state of add/remove event - simulant.fire(svg, 'click', { + fireMouseEvent(svg, 'click', { clientX: rect.left + 1, clientY: rect.top + 1 }); @@ -46,29 +46,28 @@ describe('UI::event', function () { it('should emit an event when an annotation is clicked', function (done) { - simulant.fire(svg, 'click', { - clientX: text.getBoundingClientRect().left + 1, - clientY: text.getBoundingClientRect().top + 1 + fireMouseEvent(svg, 'click', { + clientX: text.getBoundingClientRect().left + 5, + clientY: text.getBoundingClientRect().top + 5 }); setTimeout(function () { equal(annotationClickSpy.calledOnce, true); - console.log(annotationClickSpy.getCall(0).args[0], text) equal(annotationClickSpy.getCall(0).args[0], text); done(); }, 0); }); it('should emit an event when an annotation is blurred', function (done) { - simulant.fire(svg, 'click', { - clientX: text.getBoundingClientRect().left + 1, - clientY: text.getBoundingClientRect().top + 1 + fireMouseEvent(svg, 'click', { + clientX: text.getBoundingClientRect().left + 5, + clientY: text.getBoundingClientRect().top + 5 }); setTimeout(function () { - simulant.fire(svg, 'click', { - clientX: rect.left + 1, - clientY: rect.top + 1 + fireMouseEvent(svg, 'click', { + clientX: rect.left + 5, + clientY: rect.top + 5 }); setTimeout(function () { @@ -82,7 +81,7 @@ describe('UI::event', function () { it('should allow removing an event listener', function (done) { removeEventListener('annotation:click', annotationClickSpy); - simulant.fire(svg, 'click', { + fireMouseEvent(svg, 'click', { clientX: rect.left + 15, clientY: rect.top + 15 }); diff --git a/test/UI/pen.spec.js b/test/UI/pen.spec.js index ab6537e6..5ccb00d8 100644 --- a/test/UI/pen.spec.js +++ b/test/UI/pen.spec.js @@ -1,36 +1,41 @@ import { equal } from 'assert'; -import simulant from 'simulant'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; +import { firePointerEvent } from '../fireEvent'; import mockAddAnnotation from '../mockAddAnnotation'; +import mockGetAnnotations from "../mockGetAnnotations"; import mockSVGContainer from '../mockSVGContainer'; import { setPen, enablePen, disablePen } from '../../src/UI/pen'; let svg; let addAnnotationSpy; let __addAnnotation = PDFJSAnnotate.__storeAdapter.addAnnotation; +let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; function simulateCreateDrawingAnnotation(penSize, penColor) { setPen(penSize, penColor); - let rect = svg.getBoundingClientRect(); - simulant.fire(document, 'mousedown', { - clientX: rect.left + 10, - clientY: rect.top + 10 + firePointerEvent(svg, 'pointerdown', { + clientX: 10, + clientY: 10, + pointerType: "mouse" }); - simulant.fire(document, 'mousemove', { - clientX: rect.left + 15, - clientY: rect.top + 15 + firePointerEvent(svg, 'pointermove', { + clientX: 15, + clientY: 15, + pointerType: "mouse" }); - simulant.fire(document, 'mousemove', { - clientX: rect.left + 30, - clientY: rect.top + 30 + firePointerEvent(svg, 'pointermove', { + clientX: 30, + clientY: 30, + pointerType: "mouse" }); - simulant.fire(document, 'mouseup', { - clientX: rect.left + 30, - clientY: rect.top + 30 + firePointerEvent(svg, 'pointerup', { + clientX: 30, + clientY: 30, + pointerType: "mouse" }); } @@ -43,18 +48,20 @@ describe('UI::pen', function () { addAnnotationSpy = sinon.spy(); PDFJSAnnotate.__storeAdapter.addAnnotation = mockAddAnnotation(addAnnotationSpy); + PDFJSAnnotate.__storeAdapter.getAnnotations = mockGetAnnotations(); }); afterEach(function () { if (svg.parentNode) { svg.parentNode.removeChild(svg); } - + disablePen(); }); after(function () { PDFJSAnnotate.__storeAdapter.addAnnotation = __addAnnotation; + PDFJSAnnotate.__storeAdapter.getAnnotations = __getAnnotations; }); it('should do nothing when disabled', function (done) { @@ -72,8 +79,8 @@ describe('UI::pen', function () { enablePen(); simulateCreateDrawingAnnotation(); setTimeout(function () { - let args = addAnnotationSpy.getCall(0).args; equal(addAnnotationSpy.called, true); + let args = addAnnotationSpy.getCall(0).args; equal(args[0], 'test-document-id'); equal(args[1], '1'); equal(args[2].type, 'drawing'); diff --git a/test/UI/point.spec.js b/test/UI/point.spec.js index df5ba35c..ed6793d7 100644 --- a/test/UI/point.spec.js +++ b/test/UI/point.spec.js @@ -1,8 +1,9 @@ import { equal } from 'assert'; -import simulant from 'simulant'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; import { enablePoint, disablePoint } from '../../src/UI/point'; +import { fireMouseEvent, fireFocusEvent } from '../fireEvent'; import mockAddAnnotation from '../mockAddAnnotation'; +import mockGetAnnotations from '../mockGetAnnotations'; import mockAddComment from '../mockAddComment'; import mockSVGContainer from '../mockSVGContainer'; @@ -12,12 +13,11 @@ let addCommentSpy; let __addComment = PDFJSAnnotate.__storeAdapter.addComment; let __getComments = PDFJSAnnotate.__storeAdapter.getComments; let __addAnnotation = PDFJSAnnotate.__storeAdapter.addAnnotation; -let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations +let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; function simulateCreatePointAnnotation(textContent) { let rect = svg.getBoundingClientRect(); - simulant.fire(svg, 'mouseup', { - target: svg, + fireMouseEvent(svg, 'mouseup', { clientX: rect.left + 10, clientY: rect.top + 10 }); @@ -27,7 +27,7 @@ function simulateCreatePointAnnotation(textContent) { if (input) { input.focus(); input.value = textContent; - simulant.fire(input, 'blur'); + fireFocusEvent(input, 'blur'); } }); } @@ -44,15 +44,9 @@ describe('UI::point', function () { PDFJSAnnotate.__storeAdapter.addComment = mockAddComment(addCommentSpy); PDFJSAnnotate.__storeAdapter.getComments = () => { return Promise.resolve([]); - } + }; PDFJSAnnotate.__storeAdapter.addAnnotation = mockAddAnnotation(addAnnotationSpy); - PDFJSAnnotate.__storeAdapter.getAnnotations = (documentId, pageNumber) => { - return Promise.resolve({ - documentId, - pageNumber, - annotations: [] - }); - } + PDFJSAnnotate.__storeAdapter.getAnnotations = mockGetAnnotations(); }); afterEach(function () { @@ -104,9 +98,8 @@ describe('UI::point', function () { equal(addCommentArgs[0], 'test-document-id'); equal(addCommentArgs[1], addAnnotationArgs[2].uuid); equal(addCommentArgs[2], 'foo bar baz'); - + done(); }); }); - }); diff --git a/test/UI/rect.spec.js b/test/UI/rect.spec.js index 2a2755e9..4e053257 100644 --- a/test/UI/rect.spec.js +++ b/test/UI/rect.spec.js @@ -1,29 +1,32 @@ import { equal } from 'assert'; -import simulant from 'simulant'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; import { enableRect, disableRect } from '../../src/UI/rect'; +import { fireMouseEvent } from '../fireEvent'; import mockAddAnnotation from '../mockAddAnnotation'; import mockSVGContainer from '../mockSVGContainer'; +import mockGetAnnotations from "../mockGetAnnotations"; let svg; let div; let addAnnotationSpy; let __addAnnotation = PDFJSAnnotate.__storeAdapter.addAnnotation; +let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; + const ALPHABET = 'abcdefghijklmnopqrstuvwxyz'; function simulateCreateRectAnnotation(type) { let rect = svg.getBoundingClientRect(); - simulant.fire(svg, 'mousedown', { + fireMouseEvent(svg, 'mousedown', { clientX: rect.left + 10, clientY: rect.top + 10 }); - simulant.fire(svg, 'mousemove', { + fireMouseEvent(svg, 'mousemove', { clientX: rect.left + 50, clientY: rect.top + 50 }); - simulant.fire(svg, 'mouseup', { + fireMouseEvent(svg, 'mouseup', { clientX: rect.left + 50, clientY: rect.top + 50 }); @@ -52,6 +55,7 @@ describe('UI::rect', function () { addAnnotationSpy = sinon.spy(); PDFJSAnnotate.__storeAdapter.addAnnotation = mockAddAnnotation(addAnnotationSpy); + PDFJSAnnotate.__storeAdapter.getAnnotations = mockGetAnnotations(); }); afterEach(function () { @@ -68,6 +72,7 @@ describe('UI::rect', function () { after(function () { PDFJSAnnotate.__storeAdapter.addAnnotation = __addAnnotation; + PDFJSAnnotate.__storeAdapter.getAnnotations = __getAnnotations; }); it('should do nothing when disabled', function (done) { @@ -79,7 +84,7 @@ describe('UI::rect', function () { done(); }, 0); }); - + it('should create an area annotation when enabled', function (done) { disableRect(); enableRect('area'); diff --git a/test/UI/text.spec.js b/test/UI/text.spec.js index a372c880..77d6664a 100644 --- a/test/UI/text.spec.js +++ b/test/UI/text.spec.js @@ -1,20 +1,21 @@ import { equal } from 'assert'; -import simulant from 'simulant'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; import { setText, enableText, disableText } from '../../src/UI/text'; +import { fireMouseEvent, fireFocusEvent } from '../fireEvent'; import mockAddAnnotation from '../mockAddAnnotation'; import mockSVGContainer from '../mockSVGContainer'; +import mockGetAnnotations from "../mockGetAnnotations"; let svg; let addAnnotationSpy; let __addAnnotation = PDFJSAnnotate.__storeAdapter.addAnnotation; +let __getAnnotations = PDFJSAnnotate.__storeAdapter.getAnnotations; function simulateCreateTextAnnotation(textContent, textSize, textColor) { setText(textSize, textColor); let rect = svg.getBoundingClientRect(); - simulant.fire(svg, 'mouseup', { - target: svg, + fireMouseEvent(svg, 'mouseup', { clientX: rect.left + 10, clientY: rect.top + 10 }); @@ -24,7 +25,7 @@ function simulateCreateTextAnnotation(textContent, textSize, textColor) { if (input) { input.focus(); input.value = textContent; - simulant.fire(input, 'blur'); + fireFocusEvent(input, 'blur'); } }, 0); } @@ -38,6 +39,7 @@ describe('UI::text', function () { addAnnotationSpy = sinon.spy(); PDFJSAnnotate.__storeAdapter.addAnnotation = mockAddAnnotation(addAnnotationSpy); + PDFJSAnnotate.__storeAdapter.getAnnotations = mockGetAnnotations(); }); afterEach(function () { @@ -55,6 +57,7 @@ describe('UI::text', function () { after(function () { PDFJSAnnotate.__storeAdapter.addAnnotation = __addAnnotation; + PDFJSAnnotate.__storeAdapter.getAnnotations = __getAnnotations; }); it('should do nothing when disabled', function (done) { diff --git a/test/UI/utils.spec.js b/test/UI/utils.spec.js index 1afd4c2c..8bc1841c 100644 --- a/test/UI/utils.spec.js +++ b/test/UI/utils.spec.js @@ -89,15 +89,10 @@ describe('UI::utils', function () { svg.appendChild(textSvgGroup); document.body.appendChild(svg); - let rect = svg.getBoundingClientRect(); let textRect = text.getBoundingClientRect(); - let textW = textRect.width; - let textH = textRect.height; - let textX = parseInt(text.getAttribute('x'), 10); - let textY = parseInt(text.getAttribute('y'), 10); - equal(findAnnotationAtPoint(textRect.left + 1, textRect.top + 1), text); - equal(findAnnotationAtPoint(textRect.right + 1, textRect.bottom + 1), null); + equal(findAnnotationAtPoint(textRect.left + 5, textRect.top + 5), text); + equal(findAnnotationAtPoint(textRect.right + 5, textRect.bottom + 5), null); }); it('should detect if a rect collides with points', function () { @@ -130,7 +125,7 @@ describe('UI::utils', function () { equal(pointIntersectsRect(20, 20, rect), true); }); - describe('getAnnotationRect', function () { + describe('getOffsetAnnotationRect', function () { it('should get the size of a line', function () { document.body.appendChild(svg); let line = renderLine({ @@ -151,13 +146,13 @@ describe('UI::utils', function () { let y1 = parseInt(line.children[0].getAttribute('y1'), 10); let y2 = parseInt(line.children[0].getAttribute('y2'), 10); - deepEqual(getAnnotationRect(line.children[0]), { + deepEqual(getOffsetAnnotationRect(line.children[0]), { width: x2 - x1, - height: (y2 - y1) + 16, + height: (y2 - y1), left: x1, - top: y1 - (16 / 2), + top: y1, right: x1 + (x2 - x1), - bottom: y1 - (16 / 2) + (y2 - y1) + 16 + bottom: y1 + (y2 - y1) }); }); @@ -251,7 +246,7 @@ describe('UI::utils', function () { let path = createPath(); svg.appendChild(path); - let size = getAnnotationRect(path); + let size = getOffsetAnnotationRect(path); equal(size.left, 33); equal(size.top, 36); diff --git a/test/a11y/insertElementWithinChildren.spec.js b/test/a11y/insertElementWithinChildren.spec.js index 47044fab..18c9d7ce 100644 --- a/test/a11y/insertElementWithinChildren.spec.js +++ b/test/a11y/insertElementWithinChildren.spec.js @@ -1,6 +1,7 @@ import insertElementWithinChildren from '../../src/a11y/insertElementWithinChildren'; import mockPageWithTextLayer, { CHAR_WIDTH } from '../mockPageWithTextLayer'; -import { equal } from 'assert'; +import checkCIEnvironment from '../checkCIEnvironment'; +import { strictEqual } from 'assert'; function createElement(content) { let el = document.createElement('div'); @@ -27,7 +28,7 @@ describe('a11y::insertElementWithinChildren', function () { it('should insert element', function () { let el = createElement(); let result = insertElementWithinChildren(el, rect.left, rect.top, 1); - equal(result, true); + strictEqual(result, true); }); it('should insert an element at the proper point', function () { @@ -35,15 +36,15 @@ describe('a11y::insertElementWithinChildren', function () { let textLayer = page.querySelector('.textLayer'); insertElementWithinChildren(el, rect.left, rect.top, 1); let node = textLayer.children[0]; - equal(node.innerHTML, 'hello'); + strictEqual(node.innerHTML, 'hello'); }); it('should insert within an element if needed', function () { let el = createElement('hello'); let textLayer = page.querySelector('.textLayer'); - insertElementWithinChildren(el, rect.left + 10 + (CHAR_WIDTH * (process.env.CI === 'true' ? 6 : 5)), rect.top + 15, 1); + insertElementWithinChildren(el, rect.left + 10 + (CHAR_WIDTH * (checkCIEnvironment() ? 6 : 5)), rect.top + 15, 1); let node = textLayer.children[0]; - equal(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); + strictEqual(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); }); it('should insert at the bottom if all else fails', function () { @@ -51,13 +52,13 @@ describe('a11y::insertElementWithinChildren', function () { let textLayer = page.querySelector('.textLayer'); let result = insertElementWithinChildren(el, rect.right, rect.bottom, 1); let node = textLayer.children[textLayer.children.length - 1]; - equal(result, true); - equal(node.innerHTML, 'hello'); + strictEqual(result, true); + strictEqual(node.innerHTML, 'hello'); }); it('should fail if outside the box', function () { let el = createElement(); let result = insertElementWithinChildren(el, rect.right + 5, rect.bottom + 5, 1); - equal(result, false); + strictEqual(result, false); }); }); diff --git a/test/a11y/insertElementWithinElement.spec.js b/test/a11y/insertElementWithinElement.spec.js index 3e08cee2..ac8c732a 100644 --- a/test/a11y/insertElementWithinElement.spec.js +++ b/test/a11y/insertElementWithinElement.spec.js @@ -1,6 +1,7 @@ import insertElementWithinElement from '../../src/a11y/insertElementWithinElement'; import mockPageWithTextLayer, { CHAR_WIDTH } from '../mockPageWithTextLayer'; -import { equal } from 'assert'; +import checkCIEnvironment from '../checkCIEnvironment'; +import { strictEqual } from 'assert'; function createElement(content) { let el = document.createElement('div'); @@ -27,21 +28,21 @@ describe('a11y::insertElementWithinElement', function () { it('should insert an element within another element', function () { let el = createElement(); let result = insertElementWithinElement(el, rect.left + 10 + (CHAR_WIDTH * 5), rect.top + 15, 1); - equal(result, true); + strictEqual(result, true); }); it('should not insert if no element can be found', function () { let el = createElement(); let result = insertElementWithinElement(el, rect.left, rect.top + 25, 1); - equal(result, false); + strictEqual(result, false); }); it('should insert an element at the proper point', function () { let el = createElement('hello'); let textLayer = page.querySelector('.textLayer'); - insertElementWithinElement(el, rect.left + 10 + (CHAR_WIDTH * (process.env.CI === 'true' ? 6 : 5)), rect.top + 15, 1); + insertElementWithinElement(el, rect.left + 10 + (CHAR_WIDTH * (checkCIEnvironment() ? 6 : 5)), rect.top + 15, 1); let node = textLayer.children[0]; - equal(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); + strictEqual(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); }); it('should not insert within a nested element', function () { @@ -49,7 +50,7 @@ describe('a11y::insertElementWithinElement', function () { let textLayer = page.querySelector('.textLayer'); let node = textLayer.children[0]; node.innerHTML = node.innerHTML.replace('ef', 'ef'); - insertElementWithinElement(el, rect.left + 10 + (CHAR_WIDTH * (process.env.CI === 'true' ? 6 : 5)), rect.top + 15, 1); - equal(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); + insertElementWithinElement(el, rect.left + 10 + (CHAR_WIDTH * (checkCIEnvironment() ? 6 : 5)), rect.top + 15, 1); + strictEqual(node.innerHTML, 'abcde
hello
fghijklmnopqrstuvwxyz'); }); }); diff --git a/test/a11y/renderScreenReaderHints.spec.js b/test/a11y/renderScreenReaderHints.spec.js index 90d35236..cd9f08c0 100644 --- a/test/a11y/renderScreenReaderHints.spec.js +++ b/test/a11y/renderScreenReaderHints.spec.js @@ -1,11 +1,12 @@ import renderScreenReaderHints from '../../src/a11y/renderScreenReaderHints'; import mockPageWithTextLayer, { CHAR_WIDTH } from '../mockPageWithTextLayer'; import PDFJSAnnotate from '../../src/PDFJSAnnotate'; +import checkCIEnvironment from '../checkCIEnvironment'; import { equal } from 'assert'; const SR_STYLE = 'position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden;'; function mockHint(id, content) { - return `
${content}
`; + return `
${content}
`; } let page; @@ -76,7 +77,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(target.innerHTML, result); }); - + it('should render strikeout', function () { renderScreenReaderHints([{ type: 'strikeout', @@ -85,11 +86,11 @@ describe('a11y::renderScreenReaderHints', function () { rectangles: [{ height: 10, width: 50, - x: (process.env.CI === 'true' ? 60 : 50), + x: (checkCIEnvironment() ? 60 : 50), y: 10 }] }]); - + let target = textLayer.children[0]; let begin = mockHint(12345, 'Begin strikeout annotation 1'); let end = mockHint('12345-end', 'End strikeout annotation 1'); @@ -97,7 +98,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(target.innerHTML, result); }); - + it('should render drawing', function () { renderScreenReaderHints([{ type: 'drawing', @@ -110,7 +111,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(target.innerHTML, 'Unlabeled drawing'); }); - + it('should render area', function () { renderScreenReaderHints([{ type: 'area', @@ -125,7 +126,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(target.innerHTML, 'Unlabeled drawing'); }); - + it('should render textbox', function () { renderScreenReaderHints([{ type: 'textbox', @@ -142,7 +143,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(target.innerHTML, 'textbox annotation 1 (content: hello)'); }); - + it('should render point', function () { renderScreenReaderHints([{ type: 'point', @@ -180,7 +181,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(textLayer.children[0].getAttribute('id'), 'pdf-annotate-screenreader-67890'); equal(textLayer.children[1].getAttribute('id'), 'pdf-annotate-screenreader-12345'); }); - + it('should sort by rect point', function () { renderScreenReaderHints([{ type: 'highlight', @@ -209,7 +210,7 @@ describe('a11y::renderScreenReaderHints', function () { equal(children[0].getAttribute('id'), 'pdf-annotate-screenreader-67890'); equal(children[2].getAttribute('id'), 'pdf-annotate-screenreader-12345'); }); - + it('should sort by line point', function () { renderScreenReaderHints([{ type: 'drawing', @@ -226,5 +227,5 @@ describe('a11y::renderScreenReaderHints', function () { equal(textLayer.children[0].getAttribute('id'), 'pdf-annotate-screenreader-67890'); equal(textLayer.children[1].getAttribute('id'), 'pdf-annotate-screenreader-12345'); }); - }); + }); }); diff --git a/test/adapter/StoreAdapter.spec.js b/test/adapter/StoreAdapter.spec.js index 4785d7d8..a1300808 100644 --- a/test/adapter/StoreAdapter.spec.js +++ b/test/adapter/StoreAdapter.spec.js @@ -27,15 +27,15 @@ describe('StoreAdapter', function () { it('should error by default when calling getAnnotations', testExpectedError(function () { adapter.getAnnotations(); })); - + it('should error by default when calling getAnnotation', testExpectedError(function () { adapter.getAnnotation(); })); - + it('should error by default when calling addAnnotation', testExpectedError(function () { adapter.addAnnotation(); })); - + it('should error by default when calling editAnnotation', testExpectedError(function () { adapter.editAnnotation(); })); @@ -86,7 +86,7 @@ describe('StoreAdapter', function () { done(); }); }); - + it('should emit annotation:edit', function (done) { addEventListener('annotation:edit', handleAnnotationEdit); adapter.editAnnotation(12345, 67890, {type: 'bar'}); @@ -96,7 +96,7 @@ describe('StoreAdapter', function () { done(); }); }); - + it('should emit annotation:delete', function (done) { addEventListener('annotation:delete', handleAnnotationDelete); adapter.deleteAnnotation(12345, 67890); diff --git a/test/checkCIEnvironment.js b/test/checkCIEnvironment.js new file mode 100644 index 00000000..adb57cd5 --- /dev/null +++ b/test/checkCIEnvironment.js @@ -0,0 +1,12 @@ +/** + * Utility function to check what environment we're using, mainly + * focusing around CI and Firefox. For whateve reason, the Firefox + * on CI ends up with slightly different margins on things compared + * to Chrome or things on local machine. Use this function to handle + * adding a switch around using a set of values specifically for that. + * + * @returns {boolean} True if using CI and Firefox, else False + */ +export default () => { + return (process.env.CI === 'true' || process.env.CI === true) && navigator && /firefox/i.test(navigator.userAgent); +}; diff --git a/test/fireEvent.js b/test/fireEvent.js new file mode 100644 index 00000000..d993e620 --- /dev/null +++ b/test/fireEvent.js @@ -0,0 +1,34 @@ +/** + * Fires an event to the passed in target, adding in some defuault options. + * + * @param {Element|Node} target DOM element to dispatch event to + * @param {Event} Event Event to fire against the target + * @param {String} eventType String representing type of given Event that should fire + * @param {Object} options Options to use for the Event + * @returns {boolean} Returns false if event was cancelable and at least one event + * handler prevented the default, else return true. + */ +function fireEvent(target, Event, eventType, options) { + options = options || {}; + return target.dispatchEvent(new Event(eventType, Object.assign(options, { + cancelable: true, + bubbles: true, + target: target + }))); +} + +export function fireMouseEvent(target, eventType, options) { + return fireEvent(target, MouseEvent, eventType, options); +}; + +export function fireFocusEvent(target, eventType, options) { + return fireEvent(target, FocusEvent, eventType, options); +}; + +export function firePointerEvent(target, eventType, options) { + return fireEvent(target, PointerEvent, eventType, options); +}; + +export function fireKeyboardEvent(target, eventType, options) { + return fireEvent(target, KeyboardEvent, eventType, options); +}; diff --git a/test/mockAddAnnotation.js b/test/mockAddAnnotation.js index a7a6319b..1708a930 100644 --- a/test/mockAddAnnotation.js +++ b/test/mockAddAnnotation.js @@ -3,11 +3,11 @@ import uuid from '../src/utils/uuid'; export default (spy) => { return function (documentId, pageNumber, annotation) { spy(documentId, pageNumber, annotation); - + annotation.class = 'Annotation'; annotation.uuid = uuid(); annotation.page = pageNumber; return Promise.resolve(annotation); }; -} +}; diff --git a/test/mockAddComment.js b/test/mockAddComment.js index 28d11d99..c77e9caa 100644 --- a/test/mockAddComment.js +++ b/test/mockAddComment.js @@ -3,7 +3,7 @@ import uuid from '../src/utils/uuid'; export default (spy) => { return function (documentId, annotationId, content) { spy(documentId, annotationId, content); - + let comment = { class: 'Comment', uuid: uuid(), diff --git a/test/mockDeleteAnnotation.js b/test/mockDeleteAnnotation.js index 654a2658..10531be4 100644 --- a/test/mockDeleteAnnotation.js +++ b/test/mockDeleteAnnotation.js @@ -1,5 +1,5 @@ export default (spy) => { - return function (documentId, annotationId) { + return function(documentId, annotationId) { spy(documentId, annotationId); return Promise.resolve(true); }; diff --git a/test/mockEditAnnotation.js b/test/mockEditAnnotation.js index ce91eed6..d62b3553 100644 --- a/test/mockEditAnnotation.js +++ b/test/mockEditAnnotation.js @@ -1,6 +1,6 @@ export default (spy) => { - return function (documentId, annotationId, annotation) { + return function(documentId, annotationId, annotation) { spy(documentId, annotationId, annotation); return Promise.resolve(annotation); }; -} +}; diff --git a/test/mockGetAnnotations.js b/test/mockGetAnnotations.js new file mode 100644 index 00000000..77ecfd90 --- /dev/null +++ b/test/mockGetAnnotations.js @@ -0,0 +1,9 @@ +export default function() { + return function(documentId, pageNumber) { + return Promise.resolve({ + documentId, + pageNumber, + annotations: [] + }); + } +} diff --git a/test/mockPageWithTextLayer.js b/test/mockPageWithTextLayer.js index 344b45a9..a0e2b449 100644 --- a/test/mockPageWithTextLayer.js +++ b/test/mockPageWithTextLayer.js @@ -3,7 +3,7 @@ import { createPage } from '../src/UI/page'; const ALPHA = Array(26).fill(0).map((c, i) => String.fromCharCode(i + 97)); const TEXT_LAYER_TEMPLATE = Array(5).fill(0).map((c, i) => { - let left = i % 2 == 0 ? 10 : 20; + let left = i % 2 === 0 ? 10 : 20; let top = (i + 1) * 10; return `
${ALPHA.join('')}
`; }).join('\n'); @@ -14,7 +14,7 @@ export const CHAR_WIDTH = 8; export default function mockPageWithTextLayer(pageNumber = 1) { let page = createPage(pageNumber); let textLayer = page.querySelector('.textLayer'); - let annotationLayer = mockSVGContainer() + let annotationLayer = mockSVGContainer(); page.replaceChild(annotationLayer, page.querySelector('.annotationLayer')); @@ -27,7 +27,7 @@ export default function mockPageWithTextLayer(pageNumber = 1) { textLayer.style.fontFamily = 'Courier'; textLayer.style.fontSize = '10px'; textLayer.style.lineHeight = '10px'; - + // CSS isn't loaded so manually position layers textLayer.style.position = 'absolute'; annotationLayer.style.position = 'absolute'; diff --git a/test/mockPathAnnotation.js b/test/mockPathAnnotation.js index d89ecdfb..1b3735ad 100644 --- a/test/mockPathAnnotation.js +++ b/test/mockPathAnnotation.js @@ -2,7 +2,7 @@ import assign from 'object-assign'; import uuid from '../src/utils/uuid'; import renderPath from '../src/render/renderPath'; -const DEFAULT_PATH_ANNOTATION = {color: '000', width: 1, lines: [[10, 10], [12, 12], [14, 14], [16, 16], [18, 18]]}; +const DEFAULT_PATH_ANNOTATION = {color: '000', width: 1, lines: [[12, 10], [14, 12], [16, 14], [18, 16], [20, 18]]}; export default function mockPathAnnotation(annotation) { let path = renderPath(assign(DEFAULT_PATH_ANNOTATION, annotation)); diff --git a/test/mockRectAnnotation.js b/test/mockRectAnnotation.js index 9aac150c..d3f794d8 100644 --- a/test/mockRectAnnotation.js +++ b/test/mockRectAnnotation.js @@ -2,7 +2,7 @@ import assign from 'object-assign'; import uuid from '../src/utils/uuid'; import renderRect from '../src/render/renderRect'; -const DEFAULT_RECT_ANNOTATION = {type: 'highlight', rectangles: [{x: 10, y: 10, width: 20, height: 20}]}; +const DEFAULT_RECT_ANNOTATION = {type: 'highlight', rectangles: [{x: 5, y: 5, width: 20, height: 20}]}; export default function mockRectAnnotation(annotation) { let rect = renderRect(assign(DEFAULT_RECT_ANNOTATION, annotation)); diff --git a/test/mockSVGContainer.js b/test/mockSVGContainer.js index 24ac64a9..ea7ba0e4 100644 --- a/test/mockSVGContainer.js +++ b/test/mockSVGContainer.js @@ -8,4 +8,4 @@ export default (documentId = 'test-document-id', pageNumber = '1') => { svg.setAttribute('data-pdf-annotate-page', pageNumber); svg.setAttribute('data-pdf-annotate-viewport', JSON.stringify(mockViewport())); return svg; -} +}; diff --git a/test/mockTextAnnotation.js b/test/mockTextAnnotation.js index 7584f867..14264d4f 100644 --- a/test/mockTextAnnotation.js +++ b/test/mockTextAnnotation.js @@ -2,7 +2,7 @@ import assign from 'object-assign'; import uuid from '../src/utils/uuid'; import renderText from '../src/render/renderText'; -const DEFAULT_TEXT_ANNOTATION = {x: 10, y: 10, size: 12, color: '000', content: 'foo'}; +const DEFAULT_TEXT_ANNOTATION = {x: 10, y: 10, rotation: 0, size: 12, color: '000', content: 'foo'}; export default function mockTextAnnotation(annotation) { let text = renderText(assign(DEFAULT_TEXT_ANNOTATION, annotation)); diff --git a/test/render/renderPath.spec.js b/test/render/renderPath.spec.js index d574b9c3..63562cc1 100644 --- a/test/render/renderPath.spec.js +++ b/test/render/renderPath.spec.js @@ -8,7 +8,7 @@ describe('render::renderPath', function () { }); equal(path.nodeName, 'path'); - equal(path.getAttribute('d'), 'M0 5 10 15 M10 15 20 35Z'); + equal(path.getAttribute('d'), 'M0 5 L10 15'); equal(path.getAttribute('stroke'), '#000'); equal(path.getAttribute('stroke-width'), 1); equal(path.getAttribute('fill'), 'none'); diff --git a/web/index.html b/web/index.html index 82487b67..b9a81f30 100644 --- a/web/index.html +++ b/web/index.html @@ -85,6 +85,7 @@
+
@@ -94,16 +95,16 @@
- +
- +
- +
@@ -113,7 +114,7 @@
- +