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
package/package.json CHANGED
@@ -1,63 +1,67 @@
1
1
  {
2
- "name": "vibe-editor",
3
- "version": "0.0.3",
4
- "main": "src/scripts/js/VIBE.js",
5
- "keywords": [],
6
- "author": "Matthias Nowakowski",
7
- "license": "MIT",
8
- "browserslist": [
9
- "since 2017-06"
10
- ],
11
- "scripts": {
12
- "build": "./node_modules/.bin/webpack --mode=production"
13
- },
14
- "files": [
15
- "src/images/*/*",
16
- "src/scripts/js/*",
17
- "src/fonts/*",
18
- "src/styles/*.css"
19
- ],
20
- "dependencies": {
21
- "@babel/plugin-transform-classes": "^7.16.7",
22
- "@babel/preset-env": "^7.16.11",
23
- "@popperjs/core": "^2.11.6",
24
- "@tonejs/midi": "^2.0.28",
25
- "@types/react": "^18.2.28",
26
- "@types/react-dom": "^18.2.13",
27
- "axios": "^1.4.0",
28
- "babel": "^6.23.0",
29
- "babel-loader": "^8.2.3",
30
- "bootstrap": "^5.1.3",
31
- "brotli-webpack-plugin": "^1.1.0",
32
- "buffer": "^5.7.1",
33
- "compression-webpack-plugin": "^9.2.0",
34
- "css-loader": "^6.7.1",
35
- "d3": "^5.11.0",
36
- "esbuild": "0.17.14",
37
- "eslint-plugin-react-hooks": "^4.6.0",
38
- "file-loader": "^6.2.0",
39
- "h5p-lib-controls": "^0.0.15",
40
- "interactjs": "1.10.11",
41
- "midi-player-js": "^2.0.16",
42
- "mini-css-extract-plugin": "^2.6.0",
43
- "node-sass": "^7.0.1",
44
- "postcss-loader": "^6.2.1",
45
- "react-color": "^2.19.3",
46
- "react-dom": "^18.2.0",
47
- "sass-loader": "^12.6.0",
48
- "soundfont-player": "^0.12.0",
49
- "style-loader": "^3.3.1",
50
- "tone": "^14.7.77",
51
- "typescript": "4.6.3",
52
- "update": "^0.7.4",
53
- "web-midi-api": "^2.2.5",
54
- "webpack": "^5.88.2",
55
- "webpack-bundle-analyzer": "^4.5.0",
56
- "webpack-cli": "^4.9.2"
57
- },
58
- "devDependencies": {
59
- "@types/verovio": "^3.13.0",
60
- "raw-loader": "^4.0.2",
61
- "url-loader": "^4.1.1"
62
- }
2
+ "name": "vibe-editor",
3
+ "version": "0.0.5",
4
+ "main": "src/scripts/js/scripts/VIBE.js",
5
+ "keywords": [],
6
+ "author": "Matthias Nowakowski",
7
+ "license": "MIT",
8
+ "browserslist": [
9
+ "since 2017-06"
10
+ ],
11
+ "scripts": {
12
+ "build": "./node_modules/.bin/webpack --mode=development",
13
+ "watch": "./node_modules/.bin/webpack --watch"
14
+ },
15
+ "files": [
16
+ "src/images/*/*",
17
+ "src/scripts/js/*",
18
+ "src/fonts/*"
19
+ ],
20
+ "dependencies": {
21
+ "@babel/plugin-transform-classes": "^7.16.7",
22
+ "@babel/preset-env": "^7.16.11",
23
+ "@popperjs/core": "^2.11.6",
24
+ "@tonejs/midi": "^2.0.28",
25
+ "@types/react": "^18.2.28",
26
+ "@types/react-dom": "^18.2.13",
27
+ "axios": "^1.4.0",
28
+ "babel": "^6.23.0",
29
+ "babel-loader": "^8.2.3",
30
+ "bootstrap": "^5.1.3",
31
+ "brotli-webpack-plugin": "^1.1.0",
32
+ "buffer": "^5.7.1",
33
+ "compression-webpack-plugin": "^9.2.0",
34
+ "css-loader": "^6.7.1",
35
+ "d3": "^5.11.0",
36
+ "esbuild": "0.17.14",
37
+ "eslint-plugin-react-hooks": "^4.6.0",
38
+ "file-loader": "^6.2.0",
39
+ "h5p-lib-controls": "^0.0.15",
40
+ "html-webpack-plugin": "^5.6.0",
41
+ "interactjs": "1.10.11",
42
+ "midi-player-js": "^2.0.16",
43
+ "mini-css-extract-plugin": "^2.6.0",
44
+ "node-sass": "^7.0.1",
45
+ "postcss-loader": "^6.2.1",
46
+ "react-color": "^2.19.3",
47
+ "react-dom": "^18.2.0",
48
+ "sass-loader": "^12.6.0",
49
+ "soundfont-player": "^0.12.0",
50
+ "style-loader": "^3.3.1",
51
+ "svg-url-loader": "^8.0.0",
52
+ "tone": "^14.7.77",
53
+ "ts-loader": "^9.5.1",
54
+ "typescript": "4.6.3",
55
+ "update": "^0.7.4",
56
+ "web-midi-api": "^2.2.5",
57
+ "webpack": "^5.88.2",
58
+ "webpack-bundle-analyzer": "^4.5.0",
59
+ "webpack-cli": "^4.9.2"
60
+ },
61
+ "devDependencies": {
62
+ "@types/verovio": "^3.13.0",
63
+ "raw-loader": "^4.0.2",
64
+ "url-loader": "^4.1.1"
65
+ },
66
+ "description": "Current version in npm repo: ![npm](https://img.shields.io/npm/v/vibe-editor)"
63
67
  }
@@ -194,7 +194,7 @@ class Core {
194
194
  return new Promise((resolve, reject) => {
195
195
  var _a;
196
196
  var message = {
197
- id: (0, random_1.uuidv4)(),
197
+ id: random_1.uuidv4(),
198
198
  action: 'renderToSVG',
199
199
  pageNo: pageNo
200
200
  };
@@ -224,12 +224,18 @@ class Core {
224
224
  pageElement.setAttribute("preserveAspectRatio", "xMinYMin meet");
225
225
  var systemHeigth = pageElement.querySelector(".system").getBoundingClientRect().height;
226
226
  systemHeigth += systemHeigth * 0.2;
227
- that.verovioWrapper.setHeightValue(systemHeigth);
228
- if (options === null || options === void 0 ? void 0 : options.widthFactor) {
229
- console.log("pageW before", that.verovioWrapper.getOptions().pageWidth);
230
- that.verovioWrapper.setWidthValue(parseFloat(that.verovioWrapper.getOptions().pageWidth) * options.widthFactor);
231
- console.log("pageW after", that.verovioWrapper.getOptions().pageWidth);
232
- }
227
+ //that.verovioWrapper.setHeightValue(systemHeigth)
228
+ // if(!options){
229
+ // options = {}
230
+ // }
231
+ // options.widthFactor = (that.container as HTMLElement).clientWidth / screen.availWidth
232
+ // if (options?.widthFactor) {
233
+ // console.log("pageW before", that.verovioWrapper.getOptions().pageWidth)
234
+ // that.verovioWrapper.setWidthValue(
235
+ // parseFloat(that.verovioWrapper.getOptions().pageWidth) * options.widthFactor
236
+ // )
237
+ // console.log("pageW after", that.verovioWrapper.getOptions().pageWidth)
238
+ // }
233
239
  resolve();
234
240
  });
235
241
  }
@@ -307,7 +313,7 @@ class Core {
307
313
  }
308
314
  //just render the data once to make pagecount accessible
309
315
  var message = {
310
- id: (0, random_1.uuidv4)(),
316
+ id: random_1.uuidv4(),
311
317
  action: 'renderData',
312
318
  mei: d,
313
319
  isUrl: u
@@ -405,11 +411,24 @@ class Core {
405
411
  this.containerId = container.id;
406
412
  this.verovioWrapper = this.verovioWrapper || new VerovioWrapper_1.default();
407
413
  var waitingFlag = "waiting";
408
- // if (cq.getVrvSVG(this.containerId) !== null) {
409
- // document.body.classList.add(waitingFlag)
410
- // }
411
414
  // svg has to be loaded into verovio anyway
412
415
  this.sendDataToVerovio(data, isUrl);
416
+ this.interactionOverlay = cq.getInteractOverlay(this.containerId);
417
+ // get most right standing canvas in interactionOverlay
418
+ let rightMostElement = this.interactionOverlay;
419
+ let rightCoord = 0;
420
+ this.container.querySelectorAll("#interactionOverlay > *, #vrvSVG > svg > *").forEach(c => {
421
+ let bbox = c.getBoundingClientRect();
422
+ if (bbox.x + bbox.width > rightCoord) {
423
+ rightCoord = bbox.x + bbox.width;
424
+ rightMostElement = c;
425
+ }
426
+ });
427
+ var sizeRatio = ((this.container.getBoundingClientRect().width / this.interactionOverlay.getBoundingClientRect().width) + 2) * 100; //rightMostElement.getBoundingClientRect().width * 60
428
+ if (!sizeRatio || sizeRatio <= 0) {
429
+ sizeRatio = 100;
430
+ }
431
+ this.container.querySelector("#svgContainer").style.width = sizeRatio.toString() + "%";
413
432
  document.getElementById(this.containerId).dispatchEvent(new Event("loadingStart"));
414
433
  this.svgEditor.setContainerId(this.containerId);
415
434
  this.svgEditor.cacheClasses().cacheScales().cacheStyles();
@@ -549,7 +568,7 @@ class Core {
549
568
  return new Promise((resolve, reject) => {
550
569
  const message = {
551
570
  action: "getMEI",
552
- id: (0, random_1.uuidv4)()
571
+ id: random_1.uuidv4()
553
572
  };
554
573
  var response;
555
574
  response = this.verovioWrapper.setMessage(message);
@@ -566,7 +585,7 @@ class Core {
566
585
  return new Promise((resolve, reject) => {
567
586
  const message = {
568
587
  action: "renderToMidi",
569
- id: (0, random_1.uuidv4)()
588
+ id: random_1.uuidv4()
570
589
  };
571
590
  var response = this.verovioWrapper.setMessage(message);
572
591
  if (response.midi) {
@@ -1,5 +1,6 @@
1
- import VIBE from "./VIBE.js"
2
-
3
- export default function createEditor(container, options, meiCallback){
4
- return new VIBE(container, options, meiCallback)
5
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const VIBE_1 = require("./scripts/VIBE");
4
+ require("./styles/vibe.css");
5
+ const container = document.getElementById("vse-container1");
6
+ var vse = new VIBE_1.default(container, null, null);
@@ -150,6 +150,7 @@ class Annotations {
150
150
  b.addEventListener("click", this.clickAnnotTextHandler);
151
151
  });
152
152
  harmonyButton === null || harmonyButton === void 0 ? void 0 : harmonyButton.addEventListener("click", this.clickHarmonyBtnHandler);
153
+ //window.addEventListener("resize", this.resizeHandler)
153
154
  return this;
154
155
  }
155
156
  removeListeners() {
@@ -159,6 +160,7 @@ class Annotations {
159
160
  b.removeEventListener("click", this.clickAnnotTextHandler);
160
161
  });
161
162
  harmonyButton === null || harmonyButton === void 0 ? void 0 : harmonyButton.removeEventListener("click", this.clickHarmonyBtnHandler);
163
+ //window.removeEventListener("resize", this.resizeHandler)
162
164
  }
163
165
  setTextListeners() {
164
166
  // this.customAnnotationDrawer = new CustomAnnotationShapeDrawer(this.containerId)
@@ -290,9 +292,23 @@ class Annotations {
290
292
  var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, cq.getInteractOverlay(this.containerId));
291
293
  var posx = pt.x; //matrixTransform(rootMatrix).x //e.pageX - this.rootBBox.x - window.pageXOffset
292
294
  var posy = pt.y; //matrixTransform(rootMatrix).y //e.pageY - this.rootBBox.y - window.pageYOffset
293
- var annotationTarget = this.m2s.findScoreTarget(posx, posy, false);
295
+ var staves = this.interactionOverlay.querySelectorAll(".staff");
296
+ var tempDist = Math.pow(10, 10);
297
+ var annotationTarget = this.m2s.findScoreTarget(posx, posy, false, null, ["mRest"]);
298
+ if (!annotationTarget) {
299
+ var annotationCoords;
300
+ staves.forEach(s => {
301
+ var coord = coordinates.getDOMMatrixCoordinates(s, this.interactionOverlay);
302
+ var dist = Math.sqrt(Math.abs(coord.x - posx) ** 2 + Math.abs(coord.y - posy) ** 2);
303
+ if (dist < tempDist) {
304
+ tempDist = dist;
305
+ annotationTarget = this.vrvSVG.querySelector("#" + s.getAttribute("refId"));
306
+ annotationCoords = coord;
307
+ }
308
+ });
309
+ }
294
310
  var textGroup = document.createElementNS(constants_1.constants._SVGNS_, "g");
295
- textGroup.setAttribute("id", (0, random_1.uuidv4)());
311
+ textGroup.setAttribute("id", random_1.uuidv4());
296
312
  textGroup.setAttribute("targetId", annotationTarget.id);
297
313
  var text = document.createElementNS(constants_1.constants._SVGNS_, "svg");
298
314
  if (isLinked)
@@ -318,21 +334,22 @@ class Annotations {
318
334
  var foW = (50 + 2 * rectPadding + 50).toString();
319
335
  textForeignObject.setAttribute("x", foX);
320
336
  textForeignObject.setAttribute("y", foY);
321
- textForeignObject.setAttribute("height", foH);
322
- textForeignObject.setAttribute("width", foW);
337
+ // textForeignObject.style.height = foH + "px" //setAttribute("height", foH)
338
+ // textForeignObject.style.width = foW + "px" //setAttribute("width", foW)
323
339
  if (isLinked) {
324
340
  var line = document.createElementNS(constants_1.constants._SVGNS_, "line");
325
341
  line.classList.add("annotLine");
342
+ const targetCoords = annotationCoords || annotationTarget;
326
343
  const lX2 = textForeignObject.x.baseVal.valueAsString;
327
344
  const lY2 = textForeignObject.y.baseVal.valueAsString;
328
- const lX1 = annotationTarget.x.toString();
329
- const lY1 = annotationTarget.y.toString();
345
+ const lX1 = targetCoords.x.toString();
346
+ const lY1 = targetCoords.y.toString();
330
347
  line.setAttribute("x2", lX2);
331
348
  line.setAttribute("y2", lY2);
332
349
  line.setAttribute("x1", lX1);
333
350
  line.setAttribute("y1", lY1);
334
- const xDiff = parseFloat(lX1) - parseFloat(lX2);
335
- const yDiff = parseFloat(lY1) - parseFloat(lY2);
351
+ const xDiff = parseFloat(lX2) - parseFloat(lX1); //parseFloat(lX1) - parseFloat(lX2)
352
+ const yDiff = parseFloat(lY2) - parseFloat(lY1); //parseFloat(lY1) - parseFloat(lY2)
336
353
  line.setAttribute("x-diff", xDiff.toString());
337
354
  line.setAttribute("y-diff", yDiff.toString());
338
355
  line.classList.add("annotLine");
@@ -343,10 +360,8 @@ class Annotations {
343
360
  var newAnnot = {
344
361
  sourceID: textGroup.id,
345
362
  targetID: annotationTarget.id,
346
- // relativePos: {
347
- // x: textGroup.getBoundingClientRect().x - annotationTarget.getBoundingClientRect().x,
348
- // y: textGroup.getBoundingClientRect().y - annotationTarget.getBoundingClientRect().y
349
- // }
363
+ originalWidth: "200",
364
+ originalHeight: "100",
350
365
  };
351
366
  this.annotations.push(newAnnot);
352
367
  this.annotationCanvas.appendChild(textGroup);
@@ -438,7 +453,7 @@ class Annotations {
438
453
  return;
439
454
  var foreignObject = source.querySelector(".annotFO");
440
455
  const targetBbox = target.getBoundingClientRect();
441
- const targetPt = coordinates.transformToDOMMatrixCoordinates(targetBbox.x, targetBbox.y, cq.getInteractOverlay(this.containerId).querySelector("#annotationCanvas"));
456
+ const targetPt = coordinates.transformToDOMMatrixCoordinates(targetBbox.x, targetBbox.y, cq.getInteractOverlay(this.containerId)); //.querySelector("#annotationCanvas"))
442
457
  var line = source.querySelector("line");
443
458
  const xSource = targetPt.x + parseFloat(line.getAttribute("x-diff"));
444
459
  const ySource = targetPt.y + parseFloat(line.getAttribute("y-diff"));
@@ -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 = (0, coordinates_1.getDOMMatrixCoordinates)(this.lastBline, this.vrvSVG);
70
+ var lastBlineRect = 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,17 +111,19 @@ 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 = (0, coordinates_1.getDOMMatrixCoordinates)(staff.querySelector(".staffLine"), this.vrvSVG); //staff.querySelector(".staffLine").getBoundingClientRect()
114
+ var bbox = 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 = (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
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
118
118
  var staffHeight = (yBottom - yTop);
119
119
  yTop -= staffHeight * 0.20; // center the boxes
120
120
  var btnHeight = (staffHeight / 4) * 1.5;
121
121
  for (let i = 0; i < 4; i++) {
122
122
  var btn = document.createElementNS("http://www.w3.org/2000/svg", "svg");
123
123
  var btnRect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
124
- var btnText = document.createElementNS("http://www.w3.org/2000/svg", "text");
124
+ var btnFO = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
125
+ var btnText = document.createElement("div");
126
+ btnFO.append(btnText);
125
127
  btnText.textContent = (i + 1).toString();
126
128
  btn.setAttribute("x", "3px");
127
129
  btn.setAttribute("y", (yTop + btnHeight * i).toString());
@@ -133,10 +135,10 @@ class ScoreManipulator {
133
135
  btn.setAttribute("btnN", (i + 1).toString());
134
136
  btn.setAttribute("id", "voiceSelect-" + staff.getAttribute("n") + "-" + (i + 1).toString());
135
137
  //btnText is relative to btn
136
- btnText.setAttribute("x", "30%");
137
- btnText.setAttribute("y", "80%");
138
+ var fontSize = btnHeight;
139
+ btnText.style.fontSize = fontSize.toString() + "px";
138
140
  btn.append(btnRect);
139
- btn.append(btnText);
141
+ btn.append(btnFO);
140
142
  (_a = this.interactionOverlay.querySelector("#manipulatorCanvas")) === null || _a === void 0 ? void 0 : _a.append(btn);
141
143
  }
142
144
  });
@@ -155,18 +157,18 @@ class ScoreManipulator {
155
157
  var width;
156
158
  var height;
157
159
  if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1) {
158
- bbox = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff, this.vrvSVG); //referenceStaff.querySelector(".staffLine").getBoundingClientRect()
160
+ bbox = coordinates_1.getDOMMatrixCoordinates(referenceStaff, this.vrvSVG); //referenceStaff.querySelector(".staffLine").getBoundingClientRect()
159
161
  x = bbox.left;
160
162
  yTop = bbox.top;
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
163
+ yBottom = coordinates_1.getDOMMatrixCoordinates(Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0], this.vrvSVG).bottom; //Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom
162
164
  }
163
165
  else {
164
- bbox = bbox = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff.querySelector(".clef"), this.vrvSVG); //referenceStaff.querySelector(".clef").getBoundingClientRect()
166
+ bbox = bbox = coordinates_1.getDOMMatrixCoordinates(referenceStaff.querySelector(".clef"), this.vrvSVG); //referenceStaff.querySelector(".clef").getBoundingClientRect()
165
167
  x = bbox.left;
166
168
  yTop = bbox.top;
167
169
  yBottom = bbox.bottom;
168
170
  }
169
- const clefCoords = (0, coordinates_1.getDOMMatrixCoordinates)(referenceStaff.querySelector(".clef"), this.vrvSVG);
171
+ const clefCoords = coordinates_1.getDOMMatrixCoordinates(referenceStaff.querySelector(".clef"), this.vrvSVG);
170
172
  //height = referenceStaff.querySelector(".clef").getBoundingClientRect().height
171
173
  //width = referenceStaff.querySelector(".clef").getBoundingClientRect().width
172
174
  return { x: x, yTop: yTop, yBottom: yBottom, width: clefCoords.width, height: clefCoords.height };
@@ -46,12 +46,22 @@ class Tabbar {
46
46
  this.exclusiveSelectHandler = (function exclusiveSelectHandler(e) {
47
47
  this.exclusiveSelect(e);
48
48
  }).bind(this);
49
- this.styleCache = new Map();
50
49
  this.sidebarHandler = (function sidebarHandler(e) {
51
50
  var _a, _b;
52
51
  //toggle
53
52
  var that = this;
54
53
  var elParent;
54
+ // initial style caching
55
+ if (!this.styleCache) {
56
+ this.styleCache = new Map();
57
+ Array.from(cq.getContainer(this.containerId).querySelectorAll(".openSidebar, .closedSidebar")).forEach(el => {
58
+ elParent = el.parentElement;
59
+ elParent.querySelectorAll(":scope > div").forEach(d => {
60
+ that.styleCache.set(d.id, d.getAttribute("style"));
61
+ });
62
+ });
63
+ return;
64
+ }
55
65
  if (this.sidebar.classList.contains("closedSidebar")) {
56
66
  Array.from(cq.getContainer(this.containerId).querySelectorAll(".closedSidebar")).forEach(el => {
57
67
  elParent = el.parentElement;
@@ -63,15 +73,14 @@ class Tabbar {
63
73
  (_b = (_a = document.getElementById(that.containerId)) === null || _a === void 0 ? void 0 : _a.querySelector("#" + key)) === null || _b === void 0 ? void 0 : _b.setAttribute("style", value);
64
74
  }
65
75
  }
66
- that.styleCache = new Map();
76
+ //that.styleCache = new Map<string, string>()
67
77
  }
68
78
  else {
69
- //document.getElementById("sidebarContainer").style.width = "0"
70
79
  Array.from(cq.getContainer(this.containerId).querySelectorAll(".openSidebar")).forEach(el => {
71
80
  elParent = el.parentElement;
72
81
  elParent.querySelectorAll(":scope > div").forEach(d => {
73
82
  that.styleCache.set(d.id, d.getAttribute("style"));
74
- d.removeAttribute("style");
83
+ //d.removeAttribute("style")
75
84
  });
76
85
  el.classList.add("closedSidebar");
77
86
  el.classList.remove("openSidebar");
@@ -596,7 +605,7 @@ class Tabbar {
596
605
  a.removeEventListener("click", this.customToolbarHandler);
597
606
  });
598
607
  cq.getContainer(this.containerId).removeEventListener("annotChanged", this.createAnnotListHandler);
599
- (0, interactjs_1.default)("#annotList").unset();
608
+ interactjs_1.default("#annotList").unset();
600
609
  }
601
610
  closeDropdown(ddButton) {
602
611
  if (ddButton.classList.contains("show")) {
@@ -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
- (0, interactjs_1.default)("#annotList").unset();
551
+ 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 = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .customAnnotShape")
34
+ this.shapeListener = 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 = (0, interactjs_1.default)("#" + this.containerId + " .annotText")
65
+ this.textListener = 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 = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .lineDragRect.x1")
96
+ this.lineListener = interactjs_1.default("#" + this.containerId + " #interactionOverlay .lineDragRect.x1")
97
97
  .draggable({
98
98
  listeners: {
99
99
  move: this.dragLineListener.bind(this),
@@ -271,7 +271,7 @@ class AnnotationChangeHandler {
271
271
  var pt = coordinates.transformToDOMMatrixCoordinates(event.clientX, event.clientY, cq.getInteractOverlay(this.containerId).querySelector("#annotationCanvas")); //new DOMPoint(event.clientX, event.clientY)
272
272
  var edx = pt.x; //.matrixTransform(this.canvasMatrix).x
273
273
  var edy = pt.y; //matrixTransform(this.canvasMatrix).y
274
- var ptDist = coordinates.transformToDOMMatrixCoordinates(target.getBoundingClientRect().x, event.target.getBoundingClientRect().y, cq.getInteractOverlay(this.containerId).querySelector("#annotationCanvas")); //new DOMPoint(target.getBoundingClientRect().x, event.target.getBoundingClientRect().y)
274
+ var ptDist = coordinates.transformToDOMMatrixCoordinates(target.getBoundingClientRect().x, event.target.getBoundingClientRect().y, cq.getInteractOverlay(this.containerId).querySelector("#annotationCanvas"));
275
275
  var distX = (parseFloat(target.getAttribute('distX'))) || edx - ptDist.x; //matrixTransform(this.canvasMatrix).x
276
276
  var distY = (parseFloat(target.getAttribute('distY'))) || edy - ptDist.y; //matrixTransform(this.canvasMatrix).y
277
277
  target.setAttribute("distX", distX.toString());
@@ -589,6 +589,18 @@ class AnnotationChangeHandler {
589
589
  }
590
590
  setAnnotations(annotations) {
591
591
  this.annotations = annotations;
592
+ // this.annotations.forEach(annot => {
593
+ // var annotElement = cq.getInteractOverlay(this.containerId).querySelector("#" + annot.sourceID + " .annotFO") as HTMLElement
594
+ // var h = annotElement.getBoundingClientRect().height
595
+ // var w = annotElement.getBoundingClientRect().width
596
+ // var ratio = parseFloat(annot.originalWidth) / w
597
+ // if(isNaN(ratio)) return
598
+ // annot.originalWidth = (w * ratio).toString()
599
+ // annot.originalHeight = (h * ratio).toString()
600
+ // annotElement.style.height = annot.originalHeight.toString() + "px"
601
+ // annotElement.style.width = annot.originalWidth.toString() + "px"
602
+ // console.log(annot, annotElement, this.annotations)
603
+ // })
592
604
  // var newFactor = parseInt((cq.getContainer(this.containerId).querySelector("#svgContainer") as HTMLElement).style?.width?.split("%")[0]) || 100
593
605
  // if (newFactor === this.factor) return this
594
606
  // var that = this
@@ -67,7 +67,7 @@ class CustomAnnotationShapeDrawer {
67
67
  this.updateCallback();
68
68
  }
69
69
  initRect(ulx, uly) {
70
- this.shapeID = (0, random_1.uuidv4)();
70
+ this.shapeID = 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 = (0, random_1.uuidv4)();
81
+ this.shapeID = random_1.uuidv4();
82
82
  this.canvas.append('ellipse')
83
83
  .attr('cx', cx)
84
84
  .attr('cy', cy)
@@ -27,9 +27,9 @@ class InsertModeHandler {
27
27
  }
28
28
  activateInsertMode(clicked = false) {
29
29
  var _a;
30
- if (this.annotationMode || this.harmonyMode) {
31
- this.insertDeactivate();
32
- }
30
+ // if (this.annotationMode || this.harmonyMode) {
31
+ // this.insertDeactivate()
32
+ // }
33
33
  // if (clicked) {
34
34
  // if (this.unselectMenuItem("clickInsert")) { return }
35
35
  // }
@@ -245,8 +245,8 @@ class InsertModeHandler {
245
245
  }
246
246
  that.m2s.setDurationNewNote(dur);
247
247
  if (that.m2s.setMarkedNoteDurations(dur)) {
248
- (0, MEIOperations_1.cleanUp)(that.m2s.getCurrentMei());
249
- var mei = (0, MEIConverter_1.restoreXmlIdTags)(that.m2s.getCurrentMei());
248
+ MEIOperations_1.cleanUp(that.m2s.getCurrentMei());
249
+ var mei = MEIConverter_1.restoreXmlIdTags(that.m2s.getCurrentMei());
250
250
  that.loadDataCallback("", mei, false);
251
251
  }
252
252
  });
@@ -266,8 +266,8 @@ class InsertModeHandler {
266
266
  }
267
267
  that.m2s.setDotsNewNote(dots);
268
268
  if (that.m2s.setMarkedNoteDots(dots)) {
269
- (0, MEIOperations_1.cleanUp)(that.m2s.getCurrentMei());
270
- var mei = (0, MEIConverter_1.restoreXmlIdTags)(that.m2s.getCurrentMei());
269
+ MEIOperations_1.cleanUp(that.m2s.getCurrentMei());
270
+ var mei = MEIConverter_1.restoreXmlIdTags(that.m2s.getCurrentMei());
271
271
  that.loadDataCallback("", mei, false);
272
272
  }
273
273
  });
@@ -271,7 +271,7 @@ class KeyModeHandler {
271
271
  this.setContainerId(this.containerId);
272
272
  var newNote = {
273
273
  pname: pname,
274
- id: (0, random_1.uuidv4)(),
274
+ id: random_1.uuidv4(),
275
275
  dur: this.m2s.getDurationNewNote(),
276
276
  dots: this.m2s.getDotsNewNote(),
277
277
  oct: oct,
@@ -347,7 +347,7 @@ class LabelHandler {
347
347
  }
348
348
  createInputBox(posx, posy, targetId, targetClass) {
349
349
  var textGroup = document.createElementNS(constants_1.constants._SVGNS_, "g");
350
- textGroup.setAttribute("id", (0, random_1.uuidv4)());
350
+ textGroup.setAttribute("id", random_1.uuidv4());
351
351
  textGroup.setAttribute("refElementId", targetId);
352
352
  var text = document.createElementNS(constants_1.constants._SVGNS_, "svg");
353
353
  text.classList.add("labelText");
@@ -12,7 +12,7 @@ class NoteDragHandler {
12
12
  }
13
13
  setListeners() {
14
14
  var that = this;
15
- this.noteDragListener = (0, interactjs_1.default)("#" + this.containerId + " #interactionOverlay .notehead rect")
15
+ this.noteDragListener = interactjs_1.default("#" + this.containerId + " #interactionOverlay .notehead rect")
16
16
  .draggable({
17
17
  startAxis: "y",
18
18
  lockAxis: "y",
@@ -76,17 +76,13 @@ class PhantomElementHandler {
76
76
  var _a, _b, _c, _d, _e;
77
77
  if (this.m2s.getLastMouseEnter().staff === null)
78
78
  return;
79
- // var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay)
80
- // var relX = pt.x
81
- // var relY = pt.y
82
79
  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)
80
+ if (!definitionScale)
84
81
  return;
85
- var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay);
82
+ var pt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, cq.getInteractOverlay(this.containerId));
86
83
  var relX = pt.x;
87
84
  var relY = pt.y;
88
- var dsCoords = coordinates.getDOMMatrixCoordinates(definitionScale, definitionScale.closest(".page"));
89
- //console.log(relX, dsCoords, definitionScale.getBoundingClientRect())
85
+ var dsCoords = coordinates.getDOMMatrixCoordinates(definitionScale, cq.getInteractOverlay(this.containerId));
90
86
  if (relX < dsCoords.left || relX > dsCoords.right) {
91
87
  this.isTrackingMouse = false;
92
88
  return;
@@ -117,9 +113,6 @@ class PhantomElementHandler {
117
113
  });
118
114
  this.setPhantomLineListeners();
119
115
  }
120
- // if(e.type === "draggingNote"){
121
- // console.log(phantomNoteElement, this.phantomLines)
122
- // }
123
116
  }
124
117
  removeLines() {
125
118
  var lines = this.interactionOverlay.querySelectorAll(".phantomLine");