vibe-editor 0.0.0 → 0.0.1-dev

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 (38) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -9
  3. package/package.json +11 -5
  4. package/src/scripts/js/Core.js +212 -186
  5. package/src/scripts/js/MusicProcessor.js +286 -128
  6. package/src/scripts/js/{VerovioScoreEditor.js → VIBE.js} +62 -28
  7. package/src/scripts/js/assets/mei_template.js +5 -1
  8. package/src/scripts/js/datastructures/MeasureMatrix.js +6 -85
  9. package/src/scripts/js/datastructures/ScoreGraph.js +1 -1
  10. package/src/scripts/js/entry.js +3 -2
  11. package/src/scripts/js/gui/Annotations.js +188 -111
  12. package/src/scripts/js/gui/HarmonyLabel.js +26 -2
  13. package/src/scripts/js/gui/ScoreManipulator.js +61 -31
  14. package/src/scripts/js/gui/Tabbar.js +41 -21
  15. package/src/scripts/js/gui/Toolbar.js +4 -4
  16. package/src/scripts/js/handlers/AnnotationChangeHandler.js +131 -60
  17. package/src/scripts/js/handlers/ClickModeHandler.js +406 -143
  18. package/src/scripts/js/handlers/CustomToolbarHandler.js +26 -24
  19. package/src/scripts/js/handlers/GlobalKeyboardHandler.js +12 -7
  20. package/src/scripts/js/handlers/InsertModeHandler.js +26 -32
  21. package/src/scripts/js/handlers/KeyModeHandler.js +12 -86
  22. package/src/scripts/js/handlers/LabelHandler.js +3 -2
  23. package/src/scripts/js/handlers/PhantomElementHandler.js +1 -1
  24. package/src/scripts/js/handlers/ScoreManipulatorHandler.js +101 -14
  25. package/src/scripts/js/handlers/SelectionHandler.js +80 -36
  26. package/src/scripts/js/handlers/SideBarHandler.js +10 -3
  27. package/src/scripts/js/handlers/WindowHandler.js +25 -4
  28. package/src/scripts/js/utils/DOMCreator.js +1 -1
  29. package/src/scripts/js/utils/MEIConverter.js +13 -1
  30. package/src/scripts/js/utils/MEIOperations.js +180 -187
  31. package/src/scripts/js/utils/Mouse2SVG.js +200 -43
  32. package/src/scripts/js/utils/ReactWrapper.js +46 -0
  33. package/src/scripts/js/utils/RectWrapper.js +10 -0
  34. package/src/scripts/js/utils/SVGEditor.js +94 -3
  35. package/src/scripts/js/utils/VerovioWrapper.js +6 -1
  36. package/src/scripts/js/utils/convenienceQueries.js +2 -0
  37. package/src/scripts/js/utils/mappings.js +322 -56
  38. package/src/styles/VerovioScoreEditor.css +0 -694
@@ -5,19 +5,25 @@ const constants_1 = require("../constants");
5
5
  const meiOperation = require("../utils/MEIOperations");
6
6
  const meiConverter = require("../utils/MEIConverter");
7
7
  const cq = require("../utils/convenienceQueries");
8
+ const mei_template_1 = require("../assets/mei_template");
8
9
  const manipSelector = ".manipulator";
9
10
  const canvasId = "manipulatorCanvas";
10
11
  /**
11
- * Handler for all options which could modulate the given score from within the score. These functions are related to all elements seen inside a score
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)
12
14
  */
13
15
  class ScoreManipulatorHandler {
14
16
  constructor() {
17
+ this.cacheLayers = {};
15
18
  this.addMeasure = (function addMeasure(e) {
16
19
  e.target.dispatchEvent(this.manipulateEvent);
17
20
  e.preventDefault();
18
21
  e.stopPropagation();
19
22
  meiOperation.addMeasure(this.currentMEI);
20
- this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false);
23
+ var that = this;
24
+ this.loadDataCallback("last", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
25
+ that.setActiveLayers();
26
+ });
21
27
  }).bind(this);
22
28
  this.removeMeasure = (function removeMeasure(e) {
23
29
  e.target.dispatchEvent(this.manipulateEvent);
@@ -34,7 +40,10 @@ class ScoreManipulatorHandler {
34
40
  var relpos = target.classList.contains("below") ? "below" : "above";
35
41
  meiOperation.addStaff(this.currentMEI, document.getElementById(target.getAttribute("refId")), relpos);
36
42
  this.musicPlayer.resetMidiInstruments();
37
- this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false);
43
+ var that = this;
44
+ this.loadDataCallback("1", meiConverter.restoreXmlIdTags(this.currentMEI), false).then(() => {
45
+ that.setActiveLayers();
46
+ });
38
47
  }).bind(this);
39
48
  this.removeStaff = (function removeStaff(e) {
40
49
  var target = e.target.closest(".manipulator");
@@ -50,6 +59,9 @@ class ScoreManipulatorHandler {
50
59
  this.removeFunction = (function removeElementsFunction() {
51
60
  this.removeElements();
52
61
  }).bind(this);
62
+ this.selectVoiceHandler = (function selectVoiceHandler(e) {
63
+ this.selectVoice(e);
64
+ }).bind(this);
53
65
  this.sm = new ScoreManipulator_1.default();
54
66
  this.manipulateEvent = new Event("manipulated");
55
67
  }
@@ -61,18 +73,19 @@ class ScoreManipulatorHandler {
61
73
  this.manipulatorCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
62
74
  this.manipulatorCanvas.setAttribute("id", canvasId);
63
75
  this.manipulatorCanvas.classList.add("canvas");
64
- this.manipulatorCanvas.setAttribute("preserveAspectRatio", "xMinYMin meet");
65
- this.manipulatorCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "));
76
+ //this.manipulatorCanvas.setAttribute("preserveAspectRatio", "xMinYMin meet")
77
+ //this.manipulatorCanvas.setAttribute("viewBox", ["0", "0", rootWidth, rootHeigth].join(" "))
66
78
  (_a = this.interactionOverlay.querySelector("#" + canvasId)) === null || _a === void 0 ? void 0 : _a.remove();
67
79
  this.manipulatorCanvas.insertAdjacentElement("beforebegin", this.interactionOverlay.querySelector("#scoreRects"));
68
80
  this.interactionOverlay.append(this.manipulatorCanvas);
69
81
  }
70
82
  drawElements() {
71
83
  this.addCanvas();
72
- this.sm.drawMeasureAdder();
73
- this.sm.drawMeasureRemover();
84
+ this.sm.drawMeasureManipulators();
74
85
  this.sm.drawStaffManipulators();
86
+ this.sm.drawVoiceSelectors();
75
87
  this.setListeners();
88
+ return this;
76
89
  }
77
90
  removeElements() {
78
91
  //this.removeListeners()
@@ -91,6 +104,12 @@ class ScoreManipulatorHandler {
91
104
  this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
92
105
  as.addEventListener("click", that.removeStaff, true);
93
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
+ // }
94
113
  }
95
114
  removeListeners() {
96
115
  var _a, _b;
@@ -103,20 +122,88 @@ class ScoreManipulatorHandler {
103
122
  this.interactionOverlay.querySelectorAll(".removeStaff").forEach(as => {
104
123
  as.removeEventListener("click", that.removeStaff);
105
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
+ });
106
196
  }
107
- // drawFunction = (function drawFunction(e: TransitionEvent) {
108
- // var that = this
109
- // setTimeout(function () {
110
- // that.drawElements()
111
- // }, 500)
112
- // //this.drawElements()
113
- // }).bind(this)
114
197
  //SETTER////
115
198
  setMEI(mei) {
116
199
  this.currentMEI = mei;
117
200
  this.sm.setMEI(mei);
118
201
  return this;
119
202
  }
203
+ setm2s(m2s) {
204
+ this.m2s = m2s;
205
+ return this;
206
+ }
120
207
  setMusicProcessor(mp) {
121
208
  this.musicPlayer = mp;
122
209
  return this;
@@ -1,12 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const d3 = require("d3");
4
3
  const mappings_1 = require("../utils/mappings");
5
4
  const coordinates = require("../utils/coordinates");
6
5
  const cq = require("../utils/convenienceQueries");
7
6
  const marked = "marked";
8
7
  class SelectionHandler {
9
8
  constructor(containerId) {
9
+ this.selectStarted = false;
10
+ this.isSelecting = false;
11
+ this.selectEnded = false;
12
+ this.isDragging = false;
13
+ this.selectDist = 0;
14
+ this.dragOnce = false;
10
15
  /**
11
16
  * Mark clicked element
12
17
  */
@@ -61,16 +66,32 @@ class SelectionHandler {
61
66
  this.selectEndEvent = new Event("selectEnd");
62
67
  this.shiftPressed = false;
63
68
  this.setKeyListeners();
64
- this.canvas = d3.select("#" + this.containerId + " #interactionOverlay"); // draw directly in svg
65
- var dragSelectAction = d3.drag()
66
- .on('start', selStart)
67
- .on('drag', selecting)
68
- .on('end', selEnd);
69
69
  var that = this;
70
- function selStart() {
71
- if (document.getElementById(that.containerId).classList.contains("annotMode"))
72
- return; // prevent selecting when resizing annotation objects
73
- var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId));
70
+ this.getCoords = (function getCoords(e) {
71
+ this.selectDist = Math.sqrt(Math.abs(e.clientX - this.selectStartX) ** 2 + Math.abs(e.clientY - this.selectStartY) ** 2);
72
+ if (this.selectDist > 10) {
73
+ console.log("dragging", this.selectDist);
74
+ this.isDragging = true;
75
+ if (!this.dragOnce) {
76
+ this.dragOnce = true;
77
+ //this.interactionOverlay.dispatchEvent(new Event("removeClickHandler"))
78
+ this.selStart(e);
79
+ }
80
+ }
81
+ }).bind(this);
82
+ this.selStart = (function selStart(e) {
83
+ e.preventDefault();
84
+ this.selectStartX = this.selectStartX || e.clientX;
85
+ this.selectStartY = this.selectStartY || e.clientY;
86
+ if (!this.isDragging)
87
+ return;
88
+ console.log("selectstart");
89
+ if (cq.getContainer(that.containerId).classList.contains("annotMode")) {
90
+ this.selEnd(e);
91
+ return;
92
+ }
93
+ //var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId))
94
+ var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, cq.getInteractOverlay(that.containerId));
74
95
  that.initialX = pt.x; //d3.event.x
75
96
  that.initialY = pt.y; //d3.event.y
76
97
  if (!document.getElementById(that.containerId).classList.contains("harmonyMode") && !that.shiftPressed) { //!that.harmonyHandler.getGlobal()){
@@ -80,11 +101,16 @@ class SelectionHandler {
80
101
  });
81
102
  }
82
103
  that.initRect(that.initialX, that.initialY);
83
- }
84
- function selecting() {
104
+ this.isSelecting = true;
105
+ }).bind(this);
106
+ this.selecting = (function selecting(e) {
107
+ e.preventDefault();
85
108
  if (document.getElementById(that.containerId).classList.contains("annotMode"))
86
109
  return; // prevent selecting when resizing annotation objects
87
- var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId));
110
+ if (!this.isSelecting)
111
+ return;
112
+ //var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, cq.getInteractOverlay(that.containerId))
113
+ var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, cq.getInteractOverlay(that.containerId));
88
114
  const curX = pt.x; //d3.event.x + container.scrollLeft
89
115
  const curY = pt.y; //d3.event.y + container.scrollTop
90
116
  const newX = curX < that.initialX ? curX : that.initialX;
@@ -129,12 +155,20 @@ class SelectionHandler {
129
155
  chord === null || chord === void 0 ? void 0 : chord.classList.remove(marked);
130
156
  }
131
157
  });
132
- }
133
- function selEnd() {
158
+ }).bind(this);
159
+ this.selEnd = (function selEnd(e) {
134
160
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
161
+ console.log("selectionend", e.target);
162
+ e.preventDefault();
163
+ this.isSelecting = false;
164
+ this.isDragging = false;
165
+ this.dragOnce = false;
166
+ this.selectStartX = undefined;
167
+ this.selectStartY = undefined;
168
+ this.selectDist = 0;
135
169
  if (document.getElementById(that.containerId).classList.contains("annotMode"))
136
170
  return; // prevent selecting when resizing annotation objects
137
- var selectRect = that.interactionOverlay.querySelector("#selectRect");
171
+ var selectRect = cq.getInteractOverlay(that.containerId).querySelector("#selectRect");
138
172
  if (selectRect !== null && (selectRect === null || selectRect === void 0 ? void 0 : selectRect.getAttribute("width")) !== "0" && (selectRect === null || selectRect === void 0 ? void 0 : selectRect.getAttribute("height")) !== "0") {
139
173
  document.dispatchEvent(that.selectEndEvent);
140
174
  }
@@ -153,31 +187,34 @@ class SelectionHandler {
153
187
  (_h = (_g = document.getElementById(that.containerId)) === null || _g === void 0 ? void 0 : _g.querySelector("#" + mappings_1.numToNoteButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dur")))) === null || _h === void 0 ? void 0 : _h.classList.add("selected");
154
188
  (_k = (_j = document.getElementById(that.containerId)) === null || _j === void 0 ? void 0 : _j.querySelector("#" + mappings_1.numToDotButtonId.get(meiNote === null || meiNote === void 0 ? void 0 : meiNote.getAttribute("dots")))) === null || _k === void 0 ? void 0 : _k.classList.add("selected");
155
189
  }
156
- }
157
- this.dsa = dragSelectAction;
158
- this.setListeners();
159
- //this.canvas.call(dragSelectAction);
190
+ //this.interactionOverlay.dispatchEvent(new Event("resetClickHandler"))
191
+ }).bind(this);
192
+ this.resetListeners();
160
193
  }
161
194
  initRect(ulx, uly) {
162
- this.canvas.append('rect')
163
- .attr('x', ulx)
164
- .attr('y', uly)
165
- .attr('width', 0)
166
- .attr('height', 0)
167
- .attr('id', 'selectRect')
168
- .attr('stroke', 'black')
169
- .attr('stroke-width', "1px")
170
- .attr('fill', 'none');
195
+ const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
196
+ rect.setAttribute("x", ulx.toString());
197
+ rect.setAttribute("y", uly.toString());
198
+ rect.setAttribute("width", "0");
199
+ rect.setAttribute("height", "0");
200
+ rect.setAttribute("id", "selectRect");
201
+ rect.setAttribute("stroke", "black");
202
+ rect.setAttribute("stroke-width", "1px");
203
+ rect.setAttribute("fill", "none");
204
+ this.interactionOverlay.appendChild(rect);
171
205
  }
172
206
  updateRect(newX, newY, currentWidth, currentHeight) {
173
- d3.select('#selectRect')
174
- .attr('x', newX)
175
- .attr('y', newY)
176
- .attr('width', currentWidth)
177
- .attr('height', currentHeight);
207
+ const rect = this.interactionOverlay.querySelector("#selectRect");
208
+ rect.setAttribute("x", newX.toString());
209
+ rect.setAttribute("y", newY.toString());
210
+ rect.setAttribute("width", currentWidth.toString());
211
+ rect.setAttribute("height", currentHeight.toString());
178
212
  }
179
213
  removeListeners() {
180
- d3.select("#" + this.containerId + " #interactionOverlay").on('mousedown.drag', null);
214
+ //d3.select("#" + this.containerId + " #interactionOverlay").on('mousedown.drag', null)
215
+ this.interactionOverlay.removeEventListener("mousedown", this.selStart);
216
+ this.interactionOverlay.removeEventListener("mousemove", this.selecting);
217
+ this.interactionOverlay.removeEventListener("mouseup", this.selEnd);
181
218
  this.interactionOverlay.querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
182
219
  el.removeEventListener("click", this.markedHandler);
183
220
  });
@@ -185,10 +222,14 @@ class SelectionHandler {
185
222
  this.interactionOverlay.removeEventListener("keyup", this.shiftKeyHandler);
186
223
  }
187
224
  setListeners() {
188
- this.canvas.call(this.dsa);
225
+ //this.interactionOverlay.call(this.dsa);
189
226
  cq.getInteractOverlay(this.containerId).querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
190
227
  el.addEventListener("click", this.markedHandler);
191
228
  });
229
+ this.interactionOverlay.addEventListener("mousedown", this.selStart);
230
+ this.interactionOverlay.addEventListener("mousemove", this.selecting);
231
+ this.interactionOverlay.addEventListener("mousemove", this.getCoords);
232
+ this.interactionOverlay.addEventListener("mouseup", this.selEnd);
192
233
  }
193
234
  setKeyListeners() {
194
235
  this.interactionOverlay.addEventListener("keydown", this.shiftKeyHandler);
@@ -214,5 +255,8 @@ class SelectionHandler {
214
255
  this.vrvSVG = cq.getVrvSVG(id);
215
256
  return this;
216
257
  }
258
+ getIsSelecting() {
259
+ return this.isSelecting;
260
+ }
217
261
  }
218
262
  exports.default = SelectionHandler;
@@ -158,6 +158,7 @@ class SidebarHandler {
158
158
  //this.interactionOverlay.querySelectorAll("*").forEach(c => {
159
159
  c.addEventListener("click", function (e) {
160
160
  var _a, _b;
161
+ cq.getContainer(that.containerId).querySelectorAll(".marked").forEach(m => m.classList.remove("marked"));
161
162
  if (c.classList.contains("marked")) {
162
163
  c.classList.remove("marked");
163
164
  (_a = that.getElementInSVG(c.getAttribute("refId"))) === null || _a === void 0 ? void 0 : _a.classList.remove("marked");
@@ -177,6 +178,7 @@ class SidebarHandler {
177
178
  * @param element
178
179
  */
179
180
  changeSelectedElementInSidebar(element) {
181
+ var _a, _b;
180
182
  if (!element.classList.contains("meterSig"))
181
183
  return;
182
184
  var baseEl = this.vrvSVG.querySelector("#" + element.getAttribute("refId"));
@@ -184,7 +186,7 @@ class SidebarHandler {
184
186
  var count = "";
185
187
  var unit = "";
186
188
  baseEl.querySelectorAll("use").forEach(u => {
187
- var num = mappings_1.unicodeToTimesig.get(u.getAttribute("href").slice(1, 5));
189
+ var num = mappings_1.unicodeToTimesig.get(u.getAttribute("xlink:href").slice(1, 5));
188
190
  if (count === "") {
189
191
  count = num;
190
192
  }
@@ -199,8 +201,9 @@ class SidebarHandler {
199
201
  }
200
202
  tempY = u.getAttribute("y");
201
203
  });
202
- this.container.querySelector("#timeCount").value = count;
203
- this.container.querySelector("#timeUnit").value = unit;
204
+ cq.getContainer(this.containerId).querySelectorAll("#timeDiv .selected").forEach(s => s.removeAttribute("selected"));
205
+ (_a = cq.getContainer(this.containerId).querySelector(`#timeCount > [value='${count}']`)) === null || _a === void 0 ? void 0 : _a.setAttribute("selected", "");
206
+ (_b = cq.getContainer(this.containerId).querySelector(`#timeUnit > [value='${unit}']`)) === null || _b === void 0 ? void 0 : _b.setAttribute("selected", "");
204
207
  }
205
208
  setTimeForSelectedElements(e) {
206
209
  var target = e.target;
@@ -362,6 +365,10 @@ class SidebarHandler {
362
365
  ds.style.width = (that.container.getBoundingClientRect().right - target.getBoundingClientRect().right).toString() + "px";
363
366
  });
364
367
  }
368
+ /**
369
+ * Find next possible element to drop element from sidebar on
370
+ * @param e
371
+ */
365
372
  findDropTarget(e) {
366
373
  /** TODO: dropflags müssen auch in scoreRects eigegeben werden */
367
374
  e.preventDefault();
@@ -100,15 +100,15 @@ class WindowHandler {
100
100
  this.reloadTimer.push(setTimeout(function () {
101
101
  that.updateXY();
102
102
  var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
103
- that.loadDataCallback("", mei, false);
103
+ that.loadDataCallback("", mei, false, null);
104
104
  that.reloadTimer = new Array();
105
105
  }, e.elapsedTime * 1000 + 10));
106
106
  }
107
- else if (e.type === "resize" || e.type === "resizemove") {
107
+ else if (e.type === "resize" || e.type === "resizemove" || t.id.startsWith("zoom")) {
108
108
  this.reloadTimer.push(setTimeout(function () {
109
109
  that.updateXY();
110
110
  var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
111
- that.loadDataCallback("", mei, false);
111
+ that.loadDataCallback("", mei, false, null);
112
112
  that.reloadTimer = new Array();
113
113
  }, 500));
114
114
  }
@@ -170,7 +170,28 @@ class WindowHandler {
170
170
  (_a = this.zoomTimer) === null || _a === void 0 ? void 0 : _a.forEach(zt => clearTimeout(zt));
171
171
  this.zoomTimer.push(setTimeout(function () {
172
172
  var svgContainer = cq.getContainer(that.containerId).querySelector("#svgContainer");
173
- svgContainer.style.width = (100 * delta).toString() + "%";
173
+ svgContainer.querySelectorAll("#interactionOverlay, #vrvSVG").forEach((el) => {
174
+ el.style.transformOrigin = "0 0";
175
+ el.style.transform = "scale(" + delta.toString() + ")";
176
+ // if(el.id === "interactionOverlay"){
177
+ // const transformValue = window.getComputedStyle(el).getPropertyValue('transform');
178
+ // const matrix = new DOMMatrix(transformValue);
179
+ // const scaleX = matrix.a;
180
+ // const scaleY = matrix.d;
181
+ // var vbsplit = el.getAttribute("viewBox").split(" ")
182
+ // var newVb = new Array<string>()
183
+ // vbsplit.forEach((n, i) => {
184
+ // if(i === 2){
185
+ // newVb.push((parseFloat(n)/scaleX).toString())
186
+ // }else if(i === 3){
187
+ // newVb.push((parseFloat(n)/scaleY).toString())
188
+ // }else{
189
+ // newVb.push((parseFloat(n)).toString())
190
+ // }
191
+ // })
192
+ // el.setAttribute("viewBox", newVb.join(" "))
193
+ // }
194
+ });
174
195
  }, 10));
175
196
  }
176
197
  /**
@@ -125,7 +125,7 @@ exports.makeNewDatalist = makeNewDatalist;
125
125
  function makeNewSelect(id, optionValues, placeHolder = null) {
126
126
  var dataList = document.createElement("select");
127
127
  dataList.setAttribute("id", id);
128
- if (placeHolder !== null) {
128
+ if (placeHolder) {
129
129
  var option = document.createElement("option");
130
130
  option.setAttribute("value", " ");
131
131
  option.textContent = placeHolder;
@@ -2,7 +2,7 @@
2
2
  //@ts-ignore
3
3
  //const $ = H5P.jQuery
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.restoreXmlIdTags = exports.standardizeAccid = exports.docToMei = exports.meiToDoc = exports.reformatMEI = void 0;
5
+ exports.restoreXmlIdTags = exports.standardizeAccid = exports.docToMei = exports.meiToDoc = exports.cleanIdAttr = exports.reformatMEI = exports.cleanMEI = void 0;
6
6
  /**
7
7
  * clean mei to make it parsable as document
8
8
  * @param mei the mei to be cleaned
@@ -14,6 +14,7 @@ function cleanMEI(mei) {
14
14
  mei = mei.replace(/\s{2,}/g, ""); // delete all unnecessary whitespaces
15
15
  return mei;
16
16
  }
17
+ exports.cleanMEI = cleanMEI;
17
18
  function reformatMEI(mei) {
18
19
  mei = mei.replace(/\n/g, ""); // delete all unnecessary newline
19
20
  mei = mei.replace(/\s{2,}/g, ""); // delete all unnecessary whitespaces
@@ -21,6 +22,17 @@ function reformatMEI(mei) {
21
22
  return mei;
22
23
  }
23
24
  exports.reformatMEI = reformatMEI;
25
+ function cleanIdAttr(mei) {
26
+ mei.querySelectorAll("*").forEach(xi => {
27
+ if (!xi.hasAttribute('xml:id'))
28
+ return;
29
+ const id = xi.getAttribute("xml:id");
30
+ xi.removeAttribute("xml:id");
31
+ xi.setAttribute("id", id);
32
+ });
33
+ return mei;
34
+ }
35
+ exports.cleanIdAttr = cleanIdAttr;
24
36
  /**
25
37
  * Converts MEI-String to DOM-conform objec
26
38
  * @param mei