@altnovatrail/canvas 0.3.38 → 0.3.40
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/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 +24 -16
- package/lib/core/hands.js +66 -14
- package/lib/core/history.d.ts +9 -9
- 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 +34 -34
- package/lib/core/notation.d.ts +29 -0
- package/lib/core/notation.js +180 -0
- 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 +7 -7
- package/lib/core/recorder.js +7 -7
- 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 +3 -3
- package/lib/core/sheet.js +3 -3
- 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 +20 -20
- package/lib/core/tracing.js +20 -20
- package/lib/core/widths.d.ts +2 -2
- package/lib/core/widths.js +5 -5
- package/lib/core/work.d.ts +18 -18
- package/lib/core/work.js +21 -21
- package/lib/core/zoom.d.ts +34 -0
- package/lib/core/zoom.js +64 -0
- package/lib/element/icons.d.ts +19 -1
- package/lib/element/icons.js +24 -2
- package/lib/element/index.d.ts +87 -87
- package/lib/element/index.js +397 -295
- package/lib/element/labels.d.ts +21 -18
- package/lib/element/labels.js +15 -12
- package/lib/element/notation.d.ts +2 -0
- package/lib/element/notation.js +94 -0
- 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.d.ts +3 -0
- package/lib/element/session.js +8 -4
- package/lib/element/statement.d.ts +2 -2
- package/lib/element/statement.js +6 -6
- package/lib/element/tools.d.ts +21 -18
- package/lib/element/tools.js +46 -30
- package/lib/element/tracing.js +58 -31
- 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,31 +23,34 @@ 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. */
|
|
29
|
+
readonly zoomIn: string;
|
|
30
|
+
readonly zoomOut: string;
|
|
28
31
|
/**
|
|
29
32
|
* The button of a task from paper's grid, by the grid the sheet shows now: a press turns it to
|
|
30
|
-
* the next
|
|
33
|
+
* the next.
|
|
31
34
|
*/
|
|
32
35
|
readonly gridDots: string;
|
|
33
36
|
readonly gridLines: string;
|
|
34
37
|
readonly gridBlank: string;
|
|
35
38
|
readonly gridSquares: string;
|
|
36
|
-
/** 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. */
|
|
37
40
|
readonly moveTask: string;
|
|
38
41
|
readonly hideTask: string;
|
|
39
42
|
readonly showTask: string;
|
|
40
43
|
/**
|
|
41
|
-
* The tracing paper's bar of scale
|
|
44
|
+
* The tracing paper's bar of scale: its name, smaller, larger, the scale as a percentage,
|
|
42
45
|
* {percent}, which a press sets back to its own size, and fit to the window.
|
|
43
46
|
*/
|
|
44
47
|
readonly scaleButtons: string;
|
|
45
|
-
readonly
|
|
46
|
-
readonly
|
|
48
|
+
readonly smaller: string;
|
|
49
|
+
readonly larger: string;
|
|
47
50
|
readonly scaleReset: string;
|
|
48
51
|
readonly fit: string;
|
|
49
52
|
/**
|
|
50
|
-
* 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
|
|
51
54
|
* offers the photo back, and the sign above the paper of what it shows.
|
|
52
55
|
*/
|
|
53
56
|
readonly recognise: string;
|
|
@@ -55,17 +58,17 @@ export interface Labels {
|
|
|
55
58
|
readonly original: string;
|
|
56
59
|
readonly photoShown: string;
|
|
57
60
|
readonly readingShown: string;
|
|
58
|
-
/** A box of a workbook's line, alone in it
|
|
61
|
+
/** A box of a workbook's line, alone in it. */
|
|
59
62
|
readonly box: string;
|
|
60
|
-
/** A box among several of its line, by its slot: {slot}
|
|
63
|
+
/** A box among several of its line, by its slot: {slot}. */
|
|
61
64
|
readonly boxAt: string;
|
|
62
|
-
/** 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}. */
|
|
63
66
|
readonly boxIn: string;
|
|
64
|
-
/** A box's {name} when the box is filled
|
|
67
|
+
/** A box's {name} when the box is filled. */
|
|
65
68
|
readonly filled: string;
|
|
66
|
-
/** 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. */
|
|
67
70
|
readonly valued: string;
|
|
68
|
-
/** 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}. */
|
|
69
72
|
readonly part: string;
|
|
70
73
|
}
|
|
71
74
|
/** Every language the table has, by its tag: the tests hold each to English's places. */
|
|
@@ -84,7 +87,7 @@ type Labelled = {
|
|
|
84
87
|
export declare function labelsFor(tag: string | null): Labelled;
|
|
85
88
|
/**
|
|
86
89
|
* Whether the table has labels in the language of a tag, as `labelsFor` looks it up: the English
|
|
87
|
-
* 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.
|
|
88
91
|
*/
|
|
89
92
|
export declare function knows(tag: string | null): boolean;
|
|
90
93
|
/** The places a label names, each once, in the order it names them. */
|
|
@@ -96,7 +99,7 @@ export declare function placesOf(label: string): string[];
|
|
|
96
99
|
export declare function say(label: string, values: Readonly<Record<string, string | number>>): string;
|
|
97
100
|
/**
|
|
98
101
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
99
|
-
* 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
|
|
100
103
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
101
104
|
*/
|
|
102
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({
|
|
@@ -29,6 +28,8 @@ const ENGLISH = Object.freeze({
|
|
|
29
28
|
undo: "Undo",
|
|
30
29
|
clear: "Clear",
|
|
31
30
|
hand: "Hand",
|
|
31
|
+
zoomIn: "Zoom in",
|
|
32
|
+
zoomOut: "Zoom out",
|
|
32
33
|
gridDots: "Grid: dots",
|
|
33
34
|
gridLines: "Grid: lines",
|
|
34
35
|
gridBlank: "Grid: blank",
|
|
@@ -37,8 +38,8 @@ const ENGLISH = Object.freeze({
|
|
|
37
38
|
hideTask: "Hide the task",
|
|
38
39
|
showTask: "Show the task",
|
|
39
40
|
scaleButtons: "Task scale",
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
smaller: "Smaller",
|
|
42
|
+
larger: "Larger",
|
|
42
43
|
scaleReset: "{percent}: back to 100%",
|
|
43
44
|
fit: "Fit",
|
|
44
45
|
recognise: "Recognise",
|
|
@@ -77,6 +78,8 @@ const LABELS = new Map([
|
|
|
77
78
|
undo: "Отменить",
|
|
78
79
|
clear: "Очистить",
|
|
79
80
|
hand: "Рука",
|
|
81
|
+
zoomIn: "Крупнее",
|
|
82
|
+
zoomOut: "Мельче",
|
|
80
83
|
gridDots: "Сетка: точки",
|
|
81
84
|
gridLines: "Сетка: строчки",
|
|
82
85
|
gridBlank: "Сетка: пусто",
|
|
@@ -85,8 +88,8 @@ const LABELS = new Map([
|
|
|
85
88
|
hideTask: "Спрятать задачу",
|
|
86
89
|
showTask: "Показать задачу",
|
|
87
90
|
scaleButtons: "Масштаб задачи",
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
smaller: "Уменьшить",
|
|
92
|
+
larger: "Увеличить",
|
|
90
93
|
scaleReset: "{percent}: вернуть 100 %",
|
|
91
94
|
fit: "Вписать",
|
|
92
95
|
recognise: "Распознать",
|
|
@@ -116,7 +119,7 @@ export function labelsFor(tag) {
|
|
|
116
119
|
}
|
|
117
120
|
/**
|
|
118
121
|
* Whether the table has labels in the language of a tag, as `labelsFor` looks it up: the English
|
|
119
|
-
* 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.
|
|
120
123
|
*/
|
|
121
124
|
export function knows(tag) {
|
|
122
125
|
return lookup(tag) !== undefined;
|
|
@@ -156,7 +159,7 @@ export function say(label, values) {
|
|
|
156
159
|
}
|
|
157
160
|
/**
|
|
158
161
|
* A label with its places filled by name but one, which it is cut at: what comes before that place
|
|
159
|
-
* 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
|
|
160
163
|
* the place not once is a TypeError, and so is a place the values do not give, as with `say`.
|
|
161
164
|
*/
|
|
162
165
|
export function sayAround(label, place, values) {
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { formulaic, piecesOf } from "../core/notation.js";
|
|
2
|
+
// A statement read, drawn as the page prints it: its text as text, a box an answer goes in
|
|
3
|
+
// as a dashed box, and a fraction or a power as MathML, which the browser lays out itself, a
|
|
4
|
+
// fraction full size on the line and those within it smaller, as a book sets them. In a statement
|
|
5
|
+
// with no word its lone letters are its unknowns, in italics as MathML sets a letter.
|
|
6
|
+
const MATHML = "http://www.w3.org/1998/Math/MathML";
|
|
7
|
+
/** The nodes of one statement's line. */
|
|
8
|
+
export function lineOf(statement) {
|
|
9
|
+
const letters = formulaic(statement);
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const piece of piecesOf(statement)) {
|
|
12
|
+
if (piece.kind === "text")
|
|
13
|
+
out.push(...textOf(piece.text, letters));
|
|
14
|
+
else if (piece.kind === "box")
|
|
15
|
+
out.push(slot());
|
|
16
|
+
else {
|
|
17
|
+
const math = mathml("math");
|
|
18
|
+
math.setAttribute("displaystyle", "true");
|
|
19
|
+
math.append(mathOf(piece));
|
|
20
|
+
out.push(math);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/** Text of the line: in a formula, each lone letter in italics. */
|
|
26
|
+
function textOf(text, letters) {
|
|
27
|
+
if (!letters)
|
|
28
|
+
return [document.createTextNode(text)];
|
|
29
|
+
return text
|
|
30
|
+
.split(/(\p{L})/u)
|
|
31
|
+
.filter((part) => part !== "")
|
|
32
|
+
.map((part) => {
|
|
33
|
+
if (!/^\p{L}$/u.test(part))
|
|
34
|
+
return document.createTextNode(part);
|
|
35
|
+
const letter = document.createElement("i");
|
|
36
|
+
letter.textContent = part;
|
|
37
|
+
return letter;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** A dashed box an answer goes in. */
|
|
41
|
+
function slot() {
|
|
42
|
+
const box = document.createElement("span");
|
|
43
|
+
box.className = "slot";
|
|
44
|
+
return box;
|
|
45
|
+
}
|
|
46
|
+
/** A piece as MathML. */
|
|
47
|
+
function mathOf(piece) {
|
|
48
|
+
switch (piece.kind) {
|
|
49
|
+
case "text":
|
|
50
|
+
return row(tokensOf(piece.text));
|
|
51
|
+
case "box": {
|
|
52
|
+
const box = mathml("mspace");
|
|
53
|
+
box.setAttribute("class", "slot");
|
|
54
|
+
// The box of the line's own, 1.08em square, its foot as far under the baseline.
|
|
55
|
+
box.setAttribute("width", "1.08em");
|
|
56
|
+
box.setAttribute("height", "0.86em");
|
|
57
|
+
box.setAttribute("depth", "0.22em");
|
|
58
|
+
return box;
|
|
59
|
+
}
|
|
60
|
+
case "fraction": {
|
|
61
|
+
const fraction = mathml("mfrac");
|
|
62
|
+
fraction.append(rowOf(piece.over), rowOf(piece.under));
|
|
63
|
+
return fraction;
|
|
64
|
+
}
|
|
65
|
+
case "power": {
|
|
66
|
+
const power = mathml("msup");
|
|
67
|
+
power.append(rowOf(piece.base), rowOf(piece.exponent));
|
|
68
|
+
return power;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Pieces as one row of MathML. */
|
|
73
|
+
function rowOf(pieces) {
|
|
74
|
+
return row(pieces.map(mathOf));
|
|
75
|
+
}
|
|
76
|
+
function row(children) {
|
|
77
|
+
const out = mathml("mrow");
|
|
78
|
+
out.append(...children);
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/** Text as MathML's tokens: a number, a letter, and each other sign an operator; spaces dropped. */
|
|
82
|
+
function tokensOf(text) {
|
|
83
|
+
const out = [];
|
|
84
|
+
for (const [token] of text.matchAll(/\d+(?:[.,]\d+)?|\p{L}|\S/gu)) {
|
|
85
|
+
const kind = /^\d/.test(token) ? "mn" : /^\p{L}$/u.test(token) ? "mi" : "mo";
|
|
86
|
+
const element = mathml(kind);
|
|
87
|
+
element.textContent = token;
|
|
88
|
+
out.push(element);
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
function mathml(name) {
|
|
93
|
+
return document.createElementNS(MATHML, name);
|
|
94
|
+
}
|
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.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { PenMode } from "../core/hands.js";
|
|
2
|
+
import { PageZoom } from "../core/zoom.js";
|
|
2
3
|
/** The pen mode of every sheet of this page. */
|
|
3
4
|
export declare const PEN_MODE: PenMode;
|
|
5
|
+
/** The zoom of every sheet of this page. */
|
|
6
|
+
export declare const PAGE_ZOOM: PageZoom;
|
package/lib/element/session.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
// The page's pen mode
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// point of the
|
|
1
|
+
// The page's pen mode and its zoom: one of each for every sheet of the page, the mode
|
|
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, and both stay. They are states of the
|
|
4
|
+
// interface in memory, not data: nothing is stored or sent. This module is no entry point of the
|
|
5
|
+
// package.
|
|
5
6
|
import { PenMode } from "../core/hands.js";
|
|
7
|
+
import { PageZoom } from "../core/zoom.js";
|
|
6
8
|
/** The pen mode of every sheet of this page. */
|
|
7
9
|
export const PEN_MODE = new PenMode();
|
|
10
|
+
/** The zoom of every sheet of this page. */
|
|
11
|
+
export const PAGE_ZOOM = new PageZoom();
|
|
@@ -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,21 +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, and on a worked example the next part of its
|
|
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
17
|
readonly turnGrid: () => void;
|
|
17
18
|
readonly next: () => void;
|
|
18
19
|
readonly toggle: () => void;
|
|
19
|
-
/** A task from paper's tracing paper hidden, or shown again
|
|
20
|
+
/** A task from paper's tracing paper hidden, or shown again. */
|
|
20
21
|
readonly trace: () => void;
|
|
21
22
|
}
|
|
22
|
-
/** 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. */
|
|
23
24
|
export interface DemoControls {
|
|
24
25
|
/** The region that tells of the part Next opens. */
|
|
25
26
|
readonly status: string;
|
|
@@ -27,14 +28,14 @@ export interface DemoControls {
|
|
|
27
28
|
readonly parts: string;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
|
-
* What the bar is of, and is named by: a sheet, a workbook, a task from paper or a worked example
|
|
31
|
-
* (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.
|
|
32
32
|
*/
|
|
33
33
|
export type RowKind = "sheet" | "workbook" | "paper" | "example";
|
|
34
34
|
/**
|
|
35
35
|
* What the bar shows: what it is of, the tools the task allows — the hand besides, always —, the
|
|
36
|
-
* one in use, whether undo and clearing have anything to do,
|
|
37
|
-
* has a part to open and whether the
|
|
36
|
+
* one in use, whether undo and clearing have anything to do, whether the zoom has a larger step
|
|
37
|
+
* and a smaller one, and on a worked example whether Next has a part to open and whether the
|
|
38
|
+
* demo is shown.
|
|
38
39
|
*/
|
|
39
40
|
export interface ToolState {
|
|
40
41
|
readonly kind: RowKind;
|
|
@@ -42,9 +43,11 @@ export interface ToolState {
|
|
|
42
43
|
readonly tool: Tool;
|
|
43
44
|
readonly undoable: boolean;
|
|
44
45
|
readonly clearable: boolean;
|
|
46
|
+
readonly larger: boolean;
|
|
47
|
+
readonly smaller: boolean;
|
|
45
48
|
readonly opens: boolean;
|
|
46
49
|
readonly expanded: boolean;
|
|
47
|
-
/** 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. */
|
|
48
51
|
readonly traced: boolean;
|
|
49
52
|
readonly grid: PaperGrid;
|
|
50
53
|
}
|
|
@@ -58,13 +61,13 @@ export declare class Tools {
|
|
|
58
61
|
#private;
|
|
59
62
|
/**
|
|
60
63
|
* What the element puts beside its scroll container: the band the bar stands in the middle of,
|
|
61
|
-
* as wide as nothing, so that only the bar and its tooltip, which stand out of it, take a
|
|
62
|
-
* 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.
|
|
63
66
|
*/
|
|
64
67
|
readonly rail: HTMLDivElement;
|
|
65
68
|
/** The bar: a toolbar, named in the element's language. */
|
|
66
69
|
readonly element: HTMLDivElement;
|
|
67
|
-
/** 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`. */
|
|
68
71
|
readonly row: HTMLDivElement;
|
|
69
72
|
/** The tooltip of the button the pointer is over, or the keyboard's focus is on. */
|
|
70
73
|
readonly tip: HTMLDivElement;
|
|
@@ -72,10 +75,10 @@ export declare class Tools {
|
|
|
72
75
|
/**
|
|
73
76
|
* The bar as the sheet now is. Only what has changed is written. A worked example has no bar, for
|
|
74
77
|
* the learner does not write on its sheet, and its row has Next, unavailable while the demo is
|
|
75
|
-
* 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
|
|
76
79
|
* icon filled, and Demo's icon points down while the demo is shown, and along the row while it is
|
|
77
|
-
* hidden
|
|
78
|
-
* 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.
|
|
79
82
|
*/
|
|
80
83
|
show(state: ToolState): void;
|
|
81
84
|
/**
|
|
@@ -88,12 +91,12 @@ export declare class Tools {
|
|
|
88
91
|
}
|
|
89
92
|
/**
|
|
90
93
|
* A button: its icon, an SVG that says nothing — no title, hidden from a screen reader — and its
|
|
91
|
-
* label, which names it
|
|
94
|
+
* label, which names it: on the bar, only a screen reader reads it.
|
|
92
95
|
*/
|
|
93
96
|
export declare function plainButton(value: Value): HTMLButtonElement;
|
|
94
97
|
/**
|
|
95
98
|
* A value's icon on its button, filled or in outline, written only when it is another than the one
|
|
96
99
|
* there: the icon's name stays on the SVG, as data. One mirrored in a row that runs right to left
|
|
97
|
-
* says so by its class, which the style turns
|
|
100
|
+
* says so by its class, which the style turns.
|
|
98
101
|
*/
|
|
99
102
|
export declare function draw(button: HTMLButtonElement, value: Value, filled: boolean): void;
|