sense-react-timeline-editor 1.1.6 → 1.1.7
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 +49 -12
- package/dist/index.js +48 -11
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import interact from 'interactjs';
|
|
|
6
6
|
import { useSelectionContainer } from '@air/react-drag-to-select';
|
|
7
7
|
import { Upload, message } from 'antd/es';
|
|
8
8
|
import { Howl } from 'howler';
|
|
9
|
-
import { groupBy } from 'lodash-es';
|
|
9
|
+
import { groupBy, throttle } from 'lodash-es';
|
|
10
10
|
import useSize from 'ahooks/es/useSize';
|
|
11
11
|
|
|
12
12
|
function _arrayLikeToArray(r, a) {
|
|
@@ -2007,7 +2007,7 @@ var Cursor = function Cursor(_ref) {
|
|
|
2007
2007
|
});
|
|
2008
2008
|
var clientHeight = ((_document$querySelect = document.querySelector("#time-editor-container")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
|
|
2009
2009
|
return /*#__PURE__*/React.createElement(RowDnd, {
|
|
2010
|
-
top: theme === 'light' ?
|
|
2010
|
+
top: theme === 'light' ? 26 : 0,
|
|
2011
2011
|
start: startLeft,
|
|
2012
2012
|
height: clientHeight,
|
|
2013
2013
|
ref: rowRnd,
|
|
@@ -2908,6 +2908,18 @@ var EditRow = function EditRow(props) {
|
|
|
2908
2908
|
uploadBgMusic = props.uploadBgMusic;
|
|
2909
2909
|
var classNames = ['edit-row'];
|
|
2910
2910
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2911
|
+
var clientWidth = document.documentElement.clientWidth;
|
|
2912
|
+
var timeStart = parserPixelToTime(scrollLeft, {
|
|
2913
|
+
startLeft: startLeft,
|
|
2914
|
+
scale: scale,
|
|
2915
|
+
scaleWidth: scaleWidth
|
|
2916
|
+
});
|
|
2917
|
+
var timeEnd = parserPixelToTime(scrollLeft + clientWidth + 200, {
|
|
2918
|
+
startLeft: startLeft,
|
|
2919
|
+
scale: scale,
|
|
2920
|
+
scaleWidth: scaleWidth
|
|
2921
|
+
});
|
|
2922
|
+
console.log('time = ', timeStart, ', timeEnd = ', timeEnd);
|
|
2911
2923
|
var handleTime = function handleTime(e) {
|
|
2912
2924
|
if (!areaRef.current) return;
|
|
2913
2925
|
var rect = areaRef.current.getBoundingClientRect();
|
|
@@ -2971,7 +2983,9 @@ var EditRow = function EditRow(props) {
|
|
|
2971
2983
|
});
|
|
2972
2984
|
}
|
|
2973
2985
|
}
|
|
2974
|
-
}, ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).
|
|
2986
|
+
}, ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).filter(function (action) {
|
|
2987
|
+
return action.end >= timeStart && action.start <= timeEnd;
|
|
2988
|
+
}).map(function (action) {
|
|
2975
2989
|
return /*#__PURE__*/React.createElement(EditAction, _objectSpread2(_objectSpread2({
|
|
2976
2990
|
key: action.id
|
|
2977
2991
|
}, props), {}, {
|
|
@@ -3641,10 +3655,16 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3641
3655
|
}
|
|
3642
3656
|
return _context.a(2);
|
|
3643
3657
|
case 1:
|
|
3644
|
-
if (!(info.file.
|
|
3658
|
+
if (!(info.file.type !== 'audio/mp3' && info.file.type !== 'audio/wav' && info.file.type !== 'audio/mpeg')) {
|
|
3645
3659
|
_context.n = 2;
|
|
3646
3660
|
break;
|
|
3647
3661
|
}
|
|
3662
|
+
return _context.a(2, false);
|
|
3663
|
+
case 2:
|
|
3664
|
+
if (!(info.file.status === 'error')) {
|
|
3665
|
+
_context.n = 3;
|
|
3666
|
+
break;
|
|
3667
|
+
}
|
|
3648
3668
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
|
|
3649
3669
|
id: info.file.uid,
|
|
3650
3670
|
isUploading: false,
|
|
@@ -3656,9 +3676,9 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3656
3676
|
uid: info.file.uid
|
|
3657
3677
|
}]);
|
|
3658
3678
|
return _context.a(2);
|
|
3659
|
-
case
|
|
3679
|
+
case 3:
|
|
3660
3680
|
if (info.file.response) {
|
|
3661
|
-
_context.n =
|
|
3681
|
+
_context.n = 4;
|
|
3662
3682
|
break;
|
|
3663
3683
|
}
|
|
3664
3684
|
hasDefault = row.actions.some(function (action) {
|
|
@@ -3685,11 +3705,11 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3685
3705
|
};
|
|
3686
3706
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3687
3707
|
return _context.a(2);
|
|
3688
|
-
case
|
|
3708
|
+
case 4:
|
|
3689
3709
|
uid = info.file.uid;
|
|
3690
|
-
_context.n =
|
|
3710
|
+
_context.n = 5;
|
|
3691
3711
|
return getAudioDuration(info.file.response.url);
|
|
3692
|
-
case
|
|
3712
|
+
case 5:
|
|
3693
3713
|
duration = _context.v;
|
|
3694
3714
|
newAction = {
|
|
3695
3715
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3704,7 +3724,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3704
3724
|
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3705
3725
|
};
|
|
3706
3726
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3707
|
-
case
|
|
3727
|
+
case 6:
|
|
3708
3728
|
return _context.a(2);
|
|
3709
3729
|
}
|
|
3710
3730
|
}, _callee);
|
|
@@ -3898,6 +3918,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3898
3918
|
backgroundPositionX: "0, ".concat(startLeft, "px"),
|
|
3899
3919
|
backgroundSize: "".concat(startLeft, "px, ").concat(scaleWidth, "px")
|
|
3900
3920
|
}),
|
|
3921
|
+
scrollLeft: scrollLeft,
|
|
3901
3922
|
areaRef: editAreaRef,
|
|
3902
3923
|
key: key,
|
|
3903
3924
|
rowHeight: (row === null || row === void 0 ? void 0 : row.rowHeight) || _rowHeight,
|
|
@@ -3981,7 +4002,8 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
3981
4002
|
}).length) > 0,
|
|
3982
4003
|
customRequest: customRequest,
|
|
3983
4004
|
onDrop: handleDrop,
|
|
3984
|
-
type: "drag"
|
|
4005
|
+
type: "drag",
|
|
4006
|
+
accept: "audio/mp3,audio/wav,audio/mpeg"
|
|
3985
4007
|
}, tChildren), tChildren ? null : editRow);
|
|
3986
4008
|
}
|
|
3987
4009
|
return editRow;
|
|
@@ -4039,6 +4061,7 @@ var EditAreaO = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4039
4061
|
}
|
|
4040
4062
|
}
|
|
4041
4063
|
heightRef.current = height;
|
|
4064
|
+
console.log('Math.max(scaleCount * scaleWidth + startLeft, width)', Math.max(scaleCount * scaleWidth + startLeft, width), ', width', width);
|
|
4042
4065
|
return /*#__PURE__*/React.createElement(Grid, {
|
|
4043
4066
|
columnCount: 1,
|
|
4044
4067
|
rowCount: heights.length,
|
|
@@ -4231,7 +4254,7 @@ var DragLines = /*#__PURE__*/memo(function (_ref) {
|
|
|
4231
4254
|
return /*#__PURE__*/React.createElement("div", {
|
|
4232
4255
|
className: prefix('drag-line-container'),
|
|
4233
4256
|
style: {
|
|
4234
|
-
height: height
|
|
4257
|
+
height: height ? height + 30 : '100%'
|
|
4235
4258
|
}
|
|
4236
4259
|
}, isMoving && movePositions.map(function (movePos) {
|
|
4237
4260
|
// 查找在容差范围内的辅助线位置
|
|
@@ -4649,6 +4672,20 @@ var Timeline = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
4649
4672
|
};
|
|
4650
4673
|
}
|
|
4651
4674
|
}, []);
|
|
4675
|
+
useEffect(function () {
|
|
4676
|
+
var containerEl = document.querySelector('.timeline-editor');
|
|
4677
|
+
var handleScroll = throttle(function (e) {
|
|
4678
|
+
console.log('scroll', e);
|
|
4679
|
+
scrollSync.current && scrollSync.current.setState({
|
|
4680
|
+
scrollLeft: e.target.scrollLeft || 0
|
|
4681
|
+
});
|
|
4682
|
+
}, 100);
|
|
4683
|
+
containerEl.addEventListener('scroll', handleScroll);
|
|
4684
|
+
return function () {
|
|
4685
|
+
containerEl.removeEventListener('scroll', handleScroll);
|
|
4686
|
+
handleScroll.cancel();
|
|
4687
|
+
};
|
|
4688
|
+
}, []);
|
|
4652
4689
|
return /*#__PURE__*/React.createElement("div", {
|
|
4653
4690
|
ref: domRef,
|
|
4654
4691
|
style: style,
|
package/dist/index.js
CHANGED
|
@@ -2017,7 +2017,7 @@ var Cursor = function Cursor(_ref) {
|
|
|
2017
2017
|
});
|
|
2018
2018
|
var clientHeight = ((_document$querySelect = document.querySelector("#time-editor-container")) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.clientHeight) || 0;
|
|
2019
2019
|
return /*#__PURE__*/React__default['default'].createElement(RowDnd, {
|
|
2020
|
-
top: theme === 'light' ?
|
|
2020
|
+
top: theme === 'light' ? 26 : 0,
|
|
2021
2021
|
start: startLeft,
|
|
2022
2022
|
height: clientHeight,
|
|
2023
2023
|
ref: rowRnd,
|
|
@@ -2918,6 +2918,18 @@ var EditRow = function EditRow(props) {
|
|
|
2918
2918
|
uploadBgMusic = props.uploadBgMusic;
|
|
2919
2919
|
var classNames = ['edit-row'];
|
|
2920
2920
|
if (rowData === null || rowData === void 0 ? void 0 : rowData.selected) classNames.push('selected');
|
|
2921
|
+
var clientWidth = document.documentElement.clientWidth;
|
|
2922
|
+
var timeStart = parserPixelToTime(scrollLeft, {
|
|
2923
|
+
startLeft: startLeft,
|
|
2924
|
+
scale: scale,
|
|
2925
|
+
scaleWidth: scaleWidth
|
|
2926
|
+
});
|
|
2927
|
+
var timeEnd = parserPixelToTime(scrollLeft + clientWidth + 200, {
|
|
2928
|
+
startLeft: startLeft,
|
|
2929
|
+
scale: scale,
|
|
2930
|
+
scaleWidth: scaleWidth
|
|
2931
|
+
});
|
|
2932
|
+
console.log('time = ', timeStart, ', timeEnd = ', timeEnd);
|
|
2921
2933
|
var handleTime = function handleTime(e) {
|
|
2922
2934
|
if (!areaRef.current) return;
|
|
2923
2935
|
var rect = areaRef.current.getBoundingClientRect();
|
|
@@ -2981,7 +2993,9 @@ var EditRow = function EditRow(props) {
|
|
|
2981
2993
|
});
|
|
2982
2994
|
}
|
|
2983
2995
|
}
|
|
2984
|
-
}, ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).
|
|
2996
|
+
}, ((rowData === null || rowData === void 0 ? void 0 : rowData.actions) || []).filter(function (action) {
|
|
2997
|
+
return action.end >= timeStart && action.start <= timeEnd;
|
|
2998
|
+
}).map(function (action) {
|
|
2985
2999
|
return /*#__PURE__*/React__default['default'].createElement(EditAction, _objectSpread2(_objectSpread2({
|
|
2986
3000
|
key: action.id
|
|
2987
3001
|
}, props), {}, {
|
|
@@ -3651,10 +3665,16 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3651
3665
|
}
|
|
3652
3666
|
return _context.a(2);
|
|
3653
3667
|
case 1:
|
|
3654
|
-
if (!(info.file.
|
|
3668
|
+
if (!(info.file.type !== 'audio/mp3' && info.file.type !== 'audio/wav' && info.file.type !== 'audio/mpeg')) {
|
|
3655
3669
|
_context.n = 2;
|
|
3656
3670
|
break;
|
|
3657
3671
|
}
|
|
3672
|
+
return _context.a(2, false);
|
|
3673
|
+
case 2:
|
|
3674
|
+
if (!(info.file.status === 'error')) {
|
|
3675
|
+
_context.n = 3;
|
|
3676
|
+
break;
|
|
3677
|
+
}
|
|
3658
3678
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [{
|
|
3659
3679
|
id: info.file.uid,
|
|
3660
3680
|
isUploading: false,
|
|
@@ -3666,9 +3686,9 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3666
3686
|
uid: info.file.uid
|
|
3667
3687
|
}]);
|
|
3668
3688
|
return _context.a(2);
|
|
3669
|
-
case
|
|
3689
|
+
case 3:
|
|
3670
3690
|
if (info.file.response) {
|
|
3671
|
-
_context.n =
|
|
3691
|
+
_context.n = 4;
|
|
3672
3692
|
break;
|
|
3673
3693
|
}
|
|
3674
3694
|
hasDefault = row.actions.some(function (action) {
|
|
@@ -3695,11 +3715,11 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3695
3715
|
};
|
|
3696
3716
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [_newAction]);
|
|
3697
3717
|
return _context.a(2);
|
|
3698
|
-
case
|
|
3718
|
+
case 4:
|
|
3699
3719
|
uid = info.file.uid;
|
|
3700
|
-
_context.n =
|
|
3720
|
+
_context.n = 5;
|
|
3701
3721
|
return getAudioDuration(info.file.response.url);
|
|
3702
|
-
case
|
|
3722
|
+
case 5:
|
|
3703
3723
|
duration = _context.v;
|
|
3704
3724
|
newAction = {
|
|
3705
3725
|
id: ((_info$file$response = info.file.response) === null || _info$file$response === void 0 ? void 0 : _info$file$response.id) || uid,
|
|
@@ -3714,7 +3734,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3714
3734
|
uid: (_info$file = info.file) === null || _info$file === void 0 ? void 0 : _info$file.uid
|
|
3715
3735
|
};
|
|
3716
3736
|
onUpdateEditorData === null || onUpdateEditorData === void 0 ? void 0 : onUpdateEditorData(row, [newAction]);
|
|
3717
|
-
case
|
|
3737
|
+
case 6:
|
|
3718
3738
|
return _context.a(2);
|
|
3719
3739
|
}
|
|
3720
3740
|
}, _callee);
|
|
@@ -3908,6 +3928,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3908
3928
|
backgroundPositionX: "0, ".concat(startLeft, "px"),
|
|
3909
3929
|
backgroundSize: "".concat(startLeft, "px, ").concat(scaleWidth, "px")
|
|
3910
3930
|
}),
|
|
3931
|
+
scrollLeft: scrollLeft,
|
|
3911
3932
|
areaRef: editAreaRef,
|
|
3912
3933
|
key: key,
|
|
3913
3934
|
rowHeight: (row === null || row === void 0 ? void 0 : row.rowHeight) || _rowHeight,
|
|
@@ -3991,7 +4012,8 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
3991
4012
|
}).length) > 0,
|
|
3992
4013
|
customRequest: customRequest,
|
|
3993
4014
|
onDrop: handleDrop,
|
|
3994
|
-
type: "drag"
|
|
4015
|
+
type: "drag",
|
|
4016
|
+
accept: "audio/mp3,audio/wav,audio/mpeg"
|
|
3995
4017
|
}, tChildren), tChildren ? null : editRow);
|
|
3996
4018
|
}
|
|
3997
4019
|
return editRow;
|
|
@@ -4049,6 +4071,7 @@ var EditAreaO = /*#__PURE__*/React__default['default'].forwardRef(function (prop
|
|
|
4049
4071
|
}
|
|
4050
4072
|
}
|
|
4051
4073
|
heightRef.current = height;
|
|
4074
|
+
console.log('Math.max(scaleCount * scaleWidth + startLeft, width)', Math.max(scaleCount * scaleWidth + startLeft, width), ', width', width);
|
|
4052
4075
|
return /*#__PURE__*/React__default['default'].createElement(reactVirtualized.Grid, {
|
|
4053
4076
|
columnCount: 1,
|
|
4054
4077
|
rowCount: heights.length,
|
|
@@ -4241,7 +4264,7 @@ var DragLines = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
4241
4264
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4242
4265
|
className: prefix('drag-line-container'),
|
|
4243
4266
|
style: {
|
|
4244
|
-
height: height
|
|
4267
|
+
height: height ? height + 30 : '100%'
|
|
4245
4268
|
}
|
|
4246
4269
|
}, isMoving && movePositions.map(function (movePos) {
|
|
4247
4270
|
// 查找在容差范围内的辅助线位置
|
|
@@ -4659,6 +4682,20 @@ var Timeline = /*#__PURE__*/React__default['default'].forwardRef(function (props
|
|
|
4659
4682
|
};
|
|
4660
4683
|
}
|
|
4661
4684
|
}, []);
|
|
4685
|
+
React.useEffect(function () {
|
|
4686
|
+
var containerEl = document.querySelector('.timeline-editor');
|
|
4687
|
+
var handleScroll = lodashEs.throttle(function (e) {
|
|
4688
|
+
console.log('scroll', e);
|
|
4689
|
+
scrollSync.current && scrollSync.current.setState({
|
|
4690
|
+
scrollLeft: e.target.scrollLeft || 0
|
|
4691
|
+
});
|
|
4692
|
+
}, 100);
|
|
4693
|
+
containerEl.addEventListener('scroll', handleScroll);
|
|
4694
|
+
return function () {
|
|
4695
|
+
containerEl.removeEventListener('scroll', handleScroll);
|
|
4696
|
+
handleScroll.cancel();
|
|
4697
|
+
};
|
|
4698
|
+
}, []);
|
|
4662
4699
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4663
4700
|
ref: domRef,
|
|
4664
4701
|
style: style,
|