@olenbetong/synergi-course 2.0.0 → 2.2.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.
Files changed (96) hide show
  1. package/es/chrome/CategoryHeader.css +28 -0
  2. package/es/completion/CourseCompletion.css +53 -0
  3. package/es/completion/CourseCompletion.d.ts +32 -0
  4. package/es/completion/CourseCompletion.js +60 -0
  5. package/es/document/cues.d.ts +51 -6
  6. package/es/document/cues.js +117 -14
  7. package/es/document/effects.d.ts +30 -0
  8. package/es/document/effects.js +76 -0
  9. package/es/document/schema.d.ts +2722 -346
  10. package/es/document/schema.js +172 -5
  11. package/es/document/validate.d.ts +2 -1
  12. package/es/document/validate.js +83 -16
  13. package/es/index.d.ts +8 -3
  14. package/es/index.js +6 -2
  15. package/es/media/Media.css +16 -0
  16. package/es/media/icons.d.ts +1 -0
  17. package/es/media/icons.js +3 -0
  18. package/es/player/CoursePlayer.css +76 -0
  19. package/es/player/CoursePlayer.js +28 -13
  20. package/es/player/PlayerBars.d.ts +32 -0
  21. package/es/player/PlayerBars.js +14 -0
  22. package/es/player/useFullScreen.d.ts +17 -0
  23. package/es/player/useFullScreen.js +83 -0
  24. package/es/player/useMediaQuery.d.ts +7 -0
  25. package/es/player/useMediaQuery.js +16 -0
  26. package/es/steps/Blocks.d.ts +43 -3
  27. package/es/steps/Blocks.js +114 -26
  28. package/es/steps/Markdown.d.ts +7 -1
  29. package/es/steps/Markdown.js +31 -4
  30. package/es/steps/QuizStepView.d.ts +2 -1
  31. package/es/steps/QuizStepView.js +20 -10
  32. package/es/steps/RevealMotion.d.ts +29 -0
  33. package/es/steps/RevealMotion.js +55 -0
  34. package/es/steps/SlideStepView.d.ts +5 -3
  35. package/es/steps/SlideStepView.js +43 -10
  36. package/es/steps/StepBodyProps.d.ts +16 -1
  37. package/es/steps/StepView.css +390 -16
  38. package/es/steps/StepView.d.ts +36 -4
  39. package/es/steps/StepView.js +21 -5
  40. package/es/steps/motion.d.ts +59 -0
  41. package/es/steps/motion.js +136 -0
  42. package/es/transitions/Transitions.css +114 -0
  43. package/es/transitions/plan.d.ts +66 -0
  44. package/es/transitions/plan.js +185 -0
  45. package/es/transitions/playStepTransition.d.ts +23 -0
  46. package/es/transitions/playStepTransition.js +131 -0
  47. package/es/types.d.ts +16 -3
  48. package/package.json +4 -4
  49. package/src/chrome/CategoryHeader.css +28 -0
  50. package/src/completion/CourseCompletion.css +53 -0
  51. package/src/completion/CourseCompletion.test.tsx +45 -0
  52. package/src/completion/CourseCompletion.tsx +98 -0
  53. package/src/document/box.test.ts +234 -0
  54. package/src/document/cues.ts +143 -13
  55. package/src/document/document.test.ts +1 -1
  56. package/src/document/effects.ts +106 -0
  57. package/src/document/reveal.test.ts +263 -0
  58. package/src/document/schema.ts +203 -5
  59. package/src/document/validate.ts +88 -18
  60. package/src/index.ts +46 -1
  61. package/src/media/Media.css +16 -0
  62. package/src/media/icons.tsx +8 -0
  63. package/src/player/CoursePlayer.css +76 -0
  64. package/src/player/CoursePlayer.test.tsx +70 -6
  65. package/src/player/CoursePlayer.tsx +91 -60
  66. package/src/player/PlayerBars.tsx +106 -0
  67. package/src/player/fullScreen.test.tsx +70 -0
  68. package/src/player/useFullScreen.ts +91 -0
  69. package/src/player/useMediaQuery.ts +21 -0
  70. package/src/steps/Blocks.test.ts +34 -0
  71. package/src/steps/Blocks.tsx +219 -32
  72. package/src/steps/Box.test.tsx +95 -0
  73. package/src/steps/Markdown.test.tsx +46 -0
  74. package/src/steps/Markdown.tsx +42 -4
  75. package/src/steps/Presence.test.tsx +82 -0
  76. package/src/steps/QuizStepView.test.tsx +79 -0
  77. package/src/steps/QuizStepView.tsx +34 -12
  78. package/src/steps/RevealMotion.ts +66 -0
  79. package/src/steps/SlideStepView.tsx +74 -12
  80. package/src/steps/StepBodyProps.ts +16 -1
  81. package/src/steps/StepView.css +390 -16
  82. package/src/steps/StepView.test.tsx +157 -0
  83. package/src/steps/StepView.tsx +108 -19
  84. package/src/steps/motion.test.ts +98 -0
  85. package/src/steps/motion.ts +178 -0
  86. package/src/steps/visibility.test.ts +24 -0
  87. package/src/transitions/Transitions.css +114 -0
  88. package/src/transitions/plan.ts +258 -0
  89. package/src/transitions/playStepTransition.ts +162 -0
  90. package/src/transitions/transitions.test.ts +274 -0
  91. package/src/types.ts +16 -3
  92. package/es/Transitions.css +0 -55
  93. package/es/Transitions.d.ts +0 -10
  94. package/es/Transitions.js +0 -24
  95. package/src/Transitions.css +0 -55
  96. package/src/Transitions.ts +0 -35
@@ -190,6 +190,85 @@ describe("quiz", () => {
190
190
  expect(document.querySelector("audio")).toBeNull();
191
191
  });
192
192
 
193
+ describe("must answer correctly to continue", () => {
194
+ // q1 is right with Green, q2 with both Helmet and Gloves; a wrong answer comes back without an explanation.
195
+ function retryAdapter(start: Partial<QuizAttempt> = {}): QuizAdapter {
196
+ return {
197
+ start: vi.fn(async () => ({ ...attempt, passPercent: null, retryUntilCorrect: true, ...start })),
198
+ answer: vi.fn(async (_slideId: number, _attemptId: string, questionId: string, optionIds: string[]) => {
199
+ let correct = questionId === "q1" ? optionIds.join() === "o11" : [...optionIds].sort().join() === "o21,o22";
200
+ return { correct, explanation: correct ? `Explained ${questionId}.` : null };
201
+ }),
202
+ finish: vi.fn(async () =>
203
+ result({ passed: true, percent: 100, correctCount: 2, passPercent: null, retryUntilCorrect: true }),
204
+ ),
205
+ };
206
+ }
207
+
208
+ it("asks again after a wrong answer and shows the explanation only after the right one", async () => {
209
+ let quiz = retryAdapter();
210
+ renderQuiz(quiz);
211
+
212
+ await click(button("Start the quiz"));
213
+ await click(screen.getByRole("radio", { name: "Red" }));
214
+ await click(button("Answer"));
215
+ expect(screen.getByText("Not correct. Try again.")).toBeInTheDocument();
216
+ expect(screen.queryByText("Explained q1.")).not.toBeInTheDocument();
217
+ expect(screen.queryByRole("button", { name: "Next question" })).not.toBeInTheDocument();
218
+ expect(screen.getByRole("radio", { name: "Green" })).toBeEnabled();
219
+
220
+ // Choosing another answer clears the old verdict.
221
+ await click(screen.getByRole("radio", { name: "Green" }));
222
+ expect(screen.queryByText("Not correct. Try again.")).not.toBeInTheDocument();
223
+ await click(button("Answer"));
224
+ expect(screen.getByText("Correct")).toBeInTheDocument();
225
+ expect(screen.getByText("Explained q1.")).toBeInTheDocument();
226
+ expect(quiz.answer).toHaveBeenNthCalledWith(1, 7, "a1", "q1", ["o12"]);
227
+ expect(quiz.answer).toHaveBeenNthCalledWith(2, 7, "a1", "q1", ["o11"]);
228
+ await click(button("Next question"));
229
+
230
+ await click(screen.getByRole("checkbox", { name: "Helmet" }));
231
+ await click(button("Answer"));
232
+ expect(screen.getByText("Not correct. Try again.")).toBeInTheDocument();
233
+ expect(screen.queryByRole("button", { name: "See the result" })).not.toBeInTheDocument();
234
+ await click(screen.getByRole("checkbox", { name: "Gloves" }));
235
+ await click(button("Answer"));
236
+ expect(quiz.answer).toHaveBeenLastCalledWith(7, "a1", "q2", ["o21", "o22"]);
237
+ await click(button("See the result"));
238
+
239
+ expect(screen.getByText("You passed the quiz")).toBeInTheDocument();
240
+ expect(screen.getByText("You answered every question correctly.")).toBeInTheDocument();
241
+ expect(screen.queryByText(/%/)).not.toBeInTheDocument();
242
+ expect(button("Next")).toBeEnabled();
243
+ });
244
+
245
+ it("never shows an explanation that comes with a wrong answer", async () => {
246
+ let quiz = retryAdapter();
247
+ quiz.answer = vi.fn(async () => ({ correct: false, explanation: "Green is right." }));
248
+ renderQuiz(quiz);
249
+
250
+ await click(button("Start the quiz"));
251
+ await click(screen.getByRole("radio", { name: "Red" }));
252
+ await click(button("Answer"));
253
+ expect(screen.getByText("Not correct. Try again.")).toBeInTheDocument();
254
+ expect(screen.queryByText("Green is right.")).not.toBeInTheDocument();
255
+ });
256
+
257
+ it("resumes at a question that was last answered wrong", async () => {
258
+ // The server only marks a correct answer as answered in this mode.
259
+ let quiz = retryAdapter({
260
+ questions: [
261
+ { ...attempt.questions[0], answered: true },
262
+ { ...attempt.questions[1], answered: false },
263
+ ],
264
+ });
265
+ renderQuiz(quiz);
266
+
267
+ await click(button("Start the quiz"));
268
+ expect(screen.getByText("Question 2 of 2")).toBeInTheDocument();
269
+ });
270
+ });
271
+
193
272
  it("shows a quiz passed before as passed", async () => {
194
273
  let quiz = quizAdapter([], { alreadyPassed: true });
195
274
  renderQuiz(quiz);
@@ -18,7 +18,8 @@ type Phase =
18
18
 
19
19
  /**
20
20
  * A quiz, one question at a time with feedback after each answer, graded by the server.
21
- * Done when an attempt has passed.
21
+ * Done when an attempt has passed. With `retryUntilCorrect` a wrong answer only says so and the
22
+ * learner answers the same question again; the next question comes after the right answer.
22
23
  */
23
24
  export function QuizStepView({
24
25
  step,
@@ -138,7 +139,10 @@ export function QuizStepView({
138
139
  let question = attempt.questions[index];
139
140
  let nextIndex = attempt.questions.findIndex((candidate, at) => at > index && !candidate.answered);
140
141
  let isLast = nextIndex === -1;
141
- let answered = feedback != null;
142
+ let retry = attempt.retryUntilCorrect === true;
143
+ // A wrong answer in a retry quiz leaves the question open for another answer.
144
+ let answered = feedback != null && (feedback.correct || !retry);
145
+ let tryAgain = feedback != null && !answered;
142
146
  let inputName = `ob-course-quiz-${slideId}-${question.questionId}`;
143
147
 
144
148
  let answer = () =>
@@ -146,6 +150,13 @@ export function QuizStepView({
146
150
  setFeedback(await quiz.answer(slideId, attempt.attemptId, question.questionId, selected));
147
151
  });
148
152
 
153
+ let toggle = (optionId: string, checked: boolean) => {
154
+ // Changing the answer after "try again" clears the old verdict, so it is not read as being about the new choice.
155
+ if (tryAgain) setFeedback(null);
156
+ if (!question.multiple) setSelected([optionId]);
157
+ else setSelected((current) => (checked ? [...current, optionId] : current.filter((id) => id !== optionId)));
158
+ };
159
+
149
160
  let next = () => {
150
161
  if (!isLast) {
151
162
  setSelected([]);
@@ -159,11 +170,6 @@ export function QuizStepView({
159
170
  });
160
171
  };
161
172
 
162
- let toggle = (optionId: string, checked: boolean) => {
163
- if (!question.multiple) setSelected([optionId]);
164
- else setSelected((current) => (checked ? [...current, optionId] : current.filter((id) => id !== optionId)));
165
- };
166
-
167
173
  return (
168
174
  <div className="ob-course-form-step ob-course-quiz">
169
175
  <Paragraph data-size="sm" className="ob-course-hint">
@@ -194,13 +200,21 @@ export function QuizStepView({
194
200
  );
195
201
  })}
196
202
  </Fieldset>
197
- {feedback && (
198
- <Alert data-color={feedback.correct ? "success" : "danger"} className="ob-course-quiz__feedback">
203
+ {tryAgain ? (
204
+ <Alert data-color="danger" className="ob-course-quiz__feedback">
199
205
  <Heading level={3} data-size="2xs">
200
- {feedback.correct ? getLocalizedString("Correct") : getLocalizedString("Not correct")}
206
+ {getLocalizedString("Not correct. Try again.")}
201
207
  </Heading>
202
- {feedback.explanation && <Markdown>{feedback.explanation}</Markdown>}
203
208
  </Alert>
209
+ ) : (
210
+ feedback && (
211
+ <Alert data-color={feedback.correct ? "success" : "danger"} className="ob-course-quiz__feedback">
212
+ <Heading level={3} data-size="2xs">
213
+ {feedback.correct ? getLocalizedString("Correct") : getLocalizedString("Not correct")}
214
+ </Heading>
215
+ {feedback.explanation && <Markdown>{feedback.explanation}</Markdown>}
216
+ </Alert>
217
+ )
204
218
  )}
205
219
  {error}
206
220
  <div>
@@ -219,6 +233,7 @@ export function QuizStepView({
219
233
  }
220
234
 
221
235
  let { result } = phase;
236
+ let retryResult = result != null && (result.retryUntilCorrect ?? phase.attempt.retryUntilCorrect) === true;
222
237
 
223
238
  return (
224
239
  <div className="ob-course-form-step ob-course-quiz">
@@ -226,7 +241,14 @@ export function QuizStepView({
226
241
  <Heading level={2} data-size="md" ref={focusRef} tabIndex={-1}>
227
242
  {passed ? getLocalizedString("You passed the quiz") : getLocalizedString("You did not pass the quiz")}
228
243
  </Heading>
229
- {result ? (
244
+ {retryResult ? (
245
+ // Every question had to be right before the next, so a score or a percent would say nothing.
246
+ <Paragraph>
247
+ {passed
248
+ ? getLocalizedString("You answered every question correctly.")
249
+ : getLocalizedString("Answer every question correctly to pass.")}
250
+ </Paragraph>
251
+ ) : result ? (
230
252
  <>
231
253
  <Paragraph className="ob-course-quiz__score">
232
254
  {localize`You answered ${result.correctCount} of ${result.questionCount} questions correctly (${Math.round(result.percent)} %).`}
@@ -0,0 +1,66 @@
1
+ import { Component, type RefObject, useEffect, useState } from "react";
2
+ import { FADE_MS, getGlides, measureParts, type PartBox, pinLeaving, runGlides, unpinReturned } from "./motion";
3
+
4
+ /** Whether the learner asked for less motion. Read once per render; the setting rarely changes. */
5
+ export function prefersCalm() {
6
+ return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
7
+ }
8
+
9
+ /**
10
+ * A part that goes away stays for the length of its fade first. `leaving` lasts `FADE_MS`, then the
11
+ * part is absent; coming back in the meantime makes it present again at once, so stepping back or
12
+ * scrubbing the narration leaves nothing behind.
13
+ */
14
+ export function usePresence(present: boolean, calm: boolean): "present" | "leaving" | "absent" {
15
+ let [leaving, setLeaving] = useState(false);
16
+ let [wasPresent, setWasPresent] = useState(present);
17
+ if (present !== wasPresent) {
18
+ setWasPresent(present);
19
+ setLeaving(!present && !calm);
20
+ }
21
+
22
+ useEffect(() => {
23
+ if (!leaving) return;
24
+ let timer = setTimeout(() => setLeaving(false), FADE_MS);
25
+ return () => clearTimeout(timer);
26
+ }, [leaving]);
27
+
28
+ if (present) return "present";
29
+ return leaving ? "leaving" : "absent";
30
+ }
31
+
32
+ interface RevealMotionProps {
33
+ root: RefObject<HTMLElement | null>;
34
+ /** Names what is shown. A change of it with the same `source` is a reveal. */
35
+ signature: string;
36
+ /** The blocks: a change of them is an edit, or another step, and never glides. */
37
+ source: unknown;
38
+ calm: boolean;
39
+ }
40
+
41
+ /**
42
+ * Glides the parts a reveal pushed to another place, and lifts the parts that fade out out of the
43
+ * flow. Drawn inside the slide; it renders nothing. A class, since `getSnapshotBeforeUpdate` is
44
+ * where React lets a component read the page as it was just before a change is put in it.
45
+ */
46
+ export class RevealMotion extends Component<RevealMotionProps> {
47
+ getSnapshotBeforeUpdate(previous: RevealMotionProps): Map<string, PartBox> | null {
48
+ let element = this.props.root.current;
49
+ let reveal = previous.source === this.props.source && previous.signature !== this.props.signature;
50
+ return reveal && element ? measureParts(element) : null;
51
+ }
52
+
53
+ componentDidUpdate(_previous: RevealMotionProps, _state: unknown, before: Map<string, PartBox> | null) {
54
+ let element = this.props.root.current;
55
+ if (!element) return;
56
+ unpinReturned(element);
57
+ if (!before) return;
58
+ pinLeaving(element, before);
59
+ if (this.props.calm) return;
60
+ runGlides(element, getGlides(before, measureParts(element)));
61
+ }
62
+
63
+ render() {
64
+ return null;
65
+ }
66
+ }
@@ -1,15 +1,19 @@
1
1
  import clsx from "clsx";
2
- import { useEffect, useLayoutEffect, useMemo, useRef } from "react";
3
- import { getRevealSteps } from "../document/cues";
2
+ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { getRevealNavigation, getRevealState, getRevealSteps, getTimedParts } from "../document/cues";
4
+ import { getActiveEffects, getPartEffects } from "../document/effects";
4
5
  import type { SlideStep } from "../document/schema";
5
6
  import { Subtitles } from "../media/MediaControls";
6
7
  import { NarrationPlayer, useNarration } from "../media/Narration";
7
- import { Blocks, type BlocksContext } from "./Blocks";
8
+ import { Blocks, type BlocksContext, getVisibility } from "./Blocks";
8
9
  import type { StepBodyProps } from "./StepBodyProps";
10
+ import { prefersCalm, RevealMotion } from "./RevealMotion";
9
11
 
10
12
  /**
11
- * Blocks on a page. Done when every `reveal: "step"` part is shown and the narration, if any,
12
- * has played to the end (unless it is `required: false`).
13
+ * Blocks on a page. With narration, its cues show and hide the parts and the slide is done when it
14
+ * has played to the end (or at once when it is `required: false`); Next and Back go to the other
15
+ * steps. Without, Next shows the parts that wait for it, and the slide is done when no press would
16
+ * show anything more. The slide reports where Next and Back go with `onRevealNavigation`.
13
17
  */
14
18
  export function SlideStepView({
15
19
  step,
@@ -20,14 +24,28 @@ export function SlideStepView({
20
24
  onSubtitlesChange,
21
25
  onDoneChange,
22
26
  onMediaEnded,
27
+ onRevealNavigation,
28
+ revealAll = false,
29
+ renderInsert,
23
30
  }: StepBodyProps & { step: SlideStep }) {
24
- let revealSteps = useMemo(() => getRevealSteps(step.blocks), [step.blocks]);
25
31
  let narration = step.narration;
32
+ // On a narrated slide only the narration shows and hides parts; Next goes to the next step
33
+ let narrated = narration != null;
34
+ let revealSteps = useMemo(() => getRevealSteps(step.blocks, narrated), [step.blocks, narrated]);
26
35
  let state = useNarration(narration, mode === "learn", onMediaEnded);
27
36
  let clock = state.clock;
28
37
 
38
+ let navigation = useMemo(
39
+ () => getRevealNavigation(step.blocks, stepsShown, clock.startedCues, narrated),
40
+ [step.blocks, stepsShown, clock.startedCues, narrated],
41
+ );
42
+ let { next, previous, presses, pressed } = navigation;
43
+ useLayoutEffect(() => {
44
+ onRevealNavigation?.({ next, previous, presses, pressed });
45
+ }, [next, previous, presses, pressed, onRevealNavigation]);
46
+
29
47
  let mustListen = narration != null && narration.required !== false;
30
- let done = stepsShown >= revealSteps.length && (!mustListen || clock.ended);
48
+ let done = next === null && (!mustListen || clock.ended);
31
49
  useLayoutEffect(() => {
32
50
  onDoneChange(done);
33
51
  }, [done, onDoneChange]);
@@ -45,14 +63,45 @@ export function SlideStepView({
45
63
  part?.scrollIntoView?.({ block: "nearest", behavior: calm ? "auto" : "smooth" });
46
64
  }, [stepsShown, revealSteps]);
47
65
 
66
+ let reveal = useMemo(
67
+ () => getRevealState(step.blocks, stepsShown, clock.startedCues, narrated),
68
+ [step.blocks, stepsShown, clock.startedCues, narrated],
69
+ );
70
+
71
+ // The effects that were shown before this change pick the timing of the parts they act on
72
+ let active = getActiveEffects(step.blocks, reveal);
73
+ let activeKey = [...active].join("\u0000");
74
+ let [effectsSeen, setEffectsSeen] = useState({ key: activeKey, active, previous: active });
75
+ if (effectsSeen.key !== activeKey) setEffectsSeen({ key: activeKey, active, previous: effectsSeen.active });
76
+ // An editor that draws every part shows them where they are laid out, not moved by an effect
77
+ let effects = revealAll ? undefined : getPartEffects(step.blocks, reveal, effectsSeen.previous);
78
+
79
+ let calm = prefersCalm();
80
+
81
+ let signature = getTimedParts(step.blocks)
82
+ .map((part) => `${part.id}:${getVisibility(part, reveal)}`)
83
+ .join("|");
84
+
48
85
  let context: BlocksContext = {
49
- reveal: { stepsShown, revealSteps, startedCues: clock.startedCues },
86
+ reveal,
50
87
  resolveAsset,
51
88
  subtitles,
52
89
  onSubtitlesChange,
90
+ effects,
91
+ calm,
92
+ revealAll,
93
+ renderInsert,
53
94
  };
54
95
 
55
96
  let background = step.background ? resolveAsset(step.background) : undefined;
97
+ // A banner shows the image as a band of its own instead of behind the whole slide
98
+ let banner = step.layout === "banner" && background ? background : undefined;
99
+ if (banner) background = undefined;
100
+ let content = (
101
+ <div className="ob-course-slide__content">
102
+ <Blocks blocks={step.blocks} context={context} container={{ kind: "slide" }} />
103
+ </div>
104
+ );
56
105
 
57
106
  return (
58
107
  <div
@@ -60,13 +109,26 @@ export function SlideStepView({
60
109
  className={clsx(
61
110
  "ob-course-slide",
62
111
  `ob-course-slide--${step.layout ?? "default"}`,
112
+ step.width && `ob-course-slide--${step.width}`,
63
113
  background && "ob-course-slide--background",
114
+ background && step.panel === false && "ob-course-slide--bare",
64
115
  )}
65
- style={background ? { backgroundImage: `url("${background}")` } : undefined}
66
116
  >
67
- <div className="ob-course-slide__content">
68
- <Blocks blocks={step.blocks} context={context} />
69
- </div>
117
+ <RevealMotion root={rootRef} signature={signature} source={step.blocks} calm={calm} />
118
+ {/* A layer of its own, so a transition can move the background apart from the blocks */}
119
+ {background && (
120
+ <div className="ob-course-slide__background" style={{ backgroundImage: `url("${background}")` }} />
121
+ )}
122
+ {banner ? (
123
+ <div className="ob-course-banner">
124
+ <div className="ob-course-banner__stage">
125
+ <img className="ob-course-banner__image" src={banner} alt="" />
126
+ {content}
127
+ </div>
128
+ </div>
129
+ ) : (
130
+ content
131
+ )}
70
132
  {narration && (
71
133
  <NarrationPlayer
72
134
  className="ob-course-slide__narration"
@@ -1,3 +1,6 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RevealNavigation } from "../document/cues";
3
+ import type { InsertPlace } from "./Blocks";
1
4
  import type { PlayerMode, QuizAdapter, ResolveAsset } from "../types";
2
5
 
3
6
  /** What the player hands every step type. */
@@ -6,7 +9,10 @@ export interface StepBodyProps {
6
9
  mode: PlayerMode;
7
10
  resolveAsset: ResolveAsset;
8
11
  quiz?: QuizAdapter;
9
- /** How many `reveal: "step"` parts of a slide are shown. */
12
+ /**
13
+ * How many `reveal: "step"` parts of a slide count as pressed, in document order. A press of
14
+ * Next may move it by more than one, past parts that would show nothing new.
15
+ */
10
16
  stepsShown: number;
11
17
  subtitles: boolean;
12
18
  onSubtitlesChange(subtitles: boolean): void;
@@ -14,4 +20,13 @@ export interface StepBodyProps {
14
20
  onDoneChange(done: boolean): void;
15
21
  /** The step's narration or video has played to its end; called again after each replay. */
16
22
  onMediaEnded?(): void;
23
+ /** A slide reports where Next and Back go from here, and the presses that show something. */
24
+ onRevealNavigation?(navigation: RevealNavigation): void;
25
+ /**
26
+ * For an editor: every part of a slide is drawn, whatever its timing, so each can be reached,
27
+ * and the effects are left off. A part that would not be shown yet carries `is-unrevealed`.
28
+ */
29
+ revealAll?: boolean;
30
+ /** For an editor: a node drawn at each place on a slide where a block can be added. */
31
+ renderInsert?(place: InsertPlace): ReactNode;
17
32
  }