@hyperframes/studio 0.8.104 → 0.8.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{hyperframes-player-DAoaajuM.js → hyperframes-player-tnfCiVdR.js} +1 -1
- package/dist/assets/{index-BDK4rTMb.js → index-Ca6LZlVb.js} +1 -1
- package/dist/assets/index-Cre9X4RS.css +1 -0
- package/dist/assets/{index-De2aO4XM.js → index-DEDhPmPD.js} +205 -205
- package/dist/assets/{index-WV9LroAD.js → index-zpe332hb.js} +1 -1
- package/dist/{chunk-62DDWOSH.js → chunk-EEXSYY5F.js} +19 -18
- package/dist/chunk-EEXSYY5F.js.map +1 -0
- package/dist/{chunk-6GAO75IU.js → chunk-NCUBAVGK.js} +10 -8
- package/dist/chunk-NCUBAVGK.js.map +1 -0
- package/dist/{chunk-HIGHVWYD.js → chunk-QADHJFDF.js} +2 -2
- package/dist/index.css +6 -1
- package/dist/index.css.map +1 -1
- package/dist/index.html +2 -2
- package/dist/index.js +614 -638
- package/dist/index.js.map +1 -1
- package/dist/player.js +2 -2
- package/dist/styles/tailwind-preset.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/ui.js +2 -2
- package/package.json +8 -8
- package/src/captions/components/CaptionAnimationPanel.tsx +2 -2
- package/src/captions/components/CaptionPropertyPanel.tsx +2 -2
- package/src/captions/components/CaptionTimeline.tsx +3 -3
- package/src/components/AskAgentModal.tsx +1 -1
- package/src/components/LintModal.tsx +35 -35
- package/src/components/StudioErrorBoundary.tsx +1 -1
- package/src/components/StudioHeader.dom.test.tsx +4 -4
- package/src/components/StudioHeader.tsx +2 -1
- package/src/components/StudioToast.tsx +7 -16
- package/src/components/TimelineToolPicker.tsx +1 -1
- package/src/components/TimelineToolbar.tsx +11 -11
- package/src/components/dock/Dock.tsx +1 -1
- package/src/components/dock/dock.css +9 -1
- package/src/components/editor/AnimationCard.tsx +5 -5
- package/src/components/editor/AnimationCardParts.tsx +1 -1
- package/src/components/editor/BlockParamsPanel.tsx +3 -3
- package/src/components/editor/BorderRadiusEditor.tsx +8 -15
- package/src/components/editor/CanvasContextMenu.tsx +1 -1
- package/src/components/editor/ComputedTweenNotice.tsx +1 -1
- package/src/components/editor/DomEditRotateHandle.tsx +1 -1
- package/src/components/editor/EaseCurveSection.tsx +14 -19
- package/src/components/editor/EaseModeControls.tsx +2 -2
- package/src/components/editor/EaseParamFields.tsx +8 -8
- package/src/components/editor/FileTree.tsx +1 -1
- package/src/components/editor/FileTreeIcons.tsx +47 -26
- package/src/components/editor/FileTreeNodes.tsx +11 -8
- package/src/components/editor/GestureRecordControl.tsx +3 -3
- package/src/components/editor/GsapAddAnimationControl.tsx +1 -1
- package/src/components/editor/GsapAnimationSection.tsx +2 -2
- package/src/components/editor/InlineTextToolbar.tsx +4 -4
- package/src/components/editor/InspectorHeaderActions.tsx +1 -1
- package/src/components/editor/KeyframeDiamond.tsx +6 -4
- package/src/components/editor/KeyframeNavigation.tsx +4 -4
- package/src/components/editor/LayersPanel.tsx +3 -3
- package/src/components/editor/PromotableControl.tsx +2 -2
- package/src/components/editor/PropertyPanelEmptyState.tsx +4 -4
- package/src/components/editor/PropertyPanelFlatFooter.tsx +2 -2
- package/src/components/editor/PropertyPanelFlatHeader.test.tsx +1 -1
- package/src/components/editor/PropertyPanelFlatHeader.tsx +2 -2
- package/src/components/editor/SnapToolbar.tsx +5 -5
- package/src/components/editor/TimelineFxPopover.tsx +4 -4
- package/src/components/editor/Transform3DCube.tsx +1 -1
- package/src/components/editor/anchoredResizeReleaseShift.test.ts +0 -84
- package/src/components/editor/easeCurveSvg.tsx +1 -1
- package/src/components/editor/manualEditsDom.ts +3 -3
- package/src/components/editor/manualEditsDomPatches.test.ts +2 -86
- package/src/components/editor/manualEditsDomPatches.ts +0 -30
- package/src/components/editor/manualEditsSnapshot.ts +1 -0
- package/src/components/editor/persistSeam.integration.test.ts +0 -18
- package/src/components/editor/plainTranslate.ts +34 -3
- package/src/components/editor/propertyPanelColorCurveGraph.tsx +2 -2
- package/src/components/editor/propertyPanelColorGradingControls.tsx +1 -1
- package/src/components/editor/propertyPanelColorGradingSection.tsx +8 -8
- package/src/components/editor/propertyPanelColorGradingSlider.tsx +1 -1
- package/src/components/editor/propertyPanelColorSecondary.tsx +4 -4
- package/src/components/editor/propertyPanelFill.tsx +6 -6
- package/src/components/editor/propertyPanelFlatColorGradingAccessory.tsx +3 -3
- package/src/components/editor/propertyPanelFlatColorGradingSection.test.tsx +1 -1
- package/src/components/editor/propertyPanelFlatColorGradingSection.tsx +6 -9
- package/src/components/editor/propertyPanelFlatEffectsSection.tsx +4 -4
- package/src/components/editor/propertyPanelFlatMediaSection.tsx +2 -2
- package/src/components/editor/propertyPanelFlatMotionSection.tsx +2 -2
- package/src/components/editor/propertyPanelFlatOverlaysSection.tsx +2 -2
- package/src/components/editor/propertyPanelFlatPrimitives.test.tsx +4 -3
- package/src/components/editor/propertyPanelFlatPrimitives.tsx +1 -1
- package/src/components/editor/propertyPanelFlatSliderReadout.tsx +1 -1
- package/src/components/editor/propertyPanelFont.tsx +2 -2
- package/src/components/editor/propertyPanelFxCarveModule.tsx +1 -1
- package/src/components/editor/propertyPanelFxControls.tsx +2 -2
- package/src/components/editor/propertyPanelFxEqModule.tsx +2 -2
- package/src/components/editor/propertyPanelFxNodeRow.tsx +1 -1
- package/src/components/editor/propertyPanelFxPresetRun.tsx +1 -1
- package/src/components/editor/propertyPanelMediaSection.tsx +1 -1
- package/src/components/editor/propertyPanelPrimitives.tsx +1 -1
- package/src/components/editor/propertyPanelSections.tsx +2 -2
- package/src/components/editor/propertyPanelValueTier.test.ts +1 -1
- package/src/components/editor/propertyPanelValueTier.ts +1 -1
- package/src/components/feedback/StudioFeedbackCard.tsx +11 -23
- package/src/components/nle/AssetPreviewOverlay.tsx +1 -1
- package/src/components/nle/AudioMeterStrip.tsx +2 -2
- package/src/components/nle/NLEPreview.test.ts +8 -4
- package/src/components/nle/PreviewOverlays.tsx +1 -1
- package/src/components/nle/PreviewPane.tsx +3 -3
- package/src/components/nle/PreviewPoster.tsx +29 -1
- package/src/components/nle/PreviewZoomOverlay.tsx +1 -1
- package/src/components/panels/SlideshowPanel.tsx +4 -4
- package/src/components/panels/SlideshowSubPanels.tsx +19 -21
- package/src/components/panels/VariablesBindElement.tsx +1 -1
- package/src/components/panels/VariablesDeclarationForm.tsx +1 -1
- package/src/components/panels/VariablesPanel.tsx +4 -6
- package/src/components/panels/VariablesRowAction.tsx +1 -1
- package/src/components/renders/FfmpegRequiredNotice.tsx +4 -4
- package/src/components/renders/RenderQueue.tsx +2 -2
- package/src/components/renders/RenderQueueItem.tsx +3 -3
- package/src/components/sidebar/AssetCard.tsx +3 -3
- package/src/components/sidebar/AssetContextMenu.tsx +7 -7
- package/src/components/sidebar/AssetsTab.tsx +6 -6
- package/src/components/sidebar/AudioRow.tsx +5 -3
- package/src/components/sidebar/BlocksTab.tsx +6 -6
- package/src/components/sidebar/CompositionsTab.drag.test.tsx +3 -69
- package/src/components/sidebar/CompositionsTab.rootBadge.test.tsx +4 -50
- package/src/components/sidebar/CompositionsTab.thumbnails.test.tsx +256 -0
- package/src/components/sidebar/CompositionsTab.tsx +65 -12
- package/src/components/sidebar/PromptPreviewModal.tsx +3 -3
- package/src/components/sidebar/SidebarLintButton.tsx +3 -3
- package/src/components/sidebar/compositionsTabTestUtils.tsx +39 -0
- package/src/components/timelineToolbarStyles.ts +3 -3
- package/src/components/ui/Button.tsx +4 -4
- package/src/components/ui/HyperframesLogo.tsx +19 -18
- package/src/components/ui/Input.tsx +1 -1
- package/src/components/ui/Menu.tsx +4 -2
- package/src/hooks/elementOffsetStager.ts +8 -7
- package/src/hooks/useClipboard.source.test.ts +42 -4
- package/src/hooks/useClipboard.ts +13 -3
- package/src/hooks/useDomEditCommits.ts +0 -3
- package/src/hooks/useDomGeometryCommit.test.tsx +4 -1
- package/src/hooks/useDomGeometryCommit.ts +0 -1
- package/src/hooks/useDomGeometryCommits.test.tsx +177 -32
- package/src/hooks/useDomGeometryCommits.ts +4 -49
- package/src/player/components/ClipContextMenu.tsx +1 -1
- package/src/player/components/CompositionThumbnail.tsx +23 -11
- package/src/player/components/EditModal.tsx +6 -6
- package/src/player/components/KeyframeDiamondContextMenu.tsx +2 -2
- package/src/player/components/PlayerControls.tsx +3 -3
- package/src/player/components/ShortcutsPanel.tsx +8 -20
- package/src/player/components/TimelineCanvas.tsx +1 -1
- package/src/player/components/TimelineClip.tsx +2 -2
- package/src/player/components/TimelineEmptyState.tsx +2 -2
- package/src/player/components/TimelineLanes.tsx +0 -1
- package/src/player/components/TrackClipCount.tsx +1 -1
- package/src/player/components/VolumeControl.tsx +1 -1
- package/src/player/components/timelineClipChildren.tsx +1 -1
- package/src/player/components/timelineMotionStyles.test.ts +6 -22
- package/src/player/components/trackHeaderLabelRows.tsx +16 -16
- package/src/player/lib/thumbnailScheduler.ts +4 -5
- package/src/player/lib/timelineViewportBudgets.test.ts +1 -1
- package/src/player/lib/timelineViewportBudgets.ts +1 -1
- package/src/styles/hex-baseline.json +7 -19
- package/src/styles/studio.css +0 -9
- package/src/styles/tailwind-preset.shared.js +2 -1
- package/src/styles/theme.css +204 -147
- package/src/styles/theme.test.ts +13 -9
- package/src/utils/blockCategories.ts +41 -9
- package/src/utils/clipboardPayload.ts +2 -0
- package/dist/assets/index-CQN3M56N.css +0 -1
- package/dist/chunk-62DDWOSH.js.map +0 -1
- package/dist/chunk-6GAO75IU.js.map +0 -1
- package/src/hooks/gsapTargetCache.ts +0 -62
- /package/dist/{chunk-HIGHVWYD.js.map → chunk-QADHJFDF.js.map} +0 -0
|
@@ -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
|
-
//
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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="
|
|
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(
|
|
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>
|
|
@@ -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 {
|
|
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
|
|
63
|
-
const before =
|
|
64
|
-
const
|
|
65
|
-
style.
|
|
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") ===
|
|
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,
|
|
73
|
+
commitPositionPatchToHtml(selection, patches, options).catch((error) => {
|
|
73
74
|
rollback();
|
|
74
75
|
throw error;
|
|
75
76
|
});
|
|
@@ -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(
|
|
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(
|
|
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,15 @@ function mountClipboard(
|
|
|
93
97
|
domSelection: DomEditSelection | null = null,
|
|
94
98
|
sub = SUB,
|
|
95
99
|
bundle: (host: Element) => void = () => {},
|
|
100
|
+
saved = SAVED,
|
|
96
101
|
) {
|
|
97
|
-
const files: Record<string, string> = { "index.html":
|
|
102
|
+
const files: Record<string, string> = { "index.html": saved, "compositions/sub.html": sub };
|
|
98
103
|
const fail = { on: false };
|
|
99
104
|
const delayMs: Record<string, number> = {};
|
|
100
105
|
const domEditSave = { pending: Promise.resolve() };
|
|
101
106
|
const domSelectionRef = { current: domSelection };
|
|
102
107
|
stubFiles(files, fail, delayMs);
|
|
103
|
-
const iframe = mountPreview(sub, bundle);
|
|
108
|
+
const iframe = mountPreview(sub, bundle, saved);
|
|
104
109
|
const writes: string[] = [];
|
|
105
110
|
const deleted: string[] = [];
|
|
106
111
|
const writeProjectFile = async (_path: string, content: string) => {
|
|
@@ -248,6 +253,39 @@ const SUB_SELECTION = {
|
|
|
248
253
|
sourceFile: "compositions/sub.html",
|
|
249
254
|
} as DomEditSelection;
|
|
250
255
|
|
|
256
|
+
describe("paste of an element styled by its id", () => {
|
|
257
|
+
it("gives the copy the look its original has", async () => {
|
|
258
|
+
clearSelection();
|
|
259
|
+
const saved = SAVED.replace(
|
|
260
|
+
"<body>",
|
|
261
|
+
"<body><style>#badge { color: rgb(200, 30, 40); letter-spacing: 3px; }</style>",
|
|
262
|
+
).replace("</h1>", '</h1><p id="badge">New</p>');
|
|
263
|
+
const selection = {
|
|
264
|
+
hfId: stampedHfId(saved, "#badge"),
|
|
265
|
+
selector: "#badge",
|
|
266
|
+
selectorIndex: 0,
|
|
267
|
+
sourceFile: "index.html",
|
|
268
|
+
} as DomEditSelection;
|
|
269
|
+
const { clipboard, writes } = mountClipboard(selection, SUB, () => {}, saved);
|
|
270
|
+
clipboard().handleCopy();
|
|
271
|
+
await clipboard().handlePaste();
|
|
272
|
+
const page = document.createElement("iframe");
|
|
273
|
+
document.body.appendChild(page);
|
|
274
|
+
const doc = page.contentDocument as Document;
|
|
275
|
+
doc.open();
|
|
276
|
+
doc.write(writes[0] ?? "");
|
|
277
|
+
doc.close();
|
|
278
|
+
const look = (id: string) => {
|
|
279
|
+
const style = (page.contentWindow as Window).getComputedStyle(
|
|
280
|
+
doc.getElementById(id) as Element,
|
|
281
|
+
);
|
|
282
|
+
return { color: style.color, letterSpacing: style.letterSpacing };
|
|
283
|
+
};
|
|
284
|
+
expect(look("badge")).toEqual({ color: "rgb(200, 30, 40)", letterSpacing: "3px" });
|
|
285
|
+
expect(look("badge-2")).toEqual(look("badge"));
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
251
289
|
describe("copy of a sub-composition clip", () => {
|
|
252
290
|
it("rebases its relative asset paths to the project root, as the preview does", async () => {
|
|
253
291
|
clearSelection();
|
|
@@ -160,10 +160,17 @@ const hfIdsInFile = (content: string) =>
|
|
|
160
160
|
export function pasteElementHtml(
|
|
161
161
|
content: string,
|
|
162
162
|
payload: { html: string; originSelector?: string; originSelectorIndex?: number },
|
|
163
|
+
fromThisFile = false,
|
|
163
164
|
): string {
|
|
164
165
|
const reminted = remintHfIds(payload.html, new DOMParser(), hfIdsInFile(content));
|
|
165
166
|
const deduped = deduplicateIds(reminted, collectHtmlIds(content));
|
|
166
|
-
|
|
167
|
+
const result = insertAsSibling(
|
|
168
|
+
content,
|
|
169
|
+
deduped,
|
|
170
|
+
payload.originSelector,
|
|
171
|
+
payload.originSelectorIndex,
|
|
172
|
+
);
|
|
173
|
+
return fromThisFile ? carryLook(result, renamedIds(reminted, deduped), 0) : result;
|
|
167
174
|
}
|
|
168
175
|
|
|
169
176
|
/** Shared insertion path for paste and duplicate, anchored at the playhead or the selection's end. Returns the
|
|
@@ -324,6 +331,7 @@ export function useClipboard({
|
|
|
324
331
|
kind: "dom-element",
|
|
325
332
|
html: savedMarkupElseLive(parseSavedSource(content), live, sourceFile),
|
|
326
333
|
sourceFile,
|
|
334
|
+
projectId: projectIdRef.current ?? undefined,
|
|
327
335
|
originSelector: domSelection.selector,
|
|
328
336
|
originSelectorIndex: domSelection.selectorIndex,
|
|
329
337
|
};
|
|
@@ -373,15 +381,17 @@ export function useClipboard({
|
|
|
373
381
|
const targetPath = activeCompPath || "index.html";
|
|
374
382
|
try {
|
|
375
383
|
let pastedIds: string[] = [];
|
|
384
|
+
const fromThisFile = payload.sourceFile === targetPath && payload.projectId === pid;
|
|
376
385
|
const paste = (originalContent: string) => {
|
|
377
|
-
if (payload.kind !== "timeline-clip")
|
|
386
|
+
if (payload.kind !== "timeline-clip")
|
|
387
|
+
return pasteElementHtml(originalContent, payload, fromThisFile);
|
|
378
388
|
const { currentTime, elements } = usePlayerStore.getState();
|
|
379
389
|
const pasted = pasteTimelineClips(
|
|
380
390
|
originalContent,
|
|
381
391
|
payload.clips,
|
|
382
392
|
currentTime,
|
|
383
393
|
elements,
|
|
384
|
-
|
|
394
|
+
fromThisFile,
|
|
385
395
|
);
|
|
386
396
|
pastedIds = pasted.ids;
|
|
387
397
|
// A clip pasted past the current composition end would exist in the
|
|
@@ -271,12 +271,10 @@ export function useDomEditCommits({
|
|
|
271
271
|
|
|
272
272
|
const {
|
|
273
273
|
stageElementPositionOffset,
|
|
274
|
-
handleDomPathOffsetCommit,
|
|
275
274
|
handleDomBoxSizeCommit,
|
|
276
275
|
handleDomRotationCommit,
|
|
277
276
|
handleDomManualEditsReset,
|
|
278
277
|
} = useDomGeometryCommits({
|
|
279
|
-
previewIframeRef,
|
|
280
278
|
showToast,
|
|
281
279
|
commitPositionPatchToHtml,
|
|
282
280
|
readOnlyPreview,
|
|
@@ -316,7 +314,6 @@ export function useDomEditCommits({
|
|
|
316
314
|
handleDomRemoveTextField,
|
|
317
315
|
stageElementPositionOffset,
|
|
318
316
|
commitPositionPatchToHtml,
|
|
319
|
-
handleDomPathOffsetCommit,
|
|
320
317
|
handleDomBoxSizeCommit,
|
|
321
318
|
handleDomRotationCommit,
|
|
322
319
|
handleDomManualEditsReset,
|
|
@@ -168,7 +168,10 @@ describe("useDomGeometryCommit, from the package entry", () => {
|
|
|
168
168
|
expect(element.style.getPropertyValue("translate")).toBe("130.5px 90px");
|
|
169
169
|
expect(calls.patches).toEqual([
|
|
170
170
|
expect.objectContaining({
|
|
171
|
-
operations: [
|
|
171
|
+
operations: [
|
|
172
|
+
{ type: "inline-style", property: "translate", value: "130.5px 90px" },
|
|
173
|
+
{ type: "attribute", property: "data-hf-studio-original-inline-translate", value: "" },
|
|
174
|
+
],
|
|
172
175
|
}),
|
|
173
176
|
]);
|
|
174
177
|
expect(calls.urls.filter((url) => url.includes("gsap"))).toEqual([]);
|
|
@@ -111,7 +111,6 @@ export function useDomGeometryCommit({
|
|
|
111
111
|
);
|
|
112
112
|
const { stageElementPositionOffset, handleDomBoxSizeCommit, handleDomRotationCommit } =
|
|
113
113
|
useDomGeometryCommits({
|
|
114
|
-
previewIframeRef: iframeRef,
|
|
115
114
|
showToast,
|
|
116
115
|
commitPositionPatchToHtml: commitWithFreshQueue,
|
|
117
116
|
readOnlyPreview: false,
|
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
readStudioRotation,
|
|
14
14
|
} from "../components/editor/manualEdits";
|
|
15
15
|
import { useDomGeometryCommits, type UseDomGeometryCommitsParams } from "./useDomGeometryCommits";
|
|
16
|
+
import { reapplyPositionEditsAfterSeek } from "../components/editor/manualEdits";
|
|
17
|
+
import { writeTranslatePx } from "../components/editor/plainTranslate";
|
|
18
|
+
import { applyPatch } from "../utils/sourcePatcher";
|
|
16
19
|
import { DomEditCropHandles } from "../components/editor/DomEditCropHandles";
|
|
17
20
|
import { withInlineLayoutBox } from "./domSelectionTestHarness";
|
|
18
21
|
|
|
@@ -25,7 +28,6 @@ function mountCommits(
|
|
|
25
28
|
let commits: ReturnType<typeof useDomGeometryCommits> | null = null;
|
|
26
29
|
function Probe() {
|
|
27
30
|
commits = useDomGeometryCommits({
|
|
28
|
-
previewIframeRef: { current: null },
|
|
29
31
|
showToast: vi.fn(),
|
|
30
32
|
commitPositionPatchToHtml,
|
|
31
33
|
readOnlyPreview,
|
|
@@ -61,7 +63,6 @@ describe("useDomGeometryCommits rollback", () => {
|
|
|
61
63
|
|
|
62
64
|
function Probe() {
|
|
63
65
|
commits = useDomGeometryCommits({
|
|
64
|
-
previewIframeRef: { current: null },
|
|
65
66
|
showToast: vi.fn(),
|
|
66
67
|
commitPositionPatchToHtml,
|
|
67
68
|
readOnlyPreview: false,
|
|
@@ -70,9 +71,6 @@ describe("useDomGeometryCommits rollback", () => {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
act(() => root.render(<Probe />));
|
|
73
|
-
await expect(commits!.handleDomPathOffsetCommit(selection, { x: 50, y: 60 })).rejects.toBe(
|
|
74
|
-
failure,
|
|
75
|
-
);
|
|
76
74
|
await expect(
|
|
77
75
|
commits!.handleDomBoxSizeCommit(selection, { width: 200, height: 160 }, { x: 30, y: 40 }),
|
|
78
76
|
).rejects.toBe(failure);
|
|
@@ -90,20 +88,6 @@ describe("useDomGeometryCommits read-only preview", () => {
|
|
|
90
88
|
const selectionOn = (element: HTMLElement) =>
|
|
91
89
|
({ id: element.id, selector: `#${element.id}`, element }) as unknown as DomEditSelection;
|
|
92
90
|
|
|
93
|
-
it("refuses a manual offset commit: no write, no history entry", async () => {
|
|
94
|
-
const element = document.createElement("div");
|
|
95
|
-
element.id = "ro-offset";
|
|
96
|
-
document.body.append(element);
|
|
97
|
-
applyStudioPathOffset(element, { x: 1, y: 2 });
|
|
98
|
-
const commitPositionPatchToHtml =
|
|
99
|
-
vi.fn<UseDomGeometryCommitsParams["commitPositionPatchToHtml"]>();
|
|
100
|
-
const { commits, unmount } = mountCommits(commitPositionPatchToHtml, true);
|
|
101
|
-
await commits().handleDomPathOffsetCommit(selectionOn(element), { x: 99, y: 99 });
|
|
102
|
-
expect(readStudioPathOffset(element)).toEqual({ x: 1, y: 2 });
|
|
103
|
-
expect(commitPositionPatchToHtml).not.toHaveBeenCalled();
|
|
104
|
-
unmount();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
91
|
it("refuses a manual box-size commit: no write, no history entry", async () => {
|
|
108
92
|
const element = document.createElement("div");
|
|
109
93
|
element.id = "ro-size";
|
|
@@ -131,19 +115,6 @@ describe("useDomGeometryCommits read-only preview", () => {
|
|
|
131
115
|
expect(commitPositionPatchToHtml).not.toHaveBeenCalled();
|
|
132
116
|
unmount();
|
|
133
117
|
});
|
|
134
|
-
|
|
135
|
-
it("still commits an offset with the flag off", async () => {
|
|
136
|
-
const element = document.createElement("div");
|
|
137
|
-
element.id = "rw-offset";
|
|
138
|
-
document.body.append(element);
|
|
139
|
-
const commitPositionPatchToHtml = vi
|
|
140
|
-
.fn<UseDomGeometryCommitsParams["commitPositionPatchToHtml"]>()
|
|
141
|
-
.mockResolvedValue(undefined);
|
|
142
|
-
const { commits, unmount } = mountCommits(commitPositionPatchToHtml);
|
|
143
|
-
await commits().handleDomPathOffsetCommit(selectionOn(element), { x: 5, y: 6 });
|
|
144
|
-
expect(commitPositionPatchToHtml).toHaveBeenCalledTimes(1);
|
|
145
|
-
unmount();
|
|
146
|
-
});
|
|
147
118
|
});
|
|
148
119
|
|
|
149
120
|
describe("useDomGeometryCommits element position offset", () => {
|
|
@@ -230,6 +201,180 @@ describe("useDomGeometryCommits resize rollback", () => {
|
|
|
230
201
|
});
|
|
231
202
|
});
|
|
232
203
|
|
|
204
|
+
describe("a plain move of an element an older Studio moved by its offset vars", () => {
|
|
205
|
+
function legacyMoved() {
|
|
206
|
+
const element = document.createElement("div");
|
|
207
|
+
element.id = "legacy";
|
|
208
|
+
element.style.setProperty("translate", "10px 5px");
|
|
209
|
+
document.body.append(element);
|
|
210
|
+
applyStudioPathOffset(element, { x: 40, y: 30 });
|
|
211
|
+
const selection = { id: "legacy", selector: "#legacy", element } as unknown as DomEditSelection;
|
|
212
|
+
return { element, selection };
|
|
213
|
+
}
|
|
214
|
+
const legacyEnds = [
|
|
215
|
+
{ type: "inline-style", property: "--hf-studio-offset-x", value: null },
|
|
216
|
+
{ type: "inline-style", property: "--hf-studio-offset-y", value: null },
|
|
217
|
+
{ type: "attribute", property: "data-hf-studio-path-offset", value: null },
|
|
218
|
+
];
|
|
219
|
+
const keptMarks = [
|
|
220
|
+
"data-hf-studio-original-inline-translate",
|
|
221
|
+
"data-hf-studio-original-translate",
|
|
222
|
+
];
|
|
223
|
+
const studioMarks = (el: HTMLElement) =>
|
|
224
|
+
el
|
|
225
|
+
.getAttributeNames()
|
|
226
|
+
.filter((name) => name.startsWith("data-hf-studio"))
|
|
227
|
+
.sort();
|
|
228
|
+
|
|
229
|
+
it("saves the move as its translate, ends the old offset, and a seek keeps it", async () => {
|
|
230
|
+
const { element, selection } = legacyMoved();
|
|
231
|
+
const commitPositionPatchToHtml = vi
|
|
232
|
+
.fn<UseDomGeometryCommitsParams["commitPositionPatchToHtml"]>()
|
|
233
|
+
.mockResolvedValue(undefined);
|
|
234
|
+
const { commits, unmount } = mountCommits(commitPositionPatchToHtml);
|
|
235
|
+
|
|
236
|
+
await commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save();
|
|
237
|
+
reapplyPositionEditsAfterSeek(document);
|
|
238
|
+
|
|
239
|
+
expect(element.style.getPropertyValue("translate")).toBe("140px 30px");
|
|
240
|
+
expect(commitPositionPatchToHtml.mock.calls[0]![1]).toEqual([
|
|
241
|
+
{ type: "inline-style", property: "translate", value: "140px 30px" },
|
|
242
|
+
{
|
|
243
|
+
type: "attribute",
|
|
244
|
+
property: "data-hf-studio-original-inline-translate",
|
|
245
|
+
value: "10px 5px",
|
|
246
|
+
},
|
|
247
|
+
...legacyEnds,
|
|
248
|
+
]);
|
|
249
|
+
expect(studioMarks(element)).toEqual(keptMarks);
|
|
250
|
+
unmount();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("resizes with the anchor as its translate, ends the old offset, and a seek keeps it", async () => {
|
|
254
|
+
const { element, selection } = legacyMoved();
|
|
255
|
+
const commit = vi
|
|
256
|
+
.fn<UseDomGeometryCommitsParams["commitPositionPatchToHtml"]>()
|
|
257
|
+
.mockResolvedValue(undefined);
|
|
258
|
+
const { commits, unmount } = mountCommits(commit);
|
|
259
|
+
|
|
260
|
+
await commits().handleDomBoxSizeCommit(selection, { width: 80, height: 60 }, { x: 60, y: 40 });
|
|
261
|
+
reapplyPositionEditsAfterSeek(document);
|
|
262
|
+
|
|
263
|
+
expect(element.style.getPropertyValue("translate")).toBe("60px 40px");
|
|
264
|
+
expect(commit.mock.calls[0]![1]).toEqual(expect.arrayContaining(legacyEnds));
|
|
265
|
+
expect(studioMarks(element)).toEqual(expect.arrayContaining(keptMarks));
|
|
266
|
+
expect(element.hasAttribute("data-hf-studio-path-offset")).toBe(false);
|
|
267
|
+
unmount();
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it.each(["move", "resize"])(
|
|
271
|
+
"puts the old offset back whole when the %s save fails",
|
|
272
|
+
async (kind) => {
|
|
273
|
+
const { element, selection } = legacyMoved();
|
|
274
|
+
const translate = element.style.getPropertyValue("translate");
|
|
275
|
+
const { commits, unmount } = mountCommits(
|
|
276
|
+
vi.fn().mockRejectedValue(new Error("save failed")),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
const save =
|
|
280
|
+
kind === "move"
|
|
281
|
+
? commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save()
|
|
282
|
+
: commits().handleDomBoxSizeCommit(
|
|
283
|
+
selection,
|
|
284
|
+
{ width: 80, height: 60 },
|
|
285
|
+
{ x: 60, y: 40 },
|
|
286
|
+
);
|
|
287
|
+
await expect(save).rejects.toThrow();
|
|
288
|
+
expect(element.style.getPropertyValue("translate")).toBe(translate);
|
|
289
|
+
expect(element.hasAttribute("data-hf-studio-path-offset")).toBe(true);
|
|
290
|
+
expect(readStudioPathOffset(element)).toEqual({ x: 40, y: 30 });
|
|
291
|
+
unmount();
|
|
292
|
+
},
|
|
293
|
+
);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
describe("Reset after a plain move puts the author's translate back", () => {
|
|
297
|
+
function authoredLayer(translate: string | null, legacy = false) {
|
|
298
|
+
const element = document.createElement("div");
|
|
299
|
+
element.id = "layer";
|
|
300
|
+
if (translate) element.style.setProperty("translate", translate);
|
|
301
|
+
document.body.append(element);
|
|
302
|
+
if (legacy) applyStudioPathOffset(element, { x: 40, y: 30 });
|
|
303
|
+
const project = { file: element.outerHTML, history: [] as string[] };
|
|
304
|
+
const commit = vi.fn<UseDomGeometryCommitsParams["commitPositionPatchToHtml"]>(
|
|
305
|
+
async (_selection, patches) => {
|
|
306
|
+
project.history.push(project.file);
|
|
307
|
+
project.file = patches.reduce((html, op) => applyPatch(html, "layer", op), project.file);
|
|
308
|
+
},
|
|
309
|
+
);
|
|
310
|
+
const selection = { id: "layer", selector: "#layer", element } as unknown as DomEditSelection;
|
|
311
|
+
return { element, selection, project, ...mountCommits(commit) };
|
|
312
|
+
}
|
|
313
|
+
const saved = (html: string) =>
|
|
314
|
+
new DOMParser().parseFromString(html, "text/html").getElementById("layer")!;
|
|
315
|
+
const studioLeftovers = (el: Element) => [
|
|
316
|
+
...el.getAttributeNames().filter((name) => name.startsWith("data-hf-studio")),
|
|
317
|
+
...((el as HTMLElement).style.cssText.match(/--hf-studio-[\w-]+/g) ?? []),
|
|
318
|
+
];
|
|
319
|
+
|
|
320
|
+
it("restores an older Studio's layer to its authored 50% 10px, in the file and live", async () => {
|
|
321
|
+
const { element, selection, project, commits, unmount } = authoredLayer("50% 10px", true);
|
|
322
|
+
|
|
323
|
+
await commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save();
|
|
324
|
+
await commits().handleDomManualEditsReset(selection);
|
|
325
|
+
|
|
326
|
+
expect(saved(project.file).style.getPropertyValue("translate")).toBe("50% 10px");
|
|
327
|
+
expect(element.style.getPropertyValue("translate")).toBe("50% 10px");
|
|
328
|
+
expect(studioLeftovers(saved(project.file))).toEqual([]);
|
|
329
|
+
expect(studioLeftovers(element)).toEqual([]);
|
|
330
|
+
unmount();
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("restores the authored 12px 4px after a drag and a second move", async () => {
|
|
334
|
+
const { element, selection, project, commits, unmount } = authoredLayer("12px 4px");
|
|
335
|
+
|
|
336
|
+
writeTranslatePx(element, { x: 90, y: 0 });
|
|
337
|
+
await commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save();
|
|
338
|
+
await commits().stageElementPositionOffset(selection, { x: 200, y: 50 }, true).save();
|
|
339
|
+
await commits().handleDomManualEditsReset(selection);
|
|
340
|
+
|
|
341
|
+
expect(saved(project.file).style.getPropertyValue("translate")).toBe("12px 4px");
|
|
342
|
+
expect(element.style.getPropertyValue("translate")).toBe("12px 4px");
|
|
343
|
+
expect(studioLeftovers(saved(project.file))).toEqual([]);
|
|
344
|
+
unmount();
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("removes the translate of a layer that had none, in the file and live", async () => {
|
|
348
|
+
const { element, selection, project, commits, unmount } = authoredLayer(null);
|
|
349
|
+
|
|
350
|
+
await commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save();
|
|
351
|
+
await commits().handleDomManualEditsReset(selection);
|
|
352
|
+
|
|
353
|
+
expect(saved(project.file).style.getPropertyValue("translate")).toBe("");
|
|
354
|
+
expect(element.style.getPropertyValue("translate")).toBe("");
|
|
355
|
+
expect(studioLeftovers(saved(project.file))).toEqual([]);
|
|
356
|
+
unmount();
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it("undo of the Reset brings the move back, and Reset still restores the author's", async () => {
|
|
360
|
+
const { selection, project, commits, unmount } = authoredLayer("12px 4px");
|
|
361
|
+
|
|
362
|
+
await commits().stageElementPositionOffset(selection, { x: 140, y: 30 }, true).save();
|
|
363
|
+
const moved = project.file;
|
|
364
|
+
await commits().handleDomManualEditsReset(selection);
|
|
365
|
+
project.file = project.history.pop()!;
|
|
366
|
+
expect(project.file).toBe(moved);
|
|
367
|
+
|
|
368
|
+
const reloaded = saved(project.file) as HTMLElement;
|
|
369
|
+
document.body.append(reloaded);
|
|
370
|
+
expect(reloaded.style.getPropertyValue("translate")).toBe("140px 30px");
|
|
371
|
+
await commits().handleDomManualEditsReset({ ...selection, element: reloaded });
|
|
372
|
+
expect(saved(project.file).style.getPropertyValue("translate")).toBe("12px 4px");
|
|
373
|
+
expect(reloaded.style.getPropertyValue("translate")).toBe("12px 4px");
|
|
374
|
+
unmount();
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
|
|
233
378
|
describe("useDomGeometryCommits resize of a cropped element", () => {
|
|
234
379
|
it("saves the crop scaled per axis with the box in the resize's own commit", async () => {
|
|
235
380
|
const element = withInlineLayoutBox(document.createElement("div"));
|