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