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

    Used for parsing different types of serialized selector data into Selector instances.

    The SelectorFactory must be configured with SelectorDataParsers and FragmentSelectorParser in order to support different selector formats.

    For example, to create a SelectorFactory that can parse EPUB CFI selectors, do the following

    const selectorFactory = new SelectorFactory([
    new EpubCfiFragmentSelectorParser()
    ])
    const parsedEpubCfiSelector = selectorFactory.createFromFragment('epubcfi(/6/2!/4)');

    If you have a serialized Locator you can use a LocatorFactory to parse it. You can use ReaderPublication.getLocatorFactory() to get a pre-configured LocatorFactory and SelectorFactory for that publication type.

    interface ISelectorFactory {
        createFromFragment(
            fragment: string,
            refinementSelectors?: ISelector[],
        ): ISelector;
        createFromSelectorData(selectorData: unknown): ISelector[];
        createRangeSelectors(
            startSelector: ISelector[],
            endSelector: ISelector[],
        ): ISelector[];
        getFragmentSelectorParsers(): IFragmentSelectorParser[];
        getSelectorDataParsers(): ISelectorDataParser[];
    }

    Implemented by

    Methods

    • Parses a fragment selector string into an ISelector instance. The types of selectors that can be parsed depends on which selector parser implementations this factory was created with.

      If the fragment selector format is unknown, an UnknownFragmentSelector instance is returned containing the fragment string.

      Parameters

      • fragment: string

        The fragment selector to parse.

      • OptionalrefinementSelectors: ISelector[]

        Additional refinement selectors if any.

      Returns ISelector

    • Parses a serialized ISelectorData object into an ISelector instance.

      Parameters

      • selectorData: unknown

      Returns ISelector[]

    • Creates range selectors from the given startSelectors and endSelectors.

      Parameters

      • startSelector: ISelector[]

        The selector which describes the inclusive starting point of the range. The most specific selector should be first.

      • endSelector: ISelector[]

        The selectors which describes the exclusive end point of the range. The most specific selector should be first.

      Returns ISelector[]