mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
6f6a9e714d
This reverts commit 37be3901abf1044d93d83cb684e4e32721550d5a. GitOrigin-RevId: 07d422401f298a667aa635e0232985a81ce6ef4a
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
/* eslint-disable
|
|
max-len,
|
|
no-return-assign,
|
|
no-unused-vars,
|
|
*/
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
// Fix any style issues and re-enable lint.
|
|
/*
|
|
* decaffeinate suggestions:
|
|
* DS101: Remove unnecessary use of Array.from
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
* DS207: Consider shorter variations of null checks
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
*/
|
|
import App from '../../../base'
|
|
import PDFJS from './pdfJsLoader'
|
|
|
|
export default App.factory('pdfHighlights', function() {
|
|
let pdfHighlights
|
|
return (pdfHighlights = class pdfHighlights {
|
|
constructor(options) {
|
|
this.highlightsLayerDiv = options.highlights[0]
|
|
this.highlightElements = []
|
|
}
|
|
|
|
addHighlight(viewport, left, top, width, height) {
|
|
let rect = viewport.convertToViewportRectangle([
|
|
left,
|
|
top,
|
|
left + width,
|
|
top + height
|
|
])
|
|
rect = PDFJS.Util.normalizeRect(rect)
|
|
const element = document.createElement('div')
|
|
element.style.left = Math.floor(rect[0]) + 'px'
|
|
element.style.top = Math.floor(rect[1]) + 'px'
|
|
element.style.width = Math.ceil(rect[2] - rect[0]) + 'px'
|
|
element.style.height = Math.ceil(rect[3] - rect[1]) + 'px'
|
|
this.highlightElements.push(element)
|
|
this.highlightsLayerDiv.appendChild(element)
|
|
return element
|
|
}
|
|
|
|
clearHighlights() {
|
|
for (let h of Array.from(this.highlightElements)) {
|
|
if (h != null) {
|
|
h.parentNode.removeChild(h)
|
|
}
|
|
}
|
|
return (this.highlightElements = [])
|
|
}
|
|
})
|
|
})
|