Commit 5dcbe387 authored by csillag's avatar csillag

Update DTM to 7b12a39f (master branch).

parent 324ef5e0
......@@ -250,8 +250,12 @@ class window.DomTextMapper
# Get the context that encompasses the given charRange
# in the rendered text of the document
getContextForCharRange: (start, end) ->
if start < 0
throw Error "Negative range start is invalid!"
if end > @_corpus.length
throw Error "Range end is after the end of corpus!"
prefixStart = Math.max 0, start - CONTEXT_LEN
prefix = @_corpus[prefixStart .. start - 1]
prefix = if prefixStart then @_corpus[prefixStart .. start - 1] else ""
suffix = @_corpus[end .. end + CONTEXT_LEN - 1]
[prefix.trim(), suffix.trim()]
......@@ -371,9 +375,13 @@ class window.DomTextMapper
timestamp: -> new Date().getTime()
stringStartsWith: (string, prefix) ->
unless prefix
throw Error "Requires a non-empty prefix!"
string[ 0 .. prefix.length - 1 ] is prefix
stringEndsWith: (string, suffix) ->
unless suffix
throw Error "Requires a non-empty suffix!"
string[ string.length - suffix.length .. string.length ] is suffix
parentPath: (path) -> path.substr 0, path.lastIndexOf "/"
......@@ -469,7 +477,10 @@ class window.DomTextMapper
throw new Error "Selection already saved!"
sel = @rootWin.getSelection()
# @log "Saving selection: " + sel.rangeCount + " ranges."
@savedSelection = (sel.getRangeAt i) for i in [0 ... sel.rangeCount]
@savedSelection = unless sel.rangeCount
[]
else
(sel.getRangeAt i) for i in [0 ... sel.rangeCount]
switch sel.rangeCount
when 0 then @savedSelection ?= []
when 1 then @savedSelection = [ @savedSelection ]
......
......@@ -54,6 +54,7 @@ class window.PageTextMapperCore
# Update the mappings for a given page
_updateMap: (info) ->
#console.log "Updating mappings for page #" + info.index
info.domMapper.documentChanged()
info.domMapper.scan()
# Delete the mappings for a given page
......
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