@astl/editor 0.2.3 → 0.3.0

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/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export type {
4
4
  DescribeOptions,
5
5
  Outline,
6
6
  OutlineBlock,
7
+ OutlineCheck,
7
8
  OutlineComponent,
8
9
  OutlinePage,
9
10
  PickPicture,
@@ -13,7 +14,7 @@ export type {
13
14
  UploadAsset,
14
15
  UploadedAsset,
15
16
  } from './authoring.js';
16
- export { createAuthoring, pictureHtml, pictureSize, UploadRefused } from './authoring.js';
17
+ export { createAuthoring, insertCheck, pictureHtml, pictureSize, UploadRefused } from './authoring.js';
17
18
  export { defineAuthoringElements } from './define.js';
18
19
  export type { InspectorChange } from './edit.js';
19
20
  export type { AstlHelpForm, HelpKind } from './elements/help-form.js';
@@ -35,6 +36,8 @@ export type { InsertMenu, ToolbarView } from './elements/toolbar.js';
35
36
  export { AstlToolbar, FEATURED_ITEMS, VIEW_PICKED } from './elements/toolbar.js';
36
37
  export type {
37
38
  CheckboxFieldModel,
39
+ CheckTargetModel,
40
+ CheckTargetsFieldModel,
38
41
  ChildChoiceFieldModel,
39
42
  ChildChoiceModel,
40
43
  ChildFlagFieldModel,
package/src/inspect.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Inspector models: what an inspector shows for one component element. Fields come from the EditorDescriptor, or
3
3
  * are derived from the manifest; controls follow the AttributeSpec types. Every component also gets `variant` (when
4
- * its manifest has variants) and `style-template` (when templates are offered for it), after those fields. Plain
5
- * data, so any UI can render them.
4
+ * its manifest has variants) and `style-template` (when templates are offered for it), after those fields. A Check
5
+ * element (`astl-check`) has a model of its own (`Authoring.inspect`). Plain data, so any UI can render them.
6
6
  */
7
7
  import {
8
8
  type AttributeSpec,
@@ -235,6 +235,30 @@ export interface PicturePointsFieldModel extends PictureFieldBase {
235
235
  readonly points: readonly PicturePointModel[];
236
236
  }
237
237
 
238
+ /** A question a Check element can check, in its `check-targets` field. */
239
+ export interface CheckTargetModel {
240
+ /** Its source id. */
241
+ readonly id: string;
242
+ /** How authors know it on its page: its type and number ("Gap 2"). */
243
+ readonly label: string;
244
+ /** Whether this Check element checks it. */
245
+ readonly checked: boolean;
246
+ /** The name of another Check element of the page that checks it ("Check button 2"), or null. */
247
+ readonly other: string | null;
248
+ }
249
+
250
+ /**
251
+ * The questions a Check element checks (`for`): the graded questions of its page in order, each ticked when it checks
252
+ * it; one another Check element has says which. A change writes `for` with the ticked ones in this order (empty for
253
+ * none: it then checks nothing).
254
+ */
255
+ export interface CheckTargetsFieldModel extends FieldTexts {
256
+ readonly kind: 'check-targets';
257
+ /** The attribute it writes: `for`. */
258
+ readonly name: string;
259
+ readonly targets: readonly CheckTargetModel[];
260
+ }
261
+
238
262
  export type InspectorFieldModel =
239
263
  | TextFieldModel
240
264
  | NumberFieldModel
@@ -246,7 +270,8 @@ export type InspectorFieldModel =
246
270
  | ChildChoiceFieldModel
247
271
  | ChildTableFieldModel
248
272
  | PictureRegionsFieldModel
249
- | PicturePointsFieldModel;
273
+ | PicturePointsFieldModel
274
+ | CheckTargetsFieldModel;
250
275
 
251
276
  export interface InspectorModel {
252
277
  readonly tag: string;
@@ -256,6 +281,11 @@ export interface InspectorModel {
256
281
  /** Icon name from the descriptor. */
257
282
  readonly icon: string | null;
258
283
  readonly fields: readonly InspectorFieldModel[];
284
+ /**
285
+ * The Check element that checks this question (`OutlineComponent.check`): its source id and its name ("Check button
286
+ * 1"); absent or null when none does, or without the document (`Authoring.inspect` without `source`).
287
+ */
288
+ readonly checkedBy?: { readonly id: string; readonly name: string } | null;
259
289
  }
260
290
 
261
291
  /** Texts the model needs: messages of the manifest namespace (with a fallback) and kit strings. */
@@ -13,6 +13,8 @@
13
13
  "insert.explanation.description": "Why the answer is right, shown once it is checked",
14
14
  "insert.feedback": "Feedback",
15
15
  "insert.feedback.description": "A text by the verdict, shown once the answer is checked",
16
+ "insert.check": "Check button",
17
+ "insert.check.description": "One Check for the questions in the text above it",
16
18
  "insert.text": "Text",
17
19
  "insert.text.description": "A paragraph after this block",
18
20
  "insert.noMatch": "Nothing matches “{query}”.",
@@ -40,6 +42,7 @@
40
42
  "toolbar.search": "Search",
41
43
  "block.text": "Text",
42
44
  "block.gap": "Gap",
45
+ "block.check": "Check button",
43
46
  "issue.onPage": "{n} on page {page}",
44
47
  "picture.title": "Add a picture",
45
48
  "picture.editTitle": "Edit the picture",
@@ -117,6 +120,21 @@
117
120
  "inspector.uploaded": "Uploaded.",
118
121
  "inspector.uploadFailed": "The upload failed. Try again, or type its address.",
119
122
  "inspector.uploadBlocked": "The upload gave an address the URL policy does not allow.",
123
+ "check.labelField": "Button text",
124
+ "check.labelHelp": "Empty: “Check”.",
125
+ "check.targets": "Questions it checks",
126
+ "check.targetsHelp": "The questions on this page. Those ticked have no Check of their own.",
127
+ "check.noQuestions": "This page has no questions yet.",
128
+ "check.target": "{type} {n}",
129
+ "check.name": "Check button {n}",
130
+ "check.named": "“{label}”",
131
+ "check.checkedBy": "Checked by {check}",
132
+ "check.count": "{n, plural, one {# question} other {# questions}}",
133
+ "check.button": "Check",
134
+ "check.none": "No questions",
135
+ "check.auto": "automatic · {n, plural, one {# question} other {# questions}}",
136
+ "check.make": "Make it a button",
137
+ "check.makeHelp": "Where practice checks one question at a time, these questions share this Check. As a button you can pick them and set its text.",
120
138
  "issues.title": "Problems",
121
139
  "issues.errors": "{count, plural, one {# error} other {# errors}}",
122
140
  "issues.warnings": "{count, plural, one {# warning} other {# warnings}}",
@@ -13,6 +13,8 @@
13
13
  "insert.explanation.description": "Dlaczego odpowiedź jest dobra, widoczne po sprawdzeniu",
14
14
  "insert.feedback": "Informacja zwrotna",
15
15
  "insert.feedback.description": "Tekst zależny od wyniku, widoczny po sprawdzeniu",
16
+ "insert.check": "Przycisk Sprawdź",
17
+ "insert.check.description": "Jeden przycisk Sprawdź dla pytań z tekstu nad nim",
16
18
  "insert.text": "Tekst",
17
19
  "insert.text.description": "Akapit po tym bloku",
18
20
  "insert.noMatch": "Nic nie pasuje do „{query}”.",
@@ -40,6 +42,7 @@
40
42
  "toolbar.search": "Szukaj",
41
43
  "block.text": "Tekst",
42
44
  "block.gap": "Luka",
45
+ "block.check": "Przycisk Sprawdź",
43
46
  "issue.onPage": "{n} na stronie {page}",
44
47
  "picture.title": "Dodaj obrazek",
45
48
  "picture.editTitle": "Edytuj obrazek",
@@ -117,6 +120,21 @@
117
120
  "inspector.uploaded": "Wgrano.",
118
121
  "inspector.uploadFailed": "Nie udało się wgrać pliku. Spróbuj ponownie albo wpisz jego adres.",
119
122
  "inspector.uploadBlocked": "Wgrywanie zwróciło adres, na który nie pozwala polityka adresów.",
123
+ "check.labelField": "Tekst przycisku",
124
+ "check.labelHelp": "Puste: „Sprawdź”.",
125
+ "check.targets": "Pytania, które sprawdza",
126
+ "check.targetsHelp": "Pytania z tej strony. Zaznaczone nie mają własnego przycisku Sprawdź.",
127
+ "check.noQuestions": "Na tej stronie nie ma jeszcze pytań.",
128
+ "check.target": "{type} {n}",
129
+ "check.name": "przycisk Sprawdź {n}",
130
+ "check.named": "„{label}”",
131
+ "check.checkedBy": "Sprawdzane przez {check}",
132
+ "check.count": "{n, plural, one {# pytanie} few {# pytania} many {# pytań} other {# pytania}}",
133
+ "check.button": "Sprawdź",
134
+ "check.none": "Brak pytań",
135
+ "check.auto": "automatyczny · {n, plural, one {# pytanie} few {# pytania} many {# pytań} other {# pytania}}",
136
+ "check.make": "Zrób z niego przycisk",
137
+ "check.makeHelp": "Gdy ćwiczenie sprawdza po jednym pytaniu, te pytania mają wspólny przycisk Sprawdź. Jako przycisk możesz wybrać pytania i ustawić jego tekst.",
120
138
  "issues.title": "Problemy",
121
139
  "issues.errors": "{count, plural, one {# błąd} few {# błędy} many {# błędów} other {# błędu}}",
122
140
  "issues.warnings": "{count, plural, one {# ostrzeżenie} few {# ostrzeżenia} many {# ostrzeżeń} other {# ostrzeżenia}}",