Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
5e5d6688
Commit
5e5d6688
authored
May 22, 2014
by
csillag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update d-t-m to 271a373d (master branch)
parent
62a503f0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
dom_text_mapper.coffee
h/lib/dom_text_mapper.coffee
+47
-1
No files found.
h/lib/dom_text_mapper.coffee
View file @
5e5d6688
...
...
@@ -4,7 +4,7 @@ class window.DomTextMapper
USE_TABLE_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
@
instances
:
0
...
...
@@ -220,12 +220,58 @@ class window.DomTextMapper
throw
new
Error
"Found no info for path '"
+
path
+
"'!"
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
getInfoForNode
:
(
node
)
->
unless
node
?
throw
new
Error
"Called getInfoForNode(node) with null 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
# (Calles getMappingsForCharRange for each element in the given ist)
getMappingsForCharRanges
:
(
charRanges
)
->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment