mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Show labels for tracked changes above and below
This commit is contained in:
parent
0a2d93011f
commit
76415ae02b
4 changed files with 103 additions and 10 deletions
|
@ -98,7 +98,8 @@ div#trackChanges(ng-show="ui.view == 'track-changes'")
|
||||||
text="trackChanges.diff.text",
|
text="trackChanges.diff.text",
|
||||||
highlights="trackChanges.diff.highlights",
|
highlights="trackChanges.diff.highlights",
|
||||||
read-only="true",
|
read-only="true",
|
||||||
resize-on="layout:main:resize"
|
resize-on="layout:main:resize",
|
||||||
|
navigate-highlights="true"
|
||||||
)
|
)
|
||||||
.diff-deleted.text-centered(
|
.diff-deleted.text-centered(
|
||||||
ng-show="trackChanges.diff.deleted"
|
ng-show="trackChanges.diff.deleted"
|
||||||
|
|
|
@ -27,6 +27,7 @@ define [
|
||||||
readOnly: "="
|
readOnly: "="
|
||||||
gotoLine: "="
|
gotoLine: "="
|
||||||
annotations: "="
|
annotations: "="
|
||||||
|
navigateHighlights: "="
|
||||||
}
|
}
|
||||||
link: (scope, element, attrs) ->
|
link: (scope, element, attrs) ->
|
||||||
# Don't freak out if we're already in an apply callback
|
# Don't freak out if we're already in an apply callback
|
||||||
|
@ -112,7 +113,7 @@ define [
|
||||||
|
|
||||||
scope.$watch "annotations", (annotations) ->
|
scope.$watch "annotations", (annotations) ->
|
||||||
if annotations?
|
if annotations?
|
||||||
session = editor.getSession()
|
session = editor.getSession()
|
||||||
session.setAnnotations annotations
|
session.setAnnotations annotations
|
||||||
|
|
||||||
scope.$watch "readOnly", (value) ->
|
scope.$watch "readOnly", (value) ->
|
||||||
|
@ -124,11 +125,11 @@ define [
|
||||||
session.setMode("ace/mode/latex")
|
session.setMode("ace/mode/latex")
|
||||||
session.setAnnotations scope.annotations
|
session.setAnnotations scope.annotations
|
||||||
|
|
||||||
emitChange = () ->
|
emitChange = () ->
|
||||||
scope.$emit "#{scope.name}:change"
|
scope.$emit "#{scope.name}:change"
|
||||||
|
|
||||||
attachToAce = (sharejs_doc) ->
|
attachToAce = (sharejs_doc) ->
|
||||||
lines = sharejs_doc.getSnapshot().split("\n")
|
lines = sharejs_doc.getSnapshot().split("\n")
|
||||||
editor.setSession(new EditSession(lines))
|
editor.setSession(new EditSession(lines))
|
||||||
resetSession()
|
resetSession()
|
||||||
session = editor.getSession()
|
session = editor.getSession()
|
||||||
|
@ -166,7 +167,7 @@ define [
|
||||||
>Dismiss</a>
|
>Dismiss</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ace-editor-body"></div>
|
<div class="ace-editor-body"></div>
|
||||||
<div
|
<div
|
||||||
id="spellCheckMenu"
|
id="spellCheckMenu"
|
||||||
class="dropdown context-menu"
|
class="dropdown context-menu"
|
||||||
ng-show="spellingMenu.open"
|
ng-show="spellingMenu.open"
|
||||||
|
@ -197,6 +198,27 @@ define [
|
||||||
>
|
>
|
||||||
{{ annotationLabel.text }}
|
{{ annotationLabel.text }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href
|
||||||
|
class="highlights-before-label btn btn-info btn-xs"
|
||||||
|
ng-show="updateLabels.highlightsBefore > 0"
|
||||||
|
ng-click="gotoHighlightAbove()"
|
||||||
|
>
|
||||||
|
<i class="fa fa-fw fa-arrow-up"></i>
|
||||||
|
{{ updateLabels.highlightsBefore }} more update{{ updateLabels.highlightsBefore > 1 && "" || "s" }} above
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href
|
||||||
|
class="highlights-after-label btn btn-info btn-xs"
|
||||||
|
ng-show="updateLabels.highlightsAfter > 0"
|
||||||
|
ng-click="gotoHighlightBelow()"
|
||||||
|
>
|
||||||
|
<i class="fa fa-fw fa-arrow-down"></i>
|
||||||
|
{{ updateLabels.highlightsAfter }} more update{{ updateLabels.highlightsAfter > 1 && "" || "s" }} below
|
||||||
|
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,11 @@ define [
|
||||||
text: ""
|
text: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@$scope.updateLabels = {
|
||||||
|
updatesAbove: 0
|
||||||
|
updatesBelow: 0
|
||||||
|
}
|
||||||
|
|
||||||
@$scope.$watch "highlights", (value) =>
|
@$scope.$watch "highlights", (value) =>
|
||||||
@redrawAnnotations()
|
@redrawAnnotations()
|
||||||
|
|
||||||
|
@ -29,9 +34,30 @@ define [
|
||||||
e.position = position
|
e.position = position
|
||||||
@showAnnotationLabels(position)
|
@showAnnotationLabels(position)
|
||||||
|
|
||||||
@editor.on "changeSession", () =>
|
onChangeScrollTop = () =>
|
||||||
|
@updateShowMoreLabels()
|
||||||
|
|
||||||
|
@editor.getSession().on "changeScrollTop", onChangeScrollTop
|
||||||
|
|
||||||
|
@$scope.$watch "text", () =>
|
||||||
|
if @$scope.navigateHighlights
|
||||||
|
setTimeout () =>
|
||||||
|
@scrollToFirstHighlight()
|
||||||
|
, 0
|
||||||
|
|
||||||
|
@editor.on "changeSession", (e) =>
|
||||||
|
e.oldSession?.off "changeScrollTop", onChangeScrollTop
|
||||||
|
e.session.on "changeScrollTop", onChangeScrollTop
|
||||||
@redrawAnnotations()
|
@redrawAnnotations()
|
||||||
|
|
||||||
|
@$scope.gotoHighlightBelow = () =>
|
||||||
|
return if !@firstHiddenHighlightAfter?
|
||||||
|
@editor.scrollToLine(@firstHiddenHighlightAfter.end.row, true, false)
|
||||||
|
|
||||||
|
@$scope.gotoHighlightAbove = () =>
|
||||||
|
return if !@lastHiddenHighlightBefore?
|
||||||
|
@editor.scrollToLine(@lastHiddenHighlightBefore.start.row, true, false)
|
||||||
|
|
||||||
redrawAnnotations: () ->
|
redrawAnnotations: () ->
|
||||||
@_clearMarkers()
|
@_clearMarkers()
|
||||||
@_clearLabels()
|
@_clearLabels()
|
||||||
|
@ -71,6 +97,8 @@ define [
|
||||||
}
|
}
|
||||||
@_drawStrikeThrough(annotation, colorScheme)
|
@_drawStrikeThrough(annotation, colorScheme)
|
||||||
|
|
||||||
|
@updateShowMoreLabels()
|
||||||
|
|
||||||
showAnnotationLabels: (position) ->
|
showAnnotationLabels: (position) ->
|
||||||
labelToShow = null
|
labelToShow = null
|
||||||
for label in @labels or []
|
for label in @labels or []
|
||||||
|
@ -127,6 +155,39 @@ define [
|
||||||
text: labelToShow.text
|
text: labelToShow.text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateShowMoreLabels: () ->
|
||||||
|
return if !@$scope.navigateHighlights
|
||||||
|
setTimeout () =>
|
||||||
|
firstRow = @editor.getFirstVisibleRow()
|
||||||
|
lastRow = @editor.getLastVisibleRow()
|
||||||
|
highlightsBefore = 0
|
||||||
|
highlightsAfter = 0
|
||||||
|
@lastHiddenHighlightBefore = null
|
||||||
|
@firstHiddenHighlightAfter = null
|
||||||
|
for annotation in @$scope.highlights or []
|
||||||
|
range = annotation.highlight or annotation.strikeThrough
|
||||||
|
continue if !range?
|
||||||
|
if range.start.row < firstRow
|
||||||
|
highlightsBefore += 1
|
||||||
|
@lastHiddenHighlightBefore = range
|
||||||
|
if range.end.row > lastRow
|
||||||
|
highlightsAfter += 1
|
||||||
|
@firstHiddenHighlightAfter ||= range
|
||||||
|
|
||||||
|
@$scope.$apply =>
|
||||||
|
@$scope.updateLabels = {
|
||||||
|
highlightsBefore: highlightsBefore
|
||||||
|
highlightsAfter: highlightsAfter
|
||||||
|
}
|
||||||
|
, 100
|
||||||
|
|
||||||
|
scrollToFirstHighlight: () ->
|
||||||
|
for annotation in @$scope.highlights or []
|
||||||
|
range = annotation.highlight or annotation.strikeThrough
|
||||||
|
continue if !range?
|
||||||
|
@editor.scrollToLine(range.start.row, true, false)
|
||||||
|
break
|
||||||
|
|
||||||
_clearMarkers: () ->
|
_clearMarkers: () ->
|
||||||
for marker_id in @markerIds
|
for marker_id in @markerIds
|
||||||
@editor.getSession().removeMarker(marker_id)
|
@editor.getSession().removeMarker(marker_id)
|
||||||
|
@ -177,9 +238,9 @@ define [
|
||||||
new Range(
|
new Range(
|
||||||
annotation.strikeThrough.start.row, annotation.strikeThrough.start.column,
|
annotation.strikeThrough.start.row, annotation.strikeThrough.start.column,
|
||||||
annotation.strikeThrough.end.row, annotation.strikeThrough.end.column + 1
|
annotation.strikeThrough.end.row, annotation.strikeThrough.end.column + 1
|
||||||
),
|
),
|
||||||
"annotation strike-through-foreground",
|
"annotation strike-through-foreground",
|
||||||
true,
|
true,
|
||||||
"""
|
"""
|
||||||
height: #{Math.round(lineHeight/2) + 2}px;
|
height: #{Math.round(lineHeight/2) + 2}px;
|
||||||
border-bottom: 2px solid #{colorScheme.strikeThroughForegroundColor};
|
border-bottom: 2px solid #{colorScheme.strikeThroughForegroundColor};
|
||||||
|
@ -223,4 +284,4 @@ define [
|
||||||
r = parseInt(r, 10)
|
r = parseInt(r, 10)
|
||||||
g = parseInt(g, 10)
|
g = parseInt(g, 10)
|
||||||
b = parseInt(b, 10)
|
b = parseInt(b, 10)
|
||||||
return r + g + b < 3 * 128
|
return r + g + b < 3 * 128
|
||||||
|
|
|
@ -153,6 +153,16 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
.highlights-before-label {
|
||||||
|
position: absolute;
|
||||||
|
top: @line-height-computed / 2;
|
||||||
|
right: @line-height-computed;
|
||||||
|
}
|
||||||
|
.highlights-after-label {
|
||||||
|
position: absolute;
|
||||||
|
bottom: @line-height-computed / 2;
|
||||||
|
right: @line-height-computed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui-layout-resizer {
|
.ui-layout-resizer {
|
||||||
|
@ -198,4 +208,3 @@
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue