wavesurfer.js 6.4.0 → 6.5.1
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/LICENSE +1 -1
- package/README.md +36 -48
- package/dist/plugin/wavesurfer.cursor.js +19 -8
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +6 -3
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +6 -3
- package/dist/plugin/wavesurfer.markers.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.min.js +2 -2
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.js +4 -2
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +5 -2
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +5 -2
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +5 -2
- package/dist/plugin/wavesurfer.playhead.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.min.js +2 -2
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.js +101 -11
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +5 -2
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +13 -5
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +4 -2
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +77 -27
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +8 -8
- package/src/mediaelement.js +3 -0
- package/src/plugin/cursor/index.js +1 -1
- package/src/plugin/markers/index.js +1 -1
- package/src/plugin/regions/index.js +4 -0
- package/src/plugin/regions/region.js +70 -3
- package/src/util/silence-mode.js +7 -0
- package/src/wavesurfer.js +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js regions plugin 6.
|
|
2
|
+
* wavesurfer.js regions plugin 6.5.1 (2023-03-12)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -30,12 +30,15 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
30
30
|
}));
|
|
31
31
|
exports["default"] = void 0;
|
|
32
32
|
var _region = __webpack_require__(/*! ./region.js */ "./src/plugin/regions/region.js");
|
|
33
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
33
34
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
35
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
37
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
38
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
38
39
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
40
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
41
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
39
42
|
/**
|
|
40
43
|
* Regions are visual overlays on waveform that can be used to play and loop
|
|
41
44
|
* portions of audio. Regions can be dragged and resized.
|
|
@@ -165,7 +168,9 @@ var RegionsPlugin = /*#__PURE__*/function () {
|
|
|
165
168
|
return null;
|
|
166
169
|
}
|
|
167
170
|
params = _objectSpread({
|
|
168
|
-
edgeScrollWidth: this.params.edgeScrollWidth || this.defaultEdgeScrollWidth
|
|
171
|
+
edgeScrollWidth: this.params.edgeScrollWidth || this.defaultEdgeScrollWidth,
|
|
172
|
+
contentEditable: this.params.contentEditable,
|
|
173
|
+
removeButton: this.params.removeButton
|
|
169
174
|
}, params);
|
|
170
175
|
|
|
171
176
|
// Take formatTimeCallback from plugin params if not already set
|
|
@@ -472,9 +477,15 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
472
477
|
value: true
|
|
473
478
|
}));
|
|
474
479
|
exports.Region = void 0;
|
|
480
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
481
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
482
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
483
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
475
484
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
476
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
485
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
477
486
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
487
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
488
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
478
489
|
/**
|
|
479
490
|
* @since 4.0.0
|
|
480
491
|
*
|
|
@@ -503,6 +514,8 @@ var Region = /*#__PURE__*/function () {
|
|
|
503
514
|
this.start + 4 / this.wrapper.scrollWidth * this.wavesurfer.getDuration() : Number(params.end);
|
|
504
515
|
this.resize = params.resize === undefined ? true : Boolean(params.resize);
|
|
505
516
|
this.drag = params.drag === undefined ? true : Boolean(params.drag);
|
|
517
|
+
this.contentEditable = Boolean(params.contentEditable);
|
|
518
|
+
this.removeButton = Boolean(params.removeButton);
|
|
506
519
|
// reflect resize and drag state of region for region-updated listener
|
|
507
520
|
this.isResizing = false;
|
|
508
521
|
this.isDragging = false;
|
|
@@ -600,7 +613,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
600
613
|
key: "remove",
|
|
601
614
|
value: function remove() {
|
|
602
615
|
if (this.element) {
|
|
603
|
-
this.
|
|
616
|
+
this.element.remove();
|
|
604
617
|
this.element = null;
|
|
605
618
|
this.fireEvent('remove');
|
|
606
619
|
this.wavesurfer.un('zoom', this._onRedraw);
|
|
@@ -663,6 +676,40 @@ var Region = /*#__PURE__*/function () {
|
|
|
663
676
|
top: this.marginTop
|
|
664
677
|
});
|
|
665
678
|
|
|
679
|
+
/* Button Remove Region */
|
|
680
|
+
if (this.removeButton) {
|
|
681
|
+
var removeButtonEl = document.createElement('div');
|
|
682
|
+
removeButtonEl.className = 'remove-region-button';
|
|
683
|
+
removeButtonEl.textContent = '⨯';
|
|
684
|
+
this.removeButtonEl = this.element.appendChild(removeButtonEl);
|
|
685
|
+
var css = {
|
|
686
|
+
zIndex: 4,
|
|
687
|
+
position: 'absolute',
|
|
688
|
+
bottom: 0,
|
|
689
|
+
right: '4px',
|
|
690
|
+
cursor: 'pointer',
|
|
691
|
+
fontSize: '20px',
|
|
692
|
+
lineHeight: '21px',
|
|
693
|
+
color: 'grey'
|
|
694
|
+
};
|
|
695
|
+
this.style(this.removeButtonEl, css);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/* Edit content */
|
|
699
|
+
if (this.contentEditable) {
|
|
700
|
+
var contentEl = document.createElement('div');
|
|
701
|
+
contentEl.className = 'region-content';
|
|
702
|
+
contentEl.contentEditable = 'true';
|
|
703
|
+
contentEl.innerText = this.data.text || '';
|
|
704
|
+
this.contentEl = this.element.appendChild(contentEl);
|
|
705
|
+
var _css = {
|
|
706
|
+
zIndex: 4,
|
|
707
|
+
padding: '2px 5px',
|
|
708
|
+
cursor: 'text'
|
|
709
|
+
};
|
|
710
|
+
this.style(this.contentEl, _css);
|
|
711
|
+
}
|
|
712
|
+
|
|
666
713
|
/* Resize handles */
|
|
667
714
|
if (this.resize) {
|
|
668
715
|
this.handleLeftEl = this.util.withOrientation(this.element.appendChild(document.createElement('handle')), this.vertical);
|
|
@@ -671,7 +718,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
671
718
|
this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end';
|
|
672
719
|
|
|
673
720
|
// Default CSS properties for both handles.
|
|
674
|
-
var
|
|
721
|
+
var _css2 = {
|
|
675
722
|
cursor: this.vertical ? 'row-resize' : 'col-resize',
|
|
676
723
|
position: 'absolute',
|
|
677
724
|
top: '0px',
|
|
@@ -683,10 +730,10 @@ var Region = /*#__PURE__*/function () {
|
|
|
683
730
|
// Merge CSS properties per handle.
|
|
684
731
|
var handleLeftCss = this.handleStyle.left !== 'none' ? Object.assign({
|
|
685
732
|
left: '0px'
|
|
686
|
-
},
|
|
733
|
+
}, _css2, this.handleStyle.left) : null;
|
|
687
734
|
var handleRightCss = this.handleStyle.right !== 'none' ? Object.assign({
|
|
688
735
|
right: '0px'
|
|
689
|
-
},
|
|
736
|
+
}, _css2, this.handleStyle.right) : null;
|
|
690
737
|
if (handleLeftCss) {
|
|
691
738
|
this.style(this.handleLeftEl, handleLeftCss);
|
|
692
739
|
}
|
|
@@ -836,6 +883,16 @@ var Region = /*#__PURE__*/function () {
|
|
|
836
883
|
if (this.drag || this.resize) {
|
|
837
884
|
this.bindDragEvents();
|
|
838
885
|
}
|
|
886
|
+
|
|
887
|
+
/* Edit content */
|
|
888
|
+
if (this.contentEditable) {
|
|
889
|
+
this.contentEl.addEventListener('blur', this.onContentBlur.bind(this));
|
|
890
|
+
this.contentEl.addEventListener('click', this.onContentClick.bind(this));
|
|
891
|
+
}
|
|
892
|
+
/* Remove button */
|
|
893
|
+
if (this.removeButton) {
|
|
894
|
+
this.removeButtonEl.addEventListener('click', this.onRemove.bind(this));
|
|
895
|
+
}
|
|
839
896
|
}
|
|
840
897
|
}, {
|
|
841
898
|
key: "bindDragEvents",
|
|
@@ -843,7 +900,6 @@ var Region = /*#__PURE__*/function () {
|
|
|
843
900
|
var _this4 = this;
|
|
844
901
|
var container = this.wavesurfer.drawer.container;
|
|
845
902
|
var scrollSpeed = this.scrollSpeed;
|
|
846
|
-
var scrollThreshold = this.scrollThreshold;
|
|
847
903
|
var startTime;
|
|
848
904
|
var touchId;
|
|
849
905
|
var drag;
|
|
@@ -996,6 +1052,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
996
1052
|
var onMove = function onMove(event) {
|
|
997
1053
|
var duration = _this4.wavesurfer.getDuration();
|
|
998
1054
|
var orientedEvent = _this4.util.withOrientation(event, _this4.vertical);
|
|
1055
|
+
var delta = null;
|
|
999
1056
|
if (event.touches && event.touches.length > 1) {
|
|
1000
1057
|
return;
|
|
1001
1058
|
}
|
|
@@ -1033,14 +1090,18 @@ var Region = /*#__PURE__*/function () {
|
|
|
1033
1090
|
}
|
|
1034
1091
|
} else if (resize === 'end') {
|
|
1035
1092
|
if (time < _this4.start + minLength) {
|
|
1093
|
+
// Calculate the end time based on the min length of the region.
|
|
1036
1094
|
time = _this4.start + minLength;
|
|
1095
|
+
delta = time - (_this4.end + (time - startTime));
|
|
1037
1096
|
}
|
|
1038
1097
|
if (time > duration) {
|
|
1039
1098
|
time = duration;
|
|
1040
1099
|
}
|
|
1041
1100
|
}
|
|
1042
1101
|
}
|
|
1043
|
-
|
|
1102
|
+
if (!delta) {
|
|
1103
|
+
delta = time - startTime;
|
|
1104
|
+
}
|
|
1044
1105
|
startTime = time;
|
|
1045
1106
|
|
|
1046
1107
|
// Drag
|
|
@@ -1182,6 +1243,35 @@ var Region = /*#__PURE__*/function () {
|
|
|
1182
1243
|
}, eventParams);
|
|
1183
1244
|
}
|
|
1184
1245
|
}
|
|
1246
|
+
}, {
|
|
1247
|
+
key: "onContentBlur",
|
|
1248
|
+
value: function onContentBlur(event) {
|
|
1249
|
+
var _ref = this.data || {},
|
|
1250
|
+
oldText = _ref.text;
|
|
1251
|
+
var text = event.target.innerText;
|
|
1252
|
+
var data = _objectSpread(_objectSpread({}, this.data), {}, {
|
|
1253
|
+
text: text
|
|
1254
|
+
});
|
|
1255
|
+
var eventParams = {
|
|
1256
|
+
action: 'contentEdited',
|
|
1257
|
+
oldText: oldText,
|
|
1258
|
+
text: text
|
|
1259
|
+
};
|
|
1260
|
+
this.update({
|
|
1261
|
+
data: data
|
|
1262
|
+
}, eventParams);
|
|
1263
|
+
}
|
|
1264
|
+
}, {
|
|
1265
|
+
key: "onContentClick",
|
|
1266
|
+
value: function onContentClick(event) {
|
|
1267
|
+
event.stopPropagation();
|
|
1268
|
+
}
|
|
1269
|
+
}, {
|
|
1270
|
+
key: "onRemove",
|
|
1271
|
+
value: function onRemove(event) {
|
|
1272
|
+
event.stopPropagation();
|
|
1273
|
+
this.remove();
|
|
1274
|
+
}
|
|
1185
1275
|
}, {
|
|
1186
1276
|
key: "updateHandlesResize",
|
|
1187
1277
|
value: function updateHandlesResize(resize) {
|