canvas-recorder-lib 0.8.3 → 0.8.5

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 (242) hide show
  1. package/README.md +10 -2
  2. package/dev/canvas-recorder.css +14 -0
  3. package/dev/canvas-recorder.ts +500 -84
  4. package/dev/color-picker.ts +13 -0
  5. package/dev/component-picker.ts +60 -11
  6. package/dev/font-widgets.ts +2 -2
  7. package/dev/format-editor.ts +3 -1
  8. package/dev/fourier-panel.ts +7 -3
  9. package/dev/handwriting-panel.ts +7 -7
  10. package/dev/multi-text-dialog.ts +28 -15
  11. package/dev/player-body.ts +95 -36
  12. package/dev/schedule-helpers.ts +10 -3
  13. package/dev/static-image-panel.ts +4 -4
  14. package/dev/subtitles.ts +170 -0
  15. package/dev/synced-file.ts +34 -0
  16. package/dev/timeline-display.ts +1 -1
  17. package/dev/transcript-align.ts +4 -1
  18. package/dev/transcript-editor.ts +1205 -0
  19. package/dev/transcript-export.ts +90 -0
  20. package/dev/transcript-view.ts +8 -5
  21. package/dev/transcripts.ts +140 -15
  22. package/dev/video-clip-panel.ts +4 -4
  23. package/dist/dev/canvas-recorder.css +14 -0
  24. package/dist/dev/canvas-recorder.js +408 -74
  25. package/dist/dev/canvas-recorder.js.map +1 -1
  26. package/dist/dev/color-picker.d.ts.map +1 -1
  27. package/dist/dev/color-picker.js +15 -0
  28. package/dist/dev/color-picker.js.map +1 -1
  29. package/dist/dev/component-picker.d.ts +2 -1
  30. package/dist/dev/component-picker.d.ts.map +1 -1
  31. package/dist/dev/component-picker.js +56 -11
  32. package/dist/dev/component-picker.js.map +1 -1
  33. package/dist/dev/font-widgets.d.ts +2 -2
  34. package/dist/dev/font-widgets.d.ts.map +1 -1
  35. package/dist/dev/font-widgets.js.map +1 -1
  36. package/dist/dev/format-editor.d.ts.map +1 -1
  37. package/dist/dev/format-editor.js +3 -1
  38. package/dist/dev/format-editor.js.map +1 -1
  39. package/dist/dev/fourier-panel.d.ts.map +1 -1
  40. package/dist/dev/fourier-panel.js +4 -3
  41. package/dist/dev/fourier-panel.js.map +1 -1
  42. package/dist/dev/handwriting-panel.d.ts +4 -4
  43. package/dist/dev/handwriting-panel.d.ts.map +1 -1
  44. package/dist/dev/handwriting-panel.js.map +1 -1
  45. package/dist/dev/multi-text-dialog.d.ts.map +1 -1
  46. package/dist/dev/multi-text-dialog.js +23 -12
  47. package/dist/dev/multi-text-dialog.js.map +1 -1
  48. package/dist/dev/player-body.d.ts +1 -1
  49. package/dist/dev/player-body.d.ts.map +1 -1
  50. package/dist/dev/player-body.js +95 -36
  51. package/dist/dev/player-body.js.map +1 -1
  52. package/dist/dev/schedule-helpers.d.ts.map +1 -1
  53. package/dist/dev/schedule-helpers.js +4 -2
  54. package/dist/dev/schedule-helpers.js.map +1 -1
  55. package/dist/dev/static-image-panel.d.ts +3 -3
  56. package/dist/dev/static-image-panel.d.ts.map +1 -1
  57. package/dist/dev/subtitles.d.ts +36 -0
  58. package/dist/dev/subtitles.d.ts.map +1 -0
  59. package/dist/dev/subtitles.js +135 -0
  60. package/dist/dev/subtitles.js.map +1 -0
  61. package/dist/dev/synced-file.d.ts +14 -0
  62. package/dist/dev/synced-file.d.ts.map +1 -1
  63. package/dist/dev/synced-file.js +22 -0
  64. package/dist/dev/synced-file.js.map +1 -1
  65. package/dist/dev/timeline-display.d.ts +5 -0
  66. package/dist/dev/timeline-display.d.ts.map +1 -1
  67. package/dist/dev/timeline-display.js +1 -1
  68. package/dist/dev/timeline-display.js.map +1 -1
  69. package/dist/dev/transcript-align.d.ts +3 -1
  70. package/dist/dev/transcript-align.d.ts.map +1 -1
  71. package/dist/dev/transcript-align.js +2 -0
  72. package/dist/dev/transcript-align.js.map +1 -1
  73. package/dist/dev/transcript-editor.d.ts +36 -0
  74. package/dist/dev/transcript-editor.d.ts.map +1 -0
  75. package/dist/dev/transcript-editor.js +964 -0
  76. package/dist/dev/transcript-editor.js.map +1 -0
  77. package/dist/dev/transcript-export.d.ts +21 -0
  78. package/dist/dev/transcript-export.d.ts.map +1 -1
  79. package/dist/dev/transcript-export.js +65 -0
  80. package/dist/dev/transcript-export.js.map +1 -1
  81. package/dist/dev/transcript-view.d.ts +2 -0
  82. package/dist/dev/transcript-view.d.ts.map +1 -1
  83. package/dist/dev/transcript-view.js +1 -1
  84. package/dist/dev/transcript-view.js.map +1 -1
  85. package/dist/dev/transcripts.d.ts +18 -1
  86. package/dist/dev/transcripts.d.ts.map +1 -1
  87. package/dist/dev/transcripts.js +102 -12
  88. package/dist/dev/transcripts.js.map +1 -1
  89. package/dist/dev/video-clip-panel.d.ts +3 -3
  90. package/dist/dev/video-clip-panel.d.ts.map +1 -1
  91. package/dist/lib/index.d.ts +1 -0
  92. package/dist/lib/index.d.ts.map +1 -1
  93. package/dist/lib/index.js +1 -0
  94. package/dist/lib/index.js.map +1 -1
  95. package/dist/src/glib/line-font.d.ts +6 -0
  96. package/dist/src/glib/line-font.d.ts.map +1 -1
  97. package/dist/src/glib/line-font.js +9 -0
  98. package/dist/src/glib/line-font.js.map +1 -1
  99. package/dist/src/glib/path-shape.d.ts +16 -0
  100. package/dist/src/glib/path-shape.d.ts.map +1 -1
  101. package/dist/src/glib/path-shape.js +23 -0
  102. package/dist/src/glib/path-shape.js.map +1 -1
  103. package/dist/src/glib/transforms.d.ts +9 -0
  104. package/dist/src/glib/transforms.d.ts.map +1 -1
  105. package/dist/src/glib/transforms.js +7 -4
  106. package/dist/src/glib/transforms.js.map +1 -1
  107. package/dist/src/interpolate.d.ts +17 -10
  108. package/dist/src/interpolate.d.ts.map +1 -1
  109. package/dist/src/interpolate.js +1 -17
  110. package/dist/src/interpolate.js.map +1 -1
  111. package/dist/src/morph-animation.js +1 -1
  112. package/dist/src/morph-animation.js.map +1 -1
  113. package/dist/src/peano-fourier/fourier-shared.d.ts.map +1 -1
  114. package/dist/src/peano-fourier/fourier-shared.js +4 -2
  115. package/dist/src/peano-fourier/fourier-shared.js.map +1 -1
  116. package/dist/src/schedule-helper.d.ts +50 -28
  117. package/dist/src/schedule-helper.d.ts.map +1 -1
  118. package/dist/src/schedule-helper.js +22 -0
  119. package/dist/src/schedule-helper.js.map +1 -1
  120. package/dist/src/showable.d.ts +59 -11
  121. package/dist/src/showable.d.ts.map +1 -1
  122. package/dist/src/showable.js +19 -0
  123. package/dist/src/showable.js.map +1 -1
  124. package/dist/src/slide-components/arrow.d.ts +4 -4
  125. package/dist/src/slide-components/arrow.d.ts.map +1 -1
  126. package/dist/src/slide-components/cross-fade-transition.d.ts +2 -1
  127. package/dist/src/slide-components/cross-fade-transition.d.ts.map +1 -1
  128. package/dist/src/slide-components/cross-fade-transition.js +2 -1
  129. package/dist/src/slide-components/cross-fade-transition.js.map +1 -1
  130. package/dist/src/slide-components/duration-agnostic.d.ts +3 -2
  131. package/dist/src/slide-components/duration-agnostic.d.ts.map +1 -1
  132. package/dist/src/slide-components/duration-agnostic.js +4 -2
  133. package/dist/src/slide-components/duration-agnostic.js.map +1 -1
  134. package/dist/src/slide-components/fixed-duration.d.ts +3 -1
  135. package/dist/src/slide-components/fixed-duration.d.ts.map +1 -1
  136. package/dist/src/slide-components/fixed-duration.js +4 -2
  137. package/dist/src/slide-components/fixed-duration.js.map +1 -1
  138. package/dist/src/slide-components/fourier.d.ts +19 -12
  139. package/dist/src/slide-components/fourier.d.ts.map +1 -1
  140. package/dist/src/slide-components/fourier.js +70 -22
  141. package/dist/src/slide-components/fourier.js.map +1 -1
  142. package/dist/src/slide-components/function-graph.d.ts +4 -3
  143. package/dist/src/slide-components/function-graph.d.ts.map +1 -1
  144. package/dist/src/slide-components/function-graph.js +6 -2
  145. package/dist/src/slide-components/function-graph.js.map +1 -1
  146. package/dist/src/slide-components/halftone-shadow.d.ts +8 -7
  147. package/dist/src/slide-components/halftone-shadow.d.ts.map +1 -1
  148. package/dist/src/slide-components/halftone-shadow.js +2 -1
  149. package/dist/src/slide-components/halftone-shadow.js.map +1 -1
  150. package/dist/src/slide-components/handwriting-effect.d.ts +8 -6
  151. package/dist/src/slide-components/handwriting-effect.d.ts.map +1 -1
  152. package/dist/src/slide-components/handwriting-effect.js +4 -2
  153. package/dist/src/slide-components/handwriting-effect.js.map +1 -1
  154. package/dist/src/slide-components/hold.d.ts +4 -2
  155. package/dist/src/slide-components/hold.d.ts.map +1 -1
  156. package/dist/src/slide-components/hold.js +4 -2
  157. package/dist/src/slide-components/hold.js.map +1 -1
  158. package/dist/src/slide-components/image.d.ts +7 -7
  159. package/dist/src/slide-components/image.d.ts.map +1 -1
  160. package/dist/src/slide-components/image.js +4 -2
  161. package/dist/src/slide-components/image.js.map +1 -1
  162. package/dist/src/slide-components/in-parallel.d.ts +12 -3
  163. package/dist/src/slide-components/in-parallel.d.ts.map +1 -1
  164. package/dist/src/slide-components/in-parallel.js +27 -2
  165. package/dist/src/slide-components/in-parallel.js.map +1 -1
  166. package/dist/src/slide-components/in-series.d.ts +2 -1
  167. package/dist/src/slide-components/in-series.d.ts.map +1 -1
  168. package/dist/src/slide-components/in-series.js +2 -1
  169. package/dist/src/slide-components/in-series.js.map +1 -1
  170. package/dist/src/slide-components/live-duration.d.ts +3 -1
  171. package/dist/src/slide-components/live-duration.d.ts.map +1 -1
  172. package/dist/src/slide-components/live-duration.js +4 -2
  173. package/dist/src/slide-components/live-duration.js.map +1 -1
  174. package/dist/src/slide-components/multi-text.d.ts +39 -26
  175. package/dist/src/slide-components/multi-text.d.ts.map +1 -1
  176. package/dist/src/slide-components/multi-text.js +44 -29
  177. package/dist/src/slide-components/multi-text.js.map +1 -1
  178. package/dist/src/slide-components/rectangle.d.ts +5 -4
  179. package/dist/src/slide-components/rectangle.d.ts.map +1 -1
  180. package/dist/src/slide-components/rectangle.js +2 -1
  181. package/dist/src/slide-components/rectangle.js.map +1 -1
  182. package/dist/src/slide-components/registry.d.ts +5 -0
  183. package/dist/src/slide-components/registry.d.ts.map +1 -1
  184. package/dist/src/slide-components/registry.js +28 -27
  185. package/dist/src/slide-components/registry.js.map +1 -1
  186. package/dist/src/slide-components/show-error.d.ts.map +1 -1
  187. package/dist/src/slide-components/show-error.js +3 -2
  188. package/dist/src/slide-components/show-error.js.map +1 -1
  189. package/dist/src/slide-components/simple-text.d.ts +11 -10
  190. package/dist/src/slide-components/simple-text.d.ts.map +1 -1
  191. package/dist/src/slide-components/simple-text.js +5 -3
  192. package/dist/src/slide-components/simple-text.js.map +1 -1
  193. package/dist/src/slide-components/slide-component.d.ts +14 -13
  194. package/dist/src/slide-components/slide-component.d.ts.map +1 -1
  195. package/dist/src/slide-components/slide-component.js +2 -1
  196. package/dist/src/slide-components/slide-component.js.map +1 -1
  197. package/dist/src/slide-components/slide-left.d.ts +2 -1
  198. package/dist/src/slide-components/slide-left.d.ts.map +1 -1
  199. package/dist/src/slide-components/slide-left.js +2 -1
  200. package/dist/src/slide-components/slide-left.js.map +1 -1
  201. package/dist/src/slide-components/text-effect.d.ts +9 -1
  202. package/dist/src/slide-components/text-effect.d.ts.map +1 -1
  203. package/dist/src/slide-components/text-effect.js.map +1 -1
  204. package/dist/src/slide-components/traditional-text.d.ts +8 -8
  205. package/dist/src/slide-components/traditional-text.d.ts.map +1 -1
  206. package/dist/src/slide-components/video-clip.d.ts +5 -4
  207. package/dist/src/slide-components/video-clip.d.ts.map +1 -1
  208. package/dist/src/slide-components/video-clip.js +5 -2
  209. package/dist/src/slide-components/video-clip.js.map +1 -1
  210. package/lib/index.ts +1 -0
  211. package/package.json +2 -2
  212. package/src/glib/line-font.ts +9 -0
  213. package/src/glib/path-shape.ts +35 -0
  214. package/src/glib/transforms.ts +7 -4
  215. package/src/interpolate.ts +18 -27
  216. package/src/morph-animation.ts +1 -1
  217. package/src/peano-fourier/fourier-shared.ts +4 -2
  218. package/src/schedule-helper.ts +50 -28
  219. package/src/showable.ts +81 -11
  220. package/src/slide-components/arrow.ts +4 -4
  221. package/src/slide-components/cross-fade-transition.ts +9 -2
  222. package/src/slide-components/duration-agnostic.ts +4 -3
  223. package/src/slide-components/fixed-duration.ts +4 -2
  224. package/src/slide-components/fourier.ts +89 -32
  225. package/src/slide-components/function-graph.ts +7 -3
  226. package/src/slide-components/halftone-shadow.ts +9 -7
  227. package/src/slide-components/handwriting-effect.ts +8 -6
  228. package/src/slide-components/hold.ts +18 -4
  229. package/src/slide-components/image.ts +9 -7
  230. package/src/slide-components/in-parallel.ts +31 -1
  231. package/src/slide-components/in-series.ts +3 -1
  232. package/src/slide-components/live-duration.ts +4 -2
  233. package/src/slide-components/multi-text.ts +71 -44
  234. package/src/slide-components/rectangle.ts +6 -4
  235. package/src/slide-components/registry.ts +33 -27
  236. package/src/slide-components/show-error.ts +4 -2
  237. package/src/slide-components/simple-text.ts +22 -12
  238. package/src/slide-components/slide-component.ts +15 -13
  239. package/src/slide-components/slide-left.ts +9 -2
  240. package/src/slide-components/text-effect.ts +9 -0
  241. package/src/slide-components/traditional-text.ts +8 -8
  242. package/src/slide-components/video-clip.ts +9 -5
@@ -400,6 +400,12 @@ async function openColorPickerDialog(
400
400
 
401
401
  function showTab(name: TabName) {
402
402
  tabContent.replaceChildren(TAB_BUILDERS[name]());
403
+ if (name === "String") {
404
+ // So you can type, or paste, a color right away.
405
+ const input = tabContent.querySelector("input");
406
+ input?.focus();
407
+ input?.select();
408
+ }
403
409
  tabBtns.forEach((btn, n) => {
404
410
  btn.style.fontWeight = n === name ? "bold" : "";
405
411
  btn.style.borderBottomColor = n === name ? "#333" : "transparent";
@@ -416,6 +422,13 @@ async function openColorPickerDialog(
416
422
  dialog.close();
417
423
  });
418
424
  cancelBtn.addEventListener("click", () => dialog.close());
425
+ // Enter is OK, as Escape is Cancel. A focused button keeps its own Enter.
426
+ dialog.addEventListener("keydown", (event) => {
427
+ if (event.key !== "Enter" || event.isComposing) return;
428
+ if (event.target instanceof HTMLButtonElement) return;
429
+ event.preventDefault();
430
+ okBtn.click();
431
+ });
419
432
 
420
433
  dialog.addEventListener("close", () => {
421
434
  addToRecentColors(colorRef.value);
@@ -24,7 +24,8 @@ function writeLastChoice(purpose: string, key: string): void {
24
24
  * Ask the user to choose a component from the registry.
25
25
  *
26
26
  * Shows a modal list of `choices` with the selected item's description beside it.
27
- * Arrow keys move the selection, Enter or a double-click accepts, Escape cancels.
27
+ * Typing searches the names and descriptions. Arrow keys move the selection, Enter or a
28
+ * double-click accepts, Escape cancels.
28
29
  *
29
30
  * @param options.title The action, e.g. "Insert New Child".
30
31
  * @param options.subtitle What it applies to, e.g. `Inside "Scene List"`.
@@ -53,6 +54,11 @@ export function pickComponent(options: {
53
54
  "margin-bottom:0.6em;font-size:0.85em;color:#555;font-style:italic";
54
55
  hint.textContent = subtitle;
55
56
 
57
+ const search = document.createElement("input");
58
+ search.type = "text";
59
+ search.placeholder = "Search names and descriptions…";
60
+ search.style.cssText = "width:100%;box-sizing:border-box;margin-bottom:0.6em";
61
+
56
62
  const body = document.createElement("div");
57
63
  body.style.cssText = "display:flex;gap:0.8em;margin-bottom:1em";
58
64
 
@@ -77,27 +83,36 @@ export function pickComponent(options: {
77
83
  okBtn.textContent = "OK";
78
84
  buttons.append(cancelBtn, okBtn);
79
85
 
80
- dialog.append(heading, hint, body, buttons);
86
+ dialog.append(heading, hint, search, body, buttons);
81
87
 
88
+ /** The name shown: the registry entry's label, or else its key. */
89
+ const labelOf = (key: string) => componentRegistry.get(key)?.label ?? key;
82
90
  const items = choices.map((key) => {
83
91
  const li = document.createElement("li");
84
- li.textContent = key;
92
+ li.textContent = labelOf(key);
85
93
  li.style.cssText =
86
94
  "padding:0.35em 0.6em;cursor:pointer;border-bottom:1px solid #eee";
87
95
  list.append(li);
88
96
  return li;
89
97
  });
90
98
 
99
+ /** What each choice is searched by: its name and its description. */
100
+ const searchText = choices.map((key) =>
101
+ `${labelOf(key)} ${key} ${componentRegistry.get(key)?.description ?? ""}`.toLowerCase(),
102
+ );
103
+ /** The indices that match the search, in order. */
104
+ let visible = choices.map((_, i) => i);
105
+
91
106
  let selectedIndex = -1;
92
107
  function select(index: number) {
93
- if (index < 0 || index >= choices.length) return;
108
+ if (!visible.includes(index)) return;
94
109
  selectedIndex = index;
95
110
  items.forEach((li, i) => li.classList.toggle("selected", i === index));
96
111
  items[index].scrollIntoView({ block: "nearest" });
97
112
  const key = choices[index];
98
113
  const name = document.createElement("b");
99
114
  name.style.cssText = "font-style:italic;font-family:Bevan,Georgia,serif";
100
- name.textContent = key;
115
+ name.textContent = labelOf(key);
101
116
  const text = document.createElement("p");
102
117
  text.style.margin = "0.4em 0 0 0";
103
118
  text.textContent =
@@ -106,10 +121,40 @@ export function pickComponent(options: {
106
121
  }
107
122
 
108
123
  function accept() {
109
- if (selectedIndex < 0) return;
124
+ if (!visible.includes(selectedIndex)) return;
110
125
  dialog.close(choices[selectedIndex]);
111
126
  }
112
127
 
128
+ /** Move the selection `delta` places among the visible choices. */
129
+ function move(delta: 1 | -1) {
130
+ const at = visible.indexOf(selectedIndex);
131
+ select(visible[at + delta] ?? visible[at] ?? visible[0]);
132
+ }
133
+
134
+ /** Every word typed must appear, as in the font picker. */
135
+ function applySearch() {
136
+ const terms = search.value
137
+ .trim()
138
+ .toLowerCase()
139
+ .split(/\s+/)
140
+ .filter(Boolean);
141
+ visible = [];
142
+ items.forEach((li, i) => {
143
+ const match = terms.every((term) => searchText[i].includes(term));
144
+ li.hidden = !match;
145
+ if (match) visible.push(i);
146
+ });
147
+ okBtn.disabled = visible.length === 0;
148
+ if (visible.length === 0) {
149
+ selectedIndex = -1;
150
+ items.forEach((li) => li.classList.remove("selected"));
151
+ description.textContent = "Nothing matches.";
152
+ } else if (!visible.includes(selectedIndex)) {
153
+ select(visible[0]);
154
+ }
155
+ }
156
+ search.addEventListener("input", applySearch);
157
+
113
158
  items.forEach((li, i) => {
114
159
  li.addEventListener("click", () => select(i));
115
160
  li.addEventListener("dblclick", () => {
@@ -117,18 +162,21 @@ export function pickComponent(options: {
117
162
  accept();
118
163
  });
119
164
  });
120
- list.addEventListener("keydown", (e) => {
165
+ // The same keys in the list and in the search box.
166
+ const onKeyDown = (e: KeyboardEvent) => {
121
167
  if (e.key === "ArrowDown") {
122
- select(selectedIndex + 1);
168
+ move(1);
123
169
  e.preventDefault();
124
170
  } else if (e.key === "ArrowUp") {
125
- select(selectedIndex - 1);
171
+ move(-1);
126
172
  e.preventDefault();
127
173
  } else if (e.key === "Enter") {
128
174
  accept();
129
175
  e.preventDefault();
130
176
  }
131
- });
177
+ };
178
+ list.addEventListener("keydown", onKeyDown);
179
+ search.addEventListener("keydown", onKeyDown);
132
180
  okBtn.addEventListener("click", accept);
133
181
  cancelBtn.addEventListener("click", () => dialog.close(""));
134
182
  okBtn.disabled = choices.length === 0;
@@ -146,6 +194,7 @@ export function pickComponent(options: {
146
194
  });
147
195
  document.body.append(dialog);
148
196
  dialog.showModal();
149
- list.focus();
197
+ // Ready to type. The arrows and Enter work from here too.
198
+ search.focus();
150
199
  });
151
200
  }
@@ -1,4 +1,4 @@
1
- import { Keyframe } from "../src/interpolate.ts";
1
+ import { TimedKeyframe } from "../src/interpolate.ts";
2
2
  import { TraditionalTextComponent } from "../src/slide-components/traditional-text.ts";
3
3
  import {
4
4
  _fetchLocalFonts,
@@ -153,7 +153,7 @@ export function buildTraditionalTextPanel(
153
153
  * so the user can revert by clicking it. There is no explicit cancel button.
154
154
  */
155
155
  export async function openFontPickerDialog(
156
- strKf: Keyframe<string>,
156
+ strKf: TimedKeyframe<string>,
157
157
  choices: readonly string[],
158
158
  cell: HTMLElement,
159
159
  ): Promise<void> {
@@ -88,7 +88,9 @@ export class FormatEditor {
88
88
  const element = this.element;
89
89
  element.className = "format-editor";
90
90
  element.contentEditable = "true";
91
- element.spellcheck = false;
91
+ // On, like the other text fields. A suggestion arrives as ordinary input
92
+ // (insertReplacementText), which the editor reads back like typing.
93
+ element.spellcheck = true;
92
94
  element.addEventListener("beforeinput", (event) =>
93
95
  this.#onBeforeInput(event),
94
96
  );
@@ -79,7 +79,7 @@ export type FourierPanel = {
79
79
 
80
80
  const HELP =
81
81
  "Term Groups says which terms each step adds. Terms are numbered by size, 0 the largest. " +
82
- "Separate numbers with spaces and groups with commas; 5-9 means 5 6 7 8 9. " +
82
+ "Separate numbers with spaces and groups with commas; 5-9 means 5 6 7 8 9, and 8- means 8 to the last term. " +
83
83
  "Step 1 adds the first group, step 2 the second, and so on. Terms are only ever added. " +
84
84
  "Step: 0 is a single dot, the number of groups is the finished curve, fractions animate " +
85
85
  "between steps, and a negative value hides it.";
@@ -115,11 +115,15 @@ export function buildFourierPanel(component: FourierComponent): FourierPanel {
115
115
  for (const keyframe of keyframes) {
116
116
  // Each Term Groups keyframe is checked against the source in effect then.
117
117
  const prefix = keyframes.length > 1 ? `At ${keyframe.time} ms: ` : "";
118
- const parsed = parseTermGroups(keyframe.value);
119
- groupCounts.add(parsed.groups.length);
120
118
  const source = component.termsFor(
121
119
  component.sourceSchedule.at(keyframe.time),
122
120
  );
121
+ // So 8- ends at this source's last term.
122
+ const parsed = parseTermGroups(
123
+ keyframe.value,
124
+ typeof source === "string" ? undefined : source.terms.length,
125
+ );
126
+ groupCounts.add(parsed.groups.length);
123
127
  const termCount = parsed.groups.reduce(
124
128
  (sum, group) => sum + group.length,
125
129
  0,
@@ -5,7 +5,7 @@ import {
5
5
  HandwritingUnit,
6
6
  handwritingUnits,
7
7
  } from "../src/slide-components/handwriting-effect.ts";
8
- import { Keyframe } from "../src/interpolate.ts";
8
+ import { TimedKeyframe } from "../src/interpolate.ts";
9
9
  import { MultiTextComponent } from "../src/slide-components/multi-text.ts";
10
10
  import { isTextEffect } from "../src/slide-components/text-effect.ts";
11
11
  import { Showable } from "../src/showable.ts";
@@ -237,7 +237,7 @@ let lastHoldMs = 1000;
237
237
  * {@link FillIn.lastEase} says what to give the existing last keyframe.
238
238
  */
239
239
  export function fillInKeyframes(
240
- schedule: readonly Keyframe<number>[],
240
+ schedule: readonly TimedKeyframe<number>[],
241
241
  count: number,
242
242
  transitionMs: number,
243
243
  holdMs: number,
@@ -245,7 +245,7 @@ export function fillInKeyframes(
245
245
  const sorted = [...schedule].sort((a, b) => a.time - b.time);
246
246
  const last = sorted.at(-1)!;
247
247
  const beforeLast = sorted.at(-2);
248
- let ease: Keyframe<number>["easeAfter"];
248
+ let ease: TimedKeyframe<number>["easeAfter"];
249
249
  for (let i = sorted.length - 2; i >= 0; i--) {
250
250
  if (sorted[i + 1].value > sorted[i].value) {
251
251
  ease = sorted[i].easeAfter;
@@ -257,11 +257,11 @@ export function fillInKeyframes(
257
257
  time: number,
258
258
  value: number,
259
259
  startsTransition: boolean,
260
- ): Keyframe<number> =>
260
+ ): TimedKeyframe<number> =>
261
261
  startsTransition && ease
262
262
  ? { time, value, easeAfter: ease }
263
263
  : { time, value };
264
- const added: Keyframe<number>[] = [];
264
+ const added: TimedKeyframe<number>[] = [];
265
265
  let time = last.time;
266
266
  let lastEase = ease;
267
267
  if (Number.isInteger(last.value) && beforeLast?.value !== last.value) {
@@ -281,9 +281,9 @@ export function fillInKeyframes(
281
281
 
282
282
  export type FillIn = {
283
283
  /** New keyframes, in order, all after the existing last one. */
284
- readonly added: readonly Keyframe<number>[];
284
+ readonly added: readonly TimedKeyframe<number>[];
285
285
  /** The `easeAfter` the existing last keyframe should have. */
286
- readonly lastEase: Keyframe<number>["easeAfter"];
286
+ readonly lastEase: TimedKeyframe<number>["easeAfter"];
287
287
  };
288
288
 
289
289
  /**
@@ -51,6 +51,32 @@ export async function openMultiTextDialog(
51
51
  // Revert, and the History dialog, can then bring back exactly what's here now, animation and all.
52
52
  await hooks.saveNow();
53
53
 
54
+ /**
55
+ * Add a Text Format called `name`, after the other formats. A copy of `source`, so nothing
56
+ * changes on screen until the new format is edited, or else a brand new one.
57
+ */
58
+ function addFormat(name: string, source?: TextFormatComponent): void {
59
+ const copy = source && hooks.copyComponent(source);
60
+ const format =
61
+ copy instanceof TextFormatComponent ? copy : new TextFormatComponent();
62
+ format.nameScalar.value = name;
63
+ // So the component list shows the name. Spans find a format by its Name, not this.
64
+ (format as Showable).userEditableDescription = name;
65
+ const children = text.replaceableComponents!.get();
66
+ const lastFormat = children.findLastIndex(
67
+ (child) => child instanceof TextFormatComponent,
68
+ );
69
+ children.splice(lastFormat + 1, 0, format);
70
+ text.replaceableComponents!.replace(children);
71
+ }
72
+
73
+ // With no formats, every menu would offer only "(empty)", which draws nothing and shows an
74
+ // error. Start with one, as New… would make it. It stays after Revert.
75
+ if (text.formatNamesInScope().length === 0) {
76
+ addFormat("default");
77
+ hooks.changed();
78
+ }
79
+
54
80
  const originalChildren = text.replaceableComponents!.get();
55
81
  const copyKeyframes = <T>(keyframes: readonly T[]) =>
56
82
  keyframes.map((keyframe) => ({ ...keyframe }));
@@ -237,21 +263,8 @@ export async function openMultiTextDialog(
237
263
  if (name === undefined) return undefined;
238
264
  // A name that's already there just picks that format.
239
265
  if (!text.formatNamesInScope().includes(name)) {
240
- // A copy, so nothing changes on screen until the new format is edited. A brand new
241
- // format would draw at its own defaults: a different size and color.
242
- const source = text.formatInScope(currentName);
243
- const copy = source && hooks.copyComponent(source);
244
- const format =
245
- copy instanceof TextFormatComponent ? copy : new TextFormatComponent();
246
- format.nameScalar.value = name;
247
- // So the component list shows the name. Spans find a format by its Name, not this.
248
- (format as Showable).userEditableDescription = name;
249
- const children = text.replaceableComponents!.get();
250
- const lastFormat = children.findLastIndex(
251
- (child) => child instanceof TextFormatComponent,
252
- );
253
- children.splice(lastFormat + 1, 0, format);
254
- text.replaceableComponents!.replace(children);
266
+ // A brand new format would draw at its own defaults: a different size and color.
267
+ addFormat(name, text.formatInScope(currentName));
255
268
  revertBtn.disabled = false;
256
269
  hooks.changed();
257
270
  }
@@ -39,40 +39,13 @@ export const playerBodyHtml = `
39
39
  >
40
40
  🔓 Allow local files
41
41
  </button>
42
- <button type="button" id="loadJsonTestBtn">📂 Import</button>
43
- <!-- Each status is outside its label: clicking inside a label
44
- toggles the checkbox, and a status can hold buttons. -->
45
- <span style="white-space: nowrap">
46
- <label
47
- title="Your work is always saved inside the browser (see Load). When this is checked, every one of those saves is also written to a JSON file on disk, for git and your editor. Checking it asks where."
48
- ><input type="checkbox" id="jsonSyncCheckbox" disabled /> Sync to
49
- file:</label
50
- >
51
- <span id="jsonSyncStatus" style="font-size: 0.85em">…</span>
52
- </span>
53
42
  <button
54
43
  type="button"
55
- id="saveCopyAsJsonBtn"
56
- title="Write the current state to a file of your choosing, once. Doesn't change which file is synced."
44
+ id="filesBtn"
45
+ title="Import, Save Copy As, and the files on disk that follow your work."
57
46
  >
58
- 📋 Save Copy As…
47
+ 💾 Files
59
48
  </button>
60
- <span style="white-space: nowrap">
61
- <label
62
- title="The TypeScript defaults, written to a JSON file whenever they change. Compare with the synced file to see what the Visual Editor changed."
63
- ><input type="checkbox" id="defaultsSyncCheckbox" disabled /> Sync
64
- defaults to file:</label
65
- >
66
- <span id="defaultsSyncStatus" style="font-size: 0.85em">…</span>
67
- </span>
68
- <span style="white-space: nowrap">
69
- <label
70
- title="A readable list of every difference from the TypeScript defaults, with code you can paste, rewritten whenever the synced file is."
71
- ><input type="checkbox" id="diffSyncCheckbox" disabled /> Sync diffs
72
- to file:</label
73
- >
74
- <span id="diffSyncStatus" style="font-size: 0.85em">…</span>
75
- </span>
76
49
  <label hidden
77
50
  ><input
78
51
  type="radio"
@@ -344,14 +317,83 @@ export const playerBodyHtml = `
344
317
  🗑 Delete
345
318
  </button>
346
319
  <div style="flex: 1"></div>
347
- <button id="historyAbandonBtn" type="button" hidden>
348
- Switch &amp; Abandon
320
+ <button
321
+ id="historyRevertBtn"
322
+ type="button"
323
+ disabled
324
+ title="Put back what was loaded when this opened. The dialog stays open."
325
+ >
326
+ Revert
349
327
  </button>
350
- <button id="historySaveBtn" type="button" hidden>
351
- Switch &amp; Save
328
+ <button
329
+ id="historyDoneBtn"
330
+ type="button"
331
+ title="Close, keeping the entry you chose. Escape does the same."
332
+ >
333
+ Done
352
334
  </button>
353
- <button id="historyOkBtn" type="button">Keep</button>
354
- <button id="historyCancelBtn" type="button">Revert</button>
335
+ </div>
336
+ </dialog>
337
+
338
+ <dialog id="filesDialog" style="min-width: 32em; max-width: 50em">
339
+ <h2 style="margin-top: 0">Files</h2>
340
+ <p style="margin-top: 0; font-size: 0.85em; color: #555">
341
+ Your work is always saved inside the browser (see Load). The files
342
+ checked here are copies on disk, for git, your editor and Claude,
343
+ rewritten whenever your work is saved. The 💾 Files button turns orange
344
+ while a change is waiting to be written, and red when something here
345
+ needs a click.
346
+ </p>
347
+ <div style="margin-bottom: 0.8em">
348
+ <button type="button" id="loadJsonTestBtn">📂 Import</button>
349
+ </div>
350
+ <div
351
+ style="display: flex; flex-direction: column; align-items: flex-start; gap: 0.5em"
352
+ >
353
+ <!-- Each status is outside its label: clicking inside a label
354
+ toggles the checkbox, and a status can hold buttons. -->
355
+ <span style="white-space: nowrap">
356
+ <label
357
+ title="Your work is always saved inside the browser (see Load). When this is checked, every one of those saves is also written to a JSON file on disk, for git and your editor. Checking it asks where."
358
+ ><input type="checkbox" id="jsonSyncCheckbox" disabled /> Sync to
359
+ file:</label
360
+ >
361
+ <span id="jsonSyncStatus" style="font-size: 0.85em">…</span>
362
+ </span>
363
+ <button
364
+ type="button"
365
+ id="saveCopyAsJsonBtn"
366
+ title="Write the current state to a file of your choosing, once. Doesn't change which file is synced."
367
+ >
368
+ 📋 Save Copy As…
369
+ </button>
370
+ <span style="white-space: nowrap">
371
+ <label
372
+ title="The TypeScript defaults, written to a JSON file whenever they change. Compare with the synced file to see what the Visual Editor changed."
373
+ ><input type="checkbox" id="defaultsSyncCheckbox" disabled /> Sync
374
+ defaults to file:</label
375
+ >
376
+ <span id="defaultsSyncStatus" style="font-size: 0.85em">…</span>
377
+ </span>
378
+ <span style="white-space: nowrap">
379
+ <label
380
+ title="A readable list of every difference from the TypeScript defaults, with code you can paste, rewritten whenever the synced file is."
381
+ ><input type="checkbox" id="diffSyncCheckbox" disabled /> Sync diffs
382
+ to file:</label
383
+ >
384
+ <span id="diffSyncStatus" style="font-size: 0.85em">…</span>
385
+ </span>
386
+ <span style="white-space: nowrap">
387
+ <label
388
+ title="Every transcript this video uses, word by word, rewritten whenever one changes. For a second pair of eyes, yours or Claude's, looking for words that are wrong. Fix them with ✎ on a sound clip."
389
+ ><input type="checkbox" id="transcriptsSyncCheckbox" disabled />
390
+ Sync transcripts to file:</label
391
+ >
392
+ <span id="transcriptsSyncStatus" style="font-size: 0.85em">…</span>
393
+ </span>
394
+ </div>
395
+ <div style="margin-top: 1em">
396
+ <button type="button" id="filesDialogCloseBtn">Close</button>
355
397
  </div>
356
398
  </dialog>
357
399
 
@@ -457,6 +499,23 @@ export const playerBodyHtml = `
457
499
  ></td>
458
500
  </tr>
459
501
  </table>
502
+ <div style="margin-bottom: 0.6em">
503
+ <label
504
+ title="Put the transcripts in the file as a subtitle track, one word at a time as each is spoken, with the line before above it. Fix the words first with ✎ on a sound clip."
505
+ ><input type="checkbox" id="saveSubtitles" checked /> Subtitles</label
506
+ >
507
+ <button
508
+ type="button"
509
+ id="saveSubtitlesFileBtn"
510
+ title="Save the same subtitles as a separate .vtt file, for the same start and end as the video. YouTube ignores the track inside the MP4. Upload this in YouTube Studio: Subtitles → Add language → Add → Upload file → With timing."
511
+ >
512
+ Save .vtt…
513
+ </button>
514
+ <span
515
+ id="saveSubtitlesNote"
516
+ style="font-size: 0.85em; color: #555; margin-left: 0.5em"
517
+ ></span>
518
+ </div>
460
519
  <div
461
520
  id="saveLocalFilesRow"
462
521
  hidden
@@ -1,7 +1,13 @@
1
1
  import { ease, easeIn, easeOut } from "../src/interpolate.ts";
2
2
  import { easeName } from "../src/snapshot.ts";
3
3
  import { LatticeValue } from "../src/lattice.ts";
4
- import { ScalarInfo, ScheduleInfo, Showable } from "../src/showable.ts";
4
+ import {
5
+ choiceLabel,
6
+ propertyLabel,
7
+ ScalarInfo,
8
+ ScheduleInfo,
9
+ Showable,
10
+ } from "../src/showable.ts";
5
11
  import { openColorPickerDialog } from "./color-picker.ts";
6
12
  import { setSwatchColor } from "./color-utils.ts";
7
13
 
@@ -252,7 +258,7 @@ export function buildScalarSection(
252
258
  const section = document.createElement("fieldset");
253
259
  section.style.cssText = "margin-bottom:0.4em";
254
260
  const legend = document.createElement("legend");
255
- legend.textContent = info.description;
261
+ legend.textContent = propertyLabel(info);
256
262
  section.append(legend);
257
263
 
258
264
  if (info.type === "string") {
@@ -292,7 +298,8 @@ export function buildScalarSection(
292
298
  const sel = document.createElement("select");
293
299
  for (const choice of info.choices) {
294
300
  const opt = document.createElement("option");
295
- opt.value = opt.textContent = choice;
301
+ opt.value = choice;
302
+ opt.textContent = choiceLabel(info, choice);
296
303
  if (choice === info.value) opt.selected = true;
297
304
  sel.append(opt);
298
305
  }
@@ -1,5 +1,5 @@
1
1
  import { ReadOnlyRect } from "phil-lib/misc";
2
- import { Keyframe } from "../src/interpolate.ts";
2
+ import { TimedKeyframe } from "../src/interpolate.ts";
3
3
  import { SingleImageComponent } from "../src/slide-components/image.ts";
4
4
  import {
5
5
  centeredOnCanvas,
@@ -24,9 +24,9 @@ export type StaticImagePanelHooks = {
24
24
  /** The URL was changed by a button here. Save, and rebuild the schedule editor so the URL field shows it. */
25
25
  readonly urlChanged: () => void;
26
26
  /** A Dest Rect keyframe's value was replaced. Sync its number fields and on-canvas handles, and save. */
27
- readonly rectKeyframeChanged: (keyframe: Keyframe<ReadOnlyRect>) => void;
27
+ readonly rectKeyframeChanged: (keyframe: TimedKeyframe<ReadOnlyRect>) => void;
28
28
  /** The Dest Rect keyframe in ✎ edit mode, if there is one. */
29
- readonly editingRectKeyframe: () => Keyframe<ReadOnlyRect> | null;
29
+ readonly editingRectKeyframe: () => TimedKeyframe<ReadOnlyRect> | null;
30
30
  };
31
31
 
32
32
  export type StaticImagePanel = {
@@ -216,7 +216,7 @@ export function buildStaticImagePanel(
216
216
  // MARK: Actions
217
217
 
218
218
  /** Which Dest Rect keyframe a button should change, or why it can't decide. */
219
- function targetKeyframe(): Keyframe<ReadOnlyRect> | string {
219
+ function targetKeyframe(): TimedKeyframe<ReadOnlyRect> | string {
220
220
  const schedule = component.destRectSchedule.schedule;
221
221
  if (schedule.length === 1) return schedule[0];
222
222
  const editing = hooks.editingRectKeyframe();