Skip to content

@astl/editor

The editor-agnostic authoring kit: createAuthoring, the insert menu, inspector, issues and preview elements, and the textarea adapter.

<astl-insert-menu>: what authors can add, in named groups (groups): "Components" (each type with its default template), "Exercises" (the types' named starters, when any) and "Content" ("Picture", which asks for the picture in a dialog, the help for students, "Check button", one Check for the questions above it, and "Page break" when the editor can split pages, EditorAdapter.splitPage). Each entry shows its icon, its name and a one-line description, which together name its button; a press inserts at the cursor. The descriptions of types with menuMessages load when the menu is first shown (inside a popover: when that opens).

  • AuthoringElement
new AstlInsertMenu(): AstlInsertMenu;

AstlInsertMenu

AuthoringElement.constructor
Property Type Description
adapter EditorAdapter | null -
authoring Authoring | null -
dialog | AstlPictureDialog | null The picture dialog to ask with; null (default): this element's own.
filter string Shows only the entries whose label or description holds this text (any case, accents ignored), and a note when none does. Default '': every entry.
groups readonly InsertGroup[] The groups shown, in their own order. Default: all of them. A lone group's title is for screen readers only: the place that shows the menu names it (the toolbar's "Templates").
picking boolean Whether the table picker shows, after "Table" was pressed: beside the list, or in its place in a toolbar narrower than 30rem (a phone). Reflected as the picking attribute; a search or the popover the menu is in closing ends it.
add(tag, template?): Promise<string | null>;

What a press on a component or exercise entry does: inserts it (insert), after asking for its picture when the type needs one. Resolves with the inserted HTML, or null when cancelled.

Parameter Type
tag string
template? string

Promise<string | null>

addCheck(): string | null;

Inserts a Check element (astl-check) at the cursor (insertCheck): after the block the cursor is in, its for the questions of the run of text right above it, selected; its card lists its page's questions to tick. Returns its HTML, or null without an editor.

string | null

addHelp(kind): Promise<string | null>;

Adds a hint, the explanation or a feedback text to the graded element at the cursor (the inspector's help form shows it, focused), or else to the page at the cursor. Resolves with the HTML put on the page, '' when the element got it, or null without an editor.

Parameter Type
kind HelpKind

Promise<string | null>

insert(
tag,
template?,
picture?
): string | null;

Inserts a new element of tag at the cursor: its default template, or the named starter template; with picture, the element takes it (a type whose zones or pins sit on a picture: its picture field's address, its alt text and size). An element whose companion its page lacks brings it at the end of the page (the word bank of a first gap there); the cursor stays on the new element. Returns its source HTML, or null without authoring or adapter.

Parameter Type
tag string
template? string
picture? PictureFields

string | null

insertBadge(): string | null;

Inserts a badge at the cursor (insertBadge), selected for its card. Returns its HTML, or null without an editor.

string | null

insertFrame(): string | null;

Inserts a frame at the cursor (EditorStyles.insertLayout), the cursor in its title. Returns its HTML, or null without an editor or one that cannot.

string | null

insertLayout(name): Promise<string | null>;

Inserts a layout at the cursor (EditorStyles.insertLayout), the cursor in its first empty block. Beside a picture it asks for the picture first, as "Picture" does, and cancelling inserts nothing. Resolves with its HTML, or null.

Parameter Type
name LayoutName

Promise<string | null>

insertPageBreak(): string | null;

Inserts a page break at the cursor (EditorAdapter.splitPage): the new page's id, or null.

string | null

insertPicture(): Promise<string | null>;

Asks for a picture in the dialog and inserts it at the cursor. Resolves with its HTML, or null when cancelled.

Promise<string | null>

insertRule(): string | null;

Inserts a horizontal rule (<hr>) as insert puts a block: after the block the cursor is in, or in the place of an empty line. Returns its HTML, or null without an editor.

string | null

insertTable(shape?): string | null;

Inserts an empty table at the cursor (EditorStyles.insertLayout, tableHtml), the cursor in its first cell: the picker's shape, or shape's values in its place. Returns its HTML, or null without an editor or one that cannot.

Parameter Type
shape? Partial<TableShape>

string | null

insertTask(): string | null;

Inserts a task at the cursor (insertTask), with a fresh id, the cursor in its instruction. Returns its HTML, or null without an editor or one that cannot.

string | null

pickTable(): Promise<void>;

Shows the table picker (picking), its grid focused, or its first counter on a phone: a size, a header row (on by default) and a header column, then Enter, a click on the grid or "Insert table" inserts it (insertTable).

Promise<void>


<astl-inspector>: a form for the component at the cursor (answers, alternatives, correct options, whether each statement is true, the category of each card, scoring, points, variant, look), or, with the cursor outside every component, the document's own settings (its look). Every edit goes through authoring.update and the adapter (replaceElement, or setSource for the document), so the editor stays the source of truth. A block component's head has "Move up", "Move down" and "Delete" (EditorAdapter.moveBlock, removeBlock, at getCursor), each left out when the adapter cannot do it; at its page's start or end, a move is unavailable (aria-disabled). The head shows the type's icon and name and the element's id in a chip; under it, the element's own issues, as banners. The custom property --astl-inspector-columns (default 1) sets the form's columns: with 2, selects, numbers and short texts sit side by side and every other field spans the row.

  • AuthoringElement
new AstlInspector(): AstlInspector;

AstlInspector

AuthoringElement.constructor
Property Type
adapter EditorAdapter | null
authoring Authoring | null
get model(): InspectorModel | null;

The inspector model on screen (a component's, or the document's), or null.

InspectorModel | null

openHelp(part): Promise<void>;

Opens the help for students of the graded element at the cursor at part, as a tag on its frame asks (astl-help-open): the section opens and the part's first field takes the focus (a hint's, or "Add a hint" without one; the first feedback text the element has). Nothing without a graded element at the cursor.

Parameter Type
part HelpPart

Promise<void>


<astl-issues>: live validation of the whole document in the UI locale, errors first. Selecting an issue moves the editor's cursor to its element (adapter.select).

  • AuthoringElement
new AstlIssues(): AstlIssues;

AstlIssues

AuthoringElement.constructor
Property Type
adapter EditorAdapter | null
authoring Authoring | null
get issues(): readonly Issue[] | null;

The issues on screen (null before the first validation).

readonly Issue[] | null

validate(): void;

Validates now instead of waiting for the debounce.

void


<astl-picture-dialog>: asks for a picture in a modal dialog: a file, uploaded with the host's uploadAsset, one from the host's library (pickPicture), or an address (the only way without either, as it says); the alt text, required unless the picture is decorative (alt=""); and, for a new picture, an optional caption. The address must pass the authoring's URL policy, an uploaded or picked one too. ask resolves with the fields, or null when the author cancels. While the library is open the dialog steps aside: it closes and keeps every field, so a modal of the host's own, outside the top layer, takes the pointer and the keys; it opens again when the library settles.

  • AuthoringElement
new AstlPictureDialog(): AstlPictureDialog;

AstlPictureDialog

AuthoringElement.constructor
Property Type
adapter EditorAdapter | null
authoring Authoring | null
ask(request?): Promise<PictureFields | null>;

Opens the dialog. Resolves with the picture's fields, or null when the author cancels.

Parameter Type
request? PictureRequest

Promise<PictureFields | null>


<astl-picture-field>: the inspector's picture-regions and picture-points fields. The picture (by address, uploaded with the host's uploadAsset or chosen from its library, pickPicture) with its zones or pins drawn on it in palette colours and numbered; drag on it to draw a zone, click to place a pin; and every value in number fields, so nothing needs a pointer. Changes go to the inspector as astl-field-change events.

  • LitElement
new AstlPictureField(): AstlPictureField;

AstlPictureField

LitElement.constructor
Property Type Description
authoring Authoring | null -
element string | null The source id of the element the field belongs to (the inspector sets it).
field Field | null -

<astl-preview>: a button that compiles the current source with a throw-away salt and plays it in <astl-player> with local grading and the authoring's style templates, the way a student sees it, under policy. Invalid sources show their errors instead. Tokens set on the preview reach the player; the player's events stay inside.

  • AuthoringElement
new AstlPreview(): AstlPreview;

AstlPreview

AuthoringElement.constructor
Property Type Description
adapter EditorAdapter | null -
authoring Authoring | null -
hintPosition HintPosition Where the player puts a question's hint (hint-position), as on <astl-player>: row, in its help row after its Check (the default), or top, at the top of the question; another value is row. Set it as the host's students' player has it. A change applies at once.
pageNav PageNav How the player shows a view of several pages (page-nav), as on <astl-player>: bar (the default) or contents, a table of contents. Set it as the host's students' player has it. A change applies at once.
policy AttemptPolicy The policy the preview plays and grades under, the one the host's students get (default PRACTICE_POLICY). A change plays the preview again, once it has been shown.
get player(): AstlPlayer | null;

The player, once the first preview started.

AstlPlayer | null

get state(): PreviewState;

idle, loading, ready, invalid (errors shown) or failed.

PreviewState

refresh(): Promise<void>;

Compiles the current source and plays it. Resolves when the player is ready or the errors are shown.

Promise<void>


<astl-toolbar>: a word processor's toolbar for the editor in adapter, one row while it fits. By default, in order: the text style (a menu: paragraph, heading, subheading), bold, italic, underline, link, the two lists; the host's featured inserts as buttons, "Elements" (every component and content insert) and "Templates" (the named starters), menus with a search over one <astl-insert-menu>; the types' commands on the selection (EditorDescriptor.wrap, "Mark word"); the view switch (views, two or more: a segmented control of radios); undo and redo at the end. layout names the items and their order. Controls the adapter has no capability for are left out (format, undo, wrap). One tab stop: the arrow keys, Home and End move along it. Format buttons show the state at the cursor: pressed, or unavailable (aria-disabled, still focusable). A press never moves the editor's cursor: a pointer's leaves the focus in the editor, and a key's gives it back. Each button is a part, button button-<name>. The host's elements in the slots start and end sit at the bar's ends, each with its own tab stop.

  • AuthoringElement
new AstlToolbar(): AstlToolbar;

AstlToolbar

AuthoringElement.constructor
Property Type Description
adapter EditorAdapter | null -
authoring Authoring | null -
featured readonly string[] The inserts shown as buttons, in order: component tags (their default template), tag:template for a named starter, and the kit items text (an empty paragraph after the cursor's block), picture and page-break. Unknown names are skipped. Default: none (everything is under "Elements" and "Templates").
layout ToolbarLayout The items and their order: groups of item names (TOOLBAR_ITEMS), a rule between groups. An item that is not named is not drawn; an unknown name is skipped, a name given twice shows at its first place, and the view switch is a group of its own. Default: DEFAULT_TOOLBAR_LAYOUT.
view string The name of the current view.
views readonly ToolbarView[] The views of the view switch, in order; the first is the one the adapter edits, and in any other only the switch works. A pick fires astl-toolbar-view (bubbles, composed) with the view's name in detail.view; the host then sets view. Fewer than two (default: none): no switch.
get menu(): AstlInsertMenu | null;

The insert menu of "Elements" and "Templates": insert from it as a host would from <astl-insert-menu>.

AstlInsertMenu | null

get popupOpen(): boolean;

Whether one of the toolbar's popups is open: the style menu, the link dialog, an insert menu, a style popup or the style panel. An Escape that closes one goes no further than the toolbar's root, so a keydown listener on an editor around it never hears it.

boolean

openMenu(menu): Promise<void>;

Opens "Elements", "Templates" or "Layout" with its search, as its button does.

Parameter Type
menu InsertMenu

Promise<void>

openStyle(target): Promise<void>;

Asks for the style form of a target at the cursor, or the rules, as the style menu does: fires astl-style-open, and unless a host cancels it, shows them in a popup (they load now).

Parameter Type
target | EditorStyleTargetKind | "rules"

Promise<void>


What a host's uploadAsset or pickPicture rejects with to tell the author why: its message, already in the editor's locale, is shown as it is, instead of the generic failure text.

  • Error
new UploadRefused(message, options?): UploadRefused;
Parameter Type
message string
options? ErrorOptions

UploadRefused

Error.constructor
  • AuthoringElement
Property Type Description
adapter EditorAdapter | null -
authoring Authoring | null -
element string | null Source id of the element whose help this is.
inline boolean The element sits in a line of text: its help holds text, not paragraphs.

<astl-style-form>: the style of an element at the cursor (target, or what the cursor is innermost in), or of a rule of the document (rule): text, background and border, spacing, size and position, the named style, and "Own CSS", which says what the allow-list refused and why. "Save as a style" makes the element's own style a named one. Each commit of a field (a change) is one undo step, and the focus stays in the form. The adapter's style (EditorStyles) does the work; without it the form says so. Comes with loadStyleElements, on first use.

  • AuthoringElement
Property Type Description
adapter EditorAdapter | null -
authoring Authoring | null -
rule | Pick<EditorStyleRule, "name" | "for"> | null A rule to edit in place of an element: by its name, or for a tag.
target | EditorStyleTargetKind | null What the form styles, of what the cursor is in; null: the innermost.

<astl-style-rules>: the document's rules, each opening the form that edits it. "Text styles" holds a rule per tag (every paragraph, every heading of the exercise), "My styles" the named ones: add, rename, edit, delete. A deleted style leaves no class behind. Everything is one undo step, undone here or in the editor. A host places it (a view of its own, a card), with authoring and adapter, after loadStyleElements; the toolbar's style menu opens it in a popup otherwise.

  • AuthoringElement
Property Type
adapter EditorAdapter | null
authoring Authoring | null

Property Modifier Type Description
descriptors readonly readonly EditorDescriptor[] -
elements readonly readonly ElementEntry[] -
engine readonly Engine -
fonts readonly readonly EditorFont[] The fonts the style controls offer, each stack in the allow-list's normal form.
locale readonly string -
pickPicture readonly PickPicture | null The host's picture library, or null.
styles readonly readonly (EditorStylePreset & object)[] The ready styles the style menu and the style form offer, each style in the allow-list's normal form and each with its label: the host's, else the kit's message style.preset.<name> in the authoring locale, else the name.
styleTemplates readonly readonly StyleTemplate[] -
uploadAsset readonly UploadAsset | null The host's upload, or null: files are added by address only.
urlPolicy readonly UrlPolicy -
addMessages(catalogs): void;

Adds the catalogs of a part of the kit that loads later, under the host's catalogs, which may override them; t has them at once. Adding the same ones again does nothing.

Parameter Type
catalogs readonly MessageCatalog[]

void

assignIds(source): string;

source with fresh ids on pages, components and Check elements that lack one (or have an empty one).

Parameter Type
source string

string

describe(
issue,
source?,
options?
): string;

An issue as a sentence in the authoring locale. With the document it is about (source), a component's issue names the component as the author sees it, never by its id (the id stays in issue.at for "Show"): a block component by the number of its block on its page, as its card's head shows it ("Question 2 on page 1" for block 2), a component in text by its number among the components of its type on its page ("Gap 3 on page 1"); with page: false, without its page ("Question 2").

Parameter Type
issue Issue
source? string
options? DescribeOptions

string

descriptor(tag): EditorDescriptor | null;

The descriptor of a component tag, or null.

Parameter Type
tag string

EditorDescriptor | null

inspect(elementHtml, source?): InspectorModel | null;

The inspector model of one component element (source HTML), or of a Check element (astl-check: its button's text and a check-targets field), or null for elements it does not know. With the whole document (source), fields offer what other elements hold (the words of the bank a drop takes its words from, the questions of a check's page) and a question a Check element checks says which (checkedBy); without it they show the attribute's own control.

Parameter Type
elementHtml string
source? string

InspectorModel | null

inspectDocument(source): InspectorModel | null;

The document's own settings (its style template) as an inspector model for <astl-doc>, or null when the source has no <astl-doc> root or there is nothing to set. Apply its changes with update(source, change): the first element of the source is the document, so only its start tag changes.

Parameter Type
source string

InspectorModel | null

instantiate(
tag,
source,
templateId?,
selection?
): string;

The descriptor's template, or its named starter templateId, ready to insert into source: {{id}} becomes <idPrefix>-<n> with the smallest n whose id source does not use, {{selection}} the escaped selection (the text the author selected, EditorAdapter.selectedText; default ''), {{t:key}} an escaped message of the manifest namespace, and other components written without an id get fresh ones too. An element of a type with a companion and an empty attribute names the first such element of the template, else of source, else the one withCompanion adds. Throws for a tag without a descriptor or an unknown starter.

Parameter Type
tag string
source string
templateId? string
selection? string

string

loadMenuMessages(): Promise<void>;

Loads the menuMessages option's catalogs (what only insert menus show) once; t has them when it resolves. A failed load resolves too, and the next call tries again.

Promise<void>

outline(source): Outline;

Pages, their blocks and components, points and issue counts.

Parameter Type
source string

Outline

preview(source, options?): Promise<PreviewResult>;

Compiles with a random per-session salt and grades locally, under options.policy (default PRACTICE_POLICY). The source is not stored anywhere.

Parameter Type
source string
options? PreviewOptions

Promise<PreviewResult>

setPageCheck(
source,
check,
page?
): string;

source with check set (check: true) or cleared on the page page, or on every page when it is left out: a page's own Check in practice. A document without pages becomes one page with a fresh id (page-<n>) and check; clearing keeps the pages as they are (a document that became one page stays one). Byte-identical when nothing changes. In an editor, EditorAdapter.setPageCheck does the same as one undo step.

Parameter Type
source string
check boolean
page? string

string

t(
namespace,
key,
params?
): string;

A message in the authoring locale: kit (astl.editor), descriptor, engine and extra catalogs.

Parameter Type
namespace string
key string
params? Readonly<Record<string, string | number>>

string

templates(tag): readonly EditorTemplate[];

The named starters of a component tag (EditorDescriptor.templates); none without a descriptor.

Parameter Type
tag string

readonly EditorTemplate[]

update(elementHtml, change): string;

The element HTML with one inspector change applied; everything else stays byte-identical.

Parameter Type
elementHtml string
change InspectorChange

string

validate(source): ValidationReport;
Parameter Type
source string

ValidationReport

withCompanion(
tag,
source,
id?
): string | null;

source (with an inserted tag element) where that element, the one with the id id (default: the first whose companion attribute names none on its page), names a companion element of its own page, as pages play one at a time: the first one there, else the descriptor's companion template, added at the end of that page (of the document, without pages). Null when nothing changes: the type has no companion, or the element names one of its page already.

Parameter Type
tag string
source string
id? string

string | null


Property Modifier Type Description
catalogs? readonly readonly MessageCatalog[] More or overriding catalogs (any namespace), e.g. another UI locale.
descriptors readonly readonly EditorDescriptor[] One per component type authors can insert and inspect. Each tag must be registered in the engine.
elements? readonly readonly ElementEntry[] Player elements for <astl-preview>, eager or lazy.
engine readonly Engine -
fonts? readonly readonly EditorFont[] The fonts the style controls offer, in order. Default DEFAULT_FONTS, stacks every system has. A stack the style allow-list refuses throws.
locale readonly string The author's UI locale: labels, issues, template texts.
menuMessages? readonly () => Promise<readonly MessageCatalog[]> Catalogs only insert menus show (the one-line descriptions), loaded when a menu first opens rather than with the editor (loadMenuMessages): the built-ins' are the components package's builtInMenuMessages. The host's catalogs override them.
pickPicture? readonly PickPicture Opens the host's own picture library: the picture dialog and picture fields offer it beside the upload. The address it gives must pass urlPolicy. The picture dialog closes while the library is open, keeping what the author typed, so a modal of the host's own takes the pointer and the keys; it opens again when the library settles. Reject with UploadRefused to tell the author why.
styles? readonly readonly EditorStylePreset[] The ready styles the style menu and the style form offer, in order; []: none. Default DEFAULT_STYLES. A name isStyleName refuses, a declaration the style allow-list refuses, or a name given twice throws.
styleTemplates? readonly readonly StyleTemplate[] Style templates authors can pick (register the same ones with the engine and the player): the inspector offers them per component and for the whole document, labelled from their catalogs; <astl-preview> renders them.
uploadAsset? readonly UploadAsset Stores a picture file and returns its address (and size): the host's upload, used by the picture dialog, by pictures pasted or dropped into the editor and by picture fields; also by url fields with accept (a video, its captions). The address must pass urlPolicy. Without it, files are added by address only (pictures also from pickPicture). signal aborts when the author cancels or picks another file. The file's type is the browser's guess: check type and size on the server, and serve SVG with nosniff. Reject with UploadRefused to tell the author why.
urlPolicy? readonly UrlPolicy The engine's URL policy (createEngine({ urlPolicy })): the preview's player cleans with it and editors check picture addresses with it before they show them. Default isSafeUrl.

  • FieldTexts
Property Modifier Type Description
checked readonly boolean -
control readonly "checkbox" -
help readonly string | null Translated help text, or null.
kind readonly "attribute" -
label readonly string Translated label.
name readonly string -

A question a Check element can check, in its check-targets field.

Property Modifier Type Description
checked readonly boolean Whether this Check element checks it.
id readonly string Its source id.
label readonly string How authors know it on its page: its type and number ("Gap 2").
other readonly string | null The name of another Check element of the page that checks it ("Check button 2"), or null.

The questions a Check element checks (for): the graded questions of its page in order, each ticked when it checks it; one another Check element has says which. A change writes for with the ticked ones in this order (empty for none: it then checks nothing).

  • FieldTexts
Property Modifier Type Description
help readonly string | null Translated help text, or null.
kind readonly "check-targets" -
label readonly string Translated label.
name readonly string The attribute it writes: for.
targets readonly readonly CheckTargetModel[] -

  • FieldTexts
Property Modifier Type Description
attribute readonly string -
children readonly readonly ChildChoiceModel[] -
control readonly "select" | "radios" Radios for the enum values of the attribute, a select for the ids of other children (options).
help readonly string | null Translated help text, or null.
kind readonly "child-choice" -
label readonly string Translated label.
tag readonly string -

Property Modifier Type Description
id readonly string | null -
index readonly number Position among the children with this tag, from 0 (what child-choice changes use).
label readonly string The child's text, or a placeholder when it is empty.
options readonly readonly InspectorOption[] The choices of this child. Enum source: the attribute's values, the same for every child (an absent or unknown value matches none). Child source: each option child's id with its text, plus the "not set" option when the value is absent and the written value itself when it names no option (so the control shows what the source says).
value readonly string The written value; '' when absent.

  • FieldTexts
Property Modifier Type Description
attribute readonly string -
children readonly readonly ChildFlagModel[] -
help readonly string | null Translated help text, or null.
kind readonly "child-flag" -
label readonly string Translated label.
tag readonly string -

Property Modifier Type Description
checked readonly boolean -
id readonly string | null -
index readonly number Position among the children with this tag, from 0 (what child-flag changes use).
label readonly string The child's text, or a placeholder when it is empty.

  • FieldTexts
Property Modifier Type Description
attribute readonly string -
children readonly readonly ChildTextModel[] -
help readonly string | null Translated help text, or null.
kind readonly "child-text" -
label readonly string Translated label.
tag readonly string -

Property Modifier Type Description
id readonly string | null -
index readonly number Position among the children with this tag, from 0 (what child-attributes changes use).
label readonly string The child's text, or a placeholder when it is empty.
value readonly string The written value; '' when absent.

The element's own plain text, on one line (a badge's): a change replaces its whole content (kind: 'text').

  • FieldTexts
Property Modifier Type Description
help readonly string | null Translated help text, or null.
kind readonly "text" -
label readonly string Translated label.
name readonly "text" No attribute's: what the field is named by, as other fields are by theirs.
value readonly string -

How Authoring.describe names a component.

Property Modifier Type Description
page? readonly boolean Whether the name says the component's page when the document has pages: "Question 2 on page 1" (default true), or "Question 2" (false) for a host that shows the page apart.

A font a host offers (defineEditor({ fonts })): its name in the menus, and its CSS stack.

Property Modifier Type
name readonly string
stack readonly string

A ready style a host offers (defineEditor({ styles })), as a word processor has its built-in ones. Picked, it is written into the document as a named style (<astl-style>), which the exercise then owns like any other.

Property Modifier Type Description
label? readonly string Its name in the menus and in the rule. Default: the kit's message style.preset.<name>, else the name.
name readonly string The name it is applied by (class): what isStyleName takes.
style readonly string Its declarations, every one of which the style allow-list must keep.
text? readonly true A style of words: it goes on the selected text, and with only a cursor on what the cursor is in. Without it, a style of boxes: on what the cursor is in (a block, a component), words selected or not.

A change of the field, and the source id of the element it is for (an upload may end after the cursor moved).

Property Modifier Type
change readonly InspectorChange
element readonly string | null

What astl-help-open asks for.

Property Modifier Type
element readonly string
part readonly HelpPart

Property Modifier Type Description
checkedBy? readonly | { id: string; name: string; } | null The Check element that checks this question (OutlineComponent.check): its source id and its name ("Check button 1"); absent or null when none does, or without the document (Authoring.inspect without source).
fields readonly readonly InspectorFieldModel[] -
icon readonly string | null Icon name from the descriptor.
id readonly string | null -
label readonly string Translated menu label of the type (the tag when there is no descriptor).
tag readonly string -

Property Modifier Type
label readonly string
value readonly string

  • FieldTexts
Property Modifier Type Description
control readonly "number" -
help readonly string | null Translated help text, or null.
kind readonly "attribute" -
label readonly string Translated label.
max readonly number | null -
min readonly number | null -
name readonly string -
required readonly boolean -
step readonly "any" | "1" 1 for integers.
value readonly string The written value, else the manifest default; '' when neither.

Property Modifier Type Description
errors readonly number Every issue of the document.
pages readonly readonly OutlinePage[] -
points readonly number | null The sum of its pages' points, or null when nothing is graded.
warnings readonly number -

One block of a page (EditorBlockPlace): a block component directly on the page, a Check element (astl-check), or the content between two of them (paragraphs, headings, lists, quotes, pictures, with the inline components in their text).

Property Modifier Type Description
components readonly readonly OutlineComponent[] Its component, or the components in its text, in document order; none for a Check element.
errors readonly number Issues located on its components, or on the Check element.
id readonly string | null The component's or the Check element's source id (null when it has none), or null for a text block.
kind readonly "text" | "component" | "check" -
label readonly string The block's type: the component's label, block.check ("Check button") for a Check element, else block.gap ("Gap") for text that holds a graded component and block.text ("Text") for the rest.
points readonly number | null The sum of its components' points, or null when none of them is graded.
tag readonly string | null The component's tag (astl-check for a Check element), or null for a text block.
warnings readonly number -

A Check element of a page (<astl-check>): the questions it checks, as the engine and the player take them.

Property Modifier Type Description
id readonly string | null Its source id, or null when it has none.
label readonly string | null Its label, the text of its button, or null without one (the button says "Check").
targets readonly readonly string[] The source ids of the graded questions it checks, in order (planChecks): those its for names on its page, else the graded inline questions of the run of text right above it; none that a Check element before it has.
task readonly boolean Whether it is a task's own Check (check on an astl-task, whose id it has): every graded question in the task.

Property Modifier Type Description
check readonly string | null The source id of the Check element that checks it (OutlinePage.checks), or null. Where practice checks one question at a time, a question a Check element has gets no Check of its own.
errors readonly number Issues located on this component or its children.
id readonly string | null -
label readonly string Translated type label (the tag when there is no descriptor).
points readonly number | null Its points (default 1) when the type is graded, else null.
tag readonly string -
warnings readonly number -

Property Modifier Type Description
automatic readonly readonly (readonly string[])[] Its automatic Checks, where practice checks one question at a time: the source ids of the graded questions of each run of text that no Check element has, when there are two or more, in order. The player puts one Check after the last of them that checks them at once; a question alone keeps its own.
blocks readonly readonly OutlineBlock[] Its content as blocks, in order.
check readonly boolean Whether the page has check: its own Check in practice ("Check this page"). False for the implicit page, which cannot carry it (setPageCheck makes it a page that does).
checks readonly readonly OutlineCheck[] Its Check elements, in reading order (in its layouts' columns too).
components readonly readonly OutlineComponent[] -
errors readonly number Issues located on the page, its content and its components.
id readonly string | null null for the implicit page of a document without pages.
label readonly string | null -
points readonly number | null The sum of its blocks' points, or null when nothing on it is graded.
warnings readonly number -

A picture as the picture dialog asks for it: alt is '' for a decorative picture.

Property Modifier Type Description
alt readonly string -
caption? readonly string A caption makes the picture a figure.
height? readonly number -
src readonly string -
width? readonly number -

One pin of a picture-points field, in percent of the picture.

Property Modifier Type
id readonly string
index readonly number
label readonly string
x readonly number
y readonly number

  • PictureFieldBase
Property Modifier Type Description
alt readonly string -
altAttribute readonly string | null The element's attribute with the picture's alt text, which a picture from the host fills in while it is empty (null: none), and its value ('' when absent).
elementTag readonly string The tag of the element with the picture: the URL policy is asked for its srcAttribute, as the engine does.
help readonly string | null Translated help text, or null.
kind readonly "picture-points" -
label readonly string Translated label.
points readonly readonly PicturePointModel[] -
src readonly string -
srcAttribute readonly string The element's attribute with the picture's address, and its value ('' when absent).
tag readonly string -

One zone of a picture-regions field, in percent of the picture (absent or invalid numbers read as 0).

Property Modifier Type Description
flagged readonly boolean Whether the zone has the field's flag (a right place): drawn solid, the others dashed.
height readonly number -
id readonly string -
index readonly number Position among the children with the field's tag, from 0 (what child-* changes use).
label readonly string -
points readonly readonly (readonly [number, number])[] -
r readonly number -
shape readonly PictureShape -
width readonly number -
x readonly number -
y readonly number -

  • PictureFieldBase
Property Modifier Type Description
alt readonly string -
altAttribute readonly string | null The element's attribute with the picture's alt text, which a picture from the host fills in while it is empty (null: none), and its value ('' when absent).
elementTag readonly string The tag of the element with the picture: the URL policy is asked for its srcAttribute, as the engine does.
flag readonly string | null The boolean attribute of a child-flag field on the same child tag (a hotspot's right places), whose zones are drawn solid and the others dashed; null without one (every zone solid).
help readonly string | null Translated help text, or null.
kind readonly "picture-regions" -
label readonly string Translated label.
regions readonly readonly PictureRegionModel[] -
shapes readonly readonly PictureShape[] The shapes a zone may take: the values of the child's shape enum, or rectangles only when it has no shape (then no shape is written).
src readonly string -
srcAttribute readonly string The element's attribute with the picture's address, and its value ('' when absent).
tag readonly string -

What ask opens the dialog with.

Property Modifier Type Description
altRequired? readonly boolean The picture carries the task (a component's): its alt text is required, with no decorative choice.
caption? readonly boolean Whether to ask for a caption (a new picture). Default: true for a new picture, false for an edit.
current? readonly PictureFields A picture to edit: its address, alt text and size. Absent: a new picture.
decorative? readonly boolean Whether current is decorative; default: when its alt text is empty.
file? readonly File A file to upload first (pasted or dropped), through the authoring's uploadAsset.
target? readonly object The element and attribute the address is for, as the URL policy is asked; default img and src.
target.attribute readonly string -
target.tag readonly string -

How Authoring.preview grades.

Property Modifier Type Description
policy? readonly AttemptPolicy The policy of the local grading, the one the host plays the result under: a host whose students get less help than practice offers (no hints, no check of one interaction) previews with that. Default PRACTICE_POLICY.

A page or a component found by scanElements. Offsets index into the scanned string.

Property Modifier Type Description
end readonly number -
id readonly string | null The id attribute (entities decoded), or null when absent.
start readonly number -
tag readonly string -

  • FieldTexts
Property Modifier Type Description
control readonly "select" -
help readonly string | null Translated help text, or null.
kind readonly "attribute" -
label readonly string Translated label.
name readonly string -
options readonly readonly InspectorOption[] -
value readonly string The written value, else the default; '' (the "not set" option) when neither.

What astl-style-open asks for.

Property Modifier Type
target readonly | EditorStyleTargetKind | "rules"

The shape of a new table (the insert menu's "Table"): its columns, its body rows, and its headers.

Property Modifier Type Description
columns readonly number -
headerColumn readonly boolean -
headerRow readonly boolean -
rows readonly number The rows of its body; a header row comes on top of them.

What a WYSIWYG integration must provide so the authoring kit can drive it. Everything is in source HTML (the <astl-doc> format), so an adapter is free to use any internal model.

Property Modifier Type Description
editsSource? readonly boolean True when the editor shows and edits the source HTML as text (the textarea adapter, a code editor): <astl-editor> then names its view "HTML" and offers no HTML view of its own, which would show the same text. Absent: a visual editor.
style? readonly EditorStyles Styles at the cursor, named styles and layouts. Absent: an editor of source text (the textarea), no controls.
addPage(after?): string;

An empty page after the page after, in the source text (EditorAdapter.addPage).

Parameter Type
after? string

string

EditorAdapter.addPage

destroy(): void;

Removes the textarea listeners and every subscription.

void

optional focus(): void;

Focuses the editor, its cursor where it was (after a toolbar press from the keyboard). An editor that has the focus is left as it is, so a click there a moment before keeps its cursor.

void

EditorAdapter.focus

optional format(format, href?): boolean;

Toggles a format on the selection and focuses the editor; returns whether the document changed. A mark goes on all of the selected text, or off when all of it has it; link with an href links the selected text (or changes the link at the cursor) and without one removes the link at the cursor; a text style sets the blocks of the selection to it (heading or subheading again sets paragraph); a list wraps them in that list, turns the other list into it, or lifts them out of it. One undo step. Absent (with formatState): no formatting commands.

Parameter Type
format EditorFormat
href? string

boolean

EditorAdapter.format

optional formatState(): EditorFormatState;

The formats at the cursor and whether undo or redo can run. Present with format.

EditorFormatState

EditorAdapter.formatState

optional getCursor(): EditorBlockPlace | null;

The block holding the cursor (in a document without pages: page null), or null while the editor has no cursor in content. A host follows it to show the page being edited.

EditorBlockPlace | null

EditorAdapter.getCursor

getElement(id): string | null;

Source HTML of one component element, or null when the id is not in the document.

Parameter Type
id string

string | null

EditorAdapter.getElement

getSelection(): EditorSelection | null;

The component at the cursor, or null.

EditorSelection | null

EditorAdapter.getSelection

getSource(): string;

The whole document as source HTML.

string

EditorAdapter.getSource

insert(html, options?): void;

Inserts a source snippet (an instantiated template) at the cursor, never into a component: after the component the cursor is in. With replaceSelection, an inline snippet takes the place of the selected text. A rich-text editor keeps the text whole: a snippet of blocks (a block component, a paragraph) goes after the element the cursor is in directly on its page or column (a paragraph, a heading, a list), or in the place of that element when it is an empty paragraph; a layout goes after the layout the cursor is in, as layouts do not nest. A source editor (the textarea adapter) puts any snippet at the caret, as the author would type it.

Parameter Type
html string
options? EditorInsertOptions

void

EditorAdapter.insert

mergePage(id): boolean;

The page id joined to the page before it, in the source text (EditorAdapter.mergePage).

Parameter Type
id string

boolean

EditorAdapter.mergePage

optional moveBlock(block, direction): boolean;

Moves a block one place up or down within its page, the cursor with it; returns false, changing nothing, at the page's start or end or for a place that holds no block. One undo step. Absent: blocks do not move. A block in a column stays in its column; a block directly on the page moves past a whole layout, which itself never moves. A block next to a frame moves into it (its last place going up, its first going down), and a frame's first or last block out of it; a frame itself never moves.

Parameter Type
block EditorBlockPlace
direction "up" | "down"

boolean

EditorAdapter.moveBlock

onChange(listener): () => void;

Subscribe to document changes. Returns an unsubscribe function.

Parameter Type
listener () => void

() => void

EditorAdapter.onChange

optional onCursorChange(listener): () => void;

Subscribe to every move of the cursor and every change of the document or its history: what getCursor and formatState return may have changed. Returns an unsubscribe function. Present with either.

Parameter Type
listener () => void

() => void

EditorAdapter.onCursorChange

onSelectionChange(listener): () => void;

Subscribe to selection changes. Returns an unsubscribe function.

Parameter Type
listener (selection) => void

() => void

EditorAdapter.onSelectionChange

optional redo(): boolean;

Redoes the last undone step and focuses the editor; returns whether the document changed.

boolean

EditorAdapter.redo

optional removeBlock(block): boolean;

Deletes a block: its component, or all of its text; a page, a column or a frame left without content keeps one empty paragraph. Returns false, changing nothing, for a place that holds no block. One undo step.

Parameter Type
block EditorBlockPlace

boolean

EditorAdapter.removeBlock

optional removePage(id): boolean;

Deletes the page id and everything on it. The cursor goes to the start of the page before it, or of the next page when it was the first. Returns false, changing nothing, for the only page or an id that is not a page's. One undo step.

Parameter Type
id string

boolean

EditorAdapter.removePage

replaceElement(id, html): void;

Replaces one component element in place (inspector edits); the rest of the document is untouched. A cursor inside the element stays inside it: the inspector follows the element at the cursor while it writes.

Parameter Type
id string
html string

void

EditorAdapter.replaceElement

select(id): void;

Moves the cursor to an element by source id (a component or a page) and focuses the editor.

Parameter Type
id string

void

EditorAdapter.select

optional selectedText(): string;

The plain text of the selection when it lies within one text block (trimmed), else ''. A template's {{selection}} takes it, and insert with replaceSelection puts the snippet in its place. Absent: ''.

string

EditorAdapter.selectedText

setPageCheck(check, page?): boolean;

check set or cleared on a page or on every page, in the source text (EditorAdapter.setPageCheck).

Parameter Type
check boolean
page? string

boolean

EditorAdapter.setPageCheck

setSource(source): void;

Replaces the whole document.

Parameter Type
source string

void

EditorAdapter.setSource

splitPage(): string | null;

A page break at the caret, in the source text (EditorAdapter.splitPage).

string | null

EditorAdapter.splitPage

optional undo(): boolean;

Undoes the last step and focuses the editor; returns whether the document changed. Absent: no history.

boolean

EditorAdapter.undo

optional wrap(tag): boolean;

Runs the wrap command of the type tag (EditorDescriptor.wrap) on the selection and focuses the editor; returns whether the document changed. Absent: the editor offers no such command.

Parameter Type
tag string

boolean

EditorAdapter.wrap


  • FieldTexts
Property Modifier Type Description
accept readonly string | null A url attribute's files to upload (the field's accept), or null: the address is typed.
control readonly "text" -
help readonly string | null Translated help text, or null.
kind readonly "attribute" -
label readonly string Translated label.
name readonly string -
required readonly boolean -
value readonly string The written value; '' when absent.

  • FieldTexts
Property Modifier Type Description
help readonly string | null Translated help text, or null.
kind readonly "text-list" -
label readonly string Translated label.
max readonly number | null null = unbounded.
multiline readonly boolean Each value in a text area that keeps its line breaks.
tag readonly string -
values readonly readonly string[] -

A view the toolbar's view switch offers (AstlToolbar.views).

Property Modifier Type Description
description? readonly string What the view shows, said by its option's tooltip and to screen readers (its description).
label readonly string -
name readonly string -

A stored picture, as uploadAsset and pickPicture give it: its address, its size in pixels when known, and the alt text the host suggests for it (its library's, say). The picture dialog and the picture fields fill that alt text in where theirs is empty, and the author may change it there: it is the document's own copy from then on.

Property Modifier Type
alt? readonly string
height? readonly number
src readonly string
width? readonly number
type HelpKind = "hint" | "explanation" | "feedback";

What the insert menu adds: a hint, the explanation, or the next feedback text the element lacks.


type HelpPart = "hints" | "explanation" | "feedback";

A part of a graded element's help for students: its hints, its explanation, its feedback texts.


type InsertGroup = "components" | "exercises" | "content" | "layouts";

The groups of <astl-insert-menu>, in the order it shows them.


type InsertMenu = "elements" | "templates" | "layouts";

The toolbar's insert menus: every component and content insert, the named starters, or the layouts.


type InspectorChange =
| {
kind: "attribute";
name: string;
value: string | boolean | null;
}
| {
kind: "text-list";
tag: string;
values: readonly string[];
}
| {
attribute: string;
index: number;
kind: "child-flag";
tag: string;
value: boolean;
}
| {
attribute: string;
index: number;
kind: "child-choice";
tag: string;
value: string | null;
}
| {
attributes: Readonly<Record<string, string | null>>;
index: number;
kind: "child-attributes";
tag: string;
}
| {
attributes: Readonly<Record<string, string>>;
kind: "child-add";
tag: string;
}
| {
index: number;
kind: "child-remove";
tag: string;
}
| {
kind: "text";
value: string;
};

What an inspector control changes. Indexes count children with the same tag, from 0.

{
kind: "attribute";
name: string;
value: string | boolean | null;
}
Name Type Description
kind "attribute" -
name string -
value string | boolean | null A string sets the value, true writes a bare boolean attribute, false or null removes it.

{
kind: "text-list";
tag: string;
values: readonly string[];
}

{
attribute: string;
index: number;
kind: "child-flag";
tag: string;
value: boolean;
}

{
attribute: string;
index: number;
kind: "child-choice";
tag: string;
value: string | null;
}
Name Type Description
attribute string -
index number -
kind "child-choice" -
tag string -
value string | null The value to write; null removes the attribute.

{
attributes: Readonly<Record<string, string | null>>;
index: number;
kind: "child-attributes";
tag: string;
}
Name Type Description
attributes Readonly<Record<string, string | null>> -
index number -
kind "child-attributes" Several attributes of one child (a zone's shape and coordinates): a string sets one, null removes it.
tag string -

{
attributes: Readonly<Record<string, string>>;
kind: "child-add";
tag: string;
}

A new empty child with these attributes, after the last child of its tag (or at the end).


{
index: number;
kind: "child-remove";
tag: string;
}

Removes one child, its content included.


{
kind: "text";
value: string;
}

The element's whole content as this plain text (a badge's).


type InspectorFieldModel =
| TextFieldModel
| ContentTextFieldModel
| NumberFieldModel
| CheckboxFieldModel
| SelectFieldModel
| TextListFieldModel
| ChildFlagFieldModel
| ChildTextFieldModel
| ChildChoiceFieldModel
| ChildTableFieldModel
| PictureRegionsFieldModel
| PicturePointsFieldModel
| CheckTargetsFieldModel;

type LayoutName =
| EditorLayoutShape
| "picture-text";

The layouts of the insert menu's "Layout" group.


type PickPicture = (options) => Promise<UploadedAsset | null>;

Opens the host's own picture library and resolves with the chosen picture (its address, and its size when known), or null when the author closes it without one. The address must pass urlPolicy. Settle once the library has closed: the picture dialog and the picture fields then give the focus back themselves. signal aborts when the editor no longer waits for it (the picture dialog was asked for another picture or left the page, the picture field started another upload or pick): the host should then close its library.

Parameter Type
options { signal: AbortSignal; }
options.signal AbortSignal

Promise<UploadedAsset | null>


type PicturePosition = Placement;

type PictureShape = "rect" | "circle" | "polygon";

type Placement = "inline" | "start" | "end" | "center" | "full";

Where a picture, a figure or a component sits: in the line, floating at either side with text beside it, centred, or filling.


type PreviewResult =
| {
checker: LocalChecker;
issues: readonly Issue[];
ok: true;
view: string;
}
| {
issues: readonly Issue[];
ok: false;
};
{
checker: LocalChecker;
issues: readonly Issue[];
ok: true;
view: string;
}
Name Type Description
checker LocalChecker Local grading for this preview, under its policy (PreviewOptions.policy, practice by default).
issues readonly Issue[] Warnings.
ok true -
view string -

{
issues: readonly Issue[];
ok: false;
}

type ToolbarItem =
| "style"
| "font"
| "size"
| "bold"
| "italic"
| "underline"
| "link"
| "color"
| "highlight"
| "align"
| "spacing"
| "bulleted"
| "numbered"
| "clear"
| "featured"
| "elements"
| "templates"
| "layouts"
| "wraps"
| "views"
| "undo"
| "redo";

A name of the toolbar's items, for its layout (ToolbarLayout). featured stands for the featured inserts in their order, wraps for the types' commands on the selection ("Mark word") and views for the view switch.


type ToolbarLayout = readonly (readonly ToolbarItem[])[];

The toolbar's groups of items, in order: a rule parts each group from the one before.


type UploadAsset = (file, options) => Promise<UploadedAsset>;
Parameter Type
file File
options { signal: AbortSignal; }
options.signal AbortSignal

Promise<UploadedAsset>

const DEFAULT_FONTS: readonly EditorFont[];

The default list: stacks every system has, nothing to download or license.


const DEFAULT_STYLES: readonly EditorStylePreset[];

The default ready styles: boxes for a note, a tip, a warning, a definition, an example and a quote, then two for words. Their text reads at 4.5:1 on what is behind it, in the light theme and as the player paints them in the dark one (styled.browser.test.ts). A style of words holds no padding and no margin: on a phone the player gives whatever has a padding its own (styled.ts), which would pad a word inside its sentence.


const DEFAULT_TOOLBAR_LAYOUT: ToolbarLayout;

The toolbar's own layout: the text style; font and size; the marks and link; the colours; alignment and spacing; the lists and clear formatting; the inserts; the types' commands; the view switch; undo and redo.


const EDITOR_NAMESPACE: "astl.editor" = 'astl.editor';

i18n namespace of the authoring kit's own UI (insert menu, inspector, issues, preview).


const editorMessages: readonly MessageCatalog[];

const FEATURED_ITEMS: readonly string[];

Kit items a host can feature besides component tags (tag) and starters (tag:template).


const FIELD_CHANGE: "astl-field-change" = 'astl-field-change';

Fired with a FieldChange for the inspector to apply.


const FRAME_SOURCE: "<astl-box><astl-box-title></astl-box-title><p></p></astl-box>" = '<astl-box><astl-box-title></astl-box-title><p></p></astl-box>';

The source of a new frame (astl-box, the insert menu's "Frame"): its look by default, an empty title for the author to write and an empty paragraph under it.


const GLYPHS: Readonly<Record<"inline" | "block" | "picture" | "page" | "columns", SVGTemplateResult>>;

Generic glyphs by display, for pictures and for a page break: shapes only, stroked by the .icon rule of the element showing them (hosts restyle ::part(icon); data-icon carries the icon name).


const HELP_OPEN: "astl-help-open" = 'astl-help-open';

The event of a request for a graded element's help for students (detail: the element's id and a part), from a tag on its frame on the surface; the cursor is in the element by then. It bubbles, is composed and can be cancelled: a host that shows its own inspector calls preventDefault, shows it and calls its openHelp(part). Otherwise <astl-editor> opens it in its own inspector.


const INSERTED: "astl-inserted" = 'astl-inserted';

The event <astl-insert-menu> fires after it inserted something; detail.html is what it inserted.


const issueStyles: CSSResult;

const LAYOUT_COLUMNS: Readonly<Record<EditorLayoutShape, readonly (number | null)[]>>;

Each shape's columns by their flex-grow: null for an equal share.


const LAYOUT_SHAPES: readonly EditorLayoutShape[];

The shapes a layout can be changed to (EditorStyles.editLayout), in the menu's order.


const LAYOUTS: readonly LayoutName[];

const PICTURE_POSITIONS: readonly Placement[] = PLACEMENTS;

const PLACEMENTS: readonly Placement[];

const STYLE_OPEN: "astl-style-open" = 'astl-style-open';

The event of a request for a style form or the rules (detail.target: the target at the cursor, or rules). It bubbles, is composed and can be cancelled: a host that shows them itself calls preventDefault, and the element that was asked shows nothing. Otherwise that element shows its default: the toolbar a popup, the inspector a form in place.


const TOOLBAR_ITEMS: readonly ToolbarItem[];

Every item of the toolbar, by name, in the default layout's order: the formats, then the actions.


const TYPE_GLYPHS: ReadonlyMap<string, SVGTemplateResult>;

Glyphs of their own for the block types that toolbars feature by default (a choice, an ordering task, sorting into groups), by their descriptor's icon name, so featured buttons side by side differ; other types get their display's.


const VIEW_PICKED: "astl-toolbar-view" = 'astl-toolbar-view';

The event the view switch fires when an author picks a view; detail.view is its name.

function createAuthoring(options): Authoring;
Parameter Type
options AuthoringOptions

Authoring


function createTextareaAdapter(textarea): TextareaAdapter;
Parameter Type
textarea HTMLTextAreaElement

TextareaAdapter


function defineAuthoringElements(registry?): void;

Defines <astl-toolbar>, <astl-insert-menu>, <astl-inspector>, <astl-issues> and <astl-preview>, and the two they use for pictures, <astl-picture-dialog> and <astl-picture-field> (nothing is defined on import; <astl-style-form> and <astl-style-rules> come with loadStyleElements, on first use). Safe to call again; a tag already defined by another class throws, as two copies of the kit would otherwise mix silently.

Parameter Type Default value
registry? CustomElementRegistry customElements

void


function insertBadge(adapter): string;

Inserts a badge (astl-badge) at the cursor, as the insert menu's "Badge" does, for a host's own menu (its label and line: the kit's messages insert.badge and insert.badge.description): a pill holding "1", with a fresh id (badge-<n>), where EditorAdapter.insert puts an inline element. The TipTap adapter selects it, so its card shows its text and look. Returns its source HTML.

Parameter Type
adapter EditorAdapter

string


function insertCheck(authoring, adapter): string;

Inserts a Check element (astl-check) at the cursor, as the insert menu's "Check button" does, for a host's own menu (its label and line: the kit's messages insert.check and insert.check.description). It goes where EditorAdapter.insert puts a block, after the block the cursor is in, with a fresh id (check-<n>), and its for names the questions it takes there: the graded inline questions of the run of text right above it (OutlineCheck.targets), so moving text later does not change what it checks. The TipTap adapter selects it and makes the insert one undo step. Returns its source HTML.

Parameter Type
authoring Authoring
adapter EditorAdapter

string


function insertTask(adapter): string | null;

Inserts a task (astl-task) at the cursor, as the insert menu's "Task" does, for a host's own menu (its label and line: the kit's messages insert.task and insert.task.description): with a fresh id (task-<n>), an empty instruction and an empty line under it, as EditorStyles.insertLayout puts a layout, the cursor in its instruction. Returns its source HTML, or null with an editor that cannot (no style).

Parameter Type
adapter EditorAdapter

string | null


function layoutHtml(name, picture?): string;

The source of a layout; picture-text takes the source of its picture.

Parameter Type Default value
name LayoutName undefined
picture? string ''

string


function loadHelpForm(): Promise<__module>;

Defines <astl-help-form> (the inspector's help for students) where the kit is defined, and resolves once it is: a module of its own, outside the editor's first load, like the style elements. The inspector calls this when it shows a graded element, the insert menu before it adds help.

Promise<__module>


function loadStyleElements(): Promise<void>;

Defines <astl-style-form> and <astl-style-rules> where the kit is defined, and resolves once they are. A module of their own, outside the editor's first load: the toolbar and the inspector call this on first use, a host that places either element itself calls it first.

Promise<void>


function pictureHtml(picture): string;

The source HTML of a picture: an <img> that sits in text, or with a caption a <figure> that stands on its own. Every value is read once and escaped, and only the attributes of the content format are written.

Parameter Type
picture PictureFields

string


function pictureSize(value): number | undefined;

A picture's width or height as the content format takes it: a positive whole number of pixels (a safe integer), from a number or its written form; anything else is no size.

Parameter Type
value unknown

number | undefined


function positionChanges(
position,
style,
figure?
): EditorStyleChanges;

The changes that put an element whose style is style at position; leaving "full width" lets go of its width. A figure fills the line unless it has a width, so "centred" would not show on one without it (figure).

Parameter Type Default value
position Placement undefined
style string undefined
figure? boolean false

EditorStyleChanges


function positionOf(style): Placement;

The position a style value says, also written by hand, with physical sides or margin: 0 auto.

Parameter Type
style string

Placement


function renderIssues(
issues,
authoring,
adapter,
source?
): TemplateResult | typeof nothing;

A list of issues, or nothing when empty.

Parameter Type
issues readonly Issue[]
authoring Authoring
adapter EditorAdapter | null
source? string

TemplateResult | typeof nothing


function scanElements(source): ScannedElement[];

Pages (astl-page), tasks (astl-task) and components in document order, with offsets into source, for text-based adapters. A component is any custom element outside another component (so a misspelt tag is found too), but for the tags of the format: a layout's, a frame's and a task's head and sub-tasks are looked through, named styles are skipped; custom elements inside a component are its children, and inside a page or a task what they hold. Tolerant of messy input: comments, quoted > in attributes, any case, unclosed or self-closed elements.

Parameter Type
source string

ScannedElement[]


function splitPlacement(style): object;

A style value in two: what places the element (its position and width) and the rest. A surface that frames an element draws the first on the frame and the rest inside it.

Parameter Type
style string

object

Name Type
placed string
rest string

function styleNameFrom(label, taken): string;

A name for a new style from its label: lowercase letters, digits and dashes, the format's grammar, not taken.

Parameter Type
label string
taken ReadonlySet<string>

string


function tableHtml(shape): string;

The source of a new, empty table: a head of header cells (scope="col") with a header row, then a body whose rows start with a row header (scope="row") with a header column. Columns and rows within the format's limits.

Parameter Type
shape TableShape

string


function taskHtml(id): string;

The source of a new task with this id (the insert menu's "Task"): an empty instruction, an empty line.

Parameter Type
id string

string


function toolbarButtonParts(options): string[];

The part of every button a toolbar may draw (button-<name>) with these featured inserts, types with a command (their tags) and views, for an element that holds a toolbar and exports its parts.

Parameter Type
options { featured: readonly string[]; views: readonly string[]; wraps: readonly string[]; }
options.featured readonly string[]
options.views readonly string[]
options.wraps readonly string[]

string[]


function widthChanges(style, percent): EditorStyleChanges;

The changes that make an element whose style is style this wide: a handle and a field write the same.

Parameter Type
style string
percent number

EditorStyleChanges


function widthPercent(style): number | null;

The width a style value gives in percent, or null: none, or another unit.

Parameter Type
style string

number | null