This is a lower-level API. Lower-level APIs are not recommended for most projects, and may not be available on all plans. See our page on recommended deployment patterns for more information.

Annotations API Initialization

This page details the initialization options for Annotations API.

Enabling Annotations API

This section details how to enable Learnosity Annotations API in Items API. You can enable Annotations API in Items API by adding annotations: true to the config object within the request object of Items API. By default, Annotations API is disabled in Items API.

Note Annotations API is instantiated in Items API (Assess and Inline modes). Additionally, when enabling Annotations API via specifying annotations_api_init_options, these will override the more general annotations: true setting.

Initialization object

The initialization object contains all of the configuration properties for user & session identification, look and feel for the user interface, as well as properties to enable/disable certain functionality of the API. Most configuration is done within the “modules” object, where each module can be enabled and configured as desired.

const annotations_api_init_options = {
    "modules": {
        "notepad": true, // enable notepad module with default options
        "texthighlight": { // enable texthighlight with the following options:
            // Allows client to define a custom set of color scheme classes
            // Learnosity Default colors are named: theme-1, theme-2, theme-3, theme-4
            "highlight_colors": [
                'my-color-1', // highlighted DOM node will have classname "lrn-annotations-color--my-color-1"
                'my-color-2'
            ],
        },
        "stickynote": { // enable stickynote with the following options:
            "start_expanded": true, //sticky notes will be loaded in an expanded form
            "start_hidden": true //sticky notes will be loaded in hidden state
        },
        "drawing": { // enable drawing with the following options:
            // Allows client to define a custom set of color scheme classes
            // Learnosity Default colors are named:
            // lrn-annotations-drawing-color-1, lrn-annotations-drawing-color-2,
            // lrn-annotations-drawing-color-3, lrn-annotations-drawing-color-4
            "colors": [
                'my-color-1', // drawing elements will have classname "my-color-1"
                'my-color-2'
            ],
            "show_grid": true // enable the background grid display.
        }
    }
};
    


Important by default, all modules of Annotations API are disabled unless specified. Modules can be enabled by providing either a true or object value for that module. If no modules are enabled, Annotations API will not initialize.

Note Specifying "annotations": true in Items API enables all Annotations modules with a set of useful defaults, so you can activate all of the modules of Annotations API with one setting.

The available modules of Annotations API are:

Properties

Note All initialization options for Annotations API are optional.
Properties
drawing

object

Enables the drawing module, which allows users to annotate the page with a freehand drawing tool.

notepad

boolean

Enables the notepad module, which allows users to type notes into a separate window on the page.

  • True: enables the notepad module.
  • False or unspecified: does not enable the notepad module.

Note

  • In v2022.3.LTS or later the notepad's character limit default is 2000 characters and can be changed by request with customer support.
  • For LTS versions older than v2022.3.LTS, the limit is 1000 characters and can not be changed.

Default: false

stickynote

object

Enables the sticky note module, which allows users to place colored squares onto the page and type text into them.

Note The maximum character limit is 600.

texthighlight

object

Enables the text highlight module, which allows users to select text elements on screen and have those selections marked with different colors.