vibe-editor 0.0.4 → 0.0.6

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 (78) hide show
  1. package/package.json +66 -61
  2. package/src/scripts/js/Core.js +28 -9
  3. package/src/scripts/js/entry.js +6 -5
  4. package/src/scripts/js/gui/Annotations.js +27 -12
  5. package/src/scripts/js/gui/ScoreManipulator.js +6 -4
  6. package/src/scripts/js/gui/Tabbar.js +13 -4
  7. package/src/scripts/js/handlers/AnnotationChangeHandler.js +13 -1
  8. package/src/scripts/js/handlers/InsertModeHandler.js +3 -3
  9. package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
  10. package/src/scripts/js/handlers/WindowHandler.js +7 -7
  11. package/src/scripts/js/scripts/Core.js +932 -0
  12. package/src/scripts/js/scripts/MusicProcessor.js +810 -0
  13. package/src/scripts/js/scripts/VIBE.js +219 -0
  14. package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
  15. package/src/scripts/js/scripts/gui/Annotations.js +549 -0
  16. package/src/scripts/js/scripts/gui/Cursor.js +203 -0
  17. package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
  18. package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
  19. package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
  20. package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
  21. package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
  22. package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
  23. package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
  24. package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
  25. package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
  26. package/src/scripts/js/scripts/handlers/Handler.js +2 -0
  27. package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
  28. package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
  29. package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
  30. package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
  31. package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +161 -0
  32. package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
  33. package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
  34. package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
  35. package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
  36. package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
  37. package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
  38. package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
  39. package/src/scripts/js/scripts/utils/Types.js +2 -0
  40. package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +32 -18
  41. package/src/scripts/js/scripts/utils/coordinates.js +78 -0
  42. package/src/scripts/js/utils/Mouse2SVG.js +11 -4
  43. package/src/scripts/js/utils/VerovioWrapper.js +4 -4
  44. package/src/scripts/js/utils/coordinates.js +26 -2
  45. package/src/styles/vibe.css +32 -6
  46. package/src/scripts/js/.DS_Store +0 -0
  47. package/src/scripts/js/MusicPlayer.js +0 -572
  48. package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
  49. package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
  50. package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
  51. package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
  52. package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
  53. package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
  54. package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
  55. package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
  56. package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
  57. package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
  58. package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
  59. package/src/scripts/js/handlers/SelectionHandler.js +0 -262
  60. package/src/scripts/js/utils/RectWrapper.js +0 -10
  61. package/src/scripts/js/utils/SVGFiller.js +0 -245
  62. package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
  63. package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
  64. /package/src/scripts/js/{assets → scripts/assets}/mei_template.js +0 -0
  65. /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
  66. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
  67. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
  68. /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
  69. /package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +0 -0
  70. /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
  71. /package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +0 -0
  72. /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
  73. /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
  74. /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
  75. /package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +0 -0
  76. /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
  77. /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
  78. /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const MeasureMatrix_1 = require("../datastructures/MeasureMatrix");
4
- const d3 = require("d3");
5
- const coordinates = require("../utils/coordinates");
6
- const cq = require("../utils/convenienceQueries");
7
- //@ts-ignore
8
- //const $ = H5P.jQuery;
9
- /**
10
- * @deprecated
11
- * Class that handles insert mode, events, and actions.
12
- */
13
- class NoteDragHandler {
14
- constructor(containerId) {
15
- this.wasDragged = false;
16
- this.setContainerId(containerId);
17
- this.dragInit();
18
- this.noteDraggedEvent = new Event("noteDragged");
19
- }
20
- setListeners() {
21
- }
22
- removeListeners() {
23
- }
24
- resetListeners() {
25
- this.removeListeners();
26
- this.setListeners();
27
- }
28
- /**
29
- * Initialize the dragging action and handler for selected elements.
30
- */
31
- dragInit() {
32
- // Adding listeners
33
- const dragBehaviour = d3.drag()
34
- .on('start', dragStarted.bind(this))
35
- .on('drag', this.dragging.bind(this))
36
- .on('end', this.dragEnded.bind(this));
37
- this.notes = document.querySelectorAll(".note, .notehead"); //d3.select("#" + this.containerId).selectAll(".note, .notehead");
38
- this.draggedOverlayElement = null;
39
- this.notes.call(dragBehaviour);
40
- // Drag effects
41
- function dragStarted() {
42
- var _a;
43
- this.draggedOverlayElement = d3.event.sourceEvent.currentTarget;
44
- this.draggedRootSVGElement = (_a = this.rootSVG.querySelector("#" + this.draggedOverlayElement.getAttribute("refId"))) === null || _a === void 0 ? void 0 : _a.closest(".note");
45
- this.dragStartCoords = [d3.event.x, d3.event.y]; //coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, document.getElementById(c._ROOTSVGID_))
46
- this.dx = 0; //this.dragStartCoords[0]
47
- this.dy = 0; //this.dragStartCoords[1]
48
- }
49
- }
50
- dragging() {
51
- if (this.draggedOverlayElement === null || this.draggedRootSVGElement === null)
52
- return;
53
- this.dx = d3.event.x;
54
- this.dy = d3.event.y;
55
- var overlayCoords = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, this.interactionOverlay);
56
- var diffY = Math.abs(this.dy - this.dragStartCoords[1]);
57
- if (diffY > 15) {
58
- this.wasDragged = true;
59
- }
60
- //snap while dragging
61
- this.m2m.defineNote(overlayCoords.x, overlayCoords.y, {});
62
- var newNote = [this.m2m.getNewNote().pname, this.m2m.getNewNote().oct];
63
- if (this.oldNote == undefined) {
64
- this.oldNote = newNote;
65
- }
66
- const relativeY = d3.event.y - this.dragStartCoords[1]; //d3.event.y - this.dragStartCoords[1]
67
- const relativeX = 0; //d3.event.x - this.dragStartCoords[0];
68
- //overlay and defscale have completely different viewbox dimensions
69
- var defScaleVBox = this.rootSVG.querySelector(".definition-scale").viewBox.baseVal;
70
- var overlayVBox = this.interactionOverlay.viewBox.baseVal;
71
- this.scaleX = defScaleVBox.width / overlayVBox.width;
72
- this.scaleY = defScaleVBox.height / overlayVBox.height;
73
- var shiftY = 10;
74
- shiftY = relativeY < 0 ? -shiftY : shiftY;
75
- if (!this.oldNote.every((v, i) => v === newNote[i])) {
76
- this.draggedOverlayElement.setAttribute('transform', 'translate(' + [relativeX, relativeY + shiftY] + ')');
77
- this.draggedRootSVGElement.setAttribute('transform', 'translate(' + [relativeX * this.scaleX, (relativeY + shiftY) * this.scaleY] + ')');
78
- this.oldNote = newNote;
79
- }
80
- }
81
- dragEnded() {
82
- if (this.draggedOverlayElement === null || this.draggedRootSVGElement === null)
83
- return;
84
- if (this.wasDragged) {
85
- this.notes.on("drag", null);
86
- this.wasDragged = false;
87
- this.draggedOverlayElement.dispatchEvent(this.noteDraggedEvent);
88
- this.container.querySelector("#" + this.draggedRootSVGElement.id).classList.remove(this.deleteHandler.getDeleteFlag()); //remove flag to delete after dragging
89
- const action = {
90
- action: "drag",
91
- param: { elementId: this.draggedRootSVGElement.id,
92
- //x: this.dx,
93
- //y: this.dy
94
- }
95
- };
96
- this.editCallback(action).then(() => {
97
- var attr = this.elementAttrCallback(this.draggedRootSVGElement.id);
98
- var mm = new MeasureMatrix_1.default();
99
- //mm.populateFromSVG(svg)
100
- mm.populateFromMEI(this.currentMEI);
101
- var staff = this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("staff");
102
- var measure = staff.closest("measure");
103
- var staffIdx = parseInt(staff.getAttribute("n")) - 1;
104
- var measureIdx = parseInt(measure.getAttribute("n")) - 1;
105
- var dur = this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("chord") !== null ? this.currentMEI.getElementById(this.draggedRootSVGElement.id).closest("chord").getAttribute("dur") : attr.dur;
106
- let newNote = {
107
- pname: attr.pname,
108
- oct: attr.oct.toString(),
109
- dur: dur,
110
- keysig: mm.get(measureIdx, staffIdx).keysig,
111
- rest: false,
112
- };
113
- this.musicPlayer.generateTone(newNote);
114
- });
115
- }
116
- }
117
- //////////////// GETTER/ SETTER ////////////
118
- setMusicPlayer(musicPlayer) {
119
- this.musicPlayer = musicPlayer;
120
- return this;
121
- }
122
- setCurrentMEI(xmlDoc) {
123
- this.currentMEI = xmlDoc;
124
- return this;
125
- }
126
- setM2M(m2m) {
127
- this.m2m = m2m;
128
- return this;
129
- }
130
- setDeleteHandler(deleteHandler) {
131
- this.deleteHandler = deleteHandler;
132
- return this;
133
- }
134
- setEditCallback(editCallback) {
135
- this.editCallback = editCallback;
136
- return this;
137
- }
138
- setElementAttrCallback(elementAttrCallback) {
139
- this.elementAttrCallback = elementAttrCallback;
140
- return this;
141
- }
142
- setContainerId(id) {
143
- this.containerId = id;
144
- this.container = document.getElementById(id);
145
- this.interactionOverlay = cq.getInteractOverlay(id);
146
- this.rootSVG = cq.getRootSVG(id);
147
- return this;
148
- }
149
- }
150
- exports.default = NoteDragHandler;
@@ -1,262 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mappings_1 = require("../utils/mappings");
4
- const coordinates = require("../utils/coordinates");
5
- const cq = require("../utils/convenienceQueries");
6
- const marked = "marked";
7
- class SelectionHandler {
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;
15
- /**
16
- * Mark clicked element
17
- */
18
- this.markedHandler = (function markedHandler(e) {
19
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
20
- if (!this.shiftPressed) {
21
- Array.from(this.container.querySelectorAll("." + marked)).forEach(n => {
22
- n.classList.remove(marked);
23
- });
24
- }
25
- e.preventDefault();
26
- var target = e.target;
27
- if (target.getAttribute("refId") === null) {
28
- target = target.closest("[refId]");
29
- target = this.vrvSVG.querySelector("#" + target.getAttribute("refId"));
30
- }
31
- target = target.closest(".note, .rest, .mRest, .chord") || target;
32
- target.classList.add(marked);
33
- this.scoreGraph.setCurrentNodeById(target.id);
34
- // change the selected durations in the toolbar
35
- var firstMarkedNote = (_a = this.vrvSVG.querySelector(".chord.marked, .note.marked, .rest.marked")) === null || _a === void 0 ? void 0 : _a.id;
36
- var meiNote = this.m2s.getCurrentMei().getElementById(firstMarkedNote);
37
- if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
38
- meiNote = meiNote.closest("chord");
39
- }
40
- if ((firstMarkedNote === null || firstMarkedNote === void 0 ? void 0 : firstMarkedNote.length) > 0) {
41
- (_b = document.getElementById(this.containerId)) === null || _b === void 0 ? void 0 : _b.querySelectorAll("#noteGroup *, #dotGroup *, #modGroup *, #articGroup *").forEach(b => b.classList.remove("selected"));
42
- (_d = (_c = document.getElementById(this.containerId)) === null || _c === void 0 ? void 0 : _c.querySelectorAll(".lastAdded")) === null || _d === void 0 ? void 0 : _d.forEach(la => la.classList.remove("lastAdded"));
43
- //select buttons for given note state
44
- var modBtnId = cq.getContainer(this.containerId).querySelector("#customToolbar #articGroup") !== null ? "artic" : "accid";
45
- (_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");
46
- if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
47
- meiNote = meiNote.closest("chord");
48
- }
49
- (_h = (_g = document.getElementById(this.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");
50
- (_k = (_j = document.getElementById(this.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");
51
- }
52
- }).bind(this);
53
- this.shiftKeyHandler = (function shiftKeyHandler(e) {
54
- if (e.key === "Shift") {
55
- if (e.type === "keydown") {
56
- this.shiftPressed = true;
57
- }
58
- else if (e.type === "keyup") {
59
- this.shiftPressed = false;
60
- }
61
- }
62
- console.log("shiftPressed ", this.shiftPressed);
63
- }).bind(this);
64
- this.setContainerId(containerId);
65
- this.selectStartEvent = new Event("selectStart");
66
- this.selectEndEvent = new Event("selectEnd");
67
- this.shiftPressed = false;
68
- this.setKeyListeners();
69
- var that = this;
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));
95
- that.initialX = pt.x; //d3.event.x
96
- that.initialY = pt.y; //d3.event.y
97
- if (!document.getElementById(that.containerId).classList.contains("harmonyMode") && !that.shiftPressed) { //!that.harmonyHandler.getGlobal()){
98
- that.m2s.getNoteBBoxes().forEach(bb => {
99
- let note = that.vrvSVG.querySelector("#" + bb.id);
100
- note.classList.remove(marked);
101
- });
102
- }
103
- that.initRect(that.initialX, that.initialY);
104
- this.isSelecting = true;
105
- }).bind(this);
106
- this.selecting = (function selecting(e) {
107
- e.preventDefault();
108
- if (document.getElementById(that.containerId).classList.contains("annotMode"))
109
- return; // prevent selecting when resizing annotation objects
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));
114
- const curX = pt.x; //d3.event.x + container.scrollLeft
115
- const curY = pt.y; //d3.event.y + container.scrollTop
116
- const newX = curX < that.initialX ? curX : that.initialX;
117
- const newY = curY < that.initialY ? curY : that.initialY;
118
- const width = curX < that.initialX ? that.initialX - curX : curX - that.initialX;
119
- const height = curY < that.initialY ? that.initialY - curY : curY - that.initialY;
120
- that.updateRect(newX, newY, width, height);
121
- var rect = that.interactionOverlay.querySelector("#selectRect");
122
- var rectpt = coordinates.getDOMMatrixCoordinates(rect, that.vrvSVG);
123
- var rectHeightpt = rectpt.height; //Math.abs(rectpt.y - ptBottom.matrixTransform(rootMatrix.getScreenCTM().inverse()).y)
124
- var rectWidthpt = rectpt.width; //Math.abs(rectpt.x - ptRight.matrixTransform(rootMatrix.getScreenCTM().inverse()).x)
125
- var rx = rectpt.x;
126
- var ry = rectpt.y;
127
- var noteBBoxes = that.m2s.getNoteBBoxes();
128
- noteBBoxes.forEach(bb => {
129
- var note = cq.getVrvSVG(that.containerId).querySelector("#" + bb.id);
130
- let stem = note.querySelector(".stem");
131
- let accid = note.querySelector(".accid");
132
- if (bb.x >= rx &&
133
- //bb.x <= rx + rectBBox.width &&
134
- bb.x <= rx + rectWidthpt &&
135
- bb.y >= ry &&
136
- //bb.y <= ry + rectBBox.height
137
- bb.y <= ry + rectHeightpt) {
138
- note.classList.add(marked);
139
- if (stem !== null)
140
- stem.classList.add(marked);
141
- var chord = note.closest(".chord");
142
- if (chord !== null) {
143
- //if(!chord.classList.contains(marked))
144
- let noteArr = Array.from(chord.querySelectorAll(".note"));
145
- if (noteArr.every(c => c.classList.contains(marked)) && noteArr.length > 0) {
146
- chord.classList.add(marked);
147
- }
148
- }
149
- }
150
- else if (!that.shiftPressed) {
151
- note.classList.remove(marked);
152
- stem === null || stem === void 0 ? void 0 : stem.classList.remove(marked);
153
- accid === null || accid === void 0 ? void 0 : accid.classList.remove(marked);
154
- var chord = note.closest(".chord");
155
- chord === null || chord === void 0 ? void 0 : chord.classList.remove(marked);
156
- }
157
- });
158
- }).bind(this);
159
- this.selEnd = (function selEnd(e) {
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;
169
- if (document.getElementById(that.containerId).classList.contains("annotMode"))
170
- return; // prevent selecting when resizing annotation objects
171
- var selectRect = cq.getInteractOverlay(that.containerId).querySelector("#selectRect");
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") {
173
- document.dispatchEvent(that.selectEndEvent);
174
- }
175
- selectRect === null || selectRect === void 0 ? void 0 : selectRect.remove();
176
- var firstMarkedNote = (_a = that.vrvSVG.querySelector(".chord.marked, .note.marked, .rest.marked")) === null || _a === void 0 ? void 0 : _a.id;
177
- var meiNote = that.m2s.getCurrentMei().getElementById(firstMarkedNote);
178
- (_c = (_b = document.getElementById(that.containerId)) === null || _b === void 0 ? void 0 : _b.querySelectorAll(".lastAdded")) === null || _c === void 0 ? void 0 : _c.forEach(la => la.classList.remove("lastAdded"));
179
- if ((firstMarkedNote === null || firstMarkedNote === void 0 ? void 0 : firstMarkedNote.length) > 0) {
180
- (_d = document.getElementById(that.containerId)) === null || _d === void 0 ? void 0 : _d.querySelectorAll("#noteGroup *, #dotGroup *, #modGroup *, #articGroup *").forEach(b => b.classList.remove("selected"));
181
- //select buttons for given note state
182
- var modBtnId = that.container.querySelector("#customToolbar #articGroup") !== null ? "artic" : "accid";
183
- (_f = (_e = document.getElementById(that.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");
184
- if ((meiNote === null || meiNote === void 0 ? void 0 : meiNote.closest("chord")) !== null) {
185
- meiNote = meiNote.closest("chord");
186
- }
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");
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");
189
- }
190
- //this.interactionOverlay.dispatchEvent(new Event("resetClickHandler"))
191
- }).bind(this);
192
- this.resetListeners();
193
- }
194
- initRect(ulx, uly) {
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);
205
- }
206
- updateRect(newX, newY, currentWidth, 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());
212
- }
213
- removeListeners() {
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);
218
- this.interactionOverlay.querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
219
- el.removeEventListener("click", this.markedHandler);
220
- });
221
- this.interactionOverlay.removeEventListener("keydown", this.shiftKeyHandler);
222
- this.interactionOverlay.removeEventListener("keyup", this.shiftKeyHandler);
223
- }
224
- setListeners() {
225
- //this.interactionOverlay.call(this.dsa);
226
- cq.getInteractOverlay(this.containerId).querySelectorAll(".note, .rest, .mRest, .notehead").forEach(el => {
227
- el.addEventListener("click", this.markedHandler);
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);
233
- }
234
- setKeyListeners() {
235
- this.interactionOverlay.addEventListener("keydown", this.shiftKeyHandler);
236
- this.interactionOverlay.addEventListener("keyup", this.shiftKeyHandler);
237
- }
238
- resetListeners() {
239
- this.removeListeners();
240
- this.setListeners();
241
- }
242
- ///////// GETTER/ SETTER ////////
243
- setm2s(m2s) {
244
- this.m2s = m2s;
245
- return this;
246
- }
247
- setScoreGraph(sg) {
248
- this.scoreGraph = sg;
249
- return this;
250
- }
251
- setContainerId(id) {
252
- this.containerId = id;
253
- this.container = document.getElementById(id);
254
- this.interactionOverlay = cq.getInteractOverlay(id);
255
- this.vrvSVG = cq.getVrvSVG(id);
256
- return this;
257
- }
258
- getIsSelecting() {
259
- return this.isSelecting;
260
- }
261
- }
262
- exports.default = SelectionHandler;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const react_1 = require("react");
4
- const react_color_1 = require("react-color");
5
- class CoreReactWrapper extends react_1.default.Component {
6
- render() {
7
- return (react_1.default.createElement("div", null,
8
- react_1.default.createElement(react_color_1.SketchPicker, null)));
9
- }
10
- }
@@ -1,245 +0,0 @@
1
- "use strict";
2
- /**
3
- * Class to fill SVG of Score in HTML with information from underlying mei
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const random_1 = require("./random");
7
- class SVGFiller {
8
- constructor() {
9
- this.allowedMeiClasses = ["marked"];
10
- this.x = 0;
11
- this.y = 0;
12
- }
13
- /**
14
- * Fill SVG in Dom with relevant mei Information
15
- * @param mei Document from MEI
16
- */
17
- fillSVG(mei) {
18
- this.fillSystemCounts(mei);
19
- this.countBarlines();
20
- return this;
21
- }
22
- /**
23
- * Fill measure, staff and layer with n attributes from MEI
24
- * @param mei Document from MEI
25
- */
26
- fillSystemCounts(mei) {
27
- var that = this;
28
- var elements = Array.from(mei.querySelectorAll("measure, staff, layer"));
29
- elements.forEach(e => {
30
- if (e.id !== "") {
31
- var svgElement = that.container.querySelector("#" + e.id);
32
- if (svgElement === null || e.getAttribute("n") === null) {
33
- return;
34
- }
35
- svgElement.setAttribute("n", e.getAttribute("n"));
36
- }
37
- });
38
- return this;
39
- }
40
- cacheClasses() {
41
- //var svg = document.querySelector("#"+this.containerId + " #vrvSVG")
42
- var svg = document.querySelector("#" + this.containerId);
43
- if (svg === null) {
44
- return this;
45
- }
46
- this.classListMap = new Map();
47
- svg.querySelectorAll("*").forEach(el => {
48
- var _a;
49
- //if(el.tagName.toLowerCase() === "g" && el.getAttribute("id") !== null){
50
- if (el.getAttribute("id") !== null) {
51
- if (!this.classListMap.has(el.id)) {
52
- this.classListMap.set(el.id, new Array());
53
- }
54
- var classes = (_a = el.getAttribute("class")) === null || _a === void 0 ? void 0 : _a.split(" ");
55
- classes === null || classes === void 0 ? void 0 : classes.forEach(c => {
56
- if (!this.classListMap.get(el.id).includes(c)) {
57
- this.classListMap.get(el.id).push(c.slice());
58
- }
59
- });
60
- }
61
- });
62
- return this;
63
- }
64
- cacheScales() {
65
- var svg = document.querySelector("#" + this.containerId);
66
- if (svg === null) {
67
- return this;
68
- }
69
- this.scaleListMap = new Map();
70
- svg.querySelectorAll("[transform]").forEach(el => {
71
- if (el.getAttribute("id") !== null) {
72
- var tattr = el.getAttribute("transform");
73
- if (tattr.includes("scale")) {
74
- if (!this.scaleListMap.has(el.id)) {
75
- this.scaleListMap.set(el.id, tattr);
76
- }
77
- }
78
- }
79
- });
80
- return this;
81
- }
82
- copyClassesFromMei(mei) {
83
- if (this.classListMap == undefined) {
84
- return this;
85
- }
86
- mei.querySelectorAll("score *").forEach(el => {
87
- var _a;
88
- if (el.hasAttribute("class")) {
89
- var id = el.getAttribute("id") || el.getAttribute("xml:id");
90
- if (!this.classListMap.has(id)) {
91
- this.classListMap.set(id, new Array());
92
- }
93
- var classes = (_a = el.getAttribute("class")) === null || _a === void 0 ? void 0 : _a.split(" ");
94
- classes === null || classes === void 0 ? void 0 : classes.forEach(c => {
95
- if (!this.classListMap.get(id).includes(c) && this.allowedMeiClasses.includes(c)) {
96
- this.classListMap.get(id).push(c.slice());
97
- }
98
- });
99
- el.removeAttribute("class");
100
- }
101
- });
102
- return this;
103
- }
104
- /**
105
- * Reload all the classes which where distributed before
106
- * @returns this (for chaining convenience)
107
- */
108
- loadClasses(element = null) {
109
- if (this.classListMap == undefined) {
110
- return this;
111
- }
112
- if (element !== null) {
113
- var value = this.classListMap.get(element.id);
114
- if (value == undefined)
115
- return this;
116
- value.forEach(v => {
117
- if (v !== "") {
118
- element.classList.add(v);
119
- }
120
- });
121
- }
122
- else {
123
- for (const [key, value] of this.classListMap.entries()) {
124
- var el = this.container.querySelector("#" + key);
125
- if (el !== null) {
126
- //el.removeAttribute("class")
127
- value.forEach(v => {
128
- if (v !== "") {
129
- el.classList.add(v);
130
- }
131
- });
132
- }
133
- }
134
- }
135
- return this;
136
- }
137
- loadScales(element = null) {
138
- if (this.scaleListMap == undefined) {
139
- return this;
140
- }
141
- if (element !== null) {
142
- var value = this.scaleListMap.get(element.id);
143
- if (value == undefined)
144
- return this;
145
- element.style.transform = value;
146
- element.setAttribute("transform", value);
147
- }
148
- else {
149
- for (const [key, value] of this.scaleListMap.entries()) {
150
- var el = this.container.querySelector("#" + key);
151
- if (el !== null) {
152
- el.style.transform = value;
153
- el.setAttribute("transform", value);
154
- }
155
- }
156
- }
157
- return this;
158
- }
159
- repositionSVG(svg) {
160
- var _a;
161
- var transformList = ((_a = svg.getAttribute("transform")) === null || _a === void 0 ? void 0 : _a.split(") ")) || new Array();
162
- console.log(svg.getAttribute("transform"), transformList);
163
- var hasTranslate = false;
164
- transformList.forEach((t, i) => {
165
- if (t.includes("translate")) {
166
- transformList[i] = "translate(" + this.x + " " + this.y + ")";
167
- hasTranslate = true;
168
- }
169
- if (t.slice(-1) !== ")") {
170
- transformList[i] = transformList[i] + ")";
171
- }
172
- });
173
- if (!hasTranslate) {
174
- transformList.push("translate(" + this.x + " " + this.y + ")");
175
- }
176
- var trattr = transformList.join(" ");
177
- console.log(trattr);
178
- svg.setAttribute("transform", trattr);
179
- return this;
180
- }
181
- /**
182
- * Merge all tspans in a harm object in the top tspan to avoid columns for (especially in Firefox browsers)
183
- * @returns
184
- */
185
- clearTspan() {
186
- var gelements = this.container.querySelectorAll("g .harm");
187
- gelements.forEach(g => {
188
- var textEl = g.querySelector("text");
189
- var textTspan = g.querySelectorAll("tspan");
190
- var text = "";
191
- if (textTspan.length <= 2) {
192
- return;
193
- }
194
- text = textTspan[0].textContent;
195
- text = text.replace(/ /g, '');
196
- text = text.replace(/\n/g, '');
197
- textEl.querySelector("tspan").firstElementChild.textContent = text;
198
- textEl.querySelector("tspan").firstElementChild.setAttribute("font-family", "VerovioText");
199
- textTspan.forEach((tp, idx) => {
200
- if (idx >= 2) {
201
- tp.remove();
202
- }
203
- });
204
- });
205
- return this;
206
- }
207
- countBarlines() {
208
- this.container.querySelectorAll(".barLine").forEach(bl => {
209
- bl.querySelectorAll("path").forEach((p, idx) => {
210
- p.setAttribute("n", (idx + 1).toString());
211
- });
212
- });
213
- }
214
- distributeIds(element, propagation = false) {
215
- if (propagation) {
216
- var id = element.id !== "" ? element.id : element.getAttribute("refId");
217
- Array.from(element.children).forEach(c => {
218
- var selfId = c.id !== "" ? c.id : c.getAttribute("refId");
219
- if (selfId === null && id !== null) {
220
- c.setAttribute("refId", id);
221
- }
222
- this.distributeIds(c, true);
223
- });
224
- }
225
- else {
226
- Array.from(element.querySelectorAll("*")).forEach(el => {
227
- if (el.id === "") {
228
- el.setAttribute("id", random_1.uuidv4());
229
- }
230
- });
231
- }
232
- return this;
233
- }
234
- setContainerId(containerId) {
235
- this.containerId = containerId;
236
- this.container = document.getElementById(containerId);
237
- return this;
238
- }
239
- setXY(x, y) {
240
- this.x = x || 0;
241
- this.y = y || 0;
242
- //console.log("müssen die koordinaten noch umgerechnet werden???", x, y)
243
- }
244
- }
245
- exports.default = SVGFiller;