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.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback } from 'react';
1
+ import React, { useRef, useEffect, cloneElement, useImperativeHandle, useState, useLayoutEffect, useCallback, memo, forwardRef, useMemo } from 'react';
2
2
  import { AutoSizer, Grid, ScrollSync } from 'react-virtualized';
3
3
  import { useThrottleEffect, useThrottleFn } from 'ahooks';
4
4
  import { prefixNames } from 'framework-utils';
@@ -7,6 +7,7 @@ import { useSelectionContainer } from '@air/react-drag-to-select';
7
7
  import { Upload, message } from 'antd/es';
8
8
  import { Howl } from 'howler';
9
9
  import { groupBy } from 'lodash-es';
10
+ import useSize from 'ahooks/es/useSize';
10
11
 
11
12
  function _arrayLikeToArray(r, a) {
12
13
  (null == a || a > r.length) && (a = r.length);
@@ -2081,38 +2082,12 @@ var Cursor = function Cursor(_ref) {
2081
2082
  })));
2082
2083
  };
2083
2084
 
2084
- 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";
2085
+ 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";
2085
2086
  styleInject(css_248z$1);
2086
2087
 
2087
- /** 拖拽辅助线 */
2088
- var DragLines = function DragLines(_ref) {
2089
- var isMoving = _ref.isMoving,
2090
- _ref$movePositions = _ref.movePositions,
2091
- movePositions = _ref$movePositions === void 0 ? [] : _ref$movePositions,
2092
- _ref$assistPositions = _ref.assistPositions,
2093
- assistPositions = _ref$assistPositions === void 0 ? [] : _ref$assistPositions,
2094
- scrollLeft = _ref.scrollLeft;
2095
- return /*#__PURE__*/React.createElement("div", {
2096
- className: prefix('drag-line-container')
2097
- }, isMoving && movePositions.filter(function (item) {
2098
- return assistPositions.includes(item);
2099
- }).map(function (linePos, index) {
2100
- return /*#__PURE__*/React.createElement("div", {
2101
- key: index,
2102
- className: prefix('drag-line'),
2103
- style: {
2104
- left: linePos - scrollLeft
2105
- }
2106
- });
2107
- }));
2108
- };
2109
-
2110
- 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";
2088
+ 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";
2111
2089
  styleInject(css_248z$2);
2112
2090
 
2113
- 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";
2114
- styleInject(css_248z$3);
2115
-
2116
2091
  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";
2117
2092
 
2118
2093
  var _excluded = ["left", "width", "top"];
@@ -2811,7 +2786,7 @@ var EditActionO = function EditActionO(_ref) {
2811
2786
  height: rowHeight,
2812
2787
  grid: gridSnap && gridSize || DEFAULT_MOVE_GRID,
2813
2788
  adsorptionDistance: gridSnap ? Math.max((gridSize || DEFAULT_MOVE_GRID) / 2, DEFAULT_ADSORPTION_DISTANCE) : DEFAULT_ADSORPTION_DISTANCE,
2814
- adsorptionPositions: dragLineData.assistPositions,
2789
+ // adsorptionPositions={dragLineData?.assistPositions}
2815
2790
  bounds: {
2816
2791
  left: leftLimit,
2817
2792
  right: rightLimit,
@@ -2909,8 +2884,8 @@ var EditActionO = function EditActionO(_ref) {
2909
2884
  };
2910
2885
  var EditAction = /*#__PURE__*/React.memo(EditActionO);
2911
2886
 
2912
- 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";
2913
- styleInject(css_248z$4);
2887
+ 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";
2888
+ styleInject(css_248z$3);
2914
2889
 
2915
2890
  var EditRow = function EditRow(props) {
2916
2891
  var rowData = props.rowData,
@@ -2965,8 +2940,7 @@ var EditRow = function EditRow(props) {
2965
2940
  }
2966
2941
  },
2967
2942
  onClick: function onClick(e) {
2968
- var _e$target;
2969
- var action = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.closest('.timeline-editor-action');
2943
+ // const action = (e.target as HTMLElement)?.closest('.timeline-editor-action');
2970
2944
  var time = handleTime(e);
2971
2945
  if (rowData && onClickRow) {
2972
2946
  onClickRow(e, {
@@ -2974,12 +2948,10 @@ var EditRow = function EditRow(props) {
2974
2948
  time: time
2975
2949
  });
2976
2950
  }
2977
- if (hideCursor) return;
2978
- if (setCursor && !action) {
2979
- setCursor({
2980
- time: time
2981
- });
2982
- }
2951
+ // if (hideCursor) return;
2952
+ // if (setCursor && !action) {
2953
+ // setCursor({ time });
2954
+ // }
2983
2955
  },
2984
2956
  onDoubleClick: function onDoubleClick(e) {
2985
2957
  if (rowData && onDoubleClickRow) {
@@ -3014,112 +2986,6 @@ var EditRow = function EditRow(props) {
3014
2986
  }));
3015
2987
  };
3016
2988
 
3017
- function useDragLine() {
3018
- var _useState = useState({
3019
- isMoving: false,
3020
- movePositions: [],
3021
- assistPositions: []
3022
- }),
3023
- _useState2 = _slicedToArray(_useState, 2),
3024
- dragLineData = _useState2[0],
3025
- setDragLineData = _useState2[1];
3026
- /** 获取辅助线 */
3027
- var defaultGetAssistPosition = function defaultGetAssistPosition(data) {
3028
- var editorData = data.editorData,
3029
- assistActionIds = data.assistActionIds,
3030
- action = data.action,
3031
- row = data.row,
3032
- scale = data.scale,
3033
- scaleWidth = data.scaleWidth,
3034
- startLeft = data.startLeft,
3035
- cursorLeft = data.cursorLeft,
3036
- hideCursor = data.hideCursor;
3037
- var otherActions = [];
3038
- if (assistActionIds) {
3039
- editorData.forEach(function (rowItem) {
3040
- rowItem.actions.forEach(function (actionItem) {
3041
- if (assistActionIds.includes(actionItem.id)) otherActions.push(actionItem);
3042
- });
3043
- });
3044
- } else {
3045
- editorData.forEach(function (rowItem) {
3046
- if (rowItem.id !== row.id) {
3047
- otherActions.push.apply(otherActions, _toConsumableArray(rowItem.actions));
3048
- } else {
3049
- rowItem.actions.forEach(function (actionItem) {
3050
- if (actionItem.id !== action.id) otherActions.push(actionItem);
3051
- });
3052
- }
3053
- });
3054
- }
3055
- var positions = parserActionsToPositions(otherActions, {
3056
- startLeft: startLeft,
3057
- scale: scale,
3058
- scaleWidth: scaleWidth
3059
- });
3060
- if (!hideCursor) positions.push(cursorLeft);
3061
- return positions;
3062
- };
3063
- /** 获取当前移动标记 */
3064
- var defaultGetMovePosition = function defaultGetMovePosition(data) {
3065
- var start = data.start,
3066
- end = data.end,
3067
- dir = data.dir,
3068
- scale = data.scale,
3069
- scaleWidth = data.scaleWidth,
3070
- startLeft = data.startLeft;
3071
- var _parserTimeToTransfor = parserTimeToTransform({
3072
- start: start,
3073
- end: end
3074
- }, {
3075
- startLeft: startLeft,
3076
- scaleWidth: scaleWidth,
3077
- scale: scale
3078
- }),
3079
- left = _parserTimeToTransfor.left,
3080
- width = _parserTimeToTransfor.width;
3081
- if (!dir) return [left, left + width];
3082
- return dir === "right" ? [left + width] : [left];
3083
- };
3084
- /** 初始化draglines */
3085
- var initDragLine = function initDragLine(data) {
3086
- var movePositions = data.movePositions,
3087
- assistPositions = data.assistPositions;
3088
- setDragLineData({
3089
- isMoving: true,
3090
- movePositions: movePositions || [],
3091
- assistPositions: assistPositions || []
3092
- });
3093
- };
3094
- /** 更新dragline */
3095
- var updateDragLine = function updateDragLine(data) {
3096
- var movePositions = data.movePositions,
3097
- assistPositions = data.assistPositions;
3098
- setDragLineData(function (pre) {
3099
- return _objectSpread2(_objectSpread2({}, pre), {}, {
3100
- movePositions: movePositions || pre.movePositions,
3101
- assistPositions: assistPositions || pre.assistPositions
3102
- });
3103
- });
3104
- };
3105
- /** 释放draglines */
3106
- var disposeDragLine = function disposeDragLine() {
3107
- setDragLineData({
3108
- isMoving: false,
3109
- movePositions: [],
3110
- assistPositions: []
3111
- });
3112
- };
3113
- return {
3114
- initDragLine: initDragLine,
3115
- updateDragLine: updateDragLine,
3116
- disposeDragLine: disposeDragLine,
3117
- dragLineData: dragLineData,
3118
- defaultGetAssistPosition: defaultGetAssistPosition,
3119
- defaultGetMovePosition: defaultGetMovePosition
3120
- };
3121
- }
3122
-
3123
2989
  var useRowSelection = function useRowSelection(options) {
3124
2990
  var editorData = options.editorData,
3125
2991
  rowHeight = options.rowHeight,
@@ -3764,7 +3630,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3764
3630
  return /*#__PURE__*/function () {
3765
3631
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
3766
3632
  var _info$file$response, _info$file;
3767
- var totalDuration, _newAction, uid, duration, newAction;
3633
+ var hasDefault, totalDuration, _newAction, uid, duration, newAction;
3768
3634
  return _regenerator().w(function (_context) {
3769
3635
  while (1) switch (_context.n) {
3770
3636
  case 0:
@@ -3775,11 +3641,30 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3775
3641
  }
3776
3642
  return _context.a(2);
3777
3643
  case 1:
3778
- if (info.file.response) {
3644
+ if (!(info.file.status === 'error')) {
3779
3645
  _context.n = 2;
3780
3646
  break;
3781
3647
  }
3782
- totalDuration = row.actions.reduce(function (max, current) {
3648
+ onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
3649
+ id: info.file.uid,
3650
+ isUploading: false,
3651
+ start: 0,
3652
+ end: 0,
3653
+ effectId: 'custom_video_effect',
3654
+ isError: true,
3655
+ segment_type: 'bgm',
3656
+ uid: info.file.uid
3657
+ }]);
3658
+ return _context.a(2);
3659
+ case 2:
3660
+ if (info.file.response) {
3661
+ _context.n = 3;
3662
+ break;
3663
+ }
3664
+ hasDefault = row.actions.some(function (action) {
3665
+ return action.id === 'upload-bg-music';
3666
+ });
3667
+ totalDuration = hasDefault ? 0 : row.actions.reduce(function (max, current) {
3783
3668
  var _max$end;
3784
3669
  var currentEnd = current.end || 0;
3785
3670
  var maxEnd = (_max$end = max === null || max === void 0 ? void 0 : max.end) !== null && _max$end !== void 0 ? _max$end : 0;
@@ -3800,11 +3685,11 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3800
3685
  };
3801
3686
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
3802
3687
  return _context.a(2);
3803
- case 2:
3688
+ case 3:
3804
3689
  uid = info.file.uid;
3805
- _context.n = 3;
3690
+ _context.n = 4;
3806
3691
  return getAudioDuration(info.file.response.url);
3807
- case 3:
3692
+ case 4:
3808
3693
  duration = _context.v;
3809
3694
  newAction = {
3810
3695
  id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
@@ -3819,7 +3704,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3819
3704
  uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
3820
3705
  };
3821
3706
  onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
3822
- case 4:
3707
+ case 5:
3823
3708
  return _context.a(2);
3824
3709
  }
3825
3710
  }, _callee);
@@ -3829,13 +3714,6 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3829
3714
  };
3830
3715
  }();
3831
3716
  };
3832
- var _useDragLine = useDragLine(),
3833
- dragLineData = _useDragLine.dragLineData,
3834
- initDragLine = _useDragLine.initDragLine,
3835
- updateDragLine = _useDragLine.updateDragLine,
3836
- disposeDragLine = _useDragLine.disposeDragLine,
3837
- defaultGetAssistPosition = _useDragLine.defaultGetAssistPosition,
3838
- defaultGetMovePosition = _useDragLine.defaultGetMovePosition;
3839
3717
  var editAreaRef = useRef();
3840
3718
  var gridRef = useRef();
3841
3719
  var _useState = useState(0),
@@ -3937,44 +3815,10 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
3937
3815
  };
3938
3816
  });
3939
3817
  var handleInitDragLine = function handleInitDragLine(data) {
3940
- if (dragLine) {
3941
- var assistActionIds = getAssistDragLineActionIds && getAssistDragLineActionIds({
3942
- action: data.action,
3943
- row: data.row,
3944
- editorData: editorData
3945
- });
3946
- var cursorLeft = parserTimeToPixel(cursorTime, {
3947
- scaleWidth: scaleWidth,
3948
- scale: scale,
3949
- startLeft: startLeft
3950
- });
3951
- var assistPositions = defaultGetAssistPosition({
3952
- editorData: editorData,
3953
- assistActionIds: assistActionIds,
3954
- action: data.action,
3955
- row: data.row,
3956
- scale: scale,
3957
- scaleWidth: scaleWidth,
3958
- startLeft: startLeft,
3959
- hideCursor: hideCursor,
3960
- cursorLeft: cursorLeft
3961
- });
3962
- initDragLine({
3963
- assistPositions: assistPositions
3964
- });
3965
- }
3818
+ _onActionMoveStart === null || _onActionMoveStart === void 0 ? void 0 : _onActionMoveStart(data);
3966
3819
  };
3967
3820
  var handleUpdateDragLine = function handleUpdateDragLine(data) {
3968
- if (dragLine) {
3969
- var movePositions = defaultGetMovePosition(_objectSpread2(_objectSpread2({}, data), {}, {
3970
- startLeft: startLeft,
3971
- scaleWidth: scaleWidth,
3972
- scale: scale
3973
- }));
3974
- updateDragLine({
3975
- movePositions: movePositions
3976
- });
3977
- }
3821
+ _onActionMoving === null || _onActionMoving === void 0 ? void 0 : _onActionMoving(data);
3978
3822
  };
3979
3823
  useEffect(function () {
3980
3824
  if (!(engineRef === null || engineRef === void 0 ? void 0 : engineRef.current)) return;
@@ -4058,7 +3902,6 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4058
3902
  key: key,
4059
3903
  rowHeight: (row === null || row === void 0 ? void 0 : row.rowHeight) || _rowHeight,
4060
3904
  rowData: row,
4061
- dragLineData: dragLineData,
4062
3905
  allowCreateTrack: allowCreateTrack,
4063
3906
  setDropPreview: setDropPreview,
4064
3907
  containerRef: containerRef,
@@ -4100,11 +3943,9 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4100
3943
  return _onActionResizing && _onActionResizing(data);
4101
3944
  },
4102
3945
  onActionResizeEnd: function onActionResizeEnd(data) {
4103
- disposeDragLine();
4104
3946
  return _onActionResizeEnd && _onActionResizeEnd(data);
4105
3947
  },
4106
3948
  onActionMoveEnd: function onActionMoveEnd(data) {
4107
- disposeDragLine();
4108
3949
  // 传递拖拽结束参数给多选拖拽处理
4109
3950
  onDragEnd({
4110
3951
  actionId: data.action.id,
@@ -4216,9 +4057,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4216
4057
  _onScroll(param);
4217
4058
  }
4218
4059
  });
4219
- }), /*#__PURE__*/React.createElement(DragSelection, null), dragLine && /*#__PURE__*/React.createElement(DragLines, _objectSpread2({
4220
- scrollLeft: scrollLeft
4221
- }, dragLineData)), dragIndicator && function () {
4060
+ }), /*#__PURE__*/React.createElement(DragSelection, null), dragIndicator && function () {
4222
4061
  // 计算拖拽位置指示器的位置
4223
4062
  var top = 0;
4224
4063
  var targetIndex = dragIndicator.targetIndex;
@@ -4268,11 +4107,11 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
4268
4107
  });
4269
4108
  var EditArea = /*#__PURE__*/React.memo(EditAreaO);
4270
4109
 
4271
- 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";
4272
- styleInject(css_248z$5);
4110
+ 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";
4111
+ styleInject(css_248z$4);
4273
4112
 
4274
- 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";
4275
- styleInject(css_248z$6);
4113
+ 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";
4114
+ styleInject(css_248z$5);
4276
4115
 
4277
4116
  /** 动画时间轴组件 */
4278
4117
  var TimeArea = function TimeArea(_ref) {
@@ -4374,6 +4213,190 @@ var TimeArea = function TimeArea(_ref) {
4374
4213
  }));
4375
4214
  };
4376
4215
 
4216
+ 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";
4217
+ styleInject(css_248z$6);
4218
+
4219
+ /** 拖拽辅助线 */
4220
+ var DragLines = /*#__PURE__*/memo(function (_ref) {
4221
+ var isMoving = _ref.isMoving,
4222
+ _ref$movePositions = _ref.movePositions,
4223
+ movePositions = _ref$movePositions === void 0 ? [] : _ref$movePositions,
4224
+ _ref$assistPositions = _ref.assistPositions,
4225
+ assistPositions = _ref$assistPositions === void 0 ? [] : _ref$assistPositions,
4226
+ scrollLeft = _ref.scrollLeft;
4227
+ var _ref2 = useSize(document.querySelector('#time-editor-container')) || {},
4228
+ _ref2$height = _ref2.height,
4229
+ height = _ref2$height === void 0 ? 0 : _ref2$height;
4230
+ var tolerance = 5; // 容差范围,单位像素
4231
+ return /*#__PURE__*/React.createElement("div", {
4232
+ className: prefix('drag-line-container'),
4233
+ style: {
4234
+ height: height || '100%'
4235
+ }
4236
+ }, isMoving && movePositions.map(function (movePos) {
4237
+ // 查找在容差范围内的辅助线位置
4238
+ var matchedAssistPos = assistPositions.find(function (assistPos) {
4239
+ return Math.abs(movePos - assistPos) <= tolerance;
4240
+ });
4241
+ if (matchedAssistPos) {
4242
+ return /*#__PURE__*/React.createElement("div", {
4243
+ key: matchedAssistPos,
4244
+ className: prefix('drag-line'),
4245
+ style: {
4246
+ left: matchedAssistPos - scrollLeft
4247
+ }
4248
+ });
4249
+ }
4250
+ return null;
4251
+ }));
4252
+ });
4253
+
4254
+ var defaultGetAssistPosition = function defaultGetAssistPosition(data) {
4255
+ var editorData = data.editorData,
4256
+ assistActionIds = data.assistActionIds,
4257
+ action = data.action,
4258
+ row = data.row,
4259
+ scale = data.scale,
4260
+ scaleWidth = data.scaleWidth,
4261
+ startLeft = data.startLeft,
4262
+ cursorLeft = data.cursorLeft,
4263
+ hideCursor = data.hideCursor;
4264
+ var otherActions = [];
4265
+ if (assistActionIds) {
4266
+ editorData.forEach(function (rowItem) {
4267
+ rowItem.actions.forEach(function (actionItem) {
4268
+ if (assistActionIds.includes(actionItem.id)) otherActions.push(actionItem);
4269
+ });
4270
+ });
4271
+ } else {
4272
+ editorData.forEach(function (rowItem) {
4273
+ if (rowItem.id !== row.id) {
4274
+ otherActions.push.apply(otherActions, _toConsumableArray(rowItem.actions));
4275
+ } else {
4276
+ rowItem.actions.forEach(function (actionItem) {
4277
+ if (actionItem.id !== action.id) otherActions.push(actionItem);
4278
+ });
4279
+ }
4280
+ });
4281
+ }
4282
+ var positions = parserActionsToPositions(otherActions, {
4283
+ startLeft: startLeft,
4284
+ scale: scale,
4285
+ scaleWidth: scaleWidth
4286
+ });
4287
+ if (!hideCursor) positions.push(cursorLeft);
4288
+ return positions;
4289
+ };
4290
+ var defaultGetMovePosition = function defaultGetMovePosition(data) {
4291
+ var start = data.start,
4292
+ end = data.end,
4293
+ dir = data.dir,
4294
+ scale = data.scale,
4295
+ scaleWidth = data.scaleWidth,
4296
+ startLeft = data.startLeft;
4297
+ var _parserTimeToTransfor = parserTimeToTransform({
4298
+ start: start,
4299
+ end: end
4300
+ }, {
4301
+ startLeft: startLeft,
4302
+ scaleWidth: scaleWidth,
4303
+ scale: scale
4304
+ }),
4305
+ left = _parserTimeToTransfor.left,
4306
+ width = _parserTimeToTransfor.width;
4307
+ if (!dir) return [left, left + width];
4308
+ return dir === "right" ? [left + width] : [left];
4309
+ };
4310
+ var DragLineController = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function (props, ref) {
4311
+ var dragLine = props.dragLine,
4312
+ editorData = props.editorData,
4313
+ cursorTime = props.cursorTime,
4314
+ scale = props.scale,
4315
+ scaleWidth = props.scaleWidth,
4316
+ startLeft = props.startLeft,
4317
+ hideCursor = props.hideCursor,
4318
+ scrollLeft = props.scrollLeft,
4319
+ getAssistDragLineActionIds = props.getAssistDragLineActionIds;
4320
+ var _useState = useState({
4321
+ isMoving: false,
4322
+ movePositions: [],
4323
+ assistPositions: []
4324
+ }),
4325
+ _useState2 = _slicedToArray(_useState, 2),
4326
+ dragLineData = _useState2[0],
4327
+ setDragLineData = _useState2[1];
4328
+ console.log('dragLineData = ', dragLineData);
4329
+ var initDragLine = useCallback(function (data) {
4330
+ if (dragLine) {
4331
+ var assistActionIds = getAssistDragLineActionIds && getAssistDragLineActionIds({
4332
+ action: data.action,
4333
+ row: data.row,
4334
+ editorData: editorData
4335
+ });
4336
+ var cursorLeft = parserTimeToPixel(cursorTime, {
4337
+ scaleWidth: scaleWidth,
4338
+ scale: scale,
4339
+ startLeft: startLeft
4340
+ });
4341
+ var assistPositions = defaultGetAssistPosition({
4342
+ editorData: editorData,
4343
+ assistActionIds: assistActionIds,
4344
+ action: data.action,
4345
+ row: data.row,
4346
+ scale: scale,
4347
+ scaleWidth: scaleWidth,
4348
+ startLeft: startLeft,
4349
+ hideCursor: hideCursor,
4350
+ cursorLeft: cursorLeft
4351
+ });
4352
+ setDragLineData({
4353
+ isMoving: true,
4354
+ movePositions: [],
4355
+ assistPositions: assistPositions
4356
+ });
4357
+ }
4358
+ }, [dragLine, editorData, cursorTime, scale, scaleWidth, startLeft, hideCursor, getAssistDragLineActionIds]);
4359
+ var updateDragLine = useCallback(function (data) {
4360
+ if (dragLine) {
4361
+ var movePositions = defaultGetMovePosition(_objectSpread2(_objectSpread2({}, data), {}, {
4362
+ startLeft: startLeft,
4363
+ scaleWidth: scaleWidth,
4364
+ scale: scale
4365
+ }));
4366
+ setDragLineData(function (prev) {
4367
+ return _objectSpread2(_objectSpread2({}, prev), {}, {
4368
+ movePositions: movePositions
4369
+ });
4370
+ });
4371
+ }
4372
+ }, [dragLine, startLeft, scaleWidth, scale]);
4373
+ var disposeDragLine = useCallback(function () {
4374
+ setDragLineData({
4375
+ isMoving: false,
4376
+ movePositions: [],
4377
+ assistPositions: []
4378
+ });
4379
+ }, []);
4380
+ useImperativeHandle(ref, function () {
4381
+ return {
4382
+ initDragLine: initDragLine,
4383
+ updateDragLine: updateDragLine,
4384
+ disposeDragLine: disposeDragLine
4385
+ };
4386
+ }, [initDragLine, updateDragLine, disposeDragLine]);
4387
+ var dragLinesProps = useMemo(function () {
4388
+ return {
4389
+ isMoving: dragLineData.isMoving,
4390
+ movePositions: dragLineData.movePositions,
4391
+ assistPositions: dragLineData.assistPositions,
4392
+ scrollLeft: scrollLeft
4393
+ };
4394
+ }, [dragLineData.isMoving, dragLineData.movePositions, dragLineData.assistPositions, scrollLeft]);
4395
+ if (!dragLine) return null;
4396
+ return /*#__PURE__*/React.createElement(DragLines, _objectSpread2({}, dragLinesProps));
4397
+ }));
4398
+ DragLineController.displayName = "DragLineController";
4399
+
4377
4400
  var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4378
4401
  var checkedProps = checkProps(props);
4379
4402
  var style = props.style,
@@ -4385,6 +4408,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4385
4408
  autoScroll = checkedProps.autoScroll,
4386
4409
  hideCursor = checkedProps.hideCursor,
4387
4410
  disableDrag = checkedProps.disableDrag,
4411
+ dragLine = checkedProps.dragLine,
4388
4412
  scale = checkedProps.scale,
4389
4413
  scaleWidth = checkedProps.scaleWidth,
4390
4414
  startLeft = checkedProps.startLeft,
@@ -4428,6 +4452,7 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4428
4452
  _useState0 = _slicedToArray(_useState9, 2),
4429
4453
  width = _useState0[0],
4430
4454
  setWidth = _useState0[1];
4455
+ var dragLineControllerRef = useRef(null);
4431
4456
  var groupedData = groupBy(editorData, 'type');
4432
4457
  var areaCount = Object.keys(groupedData).length;
4433
4458
  var keys = Object.keys(groupedData);
@@ -4503,6 +4528,24 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4503
4528
  scrollLeft: Math.max(scrollSync.current.state.scrollLeft + delta, 0)
4504
4529
  });
4505
4530
  };
4531
+ var handleInitDragLine = useCallback(function (data) {
4532
+ var _checkedProps$onActio, _checkedProps$onActio2, _dragLineControllerRe;
4533
+ (_checkedProps$onActio = checkedProps.onActionMoveStart) === null || _checkedProps$onActio === void 0 ? void 0 : _checkedProps$onActio.call(checkedProps, data);
4534
+ (_checkedProps$onActio2 = checkedProps.onActionResizeStart) === null || _checkedProps$onActio2 === void 0 ? void 0 : _checkedProps$onActio2.call(checkedProps, data);
4535
+ (_dragLineControllerRe = dragLineControllerRef.current) === null || _dragLineControllerRe === void 0 ? void 0 : _dragLineControllerRe.initDragLine(data);
4536
+ }, [checkedProps]);
4537
+ var handleUpdateDragLine = useCallback(function (data) {
4538
+ var _checkedProps$onActio3, _checkedProps$onActio4, _dragLineControllerRe2;
4539
+ (_checkedProps$onActio3 = checkedProps.onActionMoving) === null || _checkedProps$onActio3 === void 0 ? void 0 : _checkedProps$onActio3.call(checkedProps, data);
4540
+ (_checkedProps$onActio4 = checkedProps.onActionResizing) === null || _checkedProps$onActio4 === void 0 ? void 0 : _checkedProps$onActio4.call(checkedProps, data);
4541
+ (_dragLineControllerRe2 = dragLineControllerRef.current) === null || _dragLineControllerRe2 === void 0 ? void 0 : _dragLineControllerRe2.updateDragLine(data);
4542
+ }, [checkedProps]);
4543
+ var handleDisposeDragLine = useCallback(function (data) {
4544
+ var _checkedProps$onActio5, _checkedProps$onActio6, _dragLineControllerRe3;
4545
+ (_checkedProps$onActio5 = checkedProps.onActionMoveEnd) === null || _checkedProps$onActio5 === void 0 ? void 0 : _checkedProps$onActio5.call(checkedProps, data);
4546
+ (_checkedProps$onActio6 = checkedProps.onActionResizeEnd) === null || _checkedProps$onActio6 === void 0 ? void 0 : _checkedProps$onActio6.call(checkedProps, data);
4547
+ (_dragLineControllerRe3 = dragLineControllerRef.current) === null || _dragLineControllerRe3 === void 0 ? void 0 : _dragLineControllerRe3.disposeDragLine();
4548
+ }, [checkedProps]);
4506
4549
  // 处理运行器相关数据
4507
4550
  useEffect(function () {
4508
4551
  var handleTime = function handleTime(_ref) {
@@ -4575,6 +4618,24 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4575
4618
  }
4576
4619
  };
4577
4620
  });
4621
+ var onClickTimeline = function onClickTimeline(e) {
4622
+ var _e$target;
4623
+ if (!domRef.current) return;
4624
+ var rect = domRef.current.getBoundingClientRect();
4625
+ var position = e.clientX - rect.x;
4626
+ var left = position + scrollSync.current.state.scrollLeft;
4627
+ var time = parserPixelToTime(left, {
4628
+ startLeft: startLeft,
4629
+ scale: scale,
4630
+ scaleWidth: scaleWidth
4631
+ });
4632
+ var action = (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.closest('.timeline-editor-action');
4633
+ if (action || hideCursor) return;
4634
+ console.log('onClickTimeline = ', time);
4635
+ handleSetCursor({
4636
+ time: time
4637
+ });
4638
+ };
4578
4639
  // 监听timeline区域宽度变化
4579
4640
  useEffect(function () {
4580
4641
  if (areaRef.current) {
@@ -4626,6 +4687,12 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4626
4687
  deltaScrollLeft: autoScroll && handleDeltaScrollLeft,
4627
4688
  allowCreateTrack: allowCreateTrack,
4628
4689
  onMutiSelectChange: props === null || props === void 0 ? void 0 : props.onMutiSelectChange,
4690
+ onActionMoveStart: handleInitDragLine,
4691
+ onActionResizeStart: handleInitDragLine,
4692
+ onActionMoving: handleUpdateDragLine,
4693
+ onActionResizing: handleUpdateDragLine,
4694
+ onActionMoveEnd: handleDisposeDragLine,
4695
+ onActionResizeEnd: handleDisposeDragLine,
4629
4696
  onScroll: function onScroll(params) {
4630
4697
  _onScroll(params);
4631
4698
  onScrollVertical && onScrollVertical(params);
@@ -4635,7 +4702,8 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4635
4702
  ref: containerRef,
4636
4703
  style: {
4637
4704
  height: '100%'
4638
- }
4705
+ },
4706
+ onClick: onClickTimeline
4639
4707
  }, Object.keys(groupedData).map(function (key, index) {
4640
4708
  var handleGroupDataChange = function handleGroupDataChange(updatedData) {
4641
4709
  var mergedData = editorData.filter(function (item) {
@@ -4682,6 +4750,12 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4682
4750
  containerRef: containerRef,
4683
4751
  onMutiSelectChange: props === null || props === void 0 ? void 0 : props.onMutiSelectChange,
4684
4752
  engineRef: engineRef,
4753
+ onActionMoveStart: handleInitDragLine,
4754
+ onActionResizeStart: handleInitDragLine,
4755
+ onActionMoving: handleUpdateDragLine,
4756
+ onActionResizing: handleUpdateDragLine,
4757
+ onActionMoveEnd: handleDisposeDragLine,
4758
+ onActionResizeEnd: handleDisposeDragLine,
4685
4759
  onScroll: function onScroll(params) {
4686
4760
  _onScroll(params);
4687
4761
  onScrollVertical && onScrollVertical(params);
@@ -4699,7 +4773,18 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
4699
4773
  areaRef: areaRef,
4700
4774
  scrollSync: scrollSync,
4701
4775
  deltaScrollLeft: autoScroll && handleDeltaScrollLeft
4702
- }))));
4776
+ }))), /*#__PURE__*/React.createElement(DragLineController, {
4777
+ ref: dragLineControllerRef,
4778
+ dragLine: dragLine,
4779
+ editorData: editorData,
4780
+ cursorTime: cursorTime,
4781
+ scale: scale,
4782
+ scaleWidth: scaleWidth,
4783
+ startLeft: startLeft,
4784
+ hideCursor: hideCursor,
4785
+ scrollLeft: scrollLeft,
4786
+ getAssistDragLineActionIds: checkedProps.getAssistDragLineActionIds
4787
+ }));
4703
4788
  }));
4704
4789
  });
4705
4790