Commit 5e5d6688 authored by csillag's avatar csillag

Update d-t-m to 271a373d (master branch)

parent 62a503f0
...@@ -4,7 +4,7 @@ class window.DomTextMapper ...@@ -4,7 +4,7 @@ class window.DomTextMapper
USE_TABLE_TEXT_WORKAROUND = true USE_TABLE_TEXT_WORKAROUND = true
USE_EMPTY_TEXT_WORKAROUND = true USE_EMPTY_TEXT_WORKAROUND = true
SELECT_CHILDREN_INSTEAD = ["thead", "tbody", "ol", "a", "caption", "p", "span", "div", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "li", "form"] SELECT_CHILDREN_INSTEAD = ["thead", "tbody", "tfoot", "ol", "a", "caption", "p", "span", "div", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "li", "form"]
CONTEXT_LEN = 32 CONTEXT_LEN = 32
@instances: 0 @instances: 0
...@@ -220,12 +220,58 @@ class window.DomTextMapper ...@@ -220,12 +220,58 @@ class window.DomTextMapper
throw new Error "Found no info for path '" + path + "'!" throw new Error "Found no info for path '" + path + "'!"
result result
# Return the offset of the start of given path in the DOM
getStartPosForPath: (path) ->
info = @getInfoForPath path
info.start ? @getFirstPosAfter info.node
getFirstPosAfter: (node) ->
if node.nextSibling? # Do we have a next sibling?
# Check the sibling
node = node.nextSibling
path = @getPathTo node
info = @path[path]
info.start ? @getFirstPosAfter node
else
# Nothing to see on this level. Move up in the tree.
@getFirstPosAfter node.parentNode
# Return the offset of the start of given path in the DOM
getEndPosForPath: (path) ->
info = @getInfoForPath path
info.end ? @getFirstPosBefore info.node
getFirstPosBefore: (node) ->
if node.previousSibling? # Do we have a previous sibling?
# Check the sibling
node = node.previousSibling
path = @getPathTo node
info = @path[path]
info.end ? @getFirstPosBefore node
else
# Nothing to see on this level. Move up in the tree.
@getFirstPosBefore node.parentNode
# Return info for a given node in the DOM # Return info for a given node in the DOM
getInfoForNode: (node) -> getInfoForNode: (node) ->
unless node? unless node?
throw new Error "Called getInfoForNode(node) with null node!" throw new Error "Called getInfoForNode(node) with null node!"
@getInfoForPath @getPathTo node @getInfoForPath @getPathTo node
# Return the offset of the start of given node in the DOM
getStartPosForNode: (node) ->
unless node?
throw new Error "Called getStartInfoForNode(node) with null node!"
@getStartPosForPath @getPathTo node
# Return the offset of the end of a given node in the DOM
getEndPosForNode: (node) ->
unless node?
throw new Error "Called getInfoForNode(node) with null node!"
@getEndPosForPath @getPathTo node
# Get the matching DOM elements for a given set of charRanges # Get the matching DOM elements for a given set of charRanges
# (Calles getMappingsForCharRange for each element in the given ist) # (Calles getMappingsForCharRange for each element in the given ist)
getMappingsForCharRanges: (charRanges) -> getMappingsForCharRanges: (charRanges) ->
......
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