@astl/editor 0.0.0 → 0.1.1

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.
Files changed (161) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +202 -0
  3. package/README.md +43 -0
  4. package/dist/authoring.d.ts +284 -0
  5. package/dist/authoring.d.ts.map +1 -0
  6. package/dist/authoring.js +566 -0
  7. package/dist/authoring.js.map +1 -0
  8. package/dist/define.d.ts +8 -0
  9. package/dist/define.d.ts.map +1 -0
  10. package/dist/define.js +35 -0
  11. package/dist/define.js.map +1 -0
  12. package/dist/edit.d.ts +45 -0
  13. package/dist/edit.d.ts.map +1 -0
  14. package/dist/edit.js +150 -0
  15. package/dist/edit.js.map +1 -0
  16. package/dist/elements/base.d.ts +31 -0
  17. package/dist/elements/base.d.ts.map +1 -0
  18. package/dist/elements/base.js +75 -0
  19. package/dist/elements/base.js.map +1 -0
  20. package/dist/elements/color-control.d.ts +25 -0
  21. package/dist/elements/color-control.d.ts.map +1 -0
  22. package/dist/elements/color-control.js +139 -0
  23. package/dist/elements/color-control.js.map +1 -0
  24. package/dist/elements/help-form.d.ts +31 -0
  25. package/dist/elements/help-form.d.ts.map +1 -0
  26. package/dist/elements/help-form.js +371 -0
  27. package/dist/elements/help-form.js.map +1 -0
  28. package/dist/elements/insert-menu.d.ts +79 -0
  29. package/dist/elements/insert-menu.d.ts.map +1 -0
  30. package/dist/elements/insert-menu.js +362 -0
  31. package/dist/elements/insert-menu.js.map +1 -0
  32. package/dist/elements/inspector.d.ts +24 -0
  33. package/dist/elements/inspector.d.ts.map +1 -0
  34. package/dist/elements/inspector.js +846 -0
  35. package/dist/elements/inspector.js.map +1 -0
  36. package/dist/elements/issue-list.d.ts +18 -0
  37. package/dist/elements/issue-list.d.ts.map +1 -0
  38. package/dist/elements/issue-list.js +85 -0
  39. package/dist/elements/issue-list.js.map +1 -0
  40. package/dist/elements/issues.d.ts +24 -0
  41. package/dist/elements/issues.d.ts.map +1 -0
  42. package/dist/elements/issues.js +81 -0
  43. package/dist/elements/issues.js.map +1 -0
  44. package/dist/elements/picture-dialog.d.ts +40 -0
  45. package/dist/elements/picture-dialog.d.ts.map +1 -0
  46. package/dist/elements/picture-dialog.js +433 -0
  47. package/dist/elements/picture-dialog.js.map +1 -0
  48. package/dist/elements/picture-field.d.ts +33 -0
  49. package/dist/elements/picture-field.d.ts.map +1 -0
  50. package/dist/elements/picture-field.js +692 -0
  51. package/dist/elements/picture-field.js.map +1 -0
  52. package/dist/elements/preview.d.ts +34 -0
  53. package/dist/elements/preview.d.ts.map +1 -0
  54. package/dist/elements/preview.js +165 -0
  55. package/dist/elements/preview.js.map +1 -0
  56. package/dist/elements/style-form.d.ts +30 -0
  57. package/dist/elements/style-form.d.ts.map +1 -0
  58. package/dist/elements/style-form.js +640 -0
  59. package/dist/elements/style-form.js.map +1 -0
  60. package/dist/elements/style-load.d.ts +26 -0
  61. package/dist/elements/style-load.d.ts.map +1 -0
  62. package/dist/elements/style-load.js +50 -0
  63. package/dist/elements/style-load.js.map +1 -0
  64. package/dist/elements/style-popups.d.ts +39 -0
  65. package/dist/elements/style-popups.d.ts.map +1 -0
  66. package/dist/elements/style-popups.js +173 -0
  67. package/dist/elements/style-popups.js.map +1 -0
  68. package/dist/elements/style-rules.d.ts +21 -0
  69. package/dist/elements/style-rules.d.ts.map +1 -0
  70. package/dist/elements/style-rules.js +274 -0
  71. package/dist/elements/style-rules.js.map +1 -0
  72. package/dist/elements/styles.d.ts +9 -0
  73. package/dist/elements/styles.d.ts.map +1 -0
  74. package/dist/elements/styles.js +161 -0
  75. package/dist/elements/styles.js.map +1 -0
  76. package/dist/elements/toolbar.d.ts +65 -0
  77. package/dist/elements/toolbar.d.ts.map +1 -0
  78. package/dist/elements/toolbar.js +1270 -0
  79. package/dist/elements/toolbar.js.map +1 -0
  80. package/dist/help.d.ts +33 -0
  81. package/dist/help.d.ts.map +1 -0
  82. package/dist/help.js +111 -0
  83. package/dist/help.js.map +1 -0
  84. package/dist/index.d.ts +32 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +17 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/inspect.d.ts +251 -0
  89. package/dist/inspect.d.ts.map +1 -0
  90. package/dist/inspect.js +428 -0
  91. package/dist/inspect.js.map +1 -0
  92. package/dist/messages/en.json +252 -0
  93. package/dist/messages/help/en.json +18 -0
  94. package/dist/messages/help/pl.json +18 -0
  95. package/dist/messages/pl.json +252 -0
  96. package/dist/messages/style/en.json +67 -0
  97. package/dist/messages/style/pl.json +67 -0
  98. package/dist/messages.d.ts +5 -0
  99. package/dist/messages.d.ts.map +1 -0
  100. package/dist/messages.js +9 -0
  101. package/dist/messages.js.map +1 -0
  102. package/dist/pages.d.ts +28 -0
  103. package/dist/pages.d.ts.map +1 -0
  104. package/dist/pages.js +147 -0
  105. package/dist/pages.js.map +1 -0
  106. package/dist/scan.d.ts +82 -0
  107. package/dist/scan.d.ts.map +1 -0
  108. package/dist/scan.js +329 -0
  109. package/dist/scan.js.map +1 -0
  110. package/dist/style-messages.d.ts +7 -0
  111. package/dist/style-messages.d.ts.map +1 -0
  112. package/dist/style-messages.js +12 -0
  113. package/dist/style-messages.js.map +1 -0
  114. package/dist/style-model.d.ts +50 -0
  115. package/dist/style-model.d.ts.map +1 -0
  116. package/dist/style-model.js +76 -0
  117. package/dist/style-model.js.map +1 -0
  118. package/dist/style-placing.d.ts +38 -0
  119. package/dist/style-placing.d.ts.map +1 -0
  120. package/dist/style-placing.js +98 -0
  121. package/dist/style-placing.js.map +1 -0
  122. package/dist/textarea.d.ts +17 -0
  123. package/dist/textarea.d.ts.map +1 -0
  124. package/dist/textarea.js +175 -0
  125. package/dist/textarea.js.map +1 -0
  126. package/package.json +54 -4
  127. package/src/authoring.ts +896 -0
  128. package/src/define.ts +34 -0
  129. package/src/edit.ts +195 -0
  130. package/src/elements/base.ts +93 -0
  131. package/src/elements/color-control.ts +159 -0
  132. package/src/elements/help-form.ts +404 -0
  133. package/src/elements/insert-menu.ts +481 -0
  134. package/src/elements/inspector.ts +941 -0
  135. package/src/elements/issue-list.ts +103 -0
  136. package/src/elements/issues.ts +89 -0
  137. package/src/elements/picture-dialog.ts +461 -0
  138. package/src/elements/picture-field.ts +770 -0
  139. package/src/elements/preview.ts +186 -0
  140. package/src/elements/style-form.ts +751 -0
  141. package/src/elements/style-load.ts +64 -0
  142. package/src/elements/style-popups.ts +257 -0
  143. package/src/elements/style-rules.ts +294 -0
  144. package/src/elements/styles.ts +162 -0
  145. package/src/elements/toolbar.ts +1386 -0
  146. package/src/help.ts +156 -0
  147. package/src/index.ts +81 -0
  148. package/src/inspect.ts +774 -0
  149. package/src/messages/en.json +252 -0
  150. package/src/messages/help/en.json +18 -0
  151. package/src/messages/help/pl.json +18 -0
  152. package/src/messages/pl.json +252 -0
  153. package/src/messages/style/en.json +67 -0
  154. package/src/messages/style/pl.json +67 -0
  155. package/src/messages.ts +11 -0
  156. package/src/pages.ts +158 -0
  157. package/src/scan.ts +382 -0
  158. package/src/style-messages.ts +13 -0
  159. package/src/style-model.ts +125 -0
  160. package/src/style-placing.ts +117 -0
  161. package/src/textarea.ts +182 -0
@@ -0,0 +1,941 @@
1
+ import type { EditorBlockPlace, EditorStyleTargetKind } from '@astl/core';
2
+ import {
3
+ type CSSResultGroup,
4
+ css,
5
+ html,
6
+ nothing,
7
+ type SVGTemplateResult,
8
+ svg,
9
+ type TemplateResult,
10
+ } from 'lit';
11
+ import { ifDefined } from 'lit/directives/if-defined.js';
12
+ import { live } from 'lit/directives/live.js';
13
+ import { refusalOf } from '../authoring.js';
14
+ import type { InspectorChange } from '../edit.js';
15
+ import type {
16
+ CheckboxFieldModel,
17
+ ChildChoiceFieldModel,
18
+ ChildFlagFieldModel,
19
+ ChildTableFieldModel,
20
+ ChildTextFieldModel,
21
+ InspectorFieldModel,
22
+ InspectorModel,
23
+ NumberFieldModel,
24
+ SelectFieldModel,
25
+ TextFieldModel,
26
+ TextListFieldModel,
27
+ } from '../inspect.js';
28
+ import { AuthoringElement } from './base.js';
29
+ import { GLYPHS, TYPE_GLYPHS } from './insert-menu.js';
30
+ import { SEVERITY_ICONS, sortIssues } from './issue-list.js';
31
+ import type { FieldChange } from './picture-field.js';
32
+ import { loadHelpForm, loadStyleElements, STYLE_OPEN, type StyleOpen } from './style-load.js';
33
+ import { inheritTokens, kitStyles } from './styles.js';
34
+
35
+ /** A control to focus after the next render (text list rows come and go). */
36
+ interface PendingFocus {
37
+ readonly field: number;
38
+ readonly item: number | 'add';
39
+ }
40
+
41
+ /** The icons of the head's actions: shapes only, stroked by the `.glyph` rule. */
42
+ const ACTION_ICONS = {
43
+ moveUp: svg`<path d="M10 16V4M5 9l5-5 5 5"/>`,
44
+ moveDown: svg`<path d="M10 4v12M5 11l5 5 5-5"/>`,
45
+ delete: svg`<path d="M4 6h12M8 6V4h4v2M6 6l.8 10h6.4L14 6M9 9v4M11 9v4"/>`,
46
+ } satisfies Readonly<Record<string, SVGTemplateResult>>;
47
+
48
+ /** Fields that fit beside another in the two-column form: a select, a number or a short text (no upload). */
49
+ const fitsBeside = (field: InspectorFieldModel): boolean =>
50
+ field.kind === 'attribute' &&
51
+ field.control !== 'checkbox' &&
52
+ !(field.control === 'text' && field.accept !== null);
53
+
54
+ const inputValue = (event: Event) => (event.target as HTMLInputElement | HTMLSelectElement).value;
55
+ const checkedOf = (event: Event) => (event.target as HTMLInputElement).checked;
56
+
57
+ /**
58
+ * `<astl-inspector>`: a form for the component at the cursor (answers, alternatives, correct options, whether each
59
+ * statement is true, the category of each card, scoring, points, variant, look), or, with the cursor outside every
60
+ * component, the document's own settings (its look). Every edit goes through `authoring.update` and the adapter
61
+ * (`replaceElement`, or `setSource` for the document), so the editor stays the source of truth. A block component's
62
+ * head has "Move up", "Move down" and "Delete" (`EditorAdapter.moveBlock`, `removeBlock`, at `getCursor`), each left
63
+ * out when the adapter cannot do it; at its page's start or end, a move is unavailable (`aria-disabled`). The head
64
+ * shows the type's icon and name and the element's id in a chip; under it, the element's own issues, as banners. The
65
+ * custom property `--astl-inspector-columns` (default 1) sets the form's columns: with 2, selects, numbers and short
66
+ * texts sit side by side and every other field spans the row.
67
+ */
68
+ export class AstlInspector extends AuthoringElement {
69
+ static override styles: CSSResultGroup = [
70
+ kitStyles,
71
+ // The picture fields redeclare the tokens on their :host: they take this element's (theme, host overrides).
72
+ inheritTokens('astl-picture-field, astl-style-form, astl-help-form'),
73
+ css`
74
+ .style {
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: var(--astl-space-2);
78
+ padding-block-start: var(--astl-space-3);
79
+ border-block-start: var(--astl-outline-width) solid var(--astl-line);
80
+ }
81
+ .style-title {
82
+ margin: 0;
83
+ font-size: 1rem;
84
+ }
85
+ .style-targets {
86
+ display: flex;
87
+ flex-wrap: wrap;
88
+ gap: var(--astl-space-1);
89
+ }
90
+ .fields {
91
+ display: grid;
92
+ grid-template-columns: repeat(var(--astl-inspector-columns, 1), minmax(0, 1fr));
93
+ gap: var(--astl-space-3);
94
+ }
95
+ .fields > * {
96
+ grid-column: 1 / -1;
97
+ }
98
+ .fields > .short {
99
+ grid-column: auto;
100
+ }
101
+ .field,
102
+ fieldset {
103
+ display: flex;
104
+ flex-direction: column;
105
+ gap: var(--astl-space-1);
106
+ min-inline-size: 0;
107
+ margin: 0;
108
+ padding: 0;
109
+ border: 0;
110
+ }
111
+ label:not(.check),
112
+ legend {
113
+ padding: 0;
114
+ font-weight: 600;
115
+ }
116
+ fieldset > ul,
117
+ fieldset > .check:first-of-type {
118
+ margin-block-start: var(--astl-space-1);
119
+ }
120
+ .check {
121
+ box-sizing: border-box;
122
+ display: flex;
123
+ align-items: center;
124
+ gap: var(--astl-space-2);
125
+ min-block-size: var(--astl-target-min);
126
+ cursor: pointer;
127
+ }
128
+ `,
129
+ // One child of a child-choice field with a select: its text above the select.
130
+ css`
131
+ .pick {
132
+ display: flex;
133
+ flex-direction: column;
134
+ gap: var(--astl-space-1);
135
+ margin-block-start: var(--astl-space-1);
136
+ }
137
+ .pick label {
138
+ font-weight: 400;
139
+ }
140
+ .item {
141
+ display: flex;
142
+ gap: var(--astl-space-2);
143
+ align-items: center;
144
+ }
145
+ .item :is(input, textarea) {
146
+ flex: 1 1 auto;
147
+ }
148
+ .item:has(textarea) {
149
+ align-items: flex-start;
150
+ }
151
+ .item button {
152
+ flex: none;
153
+ }
154
+ fieldset > button {
155
+ align-self: flex-start;
156
+ }
157
+ `,
158
+ // One child of a child-choice field with radios: its text, then the values side by side.
159
+ css`
160
+ .choice > legend {
161
+ font-weight: 400;
162
+ }
163
+ .choice > .values {
164
+ display: flex;
165
+ flex-wrap: wrap;
166
+ column-gap: var(--astl-space-4);
167
+ }
168
+ .help {
169
+ margin: 0;
170
+ color: var(--astl-ink-muted);
171
+ font-size: var(--astl-size-small);
172
+ }
173
+ `,
174
+ // One row of a child-table field: its text, then its controls side by side while they fit, and Remove.
175
+ css`
176
+ .row {
177
+ margin-block-start: var(--astl-space-2);
178
+ padding: var(--astl-space-2) var(--astl-space-3) var(--astl-space-3);
179
+ border: var(--astl-outline-width) solid var(--astl-line);
180
+ border-radius: var(--astl-radius-m);
181
+ }
182
+ .row > legend {
183
+ padding-inline: var(--astl-space-1);
184
+ font-weight: 400;
185
+ }
186
+ .cells {
187
+ display: flex;
188
+ flex-wrap: wrap;
189
+ align-items: flex-end;
190
+ gap: var(--astl-space-2);
191
+ }
192
+ .cell {
193
+ flex: 1 1 5rem;
194
+ display: flex;
195
+ flex-direction: column;
196
+ gap: var(--astl-space-1);
197
+ min-inline-size: 0;
198
+ font-weight: 400;
199
+ }
200
+ .cell > input,
201
+ .cell > select {
202
+ inline-size: 100%;
203
+ }
204
+ `,
205
+ // The head: the type's icon and name, the id in a chip, then the block's actions (icons), which wrap under it when
206
+ // narrow. Under it the element's issues, each a banner in its severity's colour with an icon and words.
207
+ css`
208
+ .head,
209
+ .actions {
210
+ display: flex;
211
+ flex-wrap: wrap;
212
+ align-items: center;
213
+ gap: var(--astl-space-1) var(--astl-space-2);
214
+ }
215
+ .title {
216
+ flex: 0 1 auto;
217
+ min-inline-size: 0;
218
+ }
219
+ .actions {
220
+ margin-inline-start: auto;
221
+ }
222
+ .glyph {
223
+ fill: none;
224
+ stroke: currentColor;
225
+ stroke-width: 1.8;
226
+ stroke-linecap: round;
227
+ stroke-linejoin: round;
228
+ }
229
+ .glyph circle {
230
+ fill: currentColor;
231
+ stroke: none;
232
+ }
233
+ .id {
234
+ padding-inline: var(--astl-space-2);
235
+ border-radius: var(--astl-radius-s);
236
+ background: var(--astl-accent-soft);
237
+ color: var(--astl-ink);
238
+ font-family: var(--astl-font-mono);
239
+ font-size: var(--astl-size-small);
240
+ }
241
+ .delete {
242
+ color: var(--astl-danger);
243
+ }
244
+ .issue {
245
+ display: flex;
246
+ align-items: flex-start;
247
+ gap: var(--astl-space-2);
248
+ padding-block: var(--astl-space-2);
249
+ padding-inline: var(--astl-space-3);
250
+ border-radius: var(--astl-radius-s);
251
+ background: var(--astl-danger-soft);
252
+ color: var(--astl-ink);
253
+ }
254
+ .issue .icon {
255
+ color: var(--astl-danger);
256
+ }
257
+ .issue[data-severity='warning'] {
258
+ background: var(--astl-warning-soft);
259
+ }
260
+ .issue[data-severity='warning'] .icon {
261
+ color: var(--astl-warning);
262
+ }
263
+ @media (forced-colors: active) {
264
+ .issue {
265
+ border: var(--astl-outline-width) solid CanvasText;
266
+ }
267
+ }
268
+ `,
269
+ // A text-list row in a text area keeps its line breaks and grows with them.
270
+ css`
271
+ textarea {
272
+ field-sizing: content;
273
+ min-block-size: 5lh;
274
+ resize: vertical;
275
+ }
276
+ .upload {
277
+ display: flex;
278
+ flex-direction: column;
279
+ align-items: flex-start;
280
+ }
281
+ .upload p {
282
+ margin-block: var(--astl-space-1) 0;
283
+ }
284
+ .error {
285
+ margin: 0;
286
+ padding: var(--astl-space-2);
287
+ border-inline-start: var(--astl-space-1) solid var(--astl-danger);
288
+ background: var(--astl-danger-soft);
289
+ }
290
+ `,
291
+ ];
292
+
293
+ /** Source id of the element shown: edits go to it. */
294
+ #shown: string | null = null;
295
+ /** The document's settings are shown: edits go to the start tag of `<astl-doc>`. */
296
+ #document = false;
297
+ #model: InspectorModel | null = null;
298
+ #focus: PendingFocus | null = null;
299
+ /**
300
+ * The last upload of a `url` field: its element and attribute, and what it says (a message key, or with `text` a
301
+ * host's own words, `UploadRefused`).
302
+ */
303
+ #upload: {
304
+ readonly element: string | null;
305
+ readonly name: string;
306
+ readonly key: string;
307
+ readonly error: boolean;
308
+ readonly text?: string | undefined;
309
+ } | null = null;
310
+ /** Aborts the upload under way (its `signal`): another pick replaces it. */
311
+ #abort: AbortController | null = null;
312
+
313
+ /** The inspector model on screen (a component's, or the document's), or null. */
314
+ get model(): InspectorModel | null {
315
+ return this.#model;
316
+ }
317
+
318
+ /**
319
+ * Applies a change to what is shown (the element, or the document), or to the element `element` (a picture field's
320
+ * late upload, whatever the cursor is in by then).
321
+ */
322
+ #apply(change: InspectorChange, element?: string | null): void {
323
+ const { authoring, adapter } = this;
324
+ if (authoring === null || adapter === null) return;
325
+ if (element === undefined && this.#document) {
326
+ const source = adapter.getSource();
327
+ const next = authoring.update(source, change);
328
+ if (next !== source) adapter.setSource(next);
329
+ return;
330
+ }
331
+ const id = element === undefined ? this.#shown : element;
332
+ if (id === null) return;
333
+ const current = adapter.getElement(id);
334
+ if (current === null) return;
335
+ const next = authoring.update(current, change);
336
+ if (next !== current) adapter.replaceElement(id, next);
337
+ }
338
+
339
+ protected override updated(): void {
340
+ const focus = this.#focus;
341
+ if (focus === null) return;
342
+ this.#focus = null;
343
+ const item = focus.item === 'add' ? '[data-add]' : `[data-item="${focus.item}"]`;
344
+ this.renderRoot.querySelector<HTMLElement>(`[data-field="${focus.field}"]${item}`)?.focus();
345
+ }
346
+
347
+ /** `short` marks a field that may sit beside another (`--astl-inspector-columns`). */
348
+ #fieldClass(field: InspectorFieldModel): string {
349
+ return fitsBeside(field) ? 'field short' : 'field';
350
+ }
351
+
352
+ #help(field: InspectorFieldModel, i: number): TemplateResult | typeof nothing {
353
+ return field.help === null ? nothing : html`<p class="help" id="help-${i}">${field.help}</p>`;
354
+ }
355
+
356
+ #describedBy(field: InspectorFieldModel, i: number): string | undefined {
357
+ return field.help === null ? undefined : `help-${i}`;
358
+ }
359
+
360
+ #text(field: TextFieldModel, i: number): TemplateResult {
361
+ const commit = (event: Event) => {
362
+ const value = inputValue(event);
363
+ this.#apply({
364
+ kind: 'attribute',
365
+ name: field.name,
366
+ value: value === '' && !field.required ? null : value,
367
+ });
368
+ };
369
+ return html`<div class=${this.#fieldClass(field)} part="field">
370
+ <label for="field-${i}" part="label">${field.label}</label>
371
+ <input
372
+ id="field-${i}"
373
+ type="text"
374
+ dir="auto"
375
+ autocomplete="off"
376
+ data-name=${field.name}
377
+ .value=${live(field.value)}
378
+ ?required=${field.required}
379
+ aria-describedby=${ifDefined(this.#describedBy(field, i))}
380
+ @input=${commit}
381
+ />
382
+ ${this.#help(field, i)}
383
+ ${field.accept === null || this.authoring?.uploadAsset == null ? nothing : this.#uploadControl(field, field.accept)}
384
+ </div>`;
385
+ }
386
+
387
+ /** A button that picks a file for a `url` field and uploads it, and what the last upload says. */
388
+ #uploadControl(field: TextFieldModel, accept: string): TemplateResult {
389
+ const said = this.#upload;
390
+ const status = said?.element === this.#shown && said.name === field.name ? said : null;
391
+ const words = status === null ? '' : (status.text ?? this.t(status.key));
392
+ const pick = (event: Event) => {
393
+ const input = event.target as HTMLInputElement;
394
+ const file = input.files?.[0];
395
+ input.value = '';
396
+ if (file !== undefined) void this.#uploadFile(field, file);
397
+ };
398
+ return html`<div class="upload">
399
+ <button
400
+ type="button"
401
+ aria-label=${this.t('inspector.uploadItem', { label: field.label })}
402
+ @click=${(event: Event) => ((event.currentTarget as Element).nextElementSibling as HTMLElement).click()}
403
+ >
404
+ ${this.t('inspector.upload')}
405
+ </button>
406
+ <input type="file" accept=${accept} hidden data-name=${field.name} @change=${pick} />
407
+ <div role="status">${status !== null && !status.error ? html`<p class="help">${words}</p>` : nothing}</div>
408
+ <div role="alert">${status?.error ? html`<p class="error">${words}</p>` : nothing}</div>
409
+ </div>`;
410
+ }
411
+
412
+ /**
413
+ * Uploads a file with the host's `uploadAsset` and writes its address, when the URL policy allows it (asked as the
414
+ * engine asks: the element's tag and attribute), into the element shown when it started.
415
+ */
416
+ async #uploadFile(field: TextFieldModel, file: File): Promise<void> {
417
+ const authoring = this.authoring;
418
+ const upload = authoring?.uploadAsset ?? null;
419
+ if (authoring === null || upload === null) return;
420
+ const element = this.#shown;
421
+ const tag = this.#model?.tag ?? '';
422
+ this.#abort?.abort();
423
+ const abort = new AbortController();
424
+ this.#abort = abort;
425
+ const say = (key: string, error = false, text?: string) => {
426
+ this.#upload = { element, name: field.name, key, error, text };
427
+ this.requestUpdate();
428
+ };
429
+ say('inspector.uploading');
430
+ try {
431
+ const asset = await upload(file, { signal: abort.signal });
432
+ if (abort.signal.aborted) return;
433
+ const src = typeof asset?.src === 'string' ? asset.src.trim() : '';
434
+ if (src === '' || !authoring.urlPolicy(src, { tag, attribute: field.name })) {
435
+ say('inspector.uploadBlocked', true);
436
+ return;
437
+ }
438
+ this.#apply({ kind: 'attribute', name: field.name, value: src }, element);
439
+ say('inspector.uploaded');
440
+ } catch (error) {
441
+ if (!abort.signal.aborted) say('inspector.uploadFailed', true, refusalOf(error));
442
+ }
443
+ }
444
+
445
+ #number(field: NumberFieldModel, i: number): TemplateResult {
446
+ // Numbers commit on change (blur, Enter, arrows): half-typed values like "0." never reach the source.
447
+ const commit = (event: Event) => {
448
+ const value = inputValue(event);
449
+ this.#apply({ kind: 'attribute', name: field.name, value: value === '' ? null : value });
450
+ };
451
+ return html`<div class=${this.#fieldClass(field)} part="field">
452
+ <label for="field-${i}" part="label">${field.label}</label>
453
+ <input
454
+ id="field-${i}"
455
+ type="number"
456
+ data-name=${field.name}
457
+ min=${ifDefined(field.min ?? undefined)}
458
+ max=${ifDefined(field.max ?? undefined)}
459
+ step=${field.step}
460
+ .value=${live(field.value)}
461
+ ?required=${field.required}
462
+ aria-describedby=${ifDefined(this.#describedBy(field, i))}
463
+ @change=${commit}
464
+ />
465
+ ${this.#help(field, i)}
466
+ </div>`;
467
+ }
468
+
469
+ #checkbox(field: CheckboxFieldModel, i: number): TemplateResult {
470
+ return html`<div class="field" part="field">
471
+ <label class="check" part="label">
472
+ <input
473
+ type="checkbox"
474
+ data-name=${field.name}
475
+ .checked=${live(field.checked)}
476
+ aria-describedby=${ifDefined(this.#describedBy(field, i))}
477
+ @change=${(event: Event) =>
478
+ this.#apply({ kind: 'attribute', name: field.name, value: checkedOf(event) })}
479
+ />
480
+ <span>${field.label}</span>
481
+ </label>
482
+ ${this.#help(field, i)}
483
+ </div>`;
484
+ }
485
+
486
+ #select(field: SelectFieldModel, i: number): TemplateResult {
487
+ const commit = (event: Event) => {
488
+ const value = inputValue(event);
489
+ this.#apply({ kind: 'attribute', name: field.name, value: value === '' ? null : value });
490
+ };
491
+ return html`<div class=${this.#fieldClass(field)} part="field">
492
+ <label for="field-${i}" part="label">${field.label}</label>
493
+ <select
494
+ id="field-${i}"
495
+ data-name=${field.name}
496
+ aria-describedby=${ifDefined(this.#describedBy(field, i))}
497
+ @change=${commit}
498
+ >
499
+ ${field.options.map(
500
+ (option) =>
501
+ html`<option value=${option.value} .selected=${live(option.value === field.value)}>${option.label}</option>`,
502
+ )}
503
+ </select>
504
+ ${this.#help(field, i)}
505
+ </div>`;
506
+ }
507
+
508
+ #textList(field: TextListFieldModel, i: number): TemplateResult {
509
+ const values = field.values;
510
+ const set = (next: readonly string[]) => this.#apply({ kind: 'text-list', tag: field.tag, values: next });
511
+ const add = () => {
512
+ this.#focus = { field: i, item: values.length };
513
+ set([...values, '']);
514
+ };
515
+ const remove = (j: number) => {
516
+ const next = values.filter((_, k) => k !== j);
517
+ this.#focus = { field: i, item: next.length === 0 ? 'add' : Math.min(j, next.length - 1) };
518
+ set(next);
519
+ };
520
+ const full = field.max !== null && values.length >= field.max;
521
+ return html`<fieldset data-tag=${field.tag} part="field">
522
+ <legend part="label">${field.label}</legend>
523
+ ${this.#help(field, i)}
524
+ ${
525
+ values.length === 0
526
+ ? nothing
527
+ : html`<ul role="list">
528
+ ${values.map((value, j) => {
529
+ const name = this.t('inspector.item', { label: field.label, n: j + 1 });
530
+ const described = ifDefined(this.#describedBy(field, i));
531
+ const write = (event: Event) => set(values.map((v, k) => (k === j ? inputValue(event) : v)));
532
+ // A multi-line value (a transcript) in a text area that keeps its line breaks.
533
+ return html`<li class="item">
534
+ ${
535
+ field.multiline
536
+ ? html`<textarea dir="auto" data-field=${i} data-item=${j} aria-label=${name}
537
+ aria-describedby=${described} .value=${live(value)} @input=${write}></textarea>`
538
+ : html`<input type="text" dir="auto" autocomplete="off" data-field=${i} data-item=${j}
539
+ aria-label=${name} aria-describedby=${described} .value=${live(value)} @input=${write} />`
540
+ }
541
+ <button
542
+ type="button"
543
+ aria-label=${this.t('inspector.removeItem', { label: field.label, n: j + 1 })}
544
+ @click=${() => remove(j)}
545
+ >
546
+ ${this.t('inspector.remove')}
547
+ </button>
548
+ </li>`;
549
+ })}
550
+ </ul>`
551
+ }
552
+ <button type="button" data-field=${i} data-add ?disabled=${full} @click=${add}>${this.t('inspector.add')}</button>
553
+ </fieldset>`;
554
+ }
555
+
556
+ #childFlags(field: ChildFlagFieldModel, i: number): TemplateResult {
557
+ return html`<fieldset data-tag=${field.tag} part="field" aria-describedby=${ifDefined(this.#describedBy(field, i))}>
558
+ <legend part="label">${field.label}</legend>
559
+ ${this.#help(field, i)}
560
+ ${field.children.map(
561
+ (child) => html`<label class="check">
562
+ <input
563
+ type="checkbox"
564
+ data-index=${child.index}
565
+ .checked=${live(child.checked)}
566
+ @change=${(event: Event) =>
567
+ this.#apply({
568
+ kind: 'child-flag',
569
+ tag: field.tag,
570
+ attribute: field.attribute,
571
+ index: child.index,
572
+ value: checkedOf(event),
573
+ })}
574
+ />
575
+ <span dir="auto">${child.label}</span>
576
+ </label>`,
577
+ )}
578
+ </fieldset>`;
579
+ }
580
+
581
+ /** A text input per child, labelled by the child's text (e.g. the word each clue hides); empty removes the value. */
582
+ #childTexts(field: ChildTextFieldModel, i: number): TemplateResult {
583
+ return html`<fieldset data-tag=${field.tag} part="field" aria-describedby=${ifDefined(this.#describedBy(field, i))}>
584
+ <legend part="label">${field.label}</legend>
585
+ ${this.#help(field, i)}
586
+ ${field.children.map(
587
+ (child) => html`<div class="pick">
588
+ <label for="field-${i}-${child.index}" dir="auto">${child.label}</label>
589
+ <input
590
+ id="field-${i}-${child.index}"
591
+ type="text"
592
+ dir="auto"
593
+ autocomplete="off"
594
+ data-index=${child.index}
595
+ .value=${live(child.value)}
596
+ @input=${(event: Event) =>
597
+ this.#apply({
598
+ kind: 'child-attributes',
599
+ tag: field.tag,
600
+ index: child.index,
601
+ attributes: { [field.attribute]: inputValue(event) || null },
602
+ })}
603
+ />
604
+ </div>`,
605
+ )}
606
+ </fieldset>`;
607
+ }
608
+
609
+ /**
610
+ * One control per child, named by the child's text: a radio group of the attribute's values (e.g. True / False for
611
+ * each statement), or a select of the ids of other children (e.g. the group of each card).
612
+ */
613
+ #childChoices(field: ChildChoiceFieldModel, i: number): TemplateResult {
614
+ const choose = (index: number, value: string | null) =>
615
+ this.#apply({ kind: 'child-choice', tag: field.tag, attribute: field.attribute, index, value });
616
+ return html`<fieldset data-tag=${field.tag} part="field" aria-describedby=${ifDefined(this.#describedBy(field, i))}>
617
+ <legend part="label">${field.label}</legend>
618
+ ${this.#help(field, i)}
619
+ ${field.children.map((child) =>
620
+ field.control === 'radios'
621
+ ? html`<fieldset class="choice" data-index=${child.index}>
622
+ <legend dir="auto">${child.label}</legend>
623
+ <div class="values">
624
+ ${child.options.map(
625
+ (option) => html`<label class="check">
626
+ <input
627
+ type="radio"
628
+ name="choice-${i}-${child.index}"
629
+ value=${option.value}
630
+ .checked=${live(child.value === option.value)}
631
+ @change=${() => choose(child.index, option.value)}
632
+ />
633
+ <span>${option.label}</span>
634
+ </label>`,
635
+ )}
636
+ </div>
637
+ </fieldset>`
638
+ : html`<div class="pick">
639
+ <label for="field-${i}-${child.index}" dir="auto">${child.label}</label>
640
+ <select
641
+ id="field-${i}-${child.index}"
642
+ data-index=${child.index}
643
+ @change=${(event: Event) => choose(child.index, inputValue(event) || null)}
644
+ >
645
+ ${child.options.map(
646
+ (option) =>
647
+ html`<option value=${option.value} .selected=${live(option.value === child.value)}>${option.label}</option>`,
648
+ )}
649
+ </select>
650
+ </div>`,
651
+ )}
652
+ </fieldset>`;
653
+ }
654
+
655
+ /**
656
+ * A row per child, named by its text, with a labelled control per column (text and numbers commit like the attribute
657
+ * fields), a button that removes the row, and one that adds a row at the end.
658
+ */
659
+ #childTable(field: ChildTableFieldModel, i: number): TemplateResult {
660
+ const { tag, rows, columns } = field;
661
+ const change = (index: number, attribute: string, value: string, required: boolean) =>
662
+ this.#apply({
663
+ kind: 'child-attributes',
664
+ tag,
665
+ index,
666
+ attributes: { [attribute]: value || (required ? '' : null) },
667
+ });
668
+ const add = () => {
669
+ this.#focus = { field: i, item: rows.length };
670
+ this.#apply({ kind: 'child-add', tag, attributes: field.added });
671
+ };
672
+ const remove = (index: number) => {
673
+ this.#focus = { field: i, item: rows.length > 1 ? Math.min(index, rows.length - 2) : 'add' };
674
+ this.#apply({ kind: 'child-remove', tag, index });
675
+ };
676
+ const control = (
677
+ column: ChildTableFieldModel['columns'][number],
678
+ row: ChildTableFieldModel['rows'][number],
679
+ k: number,
680
+ ) => {
681
+ const value = row.values[k] ?? '';
682
+ const commit = (event: Event) =>
683
+ change(row.index, column.attribute, inputValue(event), column.required);
684
+ const first = k === 0 ? { field: i, item: row.index } : null;
685
+ if (column.control === 'select') {
686
+ const known = column.options.some((o) => o.value === value);
687
+ const options = known
688
+ ? column.options
689
+ : [...column.options, { value, label: value || this.t('inspector.unset') }];
690
+ return html`<select data-field=${ifDefined(first?.field)} data-item=${ifDefined(first?.item)} data-name=${column.attribute} @change=${commit}>
691
+ ${options.map((o) => html`<option value=${o.value} .selected=${live(o.value === value)}>${o.label}</option>`)}
692
+ </select>`;
693
+ }
694
+ return html`<input
695
+ type=${column.control}
696
+ dir=${column.control === 'text' ? 'auto' : nothing}
697
+ autocomplete="off"
698
+ data-field=${ifDefined(first?.field)}
699
+ data-item=${ifDefined(first?.item)}
700
+ data-name=${column.attribute}
701
+ min=${ifDefined(column.min ?? undefined)}
702
+ max=${ifDefined(column.max ?? undefined)}
703
+ step=${ifDefined(column.control === 'number' ? column.step : undefined)}
704
+ .value=${live(value)}
705
+ @input=${column.control === 'text' ? commit : nothing}
706
+ @change=${column.control === 'number' ? commit : nothing}
707
+ />`;
708
+ };
709
+ return html`<fieldset data-tag=${tag} part="field" aria-describedby=${ifDefined(this.#describedBy(field, i))}>
710
+ <legend part="label">${field.label}</legend>
711
+ ${this.#help(field, i)}
712
+ ${rows.map(
713
+ (row) => html`<fieldset class="row" data-index=${row.index}>
714
+ <legend dir="auto">${row.label}</legend>
715
+ <div class="cells">
716
+ ${columns.map(
717
+ (column, k) =>
718
+ html`<label class="cell"><span>${column.label}</span>${control(column, row, k)}</label>`,
719
+ )}
720
+ <button
721
+ type="button"
722
+ aria-label=${this.t('inspector.removeItem', { label: field.label, n: row.index + 1 })}
723
+ ?disabled=${rows.length <= field.min}
724
+ @click=${() => remove(row.index)}
725
+ >
726
+ ${this.t('inspector.remove')}
727
+ </button>
728
+ </div>
729
+ </fieldset>`,
730
+ )}
731
+ <button type="button" data-field=${i} data-add ?disabled=${field.max !== null && rows.length >= field.max} @click=${add}>
732
+ ${this.t('inspector.add')}
733
+ </button>
734
+ </fieldset>`;
735
+ }
736
+
737
+ #field(field: InspectorFieldModel, i: number): TemplateResult {
738
+ switch (field.kind) {
739
+ case 'picture-regions':
740
+ case 'picture-points':
741
+ return html`<astl-picture-field
742
+ .field=${field}
743
+ .authoring=${this.authoring}
744
+ .element=${this.#shown}
745
+ @astl-field-change=${(event: CustomEvent<FieldChange>) => this.#apply(event.detail.change, event.detail.element)}
746
+ ></astl-picture-field>`;
747
+ case 'text-list':
748
+ return this.#textList(field, i);
749
+ case 'child-flag':
750
+ return this.#childFlags(field, i);
751
+ case 'child-text':
752
+ return this.#childTexts(field, i);
753
+ case 'child-choice':
754
+ return this.#childChoices(field, i);
755
+ case 'child-table':
756
+ return this.#childTable(field, i);
757
+ case 'attribute':
758
+ switch (field.control) {
759
+ case 'text':
760
+ return this.#text(field, i);
761
+ case 'number':
762
+ return this.#number(field, i);
763
+ case 'checkbox':
764
+ return this.#checkbox(field, i);
765
+ case 'select':
766
+ return this.#select(field, i);
767
+ }
768
+ }
769
+ }
770
+
771
+ /**
772
+ * The icon buttons of a block component's head, named and with a tooltip by their text: each needs the cursor's block
773
+ * (`getCursor`) and its own capability. A move off the page's start or end is unavailable but keeps the focus; after a
774
+ * delete the focus goes to the editor.
775
+ */
776
+ #actions(tag: string): TemplateResult | typeof nothing {
777
+ const { authoring, adapter } = this;
778
+ const place: EditorBlockPlace | null = adapter?.getCursor?.() ?? null;
779
+ if (authoring === null || adapter === null || place === null) return nothing;
780
+ if (authoring.descriptor(tag)?.manifest.display !== 'block') return nothing;
781
+ const page = authoring.outline(adapter.getSource()).pages.find((p) => p.id === place.page);
782
+ const button = (name: keyof typeof ACTION_ICONS, off: boolean, run: () => void) =>
783
+ html`<button type="button" class=${name} data-action=${name} aria-label=${this.t(`inspector.${name}`)}
784
+ title=${this.t(`inspector.${name}`)} aria-disabled=${off ? 'true' : nothing}
785
+ @click=${() => {
786
+ if (!off) run();
787
+ }}><svg class="icon glyph" viewBox="0 0 20 20" aria-hidden="true" focusable="false">${ACTION_ICONS[name]}</svg></button>`;
788
+ const move = (direction: 'up' | 'down') => () => adapter.moveBlock?.(place, direction);
789
+ return html`<div class="actions" part="actions">
790
+ ${adapter.moveBlock === undefined ? nothing : button('moveUp', place.index === 0, move('up'))}
791
+ ${adapter.moveBlock === undefined ? nothing : button('moveDown', place.index >= (page?.blocks.length ?? 0) - 1, move('down'))}
792
+ ${
793
+ adapter.removeBlock === undefined
794
+ ? nothing
795
+ : button('delete', false, () => {
796
+ adapter.removeBlock?.(place);
797
+ adapter.focus?.();
798
+ })
799
+ }
800
+ </div>`;
801
+ }
802
+
803
+ /** The element's own issues, the sentences its frame shows (`authoring.describe` without the page), errors first. */
804
+ #issues(model: InspectorModel): TemplateResult | typeof nothing {
805
+ const { authoring, adapter } = this;
806
+ if (authoring === null || adapter === null || model.id === null) return nothing;
807
+ const source = adapter.getSource();
808
+ const issues = sortIssues(authoring.validate(source).issues.filter((i) => i.at.element === model.id));
809
+ if (issues.length === 0) return nothing;
810
+ return html`<ul class="issues" role="list">
811
+ ${issues.map(
812
+ (
813
+ issue,
814
+ ) => html`<li class="issue" part="issue" data-code=${issue.code} data-severity=${issue.severity}>
815
+ <svg class="icon" viewBox="0 0 20 20" aria-hidden="true" focusable="false">${SEVERITY_ICONS[issue.severity]}</svg>
816
+ <span class="astl-vh">${this.t(`severity.${issue.severity}`)}: </span>
817
+ <span>${authoring.describe(issue, source, { page: false })}</span>
818
+ </li>`,
819
+ )}
820
+ </ul>`;
821
+ }
822
+
823
+ /** The head: the type's icon and name, the id in a chip when it has one, then the block's actions. */
824
+ #head(model: InspectorModel): TemplateResult {
825
+ const display = this.authoring?.descriptor(model.tag)?.manifest.display;
826
+ const glyph = TYPE_GLYPHS.get(model.icon ?? '') ?? GLYPHS[display === 'inline' ? 'inline' : 'block'];
827
+ return html`<div class="head" part="head header">
828
+ <svg class="icon glyph" viewBox="0 0 20 20" aria-hidden="true" focusable="false">${glyph}</svg>
829
+ <h2 class="title" id="title" part="title" data-id=${model.id ?? nothing}>${model.label}</h2>
830
+ ${model.id === null ? nothing : html`<code class="id" part="id">${model.id}</code>`}
831
+ ${this.#actions(model.tag)}
832
+ </div>`;
833
+ }
834
+
835
+ /** The kinds at the cursor: when they change, so does the style section. */
836
+ #styleKinds = '';
837
+ /** The target whose form is open here, while it is at the cursor. */
838
+ #styleOpen: EditorStyleTargetKind | null = null;
839
+
840
+ protected override cursorChanged(): void {
841
+ const targets = this.adapter?.style?.state().targets ?? [];
842
+ const kinds = targets.map((target) => target.kind).join(' ');
843
+ if (kinds === this.#styleKinds) return;
844
+ this.#styleKinds = kinds;
845
+ // A picture has nothing else to set here, and its position and size are why it was selected.
846
+ const first = targets[0]?.kind;
847
+ this.#styleOpen = first === 'picture' ? first : null;
848
+ if (this.#styleOpen !== null) void this.#showStyle(this.#styleOpen);
849
+ this.requestUpdate();
850
+ }
851
+
852
+ /** Shows a form here, the module loaded first. */
853
+ async #showStyle(kind: EditorStyleTargetKind): Promise<void> {
854
+ await loadStyleElements();
855
+ this.#styleOpen = kind;
856
+ this.requestUpdate();
857
+ }
858
+
859
+ /** A press on a target: a host may take it (`astl-style-open`); otherwise its form opens here, or closes. */
860
+ #askStyle(kind: EditorStyleTargetKind): void {
861
+ if (this.#styleOpen === kind) {
862
+ this.#styleOpen = null;
863
+ this.requestUpdate();
864
+ return;
865
+ }
866
+ const detail: StyleOpen = { target: kind };
867
+ const event = new CustomEvent(STYLE_OPEN, { detail, bubbles: true, composed: true, cancelable: true });
868
+ if (this.dispatchEvent(event)) void this.#showStyle(kind);
869
+ }
870
+
871
+ /** The style of what the cursor is in: a button per target, and the open one's form. */
872
+ #styleSection(): TemplateResult | typeof nothing {
873
+ const targets = this.adapter?.style?.state().targets ?? [];
874
+ if (targets.length === 0) return nothing;
875
+ const open = targets.some((target) => target.kind === this.#styleOpen) ? this.#styleOpen : null;
876
+ return html`<div class="style" part="style">
877
+ <h3 class="style-title">${this.t('inspector.style')}</h3>
878
+ <div class="style-targets">
879
+ ${targets.map(
880
+ (target) => html`<button
881
+ type="button"
882
+ data-style-target=${target.kind}
883
+ aria-expanded=${String(open === target.kind)}
884
+ @click=${() => this.#askStyle(target.kind)}
885
+ >
886
+ ${this.t(`style.target.${target.kind}`)}
887
+ </button>`,
888
+ )}
889
+ </div>
890
+ ${
891
+ open === null
892
+ ? nothing
893
+ : html`<astl-style-form .authoring=${this.authoring} .adapter=${this.adapter} .target=${open}></astl-style-form>`
894
+ }
895
+ </div>`;
896
+ }
897
+
898
+ protected override render(): TemplateResult | typeof nothing {
899
+ const { authoring, adapter } = this;
900
+ if (authoring === null) return nothing;
901
+ const selection = adapter?.getSelection() ?? null;
902
+ const source = selection === null || adapter === null ? null : adapter.getElement(selection.id);
903
+ // With the document: a field may list what another element holds (the words of a drop's bank).
904
+ const model = source === null ? null : authoring.inspect(source, adapter?.getSource());
905
+ // Outside every component: the document's own settings, under the hint.
906
+ const document =
907
+ selection === null && adapter !== null ? authoring.inspectDocument(adapter.getSource()) : null;
908
+ this.#shown = model === null ? null : (selection?.id ?? null);
909
+ this.#document = model === null && document !== null;
910
+ this.#model = model ?? document;
911
+ const { lang, dir } = this.ui;
912
+ let body: TemplateResult;
913
+ if (model === null) {
914
+ const note =
915
+ source !== null && selection !== null
916
+ ? this.t('inspector.unsupported', { tag: selection.tag })
917
+ : this.t('inspector.empty');
918
+ body = html`<h2 class="title" id="title" part="title">${this.t('inspector.title')}</h2>
919
+ <p class="note">${note}</p>
920
+ ${
921
+ document === null
922
+ ? nothing
923
+ : html`<div class="fields" data-tag=${document.tag}>${document.fields.map((f, i) => this.#field(f, i))}</div>`
924
+ }`;
925
+ } else {
926
+ // The heading says the type; the id is beside it in a chip, outside the heading.
927
+ // A graded element's help for students: a form of its own, loaded on first use.
928
+ const manifest = authoring.descriptor(model.tag)?.manifest;
929
+ if (manifest?.graded === true) void loadHelpForm().catch(() => {});
930
+ body = html`${this.#head(model)}${this.#issues(model)}
931
+ <div class="fields" data-tag=${model.tag}>${model.fields.map((f, i) => this.#field(f, i))}</div>
932
+ ${
933
+ manifest?.graded === true
934
+ ? html`<astl-help-form .authoring=${authoring} .adapter=${adapter} .element=${this.#shown}
935
+ ?inline=${manifest.display === 'inline'}></astl-help-form>`
936
+ : nothing
937
+ }`;
938
+ }
939
+ return html`<section class="kit" part="root" lang=${lang} dir=${dir} aria-labelledby="title">${body}${this.#styleSection()}</section>`;
940
+ }
941
+ }