Creates a new ContentPositionTimeline using the specified list of ReaderDocuments. A ContentPositionTimeline is used for describing positions in ReaderPublication content as integers.
See IContentPositionTimeline
for more information and examples.
The ContentPositionTimeline can be configured with different units of measurement.
See getAvailableContentPositionTimelineUnits()
for which units of measurement that are available in with this publication instance.
By default, CHARACTERS will be used as unit of measurement if no unit is specified.
The timeline is created by counting all the characters in the provided list of ReaderDocuments. Each position in the timeline can be resolved to a specific character in the publication content. This is generally the most high-resolution unit of measurement available.
In publications with lots of media, it might be desirable to count media elements (or other replaced elements) as x number of characters to get a better estimation of the "length" of the rendered publication. By default each replaced element is counted as 50 characters.
Many HTML documents may contain lots of whitespace that is not visible in the rendered publication. By default, multiple adjacent whitespaces are collapsed and counted as a single whitespace.
You can change those behaviours by configuring and passing an options object.
The timeline is created by counting all words in the provided list of ReaderDocuments. Each position in the timeline can be resolved to a specific word in the publication content.
NOTE: The current implementation uses whitespace as word boundary and is thus not suitable for all languages.
The timeline is created by counting all pre-paginated pages in the provided list of ReaderDocuments.
Each position in the timeline points to the start of a pre-paginated page.
This unit of measurement is not available in reflowable EPUBs.
Use getAvailableContentPositionTimelineUnits()
to see if this unit of measurement is supported for this publication instance.
The timeline is created by counting all provided ReaderDocuments.
The passed list of ReaderDocuments is validated according to the following rules:
If the passed list of readerDocuments fails validation, the returned Promise will be rejected with an error.
Some examples:
const spine = readerPublication.getSpine();
readerPublication.createContentPositionTimeline(spine); // OK!
readerPublication.createContentPositionTimeline(spine.slice(1, 4)) // OK!
readerPublication.createContentPositionTimeline(spine.filter(item => item.isReflowable()); // OK!
readerPublication.createContentPositionTimeline(spine.reverse()); // ERROR!
The reader documents that should be part of the timeline.
Options to use for the timeline.
A function called several times indicating the create progress as a value between 0 and 1. You can also listen on the event 'contentPositionTimelineCreateProgress' to get this information.
Creates a new EPUB Media Overlay SyncMediaTimeline if available in the publication.
The returned promise is rejected if this EPUB does not contain Media Overlays, or if the resulting timeline is empty.
The reader documents that should be part of the timeline.
Options for the IEpubMediaOverlaySyncMediaTimeline.
A function called several times indicating the create progress as a value between 0 and 1. You can also listen on the event 'syncMediaTimelineCreateProgress' to get this information.
Creates a TTS SyncMediaTimeline using the ContentBlocks from the specified reader documents.
The returned promise is rejected if this EPUB does not contain any text, i.e. if the resulting timeline is empty.
The reader documents that should be part of the timeline.
Options to use when building the timeline.
A function called several times indicating the create progress as a value between 0 and 1. You can also listen on the event 'syncMediaTimelineCreateProgress' to get this information.
Destroy this instance, allowing used resources to be garbage collected. This method has the same effect as calling readingSystemEngine.unloadPublication(),
Fetch the resolved IContentLocation from a locator, ILocatorData, URL, URI, URN, IRI.
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.
See IContentLocation
for more information
Fetches a ContentLocation for hrefs like chapter02.xhtml#title-4
.
If href
is a relative URL, you can specify a baseUrl
to from where href
is relative to.
If you don't specify a baseUrl
it will default to the root of the EPUB.
For example: To resolve a relative href
link found in a ReaderDocument, you should pass
the URL of that ReaderDocument as baseUrl:
await readerPublication.fetchContentLocationFromHref(href, readerDocument.getSourceContentDocument().getContentUrl())
The returned Promise is rejected with an error if:
href
does not resolve to a ReaderDocument
in this publication.href
and does not match any element id in the document.Fetch the preferred aspect ratio of pages in this publication defined as (width / height)
Fetch the complete publication navigation as defined in the source publication.
Fetches an UnresolvedContentLocation from a Locator, ILocatorData, URL, URI, URN, IRI. Can be used for extracting various publication data related with the Locator.
The units of measure that can be used when creating ContentPositionTimeline objects using this publication.
See IEpubReaderPublication.createContentPositionTimeline()
and IPdfReaderPublication.createContentPositionTimeline()
for how to create ContentPositionTimeline objects.
The sync media formats available in this publication.
The base URL used when creating Locators pointing to content in this publication.
Get the LocatorFactory used when creating new Locators.
Get the options related to processing and presentation of EPUB publications.
Get the IReaderPublicationStorage instance for this publication. Use the returned instance to manage the publication's storage, such as 'localStorage' for EPUB. This allows applications to save and restore the state of the IReaderPublicationStorage across reading-sessions and devices.
Get the IReadingSystemEngine that created this instance.
Get the source publication this instance is using.
Get an ordered list of IReaderDocument instances that are part of this publication.
If destroy() has been called on this instance.
If the source URL of the locator, (that is URL without the hash) matches the any source URL in the Publication.
If this method returns true, the locator MAY target content in the publication, depending on selectors inside the Locator. If this method return false, the locator DOES NOT target any content in the publication.
If this publication contains Media Overlays. If this method returns true, you can create a SyncMediaTimeline from the Media Overlays using createMediaOverlaySyncMediaTimeline().
Sets new IReaderPublicationOptions for this instance. Existing properties are preserved if they aren't defined in the passed options object. Properties explicitly set to undefined will be restored to their default values.
Changes affecting the appearance or behavior of the ReaderPublication when used with a ReaderView will not take effect until ReaderView.refresh() is called.
Get this instance as a JSON serializable object.
Generated using TypeDoc
Format specific API for an EPUB ReaderPublication.