Extensions add specific functionality to Learnosity APIs. They rely on modules within LT being available.
--
Adds the ability for authors to add non-default language content
by surrounding text with the lang
attribute. Essential for
screen readers.
To remove an inline attribute, highlight the text and use the clear formatting button in the toolbar.
Right now there's no way to remove a block attribute, because they
add surrounding <div>
elements. The only way is to use the Source
window in the rich-text editor.
Adding a custom button is a capability in Author API. Below is a code
snippet of an Author API configuration object. Note the custom button
is added under rich_text_editor
.
You MUST use the object as defined below. Also, note the toolbar_settings
which is required to place the custom button(s) where you want in the toolbar.
{
"config": {
"dependencies": {
"question_editor_api": {
"init_options": {
"rich_text_editor": {
"customButtons": [
{
"func": "LT.extensions.languageTextDirection.addLanguageAttribute",
"icon": "https://raw.githubusercontent.com/michaelsharman/LT/refs/heads/main/src/authoring/extensions/ui/languageTextDirection/assets/icon_language.svg",
"label": "Set language",
"name": "addLanguageAttribute"
}
],
"toolbar_settings": {
"ltr_toolbar": [
{
"items": ["Bold","Italic","Underline","-","TextColor","-", "LrnUnderlinedIndicator","-","RemoveFormat","FontSize"],
"name": "basicstyles"
},
{
"items": ["NumberedList","BulletedList","-","Indent","Outdent"],
"name": "list"
},
{
"items": ["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],
"name": "justify"
},
{
"items": ["Link","Unlink"],
"name": "link"
},
{
"items": ["Image","LrnMath","Table","Blockquote","SpecialChar"],
"name": "insert"
},
{
"items": ["LrnSimpleFeature"],
"name": "simplefeature"
},
{
"items": ["LrnResource"],
"name": "resource"
},
{
"items": ["LrnEditAriaLabel","LrnPopupContent"],
"name": "editAriaLabel"
},
{
"name": "custombuttons"
},
{
"items": ["Undo","Redo"],
"name": "clipboard"
},
{
"items": ["Styles"],
"name": "style"
},
{
"items": ["Sourcedialog"],
"name": "mode"
},
{
"items": ["lrn_datatable"],
"name": "data"
}
]
}
}
}
}
}
}
}
Methods
addLanguageAttribute(attribute, callback)
Called via a custom button in the rich text toolbar.
Renders a modal asking the author which language they
want to add. Then inserts a <span>
element for inline
or a <div>
or <p>
element for block with lang and dir
attributes.
Since
- 2.0.0
Parameters:
Name | Type | Description |
---|---|---|
attribute |
* | |
callback |
* |
run()
Extension constructor.
Since
- 2.0.0
Example
import { LT } from '@caspingus/lt/src/authoring/index';
LT.init(authorApp); // Set up LT with the Author API application instance variable
LT.extensions.languageTextDirection.run();