Commit 371a9ec5 authored by Ujvari Gergely's avatar Ujvari Gergely

Introducing highlightText field for annotations

- Original search highlighting modified the text field
- It was a permanent change, it is no longer that way.
- Annotation directive using a mode attribute, to differentiate between viewer and search display
- We show highlighted text only for search results
- It can be used for other differences
parent 2af87e46
......@@ -440,6 +440,7 @@ class Search
for bucket in heatmap.buckets
for annotation in bucket
thread = annotator.threading.getContainer annotation.id
#Cut out annotation branches which has no search results
children = thread.flattenChildren()
hit_in_children = false
......@@ -450,14 +451,14 @@ class Search
if $routeParams.in_body_text and
child.text.toLowerCase().indexOf($routeParams.in_body_text) > -1
#Add highlight
child.text = child.text.replace $scope.text_regexp, $scope.highlighter
child.highlightText = child.text.replace $scope.text_regexp, $scope.highlighter
unless annotation.id in $scope.search_filter or hit_in_children
continue
if $routeParams.whole_document or annotation in $scope.annotations
if $routeParams.in_body_text and
annotation.text.toLowerCase().indexOf($routeParams.in_body_text) > -1
#Add highlight
annotation.text = annotation.text.replace $scope.text_regexp, $scope.highlighter
annotation.highlightText = annotation.text.replace $scope.text_regexp, $scope.highlighter
threads.push thread
$scope.threads = threads
#Replace this with threading call
......
annotation = ['$filter', 'annotator', ($filter, annotator) ->
link: (scope, elem, attrs, controller) ->
return unless controller?
# Bind shift+enter to save
elem.bind
keydown: (e) ->
if e.keyCode == 13 && e.shiftKey
e.preventDefault()
scope.save()
# Watch for changes
scope.$watch 'model.$modelValue.id', (id) ->
scope.thread = annotator.threading.idTable[id]
# Publish the controller
scope.model = controller
controller: 'AnnotationController'
priority: 100 # Must run before ngModel
require: '?ngModel'
restrict: 'C'
scope:
mode: '@'
templateUrl: 'annotation.html'
]
authentication = ->
base =
username: null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment