@astl/editor 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +96 -0
- package/LICENSE +202 -0
- package/README.md +43 -0
- package/dist/authoring.d.ts +284 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +566 -0
- package/dist/authoring.js.map +1 -0
- package/dist/define.d.ts +8 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +35 -0
- package/dist/define.js.map +1 -0
- package/dist/edit.d.ts +45 -0
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +150 -0
- package/dist/edit.js.map +1 -0
- package/dist/elements/base.d.ts +31 -0
- package/dist/elements/base.d.ts.map +1 -0
- package/dist/elements/base.js +75 -0
- package/dist/elements/base.js.map +1 -0
- package/dist/elements/color-control.d.ts +25 -0
- package/dist/elements/color-control.d.ts.map +1 -0
- package/dist/elements/color-control.js +139 -0
- package/dist/elements/color-control.js.map +1 -0
- package/dist/elements/help-form.d.ts +31 -0
- package/dist/elements/help-form.d.ts.map +1 -0
- package/dist/elements/help-form.js +371 -0
- package/dist/elements/help-form.js.map +1 -0
- package/dist/elements/insert-menu.d.ts +79 -0
- package/dist/elements/insert-menu.d.ts.map +1 -0
- package/dist/elements/insert-menu.js +362 -0
- package/dist/elements/insert-menu.js.map +1 -0
- package/dist/elements/inspector.d.ts +24 -0
- package/dist/elements/inspector.d.ts.map +1 -0
- package/dist/elements/inspector.js +846 -0
- package/dist/elements/inspector.js.map +1 -0
- package/dist/elements/issue-list.d.ts +18 -0
- package/dist/elements/issue-list.d.ts.map +1 -0
- package/dist/elements/issue-list.js +85 -0
- package/dist/elements/issue-list.js.map +1 -0
- package/dist/elements/issues.d.ts +24 -0
- package/dist/elements/issues.d.ts.map +1 -0
- package/dist/elements/issues.js +81 -0
- package/dist/elements/issues.js.map +1 -0
- package/dist/elements/picture-dialog.d.ts +40 -0
- package/dist/elements/picture-dialog.d.ts.map +1 -0
- package/dist/elements/picture-dialog.js +433 -0
- package/dist/elements/picture-dialog.js.map +1 -0
- package/dist/elements/picture-field.d.ts +33 -0
- package/dist/elements/picture-field.d.ts.map +1 -0
- package/dist/elements/picture-field.js +692 -0
- package/dist/elements/picture-field.js.map +1 -0
- package/dist/elements/preview.d.ts +34 -0
- package/dist/elements/preview.d.ts.map +1 -0
- package/dist/elements/preview.js +165 -0
- package/dist/elements/preview.js.map +1 -0
- package/dist/elements/style-form.d.ts +30 -0
- package/dist/elements/style-form.d.ts.map +1 -0
- package/dist/elements/style-form.js +640 -0
- package/dist/elements/style-form.js.map +1 -0
- package/dist/elements/style-load.d.ts +26 -0
- package/dist/elements/style-load.d.ts.map +1 -0
- package/dist/elements/style-load.js +50 -0
- package/dist/elements/style-load.js.map +1 -0
- package/dist/elements/style-popups.d.ts +39 -0
- package/dist/elements/style-popups.d.ts.map +1 -0
- package/dist/elements/style-popups.js +173 -0
- package/dist/elements/style-popups.js.map +1 -0
- package/dist/elements/style-rules.d.ts +21 -0
- package/dist/elements/style-rules.d.ts.map +1 -0
- package/dist/elements/style-rules.js +274 -0
- package/dist/elements/style-rules.js.map +1 -0
- package/dist/elements/styles.d.ts +9 -0
- package/dist/elements/styles.d.ts.map +1 -0
- package/dist/elements/styles.js +161 -0
- package/dist/elements/styles.js.map +1 -0
- package/dist/elements/toolbar.d.ts +65 -0
- package/dist/elements/toolbar.d.ts.map +1 -0
- package/dist/elements/toolbar.js +1270 -0
- package/dist/elements/toolbar.js.map +1 -0
- package/dist/help.d.ts +33 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +111 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +251 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +428 -0
- package/dist/inspect.js.map +1 -0
- package/dist/messages/en.json +252 -0
- package/dist/messages/help/en.json +18 -0
- package/dist/messages/help/pl.json +18 -0
- package/dist/messages/pl.json +252 -0
- package/dist/messages/style/en.json +67 -0
- package/dist/messages/style/pl.json +67 -0
- package/dist/messages.d.ts +5 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +9 -0
- package/dist/messages.js.map +1 -0
- package/dist/pages.d.ts +28 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +147 -0
- package/dist/pages.js.map +1 -0
- package/dist/scan.d.ts +82 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +329 -0
- package/dist/scan.js.map +1 -0
- package/dist/style-messages.d.ts +7 -0
- package/dist/style-messages.d.ts.map +1 -0
- package/dist/style-messages.js +12 -0
- package/dist/style-messages.js.map +1 -0
- package/dist/style-model.d.ts +50 -0
- package/dist/style-model.d.ts.map +1 -0
- package/dist/style-model.js +76 -0
- package/dist/style-model.js.map +1 -0
- package/dist/style-placing.d.ts +38 -0
- package/dist/style-placing.d.ts.map +1 -0
- package/dist/style-placing.js +98 -0
- package/dist/style-placing.js.map +1 -0
- package/dist/textarea.d.ts +17 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +175 -0
- package/dist/textarea.js.map +1 -0
- package/package.json +42 -4
- package/src/authoring.ts +896 -0
- package/src/define.ts +34 -0
- package/src/edit.ts +195 -0
- package/src/elements/base.ts +93 -0
- package/src/elements/color-control.ts +159 -0
- package/src/elements/help-form.ts +404 -0
- package/src/elements/insert-menu.ts +481 -0
- package/src/elements/inspector.ts +941 -0
- package/src/elements/issue-list.ts +103 -0
- package/src/elements/issues.ts +89 -0
- package/src/elements/picture-dialog.ts +461 -0
- package/src/elements/picture-field.ts +770 -0
- package/src/elements/preview.ts +186 -0
- package/src/elements/style-form.ts +751 -0
- package/src/elements/style-load.ts +64 -0
- package/src/elements/style-popups.ts +257 -0
- package/src/elements/style-rules.ts +294 -0
- package/src/elements/styles.ts +162 -0
- package/src/elements/toolbar.ts +1386 -0
- package/src/help.ts +156 -0
- package/src/index.ts +81 -0
- package/src/inspect.ts +774 -0
- package/src/messages/en.json +252 -0
- package/src/messages/help/en.json +18 -0
- package/src/messages/help/pl.json +18 -0
- package/src/messages/pl.json +252 -0
- package/src/messages/style/en.json +67 -0
- package/src/messages/style/pl.json +67 -0
- package/src/messages.ts +11 -0
- package/src/pages.ts +158 -0
- package/src/scan.ts +382 -0
- package/src/style-messages.ts +13 -0
- package/src/style-model.ts +125 -0
- package/src/style-placing.ts +117 -0
- package/src/textarea.ts +182 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# @astl/editor
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 97e412c: Authors' own styles, column layouts and named styles in the content format.
|
|
8
|
+
|
|
9
|
+
- `style` on every element, checked by an allow-list (`cleanStyle`, `@astl/core/declarations`): what it refuses goes with
|
|
10
|
+
a warning, `STYLE_REMOVED`. `STYLE_LOW_CONTRAST` warns about text that is hard to read.
|
|
11
|
+
- `<astl-columns>` with 2 to 4 `<astl-column>` on a page, wrapping by themselves on a phone.
|
|
12
|
+
- `<astl-style>` first in `<astl-doc>`, by `name` (applied by `class`) or `for` a tag. The engine writes them into each
|
|
13
|
+
element: a view holds only `style`.
|
|
14
|
+
- The player draws them from a chunk that only such a view loads, through the CSSOM (a strict CSP allows it), following
|
|
15
|
+
the theme, and stays within the column on any screen.
|
|
16
|
+
- The TipTap surface keeps them on every node and mark, shows them, and keeps block moves, page breaks and
|
|
17
|
+
`EditorAdapter.insert` inside a column. A paste keeps what the allow-list allows, and only classes the document defines.
|
|
18
|
+
- ec2a249: The editor works like a word processor with block cards.
|
|
19
|
+
|
|
20
|
+
- `<astl-toolbar>`, part of `<astl-editor>`: the text style menu, bold, italic, underline, link, the two lists, undo and redo, the host's featured inserts as buttons (`featured`, from `defineEditor` or the element; `@astl/astrolabe` features text, gap, closed question, ordering, sort into groups and picture) and "More", the insert menu in a searchable popover. One tab stop with the arrow keys; a press never moves the cursor. Its groups wrap into rows, the inserts on a row of their own; only under 30rem (a phone) is it one row that scrolls sideways.
|
|
21
|
+
- Block cards in the TipTap surface: each block's head gives its number, type and points, with buttons to move it up or down and delete it (one undo step each, said on the status line), and "Add block" ends each page. Chips show their answer with an icon and "+N"; an option's correct marker is a toggle before its text, and "Add option" follows the last one. A card whose block has errors or warnings is dashed, in the colour of its worst issue, and says them under its head without the page ("Gap 1 has no answer."). Each page's head says "Page 2 of 3", and its title field has the visible label "Page title".
|
|
22
|
+
- Hosts theme the surface with `--astl-editor-*` custom properties: the sheet (corners, padding, border, focus ring), the cards (corners, padding), the card with the cursor (a ring, its kicker's colour), the kickers' size, the chips, the correct marker and the option rows (reference/editor.md, "Theming the surface").
|
|
23
|
+
- `label.text` ("{label}: {text}") names the insert menu's entries, the issues, the chips and the markers, so a screen reader says "Gap: The student types a word or a number." with no space before the colon.
|
|
24
|
+
- `EditorAdapter` has optional capabilities: `format` and `formatState`, `undo` and `redo`, `moveBlock` and `removeBlock`, `getCursor` and `onCursorChange`, `selectedText`, `focus`, and `insert(html, { replaceSelection })`. Adapters without them keep working; their controls are left out.
|
|
25
|
+
- `authoring.outline(source)` lists each page's blocks with their points and issue counts; `authoring.describe(issue, source)` names a component as the author sees it, never by its id (a block component by its block's number on its page, "Question 2 on page 1", a component in text by its number among its type), and with `{ page: false }` (`DescribeOptions`) without its page ("Question 2"), for a host that shows the page apart; a template's `{{selection}}` takes the selected text (a gap made from a word).
|
|
26
|
+
- `<astl-editor>`: `ready` and `astl-editor-ready`, `preview()`, `panels` (an empty list leaves the side column to the host's own `<astl-inspector>`).
|
|
27
|
+
- `@astl/astrolabe/editor` exports `createAuthoring` and its types; importing it in Node touches no DOM.
|
|
28
|
+
- The TipTap surface's stylesheet comes with the surface: `<astl-editor>`'s first load no longer carries it.
|
|
29
|
+
|
|
30
|
+
Breaking: `<astl-editor>` has no `insert-menu` or `tools` part (the menu is the toolbar's `more-menu`, the types' commands are toolbar buttons), and the inspector's heading names the type only, with the id in its `data-id`. The messages `surface.flag` and `surface.chip.title` give way to `label.text`, `surface.pageTitleName` is gone (the title field is named by its label and the page number), and `surface.pageNumber` takes `{pages}`.
|
|
31
|
+
- ba91084: `<astl-editor>` is laid out by its host: columns, bands and two states for a frame; page titles are optional.
|
|
32
|
+
|
|
33
|
+
- The work row (`part="work"`) takes two host slots: `start`, a column before the surface, and `end`, a column after the surface and the side column. A column is there only while its slot has elements (no track, no gap); from 48rem they are columns, below it `start` is above the surface and `end` below it; in another view both are hidden. Like the side column they stay in view (`--astl-editor-sticky-top`, default `--astl-space-4`, which the side column uses too) and scroll on their own when taller than the window. `--astl-editor-layout-gap` is the space between the toolbar, the status line, the work row and the preview. New parts `work`, `start` and `end`.
|
|
34
|
+
- The toolbar's icon-only buttons also have the part `icon-button`, the view switch `views`, its options `view` and the rule between groups `separator` (an element now, not a border of the group; it is drawn the same), exported by `<astl-editor>` as `toolbar-icon-button`, `toolbar-views`, `toolbar-view` and `toolbar-separator`.
|
|
35
|
+
- Frames: the hooks `--astl-editor-frame-border-width`, `--astl-editor-frame-current-border-width` (the frame keeps its size when the cursor comes in), `--astl-editor-frame-tab-background`, `--astl-editor-frame-tab-ink` and `--astl-editor-frame-tab-border` draw a rest state and the cursor's; defaults are today's look, a frame with issues keeps its dashed colour, the tab with the cursor stays the accent. The frame with the cursor has `data-astl-current` in the light DOM, for a host that draws a line from it.
|
|
36
|
+
- Page titles are optional. A page without a label shows its number and a small "Add title" button before "Join with page n" and "Delete page"; it shows the field (placeholder "Page title", named "Title of page 2", no visible label) and focuses it, and an empty field goes again on blur without changing the document. With a label, the field has a "Remove title" button: one undo step, the focus moves to "Add title", the notice line says "Removed the title of page 2". New hooks `--astl-editor-page-number-{font-family,size,letter-spacing,text-transform}` and `--astl-editor-page-title-{font-family,size,weight}`. New messages `surface.pageAddTitle`, `surface.pageRemoveTitle`, `surface.pageTitleOf` and `surface.pageTitleRemoved`.
|
|
37
|
+
- The player's generated "Page n" heading (a page without a label in a view of several pages) is visually hidden, still a heading in the accessibility tree that takes the focus; labelled pages are unchanged.
|
|
38
|
+
- The inspector's header shows the type's icon and name, the `id` in a monospace chip and icon buttons "Move up", "Move down" and "Delete" (their texts are the names and tooltips); under it the element's own issues as banners (icon, severity word, the sentence its frame shows). Parts `header`, `issue`, `field`, `label` and `id`. `--astl-inspector-columns` (default 1): with 2, selects, numbers and short texts sit side by side and everything else spans the row.
|
|
39
|
+
|
|
40
|
+
Changed:
|
|
41
|
+
|
|
42
|
+
- The inspector's per-element look field is "Element style" ("Styl elementu", message `inspector.styleTemplate`), not "Look" ("Wygląd").
|
|
43
|
+
- On the surface the page head has no visible title label: `.astl-page-title` is gone and `.astl-page-field` is a `div` that holds the title field and "Remove title"; a page without a label has no title field until "Add title".
|
|
44
|
+
- cfa6485: The editor reads like a word processor: one flowing text per page, with its elements framed.
|
|
45
|
+
|
|
46
|
+
- The TipTap surface frames each block component, with a label tab at the frame's top start: the type's icon, its name in bold and a summary of its items and points ("Closed question · 4 items · 1 pt", "4 elementy · 1 pkt"), never an id. Text runs are unframed. The frame with the cursor is in the accent, its tab filled; a frame with issues is dashed in the colour of the worst one and says them under its tab, without the page.
|
|
47
|
+
- The inspector's head gives the type and "Move up", "Move down" and "Delete" for the block component with the cursor (the adapter's `moveBlock` and `removeBlock`, left out without them): one undo step each, said in the editor's live region.
|
|
48
|
+
- The toolbar, in order: text style, bold, italic, underline, link, lists; the featured inserts, "Elements" (every component, "Picture", "Page break") and "Templates" (the starters), two searchable popovers whose entries have an icon, a name and a line on what they do; "Mark word"; the view switch; undo and redo. `openMenu('elements' | 'templates')` opens a menu; `<astl-insert-menu>` takes `groups`.
|
|
49
|
+
- The insert menus' lines are a catalog of their own per type (`messages/menu/<locale>.json`, `<type>MenuMessages`, all of them in `builtInMenuMessages` of `@astl/components/menu-messages`), which the editors load when a menu first opens: the `menuMessages` option of `defineEditor` and `createAuthoring`, and `authoring.loadMenuMessages()`. Every built-in component and starter has a one-line description in English and Polish.
|
|
50
|
+
- Pages can be deleted: `removePage(id)`, optional in `EditorAdapter` and in the TipTap adapter, deletes a page and everything on it, the cursor at the start of the page before (of the next one for the first page), one undo step; `false` for the only page or an unknown id. Each page head of the TipTap surface has a "Delete page" button while there are other pages, and the status message says "Deleted page 2".
|
|
51
|
+
- A status line under the toolbar (`part="status-line"`) counts the elements and points and says "Ready to share", or how many errors and warnings there are. It is not a live region.
|
|
52
|
+
- Views: `<astl-editor>` has `view` (`visual`, `source` or a host view) and `views` (the host's `{ name, label }`, an option, an attribute in JSON or a property); `source` shows the document's HTML in a monospace text area (`part="source"`), applied on the way back and kept, with its errors listed, while it has errors; a host view shows the `view-{name}` slot. Each change dispatches `astl-editor-view` (`detail: { view }`, bubbles, composed).
|
|
53
|
+
|
|
54
|
+
Breaking:
|
|
55
|
+
|
|
56
|
+
- The block cards are gone: no card heads, points fields, move and delete buttons on the surface, no "Add block" and no `astl-add-block` event.
|
|
57
|
+
- The surface hooks `--astl-editor-card-radius`, `--astl-editor-card-padding` and `--astl-editor-card-current-ring` are `--astl-editor-frame-radius`, `--astl-editor-frame-padding` and `--astl-editor-frame-current-ring`; `--astl-editor-card-current-kicker` is gone.
|
|
58
|
+
- `<astl-toolbar>`: "More" is "Elements" and "Templates"; `openMore()` is `openMenu(menu)`; the parts `more` and `more-menu` are `insert` and `insert-menu`, the icon part `icon-more` is `icon-add`.
|
|
59
|
+
- `DEFAULT_FEATURED` is empty: `@astl/astrolabe` features no inserts; pass `featured` to get buttons back.
|
|
60
|
+
- The kit's messages `toolbar.more`, `surface.blockTitle`, `surface.pointsField`, `surface.pointsUnit`, `surface.moveUp`, `surface.moveDown`, `surface.remove` and `surface.addBlock` are gone; `editor.description` and the starters' `template.*.description` moved from each type's `messages/<locale>.json` to `messages/menu/<locale>.json`.
|
|
61
|
+
- 4611aeb: The editor gets styles. `EditorAdapter.style` is a new optional capability, implemented on the TipTap surface. The toolbar has font, size, text colour, highlight, alignment, spacing, a style menu and clear formatting; `defineEditor({ fonts })` sets its fonts. `<astl-style-form>` (with "Own CSS", which shows what the allow-list refused, and "Save as a style") and `<astl-style-rules>` load on first use, and `astl-style-open` lets a host show them in its own place. Pictures and figures show their position and width, with a corner handle and a field that write the same. The insert menu has a group "Layout". A component in a narrow column of the surface keeps its words whole (`--astl-editor-column-with-component`).
|
|
62
|
+
- 6a4f220: The first release on npm, under the scope `@astl`: `@astl/astrolabe` with everything on by default, and the single packages it is built from, all at one version.
|
|
63
|
+
- c500ae1: Layouts get a toolbar button of their own, "Layout", and "Elements" no longer lists them. A layout can now be removed or changed once inserted: a tab over every layout (its commands in the same row while the cursor is in it) and the layout's style form have "Change layout" (the content stays), "Remove layout" (the columns go, their content stays in place) and "Delete with content" (asked first when it holds anything), and Backspace removes an empty one; `EditorStyles.layout()` and `EditorStyles.editLayout(edit)` (optional) do the same for any adapter. Exercises are placed and sized like pictures: position and width in their card, a handle on the frame edge away from the float and the position line in the tab row, text beside them in the player from 30rem and stacked below. `Placement` and `PLACEMENTS` name the positions (`PicturePosition` and `PICTURE_POSITIONS` stay, deprecated); `LAYOUT_SHAPES`, `LAYOUT_COLUMNS` and `splitPlacement` are new.
|
|
64
|
+
- 3d2f905: A layout has no tab over it on the surface any more, so the page keeps the place the student sees. While the cursor is in a layout's text (in no exercise or figure there), its columns' edges turn solid in the accent colour (as wide as before, so nothing moves) and it carries `data-astl-current` (class `astl-layout-current`), as the frame with the cursor does: a host shows the layout's settings beside the page and draws its line to it. The layout's style form starts with its commands, open, under "Columns" ("Change layout", "Remove layout", "Delete with content"); its style sections follow, closed.
|
|
65
|
+
- 2e4cc4a: Pictures from the host's own library, and refusals in the host's words.
|
|
66
|
+
|
|
67
|
+
- `pickPicture({ signal })`, an option of `createAuthoring` and `defineEditor` (type `PickPicture`), opens the host's picture library and resolves with `{ src, width?, height? }`, or `null` when the author closes it without one. The picture dialog offers "Choose from the library" beside the upload (alone without one), and so do the inspector's picture fields; the address must pass `urlPolicy`, or the dialog says the library returned an address the policy does not allow. The 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, with the picture's address, size and preview, "Chosen from the library." and the focus on the alt text. `signal` aborts when the editor no longer waits (the dialog was asked for another picture or left the page, the field started another upload or pick). The note that pictures are added by address only shows only without both hooks. `Authoring.pickPicture` is the library, or `null`. New messages `picture.library`, `picture.picked`, `picture.pickFailed` and `picture.pickBlocked`.
|
|
68
|
+
- `UploadRefused` (from `@astl/editor` and `@astl/astrolabe/editor`): an `uploadAsset` or `pickPicture` that rejects with it has its message, already in the editor's locale, shown as it is in the picture dialog, the picture fields and the inspector's `url` fields, instead of the generic failure text.
|
|
69
|
+
- 0e45514: The preview plays under the host's policy: `<astl-editor>` takes `previewPolicy` (null: `PRACTICE_POLICY`), `<astl-preview>` takes `policy`, and `Authoring.preview(source, { policy })` grades under it (`PreviewOptions`). A host whose students get less help than practice offers (an author turned hints off) previews what they get; a change plays a shown preview again. On the surface, the selects of help boxes are the kit's controls, and the card's hint cost has a short label ("Cost (% of the points)", named "Hint 2: cost" for assistive tech).
|
|
70
|
+
- 3a4945c: Ready styles, like a word processor's built-in ones. The style menu has a group "Ready styles" after "My styles", and the style form's named field a group of the same name: Note, Tip, Important, Definition, Example and Quote go on what the cursor is in, Highlight and Small print on the selected words. Picking one adds its `<astl-style>` rule to the document, labelled in the editor's language, and sets the class in one undo step; from then on it is one of "My styles", and a document with its own rule of that name keeps it. `defineEditor({ styles })` and `createAuthoring({ styles })` replace them (`[]`: none; type `EditorStylePreset`, default `DEFAULT_STYLES`, `Authoring.styles`), and a style the allow-list refuses throws. `EditorStyles.setClass(where, name, rule)` takes the rule of a ready style. The style menu scrolls when it is taller than the window.
|
|
71
|
+
- 64af38f: Help for students. Three elements of the content format, inside a graded component or on a page: `<astl-hint cost>` (hints on request, one at a time, each costing a share of the points), `<astl-explanation>` (under "Why?" after a check) and `<astl-feedback when="correct|incorrect|partial|omitted">` (a text by the verdict). Compiling moves them into the key (`AnswerKey.help`); the view keeps only what is offered (`hints`, `explanation`, `feedback`). `AttemptPolicy` gets optional `hints`, `checkScope`, `feedback` and `explanations`, whose defaults by mode (`helpPolicy`, `PRACTICE_POLICY`, `TEST_POLICY`) keep old hosts working. The protocol gets `check({ answers, element })` for one interaction, `feedback` and `explanations` on responses, and `POST /hint` (`Checker.hint`, `hints_not_allowed`, `hints_exhausted`); grading takes `hintsUsed`. The server binding serves all of it and records hints with `AttemptStore.recordHint`. The player loads its help module only for views with help: "Hint (1/2)" with the cost said first, "Check" of one interaction, a feedback box by the verdict, "Why?", a page's help at its foot. The editor's card has "Help for students" (hints with cost and order, the explanation, the four feedback texts), "Elements" has "Hint", "Explanation" and "Feedback", the surface shows labelled boxes, and the preview plays them in practice. New issues: `HINT_COST_INVALID`, `FEEDBACK_WHEN_INVALID`, `FEEDBACK_DUPLICATE`, `EXPLANATION_DUPLICATE`, `HELP_UNGRADED`, `HELP_EMPTY`.
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- c912f91: The toolbar's menus and insert menus are compact.
|
|
76
|
+
|
|
77
|
+
- Popovers have a light frame (`--astl-line`), `--astl-radius-m` corners and `--astl-space-2` inside.
|
|
78
|
+
- Menus (paragraph style, font, size and the rest): less padding around and in the items, 2px between them; they keep `--astl-target-min`.
|
|
79
|
+
- Insert menus ("Elements", "Templates", "Layouts"): no visible "Insert" title (the toolbar's button names the menu; the title is still the section's name), entries without a frame (a disabled one keeps its dashed frame), and the search with `--astl-space-2` around it.
|
|
80
|
+
- `<astl-insert-menu>` with one group in `groups` shows that group's title to screen readers only.
|
|
81
|
+
- 7bd41aa: The picture dialog asks for the next picture with an empty alt text and caption: what the author typed for the last one no longer stays in those fields.
|
|
82
|
+
- Updated dependencies [402924c]
|
|
83
|
+
- Updated dependencies [97e412c]
|
|
84
|
+
- Updated dependencies [ec2a249]
|
|
85
|
+
- Updated dependencies [ba91084]
|
|
86
|
+
- Updated dependencies [cfa6485]
|
|
87
|
+
- Updated dependencies [4611aeb]
|
|
88
|
+
- Updated dependencies [6a4f220]
|
|
89
|
+
- Updated dependencies [c500ae1]
|
|
90
|
+
- Updated dependencies [871b57a]
|
|
91
|
+
- Updated dependencies [3a4945c]
|
|
92
|
+
- Updated dependencies [64af38f]
|
|
93
|
+
- @astl/core@0.1.0
|
|
94
|
+
- @astl/engine@0.1.0
|
|
95
|
+
- @astl/player@0.1.0
|
|
96
|
+
- @astl/tokens@0.1.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @astl/editor
|
|
2
|
+
|
|
3
|
+
Editor-agnostic authoring kit: templates, ids, inspector, issues, insert menu and preview over an EditorAdapter.
|
|
4
|
+
Bring any WYSIWYG editor.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install @astl/editor @astl/engine @astl/components
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { builtInDefinitions } from '@astl/components/definitions';
|
|
16
|
+
import { builtInEditors } from '@astl/components/editors';
|
|
17
|
+
import { builtInElements } from '@astl/components/elements';
|
|
18
|
+
import { createAuthoring, createTextareaAdapter, defineAuthoringElements } from '@astl/editor';
|
|
19
|
+
import { createEngine } from '@astl/engine';
|
|
20
|
+
|
|
21
|
+
const engine = createEngine({ components: builtInDefinitions, secret: 'editor-preview-only-key' });
|
|
22
|
+
const authoring = createAuthoring({ engine, descriptors: builtInEditors, elements: builtInElements, locale: 'en' });
|
|
23
|
+
|
|
24
|
+
defineAuthoringElements(); // nothing is defined on import
|
|
25
|
+
const adapter = createTextareaAdapter(document.querySelector<HTMLTextAreaElement>('#source')!);
|
|
26
|
+
for (const el of document.querySelectorAll('astl-toolbar, astl-insert-menu, astl-inspector, astl-issues, astl-preview')) {
|
|
27
|
+
Object.assign(el, { authoring, adapter });
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Your own editor plugs in through an `EditorAdapter`; the textarea adapter above is the smallest one.
|
|
32
|
+
|
|
33
|
+
## This package or @astl/astrolabe
|
|
34
|
+
|
|
35
|
+
For a ready editor, use `<astl-editor>` from `@astl/astrolabe/editor` or `@astl/editor-tiptap`. Pick `@astl/editor`
|
|
36
|
+
to put the kit around a WYSIWYG editor of your own.
|
|
37
|
+
|
|
38
|
+
Documentation: <https://astrolabe.starship.education/reference/authoring-kit/> and
|
|
39
|
+
<https://astrolabe.starship.education/guides/any-editor/>
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Apache-2.0, see [LICENSE](https://github.com/starship1337/astrolabe/blob/main/LICENSE).
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createAuthoring: the editor-independent logic of the authoring kit. Pure (no DOM), so hosts, agents and tests can
|
|
3
|
+
* use it in any runtime; the web components and adapters are thin layers on top.
|
|
4
|
+
*/
|
|
5
|
+
import { type AttemptPolicy, type EditorDescriptor, type EditorTemplate, type Engine, type Issue, type MessageCatalog, type MessageParams, type StyleTemplate, type UrlPolicy, type ValidationReport } from '@astl/core';
|
|
6
|
+
import { type LocalChecker } from '@astl/engine';
|
|
7
|
+
import type { ElementEntry } from '@astl/player';
|
|
8
|
+
import { type InspectorChange } from './edit.js';
|
|
9
|
+
import { type InspectorModel } from './inspect.js';
|
|
10
|
+
import { type EditorFont, type EditorStylePreset } from './style-model.js';
|
|
11
|
+
export interface AuthoringOptions {
|
|
12
|
+
readonly engine: Engine;
|
|
13
|
+
/** One per component type authors can insert and inspect. Each tag must be registered in the engine. */
|
|
14
|
+
readonly descriptors: readonly EditorDescriptor[];
|
|
15
|
+
/** Player elements for `<astl-preview>`, eager or lazy. */
|
|
16
|
+
readonly elements?: readonly ElementEntry[];
|
|
17
|
+
/** The author's UI locale: labels, issues, template texts. */
|
|
18
|
+
readonly locale: string;
|
|
19
|
+
/** More or overriding catalogs (any namespace), e.g. another UI locale. */
|
|
20
|
+
readonly catalogs?: readonly MessageCatalog[];
|
|
21
|
+
/**
|
|
22
|
+
* Catalogs only insert menus show (the one-line descriptions), loaded when a menu first opens rather than with the
|
|
23
|
+
* editor (`loadMenuMessages`): the built-ins' are the components package's `builtInMenuMessages`. The host's
|
|
24
|
+
* `catalogs` override them.
|
|
25
|
+
*/
|
|
26
|
+
readonly menuMessages?: () => Promise<readonly MessageCatalog[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Style templates authors can pick (register the same ones with the engine and the player): the inspector offers
|
|
29
|
+
* them per component and for the whole document, labelled from their catalogs; `<astl-preview>` renders them.
|
|
30
|
+
*/
|
|
31
|
+
readonly styleTemplates?: readonly StyleTemplate[];
|
|
32
|
+
/**
|
|
33
|
+
* The engine's URL policy (`createEngine({ urlPolicy })`): the preview's player cleans with it and editors check
|
|
34
|
+
* picture addresses with it before they show them. Default `isSafeUrl`.
|
|
35
|
+
*/
|
|
36
|
+
readonly urlPolicy?: UrlPolicy;
|
|
37
|
+
/**
|
|
38
|
+
* The fonts the style controls offer, in order. Default `DEFAULT_FONTS`, stacks every system has. A stack the style
|
|
39
|
+
* allow-list refuses throws.
|
|
40
|
+
*/
|
|
41
|
+
readonly fonts?: readonly EditorFont[];
|
|
42
|
+
/**
|
|
43
|
+
* The ready styles the style menu and the style form offer, in order; `[]`: none. Default `DEFAULT_STYLES`. A name
|
|
44
|
+
* `isStyleName` refuses, a declaration the style allow-list refuses, or a name given twice throws.
|
|
45
|
+
*/
|
|
46
|
+
readonly styles?: readonly EditorStylePreset[];
|
|
47
|
+
/**
|
|
48
|
+
* Stores a picture file and returns its address (and size): the host's upload, used by the picture dialog, by
|
|
49
|
+
* pictures pasted or dropped into the editor and by picture fields; also by `url` fields with `accept` (a video,
|
|
50
|
+
* its captions). The address must pass `urlPolicy`. Without it, files are added by address only (pictures also
|
|
51
|
+
* from `pickPicture`). `signal` aborts when the author cancels or picks another file. The file's type is the
|
|
52
|
+
* browser's guess: check type and size on the server, and serve SVG with `nosniff`. Reject with `UploadRefused` to
|
|
53
|
+
* tell the author why.
|
|
54
|
+
*/
|
|
55
|
+
readonly uploadAsset?: UploadAsset;
|
|
56
|
+
/**
|
|
57
|
+
* Opens the host's own picture library: the picture dialog and picture fields offer it beside the upload. The
|
|
58
|
+
* address it gives must pass `urlPolicy`. The picture dialog closes while the library is open, keeping what the
|
|
59
|
+
* author typed, so a modal of the host's own takes the pointer and the keys; it opens again when the library
|
|
60
|
+
* settles. Reject with `UploadRefused` to tell the author why.
|
|
61
|
+
*/
|
|
62
|
+
readonly pickPicture?: PickPicture;
|
|
63
|
+
}
|
|
64
|
+
/** A stored picture, as `uploadAsset` and `pickPicture` give it: its address, and its size in pixels when known. */
|
|
65
|
+
export interface UploadedAsset {
|
|
66
|
+
readonly src: string;
|
|
67
|
+
readonly width?: number;
|
|
68
|
+
readonly height?: number;
|
|
69
|
+
}
|
|
70
|
+
export type UploadAsset = (file: File, options: {
|
|
71
|
+
readonly signal: AbortSignal;
|
|
72
|
+
}) => Promise<UploadedAsset>;
|
|
73
|
+
/**
|
|
74
|
+
* Opens the host's own picture library and resolves with the chosen picture (its address, and its size when known),
|
|
75
|
+
* or null when the author closes it without one. The address must pass `urlPolicy`. Settle once the library has
|
|
76
|
+
* closed: the picture dialog and the picture fields then give the focus back themselves. `signal` aborts when the
|
|
77
|
+
* editor no longer waits for it (the picture dialog was asked for another picture or left the page, the picture field
|
|
78
|
+
* started another upload or pick): the host should then close its library.
|
|
79
|
+
*/
|
|
80
|
+
export type PickPicture = (options: {
|
|
81
|
+
readonly signal: AbortSignal;
|
|
82
|
+
}) => Promise<UploadedAsset | null>;
|
|
83
|
+
/**
|
|
84
|
+
* What a host's `uploadAsset` or `pickPicture` rejects with to tell the author why: its message, already in the
|
|
85
|
+
* editor's locale, is shown as it is, instead of the generic failure text.
|
|
86
|
+
*/
|
|
87
|
+
export declare class UploadRefused extends Error {
|
|
88
|
+
constructor(message: string, options?: ErrorOptions);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The words of a host's refusal: the message of an `UploadRefused`, known by its name so that another copy of this
|
|
92
|
+
* package counts too; undefined for any other error and for a refusal without words.
|
|
93
|
+
*/
|
|
94
|
+
export declare function refusalOf(error: unknown): string | undefined;
|
|
95
|
+
/** A picture as the picture dialog asks for it: `alt` is `''` for a decorative picture. */
|
|
96
|
+
export interface PictureFields {
|
|
97
|
+
readonly src: string;
|
|
98
|
+
readonly alt: string;
|
|
99
|
+
readonly width?: number;
|
|
100
|
+
readonly height?: number;
|
|
101
|
+
/** A caption makes the picture a figure. */
|
|
102
|
+
readonly caption?: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* A picture's width or height as the content format takes it: a positive whole number of pixels (a safe integer),
|
|
106
|
+
* from a number or its written form; anything else is no size.
|
|
107
|
+
*/
|
|
108
|
+
export declare function pictureSize(value: unknown): number | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* The source HTML of a picture: an `<img>` that sits in text, or with a caption a `<figure>` that stands on its own.
|
|
111
|
+
* Every value is read once and escaped, and only the attributes of the content format are written.
|
|
112
|
+
*/
|
|
113
|
+
export declare function pictureHtml(picture: PictureFields): string;
|
|
114
|
+
export interface OutlineComponent {
|
|
115
|
+
readonly id: string | null;
|
|
116
|
+
readonly tag: string;
|
|
117
|
+
/** Translated type label (the tag when there is no descriptor). */
|
|
118
|
+
readonly label: string;
|
|
119
|
+
/** Its `points` (default 1) when the type is graded, else null. */
|
|
120
|
+
readonly points: number | null;
|
|
121
|
+
/** Issues located on this component or its children. */
|
|
122
|
+
readonly errors: number;
|
|
123
|
+
readonly warnings: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* One block of a page (`EditorBlockPlace`): a block component directly on the page, or the content between two of
|
|
127
|
+
* them (paragraphs, headings, lists, quotes, pictures, with the inline components in their text).
|
|
128
|
+
*/
|
|
129
|
+
export interface OutlineBlock {
|
|
130
|
+
readonly kind: 'component' | 'text';
|
|
131
|
+
/** The component's source id (null when it has none), or null for a text block. */
|
|
132
|
+
readonly id: string | null;
|
|
133
|
+
/** The component's tag, or null for a text block. */
|
|
134
|
+
readonly tag: string | null;
|
|
135
|
+
/**
|
|
136
|
+
* The block's type: the component's label, else `block.gap` ("Gap") for text that holds a graded component and
|
|
137
|
+
* `block.text` ("Text") for the rest.
|
|
138
|
+
*/
|
|
139
|
+
readonly label: string;
|
|
140
|
+
/** The sum of its components' points, or null when none of them is graded. */
|
|
141
|
+
readonly points: number | null;
|
|
142
|
+
/** Its component, or the components in its text, in document order. */
|
|
143
|
+
readonly components: readonly OutlineComponent[];
|
|
144
|
+
/** Issues located on its components. */
|
|
145
|
+
readonly errors: number;
|
|
146
|
+
readonly warnings: number;
|
|
147
|
+
}
|
|
148
|
+
export interface OutlinePage {
|
|
149
|
+
/** null for the implicit page of a document without pages. */
|
|
150
|
+
readonly id: string | null;
|
|
151
|
+
readonly label: string | null;
|
|
152
|
+
/** Issues located on the page, its content and its components. */
|
|
153
|
+
readonly errors: number;
|
|
154
|
+
readonly warnings: number;
|
|
155
|
+
readonly components: readonly OutlineComponent[];
|
|
156
|
+
/** Its content as blocks, in order. */
|
|
157
|
+
readonly blocks: readonly OutlineBlock[];
|
|
158
|
+
/** The sum of its blocks' points, or null when nothing on it is graded. */
|
|
159
|
+
readonly points: number | null;
|
|
160
|
+
}
|
|
161
|
+
export interface Outline {
|
|
162
|
+
readonly pages: readonly OutlinePage[];
|
|
163
|
+
/** Every issue of the document. */
|
|
164
|
+
readonly errors: number;
|
|
165
|
+
readonly warnings: number;
|
|
166
|
+
/** The sum of its pages' points, or null when nothing is graded. */
|
|
167
|
+
readonly points: number | null;
|
|
168
|
+
}
|
|
169
|
+
/** A playable preview, or the issues that block compiling. */
|
|
170
|
+
/** How `Authoring.preview` grades. */
|
|
171
|
+
export interface PreviewOptions {
|
|
172
|
+
/**
|
|
173
|
+
* The policy of the local grading, the one the host plays the result under: a host whose students get less help than
|
|
174
|
+
* practice offers (no hints, no check of one interaction) previews with that. Default `PRACTICE_POLICY`.
|
|
175
|
+
*/
|
|
176
|
+
readonly policy?: AttemptPolicy;
|
|
177
|
+
}
|
|
178
|
+
export type PreviewResult = {
|
|
179
|
+
readonly ok: true;
|
|
180
|
+
readonly view: string;
|
|
181
|
+
/** Local grading for this preview, under its policy (`PreviewOptions.policy`, practice by default). */
|
|
182
|
+
readonly checker: LocalChecker;
|
|
183
|
+
/** Warnings. */
|
|
184
|
+
readonly issues: readonly Issue[];
|
|
185
|
+
} | {
|
|
186
|
+
readonly ok: false;
|
|
187
|
+
readonly issues: readonly Issue[];
|
|
188
|
+
};
|
|
189
|
+
/** How `Authoring.describe` names a component. */
|
|
190
|
+
export interface DescribeOptions {
|
|
191
|
+
/**
|
|
192
|
+
* Whether the name says the component's page when the document has pages: "Question 2 on page 1" (default true), or
|
|
193
|
+
* "Question 2" (false) for a host that shows the page apart.
|
|
194
|
+
*/
|
|
195
|
+
readonly page?: boolean;
|
|
196
|
+
}
|
|
197
|
+
export interface Authoring {
|
|
198
|
+
readonly engine: Engine;
|
|
199
|
+
readonly locale: string;
|
|
200
|
+
readonly descriptors: readonly EditorDescriptor[];
|
|
201
|
+
readonly elements: readonly ElementEntry[];
|
|
202
|
+
readonly styleTemplates: readonly StyleTemplate[];
|
|
203
|
+
readonly urlPolicy: UrlPolicy;
|
|
204
|
+
/** The fonts the style controls offer, each stack in the allow-list's normal form. */
|
|
205
|
+
readonly fonts: readonly EditorFont[];
|
|
206
|
+
/**
|
|
207
|
+
* The ready styles the style menu and the style form offer, each style in the allow-list's normal form and each with
|
|
208
|
+
* its label: the host's, else the kit's message `style.preset.<name>` in the authoring locale, else the name.
|
|
209
|
+
*/
|
|
210
|
+
readonly styles: readonly (EditorStylePreset & {
|
|
211
|
+
readonly label: string;
|
|
212
|
+
})[];
|
|
213
|
+
/** The host's upload, or null: files are added by address only. */
|
|
214
|
+
readonly uploadAsset: UploadAsset | null;
|
|
215
|
+
/** The host's picture library, or null. */
|
|
216
|
+
readonly pickPicture: PickPicture | null;
|
|
217
|
+
/** The descriptor of a component tag, or null. */
|
|
218
|
+
descriptor(tag: string): EditorDescriptor | null;
|
|
219
|
+
/** The named starters of a component tag (`EditorDescriptor.templates`); none without a descriptor. */
|
|
220
|
+
templates(tag: string): readonly EditorTemplate[];
|
|
221
|
+
/** A message in the authoring locale: kit (`astl.editor`), descriptor, engine and extra catalogs. */
|
|
222
|
+
t(namespace: string, key: string, params?: MessageParams): string;
|
|
223
|
+
/**
|
|
224
|
+
* Loads the `menuMessages` option's catalogs (what only insert menus show) once; `t` has them when it resolves. A
|
|
225
|
+
* failed load resolves too, and the next call tries again.
|
|
226
|
+
*/
|
|
227
|
+
loadMenuMessages(): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Adds the catalogs of a part of the kit that loads later, under the host's `catalogs`, which may override them; `t`
|
|
230
|
+
* has them at once. Adding the same ones again does nothing.
|
|
231
|
+
*/
|
|
232
|
+
addMessages(catalogs: readonly MessageCatalog[]): void;
|
|
233
|
+
/**
|
|
234
|
+
* The descriptor's template, or its named starter `templateId`, ready to insert into `source`: `{{id}}` becomes
|
|
235
|
+
* `<idPrefix>-<n>` with the smallest n whose id `source` does not use, `{{selection}}` the escaped `selection` (the
|
|
236
|
+
* text the author selected, `EditorAdapter.selectedText`; default `''`), `{{t:key}}` an escaped message of the
|
|
237
|
+
* manifest namespace, and other components written without an id get fresh ones too. An element of a type with a
|
|
238
|
+
* `companion` and an empty attribute names the first such element of the template, else of `source`, else the one
|
|
239
|
+
* `withCompanion` adds. Throws for a tag without a descriptor or an unknown starter.
|
|
240
|
+
*/
|
|
241
|
+
instantiate(tag: string, source: string, templateId?: string, selection?: string): string;
|
|
242
|
+
/**
|
|
243
|
+
* `source` (with an inserted `tag` element) where that element, the one with the id `id` (default: the first whose
|
|
244
|
+
* companion attribute names none on its page), names a companion element of its own page, as pages play one at a
|
|
245
|
+
* time: the first one there, else the descriptor's `companion` template, added at the end of that page (of the
|
|
246
|
+
* document, without pages). Null when nothing changes: the type has no companion, or the element names one of its
|
|
247
|
+
* page already.
|
|
248
|
+
*/
|
|
249
|
+
withCompanion(tag: string, source: string, id?: string): string | null;
|
|
250
|
+
/**
|
|
251
|
+
* The inspector model of one component element (source HTML), or null for elements it does not know. With the
|
|
252
|
+
* whole document (`source`), fields offer what other elements hold (the words of the bank a drop takes its words
|
|
253
|
+
* from); without it they show the attribute's own control.
|
|
254
|
+
*/
|
|
255
|
+
inspect(elementHtml: string, source?: string): InspectorModel | null;
|
|
256
|
+
/**
|
|
257
|
+
* The document's own settings (its style template) as an inspector model for `<astl-doc>`, or null when the source
|
|
258
|
+
* has no `<astl-doc>` root or there is nothing to set. Apply its changes with `update(source, change)`: the first
|
|
259
|
+
* element of the source is the document, so only its start tag changes.
|
|
260
|
+
*/
|
|
261
|
+
inspectDocument(source: string): InspectorModel | null;
|
|
262
|
+
/** The element HTML with one inspector change applied; everything else stays byte-identical. */
|
|
263
|
+
update(elementHtml: string, change: InspectorChange): string;
|
|
264
|
+
validate(source: string): ValidationReport;
|
|
265
|
+
/**
|
|
266
|
+
* An issue as a sentence in the authoring locale. With the document it is about (`source`), a component's issue
|
|
267
|
+
* names the component as the author sees it, never by its id (the id stays in `issue.at` for "Show"): a block
|
|
268
|
+
* 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),
|
|
269
|
+
* a component in text by its number among the components of its type on its page ("Gap 3 on page 1"); with
|
|
270
|
+
* `page: false`, without its page ("Question 2").
|
|
271
|
+
*/
|
|
272
|
+
describe(issue: Issue, source?: string, options?: DescribeOptions): string;
|
|
273
|
+
/** `source` with fresh ids on pages and components that lack one (or have an empty one). */
|
|
274
|
+
assignIds(source: string): string;
|
|
275
|
+
/** Pages, their blocks and components, points and issue counts. */
|
|
276
|
+
outline(source: string): Outline;
|
|
277
|
+
/**
|
|
278
|
+
* Compiles with a random per-session salt and grades locally, under `options.policy` (default `PRACTICE_POLICY`). The
|
|
279
|
+
* source is not stored anywhere.
|
|
280
|
+
*/
|
|
281
|
+
preview(source: string, options?: PreviewOptions): Promise<PreviewResult>;
|
|
282
|
+
}
|
|
283
|
+
export declare function createAuthoring(options: AuthoringOptions): Authoring;
|
|
284
|
+
//# sourceMappingURL=authoring.d.ts.map
|