@dawcore/components 0.0.39-next.4 → 0.0.39-next.5
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/README.md +3 -1
- package/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +139 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -436,10 +436,12 @@ Add `<daw-keyboard-shortcuts>` as a child of `<daw-editor>`:
|
|
|
436
436
|
|
|
437
437
|
| Attribute | Shortcuts |
|
|
438
438
|
|-----------|-----------|
|
|
439
|
-
| `playback` | Space (play/pause),
|
|
439
|
+
| `playback` | Space (play/pause), Escape (stop), 0 (rewind to start) |
|
|
440
440
|
| `splitting` | S (split at playhead) |
|
|
441
441
|
| `undo` | Cmd/Ctrl+Z (undo), Cmd/Ctrl+Shift+Z (redo) |
|
|
442
442
|
|
|
443
|
+
During a clip move or trim, or a track-reorder drag, undo and redo do nothing (the keys and `editor.undo()` / `redo()`), and Escape only cancels the drag: it does not also stop playback.
|
|
444
|
+
|
|
443
445
|
Custom shortcuts via JS properties: `playbackShortcuts`, `splittingShortcuts`, `undoShortcuts`, `customShortcuts`.
|
|
444
446
|
|
|
445
447
|
## CSS Theming
|
package/dist/index.d.mts
CHANGED
|
@@ -1118,12 +1118,24 @@ declare class ClipPointerHandler {
|
|
|
1118
1118
|
private _snapDeltaToSamples;
|
|
1119
1119
|
/** Returns true if a drag interaction is currently in progress. */
|
|
1120
1120
|
get isActive(): boolean;
|
|
1121
|
+
/** True once the pointer of the current press has moved past the drag
|
|
1122
|
+
* threshold: a press that has not moved is not a drag (#848). */
|
|
1123
|
+
get isDragging(): boolean;
|
|
1121
1124
|
/**
|
|
1122
1125
|
* Attempts to handle a pointerdown event on the given target element.
|
|
1123
1126
|
* Returns true if the target is a recognized clip interaction element.
|
|
1124
1127
|
*/
|
|
1125
1128
|
tryHandle(target: Element, e: PointerEvent): boolean;
|
|
1126
1129
|
private _beginDrag;
|
|
1130
|
+
/**
|
|
1131
|
+
* The press has become a drag (the pointer passed the threshold): take the
|
|
1132
|
+
* clip's bounds and open the transaction now, not at the press. An undo
|
|
1133
|
+
* made during the press (it is not a drag, so undo works) then has no
|
|
1134
|
+
* transaction to abort, and the drag that follows starts from the clip as
|
|
1135
|
+
* the undo left it, one undo step (#848, review of #915). Returns false
|
|
1136
|
+
* when the clip is gone (the undo removed it): the press is dropped.
|
|
1137
|
+
*/
|
|
1138
|
+
private _startDrag;
|
|
1127
1139
|
/** Processes pointermove events during an active drag. */
|
|
1128
1140
|
onPointerMove(e: PointerEvent): void;
|
|
1129
1141
|
/** Processes pointerup events to finalize and dispatch result events. */
|
|
@@ -2056,9 +2068,30 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
2056
2068
|
* subsequent stop-settle dispatch. */
|
|
2057
2069
|
private _withSeekSuppression;
|
|
2058
2070
|
seekTo(time: number): void;
|
|
2059
|
-
/**
|
|
2071
|
+
/**
|
|
2072
|
+
* A clip or track drag is in progress: undo and redo do nothing until it
|
|
2073
|
+
* ends (#848). A clip counts once its pointer has moved past the drag
|
|
2074
|
+
* threshold; annotation drags do not count (annotations are not in the
|
|
2075
|
+
* undo history).
|
|
2076
|
+
*/
|
|
2077
|
+
get _dragInProgress(): boolean;
|
|
2078
|
+
/**
|
|
2079
|
+
* Cancel every drag in progress, as a `pointercancel` would. Returns whether
|
|
2080
|
+
* one was. A clip or annotation press that has not moved is not a drag and
|
|
2081
|
+
* is left alone, unless `includePresses` (the editor's disconnect, which
|
|
2082
|
+
* ends every pointer interaction).
|
|
2083
|
+
*/
|
|
2084
|
+
_cancelDrags(includePresses?: boolean): boolean;
|
|
2085
|
+
/**
|
|
2086
|
+
* Escape during a drag cancels it and does nothing else: the default is
|
|
2087
|
+
* prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
|
|
2088
|
+
* does not also stop playback. No `stopPropagation`: an app's own listener
|
|
2089
|
+
* can read `defaultPrevented`.
|
|
2090
|
+
*/
|
|
2091
|
+
private _onDragEscape;
|
|
2092
|
+
/** Undo the last edit. Does nothing while a drag is in progress. */
|
|
2060
2093
|
undo(): void;
|
|
2061
|
-
/** Redo the last undone edit. */
|
|
2094
|
+
/** Redo the last undone edit. Does nothing while a drag is in progress. */
|
|
2062
2095
|
redo(): void;
|
|
2063
2096
|
/** Whether undo is available. */
|
|
2064
2097
|
get canUndo(): boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1118,12 +1118,24 @@ declare class ClipPointerHandler {
|
|
|
1118
1118
|
private _snapDeltaToSamples;
|
|
1119
1119
|
/** Returns true if a drag interaction is currently in progress. */
|
|
1120
1120
|
get isActive(): boolean;
|
|
1121
|
+
/** True once the pointer of the current press has moved past the drag
|
|
1122
|
+
* threshold: a press that has not moved is not a drag (#848). */
|
|
1123
|
+
get isDragging(): boolean;
|
|
1121
1124
|
/**
|
|
1122
1125
|
* Attempts to handle a pointerdown event on the given target element.
|
|
1123
1126
|
* Returns true if the target is a recognized clip interaction element.
|
|
1124
1127
|
*/
|
|
1125
1128
|
tryHandle(target: Element, e: PointerEvent): boolean;
|
|
1126
1129
|
private _beginDrag;
|
|
1130
|
+
/**
|
|
1131
|
+
* The press has become a drag (the pointer passed the threshold): take the
|
|
1132
|
+
* clip's bounds and open the transaction now, not at the press. An undo
|
|
1133
|
+
* made during the press (it is not a drag, so undo works) then has no
|
|
1134
|
+
* transaction to abort, and the drag that follows starts from the clip as
|
|
1135
|
+
* the undo left it, one undo step (#848, review of #915). Returns false
|
|
1136
|
+
* when the clip is gone (the undo removed it): the press is dropped.
|
|
1137
|
+
*/
|
|
1138
|
+
private _startDrag;
|
|
1127
1139
|
/** Processes pointermove events during an active drag. */
|
|
1128
1140
|
onPointerMove(e: PointerEvent): void;
|
|
1129
1141
|
/** Processes pointerup events to finalize and dispatch result events. */
|
|
@@ -2056,9 +2068,30 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
2056
2068
|
* subsequent stop-settle dispatch. */
|
|
2057
2069
|
private _withSeekSuppression;
|
|
2058
2070
|
seekTo(time: number): void;
|
|
2059
|
-
/**
|
|
2071
|
+
/**
|
|
2072
|
+
* A clip or track drag is in progress: undo and redo do nothing until it
|
|
2073
|
+
* ends (#848). A clip counts once its pointer has moved past the drag
|
|
2074
|
+
* threshold; annotation drags do not count (annotations are not in the
|
|
2075
|
+
* undo history).
|
|
2076
|
+
*/
|
|
2077
|
+
get _dragInProgress(): boolean;
|
|
2078
|
+
/**
|
|
2079
|
+
* Cancel every drag in progress, as a `pointercancel` would. Returns whether
|
|
2080
|
+
* one was. A clip or annotation press that has not moved is not a drag and
|
|
2081
|
+
* is left alone, unless `includePresses` (the editor's disconnect, which
|
|
2082
|
+
* ends every pointer interaction).
|
|
2083
|
+
*/
|
|
2084
|
+
_cancelDrags(includePresses?: boolean): boolean;
|
|
2085
|
+
/**
|
|
2086
|
+
* Escape during a drag cancels it and does nothing else: the default is
|
|
2087
|
+
* prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
|
|
2088
|
+
* does not also stop playback. No `stopPropagation`: an app's own listener
|
|
2089
|
+
* can read `defaultPrevented`.
|
|
2090
|
+
*/
|
|
2091
|
+
private _onDragEscape;
|
|
2092
|
+
/** Undo the last edit. Does nothing while a drag is in progress. */
|
|
2060
2093
|
undo(): void;
|
|
2061
|
-
/** Redo the last undone edit. */
|
|
2094
|
+
/** Redo the last undone edit. Does nothing while a drag is in progress. */
|
|
2062
2095
|
redo(): void;
|
|
2063
2096
|
/** Whether undo is available. */
|
|
2064
2097
|
get canUndo(): boolean;
|
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
module.exports = __toCommonJS(index_exports);
|
|
83
83
|
|
|
84
84
|
// <define:__INSTALL_SPECS__>
|
|
85
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.
|
|
85
|
+
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.4", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.4", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.4", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.2", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.4" };
|
|
86
86
|
|
|
87
87
|
// src/elements/daw-annotation.ts
|
|
88
88
|
var import_lit = require("lit");
|
|
@@ -306,6 +306,7 @@ var DawAnnotationTrackElement = class extends import_lit2.LitElement {
|
|
|
306
306
|
this._onKeyDownCapture = (e) => {
|
|
307
307
|
if (!this.keyboardControls) return;
|
|
308
308
|
if (e.repeat) return;
|
|
309
|
+
if (e.key === "Escape" && e.defaultPrevented) return;
|
|
309
310
|
if ((0, import_core.keyBelongsToFocusedControl)(e)) return;
|
|
310
311
|
const match = this._shortcutEntries().find((entry) => (0, import_core.matchesKeyBinding)(e, entry.binding));
|
|
311
312
|
if (!match) return;
|
|
@@ -4673,6 +4674,8 @@ var PointerHandler = class {
|
|
|
4673
4674
|
// still holds; zeroing only the host would desync the two).
|
|
4674
4675
|
this._preDragSelectionStart = 0;
|
|
4675
4676
|
this._preDragSelectionEnd = 0;
|
|
4677
|
+
/** Cancels the armed clip drag; set while one is armed (#848). */
|
|
4678
|
+
this._cancelArmedClipDrag = null;
|
|
4676
4679
|
this.onPointerDown = (e) => {
|
|
4677
4680
|
const clipHandler = this._host._clipHandler;
|
|
4678
4681
|
if (clipHandler) {
|
|
@@ -4687,12 +4690,13 @@ var PointerHandler = class {
|
|
|
4687
4690
|
console.warn("[dawcore] setPointerCapture failed: " + String(err));
|
|
4688
4691
|
}
|
|
4689
4692
|
const onMove = (me) => clipHandler.onPointerMove(me);
|
|
4690
|
-
const detach = (
|
|
4693
|
+
const detach = (pointerId) => {
|
|
4694
|
+
this._cancelArmedClipDrag = null;
|
|
4691
4695
|
this._timeline?.removeEventListener("pointermove", onMove);
|
|
4692
4696
|
this._timeline?.removeEventListener("pointerup", onUp);
|
|
4693
4697
|
this._timeline?.removeEventListener("pointercancel", onCancel);
|
|
4694
4698
|
try {
|
|
4695
|
-
this._timeline?.releasePointerCapture(
|
|
4699
|
+
this._timeline?.releasePointerCapture(pointerId);
|
|
4696
4700
|
} catch (err) {
|
|
4697
4701
|
console.warn(
|
|
4698
4702
|
"[dawcore] releasePointerCapture failed (may already be released): " + String(err)
|
|
@@ -4702,13 +4706,19 @@ var PointerHandler = class {
|
|
|
4702
4706
|
};
|
|
4703
4707
|
const onUp = (ue) => {
|
|
4704
4708
|
clipHandler.onPointerUp(ue);
|
|
4705
|
-
detach(ue);
|
|
4709
|
+
detach(ue.pointerId);
|
|
4706
4710
|
};
|
|
4707
4711
|
const downPointerId = e.pointerId;
|
|
4708
4712
|
const onCancel = (ce) => {
|
|
4709
4713
|
if (ce.pointerId !== downPointerId) return;
|
|
4710
4714
|
clipHandler.onPointerCancel(ce);
|
|
4711
|
-
detach(ce);
|
|
4715
|
+
detach(ce.pointerId);
|
|
4716
|
+
};
|
|
4717
|
+
this._cancelArmedClipDrag = () => {
|
|
4718
|
+
clipHandler.onPointerCancel(
|
|
4719
|
+
new PointerEvent("pointercancel", { pointerId: downPointerId })
|
|
4720
|
+
);
|
|
4721
|
+
detach(downPointerId);
|
|
4712
4722
|
};
|
|
4713
4723
|
this._timeline.addEventListener("pointermove", onMove);
|
|
4714
4724
|
this._timeline.addEventListener("pointerup", onUp);
|
|
@@ -4821,6 +4831,17 @@ var PointerHandler = class {
|
|
|
4821
4831
|
}
|
|
4822
4832
|
return time * h.effectiveSampleRate / h.samplesPerPixel;
|
|
4823
4833
|
}
|
|
4834
|
+
/**
|
|
4835
|
+
* Cancel an armed clip move or trim as a `pointercancel` would: the clip
|
|
4836
|
+
* handler reverts it and the timeline's listeners and pointer capture are
|
|
4837
|
+
* released. Returns whether a clip drag was armed.
|
|
4838
|
+
*/
|
|
4839
|
+
cancelClipDrag() {
|
|
4840
|
+
const cancel = this._cancelArmedClipDrag;
|
|
4841
|
+
if (!cancel) return false;
|
|
4842
|
+
cancel();
|
|
4843
|
+
return true;
|
|
4844
|
+
}
|
|
4824
4845
|
/** Detach the drag listeners and release capture — shared by the up and
|
|
4825
4846
|
* cancel terminals so a new listener added to onPointerDown can't be
|
|
4826
4847
|
* missed on one of them. */
|
|
@@ -4975,6 +4996,11 @@ var ClipPointerHandler = class {
|
|
|
4975
4996
|
get isActive() {
|
|
4976
4997
|
return this._mode !== null;
|
|
4977
4998
|
}
|
|
4999
|
+
/** True once the pointer of the current press has moved past the drag
|
|
5000
|
+
* threshold: a press that has not moved is not a drag (#848). */
|
|
5001
|
+
get isDragging() {
|
|
5002
|
+
return this._isDragging;
|
|
5003
|
+
}
|
|
4978
5004
|
/**
|
|
4979
5005
|
* Attempts to handle a pointerdown event on the given target element.
|
|
4980
5006
|
* Returns true if the target is a recognized clip interaction element.
|
|
@@ -5009,21 +5035,32 @@ var ClipPointerHandler = class {
|
|
|
5009
5035
|
this._startPx = e.clientX;
|
|
5010
5036
|
this._isDragging = false;
|
|
5011
5037
|
this._cumulativeDeltaSamples = 0;
|
|
5038
|
+
}
|
|
5039
|
+
/**
|
|
5040
|
+
* The press has become a drag (the pointer passed the threshold): take the
|
|
5041
|
+
* clip's bounds and open the transaction now, not at the press. An undo
|
|
5042
|
+
* made during the press (it is not a drag, so undo works) then has no
|
|
5043
|
+
* transaction to abort, and the drag that follows starts from the clip as
|
|
5044
|
+
* the undo left it, one undo step (#848, review of #915). Returns false
|
|
5045
|
+
* when the clip is gone (the undo removed it): the press is dropped.
|
|
5046
|
+
*/
|
|
5047
|
+
_startDrag() {
|
|
5012
5048
|
const engine = this._host.engine;
|
|
5049
|
+
const trackId = this._trackId;
|
|
5050
|
+
const clipId = this._clipId;
|
|
5013
5051
|
if (engine) {
|
|
5014
5052
|
const bounds = engine.getClipBounds(trackId, clipId);
|
|
5015
|
-
if (bounds)
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
if (engine) {
|
|
5053
|
+
if (!bounds) return false;
|
|
5054
|
+
this._originalStartSample = bounds.startSample;
|
|
5055
|
+
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5056
|
+
this._originalDurationSamples = bounds.durationSamples;
|
|
5020
5057
|
engine.beginTransaction();
|
|
5021
5058
|
} else {
|
|
5022
5059
|
console.warn(
|
|
5023
|
-
"[dawcore]
|
|
5060
|
+
"[dawcore] drag start: engine unavailable, drag mutations will not be grouped for undo"
|
|
5024
5061
|
);
|
|
5025
5062
|
}
|
|
5026
|
-
if (
|
|
5063
|
+
if (this._mode === "trim-left" || this._mode === "trim-right") {
|
|
5027
5064
|
const container = this._host.shadowRoot?.querySelector(
|
|
5028
5065
|
`.clip-container[data-clip-id="${clipId}"]`
|
|
5029
5066
|
);
|
|
@@ -5034,21 +5071,18 @@ var ClipPointerHandler = class {
|
|
|
5034
5071
|
} else {
|
|
5035
5072
|
console.warn("[dawcore] clip container not found for trim visual feedback: " + clipId);
|
|
5036
5073
|
}
|
|
5037
|
-
const engine2 = this._host.engine;
|
|
5038
|
-
if (engine2) {
|
|
5039
|
-
const bounds = engine2.getClipBounds(trackId, clipId);
|
|
5040
|
-
if (bounds) {
|
|
5041
|
-
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5042
|
-
this._originalDurationSamples = bounds.durationSamples;
|
|
5043
|
-
}
|
|
5044
|
-
}
|
|
5045
5074
|
}
|
|
5075
|
+
return true;
|
|
5046
5076
|
}
|
|
5047
5077
|
/** Processes pointermove events during an active drag. */
|
|
5048
5078
|
onPointerMove(e) {
|
|
5049
5079
|
if (this._mode === null) return;
|
|
5050
5080
|
const totalDeltaPx = e.clientX - this._startPx;
|
|
5051
5081
|
if (!this._isDragging && Math.abs(totalDeltaPx) > DRAG_THRESHOLD) {
|
|
5082
|
+
if (!this._startDrag()) {
|
|
5083
|
+
this._reset();
|
|
5084
|
+
return;
|
|
5085
|
+
}
|
|
5052
5086
|
this._isDragging = true;
|
|
5053
5087
|
if (this._boundaryEl) {
|
|
5054
5088
|
this._boundaryEl.classList.add("dragging");
|
|
@@ -5170,10 +5204,12 @@ var ClipPointerHandler = class {
|
|
|
5170
5204
|
}
|
|
5171
5205
|
}
|
|
5172
5206
|
} finally {
|
|
5173
|
-
if (this._isDragging
|
|
5174
|
-
this.
|
|
5175
|
-
|
|
5176
|
-
|
|
5207
|
+
if (this._isDragging) {
|
|
5208
|
+
if (this._cumulativeDeltaSamples !== 0) {
|
|
5209
|
+
this._host.engine?.commitTransaction();
|
|
5210
|
+
} else {
|
|
5211
|
+
this._host.engine?.abortTransaction();
|
|
5212
|
+
}
|
|
5177
5213
|
}
|
|
5178
5214
|
this._reset();
|
|
5179
5215
|
}
|
|
@@ -5191,7 +5227,7 @@ var ClipPointerHandler = class {
|
|
|
5191
5227
|
try {
|
|
5192
5228
|
this._restoreTrimVisual();
|
|
5193
5229
|
} finally {
|
|
5194
|
-
this._host.engine?.abortTransaction();
|
|
5230
|
+
if (this._isDragging) this._host.engine?.abortTransaction();
|
|
5195
5231
|
this._reset();
|
|
5196
5232
|
}
|
|
5197
5233
|
}
|
|
@@ -5363,16 +5399,35 @@ var AnnotationDragHandler = class {
|
|
|
5363
5399
|
this._onPointerCancel = (e) => {
|
|
5364
5400
|
const drag = this._drag;
|
|
5365
5401
|
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5366
|
-
|
|
5367
|
-
if (drag.mode === "ticks") {
|
|
5368
|
-
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5369
|
-
} else {
|
|
5370
|
-
applyBoundaryResults(elements, drag.snapshot);
|
|
5371
|
-
}
|
|
5372
|
-
this._teardown();
|
|
5402
|
+
this._restoreAndTeardown(drag);
|
|
5373
5403
|
};
|
|
5374
5404
|
this._host = host;
|
|
5375
5405
|
}
|
|
5406
|
+
/** True from pointerdown on an annotation until the drag ends or is cancelled. */
|
|
5407
|
+
get isActive() {
|
|
5408
|
+
return this._drag !== null;
|
|
5409
|
+
}
|
|
5410
|
+
/** True once the pointer has moved at least `DRAG_THRESHOLD` px (an edge
|
|
5411
|
+
* drag, or a box press that moved): a press that has not moved (a click on
|
|
5412
|
+
* the box) is not a drag (#848). */
|
|
5413
|
+
get isDragging() {
|
|
5414
|
+
return this._drag?.moved ?? false;
|
|
5415
|
+
}
|
|
5416
|
+
/** Cancel the drag in progress (Escape, editor disconnect): the boundaries
|
|
5417
|
+
* go back to where they were when it began (#848). */
|
|
5418
|
+
cancel() {
|
|
5419
|
+
if (this._drag) this._restoreAndTeardown(this._drag);
|
|
5420
|
+
}
|
|
5421
|
+
/** Restore the drag-start snapshot — a cancelled drag must not commit. */
|
|
5422
|
+
_restoreAndTeardown(drag) {
|
|
5423
|
+
const elements = drag.track.annotationElements;
|
|
5424
|
+
if (drag.mode === "ticks") {
|
|
5425
|
+
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5426
|
+
} else {
|
|
5427
|
+
applyBoundaryResults(elements, drag.snapshot);
|
|
5428
|
+
}
|
|
5429
|
+
this._teardown();
|
|
5430
|
+
}
|
|
5376
5431
|
_teardown() {
|
|
5377
5432
|
const drag = this._drag;
|
|
5378
5433
|
if (!drag) return;
|
|
@@ -5520,6 +5575,10 @@ var TrackReorderHandler = class _TrackReorderHandler {
|
|
|
5520
5575
|
static _reducedMotion() {
|
|
5521
5576
|
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5522
5577
|
}
|
|
5578
|
+
/** True from the grab until the drag ends or is cancelled. */
|
|
5579
|
+
get isActive() {
|
|
5580
|
+
return this._trackId !== null;
|
|
5581
|
+
}
|
|
5523
5582
|
/** Abort any in-progress drag and reset state. Called by the editor on
|
|
5524
5583
|
* disconnect — without this, a drag interrupted by editor removal (with no
|
|
5525
5584
|
* pointercancel delivered) would leave the handler wedged and silently
|
|
@@ -7823,6 +7882,16 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7823
7882
|
if (!this.trackReordering) return;
|
|
7824
7883
|
this._trackReorderDrag.onGrab(e.detail.trackId, e.detail.pointerEvent, e.detail.gripElement);
|
|
7825
7884
|
};
|
|
7885
|
+
/**
|
|
7886
|
+
* Escape during a drag cancels it and does nothing else: the default is
|
|
7887
|
+
* prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
|
|
7888
|
+
* does not also stop playback. No `stopPropagation`: an app's own listener
|
|
7889
|
+
* can read `defaultPrevented`.
|
|
7890
|
+
*/
|
|
7891
|
+
this._onDragEscape = (e) => {
|
|
7892
|
+
if (e.key !== "Escape") return;
|
|
7893
|
+
if (this._cancelDrags()) e.preventDefault();
|
|
7894
|
+
};
|
|
7826
7895
|
// --- Recording ---
|
|
7827
7896
|
this.recordingStream = null;
|
|
7828
7897
|
/** Set in togglePauseRecording when Transport is paused alongside the
|
|
@@ -8421,6 +8490,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8421
8490
|
// --- Lifecycle ---
|
|
8422
8491
|
connectedCallback() {
|
|
8423
8492
|
super.connectedCallback();
|
|
8493
|
+
window.addEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8424
8494
|
this.addEventListener("daw-track-connected", this._onTrackConnected);
|
|
8425
8495
|
this.addEventListener("daw-track-update", this._onTrackUpdate);
|
|
8426
8496
|
this.addEventListener("daw-track-control", this._onTrackControl);
|
|
@@ -8481,6 +8551,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8481
8551
|
}
|
|
8482
8552
|
disconnectedCallback() {
|
|
8483
8553
|
super.disconnectedCallback();
|
|
8554
|
+
window.removeEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8484
8555
|
this._effectsManager?.disposeAll();
|
|
8485
8556
|
this._effectsManager = null;
|
|
8486
8557
|
this.removeEventListener("daw-track-connected", this._onTrackConnected);
|
|
@@ -8496,7 +8567,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8496
8567
|
this.removeEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
8497
8568
|
this.removeEventListener("daw-track-reorder", this._onTrackReorder);
|
|
8498
8569
|
this.removeEventListener("daw-track-reorder-grab", this._onTrackReorderGrab);
|
|
8499
|
-
this.
|
|
8570
|
+
this._cancelDrags(true);
|
|
8500
8571
|
this._childObserver?.disconnect();
|
|
8501
8572
|
this._childObserver = null;
|
|
8502
8573
|
this._trackElements.clear();
|
|
@@ -9887,16 +9958,49 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9887
9958
|
})
|
|
9888
9959
|
);
|
|
9889
9960
|
}
|
|
9890
|
-
/**
|
|
9961
|
+
/**
|
|
9962
|
+
* A clip or track drag is in progress: undo and redo do nothing until it
|
|
9963
|
+
* ends (#848). A clip counts once its pointer has moved past the drag
|
|
9964
|
+
* threshold; annotation drags do not count (annotations are not in the
|
|
9965
|
+
* undo history).
|
|
9966
|
+
*/
|
|
9967
|
+
get _dragInProgress() {
|
|
9968
|
+
return this._clipPointer.isDragging || this._trackReorderDrag.isActive;
|
|
9969
|
+
}
|
|
9970
|
+
/**
|
|
9971
|
+
* Cancel every drag in progress, as a `pointercancel` would. Returns whether
|
|
9972
|
+
* one was. A clip or annotation press that has not moved is not a drag and
|
|
9973
|
+
* is left alone, unless `includePresses` (the editor's disconnect, which
|
|
9974
|
+
* ends every pointer interaction).
|
|
9975
|
+
*/
|
|
9976
|
+
_cancelDrags(includePresses = false) {
|
|
9977
|
+
let cancelled = false;
|
|
9978
|
+
if (includePresses || this._clipPointer.isDragging) {
|
|
9979
|
+
cancelled = this._pointer.cancelClipDrag() || cancelled;
|
|
9980
|
+
}
|
|
9981
|
+
if (this._trackReorderDrag.isActive) {
|
|
9982
|
+
this._trackReorderDrag.cancel();
|
|
9983
|
+
cancelled = true;
|
|
9984
|
+
}
|
|
9985
|
+
const annotation = this._annotationDrag;
|
|
9986
|
+
if (includePresses ? annotation.isActive : annotation.isDragging) {
|
|
9987
|
+
annotation.cancel();
|
|
9988
|
+
cancelled = true;
|
|
9989
|
+
}
|
|
9990
|
+
return cancelled;
|
|
9991
|
+
}
|
|
9992
|
+
/** Undo the last edit. Does nothing while a drag is in progress. */
|
|
9891
9993
|
undo() {
|
|
9994
|
+
if (this._dragInProgress) return;
|
|
9892
9995
|
if (!this._engine) {
|
|
9893
9996
|
console.warn("[dawcore] undo: engine not ready, call ignored");
|
|
9894
9997
|
return;
|
|
9895
9998
|
}
|
|
9896
9999
|
this._engine.undo();
|
|
9897
10000
|
}
|
|
9898
|
-
/** Redo the last undone edit. */
|
|
10001
|
+
/** Redo the last undone edit. Does nothing while a drag is in progress. */
|
|
9899
10002
|
redo() {
|
|
10003
|
+
if (this._dragInProgress) return;
|
|
9900
10004
|
if (!this._engine) {
|
|
9901
10005
|
console.warn("[dawcore] redo: engine not ready, call ignored");
|
|
9902
10006
|
return;
|