sense-react-timeline-editor 1.0.20 → 1.0.22
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 +46 -8
- package/dist/index.js +46 -8
- package/dist/interface/action.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -2950,6 +2950,8 @@ var EditRow = function EditRow(props) {
|
|
|
2950
2950
|
e.stopPropagation();
|
|
2951
2951
|
if (rowData.canUpload) {
|
|
2952
2952
|
var files = e.dataTransfer.files;
|
|
2953
|
+
// @ts-expect-error 因为 files 是 FileList 类型,不能直接修改 uid 属性
|
|
2954
|
+
files[0].uid = new Date().getTime().toString();
|
|
2953
2955
|
uploadBgMusic === null || uploadBgMusic === void 0 ? void 0 : uploadBgMusic(Array.from(files));
|
|
2954
2956
|
}
|
|
2955
2957
|
},
|
|
@@ -3739,7 +3741,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3739
3741
|
// 支持 mp3\wav 格式上传
|
|
3740
3742
|
var onBeforeUpload = function onBeforeUpload(file) {
|
|
3741
3743
|
if (file.type !== 'audio/mp3' && file.type !== 'audio/wav' && file.type !== 'audio/mpeg') {
|
|
3742
|
-
message.error('只能上传
|
|
3744
|
+
message.error('只能上传mp3、wav格式的音频');
|
|
3743
3745
|
return false;
|
|
3744
3746
|
}
|
|
3745
3747
|
var maxSize = 100 * 1024 * 1024;
|
|
@@ -3752,22 +3754,48 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3752
3754
|
var handleUploadChange = function handleUploadChange(row) {
|
|
3753
3755
|
return /*#__PURE__*/function () {
|
|
3754
3756
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3755
|
-
var _info$file$response;
|
|
3756
|
-
var uid, duration, newAction;
|
|
3757
|
+
var _info$file$response, _info$file;
|
|
3758
|
+
var totalDuration, _newAction, uid, duration, newAction;
|
|
3757
3759
|
return _regenerator().w(function (_context) {
|
|
3758
3760
|
while (1) switch (_context.n) {
|
|
3759
3761
|
case 0:
|
|
3760
3762
|
console.log('Upload info:', info);
|
|
3761
|
-
if (
|
|
3763
|
+
if (info.file) {
|
|
3762
3764
|
_context.n = 1;
|
|
3763
3765
|
break;
|
|
3764
3766
|
}
|
|
3765
3767
|
return _context.a(2);
|
|
3766
3768
|
case 1:
|
|
3769
|
+
if (info.file.response) {
|
|
3770
|
+
_context.n = 2;
|
|
3771
|
+
break;
|
|
3772
|
+
}
|
|
3773
|
+
totalDuration = row.actions.reduce(function (max, current) {
|
|
3774
|
+
var _max$end;
|
|
3775
|
+
var currentEnd = current.end || 0;
|
|
3776
|
+
var maxEnd = (_max$end = max === null || max === void 0 ? void 0 : max.end) !== null && _max$end !== void 0 ? _max$end : 0;
|
|
3777
|
+
return currentEnd > maxEnd ? current : max;
|
|
3778
|
+
}, {
|
|
3779
|
+
end: 0
|
|
3780
|
+
}).end || 0;
|
|
3781
|
+
_newAction = {
|
|
3782
|
+
id: info.file.uid,
|
|
3783
|
+
effectId: 'custom_video_effect',
|
|
3784
|
+
flexible: true,
|
|
3785
|
+
url: '',
|
|
3786
|
+
start: totalDuration,
|
|
3787
|
+
end: totalDuration + 5,
|
|
3788
|
+
isUpload: true,
|
|
3789
|
+
segment_type: 'bgm',
|
|
3790
|
+
isUploading: info.isUploading || false
|
|
3791
|
+
};
|
|
3792
|
+
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3793
|
+
return _context.a(2);
|
|
3794
|
+
case 2:
|
|
3767
3795
|
uid = info.file.uid;
|
|
3768
|
-
_context.n =
|
|
3796
|
+
_context.n = 3;
|
|
3769
3797
|
return getAudioDuration(info.file.response.url);
|
|
3770
|
-
case
|
|
3798
|
+
case 3:
|
|
3771
3799
|
duration = _context.v;
|
|
3772
3800
|
newAction = {
|
|
3773
3801
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3777,10 +3805,12 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3777
3805
|
start: currentMouseTime,
|
|
3778
3806
|
end: currentMouseTime + duration,
|
|
3779
3807
|
isUpload: true,
|
|
3780
|
-
segment_type: 'bgm'
|
|
3808
|
+
segment_type: 'bgm',
|
|
3809
|
+
isUploading: false,
|
|
3810
|
+
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3781
3811
|
};
|
|
3782
3812
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3783
|
-
case
|
|
3813
|
+
case 4:
|
|
3784
3814
|
return _context.a(2);
|
|
3785
3815
|
}
|
|
3786
3816
|
}, _callee);
|
|
@@ -3990,12 +4020,20 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3990
4020
|
var canUpload = onBeforeUpload === null || onBeforeUpload === void 0 ? void 0 : onBeforeUpload(file[0]);
|
|
3991
4021
|
if (!canUpload) return;
|
|
3992
4022
|
var onSuccess = handleUploadChange(row);
|
|
4023
|
+
onSuccess({
|
|
4024
|
+
file: file[0],
|
|
4025
|
+
isUploading: true
|
|
4026
|
+
});
|
|
3993
4027
|
customRequest === null || customRequest === void 0 ? void 0 : customRequest({
|
|
3994
4028
|
file: file[0],
|
|
3995
4029
|
onSuccess: onSuccess,
|
|
3996
4030
|
method: 'POST',
|
|
3997
4031
|
action: 'bgm',
|
|
3998
4032
|
onError: function onError(err) {
|
|
4033
|
+
onSuccess({
|
|
4034
|
+
file: file[0],
|
|
4035
|
+
isUploading: false
|
|
4036
|
+
});
|
|
3999
4037
|
console.error('Upload error:', err);
|
|
4000
4038
|
}
|
|
4001
4039
|
});
|
package/dist/index.js
CHANGED
|
@@ -2959,6 +2959,8 @@ var EditRow = function EditRow(props) {
|
|
|
2959
2959
|
e.stopPropagation();
|
|
2960
2960
|
if (rowData.canUpload) {
|
|
2961
2961
|
var files = e.dataTransfer.files;
|
|
2962
|
+
// @ts-expect-error 因为 files 是 FileList 类型,不能直接修改 uid 属性
|
|
2963
|
+
files[0].uid = new Date().getTime().toString();
|
|
2962
2964
|
uploadBgMusic === null || uploadBgMusic === void 0 ? void 0 : uploadBgMusic(Array.from(files));
|
|
2963
2965
|
}
|
|
2964
2966
|
},
|
|
@@ -3748,7 +3750,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3748
3750
|
// 支持 mp3\wav 格式上传
|
|
3749
3751
|
var onBeforeUpload = function onBeforeUpload(file) {
|
|
3750
3752
|
if (file.type !== 'audio/mp3' && file.type !== 'audio/wav' && file.type !== 'audio/mpeg') {
|
|
3751
|
-
es.message.error('只能上传
|
|
3753
|
+
es.message.error('只能上传mp3、wav格式的音频');
|
|
3752
3754
|
return false;
|
|
3753
3755
|
}
|
|
3754
3756
|
var maxSize = 100 * 1024 * 1024;
|
|
@@ -3761,22 +3763,48 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3761
3763
|
var handleUploadChange = function handleUploadChange(row) {
|
|
3762
3764
|
return /*#__PURE__*/function () {
|
|
3763
3765
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(info) {
|
|
3764
|
-
var _info$file$response;
|
|
3765
|
-
var uid, duration, newAction;
|
|
3766
|
+
var _info$file$response, _info$file;
|
|
3767
|
+
var totalDuration, _newAction, uid, duration, newAction;
|
|
3766
3768
|
return _regenerator().w(function (_context) {
|
|
3767
3769
|
while (1) switch (_context.n) {
|
|
3768
3770
|
case 0:
|
|
3769
3771
|
console.log('Upload info:', info);
|
|
3770
|
-
if (
|
|
3772
|
+
if (info.file) {
|
|
3771
3773
|
_context.n = 1;
|
|
3772
3774
|
break;
|
|
3773
3775
|
}
|
|
3774
3776
|
return _context.a(2);
|
|
3775
3777
|
case 1:
|
|
3778
|
+
if (info.file.response) {
|
|
3779
|
+
_context.n = 2;
|
|
3780
|
+
break;
|
|
3781
|
+
}
|
|
3782
|
+
totalDuration = row.actions.reduce(function (max, current) {
|
|
3783
|
+
var _max$end;
|
|
3784
|
+
var currentEnd = current.end || 0;
|
|
3785
|
+
var maxEnd = (_max$end = max === null || max === void 0 ? void 0 : max.end) !== null && _max$end !== void 0 ? _max$end : 0;
|
|
3786
|
+
return currentEnd > maxEnd ? current : max;
|
|
3787
|
+
}, {
|
|
3788
|
+
end: 0
|
|
3789
|
+
}).end || 0;
|
|
3790
|
+
_newAction = {
|
|
3791
|
+
id: info.file.uid,
|
|
3792
|
+
effectId: 'custom_video_effect',
|
|
3793
|
+
flexible: true,
|
|
3794
|
+
url: '',
|
|
3795
|
+
start: totalDuration,
|
|
3796
|
+
end: totalDuration + 5,
|
|
3797
|
+
isUpload: true,
|
|
3798
|
+
segment_type: 'bgm',
|
|
3799
|
+
isUploading: info.isUploading || false
|
|
3800
|
+
};
|
|
3801
|
+
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3802
|
+
return _context.a(2);
|
|
3803
|
+
case 2:
|
|
3776
3804
|
uid = info.file.uid;
|
|
3777
|
-
_context.n =
|
|
3805
|
+
_context.n = 3;
|
|
3778
3806
|
return getAudioDuration(info.file.response.url);
|
|
3779
|
-
case
|
|
3807
|
+
case 3:
|
|
3780
3808
|
duration = _context.v;
|
|
3781
3809
|
newAction = {
|
|
3782
3810
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3786,10 +3814,12 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3786
3814
|
start: currentMouseTime,
|
|
3787
3815
|
end: currentMouseTime + duration,
|
|
3788
3816
|
isUpload: true,
|
|
3789
|
-
segment_type: 'bgm'
|
|
3817
|
+
segment_type: 'bgm',
|
|
3818
|
+
isUploading: false,
|
|
3819
|
+
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3790
3820
|
};
|
|
3791
3821
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3792
|
-
case
|
|
3822
|
+
case 4:
|
|
3793
3823
|
return _context.a(2);
|
|
3794
3824
|
}
|
|
3795
3825
|
}, _callee);
|
|
@@ -3999,12 +4029,20 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3999
4029
|
var canUpload = onBeforeUpload === null || onBeforeUpload === void 0 ? void 0 : onBeforeUpload(file[0]);
|
|
4000
4030
|
if (!canUpload) return;
|
|
4001
4031
|
var onSuccess = handleUploadChange(row);
|
|
4032
|
+
onSuccess({
|
|
4033
|
+
file: file[0],
|
|
4034
|
+
isUploading: true
|
|
4035
|
+
});
|
|
4002
4036
|
customRequest === null || customRequest === void 0 ? void 0 : customRequest({
|
|
4003
4037
|
file: file[0],
|
|
4004
4038
|
onSuccess: onSuccess,
|
|
4005
4039
|
method: 'POST',
|
|
4006
4040
|
action: 'bgm',
|
|
4007
4041
|
onError: function onError(err) {
|
|
4042
|
+
onSuccess({
|
|
4043
|
+
file: file[0],
|
|
4044
|
+
isUploading: false
|
|
4045
|
+
});
|
|
4008
4046
|
console.error('Upload error:', err);
|
|
4009
4047
|
}
|
|
4010
4048
|
});
|