@altnovatrail/canvas 0.3.39 → 0.3.41
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/README.md +1 -1
- package/lib/core/boxes.d.ts +7 -7
- package/lib/core/boxes.js +10 -10
- package/lib/core/clock.d.ts +5 -5
- package/lib/core/clock.js +5 -5
- package/lib/core/crop.d.ts +13 -13
- package/lib/core/crop.js +10 -10
- package/lib/core/eraser.d.ts +6 -6
- package/lib/core/eraser.js +6 -6
- package/lib/core/example.d.ts +6 -6
- package/lib/core/example.js +9 -9
- package/lib/core/fields.d.ts +1 -1
- package/lib/core/fields.js +1 -1
- package/lib/core/geometry.d.ts +6 -5
- package/lib/core/geometry.js +8 -6
- package/lib/core/grid.d.ts +3 -3
- package/lib/core/grid.js +3 -3
- package/lib/core/groups.d.ts +14 -14
- package/lib/core/groups.js +6 -6
- package/lib/core/hands.d.ts +19 -18
- package/lib/core/hands.js +16 -15
- package/lib/core/history.d.ts +10 -10
- package/lib/core/history.js +6 -6
- package/lib/core/index.js +8 -9
- package/lib/core/ink.js +3 -3
- package/lib/core/manifest.d.ts +3 -3
- package/lib/core/manifest.js +6 -6
- package/lib/core/marks.d.ts +39 -39
- package/lib/core/marks.js +35 -35
- package/lib/core/notation.d.ts +5 -5
- package/lib/core/outline.d.ts +3 -3
- package/lib/core/outline.js +6 -6
- package/lib/core/page.d.ts +7 -7
- package/lib/core/page.js +10 -10
- package/lib/core/png.d.ts +3 -3
- package/lib/core/png.js +3 -3
- package/lib/core/raster.d.ts +3 -3
- package/lib/core/raster.js +3 -3
- package/lib/core/recorder.d.ts +8 -8
- package/lib/core/recorder.js +8 -8
- package/lib/core/screen.d.ts +2 -2
- package/lib/core/screen.js +1 -1
- package/lib/core/sets.d.ts +1 -1
- package/lib/core/sets.js +1 -1
- package/lib/core/sheet.d.ts +5 -5
- package/lib/core/sheet.js +5 -5
- package/lib/core/submission.d.ts +24 -24
- package/lib/core/submission.js +21 -21
- package/lib/core/task.d.ts +17 -16
- package/lib/core/task.js +14 -13
- package/lib/core/tracing.d.ts +19 -19
- package/lib/core/tracing.js +19 -19
- package/lib/core/widths.d.ts +2 -2
- package/lib/core/widths.js +5 -5
- package/lib/core/work.d.ts +19 -19
- package/lib/core/work.js +22 -22
- package/lib/core/zoom.d.ts +5 -5
- package/lib/core/zoom.js +5 -5
- package/lib/element/icons.d.ts +1 -1
- package/lib/element/icons.js +2 -2
- package/lib/element/index.d.ts +87 -87
- package/lib/element/index.js +286 -283
- package/lib/element/labels.d.ts +17 -17
- package/lib/element/labels.js +7 -8
- package/lib/element/notation.js +1 -1
- package/lib/element/parts.d.ts +2 -2
- package/lib/element/parts.js +6 -6
- package/lib/element/pictures.js +1 -1
- package/lib/element/probe.d.ts +2 -2
- package/lib/element/probe.js +3 -3
- package/lib/element/session.js +2 -2
- package/lib/element/statement.d.ts +2 -2
- package/lib/element/statement.js +6 -6
- package/lib/element/tools.d.ts +17 -18
- package/lib/element/tools.js +30 -29
- package/lib/element/tracing.js +8 -8
- package/package.json +3 -3
package/lib/element/labels.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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, 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
|
*/
|
|
7
7
|
export interface Labels {
|
|
8
8
|
readonly sheet: string;
|
|
9
9
|
readonly workbook: string;
|
|
10
|
-
/** A task from the learner's paper, its crop as tracing paper over a sheet
|
|
10
|
+
/** A task from the learner's paper, its crop as tracing paper over a sheet. */
|
|
11
11
|
readonly paper: string;
|
|
12
|
-
/** A lesson's worked example, whose row has no tools of writing
|
|
12
|
+
/** A lesson's worked example, whose row has no tools of writing. */
|
|
13
13
|
readonly example: string;
|
|
14
14
|
/** The row of buttons of each: not the name of the container, which a screen reader shows too. */
|
|
15
15
|
readonly sheetButtons: string;
|
|
@@ -23,25 +23,25 @@ export interface Labels {
|
|
|
23
23
|
readonly eraser: string;
|
|
24
24
|
readonly undo: string;
|
|
25
25
|
readonly clear: string;
|
|
26
|
-
/** The tool that moves the sheet and writes nothing
|
|
26
|
+
/** The tool that moves the sheet and writes nothing. */
|
|
27
27
|
readonly hand: string;
|
|
28
|
-
/** The buttons of the page's zoom of the sheet, a step larger and a step smaller
|
|
28
|
+
/** The buttons of the page's zoom of the sheet, a step larger and a step smaller. */
|
|
29
29
|
readonly zoomIn: string;
|
|
30
30
|
readonly zoomOut: string;
|
|
31
31
|
/**
|
|
32
32
|
* The button of a task from paper's grid, by the grid the sheet shows now: a press turns it to
|
|
33
|
-
* the next
|
|
33
|
+
* the next.
|
|
34
34
|
*/
|
|
35
35
|
readonly gridDots: string;
|
|
36
36
|
readonly gridLines: string;
|
|
37
37
|
readonly gridBlank: string;
|
|
38
38
|
readonly gridSquares: string;
|
|
39
|
-
/** The tracing paper's grip, and the button atop the tools that hides it or shows it
|
|
39
|
+
/** The tracing paper's grip, and the button atop the tools that hides it or shows it. */
|
|
40
40
|
readonly moveTask: string;
|
|
41
41
|
readonly hideTask: string;
|
|
42
42
|
readonly showTask: string;
|
|
43
43
|
/**
|
|
44
|
-
* The tracing paper's bar of scale
|
|
44
|
+
* The tracing paper's bar of scale: its name, smaller, larger, the scale as a percentage,
|
|
45
45
|
* {percent}, which a press sets back to its own size, and fit to the window.
|
|
46
46
|
*/
|
|
47
47
|
readonly scaleButtons: string;
|
|
@@ -50,7 +50,7 @@ export interface Labels {
|
|
|
50
50
|
readonly scaleReset: string;
|
|
51
51
|
readonly fit: string;
|
|
52
52
|
/**
|
|
53
|
-
* The reading of the statement in clean print
|
|
53
|
+
* The reading of the statement in clean print: its button, as it offers it, waits and
|
|
54
54
|
* offers the photo back, and the sign above the paper of what it shows.
|
|
55
55
|
*/
|
|
56
56
|
readonly recognise: string;
|
|
@@ -58,17 +58,17 @@ export interface Labels {
|
|
|
58
58
|
readonly original: string;
|
|
59
59
|
readonly photoShown: string;
|
|
60
60
|
readonly readingShown: string;
|
|
61
|
-
/** A box of a workbook's line, alone in it
|
|
61
|
+
/** A box of a workbook's line, alone in it. */
|
|
62
62
|
readonly box: string;
|
|
63
|
-
/** A box among several of its line, by its slot: {slot}
|
|
63
|
+
/** A box among several of its line, by its slot: {slot}. */
|
|
64
64
|
readonly boxAt: string;
|
|
65
|
-
/** A box a demo fills, by its line and its slot in it: {line} and {slot}
|
|
65
|
+
/** A box a demo fills, by its line and its slot in it: {line} and {slot}. */
|
|
66
66
|
readonly boxIn: string;
|
|
67
|
-
/** A box's {name} when the box is filled
|
|
67
|
+
/** A box's {name} when the box is filled. */
|
|
68
68
|
readonly filled: string;
|
|
69
|
-
/** A box's {name} and the {value} a demo wrote in it
|
|
69
|
+
/** A box's {name} and the {value} a demo wrote in it. */
|
|
70
70
|
readonly valued: string;
|
|
71
|
-
/** The part of a demo the element tells of, {n}, of so many, {total}
|
|
71
|
+
/** The part of a demo the element tells of, {n}, of so many, {total}. */
|
|
72
72
|
readonly part: string;
|
|
73
73
|
}
|
|
74
74
|
/** Every language the table has, by its tag: the tests hold each to English's places. */
|
|
@@ -87,7 +87,7 @@ type Labelled = {
|
|
|
87
87
|
export declare function labelsFor(tag: string | null): Labelled;
|
|
88
88
|
/**
|
|
89
89
|
* Whether the table has labels in the language of a tag, as `labelsFor` looks it up: the English
|
|
90
|
-
* that stands for a tag it has not is in no language of the tag's
|
|
90
|
+
* that stands for a tag it has not is in no language of the tag's.
|
|
91
91
|
*/
|
|
92
92
|
export declare function knows(tag: string | null): boolean;
|
|
93
93
|
/** The places a label names, each once, in the order it names them. */
|
|
@@ -99,7 +99,7 @@ export declare function placesOf(label: string): string[];
|
|
|
99
99
|
export declare function say(label: string, values: Readonly<Record<string, string | number>>): string;
|
|
100
100
|
/**
|
|
101
101
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
102
|
-
* and what comes after it, for a node of its own to stand between them
|
|
102
|
+
* and what comes after it, for a node of its own to stand between them. A label that names
|
|
103
103
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
104
104
|
*/
|
|
105
105
|
export declare function sayAround(label: string, place: string, values: Readonly<Record<string, string | number>>): readonly [string, string];
|
package/lib/element/labels.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// The labels of the element's own buttons, of a workbook's boxes and of the parts of a worked
|
|
2
|
-
// example's demo, in the languages of the interface, English and Russian
|
|
3
|
-
// rules of the packages' translations
|
|
2
|
+
// example's demo, in the languages of the interface, English and Russian, by the shared
|
|
3
|
+
// rules of the packages' translations:
|
|
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}.»,
|
|
7
7
|
// never pieces glued together: languages put their words in other orders;
|
|
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
|
-
// - no label tells the learner's gender
|
|
11
|
-
// - the buttons' words are those of spec's table of words, the two of the page's zoom among them
|
|
12
|
-
//
|
|
13
|
-
// (R84; R88).
|
|
10
|
+
// - no label tells the learner's gender or speaks as the AI in the first person;
|
|
11
|
+
// - the buttons' words are those of spec's table of words, the two of the page's zoom among them;
|
|
12
|
+
// no button scrolls the sheet, which the hand moves, so no label says a direction.
|
|
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({
|
|
@@ -120,7 +119,7 @@ export function labelsFor(tag) {
|
|
|
120
119
|
}
|
|
121
120
|
/**
|
|
122
121
|
* Whether the table has labels in the language of a tag, as `labelsFor` looks it up: the English
|
|
123
|
-
* that stands for a tag it has not is in no language of the tag's
|
|
122
|
+
* that stands for a tag it has not is in no language of the tag's.
|
|
124
123
|
*/
|
|
125
124
|
export function knows(tag) {
|
|
126
125
|
return lookup(tag) !== undefined;
|
|
@@ -160,7 +159,7 @@ export function say(label, values) {
|
|
|
160
159
|
}
|
|
161
160
|
/**
|
|
162
161
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
163
|
-
* and what comes after it, for a node of its own to stand between them
|
|
162
|
+
* and what comes after it, for a node of its own to stand between them. A label that names
|
|
164
163
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
165
164
|
*/
|
|
166
165
|
export function sayAround(label, place, values) {
|
package/lib/element/notation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formulaic, piecesOf } from "../core/notation.js";
|
|
2
|
-
// A statement read, drawn as the page prints it
|
|
2
|
+
// A statement read, drawn as the page prints it: its text as text, a box an answer goes in
|
|
3
3
|
// as a dashed box, and a fraction or a power as MathML, which the browser lays out itself, a
|
|
4
4
|
// fraction full size on the line and those within it smaller, as a book sets them. In a statement
|
|
5
5
|
// with no word its lone letters are its unknowns, in italics as MathML sets a letter.
|
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. 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: ". */
|
|
@@ -63,7 +63,7 @@ export declare class Parts {
|
|
|
63
63
|
/** No part open, the list shown, and nothing told: a demo begins, or goes. */
|
|
64
64
|
clear(): void;
|
|
65
65
|
/**
|
|
66
|
-
* What the `n`th part, from 1, comes into sight by once it is open
|
|
66
|
+
* What the `n`th part, from 1, comes into sight by once it is open: its item, or for a
|
|
67
67
|
* picture on an area of the sheet the spot, which it places on that area, in shares of the sheet,
|
|
68
68
|
* which keeps its proportions.
|
|
69
69
|
*/
|
package/lib/element/parts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The parts of a worked example's demo the learner has opened
|
|
1
|
+
// The parts of a worked example's demo the learner has opened: a numbered list above the
|
|
2
2
|
// sheet, under the statement, in the element's own scrolling, and a polite region that tells a
|
|
3
3
|
// screen reader of the part just opened. A part opens at the list's end, and an item, once built,
|
|
4
4
|
// stays as it is while the demo is the same: hidden, the list keeps its open parts out of sight. A
|
|
@@ -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. 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. 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";
|
|
@@ -108,7 +108,7 @@ export class Parts {
|
|
|
108
108
|
this.quiet();
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* What the `n`th part, from 1, comes into sight by once it is open
|
|
111
|
+
* What the `n`th part, from 1, comes into sight by once it is open: its item, or for a
|
|
112
112
|
* picture on an area of the sheet the spot, which it places on that area, in shares of the sheet,
|
|
113
113
|
* which keeps its proportions.
|
|
114
114
|
*/
|
|
@@ -161,7 +161,7 @@ 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 (
|
|
164
|
+
* What a part that fills a box says, as nodes (WCAG 3.1.2): the labels' words, each run a
|
|
165
165
|
* span in their language, and the value a span of its own between them, in the language given,
|
|
166
166
|
* or with none, the one it inherits.
|
|
167
167
|
*/
|
|
@@ -196,7 +196,7 @@ export class Parts {
|
|
|
196
196
|
this.#sayFill(item, part);
|
|
197
197
|
}
|
|
198
198
|
else if ("text" in part) {
|
|
199
|
-
// Text, never markup: a module is data
|
|
199
|
+
// Text, never markup: a module is data.
|
|
200
200
|
item.textContent = part.text;
|
|
201
201
|
}
|
|
202
202
|
else if (!onSheet(part)) {
|
package/lib/element/pictures.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// The files of the pictures an element shows, by their references
|
|
1
|
+
// The files of the pictures an element shows, by their references: a task's statement's,
|
|
2
2
|
// and a worked example's — its statement's and its demo's, beside the sheet and on areas of it.
|
|
3
3
|
// One reference is one file and one call of the consumer's media, however many pictures show it,
|
|
4
4
|
// and a file stays while what the element shows names its reference. On the page a file has one
|
package/lib/element/probe.d.ts
CHANGED
|
@@ -17,14 +17,14 @@ export interface Probe {
|
|
|
17
17
|
/**
|
|
18
18
|
* The tutor's marks the sheet shows, in their order: each one's name, the strokes it holds on to
|
|
19
19
|
* and its frame as last drawn, in sheet units — null while none of its strokes is on the screen.
|
|
20
|
-
* A mark without a place is not among them
|
|
20
|
+
* A mark without a place is not among them.
|
|
21
21
|
*/
|
|
22
22
|
readonly marks: readonly {
|
|
23
23
|
readonly name: string;
|
|
24
24
|
readonly ids: readonly number[];
|
|
25
25
|
readonly frame: Box | null;
|
|
26
26
|
}[];
|
|
27
|
-
/** What each pointer down on the sheet does, by its `pointerId
|
|
27
|
+
/** What each pointer down on the sheet does, by its `pointerId`. */
|
|
28
28
|
readonly roles: ReadonlyMap<number, Role>;
|
|
29
29
|
}
|
|
30
30
|
/** Called by each element as it is built, with what reads its state. */
|
package/lib/element/probe.js
CHANGED
|
@@ -1,8 +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
|
|
4
|
-
// it is the element's own property
|
|
5
|
-
// element's interface stays what its decisions make it
|
|
3
|
+
// marks it shows and what each pointer down on it does. The history of writing is not here:
|
|
4
|
+
// it is the element's own property. This module is no entry point of the package, so the
|
|
5
|
+
// element's interface stays what its decisions make it.
|
|
6
6
|
const probes = new WeakMap();
|
|
7
7
|
/** Called by each element as it is built, with what reads its state. */
|
|
8
8
|
export function attachProbe(element, read) {
|
package/lib/element/session.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// The page's pen mode
|
|
1
|
+
// The page's pen mode and its zoom: one of each for every sheet of the page, the mode
|
|
2
2
|
// from a pen's first touch on any of them, the zoom as the learner last set it, till the page is
|
|
3
|
-
// loaded again. The next task is a new element
|
|
3
|
+
// loaded again. The next task is a new element, and both stay. They are states of the
|
|
4
4
|
// interface in memory, not data: nothing is stored or sent. This module is no entry point of the
|
|
5
5
|
// package.
|
|
6
6
|
import { PenMode } from "../core/hands.js";
|
|
@@ -5,7 +5,7 @@ export declare class Statement {
|
|
|
5
5
|
#private;
|
|
6
6
|
/**
|
|
7
7
|
* The statement's element: the paragraphs and the pictures, in the module's explanation language,
|
|
8
|
-
* or in the element's own without a manifest
|
|
8
|
+
* or in the element's own without a manifest.
|
|
9
9
|
*/
|
|
10
10
|
readonly element: HTMLDivElement;
|
|
11
11
|
/** A statement whose pictures the element's pictures give their files. */
|
|
@@ -29,7 +29,7 @@ export interface Framed {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* A picture beside the sheet in a frame of its size, placed with the element's pictures: a
|
|
32
|
-
* statement's, and a worked example's in its list of parts
|
|
32
|
+
* statement's, and a worked example's in its list of parts. The frame shows the picture once
|
|
33
33
|
* its file has come and is decoded, and what it shows in words till then, or if it never does.
|
|
34
34
|
*/
|
|
35
35
|
export declare function framed(pictures: Pictures, part: PicturePart): Framed;
|
package/lib/element/statement.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The statement of a task, above the sheet, in the element's own scrolling
|
|
2
|
-
// as text and its pictures from the consumer's media, which the element's pictures load
|
|
1
|
+
// The statement of a task, above the sheet, in the element's own scrolling: its paragraphs
|
|
2
|
+
// as text and its pictures from the consumer's media, which the element's pictures load.
|
|
3
3
|
// Each picture keeps a frame of its own size, so that nothing moves under the pen when it comes,
|
|
4
4
|
// and the frame shows what the picture shows in words until it comes, or if it never does. This
|
|
5
5
|
// module is no entry point of the package.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
export class Statement {
|
|
8
8
|
/**
|
|
9
9
|
* The statement's element: the paragraphs and the pictures, in the module's explanation language,
|
|
10
|
-
* or in the element's own without a manifest
|
|
10
|
+
* or in the element's own without a manifest.
|
|
11
11
|
*/
|
|
12
12
|
element = document.createElement("div");
|
|
13
13
|
#pictures;
|
|
@@ -40,7 +40,7 @@ export class Statement {
|
|
|
40
40
|
const parts = statement.map((part) => {
|
|
41
41
|
if ("text" in part) {
|
|
42
42
|
const paragraph = document.createElement("p");
|
|
43
|
-
// Text, never markup: a module is data
|
|
43
|
+
// Text, never markup: a module is data.
|
|
44
44
|
paragraph.textContent = part.text;
|
|
45
45
|
return paragraph;
|
|
46
46
|
}
|
|
@@ -54,7 +54,7 @@ export class Statement {
|
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* A picture beside the sheet in a frame of its size, placed with the element's pictures: a
|
|
57
|
-
* statement's, and a worked example's in its list of parts
|
|
57
|
+
* statement's, and a worked example's in its list of parts. The frame shows the picture once
|
|
58
58
|
* its file has come and is decoded, and what it shows in words till then, or if it never does.
|
|
59
59
|
*/
|
|
60
60
|
export function framed(pictures, part) {
|
|
@@ -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.
|
|
82
82
|
if (image.complete && image.naturalWidth > 0) {
|
|
83
83
|
swap();
|
|
84
84
|
return;
|
package/lib/element/tools.d.ts
CHANGED
|
@@ -5,22 +5,22 @@ import { ROW } from "./icons.js";
|
|
|
5
5
|
export type Value = keyof typeof ROW;
|
|
6
6
|
/**
|
|
7
7
|
* What the bar asks of the element: a tool the learner chose — perhaps the one in use — an undo, a
|
|
8
|
-
* clearing, a step of the zoom, larger or smaller
|
|
9
|
-
*
|
|
8
|
+
* clearing, a step of the zoom, larger or smaller, and on a worked example the next part of its
|
|
9
|
+
* demo, or the whole demo hidden or shown.
|
|
10
10
|
*/
|
|
11
11
|
export interface ToolActions {
|
|
12
12
|
readonly choose: (tool: Tool) => void;
|
|
13
13
|
readonly undo: () => void;
|
|
14
14
|
readonly clear: () => void;
|
|
15
15
|
readonly zoom: (larger: boolean) => void;
|
|
16
|
-
/** A task from paper's grid turned to the next
|
|
16
|
+
/** A task from paper's grid turned to the next. */
|
|
17
17
|
readonly turnGrid: () => void;
|
|
18
18
|
readonly next: () => void;
|
|
19
19
|
readonly toggle: () => void;
|
|
20
|
-
/** A task from paper's tracing paper hidden, or shown again
|
|
20
|
+
/** A task from paper's tracing paper hidden, or shown again. */
|
|
21
21
|
readonly trace: () => void;
|
|
22
22
|
}
|
|
23
|
-
/** What Next and Demo control, by their IDs in the element's shadow root
|
|
23
|
+
/** What Next and Demo control, by their IDs in the element's shadow root. */
|
|
24
24
|
export interface DemoControls {
|
|
25
25
|
/** The region that tells of the part Next opens. */
|
|
26
26
|
readonly status: string;
|
|
@@ -28,15 +28,14 @@ export interface DemoControls {
|
|
|
28
28
|
readonly parts: string;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* What the bar is of, and is named by: a sheet, a workbook, a task from paper or a worked example
|
|
32
|
-
* (R36, R42, R87).
|
|
31
|
+
* What the bar is of, and is named by: a sheet, a workbook, a task from paper or a worked example.
|
|
33
32
|
*/
|
|
34
33
|
export type RowKind = "sheet" | "workbook" | "paper" | "example";
|
|
35
34
|
/**
|
|
36
35
|
* What the bar shows: what it is of, the tools the task allows — the hand besides, always —, the
|
|
37
36
|
* one in use, whether undo and clearing have anything to do, whether the zoom has a larger step
|
|
38
|
-
* and a smaller one
|
|
39
|
-
* demo is shown
|
|
37
|
+
* and a smaller one, and on a worked example whether Next has a part to open and whether the
|
|
38
|
+
* demo is shown.
|
|
40
39
|
*/
|
|
41
40
|
export interface ToolState {
|
|
42
41
|
readonly kind: RowKind;
|
|
@@ -48,7 +47,7 @@ export interface ToolState {
|
|
|
48
47
|
readonly smaller: boolean;
|
|
49
48
|
readonly opens: boolean;
|
|
50
49
|
readonly expanded: boolean;
|
|
51
|
-
/** On a task from paper, whether its tracing paper is shown
|
|
50
|
+
/** On a task from paper, whether its tracing paper is shown, and its sheet's grid. */
|
|
52
51
|
readonly traced: boolean;
|
|
53
52
|
readonly grid: PaperGrid;
|
|
54
53
|
}
|
|
@@ -62,13 +61,13 @@ export declare class Tools {
|
|
|
62
61
|
#private;
|
|
63
62
|
/**
|
|
64
63
|
* What the element puts beside its scroll container: the band the bar stands in the middle of,
|
|
65
|
-
* as wide as nothing, so that only the bar and its tooltip, which stand out of it, take a
|
|
66
|
-
* and as the element does: a consumer's pointer-events: none stops them too
|
|
64
|
+
* as wide as nothing, so that only the bar and its tooltip, which stand out of it, take a
|
|
65
|
+
* pointer, and as the element does: a consumer's pointer-events: none stops them too.
|
|
67
66
|
*/
|
|
68
67
|
readonly rail: HTMLDivElement;
|
|
69
68
|
/** The bar: a toolbar, named in the element's language. */
|
|
70
69
|
readonly element: HTMLDivElement;
|
|
71
|
-
/** A worked example's row: Next, Demo and the consumer's buttons in the slot `actions
|
|
70
|
+
/** A worked example's row: Next, Demo and the consumer's buttons in the slot `actions`. */
|
|
72
71
|
readonly row: HTMLDivElement;
|
|
73
72
|
/** The tooltip of the button the pointer is over, or the keyboard's focus is on. */
|
|
74
73
|
readonly tip: HTMLDivElement;
|
|
@@ -76,10 +75,10 @@ export declare class Tools {
|
|
|
76
75
|
/**
|
|
77
76
|
* The bar as the sheet now is. Only what has changed is written. A worked example has no bar, for
|
|
78
77
|
* the learner does not write on its sheet, and its row has Next, unavailable while the demo is
|
|
79
|
-
* hidden or open whole, and Demo, expanded while the demo is shown
|
|
78
|
+
* hidden or open whole, and Demo, expanded while the demo is shown. The tool in use shows its
|
|
80
79
|
* icon filled, and Demo's icon points down while the demo is shown, and along the row while it is
|
|
81
|
-
* hidden
|
|
82
|
-
* and fills its icon while the paper is shown
|
|
80
|
+
* hidden. A task from paper's button atop the tools says what it does to the tracing paper,
|
|
81
|
+
* and fills its icon while the paper is shown, and its grid's button shows the grid.
|
|
83
82
|
*/
|
|
84
83
|
show(state: ToolState): void;
|
|
85
84
|
/**
|
|
@@ -92,12 +91,12 @@ export declare class Tools {
|
|
|
92
91
|
}
|
|
93
92
|
/**
|
|
94
93
|
* A button: its icon, an SVG that says nothing — no title, hidden from a screen reader — and its
|
|
95
|
-
* label, which names it
|
|
94
|
+
* label, which names it: on the bar, only a screen reader reads it.
|
|
96
95
|
*/
|
|
97
96
|
export declare function plainButton(value: Value): HTMLButtonElement;
|
|
98
97
|
/**
|
|
99
98
|
* A value's icon on its button, filled or in outline, written only when it is another than the one
|
|
100
99
|
* there: the icon's name stays on the SVG, as data. One mirrored in a row that runs right to left
|
|
101
|
-
* says so by its class, which the style turns
|
|
100
|
+
* says so by its class, which the style turns.
|
|
102
101
|
*/
|
|
103
102
|
export declare function draw(button: HTMLButtonElement, value: Value, filled: boolean): void;
|
package/lib/element/tools.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
// The element's own buttons
|
|
2
|
-
// the hand, which moves the sheet
|
|
3
|
-
// edge of the element, as the interface mockup draws it
|
|
1
|
+
// The element's own buttons: the tools the task allows — the pen and the eraser — and
|
|
2
|
+
// the hand, which moves the sheet, undo and clearing, on a vertical bar of glass at the left
|
|
3
|
+
// edge of the element, as the interface mockup draws it. It is a toolbar as WAI-ARIA's
|
|
4
4
|
// Authoring Practices have one: one stop of Tab, the arrow keys up and down from button to button,
|
|
5
5
|
// and the tools a group of radio buttons that the arrows go through without choosing one. Undo and
|
|
6
6
|
// Clear with nothing to take back or to clear stay where the focus can reach them, marked
|
|
7
7
|
// unavailable: a last undo from the keyboard leaves the focus where it was. After a line, Zoom in
|
|
8
8
|
// and Zoom out step the page's zoom of the sheet by quarters from half its fit to twice it, each
|
|
9
|
-
// unavailable at its end, as a pinch of two fingers sets it between
|
|
9
|
+
// unavailable at its end, as a pinch of two fingers sets it between. The sheet has no
|
|
10
10
|
// buttons that scroll it: the hand, two fingers or a finger in pen mode drag it, the wheel and the
|
|
11
|
-
// keys scroll it
|
|
12
|
-
// NovaTrail package of the interface draws from
|
|
11
|
+
// keys scroll it. The buttons of the bar show an icon alone, of the set every
|
|
12
|
+
// NovaTrail package of the interface draws from: each is named by its label, in the
|
|
13
13
|
// element's language (labels.ts), which only a screen reader reads, and shows it in a tooltip of
|
|
14
14
|
// its own on the pointer's hover and on the keyboard's focus, which Escape dismisses and the
|
|
15
|
-
// pointer can move onto (
|
|
16
|
-
// sheet's or the workbook's
|
|
15
|
+
// pointer can move onto (WCAG 1.4.13). The bar is named by the canvas kind's buttons: the
|
|
16
|
+
// sheet's or the workbook's, for the kind's own name is the scroll container's. A
|
|
17
17
|
// lesson's worked example has no bar: the learner does not write on its sheet, which scrolls as the
|
|
18
18
|
// page does. 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
|
|
19
|
+
// that hides the whole demo and shows it again, are actions, not tools: each shows
|
|
20
20
|
// its label beside its icon, a stop of Tab of its own, in a row of glass at the bottom of the
|
|
21
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
|
|
22
|
+
// Continue —, as the mockup has one row. A task from paper's bar has one button
|
|
23
23
|
// more, atop the tools, after a line: "Hide the task" while its tracing paper is shown, its icon
|
|
24
24
|
// filled, and "Show the task" while it is hidden — the name says the state, so the button is no
|
|
25
|
-
// toggle button as well, which would say it twice
|
|
25
|
+
// toggle button as well, which would say it twice —, and one last, after a line:
|
|
26
26
|
// the sheet's grid, its icon and its name the grid shown now, which a press turns to the next,
|
|
27
|
-
// round — dots, lines, blank, squares
|
|
27
|
+
// round — dots, lines, blank, squares. A button that goes gives its stop of Tab and the focus
|
|
28
28
|
// to the first button shown. This module is no entry point of the package.
|
|
29
29
|
import { SVG, write } from "./attributes.js";
|
|
30
30
|
import { ICONS, ROW } from "./icons.js";
|
|
@@ -45,13 +45,13 @@ export const TIP_GRACE_MS = 200;
|
|
|
45
45
|
export class Tools {
|
|
46
46
|
/**
|
|
47
47
|
* What the element puts beside its scroll container: the band the bar stands in the middle of,
|
|
48
|
-
* as wide as nothing, so that only the bar and its tooltip, which stand out of it, take a
|
|
49
|
-
* and as the element does: a consumer's pointer-events: none stops them too
|
|
48
|
+
* as wide as nothing, so that only the bar and its tooltip, which stand out of it, take a
|
|
49
|
+
* pointer, and as the element does: a consumer's pointer-events: none stops them too.
|
|
50
50
|
*/
|
|
51
51
|
rail = document.createElement("div");
|
|
52
52
|
/** The bar: a toolbar, named in the element's language. */
|
|
53
53
|
element = document.createElement("div");
|
|
54
|
-
/** A worked example's row: Next, Demo and the consumer's buttons in the slot `actions
|
|
54
|
+
/** A worked example's row: Next, Demo and the consumer's buttons in the slot `actions`. */
|
|
55
55
|
row = document.createElement("div");
|
|
56
56
|
#actions = document.createElement("slot");
|
|
57
57
|
#beforeActions = separator();
|
|
@@ -59,7 +59,7 @@ export class Tools {
|
|
|
59
59
|
tip = document.createElement("div");
|
|
60
60
|
#next = plainButton("next");
|
|
61
61
|
#demo = plainButton("demoShown");
|
|
62
|
-
/** A task from paper's button atop the tools, and the line under it
|
|
62
|
+
/** A task from paper's button atop the tools, and the line under it. */
|
|
63
63
|
#task = plainButton("task");
|
|
64
64
|
#afterTask = separator();
|
|
65
65
|
#group = document.createElement("div");
|
|
@@ -68,16 +68,16 @@ export class Tools {
|
|
|
68
68
|
#hand = radioButton("hand");
|
|
69
69
|
#undo = plainButton("undo");
|
|
70
70
|
#clear = plainButton("clear");
|
|
71
|
-
/** The page's zoom of the sheet, after a line
|
|
71
|
+
/** The page's zoom of the sheet, after a line. */
|
|
72
72
|
#beforeZoom = separator();
|
|
73
73
|
#zoomIn = plainButton("zoomIn");
|
|
74
74
|
#zoomOut = plainButton("zoomOut");
|
|
75
|
-
/** A task from paper's grid, after a line
|
|
75
|
+
/** A task from paper's grid, after a line. */
|
|
76
76
|
#beforeGrid = separator();
|
|
77
77
|
#grid = plainButton("gridDots");
|
|
78
78
|
/**
|
|
79
79
|
* The buttons with the keys of their labels, the row's and then the bar's in the order the arrow
|
|
80
|
-
* keys go through them. A button is named only by its label
|
|
80
|
+
* keys go through them. A button is named only by its label, so each is here with its key.
|
|
81
81
|
*/
|
|
82
82
|
#labelled = [
|
|
83
83
|
[this.#next, "next"],
|
|
@@ -94,7 +94,7 @@ export class Tools {
|
|
|
94
94
|
];
|
|
95
95
|
/**
|
|
96
96
|
* The bar's buttons in the order the arrow keys go through them: each shows an icon alone, and a
|
|
97
|
-
* tooltip. Next and Demo show their labels
|
|
97
|
+
* tooltip. Next and Demo show their labels.
|
|
98
98
|
*/
|
|
99
99
|
#buttons = this.#labelled
|
|
100
100
|
.map(([button]) => button)
|
|
@@ -235,10 +235,10 @@ export class Tools {
|
|
|
235
235
|
/**
|
|
236
236
|
* The bar as the sheet now is. Only what has changed is written. A worked example has no bar, for
|
|
237
237
|
* the learner does not write on its sheet, and its row has Next, unavailable while the demo is
|
|
238
|
-
* hidden or open whole, and Demo, expanded while the demo is shown
|
|
238
|
+
* hidden or open whole, and Demo, expanded while the demo is shown. The tool in use shows its
|
|
239
239
|
* icon filled, and Demo's icon points down while the demo is shown, and along the row while it is
|
|
240
|
-
* hidden
|
|
241
|
-
* and fills its icon while the paper is shown
|
|
240
|
+
* hidden. A task from paper's button atop the tools says what it does to the tracing paper,
|
|
241
|
+
* and fills its icon while the paper is shown, and its grid's button shows the grid.
|
|
242
242
|
*/
|
|
243
243
|
show(state) {
|
|
244
244
|
const { kind, tools, tool, undoable, clearable, larger, smaller, opens, expanded, traced, grid, } = state;
|
|
@@ -325,7 +325,7 @@ export class Tools {
|
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
* The name of a task from paper's button atop the tools, by the tracing paper's state, and its
|
|
328
|
-
* tooltip's, should it show
|
|
328
|
+
* tooltip's, should it show.
|
|
329
329
|
*/
|
|
330
330
|
#nameTask() {
|
|
331
331
|
const { labels } = labelsFor(this.#lang ?? null);
|
|
@@ -337,7 +337,7 @@ export class Tools {
|
|
|
337
337
|
if (this.#tipFor === this.#task)
|
|
338
338
|
this.tip.textContent = name;
|
|
339
339
|
}
|
|
340
|
-
/** The name of a task from paper's grid button, by the grid shown, and its tooltip's
|
|
340
|
+
/** The name of a task from paper's grid button, by the grid shown, and its tooltip's. */
|
|
341
341
|
#nameGrid() {
|
|
342
342
|
const { labels } = labelsFor(this.#lang ?? null);
|
|
343
343
|
const label = this.#grid.lastElementChild;
|
|
@@ -387,7 +387,8 @@ export class Tools {
|
|
|
387
387
|
* beside it at the bar's edge, unless Escape dismissed it: only what has changed is written.
|
|
388
388
|
*/
|
|
389
389
|
#showTip() {
|
|
390
|
-
// A button the pointer was over may have gone with no pointerleave: the focus's has its
|
|
390
|
+
// A button the pointer was over may have gone with no pointerleave: the focus's has its
|
|
391
|
+
// tooltip.
|
|
391
392
|
const wanted = [this.#hovered, this.#focused].find((button) => button && !button.hidden);
|
|
392
393
|
if (this.#dismissed !== undefined && this.#dismissed !== wanted)
|
|
393
394
|
this.#dismissed = undefined;
|
|
@@ -453,7 +454,7 @@ export class Tools {
|
|
|
453
454
|
}
|
|
454
455
|
/**
|
|
455
456
|
* Buttons come or go, all of them at once, and then a button that went gives its stop of Tab and
|
|
456
|
-
* the focus to the first button shown: the pen on a sheet, or a task from paper's button
|
|
457
|
+
* the focus to the first button shown: the pen on a sheet, or a task from paper's button. Till
|
|
457
458
|
* a button has had the focus, the stop is the first button shown, whichever it is now. Nothing is
|
|
458
459
|
* read or written while every button stays as it is: the bar is shown anew after every stroke.
|
|
459
460
|
*/
|
|
@@ -529,7 +530,7 @@ function radioButton(value) {
|
|
|
529
530
|
}
|
|
530
531
|
/**
|
|
531
532
|
* A button: its icon, an SVG that says nothing — no title, hidden from a screen reader — and its
|
|
532
|
-
* label, which names it
|
|
533
|
+
* label, which names it: on the bar, only a screen reader reads it.
|
|
533
534
|
*/
|
|
534
535
|
export function plainButton(value) {
|
|
535
536
|
const button = document.createElement("button");
|
|
@@ -548,7 +549,7 @@ export function plainButton(value) {
|
|
|
548
549
|
/**
|
|
549
550
|
* A value's icon on its button, filled or in outline, written only when it is another than the one
|
|
550
551
|
* there: the icon's name stays on the SVG, as data. One mirrored in a row that runs right to left
|
|
551
|
-
* says so by its class, which the style turns
|
|
552
|
+
* says so by its class, which the style turns.
|
|
552
553
|
*/
|
|
553
554
|
export function draw(button, value, filled) {
|
|
554
555
|
const icon = button.firstElementChild;
|
package/lib/element/tracing.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// The tracing paper of a task from paper
|
|
1
|
+
// The tracing paper of a task from paper: the task's crop over the dotted sheet, on a layer
|
|
2
2
|
// of its own between the author's demo and the learner's ink, in sheet units, so that it moves with
|
|
3
3
|
// the sheet as it scrolls and zooms. The crop is multiplied over the sheet: the white of its paper
|
|
4
4
|
// lets the dots and the strokes under it show, and its print stays dark. Its grip "Move the task",
|
|
5
5
|
// a bar above its top edge, moves it by the pointer — a drag, kept to the sheet — and by the arrow
|
|
6
6
|
// keys, a step at a time, Shift a leap (WCAG 2.1.1); a drag is the pointer's one way, as the sheet
|
|
7
|
-
// moves under the hand
|
|
7
|
+
// moves under the hand. The grip's tooltip says its name on the hover of a pointer that
|
|
8
8
|
// hovers and on the keyboard's focus, and Escape dismisses it, as the bar's do (WCAG 1.4.13). The
|
|
9
9
|
// crop's picture is read once, to its grey pixels, for the crop of the work.
|
|
10
10
|
//
|
|
11
|
-
// Its scale
|
|
11
|
+
// Its scale, as the mockup's `Zadacha-masshtab` has it: the grip's press, or its focus,
|
|
12
12
|
// chooses the paper — a blue frame round it with a handle at each corner, which a drag scales from
|
|
13
13
|
// the corner across, and under it the bar of scale: smaller, the percentage, which sets it back to
|
|
14
14
|
// its own size, larger, and fit to the window —; a press on the sheet lets it go. The bar's buttons
|
|
@@ -524,9 +524,9 @@ export class TracingPaper {
|
|
|
524
524
|
};
|
|
525
525
|
}
|
|
526
526
|
/**
|
|
527
|
-
* The scale a corner's drag gives, as the mockup's: the larger of the pointer's two moves
|
|
528
|
-
* each over the paper's own size on the screen, added to the scale it began at; the
|
|
529
|
-
* stays where it was.
|
|
527
|
+
* The scale a corner's drag gives, as the mockup's: the larger of the pointer's two moves
|
|
528
|
+
* outward, each over the paper's own size on the screen, added to the scale it began at; the
|
|
529
|
+
* corner across stays where it was.
|
|
530
530
|
*/
|
|
531
531
|
#cornerMove(event) {
|
|
532
532
|
const drag = this.#corner;
|
|
@@ -572,8 +572,8 @@ export class TracingPaper {
|
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
574
|
/**
|
|
575
|
-
* "Recognise" offers the reading, waits for it, and gives the photo back once the statements
|
|
576
|
-
* statements that came show again with no new reading.
|
|
575
|
+
* "Recognise" offers the reading, waits for it, and gives the photo back once the statements
|
|
576
|
+
* show; statements that came show again with no new reading.
|
|
577
577
|
*/
|
|
578
578
|
#pressMode() {
|
|
579
579
|
const reading = this.#reading;
|