sense-react-timeline-editor 1.1.4 → 1.1.6

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/index.js CHANGED
@@ -11,11 +11,13 @@ var reactDragToSelect = require('@air/react-drag-to-select');
11
11
  var es = require('antd/es');
12
12
  var howler = require('howler');
13
13
  var lodashEs = require('lodash-es');
14
+ var useSize = require('ahooks/es/useSize');
14
15
 
15
16
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
17
 
17
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
18
19
  var interact__default = /*#__PURE__*/_interopDefaultLegacy(interact);
20
+ var useSize__default = /*#__PURE__*/_interopDefaultLegacy(useSize);
19
21
 
20
22
  function _arrayLikeToArray(r, a) {
21
23
  (null == a || a > r.length) && (a = r.length);
@@ -2090,38 +2092,12 @@ var Cursor = function Cursor(_ref) {
2090
2092
  })));
2091
2093
  };
2092
2094
 
2093
- var css_248z$1 = ".timeline-editor-drag-line-container {\n position: absolute;\n height: 100%;\n top: 0;\n left: 0;\n}\n.timeline-editor-drag-line {\n width: 0;\n position: absolute;\n top: 0;\n height: 99%;\n border-left: 1px dashed rgba(82, 151, 255, 0.6);\n}\n";
2095
+ var css_248z$1 = ".timeline-editor .ant-upload-wrapper .ant-upload-drag {\n border: none !important;\n background: none !important;\n}\n.timeline-editor:hover .timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n height: 4px;\n}\n.timeline-editor-edit-area {\n flex: 1 1 auto;\n margin-top: 10px;\n overflow: hidden;\n position: relative;\n}\n.timeline-editor-edit-area.no-flex {\n flex: 0 0 auto;\n}\n.timeline-editor-edit-area.overflow-hidden {\n overflow: hidden;\n}\n.timeline-editor-edit-area.overflow-hidden .ReactVirtualized__Grid {\n overflow: hidden !important;\n height: initial !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid {\n outline: none !important;\n overflow: overlay !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n width: 0;\n height: 0;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-track {\n background-color: transparent !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-thumb {\n background: #666;\n border-radius: 16px;\n}\n.timeline-editor-selection-box {\n position: fixed;\n border: 2px solid #1890ff;\n background-color: rgba(24, 144, 255, 0.1);\n pointer-events: none;\n z-index: 9999;\n box-shadow: 0 0 8px rgba(24, 144, 255, 0.3);\n left: -100px;\n}\n";
2094
2096
  styleInject(css_248z$1);
2095
2097
 
2096
- /** 拖拽辅助线 */
2097
- var DragLines = function DragLines(_ref) {
2098
- var isMoving = _ref.isMoving,
2099
- _ref$movePositions = _ref.movePositions,
2100
- movePositions = _ref$movePositions === void 0 ? [] : _ref$movePositions,
2101
- _ref$assistPositions = _ref.assistPositions,
2102
- assistPositions = _ref$assistPositions === void 0 ? [] : _ref$assistPositions,
2103
- scrollLeft = _ref.scrollLeft;
2104
- return /*#__PURE__*/React__default['default'].createElement("div", {
2105
- className: prefix('drag-line-container')
2106
- }, isMoving && movePositions.filter(function (item) {
2107
- return assistPositions.includes(item);
2108
- }).map(function (linePos, index) {
2109
- return /*#__PURE__*/React__default['default'].createElement("div", {
2110
- key: index,
2111
- className: prefix('drag-line'),
2112
- style: {
2113
- left: linePos - scrollLeft
2114
- }
2115
- });
2116
- }));
2117
- };
2118
-
2119
- var css_248z$2 = ".timeline-editor .ant-upload-wrapper .ant-upload-drag {\n border: none !important;\n background: none !important;\n}\n.timeline-editor:hover .timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n height: 4px;\n}\n.timeline-editor-edit-area {\n flex: 1 1 auto;\n margin-top: 10px;\n overflow: hidden;\n position: relative;\n}\n.timeline-editor-edit-area.no-flex {\n flex: 0 0 auto;\n}\n.timeline-editor-edit-area.overflow-hidden {\n overflow: hidden;\n}\n.timeline-editor-edit-area.overflow-hidden .ReactVirtualized__Grid {\n overflow: hidden !important;\n height: initial !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid {\n outline: none !important;\n overflow: overlay !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar {\n width: 0;\n height: 0;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-track {\n background-color: transparent !important;\n}\n.timeline-editor-edit-area .ReactVirtualized__Grid::-webkit-scrollbar-thumb {\n background: #666;\n border-radius: 16px;\n}\n.timeline-editor-selection-box {\n position: fixed;\n border: 2px solid #1890ff;\n background-color: rgba(24, 144, 255, 0.1);\n pointer-events: none;\n z-index: 9999;\n box-shadow: 0 0 8px rgba(24, 144, 255, 0.3);\n left: -100px;\n}\n";
2098
+ var css_248z$2 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n cursor: pointer;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
2120
2099
  styleInject(css_248z$2);
2121
2100
 
2122
- var css_248z$3 = ".timeline-editor-action {\n position: absolute;\n left: 0;\n top: 0;\n background-color: #c6cbd2;\n display: flex;\n align-items: center;\n}\n.timeline-editor-action[data-action-drag=\"true\"] {\n box-shadow: 0px 8px 8px rgba(77, 54, 41, 0.08);\n border-radius: 34px;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch,\n.timeline-editor-action .timeline-editor-action-right-stretch {\n position: absolute;\n}\n.timeline-editor-action .timeline-editor-action-left-stretch {\n left: -3px;\n}\n.timeline-editor-action .timeline-editor-action-right-stretch {\n right: -3px;\n transform: rotate(180deg);\n}\n";
2123
- styleInject(css_248z$3);
2124
-
2125
2101
  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";
2126
2102
 
2127
2103
  var _excluded = ["left", "width", "top"];
@@ -2820,7 +2796,7 @@ var EditActionO = function EditActionO(_ref) {
2820
2796
  height: rowHeight,
2821
2797
  grid: gridSnap && gridSize || DEFAULT_MOVE_GRID,
2822
2798
  adsorptionDistance: gridSnap ? Math.max((gridSize || DEFAULT_MOVE_GRID) / 2, DEFAULT_ADSORPTION_DISTANCE) : DEFAULT_ADSORPTION_DISTANCE,
2823
- adsorptionPositions: dragLineData.assistPositions,
2799
+ // adsorptionPositions={dragLineData?.assistPositions}
2824
2800
  bounds: {
2825
2801
  left: leftLimit,
2826
2802
  right: rightLimit,
@@ -2918,8 +2894,8 @@ var EditActionO = function EditActionO(_ref) {
2918
2894
  };
2919
2895
  var EditAction = /*#__PURE__*/React__default['default'].memo(EditActionO);
2920
2896
 
2921
- 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";
2922
- styleInject(css_248z$4);
2897
+ var css_248z$3 = ".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";
2898
+ styleInject(css_248z$3);
2923
2899
 
2924
2900
  var EditRow = function EditRow(props) {
2925
2901
  var rowData = props.rowData,
@@ -2974,8 +2950,7 @@ var EditRow = function EditRow(props) {
2974
2950
  }
2975
2951
  },
2976
2952
  onClick: function onClick(e) {
2977
- var _e$target;
2978
- var action = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.closest('.timeline-editor-action');
2953
+ // const action = (e.target as HTMLElement)?.closest('.timeline-editor-action');
2979
2954
  var time = handleTime(e);
2980
2955
  if (rowData && onClickRow) {
2981
2956
  onClickRow(e, {
@@ -2983,12 +2958,10 @@ var EditRow = function EditRow(props) {
2983
2958
  time: time
2984
2959
  });
2985
2960
  }
2986
- if (hideCursor) return;
2987
- if (setCursor && !action) {
2988
- setCursor({
2989
- time: time
2990
- });
2991
- }
2961
+ // if (hideCursor) return;
2962
+ // if (setCursor && !action) {
2963
+ // setCursor({ time });
2964
+ // }
2992
2965
  },
2993
2966
  onDoubleClick: function onDoubleClick(e) {
2994
2967
  if (rowData && onDoubleClickRow) {
@@ -3023,112 +2996,6 @@ var EditRow = function EditRow(props) {
3023
2996
  }));
3024
2997
  };
3025
2998
 
3026
- function useDragLine() {
3027
- var _useState = React.useState({
3028
- isMoving: false,
3029
- movePositions: [],
3030
- assistPositions: []
3031
- }),
3032
- _useState2 = _slicedToArray(_useState, 2),
3033
- dragLineData = _useState2[0],
3034
- setDragLineData = _useState2[1];
3035
- /** 获取辅助线 */
3036
- var defaultGetAssistPosition = function defaultGetAssistPosition(data) {
3037
- var editorData = data.editorData,
3038
- assistActionIds = data.assistActionIds,
3039
- action = data.action,
3040
- row = data.row,
3041
- scale = data.scale,
3042
- scaleWidth = data.scaleWidth,
3043
- startLeft = data.startLeft,
3044
- cursorLeft = data.cursorLeft,
3045
- hideCursor = data.hideCursor;
3046
- var otherActions = [];
3047
- if (assistActionIds) {
3048
- editorData.forEach(function (rowItem) {
3049
- rowItem.actions.forEach(function (actionItem) {
3050
- if (assistActionIds.includes(actionItem.id)) otherActions.push(actionItem);
3051
- });
3052
- });
3053
- } else {
3054
- editorData.forEach(function (rowItem) {
3055
- if (rowItem.id !== row.id) {
3056
- otherActions.push.apply(otherActions, _toConsumableArray(rowItem.actions));
3057
- } else {
3058
- rowItem.actions.forEach(function (actionItem) {
3059
- if (actionItem.id !== action.id) otherActions.push(actionItem);
3060
- });
3061
- }
3062
- });
3063
- }
3064
- var positions = parserActionsToPositions(otherActions, {
3065
- startLeft: startLeft,
3066
- scale: scale,
3067
- scaleWidth: scaleWidth
3068
- });
3069
- if (!hideCursor) positions.push(cursorLeft);
3070
- return positions;
3071
- };
3072
- /** 获取当前移动标记 */
3073
- var defaultGetMovePosition = function defaultGetMovePosition(data) {
3074
- var start = data.start,
3075
- end = data.end,
3076
- dir = data.dir,
3077
- scale = data.scale,
3078
- scaleWidth = data.scaleWidth,
3079
- startLeft = data.startLeft;
3080
- var _parserTimeToTransfor = parserTimeToTransform({
3081
- start: start,
3082
- end: end
3083
- }, {
3084
- startLeft: startLeft,
3085
- scaleWidth: scaleWidth,
3086
- scale: scale
3087
- }),
3088
- left = _parserTimeToTransfor.left,
3089
- width = _parserTimeToTransfor.width;
3090
- if (!dir) return [left, left + width];
3091
- return dir === "right" ? [left + width] : [left];
3092
- };
3093
- /** 初始化draglines */
3094
- var initDragLine = function initDragLine(data) {
3095
- var movePositions = data.movePositions,
3096
- assistPositions = data.assistPositions;
3097
- setDragLineData({
3098
- isMoving: true,
3099
- movePositions: movePositions || [],
3100
- assistPositions: assistPositions || []
3101
- });
3102
- };
3103
- /** 更新dragline */
3104
- var updateDragLine = function updateDragLine(data) {
3105
- var movePositions = data.movePositions,
3106
- assistPositions = data.assistPositions;
3107
- setDragLineData(function (pre) {
3108
- return _objectSpread2(_objectSpread2({}, pre), {}, {
3109
- movePositions: movePositions || pre.movePositions,
3110
- assistPositions: assistPositions || pre.assistPositions
3111
- });
3112
- });
3113
- };
3114
- /** 释放draglines */
3115
- var disposeDragLine = function disposeDragLine() {
3116
- setDragLineData({
3117
- isMoving: false,
3118
- movePositions: [],
3119
- assistPositions: []
3120
- });
3121
- };
3122
- return {
3123
- initDragLine: initDragLine,
3124
- updateDragLine: updateDragLine,
3125
- disposeDragLine: disposeDragLine,
3126
- dragLineData: dragLineData,
3127
- defaultGetAssistPosition: defaultGetAssistPosition,
3128
- defaultGetMovePosition: defaultGetMovePosition
3129
- };
3130
- }
3131
-
3132
2999
  var useRowSelection = function useRowSelection(options) {
3133
3000
  var editorData = options.editorData,
3134
3001
  rowHeight = options.rowHeight,
@@ -3773,7 +3640,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3773
3640
  return /*#__PURE__*/function () {
3774
3641
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
3775
3642
  var _info$file$response, _info$file;
3776
- var totalDuration, _newAction, uid, duration, newAction;
3643
+ var hasDefault, totalDuration, _newAction, uid, duration, newAction;
3777
3644
  return _regenerator().w(function (_context) {
3778
3645
  while (1) switch (_context.n) {
3779
3646
  case 0:
@@ -3784,11 +3651,30 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3784
3651
  }
3785
3652
  return _context.a(2);
3786
3653
  case 1:
3787
- if (info.file.response) {
3654
+ if (!(info.file.status === 'error')) {
3788
3655
  _context.n = 2;
3789
3656
  break;
3790
3657
  }
3791
- totalDuration = row.actions.reduce(function (max, current) {
3658
+ onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
3659
+ id: info.file.uid,
3660
+ isUploading: false,
3661
+ start: 0,
3662
+ end: 0,
3663
+ effectId: 'custom_video_effect',
3664
+ isError: true,
3665
+ segment_type: 'bgm',
3666
+ uid: info.file.uid
3667
+ }]);
3668
+ return _context.a(2);
3669
+ case 2:
3670
+ if (info.file.response) {
3671
+ _context.n = 3;
3672
+ break;
3673
+ }
3674
+ hasDefault = row.actions.some(function (action) {
3675
+ return action.id === 'upload-bg-music';
3676
+ });
3677
+ totalDuration = hasDefault ? 0 : row.actions.reduce(function (max, current) {
3792
3678
  var _max$end;
3793
3679
  var currentEnd = current.end || 0;
3794
3680
  var maxEnd = (_max$end = max === null || max === void 0 ? void 0 : max.end) !== null && _max$end !== void 0 ? _max$end : 0;
@@ -3809,11 +3695,11 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3809
3695
  };
3810
3696
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
3811
3697
  return _context.a(2);
3812
- case 2:
3698
+ case 3:
3813
3699
  uid = info.file.uid;
3814
- _context.n = 3;
3700
+ _context.n = 4;
3815
3701
  return getAudioDuration(info.file.response.url);
3816
- case 3:
3702
+ case 4:
3817
3703
  duration = _context.v;
3818
3704
  newAction = {
3819
3705
  id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
@@ -3828,7 +3714,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3828
3714
  uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
3829
3715
  };
3830
3716
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
3831
- case 4:
3717
+ case 5:
3832
3718
  return _context.a(2);
3833
3719
  }
3834
3720
  }, _callee);
@@ -3838,13 +3724,6 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3838
3724
  };
3839
3725
  }();
3840
3726
  };
3841
- var _useDragLine = useDragLine(),
3842
- dragLineData = _useDragLine.dragLineData,
3843
- initDragLine = _useDragLine.initDragLine,
3844
- updateDragLine = _useDragLine.updateDragLine,
3845
- disposeDragLine = _useDragLine.disposeDragLine,
3846
- defaultGetAssistPosition = _useDragLine.defaultGetAssistPosition,
3847
- defaultGetMovePosition = _useDragLine.defaultGetMovePosition;
3848
3727
  var editAreaRef = React.useRef();
3849
3728
  var gridRef = React.useRef();
3850
3729
  var _useState = React.useState(0),
@@ -3946,44 +3825,10 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
3946
3825
  };
3947
3826
  });
3948
3827
  var handleInitDragLine = function handleInitDragLine(data) {
3949
- if (dragLine) {
3950
- var assistActionIds = getAssistDragLineActionIds && getAssistDragLineActionIds({
3951
- action: data.action,
3952
- row: data.row,
3953
- editorData: editorData
3954
- });
3955
- var cursorLeft = parserTimeToPixel(cursorTime, {
3956
- scaleWidth: scaleWidth,
3957
- scale: scale,
3958
- startLeft: startLeft
3959
- });
3960
- var assistPositions = defaultGetAssistPosition({
3961
- editorData: editorData,
3962
- assistActionIds: assistActionIds,
3963
- action: data.action,
3964
- row: data.row,
3965
- scale: scale,
3966
- scaleWidth: scaleWidth,
3967
- startLeft: startLeft,
3968
- hideCursor: hideCursor,
3969
- cursorLeft: cursorLeft
3970
- });
3971
- initDragLine({
3972
- assistPositions: assistPositions
3973
- });
3974
- }
3828
+ _onActionMoveStart === null || _onActionMoveStart === void 0 ? void 0 : _onActionMoveStart(data);
3975
3829
  };
3976
3830
  var handleUpdateDragLine = function handleUpdateDragLine(data) {
3977
- if (dragLine) {
3978
- var movePositions = defaultGetMovePosition(_objectSpread2(_objectSpread2({}, data), {}, {
3979
- startLeft: startLeft,
3980
- scaleWidth: scaleWidth,
3981
- scale: scale
3982
- }));
3983
- updateDragLine({
3984
- movePositions: movePositions
3985
- });
3986
- }
3831
+ _onActionMoving === null || _onActionMoving === void 0 ? void 0 : _onActionMoving(data);
3987
3832
  };
3988
3833
  React.useEffect(function () {
3989
3834
  if (!(engineRef === null || engineRef === void 0 ? void 0 : engineRef.current)) return;
@@ -4067,7 +3912,6 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4067
3912
  key: key,
4068
3913
  rowHeight: (row === null || row === void 0 ? void 0 : row.rowHeight) || _rowHeight,
4069
3914
  rowData: row,
4070
- dragLineData: dragLineData,
4071
3915
  allowCreateTrack: allowCreateTrack,
4072
3916
  setDropPreview: setDropPreview,
4073
3917
  containerRef: containerRef,
@@ -4109,11 +3953,9 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4109
3953
  return _onActionResizing && _onActionResizing(data);
4110
3954
  },
4111
3955
  onActionResizeEnd: function onActionResizeEnd(data) {
4112
- disposeDragLine();
4113
3956
  return _onActionResizeEnd && _onActionResizeEnd(data);
4114
3957
  },
4115
3958
  onActionMoveEnd: function onActionMoveEnd(data) {
4116
- disposeDragLine();
4117
3959
  // 传递拖拽结束参数给多选拖拽处理
4118
3960
  onDragEnd({
4119
3961
  actionId: data.action.id,
@@ -4225,9 +4067,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4225
4067
  _onScroll(param);
4226
4068
  }
4227
4069
  });
4228
- }), /*#__PURE__*/React__default['default'].createElement(DragSelection, null), dragLine && /*#__PURE__*/React__default['default'].createElement(DragLines, _objectSpread2({
4229
- scrollLeft: scrollLeft
4230
- }, dragLineData)), dragIndicator && function () {
4070
+ }), /*#__PURE__*/React__default['default'].createElement(DragSelection, null), dragIndicator && function () {
4231
4071
  // 计算拖拽位置指示器的位置
4232
4072
  var top = 0;
4233
4073
  var targetIndex = dragIndicator.targetIndex;
@@ -4277,11 +4117,11 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
4277
4117
  });
4278
4118
  var EditArea = /*#__PURE__*/React__default['default'].memo(EditAreaO);
4279
4119
 
4280
- var css_248z$5 = ".timeline-editor {\n height: 600px;\n width: 600px;\n min-height: 32px;\n position: relative;\n font-size: 12px;\n font-family: \"PingFang SC\";\n background-color: #191b1d;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.timeline-editor.light {\n background-color: #fff;\n}\n";
4281
- styleInject(css_248z$5);
4120
+ var css_248z$4 = ".timeline-editor {\n height: 600px;\n width: 600px;\n min-height: 32px;\n position: relative;\n font-size: 12px;\n font-family: \"PingFang SC\";\n background-color: #191b1d;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n}\n.timeline-editor.light {\n background-color: #fff;\n}\n";
4121
+ styleInject(css_248z$4);
4282
4122
 
4283
- var css_248z$6 = ".timeline-editor-time-area {\n position: relative;\n height: 32px;\n flex: 0 0 auto;\n}\n.timeline-editor-time-area .ReactVirtualized__Grid {\n outline: none;\n}\n.timeline-editor-time-area .ReactVirtualized__Grid::-webkit-scrollbar {\n display: none;\n}\n.timeline-editor-time-area-interact {\n position: absolute;\n cursor: pointer;\n left: 0;\n top: 0;\n}\n.timeline-editor-time-unit {\n border-right: 1px solid rgba(255, 255, 255, 0.2);\n position: relative;\n box-sizing: content-box;\n height: 4px !important;\n bottom: 0 !important;\n top: auto !important;\n}\n.timeline-editor-time-unit-big {\n height: 8px !important;\n}\n.timeline-editor-time-unit-scale {\n color: rgba(255, 255, 255, 0.6);\n position: absolute;\n right: 0;\n top: 0;\n transform: translate(50%, -100%);\n}\n.light.timeline-editor .timeline-editor-time-unit {\n border-color: #111;\n}\n.light.timeline-editor .timeline-editor-time-unit-scale {\n color: #666;\n}\n";
4284
- styleInject(css_248z$6);
4123
+ var css_248z$5 = ".timeline-editor-time-area {\n position: relative;\n height: 32px;\n flex: 0 0 auto;\n}\n.timeline-editor-time-area .ReactVirtualized__Grid {\n outline: none;\n}\n.timeline-editor-time-area .ReactVirtualized__Grid::-webkit-scrollbar {\n display: none;\n}\n.timeline-editor-time-area-interact {\n position: absolute;\n cursor: pointer;\n left: 0;\n top: 0;\n}\n.timeline-editor-time-unit {\n border-right: 1px solid rgba(255, 255, 255, 0.2);\n position: relative;\n box-sizing: content-box;\n height: 4px !important;\n bottom: 0 !important;\n top: auto !important;\n}\n.timeline-editor-time-unit-big {\n height: 8px !important;\n}\n.timeline-editor-time-unit-scale {\n color: rgba(255, 255, 255, 0.6);\n position: absolute;\n right: 0;\n top: 0;\n transform: translate(50%, -100%);\n}\n.light.timeline-editor .timeline-editor-time-unit {\n border-color: #111;\n}\n.light.timeline-editor .timeline-editor-time-unit-scale {\n color: #666;\n}\n";
4124
+ styleInject(css_248z$5);
4285
4125
 
4286
4126
  /** 动画时间轴组件 */
4287
4127
  var TimeArea = function TimeArea(_ref) {
@@ -4383,6 +4223,190 @@ var TimeArea = function TimeArea(_ref) {
4383
4223
  }));
4384
4224
  };
4385
4225
 
4226
+ var css_248z$6 = ".timeline-editor-drag-line-container {\n position: absolute;\n height: 100%;\n top: 0;\n left: 0;\n}\n.timeline-editor-drag-line {\n width: 0;\n position: absolute;\n top: 0;\n height: 99%;\n border-left: 0.5px solid #009C2C;\n}\n";
4227
+ styleInject(css_248z$6);
4228
+
4229
+ /** 拖拽辅助线 */
4230
+ var DragLines = /*#__PURE__*/React.memo(function (_ref) {
4231
+ var isMoving = _ref.isMoving,
4232
+ _ref$movePositions = _ref.movePositions,
4233
+ movePositions = _ref$movePositions === void 0 ? [] : _ref$movePositions,
4234
+ _ref$assistPositions = _ref.assistPositions,
4235
+ assistPositions = _ref$assistPositions === void 0 ? [] : _ref$assistPositions,
4236
+ scrollLeft = _ref.scrollLeft;
4237
+ var _ref2 = useSize__default['default'](document.querySelector('#time-editor-container')) || {},
4238
+ _ref2$height = _ref2.height,
4239
+ height = _ref2$height === void 0 ? 0 : _ref2$height;
4240
+ var tolerance = 5; // 容差范围,单位像素
4241
+ return /*#__PURE__*/React__default['default'].createElement("div", {
4242
+ className: prefix('drag-line-container'),
4243
+ style: {
4244
+ height: height || '100%'
4245
+ }
4246
+ }, isMoving && movePositions.map(function (movePos) {
4247
+ // 查找在容差范围内的辅助线位置
4248
+ var matchedAssistPos = assistPositions.find(function (assistPos) {
4249
+ return Math.abs(movePos - assistPos) <= tolerance;
4250
+ });
4251
+ if (matchedAssistPos) {
4252
+ return /*#__PURE__*/React__default['default'].createElement("div", {
4253
+ key: matchedAssistPos,
4254
+ className: prefix('drag-line'),
4255
+ style: {
4256
+ left: matchedAssistPos - scrollLeft
4257
+ }
4258
+ });
4259
+ }
4260
+ return null;
4261
+ }));
4262
+ });
4263
+
4264
+ var defaultGetAssistPosition = function defaultGetAssistPosition(data) {
4265
+ var editorData = data.editorData,
4266
+ assistActionIds = data.assistActionIds,
4267
+ action = data.action,
4268
+ row = data.row,
4269
+ scale = data.scale,
4270
+ scaleWidth = data.scaleWidth,
4271
+ startLeft = data.startLeft,
4272
+ cursorLeft = data.cursorLeft,
4273
+ hideCursor = data.hideCursor;
4274
+ var otherActions = [];
4275
+ if (assistActionIds) {
4276
+ editorData.forEach(function (rowItem) {
4277
+ rowItem.actions.forEach(function (actionItem) {
4278
+ if (assistActionIds.includes(actionItem.id)) otherActions.push(actionItem);
4279
+ });
4280
+ });
4281
+ } else {
4282
+ editorData.forEach(function (rowItem) {
4283
+ if (rowItem.id !== row.id) {
4284
+ otherActions.push.apply(otherActions, _toConsumableArray(rowItem.actions));
4285
+ } else {
4286
+ rowItem.actions.forEach(function (actionItem) {
4287
+ if (actionItem.id !== action.id) otherActions.push(actionItem);
4288
+ });
4289
+ }
4290
+ });
4291
+ }
4292
+ var positions = parserActionsToPositions(otherActions, {
4293
+ startLeft: startLeft,
4294
+ scale: scale,
4295
+ scaleWidth: scaleWidth
4296
+ });
4297
+ if (!hideCursor) positions.push(cursorLeft);
4298
+ return positions;
4299
+ };
4300
+ var defaultGetMovePosition = function defaultGetMovePosition(data) {
4301
+ var start = data.start,
4302
+ end = data.end,
4303
+ dir = data.dir,
4304
+ scale = data.scale,
4305
+ scaleWidth = data.scaleWidth,
4306
+ startLeft = data.startLeft;
4307
+ var _parserTimeToTransfor = parserTimeToTransform({
4308
+ start: start,
4309
+ end: end
4310
+ }, {
4311
+ startLeft: startLeft,
4312
+ scaleWidth: scaleWidth,
4313
+ scale: scale
4314
+ }),
4315
+ left = _parserTimeToTransfor.left,
4316
+ width = _parserTimeToTransfor.width;
4317
+ if (!dir) return [left, left + width];
4318
+ return dir === "right" ? [left + width] : [left];
4319
+ };
4320
+ var DragLineController = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (props, ref) {
4321
+ var dragLine = props.dragLine,
4322
+ editorData = props.editorData,
4323
+ cursorTime = props.cursorTime,
4324
+ scale = props.scale,
4325
+ scaleWidth = props.scaleWidth,
4326
+ startLeft = props.startLeft,
4327
+ hideCursor = props.hideCursor,
4328
+ scrollLeft = props.scrollLeft,
4329
+ getAssistDragLineActionIds = props.getAssistDragLineActionIds;
4330
+ var _useState = React.useState({
4331
+ isMoving: false,
4332
+ movePositions: [],
4333
+ assistPositions: []
4334
+ }),
4335
+ _useState2 = _slicedToArray(_useState, 2),
4336
+ dragLineData = _useState2[0],
4337
+ setDragLineData = _useState2[1];
4338
+ console.log('dragLineData = ', dragLineData);
4339
+ var initDragLine = React.useCallback(function (data) {
4340
+ if (dragLine) {
4341
+ var assistActionIds = getAssistDragLineActionIds && getAssistDragLineActionIds({
4342
+ action: data.action,
4343
+ row: data.row,
4344
+ editorData: editorData
4345
+ });
4346
+ var cursorLeft = parserTimeToPixel(cursorTime, {
4347
+ scaleWidth: scaleWidth,
4348
+ scale: scale,
4349
+ startLeft: startLeft
4350
+ });
4351
+ var assistPositions = defaultGetAssistPosition({
4352
+ editorData: editorData,
4353
+ assistActionIds: assistActionIds,
4354
+ action: data.action,
4355
+ row: data.row,
4356
+ scale: scale,
4357
+ scaleWidth: scaleWidth,
4358
+ startLeft: startLeft,
4359
+ hideCursor: hideCursor,
4360
+ cursorLeft: cursorLeft
4361
+ });
4362
+ setDragLineData({
4363
+ isMoving: true,
4364
+ movePositions: [],
4365
+ assistPositions: assistPositions
4366
+ });
4367
+ }
4368
+ }, [dragLine, editorData, cursorTime, scale, scaleWidth, startLeft, hideCursor, getAssistDragLineActionIds]);
4369
+ var updateDragLine = React.useCallback(function (data) {
4370
+ if (dragLine) {
4371
+ var movePositions = defaultGetMovePosition(_objectSpread2(_objectSpread2({}, data), {}, {
4372
+ startLeft: startLeft,
4373
+ scaleWidth: scaleWidth,
4374
+ scale: scale
4375
+ }));
4376
+ setDragLineData(function (prev) {
4377
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
4378
+ movePositions: movePositions
4379
+ });
4380
+ });
4381
+ }
4382
+ }, [dragLine, startLeft, scaleWidth, scale]);
4383
+ var disposeDragLine = React.useCallback(function () {
4384
+ setDragLineData({
4385
+ isMoving: false,
4386
+ movePositions: [],
4387
+ assistPositions: []
4388
+ });
4389
+ }, []);
4390
+ React.useImperativeHandle(ref, function () {
4391
+ return {
4392
+ initDragLine: initDragLine,
4393
+ updateDragLine: updateDragLine,
4394
+ disposeDragLine: disposeDragLine
4395
+ };
4396
+ }, [initDragLine, updateDragLine, disposeDragLine]);
4397
+ var dragLinesProps = React.useMemo(function () {
4398
+ return {
4399
+ isMoving: dragLineData.isMoving,
4400
+ movePositions: dragLineData.movePositions,
4401
+ assistPositions: dragLineData.assistPositions,
4402
+ scrollLeft: scrollLeft
4403
+ };
4404
+ }, [dragLineData.isMoving, dragLineData.movePositions, dragLineData.assistPositions, scrollLeft]);
4405
+ if (!dragLine) return null;
4406
+ return /*#__PURE__*/React__default['default'].createElement(DragLines, _objectSpread2({}, dragLinesProps));
4407
+ }));
4408
+ DragLineController.displayName = "DragLineController";
4409
+
4386
4410
  var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
4387
4411
  var checkedProps = checkProps(props);
4388
4412
  var style = props.style,
@@ -4394,6 +4418,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4394
4418
  autoScroll = checkedProps.autoScroll,
4395
4419
  hideCursor = checkedProps.hideCursor,
4396
4420
  disableDrag = checkedProps.disableDrag,
4421
+ dragLine = checkedProps.dragLine,
4397
4422
  scale = checkedProps.scale,
4398
4423
  scaleWidth = checkedProps.scaleWidth,
4399
4424
  startLeft = checkedProps.startLeft,
@@ -4437,6 +4462,7 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4437
4462
  _useState0 = _slicedToArray(_useState9, 2),
4438
4463
  width = _useState0[0],
4439
4464
  setWidth = _useState0[1];
4465
+ var dragLineControllerRef = React.useRef(null);
4440
4466
  var groupedData = lodashEs.groupBy(editorData, 'type');
4441
4467
  var areaCount = Object.keys(groupedData).length;
4442
4468
  var keys = Object.keys(groupedData);
@@ -4512,6 +4538,24 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4512
4538
  scrollLeft: Math.max(scrollSync.current.state.scrollLeft + delta, 0)
4513
4539
  });
4514
4540
  };
4541
+ var handleInitDragLine = React.useCallback(function (data) {
4542
+ var _checkedProps$onActio, _checkedProps$onActio2, _dragLineControllerRe;
4543
+ (_checkedProps$onActio = checkedProps.onActionMoveStart) === null || _checkedProps$onActio === void 0 ? void 0 : _checkedProps$onActio.call(checkedProps, data);
4544
+ (_checkedProps$onActio2 = checkedProps.onActionResizeStart) === null || _checkedProps$onActio2 === void 0 ? void 0 : _checkedProps$onActio2.call(checkedProps, data);
4545
+ (_dragLineControllerRe = dragLineControllerRef.current) === null || _dragLineControllerRe === void 0 ? void 0 : _dragLineControllerRe.initDragLine(data);
4546
+ }, [checkedProps]);
4547
+ var handleUpdateDragLine = React.useCallback(function (data) {
4548
+ var _checkedProps$onActio3, _checkedProps$onActio4, _dragLineControllerRe2;
4549
+ (_checkedProps$onActio3 = checkedProps.onActionMoving) === null || _checkedProps$onActio3 === void 0 ? void 0 : _checkedProps$onActio3.call(checkedProps, data);
4550
+ (_checkedProps$onActio4 = checkedProps.onActionResizing) === null || _checkedProps$onActio4 === void 0 ? void 0 : _checkedProps$onActio4.call(checkedProps, data);
4551
+ (_dragLineControllerRe2 = dragLineControllerRef.current) === null || _dragLineControllerRe2 === void 0 ? void 0 : _dragLineControllerRe2.updateDragLine(data);
4552
+ }, [checkedProps]);
4553
+ var handleDisposeDragLine = React.useCallback(function (data) {
4554
+ var _checkedProps$onActio5, _checkedProps$onActio6, _dragLineControllerRe3;
4555
+ (_checkedProps$onActio5 = checkedProps.onActionMoveEnd) === null || _checkedProps$onActio5 === void 0 ? void 0 : _checkedProps$onActio5.call(checkedProps, data);
4556
+ (_checkedProps$onActio6 = checkedProps.onActionResizeEnd) === null || _checkedProps$onActio6 === void 0 ? void 0 : _checkedProps$onActio6.call(checkedProps, data);
4557
+ (_dragLineControllerRe3 = dragLineControllerRef.current) === null || _dragLineControllerRe3 === void 0 ? void 0 : _dragLineControllerRe3.disposeDragLine();
4558
+ }, [checkedProps]);
4515
4559
  // 处理运行器相关数据
4516
4560
  React.useEffect(function () {
4517
4561
  var handleTime = function handleTime(_ref) {
@@ -4584,6 +4628,24 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4584
4628
  }
4585
4629
  };
4586
4630
  });
4631
+ var onClickTimeline = function onClickTimeline(e) {
4632
+ var _e$target;
4633
+ if (!domRef.current) return;
4634
+ var rect = domRef.current.getBoundingClientRect();
4635
+ var position = e.clientX - rect.x;
4636
+ var left = position + scrollSync.current.state.scrollLeft;
4637
+ var time = parserPixelToTime(left, {
4638
+ startLeft: startLeft,
4639
+ scale: scale,
4640
+ scaleWidth: scaleWidth
4641
+ });
4642
+ var action = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.closest('.timeline-editor-action');
4643
+ if (action || hideCursor) return;
4644
+ console.log('onClickTimeline = ', time);
4645
+ handleSetCursor({
4646
+ time: time
4647
+ });
4648
+ };
4587
4649
  // 监听timeline区域宽度变化
4588
4650
  React.useEffect(function () {
4589
4651
  if (areaRef.current) {
@@ -4635,6 +4697,12 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4635
4697
  deltaScrollLeft: autoScroll && handleDeltaScrollLeft,
4636
4698
  allowCreateTrack: allowCreateTrack,
4637
4699
  onMutiSelectChange: props === null || props === void 0 ? void 0 : props.onMutiSelectChange,
4700
+ onActionMoveStart: handleInitDragLine,
4701
+ onActionResizeStart: handleInitDragLine,
4702
+ onActionMoving: handleUpdateDragLine,
4703
+ onActionResizing: handleUpdateDragLine,
4704
+ onActionMoveEnd: handleDisposeDragLine,
4705
+ onActionResizeEnd: handleDisposeDragLine,
4638
4706
  onScroll: function onScroll(params) {
4639
4707
  _onScroll(params);
4640
4708
  onScrollVertical && onScrollVertical(params);
@@ -4644,7 +4712,8 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4644
4712
  ref: containerRef,
4645
4713
  style: {
4646
4714
  height: '100%'
4647
- }
4715
+ },
4716
+ onClick: onClickTimeline
4648
4717
  }, Object.keys(groupedData).map(function (key, index) {
4649
4718
  var handleGroupDataChange = function handleGroupDataChange(updatedData) {
4650
4719
  var mergedData = editorData.filter(function (item) {
@@ -4691,6 +4760,12 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4691
4760
  containerRef: containerRef,
4692
4761
  onMutiSelectChange: props === null || props === void 0 ? void 0 : props.onMutiSelectChange,
4693
4762
  engineRef: engineRef,
4763
+ onActionMoveStart: handleInitDragLine,
4764
+ onActionResizeStart: handleInitDragLine,
4765
+ onActionMoving: handleUpdateDragLine,
4766
+ onActionResizing: handleUpdateDragLine,
4767
+ onActionMoveEnd: handleDisposeDragLine,
4768
+ onActionResizeEnd: handleDisposeDragLine,
4694
4769
  onScroll: function onScroll(params) {
4695
4770
  _onScroll(params);
4696
4771
  onScrollVertical && onScrollVertical(params);
@@ -4708,7 +4783,18 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
4708
4783
  areaRef: areaRef,
4709
4784
  scrollSync: scrollSync,
4710
4785
  deltaScrollLeft: autoScroll && handleDeltaScrollLeft
4711
- }))));
4786
+ }))), /*#__PURE__*/React__default['default'].createElement(DragLineController, {
4787
+ ref: dragLineControllerRef,
4788
+ dragLine: dragLine,
4789
+ editorData: editorData,
4790
+ cursorTime: cursorTime,
4791
+ scale: scale,
4792
+ scaleWidth: scaleWidth,
4793
+ startLeft: startLeft,
4794
+ hideCursor: hideCursor,
4795
+ scrollLeft: scrollLeft,
4796
+ getAssistDragLineActionIds: checkedProps.getAssistDragLineActionIds
4797
+ }));
4712
4798
  }));
4713
4799
  });
4714
4800