@checksub_team/peaks_timeline 1.5.10 → 1.5.12
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/package.json +1 -1
- package/peaks.js +118 -17
- package/src/line-indicator.js +3 -3
- package/src/main.js +5 -0
- package/src/mode-layer.js +12 -6
- package/src/source-group.js +23 -7
- package/src/source.js +94 -2
- package/src/timeline-axis.js +4 -3
- package/src/timeline-sources.js +10 -0
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14376,7 +14376,7 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14376
14376
|
var textNode = new Konva.Text({
|
|
14377
14377
|
text: text,
|
|
14378
14378
|
fontSize: this._sizes.font,
|
|
14379
|
-
fontFamily:
|
|
14379
|
+
fontFamily: this._peaks.options.lineIndicatorFont,
|
|
14380
14380
|
fill: this._peaks.options.lineIndicatorTextColor,
|
|
14381
14381
|
align: 'center',
|
|
14382
14382
|
width: this._width
|
|
@@ -14450,7 +14450,6 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14450
14450
|
LineIndicator.prototype.removeIndicator = function (lineId, keepInList) {
|
|
14451
14451
|
if (this._indicators[lineId]) {
|
|
14452
14452
|
if (this._indicators[lineId].indicator) {
|
|
14453
|
-
console.log('remove', lineId);
|
|
14454
14453
|
this._indicators[lineId].indicator.destroy();
|
|
14455
14454
|
}
|
|
14456
14455
|
if (!keepInList) {
|
|
@@ -15422,6 +15421,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15422
15421
|
lineIndicatorNoVolumeIconSize: 24,
|
|
15423
15422
|
lineIndicatorVisibilityIconSize: 24,
|
|
15424
15423
|
lineIndicatorNoVisibilityIconSize: 24,
|
|
15424
|
+
lineIndicatorFont: 'Arial',
|
|
15425
15425
|
lineIndicatorFontSize: 10,
|
|
15426
15426
|
lineIndicatorTextColor: '#8A8F98',
|
|
15427
15427
|
lineIndicatorIconColor: '#8A8F98',
|
|
@@ -15765,7 +15765,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15765
15765
|
var selectedElement = this._selectedElement;
|
|
15766
15766
|
this.deselectElement(true);
|
|
15767
15767
|
if (selectedElement instanceof SourceGroup) {
|
|
15768
|
-
|
|
15768
|
+
if (selectedElement.isDeletable()) {
|
|
15769
|
+
this._peaks.destroySource(selectedElement.getSource().id);
|
|
15770
|
+
}
|
|
15769
15771
|
} else {
|
|
15770
15772
|
if (selectedElement.getSegment().allowDeletion) {
|
|
15771
15773
|
this._peaks.destroySegment(selectedElement.getSegment().id);
|
|
@@ -15779,7 +15781,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15779
15781
|
};
|
|
15780
15782
|
ModeLayer.prototype._updateCursorTime = function (mousePosition) {
|
|
15781
15783
|
var hoveredElement = this._view.getHoveredElement();
|
|
15782
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
15784
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15783
15785
|
this._timeLabel.text(Utils.formatTime(this._view.pixelsToTime(mousePosition.x + this._view.getFrameOffset()), false));
|
|
15784
15786
|
this._timeBackground.width(this._timeLabel.width() + 8);
|
|
15785
15787
|
this._cursorTime.x(mousePosition.x + TIME_X_OFFSET);
|
|
@@ -15795,7 +15797,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15795
15797
|
};
|
|
15796
15798
|
ModeLayer.prototype._updateCuttingLine = function (mousePosition) {
|
|
15797
15799
|
var hoveredElement = this._view.getHoveredElement();
|
|
15798
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
15800
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15799
15801
|
var minSize = this._view.timeToPixels(hoveredElement.getSource().minSize);
|
|
15800
15802
|
if (hoveredElement.getWidth() >= 2 * minSize) {
|
|
15801
15803
|
var height = hoveredElement.getCurrentHeight();
|
|
@@ -15848,7 +15850,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15848
15850
|
var mousePosition = this._stage.getPointerPosition();
|
|
15849
15851
|
mousePosition.x = this._view.timeToPixels(this._view.pixelsToTime(mousePosition.x));
|
|
15850
15852
|
var hoveredElement = this._view.getHoveredElement();
|
|
15851
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
15853
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15852
15854
|
var minSize = this._view.timeToPixels(hoveredElement.getSource().minSize);
|
|
15853
15855
|
if (hoveredElement.getWidth() >= 2 * minSize) {
|
|
15854
15856
|
var cuttingPixel;
|
|
@@ -15881,7 +15883,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15881
15883
|
this._stage.off('mouseleave', this._onMouseLeaveInCutMode);
|
|
15882
15884
|
this._stage.off('click', this._onMouseClickInCutMode);
|
|
15883
15885
|
this._cutGroup.visible(false);
|
|
15884
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
15886
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15885
15887
|
hoveredElement.toggleDragging(hoveredElement.getSource().draggable);
|
|
15886
15888
|
hoveredElement.toggleResizing(hoveredElement.getSource().resizable);
|
|
15887
15889
|
}
|
|
@@ -15908,7 +15910,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15908
15910
|
this._updateCuttingLine(mousePosition);
|
|
15909
15911
|
}
|
|
15910
15912
|
}
|
|
15911
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
15913
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
15912
15914
|
hoveredElement.toggleDragging(false);
|
|
15913
15915
|
hoveredElement.toggleResizing(false);
|
|
15914
15916
|
}
|
|
@@ -17608,7 +17610,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17608
17610
|
this._width = newWidth;
|
|
17609
17611
|
this._rightHandle.x(newWidth - HANDLE_WIDTH);
|
|
17610
17612
|
this.updatePreviews();
|
|
17611
|
-
this._title.width(newWidth - 10);
|
|
17612
17613
|
}
|
|
17613
17614
|
};
|
|
17614
17615
|
SourceGroup.prototype.setWrapping = function (wrap) {
|
|
@@ -17858,19 +17859,29 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17858
17859
|
}
|
|
17859
17860
|
};
|
|
17860
17861
|
SourceGroup.prototype._createTitle = function () {
|
|
17862
|
+
var self = this;
|
|
17863
|
+
var defaultWidth;
|
|
17861
17864
|
var title = new Konva.Text({
|
|
17862
17865
|
x: 5,
|
|
17863
17866
|
y: 5,
|
|
17864
|
-
width: this._width - 10,
|
|
17865
17867
|
text: Utils.removeLineBreaks(this._source.title),
|
|
17866
17868
|
textAlign: 'left',
|
|
17867
17869
|
verticalAlign: 'middle',
|
|
17868
|
-
fontSize:
|
|
17869
|
-
fontFamily:
|
|
17870
|
+
fontSize: this._source.textFontSize,
|
|
17871
|
+
fontFamily: this._source.textFont,
|
|
17870
17872
|
fill: this._source.textColor,
|
|
17871
17873
|
wrap: 'none',
|
|
17872
17874
|
ellipsis: true,
|
|
17873
|
-
listening: false
|
|
17875
|
+
listening: false,
|
|
17876
|
+
sceneFunc: function (context, shape) {
|
|
17877
|
+
defaultWidth = defaultWidth ? defaultWidth : shape.width();
|
|
17878
|
+
shape.width(Math.min(self._width - 10, defaultWidth));
|
|
17879
|
+
if (self._source.textBackgroundColor) {
|
|
17880
|
+
context.fillStyle = self._source.textBackgroundColor;
|
|
17881
|
+
context.fillRect(-5, -5, shape.width() + 10, shape.height() ? shape.height() + 10 : 0);
|
|
17882
|
+
}
|
|
17883
|
+
shape._sceneFunc(context);
|
|
17884
|
+
}
|
|
17874
17885
|
});
|
|
17875
17886
|
return title;
|
|
17876
17887
|
};
|
|
@@ -18221,6 +18232,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18221
18232
|
SourceGroup.prototype.isDragged = function () {
|
|
18222
18233
|
return this._dragged;
|
|
18223
18234
|
};
|
|
18235
|
+
SourceGroup.prototype.isCuttable = function () {
|
|
18236
|
+
return this._source.cuttable;
|
|
18237
|
+
};
|
|
18238
|
+
SourceGroup.prototype.isDeletable = function () {
|
|
18239
|
+
return this._source.deletable;
|
|
18240
|
+
};
|
|
18224
18241
|
SourceGroup.prototype.destroy = function () {
|
|
18225
18242
|
this._group.destroy();
|
|
18226
18243
|
};
|
|
@@ -18309,11 +18326,20 @@ module.exports = function (Utils) {
|
|
|
18309
18326
|
} else if (!Utils.isValidColor(options.selectedColor)) {
|
|
18310
18327
|
throw new TypeError('peaks.sources.' + context + ': selectedColor should be a valid CSS color');
|
|
18311
18328
|
}
|
|
18329
|
+
if (Utils.isNullOrUndefined(options.textFont)) {
|
|
18330
|
+
options.textFont = 'Arial';
|
|
18331
|
+
}
|
|
18332
|
+
if (Utils.isNullOrUndefined(options.textFontSize)) {
|
|
18333
|
+
options.textFontSize = 12;
|
|
18334
|
+
}
|
|
18312
18335
|
if (Utils.isNullOrUndefined(options.textColor)) {
|
|
18313
18336
|
options.textColor = '#000000';
|
|
18314
18337
|
} else if (!Utils.isValidColor(options.textColor)) {
|
|
18315
18338
|
throw new TypeError('peaks.sources.' + context + ': textColor should be a valid CSS color');
|
|
18316
18339
|
}
|
|
18340
|
+
if (!Utils.isNullOrUndefined(options.textBackgroundColor) && !Utils.isValidColor(options.textBackgroundColor)) {
|
|
18341
|
+
throw new TypeError('peaks.sources.' + context + ': textBackgroundColor should be a valid CSS color');
|
|
18342
|
+
}
|
|
18317
18343
|
if (Utils.isNullOrUndefined(options.textPosition)) {
|
|
18318
18344
|
options.textPosition = 'bottom';
|
|
18319
18345
|
} else if (!Utils.isString(options.textPosition)) {
|
|
@@ -18340,6 +18366,16 @@ module.exports = function (Utils) {
|
|
|
18340
18366
|
} else if (!Utils.isBoolean(options.resizable)) {
|
|
18341
18367
|
throw new TypeError('peaks.sources.' + context + ': resizable must be a boolean');
|
|
18342
18368
|
}
|
|
18369
|
+
if (Utils.isNullOrUndefined(options.cuttable)) {
|
|
18370
|
+
options.cuttable = true;
|
|
18371
|
+
} else if (!Utils.isBoolean(options.cuttable)) {
|
|
18372
|
+
throw new TypeError('peaks.sources.' + context + ': cuttable must be a boolean');
|
|
18373
|
+
}
|
|
18374
|
+
if (Utils.isNullOrUndefined(options.deletable)) {
|
|
18375
|
+
options.deletable = true;
|
|
18376
|
+
} else if (!Utils.isBoolean(options.deletable)) {
|
|
18377
|
+
throw new TypeError('peaks.sources.' + context + ': deletable must be a boolean');
|
|
18378
|
+
}
|
|
18343
18379
|
if (Utils.isNullOrUndefined(options.wrapping)) {
|
|
18344
18380
|
options.wrapping = 'both';
|
|
18345
18381
|
} else if (!Utils.isString(options.wrapping)) {
|
|
@@ -18371,7 +18407,7 @@ module.exports = function (Utils) {
|
|
|
18371
18407
|
options.wrapped = false;
|
|
18372
18408
|
}
|
|
18373
18409
|
}
|
|
18374
|
-
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, resizable, wrapping, previewHeight, binaryHeight) {
|
|
18410
|
+
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight) {
|
|
18375
18411
|
var opts = {
|
|
18376
18412
|
title: title,
|
|
18377
18413
|
url: url,
|
|
@@ -18388,7 +18424,10 @@ module.exports = function (Utils) {
|
|
|
18388
18424
|
backgroundColor: backgroundColor,
|
|
18389
18425
|
borderColor: borderColor,
|
|
18390
18426
|
selectedColor: selectedColor,
|
|
18427
|
+
textFont: textFont,
|
|
18428
|
+
textFontSize: textFontSize,
|
|
18391
18429
|
textColor: textColor,
|
|
18430
|
+
textBackgroundColor: textBackgroundColor,
|
|
18392
18431
|
textPosition: textPosition,
|
|
18393
18432
|
borderWidth: borderWidth,
|
|
18394
18433
|
borderRadius: borderRadius,
|
|
@@ -18396,6 +18435,8 @@ module.exports = function (Utils) {
|
|
|
18396
18435
|
position: position,
|
|
18397
18436
|
draggable: draggable,
|
|
18398
18437
|
resizable: resizable,
|
|
18438
|
+
cuttable: cuttable,
|
|
18439
|
+
deletable: deletable,
|
|
18399
18440
|
wrapping: wrapping,
|
|
18400
18441
|
previewHeight: previewHeight,
|
|
18401
18442
|
binaryHeight: binaryHeight
|
|
@@ -18420,7 +18461,10 @@ module.exports = function (Utils) {
|
|
|
18420
18461
|
this._backgroundColor = opts.backgroundColor;
|
|
18421
18462
|
this._borderColor = opts.borderColor;
|
|
18422
18463
|
this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
|
|
18464
|
+
this._textFont = opts.textFont;
|
|
18465
|
+
this._textFontSize = opts.textFontSize;
|
|
18423
18466
|
this._textColor = opts.textColor;
|
|
18467
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
18424
18468
|
this._textPosition = opts.textPosition;
|
|
18425
18469
|
this._borderWidth = opts.borderWidth;
|
|
18426
18470
|
this._borderRadius = opts.borderRadius;
|
|
@@ -18428,6 +18472,8 @@ module.exports = function (Utils) {
|
|
|
18428
18472
|
this._position = opts.position;
|
|
18429
18473
|
this._draggable = opts.draggable;
|
|
18430
18474
|
this._resizable = opts.resizable;
|
|
18475
|
+
this._cuttable = opts.cuttable;
|
|
18476
|
+
this._deletable = opts.deletable;
|
|
18431
18477
|
this._wrapping = opts.wrapping;
|
|
18432
18478
|
this._previewHeight = opts.previewHeight;
|
|
18433
18479
|
this._binaryHeight = opts.binaryHeight;
|
|
@@ -18569,6 +18615,24 @@ module.exports = function (Utils) {
|
|
|
18569
18615
|
this._selectedColor = selectedColor;
|
|
18570
18616
|
}
|
|
18571
18617
|
},
|
|
18618
|
+
textFont: {
|
|
18619
|
+
enumerable: true,
|
|
18620
|
+
get: function () {
|
|
18621
|
+
return this._textFont;
|
|
18622
|
+
},
|
|
18623
|
+
set: function (textFont) {
|
|
18624
|
+
this._textFont = textFont;
|
|
18625
|
+
}
|
|
18626
|
+
},
|
|
18627
|
+
textFontSize: {
|
|
18628
|
+
enumerable: true,
|
|
18629
|
+
get: function () {
|
|
18630
|
+
return this._textFontSize;
|
|
18631
|
+
},
|
|
18632
|
+
set: function (textFontSize) {
|
|
18633
|
+
this._textFontSize = textFontSize;
|
|
18634
|
+
}
|
|
18635
|
+
},
|
|
18572
18636
|
textColor: {
|
|
18573
18637
|
enumerable: true,
|
|
18574
18638
|
get: function () {
|
|
@@ -18578,6 +18642,15 @@ module.exports = function (Utils) {
|
|
|
18578
18642
|
this._textColor = textColor;
|
|
18579
18643
|
}
|
|
18580
18644
|
},
|
|
18645
|
+
textBackgroundColor: {
|
|
18646
|
+
enumerable: true,
|
|
18647
|
+
get: function () {
|
|
18648
|
+
return this._textBackgroundColor;
|
|
18649
|
+
},
|
|
18650
|
+
set: function (textBackgroundColor) {
|
|
18651
|
+
this._textBackgroundColor = textBackgroundColor;
|
|
18652
|
+
}
|
|
18653
|
+
},
|
|
18581
18654
|
textPosition: {
|
|
18582
18655
|
enumerable: true,
|
|
18583
18656
|
get: function () {
|
|
@@ -18641,6 +18714,18 @@ module.exports = function (Utils) {
|
|
|
18641
18714
|
return this._resizable;
|
|
18642
18715
|
}
|
|
18643
18716
|
},
|
|
18717
|
+
cuttable: {
|
|
18718
|
+
enumerable: true,
|
|
18719
|
+
get: function () {
|
|
18720
|
+
return this._cuttable;
|
|
18721
|
+
}
|
|
18722
|
+
},
|
|
18723
|
+
deletable: {
|
|
18724
|
+
enumerable: true,
|
|
18725
|
+
get: function () {
|
|
18726
|
+
return this._deletable;
|
|
18727
|
+
}
|
|
18728
|
+
},
|
|
18644
18729
|
wrapping: {
|
|
18645
18730
|
enumerable: true,
|
|
18646
18731
|
get: function () {
|
|
@@ -18776,7 +18861,10 @@ module.exports = function (Utils) {
|
|
|
18776
18861
|
backgroundColor: this.backgroundColor,
|
|
18777
18862
|
borderColor: this.borderColor,
|
|
18778
18863
|
selectedColor: this.selectedColor,
|
|
18864
|
+
textFont: this.textFont,
|
|
18865
|
+
textFontSize: this.textFontSize,
|
|
18779
18866
|
textColor: this.textColor,
|
|
18867
|
+
textBackgroundColor: this.textBackgroundColor,
|
|
18780
18868
|
textPosition: this.textPosition,
|
|
18781
18869
|
borderWidth: this.borderWidth,
|
|
18782
18870
|
borderRadius: this.borderRadius,
|
|
@@ -18784,6 +18872,8 @@ module.exports = function (Utils) {
|
|
|
18784
18872
|
position: this.position,
|
|
18785
18873
|
draggable: this.draggable,
|
|
18786
18874
|
resizable: this.resizable,
|
|
18875
|
+
cuttable: this.cuttable,
|
|
18876
|
+
deletable: this.deletable,
|
|
18787
18877
|
wrapping: this.wrapping,
|
|
18788
18878
|
previewHeight: this.previewHeight,
|
|
18789
18879
|
binaryHeight: this.binaryHeight
|
|
@@ -18805,7 +18895,10 @@ module.exports = function (Utils) {
|
|
|
18805
18895
|
this._backgroundColor = opts.backgroundColor;
|
|
18806
18896
|
this._borderColor = opts.borderColor;
|
|
18807
18897
|
this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
|
|
18898
|
+
this._textFont = opts.textFont;
|
|
18899
|
+
this._textFontSize = opts.textFontSize;
|
|
18808
18900
|
this._textColor = opts.textColor;
|
|
18901
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
18809
18902
|
this._textPosition = opts.textPosition;
|
|
18810
18903
|
this._borderWidth = opts.borderWidth;
|
|
18811
18904
|
this._borderRadius = opts.borderRadius;
|
|
@@ -18813,6 +18906,8 @@ module.exports = function (Utils) {
|
|
|
18813
18906
|
this._position = opts.position;
|
|
18814
18907
|
this._draggable = opts.draggable;
|
|
18815
18908
|
this._resizable = opts.resizable;
|
|
18909
|
+
this._cuttable = opts.cuttable;
|
|
18910
|
+
this._deletable = opts.deletable;
|
|
18816
18911
|
this._wrapping = opts.wrapping;
|
|
18817
18912
|
this._previewHeight = opts.previewHeight;
|
|
18818
18913
|
this._binaryHeight = opts.binaryHeight;
|
|
@@ -19325,8 +19420,9 @@ module.exports = function (Utils, Konva) {
|
|
|
19325
19420
|
break;
|
|
19326
19421
|
}
|
|
19327
19422
|
var label = Utils.formatTime(secs, false);
|
|
19328
|
-
var
|
|
19329
|
-
var
|
|
19423
|
+
var measures = context.measureText(label);
|
|
19424
|
+
var labelHeight = measures.actualBoundingBoxAscent - measures.actualBoundingBoxDescent;
|
|
19425
|
+
var labelWidth = measures.width;
|
|
19330
19426
|
var labelX = x + LEFT_PADDING;
|
|
19331
19427
|
var labelY = labelHeight;
|
|
19332
19428
|
if (!this._labelIsMasked(labelX + view.getFrameOffset(), labelX + view.getFrameOffset() + labelWidth)) {
|
|
@@ -19544,7 +19640,10 @@ module.exports = function (Source, Utils) {
|
|
|
19544
19640
|
backgroundColor: sourceToCut.backgroundColor,
|
|
19545
19641
|
borderColor: sourceToCut.borderColor,
|
|
19546
19642
|
selectedColor: sourceToCut.selectedColor,
|
|
19643
|
+
textFont: sourceToCut.textFont,
|
|
19644
|
+
textFontSize: sourceToCut.textFontSize,
|
|
19547
19645
|
textColor: sourceToCut.textColor,
|
|
19646
|
+
textBackgroundColor: sourceToCut.textBackgroundColor,
|
|
19548
19647
|
textPosition: sourceToCut.textPosition,
|
|
19549
19648
|
borderWidth: sourceToCut.borderWidth,
|
|
19550
19649
|
borderRadius: sourceToCut.borderRadius,
|
|
@@ -19552,6 +19651,8 @@ module.exports = function (Source, Utils) {
|
|
|
19552
19651
|
position: sourceToCut.position,
|
|
19553
19652
|
draggable: sourceToCut.draggable,
|
|
19554
19653
|
resizable: sourceToCut.resizable,
|
|
19654
|
+
cuttable: sourceToCut.cuttable,
|
|
19655
|
+
deletable: sourceToCut.deletable,
|
|
19555
19656
|
wrapping: sourceToCut.wrapping,
|
|
19556
19657
|
previewHeight: sourceToCut.previewHeight,
|
|
19557
19658
|
binaryHeight: sourceToCut.binaryHeight
|
|
@@ -19569,7 +19670,7 @@ module.exports = function (Source, Utils) {
|
|
|
19569
19670
|
if (!Utils.isObject(options)) {
|
|
19570
19671
|
throw new TypeError('peaks.sources.add(): expected a Source object parameter');
|
|
19571
19672
|
}
|
|
19572
|
-
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textColor, options.textPosition, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.resizable, options.wrapping, options.previewHeight, options.binaryHeight);
|
|
19673
|
+
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight);
|
|
19573
19674
|
return source;
|
|
19574
19675
|
};
|
|
19575
19676
|
TimelineSources.prototype.getSources = function () {
|
package/src/line-indicator.js
CHANGED
|
@@ -140,7 +140,7 @@ define([
|
|
|
140
140
|
var textNode = new Konva.Text({
|
|
141
141
|
text: text,
|
|
142
142
|
fontSize: this._sizes.font,
|
|
143
|
-
fontFamily:
|
|
143
|
+
fontFamily: this._peaks.options.lineIndicatorFont,
|
|
144
144
|
fill: this._peaks.options.lineIndicatorTextColor,
|
|
145
145
|
align: 'center',
|
|
146
146
|
width: this._width
|
|
@@ -235,7 +235,6 @@ define([
|
|
|
235
235
|
LineIndicator.prototype.removeIndicator = function(lineId, keepInList) {
|
|
236
236
|
if (this._indicators[lineId]) {
|
|
237
237
|
if (this._indicators[lineId].indicator) {
|
|
238
|
-
console.log('remove', lineId);
|
|
239
238
|
this._indicators[lineId].indicator.destroy();
|
|
240
239
|
}
|
|
241
240
|
if (!keepInList) {
|
|
@@ -251,7 +250,8 @@ define([
|
|
|
251
250
|
if (this._indicators[lineId]) {
|
|
252
251
|
var y = this._indicators[lineId].line.getY();
|
|
253
252
|
|
|
254
|
-
if (y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0
|
|
253
|
+
if (y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0
|
|
254
|
+
&& y - this._yPadding < this._height) {
|
|
255
255
|
// The indicator is visible
|
|
256
256
|
if (!this._indicators[lineId].indicator) {
|
|
257
257
|
this._indicators[lineId].indicator = this._createIndicator(
|
package/src/main.js
CHANGED
package/src/mode-layer.js
CHANGED
|
@@ -164,7 +164,9 @@ define([
|
|
|
164
164
|
this.deselectElement(true);
|
|
165
165
|
|
|
166
166
|
if (selectedElement instanceof SourceGroup) {
|
|
167
|
-
|
|
167
|
+
if (selectedElement.isDeletable()) {
|
|
168
|
+
this._peaks.destroySource(selectedElement.getSource().id);
|
|
169
|
+
}
|
|
168
170
|
}
|
|
169
171
|
else {
|
|
170
172
|
if (selectedElement.getSegment().allowDeletion) {
|
|
@@ -183,7 +185,7 @@ define([
|
|
|
183
185
|
ModeLayer.prototype._updateCursorTime = function(mousePosition) {
|
|
184
186
|
var hoveredElement = this._view.getHoveredElement();
|
|
185
187
|
|
|
186
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
188
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
187
189
|
this._timeLabel.text(
|
|
188
190
|
Utils.formatTime(
|
|
189
191
|
this._view.pixelsToTime(mousePosition.x + this._view.getFrameOffset()),
|
|
@@ -213,7 +215,7 @@ define([
|
|
|
213
215
|
ModeLayer.prototype._updateCuttingLine = function(mousePosition) {
|
|
214
216
|
var hoveredElement = this._view.getHoveredElement();
|
|
215
217
|
|
|
216
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
218
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
217
219
|
var minSize = this._view.timeToPixels(hoveredElement.getSource().minSize);
|
|
218
220
|
|
|
219
221
|
if (hoveredElement.getWidth() >= 2 * minSize) {
|
|
@@ -279,7 +281,7 @@ define([
|
|
|
279
281
|
|
|
280
282
|
var hoveredElement = this._view.getHoveredElement();
|
|
281
283
|
|
|
282
|
-
if (hoveredElement && hoveredElement instanceof SourceGroup) {
|
|
284
|
+
if (hoveredElement && hoveredElement instanceof SourceGroup && hoveredElement.isCuttable()) {
|
|
283
285
|
var minSize = this._view.timeToPixels(hoveredElement.getSource().minSize);
|
|
284
286
|
|
|
285
287
|
if (hoveredElement.getWidth() >= 2 * minSize) {
|
|
@@ -333,7 +335,9 @@ define([
|
|
|
333
335
|
this._stage.off('click', this._onMouseClickInCutMode);
|
|
334
336
|
this._cutGroup.visible(false);
|
|
335
337
|
|
|
336
|
-
if (hoveredElement
|
|
338
|
+
if (hoveredElement
|
|
339
|
+
&& hoveredElement instanceof SourceGroup
|
|
340
|
+
&& hoveredElement.isCuttable()) {
|
|
337
341
|
hoveredElement.toggleDragging(hoveredElement.getSource().draggable);
|
|
338
342
|
hoveredElement.toggleResizing(hoveredElement.getSource().resizable);
|
|
339
343
|
}
|
|
@@ -370,7 +374,9 @@ define([
|
|
|
370
374
|
}
|
|
371
375
|
}
|
|
372
376
|
|
|
373
|
-
if (hoveredElement
|
|
377
|
+
if (hoveredElement
|
|
378
|
+
&& hoveredElement instanceof SourceGroup
|
|
379
|
+
&& hoveredElement.isCuttable()) {
|
|
374
380
|
hoveredElement.toggleDragging(false);
|
|
375
381
|
hoveredElement.toggleResizing(false);
|
|
376
382
|
}
|
package/src/source-group.js
CHANGED
|
@@ -204,9 +204,6 @@ define([
|
|
|
204
204
|
|
|
205
205
|
// update unwrap
|
|
206
206
|
this.updatePreviews();
|
|
207
|
-
|
|
208
|
-
// update wrap
|
|
209
|
-
this._title.width(newWidth - 10);
|
|
210
207
|
}
|
|
211
208
|
};
|
|
212
209
|
|
|
@@ -526,19 +523,30 @@ define([
|
|
|
526
523
|
};
|
|
527
524
|
|
|
528
525
|
SourceGroup.prototype._createTitle = function() {
|
|
526
|
+
var self = this;
|
|
527
|
+
var defaultWidth;
|
|
528
|
+
|
|
529
529
|
var title = new Konva.Text({
|
|
530
530
|
x: 5,
|
|
531
531
|
y: 5,
|
|
532
|
-
width: this._width - 10,
|
|
533
532
|
text: Utils.removeLineBreaks(this._source.title),
|
|
534
533
|
textAlign: 'left',
|
|
535
534
|
verticalAlign: 'middle',
|
|
536
|
-
fontSize:
|
|
537
|
-
fontFamily:
|
|
535
|
+
fontSize: this._source.textFontSize,
|
|
536
|
+
fontFamily: this._source.textFont,
|
|
538
537
|
fill: this._source.textColor,
|
|
539
538
|
wrap: 'none',
|
|
540
539
|
ellipsis: true,
|
|
541
|
-
listening: false
|
|
540
|
+
listening: false,
|
|
541
|
+
sceneFunc: function(context, shape) {
|
|
542
|
+
defaultWidth = defaultWidth ? defaultWidth : shape.width();
|
|
543
|
+
shape.width(Math.min(self._width - 10, defaultWidth));
|
|
544
|
+
if (self._source.textBackgroundColor) {
|
|
545
|
+
context.fillStyle = self._source.textBackgroundColor;
|
|
546
|
+
context.fillRect(-5, -5, shape.width() + 10, shape.height() ? shape.height() + 10 : 0);
|
|
547
|
+
}
|
|
548
|
+
shape._sceneFunc(context);
|
|
549
|
+
}
|
|
542
550
|
});
|
|
543
551
|
|
|
544
552
|
return title;
|
|
@@ -1003,6 +1011,14 @@ define([
|
|
|
1003
1011
|
return this._dragged;
|
|
1004
1012
|
};
|
|
1005
1013
|
|
|
1014
|
+
SourceGroup.prototype.isCuttable = function() {
|
|
1015
|
+
return this._source.cuttable;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
SourceGroup.prototype.isDeletable = function() {
|
|
1019
|
+
return this._source.deletable;
|
|
1020
|
+
};
|
|
1021
|
+
|
|
1006
1022
|
SourceGroup.prototype.destroy = function() {
|
|
1007
1023
|
this._group.destroy();
|
|
1008
1024
|
};
|
package/src/source.js
CHANGED
|
@@ -127,6 +127,14 @@ define([
|
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
if (Utils.isNullOrUndefined(options.textFont)) {
|
|
131
|
+
options.textFont = 'Arial';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (Utils.isNullOrUndefined(options.textFontSize)) {
|
|
135
|
+
options.textFontSize = 12;
|
|
136
|
+
}
|
|
137
|
+
|
|
130
138
|
if (Utils.isNullOrUndefined(options.textColor)) {
|
|
131
139
|
options.textColor = '#000000';
|
|
132
140
|
}
|
|
@@ -134,6 +142,13 @@ define([
|
|
|
134
142
|
throw new TypeError('peaks.sources.' + context + ': textColor should be a valid CSS color');
|
|
135
143
|
}
|
|
136
144
|
|
|
145
|
+
if (!Utils.isNullOrUndefined(options.textBackgroundColor)
|
|
146
|
+
&& !Utils.isValidColor(options.textBackgroundColor)) {
|
|
147
|
+
throw new TypeError(
|
|
148
|
+
'peaks.sources.' + context + ': textBackgroundColor should be a valid CSS color'
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
137
152
|
if (Utils.isNullOrUndefined(options.textPosition)) {
|
|
138
153
|
options.textPosition = 'bottom';
|
|
139
154
|
}
|
|
@@ -170,6 +185,20 @@ define([
|
|
|
170
185
|
throw new TypeError('peaks.sources.' + context + ': resizable must be a boolean');
|
|
171
186
|
}
|
|
172
187
|
|
|
188
|
+
if (Utils.isNullOrUndefined(options.cuttable)) {
|
|
189
|
+
options.cuttable = true;
|
|
190
|
+
}
|
|
191
|
+
else if (!Utils.isBoolean(options.cuttable)) {
|
|
192
|
+
throw new TypeError('peaks.sources.' + context + ': cuttable must be a boolean');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (Utils.isNullOrUndefined(options.deletable)) {
|
|
196
|
+
options.deletable = true;
|
|
197
|
+
}
|
|
198
|
+
else if (!Utils.isBoolean(options.deletable)) {
|
|
199
|
+
throw new TypeError('peaks.sources.' + context + ': deletable must be a boolean');
|
|
200
|
+
}
|
|
201
|
+
|
|
173
202
|
if (Utils.isNullOrUndefined(options.wrapping)) {
|
|
174
203
|
options.wrapping = 'both';
|
|
175
204
|
}
|
|
@@ -234,8 +263,9 @@ define([
|
|
|
234
263
|
|
|
235
264
|
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind,
|
|
236
265
|
subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor,
|
|
237
|
-
borderColor, selectedColor,
|
|
238
|
-
|
|
266
|
+
borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor,
|
|
267
|
+
textPosition, borderWidth, borderRadius, wrapped, position, draggable, resizable, cuttable,
|
|
268
|
+
deletable, wrapping, previewHeight, binaryHeight) {
|
|
239
269
|
var opts = {
|
|
240
270
|
title: title,
|
|
241
271
|
url: url,
|
|
@@ -252,7 +282,10 @@ define([
|
|
|
252
282
|
backgroundColor: backgroundColor,
|
|
253
283
|
borderColor: borderColor,
|
|
254
284
|
selectedColor: selectedColor,
|
|
285
|
+
textFont: textFont,
|
|
286
|
+
textFontSize: textFontSize,
|
|
255
287
|
textColor: textColor,
|
|
288
|
+
textBackgroundColor: textBackgroundColor,
|
|
256
289
|
textPosition: textPosition,
|
|
257
290
|
borderWidth: borderWidth,
|
|
258
291
|
borderRadius: borderRadius,
|
|
@@ -260,6 +293,8 @@ define([
|
|
|
260
293
|
position: position,
|
|
261
294
|
draggable: draggable,
|
|
262
295
|
resizable: resizable,
|
|
296
|
+
cuttable: cuttable,
|
|
297
|
+
deletable: deletable,
|
|
263
298
|
wrapping: wrapping,
|
|
264
299
|
previewHeight: previewHeight,
|
|
265
300
|
binaryHeight: binaryHeight
|
|
@@ -286,7 +321,10 @@ define([
|
|
|
286
321
|
this._backgroundColor = opts.backgroundColor;
|
|
287
322
|
this._borderColor = opts.borderColor;
|
|
288
323
|
this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
|
|
324
|
+
this._textFont = opts.textFont;
|
|
325
|
+
this._textFontSize = opts.textFontSize;
|
|
289
326
|
this._textColor = opts.textColor;
|
|
327
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
290
328
|
this._textPosition = opts.textPosition;
|
|
291
329
|
this._borderWidth = opts.borderWidth;
|
|
292
330
|
this._borderRadius = opts.borderRadius;
|
|
@@ -294,6 +332,8 @@ define([
|
|
|
294
332
|
this._position = opts.position;
|
|
295
333
|
this._draggable = opts.draggable;
|
|
296
334
|
this._resizable = opts.resizable;
|
|
335
|
+
this._cuttable = opts.cuttable;
|
|
336
|
+
this._deletable = opts.deletable;
|
|
297
337
|
this._wrapping = opts.wrapping;
|
|
298
338
|
this._previewHeight = opts.previewHeight;
|
|
299
339
|
this._binaryHeight = opts.binaryHeight;
|
|
@@ -445,6 +485,26 @@ define([
|
|
|
445
485
|
this._selectedColor = selectedColor;
|
|
446
486
|
}
|
|
447
487
|
},
|
|
488
|
+
textFont: {
|
|
489
|
+
enumerable: true,
|
|
490
|
+
get: function() {
|
|
491
|
+
return this._textFont;
|
|
492
|
+
},
|
|
493
|
+
|
|
494
|
+
set: function(textFont) {
|
|
495
|
+
this._textFont = textFont;
|
|
496
|
+
}
|
|
497
|
+
},
|
|
498
|
+
textFontSize: {
|
|
499
|
+
enumerable: true,
|
|
500
|
+
get: function() {
|
|
501
|
+
return this._textFontSize;
|
|
502
|
+
},
|
|
503
|
+
|
|
504
|
+
set: function(textFontSize) {
|
|
505
|
+
this._textFontSize = textFontSize;
|
|
506
|
+
}
|
|
507
|
+
},
|
|
448
508
|
textColor: {
|
|
449
509
|
enumerable: true,
|
|
450
510
|
get: function() {
|
|
@@ -455,6 +515,16 @@ define([
|
|
|
455
515
|
this._textColor = textColor;
|
|
456
516
|
}
|
|
457
517
|
},
|
|
518
|
+
textBackgroundColor: {
|
|
519
|
+
enumerable: true,
|
|
520
|
+
get: function() {
|
|
521
|
+
return this._textBackgroundColor;
|
|
522
|
+
},
|
|
523
|
+
|
|
524
|
+
set: function(textBackgroundColor) {
|
|
525
|
+
this._textBackgroundColor = textBackgroundColor;
|
|
526
|
+
}
|
|
527
|
+
},
|
|
458
528
|
textPosition: {
|
|
459
529
|
enumerable: true,
|
|
460
530
|
get: function() {
|
|
@@ -523,6 +593,18 @@ define([
|
|
|
523
593
|
return this._resizable;
|
|
524
594
|
}
|
|
525
595
|
},
|
|
596
|
+
cuttable: {
|
|
597
|
+
enumerable: true,
|
|
598
|
+
get: function() {
|
|
599
|
+
return this._cuttable;
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
deletable: {
|
|
603
|
+
enumerable: true,
|
|
604
|
+
get: function() {
|
|
605
|
+
return this._deletable;
|
|
606
|
+
}
|
|
607
|
+
},
|
|
526
608
|
wrapping: {
|
|
527
609
|
enumerable: true,
|
|
528
610
|
get: function() {
|
|
@@ -693,7 +775,10 @@ define([
|
|
|
693
775
|
backgroundColor: this.backgroundColor,
|
|
694
776
|
borderColor: this.borderColor,
|
|
695
777
|
selectedColor: this.selectedColor,
|
|
778
|
+
textFont: this.textFont,
|
|
779
|
+
textFontSize: this.textFontSize,
|
|
696
780
|
textColor: this.textColor,
|
|
781
|
+
textBackgroundColor: this.textBackgroundColor,
|
|
697
782
|
textPosition: this.textPosition,
|
|
698
783
|
borderWidth: this.borderWidth,
|
|
699
784
|
borderRadius: this.borderRadius,
|
|
@@ -701,6 +786,8 @@ define([
|
|
|
701
786
|
position: this.position,
|
|
702
787
|
draggable: this.draggable,
|
|
703
788
|
resizable: this.resizable,
|
|
789
|
+
cuttable: this.cuttable,
|
|
790
|
+
deletable: this.deletable,
|
|
704
791
|
wrapping: this.wrapping,
|
|
705
792
|
previewHeight: this.previewHeight,
|
|
706
793
|
binaryHeight: this.binaryHeight
|
|
@@ -725,7 +812,10 @@ define([
|
|
|
725
812
|
this._backgroundColor = opts.backgroundColor;
|
|
726
813
|
this._borderColor = opts.borderColor;
|
|
727
814
|
this._selectedColor = opts.selectedColor || Utils.shadeColor(opts.backgroundColor, 30);
|
|
815
|
+
this._textFont = opts.textFont;
|
|
816
|
+
this._textFontSize = opts.textFontSize;
|
|
728
817
|
this._textColor = opts.textColor;
|
|
818
|
+
this._textBackgroundColor = opts.textBackgroundColor;
|
|
729
819
|
this._textPosition = opts.textPosition;
|
|
730
820
|
this._borderWidth = opts.borderWidth;
|
|
731
821
|
this._borderRadius = opts.borderRadius;
|
|
@@ -733,6 +823,8 @@ define([
|
|
|
733
823
|
this._position = opts.position;
|
|
734
824
|
this._draggable = opts.draggable;
|
|
735
825
|
this._resizable = opts.resizable;
|
|
826
|
+
this._cuttable = opts.cuttable;
|
|
827
|
+
this._deletable = opts.deletable;
|
|
736
828
|
this._wrapping = opts.wrapping;
|
|
737
829
|
this._previewHeight = opts.previewHeight;
|
|
738
830
|
this._binaryHeight = opts.binaryHeight;
|
package/src/timeline-axis.js
CHANGED
|
@@ -213,9 +213,10 @@ define([
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
var label = Utils.formatTime(secs, false);
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
var measures = context.measureText(label);
|
|
217
|
+
var labelHeight = measures.actualBoundingBoxAscent
|
|
218
|
+
- measures.actualBoundingBoxDescent;
|
|
219
|
+
var labelWidth = measures.width;
|
|
219
220
|
var labelX = x + LEFT_PADDING;
|
|
220
221
|
var labelY = labelHeight;
|
|
221
222
|
|
package/src/timeline-sources.js
CHANGED
|
@@ -81,7 +81,10 @@ define([
|
|
|
81
81
|
backgroundColor: sourceToCut.backgroundColor,
|
|
82
82
|
borderColor: sourceToCut.borderColor,
|
|
83
83
|
selectedColor: sourceToCut.selectedColor,
|
|
84
|
+
textFont: sourceToCut.textFont,
|
|
85
|
+
textFontSize: sourceToCut.textFontSize,
|
|
84
86
|
textColor: sourceToCut.textColor,
|
|
87
|
+
textBackgroundColor: sourceToCut.textBackgroundColor,
|
|
85
88
|
textPosition: sourceToCut.textPosition,
|
|
86
89
|
borderWidth: sourceToCut.borderWidth,
|
|
87
90
|
borderRadius: sourceToCut.borderRadius,
|
|
@@ -89,6 +92,8 @@ define([
|
|
|
89
92
|
position: sourceToCut.position,
|
|
90
93
|
draggable: sourceToCut.draggable,
|
|
91
94
|
resizable: sourceToCut.resizable,
|
|
95
|
+
cuttable: sourceToCut.cuttable,
|
|
96
|
+
deletable: sourceToCut.deletable,
|
|
92
97
|
wrapping: sourceToCut.wrapping,
|
|
93
98
|
previewHeight: sourceToCut.previewHeight,
|
|
94
99
|
binaryHeight: sourceToCut.binaryHeight
|
|
@@ -157,7 +162,10 @@ define([
|
|
|
157
162
|
options.backgroundColor,
|
|
158
163
|
options.borderColor,
|
|
159
164
|
options.selectedColor,
|
|
165
|
+
options.textFont,
|
|
166
|
+
options.textFontSize,
|
|
160
167
|
options.textColor,
|
|
168
|
+
options.textBackgroundColor,
|
|
161
169
|
options.textPosition,
|
|
162
170
|
options.borderWidth,
|
|
163
171
|
options.borderRadius,
|
|
@@ -165,6 +173,8 @@ define([
|
|
|
165
173
|
options.position,
|
|
166
174
|
options.draggable,
|
|
167
175
|
options.resizable,
|
|
176
|
+
options.cuttable,
|
|
177
|
+
options.deletable,
|
|
168
178
|
options.wrapping,
|
|
169
179
|
options.previewHeight,
|
|
170
180
|
options.binaryHeight
|