Add Custom Highlights to Content

Question

How can we add custom highlights to the document content in Author mode?

Answer

There are two types of highlights you can add:

  1. Non-Persistent Highlights - Such highlights are removed when the document is closed and then re-opened.

    You can use the following API method:

    ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.getHighlighter()

    to obtain an AuthorHighlighter that allows you to add a highlight between certain offsets with a specified painter.

    For example, you can use this support to implement your own spell checker with a custom highlight for the unrecognized words.

  2. Persistent Highlights - Such highlights are saved in the XML content as processing instructions.

    You can use the following API method:

    ro.sync.exml.workspace.api.editor.page.author.WSAuthorEditorPageBase.getPersistentHighlighter()

    to obtain an AuthorPersistentHighlighter class that allows you to add a persistent highlight between certain offsets, set new properties for a specific highlight, and render it with a specified painter.

    For example, you can use this support to implement your own way of adding review comments.

Was this helpful?