Adapt review panel line height to editor

This commit is contained in:
James Allen 2017-01-13 14:52:08 +01:00
parent 718f3dc388
commit bf7038f506
4 changed files with 18 additions and 4 deletions

View file

@ -55,6 +55,7 @@ div.full-size(
track-changes-enabled="trackChangesFeatureFlag",
track-changes= "editor.trackChanges",
doc-id="editor.open_doc_id"
renderer-data="reviewPanel.rendererData"
)
include ./review-panel

View file

@ -57,6 +57,7 @@ define [
trackChanges: "="
trackChangesEnabled: "="
docId: "="
rendererData: "="
}
link: (scope, element, attrs) ->
# Don't freak out if we're already in an apply callback
@ -317,6 +318,14 @@ define [
doc = session.getDocument()
doc.off "change", onChange
editor.renderer.on "changeCharacterSize", () ->
scope.$apply () ->
scope.rendererData.lineHeight = editor.renderer.lineHeight
scope.$watch "rendererData", (rendererData) ->
if rendererData?
rendererData.lineHeight = editor.renderer.lineHeight
template: """
<div class="ace-editor-wrapper">

View file

@ -23,6 +23,7 @@ define [
commentThreads: {}
resolvedThreadIds: {}
layoutToLeft: false
rendererData: {}
$scope.$on "layout:pdf:linked", (event, state) ->
$scope.reviewPanel.layoutToLeft = (state.east?.size < 220 || state.east?.initClosed)

View file

@ -32,6 +32,8 @@ define [
return if entries.length == 0
line_height = scope.reviewPanel.rendererData.lineHeight
focused_entry_index = Math.min(previous_focused_entry_index, entries.length - 1)
for entry, i in entries
if entry.scope.entry.focused
@ -57,15 +59,13 @@ define [
previousMinTop += PADDING + height
min_tops.reverse()
line_height = 15
positionLayoutEl = ($callout_el, original_top, top) ->
if original_top <= top
$callout_el.removeClass("rp-entry-callout-inverted")
$callout_el.css(top: original_top + line_height, height: top - original_top)
$callout_el.css(top: original_top + line_height - 1, height: top - original_top)
else
$callout_el.addClass("rp-entry-callout-inverted")
$callout_el.css(top: top + line_height + 1, height: original_top - top)
$callout_el.css(top: top + line_height, height: original_top - top)
# Put the focused entry as close to where it wants to be as possible
focused_entry_top = Math.max(previousMinTop, focused_entry.scope.entry.screenPos.y)
@ -104,6 +104,9 @@ define [
scope.$on "review-panel:layout", () ->
scope.$applyAsync () ->
layout()
scope.$watch "reviewPanel.rendererData.lineHeight", () ->
layout()
## Scroll lock with Ace
scroller = element