sense-react-timeline-editor 1.0.13 → 1.0.15

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.
@@ -1,4 +1,4 @@
1
- import React, { FC } from 'react';
1
+ import React from 'react';
2
2
  import { TimelineAction, TimelineRow } from '../../interface/action';
3
3
  import { CommonProp } from '../../interface/common_prop';
4
4
  import { DragLineData } from './drag_lines';
@@ -23,4 +23,4 @@ export declare type EditActionProps = CommonProp & {
23
23
  containerRef?: React.MutableRefObject<HTMLDivElement>;
24
24
  selectedActionIds?: string[];
25
25
  };
26
- export declare const EditAction: FC<EditActionProps>;
26
+ export declare const EditAction: React.NamedExoticComponent<EditActionProps>;
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback } from 'react';
2
2
  import { AutoSizer, Grid, ScrollSync } from 'react-virtualized';
3
- import { useThrottleEffect, useDebounceFn } from 'ahooks';
3
+ import { useThrottleEffect, useThrottleFn } from 'ahooks';
4
4
  import { prefixNames } from 'framework-utils';
5
5
  import interact from 'interactjs';
6
6
  import { useSelectionContainer } from '@air/react-drag-to-select';
@@ -2114,7 +2114,7 @@ styleInject(css_248z$3);
2114
2114
  var stretchIcon = "data:image/svg+xml,%3Csvg%20width%3D%227%22%20height%3D%2216%22%20viewBox%3D%220%200%207%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M7%2015C7%2015.5523%206.55228%2016%206%2016L1%2016C0.447715%2016%201.06779e-08%2015.5523%202.38498e-08%2015L3.57746e-07%201C3.70918e-07%200.447715%200.447716%20-1.5627e-07%201%20-1.43099e-07L6%209.29825e-07C6.55229%209.42996e-07%207%200.447716%207%201L7%2015Z%22%20fill%3D%22%23226EFF%22%2F%3E%3Cpath%20d%3D%22M2%204L2%2012%22%20stroke%3D%22white%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M4%2012.25L5.5%208L4%203.75%22%20fill%3D%22white%22%2F%3E%3Cpath%20d%3D%22M4%2012.25L5.5%208L4%203.75L4%2012.25Z%22%20stroke%3D%22white%22%20stroke-width%3D%220.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
2115
2115
 
2116
2116
  var _excluded = ["left", "width", "top"];
2117
- var EditAction = function EditAction(_ref) {
2117
+ var EditActionO = function EditActionO(_ref) {
2118
2118
  var editorData = _ref.editorData,
2119
2119
  row = _ref.row,
2120
2120
  action = _ref.action,
@@ -2150,7 +2150,6 @@ var EditAction = function EditAction(_ref) {
2150
2150
  setDropPreview = _ref.setDropPreview,
2151
2151
  containerRef = _ref.containerRef,
2152
2152
  selectedActionIds = _ref.selectedActionIds;
2153
- console.log('action: selectedActionIds = ', selectedActionIds);
2154
2153
  var rowRnd = useRef();
2155
2154
  var isDragWhenClick = useRef(false);
2156
2155
  var originalPosition = useRef({
@@ -2654,10 +2653,10 @@ var EditAction = function EditAction(_ref) {
2654
2653
  });
2655
2654
  }, [action, allowCreateTrack, editorData, id, onActionMoveEnd, parserTimeToTransform, parserTransformToTime, row, scale, scaleWidth, setDropPreview, setEditorData, startLeft, selectedActionIds]);
2656
2655
  // 防抖版本的 handleDragEnd
2657
- var _useDebounceFn = useDebounceFn(handleDragEndBase, {
2656
+ var _useThrottleFn = useThrottleFn(handleDragEndBase, {
2658
2657
  wait: 300
2659
2658
  }),
2660
- handleDragEnd = _useDebounceFn.run;
2659
+ handleDragEnd = _useThrottleFn.run;
2661
2660
  var handleResizeStart = function handleResizeStart(dir) {
2662
2661
  onActionResizeStart && onActionResizeStart({
2663
2662
  action: action,
@@ -2882,6 +2881,7 @@ var EditAction = function EditAction(_ref) {
2882
2881
  alt: ""
2883
2882
  }))));
2884
2883
  };
2884
+ var EditAction = /*#__PURE__*/React.memo(EditActionO);
2885
2885
 
2886
2886
  var css_248z$4 = ".timeline-editor-edit-row {\n background-repeat: no-repeat, repeat;\n display: flex;\n flex-direction: row;\n box-sizing: border-box;\n transition: background-color 0.15s ease, box-shadow 0.15s ease;\n}\n.timeline-editor-edit-row.preview-row {\n background-color: rgba(100, 150, 255, 0.15);\n border: 1px dashed rgba(100, 150, 255, 0.5);\n opacity: 0.8;\n transition: all 0.2s ease;\n}\n.timeline-editor-edit-row.selected {\n background-color: rgba(24, 144, 255, 0.08);\n box-shadow: inset 0 0 0 2px rgba(24, 144, 255, 0.4);\n position: relative;\n z-index: 10;\n}\n.timeline-editor-edit-row.selected::before {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n width: 3px;\n background-color: #1890ff;\n}\n.timeline-editor-edit-row.dragging {\n opacity: 0.6;\n cursor: move;\n}\n";
2887
2887
  styleInject(css_248z$4);
@@ -3377,8 +3377,8 @@ var useRowDrag = function useRowDrag(options) {
3377
3377
  var initialPos = state.initialElementPositions.get(elActionId);
3378
3378
  if (!initialPos) return;
3379
3379
  // 计算新位置 = 初始位置 + 总偏移量
3380
- var newX = initialPos.x + state.offsetX;
3381
- var newY = initialPos.y + state.offsetY;
3380
+ var newX = state.offsetX;
3381
+ var newY = state.offsetY;
3382
3382
  // 更新元素位置
3383
3383
  el.style.transform = "translate(".concat(newX, "px, ").concat(newY, "px)");
3384
3384
  // 存储当前位置数据
@@ -3735,7 +3735,8 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3735
3735
  url: info.file.response.url,
3736
3736
  start: currentMouseTime,
3737
3737
  end: currentMouseTime + duration,
3738
- isUpload: true
3738
+ isUpload: true,
3739
+ segment_type: 'bgm'
3739
3740
  };
3740
3741
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
3741
3742
  case 3:
@@ -4344,7 +4345,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4344
4345
  };
4345
4346
  /** 处理主动数据变化 */
4346
4347
  var handleEditorDataChange = function handleEditorDataChange(updatedData) {
4347
- var result = onChange(updatedData);
4348
+ var result = onChange === null || onChange === void 0 ? void 0 : onChange(updatedData);
4348
4349
  if (result !== false) {
4349
4350
  setEditorData(updatedData);
4350
4351
  engineRef.current.data = updatedData;
@@ -4529,7 +4530,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4529
4530
  var indexB = keys.indexOf(String(b.type));
4530
4531
  return indexA - indexB;
4531
4532
  });
4532
- var result = onChange(sortedMergedData);
4533
+ var result = onChange === null || onChange === void 0 ? void 0 : onChange(sortedMergedData);
4533
4534
  if (result !== false) {
4534
4535
  setEditorData(sortedMergedData);
4535
4536
  engineRef.current.data = sortedMergedData;
package/dist/index.js CHANGED
@@ -2123,7 +2123,7 @@ styleInject(css_248z$3);
2123
2123
  var stretchIcon = "data:image/svg+xml,%3Csvg%20width%3D%227%22%20height%3D%2216%22%20viewBox%3D%220%200%207%2016%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M7%2015C7%2015.5523%206.55228%2016%206%2016L1%2016C0.447715%2016%201.06779e-08%2015.5523%202.38498e-08%2015L3.57746e-07%201C3.70918e-07%200.447715%200.447716%20-1.5627e-07%201%20-1.43099e-07L6%209.29825e-07C6.55229%209.42996e-07%207%200.447716%207%201L7%2015Z%22%20fill%3D%22%23226EFF%22%2F%3E%3Cpath%20d%3D%22M2%204L2%2012%22%20stroke%3D%22white%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M4%2012.25L5.5%208L4%203.75%22%20fill%3D%22white%22%2F%3E%3Cpath%20d%3D%22M4%2012.25L5.5%208L4%203.75L4%2012.25Z%22%20stroke%3D%22white%22%20stroke-width%3D%220.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
2124
2124
 
2125
2125
  var _excluded = ["left", "width", "top"];
2126
- var EditAction = function EditAction(_ref) {
2126
+ var EditActionO = function EditActionO(_ref) {
2127
2127
  var editorData = _ref.editorData,
2128
2128
  row = _ref.row,
2129
2129
  action = _ref.action,
@@ -2159,7 +2159,6 @@ var EditAction = function EditAction(_ref) {
2159
2159
  setDropPreview = _ref.setDropPreview,
2160
2160
  containerRef = _ref.containerRef,
2161
2161
  selectedActionIds = _ref.selectedActionIds;
2162
- console.log('action: selectedActionIds = ', selectedActionIds);
2163
2162
  var rowRnd = React.useRef();
2164
2163
  var isDragWhenClick = React.useRef(false);
2165
2164
  var originalPosition = React.useRef({
@@ -2663,10 +2662,10 @@ var EditAction = function EditAction(_ref) {
2663
2662
  });
2664
2663
  }, [action, allowCreateTrack, editorData, id, onActionMoveEnd, parserTimeToTransform, parserTransformToTime, row, scale, scaleWidth, setDropPreview, setEditorData, startLeft, selectedActionIds]);
2665
2664
  // 防抖版本的 handleDragEnd
2666
- var _useDebounceFn = ahooks.useDebounceFn(handleDragEndBase, {
2665
+ var _useThrottleFn = ahooks.useThrottleFn(handleDragEndBase, {
2667
2666
  wait: 300
2668
2667
  }),
2669
- handleDragEnd = _useDebounceFn.run;
2668
+ handleDragEnd = _useThrottleFn.run;
2670
2669
  var handleResizeStart = function handleResizeStart(dir) {
2671
2670
  onActionResizeStart && onActionResizeStart({
2672
2671
  action: action,
@@ -2891,6 +2890,7 @@ var EditAction = function EditAction(_ref) {
2891
2890
  alt: ""
2892
2891
  }))));
2893
2892
  };
2893
+ var EditAction = /*#__PURE__*/React__default['default'].memo(EditActionO);
2894
2894
 
2895
2895
  var css_248z$4 = ".timeline-editor-edit-row {\n background-repeat: no-repeat, repeat;\n display: flex;\n flex-direction: row;\n box-sizing: border-box;\n transition: background-color 0.15s ease, box-shadow 0.15s ease;\n}\n.timeline-editor-edit-row.preview-row {\n background-color: rgba(100, 150, 255, 0.15);\n border: 1px dashed rgba(100, 150, 255, 0.5);\n opacity: 0.8;\n transition: all 0.2s ease;\n}\n.timeline-editor-edit-row.selected {\n background-color: rgba(24, 144, 255, 0.08);\n box-shadow: inset 0 0 0 2px rgba(24, 144, 255, 0.4);\n position: relative;\n z-index: 10;\n}\n.timeline-editor-edit-row.selected::before {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n width: 3px;\n background-color: #1890ff;\n}\n.timeline-editor-edit-row.dragging {\n opacity: 0.6;\n cursor: move;\n}\n";
2896
2896
  styleInject(css_248z$4);
@@ -3386,8 +3386,8 @@ var useRowDrag = function useRowDrag(options) {
3386
3386
  var initialPos = state.initialElementPositions.get(elActionId);
3387
3387
  if (!initialPos) return;
3388
3388
  // 计算新位置 = 初始位置 + 总偏移量
3389
- var newX = initialPos.x + state.offsetX;
3390
- var newY = initialPos.y + state.offsetY;
3389
+ var newX = state.offsetX;
3390
+ var newY = state.offsetY;
3391
3391
  // 更新元素位置
3392
3392
  el.style.transform = "translate(".concat(newX, "px, ").concat(newY, "px)");
3393
3393
  // 存储当前位置数据
@@ -3744,7 +3744,8 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3744
3744
  url: info.file.response.url,
3745
3745
  start: currentMouseTime,
3746
3746
  end: currentMouseTime + duration,
3747
- isUpload: true
3747
+ isUpload: true,
3748
+ segment_type: 'bgm'
3748
3749
  };
3749
3750
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
3750
3751
  case 3:
@@ -4353,7 +4354,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4353
4354
  };
4354
4355
  /** 处理主动数据变化 */
4355
4356
  var handleEditorDataChange = function handleEditorDataChange(updatedData) {
4356
- var result = onChange(updatedData);
4357
+ var result = onChange === null || onChange === void 0 ? void 0 : onChange(updatedData);
4357
4358
  if (result !== false) {
4358
4359
  setEditorData(updatedData);
4359
4360
  engineRef.current.data = updatedData;
@@ -4538,7 +4539,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4538
4539
  var indexB = keys.indexOf(String(b.type));
4539
4540
  return indexA - indexB;
4540
4541
  });
4541
- var result = onChange(sortedMergedData);
4542
+ var result = onChange === null || onChange === void 0 ? void 0 : onChange(sortedMergedData);
4542
4543
  if (result !== false) {
4543
4544
  setEditorData(sortedMergedData);
4544
4545
  engineRef.current.data = sortedMergedData;
@@ -30,6 +30,8 @@ export interface TimelineAction {
30
30
  is_disabled?: boolean;
31
31
  /** 动作是否为上传 */
32
32
  isUpload?: boolean;
33
+ /** 动作的类型 */
34
+ segment_type?: string;
33
35
  }
34
36
  /**
35
37
  * 动作行基本参数
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sense-react-timeline-editor",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "author": "xzdarcy",
5
5
  "license": "MIT",
6
6
  "keywords": [