@hyperframes/studio 0.8.104 → 0.8.106

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 (225) hide show
  1. package/dist/assets/{hyperframes-player-DAoaajuM.js → hyperframes-player-dl6K6ABp.js} +1 -1
  2. package/dist/assets/index-CMiYVGv5.js +399 -0
  3. package/dist/assets/{index-WV9LroAD.js → index-DKT5NF1Y.js} +1 -1
  4. package/dist/assets/index-lrT-gfHa.css +1 -0
  5. package/dist/assets/{index-BDK4rTMb.js → index-ooaZZhKf.js} +1 -1
  6. package/dist/{chunk-62DDWOSH.js → chunk-EEXSYY5F.js} +19 -18
  7. package/dist/chunk-EEXSYY5F.js.map +1 -0
  8. package/dist/{chunk-HIGHVWYD.js → chunk-ICTZJPQQ.js} +3 -2
  9. package/dist/chunk-ICTZJPQQ.js.map +1 -0
  10. package/dist/{chunk-6GAO75IU.js → chunk-NCUBAVGK.js} +10 -8
  11. package/dist/chunk-NCUBAVGK.js.map +1 -0
  12. package/dist/index.css +6 -1
  13. package/dist/index.css.map +1 -1
  14. package/dist/index.d.ts +15 -4
  15. package/dist/index.html +11 -2
  16. package/dist/index.js +10391 -9836
  17. package/dist/index.js.map +1 -1
  18. package/dist/player.js +2 -2
  19. package/dist/styles/tailwind-preset.js.map +1 -1
  20. package/dist/styles.css +1 -1
  21. package/dist/ui.js +2 -2
  22. package/package.json +9 -9
  23. package/src/captions/components/CaptionAnimationPanel.tsx +2 -2
  24. package/src/captions/components/CaptionPropertyPanel.tsx +2 -2
  25. package/src/captions/components/CaptionTimeline.tsx +3 -3
  26. package/src/captions/keyboard.test.ts +6 -0
  27. package/src/captions/keyboard.ts +2 -1
  28. package/src/components/AskAgentModal.tsx +1 -1
  29. package/src/components/LintModal.tsx +35 -35
  30. package/src/components/StudioErrorBoundary.tsx +1 -1
  31. package/src/components/StudioHeader.dom.test.tsx +35 -13
  32. package/src/components/StudioHeader.tsx +6 -2
  33. package/src/components/StudioToast.tsx +7 -16
  34. package/src/components/ThemeToggle.tsx +99 -0
  35. package/src/components/TimelineToolPicker.tsx +1 -1
  36. package/src/components/TimelineToolbar.tsx +11 -11
  37. package/src/components/dock/Dock.tsx +1 -1
  38. package/src/components/dock/dock.css +9 -1
  39. package/src/components/editor/AnimationCard.tsx +5 -5
  40. package/src/components/editor/AnimationCardParts.tsx +1 -1
  41. package/src/components/editor/BlockParamsPanel.tsx +3 -3
  42. package/src/components/editor/BorderRadiusEditor.tsx +8 -15
  43. package/src/components/editor/CanvasContextMenu.tsx +1 -1
  44. package/src/components/editor/ComputedTweenNotice.tsx +1 -1
  45. package/src/components/editor/DomEditOverlay.tsx +37 -5
  46. package/src/components/editor/DomEditRotateHandle.tsx +1 -1
  47. package/src/components/editor/EaseCurveSection.tsx +14 -19
  48. package/src/components/editor/EaseModeControls.tsx +2 -2
  49. package/src/components/editor/EaseParamFields.tsx +8 -8
  50. package/src/components/editor/FileTree.tsx +1 -1
  51. package/src/components/editor/FileTreeIcons.tsx +47 -26
  52. package/src/components/editor/FileTreeNodes.tsx +11 -8
  53. package/src/components/editor/GestureRecordControl.tsx +3 -3
  54. package/src/components/editor/GsapAddAnimationControl.tsx +1 -1
  55. package/src/components/editor/GsapAnimationSection.tsx +2 -2
  56. package/src/components/editor/InlineTextToolbar.tsx +4 -4
  57. package/src/components/editor/InspectorHeaderActions.tsx +1 -1
  58. package/src/components/editor/KeyframeDiamond.tsx +6 -4
  59. package/src/components/editor/KeyframeNavigation.tsx +4 -4
  60. package/src/components/editor/LayersPanel.tsx +3 -3
  61. package/src/components/editor/PromotableControl.tsx +2 -2
  62. package/src/components/editor/PropertyPanelEmptyState.tsx +4 -4
  63. package/src/components/editor/PropertyPanelFlatFooter.tsx +2 -2
  64. package/src/components/editor/PropertyPanelFlatHeader.test.tsx +1 -1
  65. package/src/components/editor/PropertyPanelFlatHeader.tsx +2 -2
  66. package/src/components/editor/SnapToolbar.tsx +5 -5
  67. package/src/components/editor/SourceEditor.tsx +2 -6
  68. package/src/components/editor/TimelineFxPopover.tsx +4 -4
  69. package/src/components/editor/Transform3DCube.tsx +1 -1
  70. package/src/components/editor/anchoredResizeReleaseShift.test.ts +0 -84
  71. package/src/components/editor/domEditOverlayStartGesture.ts +127 -115
  72. package/src/components/editor/easeCurveSvg.tsx +1 -1
  73. package/src/components/editor/gestureHoldsPreviewReload.test.tsx +275 -0
  74. package/src/components/editor/manualEditsDom.ts +36 -3
  75. package/src/components/editor/manualEditsDomPatches.test.ts +2 -86
  76. package/src/components/editor/manualEditsDomPatches.ts +0 -30
  77. package/src/components/editor/manualEditsSnapshot.ts +1 -0
  78. package/src/components/editor/marqueeCommit.test.tsx +69 -1
  79. package/src/components/editor/marqueeCommit.ts +6 -1
  80. package/src/components/editor/overlayFrameLoop.test.ts +27 -0
  81. package/src/components/editor/overlayFrameLoop.ts +21 -0
  82. package/src/components/editor/persistSeam.integration.test.ts +0 -18
  83. package/src/components/editor/plainTranslate.ts +34 -3
  84. package/src/components/editor/propertyPanelColorCurveGraph.tsx +2 -2
  85. package/src/components/editor/propertyPanelColorGradingControls.tsx +1 -1
  86. package/src/components/editor/propertyPanelColorGradingSection.tsx +8 -8
  87. package/src/components/editor/propertyPanelColorGradingSlider.tsx +1 -1
  88. package/src/components/editor/propertyPanelColorSecondary.tsx +4 -4
  89. package/src/components/editor/propertyPanelFill.tsx +6 -6
  90. package/src/components/editor/propertyPanelFlatColorGradingAccessory.tsx +3 -3
  91. package/src/components/editor/propertyPanelFlatColorGradingSection.test.tsx +1 -1
  92. package/src/components/editor/propertyPanelFlatColorGradingSection.tsx +6 -9
  93. package/src/components/editor/propertyPanelFlatEffectsSection.tsx +4 -4
  94. package/src/components/editor/propertyPanelFlatMediaSection.tsx +2 -2
  95. package/src/components/editor/propertyPanelFlatMotionSection.tsx +2 -2
  96. package/src/components/editor/propertyPanelFlatOverlaysSection.tsx +2 -2
  97. package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +4 -3
  98. package/src/components/editor/propertyPanelFlatPrimitives.tsx +1 -1
  99. package/src/components/editor/propertyPanelFlatSliderReadout.tsx +1 -1
  100. package/src/components/editor/propertyPanelFont.test.tsx +80 -3
  101. package/src/components/editor/propertyPanelFont.tsx +71 -48
  102. package/src/components/editor/propertyPanelFxCarveModule.tsx +1 -1
  103. package/src/components/editor/propertyPanelFxControls.tsx +2 -2
  104. package/src/components/editor/propertyPanelFxEqModule.tsx +2 -2
  105. package/src/components/editor/propertyPanelFxNodeRow.tsx +1 -1
  106. package/src/components/editor/propertyPanelFxPresetRun.tsx +1 -1
  107. package/src/components/editor/propertyPanelHelpers.ts +1 -2
  108. package/src/components/editor/propertyPanelMediaSection.tsx +1 -1
  109. package/src/components/editor/propertyPanelPrimitives.tsx +1 -1
  110. package/src/components/editor/propertyPanelSections.tsx +2 -2
  111. package/src/components/editor/propertyPanelValueTier.test.ts +1 -1
  112. package/src/components/editor/propertyPanelValueTier.ts +1 -1
  113. package/src/components/editor/studioCodeTheme.test.ts +20 -0
  114. package/src/components/editor/studioCodeTheme.ts +99 -0
  115. package/src/components/editor/useDomEditNudge.test.tsx +31 -0
  116. package/src/components/editor/useDomEditNudge.ts +2 -2
  117. package/src/components/editor/useInlineTextEditing.tsx +1 -1
  118. package/src/components/editor/useMotionPathData.test.tsx +64 -0
  119. package/src/components/editor/useMotionPathData.ts +5 -1
  120. package/src/components/feedback/StudioFeedbackCard.tsx +11 -23
  121. package/src/components/nle/AssetPreviewOverlay.tsx +1 -1
  122. package/src/components/nle/AudioMeterStrip.tsx +2 -2
  123. package/src/components/nle/NLEPreview.test.ts +8 -4
  124. package/src/components/nle/PreviewOverlays.tsx +1 -1
  125. package/src/components/nle/PreviewPane.tsx +3 -3
  126. package/src/components/nle/PreviewPoster.tsx +29 -1
  127. package/src/components/nle/PreviewZoomOverlay.tsx +1 -1
  128. package/src/components/panels/SlideshowPanel.tsx +4 -4
  129. package/src/components/panels/SlideshowSubPanels.tsx +19 -21
  130. package/src/components/panels/VariablesBindElement.tsx +1 -1
  131. package/src/components/panels/VariablesDeclarationForm.tsx +1 -1
  132. package/src/components/panels/VariablesPanel.tsx +4 -6
  133. package/src/components/panels/VariablesRowAction.tsx +1 -1
  134. package/src/components/renders/FfmpegRequiredNotice.tsx +4 -4
  135. package/src/components/renders/RenderQueue.tsx +2 -2
  136. package/src/components/renders/RenderQueueItem.tsx +3 -3
  137. package/src/components/sidebar/AssetCard.tsx +3 -3
  138. package/src/components/sidebar/AssetContextMenu.tsx +7 -7
  139. package/src/components/sidebar/AssetsTab.tsx +6 -6
  140. package/src/components/sidebar/AudioRow.tsx +5 -3
  141. package/src/components/sidebar/BlocksTab.tsx +6 -6
  142. package/src/components/sidebar/CompositionsTab.drag.test.tsx +3 -69
  143. package/src/components/sidebar/CompositionsTab.rootBadge.test.tsx +4 -50
  144. package/src/components/sidebar/CompositionsTab.thumbnails.test.tsx +256 -0
  145. package/src/components/sidebar/CompositionsTab.tsx +65 -12
  146. package/src/components/sidebar/PromptPreviewModal.tsx +3 -3
  147. package/src/components/sidebar/SidebarLintButton.tsx +3 -3
  148. package/src/components/sidebar/compositionsTabTestUtils.tsx +39 -0
  149. package/src/components/timelineToolbarStyles.ts +3 -3
  150. package/src/components/ui/Button.tsx +4 -4
  151. package/src/components/ui/HyperframesLogo.tsx +19 -18
  152. package/src/components/ui/Input.tsx +1 -1
  153. package/src/components/ui/Menu.tsx +4 -2
  154. package/src/hooks/appHotkeysDispatch.ts +2 -1
  155. package/src/hooks/elementOffsetStager.ts +8 -7
  156. package/src/hooks/previewPromotionSelection.test.tsx +180 -0
  157. package/src/hooks/useAppHotkeys.test.ts +32 -0
  158. package/src/hooks/useAppHotkeys.ts +1 -2
  159. package/src/hooks/useClipboard.source.test.ts +141 -23
  160. package/src/hooks/useClipboard.ts +154 -123
  161. package/src/hooks/useDomEditCommits.ts +0 -3
  162. package/src/hooks/useDomEditSession.test.tsx +76 -72
  163. package/src/hooks/useDomEditSession.ts +7 -43
  164. package/src/hooks/useDomGeometryCommit.test.tsx +4 -1
  165. package/src/hooks/useDomGeometryCommit.ts +0 -1
  166. package/src/hooks/useDomGeometryCommits.test.tsx +177 -32
  167. package/src/hooks/useDomGeometryCommits.ts +4 -49
  168. package/src/hooks/useGsapTweenCache.ts +1 -2
  169. package/src/hooks/useInlineTextEdit.ts +16 -2
  170. package/src/hooks/useLivePreviewIframe.ts +18 -0
  171. package/src/hooks/usePreviewPersistence.history.test.tsx +47 -0
  172. package/src/hooks/usePreviewPersistence.ts +2 -5
  173. package/src/hooks/useRenderClipContent.ts +3 -3
  174. package/src/index.ts +2 -0
  175. package/src/livePreviewIframeExport.test.tsx +33 -0
  176. package/src/main.tsx +4 -1
  177. package/src/player/components/AudioWaveform.test.tsx +36 -15
  178. package/src/player/components/AudioWaveform.tsx +24 -7
  179. package/src/player/components/ClipContextMenu.tsx +1 -1
  180. package/src/player/components/CompositionThumbnail.tsx +23 -11
  181. package/src/player/components/EditModal.tsx +6 -6
  182. package/src/player/components/KeyframeDiamondContextMenu.tsx +2 -2
  183. package/src/player/components/PlayerControls.tsx +3 -3
  184. package/src/player/components/ShortcutsPanel.tsx +8 -20
  185. package/src/player/components/TimelineCanvas.tsx +1 -1
  186. package/src/player/components/TimelineClip.test.tsx +38 -0
  187. package/src/player/components/TimelineClip.tsx +16 -8
  188. package/src/player/components/TimelineClipFades.test.tsx +376 -74
  189. package/src/player/components/TimelineClipFades.tsx +368 -137
  190. package/src/player/components/TimelineEmptyState.tsx +2 -2
  191. package/src/player/components/TimelineLanes.tsx +0 -1
  192. package/src/player/components/TrackClipCount.tsx +1 -1
  193. package/src/player/components/VolumeControl.tsx +1 -1
  194. package/src/player/components/timelineClipChildren.tsx +1 -1
  195. package/src/player/components/timelineMotionStyles.test.ts +6 -22
  196. package/src/player/components/trackHeaderLabelRows.tsx +16 -16
  197. package/src/player/components/useTimelineKeyboardActor.ts +1 -1
  198. package/src/player/hooks/timelinePlayerTestHarness.ts +27 -0
  199. package/src/player/hooks/useShadowPreviewReload.ts +72 -5
  200. package/src/player/lib/automationStoreSync.test.ts +18 -1
  201. package/src/player/lib/automationStoreSync.ts +29 -17
  202. package/src/player/lib/thumbnailScheduler.ts +4 -5
  203. package/src/player/lib/timelineViewportBudgets.test.ts +1 -1
  204. package/src/player/lib/timelineViewportBudgets.ts +1 -1
  205. package/src/player/sceneSwap.ts +18 -0
  206. package/src/styles/components.css +26 -0
  207. package/src/styles/hex-baseline.json +7 -19
  208. package/src/styles/studio.css +4 -7
  209. package/src/styles/tailwind-preset.shared.js +2 -1
  210. package/src/styles/theme.css +214 -147
  211. package/src/styles/theme.test.ts +13 -9
  212. package/src/utils/blockCategories.ts +41 -9
  213. package/src/utils/clipboardPayload.ts +12 -1
  214. package/src/utils/studioPendingEdits.ts +21 -0
  215. package/src/utils/studioTheme.test.tsx +141 -0
  216. package/src/utils/studioTheme.ts +34 -0
  217. package/src/utils/studioUiPreferences.ts +3 -0
  218. package/src/utils/typingTarget.test.ts +8 -1
  219. package/src/utils/typingTarget.ts +5 -0
  220. package/dist/assets/index-CQN3M56N.css +0 -1
  221. package/dist/assets/index-De2aO4XM.js +0 -399
  222. package/dist/chunk-62DDWOSH.js.map +0 -1
  223. package/dist/chunk-6GAO75IU.js.map +0 -1
  224. package/dist/chunk-HIGHVWYD.js.map +0 -1
  225. package/src/hooks/gsapTargetCache.ts +0 -62
@@ -1,6 +1,6 @@
1
1
  export function HyperframesLogo() {
2
2
  // Full logo from logo-dark.svg (263×79): heygen label + gradient mark + hyperframes wordmark.
3
- // All fill="black" paths inverted to white for the dark header.
3
+ // The wordmark paths take the text colour, so the logo reads in both themes.
4
4
  const height = 28;
5
5
  const width = Math.round(height * (263 / 79));
6
6
  return (
@@ -9,6 +9,7 @@ export function HyperframesLogo() {
9
9
  height={height}
10
10
  viewBox="0 0 263 79"
11
11
  fill="none"
12
+ className="text-text-0"
12
13
  xmlns="http://www.w3.org/2000/svg"
13
14
  aria-label="Hyperframes"
14
15
  >
@@ -39,27 +40,27 @@ export function HyperframesLogo() {
39
40
  {/* heygen label */}
40
41
  <path
41
42
  d="M0 16.6738H4.96V23.3838H11.53V16.6738H16.49V35.4538H11.53V27.6738H4.96V35.4538H0V16.6738Z"
42
- fill="white"
43
+ fill="currentColor"
43
44
  />
44
45
  <path
45
46
  d="M17.8899 28.0137C17.8899 23.4237 21.2399 20.0237 25.7999 20.0237C30.0099 20.0237 32.9399 23.0837 32.9399 27.5637C32.9399 28.2037 32.8599 28.8237 32.8299 29.3337H22.6099C23.0399 31.1337 24.6199 32.1237 27.1399 32.1237C28.7199 32.1237 30.2199 31.7237 31.2999 31.0237V34.6737C30.1699 35.3937 28.2999 35.8537 26.3599 35.8537C21.2599 35.8537 17.8799 32.6037 17.8799 28.0237L17.8899 28.0137ZM28.5699 26.1937C28.4899 24.5337 27.3899 23.5637 25.7499 23.5637C24.1099 23.5637 22.9599 24.5337 22.6099 26.1937H28.5699Z"
46
- fill="white"
47
+ fill="currentColor"
47
48
  />
48
49
  <path
49
50
  d="M37.85 33.8638L32 20.4238H37.29L40.46 28.1538L43.6 20.4238H48.48L40.33 39.5738H35.26L37.86 33.8638H37.85Z"
50
- fill="white"
51
+ fill="currentColor"
51
52
  />
52
53
  <path
53
54
  d="M48.1797 26.1138C48.1797 20.4238 52.7097 16.2438 58.9397 16.2438C61.2997 16.2438 63.5297 16.8038 64.8197 17.7238V21.9338C63.5597 20.9138 61.6797 20.2938 59.7497 20.2938C55.7797 20.2938 53.2597 22.6238 53.2597 26.1438C53.2597 29.6638 55.5697 31.8838 58.8897 31.8838C59.6397 31.8838 60.4997 31.7538 61.1997 31.5038V27.8838H57.4697V24.2338H65.5197V33.7038C63.6697 35.0938 61.1997 35.8738 58.5997 35.8738C52.5397 35.8738 48.1897 31.7438 48.1897 26.1138H48.1797Z"
54
- fill="white"
55
+ fill="currentColor"
55
56
  />
56
57
  <path
57
58
  d="M66.6604 28.0137C66.6604 23.4237 70.0104 20.0237 74.5704 20.0237C78.7804 20.0237 81.7104 23.0837 81.7104 27.5637C81.7104 28.2037 81.6304 28.8237 81.6004 29.3337H71.3804C71.8104 31.1337 73.3904 32.1237 75.9104 32.1237C77.4904 32.1237 78.9904 31.7237 80.0704 31.0237V34.6737C78.9404 35.3937 77.0704 35.8537 75.1304 35.8537C70.0304 35.8537 66.6504 32.6037 66.6504 28.0237L66.6604 28.0137ZM77.3404 26.1937C77.2604 24.5337 76.1604 23.5637 74.5204 23.5637C72.8804 23.5637 71.7304 24.5337 71.3804 26.1937H77.3404Z"
58
- fill="white"
59
+ fill="currentColor"
59
60
  />
60
61
  <path
61
62
  d="M82.9688 20.4238H87.8488V22.4138C88.7588 20.9638 90.3488 20.1038 92.3288 20.1038C95.4988 20.1038 97.3988 22.3338 97.3988 25.8138V35.4438H92.5188V26.8638C92.5188 25.0438 91.8188 24.1838 90.4788 24.1838C88.9488 24.1838 87.8488 25.3638 87.8488 27.2638V35.4438H82.9688V20.4238Z"
62
- fill="white"
63
+ fill="currentColor"
63
64
  />
64
65
  {/* gradient icon mark */}
65
66
  <path
@@ -73,47 +74,47 @@ export function HyperframesLogo() {
73
74
  {/* hyperframes wordmark */}
74
75
  <path
75
76
  d="M0 71.9996V42.7256H7.7367V53.1806H17.9826V42.7256H25.7193V71.9996H17.9826V59.8718H7.7367V71.9996H0Z"
76
- fill="white"
77
+ fill="currentColor"
77
78
  />
78
79
  <path
79
80
  d="M31.9606 78.4405L36.0171 69.5329L26.9004 48.5811H35.1389L40.0737 60.6252L44.9666 48.5811H52.5779L39.8646 78.4405H31.9606Z"
80
- fill="white"
81
+ fill="currentColor"
81
82
  />
82
83
  <path
83
84
  d="M53.3711 78.4404V48.5809H60.9823V52.052C62.446 49.501 65.0807 48.0791 68.3008 48.0791C74.3647 48.0791 78.9649 53.3066 78.9649 60.2487C78.9649 67.2745 74.3229 72.4602 68.259 72.4602C65.0807 72.4602 62.446 71.1637 60.9823 68.78V78.4404H53.3711ZM66.1262 66.1872C69.2627 66.1872 71.3119 63.7616 71.3119 60.2905C71.3119 56.8195 69.2627 54.4357 66.1262 54.4357C62.7388 54.4357 60.9823 57.2795 60.9823 59.7051V60.9178C60.9823 63.3434 62.7388 66.1872 66.1262 66.1872Z"
84
- fill="white"
85
+ fill="currentColor"
85
86
  />
86
87
  <path
87
88
  d="M93.4397 72.6269C85.4939 72.6269 80.2246 67.5667 80.2246 60.4155C80.2246 53.2643 85.4521 47.9531 92.5615 47.9531C99.1273 47.9531 103.686 52.7206 103.686 59.7045C103.686 60.7082 103.56 61.6701 103.518 62.4647H87.5849C88.2541 65.2666 90.7214 66.8139 94.6525 66.8139C97.1199 66.8139 99.4618 66.1866 101.135 65.0993V70.7868C99.3782 71.916 96.4508 72.6269 93.4397 72.6269ZM87.5849 57.5717H96.869C96.7435 54.9789 95.0289 53.4734 92.4779 53.4734C89.9687 53.4734 88.1286 54.9789 87.5849 57.5717Z"
88
- fill="white"
89
+ fill="currentColor"
89
90
  />
90
91
  <path
91
92
  d="M105.645 72V48.5808H113.214V52.9719C114.218 50.0445 116.183 48.2881 118.692 48.2881C119.361 48.2881 119.989 48.4135 120.407 48.6645V55.8993C119.822 55.5648 119.111 55.4393 118.274 55.4393C115.138 55.4393 113.256 57.6558 113.256 61.2941V72H105.645Z"
92
- fill="white"
93
+ fill="currentColor"
93
94
  />
94
95
  <path
95
96
  d="M122.643 71.9996V42.7256H139.371V49.124H130.379V54.477H138.911V60.5827H130.379V71.9996H122.643Z"
96
- fill="white"
97
+ fill="currentColor"
97
98
  />
98
99
  <path
99
100
  d="M141.258 72V48.5808H148.827V52.9719C149.831 50.0445 151.796 48.2881 154.306 48.2881C154.975 48.2881 155.602 48.4135 156.02 48.6645V55.8993C155.435 55.5648 154.724 55.4393 153.887 55.4393C150.751 55.4393 148.869 57.6558 148.869 61.2941V72H141.258Z"
100
- fill="white"
101
+ fill="currentColor"
101
102
  />
102
103
  <path
103
104
  d="M167.26 72.4602C161.154 72.4602 156.596 67.2745 156.596 60.3324C156.596 53.3066 161.196 48.0791 167.302 48.0791C170.438 48.0791 173.031 49.4173 174.536 51.8429V48.5809H182.148V72.0001H174.536V68.4873C173.031 71.0801 170.438 72.4602 167.26 72.4602ZM169.393 66.1872C172.78 66.1872 174.536 63.3434 174.536 60.876V59.6632C174.536 57.2377 172.78 54.4357 169.393 54.4357C166.298 54.4357 164.207 56.7777 164.207 60.2905C164.207 63.7616 166.298 66.1872 169.393 66.1872Z"
104
- fill="white"
105
+ fill="currentColor"
105
106
  />
106
107
  <path
107
108
  d="M184.998 72.0001V48.5809H192.609V51.6756C193.989 49.4173 196.373 48.0791 199.426 48.0791C202.521 48.0791 204.779 49.5428 206.075 52.052C207.497 49.5846 210.132 48.0791 213.352 48.0791C218.245 48.0791 221.214 51.592 221.214 57.0286V72.0001H213.603V58.5341C213.603 55.774 212.557 54.4357 210.634 54.4357C208.459 54.4357 206.912 56.234 206.912 59.0778V72.0001H199.3V58.5341C199.3 55.774 198.255 54.4357 196.373 54.4357C194.157 54.4357 192.609 56.234 192.609 59.0778V72.0001H184.998Z"
108
- fill="white"
109
+ fill="currentColor"
109
110
  />
110
111
  <path
111
112
  d="M236.338 72.6269C228.392 72.6269 223.123 67.5667 223.123 60.4155C223.123 53.2643 228.351 47.9531 235.46 47.9531C242.026 47.9531 246.584 52.7206 246.584 59.7045C246.584 60.7082 246.459 61.6701 246.417 62.4647H230.483C231.152 65.2666 233.62 66.8139 237.551 66.8139C240.018 66.8139 242.36 66.1866 244.033 65.0993V70.7868C242.277 71.916 239.349 72.6269 236.338 72.6269ZM230.483 57.5717H239.767C239.642 54.9789 237.927 53.4734 235.376 53.4734C232.867 53.4734 231.027 54.9789 230.483 57.5717Z"
112
- fill="white"
113
+ fill="currentColor"
113
114
  />
114
115
  <path
115
116
  d="M252.115 72.502C250.192 72.502 248.268 72.0838 246.93 71.3728V65.6853C247.808 66.3126 248.937 66.689 250.066 66.689C251.739 66.689 252.784 65.8526 252.784 64.5562C252.784 63.8452 252.492 63.0925 251.655 62.0888L249.899 59.956C248.728 58.4923 248.226 56.9031 248.226 55.2721C248.226 51.0065 251.864 48.0791 256.883 48.0791C258.723 48.0791 260.438 48.4555 261.65 49.0828V54.7703C260.898 54.2266 259.768 53.8503 258.723 53.8503C257.092 53.8503 256.046 54.6867 256.046 55.8994C256.046 56.6522 256.423 57.405 257.259 58.4086L258.974 60.4996C260.187 62.047 260.73 63.5943 260.73 65.2671C260.73 69.5746 257.05 72.502 252.115 72.502Z"
116
- fill="white"
117
+ fill="currentColor"
117
118
  />
118
119
  </svg>
119
120
  );
@@ -23,7 +23,7 @@ export const fieldBase = cn(
23
23
  // `aria-invalid` is not one of Tailwind's built-in aria variants, so the
24
24
  // arbitrary form is the one that compiles. The token gate would have caught
25
25
  // the bare `aria-invalid:` spelling as a class that resolves to nothing.
26
- "aria-[invalid]:border-danger",
26
+ "aria-[invalid]:border-danger-ink",
27
27
  "has-[:disabled]:opacity-40 has-[:disabled]:cursor-not-allowed",
28
28
  );
29
29
 
@@ -67,7 +67,9 @@ const itemBase = cn(
67
67
  "data-[disabled]:pointer-events-none data-[disabled]:opacity-40",
68
68
  );
69
69
 
70
- const itemDanger = cn("text-danger data-[highlighted]:bg-danger/15 data-[highlighted]:text-danger");
70
+ const itemDanger = cn(
71
+ "text-danger-ink data-[highlighted]:bg-danger/15 data-[highlighted]:text-danger-ink",
72
+ );
71
73
 
72
74
  export type MenuItemTone = "default" | "danger";
73
75
 
@@ -229,7 +231,7 @@ export function MenuCheckboxItem({
229
231
  return (
230
232
  <BaseMenu.CheckboxItem className={cn(itemBase, className)} {...props}>
231
233
  <span className="truncate">{children}</span>
232
- <span className="flex size-3 shrink-0 items-center justify-center text-accent">
234
+ <span className="flex size-3 shrink-0 items-center justify-center text-accent-ink">
233
235
  <BaseMenu.CheckboxItemIndicator>✓</BaseMenu.CheckboxItemIndicator>
234
236
  </span>
235
237
  </BaseMenu.CheckboxItem>
@@ -3,7 +3,7 @@ import { usePlayerStore } from "../player";
3
3
  import type { TimelineElement } from "../player";
4
4
  import type { DomEditSelection } from "../components/editor/domEditing";
5
5
  import { useDockLayoutStore } from "../components/dock/dockLayoutStore";
6
- import { isTypingTarget } from "../utils/typingTarget";
6
+ import { isTypingTarget, ownsPlainKeys } from "../utils/typingTarget";
7
7
  import { isEditableTarget } from "../utils/timelineDiscovery";
8
8
  import { shouldIgnoreHistoryShortcut } from "../utils/studioHelpers";
9
9
  import { canSplitElement } from "../utils/timelineElementSplit";
@@ -153,6 +153,7 @@ export function dispatchModifierKey(
153
153
  * Delete arbitration between keyframes, an automation range and the clip can
154
154
  * be asserted without standing up the whole hook. */
155
155
  export function dispatchPlainKey(event: KeyboardEvent, key: string, cb: HotkeyCallbacks): void {
156
+ if (ownsPlainKeys(event.target)) return;
156
157
  if (key === STUDIO_PLAIN_KEYS.fullscreen && !event.shiftKey && !event.altKey) {
157
158
  event.preventDefault();
158
159
  if (document.fullscreenElement) void document.exitFullscreen();
@@ -5,7 +5,8 @@ import {
5
5
  } from "../components/editor/elementPositionOffset";
6
6
  import { LAYER_REVEAL_PRIOR_POSITION_ATTR } from "../player/lib/timelineElementHelpers";
7
7
  import type { PatchOperation } from "../utils/sourcePatcher";
8
- import { translatePatch } from "../components/editor/plainTranslate";
8
+ import { writePlainMove } from "../components/editor/plainTranslate";
9
+ import { captureStudioPathOffset, restoreStudioPathOffset } from "../components/editor/manualEdits";
9
10
  import { gsapHoldsTranslate } from "./gsapRuntimeKeyframes";
10
11
  import { markStudioSaveErrorAlreadyToasted } from "../utils/studioSaveDiagnostics";
11
12
 
@@ -59,17 +60,17 @@ function stagePlainTranslate(
59
60
  next: { x: number; y: number },
60
61
  coalesceKey?: string,
61
62
  ): { save: () => Promise<void>; rollback: () => void } {
62
- const style = selection.element.style;
63
- const before = style.getPropertyValue("translate");
64
- const patch = translatePatch(next);
65
- style.setProperty("translate", patch.value);
63
+ const el = selection.element;
64
+ const before = captureStudioPathOffset(el);
65
+ const patches = writePlainMove(el, next);
66
+ const written = el.style.getPropertyValue("translate");
66
67
  const rollback = () => {
67
- if (style.getPropertyValue("translate") === patch.value) style.setProperty("translate", before);
68
+ if (el.style.getPropertyValue("translate") === written) restoreStudioPathOffset(el, before);
68
69
  };
69
70
  const key = coalesceKey ?? `move:${++plainMoveCounter}`;
70
71
  const options = { label: "Move layer", coalesceKey: key, coalesceMs: Number.POSITIVE_INFINITY };
71
72
  const save = () =>
72
- commitPositionPatchToHtml(selection, [patch], options).catch((error) => {
73
+ commitPositionPatchToHtml(selection, patches, options).catch((error) => {
73
74
  rollback();
74
75
  throw error;
75
76
  });
@@ -0,0 +1,180 @@
1
+ // @vitest-environment happy-dom
2
+ import React, { act } from "react";
3
+ import { createRoot } from "react-dom/client";
4
+ import { afterEach, describe, expect, it, vi } from "vitest";
5
+ import type { DomEditSelection } from "../components/editor/domEditing";
6
+ import { resolveElementForOverlay } from "../components/editor/domEditOverlayGeometry";
7
+ import {
8
+ makePreview,
9
+ mountPlayerWithPreview,
10
+ paintShadow,
11
+ resetPlayerStore,
12
+ type TimelinePlayerApi,
13
+ } from "../player/hooks/timelinePlayerTestHarness";
14
+ import { announcePreviewPromoted } from "../player/sceneSwap";
15
+ import { stageElementOffset } from "./elementOffsetStager";
16
+ import { savePlainRotation } from "./plainRotation";
17
+ import { useDomEditPreviewSync } from "./useDomEditPreviewSync";
18
+ import { useLivePreviewIframe } from "./useLivePreviewIframe";
19
+
20
+ (globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
21
+
22
+ vi.mock("../utils/gsapSoftReload", async (importOriginal) => ({
23
+ ...(await importOriginal<typeof import("../utils/gsapSoftReload")>()),
24
+ ensureMotionPathPluginLoaded: vi.fn(),
25
+ }));
26
+
27
+ afterEach(() => {
28
+ document.body.innerHTML = "";
29
+ resetPlayerStore();
30
+ });
31
+
32
+ const previewWithTitle = (query = "") => makePreview('<h1 id="title">Title</h1>', query);
33
+
34
+ const titleOf = (iframe: HTMLIFrameElement | null) =>
35
+ iframe!.contentDocument!.getElementById("title") as HTMLElement;
36
+
37
+ const selectionOf = (element: HTMLElement) =>
38
+ ({ element, id: "title", selector: "#title", label: "title" }) as unknown as DomEditSelection;
39
+
40
+ /** A host shaped like Desktop's: it reads its iframe once and never re-renders for a reload. */
41
+ function mountHost(followPromotions: boolean) {
42
+ const selectionRef = { current: null as DomEditSelection | null };
43
+ function Session({ host }: { host: HTMLIFrameElement }) {
44
+ const live = useLivePreviewIframe(host);
45
+ useDomEditPreviewSync({
46
+ previewIframe: followPromotions ? live : host,
47
+ activeCompPath: null,
48
+ captionEditMode: false,
49
+ domEditSelectionRef: selectionRef,
50
+ domEditGroupSelectionsRef: { current: [] },
51
+ domEditSelection: selectionRef.current,
52
+ refreshDomEditGroupSelectionsFromPreview: async () => {},
53
+ applyDomSelection: (selection) => void (selectionRef.current = selection),
54
+ buildDomSelectionFromTarget: async (element) => selectionOf(element),
55
+ refreshPreviewDocumentVersion: () => {},
56
+ syncPreviewHotkeys: () => {},
57
+ applyStudioManualEditsToPreviewRef: { current: async () => {} },
58
+ });
59
+ return null;
60
+ }
61
+ const live = previewWithTitle();
62
+ const player = mountPlayerWithPreview(live);
63
+ selectionRef.current = selectionOf(titleOf(live));
64
+ const sessionRoot = createRoot(document.body.appendChild(document.createElement("div")));
65
+ act(() => sessionRoot.render(React.createElement(Session, { host: live })));
66
+ const unmount = () => {
67
+ act(() => sessionRoot.unmount());
68
+ act(() => player.root.unmount());
69
+ };
70
+ return { player: player.getApi, selectionRef, live, unmount };
71
+ }
72
+
73
+ /** The real shadow reload: load a shadow, report it painted, and let the player promote it. */
74
+ async function promoteShadow(player: () => TimelinePlayerApi): Promise<HTMLIFrameElement> {
75
+ act(() => player().refreshPlayer());
76
+ const shadow = previewWithTitle("?_t=1");
77
+ await paintShadow(player, shadow);
78
+ expect(player().iframeRef.current).toBe(shadow);
79
+ return shadow;
80
+ }
81
+
82
+ describe("a shadow reload promoted without a host re-render", () => {
83
+ // A host stage holds both players, each with the same #title, in either order.
84
+ it.each([
85
+ ["second", true],
86
+ ["first", false],
87
+ ])(
88
+ "with the live preview %s on the stage, the selection, overlay, rotate and move land on it",
89
+ async (_, liveSecond) => {
90
+ const host = mountHost(true);
91
+ const shadow = await promoteShadow(host.player);
92
+ // The stage only orders the two players; nothing here needs their pages to load.
93
+ for (const frame of [host.live, shadow]) frame.removeAttribute("src");
94
+ const stage = document.body.appendChild(document.createElement("div"));
95
+ stage.append(...(liveSecond ? [host.live, shadow] : [shadow, host.live]));
96
+
97
+ const selection = host.selectionRef.current!;
98
+ expect(selection.element).toBe(titleOf(shadow));
99
+ const overlayNode = resolveElementForOverlay(shadow.contentDocument!, selection, null, {
100
+ current: null,
101
+ });
102
+ expect(overlayNode).toBe(selection.element);
103
+
104
+ const commitPositionPatchToHtml = vi.fn(async () => {});
105
+ await savePlainRotation({ commitPositionPatchToHtml }, selection, { angle: 30 });
106
+ await stageElementOffset(
107
+ { commitPositionPatchToHtml, showToast: vi.fn() },
108
+ selection,
109
+ { x: 10, y: 5 },
110
+ true,
111
+ ).save();
112
+ expect(titleOf(shadow).style.getPropertyValue("rotate")).toBe("30deg");
113
+ expect(titleOf(shadow).style.getPropertyValue("translate")).toBe("10px 5px");
114
+ expect(titleOf(host.live).getAttribute("style")).toBeNull();
115
+ host.unmount();
116
+ },
117
+ );
118
+
119
+ it("left the selection on the retired node when the session kept the host's first iframe", async () => {
120
+ const host = mountHost(false);
121
+ await promoteShadow(host.player);
122
+ expect(host.selectionRef.current!.element).toBe(titleOf(host.live));
123
+ host.unmount();
124
+ });
125
+ });
126
+
127
+ describe("useLivePreviewIframe", () => {
128
+ function track(host: HTMLIFrameElement) {
129
+ const seen: Array<HTMLIFrameElement | null> = [];
130
+ function Probe({ iframe }: { iframe: HTMLIFrameElement }) {
131
+ seen.push(useLivePreviewIframe(iframe));
132
+ return null;
133
+ }
134
+ const root = createRoot(document.createElement("div"));
135
+ act(() => root.render(React.createElement(Probe, { iframe: host })));
136
+ const rerender = (iframe: HTMLIFrameElement) =>
137
+ act(() => root.render(React.createElement(Probe, { iframe })));
138
+ return { live: () => seen.at(-1), rerender, root };
139
+ }
140
+
141
+ it("follows each promotion of its own preview and ignores another preview's", () => {
142
+ const [a, b, c, other] = [0, 1, 2, 3].map(() => document.createElement("iframe"));
143
+ const probe = track(a!);
144
+ act(() => announcePreviewPromoted({ retired: other!, live: c! }));
145
+ expect(probe.live()).toBe(a);
146
+ act(() => announcePreviewPromoted({ retired: a!, live: b! }));
147
+ expect(probe.live()).toBe(b);
148
+ act(() => announcePreviewPromoted({ retired: b!, live: c! }));
149
+ expect(probe.live()).toBe(c);
150
+ act(() => probe.root.unmount());
151
+ });
152
+
153
+ it("lands on the same iframe wrapped twice, as when a host wraps what it hands the session", () => {
154
+ const [a, b, c] = [0, 1, 2].map(() => document.createElement("iframe"));
155
+ let seen: { outer: HTMLIFrameElement | null; inner: HTMLIFrameElement | null } | null = null;
156
+ function Probe({ host }: { host: HTMLIFrameElement }) {
157
+ const outer = useLivePreviewIframe(host);
158
+ seen = { outer, inner: useLivePreviewIframe(outer) };
159
+ return null;
160
+ }
161
+ const root = createRoot(document.createElement("div"));
162
+ act(() => root.render(React.createElement(Probe, { host: a! })));
163
+ act(() => announcePreviewPromoted({ retired: a!, live: b! }));
164
+ expect(seen).toEqual({ outer: b, inner: b });
165
+ act(() => announcePreviewPromoted({ retired: b!, live: c! }));
166
+ expect(seen).toEqual({ outer: c, inner: c });
167
+ act(() => root.unmount());
168
+ });
169
+
170
+ it("takes a new host iframe as given, and stops listening on unmount", () => {
171
+ const [a, b, d] = [0, 1, 2].map(() => document.createElement("iframe"));
172
+ const probe = track(a!);
173
+ act(() => announcePreviewPromoted({ retired: a!, live: b! }));
174
+ probe.rerender(d!);
175
+ expect(probe.live()).toBe(d);
176
+ const remove = vi.spyOn(document, "removeEventListener");
177
+ act(() => probe.root.unmount());
178
+ expect(remove).toHaveBeenCalledWith("hf-preview-promoted", expect.any(Function));
179
+ });
180
+ });
@@ -60,6 +60,38 @@ afterEach(() => {
60
60
  });
61
61
  });
62
62
 
63
+ describe("keys on a focused slider", () => {
64
+ const slider = () => {
65
+ const el = document.createElement("div");
66
+ el.setAttribute("role", "slider");
67
+ document.body.append(el);
68
+ return el;
69
+ };
70
+ const from = (target: HTMLElement, init: KeyboardEventInit) => {
71
+ const event = new KeyboardEvent("keydown", { ...init, bubbles: true, cancelable: true });
72
+ Object.defineProperty(event, "target", { value: target });
73
+ return event;
74
+ };
75
+
76
+ it("leaves Delete to the slider instead of deleting the selected clip", () => {
77
+ usePlayerStore.setState({
78
+ elements: [bgmElement],
79
+ selectedElementId: "bgm",
80
+ selectedElementIds: new Set(["bgm"]),
81
+ });
82
+ const cb = callbacks();
83
+ dispatchPlainKey(from(slider(), { key: "Delete" }), "delete", cb);
84
+ expect(cb.handleTimelineElementsDelete).not.toHaveBeenCalled();
85
+ expect(cb.handleTimelineElementDelete).not.toHaveBeenCalled();
86
+ });
87
+
88
+ it("still undoes with Cmd+Z while a slider has focus", () => {
89
+ const cb = callbacks();
90
+ dispatchModifierKey(from(slider(), { key: "z", metaKey: true }), "z", cb);
91
+ expect(cb.handleUndo).toHaveBeenCalledTimes(1);
92
+ });
93
+ });
94
+
63
95
  describe("dispatchPlainKey — select leftward / rightward", () => {
64
96
  const clips = [
65
97
  { ...bgmElement, id: "early", key: "early", start: 0, track: 0 },
@@ -2,7 +2,6 @@ import { useCallback, useEffect, useRef } from "react";
2
2
  import { usePlayerStore } from "../player";
3
3
  import type { TimelineElement } from "../player";
4
4
  import type { DomEditSelection } from "../components/editor/domEditing";
5
- import { isTypingTarget } from "../utils/typingTarget";
6
5
  import { useCaptionStore } from "../captions/store";
7
6
  import {
8
7
  applyCaptionModelToIframe,
@@ -220,7 +219,7 @@ export function useAppHotkeys({
220
219
  dispatchModifierKey(event, key, cb);
221
220
  return;
222
221
  }
223
- if (!isTypingTarget(event.target)) dispatchPlainKey(event, key, cb);
222
+ dispatchPlainKey(event, key, cb);
224
223
  }, []);
225
224
 
226
225
  // eslint-disable-next-line no-restricted-syntax
@@ -52,12 +52,16 @@ afterEach(() => {
52
52
 
53
53
  // The preview page: the saved markup with the preview's in-memory ids, a sub-composition
54
54
  // mounted inline, and the runtime's hide on both clips.
55
- function mountPreview(sub: string, bundle: (host: Element) => void): HTMLIFrameElement {
55
+ function mountPreview(
56
+ sub: string,
57
+ bundle: (host: Element) => void,
58
+ saved = SAVED,
59
+ ): HTMLIFrameElement {
56
60
  const iframe = document.createElement("iframe");
57
61
  document.body.appendChild(iframe);
58
62
  const doc = iframe.contentDocument as Document;
59
63
  doc.open();
60
- doc.write(ensureHfIds(SAVED));
64
+ doc.write(ensureHfIds(saved));
61
65
  doc.close();
62
66
  const parsed = new DOMParser().parseFromString(ensureHfIds(sub), "text/html");
63
67
  const subRoot = (parsed.querySelector("template") as HTMLTemplateElement).content
@@ -93,14 +97,16 @@ function mountClipboard(
93
97
  domSelection: DomEditSelection | null = null,
94
98
  sub = SUB,
95
99
  bundle: (host: Element) => void = () => {},
100
+ saved = SAVED,
101
+ view = { path: "index.html" },
96
102
  ) {
97
- const files: Record<string, string> = { "index.html": SAVED, "compositions/sub.html": sub };
103
+ const files: Record<string, string> = { "index.html": saved, "compositions/sub.html": sub };
98
104
  const fail = { on: false };
99
105
  const delayMs: Record<string, number> = {};
100
106
  const domEditSave = { pending: Promise.resolve() };
101
107
  const domSelectionRef = { current: domSelection };
102
108
  stubFiles(files, fail, delayMs);
103
- const iframe = mountPreview(sub, bundle);
109
+ const iframe = mountPreview(sub, bundle, saved);
104
110
  const writes: string[] = [];
105
111
  const deleted: string[] = [];
106
112
  const writeProjectFile = async (_path: string, content: string) => {
@@ -110,7 +116,7 @@ function mountClipboard(
110
116
  function Harness() {
111
117
  api = useClipboard({
112
118
  projectId: "p",
113
- activeCompPath: "index.html",
119
+ activeCompPath: view.path,
114
120
  domEditSelectionRef: domSelectionRef,
115
121
  showToast: () => {},
116
122
  writeProjectFile,
@@ -129,7 +135,9 @@ function mountClipboard(
129
135
  root = createRoot(document.createElement("div"));
130
136
  act(() => root?.render(React.createElement(Harness)));
131
137
  const clipboard = () => api as ReturnType<typeof useClipboard>;
138
+ const rerender = () => act(() => root?.render(React.createElement(Harness)));
132
139
  return {
140
+ rerender,
133
141
  clipboard,
134
142
  writes,
135
143
  deleted,
@@ -248,6 +256,50 @@ const SUB_SELECTION = {
248
256
  sourceFile: "compositions/sub.html",
249
257
  } as DomEditSelection;
250
258
 
259
+ const copySubNext = ({ clipboard, domSelectionRef }: ReturnType<typeof mountClipboard>) => {
260
+ clearSelection();
261
+ domSelectionRef.current = SUB_SELECTION;
262
+ clipboard().handleCopy();
263
+ };
264
+
265
+ const expectSubPastedAlone = (writes: string[]) => {
266
+ expect(writes[0]).toContain(">Sub</h2>");
267
+ expect(writes[0]?.match(/>Title<\/h1>/g)).toHaveLength(1);
268
+ };
269
+
270
+ describe("paste of an element styled by its id", () => {
271
+ it("gives the copy the look its original has", async () => {
272
+ clearSelection();
273
+ const saved = SAVED.replace(
274
+ "<body>",
275
+ "<body><style>#badge { color: rgb(200, 30, 40); letter-spacing: 3px; }</style>",
276
+ ).replace("</h1>", '</h1><p id="badge">New</p>');
277
+ const selection = {
278
+ hfId: stampedHfId(saved, "#badge"),
279
+ selector: "#badge",
280
+ selectorIndex: 0,
281
+ sourceFile: "index.html",
282
+ } as DomEditSelection;
283
+ const { clipboard, writes } = mountClipboard(selection, SUB, () => {}, saved);
284
+ clipboard().handleCopy();
285
+ await clipboard().handlePaste();
286
+ const page = document.createElement("iframe");
287
+ document.body.appendChild(page);
288
+ const doc = page.contentDocument as Document;
289
+ doc.open();
290
+ doc.write(writes[0] ?? "");
291
+ doc.close();
292
+ const look = (id: string) => {
293
+ const style = (page.contentWindow as Window).getComputedStyle(
294
+ doc.getElementById(id) as Element,
295
+ );
296
+ return { color: style.color, letterSpacing: style.letterSpacing };
297
+ };
298
+ expect(look("badge")).toEqual({ color: "rgb(200, 30, 40)", letterSpacing: "3px" });
299
+ expect(look("badge-2")).toEqual(look("badge"));
300
+ });
301
+ });
302
+
251
303
  describe("copy of a sub-composition clip", () => {
252
304
  it("rebases its relative asset paths to the project root, as the preview does", async () => {
253
305
  clearSelection();
@@ -301,30 +353,24 @@ describe("copy order", () => {
301
353
 
302
354
  it("pastes the second of two copies", async () => {
303
355
  selectTitle();
304
- const { clipboard, writes, domSelectionRef } = mountClipboard();
305
- clipboard().handleCopy();
356
+ const view = mountClipboard();
357
+ view.clipboard().handleCopy();
306
358
  await new Promise((resolve) => setTimeout(resolve, 10));
307
- clearSelection();
308
- domSelectionRef.current = SUB_SELECTION;
309
- clipboard().handleCopy();
310
- await clipboard().handlePaste();
311
- expect(writes[0]).toContain(">Sub</h2>");
312
- expect(writes[0]?.match(/>Title<\/h1>/g)).toHaveLength(1);
359
+ copySubNext(view);
360
+ await view.clipboard().handlePaste();
361
+ expectSubPastedAlone(view.writes);
313
362
  });
314
363
 
315
364
  it("pastes the later copy even when the earlier copy's read lands last", async () => {
316
365
  selectTitle();
317
- const { clipboard, writes, delayMs, domSelectionRef } = mountClipboard();
318
- delayMs["index.html"] = 20;
319
- clipboard().handleCopy();
320
- clearSelection();
321
- domSelectionRef.current = SUB_SELECTION;
322
- clipboard().handleCopy();
366
+ const view = mountClipboard();
367
+ view.delayMs["index.html"] = 20;
368
+ view.clipboard().handleCopy();
369
+ copySubNext(view);
323
370
  await new Promise((resolve) => setTimeout(resolve, 40));
324
- delayMs["index.html"] = 0;
325
- await clipboard().handlePaste();
326
- expect(writes[0]).toContain(">Sub</h2>");
327
- expect(writes[0]?.match(/>Title<\/h1>/g)).toHaveLength(1);
371
+ view.delayMs["index.html"] = 0;
372
+ await view.clipboard().handlePaste();
373
+ expectSubPastedAlone(view.writes);
328
374
  });
329
375
 
330
376
  it("duplicates a hidden clip with its saved markup", async () => {
@@ -336,6 +382,78 @@ describe("copy order", () => {
336
382
  });
337
383
  });
338
384
 
385
+ describe("a copy in place, as the canvas makes one", () => {
386
+ // The copy's start and track: the saved original has no data-hf-id, its copy is minted one.
387
+ const copyAt = (html: string | undefined) => {
388
+ const copy = html?.match(/<h1[^>]*data-hf-id[^>]*>Title<\/h1>/)?.[0] ?? "";
389
+ return [copy.match(/data-start="([^"]*)"/)?.[1], copy.match(/data-track-index="([^"]*)"/)?.[1]];
390
+ };
391
+
392
+ it("duplicates at the clip's own time, on the next free track", async () => {
393
+ selectTitle();
394
+ const { clipboard, writes } = mountClipboard();
395
+ await clipboard().handleDuplicate({ inPlace: true });
396
+ expect(copyAt(writes[0])).toEqual(["2", "1"]);
397
+ });
398
+
399
+ it("pastes at the copied clip's time, not the playhead's", async () => {
400
+ selectTitle();
401
+ const { clipboard, writes } = mountClipboard();
402
+ clipboard().handleCopy();
403
+ await clipboard().handlePaste({ inPlace: true });
404
+ expect(copyAt(writes[0])).toEqual(["2", "1"]);
405
+ });
406
+
407
+ // Host at 2 s: the clip's local 1-3 s shows as a 3-5 s master row, the clock the film's own timeline has.
408
+ const SUB_CLIP: TimelineElement = {
409
+ id: SUB_HF_ID,
410
+ hfId: SUB_HF_ID,
411
+ tag: "h2",
412
+ start: 3,
413
+ duration: 2,
414
+ track: 0,
415
+ authoredTrack: 0,
416
+ sourceFile: "compositions/sub.html",
417
+ parentCompositionStart: 2,
418
+ };
419
+ const pastedSubStarts = (html: string | undefined) =>
420
+ [...(html ?? "").matchAll(/<h2[^>]*data-hf-id[^>]*data-start="([^"]+)"/g)].map((m) => m[1]);
421
+ const mountSubClip = (currentTime = 0, view = { path: "index.html" }) => {
422
+ usePlayerStore.setState({
423
+ elements: [TITLE, SUB_CLIP],
424
+ selectedElementId: SUB_CLIP.id,
425
+ selectedElementIds: new Set([SUB_CLIP.id]),
426
+ currentTime,
427
+ });
428
+ return mountClipboard(null, SUB, (host) => host.setAttribute("data-start", "2"), SAVED, view);
429
+ };
430
+
431
+ it("pastes a sub-composition's clip into the film at the moment the film shows it", async () => {
432
+ const { clipboard, writes } = mountSubClip(7);
433
+ clipboard().handleCopy();
434
+ await clipboard().handlePaste({ inPlace: true });
435
+ expect(pastedSubStarts(writes[0])).toEqual(["3"]);
436
+ });
437
+
438
+ it("duplicates a sub-composition's clip at its own local time, on another track", async () => {
439
+ const { clipboard, writes } = mountSubClip();
440
+ await clipboard().handleDuplicate({ inPlace: true });
441
+ const copy = /<h2[^>]*data-hf-id[^>]*>/.exec(writes[0] ?? "")?.[0] ?? "";
442
+ expect(copy).toContain('data-start="1"');
443
+ expect(copy).toContain('data-track-index="1"');
444
+ });
445
+
446
+ it("pastes at the playhead once the edited composition is another, whose clock differs", async () => {
447
+ const view = { path: "index.html" };
448
+ const { clipboard, writes, rerender } = mountSubClip(0.5, view);
449
+ clipboard().handleCopy();
450
+ view.path = "compositions/sub.html";
451
+ rerender();
452
+ await clipboard().handlePaste({ inPlace: true });
453
+ expect(pastedSubStarts(writes[0])).toEqual(["0.5"]);
454
+ });
455
+ });
456
+
339
457
  describe("duplicate of a clip inside a sub-composition", () => {
340
458
  it("writes the copy at local time right after the original", async () => {
341
459
  // Host at 2 s, so the clip's local 1-3 s shows as a 3-5 s master row.