Commit d816525e authored by csillag's avatar csillag

Drop the URL fragments

parent 0a0019ec
# Annotator plugin for creating the Fragment Selector
class Annotator.Plugin.FragmentSelector extends Annotator.Plugin
pluginInit: ->
@Annotator = Annotator
@anchoring = @annotator.anchoring
# Register the creator Fragment selectors
@anchoring.selectorCreators.push
name: "FragmentSelector"
describe: @_getFragmentSelector
# Create a FragmentSelector around a range
_getFragmentSelector: (annotation, target) =>
console.log "Should create a fragment selector"
return []
[
type: "TextPositionSelector"
start: startOffset
end: endOffset
]
...@@ -23,6 +23,7 @@ class Annotator.Guest extends Annotator ...@@ -23,6 +23,7 @@ class Annotator.Guest extends Annotator
TextPosition: {} TextPosition: {}
TextQuote: {} TextQuote: {}
FuzzyTextAnchors: {} FuzzyTextAnchors: {}
FragmentSelector: {}
# Internal state # Internal state
tool: 'comment' tool: 'comment'
...@@ -119,9 +120,23 @@ class Annotator.Guest extends Annotator ...@@ -119,9 +120,23 @@ class Annotator.Guest extends Annotator
# Announce the new positions, so that the sidebar knows # Announce the new positions, so that the sidebar knows
this.plugins.Bridge.sync([highlight.annotation]) this.plugins.Bridge.sync([highlight.annotation])
# Utility function to remove the hash part from a URL
_removeHash: (url) ->
url = new URL url
url.hash = ""
url.toString()
# Utility function to get the decoded form of the document URI # Utility function to get the decoded form of the document URI
getHref: => getHref: =>
@plugins.PDF?.uri() ? @plugins.Document.uri() ? super if @plugins.PDF
@plugins.PDF.uri()
else
@_removeHash @plugins.Document.uri()
getMetadata: =>
metadata = @plugins.Document?.metadata
metadata.link?.forEach (link) => link.href = @_removeHash link.href
metadata
_setupXDM: (options) -> _setupXDM: (options) ->
# jschannel chokes FF and Chrome extension origins. # jschannel chokes FF and Chrome extension origins.
...@@ -160,7 +175,7 @@ class Annotator.Guest extends Annotator ...@@ -160,7 +175,7 @@ class Annotator.Guest extends Annotator
.catch (problem) => .catch (problem) =>
trans.complete trans.complete
uri: @getHref() uri: @getHref()
metadata: @plugins.Document?.metadata metadata: @getMetadata()
trans.delayReturn(true) trans.delayReturn(true)
) )
......
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