Commit 4e1b8ce3 authored by csillag's avatar csillag

DTM changes

 * Updated dom-text-mapper to 3fb30bee (master branch)
 * Updated Annotator to 631c1345 (typed-packaging branch)

These are all internal DTM / Annotator changes.
The communcation about DOM changes has migrated from method calls
to events.

See also https://github.com/hypothesis/dom-text-mapper/issues/14
parent 3924bae4
......@@ -48,21 +48,20 @@ class window.PDFTextMapper extends window.PageTextMapperCore
@_unmapPage @pageInfo[index]
# Do something about cross-page selections
window.DomTextMapper.instances.push
id: "cross-page catcher"
rootNode: document.getElementById "viewer"
performUpdateOnNode: (node, data) =>
if "viewer" is node.getAttribute? "id"
# This event escaped the pages.
# Must be a cross-page selection.
if data.start? and data.end?
startPage = @getPageForNode data.start
endPage = @getPageForNode data.end
for index in [ startPage.index .. endPage.index ]
#console.log "Should rescan page #" + index
@_updateMap @pageInfo[index]
documentChanged: ->
timestamp: ->
viewer = document.getElementById "viewer"
viewer.addEventListener "domChange", (event) =>
node = event.srcElement
data = event.data
if "viewer" is node.getAttribute? "id"
console.log "Detected cross-page change event."
# This event escaped the pages.
# Must be a cross-page selection.
if data.start? and data.end?
startPage = @getPageForNode data.start
endPage = @getPageForNode data.end
for index in [ startPage.index .. endPage.index ]
#console.log "Should rescan page #" + index
@_updateMap @pageInfo[index]
$(PDFView.container).on 'scroll', => @_onScroll()
......
......@@ -67,7 +67,10 @@ class TextHighlight extends Annotator.Highlight
for node in normedRange.textNodes() when not white.test node.nodeValue
r = @$(node).wrapAll(hl).parent().show()[0]
window.DomTextMapper?.changed node, "created hilite"
event = document.createEvent "UIEvents"
event.initUIEvent "domChange", true, false, window, 0
event.reason = "created hilite"
node.dispatchEvent event
r
# Public: highlight a list of ranges
......@@ -121,8 +124,11 @@ class TextHighlight extends Annotator.Highlight
# We should restore original state
child = hl.childNodes[0]
@$(hl).replaceWith hl.childNodes
window.DomTextMapper?.changed child.parentNode,
"removed hilite (annotation deleted)"
event = document.createEvent "UIEvents"
event.initUIEvent "domChange", true, false, window, 0
event.reason = "removed hilite (annotation deleted)"
child.parentNode.dispatchEvent event
# Get the HTML elements making up the highlight
_getDOMElements: -> @_highlights
......
......@@ -211,9 +211,12 @@ class Range.BrowserRange
while nr.commonAncestor.nodeType isnt Node.ELEMENT_NODE
nr.commonAncestor = nr.commonAncestor.parentNode
if window.DomTextMapper? and changed
# console.log "Ranged normalization changed the DOM, updating d-t-m"
window.DomTextMapper.changed nr.commonAncestor, "range normalization", nr
if changed
event = document.createEvent "UIEvents"
event.initUIEvent "domChange", true, false, window, 0
event.reason = "range normalization"
event.data = nr
nr.commonAncestor.dispatchEvent event
new Range.NormalizedRange(nr)
......
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-3d4ae84
** Annotator 1.2.6-dev-6bedfd2
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-11-28 15:22:14Z
** Built at: 2013-11-28 17:54:20Z
*/
......@@ -492,7 +492,7 @@
}
BrowserRange.prototype.normalize = function(root) {
var changed, n, node, nr, r;
var changed, event, n, node, nr, r;
if (this.tainted) {
console.error(_t("You may only call normalize() once on a BrowserRange!"));
return false;
......@@ -557,8 +557,12 @@
while (nr.commonAncestor.nodeType !== Node.ELEMENT_NODE) {
nr.commonAncestor = nr.commonAncestor.parentNode;
}
if ((window.DomTextMapper != null) && changed) {
window.DomTextMapper.changed(nr.commonAncestor, "range normalization", nr);
if (changed) {
event = document.createEvent("UIEvents");
event.initUIEvent("domChange", true, false, window, 0);
event.reason = "range normalization";
event.data = nr;
nr.commonAncestor.dispatchEvent(event);
}
return new Range.NormalizedRange(nr);
};
......
This diff is collapsed.
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-2000a65
** Annotator 1.2.6-dev-6bedfd2
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-11-26 10:43:03Z
** Built at: 2013-11-28 18:04:55Z
*/
......@@ -61,7 +61,8 @@
}
PDFTextMapper.prototype.setEvents = function() {
var _this = this;
var viewer,
_this = this;
addEventListener("pagerender", function(evt) {
var index;
if (_this.pageInfo == null) {
......@@ -78,25 +79,23 @@
return _this._unmapPage(_this.pageInfo[index]);
}
});
window.DomTextMapper.instances.push({
id: "cross-page catcher",
rootNode: document.getElementById("viewer"),
performUpdateOnNode: function(node, data) {
var endPage, index, startPage, _i, _ref, _ref1, _results;
if ("viewer" === (typeof node.getAttribute === "function" ? node.getAttribute("id") : void 0)) {
if ((data.start != null) && (data.end != null)) {
startPage = _this.getPageForNode(data.start);
endPage = _this.getPageForNode(data.end);
_results = [];
for (index = _i = _ref = startPage.index, _ref1 = endPage.index; _ref <= _ref1 ? _i <= _ref1 : _i >= _ref1; index = _ref <= _ref1 ? ++_i : --_i) {
_results.push(_this._updateMap(_this.pageInfo[index]));
}
return _results;
viewer = document.getElementById("viewer");
viewer.addEventListener("domChange", function(event) {
var data, endPage, index, node, startPage, _i, _ref, _ref1, _results;
node = event.srcElement;
data = event.data;
if ("viewer" === (typeof node.getAttribute === "function" ? node.getAttribute("id") : void 0)) {
console.log("Detected cross-page change event.");
if ((data.start != null) && (data.end != null)) {
startPage = _this.getPageForNode(data.start);
endPage = _this.getPageForNode(data.end);
_results = [];
for (index = _i = _ref = startPage.index, _ref1 = endPage.index; _ref <= _ref1 ? _i <= _ref1 : _i >= _ref1; index = _ref <= _ref1 ? ++_i : --_i) {
_results.push(_this._updateMap(_this.pageInfo[index]));
}
return _results;
}
},
documentChanged: function() {},
timestamp: function() {}
}
});
return $(PDFView.container).on('scroll', function() {
return _this._onScroll();
......
{"version":3,"file":"annotator.pdf.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/pdf.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA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Aa,CAAA,CAAO,CAAvB,CAAG;CACA,IAAA,MAAD,MAAA;MADF,IAAA;CAGG,EAA6B,EAA7B,IAAiB,OAAlB,CAAA;UAduB;CAA3B,MAA2B;CAjG7B,IA4FkB;;CA5FlB,EAkHa,MAAA,EAAb;CAEE,GAAC,EAAD,aAAA;CAAA,GAGC,EAAD,CAAA,IAAY;CAGX,GAAA,QAAD,CAAA;CA1HF,IAkHa;;CAlHb,EA8HgB,CAAA,KAAC,KAAjB;CAEE,SAAA;CAAA,EAAA,CAAA,EAAA;CACA,EACM,CAAmB,CAAJ,EAElB,CAFA,GAED,CAFA,CAAA,sBAAA;CAIA,EAAA,KAAA,EAAA;CANF,MACA;CADA,CASkC,CAA1B,EAAR,CAAA,EAAQ,EAAuB;CAG9B,GAAA,CAAS,GAAA,KAAV;CA5IF,IA8HgB;;CA9HhB;;CAHiC,KAAM;;CAAzC,CAmJM,IAAgB,GAAP;CAEb;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;AAES,CAAP,GAAA,EAAA,CAAyB,EAAR,IAAjB;CACE,aAAM,+CAAN;QADF;CAGC,GAAA,GAAD,EAAU,IAAV,WAAmC;CAEjC,CAAM,EAAN,IAAA;CAAA,CACQ,IAAR,EAAA,KADA;CAPQ,OAKV;CALF,IAAY;;CAAZ;;CAFiC,QAAS;CAnJ5C"}
\ No newline at end of file
// Generated by CoffeeScript 1.6.3
/*
** Annotator 1.2.6-dev-9183f7e
** Annotator 1.2.6-dev-6bedfd2
** https://github.com/okfn/annotator/
**
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-11-28 15:40:48Z
** Built at: 2013-11-28 17:56:16Z
*/
......@@ -71,7 +71,7 @@
};
TextHighlight.prototype._highlightRange = function(normedRange, cssClass) {
var hl, node, r, white, _i, _len, _ref, _ref1, _results;
var event, hl, node, r, white, _i, _len, _ref, _results;
if (cssClass == null) {
cssClass = 'annotator-hl';
}
......@@ -85,9 +85,10 @@
continue;
}
r = this.$(node).wrapAll(hl).parent().show()[0];
if ((_ref1 = window.DomTextMapper) != null) {
_ref1.changed(node, "created hilite");
}
event = document.createEvent("UIEvents");
event.initUIEvent("domChange", true, false, window, 0);
event.reason = "created hilite";
node.dispatchEvent(event);
_results.push(r);
}
return _results;
......@@ -137,7 +138,7 @@
};
TextHighlight.prototype.removeFromDocument = function() {
var child, hl, _i, _len, _ref, _ref1, _results;
var child, event, hl, _i, _len, _ref, _results;
_ref = this._highlights;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
......@@ -145,7 +146,10 @@
if ((hl.parentNode != null) && this.annotator.domMapper.isPageMapped(this.pageIndex)) {
child = hl.childNodes[0];
this.$(hl).replaceWith(hl.childNodes);
_results.push((_ref1 = window.DomTextMapper) != null ? _ref1.changed(child.parentNode, "removed hilite (annotation deleted)") : void 0);
event = document.createEvent("UIEvents");
event.initUIEvent("domChange", true, false, window, 0);
event.reason = "removed hilite (annotation deleted)";
_results.push(child.parentNode.dispatchEvent(event));
} else {
_results.push(void 0);
}
......
{"version":3,"file":"annotator.texthighlights.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/texthighlights.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACGA;CAAA,KAAA,aAAA;KAAA;;0JAAA;;CAAA,CAAM;CAIJ;;CAAA,EAAa,CAAb,KAAA,IAAC;;CAAD,EACK,CAAL,KAAc,IAAb;;CADD,EAEiB,CAAjB,SAAC,EAFD;;CAAA,EAKa,CAAb,GAAa,EAAC,CAAd,GAAC;CAA0B,GAAA,GAAD,CAAA,KAAA,CAAA;CAL1B,IAKa;;CALb,EAQuB,CAAvB,GAAuB,EAAC,IAAvB,OAAD;CACG,GAAA,GAAD,MAAA,gBAAA;CATF,IAQuB;;CARvB,CAAA,CAYU,CAAV,GAAA,MAAC;;CAZD,EAeQ,CAAR,CAA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AxHjB;;CAJ0B,QAAS;;CAArC,CA8HM,IAAgB,GAAP;CAGb;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEY,EAAgB,MAAjB,IAAT;CAFF,IAAY;;CAAZ;;CAH4C,QAAS;CA9HvD"}
\ No newline at end of file
{"version":3,"file":"annotator.texthighlights.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/texthighlights.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACGA;CAAA,KAAA,aAAA;KAAA;;0JAAA;;CAAA,CAAM;CAIJ;;CAAA,EAAa,CAAb,KAAA,IAAC;;CAAD,EACK,CAAL,KAAc,IAAb;;CADD,EAEiB,CAAjB,SAAC,EAFD;;CAAA,EAKa,CAAb,GAAa,EAAC,CAAd,GAAC;CAA0B,GAAA,GAAD,CAAA,KAAA,CAAA;CAL1B,IAKa;;CALb,EAQuB,CAAvB,GAAuB,EAAC,IAAvB,OAAD;CACG,GAAA,GAAD,MAAA,gBAAA;CATF,IAQuB;;CARvB,CAAA,CAYU,CAAV,GAAA,MAAC;;CAZD,EAeQ,CAAR,CAAA,IAAS,IAAR;CACC,SAAA,IAAA;SAAA,GAAA;CAAA,CAAU,EAAA,EAAV,CAAU,EAAA,MAAa;CAAvB,aAAA;QAAA;CAAA,EAEiB,EAAA,CAAjB,GAAkB,KAAlB;CAEE,UAAA,CAAA;CAAA,EAAc,EAAqB,CAArB,CAAA,CAAd,CAGO,EAHP,EAA2B,EAAb;CAGJ,GAAO,QAAA,CAAa,IAAb;CAHH,QAGP;CAGO,QAAd,EAAA,EAAa,EAAb;CAVF,MAEiB;CAFjB,CAYoC,CAAa,EAAA,CAAjD,EAAA,CAAS,EAAT,IAAA;CACY,CAAwC,GAAtB,IAAnB,IAAmB,CAAA,CAA5B,EAAA;CADF,MAAiD;CAZjD,CAeoC,CAAY,EAAA,CAAhD,EAAA,CAAS,CAAT,KAAA;CACY,CAAuC,GAAtB,IAAlB,IAAkB,CAAA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e;CAPf,CAQoC,EAAnC,EAAD,IAAA,CAAA,CAAA;CAzFF,IAgFa;;CAhFb,EA8Fa,MAAA,EAAb;CAAiB,GAAA,SAAD;CA9FhB,IA8Fa;;CA9Fb,EAiGc,EAAA,IAAC,GAAf;CACE,EAAc,CAAb,CAAD,CAAA,IAAA;CACA,GAAG,CAAH,CAAA;CACG,GAAA,IAAD,GAAA,IAAA,SAAA;MADF,EAAA;CAGG,GAAA,OAAD,IAAA,SAAA;QALU;CAjGd,IAiGc;;CAjGd,EAyGW,EAAA,IAAX;CACE,GAAG,CAAH,CAAA;CACG,GAAA,IAAD,GAAA,IAAA,MAAA;MADF,EAAA;CAGG,GAAA,OAAD,IAAA,MAAA;QAJO;CAzGX,IAyGW;;CAzGX,EAgHoB,MAAA,SAApB;CACE,SAAA,gCAAA;CAAA;CAAA;YAAA,+BAAA;uBAAA;CAEE,GAAG,IAAH,CAAgC,GAAV,WAAnB;CAED,CAAU,CAAF,EAAR,KAAA;CAAA,CACA,EAAC,MAAD,CAAA;CADA,EAGQ,EAAR,GAAgB,EAAhB,CAAQ;CAHR,CAI+B,EAA/B,CAAK,CAAL,IAAA,CAAA;CAJA,EAKe,EAAV,CAAL,IAAA,2BALA;CAAA,IAMK,KAAW,GAAhB;MARF,IAAA;CAAA;UAFF;CAAA;uBADkB;CAhHpB,IAgHoB;;CAhHpB,EA8HiB,MAAA,MAAjB;CAAqB,GAAA,SAAD;CA9HpB,IA8HiB;;CA9HjB;;CAJ0B,QAAS;;CAArC,CAoIM,IAAgB,GAAP;CAGb;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEY,EAAgB,MAAjB,IAAT;CAFF,IAAY;;CAAZ;;CAH4C,QAAS;CApIvD"}
\ No newline at end of file
......@@ -7,38 +7,41 @@ class window.DomTextMapper
SELECT_CHILDREN_INSTEAD = ["thead", "tbody", "ol", "a", "caption", "p", "span", "div", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "li", "form"]
CONTEXT_LEN = 32
@instances: []
@changed: (node, reason = "no reason", data = {}) ->
if @instances.length is 0 then return
# console.log "==== Node"
# console.log node
# console.log "has changed: " + reason
# console.log data
for instance in @instances when instance.rootNode.contains(node)
# console.log "Telling instance '" + instance.id + "'."
instance.documentChanged()
instance.performUpdateOnNode node, false, data
instance.lastScanned = instance.timestamp()
null
@instances: 0
constructor: (@id)->
@setRealRoot()
instances = window.DomTextMapper.instances
instances.push this
@id ?= "d-t-m #" + instances.length
DomTextMapper.instances += 1
@id ?= "d-t-m #" + DomTextMapper.instances
log: (msg) ->
console.log @id + ": " + msg
log: (msg...) ->
console.log @id, ": ", msg...
# ===== Public methods =======
# Change handler
_onChange: (event) =>
# @log "received change event", event
# console.log "source", event.srcElement
# console.log "reason", event.reason ? "no reason"
# console.log "data", event.data
@documentChanged()
@performUpdateOnNode event.srcElement, false, event.data
@lastScanned = @timestamp()
# Change the root node, and subscribe to the events
_changeRootNode: (node) ->
@rootNode?.removeEventListener "domChange", @_onChange
@rootNode = node
@rootNode.addEventListener "domChange", @_onChange
node
# Consider only the sub-tree beginning with the given node.
#
# This will be the root node to use for all operations.
setRootNode: (rootNode) ->
@rootWin = window
@pathStartNode = @rootNode = rootNode
@rootWin = window
@pathStartNode = @_changeRootNode rootNode
# Consider only the sub-tree beginning with the node whose ID was given.
#
......@@ -55,7 +58,7 @@ class window.DomTextMapper
@rootWin = iframe.contentWindow
unless @rootWin?
throw new Error "Can't access contents of the specified iframe!"
@rootNode = @rootWin.document
@_changeRootNode @rootWin.document
@pathStartNode = @getBody()
# Return the default path
......@@ -66,8 +69,8 @@ class window.DomTextMapper
# (This is the default; you only need to call this, if you have configured
# a different root earlier, and now you want to restore the default setting.)
setRealRoot: ->
@rootWin = window
@rootNode = document
@rootWin = window
@_changeRootNode document
@pathStartNode = @getBody()
# Notify the library that the document has changed.
......
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