@astl/editor-tiptap 0.2.0 → 0.2.2

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/dist/styles.js CHANGED
@@ -184,6 +184,10 @@ const baseSurfaceStyles = css `
184
184
  outline: var(--astl-focus-width) solid var(--astl-focus);
185
185
  outline-offset: var(--astl-focus-offset);
186
186
  }
187
+ /* The surface's authoring controls (the page heads' buttons, a page box's, the blocks' "Add option", a frame's
188
+ position line, a picture's buttons) are compact, ghost at rest, so that the exercise looks as students see it. A
189
+ host sizes them with --astl-editor-control-size (their height, 1.75rem), --astl-editor-control-font-size (0.8125rem)
190
+ and --astl-editor-control-icon-size (0.875rem); a target stays at least 24px (WCAG 2.5.8). */
187
191
  .astl-surface
188
192
  :is(
189
193
  .astl-page-join,
@@ -194,17 +198,44 @@ const baseSurfaceStyles = css `
194
198
  .astl-help-remove,
195
199
  .astl-help-free
196
200
  ) {
197
- min-block-size: var(--astl-target-min);
198
- min-inline-size: var(--astl-target-min);
199
- padding-inline: var(--astl-space-3);
200
- border: var(--astl-outline-width) solid var(--astl-outline);
201
+ box-sizing: border-box;
202
+ display: inline-flex;
203
+ align-items: center;
204
+ justify-content: center;
205
+ gap: 0.25rem;
206
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
207
+ min-inline-size: max(24px, var(--astl-editor-control-size, 1.75rem));
208
+ padding-block: 0;
209
+ padding-inline: var(--astl-space-2);
210
+ border: var(--astl-outline-width) solid transparent;
201
211
  border-radius: var(--astl-radius-s);
202
- background: var(--astl-surface);
203
- color: var(--astl-ink);
212
+ background: transparent;
213
+ color: var(--astl-ink-muted);
204
214
  font: inherit;
205
- font-size: var(--astl-size-small);
215
+ font-family: var(--astl-font-body);
216
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
217
+ font-weight: 600;
218
+ line-height: 1.2;
219
+ white-space: nowrap;
206
220
  cursor: pointer;
207
221
  }
222
+ .astl-surface
223
+ :is(
224
+ .astl-page-join,
225
+ .astl-page-delete,
226
+ .astl-page-add-title,
227
+ .astl-page-remove-title,
228
+ .astl-page-check,
229
+ .astl-help-remove,
230
+ .astl-help-free
231
+ ):hover {
232
+ background: var(--astl-accent-soft);
233
+ color: var(--astl-ink);
234
+ }
235
+ .astl-surface :is(.astl-help-remove, .astl-block-add button) .astl-icon {
236
+ inline-size: var(--astl-editor-control-icon-size, 0.875rem);
237
+ block-size: var(--astl-editor-control-icon-size, 0.875rem);
238
+ }
208
239
  .astl-surface
209
240
  :is(.astl-page-join, .astl-page-delete, .astl-page-add-title, .astl-page-remove-title, .astl-help-free)[hidden] {
210
241
  display: none;
@@ -213,6 +244,7 @@ const baseSurfaceStyles = css `
213
244
  .astl-surface .astl-page-check[aria-pressed='true'] {
214
245
  border-color: var(--astl-accent);
215
246
  background: var(--astl-accent-soft);
247
+ color: var(--astl-ink);
216
248
  }
217
249
  .astl-surface .astl-page-check[aria-pressed='true']::before {
218
250
  content: '✓ ' / '';
@@ -290,7 +322,7 @@ const baseSurfaceStyles = css `
290
322
  display: flex;
291
323
  flex-wrap: wrap;
292
324
  align-items: center;
293
- gap: 0 var(--astl-space-1);
325
+ gap: 0.2em var(--astl-space-1);
294
326
  inline-size: fit-content;
295
327
  max-inline-size: 100%;
296
328
  margin-block: var(--astl-space-4) calc(-1 * var(--frame-width));
@@ -411,8 +443,7 @@ const baseSurfaceStyles = css `
411
443
  .astl-surface .astl-frame-note[data-severity='warning'] .astl-icon {
412
444
  color: var(--astl-warning);
413
445
  }
414
- .astl-surface .astl-flag,
415
- .astl-surface .astl-block-add button {
446
+ .astl-surface .astl-flag {
416
447
  box-sizing: border-box;
417
448
  display: inline-flex;
418
449
  align-items: center;
@@ -429,9 +460,9 @@ const baseSurfaceStyles = css `
429
460
  font: inherit;
430
461
  cursor: pointer;
431
462
  }
432
- .astl-surface .astl-block-add button:hover {
433
- border-color: var(--astl-line);
463
+ .astl-surface .astl-block-add button:hover:not(:disabled) {
434
464
  background: var(--astl-accent-soft);
465
+ color: var(--astl-ink);
435
466
  }
436
467
  .astl-surface .astl-block-add :focus-visible,
437
468
  .astl-surface .astl-flag:focus-visible {
@@ -490,22 +521,25 @@ const baseSurfaceStyles = css `
490
521
  position: relative;
491
522
  z-index: 1;
492
523
  box-sizing: border-box;
524
+ display: inline-flex;
525
+ align-items: center;
493
526
  visibility: hidden;
494
- min-block-size: var(--astl-target-min);
527
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
495
528
  margin-block: 0 var(--astl-space-1);
496
529
  margin-inline-start: auto;
497
- padding-block: var(--astl-space-1);
530
+ padding-block: 0;
498
531
  padding-inline: var(--astl-space-2);
499
- border: var(--astl-outline-width) solid var(--astl-outline);
532
+ border: var(--astl-outline-width) solid transparent;
500
533
  border-radius: var(--astl-radius-s);
501
- background: var(--astl-surface);
502
- color: var(--astl-ink);
534
+ background: transparent;
535
+ color: var(--astl-ink-muted);
503
536
  font: inherit;
504
537
  font-family: var(--astl-font-body);
505
- font-size: var(--astl-editor-kicker-size, var(--astl-size-small));
538
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
506
539
  font-style: normal;
507
- font-weight: 400;
508
- line-height: 1.3;
540
+ font-weight: 600;
541
+ line-height: 1.2;
542
+ white-space: nowrap;
509
543
  }
510
544
  .astl-surface .astl-frame-head-current > .astl-frame-line {
511
545
  visibility: visible;
@@ -515,6 +549,7 @@ const baseSurfaceStyles = css `
515
549
  }
516
550
  .astl-surface button.astl-frame-line:hover {
517
551
  background: var(--astl-accent-soft);
552
+ color: var(--astl-ink);
518
553
  }
519
554
  .astl-surface .astl-frame-line:focus-visible {
520
555
  outline: var(--astl-focus-width) solid var(--astl-focus);
@@ -526,13 +561,17 @@ const baseSurfaceStyles = css `
526
561
  .astl-surface .astl-atom-summary {
527
562
  color: var(--astl-ink);
528
563
  }
529
- /* Help for students: a labelled box in its interaction or at its place on the page, never wider than either. */
564
+ /* Help for students on the page: a compact labelled box at its place, never wider than the page. A graded block
565
+ component's own help is kept, not drawn: its frame's tags say what it has, the card edits it. */
566
+ .astl-surface .astl-block[data-astl-graded] .astl-help-box {
567
+ display: none;
568
+ }
530
569
  .astl-surface .astl-help-box {
531
570
  box-sizing: border-box;
532
571
  max-inline-size: 100%;
533
572
  margin-block: var(--astl-space-2);
534
- padding-block: var(--astl-space-1) var(--astl-space-2);
535
- padding-inline: var(--astl-space-3);
573
+ padding-block: 0 var(--astl-space-1);
574
+ padding-inline: var(--astl-space-2);
536
575
  border: var(--astl-outline-width) dashed var(--astl-outline);
537
576
  border-radius: var(--astl-radius-s);
538
577
  background: var(--astl-surface-raised);
@@ -550,13 +589,15 @@ const baseSurfaceStyles = css `
550
589
  }
551
590
  .astl-surface .astl-help-head select {
552
591
  box-sizing: border-box;
553
- min-block-size: var(--astl-target-min);
592
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
593
+ padding-block: 0;
554
594
  padding-inline: var(--astl-space-2);
555
595
  border: var(--astl-outline-width) solid var(--astl-outline);
556
596
  border-radius: var(--astl-radius-s);
557
597
  background: var(--astl-surface);
558
598
  color: var(--astl-ink);
559
599
  font: inherit;
600
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
560
601
  font-weight: 400;
561
602
  cursor: pointer;
562
603
  }
@@ -565,9 +606,13 @@ const baseSurfaceStyles = css `
565
606
  outline-offset: var(--astl-focus-offset);
566
607
  }
567
608
  ${unsafeCSS(nativeSelectCss('.astl-surface .astl-help-head select'))}
568
- /* "Remove" closes the head, a page button's look. */
609
+ /* "Remove" closes the head: a cross, a page button's look. */
569
610
  .astl-surface .astl-help-remove {
611
+ display: inline-flex;
612
+ align-items: center;
613
+ justify-content: center;
570
614
  margin-inline-start: auto;
615
+ padding-inline: 0;
571
616
  font-weight: 400;
572
617
  }
573
618
  /* A page's hint with a cost (an older source): what it costs, and "Make it free". */
@@ -582,11 +627,53 @@ const baseSurfaceStyles = css `
582
627
  display: none;
583
628
  }
584
629
  .astl-surface .astl-help-content > :first-child {
585
- margin-block-start: var(--astl-space-1);
630
+ margin-block-start: 0;
586
631
  }
587
632
  .astl-surface .astl-help-content > :last-child {
588
633
  margin-block-end: 0;
589
634
  }
635
+ /* An empty box's line says what to write there. */
636
+ .astl-surface .astl-help-content > .astl-help-empty::before {
637
+ content: attr(data-placeholder);
638
+ float: inline-start;
639
+ block-size: 0;
640
+ color: var(--astl-ink-muted);
641
+ pointer-events: none;
642
+ }
643
+ /* A frame's tags: the help for students its component has, small pills in its tab. Each is a 24px target that keeps
644
+ the tab as high as its line. */
645
+ .astl-surface .astl-frame-help {
646
+ box-sizing: border-box;
647
+ display: inline-flex;
648
+ align-items: center;
649
+ justify-content: center;
650
+ min-block-size: 24px;
651
+ min-inline-size: 24px;
652
+ margin-block: calc((1.3em - 24px) / 2);
653
+ padding: 0;
654
+ border: 0;
655
+ background: none;
656
+ color: inherit;
657
+ font: inherit;
658
+ }
659
+ .astl-surface .astl-frame-help > span {
660
+ padding-inline: 0.45em;
661
+ border: 1px solid currentColor;
662
+ border-radius: var(--astl-radius-pill);
663
+ line-height: 1.3;
664
+ white-space: nowrap;
665
+ }
666
+ .astl-surface button.astl-frame-help {
667
+ cursor: pointer;
668
+ }
669
+ .astl-surface button.astl-frame-help:hover > span {
670
+ background: var(--astl-accent-soft);
671
+ color: var(--astl-ink);
672
+ }
673
+ .astl-surface .astl-frame-help:focus-visible {
674
+ outline: var(--astl-focus-width) solid var(--astl-focus);
675
+ outline-offset: var(--astl-focus-offset);
676
+ }
590
677
  .astl-surface .astl-child {
591
678
  padding-block: var(--astl-space-1);
592
679
  padding-inline-start: var(--astl-space-5);
@@ -654,17 +741,35 @@ const baseSurfaceStyles = css `
654
741
  .astl-surface .astl-block-add {
655
742
  display: flex;
656
743
  flex-wrap: wrap;
657
- gap: var(--astl-space-2);
744
+ gap: var(--astl-space-1);
658
745
  padding-block-start: var(--astl-space-1);
659
746
  }
660
747
  .astl-surface .astl-block-add button[hidden],
661
748
  .astl-surface .astl-block-add:not(:has(button:not([hidden]))) {
662
749
  display: none;
663
750
  }
751
+ /* A small text button under the last child, as the page heads' are. */
664
752
  .astl-surface .astl-block-add button {
665
- padding-inline: var(--astl-space-2) var(--astl-space-3);
666
- color: var(--astl-accent);
753
+ box-sizing: border-box;
754
+ display: inline-flex;
755
+ align-items: center;
756
+ gap: 0.25rem;
757
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
758
+ min-inline-size: max(24px, var(--astl-editor-control-size, 1.75rem));
759
+ margin: 0;
760
+ padding-block: 0;
761
+ padding-inline: var(--astl-space-1) var(--astl-space-2);
762
+ border: var(--astl-outline-width) solid transparent;
763
+ border-radius: var(--astl-radius-s);
764
+ background: transparent;
765
+ color: var(--astl-ink-muted);
766
+ font: inherit;
767
+ font-family: var(--astl-font-body);
768
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
667
769
  font-weight: 600;
770
+ line-height: 1.2;
771
+ white-space: nowrap;
772
+ cursor: pointer;
668
773
  }
669
774
  .astl-surface .astl-block-add button:disabled {
670
775
  color: var(--astl-ink-muted);
@@ -814,28 +919,30 @@ const baseSurfaceStyles = css `
814
919
  font-size: var(--astl-size-small);
815
920
  }
816
921
  .astl-surface button.astl-picture-place {
817
- min-block-size: var(--astl-target-min);
818
- min-inline-size: var(--astl-target-min);
922
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
923
+ min-inline-size: max(24px, var(--astl-editor-control-size, 1.75rem));
924
+ padding-block: 0;
819
925
  padding-inline: var(--astl-space-2);
820
926
  border: var(--astl-outline-width) solid var(--astl-outline);
821
927
  border-radius: var(--astl-radius-s);
822
928
  background: var(--astl-surface);
823
929
  color: var(--astl-ink);
824
930
  font: inherit;
825
- font-size: var(--astl-size-small);
931
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
826
932
  cursor: pointer;
827
933
  }
828
934
  .astl-surface .astl-picture-edit {
829
935
  align-self: flex-start;
830
- min-block-size: var(--astl-target-min);
831
- min-inline-size: var(--astl-target-min);
936
+ min-block-size: max(24px, var(--astl-editor-control-size, 1.75rem));
937
+ min-inline-size: max(24px, var(--astl-editor-control-size, 1.75rem));
938
+ padding-block: 0;
832
939
  padding-inline: var(--astl-space-2);
833
940
  border: var(--astl-outline-width) solid var(--astl-outline);
834
941
  border-radius: var(--astl-radius-s);
835
942
  background: var(--astl-surface);
836
943
  color: var(--astl-ink);
837
944
  font: inherit;
838
- font-size: var(--astl-size-small);
945
+ font-size: var(--astl-editor-control-font-size, 0.8125rem);
839
946
  cursor: pointer;
840
947
  }
841
948
  .astl-surface .astl-figure {
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAkB,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErD,wGAAwG;AACxG,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,iBAAiB,GAAc,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDvB,CAAC;AAEF,MAAM,aAAa,GAAc,GAAG,CAAA,GAAG,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,EAAE,CAAC;AAErG,2FAA2F;AAC3F,MAAM,UAAU,kBAAkB,CAAC,IAAU;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAmC,CAAC;IACjE,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC;IACvC,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,kBAAkB,KAAK,SAAS;QAAE,OAAO;IACzE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,IAAI,CAAC,kBAAkB,GAAG,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;AAC9G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astl/editor-tiptap",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "<astl-editor>: the authoring kit around a TipTap surface, loaded only when no other editor is plugged in through an adapter.",
5
5
  "keywords": [
6
6
  "astrolabe",
@@ -53,11 +53,11 @@
53
53
  "access": "public"
54
54
  },
55
55
  "dependencies": {
56
- "@astl/core": "0.2.0",
57
- "@astl/editor": "0.2.0",
58
- "@astl/engine": "0.2.0",
59
- "@astl/player": "0.2.0",
60
- "@astl/tokens": "0.2.0",
56
+ "@astl/core": "0.2.2",
57
+ "@astl/editor": "0.2.2",
58
+ "@astl/engine": "0.2.2",
59
+ "@astl/player": "0.2.2",
60
+ "@astl/tokens": "0.2.2",
61
61
  "@tiptap/core": "3.32.0",
62
62
  "@tiptap/pm": "3.32.0",
63
63
  "@tiptap/starter-kit": "3.32.0",
package/src/blocks.ts CHANGED
@@ -9,6 +9,9 @@ import {
9
9
  type ComponentManifest,
10
10
  directionOf,
11
11
  type EditorBlockPlace,
12
+ EXPLANATION_TAG,
13
+ FEEDBACK_TAG,
14
+ HINT_TAG,
12
15
  type Issue,
13
16
  type MessageParams,
14
17
  type Severity,
@@ -18,6 +21,7 @@ import {
18
21
  type Authoring,
19
22
  EDITOR_NAMESPACE,
20
23
  GLYPHS,
24
+ type HelpPart,
21
25
  type Placement,
22
26
  positionOf,
23
27
  splitPlacement,
@@ -300,6 +304,8 @@ interface Tab {
300
304
  readonly glyph: string;
301
305
  readonly label: string;
302
306
  readonly meta: readonly string[];
307
+ /** Its tags: the help for students the component has, one per kind, each opening it in the card. */
308
+ readonly help: readonly { readonly part: HelpPart; readonly text: string }[];
303
309
  readonly classes: string;
304
310
  /** Where the component is placed (`placedStyle`): its tab goes with it. */
305
311
  readonly place: string;
@@ -342,10 +348,33 @@ const withoutBlockEnd = (place: string): string =>
342
348
  .filter((one) => !one.startsWith('margin-block-end') && !one.startsWith('display'))
343
349
  .join('; ');
344
350
 
351
+ /** The help for students a component holds, by kind: its hints (how many), its explanation, its feedback texts. */
352
+ function helpIn(node: PMNode, name: (tag: string) => string): Record<HelpPart, number> {
353
+ const count = { hints: 0, explanation: 0, feedback: 0 };
354
+ const add = (tag: string) => {
355
+ if (tag === HINT_TAG) count.hints++;
356
+ else if (tag === EXPLANATION_TAG) count.explanation++;
357
+ else if (tag === FEEDBACK_TAG) count.feedback++;
358
+ };
359
+ if (node.isAtom) {
360
+ for (const kept of (node.attrs.children as readonly (string | { readonly tag: string })[]) ?? [])
361
+ if (typeof kept !== 'string') add(kept.tag);
362
+ return count;
363
+ }
364
+ const tags = new Map([HINT_TAG, EXPLANATION_TAG, FEEDBACK_TAG].map((tag) => [name(tag), tag]));
365
+ node.forEach((child) => {
366
+ const tag = tags.get(child.type.name);
367
+ if (tag !== undefined) add(tag);
368
+ });
369
+ return count;
370
+ }
371
+
345
372
  /**
346
373
  * Frames over the pages: decorations only. Text runs flow on the sheet unframed; each block component directly on a
347
374
  * page is framed (`astl-frame` on its node), with a label tab at the frame's top start (`astl-frame-tab`: the type's
348
- * icon, its label and a summary: how many repeated children it holds, `surface.items`, and its points). The frame with
375
+ * icon, its label and a summary: how many repeated children it holds, `surface.items`, and its points, then a graded
376
+ * one's tags for the help for students it has, `astl-frame-help`: "2 hints", "Explanation", "Feedback", each of which
377
+ * puts the cursor in it and opens that help in the card, `openHelp`; its help itself is not drawn). The frame with
349
378
  * the cursor takes `astl-frame-current` and `data-astl-current` (the accent; its tab filled). The frames validate the document a moment after
350
379
  * each change: one with issues (those of its components, as the outline counts them) takes `astl-frame-error` or
351
380
  * `astl-frame-warning`, dashed in that colour, and says them under its tab, errors first, as `authoring.describe`
@@ -356,6 +385,7 @@ export function blocksExtension(
356
385
  typeOf: TypeOf,
357
386
  name: (tag: string) => string,
358
387
  openStyle?: () => void,
388
+ openHelp?: (part: HelpPart) => void,
359
389
  ): Extension {
360
390
  const t = (key: string, params?: MessageParams) => authoring.t(EDITOR_NAMESPACE, key, params);
361
391
  const ui = { lang: authoring.locale, dir: directionOf(authoring.locale) };
@@ -394,13 +424,29 @@ export function blocksExtension(
394
424
  * hidden, so the row is as high with the cursor in the frame as without it; on a row too narrow for both, it goes
395
425
  * above the tab, never over it.
396
426
  */
397
- const tabDom = (tab: Tab): HTMLElement => {
427
+ const tabDom = (tab: Tab, view: EditorView, getPos: () => number | undefined): HTMLElement => {
398
428
  const head = Object.assign(document.createElement('div'), { className: 'astl-frame-head', ...ui });
399
429
  head.contentEditable = 'false';
400
430
  if (tab.place !== '') head.style.cssText = withoutBlockEnd(tab.place);
401
431
  if (tab.classes.includes('astl-frame-current')) head.classList.add('astl-frame-head-current');
402
432
  const dom = head.appendChild(Object.assign(document.createElement('div'), { className: tab.classes }));
403
433
  fillTab(dom, tab);
434
+ // The tags: a press puts the cursor in the component and opens that help in the card.
435
+ for (const { part, text } of tab.help) {
436
+ const tag = dom.appendChild(document.createElement(openHelp === undefined ? 'span' : 'button'));
437
+ tag.className = 'astl-frame-help';
438
+ tag.dataset.helpPart = part;
439
+ tag.appendChild(document.createElement('span')).textContent = text;
440
+ if (openHelp === undefined) continue;
441
+ Object.assign(tag, { type: 'button', tabIndex: -1, title: t('surface.helpOpen') });
442
+ tag.addEventListener('click', (event) => {
443
+ event.preventDefault();
444
+ const pos = getPos();
445
+ if (pos === undefined) return;
446
+ view.dispatch(view.state.tr.setSelection(selectionAt(view.state.doc, pos)));
447
+ openHelp(part);
448
+ });
449
+ }
404
450
  const line = head.appendChild(document.createElement(openStyle === undefined ? 'span' : 'button'));
405
451
  line.className = 'astl-frame-line';
406
452
  line.textContent = tab.line.text;
@@ -486,19 +532,33 @@ export function blocksExtension(
486
532
  ...(items === null ? [] : [t('surface.items', { n: items })]),
487
533
  ...(manifest.graded ? [t('surface.points', { points: pointsOf(component) })] : []),
488
534
  ];
535
+ const help = manifest.graded ? helpIn(component, name) : null;
536
+ const tags =
537
+ help === null
538
+ ? []
539
+ : [
540
+ ...(help.hints > 0
541
+ ? [{ part: 'hints' as const, text: t('surface.helpHints', { n: help.hints }) }]
542
+ : []),
543
+ ...(help.explanation > 0
544
+ ? [{ part: 'explanation' as const, text: t('insert.explanation') }]
545
+ : []),
546
+ ...(help.feedback > 0 ? [{ part: 'feedback' as const, text: t('insert.feedback') }] : []),
547
+ ];
489
548
  const place = placedStyle(component);
490
549
  const style = (component.attrs.attributes as Record<string, string> | undefined)?.style ?? '';
491
550
  const tab: Tab = {
492
551
  glyph: authoring.descriptor(manifest.tag)?.icon ?? '',
493
552
  label: label(manifest),
494
553
  meta,
554
+ help: tags,
495
555
  classes: classes.join(' ').replace('astl-frame', 'astl-frame-tab'),
496
556
  place,
497
557
  line: placeLabel(t, positionOf(style), widthPercent(style)),
498
558
  };
499
559
  // The tab first, then the notes: the lower side comes first at one position.
500
560
  decorations.push(
501
- Decoration.widget(block.from, () => tabDom(tab), {
561
+ Decoration.widget(block.from, (view, getPos) => tabDom(tab, view, getPos), {
502
562
  key: `tab\n${JSON.stringify(tab)}`,
503
563
  side: -2,
504
564
  stopEvent: () => true,
package/src/element.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  type UrlPolicy,
24
24
  } from '@astl/core';
25
25
  import {
26
+ type AstlInspector,
26
27
  type AstlPictureDialog,
27
28
  type AstlPreview,
28
29
  type AstlToolbar,
@@ -34,6 +35,9 @@ import {
34
35
  type EditorFont,
35
36
  type EditorStylePreset,
36
37
  editorMessages,
38
+ HELP_OPEN,
39
+ type HelpOpen,
40
+ type HelpPart,
37
41
  type Outline,
38
42
  type PickPicture,
39
43
  type ToolbarView,
@@ -453,7 +457,7 @@ const KIT_ICONS: readonly string[] = [
453
457
 
454
458
  /** The inspector's parts, forwarded so hosts can restyle its header, banners and fields (`::part(inspector-issue)`). */
455
459
  const INSPECTOR_PARTS =
456
- 'header: inspector-header, id: inspector-id, actions: inspector-actions, issue: inspector-issue, field: inspector-field, label: inspector-label, style: inspector-style';
460
+ 'header: inspector-header, id: inspector-id, actions: inspector-actions, issue: inspector-issue, field: inspector-field, label: inspector-label, style: inspector-style, help: inspector-help, help-toggle: inspector-help-toggle, help-summary: inspector-help-summary, help-body: inspector-help-body, help-add: inspector-help-add, help-move: inspector-help-move, help-remove: inspector-help-remove';
457
461
 
458
462
  /** The built-in surface module, once imported. */
459
463
  let surfaces: typeof import('./surface.js') | null = null;
@@ -553,6 +557,15 @@ export class AstlEditor extends LitElement {
553
557
  style: (kind: 'picture' | 'figure' | 'component') => {
554
558
  void this.renderRoot.querySelector<AstlToolbar>('astl-toolbar')?.openStyle(kind);
555
559
  },
560
+ // A tag on a frame: `astl-help-open` for a host's inspector, else this element's own opens the help there.
561
+ help: (part: HelpPart) => {
562
+ const element = this.adapter?.getSelection()?.id;
563
+ if (element === undefined) return;
564
+ const detail: HelpOpen = { element, part };
565
+ const event = new CustomEvent(HELP_OPEN, { detail, bubbles: true, composed: true, cancelable: true });
566
+ if (this.dispatchEvent(event))
567
+ void this.renderRoot.querySelector<AstlInspector>('astl-inspector')?.openHelp(part);
568
+ },
556
569
  };
557
570
 
558
571
  /** What the surface tells of pages and blocks: a page added, joined or deleted, a block moved or deleted. */