vibe-editor 0.0.1-dev → 0.0.2

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 (32) hide show
  1. package/README.md +5 -0
  2. package/package.json +3 -3
  3. package/src/scripts/js/Core.js +14 -14
  4. package/src/scripts/js/VIBE.js +3 -1
  5. package/src/scripts/js/assets/mei_template.js +2 -2
  6. package/src/scripts/js/datastructures/ScoreGraph copy.js +432 -0
  7. package/src/scripts/js/datastructures/ScoreGraph.js +92 -47
  8. package/src/scripts/js/datastructures/ScoreGraph_deprecated.js +432 -0
  9. package/src/scripts/js/datastructures/ScoreNode.js +4 -0
  10. package/src/scripts/js/entry.js +2 -2
  11. package/src/scripts/js/gui/Annotations.js +4 -3
  12. package/src/scripts/js/gui/HarmonyLabel.js +1 -1
  13. package/src/scripts/js/gui/ScoreManipulator.js +7 -7
  14. package/src/scripts/js/gui/Tabbar.js +9 -8
  15. package/src/scripts/js/gui/TempoLabel.js +1 -1
  16. package/src/scripts/js/gui/Toolbar.js +1 -1
  17. package/src/scripts/js/handlers/AnnotationChangeHandler.js +3 -3
  18. package/src/scripts/js/handlers/ClickModeHandler.js +10 -3
  19. package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +2 -2
  20. package/src/scripts/js/handlers/CustomToolbarHandler.js +4 -4
  21. package/src/scripts/js/handlers/InsertModeHandler.js +7 -4
  22. package/src/scripts/js/handlers/KeyModeHandler.js +40 -17
  23. package/src/scripts/js/handlers/LabelHandler.js +3 -2
  24. package/src/scripts/js/handlers/NoteDragHandler.js +1 -1
  25. package/src/scripts/js/handlers/ScoreManipulatorHandler.js +11 -0
  26. package/src/scripts/js/handlers/SideBarHandler.js +1 -1
  27. package/src/scripts/js/handlers/TooltipHandler.js +1 -1
  28. package/src/scripts/js/utils/MEIOperations.js +28 -25
  29. package/src/scripts/js/utils/Mouse2SVG.js +10 -8
  30. package/src/scripts/js/utils/ReactWrapper.js +1 -1
  31. package/src/scripts/js/utils/SVGEditor.js +15 -5
  32. package/src/scripts/js/utils/mappings.js +17 -14
@@ -67,7 +67,7 @@ class ScoreManipulator {
67
67
  }
68
68
  drawMeasureManipulators() {
69
69
  this.lastBline = Array.from(this.vrvSVG.querySelectorAll(".barLine")).reverse()[0].querySelector("path");
70
- var lastBlineRect = coordinates_1.getDOMMatrixCoordinates(this.lastBline, this.vrvSVG);
70
+ var lastBlineRect = (0, coordinates_1.getDOMMatrixCoordinates)(this.lastBline, this.vrvSVG);
71
71
  var blineTopAdder = lastBlineRect.top;
72
72
  var blineTopRemover = lastBlineRect.top + lastBlineRect.height / 2;
73
73
  var blineRight = lastBlineRect.right;
@@ -111,10 +111,10 @@ class ScoreManipulator {
111
111
  this.vrvSVG.querySelectorAll(".page").forEach(p => {
112
112
  p.querySelector(".measure").querySelectorAll(".staff").forEach(staff => {
113
113
  var _a;
114
- var bbox = coordinates_1.getDOMMatrixCoordinates(staff.querySelector(".staffLine"), this.vrvSVG); //staff.querySelector(".staffLine").getBoundingClientRect()
114
+ var bbox = (0, coordinates_1.getDOMMatrixCoordinates)(staff.querySelector(".staffLine"), this.vrvSVG); //staff.querySelector(".staffLine").getBoundingClientRect()
115
115
  var x = bbox.left; //- rootBBox.x
116
116
  var yTop = bbox.top; //- rootBBox.y
117
- var yBottom = coordinates_1.getDOMMatrixCoordinates(Array.from(staff.querySelectorAll(".staffLine")).reverse()[0], this.vrvSVG).bottom; //Array.from(staff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom - rootBBox.y
117
+ var yBottom = (0, coordinates_1.getDOMMatrixCoordinates)(Array.from(staff.querySelectorAll(".staffLine")).reverse()[0], this.vrvSVG).bottom; //Array.from(staff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom - rootBBox.y
118
118
  var staffHeight = (yBottom - yTop);
119
119
  yTop -= staffHeight * 0.20; // center the boxes
120
120
  var btnHeight = (staffHeight / 4) * 1.5;
@@ -155,18 +155,18 @@ class ScoreManipulator {
155
155
  var width;
156
156
  var height;
157
157
  if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1) {
158
- bbox = coordinates_1.getDOMMatrixCoordinates(referenceStaff, this.vrvSVG); //referenceStaff.querySelector(".staffLine").getBoundingClientRect()
158
+ bbox = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff, this.vrvSVG); //referenceStaff.querySelector(".staffLine").getBoundingClientRect()
159
159
  x = bbox.left;
160
160
  yTop = bbox.top;
161
- yBottom = coordinates_1.getDOMMatrixCoordinates(Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0], this.vrvSVG).bottom; //Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom
161
+ yBottom = (0, coordinates_1.getDOMMatrixCoordinates)(Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0], this.vrvSVG).bottom; //Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom
162
162
  }
163
163
  else {
164
- bbox = bbox = coordinates_1.getDOMMatrixCoordinates(referenceStaff.querySelector(".clef"), this.vrvSVG); //referenceStaff.querySelector(".clef").getBoundingClientRect()
164
+ bbox = bbox = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff.querySelector(".clef"), this.vrvSVG); //referenceStaff.querySelector(".clef").getBoundingClientRect()
165
165
  x = bbox.left;
166
166
  yTop = bbox.top;
167
167
  yBottom = bbox.bottom;
168
168
  }
169
- const clefCoords = coordinates_1.getDOMMatrixCoordinates(referenceStaff.querySelector(".clef"), this.vrvSVG);
169
+ const clefCoords = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff.querySelector(".clef"), this.vrvSVG);
170
170
  //height = referenceStaff.querySelector(".clef").getBoundingClientRect().height
171
171
  //width = referenceStaff.querySelector(".clef").getBoundingClientRect().width
172
172
  return { x: x, yTop: yTop, yBottom: yBottom, width: clefCoords.width, height: clefCoords.height };
@@ -41,7 +41,7 @@ class Tabbar {
41
41
  }
42
42
  }).bind(this);
43
43
  /**
44
- * MAke Buttons in Toolbar selectable exclusively
44
+ * Make Buttons in Toolbar selectable exclusively
45
45
  */
46
46
  this.exclusiveSelectHandler = (function exclusiveSelectHandler(e) {
47
47
  this.exclusiveSelect(e);
@@ -342,6 +342,7 @@ class Tabbar {
342
342
  this.accidButtonGroup.appendChild(dc.makeNewButton("&#x1D12B", "alterDDown", buttonStyleDarkOutline + " " + smuflFont + " " + alterBtn, "", true));
343
343
  this.accidButtonGroup.appendChild(dc.makeNewButton("&#x1D12A", "alterDUp", buttonStyleDarkOutline + " " + smuflFont + " " + alterBtn, "", true));
344
344
  this.accidButtonGroup.addEventListener("click", this.exclusiveSelectHandler);
345
+ this.createArticulationButtons();
345
346
  this.soundGroup = cq.getContainer(this.containerId).querySelector("#soundGroup");
346
347
  this.soundGroup.appendChild(dc.makeNewButton("", "playBtn", buttonStyleDarkOutline));
347
348
  //this.soundGroup.appendChild(dc.makeNewButton("", "pauseBtn", buttonStyleDarkOutline))
@@ -426,13 +427,13 @@ class Tabbar {
426
427
  this.annotGroupKM.append(dc.makeNewButton("Harmony", "harmonyAnnotButton", buttonStyleDarkOutline));
427
428
  this.annotGroupKM.addEventListener("click", this.exclusiveSelectHandler);
428
429
  }
429
- createArticualtionButtons() {
430
- this.articGroup = dc.makeNewDiv("articGroup", "customGroup btn-group-md me-2 h-100", { role: "group" });
430
+ createArticulationButtons() {
431
+ this.articGroup = cq.getContainer(this.containerId).querySelector("#articGroup"); //dc.makeNewDiv("articGroup", "customGroup btn-group-md me-2 h-100", { role: "group" }) as HTMLElement
431
432
  this.articGroup.append(dc.makeNewButton(".", "staccatoBtn", buttonStyleDarkOutline));
432
433
  this.articGroup.append(dc.makeNewButton("_", "tenutoBtn", buttonStyleDarkOutline));
433
434
  this.articGroup.append(dc.makeNewButton("𝅿", "marcatoBtn", buttonStyleDarkOutline + " " + smuflFont, "", true));
434
435
  this.articGroup.append(dc.makeNewButton("𝅻", "accentBtn", buttonStyleDarkOutline + " " + smuflFont, "", true));
435
- this.articGroup.addEventListener("click", this.exclusiveSelectHandler);
436
+ //this.articGroup.addEventListener("click", this.exclusiveSelectHandler)
436
437
  }
437
438
  createMainToolbar() {
438
439
  this.createButtons();
@@ -456,7 +457,7 @@ class Tabbar {
456
457
  this.customToolbar = cq.getContainer(this.containerId).querySelector("#customToolbar");
457
458
  //this.createInsertSelect()
458
459
  this.createButtonsAnnotationMode();
459
- this.createArticualtionButtons();
460
+ //this.createArticulationButtons()
460
461
  }
461
462
  removeAllCustomGroups() {
462
463
  Array.from(this.customToolbar.children).forEach(c => {
@@ -479,7 +480,7 @@ class Tabbar {
479
480
  // achtung: nie preventDefault in einem Document anwenden
480
481
  document.addEventListener("keydown", this.closeHandlerKey);
481
482
  //document.getElementsByClassName("vibe-container")[0]?.addEventListener("click", this.closeHandlerMouse)
482
- cq.getContainer(this.containerId).querySelectorAll("#dotGroup button, #noteGroup button, #modGroup button, #accidGroup Button").forEach(el => {
483
+ cq.getContainer(this.containerId).querySelectorAll("#dotGroup button, #noteGroup button, #modGroup button, #accidGroup button, #articGroup button").forEach(el => {
483
484
  el.addEventListener("click", this.exclusiveSelectHandler);
484
485
  });
485
486
  cq.getContainer(this.containerId).querySelector("#toggleSidebar").addEventListener("click", this.sidebarHandler);
@@ -595,7 +596,7 @@ class Tabbar {
595
596
  a.removeEventListener("click", this.customToolbarHandler);
596
597
  });
597
598
  cq.getContainer(this.containerId).removeEventListener("annotChanged", this.createAnnotListHandler);
598
- interactjs_1.default("#annotList").unset();
599
+ (0, interactjs_1.default)("#annotList").unset();
599
600
  }
600
601
  closeDropdown(ddButton) {
601
602
  if (ddButton.classList.contains("show")) {
@@ -619,7 +620,6 @@ class Tabbar {
619
620
  sbb.height = sbb.height + y;
620
621
  }
621
622
  exclusiveSelect(e) {
622
- 1;
623
623
  var target = e.target;
624
624
  var tagname = "button";
625
625
  if (target.tagName.toLowerCase() === tagname) {
@@ -635,6 +635,7 @@ class Tabbar {
635
635
  target.classList.remove(selectedFlag);
636
636
  }
637
637
  }
638
+ return this;
638
639
  }
639
640
  clickInsertHandler() {
640
641
  //this.customToolbar.appendChild(this.insertSelectGroup)
@@ -29,7 +29,7 @@ class TempoLabel {
29
29
  createElement(inputString) {
30
30
  if (typeof this.element === "undefined") {
31
31
  this.element = this.currentMEI.createElement("tempo");
32
- this.element.setAttribute("id", random_1.uuidv4());
32
+ this.element.setAttribute("id", (0, random_1.uuidv4)());
33
33
  }
34
34
  Array.from(this.element.children).forEach(c => {
35
35
  c.remove();
@@ -548,7 +548,7 @@ class Toolbar {
548
548
  // el.removeEventListener("click", this.sidebarHandler)
549
549
  // })
550
550
  cq.getContainer(this.containerId).removeEventListener("annotChanged", this.createAnnotListFunction);
551
- interactjs_1.default("#annotList").unset();
551
+ (0, interactjs_1.default)("#annotList").unset();
552
552
  }
553
553
  closeDropdown(ddButton) {
554
554
  if (ddButton.classList.contains("show")) {
@@ -31,7 +31,7 @@ class AnnotationChangeHandler {
31
31
  setListeners() {
32
32
  //if(document.getElementById(this.containerId).querySelector(".sidebar.openSidebar") != null) return
33
33
  var that = this;
34
- this.shapeListener = interactjs_1.default("#" + this.containerId + " #interactionOverlay .customAnnotShape")
34
+ this.shapeListener = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .customAnnotShape")
35
35
  .resizable({
36
36
  // resize from all edges and corners
37
37
  edges: { left: true, right: true, bottom: true, top: true },
@@ -62,7 +62,7 @@ class AnnotationChangeHandler {
62
62
  })
63
63
  ]
64
64
  });
65
- this.textListener = interactjs_1.default("#" + this.containerId + " .annotText")
65
+ this.textListener = (0, interactjs_1.default)("#" + this.containerId + " .annotText")
66
66
  .resizable({
67
67
  // resize from all edges and corners
68
68
  edges: { left: true, right: true, bottom: true, top: true },
@@ -93,7 +93,7 @@ class AnnotationChangeHandler {
93
93
  })
94
94
  ]
95
95
  });
96
- this.lineListener = interactjs_1.default("#" + this.containerId + " #interactionOverlay .lineDragRect.x1")
96
+ this.lineListener = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .lineDragRect.x1")
97
97
  .draggable({
98
98
  listeners: {
99
99
  move: this.dragLineListener.bind(this),
@@ -328,14 +328,17 @@ class ClickModeHandler {
328
328
  return;
329
329
  }
330
330
  clickSelect(e) {
331
- var _a;
332
331
  if (!this.shiftPressed) {
333
332
  cq.getVrvSVG(this.containerId).querySelectorAll(".marked").forEach(m => m.classList.remove(marked));
334
333
  }
335
334
  const t = e.target;
336
335
  const notehead = cq.getVrvSVG(this.containerId).querySelector(`#${t.parentElement.getAttribute("refId")}`);
337
336
  notehead === null || notehead === void 0 ? void 0 : notehead.classList.add(marked);
338
- (_a = notehead.closest(".note")) === null || _a === void 0 ? void 0 : _a.classList.add(marked);
337
+ const note = notehead.closest(".note");
338
+ if (note) {
339
+ note.classList.add(marked);
340
+ this.scoreGraph.setCurrentNodeById(note.id);
341
+ }
339
342
  }
340
343
  selStart(e) {
341
344
  e.preventDefault();
@@ -437,7 +440,7 @@ class ClickModeHandler {
437
440
  (_d = document.getElementById(this.containerId)) === null || _d === void 0 ? void 0 : _d.querySelectorAll("#noteGroup *, #dotGroup *, #modGroup *, #articGroup *").forEach(b => b.classList.remove("selected"));
438
441
  //select buttons for given note state
439
442
  var modBtnId = this.container.querySelector("#customToolbar #articGroup") !== null ? "artic" : "accid";
440
- (_f = (_e = document.getElementById(this.containerId)) === null || _e === void 0 ? void 0 : _e.querySelector("#" + mappings_1.attrToModButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute(modBtnId)))) === null || _f === void 0 ? void 0 : _f.classList.add("selected");
443
+ (_f = (_e = document.getElementById(this.containerId)) === null || _e === void 0 ? void 0 : _e.querySelector("#" + mappings_1.attrToAccidButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute(modBtnId)))) === null || _f === void 0 ? void 0 : _f.classList.add("selected");
441
444
  if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
442
445
  meiNote = meiNote.closest("chord");
443
446
  }
@@ -501,6 +504,10 @@ class ClickModeHandler {
501
504
  this.musicPlayer = musicPlayer;
502
505
  return this;
503
506
  }
507
+ setScoreGraph(sg) {
508
+ this.scoreGraph = sg;
509
+ return this;
510
+ }
504
511
  setContainerId(id) {
505
512
  this.containerId = id;
506
513
  this.vrvSVG = cq.getVrvSVG(id);
@@ -67,7 +67,7 @@ class CustomAnnotationShapeDrawer {
67
67
  this.updateCallback();
68
68
  }
69
69
  initRect(ulx, uly) {
70
- this.shapeID = random_1.uuidv4();
70
+ this.shapeID = (0, random_1.uuidv4)();
71
71
  this.canvas.append('rect')
72
72
  .attr('x', ulx)
73
73
  .attr('y', uly)
@@ -78,7 +78,7 @@ class CustomAnnotationShapeDrawer {
78
78
  this.shape = document.getElementById(this.shapeID);
79
79
  }
80
80
  initCircle(cx, cy) {
81
- this.shapeID = random_1.uuidv4();
81
+ this.shapeID = (0, random_1.uuidv4)();
82
82
  this.canvas.append('ellipse')
83
83
  .attr('cx', cx)
84
84
  .attr('cy', cy)
@@ -47,7 +47,7 @@ class CustomToolbarHandler {
47
47
  var d = this.alterDUpButton = this.container.querySelector("#alterDUp");
48
48
  var e = this.alterDDownButton = this.container.querySelector("#alterDDown");
49
49
  this.alterButtons = [a, b, c, d, e];
50
- this.articButtons = new Array();
50
+ this.articButtons = Array.from(this.container.querySelectorAll("#articGroup .btn")); //new Array()
51
51
  this.tabButtons = Array.from(this.container.querySelectorAll(".tabBtn"));
52
52
  }
53
53
  setListeners() {
@@ -60,9 +60,9 @@ class CustomToolbarHandler {
60
60
  this.alterButtons.forEach(ab => {
61
61
  ab.addEventListener("click", this.alterFunction);
62
62
  });
63
- if (this.articButtons.length === 0) {
64
- cq.getContainer(this.containerId).querySelectorAll("#articGroup .btn").forEach(btn => this.articButtons.push(btn));
65
- }
63
+ // if(this.articButtons.length === 0){
64
+ // cq.getContainer(this.containerId).querySelectorAll("#articGroup .btn").forEach(btn => this.articButtons.push(btn))
65
+ // }
66
66
  this.articButtons.forEach(ab => {
67
67
  ab.addEventListener("click", this.articulationHandlerFunction);
68
68
  });
@@ -44,6 +44,7 @@ class InsertModeHandler {
44
44
  this.clickModeHandler = this.clickModeHandler || new ClickModeHandler_1.default();
45
45
  this.clickModeHandler
46
46
  .setContainerId(this.containerId)
47
+ .setScoreGraph(this.scoreGraph)
47
48
  .setInsertCallback(this.insertCallback)
48
49
  .setDeleteCallback(this.deleteCallback)
49
50
  .setAnnotations(this.annotations)
@@ -81,6 +82,7 @@ class InsertModeHandler {
81
82
  break;
82
83
  case "staticTextButton":
83
84
  case "linkedAnnotButton":
85
+ this.container.classList.remove("harmonyMode");
84
86
  this.annotationMode = true;
85
87
  this.harmonyMode = false;
86
88
  if (this.annotations == undefined) {
@@ -173,6 +175,7 @@ class InsertModeHandler {
173
175
  .setContainerId(this.containerId)
174
176
  .setm2s(this.m2s)
175
177
  .setMEI(this.m2s.getCurrentMei())
178
+ .setScoreGraph(this.scoreGraph)
176
179
  .setMusicProcessor(this.musicPlayer)
177
180
  .setLoadDataCallback(this.loadDataCallback)
178
181
  .drawElements();
@@ -242,8 +245,8 @@ class InsertModeHandler {
242
245
  }
243
246
  that.m2s.setDurationNewNote(dur);
244
247
  if (that.m2s.setMarkedNoteDurations(dur)) {
245
- MEIOperations_1.cleanUp(that.m2s.getCurrentMei());
246
- var mei = MEIConverter_1.restoreXmlIdTags(that.m2s.getCurrentMei());
248
+ (0, MEIOperations_1.cleanUp)(that.m2s.getCurrentMei());
249
+ var mei = (0, MEIConverter_1.restoreXmlIdTags)(that.m2s.getCurrentMei());
247
250
  that.loadDataCallback("", mei, false);
248
251
  }
249
252
  });
@@ -263,8 +266,8 @@ class InsertModeHandler {
263
266
  }
264
267
  that.m2s.setDotsNewNote(dots);
265
268
  if (that.m2s.setMarkedNoteDots(dots)) {
266
- MEIOperations_1.cleanUp(that.m2s.getCurrentMei());
267
- var mei = MEIConverter_1.restoreXmlIdTags(that.m2s.getCurrentMei());
269
+ (0, MEIOperations_1.cleanUp)(that.m2s.getCurrentMei());
270
+ var mei = (0, MEIConverter_1.restoreXmlIdTags)(that.m2s.getCurrentMei());
268
271
  that.loadDataCallback("", mei, false);
269
272
  }
270
273
  });
@@ -132,7 +132,7 @@ class KeyModeHandler {
132
132
  newNote.staffId = currentStaff.closest("measure").nextElementSibling.querySelector(`staff[n='${staffN}']`).id;
133
133
  newNote.layerId = currentStaff.closest("measure").nextElementSibling.querySelector(`staff[n='${staffN}'] layer[n='${layerN}']`).id;
134
134
  newNote.relPosX = "left";
135
- newNote.nearestNoteId = this.m2s.getCurrentMei().querySelector("#" + newNote.staffId).querySelector("mRest").id;
135
+ newNote.nearestNoteId = this.m2s.getCurrentMei().querySelector("#" + newNote.staffId).querySelector(`layer[n='${layerN}'] > mRest`).id;
136
136
  }
137
137
  else {
138
138
  //or if ne note must be rendered into the next bar
@@ -140,12 +140,14 @@ class KeyModeHandler {
140
140
  if (this.m2s.getCurrentMei().querySelector("#" + newNote.nearestNoteId) === null)
141
141
  return;
142
142
  if (this.m2s.getCurrentMei().querySelector("#" + newNote.nearestNoteId).tagName !== "mRest") {
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;
143
+ // newNote.staffId = this.m2s.getCurrentMei().getElementById(this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")?.getId())?.closest("staff").id || newNote.staffId
144
+ // newNote.layerId = this.m2s.getCurrentMei().getElementById(this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")?.getId())?.closest("layer").id || newNote.layerId
145
+ newNote.staffId = ((_c = this.m2s.getCurrentMei().getElementById((_b = this.scoreGraph.lookUp(["note", "rest", "mRest"], "right")) === null || _b === void 0 ? void 0 : _b.getId())) === null || _c === void 0 ? void 0 : _c.closest("staff").id) || newNote.staffId;
146
+ newNote.layerId = ((_e = this.m2s.getCurrentMei().getElementById((_d = this.scoreGraph.lookUp(["note", "rest", "mRest"], "right")) === null || _d === void 0 ? void 0 : _d.getId())) === null || _e === void 0 ? void 0 : _e.closest("layer").id) || newNote.layerId;
145
147
  }
146
148
  if (oldStaffId !== newNote.staffId) {
147
149
  newNote.relPosX = "left";
148
- newNote.nearestNoteId = (_f = this.scoreGraph.getCurrentNode()) === null || _f === void 0 ? void 0 : _f.getId();
150
+ newNote.nearestNoteId = (_f = this.scoreGraph.getNextClass(["note", "rest", "mRest"], "right")) === null || _f === void 0 ? void 0 : _f.getId(); //this.scoreGraph.getCurrentNode()?.getId()
149
151
  }
150
152
  }
151
153
  this.insertCallback(newNote, true).then(() => {
@@ -210,25 +212,42 @@ class KeyModeHandler {
210
212
  * @returns
211
213
  */
212
214
  createNewNote(pname, oct, options) {
213
- var _a, _b, _c, _d, _e, _f;
215
+ var _a, _b, _c, _d, _e, _f, _g;
214
216
  //get relevant staffinfo
215
- var nearestNodeId = (_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId();
216
- if (nearestNodeId == undefined)
217
+ // var nearestNodeId = this.scoreGraph.getCurrentNode()?.getId()
218
+ // if (nearestNodeId == undefined) return
219
+ if (!this.scoreGraph.getCurrentNode())
217
220
  return;
218
- var closestStaff = ((_b = this.m2s.getCurrentMei().getElementById(nearestNodeId)) === null || _b === void 0 ? void 0 : _b.closest("staff")) || this.m2s.getCurrentMei().querySelector("measure > staff"); //asume first measure first staff
221
+ function getLastActiveNode(cid, sg) {
222
+ var activeNotes = Array.from(cq.getContainer(cid).querySelectorAll(".activeLayer > .note")).reverse();
223
+ var hasNotes = activeNotes.length > 0;
224
+ var lastNode = cq.getContainer(cid).querySelector(".activeLayer > :is(.lastAdded, .rest, .mRest");
225
+ if (hasNotes) {
226
+ lastNode = activeNotes[0];
227
+ }
228
+ sg.setCurrentNodeById(lastNode.id);
229
+ return lastNode.id;
230
+ }
231
+ var nearestNodeId = this.scoreGraph.getCurrentNode().getDocElement().closest(".activeLayer") ? this.scoreGraph.getCurrentNode().getId() : getLastActiveNode(this.containerId, this.scoreGraph);
232
+ var closestStaff = ((_a = this.m2s.getCurrentMei().getElementById(nearestNodeId)) === null || _a === void 0 ? void 0 : _a.closest("staff")) || this.m2s.getCurrentMei().querySelector("measure > staff"); //asume first measure first staff
219
233
  var closestMeasure = closestStaff.closest("measure");
220
234
  var closestStaffIdx = parseInt(closestStaff.getAttribute("n")) - 1;
221
235
  var closestMeasureIdx = parseInt(closestMeasure.getAttribute("n")) - 1;
222
236
  var keysig = this.m2s.getMeasureMatrix().get(closestMeasureIdx, closestStaffIdx).keysig;
223
237
  var accids = mappings_1.keysigToNotes.get(keysig);
224
238
  var accid;
225
- if (options === null) {
226
- accids = accids.filter((s) => { return s === pname; });
227
- if (accids.length === 1) {
228
- accid = keysig.charAt(1);
239
+ var artic;
240
+ if (!options) {
241
+ accid = mappings_1.accidButtonToAttr.get((_b = cq.getContainer(this.containerId).querySelector("#accidGroup > button.selected")) === null || _b === void 0 ? void 0 : _b.id); // try first to create a new accid based on the tabbar state
242
+ artic = mappings_1.articButtonToAttr.get((_c = cq.getContainer(this.containerId).querySelector("#articGroup > button.selected")) === null || _c === void 0 ? void 0 : _c.id);
243
+ if (!accid) {
244
+ accids = accids.filter((s) => { return s === pname; });
245
+ if (accids.length === 1) {
246
+ accid = keysig.charAt(1);
247
+ }
229
248
  }
230
249
  }
231
- else if (options === null || options === void 0 ? void 0 : options.accid) {
250
+ if (options === null || options === void 0 ? void 0 : options.accid) {
232
251
  accid = options.accid;
233
252
  //should the note be enharmonically swapped?
234
253
  //midi inputs are only given as sharps
@@ -238,6 +257,9 @@ class KeyModeHandler {
238
257
  pname = String.fromCharCode(pname.charCodeAt(0) + increment);
239
258
  }
240
259
  }
260
+ if (options === null || options === void 0 ? void 0 : options.artic) {
261
+ artic = options.artic; // TODO: Which format will be set?
262
+ }
241
263
  var targetChord;
242
264
  //if(this.container.querySelector("#chordButton")?.classList.contains("selected")){
243
265
  if (this.shiftDown) {
@@ -249,18 +271,19 @@ class KeyModeHandler {
249
271
  this.setContainerId(this.containerId);
250
272
  var newNote = {
251
273
  pname: pname,
252
- id: random_1.uuidv4(),
274
+ id: (0, random_1.uuidv4)(),
253
275
  dur: this.m2s.getDurationNewNote(),
254
276
  dots: this.m2s.getDotsNewNote(),
255
277
  oct: oct,
256
278
  keysig: keysig,
257
279
  accid: accid,
280
+ artic: artic,
258
281
  nearestNoteId: nearestNodeId,
259
282
  relPosX: "right",
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,
283
+ staffId: (_d = this.vrvSVG.querySelector("#" + nearestNodeId)) === null || _d === void 0 ? void 0 : _d.closest(".staff").id,
284
+ layerId: (_f = this.container.querySelector(`#${(_e = this.vrvSVG.querySelector("#" + nearestNodeId)) === null || _e === void 0 ? void 0 : _e.closest(".staff").id} .activeLayer`)) === null || _f === void 0 ? void 0 : _f.id,
262
285
  chordElement: targetChord,
263
- rest: (_f = this.container.querySelector("#pauseNote")) === null || _f === void 0 ? void 0 : _f.classList.contains("selected")
286
+ rest: (_g = this.container.querySelector("#pauseNote")) === null || _g === void 0 ? void 0 : _g.classList.contains("selected")
264
287
  };
265
288
  return newNote;
266
289
  }
@@ -13,7 +13,8 @@ const labelSelectors = "." + labelClasses.join(",.");
13
13
  class LabelHandler {
14
14
  constructor(containerId) {
15
15
  this.setHarmonyLabelHandlerClick = (function setHarmonyLabelHandler(e) {
16
- if (this.container.classList.contains("harmonyMode")) {
16
+ //if (this.container.classList.contains("harmonyMode")) {
17
+ if (this.container.querySelector("#annotGroupKM > #harmonyAnnotButton.selected")) {
17
18
  this.harmonyLabelHandler(e);
18
19
  }
19
20
  }).bind(this);
@@ -346,7 +347,7 @@ class LabelHandler {
346
347
  }
347
348
  createInputBox(posx, posy, targetId, targetClass) {
348
349
  var textGroup = document.createElementNS(constants_1.constants._SVGNS_, "g");
349
- textGroup.setAttribute("id", random_1.uuidv4());
350
+ textGroup.setAttribute("id", (0, random_1.uuidv4)());
350
351
  textGroup.setAttribute("refElementId", targetId);
351
352
  var text = document.createElementNS(constants_1.constants._SVGNS_, "svg");
352
353
  text.classList.add("labelText");
@@ -12,7 +12,7 @@ class NoteDragHandler {
12
12
  }
13
13
  setListeners() {
14
14
  var that = this;
15
- this.noteDragListener = interactjs_1.default("#" + this.containerId + " #interactionOverlay .notehead rect")
15
+ this.noteDragListener = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .notehead rect")
16
16
  .draggable({
17
17
  startAxis: "y",
18
18
  lockAxis: "y",
@@ -193,6 +193,13 @@ class ScoreManipulatorHandler {
193
193
  cq.getContainer(this.containerId).querySelectorAll("#vrvSVG .staff:not(:has(.activeLayer))").forEach(staff => {
194
194
  this.setActiveLayerClass(staff.getAttribute("n"), "1");
195
195
  });
196
+ var activeNotes = Array.from(cq.getContainer(this.containerId).querySelectorAll(".activeLayer > .note")).reverse();
197
+ var hasNotes = activeNotes.length > 0;
198
+ var lastNode = cq.getContainer(this.containerId).querySelector(".activeLayer > :is(.rest, .mRest");
199
+ if (hasNotes) {
200
+ lastNode = activeNotes[0];
201
+ }
202
+ this.scoreGraph.setCurrentNodeById(lastNode.id);
196
203
  }
197
204
  //SETTER////
198
205
  setMEI(mei) {
@@ -208,6 +215,10 @@ class ScoreManipulatorHandler {
208
215
  this.musicPlayer = mp;
209
216
  return this;
210
217
  }
218
+ setScoreGraph(sg) {
219
+ this.scoreGraph = sg;
220
+ return this;
221
+ }
211
222
  setLoadDataCallback(loadDataCallback) {
212
223
  this.loadDataCallback = loadDataCallback;
213
224
  return this;
@@ -74,7 +74,7 @@ class SidebarHandler {
74
74
  that.setSelectListeners();
75
75
  }
76
76
  }, false);
77
- this.resizeListener = interactjs_1.default("#" + this.containerId + " #sidebarContainer")
77
+ this.resizeListener = (0, interactjs_1.default)("#" + this.containerId + " #sidebarContainer")
78
78
  .resizable({
79
79
  edges: { left: false, right: true, bottom: false, top: false },
80
80
  listeners: {
@@ -93,7 +93,7 @@ class TooltipHandler {
93
93
  arrow.setAttribute("data-popper-arrow", "");
94
94
  tt.append(arrow);
95
95
  this.container.prepend(tt);
96
- core_1.createPopper(el, tt, {
96
+ (0, core_1.createPopper)(el, tt, {
97
97
  placement: 'top-start',
98
98
  modifiers: [
99
99
  {