vibe-editor 0.0.4 → 0.0.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/package.json +65 -61
- package/src/scripts/js/Core.js +28 -9
- package/src/scripts/js/entry.js +6 -5
- package/src/scripts/js/gui/Annotations.js +27 -12
- package/src/scripts/js/gui/ScoreManipulator.js +6 -4
- package/src/scripts/js/gui/Tabbar.js +13 -4
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +13 -1
- package/src/scripts/js/handlers/InsertModeHandler.js +3 -3
- package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
- package/src/scripts/js/handlers/WindowHandler.js +7 -7
- package/src/scripts/js/scripts/Core.js +932 -0
- package/src/scripts/js/scripts/MusicProcessor.js +810 -0
- package/src/scripts/js/scripts/VIBE.js +219 -0
- package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
- package/src/scripts/js/scripts/gui/Annotations.js +549 -0
- package/src/scripts/js/scripts/gui/Cursor.js +203 -0
- package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
- package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
- package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
- package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
- package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
- package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
- package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
- package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
- package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
- package/src/scripts/js/scripts/handlers/Handler.js +2 -0
- package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
- package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
- package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
- package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
- package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +168 -0
- package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
- package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
- package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
- package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
- package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
- package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
- package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
- package/src/scripts/js/scripts/utils/Types.js +2 -0
- package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +35 -21
- package/src/scripts/js/scripts/utils/coordinates.js +54 -0
- package/src/scripts/js/utils/Mouse2SVG.js +11 -4
- package/src/scripts/js/utils/VerovioWrapper.js +4 -4
- package/src/scripts/js/utils/coordinates.js +26 -2
- package/src/scripts/js/.DS_Store +0 -0
- package/src/scripts/js/MusicPlayer.js +0 -572
- package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
- package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
- package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
- package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
- package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
- package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
- package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
- package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
- package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
- package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
- package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
- package/src/scripts/js/handlers/SelectionHandler.js +0 -262
- package/src/scripts/js/utils/RectWrapper.js +0 -10
- package/src/scripts/js/utils/SVGFiller.js +0 -245
- package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
- package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
- package/src/styles/vibe.css +0 -785
- /package/src/scripts/js/{assets → scripts/assets}/mei_template.js +0 -0
- /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +0 -0
- /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -1,407 +0,0 @@
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
2
|
-
const Cursor_1 = require("../gui/Cursor");
|
3
|
-
const mappings_1 = require("../utils/mappings");
|
4
|
-
const random_1 = require("../utils/random");
|
5
|
-
const cq = require("../utils/convenienceQueries");
|
6
|
-
const marked = "marked";
|
7
|
-
class KeyModeHandler {
|
8
|
-
constructor(containerId) {
|
9
|
-
/**
|
10
|
-
* Event handler for inserting Notes
|
11
|
-
*/
|
12
|
-
this.keyModeHandler = (function keyModeHandler(e) {
|
13
|
-
var _a;
|
14
|
-
if (!cq.hasActiveElement(this.containerId))
|
15
|
-
return;
|
16
|
-
if (this.musicPlayer.getIsPlaying() === true) {
|
17
|
-
return;
|
18
|
-
} // getIsPlaying could also be undefined
|
19
|
-
if (mappings_1.keyCodeNoteMap.has(e.code) && typeof this.cursor != undefined) {
|
20
|
-
e.preventDefault();
|
21
|
-
var pname = mappings_1.keyCodeNoteMap.get(e.code);
|
22
|
-
var oct = mappings_1.octToNum.get((_a = this.container.querySelector("#octaveGroupKM .selected")) === null || _a === void 0 ? void 0 : _a.id) || "4";
|
23
|
-
const newNote = this.createNewNote(pname, oct, null);
|
24
|
-
if (newNote == undefined)
|
25
|
-
return;
|
26
|
-
var noteExists = false;
|
27
|
-
var noteToDelete;
|
28
|
-
if (this.cursor.nextElement.classList.contains("chord")) {
|
29
|
-
var chordNotes = Array.from(this.cursor.nextElement.querySelectorAll(".note"));
|
30
|
-
chordNotes.forEach((n) => {
|
31
|
-
var meiNote = this.m2m.getCurrentMei().getElementById(n.id);
|
32
|
-
var sameOct = meiNote.getAttribute("oct") === newNote.oct;
|
33
|
-
var samePname = meiNote.getAttribute("pname") === newNote.pname;
|
34
|
-
if (sameOct && samePname) {
|
35
|
-
noteExists = true;
|
36
|
-
noteToDelete = n;
|
37
|
-
}
|
38
|
-
});
|
39
|
-
}
|
40
|
-
if (!noteExists) {
|
41
|
-
var replace = this.container.querySelector("#insertToggle").checked;
|
42
|
-
this.insertCallback(newNote, replace).then(() => {
|
43
|
-
this.m2m.update();
|
44
|
-
this.resetListeners();
|
45
|
-
var currentTargetId;
|
46
|
-
if (newNote.chordElement != undefined) {
|
47
|
-
currentTargetId = this.rootSVG.querySelector("#" + newNote.chordElement.id).closest(".chord").id; // new chord with own ID is created, if note is added
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
currentTargetId = newNote.id;
|
51
|
-
}
|
52
|
-
this.scoreGraph.setCurrentNodeById(currentTargetId);
|
53
|
-
if (this.scoreGraph.getCurrentNode() != undefined) {
|
54
|
-
this.cursor.definePosById(this.scoreGraph.getCurrentNode().getId());
|
55
|
-
}
|
56
|
-
this.musicPlayer.generateTone(newNote);
|
57
|
-
}).catch(() => {
|
58
|
-
//alert("your bar is too small")
|
59
|
-
});
|
60
|
-
}
|
61
|
-
else {
|
62
|
-
this.deleteCallback([noteToDelete]).then(() => {
|
63
|
-
var _a;
|
64
|
-
this.m2m.update();
|
65
|
-
this.resetListeners();
|
66
|
-
this.scoreGraph.setCurrentNodeById(newNote.chordElement.id);
|
67
|
-
this.cursor.definePosById((_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId());
|
68
|
-
});
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}).bind(this);
|
72
|
-
this.pressedHandler = (function pressedHandler(e) {
|
73
|
-
this.assignKeys(e);
|
74
|
-
}).bind(this);
|
75
|
-
/**
|
76
|
-
* Event Handler for any Keyboard input (except inserting)
|
77
|
-
*/
|
78
|
-
this.keyInputHandler = (function keyInputHandler(e) {
|
79
|
-
var _a, _b;
|
80
|
-
if (!cq.hasActiveElement(this.containerId))
|
81
|
-
return;
|
82
|
-
if (e.ctrlKey || e.metaKey)
|
83
|
-
return; //prevent confusion with global keyboard functionalities
|
84
|
-
if (this.interactionOverlay.querySelector("div[contenteditable=true]") !== null)
|
85
|
-
return; // prevent navigating in scrore, when label editor is open
|
86
|
-
//this.setCurrentNodeScoreGraph()
|
87
|
-
if (this.scoreGraph.getCurrentNode() == undefined) {
|
88
|
-
(_a = this.scoreGraph) === null || _a === void 0 ? void 0 : _a.setCurrentNodeById((_b = this.cursor) === null || _b === void 0 ? void 0 : _b.getNextElement().id);
|
89
|
-
}
|
90
|
-
if (e.shiftKey && e.key.includes("Arrow")) {
|
91
|
-
e.preventDefault();
|
92
|
-
this.navigateSelection(e.key);
|
93
|
-
}
|
94
|
-
else if (e.key.includes("Arrow")) {
|
95
|
-
e.preventDefault();
|
96
|
-
this.endSelection();
|
97
|
-
this.navigateCursor(e.key);
|
98
|
-
}
|
99
|
-
else if (["Delete", "Backspace"].indexOf(e.key) > -1) {
|
100
|
-
e.preventDefault();
|
101
|
-
//this.deleteByKey(e.key)
|
102
|
-
}
|
103
|
-
}).bind(this);
|
104
|
-
/**
|
105
|
-
* Set Cursor to new position after pasting
|
106
|
-
*/
|
107
|
-
this.pastedHandler = (function pastedHandler(e) {
|
108
|
-
var _a;
|
109
|
-
console.log("PASTED ", e);
|
110
|
-
this.scoreGraph.setCurrentNodeById(e.detail);
|
111
|
-
this.cursor.definePosById((_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId());
|
112
|
-
}).bind(this);
|
113
|
-
this.setContainerId(containerId);
|
114
|
-
this.cursor = new Cursor_1.default(containerId);
|
115
|
-
}
|
116
|
-
setListeners() {
|
117
|
-
document.addEventListener("keydown", this.pressedHandler);
|
118
|
-
document.addEventListener("keyup", this.pressedHandler);
|
119
|
-
document.addEventListener('keydown', this.keyModeHandler);
|
120
|
-
document.addEventListener('keydown', this.keyInputHandler);
|
121
|
-
document.addEventListener("pasted", this.pastedHandler);
|
122
|
-
this.cursor.setClickListener();
|
123
|
-
}
|
124
|
-
removeListeners() {
|
125
|
-
document.removeEventListener("keydown", this.pressedHandler);
|
126
|
-
document.removeEventListener("keyup", this.pressedHandler);
|
127
|
-
document.removeEventListener('keydown', this.keyModeHandler);
|
128
|
-
document.removeEventListener('keydown', this.keyInputHandler);
|
129
|
-
document.removeEventListener("pasted", this.pastedHandler);
|
130
|
-
this.cursor.flashStop();
|
131
|
-
this.cursor.removeClickListener();
|
132
|
-
}
|
133
|
-
resetListeners() {
|
134
|
-
this.removeListeners();
|
135
|
-
this.setListeners();
|
136
|
-
}
|
137
|
-
assignKeys(e) {
|
138
|
-
var b = false;
|
139
|
-
if (e.type === "keydown") {
|
140
|
-
b = true;
|
141
|
-
}
|
142
|
-
else if (e.type === "keyup") {
|
143
|
-
b = false;
|
144
|
-
}
|
145
|
-
switch (e.key) {
|
146
|
-
case "Shift":
|
147
|
-
this.shiftDown = b;
|
148
|
-
break;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
/**
|
152
|
-
* create a newNote
|
153
|
-
* @param pname pitch name
|
154
|
-
* @param oct octave
|
155
|
-
* @param options
|
156
|
-
* @returns
|
157
|
-
*/
|
158
|
-
createNewNote(pname, oct, options) {
|
159
|
-
var _a, _b;
|
160
|
-
//get relevant staffinfo
|
161
|
-
this.setCurrentNodeScoreGraph();
|
162
|
-
var nearestNodeId = (_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId();
|
163
|
-
if (nearestNodeId == undefined)
|
164
|
-
return;
|
165
|
-
var closestStaff = ((_b = this.m2m.getCurrentMei().getElementById(nearestNodeId)) === null || _b === void 0 ? void 0 : _b.closest("staff")) || this.m2m.getCurrentMei().querySelector("measure > staff"); //asume first measure first staff
|
166
|
-
var closestMeasure = closestStaff.closest("measure");
|
167
|
-
var closestStaffIdx = parseInt(closestStaff.getAttribute("n")) - 1;
|
168
|
-
var closestMeasureIdx = parseInt(closestMeasure.getAttribute("n")) - 1;
|
169
|
-
var keysig = this.m2m.getMeasureMatrix().get(closestMeasureIdx, closestStaffIdx).keysig;
|
170
|
-
var accids;
|
171
|
-
var accid;
|
172
|
-
if (keysig == undefined) {
|
173
|
-
accids = mappings_1.keysigToNotes.get(keysig);
|
174
|
-
accids = accids.filter((s) => { return s === pname; });
|
175
|
-
if (accids.length === 1) {
|
176
|
-
accid = keysig.charAt(1);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
var targetChord;
|
180
|
-
//if(this.container.querySelector("#chordButton")?.classList.contains("selected")){
|
181
|
-
if (this.shiftDown) {
|
182
|
-
targetChord = this.rootSVG.querySelector("#" + nearestNodeId);
|
183
|
-
if ((targetChord === null || targetChord === void 0 ? void 0 : targetChord.closest(".chord")) !== null) {
|
184
|
-
targetChord = targetChord.closest(".chord");
|
185
|
-
}
|
186
|
-
}
|
187
|
-
var relPosX = this.cursor.isBOL() ? "left" : "right";
|
188
|
-
this.setContainerId(this.containerId);
|
189
|
-
var newNote = {
|
190
|
-
pname: pname,
|
191
|
-
id: random_1.uuidv4(),
|
192
|
-
dur: this.m2m.getDurationNewNote(),
|
193
|
-
dots: this.m2m.getDotsNewNote(),
|
194
|
-
oct: oct,
|
195
|
-
keysig: keysig,
|
196
|
-
accid: accid,
|
197
|
-
nearestNoteId: nearestNodeId,
|
198
|
-
relPosX: relPosX,
|
199
|
-
staffId: this.rootSVG.querySelector("#" + nearestNodeId).closest(".staff").id,
|
200
|
-
chordElement: targetChord,
|
201
|
-
rest: this.container.querySelector("#pauseNote").classList.contains("selected")
|
202
|
-
};
|
203
|
-
return newNote;
|
204
|
-
}
|
205
|
-
/**
|
206
|
-
* Navigate through Scoregraph with Arrow Keys
|
207
|
-
* @param direction Key Code for Arrows
|
208
|
-
*/
|
209
|
-
navigateCursor(direction) {
|
210
|
-
var _a, _b, _c, _d, _e;
|
211
|
-
var prevNode = this.scoreGraph.getCurrentNode();
|
212
|
-
var container = document.getElementById(this.containerId);
|
213
|
-
this.rootSVG.querySelectorAll(".marked").forEach(m => m.classList.remove("marked"));
|
214
|
-
var cbs = (_a = container.querySelector("#chordButton")) === null || _a === void 0 ? void 0 : _a.classList.contains("selected");
|
215
|
-
if (cbs) {
|
216
|
-
this.scoreGraph.nextClass(["chord", "note"], direction);
|
217
|
-
}
|
218
|
-
else {
|
219
|
-
switch (direction) {
|
220
|
-
case "ArrowLeft":
|
221
|
-
(_b = document.querySelectorAll(".lastAdded")) === null || _b === void 0 ? void 0 : _b.forEach(la => la.classList.remove("lastAdded"));
|
222
|
-
this.scoreGraph.nextLeft();
|
223
|
-
break;
|
224
|
-
case "ArrowRight":
|
225
|
-
(_c = document.querySelectorAll(".lastAdded")) === null || _c === void 0 ? void 0 : _c.forEach(la => la.classList.remove("lastAdded"));
|
226
|
-
this.scoreGraph.nextRight();
|
227
|
-
break;
|
228
|
-
// case "ArrowUp":
|
229
|
-
// this.scoreGraph.nextUp()
|
230
|
-
// break;
|
231
|
-
// case "ArrowDown":
|
232
|
-
// this.scoreGraph.nextDown()
|
233
|
-
// break;
|
234
|
-
}
|
235
|
-
}
|
236
|
-
if (this.scoreGraph.getCurrentNode() == undefined)
|
237
|
-
return;
|
238
|
-
(_d = this.rootSVG.querySelector("#" + prevNode.getId())) === null || _d === void 0 ? void 0 : _d.classList.remove("marked");
|
239
|
-
this.cursor.definePosById(this.scoreGraph.getCurrentNode().getId());
|
240
|
-
(_e = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getId())) === null || _e === void 0 ? void 0 : _e.classList.add("marked");
|
241
|
-
if (this.scoreGraph.getCurrentNode().getId().indexOf("BOL") === -1) {
|
242
|
-
this.setCurrentNodeScoreGraph(this.scoreGraph.getCurrentNode().getId());
|
243
|
-
}
|
244
|
-
}
|
245
|
-
// navigateSelection(direction: string){
|
246
|
-
// if(typeof this.startSelect === "undefined"){
|
247
|
-
// this.startSelect = document.getElementById(this.scoreGraph.getCurrentNode().getId()).getBoundingClientRect()
|
248
|
-
// }
|
249
|
-
// this.navigateCursor(direction)
|
250
|
-
// if(this.selectRect == undefined){
|
251
|
-
// this.selectRect = document.createElementNS(c._SVGNS_, "rect")
|
252
|
-
// this.selectRect.setAttribute("id", "keyModeSelectRect")
|
253
|
-
// document.getElementById("canvasG").appendChild(this.selectRect)
|
254
|
-
// }
|
255
|
-
// var cursorPos = this.cursor.getPos() //document.getElementById("cursor").getBoundingClientRect()
|
256
|
-
// var startSelectX = coord.adjustToPage(this.startSelect.left, "x")
|
257
|
-
// var cursorX = cursorPos.x
|
258
|
-
// var startSelectY = coord.adjustToPage(this.startSelect.top, "y") + window.pageYOffset
|
259
|
-
// var cursorY = cursorPos.y //+ window.pageYOffset
|
260
|
-
// if(cursorX < startSelectX){ // draw rect to right
|
261
|
-
// this.selectRect.setAttribute("x", cursorX.toString())
|
262
|
-
// this.selectRect.setAttribute("width", Math.abs(cursorX - startSelectX).toString())
|
263
|
-
// }else{ // else right
|
264
|
-
// this.selectRect.setAttribute("x", startSelectX.toString())
|
265
|
-
// this.selectRect.setAttribute("width", Math.abs(coord.adjustToPage(this.startSelect.left, "x") - cursorX).toString())
|
266
|
-
// }
|
267
|
-
// if(cursorY < startSelectY){ // draw rect to top
|
268
|
-
// this.selectRect.setAttribute("y", cursorY.toString())
|
269
|
-
// //this.selectRect.setAttribute("height", Math.abs(cursorPos.y - coord.adjustToPage(this.startSelect.top, "y")).toString())
|
270
|
-
// this.selectRect.setAttribute("height", Math.abs(cursorY - startSelectY).toString())
|
271
|
-
// //console.log(cursorY, startSelectY, this.selectRect.getAttribute("height"))
|
272
|
-
// }else{ // else bottom
|
273
|
-
// this.selectRect.setAttribute("y", startSelectY.toString())
|
274
|
-
// this.selectRect.setAttribute("height", Math.abs(coord.adjustToPage(this.startSelect.bottom, "y") - cursorY).toString())
|
275
|
-
// //this.selectRect.setAttribute("height", Math.abs(coord.adjustToPage(this.startSelect.top, "y") - coord.adjustToPage(cursorPos.y, "y")).toString())
|
276
|
-
// //console.log(cursorY, startSelectY, this.selectRect.getAttribute("height"))
|
277
|
-
// }
|
278
|
-
// var rectBBox = this.selectRect.getBoundingClientRect()
|
279
|
-
// var rx = rectBBox.x + window.pageXOffset //accomodate for scrolling
|
280
|
-
// var ry = rectBBox.y + window.pageYOffset
|
281
|
-
// this.m2m.getNoteBBoxes().forEach(bb => {
|
282
|
-
// var note = document.getElementById(bb.id)
|
283
|
-
// let stem = note.querySelector(".stem") as HTMLElement
|
284
|
-
// if( bb.x >= rx &&
|
285
|
-
// bb.x <= rx + rectBBox.width &&
|
286
|
-
// bb.y >= ry &&
|
287
|
-
// bb.y <= ry + rectBBox.height) {
|
288
|
-
// note.classList.add(marked)
|
289
|
-
// if(stem !== null) stem.classList.add(marked)
|
290
|
-
// var chord = note.closest(".chord")
|
291
|
-
// if(chord !== null){
|
292
|
-
// if(!chord.classList.contains(marked)) chord.classList.add(marked)
|
293
|
-
// }
|
294
|
-
// }else{
|
295
|
-
// note.classList.remove(marked)
|
296
|
-
// if(stem !== null) stem.classList.remove(marked)
|
297
|
-
// var chord = note.closest(".chord")
|
298
|
-
// if(chord !== null) chord.classList.remove(marked)
|
299
|
-
// }
|
300
|
-
// })
|
301
|
-
// }
|
302
|
-
/**
|
303
|
-
* End selection in Keyboardmode
|
304
|
-
*/
|
305
|
-
endSelection() {
|
306
|
-
this.startSelect = undefined;
|
307
|
-
if (this.selectRect !== null && typeof this.selectRect !== "undefined") {
|
308
|
-
this.selectRect.remove();
|
309
|
-
this.rootSVG.querySelectorAll(".marked").forEach(m => {
|
310
|
-
m.classList.remove("marked");
|
311
|
-
});
|
312
|
-
}
|
313
|
-
this.selectRect = undefined;
|
314
|
-
}
|
315
|
-
/**
|
316
|
-
*
|
317
|
-
* @param elementId Id of the current Element to be set in the ScoreGrap
|
318
|
-
*/
|
319
|
-
setCurrentNodeScoreGraph(elementId = null) {
|
320
|
-
if (this.scoreGraph.getCurrentNode() == undefined || elementId === null) {
|
321
|
-
var nextEl = this.cursor.getNextElement();
|
322
|
-
if (nextEl == undefined)
|
323
|
-
return;
|
324
|
-
if (nextEl.classList.contains("staff")) {
|
325
|
-
nextEl = nextEl.querySelector(".layer");
|
326
|
-
}
|
327
|
-
this.scoreGraph.setCurrentNodeById(nextEl.id);
|
328
|
-
}
|
329
|
-
else if (elementId !== null) {
|
330
|
-
this.scoreGraph.setCurrentNodeById(elementId);
|
331
|
-
}
|
332
|
-
return this;
|
333
|
-
}
|
334
|
-
/**
|
335
|
-
* Delete next element depending on Keyboad input (Backspace: left, Delete: right)
|
336
|
-
* @param key "Backspace" or "Delete"
|
337
|
-
*/
|
338
|
-
deleteByKey(key) {
|
339
|
-
var _a, _b;
|
340
|
-
var elementToDelete;
|
341
|
-
var currNodeId;
|
342
|
-
var isFocusedChord = ((_a = this.container.querySelector("#chordButton")) === null || _a === void 0 ? void 0 : _a.classList.contains("selected")) ? true : false;
|
343
|
-
if (isFocusedChord) {
|
344
|
-
key = "Backspace";
|
345
|
-
}
|
346
|
-
switch (key) {
|
347
|
-
case "Delete":
|
348
|
-
//elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getRight().getId())
|
349
|
-
//break;
|
350
|
-
case "Backspace":
|
351
|
-
elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getId());
|
352
|
-
if (this.scoreGraph.getCurrentNode().isLayer()) {
|
353
|
-
elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getLeft().getId());
|
354
|
-
this.navigateCursor("ArrowLeft");
|
355
|
-
}
|
356
|
-
if (!((_b = this.scoreGraph.getCurrentNode().getLeft()) === null || _b === void 0 ? void 0 : _b.isBOL())) {
|
357
|
-
this.navigateCursor("ArrowLeft");
|
358
|
-
}
|
359
|
-
else {
|
360
|
-
this.navigateCursor("ArrowRight");
|
361
|
-
}
|
362
|
-
break;
|
363
|
-
}
|
364
|
-
currNodeId = this.scoreGraph.getCurrentNode().getId();
|
365
|
-
// if(this.rootSVG.querySelector(".marked") === null){
|
366
|
-
// this.deleteCallback([elementToDelete]).then(() => {
|
367
|
-
// this.m2m.update();
|
368
|
-
// this.resetListeners()
|
369
|
-
// this.cursor.definePosById(currNodeId)
|
370
|
-
// })
|
371
|
-
// }
|
372
|
-
}
|
373
|
-
///// GETTER / SETTER////////////////
|
374
|
-
setM2M(m2m) {
|
375
|
-
this.m2m = m2m;
|
376
|
-
this.cursor.setM2M(m2m);
|
377
|
-
return this;
|
378
|
-
}
|
379
|
-
setMusicPlayer(musicPlayer) {
|
380
|
-
this.musicPlayer = musicPlayer;
|
381
|
-
return this;
|
382
|
-
}
|
383
|
-
setScoreGraph(scoreGraph) {
|
384
|
-
this.scoreGraph = scoreGraph;
|
385
|
-
return this;
|
386
|
-
}
|
387
|
-
setCurrentMEI(mei) {
|
388
|
-
this.currentMEI = mei;
|
389
|
-
return this;
|
390
|
-
}
|
391
|
-
setContainerId(id) {
|
392
|
-
this.containerId = id;
|
393
|
-
this.rootSVG = cq.getRootSVG(id);
|
394
|
-
this.interactionOverlay = cq.getInteractOverlay(id);
|
395
|
-
this.container = document.getElementById(id);
|
396
|
-
return this;
|
397
|
-
}
|
398
|
-
setInsertCallback(insertCallback) {
|
399
|
-
this.insertCallback = insertCallback;
|
400
|
-
return this;
|
401
|
-
}
|
402
|
-
setDeleteCallback(deleteCallback) {
|
403
|
-
this.deleteCallback = deleteCallback;
|
404
|
-
return this;
|
405
|
-
}
|
406
|
-
}
|
407
|
-
exports.default = KeyModeHandler;
|