@altnovatrail/canvas 0.3.32 → 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/core/boxes.d.ts +1 -1
- package/lib/core/boxes.js +3 -3
- package/lib/core/crop.d.ts +1 -5
- package/lib/core/crop.js +1 -5
- package/lib/core/example.js +2 -2
- package/lib/core/grid.d.ts +3 -6
- package/lib/core/grid.js +2 -2
- package/lib/core/groups.d.ts +1 -1
- package/lib/core/groups.js +1 -1
- package/lib/core/hands.d.ts +7 -7
- package/lib/core/hands.js +6 -6
- package/lib/core/history.d.ts +3 -2
- package/lib/core/history.js +3 -2
- package/lib/core/index.js +2 -2
- package/lib/core/manifest.d.ts +2 -3
- package/lib/core/manifest.js +2 -3
- package/lib/core/marks.d.ts +3 -3
- package/lib/core/marks.js +3 -4
- package/lib/core/page.d.ts +2 -2
- package/lib/core/page.js +6 -6
- package/lib/core/recorder.d.ts +5 -5
- package/lib/core/recorder.js +5 -5
- package/lib/core/screen.d.ts +7 -8
- package/lib/core/screen.js +4 -4
- package/lib/core/submission.d.ts +2 -2
- package/lib/core/submission.js +2 -2
- package/lib/core/task.d.ts +6 -7
- package/lib/core/task.js +1 -1
- package/lib/core/zoom.d.ts +2 -2
- package/lib/core/zoom.js +2 -2
- 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/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];
|