@remotion/studio 4.0.498 → 4.0.500
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/components/AssetSelector.js +8 -6
- package/dist/components/AssetSelectorItem.d.ts +24 -0
- package/dist/components/AssetSelectorItem.js +144 -83
- package/dist/components/Canvas.js +162 -7
- package/dist/components/CompositionSelector.js +15 -42
- package/dist/components/CompositionSelectorItem.js +21 -13
- package/dist/components/ControlButton.js +1 -0
- package/dist/components/EditorContent.js +1 -1
- package/dist/components/EditorRuler/Ruler.js +5 -3
- package/dist/components/ExplorerPanel.js +2 -1
- package/dist/components/ExplorerPanelRef.d.ts +2 -0
- package/dist/components/ForceSpecificCursor.js +13 -1
- package/dist/components/GlobalKeybindings.js +7 -1
- package/dist/components/InlineAction.d.ts +2 -1
- package/dist/components/InlineAction.js +2 -2
- package/dist/components/InlineDropdown.d.ts +1 -1
- package/dist/components/InlineDropdown.js +3 -2
- package/dist/components/InspectorPanel/AlignmentControls.d.ts +2 -2
- package/dist/components/InspectorPanel/AlignmentControls.js +5 -2
- package/dist/components/InspectorPanel/CompositionInspector.js +8 -7
- package/dist/components/InspectorPanel/CompositionMetadata.js +170 -57
- package/dist/components/InspectorPanel/ConnectedCompositionsSection.d.ts +2 -2
- package/dist/components/InspectorPanel/SequenceInspectorHeader.d.ts +3 -3
- package/dist/components/InspectorPanel/SequenceSelectionInspector.js +7 -7
- package/dist/components/InspectorPanel/common.d.ts +17 -4
- package/dist/components/InspectorPanel/common.js +60 -6
- package/dist/components/InspectorPanel/use-composition-actions.js +1 -0
- package/dist/components/InspectorPanel/use-track-for-selection.d.ts +1 -1
- package/dist/components/InspectorSequenceSection.js +43 -19
- package/dist/components/KeyboardShortcutsExplainer.js +4 -2
- package/dist/components/Menu/MenuItem.js +2 -1
- package/dist/components/MenuCompositionName.js +30 -7
- package/dist/components/MenuToolbar.d.ts +0 -1
- package/dist/components/MenuToolbar.js +8 -7
- package/dist/components/MobilePanel.d.ts +2 -1
- package/dist/components/MobilePanel.js +29 -25
- package/dist/components/ModalContainer.d.ts +1 -0
- package/dist/components/ModalContainer.js +2 -2
- package/dist/components/Modals.js +1 -1
- package/dist/components/NewComposition/DismissableModal.d.ts +1 -0
- package/dist/components/NewComposition/DismissableModal.js +2 -2
- package/dist/components/NewComposition/InputDragger.d.ts +34 -0
- package/dist/components/NewComposition/InputDragger.js +262 -23
- package/dist/components/OutlineToggle.d.ts +1 -3
- package/dist/components/OutlineToggle.js +2 -2
- package/dist/components/PreviewToolbar.js +10 -4
- package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.d.ts +7 -0
- package/dist/components/QuickSwitcher/ExplorerQuickSwitcherTrigger.js +44 -0
- package/dist/components/QuickSwitcher/NoResults.d.ts +1 -1
- package/dist/components/QuickSwitcher/NoResults.js +1 -0
- package/dist/components/QuickSwitcher/QuickSwitcher.d.ts +5 -0
- package/dist/components/QuickSwitcher/QuickSwitcher.js +6 -2
- package/dist/components/QuickSwitcher/QuickSwitcherContent.d.ts +5 -0
- package/dist/components/QuickSwitcher/QuickSwitcherContent.js +76 -12
- package/dist/components/QuickSwitcher/QuickSwitcherResult.d.ts +4 -0
- package/dist/components/QuickSwitcher/QuickSwitcherResult.js +11 -8
- package/dist/components/QuickSwitcher/asset-search.d.ts +9 -0
- package/dist/components/QuickSwitcher/asset-search.js +42 -0
- package/dist/components/SelectedOutlineCropControls.d.ts +8 -0
- package/dist/components/SelectedOutlineCropControls.js +299 -0
- package/dist/components/SelectedOutlineElement.js +83 -43
- package/dist/components/SelectedOutlineOverlay.d.ts +2 -2
- package/dist/components/SelectedOutlineOverlay.js +130 -8
- package/dist/components/SequencePropsSubscriptionProvider.d.ts +2 -0
- package/dist/components/SequencePropsSubscriptionProvider.js +31 -3
- package/dist/components/SidebarCollapserControls.d.ts +3 -1
- package/dist/components/SidebarCollapserControls.js +34 -29
- package/dist/components/SnappingToggle.d.ts +1 -3
- package/dist/components/SnappingToggle.js +2 -2
- package/dist/components/Splitter/SplitterContainer.d.ts +2 -0
- package/dist/components/Splitter/SplitterContainer.js +5 -1
- package/dist/components/Splitter/SplitterContext.d.ts +2 -0
- package/dist/components/Splitter/SplitterContext.js +2 -0
- package/dist/components/Splitter/SplitterElement.js +6 -1
- package/dist/components/Splitter/SplitterHandle.js +27 -2
- package/dist/components/Timeline/Timeline.js +1 -1
- package/dist/components/Timeline/TimelineAssetField.d.ts +9 -1
- package/dist/components/Timeline/TimelineAssetField.js +52 -100
- package/dist/components/Timeline/TimelineClipboardKeybindings.d.ts +7 -3
- package/dist/components/Timeline/TimelineClipboardKeybindings.js +65 -38
- package/dist/components/Timeline/TimelineColorField.js +20 -1
- package/dist/components/Timeline/TimelineEffectPropItem.js +8 -77
- package/dist/components/Timeline/TimelineExpandedKeyframeRow.js +1 -0
- package/dist/components/Timeline/TimelineHeightContainer.d.ts +2 -2
- package/dist/components/Timeline/TimelineInOutDragHandler.js +25 -1
- package/dist/components/Timeline/TimelineKeyframeTracksContext.d.ts +3 -3
- package/dist/components/Timeline/TimelineLayerEye.js +4 -1
- package/dist/components/Timeline/TimelineList.d.ts +2 -2
- package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +7 -1
- package/dist/components/Timeline/TimelineSelection.d.ts +5 -5
- package/dist/components/Timeline/TimelineSelection.js +8 -6
- package/dist/components/Timeline/TimelineSequence.js +7 -6
- package/dist/components/Timeline/TimelineSequenceItem.js +57 -10
- package/dist/components/Timeline/TimelineSequenceName.js +1 -0
- package/dist/components/Timeline/TimelineSequencePropItem.js +27 -75
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.d.ts +5 -1
- package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +29 -12
- package/dist/components/Timeline/TimelineTrack.d.ts +2 -2
- package/dist/components/Timeline/TimelineTracks.d.ts +2 -2
- package/dist/components/Timeline/find-track-for-node-path-info.d.ts +1 -1
- package/dist/components/Timeline/get-sequence-context-menu-items.js +14 -12
- package/dist/components/Timeline/reset-selected-timeline-props.js +18 -10
- package/dist/components/Timeline/save-effect-prop.d.ts +10 -0
- package/dist/components/Timeline/save-effect-prop.js +52 -1
- package/dist/components/Timeline/should-show-track-in-timeline.d.ts +2 -2
- package/dist/components/Timeline/timeline-asset-link.js +17 -1
- package/dist/components/Timeline/use-sequence-freeze-frame-menu-item.d.ts +4 -0
- package/dist/components/Timeline/use-sequence-freeze-frame-menu-item.js +9 -3
- package/dist/components/Timeline/use-timeline-height.d.ts +2 -2
- package/dist/components/Timeline/use-timeline-keyframe-drag.js +6 -4
- package/dist/components/TopPanel.js +3 -2
- package/dist/components/UndoRedoButtons.js +27 -5
- package/dist/components/composition-drop-preview.d.ts +33 -0
- package/dist/components/composition-drop-preview.js +68 -0
- package/dist/components/drop-handler-data.d.ts +1 -1
- package/dist/components/drop-handler-data.js +27 -60
- package/dist/components/effect-drag-and-drop.d.ts +1 -1
- package/dist/components/effect-drag-and-drop.js +7 -55
- package/dist/components/element-drag-and-drop.d.ts +1 -1
- package/dist/components/element-drag-and-drop.js +5 -17
- package/dist/components/handle-drop.js +0 -1
- package/dist/components/import-assets.d.ts +7 -8
- package/dist/components/import-assets.js +2 -9
- package/dist/components/menu-toolbar-height.d.ts +1 -0
- package/dist/components/menu-toolbar-height.js +4 -0
- package/dist/components/selected-outline-drag.d.ts +41 -4
- package/dist/components/selected-outline-drag.js +179 -2
- package/dist/components/selected-outline-geometry.d.ts +1 -0
- package/dist/components/selected-outline-measurement.d.ts +11 -0
- package/dist/components/selected-outline-measurement.js +64 -3
- package/dist/components/selected-outline-types.d.ts +44 -1
- package/dist/components/selected-outline-types.js +21 -1
- package/dist/error-overlay/remotion-overlay/Overlay.js +3 -3
- package/dist/error-overlay/remotion-overlay/ShortcutHint.js +2 -3
- package/dist/esm/{chunk-7a6q9hk2.js → chunk-dr1y1vm3.js} +11851 -9494
- package/dist/esm/internals.mjs +11851 -9494
- package/dist/esm/previewEntry.mjs +55150 -52795
- package/dist/esm/renderEntry.mjs +1 -1
- package/dist/helpers/calculate-timeline.d.ts +2 -2
- package/dist/helpers/calculate-timeline.js +8 -28
- package/dist/helpers/get-effective-translation.d.ts +13 -1
- package/dist/helpers/get-effective-translation.js +12 -6
- package/dist/helpers/get-timeline-sequence-sort-key.d.ts +3 -10
- package/dist/helpers/get-timeline-sequence-sort-key.js +5 -13
- package/dist/helpers/interactivity-enabled.d.ts +1 -0
- package/dist/helpers/interactivity-enabled.js +7 -2
- package/dist/helpers/is-mac.d.ts +1 -0
- package/dist/helpers/is-mac.js +4 -0
- package/dist/helpers/open-in-editor.d.ts +5 -1
- package/dist/helpers/open-in-editor.js +15 -1
- package/dist/helpers/ruler-canvas-size.d.ts +7 -0
- package/dist/helpers/ruler-canvas-size.js +14 -1
- package/dist/helpers/sort-by-nonce-history.js +97 -19
- package/dist/helpers/use-image-metadata.d.ts +1 -0
- package/dist/helpers/use-image-metadata.js +8 -5
- package/dist/helpers/use-keybinding.js +2 -3
- package/dist/helpers/use-media-metadata.d.ts +1 -0
- package/dist/helpers/use-media-metadata.js +8 -5
- package/dist/helpers/use-menu-structure.js +10 -1
- package/dist/icons/caret.d.ts +1 -0
- package/dist/icons/caret.js +2 -2
- package/dist/icons/pen.d.ts +5 -0
- package/dist/icons/pen.js +8 -0
- package/dist/state/modals.d.ts +5 -0
- package/package.json +13 -12
- package/dist/helpers/get-timeline-sequence-hash.d.ts +0 -6
- package/dist/helpers/get-timeline-sequence-hash.js +0 -33
|
@@ -48,6 +48,7 @@ const z_index_1 = require("../state/z-index");
|
|
|
48
48
|
const AssetSelectorItem_1 = require("./AssetSelectorItem");
|
|
49
49
|
const styles_1 = require("./Menu/styles");
|
|
50
50
|
const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
51
|
+
const ExplorerQuickSwitcherTrigger_1 = require("./QuickSwitcher/ExplorerQuickSwitcherTrigger");
|
|
51
52
|
const use_static_files_1 = require("./use-static-files");
|
|
52
53
|
const container = {
|
|
53
54
|
display: 'flex',
|
|
@@ -158,11 +159,12 @@ const AssetSelector = ({ readOnlyStudio }) => {
|
|
|
158
159
|
setDropLocation(null);
|
|
159
160
|
}
|
|
160
161
|
}, [dropLocation, staticFiles]);
|
|
161
|
-
return (jsx_runtime_1.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
return (jsx_runtime_1.jsxs("div", { style: container, onDragOver: shouldAllowUpload ? onDragOver : undefined, onDrop: shouldAllowUpload ? onDrop : undefined, children: [
|
|
163
|
+
jsx_runtime_1.jsx(ExplorerQuickSwitcherTrigger_1.ExplorerQuickSwitcherTrigger, { mode: "assets", showShortcut: true, tabIndex: tabIndex }), staticFiles.length === 0 ? (publicFolderExists ? (jsx_runtime_1.jsx("div", { style: emptyState, children: jsx_runtime_1.jsxs("div", { style: label, children: ["To add assets, place a file in the", ' ', jsx_runtime_1.jsx("code", { style: styles_1.inlineCodeSnippet, children: "public" }),
|
|
164
|
+
" folder of your project or drag and drop a file here."] }) })) : (jsx_runtime_1.jsx("div", { style: emptyState, children: jsx_runtime_1.jsxs("div", { style: label, children: ["To add assets, create a folder called", ' ', jsx_runtime_1.jsx("code", { style: styles_1.inlineCodeSnippet, children: "public" }),
|
|
165
|
+
" in the root of your project and place a file in it."] }) }))) : (jsx_runtime_1.jsx("div", { className: "__remotion-vertical-scrollbar", style: {
|
|
166
|
+
...list,
|
|
167
|
+
backgroundColor: isDropDiv ? colors_1.WHITE_ALPHA_06 : colors_1.BACKGROUND,
|
|
168
|
+
}, onDragEnter: onDragEnter, onDragLeave: onDragLeave, children: jsx_runtime_1.jsx(AssetSelectorItem_1.AssetFolderTree, { item: assetTree, level: 0, parentFolder: null, name: null, tabIndex: tabIndex, toggleFolder: toggleFolder, dropLocation: dropLocation, setDropLocation: setDropLocation, readOnlyStudio: readOnlyStudio }) }))] }));
|
|
167
169
|
};
|
|
168
170
|
exports.AssetSelector = AssetSelector;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { AssetStructure } from '../helpers/create-folder-tree';
|
|
3
|
+
import type { ComboboxValue } from './NewComposition/ComboBox';
|
|
4
|
+
export declare const getAssetActionAvailability: ({ readOnlyStudio, connectionStatus, publicFolderExists, }: {
|
|
5
|
+
readOnlyStudio: boolean;
|
|
6
|
+
connectionStatus: "connected" | "disconnected" | "init";
|
|
7
|
+
publicFolderExists: string | null;
|
|
8
|
+
}) => {
|
|
9
|
+
mutationsDisabled: boolean;
|
|
10
|
+
fileExplorerDisabled: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const getCanDragAsset: ({ readOnlyStudio, relativePath, }: {
|
|
13
|
+
readOnlyStudio: boolean;
|
|
14
|
+
relativePath: string;
|
|
15
|
+
}) => boolean;
|
|
16
|
+
export declare const getAssetContextMenuItems: ({ relativePath, fileManagerName, copyFileName, copyStaticFilePath, openAssetInExplorer, renameAsset, deleteAsset, fileExplorerDisabled, mutationsDisabled, }: {
|
|
17
|
+
relativePath: string;
|
|
18
|
+
fileManagerName: string;
|
|
19
|
+
copyFileName: () => void;
|
|
20
|
+
copyStaticFilePath: () => void;
|
|
21
|
+
openAssetInExplorer: () => void;
|
|
22
|
+
renameAsset: () => void;
|
|
23
|
+
deleteAsset: () => void;
|
|
24
|
+
fileExplorerDisabled: boolean;
|
|
25
|
+
mutationsDisabled: boolean;
|
|
26
|
+
}) => ComboboxValue[];
|
|
3
27
|
export declare const AssetFolderTree: React.FC<{
|
|
4
28
|
readonly item: AssetStructure;
|
|
5
29
|
readonly name: string | null;
|
|
@@ -33,9 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.AssetFolderTree = void 0;
|
|
36
|
+
exports.AssetFolderTree = exports.getAssetContextMenuItems = exports.getCanDragAsset = exports.getAssetActionAvailability = void 0;
|
|
37
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const
|
|
38
|
+
const drag_and_drop_1 = require("@remotion/drag-and-drop");
|
|
39
39
|
const react_1 = require("react");
|
|
40
40
|
const remotion_1 = require("remotion");
|
|
41
41
|
const no_react_1 = require("remotion/no-react");
|
|
@@ -49,6 +49,8 @@ const mobile_layout_1 = require("../helpers/mobile-layout");
|
|
|
49
49
|
const sidebar_scroll_into_view_1 = require("../helpers/sidebar-scroll-into-view");
|
|
50
50
|
const url_state_1 = require("../helpers/url-state");
|
|
51
51
|
const use_asset_drag_events_1 = __importStar(require("../helpers/use-asset-drag-events"));
|
|
52
|
+
const use_image_metadata_1 = require("../helpers/use-image-metadata");
|
|
53
|
+
const use_media_metadata_1 = require("../helpers/use-media-metadata");
|
|
52
54
|
const clipboard_1 = require("../icons/clipboard");
|
|
53
55
|
const folder_1 = require("../icons/folder");
|
|
54
56
|
const modals_1 = require("../state/modals");
|
|
@@ -103,6 +105,91 @@ const revealIconStyle = {
|
|
|
103
105
|
height: 12,
|
|
104
106
|
color: colors_1.CURRENT_COLOR,
|
|
105
107
|
};
|
|
108
|
+
const getAssetActionAvailability = ({ readOnlyStudio, connectionStatus, publicFolderExists, }) => {
|
|
109
|
+
return {
|
|
110
|
+
mutationsDisabled: readOnlyStudio || connectionStatus !== 'connected',
|
|
111
|
+
fileExplorerDisabled: publicFolderExists === null ||
|
|
112
|
+
readOnlyStudio ||
|
|
113
|
+
connectionStatus !== 'connected',
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
exports.getAssetActionAvailability = getAssetActionAvailability;
|
|
117
|
+
const getCanDragAsset = ({ readOnlyStudio, relativePath, }) => {
|
|
118
|
+
return !readOnlyStudio && (0, import_assets_1.getAssetElementFromPath)(relativePath) !== null;
|
|
119
|
+
};
|
|
120
|
+
exports.getCanDragAsset = getCanDragAsset;
|
|
121
|
+
const getAssetContextMenuItems = ({ relativePath, fileManagerName, copyFileName, copyStaticFilePath, openAssetInExplorer, renameAsset, deleteAsset, fileExplorerDisabled, mutationsDisabled, }) => {
|
|
122
|
+
return [
|
|
123
|
+
(0, open_in_new_window_1.getOpenInNewWindowMenuItem)(`/assets/${relativePath}`),
|
|
124
|
+
{
|
|
125
|
+
type: 'divider',
|
|
126
|
+
id: 'open-in-new-window-divider',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'copy-asset-file-name',
|
|
130
|
+
keyHint: null,
|
|
131
|
+
label: 'Copy file name',
|
|
132
|
+
leftItem: null,
|
|
133
|
+
onClick: copyFileName,
|
|
134
|
+
quickSwitcherLabel: 'Copy asset file name',
|
|
135
|
+
subMenu: null,
|
|
136
|
+
type: 'item',
|
|
137
|
+
value: 'copy-asset-file-name',
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: 'copy-asset-static-file-path',
|
|
141
|
+
keyHint: null,
|
|
142
|
+
label: 'Copy staticFile() path',
|
|
143
|
+
leftItem: null,
|
|
144
|
+
onClick: copyStaticFilePath,
|
|
145
|
+
quickSwitcherLabel: 'Copy staticFile() path',
|
|
146
|
+
subMenu: null,
|
|
147
|
+
type: 'item',
|
|
148
|
+
value: 'copy-asset-static-file-path',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: 'divider',
|
|
152
|
+
id: 'asset-file-actions-divider',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 'open-asset-in-explorer',
|
|
156
|
+
keyHint: null,
|
|
157
|
+
label: `Show in ${fileManagerName}`,
|
|
158
|
+
leftItem: null,
|
|
159
|
+
onClick: openAssetInExplorer,
|
|
160
|
+
quickSwitcherLabel: `Show asset in ${fileManagerName}`,
|
|
161
|
+
subMenu: null,
|
|
162
|
+
type: 'item',
|
|
163
|
+
value: 'open-asset-in-explorer',
|
|
164
|
+
disabled: fileExplorerDisabled,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: 'rename-asset',
|
|
168
|
+
keyHint: null,
|
|
169
|
+
label: 'Rename...',
|
|
170
|
+
leftItem: null,
|
|
171
|
+
onClick: renameAsset,
|
|
172
|
+
quickSwitcherLabel: 'Rename asset...',
|
|
173
|
+
subMenu: null,
|
|
174
|
+
type: 'item',
|
|
175
|
+
value: 'rename-asset',
|
|
176
|
+
disabled: mutationsDisabled,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 'delete-asset',
|
|
180
|
+
keyHint: null,
|
|
181
|
+
label: 'Delete...',
|
|
182
|
+
leftItem: null,
|
|
183
|
+
onClick: deleteAsset,
|
|
184
|
+
quickSwitcherLabel: 'Delete asset...',
|
|
185
|
+
subMenu: null,
|
|
186
|
+
type: 'item',
|
|
187
|
+
value: 'delete-asset',
|
|
188
|
+
disabled: mutationsDisabled,
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
};
|
|
192
|
+
exports.getAssetContextMenuItems = getAssetContextMenuItems;
|
|
106
193
|
const AssetFolderItem = ({ tabIndex, item, level, parentFolder, toggleFolder, dropLocation, setDropLocation, readOnlyStudio, }) => {
|
|
107
194
|
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
108
195
|
const openFolderTimerRef = (0, react_1.useRef)(null);
|
|
@@ -197,7 +284,7 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
|
|
|
197
284
|
return false;
|
|
198
285
|
}, [canvasContent, relativePath]);
|
|
199
286
|
const canDragAsset = (0, react_1.useMemo)(() => {
|
|
200
|
-
return
|
|
287
|
+
return (0, exports.getCanDragAsset)({ readOnlyStudio, relativePath });
|
|
201
288
|
}, [readOnlyStudio, relativePath]);
|
|
202
289
|
const onPointerLeave = (0, react_1.useCallback)(() => {
|
|
203
290
|
setHovered(false);
|
|
@@ -224,14 +311,40 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
|
|
|
224
311
|
setSidebarCollapsedState,
|
|
225
312
|
]);
|
|
226
313
|
const onDragStart = (0, react_1.useCallback)((e) => {
|
|
314
|
+
var _a, _b, _c, _d;
|
|
227
315
|
if (!canDragAsset) {
|
|
228
316
|
e.preventDefault();
|
|
229
317
|
return;
|
|
230
318
|
}
|
|
231
319
|
setIsDragging(true);
|
|
232
320
|
e.dataTransfer.effectAllowed = 'copy';
|
|
233
|
-
|
|
234
|
-
|
|
321
|
+
const src = (0, remotion_1.staticFile)(relativePath);
|
|
322
|
+
const imageMetadata = previewFileType === 'image' ? (0, use_image_metadata_1.getCachedImageMetadata)(src) : null;
|
|
323
|
+
const mediaMetadata = previewFileType === 'audio' || previewFileType === 'video'
|
|
324
|
+
? (0, use_media_metadata_1.getCachedMediaMetadata)(src)
|
|
325
|
+
: null;
|
|
326
|
+
const width = (_b = (_a = imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.width) !== null && _a !== void 0 ? _a : mediaMetadata === null || mediaMetadata === void 0 ? void 0 : mediaMetadata.width) !== null && _b !== void 0 ? _b : null;
|
|
327
|
+
const height = (_d = (_c = imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.height) !== null && _c !== void 0 ? _c : mediaMetadata === null || mediaMetadata === void 0 ? void 0 : mediaMetadata.height) !== null && _d !== void 0 ? _d : null;
|
|
328
|
+
const hasDimensions = width !== null &&
|
|
329
|
+
height !== null &&
|
|
330
|
+
Number.isInteger(width) &&
|
|
331
|
+
Number.isInteger(height) &&
|
|
332
|
+
width > 0 &&
|
|
333
|
+
height > 0;
|
|
334
|
+
const durationInSeconds = (mediaMetadata === null || mediaMetadata === void 0 ? void 0 : mediaMetadata.duration) !== undefined &&
|
|
335
|
+
Number.isFinite(mediaMetadata.duration) &&
|
|
336
|
+
mediaMetadata.duration > 0
|
|
337
|
+
? mediaMetadata.duration
|
|
338
|
+
: null;
|
|
339
|
+
const dragData = drag_and_drop_1.DragAndDropInternals.makeDragData({
|
|
340
|
+
type: 'asset',
|
|
341
|
+
assetPath: relativePath,
|
|
342
|
+
width: hasDimensions ? width : null,
|
|
343
|
+
height: hasDimensions ? height : null,
|
|
344
|
+
durationInSeconds,
|
|
345
|
+
});
|
|
346
|
+
e.dataTransfer.setData(dragData.mimeType, dragData.payload);
|
|
347
|
+
}, [canDragAsset, previewFileType, relativePath]);
|
|
235
348
|
const onDragEnd = (0, react_1.useCallback)(() => {
|
|
236
349
|
setIsDragging(false);
|
|
237
350
|
}, []);
|
|
@@ -285,7 +398,11 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
|
|
|
285
398
|
(0, NotificationCenter_1.showNotification)(`Could not open file: ${err.message}`, 2000);
|
|
286
399
|
});
|
|
287
400
|
}, [relativePath]);
|
|
288
|
-
const
|
|
401
|
+
const { mutationsDisabled, fileExplorerDisabled } = (0, exports.getAssetActionAvailability)({
|
|
402
|
+
readOnlyStudio,
|
|
403
|
+
connectionStatus,
|
|
404
|
+
publicFolderExists: window.remotion_publicFolderExists,
|
|
405
|
+
});
|
|
289
406
|
const deleteAsset = (0, react_1.useCallback)(() => {
|
|
290
407
|
confirm({
|
|
291
408
|
title: 'Delete asset',
|
|
@@ -310,90 +427,34 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
|
|
|
310
427
|
(0, NotificationCenter_1.showNotification)(`Could not delete ${relativePath}: ${err.message}`, 3000);
|
|
311
428
|
});
|
|
312
429
|
}, [confirm, relativePath]);
|
|
430
|
+
const renameAsset = (0, react_1.useCallback)(() => {
|
|
431
|
+
setSelectedModal({
|
|
432
|
+
type: 'rename-static-file',
|
|
433
|
+
relativePath,
|
|
434
|
+
});
|
|
435
|
+
}, [relativePath, setSelectedModal]);
|
|
313
436
|
const contextMenu = (0, react_1.useMemo)(() => {
|
|
314
|
-
return
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
onClick: copyFileName,
|
|
326
|
-
quickSwitcherLabel: 'Copy asset file name',
|
|
327
|
-
subMenu: null,
|
|
328
|
-
type: 'item',
|
|
329
|
-
value: 'copy-asset-file-name',
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
id: 'copy-asset-static-file-path',
|
|
333
|
-
keyHint: null,
|
|
334
|
-
label: 'Copy staticFile() path',
|
|
335
|
-
leftItem: null,
|
|
336
|
-
onClick: copyStaticFilePath,
|
|
337
|
-
quickSwitcherLabel: 'Copy staticFile() path',
|
|
338
|
-
subMenu: null,
|
|
339
|
-
type: 'item',
|
|
340
|
-
value: 'copy-asset-static-file-path',
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
type: 'divider',
|
|
344
|
-
id: 'asset-file-actions-divider',
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
id: 'open-asset-in-explorer',
|
|
348
|
-
keyHint: null,
|
|
349
|
-
label: `Show in ${fileManagerName}`,
|
|
350
|
-
leftItem: null,
|
|
351
|
-
onClick: openAssetInExplorer,
|
|
352
|
-
quickSwitcherLabel: `Show asset in ${fileManagerName}`,
|
|
353
|
-
subMenu: null,
|
|
354
|
-
type: 'item',
|
|
355
|
-
value: 'open-asset-in-explorer',
|
|
356
|
-
disabled: serverActionDisabled || window.remotion_publicFolderExists === null,
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
id: 'rename-asset',
|
|
360
|
-
keyHint: null,
|
|
361
|
-
label: 'Rename...',
|
|
362
|
-
leftItem: null,
|
|
363
|
-
onClick: () => {
|
|
364
|
-
setSelectedModal({
|
|
365
|
-
type: 'rename-static-file',
|
|
366
|
-
relativePath,
|
|
367
|
-
});
|
|
368
|
-
},
|
|
369
|
-
quickSwitcherLabel: 'Rename asset...',
|
|
370
|
-
subMenu: null,
|
|
371
|
-
type: 'item',
|
|
372
|
-
value: 'rename-asset',
|
|
373
|
-
disabled: serverActionDisabled,
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
id: 'delete-asset',
|
|
377
|
-
keyHint: null,
|
|
378
|
-
label: 'Delete...',
|
|
379
|
-
leftItem: null,
|
|
380
|
-
onClick: deleteAsset,
|
|
381
|
-
quickSwitcherLabel: 'Delete asset...',
|
|
382
|
-
subMenu: null,
|
|
383
|
-
type: 'item',
|
|
384
|
-
value: 'delete-asset',
|
|
385
|
-
disabled: serverActionDisabled,
|
|
386
|
-
},
|
|
387
|
-
];
|
|
437
|
+
return (0, exports.getAssetContextMenuItems)({
|
|
438
|
+
relativePath,
|
|
439
|
+
fileManagerName,
|
|
440
|
+
copyFileName,
|
|
441
|
+
copyStaticFilePath,
|
|
442
|
+
openAssetInExplorer,
|
|
443
|
+
renameAsset,
|
|
444
|
+
deleteAsset,
|
|
445
|
+
fileExplorerDisabled,
|
|
446
|
+
mutationsDisabled,
|
|
447
|
+
});
|
|
388
448
|
}, [
|
|
389
449
|
copyFileName,
|
|
390
450
|
copyStaticFilePath,
|
|
391
451
|
deleteAsset,
|
|
452
|
+
fileExplorerDisabled,
|
|
392
453
|
fileManagerName,
|
|
454
|
+
mutationsDisabled,
|
|
393
455
|
openAssetInExplorer,
|
|
456
|
+
renameAsset,
|
|
394
457
|
relativePath,
|
|
395
|
-
serverActionDisabled,
|
|
396
|
-
setSelectedModal,
|
|
397
458
|
]);
|
|
398
459
|
const revealInExplorer = (0, react_1.useCallback)((e) => {
|
|
399
460
|
e.stopPropagation();
|
|
@@ -405,7 +466,7 @@ const AssetSelectorItem = ({ item, tabIndex, level, parentFolder, readOnlyStudio
|
|
|
405
466
|
}, [copyStaticFilePath]);
|
|
406
467
|
return (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { values: contextMenu, onOpen: null, children: jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("div", { ref: rowRef, style: style, onPointerEnter: onPointerEnter, onPointerLeave: onPointerLeave, onClick: onClick, draggable: canDragAsset, onDragStart: onDragStart, onDragEnd: onDragEnd, tabIndex: tabIndex, title: item.name, children: [
|
|
407
468
|
jsx_runtime_1.jsx(AssetFileIcon_1.AssetFileIcon, { fileType: previewFileType, style: iconStyle, color: colors_1.LIGHT_TEXT }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: label, children: item.name }), hovered && !isDragging ? (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
408
|
-
jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(InlineAction_1.InlineAction, { title: "Copy staticFile() path", renderAction: renderCopyAction, onClick: copyToClipboard }),
|
|
469
|
+
jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(InlineAction_1.InlineAction, { title: "Copy staticFile() path", renderAction: renderCopyAction, onClick: copyToClipboard }), fileExplorerDisabled ? null : (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
409
470
|
jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(InlineAction_1.InlineAction, { title: `Show in ${fileManagerName}`, renderAction: renderFileExplorerAction, onClick: revealInExplorer })
|
|
410
471
|
] }))] })) : null] }) }) }));
|
|
411
472
|
};
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Canvas = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const drag_and_drop_1 = require("@remotion/drag-and-drop");
|
|
8
9
|
const react_1 = require("react");
|
|
9
10
|
const remotion_1 = require("remotion");
|
|
10
11
|
const get_static_files_1 = require("../api/get-static-files");
|
|
@@ -22,8 +23,10 @@ const studio_fit_padding_1 = require("../helpers/studio-fit-padding");
|
|
|
22
23
|
const use_keybinding_1 = require("../helpers/use-keybinding");
|
|
23
24
|
const canvas_ref_1 = require("../state/canvas-ref");
|
|
24
25
|
const editor_guides_1 = require("../state/editor-guides");
|
|
26
|
+
const editor_snapping_1 = require("../state/editor-snapping");
|
|
25
27
|
const editor_zoom_gestures_1 = require("../state/editor-zoom-gestures");
|
|
26
28
|
const call_api_1 = require("./call-api");
|
|
29
|
+
const composition_drop_preview_1 = require("./composition-drop-preview");
|
|
27
30
|
const ConfirmationDialog_1 = require("./ConfirmationDialog");
|
|
28
31
|
const drop_handler_data_1 = require("./drop-handler-data");
|
|
29
32
|
const EditorGuides_1 = __importDefault(require("./EditorGuides"));
|
|
@@ -37,6 +40,7 @@ const NotificationCenter_1 = require("./Notifications/NotificationCenter");
|
|
|
37
40
|
const Preview_1 = require("./Preview");
|
|
38
41
|
const ResetZoomButton_1 = require("./ResetZoomButton");
|
|
39
42
|
const SvgImportDialog_1 = require("./SvgImportDialog");
|
|
43
|
+
const imperative_state_1 = require("./Timeline/imperative-state");
|
|
40
44
|
const use_resolved_stack_1 = require("./Timeline/use-resolved-stack");
|
|
41
45
|
const elementInstallCompositionIdStyle = {
|
|
42
46
|
fontFamily: 'monospace',
|
|
@@ -100,7 +104,7 @@ const calculateCanvasScale = ({ addFitPadding, canvasSize, compositionHeight, co
|
|
|
100
104
|
? (0, studio_fit_padding_1.calculateStudioScale)(options)
|
|
101
105
|
: remotion_1.Internals.calculateScale(options);
|
|
102
106
|
};
|
|
103
|
-
const getDropPosition = ({ addFitPadding, clientX, clientY, contentDimensions, previewSize, size, }) => {
|
|
107
|
+
const getDropPosition = ({ addFitPadding, clientX, clientY, contentDimensions, unbounded, previewSize, size, }) => {
|
|
104
108
|
if (contentDimensions === null || contentDimensions === 'none') {
|
|
105
109
|
return null;
|
|
106
110
|
}
|
|
@@ -111,7 +115,10 @@ const getDropPosition = ({ addFitPadding, clientX, clientY, contentDimensions, p
|
|
|
111
115
|
compositionWidth: contentDimensions.width,
|
|
112
116
|
previewSize: previewSize.size,
|
|
113
117
|
});
|
|
114
|
-
const
|
|
118
|
+
const getCenterPoint = unbounded
|
|
119
|
+
? get_effective_translation_1.getUnboundedCenterPointWhileScrolling
|
|
120
|
+
: get_effective_translation_1.getCenterPointWhileScrolling;
|
|
121
|
+
const { centerX, centerY } = getCenterPoint({
|
|
115
122
|
size,
|
|
116
123
|
clientX,
|
|
117
124
|
clientY,
|
|
@@ -155,12 +162,14 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
155
162
|
const config = remotion_1.Internals.useUnsafeVideoConfig();
|
|
156
163
|
const areRulersVisible = (0, use_is_ruler_visible_1.useIsRulerVisible)();
|
|
157
164
|
const { editorShowGuides } = (0, react_1.useContext)(editor_guides_1.EditorShowGuidesContext);
|
|
165
|
+
const { editorSnapping } = (0, react_1.useContext)(editor_snapping_1.EditorSnappingContext);
|
|
158
166
|
const { compositions } = (0, react_1.useContext)(remotion_1.Internals.CompositionManager);
|
|
159
167
|
const { previewServerState, subscribeToEvent } = (0, react_1.useContext)(client_id_1.StudioServerConnectionCtx);
|
|
160
168
|
const previewServerClientId = previewServerState.type === 'connected'
|
|
161
169
|
? previewServerState.clientId
|
|
162
170
|
: null;
|
|
163
171
|
const [isAddingAsset, setIsAddingAsset] = (0, react_1.useState)(false);
|
|
172
|
+
const [compositionDropPreview, setCompositionDropPreview] = (0, react_1.useState)(null);
|
|
164
173
|
const [installingElementName, setInstallingElementName] = (0, react_1.useState)(null);
|
|
165
174
|
const [pendingElementInstallRequests, setPendingElementInstallRequests] = (0, react_1.useState)([]);
|
|
166
175
|
const [activeElementInstallRequest, setActiveElementInstallRequest] = (0, react_1.useState)(null);
|
|
@@ -696,18 +705,109 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
696
705
|
};
|
|
697
706
|
}, [activeElementInstallRequest, confirm]);
|
|
698
707
|
const onDragOver = (0, react_1.useCallback)((event) => {
|
|
708
|
+
var _a;
|
|
709
|
+
var _b;
|
|
699
710
|
if (!(0, drop_handler_data_1.isSupportedDropEvent)(event) || !isDragEventInsideCanvas(event)) {
|
|
711
|
+
setCompositionDropPreview(null);
|
|
700
712
|
return;
|
|
701
713
|
}
|
|
702
714
|
if (!canDropAssets && !cannotAddSequence) {
|
|
715
|
+
setCompositionDropPreview(null);
|
|
703
716
|
return;
|
|
704
717
|
}
|
|
705
718
|
event.preventDefault();
|
|
706
719
|
if (event.dataTransfer) {
|
|
707
720
|
event.dataTransfer.dropEffect = canDropAssets ? 'copy' : 'none';
|
|
708
721
|
}
|
|
709
|
-
|
|
722
|
+
if (!canDropAssets ||
|
|
723
|
+
contentDimensions === null ||
|
|
724
|
+
contentDimensions === 'none') {
|
|
725
|
+
setCompositionDropPreview(null);
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const metadata = drag_and_drop_1.DragAndDropInternals.getDragPreviewMetadata((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) !== null && _b !== void 0 ? _b : []);
|
|
729
|
+
if ((metadata === null || metadata === void 0 ? void 0 : metadata.type) !== 'composition' ||
|
|
730
|
+
metadata.width === undefined ||
|
|
731
|
+
metadata.height === undefined) {
|
|
732
|
+
setCompositionDropPreview(null);
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
let dropPosition = getDropPosition({
|
|
736
|
+
addFitPadding,
|
|
737
|
+
clientX: event.clientX,
|
|
738
|
+
clientY: event.clientY,
|
|
739
|
+
contentDimensions,
|
|
740
|
+
unbounded: true,
|
|
741
|
+
previewSize,
|
|
742
|
+
size,
|
|
743
|
+
});
|
|
744
|
+
if (dropPosition === null) {
|
|
745
|
+
setCompositionDropPreview(null);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
const compositionDimensions = {
|
|
749
|
+
width: metadata.width,
|
|
750
|
+
height: metadata.height,
|
|
751
|
+
};
|
|
752
|
+
if (editorSnapping && !event.metaKey && !event.ctrlKey) {
|
|
753
|
+
dropPosition = (0, composition_drop_preview_1.snapCompositionDropPosition)({
|
|
754
|
+
compositionDimensions,
|
|
755
|
+
destinationDimensions: contentDimensions,
|
|
756
|
+
dropPosition,
|
|
757
|
+
scale: calculateCanvasScale({
|
|
758
|
+
addFitPadding,
|
|
759
|
+
canvasSize: size,
|
|
760
|
+
compositionHeight: contentDimensions.height,
|
|
761
|
+
compositionWidth: contentDimensions.width,
|
|
762
|
+
previewSize: previewSize.size,
|
|
763
|
+
}),
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
setCompositionDropPreview((currentPreview) => {
|
|
767
|
+
if ((currentPreview === null || currentPreview === void 0 ? void 0 : currentPreview.compositionDimensions.width) ===
|
|
768
|
+
compositionDimensions.width &&
|
|
769
|
+
currentPreview.compositionDimensions.height ===
|
|
770
|
+
compositionDimensions.height &&
|
|
771
|
+
currentPreview.dropPosition.centerX === dropPosition.centerX &&
|
|
772
|
+
currentPreview.dropPosition.centerY === dropPosition.centerY) {
|
|
773
|
+
return currentPreview;
|
|
774
|
+
}
|
|
775
|
+
return {
|
|
776
|
+
compositionDimensions,
|
|
777
|
+
dropPosition,
|
|
778
|
+
};
|
|
779
|
+
});
|
|
780
|
+
}, [
|
|
781
|
+
addFitPadding,
|
|
782
|
+
canDropAssets,
|
|
783
|
+
cannotAddSequence,
|
|
784
|
+
contentDimensions,
|
|
785
|
+
editorSnapping,
|
|
786
|
+
previewSize,
|
|
787
|
+
size,
|
|
788
|
+
]);
|
|
789
|
+
const onDragLeave = (0, react_1.useCallback)((event) => {
|
|
790
|
+
const canvas = canvas_ref_1.canvasRef.current;
|
|
791
|
+
if (canvas !== null) {
|
|
792
|
+
const rect = canvas.getBoundingClientRect();
|
|
793
|
+
if ((event.clientX >= rect.left &&
|
|
794
|
+
event.clientX <= rect.right &&
|
|
795
|
+
event.clientY >= rect.top &&
|
|
796
|
+
event.clientY <= rect.bottom) ||
|
|
797
|
+
(event.relatedTarget instanceof Node &&
|
|
798
|
+
canvas.contains(event.relatedTarget))) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
setCompositionDropPreview(null);
|
|
803
|
+
}, []);
|
|
804
|
+
const onDragEnd = (0, react_1.useCallback)(() => {
|
|
805
|
+
setCompositionDropPreview(null);
|
|
806
|
+
}, []);
|
|
710
807
|
const onDrop = (0, react_1.useCallback)(async (event) => {
|
|
808
|
+
var _a;
|
|
809
|
+
var _b;
|
|
810
|
+
setCompositionDropPreview(null);
|
|
711
811
|
if (!(0, drop_handler_data_1.isSupportedDropEvent)(event) || !isDragEventInsideCanvas(event)) {
|
|
712
812
|
return;
|
|
713
813
|
}
|
|
@@ -732,14 +832,42 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
732
832
|
event.stopPropagation();
|
|
733
833
|
setIsAddingAsset(true);
|
|
734
834
|
try {
|
|
735
|
-
const
|
|
835
|
+
const metadata = drag_and_drop_1.DragAndDropInternals.getDragPreviewMetadata((_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.types) !== null && _b !== void 0 ? _b : []);
|
|
836
|
+
const isComposition = (metadata === null || metadata === void 0 ? void 0 : metadata.type) === 'composition';
|
|
837
|
+
let dropPosition = getDropPosition({
|
|
736
838
|
addFitPadding,
|
|
737
839
|
clientX: event.clientX,
|
|
738
840
|
clientY: event.clientY,
|
|
739
841
|
contentDimensions,
|
|
842
|
+
unbounded: isComposition,
|
|
740
843
|
previewSize,
|
|
741
844
|
size,
|
|
742
845
|
});
|
|
846
|
+
if (dropPosition !== null &&
|
|
847
|
+
isComposition &&
|
|
848
|
+
metadata.width !== undefined &&
|
|
849
|
+
metadata.height !== undefined &&
|
|
850
|
+
contentDimensions !== null &&
|
|
851
|
+
contentDimensions !== 'none' &&
|
|
852
|
+
editorSnapping &&
|
|
853
|
+
!event.metaKey &&
|
|
854
|
+
!event.ctrlKey) {
|
|
855
|
+
dropPosition = (0, composition_drop_preview_1.snapCompositionDropPosition)({
|
|
856
|
+
compositionDimensions: {
|
|
857
|
+
width: metadata.width,
|
|
858
|
+
height: metadata.height,
|
|
859
|
+
},
|
|
860
|
+
destinationDimensions: contentDimensions,
|
|
861
|
+
dropPosition,
|
|
862
|
+
scale: calculateCanvasScale({
|
|
863
|
+
addFitPadding,
|
|
864
|
+
canvasSize: size,
|
|
865
|
+
compositionHeight: contentDimensions.height,
|
|
866
|
+
compositionWidth: contentDimensions.width,
|
|
867
|
+
previewSize: previewSize.size,
|
|
868
|
+
}),
|
|
869
|
+
});
|
|
870
|
+
}
|
|
743
871
|
await (0, handle_drop_1.handleDrop)({
|
|
744
872
|
chooseSvgImportMode,
|
|
745
873
|
compositionFile,
|
|
@@ -748,7 +876,7 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
748
876
|
dropPosition,
|
|
749
877
|
event,
|
|
750
878
|
fps: config.fps,
|
|
751
|
-
from:
|
|
879
|
+
from: (0, imperative_state_1.getCurrentFrame)(),
|
|
752
880
|
});
|
|
753
881
|
}
|
|
754
882
|
finally {
|
|
@@ -763,6 +891,7 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
763
891
|
config,
|
|
764
892
|
contentDimensions,
|
|
765
893
|
currentCompositionId,
|
|
894
|
+
editorSnapping,
|
|
766
895
|
previewSize,
|
|
767
896
|
size,
|
|
768
897
|
]);
|
|
@@ -861,12 +990,16 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
861
990
|
]);
|
|
862
991
|
(0, react_1.useEffect)(() => {
|
|
863
992
|
document.addEventListener('dragover', onDragOver, { capture: true });
|
|
993
|
+
document.addEventListener('dragleave', onDragLeave, { capture: true });
|
|
994
|
+
document.addEventListener('dragend', onDragEnd, { capture: true });
|
|
864
995
|
document.addEventListener('drop', onDrop, { capture: true });
|
|
865
996
|
return () => {
|
|
866
997
|
document.removeEventListener('dragover', onDragOver, { capture: true });
|
|
998
|
+
document.removeEventListener('dragleave', onDragLeave, { capture: true });
|
|
999
|
+
document.removeEventListener('dragend', onDragEnd, { capture: true });
|
|
867
1000
|
document.removeEventListener('drop', onDrop, { capture: true });
|
|
868
1001
|
};
|
|
869
|
-
}, [onDragOver, onDrop]);
|
|
1002
|
+
}, [onDragEnd, onDragLeave, onDragOver, onDrop]);
|
|
870
1003
|
(0, react_1.useEffect)(() => {
|
|
871
1004
|
if (!canDropAssets ||
|
|
872
1005
|
!keybindings.isHighestContext ||
|
|
@@ -876,7 +1009,29 @@ const Canvas = ({ canvasContent, size }) => {
|
|
|
876
1009
|
document.addEventListener('paste', onPaste);
|
|
877
1010
|
return () => document.removeEventListener('paste', onPaste);
|
|
878
1011
|
}, [canDropAssets, keybindings.isHighestContext, onPaste]);
|
|
1012
|
+
const compositionDropPreviewStyle = (0, react_1.useMemo)(() => {
|
|
1013
|
+
if (compositionDropPreview === null ||
|
|
1014
|
+
contentDimensions === null ||
|
|
1015
|
+
contentDimensions === 'none') {
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
const box = (0, composition_drop_preview_1.getCompositionDropPreviewBox)({
|
|
1019
|
+
canvasSize: size,
|
|
1020
|
+
destinationDimensions: contentDimensions,
|
|
1021
|
+
preview: compositionDropPreview,
|
|
1022
|
+
previewSize,
|
|
1023
|
+
});
|
|
1024
|
+
return {
|
|
1025
|
+
...box,
|
|
1026
|
+
position: 'absolute',
|
|
1027
|
+
boxSizing: 'border-box',
|
|
1028
|
+
border: colors_1.BORDER_TIMELINE_DROP_BLUE,
|
|
1029
|
+
backgroundColor: colors_1.TIMELINE_DROP_BLUE_ALPHA_16,
|
|
1030
|
+
pointerEvents: 'none',
|
|
1031
|
+
zIndex: 1,
|
|
1032
|
+
};
|
|
1033
|
+
}, [compositionDropPreview, contentDimensions, previewSize, size]);
|
|
879
1034
|
return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
|
|
880
|
-
jsx_runtime_1.jsxs("div", { ref: canvas_ref_1.canvasRef, style: getContainerStyle(editorZoomGestures), children: [size ? (jsx_runtime_1.jsx(Preview_1.VideoPreview, { canvasContent: canvasContent, contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, onRetryAssetMetadata: fetchMetadata })) : null, isFit ? null : (jsx_runtime_1.jsx("div", { style: resetZoom, className: "css-reset", children: jsx_runtime_1.jsx(ResetZoomButton_1.ResetZoomButton, { onClick: onReset }) })), editorShowGuides && canvasContent.type === 'composition' && (jsx_runtime_1.jsx(EditorGuides_1.default, { canvasSize: size, contentDimensions: contentDimensions, assetMetadata: assetResolution }))] }), areRulersVisible && (jsx_runtime_1.jsx(EditorRuler_1.EditorRulers, { contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, containerRef: canvas_ref_1.canvasRef }))] }));
|
|
1035
|
+
jsx_runtime_1.jsxs("div", { ref: canvas_ref_1.canvasRef, style: getContainerStyle(editorZoomGestures), children: [size ? (jsx_runtime_1.jsx(Preview_1.VideoPreview, { canvasContent: canvasContent, contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, onRetryAssetMetadata: fetchMetadata })) : null, compositionDropPreviewStyle === null ? null : (jsx_runtime_1.jsx("div", { className: "css-reset", "data-testid": "composition-drop-preview", style: compositionDropPreviewStyle })), isFit ? null : (jsx_runtime_1.jsx("div", { style: resetZoom, className: "css-reset", children: jsx_runtime_1.jsx(ResetZoomButton_1.ResetZoomButton, { onClick: onReset }) })), editorShowGuides && canvasContent.type === 'composition' && (jsx_runtime_1.jsx(EditorGuides_1.default, { canvasSize: size, contentDimensions: contentDimensions, assetMetadata: assetResolution }))] }), areRulersVisible && (jsx_runtime_1.jsx(EditorRuler_1.EditorRulers, { contentDimensions: contentDimensions, canvasSize: size, assetMetadata: assetResolution, containerRef: canvas_ref_1.canvasRef }))] }));
|
|
881
1036
|
};
|
|
882
1037
|
exports.Canvas = Canvas;
|