@remotion/studio 4.0.520 → 4.0.521

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/api/shut-down-studio.d.ts +6 -0
  2. package/dist/api/shut-down-studio.js +23 -0
  3. package/dist/components/AudioWaveform.js +10 -6
  4. package/dist/components/Canvas.js +84 -12
  5. package/dist/components/CaptionInspector.d.ts +1 -0
  6. package/dist/components/CaptionInspector.js +43 -2
  7. package/dist/components/CaptionTextEditor.js +1 -1
  8. package/dist/components/CompositionSelector.js +41 -30
  9. package/dist/components/CompositionSelectorItem.d.ts +7 -0
  10. package/dist/components/CompositionSelectorItem.js +343 -67
  11. package/dist/components/ElementInstallConfirmation.js +74 -64
  12. package/dist/components/ElementLibraryModal.js +3 -1
  13. package/dist/components/InlineCaptionInspector.js +37 -1
  14. package/dist/components/InspectorPanel/ElementLibraryButton.js +3 -18
  15. package/dist/components/InspectorSequenceSection.js +1 -4
  16. package/dist/components/Menu/MenuSubItem.js +1 -1
  17. package/dist/components/ModalContainer.d.ts +1 -0
  18. package/dist/components/ModalContainer.js +2 -2
  19. package/dist/components/ModalHeader.js +5 -1
  20. package/dist/components/QuickSwitcher/asset-search.d.ts +0 -1
  21. package/dist/components/QuickSwitcher/asset-search.js +1 -16
  22. package/dist/components/RenderButton.js +2 -2
  23. package/dist/components/RenderModal/RenderStatusModal.js +7 -1
  24. package/dist/components/RenderModal/ServerRenderModal.js +1 -1
  25. package/dist/components/RenderModal/WebRenderModal.js +1 -1
  26. package/dist/components/RenderQueue/ClientRenderQueueProcessor.js +1 -1
  27. package/dist/components/SettingsModal.js +8 -5
  28. package/dist/components/TimeValue.js +36 -7
  29. package/dist/components/Timeline/Timeline.d.ts +1 -1
  30. package/dist/components/Timeline/Timeline.js +31 -19
  31. package/dist/components/Timeline/TimelineAssetField.d.ts +0 -1
  32. package/dist/components/Timeline/TimelineAssetField.js +16 -9
  33. package/dist/components/Timeline/TimelineCollapseToggle.js +1 -1
  34. package/dist/components/Timeline/TimelineFontWeightField.d.ts +11 -0
  35. package/dist/components/Timeline/TimelineFontWeightField.js +65 -0
  36. package/dist/components/Timeline/TimelineLayerChildren.d.ts +21 -0
  37. package/dist/components/Timeline/TimelineLayerChildren.js +129 -0
  38. package/dist/components/Timeline/TimelineNumberField.js +13 -5
  39. package/dist/components/Timeline/TimelinePrimitiveFieldValue.js +4 -0
  40. package/dist/components/Timeline/TimelineSequence.js +38 -32
  41. package/dist/components/Timeline/TimelineSequenceItem.js +2 -1
  42. package/dist/components/Timeline/TimelineSequenceRightEdgeDragHandle.js +19 -7
  43. package/dist/components/Timeline/TimelineTickFormatProvider.d.ts +8 -0
  44. package/dist/components/Timeline/TimelineTickFormatProvider.js +16 -0
  45. package/dist/components/Timeline/TimelineTimeIndicators.js +7 -3
  46. package/dist/components/Timeline/TimelineVideoInfo.js +7 -3
  47. package/dist/components/Timeline/timeline-field-display-utils.js +1 -0
  48. package/dist/components/UpdateStatusContext.d.ts +5 -0
  49. package/dist/components/UpdateStatusContext.js +53 -2
  50. package/dist/components/UpdatesSettings.js +25 -4
  51. package/dist/components/WebMcp.js +26 -0
  52. package/dist/components/composition-selector-drag-data.d.ts +27 -0
  53. package/dist/components/composition-selector-drag-data.js +80 -0
  54. package/dist/components/import-assets.d.ts +2 -1
  55. package/dist/components/import-assets.js +11 -1
  56. package/dist/components/parse-caption-file.d.ts +5 -0
  57. package/dist/components/parse-caption-file.js +63 -0
  58. package/dist/esm/chunk-emw4k5b0.js +99527 -0
  59. package/dist/esm/{chunk-np6q13k5.js → chunk-vkrvnx2h.js} +5913 -4699
  60. package/dist/esm/index.mjs +23 -8
  61. package/dist/esm/internals.mjs +6729 -5366
  62. package/dist/esm/previewEntry.mjs +6779 -5416
  63. package/dist/esm/renderEntry.mjs +1 -1
  64. package/dist/helpers/get-preview-file-type.js +22 -3
  65. package/dist/helpers/inserted-element-selection.d.ts +2 -1
  66. package/dist/helpers/use-menu-structure.js +2 -2
  67. package/dist/index.d.ts +1 -0
  68. package/dist/index.js +3 -1
  69. package/dist/state/modals.d.ts +0 -2
  70. package/package.json +16 -16
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompositionSelectorItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const browser_studio_operations_1 = require("../helpers/browser-studio-operations");
6
7
  const client_id_1 = require("../helpers/client-id");
7
8
  const colors_1 = require("../helpers/colors");
8
9
  const hoverable_1 = require("../helpers/hoverable");
@@ -12,6 +13,7 @@ const folder_1 = require("../icons/folder");
12
13
  const modals_1 = require("../state/modals");
13
14
  const composition_drag_data_1 = require("./composition-drag-data");
14
15
  const composition_menu_items_1 = require("./composition-menu-items");
16
+ const composition_selector_drag_data_1 = require("./composition-selector-drag-data");
15
17
  const CompositionContextButton_1 = require("./CompositionContextButton");
16
18
  const CompositionOrStillIcon_1 = require("./CompositionOrStillIcon");
17
19
  const ContextMenu_1 = require("./ContextMenu");
@@ -56,7 +58,56 @@ const iconStyle = {
56
58
  height: 18,
57
59
  flexShrink: 0,
58
60
  };
59
- const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, selectComposition, toggleFolder, clearRootDragHover, }) => {
61
+ const reorderWrapper = {
62
+ position: 'relative',
63
+ };
64
+ const reorderLineBase = {
65
+ backgroundColor: colors_1.TIMELINE_BLUE,
66
+ height: 2,
67
+ left: 0,
68
+ pointerEvents: 'none',
69
+ position: 'absolute',
70
+ right: 0,
71
+ zIndex: 1,
72
+ };
73
+ const folderAutoExpansionDelay = 700;
74
+ const itemToDescriptor = (item) => {
75
+ return item.type === 'composition'
76
+ ? { type: 'composition', compositionId: item.composition.id }
77
+ : {
78
+ type: 'folder',
79
+ folderName: item.folderName,
80
+ parentName: item.parentName,
81
+ };
82
+ };
83
+ const itemsAreEqual = (left, right) => {
84
+ if (left.type === 'composition') {
85
+ return (right.type === 'composition' && left.compositionId === right.compositionId);
86
+ }
87
+ return (right.type === 'folder' &&
88
+ left.folderName === right.folderName &&
89
+ left.parentName === right.parentName);
90
+ };
91
+ const getFolderPath = ({ folderName, parentName, }) => {
92
+ return [parentName, folderName].filter(Boolean).join('/');
93
+ };
94
+ const wouldMoveFolderIntoItself = ({ activeDrag, destinationParentFolderPath, }) => {
95
+ if (activeDrag.item.type !== 'folder' ||
96
+ destinationParentFolderPath === null) {
97
+ return false;
98
+ }
99
+ const sourceFolderPath = getFolderPath(activeDrag.item);
100
+ return (destinationParentFolderPath === sourceFolderPath ||
101
+ destinationParentFolderPath.startsWith(`${sourceFolderPath}/`));
102
+ };
103
+ const canMoveIntoFolder = ({ activeDrag, destinationFolderPath, }) => {
104
+ return (activeDrag.parentFolderPath !== destinationFolderPath &&
105
+ !wouldMoveFolderIntoItself({
106
+ activeDrag,
107
+ destinationParentFolderPath: destinationFolderPath,
108
+ }));
109
+ };
110
+ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, selectComposition, toggleFolder, clearRootDragHover, canReorder, activeDragRef, parentFolderPath, previousSibling, nextSibling, }) => {
60
111
  const selected = (0, react_1.useMemo)(() => {
61
112
  if (item.type === 'composition') {
62
113
  return currentComposition === item.composition.id;
@@ -64,7 +115,30 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
64
115
  return false;
65
116
  }, [item, currentComposition]);
66
117
  const [isDragging, setIsDragging] = (0, react_1.useState)(false);
67
- const [dragHovered, setDragHovered] = (0, react_1.useState)(false);
118
+ const [dropPosition, setDropPosition] = (0, react_1.useState)(null);
119
+ const dropPositionRef = (0, react_1.useRef)(null);
120
+ const folderExpansionTimer = (0, react_1.useRef)(null);
121
+ const folderExpansionRequested = (0, react_1.useRef)(false);
122
+ const cancelFolderExpansion = (0, react_1.useCallback)(() => {
123
+ if (folderExpansionTimer.current !== null) {
124
+ window.clearTimeout(folderExpansionTimer.current);
125
+ folderExpansionTimer.current = null;
126
+ }
127
+ }, []);
128
+ const updateDropPosition = (0, react_1.useCallback)((position) => {
129
+ dropPositionRef.current = position;
130
+ setDropPosition(position);
131
+ }, []);
132
+ (0, react_1.useEffect)(() => {
133
+ return cancelFolderExpansion;
134
+ }, [cancelFolderExpansion]);
135
+ const folderIsExpanded = item.type === 'folder' && item.expanded;
136
+ (0, react_1.useEffect)(() => {
137
+ if (folderIsExpanded) {
138
+ folderExpansionRequested.current = false;
139
+ cancelFolderExpansion();
140
+ }
141
+ }, [cancelFolderExpansion, folderIsExpanded]);
68
142
  const compositionRowRef = (0, react_1.useRef)(null);
69
143
  const compositionId = item.type === 'composition' ? item.composition.id : null;
70
144
  (0, react_1.useLayoutEffect)(() => {
@@ -78,7 +152,7 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
78
152
  });
79
153
  }, [compositionId, selected]);
80
154
  const style = (0, react_1.useMemo)(() => {
81
- const idleBackground = dragHovered
155
+ const idleBackground = dropPosition === 'inside'
82
156
  ? colors_1.WHITE_ALPHA_12
83
157
  : selected
84
158
  ? colors_1.WHITE_ALPHA_06
@@ -87,13 +161,22 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
87
161
  ...itemStyle,
88
162
  ...(0, hoverable_1.hoverableStyle)({
89
163
  idleBackground,
90
- hoverBackground: dragHovered ? colors_1.WHITE_ALPHA_12 : colors_1.WHITE_ALPHA_06,
164
+ hoverBackground: dropPosition === 'inside' ? colors_1.WHITE_ALPHA_12 : colors_1.WHITE_ALPHA_06,
91
165
  idleColor: selected ? colors_1.WHITE : colors_1.LIGHT_TEXT,
92
166
  hoverColor: colors_1.WHITE,
93
167
  }),
94
168
  paddingLeft: 12 + level * 8,
95
169
  };
96
- }, [dragHovered, level, selected]);
170
+ }, [dropPosition, level, selected]);
171
+ const reorderLineStyle = (0, react_1.useMemo)(() => {
172
+ if (dropPosition !== 'before' && dropPosition !== 'after') {
173
+ return null;
174
+ }
175
+ return {
176
+ ...reorderLineBase,
177
+ ...(dropPosition === 'before' ? { top: -1 } : { bottom: -1 }),
178
+ };
179
+ }, [dropPosition]);
97
180
  const onClick = (0, react_1.useCallback)((evt) => {
98
181
  evt.preventDefault();
99
182
  if (item.type === 'composition') {
@@ -146,84 +229,185 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
146
229
  resolvedLocation,
147
230
  setSelectedModal,
148
231
  ]);
149
- const onCompositionDragStart = (0, react_1.useCallback)((event) => {
150
- var _a, _b, _c, _d;
151
- if (item.type !== 'composition' || window.remotion_isReadOnlyStudio) {
232
+ const onItemDragStart = (0, react_1.useCallback)((event) => {
233
+ var _a, _b, _c, _d, _e;
234
+ if (window.remotion_isReadOnlyStudio) {
152
235
  event.preventDefault();
153
236
  return;
154
237
  }
238
+ const itemDescriptor = itemToDescriptor(item);
239
+ activeDragRef.current = {
240
+ item: itemDescriptor,
241
+ parentFolderPath,
242
+ };
155
243
  setIsDragging(true);
156
244
  event.dataTransfer.effectAllowed = 'copyMove';
157
- const dragData = (0, composition_drag_data_1.makeCompositionDragData)({
158
- compositionFile: (_a = resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source) !== null && _a !== void 0 ? _a : null,
159
- compositionId: item.composition.id,
160
- width: (_b = item.composition.width) !== null && _b !== void 0 ? _b : null,
161
- height: (_c = item.composition.height) !== null && _c !== void 0 ? _c : null,
162
- durationInFrames: (_d = item.composition.durationInFrames) !== null && _d !== void 0 ? _d : null,
245
+ const selectorDragData = (0, composition_selector_drag_data_1.makeCompositionSelectorDragData)({
246
+ item: itemDescriptor,
247
+ sourceFile: (_a = resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source) !== null && _a !== void 0 ? _a : null,
163
248
  });
164
- event.dataTransfer.setData(dragData.mimeType, dragData.payload);
165
- }, [item, resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source]);
166
- const onCompositionDragEnd = (0, react_1.useCallback)(() => {
249
+ event.dataTransfer.setData(selectorDragData.mimeType, selectorDragData.payload);
250
+ if (item.type === 'composition') {
251
+ const browserStudioOperations = (0, browser_studio_operations_1.getBrowserStudioOperations)();
252
+ const compositionDragData = (0, composition_drag_data_1.makeCompositionDragData)({
253
+ compositionFile: browserStudioOperations === null
254
+ ? ((_b = resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source) !== null && _b !== void 0 ? _b : null)
255
+ : browserStudioOperations.getCompositionFile(item.composition.id),
256
+ compositionId: item.composition.id,
257
+ width: (_c = item.composition.width) !== null && _c !== void 0 ? _c : null,
258
+ height: (_d = item.composition.height) !== null && _d !== void 0 ? _d : null,
259
+ durationInFrames: (_e = item.composition.durationInFrames) !== null && _e !== void 0 ? _e : null,
260
+ });
261
+ event.dataTransfer.setData(compositionDragData.mimeType, compositionDragData.payload);
262
+ }
263
+ }, [activeDragRef, item, parentFolderPath, resolvedLocation === null || resolvedLocation === void 0 ? void 0 : resolvedLocation.source]);
264
+ const onItemDragEnd = (0, react_1.useCallback)(() => {
265
+ activeDragRef.current = null;
266
+ cancelFolderExpansion();
167
267
  setIsDragging(false);
168
- }, []);
169
- const onFolderDragOver = (0, react_1.useCallback)((event) => {
268
+ updateDropPosition(null);
269
+ }, [activeDragRef, cancelFolderExpansion, updateDropPosition]);
270
+ const getDropPosition = (0, react_1.useCallback)((event) => {
271
+ const activeDrag = activeDragRef.current;
272
+ if (activeDrag === null) {
273
+ return null;
274
+ }
275
+ if (!canReorder) {
276
+ if (item.type !== 'folder') {
277
+ return null;
278
+ }
279
+ return canMoveIntoFolder({
280
+ activeDrag,
281
+ destinationFolderPath: getFolderPath(item),
282
+ })
283
+ ? 'inside'
284
+ : null;
285
+ }
286
+ const { top, height } = event.currentTarget.getBoundingClientRect();
287
+ const progress = height === 0 ? 0.5 : (event.clientY - top) / height;
288
+ const position = item.type === 'composition'
289
+ ? progress < 0.5
290
+ ? 'before'
291
+ : 'after'
292
+ : progress < 0.25
293
+ ? 'before'
294
+ : progress > 0.75
295
+ ? 'after'
296
+ : 'inside';
297
+ const target = itemToDescriptor(item);
298
+ if (itemsAreEqual(activeDrag.item, target)) {
299
+ return null;
300
+ }
301
+ if (position === 'before' &&
302
+ previousSibling !== null &&
303
+ itemsAreEqual(activeDrag.item, itemToDescriptor(previousSibling))) {
304
+ return null;
305
+ }
306
+ if (position === 'after' &&
307
+ nextSibling !== null &&
308
+ itemsAreEqual(activeDrag.item, itemToDescriptor(nextSibling))) {
309
+ return null;
310
+ }
311
+ if (position === 'inside' && item.type === 'folder') {
312
+ return canMoveIntoFolder({
313
+ activeDrag,
314
+ destinationFolderPath: getFolderPath(item),
315
+ })
316
+ ? position
317
+ : null;
318
+ }
319
+ return wouldMoveFolderIntoItself({
320
+ activeDrag,
321
+ destinationParentFolderPath: parentFolderPath,
322
+ })
323
+ ? null
324
+ : position;
325
+ }, [
326
+ activeDragRef,
327
+ canReorder,
328
+ item,
329
+ nextSibling,
330
+ parentFolderPath,
331
+ previousSibling,
332
+ ]);
333
+ const scheduleFolderExpansion = (0, react_1.useCallback)(() => {
170
334
  if (item.type !== 'folder' ||
171
- window.remotion_isReadOnlyStudio ||
172
- (0, composition_drag_data_1.getCompositionDragPreviewMetadata)(event.dataTransfer.types) === null) {
335
+ item.expanded ||
336
+ folderExpansionTimer.current !== null ||
337
+ folderExpansionRequested.current) {
173
338
  return;
174
339
  }
175
- event.preventDefault();
176
- event.stopPropagation();
177
- event.dataTransfer.dropEffect = 'move';
178
- clearRootDragHover();
179
- setDragHovered(true);
180
- }, [clearRootDragHover, item]);
181
- const onFolderDragLeave = (0, react_1.useCallback)(() => {
182
- setDragHovered(false);
183
- }, []);
184
- const onFolderChildListDragOver = (0, react_1.useCallback)((event) => {
185
- if (item.type !== 'folder' ||
186
- window.remotion_isReadOnlyStudio ||
187
- (0, composition_drag_data_1.getCompositionDragPreviewMetadata)(event.dataTransfer.types) === null) {
340
+ const activeDrag = activeDragRef.current;
341
+ if (activeDrag === null ||
342
+ !canMoveIntoFolder({
343
+ activeDrag,
344
+ destinationFolderPath: getFolderPath(item),
345
+ })) {
188
346
  return;
189
347
  }
190
- event.preventDefault();
191
- event.stopPropagation();
192
- event.dataTransfer.dropEffect = 'move';
193
- clearRootDragHover();
194
- }, [clearRootDragHover, item]);
195
- const onFolderDrop = (0, react_1.useCallback)(async (event) => {
196
- if (item.type !== 'folder' || window.remotion_isReadOnlyStudio) {
348
+ folderExpansionTimer.current = window.setTimeout(() => {
349
+ folderExpansionTimer.current = null;
350
+ const currentActiveDrag = activeDragRef.current;
351
+ if (currentActiveDrag === null ||
352
+ !canMoveIntoFolder({
353
+ activeDrag: currentActiveDrag,
354
+ destinationFolderPath: getFolderPath(item),
355
+ })) {
356
+ return;
357
+ }
358
+ folderExpansionRequested.current = true;
359
+ toggleFolder(item.folderName, item.parentName);
360
+ }, folderAutoExpansionDelay);
361
+ }, [activeDragRef, item, toggleFolder]);
362
+ const onRowDragOver = (0, react_1.useCallback)((event) => {
363
+ if (window.remotion_isReadOnlyStudio ||
364
+ !(0, composition_selector_drag_data_1.hasCompositionSelectorDragData)(event.dataTransfer.types)) {
197
365
  return;
198
366
  }
199
- const compositionDragData = (0, composition_drag_data_1.parseCompositionDragData)(event.dataTransfer);
200
- if (compositionDragData === null) {
367
+ const position = getDropPosition(event);
368
+ if (position === null) {
369
+ cancelFolderExpansion();
370
+ updateDropPosition(null);
371
+ event.stopPropagation();
201
372
  return;
202
373
  }
374
+ if (position === 'inside') {
375
+ scheduleFolderExpansion();
376
+ }
377
+ else {
378
+ cancelFolderExpansion();
379
+ }
203
380
  event.preventDefault();
204
381
  event.stopPropagation();
382
+ event.dataTransfer.dropEffect = 'move';
205
383
  clearRootDragHover();
206
- setDragHovered(false);
207
- const isAlreadyDirectChild = item.items.some((child) => {
208
- return (child.type === 'composition' &&
209
- child.composition.id === compositionDragData.compositionId);
210
- });
211
- if (isAlreadyDirectChild) {
212
- return;
213
- }
214
- const notification = (0, NotificationCenter_1.showNotification)(`Moving ${compositionDragData.compositionId}...`, null);
215
- const controller = new AbortController();
384
+ updateDropPosition(position);
385
+ }, [
386
+ cancelFolderExpansion,
387
+ clearRootDragHover,
388
+ getDropPosition,
389
+ scheduleFolderExpansion,
390
+ updateDropPosition,
391
+ ]);
392
+ const onRowDragLeave = (0, react_1.useCallback)(() => {
393
+ cancelFolderExpansion();
394
+ updateDropPosition(null);
395
+ }, [cancelFolderExpansion, updateDropPosition]);
396
+ const moveItem = (0, react_1.useCallback)(async ({ destination, dragData, }) => {
397
+ const label = dragData.item.type === 'composition'
398
+ ? dragData.item.compositionId
399
+ : dragData.item.folderName;
400
+ const notification = (0, NotificationCenter_1.showNotification)(`Moving ${label}...`, null);
216
401
  try {
217
402
  const result = await (0, actions_1.applyCodemod)({
218
403
  codemod: {
219
- type: 'move-composition-to-folder',
220
- idToMove: compositionDragData.compositionId,
221
- folderName: item.folderName,
222
- parentName: item.parentName,
404
+ type: 'move-composition-or-folder',
405
+ source: dragData.item,
406
+ destination,
223
407
  },
224
408
  dryRun: false,
225
- signal: controller.signal,
226
- symbolicatedStack: (0, composition_drag_data_1.compositionDragDataToSymbolicatedStack)(compositionDragData),
409
+ signal: new AbortController().signal,
410
+ symbolicatedStack: (0, composition_selector_drag_data_1.compositionSelectorDragDataToSymbolicatedStack)(dragData),
227
411
  });
228
412
  if (result.success) {
229
413
  notification.dismiss();
@@ -231,23 +415,115 @@ const CompositionSelectorItem = ({ item, level, currentComposition, tabIndex, se
231
415
  else {
232
416
  notification.replaceContent(result.reason, 4000);
233
417
  }
234
- if (result.success && !item.expanded) {
418
+ if (result.success &&
419
+ destination.type === 'folder' &&
420
+ item.type === 'folder' &&
421
+ !item.expanded) {
235
422
  toggleFolder(item.folderName, item.parentName);
236
423
  }
237
424
  }
238
425
  catch (err) {
239
426
  notification.replaceContent(err instanceof Error ? err.message : String(err), 4000);
240
427
  }
241
- }, [clearRootDragHover, item, toggleFolder]);
428
+ }, [item, toggleFolder]);
429
+ const onRowDrop = (0, react_1.useCallback)(async (event) => {
430
+ cancelFolderExpansion();
431
+ const dragData = (0, composition_selector_drag_data_1.parseCompositionSelectorDragData)(event.dataTransfer);
432
+ const position = dropPositionRef.current;
433
+ if (dragData === null) {
434
+ return;
435
+ }
436
+ if (position === null) {
437
+ event.stopPropagation();
438
+ return;
439
+ }
440
+ event.preventDefault();
441
+ event.stopPropagation();
442
+ clearRootDragHover();
443
+ updateDropPosition(null);
444
+ await moveItem({
445
+ dragData,
446
+ destination: position === 'inside' && item.type === 'folder'
447
+ ? {
448
+ type: 'folder',
449
+ folderName: item.folderName,
450
+ parentName: item.parentName,
451
+ }
452
+ : {
453
+ type: position === 'before' ? 'before' : 'after',
454
+ target: itemToDescriptor(item),
455
+ },
456
+ });
457
+ }, [
458
+ cancelFolderExpansion,
459
+ clearRootDragHover,
460
+ item,
461
+ moveItem,
462
+ updateDropPosition,
463
+ ]);
464
+ const onFolderChildListDragOver = (0, react_1.useCallback)((event) => {
465
+ if (item.type !== 'folder' ||
466
+ window.remotion_isReadOnlyStudio ||
467
+ !(0, composition_selector_drag_data_1.hasCompositionSelectorDragData)(event.dataTransfer.types)) {
468
+ return;
469
+ }
470
+ const activeDrag = activeDragRef.current;
471
+ if (activeDrag === null ||
472
+ !canMoveIntoFolder({
473
+ activeDrag,
474
+ destinationFolderPath: getFolderPath(item),
475
+ })) {
476
+ event.stopPropagation();
477
+ return;
478
+ }
479
+ event.preventDefault();
480
+ event.stopPropagation();
481
+ event.dataTransfer.dropEffect = 'move';
482
+ clearRootDragHover();
483
+ }, [activeDragRef, clearRootDragHover, item]);
484
+ const onFolderChildListDrop = (0, react_1.useCallback)(async (event) => {
485
+ if (item.type !== 'folder' || window.remotion_isReadOnlyStudio) {
486
+ return;
487
+ }
488
+ const dragData = (0, composition_selector_drag_data_1.parseCompositionSelectorDragData)(event.dataTransfer);
489
+ if (dragData === null) {
490
+ return;
491
+ }
492
+ const activeDrag = activeDragRef.current;
493
+ if (activeDrag === null ||
494
+ !canMoveIntoFolder({
495
+ activeDrag,
496
+ destinationFolderPath: getFolderPath(item),
497
+ })) {
498
+ event.stopPropagation();
499
+ return;
500
+ }
501
+ event.preventDefault();
502
+ event.stopPropagation();
503
+ clearRootDragHover();
504
+ await moveItem({
505
+ dragData,
506
+ destination: {
507
+ type: 'folder',
508
+ folderName: item.folderName,
509
+ parentName: item.parentName,
510
+ },
511
+ });
512
+ }, [activeDragRef, clearRootDragHover, item, moveItem]);
242
513
  if (item.type === 'folder') {
514
+ const folderPath = getFolderPath(item);
243
515
  return (jsx_runtime_1.jsxs(jsx_runtime_1.Fragment, { children: [
244
- jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { getItems: getContextMenuItems, children: jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("div", { style: style, className: `__remotion-composition-selector-item ${hoverable_1.HOVERABLE_CLASS_NAME} ${hoverable_1.HOVER_GROUP_CLASS_NAME}`, tabIndex: tabIndex, onClick: onClick, onKeyDown: onKeyDown, onDragOver: onFolderDragOver, onDragLeave: onFolderDragLeave, onDrop: onFolderDrop, title: item.folderName, role: "button", children: [item.expanded ? (jsx_runtime_1.jsx(folder_1.ExpandedFolderIcon, { style: iconStyle, color: colors_1.CURRENT_COLOR })) : (jsx_runtime_1.jsx(folder_1.CollapsedFolderIcon, { color: colors_1.CURRENT_COLOR, style: iconStyle })), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelStyle, children: item.folderName }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { getItems: getContextMenuItems, visible: true, readOnlyStudio: window.remotion_isReadOnlyStudio })
245
- ] }) }) }), item.expanded ? (jsx_runtime_1.jsx("div", { onDragOver: onFolderChildListDragOver, onDrop: onFolderDrop, children: item.items.map((childItem) => {
246
- return (jsx_runtime_1.jsx(exports.CompositionSelectorItem, { currentComposition: currentComposition, selectComposition: selectComposition, item: childItem, tabIndex: tabIndex, level: level + 1, toggleFolder: toggleFolder, clearRootDragHover: clearRootDragHover }, childItem.key + childItem.type));
516
+ jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { getItems: getContextMenuItems, children: jsx_runtime_1.jsxs("div", { style: reorderWrapper, children: [reorderLineStyle ? (jsx_runtime_1.jsx("div", { "data-composition-reorder-line": true, style: reorderLineStyle })) : null, jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("div", { style: style, className: `__remotion-composition-selector-item ${hoverable_1.HOVERABLE_CLASS_NAME} ${hoverable_1.HOVER_GROUP_CLASS_NAME}`, tabIndex: tabIndex, onClick: onClick, onKeyDown: onKeyDown, draggable: !window.remotion_isReadOnlyStudio, onDragStart: onItemDragStart, onDragEnd: onItemDragEnd, onDragOver: onRowDragOver, onDragLeave: onRowDragLeave, onDrop: onRowDrop, title: item.folderName, role: "button", "aria-expanded": item.expanded, children: [item.expanded ? (jsx_runtime_1.jsx(folder_1.ExpandedFolderIcon, { style: iconStyle, color: colors_1.CURRENT_COLOR })) : (jsx_runtime_1.jsx(folder_1.CollapsedFolderIcon, { color: colors_1.CURRENT_COLOR, style: iconStyle })), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelStyle, children: item.folderName }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { getItems: getContextMenuItems, visible: true, readOnlyStudio: window.remotion_isReadOnlyStudio })
517
+ ] }) })
518
+ ] }) }), item.expanded ? (jsx_runtime_1.jsx("div", { onDragOver: onFolderChildListDragOver, onDrop: onFolderChildListDrop, children: item.items.map((childItem, index) => {
519
+ return (jsx_runtime_1.jsx(exports.CompositionSelectorItem, { currentComposition: currentComposition, selectComposition: selectComposition, item: childItem, tabIndex: tabIndex, level: level + 1, toggleFolder: toggleFolder, clearRootDragHover: clearRootDragHover, canReorder: canReorder, activeDragRef: activeDragRef, parentFolderPath: folderPath, previousSibling: index === 0 ? null : item.items[index - 1], nextSibling: index === item.items.length - 1
520
+ ? null
521
+ : item.items[index + 1] }, childItem.key + childItem.type));
247
522
  }) })) : null] }));
248
523
  }
249
- return (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { getItems: getContextMenuItems, children: jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("a", { ref: compositionRowRef, style: style, tabIndex: tabIndex, onClick: onClick, onKeyDown: onKeyDown, draggable: !window.remotion_isReadOnlyStudio, onDragStart: onCompositionDragStart, onDragEnd: onCompositionDragEnd, type: "button", title: item.composition.id, className: `__remotion-composition __remotion-composition-selector-item ${hoverable_1.HOVERABLE_CLASS_NAME} ${hoverable_1.HOVER_GROUP_CLASS_NAME}`, "data-compname": item.composition.id, children: [
250
- jsx_runtime_1.jsx(CompositionOrStillIcon_1.CompositionOrStillIcon, { composition: item.composition, color: colors_1.CURRENT_COLOR, style: iconStyle }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelStyle, children: item.composition.id }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { getItems: getContextMenuItems, visible: !isDragging, readOnlyStudio: window.remotion_isReadOnlyStudio }), jsx_runtime_1.jsx(SidebarRenderButton_1.SidebarRenderButton, { visible: !isDragging, composition: item.composition, readOnlyStudio: window.remotion_isReadOnlyStudio })
251
- ] }) }) }));
524
+ return (jsx_runtime_1.jsx(ContextMenu_1.ContextMenu, { getItems: getContextMenuItems, children: jsx_runtime_1.jsxs("div", { style: reorderWrapper, children: [reorderLineStyle ? (jsx_runtime_1.jsx("div", { "data-composition-reorder-line": true, style: reorderLineStyle })) : null, jsx_runtime_1.jsx(layout_1.Row, { align: "center", children: jsx_runtime_1.jsxs("a", { ref: compositionRowRef, style: style, tabIndex: tabIndex, onClick: onClick, onKeyDown: onKeyDown, draggable: !window.remotion_isReadOnlyStudio, onDragStart: onItemDragStart, onDragEnd: onItemDragEnd, onDragOver: onRowDragOver, onDragLeave: onRowDragLeave, onDrop: onRowDrop, type: "button", title: item.composition.id, className: `__remotion-composition __remotion-composition-selector-item ${hoverable_1.HOVERABLE_CLASS_NAME} ${hoverable_1.HOVER_GROUP_CLASS_NAME}`, "data-compname": item.composition.id, children: [
525
+ jsx_runtime_1.jsx(CompositionOrStillIcon_1.CompositionOrStillIcon, { composition: item.composition, color: colors_1.CURRENT_COLOR, style: iconStyle }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 1 }), jsx_runtime_1.jsx("div", { style: labelStyle, children: item.composition.id }), jsx_runtime_1.jsx(layout_1.Spacing, { x: 0.5 }), jsx_runtime_1.jsx(CompositionContextButton_1.CompositionContextButton, { getItems: getContextMenuItems, visible: !isDragging, readOnlyStudio: window.remotion_isReadOnlyStudio }), jsx_runtime_1.jsx(SidebarRenderButton_1.SidebarRenderButton, { visible: !isDragging, composition: item.composition, readOnlyStudio: window.remotion_isReadOnlyStudio })
526
+ ] }) })
527
+ ] }) }));
252
528
  };
253
529
  exports.CompositionSelectorItem = CompositionSelectorItem;