Skip to content

Authoring kit

@astl/editor adds the Astrolabe parts of an editor to the WYSIWYG editor you already have: a toolbar with an insert menu, an inspector for answers and settings, a live issues list and a preview that grades. Your editor connects through one interface, EditorAdapter. How to use it: Any WYSIWYG editor. The kit assembled around a surface, ready to use, is <astl-editor>; a running example on a textarea: Authoring kit.

createAuthoring(options) returns the editor-independent logic (no DOM, so it also runs in workers, servers and agent tools). @astl/astrolabe/editor exports it too, with the built-in lists, and importing that entry in Node touches no DOM: a server validates a draft and names its issues as the editor does.

import { builtInEditors, createAuthoring } from '@astl/astrolabe/editor';
import { createEngine } from '@astl/astrolabe/engine';
const authoring = createAuthoring({
engine: createEngine({ secret: 'editor-preview-only-key' }), // every built-in
descriptors: builtInEditors,
locale: 'en',
});
const { issues } = authoring.validate(draft);
const sentences = issues.map((issue) => authoring.describe(issue, draft)); // "Question 1 on page 1 has no correct answer."
Option Type Meaning
engine Engine validates and compiles; give it a throw-away secret such as 'editor-preview-only-key'
descriptors EditorDescriptor[] one per component authors can insert and inspect; each tag must be registered in the engine
elements ElementEntry[] player elements for <astl-preview>, eager or lazy
locale string the author's UI locale: labels, issues, template texts
catalogs MessageCatalog[] more or overriding messages (any namespace), for example another locale
styleTemplates StyleTemplate[] looks the inspector offers per component and for the document, rendered by <astl-preview> (Looks); the inspector also offers each type's variants
urlPolicy UrlPolicy the engine's URL policy: editors show only pictures it allows, and <astl-preview> sets it as the page's player policy (the default never replaces a policy the page set). Default isSafeUrl (URLs)
uploadAsset UploadAsset the host's upload, (file, { signal }) to a Promise of { src, width?, height?, alt? }: stores a picture file (or a component's media file, through a url field with accept) and gives its address (and size in pixels, and the alt text the host suggests for it: the picture dialog and picture fields fill it in where theirs is empty). The picture dialog, pasted and dropped pictures, picture fields and url fields with accept use it; the address must pass urlPolicy, or nothing is written. signal aborts when the author cancels or picks another file. Reject with UploadRefused to tell the author why. Without it, pictures are added by address only (or from pickPicture), and the UI says so; files too
fonts EditorFont[] what the font menus offer, { name, stack }: stack must pass the allow-list, or this throws a TypeError. Default DEFAULT_FONTS, five system stacks
styles EditorStylePreset[] the ready styles the style menu and the style form offer, { name, style, label?, text? }; []: none. A name isStyleName refuses, a declaration the allow-list refuses or a name given twice throws a TypeError. Default DEFAULT_STYLES, eight styles
pickPicture PickPicture the host's own picture library, ({ signal }) to a Promise of { src, width?, height?, alt? }, or null when the author closes it without one; alt, the alt text the library keeps for the picture, fills in the picture dialog's or the element's empty alt text, which the author may change there. The picture dialog and picture fields offer it beside the upload; the address must pass urlPolicy, or nothing is written. 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. signal aborts when the editor no longer waits (the picture dialog was asked for another picture or left the page, the picture field started another upload or pick): close the library then
Member Returns Meaning
fonts EditorFont[] the fonts option, or its default
styles EditorStylePreset[] the styles option, or its default, 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
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
instantiate(tag, source) string the descriptor's template with a fresh id: <idPrefix>-<n>, the smallest n source does not use; {{t:key}} becomes an escaped message; other components written without an id get fresh ones too; an element of a type with a companion and that attribute empty names the first such element of the template, else of source (withCompanion then names one of the element's own page). A third argument, the id of a named starter, instantiates that starter instead. A fourth, the text the author selected (default ''), escaped, takes the place of {{selection}}, so a gap made from a word takes it as its answer. Throws for an unknown tag or starter
withCompanion(tag, source, id?) string | null for a descriptor with a companion ({ tag, attribute }, a gap and its word bank): source where the element id (default: the first whose companion is not on its page) names a companion element of its own page, as pages play one at a time: the first one there, else that tag's template added at the end of the page; null when nothing changes. <astl-insert-menu> applies it after inserting a default template and keeps the new element selected
templates(tag) EditorTemplate[] the named starters of a type (its descriptor's templates), none without
inspect(elementHtml, source?) InspectorModel | null the inspector model of one component element: { tag, id, label, icon, fields }, or of a Check element (its label and a check-targets field); with the whole document source, fields offer what other elements hold (a drop lists the words of its bank, a check its page's questions) and a question a check has says which (checkedBy: { id, name })
inspectDocument(source) InspectorModel | null the look of the whole exercise: a style-template field for <astl-doc>; null when no template allows the document scope and none is written (Looks)
update(elementHtml, change) string the element with one InspectorChange applied; everything else stays byte-identical
validate(source) ValidationReport { ok, issues } from the engine
describe(issue, source?) string an issue as a sentence in the authoring locale; with the document it is about, a component is named as the author sees it, never by its id (issue.at keeps the id): a block component by its block's number 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 its type on its page ("Gap 3 on page 1"). A third argument, the options { page: false }, leaves the page out ("Question 2"), for a host that shows the page apart; the default keeps it. A document without pages has no page to leave out
assignIds(source) string source with fresh ids on pages and components that lack one
outline(source) Outline pages with their blocks, components, points and error and warning counts; each page's check says whether it has its own Check in practice (false for the implicit page of a document without pages)
setPageCheck(source, check, page?) string source with check set (true) or cleared on the page page, or on every page when it is left out: a page's own Check in practice (the content format). A document without pages becomes one page with a fresh id (page-<n>, after the named styles at its head) and check; clearing keeps the pages as they are, so a document that became one page stays one. Byte-identical when nothing changes (set already, cleared already, an unknown id). In an editor, the adapter's setPageCheck does it as one undo step
preview(source, options?) Promise<PreviewResult> compiles with a random per-session salt and grades locally ({ ok, view, checker, issues }), under options.policy (default PRACTICE_POLICY)
descriptor(tag) EditorDescriptor | null the descriptor of a tag
t(namespace, key, params?) string a message in the authoring locale
engine, locale, descriptors, elements the options
styleTemplates, urlPolicy the options, with their defaults
uploadAsset UploadAsset | null the host's upload, or null
pickPicture PickPicture | null the host's picture library, or null

UploadRefused is what uploadAsset or pickPicture rejects with to tell the author why: new UploadRefused(message, options?) is an Error whose message, already in the editor's locale, is shown as it is instead of the generic failure text (a blank one keeps that text). It is known by its name, UploadRefused, so another copy of the package counts too.

pictureHtml({ src, alt, width?, height?, caption? }) writes the source of a picture as the picture dialog gives it: an <img> (it sits in text), or with a caption a <figure> with its <figcaption>. Every value is escaped and only the attributes of the content format are written; alt: '' is a decorative picture.

insertCheck(authoring, adapter) inserts a Check element at the cursor as the insert menu's "Check button" does, for a host's own menu: after the block the cursor is in, with a fresh id and its for the questions of the run of text right above it (one undo step in the TipTap editor). It returns its HTML.

outline(source) is what a host shows next to the editor: a list of pages, each with its blocks. A block is a block component directly on the page, a Check element, or the content between two of them (paragraphs, headings, lists, pictures, with the inline components in their text): the same blocks EditorAdapter.moveBlock, removeBlock and getCursor take by their place, { page, index }. The content format has no blocks. A layout is not one: the blocks in its columns are on the page's list, in reading order.

interface Outline { pages: OutlinePage[]; errors: number; warnings: number; points: number | null }
interface OutlinePage {
id: string | null; // null for a document without pages
label: string | null;
errors: number; warnings: number; // on the page, its content and its components
points: number | null; // the sum of its blocks' points, null when nothing on it is graded
components: OutlineComponent[]; // each with `check`: the id of the Check element that has it, or null
blocks: OutlineBlock[];
checks: OutlineCheck[]; // its Check elements, in reading order
automatic: string[][]; // the questions of each run of text no check has, two or more: an automatic Check each
}
interface OutlineBlock {
kind: 'component' | 'text' | 'check';
id: string | null; tag: string | null; // the component's or the check's, null for a text block
label: string; // the component's type ("Closed question"), "Check button", else "Gap" for text with a graded component, else "Text"
points: number | null; // a component's points (default 1), or the sum of those in the text
components: OutlineComponent[]; // its component, or those in its text
errors: number; warnings: number;
}
interface OutlineCheck {
id: string | null;
label: string | null; // its button's text, null for "Check"
targets: string[]; // the source ids of its questions, as the engine and the player take them
task: boolean; // a task's own Check (`check` on an astl-task, whose id it has): every graded question in the task
}

The page with the cursor is adapter.getCursor?.()?.page, which changes on onCursorChange.

A type can bring whole exercises with sample content next to its default template, which stays what its own entry inserts: templates: [{ id, label, description?, icon?, template }] on its EditorDescriptor. Ids are kebab-case and unique in the type (createAuthoring throws otherwise); each template has the placeholders of template (exactly one {{id}}, texts as {{t:key}} from the type's catalogs, so a starter comes in every UI language).

A starter can hold more components than its own, such as the word bank's "Drag words into gaps": {{id}} goes on the type's own element (the bank) and the others (its gaps) are written without an id. Each insert gives them fresh ones, and every element of a type with a companion (a gap) that leaves the attribute out names the starter's own bank.

type InspectorChange =
| { kind: 'attribute'; name: string; value: string | boolean | null } // true = bare attribute, false/null = remove
| { kind: 'text-list'; tag: string; values: readonly string[] } // e.g. the <astl-alt> alternatives
| { kind: 'child-flag'; tag: string; attribute: string; index: number; value: boolean } // e.g. `correct` on option 2
| { kind: 'child-choice'; tag: string; attribute: string; index: number; value: string | null } // e.g. `answer` on statement 1
| { kind: 'child-attributes'; tag: string; index: number; attributes: Record<string, string | null> } // a zone's shape and coordinates
| { kind: 'child-add'; tag: string; attributes: Record<string, string> } // a new empty child after the last of its tag
| { kind: 'child-remove'; tag: string; index: number } // one child, its content included
| { kind: 'text'; value: string }; // the element's whole content as plain text (a badge's)

Inspector fields come from the EditorDescriptor (or from the manifest when it has no fields); controls follow the attribute types: text, number with min, max and step, checkbox, select with translated options from editor.value.<attribute>.<value>, text-list, child-flag, child-text (a text input per child for a free-text attribute, e.g. the word each clue of a word search hides; an empty input removes it, through a child-attributes change), child-choice (radios of the enum values, or with options: '<tag>' a select of the ids of those children), check-targets (a Check element's only: { kind: 'check-targets', name: 'for', targets: [{ id, label, checked, other }] }, a checkbox per graded question of its page, written as for through an attribute change), text (a badge's only: { kind: 'text', name: 'text', label, help, value }, its text, written whole through a text change; its shape, fill and colour are select fields) and child-table ({ kind: 'child-table', tag, columns: [{ attribute, label }], label, help? }: a row per child, named by its text, with a text, number or select control per column, Remove per row and Add, through child-attributes, child-remove and child-add changes; a crossword's words). An attribute field with options: { from, tag } is a select of the ids of the tag children of the element whose id is in the attribute from, by their text (a drop's answer among the words of its bank bank); without the document or that element it keeps its own control. An attribute field with variants shows only while the element shows one of them (its variant when the manifest has that value, else the default): a select's native switch is for its dropdown alone. Each component's reference page lists its fields.

Two field options are for media:

  • { kind: 'attribute', name, label, help?, accept } on a url attribute: next to its address, an upload of the files accept names (a file input's accept, e.g. video/mp4,video/webm) through uploadAsset. The address it gives goes to the element the upload was for, when urlPolicy allows it; the field says what happened.
  • { kind: 'text-list', tag, label, help?, multiline: true }: each child in a text area that keeps its line breaks (a transcript), not on one line.

Two field kinds are for components with a picture (<astl-picture-field> draws them):

  • { kind: 'picture-regions', tag, src, alt?, label, help? }: zones on the picture of the element's url attribute src, one child of tag each. A zone has id, shape (rect, circle or polygon), x and y (a rectangle's top-left corner, a circle's centre), width and height (rectangle), r (circle, a share of the width), points (polygon: x,y x,y ...) and an optional label. Every coordinate is a percentage of the picture: x of its width from the left edge, y of its height from the top.
  • { kind: 'picture-points', tag, src, alt?, label, help? }: pins on the picture, one child of tag each, with id, x, y (percent) and label.

Both show the picture, take its address, an upload or a picture from pickPicture (with alt, the element's attribute that holds the picture's alt text, an upload's or a pick's alt fills it in while it is empty), and draw each zone or pin in the palette colour of its number (--astl-palette-1 to -8) with the number on it, so no zone is told apart by colour alone. Authors drag on the picture to draw a zone or click it to place a pin, and edit every value in number fields (no pointer needed): add, remove, change the shape around the same centre, add or remove polygon points, label.

Call defineAuthoringElements() once (nothing is defined on import), then give each element its authoring and adapter properties. Use as many as you like.

Element Members What it does
<astl-toolbar> featured: string[], views: { name, label, description? }[], view, layout: ToolbarLayout, menu, popupOpen, openMenu(menu), openStyle(target) a word processor's toolbar, by default (layout: DEFAULT_TOOLBAR_LAYOUT, groups of TOOLBAR_ITEMS; its layout): text style, with an adapter that has style also font, size, colours, alignment, spacing and clear formatting; bold, italic, underline, link, lists, then the featured inserts (component tags, tag:template, text, picture, page-break), "Elements" and "Templates" (the insert menu in a popover, with a search: the components, "Picture" and "Page break", or the starters), the types' commands, the views as a radio group when there are two or more (a description is the option's tooltip and its description for a screen reader; a press fires astl-toolbar-view, detail.view; away from the first view the other buttons are unavailable), undo and redo. One tab stop with the arrow keys; a press never moves the cursor, and buttons the adapter has no capability for are left out. openMenu('elements' | 'templates') opens a menu; openStyle(target) asks for a form or the rules (below); popupOpen is true while a popup is open, and an Escape that closes one stops at the toolbar's root. Slots: start and end, the host's elements at the bar's ends, each with its own tab stop. Parts: toolbar, button (every button) and button-<name> (each by its name: button-bold, button-insert-astl-gap, button-wrap-<tag>, button-view-<name>; the buttons' parts), icon-button (the ones that are an icon alone), views (the view switch) and view (each of its options), separator (the rule that opens each group but the first and the view switch), icon, insert, menu, style-menu, style-colors, style-panel
<astl-insert-menu> insert(tag, template?): string | null, add(tag, template?), insertPicture(): Promise<string | null>, insertPageBreak(), insertLayout(name): Promise<string | null>, insertFrame(): string | null, insertTask(): string | null, insertRule(): string | null, pickTable(): Promise<void>, insertTable(shape?): string | null, insertBadge(): string | null, addHelp(kind): Promise<string | null>, filter, groups, dialog, picking buttons in the named groups of groups (default all four): "Components" (each type with its default template), "Exercises" (the named starters, when any), "Content" ("Picture", "Badge" (insertBadge), "Hint", "Explanation" and "Feedback" (addHelp: into the graded element at the cursor, else onto the page), and "Page break" when the adapter has splitPage) and "Layout" (when the adapter has style: the layouts, layoutHtml(name) being the source of each, "Frame" (insertFrame(), its source FRAME_SOURCE), "Task" (insertTask(), with a fresh id, its source taskHtml(id)), "Horizontal line", insertRule(), then "Table": pickTable() shows a picker beside the list (picking, reflected as an attribute), a grid of squares to point at or size with the arrow keys and a header row and a header column to tick, Enter or a click inserting it (insertTable(shape?), its source tableHtml(shape)); in a toolbar narrower than 30rem (a phone) the picker takes the list's place, with counters and an "Insert table" button); each button's name is its label and description. A press inserts at the cursor, and astl-inserted fires (detail.html). filter shows only the entries whose label or description holds it (any case, accents ignored); dialog is a picture dialog to use instead of its own
<astl-inspector> model: InspectorModel | null the form for the component at the cursor: answers, alternatives, correct options, scoring, points. Its header (part="header", also part="head") shows the type's icon, the type as the heading ("Gap") and the id in a monospace chip (part="id", also in data-id of the heading); for a block component it has the icon buttons "Move up", "Move down" and "Delete" (part="actions", their texts the names and tooltips), through the adapter's moveBlock and removeBlock. Under it the element's own issues as banners (part="issue": icon, severity word, the sentence its frame shows), then the fields (part="field", each label part="label"), and with an adapter that has style a section (part="style") with what the cursor is in, each opening its form (below). A graded element's help for students heads the form (<astl-help-form>, its parts forwarded); openHelp(part): Promise<void> opens it at hints, explanation or feedback, the part's first field focused, as a tag on the surface asks with astl-help-open (HELP_OPEN, cancelable, detail: { element, part }). --astl-inspector-columns (default 1) sets the form's columns: with 2, selects, numbers and short texts sit side by side and everything else spans the row
<astl-issues> issues: Issue[] | null, validate() live validation in the UI locale, 300 ms after the last change, errors first; choosing an issue calls adapter.select(id)
<astl-preview> state, player, policy, hintPosition, pageNav, refresh(): Promise<void> compiles on request and plays the result in <astl-player> with local grading, under policy (default PRACTICE_POLICY; a change plays a shown preview again); an invalid source shows its errors instead. state: idle, loading, ready, invalid or failed. hintPosition (attribute hint-position, default row) goes on to the player, as its hint-position: set it as your students' player has it; a change applies at once. So does pageNav (attribute page-nav, default bar), as the player's page-nav. The player's help parts are the preview's too, under their own names (help, help-actions, hint-cost and the rest, help-top included), so your stylesheet for the students' help rows reaches the preview's with astl-preview::part(...)
<astl-picture-dialog> ask(request?): Promise<PictureFields | null> a modal dialog for one picture: a file (uploaded with uploadAsset), a picture from the host's library (pickPicture: the dialog closes while the library is open, then opens again with the picture and the focus on the alt text) or an address, the alt text (required, or "decorative" for alt=""; an upload's or a pick's alt fills it in while it is empty and the picture is not decorative) and, for a new picture, an optional caption. The address must pass urlPolicy. request: { current?, file?, caption?, decorative? }; null when the author cancels. The insert menu has its own unless given one
<astl-picture-field> field, authoring the inspector's picture fields (above); it fires astl-field-change with an InspectorChange
<astl-style-form> target, rule the style form of an element at the cursor (target: a kind, or null for the innermost) or of a rule (rule: { name } or { for }). Call loadStyleElements() first. Parts: root, section, field, label
<astl-style-rules> the document's rules: text styles and named styles. Call loadStyleElements() first. Parts: root, title
<astl-help-form> element, inline a graded element's help for students (hints with their cost and order, a new one a draft until it has text, the explanation, the feedback texts), edited through replaceElement; a disclosure, closed for each element until opened, that says what the element has while closed. The inspector shows it for the element at the cursor. Call loadHelpForm() first. Parts: help, help-toggle, help-summary, help-body, help-add, help-move, help-remove

All of them use native controls, the --astl-* tokens (override them on the elements), data-theme for the theme, and the parts root and title (plus button, icon and player where they have them). See Looks.

In a narrow column (a small phone, larger text), the cards of <astl-issues>, <astl-inspector> and <astl-preview> take less padding, from their own width in the page's root font size: 0.5rem at 20rem and under, and 0.25rem at their sides at 13rem and under, so they switch together in a column of one width; the player in the preview does the same. They measure their width rather than being size containers, so in any layout they take the width they had; in a box that sizes to its content, a card that narrow because its content is short takes the smaller padding too.

<astl-style-form> and <astl-style-rules> are outside the kit's first load: loadStyleElements() defines them where defineAuthoringElements defined the kit, once, and resolves when they are. The toolbar and the inspector do that themselves on first use. Each asks for a form or the rules with the event astl-style-open (STYLE_OPEN, cancelable, detail: { target }, a target kind or 'rules'), and shows them itself unless a host cancels it. How an author uses them: Styles in the editor.

EditorAdapter (@astl/core) is the only thing an editor integration implements:

Member Meaning
getSource() / setSource(source) the whole <astl-doc> as source HTML
insert(html, options?) insert an instantiated template at the cursor, never into a component (after it). A rich-text editor puts a snippet of blocks after the element the cursor is in on its page, or in the place of an empty paragraph. With { replaceSelection: true }, an inline snippet takes the place of the selected text
getElement(id) / replaceElement(id, html) one component element as source HTML, read and replaced in place
getSelection() { id, tag } of the component at the cursor, or null
select(id) move the cursor to a component or a page and focus the editor
onChange(listener) / onSelectionChange(listener) subscriptions; each returns an unsubscribe function
editsSource (optional) 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
wrap(tag) (optional) runs the wrap command of a type on the selection (EditorDescriptor.wrap); returns whether the document changed
splitPage() (optional) a page break at the cursor (a paragraph or a heading splits there; any other block stays whole, the break after it): the new page's id (page-<n>, with the lang and dir of its page), or null when the cursor is on no page
addPage(after?) (optional) an empty page after the page after, else after the last page: its id
mergePage(id) (optional) joins the page to the page before it, which keeps its id, title, lang and dir; false for the first page or an unknown id
removePage(id) (optional) deletes the page and everything on it, the cursor at the start of the page before (of the next one for the first page); false for the only page or an unknown id
setPageCheck(check, page?) (optional) sets (true) or clears check on the page page, or on every page when it is left out, one undo step said on the notice line; a document without pages becomes one page with a fresh id and check in the same step. false when it was so already or for an unknown id. The page head's "Check this page" takes the same step
format(format, href?), formatState() (optional) toggles bold, italic, underline, link (with href; without, removes it), paragraph, heading, subheading, bulleted or numbered on the selection, one undo step; the state is { active, enabled, href, undo, redo } at the cursor, for the toolbar's pressed and unavailable buttons
undo(), redo() (optional) the editor's history; each returns whether the document changed
moveBlock(place, direction), removeBlock(place) (optional) moves a block { page, index } one place 'up' or 'down' within its page, the cursor with it, or deletes it; one undo step each, false when nothing changes
getCursor(), onCursorChange(listener) (optional) the block with the cursor, { page, index } or null, and a subscription to every cursor move and change (what getCursor and formatState return may have changed)
selectedText() (optional) the plain text of the selection within one text block, else '': what {{selection}} takes
focus() (optional) focuses the editor with its cursor where it was; the toolbar calls it after a key press
style (optional) EditorStyles, below: turns on the style controls, the form, the rules and the layouts. onCursorChange tells them when to read it again

EditorStyles, each command one undo step that keeps the cursor. What it writes passes the allow-list (@astl/core/declarations); every change returns whether the document changed:

Member Meaning
state() at the cursor: textEnabled (the text takes styles), hasSelection, text (the declarations of the selected text, those it has throughout), mixed (the properties with more than one value), textClass, and targets, what the cursor is in from the inside out, each { kind, tag, style, className }
setText(changes) declarations on the selected text, one span per run, its other declarations kept; a value of null removes one. With only a cursor, on what is typed next
setTarget(kind, changes) declarations on a target: picture, figure (its picture then fills it), block (every text block of the selection, a table's cell among them), component, column, layout, frame (an astl-box), rule (a selected horizontal rule), table
replaceTarget(kind, style) a target's whole style
setClass('text' | kind, name | null, rule?) sets the named style, replacing any, or takes it away. With rule (a ready style, { name, label, style } of the same name), a document without a rule of that name gets it in the same undo step; one of the document's own stays as it is. false, changing nothing, for a rule of another name or with for, a new rule past the limit, or a class that changes nothing (no target, or already there)
clear() takes the marks and text styles of the selection, and the styles of the blocks it covers whole
rules() the document's rules, { name?, label?, for?, style }, in order
setRule(rule) adds or changes a rule, found by its name or its for; a for rule with no style goes
removeRule({ name } | { for }) removes a rule; a named one's class leaves every element
saveRule(kind, label) turns a target's own style into a new named style with this label, the target carrying it: its name, or null
insertLayout(html) inserts a layout's, a frame's or a table's source at the cursor, the cursor in its first empty block (a frame's title, a table's first cell); a frame never goes into a frame, nor a layout into a frame in a column, nor a table into a table: from inside one, it goes after it
layout() (optional) the layout the cursor is in, { shape, columns, empty } (shape: two, three, wide-narrow, narrow-wide, or null for another), or null
editLayout(edit) (optional) on the layout the cursor is in, one undo step: unwrap (its content stays in place, one column after another), delete (with its content; ask first when layout().empty is false), or a shape (the content stays; a column that goes gives its content to the last one left). false, changing nothing, without a layout or for the shape it has
frame() (optional) the frame (astl-box) the cursor is in, { look, tag, empty } (look: its title-place, variant, icon and palette as written, an absent one its default), or null
editFrame(edit) (optional) on the frame the cursor is in, one undo step: { attribute, value } (one of its look, null for its default), { tag: true | false } (a tag added, the cursor in it, or taken away), unwrap (its content stays in place, its title a heading and its tag a paragraph before it) or delete (with its content; ask first when frame().empty is false). false, changing nothing, without a frame or for what it has
table() (optional) the table the cursor is in, { rows, columns, headerRow, headerColumn, caption, can, empty } (can: per command and for headerRow and headerColumn, whether it would change the table now, at the cell with the cursor), or null
editTable(edit) (optional) on the table the cursor is in, at the cell with the cursor, one undo step: row-before, row-after, row-delete, column-before, column-after, column-delete (a merged cell across the line grows or shrinks, one that starts on a deleted row moves on), merge-right, merge-down (colspan, rowspan, their content joined, one question at most), split, { headerRow } (the first row as th scope="col" in a thead), { headerColumn } (each body row's first cell as th scope="row"), { caption } (added, the cursor in it, or taken away) or delete (ask first when table().empty is false). false, changing nothing, without a table or for an edit can says no to

createTextareaAdapter(textarea) is the reference implementation: it edits the source as text, keeps your formatting and finds elements by id. It has the page methods and none of the other optional capabilities: the toolbar shows its inserts only, and they go at the caret. destroy() removes its listeners. insert(html) replaces the selection unless that would break the source: inside a tag it inserts after the tag, inside or on a component after that component, outside <astl-doc> at the end of the last page. Its page methods change only what a break or a join needs (page tags, the tags of a paragraph broken in the middle, an empty paragraph for a page left without one), so the rest of the source stays as written. Change events fire on input and after the adapter's own edits; selection events on select, keyup, click and focus, only when the component at the caret changes.

scanElements(source) lists pages, tasks and components with their { tag, id, start, end } offsets in the text, for text-based adapters, a task before the components it holds. It tolerates comments, quoting, case and unclosed tags. tableHtml({ columns, rows, headerRow, headerColumn }) is the source of a new, empty table within the format's limits: a header row of th scope="col" cells in a thead over rows body rows, each starting with a th scope="row" with a header column. insertTask(adapter) inserts a task with a fresh id (task-<n>) through EditorStyles.insertLayout, the cursor in its instruction, for a host's own menu, and returns its source; taskHtml(id) is that source. A task's card (inspect) has its number, level, check and palette, its tags as a text-list field (the first added right after its instruction) and their icons as a child-choice field; inspectDocument has task-numbering once the document has a task.

The kit's own strings are in the namespace astl.editor (editorMessages, English and Polish; what only the style form and rules say loads with them, and catalogs rewords those too). Labels, help texts and templates of each component come from its own catalogs (editor.*, template.* keys).