mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Do not show the text layer when the user clicks outside pages. Remove some debug statements.
This commit is contained in:
@@ -406,8 +406,14 @@ define [
|
||||
element.scrollTop(currentScrollTop + delta)
|
||||
|
||||
element.on 'mousedown', (e) ->
|
||||
if !_hasSelection()
|
||||
console.log 'adding class'
|
||||
# We're checking that the event target isn't the directive root element
|
||||
# to make sure that the click was within a PDF page - no point in showing
|
||||
# the text layer when the click is outside.
|
||||
# If the user clicks a PDF page, the mousedown target will be the canvas
|
||||
# element (or the text layer one). Alternatively, if the event target is
|
||||
# the root element, we can assume that the user has clicked either the
|
||||
# grey background area or the scrollbars.
|
||||
if e.target != element[0] and !_hasSelection()
|
||||
element.addClass 'pdfjs-viewer-show-text'
|
||||
$(document.body).one 'mouseup', _handleSelectionMouseUp
|
||||
|
||||
@@ -416,20 +422,13 @@ define [
|
||||
|
||||
_removeClassIfNoSelection = () ->
|
||||
if _hasSelection()
|
||||
console.log 'has selection, keeping class'
|
||||
$(document.body).one 'mouseup', _handleSelectionMouseUp
|
||||
else
|
||||
console.log 'no selection, removing class'
|
||||
element.removeClass 'pdfjs-viewer-show-text'
|
||||
|
||||
_hasSelection = () ->
|
||||
selection = window.getSelection()
|
||||
if _isSelectionWithinPDF(selection) and selection.toString() != ''
|
||||
console.log 'selection within and not empty' + selection.toString()
|
||||
return true
|
||||
else
|
||||
console.log 'selection outside or empty'
|
||||
return false
|
||||
return _isSelectionWithinPDF(selection) and selection.toString() != ''
|
||||
|
||||
_isSelectionWithinPDF = (selection) ->
|
||||
if selection.rangeCount == 0
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
.full-size;
|
||||
background-color: @gray-lighter;
|
||||
overflow: scroll;
|
||||
user-select: none;
|
||||
canvas, div.pdf-canvas {
|
||||
background: white;
|
||||
box-shadow: black 0px 0px 10px;
|
||||
@@ -38,6 +37,7 @@
|
||||
margin: 10px auto;
|
||||
padding: 0 10px;
|
||||
box-sizing: content-box;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
.progress-thin {
|
||||
|
||||
Reference in New Issue
Block a user