@remotion/studio 4.0.471 → 4.0.473
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/api/rename-static-file.d.ts +6 -0
- package/dist/api/rename-static-file.js +18 -0
- package/dist/components/AssetSelector.js +55 -5
- package/dist/components/AssetSelectorItem.js +153 -27
- package/dist/components/Canvas.js +147 -0
- package/dist/components/CompositionSelectorItem.d.ts +1 -0
- package/dist/components/CompositionSelectorItem.js +12 -4
- package/dist/components/ConfirmationDialog-types.d.ts +8 -0
- package/dist/components/ConfirmationDialog-types.js +2 -0
- package/dist/components/ConfirmationDialog.d.ts +7 -0
- package/dist/components/ConfirmationDialog.js +103 -0
- package/dist/components/ContextMenu.d.ts +9 -1
- package/dist/components/ContextMenu.js +99 -47
- package/dist/components/CurrentAsset.d.ts +1 -0
- package/dist/components/CurrentAsset.js +13 -2
- package/dist/components/Editor.js +14 -6
- package/dist/components/EditorContent.js +15 -2
- package/dist/components/EditorContexts.js +2 -1
- package/dist/components/EditorRuler/Ruler.js +2 -0
- package/dist/components/ExplorerPanel.d.ts +0 -4
- package/dist/components/ExplorerPanel.js +8 -4
- package/dist/components/ExplorerPanelRef.d.ts +4 -0
- package/dist/components/ExplorerPanelRef.js +5 -0
- package/dist/components/FilePreview.d.ts +1 -1
- package/dist/components/InitialCompositionLoader.d.ts +0 -1
- package/dist/components/InitialCompositionLoader.js +5 -27
- package/dist/components/Menu/MenuItem.js +7 -1
- package/dist/components/Menu/SubMenu.js +5 -1
- package/dist/components/Menu/portals.js +17 -8
- package/dist/components/MenuToolbar.js +5 -1
- package/dist/components/ModalContainer.js +6 -1
- package/dist/components/Modals.js +8 -2
- package/dist/components/NewComposition/CodemodFooter.js +2 -2
- package/dist/components/NewComposition/ComboBox.js +8 -2
- package/dist/components/NewComposition/DeleteFolder.d.ts +6 -0
- package/dist/components/NewComposition/DeleteFolder.js +39 -0
- package/dist/components/NewComposition/DeleteStaticFile.d.ts +4 -0
- package/dist/components/NewComposition/DeleteStaticFile.js +44 -0
- package/dist/components/NewComposition/RenameFolder.d.ts +6 -0
- package/dist/components/NewComposition/RenameFolder.js +60 -0
- package/dist/components/NewComposition/RenameStaticFile.d.ts +4 -0
- package/dist/components/NewComposition/RenameStaticFile.js +118 -0
- package/dist/components/OptionsPanel.js +5 -1
- package/dist/components/OutlineToggle.d.ts +2 -0
- package/dist/components/OutlineToggle.js +20 -0
- package/dist/components/Preview.d.ts +0 -2
- package/dist/components/Preview.js +23 -33
- package/dist/components/PreviewToolbar.js +19 -6
- package/dist/components/RenderButton.js +8 -2
- package/dist/components/RenderPreview.js +2 -2
- package/dist/components/SelectedOutlineOverlay.d.ts +105 -4
- package/dist/components/SelectedOutlineOverlay.js +578 -59
- package/dist/components/ShowOutlinesProvider.d.ts +4 -0
- package/dist/components/ShowOutlinesProvider.js +24 -0
- package/dist/components/SizeSelector.js +3 -3
- package/dist/components/Splitter/SplitterContainer.js +9 -0
- package/dist/components/Splitter/SplitterHandle.js +65 -70
- package/dist/components/StaticFilePreview.js +2 -2
- package/dist/components/Timeline/KeyframeSettingsModal.d.ts +15 -0
- package/dist/components/Timeline/KeyframeSettingsModal.js +150 -0
- package/dist/components/Timeline/Timeline.js +50 -15
- package/dist/components/Timeline/TimelineArrayField.d.ts +9 -0
- package/dist/components/Timeline/TimelineArrayField.js +210 -0
- package/dist/components/Timeline/TimelineBooleanField.d.ts +2 -2
- package/dist/components/Timeline/TimelineBooleanField.js +2 -2
- package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +43 -0
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +479 -0
- package/dist/components/Timeline/TimelineColorField.d.ts +2 -2
- package/dist/components/Timeline/TimelineColorField.js +2 -8
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +12 -2
- package/dist/components/Timeline/TimelineEffectItem.js +3 -2
- package/dist/components/Timeline/TimelineEffectPropItem.js +146 -26
- package/dist/components/Timeline/TimelineEnumField.d.ts +2 -2
- package/dist/components/Timeline/TimelineEnumField.js +3 -3
- package/dist/components/Timeline/TimelineKeyframeControls.d.ts +4 -3
- package/dist/components/Timeline/TimelineKeyframeControls.js +41 -37
- package/dist/components/Timeline/TimelineKeyframeDiamond.js +24 -21
- package/dist/components/Timeline/TimelineKeyframeDiamondIcon.d.ts +6 -0
- package/dist/components/Timeline/TimelineKeyframeDiamondIcon.js +14 -0
- package/dist/components/Timeline/TimelineKeyframeDragState.d.ts +17 -0
- package/dist/components/Timeline/TimelineKeyframeDragState.js +39 -0
- package/dist/components/Timeline/TimelineKeyframedValue.d.ts +7 -2
- package/dist/components/Timeline/TimelineKeyframedValue.js +22 -8
- package/dist/components/Timeline/TimelineLayerEye.d.ts +1 -0
- package/dist/components/Timeline/TimelineLayerEye.js +8 -3
- package/dist/components/Timeline/TimelineList.js +2 -2
- package/dist/components/Timeline/TimelineMediaInfo.d.ts +0 -13
- package/dist/components/Timeline/TimelineMediaInfo.js +8 -73
- package/dist/components/Timeline/TimelineNumberField.d.ts +2 -2
- package/dist/components/Timeline/TimelineNumberField.js +7 -11
- package/dist/components/Timeline/TimelinePrimitiveFieldValue.d.ts +17 -0
- package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +53 -0
- package/dist/components/Timeline/TimelineRotationField.d.ts +2 -2
- package/dist/components/Timeline/TimelineRotationField.js +41 -24
- package/dist/components/Timeline/TimelineRowChrome.js +8 -7
- package/dist/components/Timeline/TimelineScaleField.d.ts +20 -0
- package/dist/components/Timeline/TimelineScaleField.js +314 -0
- package/dist/components/Timeline/TimelineSchemaField.d.ts +3 -2
- package/dist/components/Timeline/TimelineSchemaField.js +8 -42
- package/dist/components/Timeline/TimelineSelection.js +3 -2
- package/dist/components/Timeline/TimelineSequence.d.ts +1 -0
- package/dist/components/Timeline/TimelineSequence.js +51 -10
- package/dist/components/Timeline/TimelineSequenceFrame.js +1 -0
- package/dist/components/Timeline/TimelineSequenceItem.d.ts +1 -0
- package/dist/components/Timeline/TimelineSequenceItem.js +282 -28
- package/dist/components/Timeline/TimelineSequencePropItem.js +161 -35
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +58 -0
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +525 -0
- package/dist/components/Timeline/TimelineTrack.js +1 -1
- package/dist/components/Timeline/TimelineTranslateField.d.ts +2 -2
- package/dist/components/Timeline/TimelineTranslateField.js +21 -25
- package/dist/components/Timeline/TimelineUvCoordinateField.d.ts +2 -2
- package/dist/components/Timeline/TimelineUvCoordinateField.js +20 -26
- package/dist/components/Timeline/apply-effect-response-to-code-values.d.ts +5 -0
- package/dist/components/Timeline/apply-effect-response-to-code-values.js +19 -0
- package/dist/components/Timeline/call-add-keyframe.js +4 -0
- package/dist/components/Timeline/call-move-keyframe.d.ts +19 -0
- package/dist/components/Timeline/call-move-keyframe.js +71 -0
- package/dist/components/Timeline/call-update-keyframe-settings.d.ts +22 -0
- package/dist/components/Timeline/call-update-keyframe-settings.js +52 -0
- package/dist/components/Timeline/delete-selected-timeline-item.d.ts +7 -4
- package/dist/components/Timeline/delete-selected-timeline-item.js +33 -21
- package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +4 -2
- package/dist/components/Timeline/duplicate-selected-timeline-item.js +39 -34
- package/dist/components/Timeline/get-bounded-keyframe-drag-delta.d.ts +8 -0
- package/dist/components/Timeline/get-bounded-keyframe-drag-delta.js +12 -0
- package/dist/components/Timeline/get-keyframe-navigation.d.ts +2 -2
- package/dist/components/Timeline/get-keyframe-navigation.js +14 -6
- package/dist/components/Timeline/get-node-keyframes.d.ts +5 -2
- package/dist/components/Timeline/get-node-keyframes.js +38 -5
- package/dist/components/Timeline/get-timeline-keyframes.js +4 -4
- package/dist/components/Timeline/reset-selected-timeline-props.js +22 -8
- package/dist/components/Timeline/save-effect-prop.d.ts +14 -3
- package/dist/components/Timeline/save-effect-prop.js +36 -18
- package/dist/components/Timeline/save-prop-queue.d.ts +2 -1
- package/dist/components/Timeline/save-prop-queue.js +5 -2
- package/dist/components/Timeline/save-sequence-prop.d.ts +2 -7
- package/dist/components/Timeline/save-sequence-prop.js +33 -30
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.d.ts +3 -0
- package/dist/components/Timeline/should-clear-selection-on-pointer-down.js +7 -0
- package/dist/components/Timeline/timeline-asset-link.d.ts +13 -0
- package/dist/components/Timeline/timeline-asset-link.js +37 -0
- package/dist/components/Timeline/timeline-field-utils.d.ts +1 -0
- package/dist/components/Timeline/timeline-field-utils.js +5 -1
- package/dist/components/Timeline/timeline-translate-utils.js +9 -2
- package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +7 -0
- package/dist/components/Timeline/use-timeline-keyframe-drag.d.ts +10 -0
- package/dist/components/Timeline/use-timeline-keyframe-drag.js +378 -0
- package/dist/components/TopPanel.d.ts +1 -1
- package/dist/components/folder-menu-items.d.ts +12 -0
- package/dist/components/folder-menu-items.js +147 -0
- package/dist/components/import-assets.d.ts +22 -0
- package/dist/components/import-assets.js +294 -0
- package/dist/components/load-canvas-content-from-url.d.ts +1 -0
- package/dist/components/load-canvas-content-from-url.js +9 -3
- package/dist/components/use-select-asset.d.ts +1 -0
- package/dist/components/use-select-asset.js +30 -0
- package/dist/error-overlay/error-origin.d.ts +3 -0
- package/dist/error-overlay/error-origin.js +42 -0
- package/dist/error-overlay/react-overlay/listen-to-runtime-errors.js +6 -2
- package/dist/error-overlay/remotion-overlay/ErrorLoader.js +38 -0
- package/dist/error-overlay/remotion-overlay/ShortcutHint.js +1 -1
- package/dist/error-overlay/remotion-overlay/log-studio-error.d.ts +3 -0
- package/dist/error-overlay/remotion-overlay/log-studio-error.js +27 -0
- package/dist/esm/{chunk-z0z9d4r0.js → chunk-q0jkt0zq.js} +23062 -17350
- package/dist/esm/internals.mjs +23062 -17350
- package/dist/esm/previewEntry.mjs +22351 -16615
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/calculate-timeline.js +7 -3
- package/dist/helpers/create-folder-tree.js +1 -0
- package/dist/helpers/get-asset-metadata.js +2 -2
- package/dist/helpers/get-folder-id.d.ts +4 -0
- package/dist/helpers/get-folder-id.js +7 -0
- package/dist/helpers/get-preview-file-type.d.ts +2 -0
- package/dist/helpers/get-preview-file-type.js +33 -0
- package/dist/helpers/get-timeline-sequence-sort-key.d.ts +2 -0
- package/dist/helpers/install-required-package.d.ts +1 -0
- package/dist/helpers/install-required-package.js +39 -0
- package/dist/helpers/remote-asset-drag.d.ts +4 -0
- package/dist/helpers/remote-asset-drag.js +73 -0
- package/dist/helpers/timeline-layout.js +5 -1
- package/dist/helpers/use-asset-drag-events.d.ts +5 -2
- package/dist/helpers/use-asset-drag-events.js +13 -2
- package/dist/helpers/validate-folder-rename.d.ts +6 -0
- package/dist/helpers/validate-folder-rename.js +19 -0
- package/dist/hot-middleware-client/client.js +6 -0
- package/dist/state/editor-outlines.d.ts +8 -0
- package/dist/state/editor-outlines.js +18 -0
- package/dist/state/modals.d.ts +29 -2
- package/dist/state/scale-lock.d.ts +18 -0
- package/dist/state/scale-lock.js +59 -0
- package/package.json +10 -10
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTimelineKeyframeDrag = void 0;
|
|
4
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const remotion_1 = require("remotion");
|
|
7
|
+
const client_id_1 = require("../../helpers/client-id");
|
|
8
|
+
const timeline_layout_1 = require("../../helpers/timeline-layout");
|
|
9
|
+
const call_move_keyframe_1 = require("./call-move-keyframe");
|
|
10
|
+
const find_track_for_node_path_info_1 = require("./find-track-for-node-path-info");
|
|
11
|
+
const get_bounded_keyframe_drag_delta_1 = require("./get-bounded-keyframe-drag-delta");
|
|
12
|
+
const parse_keyframe_field_from_node_path_1 = require("./parse-keyframe-field-from-node-path");
|
|
13
|
+
const TimelineKeyframeDragState_1 = require("./TimelineKeyframeDragState");
|
|
14
|
+
const TimelineSelection_1 = require("./TimelineSelection");
|
|
15
|
+
const TimelineWidthProvider_1 = require("./TimelineWidthProvider");
|
|
16
|
+
const pointerDragThreshold = 3;
|
|
17
|
+
const isKeyframeSelection = (selection) => selection.type === 'keyframe';
|
|
18
|
+
const getCodeValueForTarget = ({ codeValues, nodePath, }) => codeValues[remotion_1.Internals.makeSequencePropsSubscriptionKey(nodePath)];
|
|
19
|
+
const getTimelineKeyframeDragTarget = ({ codeValues, displayFrame, nodePathInfo, overrideIdsToNodePaths, sequences, }) => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
const field = (0, parse_keyframe_field_from_node_path_1.parseKeyframeFieldFromNodePath)(nodePathInfo.auxiliaryKeys);
|
|
22
|
+
if (field === null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const track = (0, find_track_for_node_path_info_1.findTrackForNodePathInfo)({
|
|
26
|
+
sequences,
|
|
27
|
+
overrideIdsToNodePaths,
|
|
28
|
+
nodePathInfo,
|
|
29
|
+
});
|
|
30
|
+
const sequence = (_a = track === null || track === void 0 ? void 0 : track.sequence) !== null && _a !== void 0 ? _a : null;
|
|
31
|
+
if (!(sequence === null || sequence === void 0 ? void 0 : sequence.controls)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const sourceFrame = displayFrame - ((_b = track === null || track === void 0 ? void 0 : track.keyframeDisplayOffset) !== null && _b !== void 0 ? _b : 0);
|
|
35
|
+
const nodePath = nodePathInfo.sequenceSubscriptionKey;
|
|
36
|
+
const fileName = nodePath.absolutePath;
|
|
37
|
+
const sequenceStatus = getCodeValueForTarget({ codeValues, nodePath });
|
|
38
|
+
if (!(sequenceStatus === null || sequenceStatus === void 0 ? void 0 : sequenceStatus.canUpdate)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (field.type === 'effect') {
|
|
42
|
+
const effect = sequence.effects[field.effectIndex];
|
|
43
|
+
const effectStatus = sequenceStatus.effects.find((candidate) => candidate.effectIndex === field.effectIndex);
|
|
44
|
+
if (!effect || !(effectStatus === null || effectStatus === void 0 ? void 0 : effectStatus.canUpdate)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const effectPropStatus = effectStatus.props[field.fieldKey];
|
|
48
|
+
if ((effectPropStatus === null || effectPropStatus === void 0 ? void 0 : effectPropStatus.status) !== 'keyframed') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (!effectPropStatus.keyframes.some((keyframe) => keyframe.frame === sourceFrame)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
type: 'effect',
|
|
56
|
+
displayFrame,
|
|
57
|
+
effectIndex: field.effectIndex,
|
|
58
|
+
fieldKey: field.fieldKey,
|
|
59
|
+
fileName,
|
|
60
|
+
nodePath,
|
|
61
|
+
nodePathInfo,
|
|
62
|
+
propStatus: effectPropStatus,
|
|
63
|
+
schema: effect.schema,
|
|
64
|
+
sourceFrame,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const sequencePropStatus = sequenceStatus.props[field.fieldKey];
|
|
68
|
+
if ((sequencePropStatus === null || sequencePropStatus === void 0 ? void 0 : sequencePropStatus.status) !== 'keyframed') {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
if (!sequencePropStatus.keyframes.some((keyframe) => keyframe.frame === sourceFrame)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
type: 'sequence',
|
|
76
|
+
displayFrame,
|
|
77
|
+
fieldKey: field.fieldKey,
|
|
78
|
+
fileName,
|
|
79
|
+
nodePath,
|
|
80
|
+
nodePathInfo,
|
|
81
|
+
propStatus: sequencePropStatus,
|
|
82
|
+
schema: sequence.controls.schema,
|
|
83
|
+
sourceFrame,
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
const getTargetGroupKey = (target) => {
|
|
87
|
+
return JSON.stringify({
|
|
88
|
+
type: target.type,
|
|
89
|
+
nodePath: target.nodePath,
|
|
90
|
+
effectIndex: target.type === 'effect' ? target.effectIndex : null,
|
|
91
|
+
fieldKey: target.fieldKey,
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const groupTargets = (targets) => {
|
|
95
|
+
var _a;
|
|
96
|
+
const groups = new Map();
|
|
97
|
+
for (const target of targets) {
|
|
98
|
+
const key = getTargetGroupKey(target);
|
|
99
|
+
const group = (_a = groups.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
100
|
+
group.push(target);
|
|
101
|
+
groups.set(key, group);
|
|
102
|
+
}
|
|
103
|
+
return [...groups.values()];
|
|
104
|
+
};
|
|
105
|
+
const getMovesForGroup = ({ group, delta, }) => group.map((target) => ({
|
|
106
|
+
fromFrame: target.sourceFrame,
|
|
107
|
+
toFrame: target.sourceFrame + delta,
|
|
108
|
+
}));
|
|
109
|
+
const canMoveTimelineKeyframeDragTargets = ({ targets, delta, }) => groupTargets(targets).every((group) => {
|
|
110
|
+
const [first] = group;
|
|
111
|
+
if (!first) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return (0, studio_shared_1.canMoveKeyframesWithoutCollisions)({
|
|
115
|
+
status: first.propStatus,
|
|
116
|
+
moves: getMovesForGroup({ group, delta }),
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
const makeMovedKeyframedDragOverride = ({ group, delta, }) => {
|
|
120
|
+
const [first] = group;
|
|
121
|
+
if (!first) {
|
|
122
|
+
throw new Error('Expected a keyframe drag target');
|
|
123
|
+
}
|
|
124
|
+
const moves = new Map(getMovesForGroup({ group, delta }).map((move) => [move.fromFrame, move.toFrame]));
|
|
125
|
+
return {
|
|
126
|
+
type: 'keyframed',
|
|
127
|
+
status: {
|
|
128
|
+
...first.propStatus,
|
|
129
|
+
keyframes: first.propStatus.keyframes
|
|
130
|
+
.map((keyframe) => {
|
|
131
|
+
var _a;
|
|
132
|
+
return ({
|
|
133
|
+
...keyframe,
|
|
134
|
+
frame: (_a = moves.get(keyframe.frame)) !== null && _a !== void 0 ? _a : keyframe.frame,
|
|
135
|
+
});
|
|
136
|
+
})
|
|
137
|
+
.sort((a, b) => a.frame - b.frame),
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
const applyDragOverrides = ({ delta, setDragOverrides, setEffectDragOverrides, targets, }) => {
|
|
142
|
+
for (const group of groupTargets(targets)) {
|
|
143
|
+
const [first] = group;
|
|
144
|
+
if (!first) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const override = makeMovedKeyframedDragOverride({ group, delta });
|
|
148
|
+
if (first.type === 'sequence') {
|
|
149
|
+
setDragOverrides(first.nodePath, first.fieldKey, override);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
setEffectDragOverrides(first.nodePath, first.effectIndex, first.fieldKey, override);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const clearDragOverridesForTargets = ({ clearDragOverrides, clearEffectDragOverrides, targets, }) => {
|
|
156
|
+
const clearedSequences = new Set();
|
|
157
|
+
const clearedEffects = new Set();
|
|
158
|
+
for (const target of targets) {
|
|
159
|
+
if (target.type === 'sequence') {
|
|
160
|
+
const sequenceKey = JSON.stringify(target.nodePath);
|
|
161
|
+
if (clearedSequences.has(sequenceKey)) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
clearedSequences.add(sequenceKey);
|
|
165
|
+
clearDragOverrides(target.nodePath);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const effectKey = JSON.stringify({
|
|
169
|
+
nodePath: target.nodePath,
|
|
170
|
+
effectIndex: target.effectIndex,
|
|
171
|
+
});
|
|
172
|
+
if (clearedEffects.has(effectKey)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
clearedEffects.add(effectKey);
|
|
176
|
+
clearEffectDragOverrides(target.nodePath, target.effectIndex);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const getFrameDelta = ({ clientXDelta, durationInFrames, timelineWidth, }) => {
|
|
180
|
+
const timelineContentWidth = timelineWidth - timeline_layout_1.TIMELINE_PADDING * 2;
|
|
181
|
+
if (timelineContentWidth <= 0) {
|
|
182
|
+
return 0;
|
|
183
|
+
}
|
|
184
|
+
return Math.round((clientXDelta / timelineContentWidth) * durationInFrames);
|
|
185
|
+
};
|
|
186
|
+
const useTimelineKeyframeDrag = ({ frame, nodePathInfo, onSelect, selectable, selected, }) => {
|
|
187
|
+
const videoConfig = (0, remotion_1.useVideoConfig)();
|
|
188
|
+
const timelineWidth = (0, react_1.useContext)(TimelineWidthProvider_1.TimelineWidthContext);
|
|
189
|
+
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
190
|
+
const { sequences } = (0, react_1.useContext)(remotion_1.Internals.SequenceManager);
|
|
191
|
+
const { overrideIdToNodePathMappings } = (0, react_1.useContext)(remotion_1.Internals.OverrideIdsToNodePathsGettersContext);
|
|
192
|
+
const { codeValues } = (0, react_1.useContext)(remotion_1.Internals.VisualModeCodeValuesContext);
|
|
193
|
+
const { clearDragOverrides, clearEffectDragOverrides, setCodeValues, setDragOverrides, setEffectDragOverrides, } = (0, react_1.useContext)(remotion_1.Internals.VisualModeSettersContext);
|
|
194
|
+
const currentSelection = (0, TimelineSelection_1.useCurrentTimelineSelectionStateAsRef)();
|
|
195
|
+
const { clearDraggedKeyframes, setDraggedKeyframes } = (0, TimelineKeyframeDragState_1.useTimelineKeyframeDragState)();
|
|
196
|
+
return (0, react_1.useCallback)((e) => {
|
|
197
|
+
if (e.button !== 0 ||
|
|
198
|
+
!selectable ||
|
|
199
|
+
timelineWidth === null ||
|
|
200
|
+
previewServerState.type !== 'connected') {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
e.preventDefault();
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
const interaction = {
|
|
206
|
+
shiftKey: e.shiftKey,
|
|
207
|
+
toggleKey: e.metaKey || e.ctrlKey,
|
|
208
|
+
};
|
|
209
|
+
const shouldDragExistingSelection = selected && !interaction.shiftKey && !interaction.toggleKey;
|
|
210
|
+
if (!shouldDragExistingSelection) {
|
|
211
|
+
onSelect(interaction);
|
|
212
|
+
}
|
|
213
|
+
const clickedSelection = {
|
|
214
|
+
type: 'keyframe',
|
|
215
|
+
nodePathInfo,
|
|
216
|
+
frame,
|
|
217
|
+
};
|
|
218
|
+
const selectedKeyframes = currentSelection.current.selectedItems.filter(isKeyframeSelection);
|
|
219
|
+
const keyframesToDrag = shouldDragExistingSelection && selectedKeyframes.length > 0
|
|
220
|
+
? selectedKeyframes
|
|
221
|
+
: [clickedSelection];
|
|
222
|
+
const startClientX = e.clientX;
|
|
223
|
+
let dragTargets = null;
|
|
224
|
+
let hasDragged = false;
|
|
225
|
+
let lastDelta = 0;
|
|
226
|
+
const resolveDragTargets = () => {
|
|
227
|
+
if (dragTargets !== null) {
|
|
228
|
+
return dragTargets;
|
|
229
|
+
}
|
|
230
|
+
dragTargets = keyframesToDrag
|
|
231
|
+
.map((keyframe) => getTimelineKeyframeDragTarget({
|
|
232
|
+
codeValues,
|
|
233
|
+
displayFrame: keyframe.frame,
|
|
234
|
+
nodePathInfo: keyframe.nodePathInfo,
|
|
235
|
+
overrideIdsToNodePaths: overrideIdToNodePathMappings,
|
|
236
|
+
sequences,
|
|
237
|
+
}))
|
|
238
|
+
.filter((target) => target !== null);
|
|
239
|
+
return dragTargets;
|
|
240
|
+
};
|
|
241
|
+
const cleanup = () => {
|
|
242
|
+
window.removeEventListener('pointermove', onPointerMove);
|
|
243
|
+
window.removeEventListener('pointerup', onPointerUp);
|
|
244
|
+
window.removeEventListener('pointercancel', onPointerCancel);
|
|
245
|
+
};
|
|
246
|
+
const clearActiveOverrides = () => {
|
|
247
|
+
const targets = dragTargets;
|
|
248
|
+
if (targets === null) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
clearDragOverridesForTargets({
|
|
252
|
+
clearDragOverrides,
|
|
253
|
+
clearEffectDragOverrides,
|
|
254
|
+
targets,
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
const onPointerMove = (event) => {
|
|
258
|
+
const clientXDelta = event.clientX - startClientX;
|
|
259
|
+
if (!hasDragged && Math.abs(clientXDelta) < pointerDragThreshold) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const targets = resolveDragTargets();
|
|
263
|
+
if (targets.length === 0) {
|
|
264
|
+
cleanup();
|
|
265
|
+
clearDraggedKeyframes();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const rawDelta = getFrameDelta({
|
|
269
|
+
clientXDelta,
|
|
270
|
+
durationInFrames: videoConfig.durationInFrames,
|
|
271
|
+
timelineWidth,
|
|
272
|
+
});
|
|
273
|
+
const delta = (0, get_bounded_keyframe_drag_delta_1.getBoundedKeyframeDragDelta)({
|
|
274
|
+
delta: rawDelta,
|
|
275
|
+
durationInFrames: videoConfig.durationInFrames,
|
|
276
|
+
targets,
|
|
277
|
+
});
|
|
278
|
+
if (hasDragged && delta === lastDelta) {
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
hasDragged = true;
|
|
282
|
+
lastDelta = delta;
|
|
283
|
+
if (!canMoveTimelineKeyframeDragTargets({ targets, delta })) {
|
|
284
|
+
clearActiveOverrides();
|
|
285
|
+
clearDraggedKeyframes();
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
setDraggedKeyframes(targets.map((target) => ({
|
|
289
|
+
nodePathInfo: target.nodePathInfo,
|
|
290
|
+
frame: target.displayFrame + delta,
|
|
291
|
+
})));
|
|
292
|
+
applyDragOverrides({
|
|
293
|
+
delta,
|
|
294
|
+
setDragOverrides,
|
|
295
|
+
setEffectDragOverrides,
|
|
296
|
+
targets,
|
|
297
|
+
});
|
|
298
|
+
};
|
|
299
|
+
const onPointerUp = () => {
|
|
300
|
+
cleanup();
|
|
301
|
+
const targets = dragTargets;
|
|
302
|
+
if (!hasDragged || lastDelta === 0 || targets === null) {
|
|
303
|
+
clearActiveOverrides();
|
|
304
|
+
clearDraggedKeyframes();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
if (!canMoveTimelineKeyframeDragTargets({
|
|
308
|
+
targets,
|
|
309
|
+
delta: lastDelta,
|
|
310
|
+
})) {
|
|
311
|
+
clearActiveOverrides();
|
|
312
|
+
clearDraggedKeyframes();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
currentSelection.current.selectItems(targets.map((target) => ({
|
|
316
|
+
type: 'keyframe',
|
|
317
|
+
nodePathInfo: target.nodePathInfo,
|
|
318
|
+
frame: target.displayFrame + lastDelta,
|
|
319
|
+
})));
|
|
320
|
+
clearActiveOverrides();
|
|
321
|
+
clearDraggedKeyframes();
|
|
322
|
+
(0, call_move_keyframe_1.callMoveKeyframes)({
|
|
323
|
+
sequenceKeyframes: targets
|
|
324
|
+
.filter((target) => target.type === 'sequence')
|
|
325
|
+
.map((target) => ({
|
|
326
|
+
fileName: target.fileName,
|
|
327
|
+
nodePath: target.nodePath,
|
|
328
|
+
fieldKey: target.fieldKey,
|
|
329
|
+
fromFrame: target.sourceFrame,
|
|
330
|
+
toFrame: target.sourceFrame + lastDelta,
|
|
331
|
+
schema: target.schema,
|
|
332
|
+
})),
|
|
333
|
+
effectKeyframes: targets
|
|
334
|
+
.filter((target) => target.type === 'effect')
|
|
335
|
+
.map((target) => ({
|
|
336
|
+
fileName: target.fileName,
|
|
337
|
+
nodePath: target.nodePath,
|
|
338
|
+
effectIndex: target.effectIndex,
|
|
339
|
+
fieldKey: target.fieldKey,
|
|
340
|
+
fromFrame: target.sourceFrame,
|
|
341
|
+
toFrame: target.sourceFrame + lastDelta,
|
|
342
|
+
schema: target.schema,
|
|
343
|
+
})),
|
|
344
|
+
setCodeValues,
|
|
345
|
+
clientId: previewServerState.clientId,
|
|
346
|
+
}).catch(() => undefined);
|
|
347
|
+
};
|
|
348
|
+
const onPointerCancel = () => {
|
|
349
|
+
cleanup();
|
|
350
|
+
clearActiveOverrides();
|
|
351
|
+
clearDraggedKeyframes();
|
|
352
|
+
};
|
|
353
|
+
window.addEventListener('pointermove', onPointerMove);
|
|
354
|
+
window.addEventListener('pointerup', onPointerUp);
|
|
355
|
+
window.addEventListener('pointercancel', onPointerCancel);
|
|
356
|
+
}, [
|
|
357
|
+
clearDragOverrides,
|
|
358
|
+
clearEffectDragOverrides,
|
|
359
|
+
clearDraggedKeyframes,
|
|
360
|
+
codeValues,
|
|
361
|
+
currentSelection,
|
|
362
|
+
frame,
|
|
363
|
+
nodePathInfo,
|
|
364
|
+
onSelect,
|
|
365
|
+
overrideIdToNodePathMappings,
|
|
366
|
+
previewServerState,
|
|
367
|
+
selectable,
|
|
368
|
+
selected,
|
|
369
|
+
sequences,
|
|
370
|
+
setCodeValues,
|
|
371
|
+
setDragOverrides,
|
|
372
|
+
setDraggedKeyframes,
|
|
373
|
+
setEffectDragOverrides,
|
|
374
|
+
timelineWidth,
|
|
375
|
+
videoConfig.durationInFrames,
|
|
376
|
+
]);
|
|
377
|
+
};
|
|
378
|
+
exports.useTimelineKeyframeDrag = useTimelineKeyframeDrag;
|
|
@@ -3,6 +3,6 @@ export declare const useResponsiveSidebarStatus: () => "collapsed" | "expanded";
|
|
|
3
3
|
export declare const TopPanel: React.NamedExoticComponent<{
|
|
4
4
|
readonly readOnlyStudio: boolean;
|
|
5
5
|
readonly onMounted: () => void;
|
|
6
|
-
readonly drawRef: React.
|
|
6
|
+
readonly drawRef: React.Ref<HTMLDivElement>;
|
|
7
7
|
readonly bufferStateDelayInMilliseconds: number;
|
|
8
8
|
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SetStateAction } from 'react';
|
|
2
|
+
import type { ResolvedStackLocation } from 'remotion';
|
|
3
|
+
import type { ModalState } from '../state/modals';
|
|
4
|
+
import type { ComboboxValue } from './NewComposition/ComboBox';
|
|
5
|
+
export declare const getFolderMenuItems: ({ closeMenu, connectionStatus, folder, readOnlyStudio, resolvedLocation, setSelectedModal, }: {
|
|
6
|
+
closeMenu: () => void;
|
|
7
|
+
connectionStatus: "connected" | "disconnected" | "init";
|
|
8
|
+
folder: import("remotion").TFolder;
|
|
9
|
+
readOnlyStudio: boolean;
|
|
10
|
+
resolvedLocation: ResolvedStackLocation | null;
|
|
11
|
+
setSelectedModal: (value: SetStateAction<ModalState | null>) => void;
|
|
12
|
+
}) => ComboboxValue[];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFolderMenuItems = void 0;
|
|
4
|
+
const no_react_1 = require("remotion/no-react");
|
|
5
|
+
const format_file_location_1 = require("../helpers/format-file-location");
|
|
6
|
+
const get_folder_id_1 = require("../helpers/get-folder-id");
|
|
7
|
+
const open_in_editor_1 = require("../helpers/open-in-editor");
|
|
8
|
+
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
9
|
+
const getFolderMenuItems = ({ closeMenu, connectionStatus, folder, readOnlyStudio, resolvedLocation, setSelectedModal, }) => {
|
|
10
|
+
const editorName = window.remotion_editorName;
|
|
11
|
+
const folderId = (0, get_folder_id_1.getFolderId)({
|
|
12
|
+
folderName: folder.name,
|
|
13
|
+
parentName: folder.parent,
|
|
14
|
+
});
|
|
15
|
+
const fileLocation = (0, format_file_location_1.formatFileLocation)({
|
|
16
|
+
location: resolvedLocation,
|
|
17
|
+
root: window.remotion_cwd,
|
|
18
|
+
});
|
|
19
|
+
const showInEditorDisabled = connectionStatus !== 'connected' || !resolvedLocation;
|
|
20
|
+
const copyFileLocationDisabled = !fileLocation;
|
|
21
|
+
const codemodDisabled = readOnlyStudio || !folder.stack;
|
|
22
|
+
return [
|
|
23
|
+
editorName
|
|
24
|
+
? {
|
|
25
|
+
id: 'show-folder-in-editor',
|
|
26
|
+
keyHint: null,
|
|
27
|
+
label: `Show folder in ${editorName}`,
|
|
28
|
+
leftItem: null,
|
|
29
|
+
onClick: async () => {
|
|
30
|
+
closeMenu();
|
|
31
|
+
if (!resolvedLocation) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
await (0, open_in_editor_1.openOriginalPositionInEditor)(resolvedLocation);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
(0, NotificationCenter_1.showNotification)(err.message, 2000);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
quickSwitcherLabel: `Show folder in ${editorName}`,
|
|
42
|
+
subMenu: null,
|
|
43
|
+
type: 'item',
|
|
44
|
+
value: 'show-folder-in-editor',
|
|
45
|
+
disabled: showInEditorDisabled,
|
|
46
|
+
}
|
|
47
|
+
: null,
|
|
48
|
+
{
|
|
49
|
+
id: 'copy-folder-file-location',
|
|
50
|
+
keyHint: null,
|
|
51
|
+
label: `Copy file location`,
|
|
52
|
+
leftItem: null,
|
|
53
|
+
onClick: () => {
|
|
54
|
+
closeMenu();
|
|
55
|
+
if (!fileLocation) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
navigator.clipboard
|
|
59
|
+
.writeText(fileLocation)
|
|
60
|
+
.then(() => {
|
|
61
|
+
(0, NotificationCenter_1.showNotification)('Copied file location to clipboard', 1000);
|
|
62
|
+
})
|
|
63
|
+
.catch((err) => {
|
|
64
|
+
(0, NotificationCenter_1.showNotification)(`Could not copy to clipboard: ${err.message}`, 1000);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
quickSwitcherLabel: 'Copy folder file location',
|
|
68
|
+
subMenu: null,
|
|
69
|
+
type: 'item',
|
|
70
|
+
value: 'copy-folder-file-location',
|
|
71
|
+
disabled: copyFileLocationDisabled,
|
|
72
|
+
},
|
|
73
|
+
editorName || fileLocation
|
|
74
|
+
? {
|
|
75
|
+
type: 'divider',
|
|
76
|
+
id: 'show-folder-in-editor-divider',
|
|
77
|
+
}
|
|
78
|
+
: null,
|
|
79
|
+
{
|
|
80
|
+
id: 'rename-folder',
|
|
81
|
+
keyHint: null,
|
|
82
|
+
label: `Rename...`,
|
|
83
|
+
leftItem: null,
|
|
84
|
+
onClick: () => {
|
|
85
|
+
closeMenu();
|
|
86
|
+
setSelectedModal({
|
|
87
|
+
type: 'rename-folder',
|
|
88
|
+
folderName: folder.name,
|
|
89
|
+
parentName: folder.parent,
|
|
90
|
+
stack: folder.stack,
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
quickSwitcherLabel: 'Rename folder...',
|
|
94
|
+
subMenu: null,
|
|
95
|
+
type: 'item',
|
|
96
|
+
value: 'rename-folder',
|
|
97
|
+
disabled: codemodDisabled,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: 'delete-folder',
|
|
101
|
+
keyHint: null,
|
|
102
|
+
label: `Delete...`,
|
|
103
|
+
leftItem: null,
|
|
104
|
+
onClick: () => {
|
|
105
|
+
closeMenu();
|
|
106
|
+
setSelectedModal({
|
|
107
|
+
type: 'delete-folder',
|
|
108
|
+
folderName: folder.name,
|
|
109
|
+
parentName: folder.parent,
|
|
110
|
+
stack: folder.stack,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
quickSwitcherLabel: 'Delete folder...',
|
|
114
|
+
subMenu: null,
|
|
115
|
+
type: 'item',
|
|
116
|
+
value: 'delete-folder',
|
|
117
|
+
disabled: codemodDisabled,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
type: 'divider',
|
|
121
|
+
id: 'copy-folder-id-divider',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'copy-folder-id',
|
|
125
|
+
keyHint: null,
|
|
126
|
+
label: `Copy ID`,
|
|
127
|
+
leftItem: null,
|
|
128
|
+
onClick: () => {
|
|
129
|
+
closeMenu();
|
|
130
|
+
navigator.clipboard
|
|
131
|
+
.writeText(folderId)
|
|
132
|
+
.then(() => {
|
|
133
|
+
(0, NotificationCenter_1.showNotification)('Copied to clipboard', 1000);
|
|
134
|
+
})
|
|
135
|
+
.catch((err) => {
|
|
136
|
+
(0, NotificationCenter_1.showNotification)(`Could not copy to clipboard: ${err.message}`, 1000);
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
quickSwitcherLabel: 'Copy folder ID',
|
|
140
|
+
subMenu: null,
|
|
141
|
+
type: 'item',
|
|
142
|
+
value: 'copy-folder-id',
|
|
143
|
+
disabled: false,
|
|
144
|
+
},
|
|
145
|
+
].filter(no_react_1.NoReactInternals.truthy);
|
|
146
|
+
};
|
|
147
|
+
exports.getFolderMenuItems = getFolderMenuItems;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type FileType, type InsertableCompositionElement } from '@remotion/studio-shared';
|
|
2
|
+
export declare const getAssetElement: ({ fileType, src, }: {
|
|
3
|
+
fileType: FileType;
|
|
4
|
+
src: string;
|
|
5
|
+
}) => InsertableCompositionElement | null;
|
|
6
|
+
export declare const getAssetElementFromPath: (assetPath: string) => InsertableCompositionElement | null;
|
|
7
|
+
export declare const pickFilesToImport: () => Promise<File[]>;
|
|
8
|
+
export declare const importAssets: ({ compositionFile, compositionId, files, }: {
|
|
9
|
+
compositionFile: string;
|
|
10
|
+
compositionId: string;
|
|
11
|
+
files: File[];
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
export declare const importRemoteAsset: ({ compositionFile, compositionId, url, }: {
|
|
14
|
+
compositionFile: string;
|
|
15
|
+
compositionId: string;
|
|
16
|
+
url: string;
|
|
17
|
+
}) => Promise<void>;
|
|
18
|
+
export declare const insertExistingAssets: ({ assetPaths, compositionFile, compositionId, }: {
|
|
19
|
+
assetPaths: string[];
|
|
20
|
+
compositionFile: string;
|
|
21
|
+
compositionId: string;
|
|
22
|
+
}) => Promise<void>;
|