mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-14 16:53:27 +00:00
Fix spell-checker menu going offscreen.
This commit is contained in:
parent
60cbc989e2
commit
07f884df70
5 changed files with 24 additions and 1 deletions
|
@ -4,6 +4,7 @@ define ["base"], (App) ->
|
|||
open: "<"
|
||||
top: "<"
|
||||
left: "<"
|
||||
layoutFromBottom: "<"
|
||||
highlight: "<"
|
||||
replaceWord: "&"
|
||||
learnWord: "&"
|
||||
|
@ -13,7 +14,7 @@ define ["base"], (App) ->
|
|||
class="dropdown context-menu spell-check-menu"
|
||||
ng-show="$ctrl.open"
|
||||
ng-style="{top: $ctrl.top, left: $ctrl.left}"
|
||||
ng-class="{open: $ctrl.open}"
|
||||
ng-class="{open: $ctrl.open, 'spell-check-menu-from-bottom': $ctrl.layoutFromBottom}"
|
||||
>
|
||||
<ul class="dropdown-menu">
|
||||
<li ng-repeat="suggestion in $ctrl.highlight.suggestions | limitTo:8">
|
||||
|
|
|
@ -544,6 +544,7 @@ define [
|
|||
open="spellMenu.open"
|
||||
top="spellMenu.top"
|
||||
left="spellMenu.left"
|
||||
layout-from-bottom="spellMenu.layoutFromBottom"
|
||||
highlight="spellMenu.highlight"
|
||||
replace-word="replaceWord(highlight, suggestion)"
|
||||
learn-word="learnWord(highlight)"
|
||||
|
|
|
@ -30,6 +30,12 @@ define [
|
|||
end: position
|
||||
})
|
||||
|
||||
isContextMenuEventOnBottomHalf: (e) ->
|
||||
clientY = e.domEvent.clientY
|
||||
editorBoundingRect = e.target.container.getBoundingClientRect()
|
||||
relativeYPos = (clientY - editorBoundingRect.top) / editorBoundingRect.height
|
||||
return relativeYPos > 0.5
|
||||
|
||||
selectHighlightedWord: (highlight) ->
|
||||
row = highlight.range.start.row
|
||||
startColumn = highlight.range.start.column
|
||||
|
|
|
@ -55,6 +55,7 @@ define [], () ->
|
|||
openContextMenu: (e) ->
|
||||
coords = @adapter.getCoordsFromContextMenuEvent(e)
|
||||
highlight = @adapter.getHighlightFromCoords(coords)
|
||||
shouldPositionFromBottom = @adapter.isContextMenuEventOnBottomHalf(e)
|
||||
if highlight
|
||||
@adapter.preventContextMenuEventDefault(e)
|
||||
@adapter.selectHighlightedWord(highlight)
|
||||
|
@ -63,6 +64,7 @@ define [], () ->
|
|||
open: true
|
||||
top: coords.y + 'px'
|
||||
left: coords.x + 'px'
|
||||
layoutFromBottom: shouldPositionFromBottom
|
||||
highlight: highlight
|
||||
}
|
||||
return false
|
||||
|
|
|
@ -649,3 +649,16 @@ CodeMirror
|
|||
height: auto;
|
||||
border-bottom: 1px solid @modal-header-border-color;
|
||||
}
|
||||
|
||||
.spell-check-menu {
|
||||
> .dropdown-menu > li > a {
|
||||
padding: 2px 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.spell-check-menu-from-bottom {
|
||||
> .dropdown-menu {
|
||||
top: auto;
|
||||
bottom: 100%;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue