vibe-editor 0.0.3 → 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.
Files changed (87) hide show
  1. package/package.json +65 -61
  2. package/src/scripts/js/Core.js +32 -13
  3. package/src/scripts/js/entry.js +6 -5
  4. package/src/scripts/js/gui/Annotations.js +28 -13
  5. package/src/scripts/js/gui/ScoreManipulator.js +13 -11
  6. package/src/scripts/js/gui/Tabbar.js +14 -5
  7. package/src/scripts/js/gui/Toolbar.js +1 -1
  8. package/src/scripts/js/handlers/AnnotationChangeHandler.js +16 -4
  9. package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +2 -2
  10. package/src/scripts/js/handlers/InsertModeHandler.js +7 -7
  11. package/src/scripts/js/handlers/KeyModeHandler.js +1 -1
  12. package/src/scripts/js/handlers/LabelHandler.js +1 -1
  13. package/src/scripts/js/handlers/NoteDragHandler.js +1 -1
  14. package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
  15. package/src/scripts/js/handlers/{SideBarHandler.js → SidebarHandler.js} +1 -1
  16. package/src/scripts/js/handlers/TooltipHandler.js +1 -1
  17. package/src/scripts/js/handlers/WindowHandler.js +7 -7
  18. package/src/scripts/js/scripts/Core.js +932 -0
  19. package/src/scripts/js/scripts/MusicProcessor.js +810 -0
  20. package/src/scripts/js/scripts/VIBE.js +219 -0
  21. package/src/scripts/js/{assets → scripts/assets}/mei_template.js +2 -2
  22. package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
  23. package/src/scripts/js/scripts/gui/Annotations.js +549 -0
  24. package/src/scripts/js/scripts/gui/Cursor.js +203 -0
  25. package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +1 -1
  26. package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
  27. package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
  28. package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
  29. package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +1 -1
  30. package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
  31. package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
  32. package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
  33. package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
  34. package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
  35. package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
  36. package/src/scripts/js/scripts/handlers/Handler.js +2 -0
  37. package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
  38. package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
  39. package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
  40. package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
  41. package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +168 -0
  42. package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
  43. package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
  44. package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
  45. package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
  46. package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
  47. package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
  48. package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +1 -1
  49. package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
  50. package/src/scripts/js/scripts/utils/Types.js +2 -0
  51. package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +35 -21
  52. package/src/scripts/js/scripts/utils/coordinates.js +54 -0
  53. package/src/scripts/js/utils/MEIOperations.js +22 -22
  54. package/src/scripts/js/utils/Mouse2SVG.js +13 -6
  55. package/src/scripts/js/utils/SVGEditor.js +2 -2
  56. package/src/scripts/js/utils/VerovioWrapper.js +4 -4
  57. package/src/scripts/js/utils/coordinates.js +26 -2
  58. package/src/scripts/js/.DS_Store +0 -0
  59. package/src/scripts/js/MusicPlayer.js +0 -572
  60. package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
  61. package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
  62. package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
  63. package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
  64. package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
  65. package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
  66. package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
  67. package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
  68. package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
  69. package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
  70. package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
  71. package/src/scripts/js/handlers/SelectionHandler.js +0 -262
  72. package/src/scripts/js/utils/RectWrapper.js +0 -10
  73. package/src/scripts/js/utils/SVGFiller.js +0 -245
  74. package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
  75. package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
  76. package/src/styles/vibe.css +0 -785
  77. /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
  78. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
  79. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
  80. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
  81. /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
  82. /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
  83. /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
  84. /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
  85. /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
  86. /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
  87. /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants_1 = require("../constants");
4
+ const PhantomElement_1 = require("../gui/PhantomElement");
5
+ const coordinates = require("../utils/coordinates");
6
+ const cq = require("../utils/convenienceQueries");
7
+ class PhantomElementHandler {
8
+ constructor(containerId) {
9
+ this.trackMouseHandler = (function handler(e) {
10
+ var that = this;
11
+ that.trackMouse(e);
12
+ }).bind(this);
13
+ this.timeMarkerHandler = (function timeMarkerHandler(e) {
14
+ this.drawMarkers(e);
15
+ }).bind(this);
16
+ this.setContainerId(containerId);
17
+ this.addCanvas();
18
+ this.phantom = new PhantomElement_1.default("note", containerId);
19
+ this.isTrackingMouse = false;
20
+ }
21
+ addCanvas() {
22
+ if (cq.getInteractOverlay(this.containerId).querySelector("#phantomCanvas") !== null)
23
+ return;
24
+ this.rootBBox = this.vrvSVG.getBoundingClientRect();
25
+ var rootWidth = this.rootBBox.width.toString();
26
+ var rootHeigth = this.rootBBox.height.toString();
27
+ if (this.phantomCanvas == undefined) {
28
+ this.phantomCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
29
+ this.phantomCanvas.setAttribute("id", "phantomCanvas");
30
+ }
31
+ this.interactionOverlay.insertBefore(this.phantomCanvas, this.interactionOverlay.firstChild);
32
+ }
33
+ setListeners() {
34
+ this.interactionOverlay.addEventListener("mousemove", this.trackMouseHandler);
35
+ this.interactionOverlay.querySelectorAll(".notehead rect").forEach(n => n.addEventListener("draggingNote", this.trackMouseHandler));
36
+ // Listener just for staves
37
+ this.interactionOverlay.querySelectorAll(".staffLine").forEach(element => {
38
+ element.addEventListener('click', this.trackMouseHandler);
39
+ });
40
+ this.interactionOverlay.querySelectorAll(".staff").forEach(s => {
41
+ s.addEventListener("currStaffChanged", this.timeMarkerHandler);
42
+ });
43
+ return this;
44
+ }
45
+ setPhantomLineListeners() {
46
+ this.interactionOverlay.querySelectorAll(".phantomLine").forEach(element => {
47
+ element.addEventListener('click', this.trackMouseHandler);
48
+ });
49
+ }
50
+ removeListeners() {
51
+ this.interactionOverlay.removeEventListener("mousemove", this.trackMouseHandler);
52
+ this.interactionOverlay.querySelectorAll(".notehead rect").forEach(n => n.removeEventListener("draggingNote", this.trackMouseHandler));
53
+ this.interactionOverlay.querySelectorAll(".staff").forEach(s => {
54
+ s.removeEventListener("currStaffChanged", this.timeMarkerHandler);
55
+ });
56
+ this.interactionOverlay.querySelectorAll(".staffLine").forEach(element => {
57
+ element.removeEventListener('click', this.trackMouseHandler);
58
+ clearInterval(this.trackMouseHandler);
59
+ });
60
+ if (this.phantom) {
61
+ this.phantom.removePhantomNote();
62
+ this.phantom = undefined;
63
+ }
64
+ return this;
65
+ }
66
+ removePhantomLineListeners() {
67
+ this.interactionOverlay.querySelectorAll(".phantomLine").forEach(element => {
68
+ element.removeEventListener('click', this.trackMouseHandler);
69
+ });
70
+ }
71
+ /**
72
+ * Draw circle under mouse cursor
73
+ * @param e
74
+ */
75
+ trackMouse(e) {
76
+ var _a, _b, _c, _d, _e;
77
+ if (this.m2s.getLastMouseEnter().staff === null)
78
+ return;
79
+ // var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay)
80
+ // var relX = pt.x
81
+ // var relY = pt.y
82
+ var definitionScale = (_b = cq.getVrvSVG(this.containerId).querySelector("#" + ((_a = this.m2s.getLastMouseEnter().staff) === null || _a === void 0 ? void 0 : _a.getAttribute("refId")))) === null || _b === void 0 ? void 0 : _b.closest(".definition-scale");
83
+ if (definitionScale == undefined || definitionScale == null)
84
+ return;
85
+ var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay);
86
+ var relX = pt.x;
87
+ var relY = pt.y;
88
+ var dsCoords = coordinates.getDOMMatrixCoordinates(definitionScale, definitionScale.closest(".page"));
89
+ //console.log(relX, dsCoords, definitionScale.getBoundingClientRect())
90
+ if (relX < dsCoords.left || relX > dsCoords.right) {
91
+ this.isTrackingMouse = false;
92
+ return;
93
+ }
94
+ this.isTrackingMouse = true;
95
+ var target = e.target;
96
+ target = target.closest("g");
97
+ var options = {};
98
+ if (target === null || target === void 0 ? void 0 : target.classList.contains("staffLine")) {
99
+ options["staffLineId"] = target.id;
100
+ }
101
+ var phantomNoteElement = this.phantom.getNoteElement();
102
+ if (phantomNoteElement == undefined) {
103
+ return;
104
+ }
105
+ phantomNoteElement.setAttribute("cx", relX.toString());
106
+ phantomNoteElement.setAttribute("cy", relY.toString());
107
+ phantomNoteElement.setAttribute("r", ((_d = (_c = this.m2s) === null || _c === void 0 ? void 0 : _c.getLineDist()) === null || _d === void 0 ? void 0 : _d.toString()) || "0");
108
+ phantomNoteElement.setAttribute("visibility", phantomNoteElement.getAttribute("visibility") || "visible");
109
+ this.m2s.defineNote(relX, relY, options);
110
+ var newCY = (_e = (this.m2s.getNewNoteY())) === null || _e === void 0 ? void 0 : _e.toString();
111
+ phantomNoteElement.setAttribute("cy", (newCY || "0"));
112
+ this.removeLines();
113
+ if (this.m2s.getPhantomLines() != undefined) {
114
+ this.phantomLines = new Array();
115
+ this.m2s.getPhantomLines().forEach(pl => {
116
+ this.phantomLines.push(new PhantomElement_1.default("line", this.containerId, { lineX: relX, lineY: pl }, this.phantomCanvas));
117
+ });
118
+ this.setPhantomLineListeners();
119
+ }
120
+ // if(e.type === "draggingNote"){
121
+ // console.log(phantomNoteElement, this.phantomLines)
122
+ // }
123
+ }
124
+ removeLines() {
125
+ var lines = this.interactionOverlay.querySelectorAll(".phantomLine");
126
+ this.removePhantomLineListeners();
127
+ if (lines.length > 0) {
128
+ lines.forEach(l => {
129
+ l.remove();
130
+ });
131
+ }
132
+ return this;
133
+ }
134
+ drawMarkers(e) {
135
+ this.container.querySelectorAll(".phantomMarker").forEach(pm => pm.remove());
136
+ var pm = new PhantomElement_1.default("timeMarkers", this.containerId, { lastStaffEnteredId: e.target.getAttribute("refId"),
137
+ measureMatrix: this.m2s.getMeasureMatrix() });
138
+ }
139
+ resetCanvas() {
140
+ this.setContainerId(this.containerId);
141
+ this.rootBBox = this.vrvSVG.getBoundingClientRect();
142
+ this.phantomCanvas = this.interactionOverlay.querySelector("#phantomCanvas");
143
+ this.removeListeners();
144
+ this.removePhantomLineListeners();
145
+ this.phantom = new PhantomElement_1.default("note", this.containerId);
146
+ this.setListeners();
147
+ this.setPhantomLineListeners();
148
+ }
149
+ setm2s(m2s) {
150
+ this.m2s = m2s;
151
+ return this;
152
+ }
153
+ setContainerId(id) {
154
+ this.containerId = id;
155
+ this.vrvSVG = cq.getVrvSVG(id);
156
+ this.interactionOverlay = cq.getInteractOverlay(id);
157
+ this.container = document.getElementById(id);
158
+ return this;
159
+ }
160
+ setPhantomNote(note = undefined) {
161
+ this.phantom = note || new PhantomElement_1.default("note", this.containerId);
162
+ return this;
163
+ }
164
+ getIsTrackingMouse() {
165
+ return this.isTrackingMouse;
166
+ }
167
+ }
168
+ exports.default = PhantomElementHandler;
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ScoreManipulator_1 = require("../gui/ScoreManipulator");
4
+ const constants_1 = require("../constants");
5
+ const meiOperation = require("../utils/MEIOperations");
6
+ const meiConverter = require("../utils/MEIConverter");
7
+ const cq = require("../utils/convenienceQueries");
8
+ const mei_template_1 = require("../assets/mei_template");
9
+ const manipSelector = ".manipulator";
10
+ const canvasId = "manipulatorCanvas";
11
+ /**
12
+ * Handler for all options which could change the given score with methods which are not bound to the toolsbars.
13
+ * These functions are related to all elements seen inside a score. (Adding Staves, Measures and Layers)
14
+ */
15
+ class ScoreManipulatorHandler {
16
+ constructor() {
17
+ this.cacheLayers = {};
18
+ this.addMeasure = (function addMeasure(e) {
19
+ e.target.dispatchEvent(this.manipulateEvent);
20
+ e.preventDefault();
21
+ e.stopPropagation();
22
+ meiOperation.addMeasure(this.currentMEI);
23
+ var that = this;
24
+ this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
25
+ that.setActiveLayers();
26
+ });
27
+ }).bind(this);
28
+ this.removeMeasure = (function removeMeasure(e) {
29
+ e.target.dispatchEvent(this.manipulateEvent);
30
+ e.preventDefault();
31
+ e.stopPropagation();
32
+ meiOperation.removeMeasure(this.currentMEI);
33
+ this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false);
34
+ }).bind(this);
35
+ this.addStaff = (function addStaff(e) {
36
+ var target = e.target.closest(".manipulator");
37
+ target.dispatchEvent(this.manipulateEvent);
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ var relpos = target.classList.contains("below") ? "below" : "above";
41
+ meiOperation.addStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
42
+ this.musicPlayer.resetMidiInstruments();
43
+ var that = this;
44
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
45
+ that.setActiveLayers();
46
+ });
47
+ }).bind(this);
48
+ this.removeStaff = (function removeStaff(e) {
49
+ var target = e.target.closest(".manipulator");
50
+ target.dispatchEvent(this.manipulateEvent);
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ var relpos = target.classList.contains("below") ? "below" : "above";
54
+ meiOperation.removeStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
55
+ this.musicPlayer.resetMidiInstruments();
56
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false);
57
+ e.target.dispatchEvent(this.manipulateEvent);
58
+ }).bind(this);
59
+ this.removeFunction = (function removeElementsFunction() {
60
+ this.removeElements();
61
+ }).bind(this);
62
+ this.selectVoiceHandler = (function selectVoiceHandler(e) {
63
+ this.selectVoice(e);
64
+ }).bind(this);
65
+ this.sm = new ScoreManipulator_1.default();
66
+ this.manipulateEvent = new Event("manipulated");
67
+ }
68
+ addCanvas() {
69
+ var _a;
70
+ var rootBBox = cq.getVrvSVG(this.containerId).firstElementChild.getBoundingClientRect();
71
+ var rootWidth = rootBBox.width.toString();
72
+ var rootHeigth = rootBBox.height.toString();
73
+ this.manipulatorCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
74
+ this.manipulatorCanvas.setAttribute("id", canvasId);
75
+ this.manipulatorCanvas.classList.add("canvas");
76
+ //this.manipulatorCanvas.setAttribute("preserveAspectRatio", "xMinYMin meet")
77
+ //this.manipulatorCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "))
78
+ (_a = this.interactionOverlay.querySelector("#" + canvasId)) === null || _a === void 0 ? void 0 : _a.remove();
79
+ this.manipulatorCanvas.insertAdjacentElement("beforebegin", this.interactionOverlay.querySelector("#scoreRects"));
80
+ this.interactionOverlay.append(this.manipulatorCanvas);
81
+ }
82
+ drawElements() {
83
+ this.addCanvas();
84
+ this.sm.drawMeasureManipulators();
85
+ this.sm.drawStaffManipulators();
86
+ this.sm.drawVoiceSelectors();
87
+ this.setListeners();
88
+ return this;
89
+ }
90
+ removeElements() {
91
+ //this.removeListeners()
92
+ this.interactionOverlay.querySelectorAll(manipSelector).forEach(m => {
93
+ m.remove();
94
+ });
95
+ }
96
+ setListeners() {
97
+ var that = this;
98
+ this.removeListeners();
99
+ this.interactionOverlay.querySelector("#measureAdder").addEventListener("click", this.addMeasure, true);
100
+ this.interactionOverlay.querySelector("#measureRemover").addEventListener("click", this.removeMeasure, true);
101
+ this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
102
+ as.addEventListener("click", that.addStaff, true);
103
+ });
104
+ this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
105
+ as.addEventListener("click", that.removeStaff, true);
106
+ });
107
+ this.interactionOverlay.querySelectorAll(".voiceBtn").forEach(vb => {
108
+ vb.addEventListener("click", that.selectVoiceHandler, true);
109
+ });
110
+ // if(!this.interactionOverlay.querySelector(".voiceBtn.selected")){
111
+ // (this.interactionOverlay.querySelector(".voiceBtn") as HTMLElement).click()
112
+ // }
113
+ }
114
+ removeListeners() {
115
+ var _a, _b;
116
+ var that = this;
117
+ (_a = this.interactionOverlay.querySelector("#measureAdder")) === null || _a === void 0 ? void 0 : _a.removeEventListener("click", this.addMeasure);
118
+ (_b = this.interactionOverlay.querySelector("#measureRemover")) === null || _b === void 0 ? void 0 : _b.removeEventListener("click", this.removeMeasure);
119
+ this.interactionOverlay.querySelectorAll(".addStaff").forEach(as => {
120
+ as.removeEventListener("click", that.addStaff);
121
+ });
122
+ this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
123
+ as.removeEventListener("click", that.removeStaff);
124
+ });
125
+ this.interactionOverlay.querySelectorAll(".voiceBtn").forEach(vb => {
126
+ vb.removeEventListener("click", that.selectVoiceHandler);
127
+ });
128
+ }
129
+ /**
130
+ * Logic for behaviour if when a voice btn is selected:
131
+ * Creating new layer, deactivating and reactivating layers.
132
+ * Afterwards the MEI will be rendered anew.
133
+ * @param e
134
+ */
135
+ selectVoice(e) {
136
+ var t = e.target.closest(".voiceBtn");
137
+ var staffN = t.getAttribute("staffN");
138
+ var btnN = t.getAttribute("btnN");
139
+ // change between selected and inactive button
140
+ if (t.classList.contains("selected")) {
141
+ t.classList.remove("selected");
142
+ t.classList.add("inactive");
143
+ }
144
+ else if (t.classList.contains("inactive")) {
145
+ t.classList.remove("inactive");
146
+ t.classList.add("selected");
147
+ }
148
+ var that = this;
149
+ //In this case there is no existing layer for the selected voice
150
+ if (!this.currentMEI.querySelector(`staff[n='${staffN}'] layer[n='${btnN}']`) && !this.cacheLayers[staffN + btnN]) {
151
+ meiOperation.addLayerForStaff(this.currentMEI, staffN, btnN);
152
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
153
+ that.setActiveLayerClass(staffN, btnN);
154
+ });
155
+ }
156
+ else {
157
+ // if the button is really inactive, cache the layer for this layer and staff
158
+ if (t.classList.contains("inactive")) {
159
+ this.cacheLayers[staffN + btnN] = this.currentMEI.querySelectorAll(`staff[n='${staffN}'] layer[n='${btnN}']`);
160
+ console.log(this.cacheLayers);
161
+ this.currentMEI.querySelectorAll(`staff[n='${staffN}'] layer[n='${btnN}']`).forEach(el => el.remove());
162
+ }
163
+ else if (this.cacheLayers[staffN + btnN]) { // bring the layers back to life
164
+ this.currentMEI.querySelectorAll(`staff[n='${staffN}']`).forEach((staff, i) => {
165
+ if (this.cacheLayers[staffN + btnN][i]) {
166
+ staff.insertBefore(this.cacheLayers[staffN + btnN][i], staff.querySelector(`layer[n='${(parseInt(btnN) + 1).toString()}']`));
167
+ }
168
+ else {
169
+ staff.append(new mei_template_1.default().createLayer(btnN));
170
+ }
171
+ });
172
+ delete this.cacheLayers[staffN + btnN];
173
+ }
174
+ this.loadDataCallback("", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
175
+ that.setActiveLayerClass(staffN, btnN);
176
+ });
177
+ }
178
+ }
179
+ setActiveLayerClass(staffN, btnN) {
180
+ this.interactionOverlay.querySelectorAll(`.voiceBtn[staffN='${staffN}'].selected`).forEach(vb => vb.classList.remove("selected"));
181
+ this.interactionOverlay.querySelectorAll(`.voiceBtn:not(.inactive)[staffN='${staffN}'][btnN='${btnN}']`).forEach(vb => vb.classList.add("selected"));
182
+ cq.getContainer(this.containerId).querySelectorAll(`.staff[n='${staffN}'] > .activeLayer`).forEach(layer => layer.classList.remove("activeLayer"));
183
+ cq.getContainer(this.containerId).querySelectorAll(`.staff[n='${staffN}'] > .layer[n='${btnN}']`).forEach(layer => {
184
+ layer.classList.add("activeLayer");
185
+ });
186
+ return this;
187
+ }
188
+ setActiveLayers() {
189
+ cq.getContainer(this.containerId).querySelectorAll(".activeLayer").forEach(al => {
190
+ var staffN = al.closest(".staff").getAttribute("n");
191
+ this.setActiveLayerClass(staffN, al.getAttribute("n"));
192
+ });
193
+ cq.getContainer(this.containerId).querySelectorAll("#vrvSVG .staff:not(:has(.activeLayer))").forEach(staff => {
194
+ this.setActiveLayerClass(staff.getAttribute("n"), "1");
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);
203
+ }
204
+ //SETTER////
205
+ setMEI(mei) {
206
+ this.currentMEI = mei;
207
+ this.sm.setMEI(mei);
208
+ return this;
209
+ }
210
+ setm2s(m2s) {
211
+ this.m2s = m2s;
212
+ return this;
213
+ }
214
+ setMusicProcessor(mp) {
215
+ this.musicPlayer = mp;
216
+ return this;
217
+ }
218
+ setScoreGraph(sg) {
219
+ this.scoreGraph = sg;
220
+ return this;
221
+ }
222
+ setLoadDataCallback(loadDataCallback) {
223
+ this.loadDataCallback = loadDataCallback;
224
+ return this;
225
+ }
226
+ setContainerId(containerId) {
227
+ this.containerId = containerId;
228
+ this.interactionOverlay = cq.getInteractOverlay(containerId);
229
+ this.sm.setContainerId(this.containerId);
230
+ return this;
231
+ }
232
+ }
233
+ exports.default = ScoreManipulatorHandler;