vibe-editor 0.0.0 → 0.0.1
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/LICENSE +1 -1
- package/README.md +12 -9
- package/package.json +11 -5
- package/src/scripts/js/Core.js +212 -186
- package/src/scripts/js/MusicProcessor.js +286 -128
- package/src/scripts/js/{VerovioScoreEditor.js → VIBE.js} +62 -28
- package/src/scripts/js/assets/mei_template.js +5 -1
- package/src/scripts/js/datastructures/MeasureMatrix.js +6 -85
- package/src/scripts/js/datastructures/ScoreGraph.js +1 -1
- package/src/scripts/js/entry.js +3 -2
- package/src/scripts/js/gui/Annotations.js +188 -111
- package/src/scripts/js/gui/HarmonyLabel.js +26 -2
- package/src/scripts/js/gui/ScoreManipulator.js +61 -31
- package/src/scripts/js/gui/Tabbar.js +41 -21
- package/src/scripts/js/gui/Toolbar.js +4 -4
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +131 -60
- package/src/scripts/js/handlers/ClickModeHandler.js +406 -143
- package/src/scripts/js/handlers/CustomToolbarHandler.js +26 -24
- package/src/scripts/js/handlers/GlobalKeyboardHandler.js +12 -7
- package/src/scripts/js/handlers/InsertModeHandler.js +26 -32
- package/src/scripts/js/handlers/KeyModeHandler.js +12 -86
- package/src/scripts/js/handlers/LabelHandler.js +3 -2
- package/src/scripts/js/handlers/PhantomElementHandler.js +1 -1
- package/src/scripts/js/handlers/ScoreManipulatorHandler.js +101 -14
- package/src/scripts/js/handlers/SelectionHandler.js +80 -36
- package/src/scripts/js/handlers/SideBarHandler.js +10 -3
- package/src/scripts/js/handlers/WindowHandler.js +25 -4
- package/src/scripts/js/utils/DOMCreator.js +1 -1
- package/src/scripts/js/utils/MEIConverter.js +13 -1
- package/src/scripts/js/utils/MEIOperations.js +180 -187
- package/src/scripts/js/utils/Mouse2SVG.js +200 -43
- package/src/scripts/js/utils/ReactWrapper.js +46 -0
- package/src/scripts/js/utils/RectWrapper.js +10 -0
- package/src/scripts/js/utils/SVGEditor.js +94 -3
- package/src/scripts/js/utils/VerovioWrapper.js +6 -1
- package/src/scripts/js/utils/convenienceQueries.js +2 -0
- package/src/scripts/js/utils/mappings.js +322 -56
- package/src/styles/VerovioScoreEditor.css +0 -694
@@ -191,44 +191,46 @@ class CustomToolbarHandler {
|
|
191
191
|
oldBeam.remove();
|
192
192
|
}
|
193
193
|
meiOperation.cleanUp(this.currentMEI);
|
194
|
-
|
194
|
+
const mei = meiConverter.restoreXmlIdTags(this.currentMEI);
|
195
195
|
this.loadDataCallback("", mei, false);
|
196
196
|
}
|
197
197
|
}
|
198
198
|
/**
|
199
|
-
* Alter Notes (accid) according to button.
|
199
|
+
* Alter Notes (accid) according to button. When Button is not Selected,
|
200
200
|
* @param e
|
201
201
|
* @returns
|
202
202
|
*/
|
203
203
|
alterNotes(e) {
|
204
|
-
|
205
|
-
var accidSig;
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
204
|
+
const target = e.target;
|
205
|
+
var accidSig = "n";
|
206
|
+
if (target.classList.contains("selected")) {
|
207
|
+
switch (target.id) {
|
208
|
+
case "alterUp":
|
209
|
+
accidSig = "s";
|
210
|
+
break;
|
211
|
+
case "alterDown":
|
212
|
+
accidSig = "f";
|
213
|
+
break;
|
214
|
+
case "alterDUp":
|
215
|
+
accidSig = "ss";
|
216
|
+
break;
|
217
|
+
case "alterDDown":
|
218
|
+
accidSig = "ff";
|
219
|
+
break;
|
220
|
+
case "alterNeutral":
|
221
|
+
accidSig = "n";
|
222
|
+
break;
|
223
|
+
default:
|
224
|
+
console.error(target.id, "No such option for accid alteration");
|
225
|
+
return;
|
226
|
+
}
|
225
227
|
}
|
226
228
|
this.vrvSVG.querySelectorAll(".note.marked").forEach(nm => {
|
227
229
|
var meiElement = this.currentMEI.getElementById(nm.id);
|
228
230
|
meiElement.setAttribute("accid", accidSig);
|
229
231
|
meiElement.removeAttribute("accid.ges");
|
230
232
|
});
|
231
|
-
|
233
|
+
const mei = meiConverter.restoreXmlIdTags(this.currentMEI);
|
232
234
|
meiOperation.adjustAccids(mei);
|
233
235
|
this.loadDataCallback("", mei, false);
|
234
236
|
}
|
@@ -152,7 +152,7 @@ class GlobalKeyboardHandler {
|
|
152
152
|
});
|
153
153
|
}
|
154
154
|
/**
|
155
|
-
* Copy marked Elements
|
155
|
+
* Copy marked Elements only in active Layer (only monophonic copies are possible right now)
|
156
156
|
* @param e
|
157
157
|
*/
|
158
158
|
copyHandler(e) {
|
@@ -160,10 +160,11 @@ class GlobalKeyboardHandler {
|
|
160
160
|
return;
|
161
161
|
e.preventDefault();
|
162
162
|
this.copiedIds = new Array();
|
163
|
-
|
163
|
+
cq.getContainer(this.containerId).querySelectorAll(".activeLayer .marked").forEach(m => {
|
164
164
|
this.copiedIds.push(m.id);
|
165
165
|
});
|
166
166
|
this.copiedIds.filter(n => n); //undefined and null Elements will be excluded
|
167
|
+
console.log("Copied", this.copiedIds);
|
167
168
|
}
|
168
169
|
/**
|
169
170
|
* paste marked Elements
|
@@ -173,13 +174,15 @@ class GlobalKeyboardHandler {
|
|
173
174
|
var _a, _b;
|
174
175
|
//if(!this.hasContainerFocus()) return
|
175
176
|
//e.preventDefault()
|
176
|
-
|
177
|
-
if (this.copiedIds
|
178
|
-
|
179
|
-
|
177
|
+
const pastePosition = ((_a = this.container.querySelector(".chord.marked, .note.marked, .rest.marked, .mRest.marked")) === null || _a === void 0 ? void 0 : _a.id) || ((_b = this.container.querySelector("#cursor")) === null || _b === void 0 ? void 0 : _b.getAttribute("refId"));
|
178
|
+
if (this.copiedIds && pastePosition) {
|
179
|
+
const pasteResult = meiOperation.paste(this.copiedIds, pastePosition, this.currentMEI);
|
180
|
+
this.currentMEI = pasteResult[0];
|
181
|
+
const lastId = pasteResult[1];
|
182
|
+
const mei = meiConverter.restoreXmlIdTags(this.currentMEI);
|
180
183
|
this.loadDataCallback("", mei, false).then(mei => {
|
181
184
|
//Tell everyone that a past just occured to readjust certain elements e.g.
|
182
|
-
|
185
|
+
const pastedEvent = new CustomEvent("pasted", { detail: lastId });
|
183
186
|
document.dispatchEvent(pastedEvent);
|
184
187
|
});
|
185
188
|
}
|
@@ -323,6 +326,8 @@ class GlobalKeyboardHandler {
|
|
323
326
|
return this.container.classList.contains("activeContainer");
|
324
327
|
}
|
325
328
|
hasEditableOpen() {
|
329
|
+
if (!document.getElementById(this.containerId))
|
330
|
+
return false;
|
326
331
|
return document.getElementById(this.containerId).querySelector(".canvas *[contenteditable=true]") !== null;
|
327
332
|
}
|
328
333
|
/////// GETTER/ SETTER ///////
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.default = void 0;
|
4
|
-
const SelectionHandler_1 = require("./SelectionHandler");
|
5
4
|
const Annotations_1 = require("../gui/Annotations");
|
6
5
|
const LabelHandler_1 = require("./LabelHandler");
|
7
6
|
const KeyModeHandler_1 = require("./KeyModeHandler");
|
@@ -27,7 +26,7 @@ class InsertModeHandler {
|
|
27
26
|
this.annotations = new Annotations_1.default(containerId);
|
28
27
|
}
|
29
28
|
activateInsertMode(clicked = false) {
|
30
|
-
var _a
|
29
|
+
var _a;
|
31
30
|
if (this.annotationMode || this.harmonyMode) {
|
32
31
|
this.insertDeactivate();
|
33
32
|
}
|
@@ -42,7 +41,7 @@ class InsertModeHandler {
|
|
42
41
|
this.harmonyMode = false;
|
43
42
|
this.phantomNoteHandler = new PhantomElementHandler_1.default(this.containerId);
|
44
43
|
this.setPhantomNote();
|
45
|
-
this.clickModeHandler = this.clickModeHandler
|
44
|
+
this.clickModeHandler = this.clickModeHandler || new ClickModeHandler_1.default();
|
46
45
|
this.clickModeHandler
|
47
46
|
.setContainerId(this.containerId)
|
48
47
|
.setInsertCallback(this.insertCallback)
|
@@ -63,18 +62,9 @@ class InsertModeHandler {
|
|
63
62
|
.resetListeners();
|
64
63
|
this.deleteHandler.setListeners();
|
65
64
|
(_a = this.annotations) === null || _a === void 0 ? void 0 : _a.setm2s(this.m2s);
|
66
|
-
|
65
|
+
//this.annotations?.updateCanvas()
|
67
66
|
//this.annotations?.resetTextListeners() // annotations should also be interactable when in notation mode
|
68
|
-
this.activateSelectionMode()
|
69
|
-
}
|
70
|
-
activateSelectionMode() {
|
71
|
-
//this.insertDeactivate()
|
72
|
-
this.selectionHandler = new SelectionHandler_1.default(this.containerId);
|
73
|
-
this.selectionHandler
|
74
|
-
.setm2s(this.m2s)
|
75
|
-
.setScoreGraph(this.scoreGraph)
|
76
|
-
.resetListeners();
|
77
|
-
return this;
|
67
|
+
//this.activateSelectionMode()
|
78
68
|
}
|
79
69
|
activateAnnotationMode() {
|
80
70
|
var _a;
|
@@ -99,14 +89,17 @@ class InsertModeHandler {
|
|
99
89
|
else {
|
100
90
|
this.annotations.updateCanvas();
|
101
91
|
}
|
102
|
-
this.annotations
|
103
|
-
|
104
|
-
.setm2s(this.m2s)
|
105
|
-
.setMusicProcessor(this.musicPlayer)
|
106
|
-
.setToFront()
|
107
|
-
.setMenuClickHandler();
|
92
|
+
this.annotations.setAnnotationCanvas(cq.getInteractOverlay(this.containerId).querySelector("#annotationCanvas"));
|
93
|
+
this.annotations.updateLinkedTexts();
|
108
94
|
break;
|
109
95
|
}
|
96
|
+
this.annotations
|
97
|
+
.setContainerId(this.containerId)
|
98
|
+
.setm2s(this.m2s)
|
99
|
+
.setMusicProcessor(this.musicPlayer)
|
100
|
+
//.setToFront()
|
101
|
+
.setListeners()
|
102
|
+
.setMenuClickHandler();
|
110
103
|
}
|
111
104
|
activateHarmonyMode() {
|
112
105
|
if (this.labelHandler == undefined) {
|
@@ -159,7 +152,7 @@ class InsertModeHandler {
|
|
159
152
|
// this.selectionHandler = undefined
|
160
153
|
if (this.annotations != undefined) {
|
161
154
|
this.annotations.removeListeners();
|
162
|
-
this.annotations.setToBack()
|
155
|
+
//this.annotations.setToBack()
|
163
156
|
this.annotationMode = false;
|
164
157
|
}
|
165
158
|
if (this.labelHandler != undefined) {
|
@@ -175,15 +168,17 @@ class InsertModeHandler {
|
|
175
168
|
if (this.smHandler == undefined) {
|
176
169
|
this.smHandler = new ScoreManipulatorHandler_1.default();
|
177
170
|
}
|
171
|
+
//var activeLayer = this.container.querySelector(".activeLayer")
|
178
172
|
this.smHandler
|
179
173
|
.setContainerId(this.containerId)
|
174
|
+
.setm2s(this.m2s)
|
180
175
|
.setMEI(this.m2s.getCurrentMei())
|
181
176
|
.setMusicProcessor(this.musicPlayer)
|
182
177
|
.setLoadDataCallback(this.loadDataCallback)
|
183
178
|
.drawElements();
|
184
|
-
//
|
179
|
+
//create some more measures at start for debugging purposes
|
185
180
|
// if (this.firstCall) {
|
186
|
-
// for (let i = 0; i <
|
181
|
+
// for (let i = 0; i < 15; i++) {
|
187
182
|
// this.interactionOverlay.querySelector("#measureAdder").dispatchEvent(new MouseEvent("click"))
|
188
183
|
// }
|
189
184
|
// this.firstCall = false
|
@@ -199,8 +194,6 @@ class InsertModeHandler {
|
|
199
194
|
case "notationTabBtn":
|
200
195
|
case "articulationTabBtn":
|
201
196
|
case "clickInsert":
|
202
|
-
that.activateInsertMode(true);
|
203
|
-
break;
|
204
197
|
case "keyMode":
|
205
198
|
that.activateInsertMode(true);
|
206
199
|
break;
|
@@ -225,6 +218,9 @@ class InsertModeHandler {
|
|
225
218
|
b.addEventListener("click", function (e) {
|
226
219
|
let dur = 0;
|
227
220
|
switch (this.id) {
|
221
|
+
case "breveNote":
|
222
|
+
dur = 0.5;
|
223
|
+
break;
|
228
224
|
case "fullNote":
|
229
225
|
dur = 1;
|
230
226
|
break;
|
@@ -252,6 +248,7 @@ class InsertModeHandler {
|
|
252
248
|
}
|
253
249
|
});
|
254
250
|
});
|
251
|
+
//Sets dots according to button in dotGroup. If no Button is selected, the dots will be set to 0.
|
255
252
|
Array.from(this.container.querySelectorAll("#dotGroup > *")).forEach(b => {
|
256
253
|
b.addEventListener("click", function (e) {
|
257
254
|
let dots = 0;
|
@@ -348,9 +345,8 @@ class InsertModeHandler {
|
|
348
345
|
return this;
|
349
346
|
}
|
350
347
|
resetCanvas() {
|
351
|
-
|
352
|
-
|
353
|
-
}
|
348
|
+
var _a;
|
349
|
+
(_a = this.annotations) === null || _a === void 0 ? void 0 : _a.addCanvas().resetListeners();
|
354
350
|
return this;
|
355
351
|
}
|
356
352
|
getAnnotations() {
|
@@ -363,18 +359,16 @@ class InsertModeHandler {
|
|
363
359
|
return this.phantomNoteHandler;
|
364
360
|
}
|
365
361
|
disableNoteInput() {
|
366
|
-
var _a, _b
|
362
|
+
var _a, _b;
|
367
363
|
(_a = this.keyModeHandler) === null || _a === void 0 ? void 0 : _a.removeListeners();
|
368
364
|
(_b = this.clickModeHandler) === null || _b === void 0 ? void 0 : _b.removeListeners();
|
369
|
-
(_c = this.selectionHandler) === null || _c === void 0 ? void 0 : _c.removeListeners();
|
370
365
|
}
|
371
366
|
enableNoteInput() {
|
372
|
-
var _a, _b
|
367
|
+
var _a, _b;
|
373
368
|
if (!(this.annotationMode || this.harmonyMode)) {
|
374
369
|
(_a = this.keyModeHandler) === null || _a === void 0 ? void 0 : _a.setListeners();
|
375
370
|
(_b = this.clickModeHandler) === null || _b === void 0 ? void 0 : _b.setListeners();
|
376
371
|
}
|
377
|
-
(_c = this.selectionHandler) === null || _c === void 0 ? void 0 : _c.setListeners();
|
378
372
|
}
|
379
373
|
}
|
380
374
|
exports.default = InsertModeHandler;
|
@@ -50,10 +50,9 @@ class KeyModeHandler {
|
|
50
50
|
* Set Cursor to new position after pasting
|
51
51
|
*/
|
52
52
|
this.pastedHandler = (function pastedHandler(e) {
|
53
|
-
var _a;
|
54
53
|
console.log("PASTED ", e);
|
55
54
|
this.scoreGraph.setCurrentNodeById(e.detail);
|
56
|
-
this.cursor.definePosById(
|
55
|
+
//this.cursor.definePosById(this.scoreGraph.getCurrentNode()?.getId())
|
57
56
|
}).bind(this);
|
58
57
|
this.setContainerId(containerId);
|
59
58
|
}
|
@@ -96,73 +95,13 @@ class KeyModeHandler {
|
|
96
95
|
var pname = mappings_1.keyCodeNoteMap.get(e.code);
|
97
96
|
var oct = mappings_1.octToNum.get((_a = this.container.querySelector("#octaveGroupKM .selected")) === null || _a === void 0 ? void 0 : _a.id) || "4";
|
98
97
|
const newNote = this.createNewNote(pname, oct, null);
|
99
|
-
if (newNote
|
98
|
+
if (!newNote)
|
100
99
|
return;
|
101
100
|
this.processNewNote(newNote);
|
102
|
-
// var noteExists: Boolean = false
|
103
|
-
// var noteToDelete: Element
|
104
|
-
// if (document.getElementById(currentNode.getId()).closest(".chord") !== null) {
|
105
|
-
// var chordNotes = Array.from(document.getElementById(currentNode.getId()).closest(".chord").querySelectorAll(".note"))
|
106
|
-
// chordNotes.forEach((n: Element) => {
|
107
|
-
// var meiNote = this.m2s.getCurrentMei().getElementById(n.id)
|
108
|
-
// var sameOct = meiNote.getAttribute("oct") === newNote.oct
|
109
|
-
// var samePname = meiNote.getAttribute("pname") === newNote.pname
|
110
|
-
// if (sameOct && samePname) {
|
111
|
-
// noteExists = true
|
112
|
-
// noteToDelete = n
|
113
|
-
// }
|
114
|
-
// })
|
115
|
-
// }
|
116
|
-
// if (!noteExists) {
|
117
|
-
// // check if new note should replace a rest
|
118
|
-
// if (this.scoreGraph.getCurrentNode().getDocElement().classList.contains("rest")) {
|
119
|
-
// newNote.relPosX = "left";
|
120
|
-
// newNote.nearestNoteId = this.scoreGraph.getCurrentNode().getId()
|
121
|
-
// } else if (!this.scoreGraph.getCurrentNode()?.getDocElement().classList.contains("mRest") && this.scoreGraph.lookUp(["note", "rest", "mRest"], "right") == null && newNote.chordElement == undefined) {
|
122
|
-
// //check if new Measure must be created
|
123
|
-
// meiOperation.addMeasure(this.m2s.getCurrentMei())
|
124
|
-
// var currentStaff = this.m2s.getCurrentMei().getElementById(newNote.staffId)
|
125
|
-
// var staffN = currentStaff.getAttribute("n")
|
126
|
-
// newNote.staffId = currentStaff.closest("measure").nextElementSibling.querySelector("staff[n=\"" + staffN + "\"]").id
|
127
|
-
// newNote.relPosX = "left"
|
128
|
-
// newNote.nearestNoteId = this.m2s.getCurrentMei().querySelector("#" + newNote.staffId).querySelector("mRest").id
|
129
|
-
// } else {
|
130
|
-
// //or if ne note must be rendered into the next bar
|
131
|
-
// var oldStaffId = newNote.staffId
|
132
|
-
// if (this.m2s.getCurrentMei().querySelector("#" + newNote.nearestNoteId) === null) return
|
133
|
-
// if (this.m2s.getCurrentMei().querySelector("#" + newNote.nearestNoteId).tagName !== "mRest") {
|
134
|
-
// newNote.staffId = this.m2s.getCurrentMei().getElementById(this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")?.getId())?.closest("staff").id || newNote.staffId
|
135
|
-
// }
|
136
|
-
// if (oldStaffId !== newNote.staffId) {
|
137
|
-
// newNote.relPosX = "left"
|
138
|
-
// newNote.nearestNoteId = this.scoreGraph.getCurrentNode()?.getId()
|
139
|
-
// }
|
140
|
-
// }
|
141
|
-
// this.insertCallback(newNote, true).then(() => {
|
142
|
-
// //this.m2s.update();
|
143
|
-
// this.resetListeners()
|
144
|
-
// var currentTargetId;
|
145
|
-
// if (newNote.chordElement != undefined) {
|
146
|
-
// currentTargetId = this.vrvSVG.querySelector("#" + newNote.chordElement.id).closest(".chord").id // new chord with own ID is created, if note is added
|
147
|
-
// } else {
|
148
|
-
// currentTargetId = newNote.id
|
149
|
-
// }
|
150
|
-
// this.scoreGraph.setCurrentNodeById(currentTargetId)
|
151
|
-
// this.musicPlayer.generateTone(newNote)
|
152
|
-
// }).catch(() => {
|
153
|
-
// //alert("your bar is too small")
|
154
|
-
// })
|
155
|
-
// } else {
|
156
|
-
// this.deleteCallback([noteToDelete]).then(() => {
|
157
|
-
// //this.m2s.update();
|
158
|
-
// this.resetListeners()
|
159
|
-
// this.scoreGraph.setCurrentNodeById(newNote.chordElement?.id)
|
160
|
-
// })
|
161
|
-
// }
|
162
101
|
}
|
163
102
|
}
|
164
103
|
processNewNote(newNote) {
|
165
|
-
var _a, _b, _c, _d;
|
104
|
+
var _a, _b, _c, _d, _e, _f;
|
166
105
|
var currentNode = this.scoreGraph.getCurrentNode();
|
167
106
|
var noteExists = false;
|
168
107
|
var noteToDelete;
|
@@ -179,6 +118,7 @@ class KeyModeHandler {
|
|
179
118
|
});
|
180
119
|
}
|
181
120
|
if (!noteExists) {
|
121
|
+
var currentStaff = this.m2s.getCurrentMei().getElementById(newNote.staffId);
|
182
122
|
// check if new note should replace a rest
|
183
123
|
if (this.scoreGraph.getCurrentNode().getDocElement().classList.contains("rest")) {
|
184
124
|
newNote.relPosX = "left";
|
@@ -187,9 +127,10 @@ class KeyModeHandler {
|
|
187
127
|
else if (!((_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getDocElement().classList.contains("mRest")) && this.scoreGraph.lookUp(["note", "rest", "mRest"], "right") == null && newNote.chordElement == undefined) {
|
188
128
|
//check if new Measure must be created
|
189
129
|
meiOperation.addMeasure(this.m2s.getCurrentMei());
|
190
|
-
var currentStaff = this.m2s.getCurrentMei().getElementById(newNote.staffId);
|
191
130
|
var staffN = currentStaff.getAttribute("n");
|
192
|
-
|
131
|
+
var layerN = this.m2s.getCurrentMei().getElementById(newNote.layerId).getAttribute("n");
|
132
|
+
newNote.staffId = currentStaff.closest("measure").nextElementSibling.querySelector(`staff[n='${staffN}']`).id;
|
133
|
+
newNote.layerId = currentStaff.closest("measure").nextElementSibling.querySelector(`staff[n='${staffN}'] layer[n='${layerN}']`).id;
|
193
134
|
newNote.relPosX = "left";
|
194
135
|
newNote.nearestNoteId = this.m2s.getCurrentMei().querySelector("#" + newNote.staffId).querySelector("mRest").id;
|
195
136
|
}
|
@@ -200,10 +141,11 @@ class KeyModeHandler {
|
|
200
141
|
return;
|
201
142
|
if (this.m2s.getCurrentMei().querySelector("#" + newNote.nearestNoteId).tagName !== "mRest") {
|
202
143
|
newNote.staffId = ((_c = this.m2s.getCurrentMei().getElementById((_b = this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")) === null || _b === void 0 ? void 0 : _b.getId())) === null || _c === void 0 ? void 0 : _c.closest("staff").id) || newNote.staffId;
|
144
|
+
newNote.layerId = ((_e = this.m2s.getCurrentMei().getElementById((_d = this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")) === null || _d === void 0 ? void 0 : _d.getId())) === null || _e === void 0 ? void 0 : _e.closest("layer").id) || newNote.layerId;
|
203
145
|
}
|
204
146
|
if (oldStaffId !== newNote.staffId) {
|
205
147
|
newNote.relPosX = "left";
|
206
|
-
newNote.nearestNoteId = (
|
148
|
+
newNote.nearestNoteId = (_f = this.scoreGraph.getCurrentNode()) === null || _f === void 0 ? void 0 : _f.getId();
|
207
149
|
}
|
208
150
|
}
|
209
151
|
this.insertCallback(newNote, true).then(() => {
|
@@ -268,7 +210,7 @@ class KeyModeHandler {
|
|
268
210
|
* @returns
|
269
211
|
*/
|
270
212
|
createNewNote(pname, oct, options) {
|
271
|
-
var _a, _b, _c, _d;
|
213
|
+
var _a, _b, _c, _d, _e, _f;
|
272
214
|
//get relevant staffinfo
|
273
215
|
var nearestNodeId = (_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId();
|
274
216
|
if (nearestNodeId == undefined)
|
@@ -316,8 +258,9 @@ class KeyModeHandler {
|
|
316
258
|
nearestNoteId: nearestNodeId,
|
317
259
|
relPosX: "right",
|
318
260
|
staffId: (_c = this.vrvSVG.querySelector("#" + nearestNodeId)) === null || _c === void 0 ? void 0 : _c.closest(".staff").id,
|
261
|
+
layerId: (_e = this.container.querySelector(`#${(_d = this.vrvSVG.querySelector("#" + nearestNodeId)) === null || _d === void 0 ? void 0 : _d.closest(".staff").id} .activeLayer`)) === null || _e === void 0 ? void 0 : _e.id,
|
319
262
|
chordElement: targetChord,
|
320
|
-
rest: (
|
263
|
+
rest: (_f = this.container.querySelector("#pauseNote")) === null || _f === void 0 ? void 0 : _f.classList.contains("selected")
|
321
264
|
};
|
322
265
|
return newNote;
|
323
266
|
}
|
@@ -368,16 +311,6 @@ class KeyModeHandler {
|
|
368
311
|
* @param elementId Id of the current Element to be set in the ScoreGrap
|
369
312
|
*/
|
370
313
|
setCurrentNodeScoreGraph(elementId = null) {
|
371
|
-
// if(this.scoreGraph.getCurrentNode() == undefined || elementId === null){
|
372
|
-
// var nextEl = this.cursor.getNextElement()
|
373
|
-
// if(nextEl == undefined) return
|
374
|
-
// if(nextEl.classList.contains("staff")){
|
375
|
-
// nextEl = nextEl.querySelector(".layer")
|
376
|
-
// }
|
377
|
-
// this.scoreGraph.setCurrentNodeById(nextEl.id)
|
378
|
-
// }else if(elementId !== null){
|
379
|
-
// this.scoreGraph.setCurrentNodeById(elementId)
|
380
|
-
// }
|
381
314
|
this.scoreGraph.setCurrentNodeById(elementId);
|
382
315
|
return this;
|
383
316
|
}
|
@@ -412,13 +345,6 @@ class KeyModeHandler {
|
|
412
345
|
break;
|
413
346
|
}
|
414
347
|
currNodeId = this.scoreGraph.getCurrentNode().getId();
|
415
|
-
// if(this.vrvSVG.querySelector(".marked") === null){
|
416
|
-
// this.deleteCallback([elementToDelete]).then(() => {
|
417
|
-
// this.m2s.update();
|
418
|
-
// this.resetListeners()
|
419
|
-
// this.cursor.definePosById(currNodeId)
|
420
|
-
// })
|
421
|
-
// }
|
422
348
|
}
|
423
349
|
///// GETTER / SETTER////////////////
|
424
350
|
setm2s(m2s) {
|
@@ -101,13 +101,14 @@ class LabelHandler {
|
|
101
101
|
var rootWidth = this.rootBBox.width.toString();
|
102
102
|
var rootHeigth = this.rootBBox.height.toString();
|
103
103
|
var vb = this.interactionOverlay.getAttribute("viewBox");
|
104
|
-
|
104
|
+
this.labelCanvas = this.interactionOverlay.querySelector("#labelCanvas");
|
105
|
+
if (!this.labelCanvas) {
|
105
106
|
this.labelCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
106
107
|
this.labelCanvas.setAttribute("id", "labelCanvas");
|
107
108
|
this.labelCanvas.classList.add("canvas");
|
108
109
|
//this.labelCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "))
|
109
110
|
}
|
110
|
-
this.labelCanvas.setAttribute("viewBox", vb)
|
111
|
+
//this.labelCanvas.setAttribute("viewBox", vb)
|
111
112
|
this.interactionOverlay.insertBefore(this.labelCanvas, this.interactionOverlay.firstChild);
|
112
113
|
return this;
|
113
114
|
}
|
@@ -57,7 +57,7 @@ class PhantomElementHandler {
|
|
57
57
|
element.removeEventListener('click', this.trackMouseHandler);
|
58
58
|
clearInterval(this.trackMouseHandler);
|
59
59
|
});
|
60
|
-
if (this.phantom
|
60
|
+
if (this.phantom) {
|
61
61
|
this.phantom.removePhantomNote();
|
62
62
|
this.phantom = undefined;
|
63
63
|
}
|