sense-react-timeline-editor 1.1.33 → 1.1.35
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 +44 -42
- package/dist/index.js +44 -42
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { prefixNames } from 'framework-utils';
|
|
|
5
5
|
import interact from 'interactjs';
|
|
6
6
|
import { useSelectionContainer } from '@air/react-drag-to-select';
|
|
7
7
|
import { message } from 'antd/es';
|
|
8
|
-
import
|
|
8
|
+
import 'howler';
|
|
9
9
|
import { groupBy, throttle } from 'lodash-es';
|
|
10
10
|
import useSize from 'ahooks/es/useSize';
|
|
11
11
|
|
|
@@ -3579,26 +3579,6 @@ var useRowDrag = function useRowDrag(options) {
|
|
|
3579
3579
|
};
|
|
3580
3580
|
};
|
|
3581
3581
|
|
|
3582
|
-
// 获取音频时长
|
|
3583
|
-
var getAudioDuration = function getAudioDuration(url) {
|
|
3584
|
-
return new Promise(function (resolve) {
|
|
3585
|
-
var sound = new Howl({
|
|
3586
|
-
src: url
|
|
3587
|
-
});
|
|
3588
|
-
sound.on('load', function () {
|
|
3589
|
-
resolve(sound.duration());
|
|
3590
|
-
sound.unload();
|
|
3591
|
-
});
|
|
3592
|
-
setTimeout(function () {
|
|
3593
|
-
resolve(2); // 加载失败时返回默认时长2秒
|
|
3594
|
-
sound.unload();
|
|
3595
|
-
}, 6 * 1000); // 60秒超时 60 * 1000
|
|
3596
|
-
sound.on('loaderror', function () {
|
|
3597
|
-
resolve(2); // 加载失败时返回默认时长2秒
|
|
3598
|
-
sound.unload();
|
|
3599
|
-
});
|
|
3600
|
-
});
|
|
3601
|
-
};
|
|
3602
3582
|
var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
3603
3583
|
var className = props.className,
|
|
3604
3584
|
_props$isMulti = props.isMulti,
|
|
@@ -3650,7 +3630,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3650
3630
|
return /*#__PURE__*/function () {
|
|
3651
3631
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3652
3632
|
var _info$file$response, _info$file, _info$file$response2;
|
|
3653
|
-
var maxSize, hasDefault, totalDuration, _newAction, uid,
|
|
3633
|
+
var maxSize, hasDefault, totalDuration, _newAction, uid, newAction;
|
|
3654
3634
|
return _regenerator().w(function (_context) {
|
|
3655
3635
|
while (1) switch (_context.n) {
|
|
3656
3636
|
case 0:
|
|
@@ -3720,17 +3700,13 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3720
3700
|
return _context.a(2);
|
|
3721
3701
|
case 5:
|
|
3722
3702
|
uid = info.file.uid;
|
|
3723
|
-
_context.n = 6;
|
|
3724
|
-
return getAudioDuration(info.file.response.url);
|
|
3725
|
-
case 6:
|
|
3726
|
-
duration = _context.v;
|
|
3727
3703
|
newAction = {
|
|
3728
3704
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
3729
3705
|
effectId: 'custom_video_effect',
|
|
3730
3706
|
flexible: true,
|
|
3731
3707
|
url: info.file.response.url,
|
|
3732
3708
|
start: currentMouseTime,
|
|
3733
|
-
end: currentMouseTime +
|
|
3709
|
+
end: currentMouseTime + 1000,
|
|
3734
3710
|
isUpload: true,
|
|
3735
3711
|
segment_type: 'bgm',
|
|
3736
3712
|
isUploading: false,
|
|
@@ -3738,7 +3714,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3738
3714
|
waveform: ((_info$file$response2 = info.file.response) === null || _info$file$response2 === void 0 ? void 0 : _info$file$response2.peaks) || []
|
|
3739
3715
|
};
|
|
3740
3716
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3741
|
-
case
|
|
3717
|
+
case 6:
|
|
3742
3718
|
return _context.a(2);
|
|
3743
3719
|
}
|
|
3744
3720
|
}, _callee);
|
|
@@ -3890,20 +3866,35 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3890
3866
|
if (trackPreviewDataRef.current) setTrackPreview(trackPreviewDataRef.current);
|
|
3891
3867
|
if (dragIndicatorDataRef.current) setDragIndicator(dragIndicatorDataRef.current);
|
|
3892
3868
|
}, [scrollTop]);
|
|
3869
|
+
// 使用 ref 追踪 handleSelectionChange 的调用深度,避免无限循环
|
|
3870
|
+
var selectionChangeDepthRef = useRef(0);
|
|
3893
3871
|
// 框选功能
|
|
3894
3872
|
var handleSelectionChange = useCallback(function (selectedActionIds) {
|
|
3895
|
-
//
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3873
|
+
// 如果调用深度过深(超过10层),说明可能存在无限循环,直接返回
|
|
3874
|
+
if (selectionChangeDepthRef.current > 10) {
|
|
3875
|
+
console.warn('Selection change depth exceeded, possible infinite loop detected');
|
|
3876
|
+
return;
|
|
3877
|
+
}
|
|
3878
|
+
selectionChangeDepthRef.current++;
|
|
3879
|
+
try {
|
|
3880
|
+
// 更新 editorData 中每个 action 的选中状态
|
|
3881
|
+
var updatedData = editorData.map(function (row) {
|
|
3882
|
+
return _objectSpread2(_objectSpread2({}, row), {}, {
|
|
3883
|
+
actions: row.actions.map(function (action) {
|
|
3884
|
+
return _objectSpread2(_objectSpread2({}, action), {}, {
|
|
3885
|
+
selected: selectedActionIds.includes(action.id)
|
|
3886
|
+
});
|
|
3887
|
+
})
|
|
3888
|
+
});
|
|
3903
3889
|
});
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3890
|
+
setEditorData(updatedData);
|
|
3891
|
+
onMutiSelectChange === null || onMutiSelectChange === void 0 ? void 0 : onMutiSelectChange(selectedActionIds);
|
|
3892
|
+
} finally {
|
|
3893
|
+
// 延迟重置计数器,确保在 React 完成渲染后执行
|
|
3894
|
+
setTimeout(function () {
|
|
3895
|
+
selectionChangeDepthRef.current--;
|
|
3896
|
+
}, 0);
|
|
3897
|
+
}
|
|
3907
3898
|
}, [editorData, setEditorData, onMutiSelectChange]);
|
|
3908
3899
|
var _useRowSelection = useRowSelection({
|
|
3909
3900
|
editorData: editorData,
|
|
@@ -4787,8 +4778,19 @@ var Timeline = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (p
|
|
|
4787
4778
|
useEffect(function () {
|
|
4788
4779
|
var handleClickOutside = function handleClickOutside(e) {
|
|
4789
4780
|
var target = e.target;
|
|
4790
|
-
var
|
|
4791
|
-
if (
|
|
4781
|
+
var areaEl = target.closest('.timeline-editor-time-area');
|
|
4782
|
+
if (areaEl) return;
|
|
4783
|
+
var actionEl = target.closest('.timeline-editor-action');
|
|
4784
|
+
if (actionEl) {
|
|
4785
|
+
var _props$onClickActionO;
|
|
4786
|
+
// @ts-expect-error 类型断言
|
|
4787
|
+
(_props$onClickActionO = props.onClickActionOnly) === null || _props$onClickActionO === void 0 ? void 0 : _props$onClickActionO.call(props, e, {
|
|
4788
|
+
action: {
|
|
4789
|
+
id: actionEl.dataset.actionId
|
|
4790
|
+
}
|
|
4791
|
+
});
|
|
4792
|
+
return;
|
|
4793
|
+
}
|
|
4792
4794
|
engineRef.current.trigger('mousedown', {
|
|
4793
4795
|
target: target,
|
|
4794
4796
|
evt: e
|
|
@@ -4804,7 +4806,7 @@ var Timeline = /*#__PURE__*/React.memo(/*#__PURE__*/React.forwardRef(function (p
|
|
|
4804
4806
|
return function () {
|
|
4805
4807
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
4806
4808
|
};
|
|
4807
|
-
}, []);
|
|
4809
|
+
}, [props.onClickActionOnly]);
|
|
4808
4810
|
// ref 数据
|
|
4809
4811
|
useImperativeHandle(ref, function () {
|
|
4810
4812
|
return {
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var frameworkUtils = require('framework-utils');
|
|
|
9
9
|
var interact = require('interactjs');
|
|
10
10
|
var reactDragToSelect = require('@air/react-drag-to-select');
|
|
11
11
|
var es = require('antd/es');
|
|
12
|
-
|
|
12
|
+
require('howler');
|
|
13
13
|
var lodashEs = require('lodash-es');
|
|
14
14
|
var useSize = require('ahooks/es/useSize');
|
|
15
15
|
|
|
@@ -3589,26 +3589,6 @@ var useRowDrag = function useRowDrag(options) {
|
|
|
3589
3589
|
};
|
|
3590
3590
|
};
|
|
3591
3591
|
|
|
3592
|
-
// 获取音频时长
|
|
3593
|
-
var getAudioDuration = function getAudioDuration(url) {
|
|
3594
|
-
return new Promise(function (resolve) {
|
|
3595
|
-
var sound = new howler.Howl({
|
|
3596
|
-
src: url
|
|
3597
|
-
});
|
|
3598
|
-
sound.on('load', function () {
|
|
3599
|
-
resolve(sound.duration());
|
|
3600
|
-
sound.unload();
|
|
3601
|
-
});
|
|
3602
|
-
setTimeout(function () {
|
|
3603
|
-
resolve(2); // 加载失败时返回默认时长2秒
|
|
3604
|
-
sound.unload();
|
|
3605
|
-
}, 6 * 1000); // 60秒超时 60 * 1000
|
|
3606
|
-
sound.on('loaderror', function () {
|
|
3607
|
-
resolve(2); // 加载失败时返回默认时长2秒
|
|
3608
|
-
sound.unload();
|
|
3609
|
-
});
|
|
3610
|
-
});
|
|
3611
|
-
};
|
|
3612
3592
|
var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
3613
3593
|
var className = props.className,
|
|
3614
3594
|
_props$isMulti = props.isMulti,
|
|
@@ -3660,7 +3640,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3660
3640
|
return /*#__PURE__*/function () {
|
|
3661
3641
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3662
3642
|
var _info$file$response, _info$file, _info$file$response2;
|
|
3663
|
-
var maxSize, hasDefault, totalDuration, _newAction, uid,
|
|
3643
|
+
var maxSize, hasDefault, totalDuration, _newAction, uid, newAction;
|
|
3664
3644
|
return _regenerator().w(function (_context) {
|
|
3665
3645
|
while (1) switch (_context.n) {
|
|
3666
3646
|
case 0:
|
|
@@ -3730,17 +3710,13 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3730
3710
|
return _context.a(2);
|
|
3731
3711
|
case 5:
|
|
3732
3712
|
uid = info.file.uid;
|
|
3733
|
-
_context.n = 6;
|
|
3734
|
-
return getAudioDuration(info.file.response.url);
|
|
3735
|
-
case 6:
|
|
3736
|
-
duration = _context.v;
|
|
3737
3713
|
newAction = {
|
|
3738
3714
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
3739
3715
|
effectId: 'custom_video_effect',
|
|
3740
3716
|
flexible: true,
|
|
3741
3717
|
url: info.file.response.url,
|
|
3742
3718
|
start: currentMouseTime,
|
|
3743
|
-
end: currentMouseTime +
|
|
3719
|
+
end: currentMouseTime + 1000,
|
|
3744
3720
|
isUpload: true,
|
|
3745
3721
|
segment_type: 'bgm',
|
|
3746
3722
|
isUploading: false,
|
|
@@ -3748,7 +3724,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3748
3724
|
waveform: ((_info$file$response2 = info.file.response) === null || _info$file$response2 === void 0 ? void 0 : _info$file$response2.peaks) || []
|
|
3749
3725
|
};
|
|
3750
3726
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3751
|
-
case
|
|
3727
|
+
case 6:
|
|
3752
3728
|
return _context.a(2);
|
|
3753
3729
|
}
|
|
3754
3730
|
}, _callee);
|
|
@@ -3900,20 +3876,35 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3900
3876
|
if (trackPreviewDataRef.current) setTrackPreview(trackPreviewDataRef.current);
|
|
3901
3877
|
if (dragIndicatorDataRef.current) setDragIndicator(dragIndicatorDataRef.current);
|
|
3902
3878
|
}, [scrollTop]);
|
|
3879
|
+
// 使用 ref 追踪 handleSelectionChange 的调用深度,避免无限循环
|
|
3880
|
+
var selectionChangeDepthRef = React.useRef(0);
|
|
3903
3881
|
// 框选功能
|
|
3904
3882
|
var handleSelectionChange = React.useCallback(function (selectedActionIds) {
|
|
3905
|
-
//
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3883
|
+
// 如果调用深度过深(超过10层),说明可能存在无限循环,直接返回
|
|
3884
|
+
if (selectionChangeDepthRef.current > 10) {
|
|
3885
|
+
console.warn('Selection change depth exceeded, possible infinite loop detected');
|
|
3886
|
+
return;
|
|
3887
|
+
}
|
|
3888
|
+
selectionChangeDepthRef.current++;
|
|
3889
|
+
try {
|
|
3890
|
+
// 更新 editorData 中每个 action 的选中状态
|
|
3891
|
+
var updatedData = editorData.map(function (row) {
|
|
3892
|
+
return _objectSpread2(_objectSpread2({}, row), {}, {
|
|
3893
|
+
actions: row.actions.map(function (action) {
|
|
3894
|
+
return _objectSpread2(_objectSpread2({}, action), {}, {
|
|
3895
|
+
selected: selectedActionIds.includes(action.id)
|
|
3896
|
+
});
|
|
3897
|
+
})
|
|
3898
|
+
});
|
|
3913
3899
|
});
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3900
|
+
setEditorData(updatedData);
|
|
3901
|
+
onMutiSelectChange === null || onMutiSelectChange === void 0 ? void 0 : onMutiSelectChange(selectedActionIds);
|
|
3902
|
+
} finally {
|
|
3903
|
+
// 延迟重置计数器,确保在 React 完成渲染后执行
|
|
3904
|
+
setTimeout(function () {
|
|
3905
|
+
selectionChangeDepthRef.current--;
|
|
3906
|
+
}, 0);
|
|
3907
|
+
}
|
|
3917
3908
|
}, [editorData, setEditorData, onMutiSelectChange]);
|
|
3918
3909
|
var _useRowSelection = useRowSelection({
|
|
3919
3910
|
editorData: editorData,
|
|
@@ -4797,8 +4788,19 @@ var Timeline = /*#__PURE__*/React__default['default'].memo(/*#__PURE__*/React__d
|
|
|
4797
4788
|
React.useEffect(function () {
|
|
4798
4789
|
var handleClickOutside = function handleClickOutside(e) {
|
|
4799
4790
|
var target = e.target;
|
|
4800
|
-
var
|
|
4801
|
-
if (
|
|
4791
|
+
var areaEl = target.closest('.timeline-editor-time-area');
|
|
4792
|
+
if (areaEl) return;
|
|
4793
|
+
var actionEl = target.closest('.timeline-editor-action');
|
|
4794
|
+
if (actionEl) {
|
|
4795
|
+
var _props$onClickActionO;
|
|
4796
|
+
// @ts-expect-error 类型断言
|
|
4797
|
+
(_props$onClickActionO = props.onClickActionOnly) === null || _props$onClickActionO === void 0 ? void 0 : _props$onClickActionO.call(props, e, {
|
|
4798
|
+
action: {
|
|
4799
|
+
id: actionEl.dataset.actionId
|
|
4800
|
+
}
|
|
4801
|
+
});
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4802
4804
|
engineRef.current.trigger('mousedown', {
|
|
4803
4805
|
target: target,
|
|
4804
4806
|
evt: e
|
|
@@ -4814,7 +4816,7 @@ var Timeline = /*#__PURE__*/React__default['default'].memo(/*#__PURE__*/React__d
|
|
|
4814
4816
|
return function () {
|
|
4815
4817
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
4816
4818
|
};
|
|
4817
|
-
}, []);
|
|
4819
|
+
}, [props.onClickActionOnly]);
|
|
4818
4820
|
// ref 数据
|
|
4819
4821
|
React.useImperativeHandle(ref, function () {
|
|
4820
4822
|
return {
|