wavesurfer.js 6.3.0 → 6.4.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.
Files changed (53) hide show
  1. package/README.md +1 -0
  2. package/dist/plugin/wavesurfer.cursor.js +29 -49
  3. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  4. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  5. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  6. package/dist/plugin/wavesurfer.elan.js +19 -49
  7. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  8. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  10. package/dist/plugin/wavesurfer.markers.js +57 -72
  11. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  12. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  13. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  14. package/dist/plugin/wavesurfer.mediasession.js +5 -15
  15. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  16. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  18. package/dist/plugin/wavesurfer.microphone.js +44 -62
  19. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  20. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  22. package/dist/plugin/wavesurfer.minimap.js +16 -68
  23. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  24. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  26. package/dist/plugin/wavesurfer.playhead.js +2 -29
  27. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  28. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  29. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  30. package/dist/plugin/wavesurfer.regions.js +98 -252
  31. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  32. package/dist/plugin/wavesurfer.regions.min.js +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  34. package/dist/plugin/wavesurfer.spectrogram.js +51 -146
  35. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  36. package/dist/plugin/wavesurfer.spectrogram.min.js +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  38. package/dist/plugin/wavesurfer.timeline.js +42 -85
  39. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  40. package/dist/plugin/wavesurfer.timeline.min.js +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  42. package/dist/wavesurfer-html-init.js +31 -53
  43. package/dist/wavesurfer-html-init.js.map +1 -1
  44. package/dist/wavesurfer-html-init.min.js +1 -1
  45. package/dist/wavesurfer-html-init.min.js.map +1 -1
  46. package/dist/wavesurfer.js +419 -982
  47. package/dist/wavesurfer.js.map +1 -1
  48. package/dist/wavesurfer.min.js +2 -2
  49. package/dist/wavesurfer.min.js.map +1 -1
  50. package/package.json +6 -6
  51. package/src/plugin/cursor/index.js +15 -3
  52. package/src/plugin/markers/index.js +39 -0
  53. package/CHANGES.md +0 -482
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 6.3.0 (2022-10-03)
2
+ * wavesurfer.js markers plugin 6.4.0 (2022-11-05)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -29,19 +29,16 @@ Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
31
  exports["default"] = void 0;
32
-
33
32
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
33
  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
-
37
34
  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
-
39
35
  /**
40
36
  * @typedef {Object} MarkerParams
41
37
  * @desc The parameters used to describe a marker.
42
38
  * @example wavesurfer.addMarker(regionParams);
43
39
  * @property {number} time The time to set the marker at
44
40
  * @property {?label} string An optional marker label
41
+ * @property {?tooltip} string An optional marker tooltip
45
42
  * @property {?color} string Background color for marker
46
43
  * @property {?position} string "top" or "bottom", defaults to "bottom"
47
44
  * @property {?markerElement} element An HTML element to display instead of the default marker image
@@ -71,15 +68,13 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
71
68
  * ]
72
69
  * });
73
70
  */
71
+
74
72
  var DEFAULT_FILL_COLOR = "#D8D8D8";
75
73
  var DEFAULT_POSITION = "bottom";
76
-
77
74
  var MarkersPlugin = /*#__PURE__*/function () {
78
75
  function MarkersPlugin(params, ws) {
79
76
  var _this = this;
80
-
81
77
  _classCallCheck(this, MarkersPlugin);
82
-
83
78
  this.params = params;
84
79
  this.wavesurfer = ws;
85
80
  this.util = ws.util;
@@ -88,60 +83,45 @@ var MarkersPlugin = /*#__PURE__*/function () {
88
83
  this.markerWidth = 11;
89
84
  this.markerHeight = 22;
90
85
  this.dragging = false;
91
-
92
86
  this._onResize = function () {
93
87
  _this._updateMarkerPositions();
94
88
  };
95
-
96
89
  this._onBackendCreated = function () {
97
90
  _this.wrapper = _this.wavesurfer.drawer.wrapper;
98
-
99
91
  if (_this.params.markers) {
100
92
  _this.params.markers.forEach(function (marker) {
101
93
  return _this.add(marker);
102
94
  });
103
95
  }
104
-
105
96
  window.addEventListener('resize', _this._onResize, true);
106
97
  window.addEventListener('orientationchange', _this._onResize, true);
107
-
108
98
  _this.wavesurfer.on('zoom', _this._onResize);
109
-
110
99
  if (!_this.markers.find(function (marker) {
111
100
  return marker.draggable;
112
101
  })) {
113
102
  return;
114
103
  }
115
-
116
104
  _this.onMouseMove = function (e) {
117
105
  return _this._onMouseMove(e);
118
106
  };
119
-
120
107
  window.addEventListener('mousemove', _this.onMouseMove);
121
-
122
108
  _this.onMouseUp = function (e) {
123
109
  return _this._onMouseUp(e);
124
110
  };
125
-
126
111
  window.addEventListener("mouseup", _this.onMouseUp);
127
112
  };
128
-
129
113
  this.markers = [];
130
-
131
114
  this._onReady = function () {
132
115
  _this.wrapper = _this.wavesurfer.drawer.wrapper;
133
-
134
116
  _this._updateMarkerPositions();
135
117
  };
136
118
  }
137
-
138
119
  _createClass(MarkersPlugin, [{
139
120
  key: "init",
140
121
  value: function init() {
141
122
  // Check if ws is ready
142
123
  if (this.wavesurfer.isReady) {
143
124
  this._onBackendCreated();
144
-
145
125
  this._onReady();
146
126
  } else {
147
127
  this.wavesurfer.once('ready', this._onReady);
@@ -156,30 +136,28 @@ var MarkersPlugin = /*#__PURE__*/function () {
156
136
  this.wavesurfer.un('zoom', this._onResize);
157
137
  window.removeEventListener('resize', this._onResize, true);
158
138
  window.removeEventListener('orientationchange', this._onResize, true);
159
-
160
139
  if (this.onMouseMove) {
161
140
  window.removeEventListener('mousemove', this.onMouseMove);
162
141
  }
163
-
164
142
  if (this.onMouseUp) {
165
143
  window.removeEventListener("mouseup", this.onMouseUp);
166
144
  }
167
-
168
145
  this.clear();
169
146
  }
147
+
170
148
  /**
171
149
  * Add a marker
172
150
  *
173
151
  * @param {MarkerParams} params Marker definition
174
152
  * @return {object} The created marker
175
153
  */
176
-
177
154
  }, {
178
155
  key: "add",
179
156
  value: function add(params) {
180
157
  var marker = {
181
158
  time: params.time,
182
159
  label: params.label,
160
+ tooltip: params.tooltip,
183
161
  color: params.color || DEFAULT_FILL_COLOR,
184
162
  position: params.position || DEFAULT_POSITION,
185
163
  draggable: !!params.draggable,
@@ -188,44 +166,38 @@ var MarkersPlugin = /*#__PURE__*/function () {
188
166
  marker.el = this._createMarkerElement(marker, params.markerElement);
189
167
  this.wrapper.appendChild(marker.el);
190
168
  this.markers.push(marker);
191
-
192
169
  this._updateMarkerPositions();
193
-
170
+ this._registerEvents();
194
171
  return marker;
195
172
  }
173
+
196
174
  /**
197
175
  * Remove a marker
198
176
  *
199
177
  * @param {number} index Index of the marker to remove
200
178
  */
201
-
202
179
  }, {
203
180
  key: "remove",
204
181
  value: function remove(index) {
205
182
  var marker = this.markers[index];
206
-
207
183
  if (!marker) {
208
184
  return;
209
185
  }
210
-
211
186
  var label = marker.el.getElementsByClassName("marker-label")[0];
212
-
213
187
  if (label) {
214
188
  if (label._onContextMenu) {
215
189
  label.removeEventListener("contextmenu", label._onContextMenu);
216
190
  }
217
-
218
191
  if (label._onClick) {
219
192
  label.removeEventListener("click", label._onClick);
220
193
  }
221
-
222
194
  if (label._onMouseDown) {
223
195
  label.removeEventListener("mousedown", label._onMouseDown);
224
196
  }
225
197
  }
226
-
227
198
  this.wrapper.removeChild(marker.el);
228
199
  this.markers.splice(index, 1);
200
+ this._unregisterEvents();
229
201
  }
230
202
  }, {
231
203
  key: "_createPointerSVG",
@@ -238,11 +210,9 @@ var MarkersPlugin = /*#__PURE__*/function () {
238
210
  polygon.setAttribute("stroke", "#979797");
239
211
  polygon.setAttribute("fill", color);
240
212
  polygon.setAttribute("points", "20 0 40 30 40 80 0 80 0 30");
241
-
242
213
  if (position == "top") {
243
214
  polygon.setAttribute("transform", "rotate(180, 20 40)");
244
215
  }
245
-
246
216
  el.appendChild(polygon);
247
217
  this.style(el, {
248
218
  width: this.markerWidth + "px",
@@ -257,8 +227,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
257
227
  key: "_createMarkerElement",
258
228
  value: function _createMarkerElement(marker, markerElement) {
259
229
  var _this2 = this;
260
-
261
230
  var label = marker.label;
231
+ var tooltip = marker.tooltip;
262
232
  var el = document.createElement('marker');
263
233
  el.className = "wavesurfer-marker";
264
234
  this.style(el, {
@@ -280,25 +250,21 @@ var MarkersPlugin = /*#__PURE__*/function () {
280
250
  });
281
251
  el.appendChild(line);
282
252
  var labelDiv = document.createElement('div');
283
-
284
253
  var point = markerElement || this._createPointerSVG(marker.color, marker.position);
285
-
286
254
  if (marker.draggable) {
287
255
  point.draggable = false;
288
256
  }
289
-
290
257
  labelDiv.appendChild(point);
291
-
292
258
  if (label) {
293
259
  var labelEl = document.createElement('span');
294
260
  labelEl.innerText = label;
261
+ labelEl.setAttribute('title', tooltip);
295
262
  this.style(labelEl, {
296
263
  "font-family": "monospace",
297
264
  "font-size": "90%"
298
265
  });
299
266
  labelDiv.appendChild(labelEl);
300
267
  }
301
-
302
268
  this.style(labelDiv, {
303
269
  display: "flex",
304
270
  "align-items": "center",
@@ -306,41 +272,31 @@ var MarkersPlugin = /*#__PURE__*/function () {
306
272
  });
307
273
  labelDiv.classList.add("marker-label");
308
274
  el.appendChild(labelDiv);
309
-
310
275
  labelDiv._onClick = function (e) {
311
- e.stopPropagation(); // Click event is caught when the marker-drop event was dispatched.
276
+ e.stopPropagation();
277
+ // Click event is caught when the marker-drop event was dispatched.
312
278
  // Drop event was dispatched at this moment, but this.dragging
313
279
  // is waiting for the next tick to set as false
314
-
315
280
  if (_this2.dragging) {
316
281
  return;
317
282
  }
318
-
319
283
  _this2.wavesurfer.setCurrentTime(marker.time);
320
-
321
284
  _this2.wavesurfer.fireEvent("marker-click", marker, e);
322
285
  };
323
-
324
286
  labelDiv.addEventListener("click", labelDiv._onClick);
325
-
326
287
  labelDiv._onContextMenu = function (e) {
327
288
  if (marker.preventContextMenu) {
328
289
  e.preventDefault();
329
290
  }
330
-
331
291
  _this2.wavesurfer.fireEvent("marker-contextmenu", marker, e);
332
292
  };
333
-
334
293
  labelDiv.addEventListener("contextmenu", labelDiv._onContextMenu);
335
-
336
294
  if (marker.draggable) {
337
295
  labelDiv._onMouseDown = function () {
338
296
  _this2.selectedMarker = marker;
339
297
  };
340
-
341
298
  labelDiv.addEventListener("mousedown", labelDiv._onMouseDown);
342
299
  }
343
-
344
300
  return el;
345
301
  }
346
302
  }, {
@@ -348,10 +304,10 @@ var MarkersPlugin = /*#__PURE__*/function () {
348
304
  value: function _updateMarkerPositions() {
349
305
  for (var i = 0; i < this.markers.length; i++) {
350
306
  var marker = this.markers[i];
351
-
352
307
  this._updateMarkerPosition(marker);
353
308
  }
354
309
  }
310
+
355
311
  /**
356
312
  * Update a marker position based on its time property.
357
313
  *
@@ -359,7 +315,6 @@ var MarkersPlugin = /*#__PURE__*/function () {
359
315
  * @param {MarkerParams} params The marker to update.
360
316
  * @returns {void}
361
317
  */
362
-
363
318
  }, {
364
319
  key: "_updateMarkerPosition",
365
320
  value: function _updateMarkerPosition(params) {
@@ -372,6 +327,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
372
327
  "max-width": elementWidth - leftPx + "px"
373
328
  });
374
329
  }
330
+
375
331
  /**
376
332
  * Fires `marker-drag` event, update the `time` property for the
377
333
  * selected marker based on the mouse position, and calls to update
@@ -381,23 +337,20 @@ var MarkersPlugin = /*#__PURE__*/function () {
381
337
  * @param {MouseEvent} event The mouse event.
382
338
  * @returns {void}
383
339
  */
384
-
385
340
  }, {
386
341
  key: "_onMouseMove",
387
342
  value: function _onMouseMove(event) {
388
343
  if (!this.selectedMarker) {
389
344
  return;
390
345
  }
391
-
392
346
  if (!this.dragging) {
393
347
  this.dragging = true;
394
348
  this.wavesurfer.fireEvent("marker-drag", this.selectedMarker, event);
395
349
  }
396
-
397
350
  this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * this.wavesurfer.getDuration();
398
-
399
351
  this._updateMarkerPositions();
400
352
  }
353
+
401
354
  /**
402
355
  * Fires `marker-drop` event and unselect the dragged marker.
403
356
  *
@@ -405,35 +358,70 @@ var MarkersPlugin = /*#__PURE__*/function () {
405
358
  * @param {MouseEvent} event The mouse event.
406
359
  * @returns {void}
407
360
  */
408
-
409
361
  }, {
410
362
  key: "_onMouseUp",
411
363
  value: function _onMouseUp(event) {
412
364
  var _this3 = this;
413
-
414
365
  if (this.selectedMarker) {
415
366
  setTimeout(function () {
416
367
  _this3.selectedMarker = false;
417
368
  _this3.dragging = false;
418
369
  }, 0);
419
370
  }
420
-
421
371
  if (!this.dragging) {
422
372
  return;
423
373
  }
424
-
425
374
  event.stopPropagation();
426
375
  var duration = this.wavesurfer.getDuration();
427
376
  this.selectedMarker.time = this.wavesurfer.drawer.handleEvent(event) * duration;
428
-
429
377
  this._updateMarkerPositions();
430
-
431
378
  this.wavesurfer.fireEvent("marker-drop", this.selectedMarker, event);
432
379
  }
380
+ }, {
381
+ key: "_registerEvents",
382
+ value: function _registerEvents() {
383
+ var _this4 = this;
384
+ if (!this.markers.find(function (marker) {
385
+ return marker.draggable;
386
+ })) {
387
+ return;
388
+ }
389
+ //we have some draggable markers, check for listeners
390
+ if (!this.onMouseMove) {
391
+ this.onMouseMove = function (e) {
392
+ return _this4._onMouseMove(e);
393
+ };
394
+ window.addEventListener('mousemove', this.onMouseMove);
395
+ }
396
+ if (!this.onMouseUp) {
397
+ this.onMouseUp = function (e) {
398
+ return _this4._onMouseUp(e);
399
+ };
400
+ window.addEventListener("mouseup", this.onMouseUp);
401
+ }
402
+ }
403
+ }, {
404
+ key: "_unregisterEvents",
405
+ value: function _unregisterEvents() {
406
+ if (this.markers.find(function (marker) {
407
+ return marker.draggable;
408
+ })) {
409
+ return;
410
+ }
411
+ //we don't have any draggable markers, unregister listeners
412
+ if (this.onMouseMove) {
413
+ window.removeEventListener('mousemove', this.onMouseMove);
414
+ this.onMouseMove = null;
415
+ }
416
+ if (this.onMouseUp) {
417
+ window.removeEventListener("mouseup", this.onMouseUp);
418
+ this.onMouseUp = null;
419
+ }
420
+ }
421
+
433
422
  /**
434
423
  * Remove all markers
435
424
  */
436
-
437
425
  }, {
438
426
  key: "clear",
439
427
  value: function clear() {
@@ -472,7 +460,6 @@ var MarkersPlugin = /*#__PURE__*/function () {
472
460
  if (!this.initialisedPluginList.markers) {
473
461
  this.initPlugin('markers');
474
462
  }
475
-
476
463
  return this.markers.add(options);
477
464
  },
478
465
  clearMarkers: function clearMarkers() {
@@ -483,10 +470,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
483
470
  };
484
471
  }
485
472
  }]);
486
-
487
473
  return MarkersPlugin;
488
474
  }();
489
-
490
475
  exports["default"] = MarkersPlugin;
491
476
  module.exports = exports.default;
492
477
 
@@ -1 +1 @@
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;;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,SAA3B;AACA,IAAMC,gBAAgB,GAAG,QAAzB;;IAEqBC;EAuCjB,uBAAYC,MAAZ,EAAoBC,EAApB,EAAwB;IAAA;;IAAA;;IACpB,KAAKD,MAAL,GAAcA,MAAd;IACA,KAAKE,UAAL,GAAkBD,EAAlB;IACA,KAAKE,IAAL,GAAYF,EAAE,CAACE,IAAf;IACA,KAAKC,KAAL,GAAa,KAAKD,IAAL,CAAUC,KAAvB;IACA,KAAKC,eAAL,GAAuB,CAAvB;IACA,KAAKC,WAAL,GAAmB,EAAnB;IACA,KAAKC,YAAL,GAAoB,EAApB;IACA,KAAKC,QAAL,GAAgB,KAAhB;;IAGA,KAAKC,SAAL,GAAiB,YAAM;MACnB,KAAI,CAACC,sBAAL;IACH,CAFD;;IAIA,KAAKC,iBAAL,GAAyB,YAAM;MAC3B,KAAI,CAACC,OAAL,GAAe,KAAI,CAACV,UAAL,CAAgBW,MAAhB,CAAuBD,OAAtC;;MACA,IAAI,KAAI,CAACZ,MAAL,CAAYc,OAAhB,EAAyB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pack://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;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ACzF,OAAO,IAAI,IAAI,CAACA,OAAO,CAACmB,KAAK,EAAE;UACxC;QACJ,CAAC;QACDuE,QAAQ,EAAEzG;MACd,CAAC;IACL;EAAC;EAAA;AAAA;AAAA;AAAA;;;;;;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\": \"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 _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","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","tooltip","color","position","preventContextMenu","el","_createMarkerElement","markerElement","appendChild","push","_registerEvents","index","getElementsByClassName","_onContextMenu","_onClick","_onMouseDown","removeChild","splice","_unregisterEvents","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,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 6.3.0 (2022-10-03)
2
+ * wavesurfer.js markers plugin 6.4.0 (2022-11-05)
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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=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,n,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}}}],(n=[{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,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(),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)}}},{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=document.createElement("marker");i.className="wavesurfer-marker",this.style(i,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var a=document.createElement("div"),s=t?t.width:this.markerWidth;e.offset=(s-this.markerLineWidth)/2,this.style(a,{"flex-grow":1,"margin-left":e.offset+"px",background:"black",width:this.markerLineWidth+"px",opacity:.1}),i.appendChild(a);var o=document.createElement("div"),u=t||this._createPointerSVG(e.color,e.position);if(e.draggable&&(u.draggable=!1),o.appendChild(u),n){var d=document.createElement("span");d.innerText=n,this.style(d,{"font-family":"monospace","font-size":"90%"}),o.appendChild(d)}return this.style(o,{display:"flex","align-items":"center",cursor:"pointer"}),o.classList.add("marker-label"),i.appendChild(o),o._onClick=function(t){t.stopPropagation(),r.dragging||(r.wavesurfer.setCurrentTime(e.time),r.wavesurfer.fireEvent("marker-click",e,t))},o.addEventListener("click",o._onClick),o._onContextMenu=function(t){e.preventContextMenu&&t.preventDefault(),r.wavesurfer.fireEvent("marker-contextmenu",e,t)},o.addEventListener("contextmenu",o._onContextMenu),e.draggable&&(o._onMouseDown=function(){r.selectedMarker=e},o.addEventListener("mousedown",o._onMouseDown)),i}},{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:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,e.exports=t.default}},t={};var r=function r(n){var i=t[n];if(void 0!==i)return i.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}(188);return r})()));
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 r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=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,n,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}}}],(n=[{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":"monospace","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)}}])&&r(t.prototype,n),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=n,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