wavesurfer.js 6.3.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 -47
- package/dist/plugin/wavesurfer.cursor.js +45 -54
- 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 +24 -51
- 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 +62 -74
- 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 +8 -16
- 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 +48 -63
- 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 +20 -69
- 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 +6 -30
- 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 +203 -260
- 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 +55 -147
- 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 +53 -88
- 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 +34 -54
- 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 +490 -1003
- 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 +11 -11
- package/src/mediaelement.js +3 -0
- package/src/plugin/cursor/index.js +15 -3
- package/src/plugin/markers/index.js +40 -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
- package/CHANGES.md +0 -482
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js markers plugin 6.
|
|
2
|
+
* wavesurfer.js markers plugin 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -29,19 +29,19 @@ Object.defineProperty(exports, "__esModule", ({
|
|
|
29
29
|
value: true
|
|
30
30
|
}));
|
|
31
31
|
exports["default"] = void 0;
|
|
32
|
-
|
|
32
|
+
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
33
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
34
|
-
|
|
35
|
-
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); } }
|
|
36
|
-
|
|
34
|
+
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); } }
|
|
37
35
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
38
|
-
|
|
36
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
37
|
+
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
38
|
/**
|
|
40
39
|
* @typedef {Object} MarkerParams
|
|
41
40
|
* @desc The parameters used to describe a marker.
|
|
42
41
|
* @example wavesurfer.addMarker(regionParams);
|
|
43
42
|
* @property {number} time The time to set the marker at
|
|
44
43
|
* @property {?label} string An optional marker label
|
|
44
|
+
* @property {?tooltip} string An optional marker tooltip
|
|
45
45
|
* @property {?color} string Background color for marker
|
|
46
46
|
* @property {?position} string "top" or "bottom", defaults to "bottom"
|
|
47
47
|
* @property {?markerElement} element An HTML element to display instead of the default marker image
|
|
@@ -71,15 +71,13 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
71
71
|
* ]
|
|
72
72
|
* });
|
|
73
73
|
*/
|
|
74
|
+
|
|
74
75
|
var DEFAULT_FILL_COLOR = "#D8D8D8";
|
|
75
76
|
var DEFAULT_POSITION = "bottom";
|
|
76
|
-
|
|
77
77
|
var MarkersPlugin = /*#__PURE__*/function () {
|
|
78
78
|
function MarkersPlugin(params, ws) {
|
|
79
79
|
var _this = this;
|
|
80
|
-
|
|
81
80
|
_classCallCheck(this, MarkersPlugin);
|
|
82
|
-
|
|
83
81
|
this.params = params;
|
|
84
82
|
this.wavesurfer = ws;
|
|
85
83
|
this.util = ws.util;
|
|
@@ -88,60 +86,45 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
88
86
|
this.markerWidth = 11;
|
|
89
87
|
this.markerHeight = 22;
|
|
90
88
|
this.dragging = false;
|
|
91
|
-
|
|
92
89
|
this._onResize = function () {
|
|
93
90
|
_this._updateMarkerPositions();
|
|
94
91
|
};
|
|
95
|
-
|
|
96
92
|
this._onBackendCreated = function () {
|
|
97
93
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
98
|
-
|
|
99
94
|
if (_this.params.markers) {
|
|
100
95
|
_this.params.markers.forEach(function (marker) {
|
|
101
96
|
return _this.add(marker);
|
|
102
97
|
});
|
|
103
98
|
}
|
|
104
|
-
|
|
105
99
|
window.addEventListener('resize', _this._onResize, true);
|
|
106
100
|
window.addEventListener('orientationchange', _this._onResize, true);
|
|
107
|
-
|
|
108
101
|
_this.wavesurfer.on('zoom', _this._onResize);
|
|
109
|
-
|
|
110
102
|
if (!_this.markers.find(function (marker) {
|
|
111
103
|
return marker.draggable;
|
|
112
104
|
})) {
|
|
113
105
|
return;
|
|
114
106
|
}
|
|
115
|
-
|
|
116
107
|
_this.onMouseMove = function (e) {
|
|
117
108
|
return _this._onMouseMove(e);
|
|
118
109
|
};
|
|
119
|
-
|
|
120
110
|
window.addEventListener('mousemove', _this.onMouseMove);
|
|
121
|
-
|
|
122
111
|
_this.onMouseUp = function (e) {
|
|
123
112
|
return _this._onMouseUp(e);
|
|
124
113
|
};
|
|
125
|
-
|
|
126
114
|
window.addEventListener("mouseup", _this.onMouseUp);
|
|
127
115
|
};
|
|
128
|
-
|
|
129
116
|
this.markers = [];
|
|
130
|
-
|
|
131
117
|
this._onReady = function () {
|
|
132
118
|
_this.wrapper = _this.wavesurfer.drawer.wrapper;
|
|
133
|
-
|
|
134
119
|
_this._updateMarkerPositions();
|
|
135
120
|
};
|
|
136
121
|
}
|
|
137
|
-
|
|
138
122
|
_createClass(MarkersPlugin, [{
|
|
139
123
|
key: "init",
|
|
140
124
|
value: function init() {
|
|
141
125
|
// Check if ws is ready
|
|
142
126
|
if (this.wavesurfer.isReady) {
|
|
143
127
|
this._onBackendCreated();
|
|
144
|
-
|
|
145
128
|
this._onReady();
|
|
146
129
|
} else {
|
|
147
130
|
this.wavesurfer.once('ready', this._onReady);
|
|
@@ -156,30 +139,28 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
156
139
|
this.wavesurfer.un('zoom', this._onResize);
|
|
157
140
|
window.removeEventListener('resize', this._onResize, true);
|
|
158
141
|
window.removeEventListener('orientationchange', this._onResize, true);
|
|
159
|
-
|
|
160
142
|
if (this.onMouseMove) {
|
|
161
143
|
window.removeEventListener('mousemove', this.onMouseMove);
|
|
162
144
|
}
|
|
163
|
-
|
|
164
145
|
if (this.onMouseUp) {
|
|
165
146
|
window.removeEventListener("mouseup", this.onMouseUp);
|
|
166
147
|
}
|
|
167
|
-
|
|
168
148
|
this.clear();
|
|
169
149
|
}
|
|
150
|
+
|
|
170
151
|
/**
|
|
171
152
|
* Add a marker
|
|
172
153
|
*
|
|
173
154
|
* @param {MarkerParams} params Marker definition
|
|
174
155
|
* @return {object} The created marker
|
|
175
156
|
*/
|
|
176
|
-
|
|
177
157
|
}, {
|
|
178
158
|
key: "add",
|
|
179
159
|
value: function add(params) {
|
|
180
160
|
var marker = {
|
|
181
161
|
time: params.time,
|
|
182
162
|
label: params.label,
|
|
163
|
+
tooltip: params.tooltip,
|
|
183
164
|
color: params.color || DEFAULT_FILL_COLOR,
|
|
184
165
|
position: params.position || DEFAULT_POSITION,
|
|
185
166
|
draggable: !!params.draggable,
|
|
@@ -188,44 +169,38 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
188
169
|
marker.el = this._createMarkerElement(marker, params.markerElement);
|
|
189
170
|
this.wrapper.appendChild(marker.el);
|
|
190
171
|
this.markers.push(marker);
|
|
191
|
-
|
|
192
172
|
this._updateMarkerPositions();
|
|
193
|
-
|
|
173
|
+
this._registerEvents();
|
|
194
174
|
return marker;
|
|
195
175
|
}
|
|
176
|
+
|
|
196
177
|
/**
|
|
197
178
|
* Remove a marker
|
|
198
179
|
*
|
|
199
180
|
* @param {number} index Index of the marker to remove
|
|
200
181
|
*/
|
|
201
|
-
|
|
202
182
|
}, {
|
|
203
183
|
key: "remove",
|
|
204
184
|
value: function remove(index) {
|
|
205
185
|
var marker = this.markers[index];
|
|
206
|
-
|
|
207
186
|
if (!marker) {
|
|
208
187
|
return;
|
|
209
188
|
}
|
|
210
|
-
|
|
211
189
|
var label = marker.el.getElementsByClassName("marker-label")[0];
|
|
212
|
-
|
|
213
190
|
if (label) {
|
|
214
191
|
if (label._onContextMenu) {
|
|
215
192
|
label.removeEventListener("contextmenu", label._onContextMenu);
|
|
216
193
|
}
|
|
217
|
-
|
|
218
194
|
if (label._onClick) {
|
|
219
195
|
label.removeEventListener("click", label._onClick);
|
|
220
196
|
}
|
|
221
|
-
|
|
222
197
|
if (label._onMouseDown) {
|
|
223
198
|
label.removeEventListener("mousedown", label._onMouseDown);
|
|
224
199
|
}
|
|
225
200
|
}
|
|
226
|
-
|
|
227
201
|
this.wrapper.removeChild(marker.el);
|
|
228
202
|
this.markers.splice(index, 1);
|
|
203
|
+
this._unregisterEvents();
|
|
229
204
|
}
|
|
230
205
|
}, {
|
|
231
206
|
key: "_createPointerSVG",
|
|
@@ -238,11 +213,9 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
238
213
|
polygon.setAttribute("stroke", "#979797");
|
|
239
214
|
polygon.setAttribute("fill", color);
|
|
240
215
|
polygon.setAttribute("points", "20 0 40 30 40 80 0 80 0 30");
|
|
241
|
-
|
|
242
216
|
if (position == "top") {
|
|
243
217
|
polygon.setAttribute("transform", "rotate(180, 20 40)");
|
|
244
218
|
}
|
|
245
|
-
|
|
246
219
|
el.appendChild(polygon);
|
|
247
220
|
this.style(el, {
|
|
248
221
|
width: this.markerWidth + "px",
|
|
@@ -257,8 +230,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
257
230
|
key: "_createMarkerElement",
|
|
258
231
|
value: function _createMarkerElement(marker, markerElement) {
|
|
259
232
|
var _this2 = this;
|
|
260
|
-
|
|
261
233
|
var label = marker.label;
|
|
234
|
+
var tooltip = marker.tooltip;
|
|
262
235
|
var el = document.createElement('marker');
|
|
263
236
|
el.className = "wavesurfer-marker";
|
|
264
237
|
this.style(el, {
|
|
@@ -280,25 +253,21 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
280
253
|
});
|
|
281
254
|
el.appendChild(line);
|
|
282
255
|
var labelDiv = document.createElement('div');
|
|
283
|
-
|
|
284
256
|
var point = markerElement || this._createPointerSVG(marker.color, marker.position);
|
|
285
|
-
|
|
286
257
|
if (marker.draggable) {
|
|
287
258
|
point.draggable = false;
|
|
288
259
|
}
|
|
289
|
-
|
|
290
260
|
labelDiv.appendChild(point);
|
|
291
|
-
|
|
292
261
|
if (label) {
|
|
293
262
|
var labelEl = document.createElement('span');
|
|
294
263
|
labelEl.innerText = label;
|
|
264
|
+
labelEl.setAttribute('title', tooltip);
|
|
295
265
|
this.style(labelEl, {
|
|
296
|
-
"font-family": "
|
|
266
|
+
"font-family": "inherit",
|
|
297
267
|
"font-size": "90%"
|
|
298
268
|
});
|
|
299
269
|
labelDiv.appendChild(labelEl);
|
|
300
270
|
}
|
|
301
|
-
|
|
302
271
|
this.style(labelDiv, {
|
|
303
272
|
display: "flex",
|
|
304
273
|
"align-items": "center",
|
|
@@ -306,41 +275,31 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
306
275
|
});
|
|
307
276
|
labelDiv.classList.add("marker-label");
|
|
308
277
|
el.appendChild(labelDiv);
|
|
309
|
-
|
|
310
278
|
labelDiv._onClick = function (e) {
|
|
311
|
-
e.stopPropagation();
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
// Click event is caught when the marker-drop event was dispatched.
|
|
312
281
|
// Drop event was dispatched at this moment, but this.dragging
|
|
313
282
|
// is waiting for the next tick to set as false
|
|
314
|
-
|
|
315
283
|
if (_this2.dragging) {
|
|
316
284
|
return;
|
|
317
285
|
}
|
|
318
|
-
|
|
319
286
|
_this2.wavesurfer.setCurrentTime(marker.time);
|
|
320
|
-
|
|
321
287
|
_this2.wavesurfer.fireEvent("marker-click", marker, e);
|
|
322
288
|
};
|
|
323
|
-
|
|
324
289
|
labelDiv.addEventListener("click", labelDiv._onClick);
|
|
325
|
-
|
|
326
290
|
labelDiv._onContextMenu = function (e) {
|
|
327
291
|
if (marker.preventContextMenu) {
|
|
328
292
|
e.preventDefault();
|
|
329
293
|
}
|
|
330
|
-
|
|
331
294
|
_this2.wavesurfer.fireEvent("marker-contextmenu", marker, e);
|
|
332
295
|
};
|
|
333
|
-
|
|
334
296
|
labelDiv.addEventListener("contextmenu", labelDiv._onContextMenu);
|
|
335
|
-
|
|
336
297
|
if (marker.draggable) {
|
|
337
298
|
labelDiv._onMouseDown = function () {
|
|
338
299
|
_this2.selectedMarker = marker;
|
|
339
300
|
};
|
|
340
|
-
|
|
341
301
|
labelDiv.addEventListener("mousedown", labelDiv._onMouseDown);
|
|
342
302
|
}
|
|
343
|
-
|
|
344
303
|
return el;
|
|
345
304
|
}
|
|
346
305
|
}, {
|
|
@@ -348,10 +307,10 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
348
307
|
value: function _updateMarkerPositions() {
|
|
349
308
|
for (var i = 0; i < this.markers.length; i++) {
|
|
350
309
|
var marker = this.markers[i];
|
|
351
|
-
|
|
352
310
|
this._updateMarkerPosition(marker);
|
|
353
311
|
}
|
|
354
312
|
}
|
|
313
|
+
|
|
355
314
|
/**
|
|
356
315
|
* Update a marker position based on its time property.
|
|
357
316
|
*
|
|
@@ -359,7 +318,6 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
359
318
|
* @param {MarkerParams} params The marker to update.
|
|
360
319
|
* @returns {void}
|
|
361
320
|
*/
|
|
362
|
-
|
|
363
321
|
}, {
|
|
364
322
|
key: "_updateMarkerPosition",
|
|
365
323
|
value: function _updateMarkerPosition(params) {
|
|
@@ -372,6 +330,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
372
330
|
"max-width": elementWidth - leftPx + "px"
|
|
373
331
|
});
|
|
374
332
|
}
|
|
333
|
+
|
|
375
334
|
/**
|
|
376
335
|
* Fires `marker-drag` event, update the `time` property for the
|
|
377
336
|
* selected marker based on the mouse position, and calls to update
|
|
@@ -381,23 +340,20 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
381
340
|
* @param {MouseEvent} event The mouse event.
|
|
382
341
|
* @returns {void}
|
|
383
342
|
*/
|
|
384
|
-
|
|
385
343
|
}, {
|
|
386
344
|
key: "_onMouseMove",
|
|
387
345
|
value: function _onMouseMove(event) {
|
|
388
346
|
if (!this.selectedMarker) {
|
|
389
347
|
return;
|
|
390
348
|
}
|
|
391
|
-
|
|
392
349
|
if (!this.dragging) {
|
|
393
350
|
this.dragging = true;
|
|
394
351
|
this.wavesurfer.fireEvent("marker-drag", this.selectedMarker, event);
|
|
395
352
|
}
|
|
396
|
-
|
|
397
353
|
this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();
|
|
398
|
-
|
|
399
354
|
this._updateMarkerPositions();
|
|
400
355
|
}
|
|
356
|
+
|
|
401
357
|
/**
|
|
402
358
|
* Fires `marker-drop` event and unselect the dragged marker.
|
|
403
359
|
*
|
|
@@ -405,35 +361,70 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
405
361
|
* @param {MouseEvent} event The mouse event.
|
|
406
362
|
* @returns {void}
|
|
407
363
|
*/
|
|
408
|
-
|
|
409
364
|
}, {
|
|
410
365
|
key: "_onMouseUp",
|
|
411
366
|
value: function _onMouseUp(event) {
|
|
412
367
|
var _this3 = this;
|
|
413
|
-
|
|
414
368
|
if (this.selectedMarker) {
|
|
415
369
|
setTimeout(function () {
|
|
416
370
|
_this3.selectedMarker = false;
|
|
417
371
|
_this3.dragging = false;
|
|
418
372
|
}, 0);
|
|
419
373
|
}
|
|
420
|
-
|
|
421
374
|
if (!this.dragging) {
|
|
422
375
|
return;
|
|
423
376
|
}
|
|
424
|
-
|
|
425
377
|
event.stopPropagation();
|
|
426
378
|
var duration = this.wavesurfer.getDuration();
|
|
427
379
|
this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;
|
|
428
|
-
|
|
429
380
|
this._updateMarkerPositions();
|
|
430
|
-
|
|
431
381
|
this.wavesurfer.fireEvent("marker-drop", this.selectedMarker, event);
|
|
432
382
|
}
|
|
383
|
+
}, {
|
|
384
|
+
key: "_registerEvents",
|
|
385
|
+
value: function _registerEvents() {
|
|
386
|
+
var _this4 = this;
|
|
387
|
+
if (!this.markers.find(function (marker) {
|
|
388
|
+
return marker.draggable;
|
|
389
|
+
})) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
//we have some draggable markers, check for listeners
|
|
393
|
+
if (!this.onMouseMove) {
|
|
394
|
+
this.onMouseMove = function (e) {
|
|
395
|
+
return _this4._onMouseMove(e);
|
|
396
|
+
};
|
|
397
|
+
window.addEventListener('mousemove', this.onMouseMove);
|
|
398
|
+
}
|
|
399
|
+
if (!this.onMouseUp) {
|
|
400
|
+
this.onMouseUp = function (e) {
|
|
401
|
+
return _this4._onMouseUp(e);
|
|
402
|
+
};
|
|
403
|
+
window.addEventListener("mouseup", this.onMouseUp);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}, {
|
|
407
|
+
key: "_unregisterEvents",
|
|
408
|
+
value: function _unregisterEvents() {
|
|
409
|
+
if (this.markers.find(function (marker) {
|
|
410
|
+
return marker.draggable;
|
|
411
|
+
})) {
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
//we don't have any draggable markers, unregister listeners
|
|
415
|
+
if (this.onMouseMove) {
|
|
416
|
+
window.removeEventListener('mousemove', this.onMouseMove);
|
|
417
|
+
this.onMouseMove = null;
|
|
418
|
+
}
|
|
419
|
+
if (this.onMouseUp) {
|
|
420
|
+
window.removeEventListener("mouseup", this.onMouseUp);
|
|
421
|
+
this.onMouseUp = null;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
433
425
|
/**
|
|
434
426
|
* Remove all markers
|
|
435
427
|
*/
|
|
436
|
-
|
|
437
428
|
}, {
|
|
438
429
|
key: "clear",
|
|
439
430
|
value: function clear() {
|
|
@@ -472,7 +463,6 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
472
463
|
if (!this.initialisedPluginList.markers) {
|
|
473
464
|
this.initPlugin('markers');
|
|
474
465
|
}
|
|
475
|
-
|
|
476
466
|
return this.markers.add(options);
|
|
477
467
|
},
|
|
478
468
|
clearMarkers: function clearMarkers() {
|
|
@@ -483,10 +473,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
|
|
|
483
473
|
};
|
|
484
474
|
}
|
|
485
475
|
}]);
|
|
486
|
-
|
|
487
476
|
return MarkersPlugin;
|
|
488
477
|
}();
|
|
489
|
-
|
|
490
478
|
exports["default"] = MarkersPlugin;
|
|
491
479
|
module.exports = exports.default;
|
|
492
480
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wavesurfer.markers.js","mappings":";;;;;AAA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AAQ,KAAK3E,OAAL,CAAaiE,MAAb,GAAsB,CAA9B,EAAkC;QAC9B,KAAKa,MAAL,CAAY,CAAZ;MACH;IACJ;;;;IAlWD;AACJ;AACA;AACA;AACA;AACA;AACA;;IAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACI,gBAAc5F,MAAd,EAAsB;MAClB,OAAO;QACH6F,IAAI,EAAE,SADH;QAEHC,SAAS,EAAE9F,MAAM,IAAIA,MAAM,CAAC8F,SAAjB,GAA6B9F,MAAM,CAAC8F,SAApC,GAAgD,KAFxD;QAGH9F,MAAM,EAAEA,MAHL;QAIH+F,WAAW,EAAE;UACTC,SADS,qBACCC,OADD,EACU;YACf,IAAI,CAAC,KAAKC,qBAAL,CAA2BpF,OAAhC,EAAyC;cACrC,KAAKqF,UAAL,CAAgB,SAAhB;YACH;;YACD,OAAO,KAAKrF,OAAL,CAAaG,GAAb,CAAiBgF,OAAjB,CAAP;UACH,CANQ;UAOTG,YAPS,0BAOM;YACX,KAAKtF,OAAL,IAAgB,KAAKA,OAAL,CAAamB,KAAb,EAAhB;UACH;QATQ,CAJV;QAeHoE,QAAQ,EAAEtG;MAfP,CAAP;IAiBH;;;;;;;;;;;;;UC7EL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/markers/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n * @property {?draggable} boolean Set marker as draggable, defaults to false\n * @property {?boolean} preventContextMenu Determines whether the context menu\n * is prevented from being opened, defaults to false\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n * @fires MarkersPlugin#marker-drag\n * @fires MarkersPlugin#marker-drop\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerLineWidth = 1;\n this.markerWidth = 11;\n this.markerHeight = 22;\n this.dragging = false;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n\n if (!this.markers.find(marker => marker.draggable)){\n return;\n }\n\n this.onMouseMove = (e) => this._onMouseMove(e);\n window.addEventListener('mousemove', this.onMouseMove);\n\n this.onMouseUp = (e) => this._onMouseUp(e);\n window.addEventListener(\"mouseup\", this.onMouseUp);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n if (this.onMouseMove) {\n window.removeEventListener('mousemove', this.onMouseMove);\n }\n if (this.onMouseUp) {\n window.removeEventListener(\"mouseup\", this.onMouseUp);\n }\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION,\n draggable: !!params.draggable,\n preventContextMenu: !!params.preventContextMenu\n };\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n let label = marker.el.getElementsByClassName(\"marker-label\")[0];\n if (label) {\n if (label._onContextMenu) {\n label.removeEventListener(\"contextmenu\", label._onContextMenu);\n }\n if (label._onClick) {\n label.removeEventListener(\"click\", label._onClick);\n }\n if (label._onMouseDown) {\n label.removeEventListener(\"mousedown\", label._onMouseDown);\n }\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n const width = markerElement ? markerElement.width : this.markerWidth;\n marker.offset = (width - this.markerLineWidth) / 2;\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": marker.offset + \"px\",\n background: \"black\",\n width: this.markerLineWidth + \"px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n if (marker.draggable){\n point.draggable = false;\n }\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n labelDiv.classList.add(\"marker-label\");\n\n el.appendChild(labelDiv);\n\n labelDiv._onClick = (e) => {\n e.stopPropagation();\n // Click event is caught when the marker-drop event was dispatched.\n // Drop event was dispatched at this moment, but this.dragging\n // is waiting for the next tick to set as false\n if (this.dragging){\n return;\n }\n this.wavesurfer.setCurrentTime(marker.time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n };\n labelDiv.addEventListener(\"click\", labelDiv._onClick);\n\n labelDiv._onContextMenu = (e) => {\n if (marker.preventContextMenu) {\n e.preventDefault();\n }\n this.wavesurfer.fireEvent(\"marker-contextmenu\", marker, e);\n };\n labelDiv.addEventListener(\"contextmenu\", labelDiv._onContextMenu);\n\n if (marker.draggable) {\n labelDiv._onMouseDown = () => {\n this.selectedMarker = marker;\n };\n labelDiv.addEventListener(\"mousedown\", labelDiv._onMouseDown);\n }\n return el;\n }\n\n _updateMarkerPositions() {\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n this._updateMarkerPosition(marker);\n }\n }\n\n /**\n * Update a marker position based on its time property.\n *\n * @private\n * @param {MarkerParams} params The marker to update.\n * @returns {void}\n */\n _updateMarkerPosition(params) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(params.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - params.offset);\n this.style(params.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n\n /**\n * Fires `marker-drag` event, update the `time` property for the\n * selected marker based on the mouse position, and calls to update\n * its position.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseMove(event) {\n if (!this.selectedMarker){\n return;\n }\n if (!this.dragging){\n this.dragging = true;\n this.wavesurfer.fireEvent(\"marker-drag\", this.selectedMarker, event);\n }\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();\n this._updateMarkerPositions();\n }\n\n /**\n * Fires `marker-drop` event and unselect the dragged marker.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseUp(event) {\n if (this.selectedMarker) {\n setTimeout(() => {\n this.selectedMarker = false;\n this.dragging = false;\n }, 0);\n }\n\n if (!this.dragging) {\n return;\n }\n\n event.stopPropagation();\n const duration = this.wavesurfer.getDuration();\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;\n this._updateMarkerPositions();\n this.wavesurfer.fireEvent(\"marker-drop\", this.selectedMarker, event);\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerLineWidth","markerWidth","markerHeight","dragging","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","find","draggable","onMouseMove","e","_onMouseMove","onMouseUp","_onMouseUp","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","preventContextMenu","el","_createMarkerElement","markerElement","appendChild","push","index","getElementsByClassName","_onContextMenu","_onClick","_onMouseDown","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","overflow","line","offset","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","classList","stopPropagation","setCurrentTime","fireEvent","preventDefault","selectedMarker","i","length","_updateMarkerPosition","duration","getDuration","elementWidth","pixelRatio","positionPct","Math","min","leftPx","event","handleEvent","setTimeout","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"wavesurfer.markers.js","mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD;;;;;;;;;;;;;;;;;;;;;;ACVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAMA,kBAAkB,GAAG,SAAS;AACpC,IAAMC,gBAAgB,GAAG,QAAQ;AAAC,IAEbC,aAAa;EAuC9B,SAAAA,cAAYC,MAAM,EAAEC,EAAE,EAAE;IAAA,IAAAC,KAAA;IAAAC,eAAA,OAAAJ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AAEA,MAAM;QACd6G,WAAW,EAAE;UACTC,SAAS,WAAAA,UAACC,OAAO,EAAE;YACf,IAAI,CAAC,IAAI,CAACC,qBAAqB,CAAChG,OAAO,EAAE;cACrC,IAAI,CAACiG,UAAU,CAAC,SAAS,CAAC;YAC9B;YACA,OAAO,IAAI,CAACjG,OAAO,CAACG,GAAG,CAAC4F,OAAO,CAAC;UACpC,CAAC;UACDG,YAAY,WAAAA,aAAA,EAAG;YACX,IAAI,CAAClG,OAAO,IAAI,IAAI,CAACA,OAAO,CAACwB,KAAK,EAAE;UACxC;QACJ,CAAC;QACD2E,QAAQ,EAAEpH;MACd,CAAC;IACL;EAAC;EAAA,OAAAA,aAAA;AAAA;AAAAqH,kBAAA,GAAArH,aAAA;AAAAuH,MAAA,CAAAF,OAAA,GAAAA,OAAA,CAAAC,OAAA;;;;;;UC9EL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://WaveSurfer/webpack/universalModuleDefinition","webpack://WaveSurfer/./src/plugin/markers/index.js","webpack://WaveSurfer/webpack/bootstrap","webpack://WaveSurfer/webpack/before-startup","webpack://WaveSurfer/webpack/startup","webpack://WaveSurfer/webpack/after-startup"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(self, () => {\nreturn ","/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?tooltip} string An optional marker tooltip\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n * @property {?draggable} boolean Set marker as draggable, defaults to false\n * @property {?boolean} preventContextMenu Determines whether the context menu\n * is prevented from being opened, defaults to false\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n * @fires MarkersPlugin#marker-drag\n * @fires MarkersPlugin#marker-drop\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerLineWidth = 1;\n this.markerWidth = 11;\n this.markerHeight = 22;\n this.dragging = false;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n\n if (!this.markers.find(marker => marker.draggable)){\n return;\n }\n\n this.onMouseMove = (e) => this._onMouseMove(e);\n window.addEventListener('mousemove', this.onMouseMove);\n\n this.onMouseUp = (e) => this._onMouseUp(e);\n window.addEventListener(\"mouseup\", this.onMouseUp);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n if (this.onMouseMove) {\n window.removeEventListener('mousemove', this.onMouseMove);\n }\n if (this.onMouseUp) {\n window.removeEventListener(\"mouseup\", this.onMouseUp);\n }\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n tooltip: params.tooltip,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION,\n draggable: !!params.draggable,\n preventContextMenu: !!params.preventContextMenu\n };\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n this._registerEvents();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n let label = marker.el.getElementsByClassName(\"marker-label\")[0];\n if (label) {\n if (label._onContextMenu) {\n label.removeEventListener(\"contextmenu\", label._onContextMenu);\n }\n if (label._onClick) {\n label.removeEventListener(\"click\", label._onClick);\n }\n if (label._onMouseDown) {\n label.removeEventListener(\"mousedown\", label._onMouseDown);\n }\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n\n this._unregisterEvents();\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let tooltip = marker.tooltip;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n const width = markerElement ? markerElement.width : this.markerWidth;\n marker.offset = (width - this.markerLineWidth) / 2;\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": marker.offset + \"px\",\n background: \"black\",\n width: this.markerLineWidth + \"px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n if (marker.draggable){\n point.draggable = false;\n }\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n labelEl.setAttribute('title', tooltip);\n this.style(labelEl, {\n \"font-family\": \"inherit\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n labelDiv.classList.add(\"marker-label\");\n\n el.appendChild(labelDiv);\n\n labelDiv._onClick = (e) => {\n e.stopPropagation();\n // Click event is caught when the marker-drop event was dispatched.\n // Drop event was dispatched at this moment, but this.dragging\n // is waiting for the next tick to set as false\n if (this.dragging){\n return;\n }\n this.wavesurfer.setCurrentTime(marker.time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n };\n labelDiv.addEventListener(\"click\", labelDiv._onClick);\n\n labelDiv._onContextMenu = (e) => {\n if (marker.preventContextMenu) {\n e.preventDefault();\n }\n this.wavesurfer.fireEvent(\"marker-contextmenu\", marker, e);\n };\n labelDiv.addEventListener(\"contextmenu\", labelDiv._onContextMenu);\n\n if (marker.draggable) {\n labelDiv._onMouseDown = () => {\n this.selectedMarker = marker;\n };\n labelDiv.addEventListener(\"mousedown\", labelDiv._onMouseDown);\n }\n return el;\n }\n\n _updateMarkerPositions() {\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n this._updateMarkerPosition(marker);\n }\n }\n\n /**\n * Update a marker position based on its time property.\n *\n * @private\n * @param {MarkerParams} params The marker to update.\n * @returns {void}\n */\n _updateMarkerPosition(params) {\n const duration = this.wavesurfer.getDuration();\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(params.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - params.offset);\n this.style(params.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n\n /**\n * Fires `marker-drag` event, update the `time` property for the\n * selected marker based on the mouse position, and calls to update\n * its position.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseMove(event) {\n if (!this.selectedMarker){\n return;\n }\n if (!this.dragging){\n this.dragging = true;\n this.wavesurfer.fireEvent(\"marker-drag\", this.selectedMarker, event);\n }\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();\n this._updateMarkerPositions();\n }\n\n /**\n * Fires `marker-drop` event and unselect the dragged marker.\n *\n * @private\n * @param {MouseEvent} event The mouse event.\n * @returns {void}\n */\n _onMouseUp(event) {\n if (this.selectedMarker) {\n setTimeout(() => {\n this.selectedMarker = false;\n this.dragging = false;\n }, 0);\n }\n\n if (!this.dragging) {\n return;\n }\n\n event.stopPropagation();\n const duration = this.wavesurfer.getDuration();\n this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;\n this._updateMarkerPositions();\n this.wavesurfer.fireEvent(\"marker-drop\", this.selectedMarker, event);\n }\n\n _registerEvents() {\n if (!this.markers.find(marker => marker.draggable)) {\n return;\n }\n //we have some draggable markers, check for listeners\n if (!this.onMouseMove) {\n this.onMouseMove = (e) => this._onMouseMove(e);\n window.addEventListener('mousemove', this.onMouseMove);\n }\n\n if (!this.onMouseUp) {\n this.onMouseUp = (e) => this._onMouseUp(e);\n window.addEventListener(\"mouseup\", this.onMouseUp);\n }\n }\n\n _unregisterEvents() {\n if (this.markers.find(marker => marker.draggable)) {\n return;\n }\n //we don't have any draggable markers, unregister listeners\n if (this.onMouseMove) {\n window.removeEventListener('mousemove', this.onMouseMove);\n this.onMouseMove = null;\n }\n if (this.onMouseUp) {\n window.removeEventListener(\"mouseup\", this.onMouseUp);\n this.onMouseUp = null;\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n",""],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","_this","_classCallCheck","wavesurfer","util","style","markerLineWidth","markerWidth","markerHeight","dragging","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","find","draggable","onMouseMove","e","_onMouseMove","onMouseUp","_onMouseUp","_onReady","_createClass","key","value","init","isReady","once","destroy","un","removeEventListener","clear","time","label","tooltip","color","position","preventContextMenu","el","_createMarkerElement","markerElement","appendChild","push","_registerEvents","remove","index","getElementsByClassName","_onContextMenu","_onClick","_onMouseDown","removeChild","splice","_unregisterEvents","_createPointerSVG","svgNS","document","createElementNS","polygon","setAttribute","width","height","_this2","createElement","className","display","overflow","line","offset","background","opacity","labelDiv","point","labelEl","innerText","cursor","classList","stopPropagation","setCurrentTime","fireEvent","preventDefault","selectedMarker","i","length","_updateMarkerPosition","duration","getDuration","elementWidth","pixelRatio","positionPct","Math","min","leftPx","event","handleEvent","_this3","setTimeout","_this4","create","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance","exports","default","module"],"sourceRoot":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js markers plugin 6.
|
|
2
|
+
* wavesurfer.js markers plugin 6.5.0 (2023-03-11)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(self,(()=>(()=>{"use strict";var e={188:(e,t)=>{function r(e,t){for(var
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(self,(()=>(()=>{"use strict";var e={188:(e,t)=>{function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(o=i.key,s=void 0,s=function(e,t){if("object"!==r(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==r(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(o,"string"),"symbol"===r(s)?s:String(s)),i)}var o,s}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerLineWidth=1,this.markerWidth=11,this.markerHeight=22,this.dragging=!1,this._onResize=function(){n._updateMarkerPositions()},this._onBackendCreated=function(){n.wrapper=n.wavesurfer.drawer.wrapper,n.params.markers&&n.params.markers.forEach((function(e){return n.add(e)})),window.addEventListener("resize",n._onResize,!0),window.addEventListener("orientationchange",n._onResize,!0),n.wavesurfer.on("zoom",n._onResize),n.markers.find((function(e){return e.draggable}))&&(n.onMouseMove=function(e){return n._onMouseMove(e)},window.addEventListener("mousemove",n.onMouseMove),n.onMouseUp=function(e){return n._onMouseUp(e)},window.addEventListener("mouseup",n.onMouseUp))},this.markers=[],this._onReady=function(){n.wrapper=n.wavesurfer.drawer.wrapper,n._updateMarkerPositions()}}var t,r,i;return t=e,i=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(r=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.onMouseMove&&window.removeEventListener("mousemove",this.onMouseMove),this.onMouseUp&&window.removeEventListener("mouseup",this.onMouseUp),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,tooltip:e.tooltip,color:e.color||"#D8D8D8",position:e.position||"bottom",draggable:!!e.draggable,preventContextMenu:!!e.preventContextMenu};return t.el=this._createMarkerElement(t,e.markerElement),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),this._registerEvents(),t}},{key:"remove",value:function(e){var t=this.markers[e];if(t){var r=t.el.getElementsByClassName("marker-label")[0];r&&(r._onContextMenu&&r.removeEventListener("contextmenu",r._onContextMenu),r._onClick&&r.removeEventListener("click",r._onClick),r._onMouseDown&&r.removeEventListener("mousedown",r._onMouseDown)),this.wrapper.removeChild(t.el),this.markers.splice(e,1),this._unregisterEvents()}}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",n=document.createElementNS(r,"svg"),i=document.createElementNS(r,"polygon");return n.setAttribute("viewBox","0 0 40 80"),i.setAttribute("id","polygon"),i.setAttribute("stroke","#979797"),i.setAttribute("fill",e),i.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&i.setAttribute("transform","rotate(180, 20 40)"),n.appendChild(i),this.style(n,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),n}},{key:"_createMarkerElement",value:function(e,t){var r=this,n=e.label,i=e.tooltip,o=document.createElement("marker");o.className="wavesurfer-marker",this.style(o,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var s=document.createElement("div"),a=t?t.width:this.markerWidth;e.offset=(a-this.markerLineWidth)/2,this.style(s,{"flex-grow":1,"margin-left":e.offset+"px",background:"black",width:this.markerLineWidth+"px",opacity:.1}),o.appendChild(s);var u=document.createElement("div"),d=t||this._createPointerSVG(e.color,e.position);if(e.draggable&&(d.draggable=!1),u.appendChild(d),n){var l=document.createElement("span");l.innerText=n,l.setAttribute("title",i),this.style(l,{"font-family":"inherit","font-size":"90%"}),u.appendChild(l)}return this.style(u,{display:"flex","align-items":"center",cursor:"pointer"}),u.classList.add("marker-label"),o.appendChild(u),u._onClick=function(t){t.stopPropagation(),r.dragging||(r.wavesurfer.setCurrentTime(e.time),r.wavesurfer.fireEvent("marker-click",e,t))},u.addEventListener("click",u._onClick),u._onContextMenu=function(t){e.preventContextMenu&&t.preventDefault(),r.wavesurfer.fireEvent("marker-contextmenu",e,t)},u.addEventListener("contextmenu",u._onContextMenu),e.draggable&&(u._onMouseDown=function(){r.selectedMarker=e},u.addEventListener("mousedown",u._onMouseDown)),o}},{key:"_updateMarkerPositions",value:function(){for(var e=0;e<this.markers.length;e++){var t=this.markers[e];this._updateMarkerPosition(t)}}},{key:"_updateMarkerPosition",value:function(e){var t=this.wavesurfer.getDuration(),r=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,n=r*Math.min(e.time/t,1)-e.offset;this.style(e.el,{left:n+"px","max-width":r-n+"px"})}},{key:"_onMouseMove",value:function(e){this.selectedMarker&&(this.dragging||(this.dragging=!0,this.wavesurfer.fireEvent("marker-drag",this.selectedMarker,e)),this.selectedMarker.time=this.wavesurfer.drawer.handleEvent(e)*this.wavesurfer.getDuration(),this._updateMarkerPositions())}},{key:"_onMouseUp",value:function(e){var t=this;if(this.selectedMarker&&setTimeout((function(){t.selectedMarker=!1,t.dragging=!1}),0),this.dragging){e.stopPropagation();var r=this.wavesurfer.getDuration();this.selectedMarker.time=this.wavesurfer.drawer.handleEvent(e)*r,this._updateMarkerPositions(),this.wavesurfer.fireEvent("marker-drop",this.selectedMarker,e)}}},{key:"_registerEvents",value:function(){var e=this;this.markers.find((function(e){return e.draggable}))&&(this.onMouseMove||(this.onMouseMove=function(t){return e._onMouseMove(t)},window.addEventListener("mousemove",this.onMouseMove)),this.onMouseUp||(this.onMouseUp=function(t){return e._onMouseUp(t)},window.addEventListener("mouseup",this.onMouseUp)))}},{key:"_unregisterEvents",value:function(){this.markers.find((function(e){return e.draggable}))||(this.onMouseMove&&(window.removeEventListener("mousemove",this.onMouseMove),this.onMouseMove=null),this.onMouseUp&&(window.removeEventListener("mouseup",this.onMouseUp),this.onMouseUp=null))}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&n(t.prototype,r),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=i,e.exports=t.default}},t={};var r=function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}(188);return r})()));
|
|
7
7
|
//# sourceMappingURL=wavesurfer.markers.min.js.map
|