wavesurfer.js 6.4.0 → 6.5.0
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 +106 -9
- 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 +76 -1
- 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.0 (2023-03-11)
|
|
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;
|
|
@@ -663,6 +676,41 @@ 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.innerText = 'x';
|
|
684
|
+
this.removeButtonEl = this.element.appendChild(removeButtonEl);
|
|
685
|
+
var css = {
|
|
686
|
+
zIndex: 4,
|
|
687
|
+
position: 'absolute',
|
|
688
|
+
bottom: 0,
|
|
689
|
+
right: 0,
|
|
690
|
+
cursor: 'pointer',
|
|
691
|
+
marginRight: '3px',
|
|
692
|
+
fontSize: '80%',
|
|
693
|
+
color: 'grey',
|
|
694
|
+
height: '14px'
|
|
695
|
+
};
|
|
696
|
+
this.style(this.removeButtonEl, css);
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/* Edit content */
|
|
700
|
+
if (this.contentEditable) {
|
|
701
|
+
var contentEl = document.createElement('div');
|
|
702
|
+
contentEl.className = 'region-content';
|
|
703
|
+
contentEl.contentEditable = true;
|
|
704
|
+
contentEl.innerText = this.data.text || '';
|
|
705
|
+
this.contentEl = this.element.appendChild(contentEl);
|
|
706
|
+
var _css = {
|
|
707
|
+
zIndex: 4,
|
|
708
|
+
padding: '2px 5px',
|
|
709
|
+
cursor: 'text'
|
|
710
|
+
};
|
|
711
|
+
this.style(this.contentEl, _css);
|
|
712
|
+
}
|
|
713
|
+
|
|
666
714
|
/* Resize handles */
|
|
667
715
|
if (this.resize) {
|
|
668
716
|
this.handleLeftEl = this.util.withOrientation(this.element.appendChild(document.createElement('handle')), this.vertical);
|
|
@@ -671,7 +719,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
671
719
|
this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end';
|
|
672
720
|
|
|
673
721
|
// Default CSS properties for both handles.
|
|
674
|
-
var
|
|
722
|
+
var _css2 = {
|
|
675
723
|
cursor: this.vertical ? 'row-resize' : 'col-resize',
|
|
676
724
|
position: 'absolute',
|
|
677
725
|
top: '0px',
|
|
@@ -683,10 +731,10 @@ var Region = /*#__PURE__*/function () {
|
|
|
683
731
|
// Merge CSS properties per handle.
|
|
684
732
|
var handleLeftCss = this.handleStyle.left !== 'none' ? Object.assign({
|
|
685
733
|
left: '0px'
|
|
686
|
-
},
|
|
734
|
+
}, _css2, this.handleStyle.left) : null;
|
|
687
735
|
var handleRightCss = this.handleStyle.right !== 'none' ? Object.assign({
|
|
688
736
|
right: '0px'
|
|
689
|
-
},
|
|
737
|
+
}, _css2, this.handleStyle.right) : null;
|
|
690
738
|
if (handleLeftCss) {
|
|
691
739
|
this.style(this.handleLeftEl, handleLeftCss);
|
|
692
740
|
}
|
|
@@ -836,6 +884,21 @@ var Region = /*#__PURE__*/function () {
|
|
|
836
884
|
if (this.drag || this.resize) {
|
|
837
885
|
this.bindDragEvents();
|
|
838
886
|
}
|
|
887
|
+
|
|
888
|
+
/* Edit content */
|
|
889
|
+
if (this.contentEditable) {
|
|
890
|
+
this.contentEl.addEventListener('blur', this.onContentBlur.bind(this));
|
|
891
|
+
this.contentEl.addEventListener('click', this.onContentClick.bind(this));
|
|
892
|
+
}
|
|
893
|
+
/* Remove button */
|
|
894
|
+
if (this.removeButton) {
|
|
895
|
+
this.removeButtonEl.addEventListener('click', this.onRemove.bind(this));
|
|
896
|
+
}
|
|
897
|
+
this.on('remove', function () {
|
|
898
|
+
_this3.contentEl.removeEventListener('blur', _this3.onContentBlur.bind(_this3));
|
|
899
|
+
_this3.contentEl.removeEventListener('click', _this3.onContentClick.bind(_this3));
|
|
900
|
+
_this3.removeButtonEl.removeEventListener('click', _this3.onRemove.bind(_this3));
|
|
901
|
+
});
|
|
839
902
|
}
|
|
840
903
|
}, {
|
|
841
904
|
key: "bindDragEvents",
|
|
@@ -996,6 +1059,7 @@ var Region = /*#__PURE__*/function () {
|
|
|
996
1059
|
var onMove = function onMove(event) {
|
|
997
1060
|
var duration = _this4.wavesurfer.getDuration();
|
|
998
1061
|
var orientedEvent = _this4.util.withOrientation(event, _this4.vertical);
|
|
1062
|
+
var delta = null;
|
|
999
1063
|
if (event.touches && event.touches.length > 1) {
|
|
1000
1064
|
return;
|
|
1001
1065
|
}
|
|
@@ -1033,14 +1097,18 @@ var Region = /*#__PURE__*/function () {
|
|
|
1033
1097
|
}
|
|
1034
1098
|
} else if (resize === 'end') {
|
|
1035
1099
|
if (time < _this4.start + minLength) {
|
|
1100
|
+
// Calculate the end time based on the min length of the region.
|
|
1036
1101
|
time = _this4.start + minLength;
|
|
1102
|
+
delta = time - (_this4.end + (time - startTime));
|
|
1037
1103
|
}
|
|
1038
1104
|
if (time > duration) {
|
|
1039
1105
|
time = duration;
|
|
1040
1106
|
}
|
|
1041
1107
|
}
|
|
1042
1108
|
}
|
|
1043
|
-
|
|
1109
|
+
if (!delta) {
|
|
1110
|
+
delta = time - startTime;
|
|
1111
|
+
}
|
|
1044
1112
|
startTime = time;
|
|
1045
1113
|
|
|
1046
1114
|
// Drag
|
|
@@ -1182,6 +1250,35 @@ var Region = /*#__PURE__*/function () {
|
|
|
1182
1250
|
}, eventParams);
|
|
1183
1251
|
}
|
|
1184
1252
|
}
|
|
1253
|
+
}, {
|
|
1254
|
+
key: "onContentBlur",
|
|
1255
|
+
value: function onContentBlur(event) {
|
|
1256
|
+
var _ref = this.data || {},
|
|
1257
|
+
oldText = _ref.text;
|
|
1258
|
+
var text = event.target.innerText;
|
|
1259
|
+
var data = _objectSpread(_objectSpread({}, this.data), {}, {
|
|
1260
|
+
text: text
|
|
1261
|
+
});
|
|
1262
|
+
var eventParams = {
|
|
1263
|
+
action: 'contentEdited',
|
|
1264
|
+
oldText: oldText,
|
|
1265
|
+
text: text
|
|
1266
|
+
};
|
|
1267
|
+
this.update({
|
|
1268
|
+
data: data
|
|
1269
|
+
}, eventParams);
|
|
1270
|
+
}
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "onContentClick",
|
|
1273
|
+
value: function onContentClick(event) {
|
|
1274
|
+
event.stopPropagation();
|
|
1275
|
+
}
|
|
1276
|
+
}, {
|
|
1277
|
+
key: "onRemove",
|
|
1278
|
+
value: function onRemove(event) {
|
|
1279
|
+
event.stopPropagation();
|
|
1280
|
+
this.remove();
|
|
1281
|
+
}
|
|
1185
1282
|
}, {
|
|
1186
1283
|
key: "updateHandlesResize",
|
|
1187
1284
|
value: function updateHandlesResize(resize) {
|