Options
All
  • Public
  • Public/Protected
  • All
Menu

Locator instances are used for referencing specific locations (including ranges) in publications.

The Locator type is modeled after and compatible with the "External Web Resource" and "Specific Resource" types defined by the Web Annotations specification: https://www.w3.org/TR/annotation-model

Locator can be serialized into various formats such as:

  • IWebAnnotationResourceData - modeling the Web annotation "External Web Resource" type.
  • IWebAnnotationSpecificResourceData - modeling the Web annotation "Specific Resource" type.
  • URL - (non-fragment selectors are serialized according to the Selectors and States Note: https://www.w3.org/TR/selectors-states/

Legacy Colibrio IAnnotationTarget objects are not valid with the "External Web Resource" or "Specific Resource" types due to using "id" instead of "source" while also specifying a "selector". For backwards compatibility, these object can still be parsed into Locators.

NOTE: JSON-LD processing is NOT supported. Ensure that the data used to instantiate Locators follows the recommended serialization format specified in https://www.w3.org/TR/annotation-vocab/#json-ld-context

colibrionamespace

core.locator

Hierarchy

  • Locator

Implements

Index

Constructors

constructor

  • Creates a new Locator instance. No validation is performed on the supplied arguments. NOTE: Clients should use the LocatorFactory.parse() to create Locators from URLs or JSON data.

    Parameters

    • _sourceUrl: string

      The URL to the target resource without the hash fragment part if any.

    • _selectors: ISelector[]

      The selectors for this Locator.

    Returns Locator

Methods

getSelectors

  • Get the Selectors for this Locator. Multiple Selectors should select the same content, however some Selectors will not have the same precision as others. The first selector in the array has the highest precision.

    Returns ISelector[]

getSourceUrl

  • getSourceUrl(): string
  • Returns the URL to the Locator without the hash fragment part if any. This can be a http URL, an isbn identifier (isbn:4636...) or any other URL, URI, IRI, URN identifier

    Returns string

toJSON

  • Returns this locator as a JSON serializable object. Use LocatorFactory.parse() to deserialize this data back to a Locator.

    Returns ISimpleLocatorData

toLegacyAnnotationTarget

  • Method used to convert a locator to a ILegacyAnnotationTarget that is compatible with older versions of the Colibrio framework. Note that the format and type fields will not be set, so if you need them, you have to set them manually.

    Returns ILegacyAnnotationTargetData

toString

  • toString(sourceUrl?: string): string
  • Get this Locator as an URL string.

    Parameters

    • Optional sourceUrl: string

    Returns string

toUrl

  • toUrl(sourceUrl?: string): URL
  • Get this Locator as an URL.

    Parameters

    • Optional sourceUrl: string

    Returns URL

toWebAnnotationResource

toWebAnnotationSpecificResource

Generated using TypeDoc