Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

CFI blacklist (element, class, id) #30

@danielweck

Description

@danielweck

Related issue: readium/readium-js-viewer#278

The CFI library currently doesn't expose an API to easily customize blacklists across the board (i.e. for all the features that rely on CFI interpretation/generation). There are functions / methods that take blacklist parameters, but this is not integrated consistently. For example (abbreviated code):

https://github.com/readium/readium-shared-js/blob/develop/js/views/cfi_navigation_logic.js#L544

this.getFirstVisibleElementCfi = function(topOffset) {

        var foundElement = this.findFirstVisibleElement(topOffset);
...
        var cfi = EPUBcfi.Generator.generateElementCFIComponent(foundElement.$element[0]);
...
        return cfi + "@0:" + foundElement.percentY;
    };

Note how EPUBcfi.Generator.generateElementCFIComponent() does not take into account default blacklists, let alone custom ones. Yet, the low-level API itself is capable of handling blacklists:

https://github.com/readium/readium-cfi-js/blob/develop/src/models/cfi_generator.js#L161

generateElementCFIComponent : function (startElement, classBlacklist, elementBlacklist, idBlacklist) {
...
    },

We need a top-level registry of blacklisted elements, classes, ids. There should be a default set (annotation highlights, media overlays character-range highlights, mathjax, etc.), and this should be configurable when the Readium instance is created (allowing vendor customization, e.g. jQuery "highlight" plugin)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions