canvas-recorder-lib 0.8.0 → 0.8.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 (54) hide show
  1. package/BREAKING-CHANGES.md +8 -8
  2. package/dev/canvas-recorder.ts +52 -1
  3. package/dev/character-panel.ts +201 -0
  4. package/dev/format-editor.ts +36 -0
  5. package/dev/multi-text-dialog.ts +31 -2
  6. package/dev/multi-text-panel.ts +6 -0
  7. package/dist/dev/canvas-recorder.js +47 -1
  8. package/dist/dev/canvas-recorder.js.map +1 -1
  9. package/dist/dev/character-panel.d.ts +43 -0
  10. package/dist/dev/character-panel.d.ts.map +1 -0
  11. package/dist/dev/character-panel.js +133 -0
  12. package/dist/dev/character-panel.js.map +1 -0
  13. package/dist/dev/format-editor.d.ts +16 -0
  14. package/dist/dev/format-editor.d.ts.map +1 -1
  15. package/dist/dev/format-editor.js +31 -0
  16. package/dist/dev/format-editor.js.map +1 -1
  17. package/dist/dev/multi-text-dialog.d.ts +2 -0
  18. package/dist/dev/multi-text-dialog.d.ts.map +1 -1
  19. package/dist/dev/multi-text-dialog.js +26 -2
  20. package/dist/dev/multi-text-dialog.js.map +1 -1
  21. package/dist/dev/multi-text-panel.d.ts.map +1 -1
  22. package/dist/dev/multi-text-panel.js +6 -0
  23. package/dist/dev/multi-text-panel.js.map +1 -1
  24. package/dist/src/glib/font-choices.d.ts +61 -0
  25. package/dist/src/glib/font-choices.d.ts.map +1 -0
  26. package/dist/src/glib/font-choices.js +101 -0
  27. package/dist/src/glib/font-choices.js.map +1 -0
  28. package/dist/src/glib/letters-base.d.ts +97 -0
  29. package/dist/src/glib/letters-base.d.ts.map +1 -1
  30. package/dist/src/glib/letters-base.js +120 -18
  31. package/dist/src/glib/letters-base.js.map +1 -1
  32. package/dist/src/glib/line-font.d.ts +23 -3
  33. package/dist/src/glib/line-font.d.ts.map +1 -1
  34. package/dist/src/glib/line-font.js +40 -1
  35. package/dist/src/glib/line-font.js.map +1 -1
  36. package/dist/src/slide-components/multi-text.d.ts +24 -0
  37. package/dist/src/slide-components/multi-text.d.ts.map +1 -1
  38. package/dist/src/slide-components/multi-text.js +75 -5
  39. package/dist/src/slide-components/multi-text.js.map +1 -1
  40. package/dist/src/slide-components/registry.d.ts.map +1 -1
  41. package/dist/src/slide-components/registry.js +3 -2
  42. package/dist/src/slide-components/registry.js.map +1 -1
  43. package/dist/src/slide-components/simple-text.d.ts +20 -0
  44. package/dist/src/slide-components/simple-text.d.ts.map +1 -1
  45. package/dist/src/slide-components/simple-text.js +58 -5
  46. package/dist/src/slide-components/simple-text.js.map +1 -1
  47. package/internals.md +402 -406
  48. package/package.json +1 -1
  49. package/src/glib/font-choices.ts +132 -0
  50. package/src/glib/letters-base.ts +212 -18
  51. package/src/glib/line-font.ts +56 -3
  52. package/src/slide-components/multi-text.ts +100 -4
  53. package/src/slide-components/registry.ts +3 -2
  54. package/src/slide-components/simple-text.ts +76 -4
@@ -1,7 +1,7 @@
1
1
  # Breaking Changes
2
2
 
3
3
  Changes that can break a project using this library, newest first, and what to do about each.
4
- This is not a full list of changes: new features and fixes aren't here.
4
+ This is not a full list of changes: new features and fixes aren't here.
5
5
 
6
6
  While the version is 0.x, every breaking change comes with a new minor version (0.5 → 0.6), and nothing else does.
7
7
  A project that depends on `"^0.5.0"` gets 0.5.x updates but never 0.6.0, so it only meets these changes when someone installs the new version on purpose.
@@ -9,21 +9,21 @@ A project that depends on `"^0.5.0"` gets 0.5.x updates but never 0.6.0, so it o
9
9
  ## 0.8.0 (2026-11-12)
10
10
 
11
11
  - **`samplesToFourier()` leaves out the frequency 0 term,** the center, unless you pass `{ keepCenter: true }`.
12
- That term is the average of the samples, a fixed offset. Without it the curve is the same shape, centered on that average.
12
+ That term is the average of the samples, a fixed offset. Without it the curve is the same shape, centered on that average.
13
13
  `FourierComponent` gets the new default, and so does `getAnimationRules()` given a path string.
14
14
  A Fourier component still puts the finished curve in the same place in Dest Rect.
15
15
  - **Every term after the center moves down one number,** so Term Groups can add different terms than before.
16
- For art drawn away from the origin, the center is often term 0, and everything moves. (The showcase's Walking Man: term 0, 45% of the total amplitude.)
17
- For a shape centered on the origin, the center is tiny and far down the list (the showcase's Star: term 42), so only a group that ends past it changes, by one small term.
18
- - To get the same picture, subtract 1 from every term number after the center's. The showcase's Fourier Component slide did: `0 1, 2, 3-5, 6-8, 9-11` became `0, 1, 2-4, 5-7, 8-10`.
19
- The finished curve is the same either way. What goes away is the step that slid the curve to the center.
20
- - Code that needs the terms to add up to exactly the samples, in place, should pass `{ keepCenter: true }`. The showcase's Fourier Morph does.
16
+ For art drawn away from the origin, the center is often term 0, and everything moves. (The showcase's Walking Man: term 0, 45% of the total amplitude.)
17
+ For a shape centered on the origin, the center is tiny and far down the list (the showcase's Star: term 42), so only a group that ends past it changes, by one small term.
18
+ - To get the same picture, subtract 1 from every term number after the center's. The showcase's Fourier Component slide did: `0 1, 2, 3-5, 6-8, 9-11` became `0, 1, 2-4, 5-7, 8-10`.
19
+ The finished curve is the same either way. What goes away is the step that slid the curve to the center.
20
+ - Code that needs the terms to add up to exactly the samples, in place, should pass `{ keepCenter: true }`. The showcase's Fourier Morph does.
21
21
 
22
22
  ## 0.7.0 (2026-11-07)
23
23
 
24
24
  - **`VisualEditorAPI.getDecodedBuffer()` returns a mono buffer,** at 48 kHz, for every file.
25
25
  It used to return the file's own channels, so a stereo file's channel 0 was its left channel; now it's the average of both.
26
- A waveform drawn from channel 0 still works, and shows the whole sound. Code that reads channel 1 should read channel 0.
26
+ A waveform drawn from channel 0 still works, and shows the whole sound. Code that reads channel 1 should read channel 0.
27
27
 
28
28
  ## 0.6.0 (2026-11-05)
29
29
 
@@ -136,11 +136,16 @@ import {
136
136
  } from "../src/slide-components/serialize.ts";
137
137
  import { SlideComponent } from "../src/slide-components/slide-component.ts";
138
138
  import { VideoClipComponent } from "../src/slide-components/video-clip.ts";
139
- import { MultiTextComponent } from "../src/slide-components/multi-text.ts";
139
+ import {
140
+ MultiTextComponent,
141
+ TextFormatComponent,
142
+ } from "../src/slide-components/multi-text.ts";
143
+ import { TextComponent } from "../src/slide-components/simple-text.ts";
140
144
  import { FourierComponent } from "../src/slide-components/fourier.ts";
141
145
  import { buildFourierPanel } from "./fourier-panel.ts";
142
146
  import { HandwritingEffectComponent } from "../src/slide-components/handwriting-effect.ts";
143
147
  import { buildHandwritingPanel } from "./handwriting-panel.ts";
148
+ import { buildCharacterPanel, CharacterPanel } from "./character-panel.ts";
144
149
  import { SingleImageComponent } from "../src/slide-components/image.ts";
145
150
  import { buildStaticImagePanel } from "./static-image-panel.ts";
146
151
  import { InSeriesComponent } from "../src/slide-components/in-series.ts";
@@ -6741,6 +6746,15 @@ function updateScheduleEditor(selectable: Showable) {
6741
6746
  // Every keystroke in Divisions or Progress updates the status.
6742
6747
  scheduleEditorRefreshers.push(handwritingPanel.refresh);
6743
6748
  }
6749
+ const characterPanel = buildCharacterPanelFor(selectable);
6750
+ if (characterPanel) {
6751
+ // The warnings here, the list of characters after the properties.
6752
+ scheduleEditorFieldset.append(characterPanel.status);
6753
+ // Every keystroke in Text, and a new Font.
6754
+ scheduleEditorRefreshers.push(characterPanel.refresh);
6755
+ // The Font at the playhead is the one the list shows.
6756
+ goToButtonUpdaters.push(characterPanel.timeChanged);
6757
+ }
6744
6758
  // A component's own panels, and the project's: after the library's, so on a Fourier
6745
6759
  // the library's status comes first.
6746
6760
  scheduleEditorFieldset.append(...startEditorPanels(selectable));
@@ -6795,9 +6809,45 @@ function updateScheduleEditor(selectable: Showable) {
6795
6809
  }
6796
6810
  scheduleEditorFieldset.append(section);
6797
6811
  }
6812
+ if (characterPanel) {
6813
+ scheduleEditorFieldset.append(characterPanel.palette);
6814
+ }
6798
6815
  scheduleEditorFieldset.append(buildSoundClipSection(selectable));
6799
6816
  }
6800
6817
 
6818
+ /**
6819
+ * The Characters panel for a Text or a Text Format, or undefined for anything else.
6820
+ *
6821
+ * A Text Format doesn't know its text, so its warnings come from its Multi Text: the
6822
+ * ones for this format. The Multi Text shows them all, in its Text Frame panel.
6823
+ */
6824
+ function buildCharacterPanelFor(
6825
+ selectable: Showable,
6826
+ ): CharacterPanel | undefined {
6827
+ if (selectable instanceof TextComponent) {
6828
+ return buildCharacterPanel({
6829
+ fontName: () => selectable.fontSchedule.at(componentTimeMs(selectable)),
6830
+ missing: () => selectable.missingCharacters(),
6831
+ });
6832
+ }
6833
+ if (selectable instanceof TextFormatComponent) {
6834
+ return buildCharacterPanel({
6835
+ fontName: () => selectable.fontSchedule.at(componentTimeMs(selectable)),
6836
+ missing() {
6837
+ const parent = (selectable as Showable).parent;
6838
+ if (!(parent instanceof MultiTextComponent)) return [];
6839
+ const name = selectable.nameScalar.value;
6840
+ return parent.formatInScope(name) === selectable
6841
+ ? parent
6842
+ .missingCharacters()
6843
+ .filter(({ formatName }) => formatName === name)
6844
+ : [];
6845
+ },
6846
+ });
6847
+ }
6848
+ return undefined;
6849
+ }
6850
+
6801
6851
  // MARK: Split
6802
6852
 
6803
6853
  /**
@@ -7030,6 +7080,7 @@ function buildMultiTextFrame(text: MultiTextComponent): HTMLElement {
7030
7080
  if (root) updateComponentEditor(root);
7031
7081
  updateScheduleEditor(text);
7032
7082
  },
7083
+ timeMs: () => componentTimeMs(text),
7033
7084
  });
7034
7085
  },
7035
7086
  });
@@ -0,0 +1,201 @@
1
+ import {
2
+ allFontCharacters,
3
+ fontCharacters,
4
+ FontName,
5
+ MissingCharacters,
6
+ } from "../src/glib/font-choices.ts";
7
+
8
+ /**
9
+ * The Characters panel, for a Text Format or a Text: every character any
10
+ * font has, with the ones this font doesn't have grayed out. Click one to
11
+ * copy it. And a warning when the text uses a character its font doesn't
12
+ * have.
13
+ *
14
+ * The ✎ Edit Text dialog has one too, where a click types the character.
15
+ * @module
16
+ */
17
+
18
+ export type CharacterPanelHooks = {
19
+ /** The font to gray the characters for: the one at the playhead, or at the cursor. */
20
+ fontName(): FontName;
21
+ /**
22
+ * What to warn about. See `MultiTextComponent.missingCharacters()`.
23
+ * Without this, {@link CharacterPanel.status} stays empty.
24
+ */
25
+ missing?(): readonly MissingCharacters[];
26
+ /**
27
+ * Clicking a character calls this, instead of copying it. For a panel next to a
28
+ * text field: type the character at the cursor. Clicking doesn't take the focus.
29
+ */
30
+ onPick?(char: string): void;
31
+ };
32
+
33
+ export type CharacterPanel = {
34
+ /** The warnings. Empty, and taking no room, when there's nothing to warn about. */
35
+ readonly status: HTMLElement;
36
+ /** The characters. Goes after the properties: it's tall, and it's for reference. */
37
+ readonly palette: HTMLElement;
38
+ /** Something may have changed: the font, the text. Redraw. */
39
+ refresh(): void;
40
+ /** The playhead or the cursor moved. Cheap unless the font changed. */
41
+ timeChanged(): void;
42
+ };
43
+
44
+ /** Unavailable characters, and the note that counts them. */
45
+ const GRAY = "#b0b0b0";
46
+
47
+ /** Whether the list is open. It stays the way you left it, from one component to the next. */
48
+ let paletteOpen = true;
49
+
50
+ /** A character you can't see, like the no-break space, by its code point. */
51
+ function isInvisible(char: string): boolean {
52
+ return /^[\p{C}\p{Z}]$/u.test(char);
53
+ }
54
+
55
+ function codePoint(char: string): string {
56
+ return (
57
+ "U+" + char.codePointAt(0)!.toString(16).toUpperCase().padStart(4, "0")
58
+ );
59
+ }
60
+
61
+ /** “π≈”, with anything invisible spelled out: “π” and U+0009. */
62
+ export function showCharacters(characters: readonly string[]): string {
63
+ const visible = characters.filter((char) => !isInvisible(char));
64
+ const invisible = characters.filter(isInvisible).map(codePoint);
65
+ return [...(visible.length ? [`“${visible.join("")}”`] : []), ...invisible]
66
+ .join(" and ")
67
+ .replace(/ and (?=.* and )/g, ", ");
68
+ }
69
+
70
+ /**
71
+ * One warning line's text.
72
+ * @param withFormat Name the Text Format. For a Multi Text, which has several.
73
+ */
74
+ export function describeMissing(
75
+ { fontName, formatName, characters }: MissingCharacters,
76
+ withFormat: boolean,
77
+ ): string {
78
+ const where =
79
+ withFormat && formatName !== undefined
80
+ ? ` (Text Format “${formatName}”)`
81
+ : "";
82
+ return `⚠ Not available in ${fontName}${where}, so not drawn: ${showCharacters(characters)}`;
83
+ }
84
+
85
+ export function buildCharacterPanel(
86
+ hooks: CharacterPanelHooks,
87
+ ): CharacterPanel {
88
+ const status = document.createElement("div");
89
+ status.style.cssText = "font-size:0.9em;color:#a06000;line-height:1.4";
90
+
91
+ const palette = document.createElement("fieldset");
92
+ palette.style.cssText = "border-color:#6a7fae;margin-top:0.4em";
93
+ const legend = document.createElement("legend");
94
+ legend.textContent = "Characters";
95
+ const details = document.createElement("details");
96
+ details.open = paletteOpen;
97
+ details.addEventListener("toggle", () => {
98
+ paletteOpen = details.open;
99
+ });
100
+ const summary = document.createElement("summary");
101
+ summary.style.cssText = "cursor:pointer;font-size:0.9em";
102
+ const grid = document.createElement("div");
103
+ grid.style.cssText =
104
+ "display:flex;flex-wrap:wrap;gap:2px;margin-top:0.3em;user-select:text";
105
+ const note = document.createElement("div");
106
+ note.style.cssText = `font-size:0.85em;color:${GRAY};margin-top:0.3em`;
107
+ const copied = document.createElement("div");
108
+ copied.style.cssText = "font-size:0.85em;color:#555;min-height:1.2em";
109
+ details.append(summary, grid, note);
110
+ palette.append(legend, details);
111
+ if (!hooks.onPick) {
112
+ palette.append(copied);
113
+ }
114
+
115
+ // MARK: The grid
116
+
117
+ const cells = allFontCharacters().map((char) => {
118
+ const cell = document.createElement("button");
119
+ cell.type = "button";
120
+ const invisible = isInvisible(char);
121
+ // U+FE0E asks for the plain text version of a character like ⚫, not a color emoji
122
+ // that ignores the gray. Only for showing it: the copy is just `char`.
123
+ cell.textContent = invisible
124
+ ? codePoint(char).slice(2)
125
+ : /\p{Extended_Pictographic}/u.test(char)
126
+ ? char + "\uFE0E"
127
+ : char;
128
+ cell.style.cssText =
129
+ "min-width:1.9em;height:1.9em;padding:0 0.15em;font-size:1.05em;" +
130
+ "border:1px solid #ddd;border-radius:3px;background:white;cursor:pointer" +
131
+ (invisible ? ";font-size:0.6em;min-width:3.2em;height:3.2em" : "");
132
+ if (hooks.onPick) {
133
+ // Leave the focus, and so the cursor, in the text.
134
+ cell.addEventListener("mousedown", (event) => event.preventDefault());
135
+ }
136
+ cell.addEventListener("click", () => {
137
+ if (hooks.onPick) {
138
+ hooks.onPick(char);
139
+ return;
140
+ }
141
+ navigator.clipboard.writeText(char).then(
142
+ () => {
143
+ copied.textContent = `Copied ${showCharacters([char])}.`;
144
+ },
145
+ (reason: unknown) => {
146
+ copied.textContent = `Couldn't copy: ${String(reason)}`;
147
+ },
148
+ );
149
+ });
150
+ return { char, cell };
151
+ });
152
+ grid.append(...cells.map(({ cell }) => cell));
153
+
154
+ // MARK: Behavior
155
+
156
+ let shownFont: FontName | undefined;
157
+
158
+ function drawPalette(fontName: FontName): void {
159
+ shownFont = fontName;
160
+ const available = fontCharacters(fontName);
161
+ let elsewhere = 0;
162
+ for (const { char, cell } of cells) {
163
+ const has = available.has(char);
164
+ if (!has) elsewhere++;
165
+ cell.style.color = has ? "black" : GRAY;
166
+ cell.title =
167
+ `${codePoint(char)}` +
168
+ (char == " " ? ", no-break space: joins two words" : "") +
169
+ (has ? "" : `. Not in ${fontName}.`) +
170
+ (hooks.onPick ? "\nClick to type it." : "\nClick to copy.");
171
+ }
172
+ summary.textContent = hooks.onPick
173
+ ? `${available.size} in ${fontName}, the font at the cursor. Click one to type it.`
174
+ : `${available.size} in ${fontName}. Click one to copy it.`;
175
+ note.textContent =
176
+ elsewhere == 0
177
+ ? ""
178
+ : `${elsewhere} ${elsewhere == 1 ? "character" : "characters"} only available in other fonts`;
179
+ }
180
+
181
+ function refresh(): void {
182
+ drawPalette(hooks.fontName());
183
+ status.replaceChildren(
184
+ ...(hooks.missing?.() ?? []).map((missing) => {
185
+ const line = document.createElement("div");
186
+ line.textContent = describeMissing(missing, false);
187
+ return line;
188
+ }),
189
+ );
190
+ status.style.marginBottom = status.childElementCount ? "0.4em" : "";
191
+ }
192
+
193
+ function timeChanged(): void {
194
+ if (hooks.fontName() !== shownFont) {
195
+ drawPalette(hooks.fontName());
196
+ }
197
+ }
198
+
199
+ refresh();
200
+ return { status, palette, refresh, timeChanged };
201
+ }
@@ -45,6 +45,12 @@ export class FormatEditor {
45
45
  */
46
46
  onChange: ((value: string) => void) | undefined;
47
47
 
48
+ /**
49
+ * Called when the cursor moves inside the editor, including after a change.
50
+ * See {@link formatAtCursor}.
51
+ */
52
+ onCursorMove: (() => void) | undefined;
53
+
48
54
  #knownNames: readonly string[] = [];
49
55
  /**
50
56
  * If the user deletes the leading format, we put this one back.
@@ -117,6 +123,7 @@ export class FormatEditor {
117
123
  const selection = this.#getSelection();
118
124
  if (selection) {
119
125
  this.#lastSelection = selection;
126
+ this.onCursorMove?.();
120
127
  }
121
128
  },
122
129
  { signal: this.#abort.signal },
@@ -192,6 +199,35 @@ export class FormatEditor {
192
199
  }
193
200
  }
194
201
 
202
+ /**
203
+ * Type `text` at the cursor, replacing the selection, as if the user had typed it.
204
+ * For a button outside the editor: the cursor is where it was last, even if the
205
+ * button took the focus. Format markers in `text` are dropped.
206
+ */
207
+ insertText(text: string) {
208
+ const selection = this.#getSelection() ??
209
+ this.#lastSelection ?? {
210
+ start: this.#units().length,
211
+ end: this.#units().length,
212
+ };
213
+ this.element.focus();
214
+ this.#replace(selection, pushContent([], text), "typing");
215
+ }
216
+
217
+ /**
218
+ * The name of the format in effect at the cursor, or where the cursor was last.
219
+ * Text typed there would be in this format.
220
+ */
221
+ formatAtCursor(): string {
222
+ const units = this.#units();
223
+ const offset = (this.#getSelection() ?? this.#lastSelection)?.start;
224
+ // Before the leading format, typing goes after it. See #replace().
225
+ return (
226
+ formatInEffect(units, Math.max(1, offset ?? units.length)) ??
227
+ this.#leadingName
228
+ );
229
+ }
230
+
195
231
  undo() {
196
232
  if (this.#historyIndex > 0) {
197
233
  this.#historyIndex--;
@@ -4,6 +4,7 @@ import {
4
4
  TextFormatComponent,
5
5
  TextSpanComponent,
6
6
  } from "../src/slide-components/multi-text.ts";
7
+ import { buildCharacterPanel, describeMissing } from "./character-panel.ts";
7
8
  import { FormatEditor } from "./format-editor.ts";
8
9
 
9
10
  /** What the dialog needs from the Visual Editor. It never reaches into canvas-recorder.ts directly. */
@@ -19,6 +20,8 @@ export type MultiTextDialogHooks = {
19
20
  readonly copyComponent: (component: Showable) => Showable | undefined;
20
21
  /** The dialog closed. Rebuild the editors it covered. */
21
22
  readonly closed: () => void;
23
+ /** The Multi Text's own time at the playhead. A format's Font can change over time. */
24
+ readonly timeMs: () => number;
22
25
  };
23
26
 
24
27
  /** Someone animated this span, by hand or in TypeScript. Editing its text flattens it. */
@@ -107,7 +110,10 @@ export async function openMultiTextDialog(
107
110
  toolbar.append(insertFormatBtn);
108
111
  const notes = document.createElement("div");
109
112
  notes.style.cssText = "font-size:0.85em;color:#a06000;margin-top:0.3em";
110
- top.append(heading, hint, toolbar, notes);
113
+ /** Characters a font doesn't have. It changes as you type, so it's apart from the notes. */
114
+ const missingLines = document.createElement("div");
115
+ missingLines.style.cssText = notes.style.cssText;
116
+ top.append(heading, hint, toolbar, notes, missingLines);
111
117
 
112
118
  const middle = document.createElement("div");
113
119
  middle.style.cssText = "flex:1;overflow-y:auto;padding:0.8em";
@@ -167,6 +173,16 @@ export async function openMultiTextDialog(
167
173
  );
168
174
  }
169
175
  }
176
+ /** Every character the text uses that its font doesn't have, over the whole timeline. */
177
+ const showMissing = () => {
178
+ missingLines.replaceChildren(
179
+ ...text.missingCharacters().map((missing) => {
180
+ const div = document.createElement("div");
181
+ div.textContent = describeMissing(missing, true);
182
+ return div;
183
+ }),
184
+ );
185
+ };
170
186
  const noFormatsNote = note(
171
187
  "This text has no Text Formats yet. Pick New… in a menu to make one.",
172
188
  );
@@ -174,6 +190,7 @@ export async function openMultiTextDialog(
174
190
  const formatsChanged = () => {
175
191
  editor.knownNames = text.formatNamesInScope();
176
192
  noFormatsNote.hidden = editor.knownNames.length > 0;
193
+ showMissing();
177
194
  };
178
195
 
179
196
  // MARK: Behavior
@@ -185,7 +202,16 @@ export async function openMultiTextDialog(
185
202
  onNewFormat: newFormat,
186
203
  });
187
204
  editor.element.style.minHeight = "12rem";
188
- middle.append(editor.element, errorLine);
205
+ // Grayed for the font of the format at the cursor. A click types the character there.
206
+ const characters = buildCharacterPanel({
207
+ fontName: () =>
208
+ text
209
+ .formatInScope(editor.formatAtCursor())
210
+ ?.fontSchedule.at(hooks.timeMs()) ?? "Line Font",
211
+ onPick: (char) => editor.insertText(char),
212
+ });
213
+ editor.onCursorMove = () => characters.timeChanged();
214
+ middle.append(editor.element, errorLine, characters.palette);
189
215
  formatsChanged();
190
216
 
191
217
  editor.onChange = (value) => {
@@ -199,6 +225,9 @@ export async function openMultiTextDialog(
199
225
  }
200
226
  errorLine.textContent = "";
201
227
  revertBtn.disabled = false;
228
+ showMissing();
229
+ // Picking another format in a menu doesn't move the cursor.
230
+ characters.timeChanged();
202
231
  hooks.changed();
203
232
  };
204
233
 
@@ -12,6 +12,7 @@ import {
12
12
  tidyRect,
13
13
  } from "./rect-snap.ts";
14
14
  import { buildNumericInput } from "./schedule-helpers.ts";
15
+ import { describeMissing } from "./character-panel.ts";
15
16
 
16
17
  /** Whether the frame is drawn on the canvas (👁), and whether it has handles to drag (✎). */
17
18
  export type CanvasState = {
@@ -232,6 +233,11 @@ export function buildTextFramePanel(
232
233
  `Height Mode is unbounded, so the frame's ${sideways ? "width" : "height"} doesn't limit the text.`,
233
234
  );
234
235
  }
236
+ // Over the whole timeline, not just the playhead. Select a Text Format to see every
237
+ // character its font has.
238
+ for (const missing of text.missingCharacters()) {
239
+ note(describeMissing(missing, true));
240
+ }
235
241
  }
236
242
 
237
243
  refresh();
@@ -34,11 +34,13 @@ import { pickComponent } from "./component-picker.js";
34
34
  import { buildComponents, } from "../src/slide-components/serialize.js";
35
35
  import { SlideComponent } from "../src/slide-components/slide-component.js";
36
36
  import { VideoClipComponent } from "../src/slide-components/video-clip.js";
37
- import { MultiTextComponent } from "../src/slide-components/multi-text.js";
37
+ import { MultiTextComponent, TextFormatComponent, } from "../src/slide-components/multi-text.js";
38
+ import { TextComponent } from "../src/slide-components/simple-text.js";
38
39
  import { FourierComponent } from "../src/slide-components/fourier.js";
39
40
  import { buildFourierPanel } from "./fourier-panel.js";
40
41
  import { HandwritingEffectComponent } from "../src/slide-components/handwriting-effect.js";
41
42
  import { buildHandwritingPanel } from "./handwriting-panel.js";
43
+ import { buildCharacterPanel } from "./character-panel.js";
42
44
  import { SingleImageComponent } from "../src/slide-components/image.js";
43
45
  import { buildStaticImagePanel } from "./static-image-panel.js";
44
46
  import { InSeriesComponent } from "../src/slide-components/in-series.js";
@@ -5736,6 +5738,15 @@ function updateScheduleEditor(selectable) {
5736
5738
  // Every keystroke in Divisions or Progress updates the status.
5737
5739
  scheduleEditorRefreshers.push(handwritingPanel.refresh);
5738
5740
  }
5741
+ const characterPanel = buildCharacterPanelFor(selectable);
5742
+ if (characterPanel) {
5743
+ // The warnings here, the list of characters after the properties.
5744
+ scheduleEditorFieldset.append(characterPanel.status);
5745
+ // Every keystroke in Text, and a new Font.
5746
+ scheduleEditorRefreshers.push(characterPanel.refresh);
5747
+ // The Font at the playhead is the one the list shows.
5748
+ goToButtonUpdaters.push(characterPanel.timeChanged);
5749
+ }
5739
5750
  // A component's own panels, and the project's: after the library's, so on a Fourier
5740
5751
  // the library's status comes first.
5741
5752
  scheduleEditorFieldset.append(...startEditorPanels(selectable));
@@ -5782,8 +5793,42 @@ function updateScheduleEditor(selectable) {
5782
5793
  }
5783
5794
  scheduleEditorFieldset.append(section);
5784
5795
  }
5796
+ if (characterPanel) {
5797
+ scheduleEditorFieldset.append(characterPanel.palette);
5798
+ }
5785
5799
  scheduleEditorFieldset.append(buildSoundClipSection(selectable));
5786
5800
  }
5801
+ /**
5802
+ * The Characters panel for a Text or a Text Format, or undefined for anything else.
5803
+ *
5804
+ * A Text Format doesn't know its text, so its warnings come from its Multi Text: the
5805
+ * ones for this format. The Multi Text shows them all, in its Text Frame panel.
5806
+ */
5807
+ function buildCharacterPanelFor(selectable) {
5808
+ if (selectable instanceof TextComponent) {
5809
+ return buildCharacterPanel({
5810
+ fontName: () => selectable.fontSchedule.at(componentTimeMs(selectable)),
5811
+ missing: () => selectable.missingCharacters(),
5812
+ });
5813
+ }
5814
+ if (selectable instanceof TextFormatComponent) {
5815
+ return buildCharacterPanel({
5816
+ fontName: () => selectable.fontSchedule.at(componentTimeMs(selectable)),
5817
+ missing() {
5818
+ const parent = selectable.parent;
5819
+ if (!(parent instanceof MultiTextComponent))
5820
+ return [];
5821
+ const name = selectable.nameScalar.value;
5822
+ return parent.formatInScope(name) === selectable
5823
+ ? parent
5824
+ .missingCharacters()
5825
+ .filter(({ formatName }) => formatName === name)
5826
+ : [];
5827
+ },
5828
+ });
5829
+ }
5830
+ return undefined;
5831
+ }
5787
5832
  // MARK: Split
5788
5833
  /**
5789
5834
  * The series a Video Clip would be split within, or a sentence saying why it
@@ -5999,6 +6044,7 @@ function buildMultiTextFrame(text) {
5999
6044
  updateComponentEditor(root);
6000
6045
  updateScheduleEditor(text);
6001
6046
  },
6047
+ timeMs: () => componentTimeMs(text),
6002
6048
  });
6003
6049
  },
6004
6050
  });