@altnovatrail/canvas 0.3.33 → 0.3.34
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/lib/element/icons.d.ts +1 -1
- package/lib/element/icons.js +2 -2
- package/lib/element/index.d.ts +28 -30
- package/lib/element/index.js +125 -123
- package/lib/element/labels.d.ts +7 -7
- package/lib/element/labels.js +9 -10
- package/lib/element/parts.d.ts +1 -1
- package/lib/element/parts.js +9 -9
- package/lib/element/probe.d.ts +1 -1
- package/lib/element/probe.js +3 -4
- package/lib/element/session.js +1 -1
- package/lib/element/statement.js +1 -1
- package/lib/element/tools.d.ts +1 -1
- package/lib/element/tools.js +16 -18
- package/package.json +1 -1
package/lib/element/icons.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type IconName = keyof typeof ICONS;
|
|
|
54
54
|
/**
|
|
55
55
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
56
56
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
57
|
-
* runs right to left (
|
|
57
|
+
* runs right to left (R78 spec).
|
|
58
58
|
*/
|
|
59
59
|
export declare const ROW: {
|
|
60
60
|
readonly next: {
|
package/lib/element/icons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Written by scripts/icons.ts — `just icons` — from @iconify-json/material-symbols 1.2.99:
|
|
2
|
-
// Material Symbols by Google, under the Apache License 2.0 (R46
|
|
2
|
+
// Material Symbols by Google, under the Apache License 2.0 (R46; R78 spec).
|
|
3
3
|
// ci-lint fails unless it is what the script writes, so it is never edited by hand. This module is
|
|
4
4
|
// no entry point of the package.
|
|
5
5
|
/** The icons of the row's buttons, by their names in the set, as the element draws them. */
|
|
@@ -80,7 +80,7 @@ export const ICONS = {
|
|
|
80
80
|
/**
|
|
81
81
|
* Each value of the row, by its button's key: the icon in outline, the one the button shows while
|
|
82
82
|
* chosen — the same for a value without a fill — and whether the icon is mirrored in a row that
|
|
83
|
-
* runs right to left (
|
|
83
|
+
* runs right to left (R78 spec).
|
|
84
84
|
*/
|
|
85
85
|
export const ROW = {
|
|
86
86
|
next: {
|
package/lib/element/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ import { type Task, type Tool } from "../core/task.js";
|
|
|
10
10
|
* CanvasElement has it, what its events tell and the work it gives for checking, here, and the data
|
|
11
11
|
* — the history of writing, the context of a submission, the filled slots and the state of a demo
|
|
12
12
|
* — through the DOM-free part. The entry point gives them under spec's names, the same types, the
|
|
13
|
-
* media
|
|
14
|
-
*
|
|
13
|
+
* media and the tutor's marks too. The crop and a task with its temporary tools are the element's
|
|
14
|
+
* own (R26, R41).
|
|
15
15
|
*/
|
|
16
16
|
export type { Box, CanvasElement, CanvasEventMap, DemoChangeEvent, ExportedCell, ExportedSheet, ExportedWork, ExportedWorkbook, HistoryChange, HistoryChangeEvent, Media, ToolChange, ToolChangeEvent, } from "@altnovatrail/spec/canvas";
|
|
17
17
|
export type { Filled, Filling } from "../core/boxes.js";
|
|
@@ -65,7 +65,7 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
|
|
|
65
65
|
* A lesson's worked example (R42; R58 spec): the open view of a segment `worked_example` of the
|
|
66
66
|
* module format 0.4 — its statement, which the element shows above the sheet as a task's (R23),
|
|
67
67
|
* the grid of its sheet or the lines of its workbook, and the parts of the author's demo, which
|
|
68
|
-
* on a workbook fill the lines' boxes with their values (
|
|
68
|
+
* on a workbook fill the lines' boxes with their values (R61). The type is spec's (R73 spec; R41).
|
|
69
69
|
* The element shows a task or a worked example, not both: an example while a task is given, while
|
|
70
70
|
* the sheet has a history of writing, or while a stroke or an erasing is under way, is a
|
|
71
71
|
* TypeError, and so is one the schema refuses, at its field. `undefined` takes the example off,
|
|
@@ -113,13 +113,13 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
|
|
|
113
113
|
get manifest(): Manifest | undefined;
|
|
114
114
|
set manifest(manifest: Manifest | undefined);
|
|
115
115
|
/**
|
|
116
|
-
* What gives the files of the pictures, by their references, as the contract has it (
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
116
|
+
* What gives the files of the pictures, by their references, as the contract has it (R07;
|
|
117
|
+
* R36 spec): a task's statement's, and a worked example's — its statement's and every part's of
|
|
118
|
+
* its demo, which it asks for as the example comes, before the learner opens them (R42). A
|
|
119
|
+
* reference is asked for once, whichever pictures show it, and its file stays while the task or
|
|
120
|
+
* the example names it. Until a picture's file comes, or if it never does, its frame shows what
|
|
121
|
+
* it shows in words. A new function serves the references that have no file yet, and stops no
|
|
122
|
+
* load the last one began.
|
|
123
123
|
*/
|
|
124
124
|
get media(): Media | undefined;
|
|
125
125
|
set media(media: Media | undefined);
|
|
@@ -160,12 +160,11 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
|
|
|
160
160
|
* workbook where an answer cell is, by its item and its slot (R39). A mark holds on to the
|
|
161
161
|
* strokes the model saw there and is drawn around those of them the sheet shows, as they are now
|
|
162
162
|
* — a cell's around its box too: new strokes do not move it, and when all of them are erased it
|
|
163
|
-
* is gone, till undo brings them back. A box of a workbook that was empty is framed alone (
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* to a page of its boxes: one of other strokes or other boxes is a TypeError, and so are marks
|
|
163
|
+
* is gone, till undo brings them back. A box of a workbook that was empty is framed alone (R74
|
|
164
|
+
* spec). A box that comes near no stroke, and a cell on a sheet, which takes no zones, have no
|
|
165
|
+
* frame: the question is asked without one. The type is spec's (R83 spec). A submission goes back
|
|
166
|
+
* to a sheet whose history holds its strokes, as its digest tells (R27), and a workbook's to a
|
|
167
|
+
* page of its boxes: one of other strokes or other boxes is a TypeError, and so are marks
|
|
169
168
|
* given before the task and the history they hold on to, and marks that are not marks. A new
|
|
170
169
|
* history, and a new page, put the marks back on their strokes, or take them off. `undefined`
|
|
171
170
|
* takes the marks off. Every value is checked as it comes, and marks equal to those shown write
|
|
@@ -180,9 +179,9 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
|
|
|
180
179
|
* The element's `lang` came, changed or went: its buttons and a workbook's boxes are labelled in
|
|
181
180
|
* it, or in English for a language their labels are not in, and for none (R28, R36). Or
|
|
182
181
|
* `tools-hidden` did: while the element has it, the bar is out of sight and of the accessibility
|
|
183
|
-
* tree, as `app` hides it on a phone under its tutor's sheet (R84;
|
|
184
|
-
*
|
|
185
|
-
*
|
|
182
|
+
* tree, as `app` hides it on a phone under its tutor's sheet (R84; R36 spec). An attribute the
|
|
183
|
+
* element had before it was defined comes here just after the constructor, which reads no
|
|
184
|
+
* attribute.
|
|
186
185
|
*/
|
|
187
186
|
attributeChangedCallback(name: string): void;
|
|
188
187
|
/**
|
|
@@ -214,17 +213,16 @@ export declare class NovatrailCanvas extends HTMLElement implements CanvasElemen
|
|
|
214
213
|
*/
|
|
215
214
|
exportWork(): Promise<ExportedWork | null>;
|
|
216
215
|
/**
|
|
217
|
-
* The picture of the work, for the `picture` of a stored work that app puts on the server
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
* 4 MiB of a stored work.
|
|
216
|
+
* The picture of the work, for the `picture` of a stored work that app puts on the server, a
|
|
217
|
+
* method of the agreement with app (R83; R36 spec): the PNG of the strokes the surface shows,
|
|
218
|
+
* with no condition — the whole sheet, or the workbook's whole page with its draft, one pixel a
|
|
219
|
+
* unit, 1000 × 1400, whatever is filled and whether the work was sent to be checked or not; an
|
|
220
|
+
* empty surface, and a worked example's, is white. The strokes are those `exportWork()` takes, as
|
|
221
|
+
* the history has them: not the stroke under way, but those under an eraser not yet lifted. Each
|
|
222
|
+
* is the outline the screen fills, black on white with no theme and no template, and the pixels
|
|
223
|
+
* go through the crop's encoder, grey a byte each: so the picture looks as the sheet does, and
|
|
224
|
+
* holds at most 1,576,640 bytes, for the encoder spends at most 9 bits on a byte of a row, under
|
|
225
|
+
* the 4 MiB of a stored work.
|
|
228
226
|
*/
|
|
229
227
|
exportPicture(): Promise<Blob>;
|
|
230
228
|
disconnectedCallback(): void;
|
package/lib/element/index.js
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
// The package's entry point @altnovatrail/canvas: the canvas as a custom element, one for every
|
|
2
2
|
// canvas kind, with its markup in an open shadow root (R07). Importing it registers the element,
|
|
3
|
-
// once: a page has one element of this name.
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// the
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
// the
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
3
|
+
// once: a page has one element of this name. The types of its contract with app are spec's, of
|
|
4
|
+
// @altnovatrail/spec/canvas: the element implements its CanvasElement, and the package puts the
|
|
5
|
+
// element and its events in the DOM's maps (R07).
|
|
6
|
+
//
|
|
7
|
+
// The handwriting sheet takes its input one pointer at a time (R18), with undo and clearing (R19).
|
|
8
|
+
// Its eraser takes strokes off whole, by the path of a press, as the tool or a pen's eraser, and
|
|
9
|
+
// the sheet keeps the history of writing (R22). The sheet is a stack of layers, the task's grid on
|
|
10
|
+
// its template and the task's statement above it, its look the consumer's to theme (R23). The
|
|
11
|
+
// tutor's marks of a submission hold on to the learner's strokes, and a frame shows where each is,
|
|
12
|
+
// over the work (R26). The history of writing comes in and goes out, an event tells of every
|
|
13
|
+
// action, and the work for checking is the crop with the context of its submission (R27). Over it
|
|
14
|
+
// all stand the element's own buttons — the tools the task allows, undo and clearing —, labelled
|
|
15
|
+
// in the element's `lang` (R28), on a vertical bar of glass at its left edge (R84). On a tablet a
|
|
16
|
+
// pen's touch puts the page in pen mode, where a finger writes nothing and a button lets it write
|
|
17
|
+
// again, a palm writes nothing, and two fingers scroll (R29), one finger too (R84).
|
|
18
|
+
// The task comes in the names of the module format 0.4, checked as its schema checks it, and the
|
|
19
|
+
// module's manifest gives the height of a digit and the statement's language (R32; R60).
|
|
20
|
+
//
|
|
21
|
+
// The workbook's lines, laid out on its page, stand on the template in place of the grid —
|
|
22
|
+
// numbers, text and boxes, which a screen reader reads in the task's order (R35; R36). Each stroke
|
|
23
|
+
// is in one box or in none, by a rule of whole numbers, and `filled` tells which boxes hold one: a
|
|
24
|
+
// filled box's frame is thicker, and its name says so (R37). A workbook's work for checking is the
|
|
25
|
+
// crop of each filled box, with the table of the boxes' strokes for its context (R38).
|
|
26
|
+
//
|
|
27
|
+
// A lesson's worked example it shows on a sheet the learner does not write on: its statement above
|
|
28
|
+
// the sheet, its grid, and a bar without the tools of writing, while a finger or a pen scrolls the
|
|
29
|
+
// sheet as the browser scrolls the statement. The parts of its demo the learner opens one at a time
|
|
30
|
+
// with Next, into a list above the sheet that a polite region tells a screen reader of, and hides
|
|
31
|
+
// and shows with Demo; app keeps how far the learner has gone by `demoState` and `demochange`. The
|
|
32
|
+
// pictures of the statement and of the demo come from the consumer's media, one file for each
|
|
33
|
+
// reference, all of them as the task or the example comes: a part opened shows its picture at
|
|
34
|
+
// once. A picture on an area of the sheet stands on the layer of the author's demo, over its area,
|
|
35
|
+
// and the sheet scrolls to the area as the part opens (R42). A worked example on a workbook lays
|
|
36
|
+
// its lines out as a task's, and a part of its demo that fills a box writes the box's value in it
|
|
37
|
+
// (R61).
|
|
38
|
+
//
|
|
39
|
+
// The keyboard goes into the sheet and out: a container that scrolls is a region named by the
|
|
40
|
+
// canvas kind, with a stop of Tab of its own and a ring when the keyboard brings the focus there
|
|
41
|
+
// (R33); for a `lang` the labels are not in, the container is in theirs and the column in the
|
|
42
|
+
// element's (R74). Zoom in and Zoom out step the page's zoom of the sheet from its fit to twice
|
|
43
|
+
// it, and a zoomed sheet scrolls across as well as down, with two fingers, the wheel and the keys
|
|
44
|
+
// (R73).
|
|
41
45
|
import { cellOf, cellsOf, filledOf, sheetFilledOf } from "../core/boxes.js";
|
|
42
46
|
import { Clock } from "../core/clock.js";
|
|
43
47
|
import { ERASER_BUTTON, Eraser } from "../core/eraser.js";
|
|
@@ -87,8 +91,8 @@ const DEMO_CHANGE = "demochange";
|
|
|
87
91
|
/** What Next and Demo control, by their IDs in the shadow root: the region, and the list (R42). */
|
|
88
92
|
const DEMO_IDS = { status: "demo-status", parts: "demo-parts" };
|
|
89
93
|
/**
|
|
90
|
-
* The colour of the tutor's frames unless the consumer's theme gives one: a blue,
|
|
91
|
-
*
|
|
94
|
+
* The colour of the tutor's frames unless the consumer's theme gives one: a blue, and not a red,
|
|
95
|
+
* which would read as «wrong».
|
|
92
96
|
*/
|
|
93
97
|
const MARK = "#2563eb";
|
|
94
98
|
/** How far a frame stands off the points of its strokes, in sheet units, as canvas-api's (R26). */
|
|
@@ -97,7 +101,7 @@ const MARK_PADDING = 10;
|
|
|
97
101
|
const MARK_CORNER = 6;
|
|
98
102
|
/**
|
|
99
103
|
* How near a stroke's ink the eraser takes it, in CSS pixels: the same on every screen, whatever
|
|
100
|
-
* the sheet's scale (R22).
|
|
104
|
+
* the sheet's scale (R22).
|
|
101
105
|
*/
|
|
102
106
|
const ERASER_RADIUS_PX = 10;
|
|
103
107
|
// The statement and the sheet stand in a column of their own, as wide as the element up to
|
|
@@ -106,32 +110,32 @@ const ERASER_RADIUS_PX = 10;
|
|
|
106
110
|
// The page's zoom widens the column with the sheet, to twice its fit, and the container scrolls
|
|
107
111
|
// it across too, left to right whatever the page's direction, while the statement and a demo's
|
|
108
112
|
// parts stay as wide as the fit and stick to its left, in the element's own direction: they wrap
|
|
109
|
-
// as
|
|
110
|
-
// stage, which sticks to the container's top and left, and each shows what lies there, shifted
|
|
111
|
-
// the frame the ink is drawn in (R18, R23
|
|
113
|
+
// as at the fit, and scroll down alone (R73). The layers of the sheet stand in its visible part,
|
|
114
|
+
// the stage, which sticks to the container's top and left, and each shows what lies there, shifted
|
|
115
|
+
// in the frame the ink is drawn in (R18, R23).
|
|
112
116
|
// Over the container, in the same cell of the frame's grid, stands the rail of the element's own
|
|
113
117
|
// buttons: a band as tall as the part of the element in sight and as wide as nothing, sticking to
|
|
114
118
|
// the top of whatever scrolls the element, as far down as the consumer's --novatrail-canvas-top
|
|
115
119
|
// says, and in its middle, 16 pixels from the left edge, the bar of buttons: 52 pixels wide, round
|
|
116
120
|
// at its ends, of the mockup's glass — the fill the consumer's theme gives, blurred behind, or the
|
|
117
121
|
// paper alone where nothing blurs — over the sheet as it scrolls by (R84; R148 spec). A bar taller
|
|
118
|
-
// than the band scrolls inside its glass (1.4.10). A worked example's bar holds the zoom's
|
|
119
|
-
// alone, and its Next and Demo stand in a row of the same glass at the band's bottom, the
|
|
122
|
+
// than the band scrolls inside its glass (WCAG 1.4.10). A worked example's bar holds the zoom's
|
|
123
|
+
// pair alone, and its Next and Demo stand in a row of the same glass at the band's bottom, the
|
|
120
124
|
// consumer's buttons of the slot actions after them (R84). The tool in use is filled with the
|
|
121
125
|
// accent at an eighth, its icon in the accent; a button in focus shows a ring in the accent; an
|
|
122
|
-
// unavailable one is paler by its colour, not its opacity, which would pale the ring too (
|
|
123
|
-
// 1.4.11). A button's tooltip stands beside it, white on near-black, as the mockup has it.
|
|
124
|
-
// in the element moves but the scrolling, which jumps, and no tooltip fades (2.3.3).
|
|
125
|
-
// as tall as the statement and the sheet unless it is given a height: then the
|
|
126
|
-
// sheet scroll in it, under the bar. A worked example's open parts stand between
|
|
127
|
-
// the sheet, and the region that tells of them is out of sight, but not out of
|
|
128
|
-
// reader reads, where a hidden region would tell nothing (R42). A picture's
|
|
129
|
-
// its item's line, from its top, so that the item's number stands at the
|
|
130
|
-
// does, and not at the picture's bottom
|
|
131
|
-
// layer of the author's demo, and the sheet scrolls to a hidden box of the
|
|
132
|
-
// which neither paints nor takes a pointer (
|
|
133
|
-
// zooms: the pointer writes, and two fingers scroll by the element's own code
|
|
134
|
-
// mode one finger too (R84).
|
|
126
|
+
// unavailable one is paler by its colour, not its opacity, which would pale the ring too (WCAG
|
|
127
|
+
// 2.4.7, 1.4.11). A button's tooltip stands beside it, white on near-black, as the mockup has it.
|
|
128
|
+
// Nothing in the element moves but the scrolling, which jumps, and no tooltip fades (WCAG 2.3.3).
|
|
129
|
+
// The element is as tall as the statement and the sheet unless it is given a height: then the
|
|
130
|
+
// statement and the sheet scroll in it, under the bar. A worked example's open parts stand between
|
|
131
|
+
// the statement and the sheet, and the region that tells of them is out of sight, but not out of
|
|
132
|
+
// the tree a screen reader reads, where a hidden region would tell nothing (R42). A picture's
|
|
133
|
+
// frame there stands in its item's line, from its top, so that the item's number stands at the
|
|
134
|
+
// top too, as a paragraph's does, and not at the picture's bottom. A picture on an area of the
|
|
135
|
+
// sheet stands on the layer of the author's demo, and the sheet scrolls to a hidden box of the
|
|
136
|
+
// area in its own flow, which neither paints nor takes a pointer (R42). On the canvas the browser
|
|
137
|
+
// neither scrolls nor zooms: the pointer writes, and two fingers scroll by the element's own code
|
|
138
|
+
// (R29), and in pen mode one finger too (R84).
|
|
135
139
|
// The canvas and the buttons take pointer events only as the element does: a consumer's
|
|
136
140
|
// pointer-events: none on the element stops the writing and the buttons' pointer, though not
|
|
137
141
|
// their keys (R20, R28). A worked example's canvas takes no pointer at all: a finger or a pen on
|
|
@@ -325,10 +329,10 @@ const sheets = new WeakMap();
|
|
|
325
329
|
* Gives the element's shadow root its style, as a sheet the root adopts, and not a `<style>` in
|
|
326
330
|
* its tree: a consumer's content security policy that allows no inline style, as app's
|
|
327
331
|
* `style-src 'self'`, blocks the one and not the other, and the element asks of the policy only
|
|
328
|
-
* `img-src blob:` (R51;
|
|
329
|
-
*
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
+
* `img-src blob:` (R51; R36 spec). A root adopts only a sheet made for its own document, by that
|
|
333
|
+
* document's window, and an element moved into another document comes there without its sheets:
|
|
334
|
+
* it adopts that document's sheet then. A document without a window, which can make no sheet,
|
|
335
|
+
* leaves the element unstyled till it comes into one that can.
|
|
332
336
|
*/
|
|
333
337
|
function adoptStyle(root) {
|
|
334
338
|
const owner = root.ownerDocument;
|
|
@@ -361,7 +365,7 @@ function marksLayer() {
|
|
|
361
365
|
svg.setAttribute("role", "none");
|
|
362
366
|
return svg;
|
|
363
367
|
}
|
|
364
|
-
/** An HTML layer of the sheet,
|
|
368
|
+
/** An HTML layer of the sheet, for the module's widget from stage 4: empty till then. */
|
|
365
369
|
function htmlLayer(name) {
|
|
366
370
|
const div = document.createElement("div");
|
|
367
371
|
div.className = name;
|
|
@@ -376,25 +380,25 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
376
380
|
/**
|
|
377
381
|
* The wrapper, which does not scroll, of the container that scrolls and of the ring of its focus
|
|
378
382
|
* over it: an outline of the container itself would stand under the sheet's paper and stage,
|
|
379
|
-
* which are positioned in it (
|
|
383
|
+
* which are positioned in it (R33).
|
|
380
384
|
*/
|
|
381
385
|
#wrapper = document.createElement("div");
|
|
382
386
|
#viewport = document.createElement("div");
|
|
383
387
|
#ring = document.createElement("div");
|
|
384
388
|
#column = document.createElement("div");
|
|
385
389
|
#sheet = document.createElement("div");
|
|
386
|
-
/** The sheet's visible part, where its layers stand, bottom to top (
|
|
390
|
+
/** The sheet's visible part, where its layers stand, bottom to top (R23). */
|
|
387
391
|
#stage = document.createElement("div");
|
|
388
392
|
/** The author's template: a sheet's grid, or a workbook's lines, a list of its items (R36). */
|
|
389
393
|
#template = svgLayer("template");
|
|
390
394
|
#grid = document.createElementNS(SVG, "path");
|
|
391
395
|
#print = document.createElementNS(SVG, "g");
|
|
392
396
|
#lines = document.createElementNS(SVG, "g");
|
|
393
|
-
/** The module's widget, from stage 4 (R16 spec): empty
|
|
397
|
+
/** The module's widget, from stage 4 (R16 spec): empty till then. */
|
|
394
398
|
#widget = htmlLayer("widget");
|
|
395
|
-
/** The author's demo: a worked example's pictures on areas of the sheet (
|
|
399
|
+
/** The author's demo: a worked example's pictures on areas of the sheet (R42). */
|
|
396
400
|
#show = svgLayer("show");
|
|
397
|
-
/** The tutor's layer, in two: the sketch under the learner's work, the marks over it (
|
|
401
|
+
/** The tutor's layer, in two: the sketch under the learner's work, the marks over it (R26). */
|
|
398
402
|
#sketch = svgLayer("sketch");
|
|
399
403
|
/** The learner's work: the ink. */
|
|
400
404
|
#canvas = document.createElement("canvas");
|
|
@@ -456,7 +460,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
456
460
|
#finger = false;
|
|
457
461
|
/**
|
|
458
462
|
* What two fingers scroll in the gesture under way, down and across, each chosen at the first
|
|
459
|
-
* step that goes along its axis (
|
|
463
|
+
* step that goes along its axis (R73): undefined till then, and null when nothing scrolls so.
|
|
460
464
|
*/
|
|
461
465
|
#latch;
|
|
462
466
|
#latchAcross;
|
|
@@ -471,7 +475,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
471
475
|
#ported = new ResizeObserver(() => this.#fit());
|
|
472
476
|
#unwatchPen;
|
|
473
477
|
#unwatchZoom;
|
|
474
|
-
/** The page's zoom as the sheet is laid out by it (
|
|
478
|
+
/** The page's zoom as the sheet is laid out by it (R73). */
|
|
475
479
|
#zoom = 0;
|
|
476
480
|
#tool = "pen";
|
|
477
481
|
#task;
|
|
@@ -490,7 +494,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
490
494
|
#rects = [];
|
|
491
495
|
/**
|
|
492
496
|
* The texts of the values a worked example's demo has written in its boxes, one for each frame
|
|
493
|
-
* that has had one (
|
|
497
|
+
* that has had one (R61).
|
|
494
498
|
*/
|
|
495
499
|
#values = [];
|
|
496
500
|
#taken = new WeakMap();
|
|
@@ -543,7 +547,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
543
547
|
*/
|
|
544
548
|
#k = 0;
|
|
545
549
|
#sheetAt = 0;
|
|
546
|
-
/** The sheet's left in the container's content, as laid out then, in CSS pixels (
|
|
550
|
+
/** The sheet's left in the container's content, as laid out then, in CSS pixels (R73). */
|
|
547
551
|
#sheetAtX = 0;
|
|
548
552
|
/** The top and the left of the visible part, in sheet units, kept from the last scroll. */
|
|
549
553
|
#vy = 0;
|
|
@@ -606,7 +610,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
606
610
|
this.#canvas.addEventListener("transitionend", () => this.#request());
|
|
607
611
|
this.#canvas.addEventListener("transitioncancel", () => this.#request());
|
|
608
612
|
this.#viewport.addEventListener("scroll", () => this.#scrolled(), { passive: true });
|
|
609
|
-
// A container
|
|
613
|
+
// A container left with nothing to scroll keeps its stop of Tab while it has the focus.
|
|
610
614
|
this.#viewport.addEventListener("blur", () => this.#region());
|
|
611
615
|
attachProbe(this, () => ({
|
|
612
616
|
strokes: this.#work.strokes,
|
|
@@ -685,7 +689,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
685
689
|
* A lesson's worked example (R42; R58 spec): the open view of a segment `worked_example` of the
|
|
686
690
|
* module format 0.4 — its statement, which the element shows above the sheet as a task's (R23),
|
|
687
691
|
* the grid of its sheet or the lines of its workbook, and the parts of the author's demo, which
|
|
688
|
-
* on a workbook fill the lines' boxes with their values (
|
|
692
|
+
* on a workbook fill the lines' boxes with their values (R61). The type is spec's (R73 spec; R41).
|
|
689
693
|
* The element shows a task or a worked example, not both: an example while a task is given, while
|
|
690
694
|
* the sheet has a history of writing, or while a stroke or an erasing is under way, is a
|
|
691
695
|
* TypeError, and so is one the schema refuses, at its field. `undefined` takes the example off,
|
|
@@ -792,13 +796,13 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
792
796
|
this.#settings = settings;
|
|
793
797
|
}
|
|
794
798
|
/**
|
|
795
|
-
* What gives the files of the pictures, by their references, as the contract has it (
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
799
|
+
* What gives the files of the pictures, by their references, as the contract has it (R07;
|
|
800
|
+
* R36 spec): a task's statement's, and a worked example's — its statement's and every part's of
|
|
801
|
+
* its demo, which it asks for as the example comes, before the learner opens them (R42). A
|
|
802
|
+
* reference is asked for once, whichever pictures show it, and its file stays while the task or
|
|
803
|
+
* the example names it. Until a picture's file comes, or if it never does, its frame shows what
|
|
804
|
+
* it shows in words. A new function serves the references that have no file yet, and stops no
|
|
805
|
+
* load the last one began.
|
|
802
806
|
*/
|
|
803
807
|
get media() {
|
|
804
808
|
return this.#pictures.media;
|
|
@@ -894,12 +898,11 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
894
898
|
* workbook where an answer cell is, by its item and its slot (R39). A mark holds on to the
|
|
895
899
|
* strokes the model saw there and is drawn around those of them the sheet shows, as they are now
|
|
896
900
|
* — a cell's around its box too: new strokes do not move it, and when all of them are erased it
|
|
897
|
-
* is gone, till undo brings them back. A box of a workbook that was empty is framed alone (
|
|
898
|
-
*
|
|
899
|
-
*
|
|
900
|
-
*
|
|
901
|
-
*
|
|
902
|
-
* to a page of its boxes: one of other strokes or other boxes is a TypeError, and so are marks
|
|
901
|
+
* is gone, till undo brings them back. A box of a workbook that was empty is framed alone (R74
|
|
902
|
+
* spec). A box that comes near no stroke, and a cell on a sheet, which takes no zones, have no
|
|
903
|
+
* frame: the question is asked without one. The type is spec's (R83 spec). A submission goes back
|
|
904
|
+
* to a sheet whose history holds its strokes, as its digest tells (R27), and a workbook's to a
|
|
905
|
+
* page of its boxes: one of other strokes or other boxes is a TypeError, and so are marks
|
|
903
906
|
* given before the task and the history they hold on to, and marks that are not marks. A new
|
|
904
907
|
* history, and a new page, put the marks back on their strokes, or take them off. `undefined`
|
|
905
908
|
* takes the marks off. Every value is checked as it comes, and marks equal to those shown write
|
|
@@ -939,7 +942,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
939
942
|
unwatch();
|
|
940
943
|
unenlist();
|
|
941
944
|
};
|
|
942
|
-
// The page's zoom, on every sheet of it (
|
|
945
|
+
// The page's zoom, on every sheet of it (R73): it may have changed while the element was away.
|
|
943
946
|
this.#zoomTo(PAGE_ZOOM.value);
|
|
944
947
|
this.#unwatchZoom = PAGE_ZOOM.watch(() => this.#zoomed());
|
|
945
948
|
// A page that grows or shrinks scrolls nothing, and neither does a window of another size.
|
|
@@ -952,9 +955,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
952
955
|
* The element's `lang` came, changed or went: its buttons and a workbook's boxes are labelled in
|
|
953
956
|
* it, or in English for a language their labels are not in, and for none (R28, R36). Or
|
|
954
957
|
* `tools-hidden` did: while the element has it, the bar is out of sight and of the accessibility
|
|
955
|
-
* tree, as `app` hides it on a phone under its tutor's sheet (R84;
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
+
* tree, as `app` hides it on a phone under its tutor's sheet (R84; R36 spec). An attribute the
|
|
959
|
+
* element had before it was defined comes here just after the constructor, which reads no
|
|
960
|
+
* attribute.
|
|
958
961
|
*/
|
|
959
962
|
attributeChangedCallback(name) {
|
|
960
963
|
if (name === "tools-hidden") {
|
|
@@ -969,7 +972,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
969
972
|
}
|
|
970
973
|
/**
|
|
971
974
|
* The demo's list says a box it fills in the labels' language, around its value, which is a node
|
|
972
|
-
* of its own in the parts' language: "Box 1.2: " and "5" (
|
|
975
|
+
* of its own in the parts' language: "Box 1.2: " and "5" (R61); its open items too, anew.
|
|
973
976
|
* Without `lang` the labels are English, as the element's own.
|
|
974
977
|
*/
|
|
975
978
|
#nameBoxes(tag = this.getAttribute("lang")) {
|
|
@@ -1037,17 +1040,16 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1037
1040
|
return Object.freeze({ png: blobOf(work.png), submission: work.submission });
|
|
1038
1041
|
}
|
|
1039
1042
|
/**
|
|
1040
|
-
* The picture of the work, for the `picture` of a stored work that app puts on the server
|
|
1041
|
-
*
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1044
|
-
*
|
|
1045
|
-
*
|
|
1046
|
-
*
|
|
1047
|
-
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1050
|
-
* 4 MiB of a stored work.
|
|
1043
|
+
* The picture of the work, for the `picture` of a stored work that app puts on the server, a
|
|
1044
|
+
* method of the agreement with app (R83; R36 spec): the PNG of the strokes the surface shows,
|
|
1045
|
+
* with no condition — the whole sheet, or the workbook's whole page with its draft, one pixel a
|
|
1046
|
+
* unit, 1000 × 1400, whatever is filled and whether the work was sent to be checked or not; an
|
|
1047
|
+
* empty surface, and a worked example's, is white. The strokes are those `exportWork()` takes, as
|
|
1048
|
+
* the history has them: not the stroke under way, but those under an eraser not yet lifted. Each
|
|
1049
|
+
* is the outline the screen fills, black on white with no theme and no template, and the pixels
|
|
1050
|
+
* go through the crop's encoder, grey a byte each: so the picture looks as the sheet does, and
|
|
1051
|
+
* holds at most 1,576,640 bytes, for the encoder spends at most 9 bits on a byte of a row, under
|
|
1052
|
+
* the 4 MiB of a stored work.
|
|
1051
1053
|
*/
|
|
1052
1054
|
async exportPicture() {
|
|
1053
1055
|
// A pixel a unit: the ink is 3 px wide, as on a screen of a pixel a unit.
|
|
@@ -1230,7 +1232,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1230
1232
|
* Each box of the lines as it now is (R36, R37): its frame, thicker when it is filled, and its
|
|
1231
1233
|
* name in the labels' language, by the element's `lang` — "Box" alone in its line, numbered by
|
|
1232
1234
|
* its slot among several, and "filled" when it is. A value a worked example's demo wrote in it is
|
|
1233
|
-
* no part of its name: its text after the frame says it, in the lines' language (
|
|
1235
|
+
* no part of its name: its text after the frame says it, in the lines' language (R61). Only
|
|
1234
1236
|
* what has changed is written.
|
|
1235
1237
|
*/
|
|
1236
1238
|
#markBoxes() {
|
|
@@ -1468,7 +1470,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1468
1470
|
/**
|
|
1469
1471
|
* The sheet's top in the container's content, in CSS pixels as laid out: under the statement —
|
|
1470
1472
|
* or, along `x`, its left: its margin in the middle of a wide container, and none once it is
|
|
1471
|
-
* wider (
|
|
1473
|
+
* wider (R73).
|
|
1472
1474
|
*/
|
|
1473
1475
|
#sheetEdge(axis) {
|
|
1474
1476
|
const port = clientBoxOf(this.#viewport);
|
|
@@ -1490,7 +1492,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1490
1492
|
this.#request();
|
|
1491
1493
|
}
|
|
1492
1494
|
/**
|
|
1493
|
-
* Zoom in or Zoom out was pressed (
|
|
1495
|
+
* Zoom in or Zoom out was pressed (R73): the page's zoom goes a step larger or smaller, and every
|
|
1494
1496
|
* sheet of the page is laid out by it — but not while a pointer writes or erases on one of them,
|
|
1495
1497
|
* for nothing moves under it.
|
|
1496
1498
|
*/
|
|
@@ -1499,7 +1501,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1499
1501
|
PAGE_ZOOM.step(larger);
|
|
1500
1502
|
}
|
|
1501
1503
|
/**
|
|
1502
|
-
* The page's zoom has changed (
|
|
1504
|
+
* The page's zoom has changed (R73): the sheet is laid out by it at once, its top left corner in
|
|
1503
1505
|
* sight staying where it was on the sheet, and the row shows what the zoom can do now.
|
|
1504
1506
|
*/
|
|
1505
1507
|
#zoomed() {
|
|
@@ -1511,7 +1513,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1511
1513
|
/**
|
|
1512
1514
|
* The column and the container as wide as a zoom asks, and whether that is another than the
|
|
1513
1515
|
* last: the column widens with the sheet, and the container scrolls it across while the zoom is
|
|
1514
|
-
* beyond the fit (
|
|
1516
|
+
* beyond the fit (R73).
|
|
1515
1517
|
*/
|
|
1516
1518
|
#zoomTo(zoom) {
|
|
1517
1519
|
if (zoom === this.#zoom)
|
|
@@ -1525,7 +1527,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1525
1527
|
/**
|
|
1526
1528
|
* The statement and a demo's parts keep the element's own direction while the zoomed container
|
|
1527
1529
|
* runs left to right: the direction the element computes, by an attribute or by a style, as the
|
|
1528
|
-
* last layout read it (
|
|
1530
|
+
* last layout read it (R73).
|
|
1529
1531
|
*/
|
|
1530
1532
|
#keepDirection() {
|
|
1531
1533
|
if (this.#zoom <= 1 || !this.isConnected)
|
|
@@ -1583,7 +1585,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1583
1585
|
* Two fingers moved right on the screen by `dx` CSS pixels and down it by `dy` (R29), and what
|
|
1584
1586
|
* they scroll goes with them. The gesture's first step down chooses what it scrolls down, for the
|
|
1585
1587
|
* whole gesture, and its first step across, while the sheet is zoomed, what it scrolls across
|
|
1586
|
-
* (
|
|
1588
|
+
* (R73): the sheet's own container if it can go that way, or else the nearest ancestor of the
|
|
1587
1589
|
* element that scrolls and can, or else the page. A container at its end hands the scroll on at
|
|
1588
1590
|
* the next gesture, not within this one. The steps of an event add up, and its end scrolls them
|
|
1589
1591
|
* at once.
|
|
@@ -1622,7 +1624,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1622
1624
|
}
|
|
1623
1625
|
/**
|
|
1624
1626
|
* What scrolls on down the content, for `onward`, or back up it — or, along `x`, on right across
|
|
1625
|
-
* it or back left (
|
|
1627
|
+
* it or back left (R73).
|
|
1626
1628
|
*/
|
|
1627
1629
|
#scrollerFor(onward, axis = "y") {
|
|
1628
1630
|
if (scrollsOn(this.#viewport, onward, axis)) {
|
|
@@ -1654,7 +1656,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1654
1656
|
/**
|
|
1655
1657
|
* The stage takes the visible part of the sheet, and the canvas a pixel of its buffer for each
|
|
1656
1658
|
* device pixel: its size on the screen times the density (R18). The layers follow in the same
|
|
1657
|
-
* frame. However large the zoom, the canvas is no larger than the container (
|
|
1659
|
+
* frame. However large the zoom, the canvas is no larger than the container (R73).
|
|
1658
1660
|
*/
|
|
1659
1661
|
#layout() {
|
|
1660
1662
|
// The content of a new size, or the container, may overflow it now, or no more.
|
|
@@ -1806,11 +1808,11 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1806
1808
|
this.#refresh();
|
|
1807
1809
|
}
|
|
1808
1810
|
/**
|
|
1809
|
-
* The values a worked example's demo has written in the boxes of its workbook (
|
|
1811
|
+
* The values a worked example's demo has written in the boxes of its workbook (R61): each in
|
|
1810
1812
|
* the middle of its box, on the line's baseline, at the width the layout gives its text, as the
|
|
1811
1813
|
* lines' texts are; none while the demo is hidden. A value is a text of its own just after its
|
|
1812
1814
|
* box's frame, which a screen reader reads after the box, in the lines' language, as the lines'
|
|
1813
|
-
* texts are (
|
|
1815
|
+
* texts are (R61; WCAG 3.1.2). Only what changed is written.
|
|
1814
1816
|
*/
|
|
1815
1817
|
#showFills(fills) {
|
|
1816
1818
|
const page = this.#laid;
|
|
@@ -1865,7 +1867,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1865
1867
|
* where it came to: what scrolls back up goes back as far as the band covers it. A margin of
|
|
1866
1868
|
* scrolling would hold for every scroller of the chain alike — the sheet's container and the
|
|
1867
1869
|
* page. An area of the sheet taller than what is in sight comes by its top from below, but by its
|
|
1868
|
-
* bottom from above, and then the band's cover brings its top back into sight (
|
|
1870
|
+
* bottom from above, and then the band's cover brings its top back into sight (R42). The bar of
|
|
1869
1871
|
* buttons covers nothing at the top: it stands at the left edge, and a worked example's row at
|
|
1870
1872
|
* the bottom, where a scroll margin keeps what comes from below above it (R84).
|
|
1871
1873
|
*/
|
|
@@ -1877,7 +1879,7 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1877
1879
|
item.style.setProperty("scroll-margin-bottom", `${under}px`);
|
|
1878
1880
|
item.scrollIntoView({ block: "nearest", behavior: "instant" });
|
|
1879
1881
|
// A scroller that comes to its top hands the rest on to the next. A scroller goes again only
|
|
1880
|
-
// while each of its scrolls leaves less covered than the last (
|
|
1882
|
+
// while each of its scrolls leaves less covered than the last (R73).
|
|
1881
1883
|
const covered = new Map();
|
|
1882
1884
|
for (;;) {
|
|
1883
1885
|
const latch = this.#scrollerFor(false);
|
|
@@ -1922,9 +1924,9 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1922
1924
|
* it, and the keyboard scrolls it: in Safari a container that nothing in it can take the focus in
|
|
1923
1925
|
* scrolls by no key without (R90 spec; WebKit's bug 277290). Without a height of its own the
|
|
1924
1926
|
* element scrolls with the page and has no stop of Tab, and neither has one whose task fits. A
|
|
1925
|
-
* container that holds the focus keeps all three till the focus leaves it, not the window (
|
|
1927
|
+
* container that holds the focus keeps all three till the focus leaves it, not the window (R33).
|
|
1926
1928
|
* Across, it scrolls while the sheet is zoomed, and an element without a height has a region
|
|
1927
|
-
* then too, if its sheet is wider than it (
|
|
1929
|
+
* then too, if its sheet is wider than it (R73); unzoomed, it hides what overflows across.
|
|
1928
1930
|
*/
|
|
1929
1931
|
#region() {
|
|
1930
1932
|
if (!this.isConnected)
|
|
@@ -1941,11 +1943,11 @@ export class NovatrailCanvas extends HTMLElement {
|
|
|
1941
1943
|
* The region's name: the canvas kind's, or a worked example's, in the labels' language, which
|
|
1942
1944
|
* the row's buttons are named in. For a `lang` the labels are not in, the container is in
|
|
1943
1945
|
* theirs, English, and the column, all the container holds, in the element's: the name is said
|
|
1944
|
-
* in the language it is in, and the statement, the parts and the sheet
|
|
1946
|
+
* in the language it is in, and the statement, the parts and the sheet in the element's (R74).
|
|
1945
1947
|
* With a `lang` the labels are in, the name is in the element's language already, and both are
|
|
1946
1948
|
* in it, by an attribute of their own: Firefox gives a shadow tree no language of its host, and
|
|
1947
1949
|
* WebKit takes no new one into the tree, though HTML has a node whose parent is a shadow root
|
|
1948
|
-
* take its host's (
|
|
1950
|
+
* take its host's (R78). Without a `lang` the element's language is the page's, which no
|
|
1949
1951
|
* attribute could name, and neither has one.
|
|
1950
1952
|
*/
|
|
1951
1953
|
#nameRegion() {
|
|
@@ -2158,7 +2160,7 @@ function near({ x, y }, box, reach) {
|
|
|
2158
2160
|
* An item of a workbook's lines (R36): its number, then its text and its boxes in the order they
|
|
2159
2161
|
* are read, each where the layout put it. The item is an `<svg>` of its own place and size, which
|
|
2160
2162
|
* shows what it holds beyond its edges, and its parts lie from its origin: Firefox brings a group
|
|
2161
|
-
* into view as a point at its origin, and only a box with a size whole
|
|
2163
|
+
* into view as a point at its origin, and only a box with a size whole.
|
|
2162
2164
|
* A piece of text is fitted to its width by SVG, whatever the font, and its size is never read.
|
|
2163
2165
|
*/
|
|
2164
2166
|
function itemOf(item) {
|
|
@@ -2362,7 +2364,7 @@ function clientBoxOf(element) {
|
|
|
2362
2364
|
return { left, top, right, bottom, across, down };
|
|
2363
2365
|
}
|
|
2364
2366
|
/**
|
|
2365
|
-
* How much the page scales an element down the screen, or across it along `x` (
|
|
2367
|
+
* How much the page scales an element down the screen, or across it along `x` (R73): 1 unless an
|
|
2366
2368
|
* ancestor transforms it. `box` is its rectangle on the screen, when the caller has it already.
|
|
2367
2369
|
*/
|
|
2368
2370
|
function scaleOf(element, box, axis = "y") {
|
package/lib/element/labels.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What the element says: its scroll container the canvas kind's name, or a worked example's, and
|
|
3
|
-
* the row of buttons a name of its own, that of the kind's buttons (
|
|
3
|
+
* the row of buttons a name of its own, that of the kind's buttons (R28), the name of the group of
|
|
4
4
|
* tools and each button, a workbook's box its name, and the number of a part of a demo the element
|
|
5
5
|
* tells of. A label with places names them in braces.
|
|
6
6
|
*/
|
|
@@ -21,7 +21,7 @@ export interface Labels {
|
|
|
21
21
|
readonly eraser: string;
|
|
22
22
|
readonly undo: string;
|
|
23
23
|
readonly clear: string;
|
|
24
|
-
/** The buttons of the page's zoom, a step larger and a step smaller (
|
|
24
|
+
/** The buttons of the page's zoom, a step larger and a step smaller (R73). */
|
|
25
25
|
readonly zoomIn: string;
|
|
26
26
|
readonly zoomOut: string;
|
|
27
27
|
/** The button that lets a finger write again, in pen mode (R29). */
|
|
@@ -47,10 +47,10 @@ type Labelled = {
|
|
|
47
47
|
readonly labels: Labels;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
|
-
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647's
|
|
51
|
+
* Lookup does it: in lower case, cut subtag by subtag from its end until the table has what is
|
|
52
|
+
* left, a single-letter subtag going with the subtag after it. English stands for any other tag,
|
|
53
|
+
* and for none.
|
|
54
54
|
*/
|
|
55
55
|
export declare function labelsFor(tag: string | null): Labelled;
|
|
56
56
|
/**
|
|
@@ -67,7 +67,7 @@ export declare function placesOf(label: string): string[];
|
|
|
67
67
|
export declare function say(label: string, values: Readonly<Record<string, string | number>>): string;
|
|
68
68
|
/**
|
|
69
69
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
70
|
-
* and what comes after it, for a node of its own to stand between them (
|
|
70
|
+
* and what comes after it, for a node of its own to stand between them (R61). A label that names
|
|
71
71
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
72
72
|
*/
|
|
73
73
|
export declare function sayAround(label: string, place: string, values: Readonly<Record<string, string | number>>): readonly [string, string];
|
package/lib/element/labels.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The labels of the element's own buttons, of a workbook's boxes and of the parts of a worked
|
|
2
2
|
// example's demo, in the languages of the interface, English and Russian (R92 spec), by the shared
|
|
3
|
-
// rules of the packages' translations (R91 spec; R28, R29, R33, R36, R37, R42
|
|
3
|
+
// rules of the packages' translations (R91 spec; R28, R29, R33, R36, R37, R42):
|
|
4
4
|
// - the language is the element's own `lang`, looked up as RFC 4647 does it, and English stands for
|
|
5
5
|
// any other, under a `lang` of its own;
|
|
6
6
|
// - a label with a number or a word in it is one string with named places, «Часть {n} из {total}.»,
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
// - no label counts a thing, so none has forms of number yet. The first that does takes CLDR's
|
|
9
9
|
// categories, `other` always among them, chosen by `Intl.PluralRules` of the label's language;
|
|
10
10
|
// - no label tells the learner's gender (R70 spec) or speaks as the AI in the first person (П-15);
|
|
11
|
-
// - the buttons' words are those of
|
|
12
|
-
//
|
|
13
|
-
// sheet left the row with their buttons (R84).
|
|
11
|
+
// - the buttons' words are those of spec's table of words, the two of the page's zoom among them
|
|
12
|
+
// (R91 spec; R73); no button scrolls the sheet, so no label says a direction (R84).
|
|
14
13
|
// This module is no entry point of the package.
|
|
15
14
|
/** The labels in English, the code's own language: those of any language the table has not. */
|
|
16
15
|
const ENGLISH = Object.freeze({
|
|
@@ -74,10 +73,10 @@ const LABELS = new Map([
|
|
|
74
73
|
/** Every language the table has, by its tag: the tests hold each to English's places. */
|
|
75
74
|
export const LANGUAGES = [...LABELS.keys()];
|
|
76
75
|
/**
|
|
77
|
-
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
76
|
+
* The labels for a language tag, and the language they are in. The tag is looked up as RFC 4647's
|
|
77
|
+
* Lookup does it: in lower case, cut subtag by subtag from its end until the table has what is
|
|
78
|
+
* left, a single-letter subtag going with the subtag after it. English stands for any other tag,
|
|
79
|
+
* and for none.
|
|
81
80
|
*/
|
|
82
81
|
export function labelsFor(tag) {
|
|
83
82
|
return lookup(tag) ?? { lang: "en", labels: ENGLISH };
|
|
@@ -89,7 +88,7 @@ export function labelsFor(tag) {
|
|
|
89
88
|
export function knows(tag) {
|
|
90
89
|
return lookup(tag) !== undefined;
|
|
91
90
|
}
|
|
92
|
-
/** The labels the table has for a tag, by RFC 4647
|
|
91
|
+
/** The labels the table has for a tag, by RFC 4647's Lookup, or none. */
|
|
93
92
|
function lookup(tag) {
|
|
94
93
|
let range = (tag ?? "").toLowerCase();
|
|
95
94
|
while (range !== "") {
|
|
@@ -124,7 +123,7 @@ export function say(label, values) {
|
|
|
124
123
|
}
|
|
125
124
|
/**
|
|
126
125
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
127
|
-
* and what comes after it, for a node of its own to stand between them (
|
|
126
|
+
* and what comes after it, for a node of its own to stand between them (R61). A label that names
|
|
128
127
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
129
128
|
*/
|
|
130
129
|
export function sayAround(label, place, values) {
|
package/lib/element/parts.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface Told {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* What a part that fills a box says: the box, in the labels' language, around the value the demo
|
|
12
|
-
* wrote in it, which is in the parts' own (
|
|
12
|
+
* wrote in it, which is in the parts' own (R61). Without a value the box is `before` alone.
|
|
13
13
|
*/
|
|
14
14
|
export interface FillWords {
|
|
15
15
|
/** The labels' words before the value: "Box 1.2: ". */
|
package/lib/element/parts.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// picture is, which shows the picture once the element's pictures have its file and what it shows
|
|
7
7
|
// in words till then. A picture on an area of the sheet is read by its words here, while the
|
|
8
8
|
// picture itself stands on the layer of the author's demo, stretched over its area, the later part
|
|
9
|
-
// over the earlier, and nothing stands there till its file is decoded (
|
|
9
|
+
// over the earlier, and nothing stands there till its file is decoded (R42). A box of a workbook
|
|
10
10
|
// the demo fills is read as the box, in the labels' language, and its value, a node of its own in
|
|
11
|
-
// the parts' language, which the element writes in the box itself too (
|
|
11
|
+
// the parts' language, which the element writes in the box itself too (R61). This module is
|
|
12
12
|
// no entry point of the package.
|
|
13
13
|
import { isFill, onSheet, } from "../core/example.js";
|
|
14
14
|
import { SHEET } from "../core/sheet.js";
|
|
@@ -161,9 +161,9 @@ export class Parts {
|
|
|
161
161
|
item.replaceChildren(...this.#fillNodes(part, null));
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
|
-
* What a part that fills a box says, as nodes (
|
|
165
|
-
* in their language, and the value a span of its own between them, in the language given,
|
|
166
|
-
* with none, the one it inherits.
|
|
164
|
+
* What a part that fills a box says, as nodes (R61; WCAG 3.1.2): the labels' words, each run a
|
|
165
|
+
* span in their language, and the value a span of its own between them, in the language given,
|
|
166
|
+
* or with none, the one it inherits.
|
|
167
167
|
*/
|
|
168
168
|
#fillNodes(part, valueLang) {
|
|
169
169
|
const { before, value, after, lang } = this.#fillWords(part);
|
|
@@ -176,7 +176,7 @@ export class Parts {
|
|
|
176
176
|
nodes.push(spanOf(after, lang));
|
|
177
177
|
return nodes;
|
|
178
178
|
}
|
|
179
|
-
/** An item leaving the list takes its picture off, once, and
|
|
179
|
+
/** An item leaving the list takes its picture off, once, and leaves the fills. */
|
|
180
180
|
#takeOff(item) {
|
|
181
181
|
this.#off.get(item)?.();
|
|
182
182
|
this.#off.delete(item);
|
|
@@ -219,9 +219,9 @@ export class Parts {
|
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* A picture on its area of the sheet, at the end of the layer, stretched over the area: its
|
|
222
|
-
* corners at the area's
|
|
223
|
-
* element's pictures have it decoded, and nothing till then: its words are in
|
|
224
|
-
* gives back takes the picture off the sheet.
|
|
222
|
+
* corners at the area's, as the module format's lessons place it (SVG 2). It shows its file's
|
|
223
|
+
* address once the element's pictures have it decoded, and nothing till then: its words are in
|
|
224
|
+
* its item. What it gives back takes the picture off the sheet.
|
|
225
225
|
*/
|
|
226
226
|
#onTheSheet(part) {
|
|
227
227
|
const image = document.createElementNS(SVG, "image");
|
package/lib/element/probe.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface Probe {
|
|
|
10
10
|
readonly live: Stroke | undefined;
|
|
11
11
|
/** The IDs of the strokes the eraser under way has come near, or none between presses. */
|
|
12
12
|
readonly pending: readonly number[];
|
|
13
|
-
/** How many outlines of strokes the element has computed
|
|
13
|
+
/** How many outlines of strokes the element has computed since it was built. */
|
|
14
14
|
readonly outlines: number;
|
|
15
15
|
/** Where the sheet is on the screen, or nothing while the element is not laid out. */
|
|
16
16
|
readonly view: View | undefined;
|
package/lib/element/probe.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// What a test sees of an element beyond its interface: its strokes, the stroke under way, what the
|
|
2
2
|
// eraser is about to take, its view of the sheet, how many outlines it has drawn, the tutor's
|
|
3
|
-
// marks it shows and what each pointer down on it does (R29). The history of writing is
|
|
4
|
-
// element's own property
|
|
5
|
-
// element's interface stays what
|
|
6
|
-
// RUN.md, T10, T14, T15, T33, T34, T35).
|
|
3
|
+
// marks it shows and what each pointer down on it does (R29). The history of writing is not here:
|
|
4
|
+
// it is the element's own property (R27). This module is no entry point of the package, so the
|
|
5
|
+
// element's interface stays what its decisions make it (R07, R12, R19, R22, R27, R29).
|
|
7
6
|
const probes = new WeakMap();
|
|
8
7
|
/** Called by each element as it is built, with what reads its state. */
|
|
9
8
|
export function attachProbe(element, read) {
|
package/lib/element/session.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The page's pen mode (R29) and its zoom (
|
|
1
|
+
// The page's pen mode (R29) and its zoom (R73): one of each for every sheet of the page, the mode
|
|
2
2
|
// from a pen's first touch on any of them until the learner asks for the finger, the zoom as the
|
|
3
3
|
// learner last stepped it, till the page is loaded again. The next task is a new element (R20),
|
|
4
4
|
// and both stay. They are states of the interface in memory, not data: nothing is stored or sent.
|
package/lib/element/statement.js
CHANGED
|
@@ -78,7 +78,7 @@ export function framed(pictures, part) {
|
|
|
78
78
|
frame.replaceChildren(image);
|
|
79
79
|
};
|
|
80
80
|
// A browser that keeps the decoded address at hand has the picture whole at once, as
|
|
81
|
-
// Chromium does; another decodes it again, and the frame shows its words till then (
|
|
81
|
+
// Chromium does; another decodes it again, and the frame shows its words till then (R42).
|
|
82
82
|
if (image.complete && image.naturalWidth > 0) {
|
|
83
83
|
swap();
|
|
84
84
|
return;
|
package/lib/element/tools.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare class Tools {
|
|
|
65
65
|
* The bar as the sheet now is. Only what has changed is written. A worked example's has no tools
|
|
66
66
|
* of writing, no undo and no clearing, for the learner does not write on its sheet, and its row
|
|
67
67
|
* has Next, unavailable while the demo is hidden or open whole, and Demo, expanded while the demo
|
|
68
|
-
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (
|
|
68
|
+
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (R73). The tool in use
|
|
69
69
|
* shows its icon filled, and Demo's icon points down while the demo is shown, and along the row
|
|
70
70
|
* while it is hidden (R46).
|
|
71
71
|
*/
|
package/lib/element/tools.js
CHANGED
|
@@ -6,23 +6,21 @@
|
|
|
6
6
|
// one. Undo and Clear with nothing to take back or to clear stay where the focus can reach them,
|
|
7
7
|
// marked unavailable: a last undo from the keyboard leaves the focus where it was. Zoom in and Zoom
|
|
8
8
|
// out step the page's zoom of the sheet, from its fit to twice it, each unavailable at its end
|
|
9
|
-
// (
|
|
10
|
-
// scroll it: a hand drags it, the wheel and the keys scroll it (R84;
|
|
11
|
-
// amendment to R90 spec).
|
|
9
|
+
// (R73). In pen mode a last button lets a finger write again (R29). The sheet has no buttons that
|
|
10
|
+
// scroll it: a hand drags it, the wheel and the keys scroll it (R84; R90 spec).
|
|
12
11
|
// The buttons of the bar show an icon alone, of the set every NovaTrail package of the interface
|
|
13
12
|
// draws from (R46; R78 spec): each is named by its label, in the element's language (labels.ts),
|
|
14
13
|
// which only a screen reader reads, and shows it in a tooltip of its own on the pointer's hover and
|
|
15
|
-
// on the keyboard's focus, which Escape dismisses and the pointer can move onto (
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// the first button shown. This module is no entry point of the package.
|
|
14
|
+
// on the keyboard's focus, which Escape dismisses and the pointer can move onto (R90 spec; WCAG
|
|
15
|
+
// 1.4.13). The bar is named by the canvas kind's buttons: the sheet's or the workbook's (R36), for
|
|
16
|
+
// the kind's own name is the scroll container's (R28). A lesson's worked example names it too, and
|
|
17
|
+
// has no tools of writing: the learner does not write on its sheet, and its bar holds the zoom's
|
|
18
|
+
// pair alone. Its demo's buttons, Next, which opens the next part, and Demo, a disclosure button
|
|
19
|
+
// that hides the whole demo and shows it again, are actions, not tools (R42; R90 spec): each shows
|
|
20
|
+
// its label beside its icon, a stop of Tab of its own, in a row of glass at the bottom of the
|
|
21
|
+
// element, and after a line the slot `actions`, where the consumer puts its own buttons — app's
|
|
22
|
+
// Continue —, as the mockup has one row (R84; R36 spec). A button that goes gives its stop of Tab
|
|
23
|
+
// and the focus to the first button shown. This module is no entry point of the package.
|
|
26
24
|
import { SVG, write } from "./attributes.js";
|
|
27
25
|
import { ICONS, ROW } from "./icons.js";
|
|
28
26
|
import { labelsFor } from "./labels.js";
|
|
@@ -209,7 +207,7 @@ export class Tools {
|
|
|
209
207
|
* The bar as the sheet now is. Only what has changed is written. A worked example's has no tools
|
|
210
208
|
* of writing, no undo and no clearing, for the learner does not write on its sheet, and its row
|
|
211
209
|
* has Next, unavailable while the demo is hidden or open whole, and Demo, expanded while the demo
|
|
212
|
-
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (
|
|
210
|
+
* is shown (R42). Zoom in and Zoom out stand unavailable at their ends (R73). The tool in use
|
|
213
211
|
* shows its icon filled, and Demo's icon points down while the demo is shown, and along the row
|
|
214
212
|
* while it is hidden (R46).
|
|
215
213
|
*/
|
|
@@ -407,7 +405,7 @@ export class Tools {
|
|
|
407
405
|
#shown() {
|
|
408
406
|
return this.#buttons.filter((button) => !button.hidden);
|
|
409
407
|
}
|
|
410
|
-
/** The first button the bar shows: Zoom in and Zoom out are on every bar (
|
|
408
|
+
/** The first button the bar shows: Zoom in and Zoom out are on every bar (R73). */
|
|
411
409
|
#first() {
|
|
412
410
|
return this.#shown()[0] ?? this.#zoomIn;
|
|
413
411
|
}
|
|
@@ -420,8 +418,8 @@ export class Tools {
|
|
|
420
418
|
/**
|
|
421
419
|
* Glass that scrolls inside itself — the bar down, a worked example's row across — brings what has
|
|
422
420
|
* the focus wholly into its view, within its padding, as the first button and the last stand at its
|
|
423
|
-
* ends (2.4.11): Firefox's focus() leaves one in sight in part where it is, and so do all
|
|
424
|
-
* engines in a row. The glass alone scrolls, not what scrolls the element.
|
|
421
|
+
* ends (WCAG 2.4.11): Firefox's focus() leaves one in sight in part where it is, and so do all
|
|
422
|
+
* three engines in a row. The glass alone scrolls, not what scrolls the element.
|
|
425
423
|
*/
|
|
426
424
|
function bringIn(glass, item) {
|
|
427
425
|
const outer = glass.getBoundingClientRect();
|