@remotion/studio 4.0.468 → 4.0.470
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/Studio.js +1 -1
- package/dist/api/save-render-output.js +3 -12
- package/dist/components/AudioWaveform.d.ts +1 -0
- package/dist/components/AudioWaveform.js +41 -23
- package/dist/components/CompositionSelectorItem.js +1 -1
- package/dist/components/ContextMenu.d.ts +1 -0
- package/dist/components/ContextMenu.js +8 -3
- package/dist/components/EditorContent.js +5 -4
- package/dist/components/EditorGuides/Guide.js +1 -1
- package/dist/components/ExpandedTracksProvider.js +3 -8
- package/dist/components/Menu/MenuItem.d.ts +1 -1
- package/dist/components/Menu/MenuItem.js +2 -2
- package/dist/components/Menu/MenuSubItem.js +5 -5
- package/dist/components/MenuBuildIndicator.js +0 -1
- package/dist/components/NewComposition/InputDragger.js +1 -0
- package/dist/components/Preview.js +4 -1
- package/dist/components/PreviewToolbar.js +2 -4
- package/dist/components/SelectedOutlineOverlay.d.ts +18 -0
- package/dist/components/SelectedOutlineOverlay.js +645 -0
- package/dist/components/Timeline/Timeline.js +18 -3
- package/dist/components/Timeline/TimelineDeleteKeybindings.d.ts +2 -0
- package/dist/components/Timeline/TimelineDeleteKeybindings.js +86 -0
- package/dist/components/Timeline/TimelineDragHandler.js +19 -244
- package/dist/components/Timeline/{TimelineEffectGroupRow.d.ts → TimelineEffectItem.d.ts} +1 -1
- package/dist/components/Timeline/{TimelineEffectGroupRow.js → TimelineEffectItem.js} +61 -35
- package/dist/components/Timeline/{TimelineEffectFieldRow.d.ts → TimelineEffectPropItem.d.ts} +4 -1
- package/dist/components/Timeline/{TimelineEffectFieldRow.js → TimelineEffectPropItem.js} +100 -16
- package/dist/components/Timeline/TimelineExpandArrowButton.js +5 -1
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.d.ts +11 -0
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +55 -0
- package/dist/components/Timeline/TimelineExpandedRow.d.ts +1 -0
- package/dist/components/Timeline/TimelineExpandedRow.js +29 -11
- package/dist/components/Timeline/TimelineExpandedSection.d.ts +1 -0
- package/dist/components/Timeline/TimelineExpandedSection.js +4 -4
- package/dist/components/Timeline/TimelineExpandedTrackKeyframes.d.ts +1 -1
- package/dist/components/Timeline/TimelineExpandedTrackKeyframes.js +9 -120
- package/dist/components/Timeline/TimelineFieldLabel.d.ts +6 -0
- package/dist/components/Timeline/TimelineFieldLabel.js +30 -0
- package/dist/components/Timeline/TimelineInOutDragHandler.d.ts +2 -0
- package/dist/components/Timeline/TimelineInOutDragHandler.js +324 -0
- package/dist/components/Timeline/TimelineInOutPointer.js +3 -1
- package/dist/components/Timeline/TimelineInOutPointerHandle.d.ts +1 -0
- package/dist/components/Timeline/TimelineInOutPointerHandle.js +5 -4
- package/dist/components/Timeline/TimelineItemStack.d.ts +5 -0
- package/dist/components/Timeline/TimelineItemStack.js +82 -0
- package/dist/components/Timeline/TimelineKeyframeControls.d.ts +17 -0
- package/dist/components/Timeline/TimelineKeyframeControls.js +217 -0
- package/dist/components/Timeline/TimelineKeyframeDiamond.d.ts +7 -0
- package/dist/components/Timeline/TimelineKeyframeDiamond.js +88 -0
- package/dist/components/Timeline/TimelineKeyframedValue.d.ts +8 -0
- package/dist/components/Timeline/TimelineKeyframedValue.js +36 -0
- package/dist/components/Timeline/TimelineLayerEye.js +1 -0
- package/dist/components/Timeline/TimelineList.js +3 -11
- package/dist/components/Timeline/TimelineMediaInfo.d.ts +13 -1
- package/dist/components/Timeline/TimelineMediaInfo.js +33 -80
- package/dist/components/Timeline/TimelineRowChrome.d.ts +10 -1
- package/dist/components/Timeline/TimelineRowChrome.js +64 -6
- package/dist/components/Timeline/TimelineSchemaField.js +7 -2
- package/dist/components/Timeline/TimelineSelection.d.ts +85 -0
- package/dist/components/Timeline/TimelineSelection.js +417 -0
- package/dist/components/Timeline/TimelineSequence.d.ts +2 -0
- package/dist/components/Timeline/TimelineSequence.js +18 -6
- package/dist/components/Timeline/TimelineSequenceFrame.js +1 -0
- package/dist/components/Timeline/{TimelineListItem.d.ts → TimelineSequenceItem.d.ts} +2 -2
- package/dist/components/Timeline/{TimelineListItem.js → TimelineSequenceItem.js} +148 -63
- package/dist/components/Timeline/TimelineSequenceName.d.ts +7 -0
- package/dist/components/Timeline/TimelineSequenceName.js +50 -0
- package/dist/components/Timeline/{TimelineFieldRow.d.ts → TimelineSequencePropItem.d.ts} +5 -3
- package/dist/components/Timeline/TimelineSequencePropItem.js +183 -0
- package/dist/components/Timeline/TimelineTimeIndicators.js +0 -1
- package/dist/components/Timeline/TimelineTrack.d.ts +5 -0
- package/dist/components/Timeline/TimelineTrack.js +66 -0
- package/dist/components/Timeline/TimelineTracks.js +2 -16
- package/dist/components/Timeline/TimelineTranslateField.js +14 -22
- package/dist/components/Timeline/TimelineUvCoordinateField.d.ts +11 -0
- package/dist/components/Timeline/TimelineUvCoordinateField.js +126 -0
- package/dist/components/Timeline/TimelineVideoInfo.js +11 -12
- package/dist/components/Timeline/call-add-keyframe.d.ts +23 -0
- package/dist/components/Timeline/call-add-keyframe.js +54 -0
- package/dist/components/Timeline/call-delete-keyframe.d.ts +21 -0
- package/dist/components/Timeline/call-delete-keyframe.js +50 -0
- package/dist/components/Timeline/delete-selected-keyframe.d.ts +11 -0
- package/dist/components/Timeline/delete-selected-keyframe.js +51 -0
- package/dist/components/Timeline/delete-selected-timeline-item.d.ts +17 -0
- package/dist/components/Timeline/delete-selected-timeline-item.js +183 -0
- package/dist/components/Timeline/duplicate-selected-timeline-item.d.ts +13 -0
- package/dist/components/Timeline/duplicate-selected-timeline-item.js +66 -0
- package/dist/components/Timeline/find-track-for-node-path-info.d.ts +7 -0
- package/dist/components/Timeline/find-track-for-node-path-info.js +13 -0
- package/dist/components/Timeline/get-keyframe-navigation.d.ts +9 -0
- package/dist/components/Timeline/get-keyframe-navigation.js +26 -0
- package/dist/components/Timeline/get-node-keyframes.d.ts +11 -0
- package/dist/components/Timeline/get-node-keyframes.js +23 -0
- package/dist/components/Timeline/get-timeline-keyframes.js +6 -8
- package/dist/components/Timeline/parse-keyframe-field-from-node-path.d.ts +8 -0
- package/dist/components/Timeline/parse-keyframe-field-from-node-path.js +26 -0
- package/dist/components/Timeline/save-sequence-prop.d.ts +14 -2
- package/dist/components/Timeline/save-sequence-prop.js +42 -7
- package/dist/components/Timeline/timeline-field-row-layout.d.ts +1 -0
- package/dist/components/Timeline/timeline-field-row-layout.js +11 -1
- package/dist/components/Timeline/timeline-row-layout.d.ts +1 -0
- package/dist/components/Timeline/timeline-row-layout.js +2 -1
- package/dist/components/Timeline/timeline-translate-utils.d.ts +2 -0
- package/dist/components/Timeline/timeline-translate-utils.js +20 -0
- package/dist/components/Timeline/use-expanded-track-keyframe-rows.d.ts +17 -0
- package/dist/components/Timeline/use-expanded-track-keyframe-rows.js +52 -0
- package/dist/components/Timeline/use-open-sequence-in-editor.d.ts +6 -0
- package/dist/components/Timeline/use-open-sequence-in-editor.js +31 -0
- package/dist/components/composition-menu-items.js +32 -1
- package/dist/error-overlay/remotion-overlay/OpenInEditor.js +0 -1
- package/dist/esm/{chunk-8q828zk7.js → chunk-dny42qnq.js} +10566 -6221
- package/dist/esm/internals.mjs +10566 -6221
- package/dist/esm/previewEntry.mjs +10548 -6203
- package/dist/esm/renderEntry.mjs +3 -1
- package/dist/helpers/colors.d.ts +1 -1
- package/dist/helpers/colors.js +1 -1
- package/dist/helpers/format-file-location.d.ts +9 -0
- package/dist/helpers/format-file-location.js +27 -0
- package/dist/helpers/get-box-quads-polyfill-internals.d.ts +82 -0
- package/dist/helpers/get-box-quads-polyfill-internals.js +2395 -0
- package/dist/helpers/get-box-quads-ponyfill.d.ts +10 -0
- package/dist/helpers/get-box-quads-ponyfill.js +23 -0
- package/dist/helpers/open-in-editor.d.ts +1 -1
- package/dist/helpers/open-in-editor.js +11 -26
- package/dist/helpers/timeline-layout.d.ts +8 -7
- package/dist/helpers/timeline-layout.js +9 -8
- package/dist/helpers/timeline-node-path-key.d.ts +2 -0
- package/dist/helpers/timeline-node-path-key.js +10 -0
- package/dist/helpers/use-menu-structure.js +8 -16
- package/dist/renderEntry.js +2 -2
- package/package.json +10 -10
- package/dist/components/Timeline/TimelineFieldRow.js +0 -113
- package/dist/components/Timeline/TimelineStack/index.d.ts +0 -8
- package/dist/components/Timeline/TimelineStack/index.js +0 -119
|
@@ -3,19 +3,77 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TimelineRowChrome = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const colors_1 = require("../../helpers/colors");
|
|
6
7
|
const Padder_1 = require("./Padder");
|
|
7
8
|
const timeline_row_layout_1 = require("./timeline-row-layout");
|
|
9
|
+
const TimelineSelection_1 = require("./TimelineSelection");
|
|
8
10
|
const rowBase = {
|
|
11
|
+
alignItems: 'stretch',
|
|
9
12
|
display: 'flex',
|
|
13
|
+
};
|
|
14
|
+
const leftChromeStyle = {
|
|
10
15
|
alignItems: 'center',
|
|
16
|
+
alignSelf: 'stretch',
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flexShrink: 0,
|
|
11
19
|
};
|
|
12
|
-
const
|
|
13
|
-
|
|
20
|
+
const keyframeControlsColumnStyle = {
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexShrink: 0,
|
|
24
|
+
justifyContent: 'flex-start',
|
|
25
|
+
marginRight: -(timeline_row_layout_1.TIMELINE_KEYFRAME_CONTROLS_WIDTH - timeline_row_layout_1.TIMELINE_ROW_BASE_PADDING),
|
|
26
|
+
width: timeline_row_layout_1.TIMELINE_KEYFRAME_CONTROLS_WIDTH,
|
|
27
|
+
};
|
|
28
|
+
const TimelineRowChrome = ({ depth, eye, keyframeControls, arrow, children, style, selected, selectable, onSelect, showSelectedBackground, containsSelection, outerHeight, onDoubleClick, }) => {
|
|
29
|
+
const indentWidth = (0, timeline_row_layout_1.getTimelineRowIndentWidth)(depth);
|
|
30
|
+
const chromeColumnStyle = (0, react_1.useMemo)(() => ({
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
alignSelf: 'stretch',
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexShrink: 0,
|
|
35
|
+
paddingLeft: keyframeControls ? 0 : timeline_row_layout_1.TIMELINE_ROW_BASE_PADDING,
|
|
36
|
+
}), [keyframeControls]);
|
|
37
|
+
const onPointerDown = (0, react_1.useCallback)((e) => {
|
|
38
|
+
if (e.button === 0) {
|
|
39
|
+
e.stopPropagation();
|
|
40
|
+
onSelect({
|
|
41
|
+
shiftKey: e.shiftKey,
|
|
42
|
+
toggleKey: e.metaKey || e.ctrlKey,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [onSelect]);
|
|
46
|
+
const onContextMenu = (0, react_1.useCallback)((e) => {
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
onSelect();
|
|
49
|
+
}, [onSelect]);
|
|
50
|
+
const highlightBackground = showSelectedBackground && (selected || containsSelection)
|
|
51
|
+
? TimelineSelection_1.TIMELINE_SELECTED_BACKGROUND
|
|
52
|
+
: undefined;
|
|
53
|
+
const innerRowStyle = (0, react_1.useMemo)(() => ({
|
|
14
54
|
...rowBase,
|
|
15
|
-
paddingLeft: timeline_row_layout_1.TIMELINE_ROW_BASE_PADDING,
|
|
16
55
|
...style,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
56
|
+
backgroundColor: outerHeight === undefined ? highlightBackground : undefined,
|
|
57
|
+
}), [style, outerHeight, highlightBackground]);
|
|
58
|
+
const outerStyle = (0, react_1.useMemo)(() => {
|
|
59
|
+
if (outerHeight === null) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
height: outerHeight,
|
|
64
|
+
borderBottom: `1px solid ${colors_1.TIMELINE_TRACK_SEPARATOR}`,
|
|
65
|
+
display: 'flex',
|
|
66
|
+
flexDirection: 'column',
|
|
67
|
+
justifyContent: 'center',
|
|
68
|
+
backgroundColor: highlightBackground,
|
|
69
|
+
};
|
|
70
|
+
}, [outerHeight, highlightBackground]);
|
|
71
|
+
const chrome = (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
72
|
+
jsx_runtime_1.jsxs("div", { style: leftChromeStyle, children: [keyframeControls ? (jsx_runtime_1.jsx("div", { style: keyframeControlsColumnStyle, children: keyframeControls })) : null, jsx_runtime_1.jsxs("div", { style: chromeColumnStyle, children: [eye, indentWidth > 0 ? jsx_runtime_1.jsx(Padder_1.Padder, { depth: depth }) : null, arrow] })
|
|
73
|
+
] }), children] }));
|
|
74
|
+
if (outerStyle) {
|
|
75
|
+
return (jsx_runtime_1.jsx("div", { style: outerStyle, onPointerDown: selectable ? onPointerDown : undefined, onContextMenu: selectable ? onContextMenu : undefined, onDoubleClick: onDoubleClick, children: jsx_runtime_1.jsx("div", { style: innerRowStyle, children: chrome }) }));
|
|
76
|
+
}
|
|
77
|
+
return (jsx_runtime_1.jsx("div", { onPointerDown: selectable ? onPointerDown : undefined, onContextMenu: selectable ? onContextMenu : undefined, onDoubleClick: onDoubleClick, style: innerRowStyle, children: chrome }));
|
|
20
78
|
};
|
|
21
79
|
exports.TimelineRowChrome = TimelineRowChrome;
|
|
@@ -9,10 +9,13 @@ const TimelineEnumField_1 = require("./TimelineEnumField");
|
|
|
9
9
|
const TimelineNumberField_1 = require("./TimelineNumberField");
|
|
10
10
|
const TimelineRotationField_1 = require("./TimelineRotationField");
|
|
11
11
|
const TimelineTranslateField_1 = require("./TimelineTranslateField");
|
|
12
|
+
const TimelineUvCoordinateField_1 = require("./TimelineUvCoordinateField");
|
|
12
13
|
const unsupportedLabel = {
|
|
13
14
|
color: 'rgba(255, 255, 255, 0.4)',
|
|
14
15
|
fontSize: 12,
|
|
15
16
|
fontStyle: 'italic',
|
|
17
|
+
userSelect: 'none',
|
|
18
|
+
WebkitUserSelect: 'none',
|
|
16
19
|
};
|
|
17
20
|
const notEditableBackground = {
|
|
18
21
|
backgroundColor: 'rgba(255, 0, 0, 0.2)',
|
|
@@ -30,10 +33,9 @@ const TimelineNonEditableStatus = ({ propStatus }) => {
|
|
|
30
33
|
if (propStatus.canUpdate) {
|
|
31
34
|
return null;
|
|
32
35
|
}
|
|
33
|
-
if (propStatus.reason === 'computed') {
|
|
36
|
+
if (propStatus.reason === 'computed' || propStatus.reason === 'keyframed') {
|
|
34
37
|
return (jsx_runtime_1.jsx("span", { style: unsupportedLabel, children: (0, get_timeline_keyframes_1.getComputedStatusLabel)(propStatus) }));
|
|
35
38
|
}
|
|
36
|
-
throw new Error(`Unsupported prop status: ${propStatus.reason}`);
|
|
37
39
|
};
|
|
38
40
|
exports.TimelineNonEditableStatus = TimelineNonEditableStatus;
|
|
39
41
|
const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propStatus, effectiveValue, }) => {
|
|
@@ -49,6 +51,9 @@ const TimelineFieldValue = ({ field, onSave, onDragValueChange, onDragEnd, propS
|
|
|
49
51
|
if (field.typeName === 'translate') {
|
|
50
52
|
return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineTranslateField_1.TimelineTranslateField, { field: field, effectiveValue: effectiveValue, propStatus: propStatus, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
|
|
51
53
|
}
|
|
54
|
+
if (field.typeName === 'uv-coordinate') {
|
|
55
|
+
return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineUvCoordinateField_1.TimelineUvCoordinateField, { field: field, effectiveValue: effectiveValue, propStatus: propStatus, onSave: onSave, onDragValueChange: onDragValueChange, onDragEnd: onDragEnd }) }));
|
|
56
|
+
}
|
|
52
57
|
if (field.typeName === 'boolean') {
|
|
53
58
|
return (jsx_runtime_1.jsx("span", { style: wrapperStyle, children: jsx_runtime_1.jsx(TimelineBooleanField_1.TimelineBooleanField, { field: field, propStatus: propStatus, onSave: onSave, effectiveValue: effectiveValue }) }));
|
|
54
59
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { type CSSProperties } from 'react';
|
|
2
|
+
import type { SequenceNodePathInfo, TrackWithHash } from '../../helpers/get-timeline-sequence-sort-key';
|
|
3
|
+
export declare const TIMELINE_SELECTED_BACKGROUND = "#3B3F42";
|
|
4
|
+
export declare const TIMELINE_SELECTED_LABEL_BACKGROUND = "#B0B0B0";
|
|
5
|
+
export declare const TIMELINE_SELECTED_LABEL_TEXT = "black";
|
|
6
|
+
export declare const TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING = 2;
|
|
7
|
+
export declare const getTimelineSelectedLabelStyle: (selected: boolean, subcategory: boolean) => CSSProperties;
|
|
8
|
+
export declare const getTimelineColor: (selected: boolean, subcategory: boolean) => "black" | "rgba(255, 255, 255, 0.8)";
|
|
9
|
+
export declare const getTimelineSelectedTrackHighlightStyle: (timelineWidth: number) => CSSProperties;
|
|
10
|
+
export declare const SELECTION_ENABLED = false;
|
|
11
|
+
export declare const TIMELINE_TOP_DRAG = false;
|
|
12
|
+
export declare const ENABLE_OUTLINES = false;
|
|
13
|
+
type TimelineSelectionBase = {
|
|
14
|
+
readonly nodePathInfo: SequenceNodePathInfo;
|
|
15
|
+
};
|
|
16
|
+
export type TimelineSelection = (TimelineSelectionBase & {
|
|
17
|
+
readonly type: 'sequence';
|
|
18
|
+
}) | (TimelineSelectionBase & {
|
|
19
|
+
readonly type: 'sequence-prop';
|
|
20
|
+
readonly key: string;
|
|
21
|
+
}) | (TimelineSelectionBase & {
|
|
22
|
+
readonly type: 'sequence-all-effects';
|
|
23
|
+
}) | (TimelineSelectionBase & {
|
|
24
|
+
readonly type: 'sequence-effect';
|
|
25
|
+
readonly i: number;
|
|
26
|
+
}) | (TimelineSelectionBase & {
|
|
27
|
+
readonly type: 'sequence-effect-prop';
|
|
28
|
+
readonly i: number;
|
|
29
|
+
readonly key: string;
|
|
30
|
+
}) | (TimelineSelectionBase & {
|
|
31
|
+
readonly type: 'keyframe';
|
|
32
|
+
readonly frame: number;
|
|
33
|
+
});
|
|
34
|
+
export type TimelineSelectionInteraction = {
|
|
35
|
+
readonly shiftKey: boolean;
|
|
36
|
+
readonly toggleKey: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare const isTimelineSelectionModifierEvent: ({ shiftKey, metaKey, ctrlKey, }: {
|
|
39
|
+
readonly shiftKey: boolean;
|
|
40
|
+
readonly metaKey: boolean;
|
|
41
|
+
readonly ctrlKey: boolean;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
export type TimelineSelectionState = {
|
|
44
|
+
readonly selectedItems: readonly TimelineSelection[];
|
|
45
|
+
readonly anchor: TimelineSelection | null;
|
|
46
|
+
};
|
|
47
|
+
export declare const getTimelineSelectionAfterInteraction: ({ currentState, clickedItem, interaction, allSelectableItems, }: {
|
|
48
|
+
readonly currentState: TimelineSelectionState;
|
|
49
|
+
readonly clickedItem: TimelineSelection;
|
|
50
|
+
readonly interaction: TimelineSelectionInteraction;
|
|
51
|
+
readonly allSelectableItems: readonly TimelineSelection[];
|
|
52
|
+
}) => TimelineSelectionState;
|
|
53
|
+
type TimelineSelectionContextValue = {
|
|
54
|
+
readonly canSelect: boolean;
|
|
55
|
+
readonly selectedItems: readonly TimelineSelection[];
|
|
56
|
+
readonly isSelected: (item: TimelineSelection) => boolean;
|
|
57
|
+
readonly selectItem: (item: TimelineSelection, interaction?: TimelineSelectionInteraction) => void;
|
|
58
|
+
readonly selectItems: (items: readonly TimelineSelection[]) => void;
|
|
59
|
+
readonly registerSelectableItem: (item: TimelineSelection) => () => void;
|
|
60
|
+
readonly containsSelection: (nodePathInfo: SequenceNodePathInfo) => boolean;
|
|
61
|
+
readonly clearSelection: () => void;
|
|
62
|
+
};
|
|
63
|
+
export declare const getTimelineSelectionFromNodePathInfo: (nodePathInfo: SequenceNodePathInfo | null) => TimelineSelection | null;
|
|
64
|
+
export declare const getSelectableTimelineSequenceSelections: (tracks: readonly Pick<TrackWithHash, "nodePathInfo">[]) => TimelineSelection[];
|
|
65
|
+
export declare const getTimelineSequenceSelectionKey: (nodePathInfo: SequenceNodePathInfo) => string;
|
|
66
|
+
export declare const TimelineSelectAllKeybindings: React.FC<{
|
|
67
|
+
readonly timeline: readonly TrackWithHash[];
|
|
68
|
+
}>;
|
|
69
|
+
export declare const TimelineSelectionProvider: React.FC<{
|
|
70
|
+
readonly children: React.ReactNode;
|
|
71
|
+
}>;
|
|
72
|
+
export declare const useTimelineSelection: () => TimelineSelectionContextValue;
|
|
73
|
+
export declare const useCurrentTimelineSelectionStateAsRef: () => React.RefObject<TimelineSelectionContextValue>;
|
|
74
|
+
export declare const useTimelineRowSelection: (nodePathInfo: SequenceNodePathInfo | null) => {
|
|
75
|
+
onSelect: (interaction?: TimelineSelectionInteraction | undefined) => void;
|
|
76
|
+
selectable: boolean;
|
|
77
|
+
selected: boolean;
|
|
78
|
+
};
|
|
79
|
+
export declare const useTimelineKeyframeSelection: (nodePathInfo: SequenceNodePathInfo, frame: number) => {
|
|
80
|
+
onSelect: (interaction?: TimelineSelectionInteraction | undefined) => void;
|
|
81
|
+
selectable: boolean;
|
|
82
|
+
selected: boolean;
|
|
83
|
+
};
|
|
84
|
+
export declare const useTimelineRowContainsSelection: (nodePathInfo: SequenceNodePathInfo | null) => boolean;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useTimelineRowContainsSelection = exports.useTimelineKeyframeSelection = exports.useTimelineRowSelection = exports.useCurrentTimelineSelectionStateAsRef = exports.useTimelineSelection = exports.TimelineSelectionProvider = exports.TimelineSelectAllKeybindings = exports.getTimelineSequenceSelectionKey = exports.getSelectableTimelineSequenceSelections = exports.getTimelineSelectionFromNodePathInfo = exports.getTimelineSelectionAfterInteraction = exports.isTimelineSelectionModifierEvent = exports.ENABLE_OUTLINES = exports.TIMELINE_TOP_DRAG = exports.SELECTION_ENABLED = exports.getTimelineSelectedTrackHighlightStyle = exports.getTimelineColor = exports.getTimelineSelectedLabelStyle = exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING = exports.TIMELINE_SELECTED_LABEL_TEXT = exports.TIMELINE_SELECTED_LABEL_BACKGROUND = exports.TIMELINE_SELECTED_BACKGROUND = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const studio_shared_1 = require("@remotion/studio-shared");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const client_id_1 = require("../../helpers/client-id");
|
|
8
|
+
const timeline_layout_1 = require("../../helpers/timeline-layout");
|
|
9
|
+
const timeline_node_path_key_1 = require("../../helpers/timeline-node-path-key");
|
|
10
|
+
const use_keybinding_1 = require("../../helpers/use-keybinding");
|
|
11
|
+
const TimelineDeleteKeybindings_1 = require("./TimelineDeleteKeybindings");
|
|
12
|
+
exports.TIMELINE_SELECTED_BACKGROUND = '#3B3F42';
|
|
13
|
+
exports.TIMELINE_SELECTED_LABEL_BACKGROUND = '#B0B0B0';
|
|
14
|
+
exports.TIMELINE_SELECTED_LABEL_TEXT = 'black';
|
|
15
|
+
exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING = 2;
|
|
16
|
+
const getTimelineSelectedLabelStyle = (selected, subcategory) => {
|
|
17
|
+
return {
|
|
18
|
+
paddingLeft: exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING,
|
|
19
|
+
paddingRight: exports.TIMELINE_SELECTED_LABEL_HORIZONTAL_PADDING,
|
|
20
|
+
...(selected
|
|
21
|
+
? {
|
|
22
|
+
backgroundColor: subcategory
|
|
23
|
+
? 'rgba(255, 255, 255, 0.1)'
|
|
24
|
+
: exports.TIMELINE_SELECTED_LABEL_BACKGROUND,
|
|
25
|
+
}
|
|
26
|
+
: {}),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
exports.getTimelineSelectedLabelStyle = getTimelineSelectedLabelStyle;
|
|
30
|
+
const getTimelineColor = (selected, subcategory) => {
|
|
31
|
+
return selected && !subcategory
|
|
32
|
+
? exports.TIMELINE_SELECTED_LABEL_TEXT
|
|
33
|
+
: 'rgba(255, 255, 255, 0.8)';
|
|
34
|
+
};
|
|
35
|
+
exports.getTimelineColor = getTimelineColor;
|
|
36
|
+
const getTimelineSelectedTrackHighlightStyle = (timelineWidth) => ({
|
|
37
|
+
backgroundColor: exports.TIMELINE_SELECTED_BACKGROUND,
|
|
38
|
+
bottom: 0,
|
|
39
|
+
left: -timeline_layout_1.TIMELINE_PADDING,
|
|
40
|
+
pointerEvents: 'none',
|
|
41
|
+
position: 'absolute',
|
|
42
|
+
top: 0,
|
|
43
|
+
width: timelineWidth,
|
|
44
|
+
});
|
|
45
|
+
exports.getTimelineSelectedTrackHighlightStyle = getTimelineSelectedTrackHighlightStyle;
|
|
46
|
+
exports.SELECTION_ENABLED = false;
|
|
47
|
+
exports.TIMELINE_TOP_DRAG = false;
|
|
48
|
+
exports.ENABLE_OUTLINES = false;
|
|
49
|
+
const isTimelineSelectionModifierEvent = ({ shiftKey, metaKey, ctrlKey, }) => {
|
|
50
|
+
return shiftKey || metaKey || ctrlKey;
|
|
51
|
+
};
|
|
52
|
+
exports.isTimelineSelectionModifierEvent = isTimelineSelectionModifierEvent;
|
|
53
|
+
const getTimelineSelectionType = (item) => item.type;
|
|
54
|
+
const getTimelineSelectionAnchor = (selectedItems, previousAnchor, targetType) => {
|
|
55
|
+
if (previousAnchor &&
|
|
56
|
+
getTimelineSelectionType(previousAnchor) === targetType) {
|
|
57
|
+
return previousAnchor;
|
|
58
|
+
}
|
|
59
|
+
for (let i = selectedItems.length - 1; i >= 0; i--) {
|
|
60
|
+
const candidate = selectedItems[i];
|
|
61
|
+
if (getTimelineSelectionType(candidate) === targetType) {
|
|
62
|
+
return candidate;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
};
|
|
67
|
+
const getRangeSelection = ({ anchor, clickedItem, allSelectableItems, }) => {
|
|
68
|
+
const anchorKey = getTimelineSelectionKey(anchor);
|
|
69
|
+
const clickedKey = getTimelineSelectionKey(clickedItem);
|
|
70
|
+
const orderedOfType = allSelectableItems.filter((item) => getTimelineSelectionType(item) === clickedItem.type);
|
|
71
|
+
const anchorIndex = orderedOfType.findIndex((item) => getTimelineSelectionKey(item) === anchorKey);
|
|
72
|
+
const clickedIndex = orderedOfType.findIndex((item) => getTimelineSelectionKey(item) === clickedKey);
|
|
73
|
+
if (anchorIndex === -1 || clickedIndex === -1) {
|
|
74
|
+
return [clickedItem];
|
|
75
|
+
}
|
|
76
|
+
const [from, to] = anchorIndex < clickedIndex
|
|
77
|
+
? [anchorIndex, clickedIndex]
|
|
78
|
+
: [clickedIndex, anchorIndex];
|
|
79
|
+
return orderedOfType.slice(from, to + 1);
|
|
80
|
+
};
|
|
81
|
+
const getTimelineSelectionAfterInteraction = ({ currentState, clickedItem, interaction, allSelectableItems, }) => {
|
|
82
|
+
const { selectedItems, anchor: previousAnchor } = currentState;
|
|
83
|
+
const clickedType = getTimelineSelectionType(clickedItem);
|
|
84
|
+
const nextAnchor = getTimelineSelectionAnchor(selectedItems, previousAnchor, clickedType);
|
|
85
|
+
const clickedKey = getTimelineSelectionKey(clickedItem);
|
|
86
|
+
if (interaction.shiftKey && nextAnchor) {
|
|
87
|
+
return {
|
|
88
|
+
selectedItems: getRangeSelection({
|
|
89
|
+
anchor: nextAnchor,
|
|
90
|
+
clickedItem,
|
|
91
|
+
allSelectableItems,
|
|
92
|
+
}),
|
|
93
|
+
anchor: nextAnchor,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (interaction.toggleKey) {
|
|
97
|
+
const sameTypeItems = selectedItems.filter((item) => getTimelineSelectionType(item) === clickedType);
|
|
98
|
+
const existingKeySet = new Set(sameTypeItems.map(getTimelineSelectionKey));
|
|
99
|
+
if (existingKeySet.has(clickedKey)) {
|
|
100
|
+
const toggledSelection = sameTypeItems.filter((item) => getTimelineSelectionKey(item) !== clickedKey);
|
|
101
|
+
return {
|
|
102
|
+
selectedItems: toggledSelection,
|
|
103
|
+
anchor: toggledSelection.length === 0 ? null : clickedItem,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const selectableOrderMap = new Map(allSelectableItems
|
|
107
|
+
.filter((item) => getTimelineSelectionType(item) === clickedType)
|
|
108
|
+
.map((item, index) => [getTimelineSelectionKey(item), index]));
|
|
109
|
+
const extendedSelection = [...sameTypeItems, clickedItem].sort((a, b) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
return (((_a = selectableOrderMap.get(getTimelineSelectionKey(a))) !== null && _a !== void 0 ? _a : 0) -
|
|
112
|
+
((_b = selectableOrderMap.get(getTimelineSelectionKey(b))) !== null && _b !== void 0 ? _b : 0));
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
selectedItems: extendedSelection,
|
|
116
|
+
anchor: clickedItem,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
selectedItems: [clickedItem],
|
|
121
|
+
anchor: clickedItem,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
exports.getTimelineSelectionAfterInteraction = getTimelineSelectionAfterInteraction;
|
|
125
|
+
const defaultTimelineSelectionContextValue = {
|
|
126
|
+
canSelect: false,
|
|
127
|
+
selectedItems: [],
|
|
128
|
+
isSelected: () => false,
|
|
129
|
+
selectItem: () => undefined,
|
|
130
|
+
selectItems: () => undefined,
|
|
131
|
+
registerSelectableItem: () => () => undefined,
|
|
132
|
+
containsSelection: () => false,
|
|
133
|
+
clearSelection: () => undefined,
|
|
134
|
+
};
|
|
135
|
+
const TimelineSelectionContext = (0, react_1.createContext)(defaultTimelineSelectionContextValue);
|
|
136
|
+
const CurrentTimelineSelectionContext = (0, react_1.createContext)(null);
|
|
137
|
+
const parseEffectIndex = (effectIndex) => {
|
|
138
|
+
const parsed = Number(effectIndex);
|
|
139
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return parsed;
|
|
143
|
+
};
|
|
144
|
+
const getTimelineSelectionFromNodePathInfo = (nodePathInfo) => {
|
|
145
|
+
if (nodePathInfo === null) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
const { auxiliaryKeys } = nodePathInfo;
|
|
149
|
+
if (auxiliaryKeys.length === 0) {
|
|
150
|
+
return { type: 'sequence', nodePathInfo };
|
|
151
|
+
}
|
|
152
|
+
if (auxiliaryKeys.length === 2 && auxiliaryKeys[0] === 'controls') {
|
|
153
|
+
return { type: 'sequence-prop', nodePathInfo, key: auxiliaryKeys[1] };
|
|
154
|
+
}
|
|
155
|
+
if (auxiliaryKeys.length === 1 && auxiliaryKeys[0] === 'effects') {
|
|
156
|
+
return { type: 'sequence-all-effects', nodePathInfo };
|
|
157
|
+
}
|
|
158
|
+
if (auxiliaryKeys[0] === 'effects') {
|
|
159
|
+
const effectIndex = parseEffectIndex(auxiliaryKeys[1]);
|
|
160
|
+
if (effectIndex === null) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
if (auxiliaryKeys.length === 2) {
|
|
164
|
+
return { type: 'sequence-effect', nodePathInfo, i: effectIndex };
|
|
165
|
+
}
|
|
166
|
+
if (auxiliaryKeys.length === 3) {
|
|
167
|
+
return {
|
|
168
|
+
type: 'sequence-effect-prop',
|
|
169
|
+
nodePathInfo,
|
|
170
|
+
i: effectIndex,
|
|
171
|
+
key: auxiliaryKeys[2],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
};
|
|
177
|
+
exports.getTimelineSelectionFromNodePathInfo = getTimelineSelectionFromNodePathInfo;
|
|
178
|
+
const getTimelineSelectionKey = (item) => {
|
|
179
|
+
const sequenceKey = (0, exports.getTimelineSequenceSelectionKey)(item.nodePathInfo);
|
|
180
|
+
switch (item.type) {
|
|
181
|
+
case 'sequence':
|
|
182
|
+
return `${sequenceKey}.sequence`;
|
|
183
|
+
case 'sequence-prop':
|
|
184
|
+
return `${sequenceKey}.sequence-prop.${item.key}`;
|
|
185
|
+
case 'sequence-all-effects':
|
|
186
|
+
return `${sequenceKey}.sequence-all-effects`;
|
|
187
|
+
case 'sequence-effect':
|
|
188
|
+
return `${sequenceKey}.sequence-effect.${item.i}`;
|
|
189
|
+
case 'sequence-effect-prop':
|
|
190
|
+
return `${sequenceKey}.sequence-effect-prop.${item.i}.${item.key}`;
|
|
191
|
+
case 'keyframe':
|
|
192
|
+
return `${(0, timeline_node_path_key_1.timelineNodePathInfoToKey)(item.nodePathInfo)}.keyframe.${item.frame}`;
|
|
193
|
+
default:
|
|
194
|
+
throw new Error(`Unexpected timeline selection type: ${item}`);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const nodePathDescendsFrom = (descendant, ancestor) => {
|
|
198
|
+
if ((0, studio_shared_1.stringifySequenceExpandedRowKey)(descendant.sequenceSubscriptionKey) !==
|
|
199
|
+
(0, studio_shared_1.stringifySequenceExpandedRowKey)(ancestor.sequenceSubscriptionKey)) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
if (descendant.index !== ancestor.index) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
// Must be strictly deeper than `ancestor` (i.e. a descendant), not the same row.
|
|
206
|
+
if (descendant.auxiliaryKeys.length <= ancestor.auxiliaryKeys.length) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
return ancestor.auxiliaryKeys.every((key, i) => descendant.auxiliaryKeys[i] === key);
|
|
210
|
+
};
|
|
211
|
+
const getSelectableTimelineSequenceSelections = (tracks) => {
|
|
212
|
+
return tracks.flatMap((track) => {
|
|
213
|
+
if (track.nodePathInfo === null ||
|
|
214
|
+
track.nodePathInfo.auxiliaryKeys.length > 0) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
return [{ type: 'sequence', nodePathInfo: track.nodePathInfo }];
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
exports.getSelectableTimelineSequenceSelections = getSelectableTimelineSequenceSelections;
|
|
221
|
+
const getTimelineSequenceSelectionKey = (nodePathInfo) => (0, timeline_node_path_key_1.timelineNodePathInfoToKey)({ ...nodePathInfo, auxiliaryKeys: [] });
|
|
222
|
+
exports.getTimelineSequenceSelectionKey = getTimelineSequenceSelectionKey;
|
|
223
|
+
const TimelineSelectAllKeybindings = ({ timeline }) => {
|
|
224
|
+
const keybindings = (0, use_keybinding_1.useKeybinding)();
|
|
225
|
+
const { canSelect } = (0, exports.useTimelineSelection)();
|
|
226
|
+
const currentSelection = (0, exports.useCurrentTimelineSelectionStateAsRef)();
|
|
227
|
+
const selectableSequenceSelections = (0, react_1.useMemo)(() => (0, exports.getSelectableTimelineSequenceSelections)(timeline), [timeline]);
|
|
228
|
+
const selectableSequenceSelectionsRef = (0, react_1.useRef)(selectableSequenceSelections);
|
|
229
|
+
selectableSequenceSelectionsRef.current = selectableSequenceSelections;
|
|
230
|
+
(0, react_1.useEffect)(() => {
|
|
231
|
+
if (!canSelect) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const selectAll = keybindings.registerKeybinding({
|
|
235
|
+
event: 'keydown',
|
|
236
|
+
key: 'a',
|
|
237
|
+
callback: () => {
|
|
238
|
+
const latestSelectableSequenceSelections = selectableSequenceSelectionsRef.current;
|
|
239
|
+
if (latestSelectableSequenceSelections.length === 0) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
currentSelection.current.selectItems(latestSelectableSequenceSelections);
|
|
243
|
+
},
|
|
244
|
+
commandCtrlKey: true,
|
|
245
|
+
preventDefault: true,
|
|
246
|
+
triggerIfInputFieldFocused: false,
|
|
247
|
+
keepRegisteredWhenNotHighestContext: false,
|
|
248
|
+
});
|
|
249
|
+
return () => {
|
|
250
|
+
selectAll.unregister();
|
|
251
|
+
};
|
|
252
|
+
}, [canSelect, currentSelection, keybindings]);
|
|
253
|
+
return null;
|
|
254
|
+
};
|
|
255
|
+
exports.TimelineSelectAllKeybindings = TimelineSelectAllKeybindings;
|
|
256
|
+
const TimelineSelectionProvider = ({ children }) => {
|
|
257
|
+
const { previewServerState } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
258
|
+
const canSelect = exports.SELECTION_ENABLED &&
|
|
259
|
+
previewServerState.type === 'connected' &&
|
|
260
|
+
!window.remotion_isReadOnlyStudio;
|
|
261
|
+
const [selectedItems, setSelectedItems] = (0, react_1.useState)([]);
|
|
262
|
+
const selectionAnchor = (0, react_1.useRef)(null);
|
|
263
|
+
const selectableItemsOrder = (0, react_1.useRef)(new Map());
|
|
264
|
+
const selectableItems = (0, react_1.useRef)(new Map());
|
|
265
|
+
const registrationCounter = (0, react_1.useRef)(0);
|
|
266
|
+
(0, react_1.useEffect)(() => {
|
|
267
|
+
if (!canSelect) {
|
|
268
|
+
setSelectedItems([]);
|
|
269
|
+
}
|
|
270
|
+
}, [canSelect]);
|
|
271
|
+
const selectedKeys = (0, react_1.useMemo)(() => new Set(selectedItems.map(getTimelineSelectionKey)), [selectedItems]);
|
|
272
|
+
const isSelected = (0, react_1.useCallback)((item) => {
|
|
273
|
+
return selectedKeys.has(getTimelineSelectionKey(item));
|
|
274
|
+
}, [selectedKeys]);
|
|
275
|
+
const selectItem = (0, react_1.useCallback)((item, interaction = {
|
|
276
|
+
shiftKey: false,
|
|
277
|
+
toggleKey: false,
|
|
278
|
+
}) => {
|
|
279
|
+
if (!canSelect) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
setSelectedItems((currentSelectedItems) => {
|
|
283
|
+
const orderedSelectableItems = [
|
|
284
|
+
...selectableItems.current.values(),
|
|
285
|
+
].sort((a, b) => {
|
|
286
|
+
var _a, _b;
|
|
287
|
+
return (((_a = selectableItemsOrder.current.get(getTimelineSelectionKey(a))) !== null && _a !== void 0 ? _a : 0) -
|
|
288
|
+
((_b = selectableItemsOrder.current.get(getTimelineSelectionKey(b))) !== null && _b !== void 0 ? _b : 0));
|
|
289
|
+
});
|
|
290
|
+
const nextState = (0, exports.getTimelineSelectionAfterInteraction)({
|
|
291
|
+
currentState: {
|
|
292
|
+
selectedItems: currentSelectedItems,
|
|
293
|
+
anchor: selectionAnchor.current,
|
|
294
|
+
},
|
|
295
|
+
clickedItem: item,
|
|
296
|
+
interaction,
|
|
297
|
+
allSelectableItems: orderedSelectableItems,
|
|
298
|
+
});
|
|
299
|
+
selectionAnchor.current = nextState.anchor;
|
|
300
|
+
return nextState.selectedItems;
|
|
301
|
+
});
|
|
302
|
+
}, [canSelect]);
|
|
303
|
+
const selectItems = (0, react_1.useCallback)((items) => {
|
|
304
|
+
if (!canSelect) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
selectionAnchor.current =
|
|
308
|
+
items.length === 0 ? null : items[items.length - 1];
|
|
309
|
+
setSelectedItems(items);
|
|
310
|
+
}, [canSelect]);
|
|
311
|
+
const registerSelectableItem = (0, react_1.useCallback)((item) => {
|
|
312
|
+
const key = getTimelineSelectionKey(item);
|
|
313
|
+
const registrationOrder = registrationCounter.current;
|
|
314
|
+
registrationCounter.current += 1;
|
|
315
|
+
selectableItems.current.set(key, item);
|
|
316
|
+
selectableItemsOrder.current.set(key, registrationOrder);
|
|
317
|
+
return () => {
|
|
318
|
+
selectableItems.current.delete(key);
|
|
319
|
+
selectableItemsOrder.current.delete(key);
|
|
320
|
+
};
|
|
321
|
+
}, []);
|
|
322
|
+
const clearSelection = (0, react_1.useCallback)(() => {
|
|
323
|
+
selectionAnchor.current = null;
|
|
324
|
+
setSelectedItems([]);
|
|
325
|
+
}, []);
|
|
326
|
+
const containsSelection = (0, react_1.useCallback)((nodePathInfo) => {
|
|
327
|
+
return selectedItems.some((selected) => nodePathDescendsFrom(selected.nodePathInfo, nodePathInfo));
|
|
328
|
+
}, [selectedItems]);
|
|
329
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
330
|
+
canSelect,
|
|
331
|
+
selectedItems,
|
|
332
|
+
isSelected,
|
|
333
|
+
selectItem,
|
|
334
|
+
selectItems,
|
|
335
|
+
registerSelectableItem,
|
|
336
|
+
containsSelection,
|
|
337
|
+
clearSelection,
|
|
338
|
+
}), [
|
|
339
|
+
canSelect,
|
|
340
|
+
selectedItems,
|
|
341
|
+
isSelected,
|
|
342
|
+
selectItem,
|
|
343
|
+
selectItems,
|
|
344
|
+
registerSelectableItem,
|
|
345
|
+
containsSelection,
|
|
346
|
+
clearSelection,
|
|
347
|
+
]);
|
|
348
|
+
const currentSelection = (0, react_1.useRef)(value);
|
|
349
|
+
currentSelection.current = value;
|
|
350
|
+
return (jsx_runtime_1.jsx(CurrentTimelineSelectionContext.Provider, { value: currentSelection, children: jsx_runtime_1.jsxs(TimelineSelectionContext.Provider, { value: value, children: [children, jsx_runtime_1.jsx(TimelineDeleteKeybindings_1.TimelineDeleteKeybindings, {})
|
|
351
|
+
] }) }));
|
|
352
|
+
};
|
|
353
|
+
exports.TimelineSelectionProvider = TimelineSelectionProvider;
|
|
354
|
+
const useTimelineSelection = () => {
|
|
355
|
+
return (0, react_1.useContext)(TimelineSelectionContext);
|
|
356
|
+
};
|
|
357
|
+
exports.useTimelineSelection = useTimelineSelection;
|
|
358
|
+
const useCurrentTimelineSelectionStateAsRef = () => {
|
|
359
|
+
const currentSelection = (0, react_1.useContext)(CurrentTimelineSelectionContext);
|
|
360
|
+
if (currentSelection === null) {
|
|
361
|
+
throw new Error('useCurrentTimelineSelectionStateAsRef must be used inside TimelineSelectionProvider');
|
|
362
|
+
}
|
|
363
|
+
return currentSelection;
|
|
364
|
+
};
|
|
365
|
+
exports.useCurrentTimelineSelectionStateAsRef = useCurrentTimelineSelectionStateAsRef;
|
|
366
|
+
const useTimelineRowSelection = (nodePathInfo) => {
|
|
367
|
+
const { canSelect, isSelected, selectItem, registerSelectableItem } = (0, exports.useTimelineSelection)();
|
|
368
|
+
const selectionItem = (0, react_1.useMemo)(() => (0, exports.getTimelineSelectionFromNodePathInfo)(nodePathInfo), [nodePathInfo]);
|
|
369
|
+
(0, react_1.useEffect)(() => {
|
|
370
|
+
if (selectionItem === null) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
return registerSelectableItem(selectionItem);
|
|
374
|
+
}, [registerSelectableItem, selectionItem]);
|
|
375
|
+
const selected = selectionItem === null ? false : isSelected(selectionItem);
|
|
376
|
+
const onSelect = (0, react_1.useCallback)((interaction) => {
|
|
377
|
+
if (selectionItem === null) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
selectItem(selectionItem, interaction);
|
|
381
|
+
}, [selectItem, selectionItem]);
|
|
382
|
+
return {
|
|
383
|
+
onSelect,
|
|
384
|
+
selectable: canSelect && selectionItem !== null,
|
|
385
|
+
selected,
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
exports.useTimelineRowSelection = useTimelineRowSelection;
|
|
389
|
+
const useTimelineKeyframeSelection = (nodePathInfo, frame) => {
|
|
390
|
+
const { canSelect, isSelected, selectItem, registerSelectableItem } = (0, exports.useTimelineSelection)();
|
|
391
|
+
const selectionItem = (0, react_1.useMemo)(() => ({
|
|
392
|
+
type: 'keyframe',
|
|
393
|
+
nodePathInfo,
|
|
394
|
+
frame,
|
|
395
|
+
}), [nodePathInfo, frame]);
|
|
396
|
+
(0, react_1.useEffect)(() => {
|
|
397
|
+
return registerSelectableItem(selectionItem);
|
|
398
|
+
}, [registerSelectableItem, selectionItem]);
|
|
399
|
+
const selected = isSelected(selectionItem);
|
|
400
|
+
const onSelect = (0, react_1.useCallback)((interaction) => {
|
|
401
|
+
selectItem(selectionItem, interaction);
|
|
402
|
+
}, [selectItem, selectionItem]);
|
|
403
|
+
return {
|
|
404
|
+
onSelect,
|
|
405
|
+
selectable: canSelect,
|
|
406
|
+
selected,
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
exports.useTimelineKeyframeSelection = useTimelineKeyframeSelection;
|
|
410
|
+
const useTimelineRowContainsSelection = (nodePathInfo) => {
|
|
411
|
+
const { containsSelection } = (0, exports.useTimelineSelection)();
|
|
412
|
+
if (nodePathInfo === null) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
return containsSelection(nodePathInfo);
|
|
416
|
+
};
|
|
417
|
+
exports.useTimelineRowContainsSelection = useTimelineRowContainsSelection;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { TSequence } from 'remotion';
|
|
3
|
+
import type { SequenceNodePathInfo } from '../../helpers/get-timeline-sequence-sort-key';
|
|
3
4
|
export declare const TimelineSequence: React.NamedExoticComponent<{
|
|
4
5
|
readonly s: TSequence;
|
|
6
|
+
readonly nodePathInfo: SequenceNodePathInfo | null;
|
|
5
7
|
}>;
|