Colibrio Reader Framework API - Cloud license
    Preparing search index...

    Represents a location within a ReaderPublication and methods to extract information related to that location. A ContentLocation can be a position in the publication content, or a range across publication content.

    ContentLocations are provided by all APIs in the framework that reference positions and ranges within ReaderPublications. Some example of APIs that provide ContentLocations are:

    • ReaderView.getVisibleRange()
    • EngineEvents,
    • SyncMediaTimeline
    • etc.

    In contrast to UnresolvedContentLocation, a ContentLocation knows its position within the publication content and can thereby be used to compare and sort ContentLocation instances synchronously. The following methods are synchronous in ContentLocation but not in UnresolvedContentLocation:

    • contains()
    • equals()
    • intersects()
    • isAfter()
    • isBefore()

    If you only need to get the ReaderDocument for a Locator, ReaderPublication.fetchUnresolvedContentLocation() should be preferred as it is more performant than ReaderPublication.fetchContentLocation().

    interface IContentLocation {
        collapseToEnd(): IContentLocation;
        collapseToStart(): IContentLocation;
        contains(otherLocation: IContentLocation): boolean;
        createRangeTo(endLocation: IContentLocation): IContentLocation;
        equals(otherLocation: IContentLocation): boolean;
        fetchContentBlockTargets(
            fetchMode: ContentBlockTargetFetchMode,
        ): Promise<IContentBlockTarget[]>;
        fetchContentResolver(): Promise<IContentLocationContentResolver>;
        fetchNavigationItemReferences(
            options: IFetchNavigationItemReferencesOptions,
        ): Promise<IFetchNavigationItemReferencesResult>;
        getLocator(): Locator;
        getReaderDocuments(): IReaderDocument[];
        getReaderPublication(): IReaderPublication;
        intersects(otherLocation: IContentLocation): boolean;
        isAfter(otherLocation: IContentLocation): boolean;
        isBefore(otherLocation: IContentLocation): boolean;
        isRange(): boolean;
        toJSON(): ISimpleLocatorData;
    }

    Methods

    • If this ContentLocation represents a range, it creates a new ContentLocation by collapsing to its end position. If this ContentLocation does not represent a range, the instance itself is returned.

      Returns IContentLocation

    • If this ContentLocation represents a range, it creates a new ContentLocation by collapsing to its start position. If this ContentLocation does not represent a range, the instance itself is returned.

      Returns IContentLocation

    • Check if the passed ContentLocation is equal to this one, or is contained inside this ContentLocation.

      Parameters

      Returns boolean

    • Check if this ContentLocation target exactly the same content as the passed ContentLocation.

      Parameters

      Returns boolean

    • Fetch references to the ReaderPublicationNavigationItems related with this ContentLocation. This can for example be used to get the current "Table of Contents" items that are currently visible in the ReaderView.

      Example:

      readerView.getReadingPosition().fetchNavigationItemReferences({
      collectionTypes: [NavigationCollectionType.TOC], // Only fetch items from the "Table of contents" collection.
      greedy: true, // For TOC, specify `greedy: true`, see IFetchNavigationItemReferencesOptions for more information.
      })

      Returns Promise<IFetchNavigationItemReferencesResult>

    • Get the Locator that was used to create this instance.

      Returns Locator

    • Check if this ContentLocation intersects with another ContentLocation.

      Parameters

      Returns boolean

    • Check if this ContentLocation is strictly after the passed ContentLocation. Returns false if the locations are intersecting.

      Parameters

      Returns boolean

    • Check if this ContentLocation is strictly before the passed ContentLocation. Returns false if the locations are intersecting.

      Parameters

      Returns boolean

    • Returns true if this ContentLocation represents a range.

      Returns boolean

    • Return a serializable version of the Locator that was used to create this instance. This is the same as calling getLocator().toJSON().

      Returns ISimpleLocatorData