Commit 5e8e89f1 authored by csillag's avatar csillag

Update Annotator to 42b8bb1c (typed-packaging branch)

Fixes #1219.
Fixes #1227.
parent 5e5d6688
...@@ -372,16 +372,13 @@ class Annotator extends Delegator ...@@ -372,16 +372,13 @@ class Annotator extends Delegator
try try
a = s.code.call this, annotation, target a = s.code.call this, annotation, target
if a if a
# console.log "Strategy '" + s.name + "' yielded an anchor." # console.log "Strategy '" + s.name + "' yielded an anchor:", a
return result: a return result: a
# else # else
# console.log "Strategy '" + s.name + "' did NOT yield an anchor." # console.log "Strategy '" + s.name + "' did NOT yield an anchor."
catch error catch error
# console.log "Strategy '" + s.name + "' has thrown an error." console.log "Strategy '" + s.name + "' has thrown an error.",
if error instanceof Range.RangeError error.stack ? error
return error: error
else
throw error
return error: "No strategies worked." return error: "No strategies worked."
...@@ -416,6 +413,7 @@ class Annotator extends Delegator ...@@ -416,6 +413,7 @@ class Annotator extends Delegator
annotation.quote = [] annotation.quote = []
annotation.anchors = [] annotation.anchors = []
# console.log "Running setupAnnotation for", annotation.id
for t in annotation.target for t in annotation.target
try try
# Create an anchor for this target # Create an anchor for this target
...@@ -443,9 +441,8 @@ class Annotator extends Delegator ...@@ -443,9 +441,8 @@ class Annotator extends Delegator
console.log "Could not create anchor for annotation '", console.log "Could not create anchor for annotation '",
annotation.id, "'." annotation.id, "'."
catch exception catch exception
if exception.stack? then console.log exception.stack console.log "Error in setupAnnotation for", annotation.id,
console.log exception.message ":", exception.stack ? exception
console.log exception
# Join all the quotes into one string. # Join all the quotes into one string.
annotation.quote = annotation.quote.join(' / ') annotation.quote = annotation.quote.join(' / ')
......
...@@ -69,14 +69,27 @@ class Annotator.Plugin.TextPosition extends Annotator.Plugin ...@@ -69,14 +69,27 @@ class Annotator.Plugin.TextPosition extends Annotator.Plugin
_getTextPositionSelector: (selection) => _getTextPositionSelector: (selection) =>
return [] unless selection.type is "text range" return [] unless selection.type is "text range"
startOffset = (@annotator.domMapper.getInfoForNode selection.range.start).start startOffset = @annotator.domMapper.getStartPosForNode selection.range.start
endOffset = (@annotator.domMapper.getInfoForNode selection.range.end).end endOffset = @annotator.domMapper.getEndPosForNode selection.range.end
[ if startOffset? and endOffset?
type: "TextPositionSelector" [
start: startOffset type: "TextPositionSelector"
end: endOffset start: startOffset
] end: endOffset
]
else
# It looks like we can't determine the start and end offsets.
# That means no valid TextPosition selector can be generated from this.
unless startOffset?
console.log "Warning: can't generate TextPosition selector, because",
selection.range.start,
"does not have a valid start position."
unless endOffset?
console.log "Warning: can't generate TextPosition selector, because",
selection.range.end,
"does not have a valid end position."
[ ]
# Create an anchor using the saved TextPositionSelector. # Create an anchor using the saved TextPositionSelector.
# The quote is verified. # The quote is verified.
...@@ -86,6 +99,14 @@ class Annotator.Plugin.TextPosition extends Annotator.Plugin ...@@ -86,6 +99,14 @@ class Annotator.Plugin.TextPosition extends Annotator.Plugin
selector = @annotator.findSelector target.selector, "TextPositionSelector" selector = @annotator.findSelector target.selector, "TextPositionSelector"
return unless selector? return unless selector?
unless selector.start?
console.log "Warning: 'start' field is missing from TextPositionSelector. Skipping."
return null
unless selector.end?
console.log "Warning: 'end' field is missing from TextPositionSelector. Skipping."
return null
content = @annotator.domMapper.getCorpus()[selector.start .. selector.end-1].trim() content = @annotator.domMapper.getCorpus()[selector.start .. selector.end-1].trim()
currentQuote = @annotator.normalizeString content currentQuote = @annotator.normalizeString content
savedQuote = @annotator.getQuoteForTarget? target savedQuote = @annotator.getQuoteForTarget? target
......
...@@ -34,25 +34,32 @@ class Annotator.Plugin.TextQuote extends Annotator.Plugin ...@@ -34,25 +34,32 @@ class Annotator.Plugin.TextQuote extends Annotator.Plugin
unless rangeEnd? unless rangeEnd?
throw new Error "Called getTextQuoteSelector() on a range with no valid end." throw new Error "Called getTextQuoteSelector() on a range with no valid end."
[ if @annotator.plugins.DomTextMapper
if @annotator.plugins.DomTextMapper # Calculate the quote and context using DTM
# Calculate the quote and context using DTM
startOffset = (@annotator.domMapper.getInfoForNode rangeStart).start startOffset = @annotator.domMapper.getStartPosForNode rangeStart
endOffset = (@annotator.domMapper.getInfoForNode rangeEnd).end endOffset = @annotator.domMapper.getEndPosForNode rangeEnd
if startOffset? and endOffset?
quote = @annotator.domMapper.getCorpus()[startOffset .. endOffset-1].trim() quote = @annotator.domMapper.getCorpus()[startOffset .. endOffset-1].trim()
[prefix, suffix] = @annotator.domMapper.getContextForCharRange startOffset, endOffset [prefix, suffix] = @annotator.domMapper.getContextForCharRange startOffset, endOffset
type: "TextQuoteSelector" [
exact: quote type: "TextQuoteSelector"
prefix: prefix exact: quote
suffix: suffix prefix: prefix
suffix: suffix
]
else else
# Get the quote directly from the range # It looks like we can't determine the start and end offsets.
# That means no valid TextQuote selector can be generated from this.
console.log "Warning: can't generate TextQuote selector.", startOffset, endOffset
[ ]
else
# Get the quote directly from the range
[
type: "TextQuoteSelector" type: "TextQuoteSelector"
exact: selection.range.text().trim() exact: selection.range.text().trim()
]
]
...@@ -106,7 +106,7 @@ class Annotator.Plugin.TextRange extends Annotator.Plugin ...@@ -106,7 +106,7 @@ class Annotator.Plugin.TextRange extends Annotator.Plugin
# " Current quote is '#{currentQuote}'.)" # " Current quote is '#{currentQuote}'.)"
return null return null
if startInfo? if startInfo?.start? and endInfo?.end?
# Create a TextPositionAnchor from the start and end offsets # Create a TextPositionAnchor from the start and end offsets
# of this range # of this range
# (to be used with dom-text-mapper) # (to be used with dom-text-mapper)
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:28Z ** Built at: 2014-05-22 14:28:52Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:28Z ** Built at: 2014-05-22 14:28:52Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:34Z ** Built at: 2014-05-22 14:28:58Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:40Z ** Built at: 2014-05-22 14:29:04Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:25Z ** Built at: 2014-05-22 14:28:48Z
*/ */
...@@ -1378,7 +1378,7 @@ ...@@ -1378,7 +1378,7 @@
}; };
Annotator.prototype.createAnchor = function(annotation, target) { Annotator.prototype.createAnchor = function(annotation, target) {
var a, anchor, error, s, _k, _len2, _ref1; var a, anchor, error, s, _k, _len2, _ref1, _ref2;
if (target == null) { if (target == null) {
throw new Error("Trying to find anchor for null target!"); throw new Error("Trying to find anchor for null target!");
} }
...@@ -1396,13 +1396,7 @@ ...@@ -1396,13 +1396,7 @@
} }
} catch (_error) { } catch (_error) {
error = _error; error = _error;
if (error instanceof Range.RangeError) { console.log("Strategy '" + s.name + "' has thrown an error.", (_ref2 = error.stack) != null ? _ref2 : error);
return {
error: error
};
} else {
throw error;
}
} }
} }
return { return {
...@@ -1411,7 +1405,7 @@ ...@@ -1411,7 +1405,7 @@
}; };
Annotator.prototype.setupAnnotation = function(annotation) { Annotator.prototype.setupAnnotation = function(annotation) {
var anchor, exception, pageIndex, result, t, _base, _k, _l, _len2, _ref1, _ref2, _ref3; var anchor, exception, pageIndex, result, t, _base, _k, _l, _len2, _ref1, _ref2, _ref3, _ref4;
if (annotation.target == null) { if (annotation.target == null) {
annotation.target = this.selectedTargets; annotation.target = this.selectedTargets;
} }
...@@ -1447,11 +1441,7 @@ ...@@ -1447,11 +1441,7 @@
} }
} catch (_error) { } catch (_error) {
exception = _error; exception = _error;
if (exception.stack != null) { console.log("Error in setupAnnotation for", annotation.id, ":", (_ref4 = exception.stack) != null ? _ref4 : exception);
console.log(exception.stack);
}
console.log(exception.message);
console.log(exception);
} }
} }
annotation.quote = annotation.quote.join(' / '); annotation.quote = annotation.quote.join(' / ');
......
This diff is collapsed.
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:40Z ** Built at: 2014-05-22 14:29:05Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:32Z ** Built at: 2014-05-22 14:28:56Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:32Z ** Built at: 2014-05-22 14:28:56Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:35Z ** Built at: 2014-05-22 14:29:00Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:35Z ** Built at: 2014-05-22 14:28:59Z
*/ */
......
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:38Z ** Built at: 2014-05-22 14:29:02Z
*/ */
...@@ -86,15 +86,25 @@ ...@@ -86,15 +86,25 @@
if (selection.type !== "text range") { if (selection.type !== "text range") {
return []; return [];
} }
startOffset = (this.annotator.domMapper.getInfoForNode(selection.range.start)).start; startOffset = this.annotator.domMapper.getStartPosForNode(selection.range.start);
endOffset = (this.annotator.domMapper.getInfoForNode(selection.range.end)).end; endOffset = this.annotator.domMapper.getEndPosForNode(selection.range.end);
return [ if ((startOffset != null) && (endOffset != null)) {
{ return [
type: "TextPositionSelector", {
start: startOffset, type: "TextPositionSelector",
end: endOffset start: startOffset,
end: endOffset
}
];
} else {
if (startOffset == null) {
console.log("Warning: can't generate TextPosition selector, because", selection.range.start, "does not have a valid start position.");
} }
]; if (endOffset == null) {
console.log("Warning: can't generate TextPosition selector, because", selection.range.end, "does not have a valid end position.");
}
return [];
}
}; };
TextPosition.prototype.createFromPositionSelector = function(annotation, target) { TextPosition.prototype.createFromPositionSelector = function(annotation, target) {
...@@ -103,6 +113,14 @@ ...@@ -103,6 +113,14 @@
if (selector == null) { if (selector == null) {
return; return;
} }
if (selector.start == null) {
console.log("Warning: 'start' field is missing from TextPositionSelector. Skipping.");
return null;
}
if (selector.end == null) {
console.log("Warning: 'end' field is missing from TextPositionSelector. Skipping.");
return null;
}
content = this.annotator.domMapper.getCorpus().slice(selector.start, +(selector.end - 1) + 1 || 9e9).trim(); content = this.annotator.domMapper.getCorpus().slice(selector.start, +(selector.end - 1) + 1 || 9e9).trim();
currentQuote = this.annotator.normalizeString(content); currentQuote = this.annotator.normalizeString(content);
savedQuote = typeof (_base = this.annotator).getQuoteForTarget === "function" ? _base.getQuoteForTarget(target) : void 0; savedQuote = typeof (_base = this.annotator).getQuoteForTarget === "function" ? _base.getQuoteForTarget(target) : void 0;
......
{"version":3,"file":"annotator.textposition.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/textposition.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACEA;CAAA,KAAA,kBAAA;KAAA;;uFAAA;;CAAA,CAAM;CAEJ;;CAAA,EAAa,CAAb,KAAA,SAAC;;CAEY,CAAY,CAAZ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,gBAAC;CAIZ,EAHG,CAAA,CAGH,CAHE;CAGF,EAHW,CAAA,EAAD;CAGV,CAAiB,GAAjB,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,wCAAM;CAMN,GAAO,EAAP,YAAA;CAAoB,GAAU,CAAA,SAAA,MAAA;QAN9B;CAOA,GAAO,EAAP,UAAA;CAAkB,GAAU,CAAA,SAAA,IAAA;QAP5B;CAAA,EASa,CAAZ,EAAD,GAAA,SAA+B;CAfjC,IAEa;;CAFb,EAkBkB,CAAA,KAAC,OAAnB;CAGE,SAAA,oCAAA;CAAA,CAAgE,CAArD,CAAC,CAAD,CAAX,EAAA,CAAqB,cAAV;CAAX,EAGY,CAAkB,EAA9B,EAAoB,CAApB;CAHA,EAMmB,CAAA,CAAgB,CAAnC,GAA6B,GAA7B;CANA,EASc,CAAwB,EAAtC,CAAwD,EAA1C,EAAd,CAA0B;CAGrB,CAA8B,EAA/B,KAAU,EAAV,EAAA;CAjCN,IAkBkB;;CAlBlB;;CAF+B,QAAS;;CAA1C,CAuCM,IAAgB,GAAP;CAEb;;;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEE,EAAa,CAAZ,EAAD,GAAA;AAGO,CAAP,GAAA,EAAA,CAAyB,EAAR,IAAjB;CACE,GAAA,GAAO,CAAP,wEAAA;CACA,aAAA;QALF;CAAA,GAQC,EAAD,GAAU,OAAiB;CACzB,CAAM,EAAN,IAAA,cAAA;CAAA,CACU,EAAC,IAAX,gBADA;CATF,OAQA;CARA,GAYC,EAAD,GAAU,UAAoB;CAI5B,CAAM,EAAN,IAAA,EAAA;CAAA,CACM,EAAN,IAAA,kBADA;CAhBF,OAYA;CAQC,EAA+B,CAA/B,KAAS,IAAV,KAAA;CAtBF,IAAY;;CAAZ,EAyB0B,MAAC,eAA3B;CACE,SAAA,YAAA;CAAA,GAAiB,CAAkB,CAAnC,GAA0B,GAA1B;CAAA,CAAA,aAAO;QAAP;CAAA,EAEc,CAAE,CAAkD,CAAlE,GAAyB,EAAzB,GAAe;CAFf,EAGY,CAAE,CAAkD,CAAhE,GAAA,KAAa;aAEb;SACE;CAAA,CAAM,EAAN,MAAA,YAAA;CAAA,CACO,GAAP,KAAA,CADA;CAAA,CAEK,CAAL,MAFA,CAEA;UAHF;CANwB;CAzB1B,IAyB0B;;CAzB1B,CAuCyC,CAAb,GAAA,GAAC,CAAD,gBAA5B;CAGE,SAAA,wCAAA;CAAA,CAAoD,CAAzC,CAAC,EAAZ,EAAA,CAAqB,GAAV,UAAA;CACX,GAAc,EAAd,UAAA;CAAA,aAAA;QADA;CAAA,EAGU,CAAC,EAAX,CAAA,EAAoB,6CAAwD;CAH5E,EAIe,CAAC,EAAhB,CAAe,EAAU,GAAzB,GAAe;CAJf,IAKuB,CAAvB,IAAA;CACA,GAAG,CAAkC,CAArC,IAAA,EAAmB,QAAhB;CAOD,GAAA,WAAO;QAbT;CAgBuB,CAAY,CAA/B,CAAA,CAAA,CAAA,EACM,CADN,CAAA,EAAA,CAAA,KAAA;CA1DN,IAuC4B;;CAvC5B;;CAF0C,QAAS;CAvCrD"} {"version":3,"file":"annotator.textposition.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/textposition.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACE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 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:39Z ** Built at: 2014-05-22 14:29:03Z
*/ */
...@@ -69,17 +69,32 @@ ...@@ -69,17 +69,32 @@
if (rangeEnd == null) { if (rangeEnd == null) {
throw new Error("Called getTextQuoteSelector() on a range with no valid end."); throw new Error("Called getTextQuoteSelector() on a range with no valid end.");
} }
return [ if (this.annotator.plugins.DomTextMapper) {
this.annotator.plugins.DomTextMapper ? (startOffset = (this.annotator.domMapper.getInfoForNode(rangeStart)).start, endOffset = (this.annotator.domMapper.getInfoForNode(rangeEnd)).end, quote = this.annotator.domMapper.getCorpus().slice(startOffset, +(endOffset - 1) + 1 || 9e9).trim(), (_ref1 = this.annotator.domMapper.getContextForCharRange(startOffset, endOffset), prefix = _ref1[0], suffix = _ref1[1], _ref1), { startOffset = this.annotator.domMapper.getStartPosForNode(rangeStart);
type: "TextQuoteSelector", endOffset = this.annotator.domMapper.getEndPosForNode(rangeEnd);
exact: quote, if ((startOffset != null) && (endOffset != null)) {
prefix: prefix, quote = this.annotator.domMapper.getCorpus().slice(startOffset, +(endOffset - 1) + 1 || 9e9).trim();
suffix: suffix _ref1 = this.annotator.domMapper.getContextForCharRange(startOffset, endOffset), prefix = _ref1[0], suffix = _ref1[1];
}) : { return [
type: "TextQuoteSelector", {
exact: selection.range.text().trim() type: "TextQuoteSelector",
exact: quote,
prefix: prefix,
suffix: suffix
}
];
} else {
console.log("Warning: can't generate TextQuote selector.", startOffset, endOffset);
return [];
} }
]; } else {
return [
{
type: "TextQuoteSelector",
exact: selection.range.text().trim()
}
];
}
}; };
return TextQuote; return TextQuote;
......
{"version":3,"file":"annotator.textquote.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/textquote.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACCA;CAAA,GAAA,EAAA;KAAA;;oSAAA;;CAAA,CAAM,IAAgB,GAAP;CAEb;;;;;;CAAA;;CAAA,EAAa,CAAb,KAAC;;CAAD,EACK,CAAL,KAAC;;CADD,EAIY,MAAA,CAAZ;CAGE,SAAA,EAAA;CAAA,GAAC,EAAD,GAAU,OAAiB;CACzB,CAAM,EAAN,IAAA,WAAA;CAAA,CACU,EAAC,IAAX,aADA;CADF,OAAA;CAKC,EAA8B,CAA9B,EAA8B,GAArB,IAAV,IAAA;CACE,OAAA,IAAA;CAAA,CAAoD,CAAzC,EAAC,CAA6B,EAAzC,CAAqB,GAAV,OAAA;CACX,GAAG,IAAH,QAAA;CACG,IAAA,GAAkC,CAAzB,MAAV,EAAA;MADF,IAAA;CAAA,gBAGE;UAL2B;CARrB,MAQqB;CAZjC,IAIY;;CAJZ,EAoBuB,MAAC,YAAxB;CACE,SAAA,gEAAA;CAAA,GAAiB,CAAkB,CAAnC,GAA0B,GAA1B;CAAA,CAAA,aAAO;QAAP;CAEA,GAAO,EAAP,iBAAA;CACE,GAAU,CAAA,SAAA,kCAAA;QAHZ;CAAA,EAKa,EAAe,CAA5B,GAAsB,CAAtB;CACA,GAAO,EAAP,YAAA;CACE,GAAU,CAAA,SAAA,iDAAA;QAPZ;CAAA,EAQW,EAAe,CAA1B,EAAA,CAAoB;CACpB,GAAO,EAAP,UAAA;CACE,GAAU,CAAA,SAAA,+CAAA;QAVZ;aAYA;CACM,CAIF,CADA,CAHE,CAGF,EAHmB,CAIN,CAJZ,CAGc,CAAf,EAHF,CAGiB,QAGI,0BADiD;CAGpE,CAAM,EAAN,MAAA,SAAA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;CAYA,GAAG,EAAH,CAAqB,EAAR,IAAb;CAGE,EAAc,CAAC,IAAf,CAAwB,CAAV,CAAd,OAAc;CAAd,EACY,CAAC,IAAb,CAAA,OAAY;CAEZ,GAAG,IAAH,WAAA,EAAG;CACD,EAAQ,CAAC,CAAT,IAAkB,CAAlB,sCAAoE;CAApE,CAC4E,EAAxD,IAAD,CAAU,CAA7B,CAAmB,WAAA;iBAEnB;aACE;CAAA,CAAM,EAAN,UAAA,KAAA;CAAA,CACO,GAAP,SAAA;CADA,CAEQ,IAAR,QAAA;CAFA,CAGQ,IAAR,QAAA;cAJF;CAJF;MAAA,IAAA;CAaE,CAA2D,CAA3D,IAAO,EAAP,CAAA,CAAA,kCAAA;CAbF,gBAcE;UApBJ;MAAA,EAAA;eAuBE;WACE;CAAA,CAAM,EAAN,QAAA,OAAA;CAAA,CACO,EAAA,CAAP,IAAgB,GAAhB;YAFF;CAvBF;QAbqB;CApBvB,IAoBuB;;CApBvB;;CAFuC,QAAS;CAAlD"}
\ No newline at end of file \ No newline at end of file
// Generated by CoffeeScript 1.6.3 // Generated by CoffeeScript 1.6.3
/* /*
** Annotator 1.2.6-dev-2e8e3af ** Annotator 1.2.6-dev-42b8bb1
** https://github.com/okfn/annotator/ ** https://github.com/okfn/annotator/
** **
** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning. ** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
** Dual licensed under the MIT and GPLv3 licenses. ** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE ** https://github.com/okfn/annotator/blob/master/LICENSE
** **
** Built at: 2014-05-21 11:45:37Z ** Built at: 2014-05-22 14:29:01Z
*/ */
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
if ((savedQuote != null) && currentQuote !== savedQuote) { if ((savedQuote != null) && currentQuote !== savedQuote) {
return null; return null;
} }
if (startInfo != null) { if (((startInfo != null ? startInfo.start : void 0) != null) && ((endInfo != null ? endInfo.end : void 0) != null)) {
return new this.Annotator.TextPositionAnchor(this.annotator, annotation, target, startInfo.start, endInfo.end, (_ref1 = startInfo.pageIndex) != null ? _ref1 : 0, (_ref2 = endInfo.pageIndex) != null ? _ref2 : 0, currentQuote); return new this.Annotator.TextPositionAnchor(this.annotator, annotation, target, startInfo.start, endInfo.end, (_ref1 = startInfo.pageIndex) != null ? _ref1 : 0, (_ref2 = endInfo.pageIndex) != null ? _ref2 : 0, currentQuote);
} else { } else {
return new TextRangeAnchor(this.annotator, annotation, target, normedRange, currentQuote); return new TextRangeAnchor(this.annotator, annotation, target, normedRange, currentQuote);
......
{"version":3,"file":"annotator.textrange.js","sources":["_preamble.coffee","_annotator_mapsrc/src/plugin/textrange.coffee"],"names":[],"mappings":";AAAA;;;;;;;;;;CAAA;CAAA;;;;;;;ACmBA;CAAA,KAAA,eAAA;KAAA;;uFAAA;;CAAA,CAAM;CAEJ;;CAAA,EAAa,CAAb,KAAA,MAAC;;CAEY,CAAY,CAAZ,CAAA,CAAA,CAAA,GAAA,CAAA,eAAC;CAEZ,EAF4C,CAAA,CAE5C,CAF2C;CAE3C,CAAiB,GAAjB,CAAA,GAAA,CAAA,uCAAM;CAEN,GAAO,EAAP,YAAA;CAAoB,GAAU,CAAA,SAAA,MAAA;QAF9B;CAAA,EAIa,CAAZ,EAAD,GAAA,MAA4B;CAR9B,IAEa;;CAFb,EAWkB,MAAA,OAAlB;CAGO,CAA8B,EAA/B,CAAA,IAAU,IAAV;CAdN,IAWkB;;CAXlB;;CAF4B,QAAS;;CAAvC,CAqBM,IAAgB,GAAP;CAEb;;;;;;;CAAA;;CAAA,EAAY,MAAA,CAAZ;CAEE,EAAa,CAAZ,EAAD,GAAA;CAAA,GAGC,EAAD,GAAU,OAAiB;CACzB,CAAM,EAAN,IAAA,OAAA;CAAA,CACU,EAAC,IAAX,SADA;CAJF,OAGA;CAHA,GAQC,EAAD,GAAU,UAAoB;CAE5B,CAAM,EAAN,GAAA,CAAA;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SAAA,oHAAA;CAAA,CAAoD,CAAzC,CAAC,EAAZ,EAAA,CAAqB,GAAV,GAAA;CACX,GAAO,EAAP,UAAA;CAAsB,GAAA,WAAO;QAD7B;CAIA;CACE,EAAQ,CAAC,CAAT,GAAA,CAAkB;CAAlB,EACc,CAAiB,CAAZ,EAA8B,CAAjD,CAAc,EAAd;MAFF,EAAA;CAIE,KAAA,EADI;CACJ,GAAA,WAAO;QART;CAAA,CAeE,CAJa,CAAC,CAGF,CAHd,CAA+D,EAAtC,EAGoC,CAH7D,CAA0C,CAG5B,CAHC,iCAO+C;CAlB9D,IAyBuB,CAAvB,IAAA;CACA,GAAG,CAAkC,CAArC,IAAA,EAAmB,QAAhB;CAID,GAAA,WAAO;QA9BT;CAgCA,GAAG,EAAH,4CAAA,MAAG;CAII,CAAyC,CAA1C,CAAA,CAAA,CAAA,CACsB,EADZ,CAAV,EAAA,GAAA,GAAA;MAJN,EAAA;CAWsB,CAAY,EAA5B,EAAA,GAAA,CAAA,CAAA,CAAA,GAAA;QA5CiB;CAjCzB,IAiCyB;;CAjCzB;;CAFuC,QAAS;CArBlD"}
\ No newline at end of file \ No newline at end of file
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