vibe-editor 0.0.4 → 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.
- package/package.json +65 -61
- package/src/scripts/js/Core.js +28 -9
- package/src/scripts/js/entry.js +6 -5
- package/src/scripts/js/gui/Annotations.js +27 -12
- package/src/scripts/js/gui/ScoreManipulator.js +6 -4
- package/src/scripts/js/gui/Tabbar.js +13 -4
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +13 -1
- package/src/scripts/js/handlers/InsertModeHandler.js +3 -3
- package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
- package/src/scripts/js/handlers/WindowHandler.js +7 -7
- package/src/scripts/js/scripts/Core.js +932 -0
- package/src/scripts/js/scripts/MusicProcessor.js +810 -0
- package/src/scripts/js/scripts/VIBE.js +219 -0
- package/src/scripts/js/scripts/datastructures/MeasureMatrix.js +156 -0
- package/src/scripts/js/scripts/gui/Annotations.js +549 -0
- package/src/scripts/js/scripts/gui/Cursor.js +203 -0
- package/src/scripts/js/scripts/gui/PhantomElement.js +132 -0
- package/src/scripts/js/scripts/gui/ScoreManipulator.js +188 -0
- package/src/scripts/js/scripts/gui/Tabbar.js +705 -0
- package/src/scripts/js/{gui/Toolbar copy.js → scripts/gui/Toolbar.js} +15 -11
- package/src/scripts/js/scripts/handlers/AnnotationChangeHandler.js +650 -0
- package/src/scripts/js/scripts/handlers/ClickModeHandler.js +535 -0
- package/src/scripts/js/{gui → scripts/handlers}/CustomAnnotationShapeDrawer.js +34 -17
- package/src/scripts/js/{handlers/ModHandler.js → scripts/handlers/CustomToolbarHandler.js} +54 -66
- package/src/scripts/js/scripts/handlers/GlobalKeyboardHandler.js +372 -0
- package/src/scripts/js/scripts/handlers/Handler.js +2 -0
- package/src/scripts/js/{handlers/InsertModeHandler_deprecated.js → scripts/handlers/InsertModeHandler.js} +117 -164
- package/src/scripts/js/scripts/handlers/KeyModeHandler.js +405 -0
- package/src/scripts/js/scripts/handlers/LabelHandler.js +463 -0
- package/src/scripts/js/scripts/handlers/NoteDragHandler.js +97 -0
- package/src/scripts/js/scripts/handlers/PhantomElementHandler.js +168 -0
- package/src/scripts/js/scripts/handlers/ScoreManipulatorHandler.js +233 -0
- package/src/scripts/js/scripts/handlers/SidebarHandler.js +506 -0
- package/src/scripts/js/scripts/handlers/TooltipHandler.js +132 -0
- package/src/scripts/js/scripts/handlers/WindowHandler.js +278 -0
- package/src/scripts/js/scripts/utils/MEIOperations.js +2121 -0
- package/src/scripts/js/{utils/Mouse2MEI.js → scripts/utils/Mouse2SVG.js} +225 -57
- package/src/scripts/js/scripts/utils/SVGEditor.js +453 -0
- package/src/scripts/js/scripts/utils/Types.js +2 -0
- package/src/scripts/js/{utils/VerovioWrapper copy.js → scripts/utils/VerovioWrapper.js} +35 -21
- package/src/scripts/js/scripts/utils/coordinates.js +54 -0
- package/src/scripts/js/utils/Mouse2SVG.js +11 -4
- package/src/scripts/js/utils/VerovioWrapper.js +4 -4
- package/src/scripts/js/utils/coordinates.js +26 -2
- package/src/scripts/js/.DS_Store +0 -0
- package/src/scripts/js/MusicPlayer.js +0 -572
- package/src/scripts/js/datastructures/ScoreGraph copy.js +0 -432
- package/src/scripts/js/gui/CustomAnnotationDrawer.js +0 -114
- package/src/scripts/js/handlers/AnnotationDragHandler.js +0 -113
- package/src/scripts/js/handlers/AnnotationLineHandler.js +0 -113
- package/src/scripts/js/handlers/ArticulationHandler.js +0 -20
- package/src/scripts/js/handlers/HarmonyHandler.js +0 -282
- package/src/scripts/js/handlers/InsertModeHandler copy.js +0 -423
- package/src/scripts/js/handlers/KeyModeHandler copy.js +0 -407
- package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +0 -411
- package/src/scripts/js/handlers/NoteDragHandler copy.js +0 -148
- package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +0 -150
- package/src/scripts/js/handlers/SelectionHandler.js +0 -262
- package/src/scripts/js/utils/RectWrapper.js +0 -10
- package/src/scripts/js/utils/SVGFiller.js +0 -245
- package/src/scripts/js/utils/VerovioWrapperLocal.js +0 -156
- package/src/scripts/js/utils/firefoxBBoxes.js +0 -143
- package/src/styles/vibe.css +0 -785
- /package/src/scripts/js/{assets → scripts/assets}/mei_template.js +0 -0
- /package/src/scripts/js/{constants.js → scripts/constants.js} +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph.js +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreGraph_deprecated.js +0 -0
- /package/src/scripts/js/{datastructures → scripts/datastructures}/ScoreNode.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/HarmonyLabel.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/Label.js +0 -0
- /package/src/scripts/js/{gui → scripts/gui}/TempoLabel.js +0 -0
- /package/src/scripts/js/{handlers → scripts/handlers}/DeleteHandler.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/DOMCreator.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/MEIConverter.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/ReactWrapper.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/convenienceQueries.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/mappings.js +0 -0
- /package/src/scripts/js/{utils → scripts/utils}/random.js +0 -0
@@ -0,0 +1,278 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const cq = require("../utils/convenienceQueries");
|
4
|
+
const meiConverter = require("../utils/MEIConverter");
|
5
|
+
class WindowHandler {
|
6
|
+
constructor() {
|
7
|
+
/**
|
8
|
+
* Update all elements that are affected by a window size change
|
9
|
+
*/
|
10
|
+
this.scrollingTimer = new Array();
|
11
|
+
this.updateFunction = this.update.bind(this);
|
12
|
+
/**
|
13
|
+
* Reload svg when registered events ended
|
14
|
+
*/
|
15
|
+
this.reloadTimer = new Array();
|
16
|
+
this.reloadSVGFunction = this.reloadSVG.bind(this);
|
17
|
+
this.toggleCTRLFunction = this.toggleCTRL.bind(this);
|
18
|
+
this.deltaTemp = 1;
|
19
|
+
this.zoomTimer = new Array();
|
20
|
+
this.wheelZoomFunction = this.wheelZoom.bind(this);
|
21
|
+
this.clickZoomFunction = this.clickZoom.bind(this);
|
22
|
+
this.cacheContainerAttrFunction = this.cacheContainerAttr.bind(this);
|
23
|
+
this.loadContainerAttrFunction = this.loadContainerAttr.bind(this);
|
24
|
+
this.ctrlPressed = false;
|
25
|
+
this.w = window;
|
26
|
+
while (this.w !== this.w.parent) {
|
27
|
+
this.w = this.w.parent;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
setListeners() {
|
31
|
+
this.eventContainer = this.container;
|
32
|
+
window.addEventListener("scroll", this.updateFunction);
|
33
|
+
//window.addEventListener("resize", this.update)
|
34
|
+
this.w.addEventListener("resize", this.reloadSVGFunction);
|
35
|
+
this.w.addEventListener("deviceorientation", this.updateFunction);
|
36
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("transitionend", this.updateFunction);
|
37
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("transitionend", this.reloadSVGFunction);
|
38
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("resizemove", this.updateFunction);
|
39
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("resizemove", this.reloadSVGFunction);
|
40
|
+
this.vrvSVG.addEventListener("scroll", this.updateFunction);
|
41
|
+
//this.vrvSVG.addEventListener("resize", this.update)
|
42
|
+
this.vrvSVG.addEventListener("deviceorientation", this.updateFunction);
|
43
|
+
document.addEventListener("fullscreenchange", this.updateFunction);
|
44
|
+
this.eventContainer.addEventListener("wheel", this.wheelZoomFunction);
|
45
|
+
this.eventContainer.querySelectorAll("#zoomGroup > button").forEach(b => b.addEventListener("click", this.clickZoomFunction));
|
46
|
+
document.addEventListener("keydown", this.toggleCTRLFunction);
|
47
|
+
document.addEventListener("keyup", this.toggleCTRLFunction);
|
48
|
+
this.eventContainer.addEventListener("loadingStart", this.cacheContainerAttrFunction);
|
49
|
+
this.eventContainer.addEventListener("loadingEnd", this.loadContainerAttrFunction);
|
50
|
+
return this;
|
51
|
+
}
|
52
|
+
removeListeners() {
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
54
|
+
window.removeEventListener("scroll", this.updateFunction);
|
55
|
+
this.w.removeEventListener("resize", this.updateFunction);
|
56
|
+
this.w.removeEventListener("resize", this.reloadSVGFunction);
|
57
|
+
this.w.removeEventListener("deviceorientation", this.updateFunction);
|
58
|
+
(_a = this.eventContainer) === null || _a === void 0 ? void 0 : _a.querySelector("#sidebarContainer").removeEventListener("transitionend", this.updateFunction);
|
59
|
+
(_b = this.eventContainer) === null || _b === void 0 ? void 0 : _b.querySelector("#sidebarContainer").removeEventListener("transitionend", this.reloadSVGFunction);
|
60
|
+
(_c = this.eventContainer) === null || _c === void 0 ? void 0 : _c.querySelector("#sidebarContainer").removeEventListener("resizemove", this.updateFunction);
|
61
|
+
(_d = this.eventContainer) === null || _d === void 0 ? void 0 : _d.querySelector("#sidebarContainer").removeEventListener("resizemove", this.reloadSVGFunction);
|
62
|
+
this.vrvSVG.removeEventListener("scroll", this.updateFunction);
|
63
|
+
//this.vrvSVG.removeEventListener("resize", this.update)
|
64
|
+
this.vrvSVG.removeEventListener("deviceorientation", this.updateFunction);
|
65
|
+
document.removeEventListener("fullscreenchange", this.updateFunction);
|
66
|
+
(_e = this.eventContainer) === null || _e === void 0 ? void 0 : _e.removeEventListener("wheel", this.wheelZoomFunction);
|
67
|
+
(_f = this.eventContainer) === null || _f === void 0 ? void 0 : _f.querySelectorAll("#zoomGroup > button").forEach(b => b.removeEventListener("click", this.clickZoomFunction));
|
68
|
+
document.removeEventListener("keydown", this.toggleCTRLFunction);
|
69
|
+
document.removeEventListener("keyup", this.toggleCTRLFunction);
|
70
|
+
(_g = this.eventContainer) === null || _g === void 0 ? void 0 : _g.removeEventListener("loadingStart", this.cacheContainerAttrFunction);
|
71
|
+
(_h = this.eventContainer) === null || _h === void 0 ? void 0 : _h.removeEventListener("loadingEnd", this.loadContainerAttrFunction);
|
72
|
+
return this;
|
73
|
+
}
|
74
|
+
update(e) {
|
75
|
+
var _a;
|
76
|
+
// special rule for transition events since so much with different propertynames are fired
|
77
|
+
if (e instanceof TransitionEvent) {
|
78
|
+
if (!e.propertyName.includes("width"))
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
var that = this;
|
82
|
+
(_a = this.scrollingTimer) === null || _a === void 0 ? void 0 : _a.forEach(s => clearTimeout(s));
|
83
|
+
this.scrollingTimer.push(setTimeout(function () {
|
84
|
+
var _a, _b, _c, _d;
|
85
|
+
that.updateXY();
|
86
|
+
(_a = that.m2s) === null || _a === void 0 ? void 0 : _a.update();
|
87
|
+
(_b = that.annotations) === null || _b === void 0 ? void 0 : _b.updateCanvas();
|
88
|
+
(_d = (_c = that.insertModeHandler) === null || _c === void 0 ? void 0 : _c.getPhantomNoteHandler()) === null || _d === void 0 ? void 0 : _d.resetCanvas();
|
89
|
+
that.scrollingTimer = new Array();
|
90
|
+
}, 500));
|
91
|
+
}
|
92
|
+
reloadSVG(e) {
|
93
|
+
var _a;
|
94
|
+
var t = e.target;
|
95
|
+
var that = this;
|
96
|
+
(_a = this.reloadTimer) === null || _a === void 0 ? void 0 : _a.forEach(r => clearTimeout(r));
|
97
|
+
if (t.id === "sidebarContainer" && !(e.propertyName.includes("width"))) {
|
98
|
+
// Timeout is needed to ensure, that transition has been completed and in eventphase 0
|
99
|
+
// Must be a slighty longer than transitiontime
|
100
|
+
this.reloadTimer.push(setTimeout(function () {
|
101
|
+
that.updateXY();
|
102
|
+
var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
|
103
|
+
that.loadDataCallback("", mei, false, null);
|
104
|
+
that.reloadTimer = new Array();
|
105
|
+
}, e.elapsedTime * 1000 + 10));
|
106
|
+
}
|
107
|
+
else if (e.type === "resize" || e.type === "resizemove" || t.id.startsWith("zoom")) {
|
108
|
+
this.reloadTimer.push(setTimeout(function () {
|
109
|
+
that.updateXY();
|
110
|
+
var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
|
111
|
+
that.loadDataCallback("", mei, false, null);
|
112
|
+
that.reloadTimer = new Array();
|
113
|
+
}, 500));
|
114
|
+
}
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Toggle ctrl or meta button. Is used to activte zoom function
|
118
|
+
* @param e
|
119
|
+
*/
|
120
|
+
toggleCTRL(e) {
|
121
|
+
if (e.key === "Meta" || e.key === "Control") {
|
122
|
+
if (e.type === "keydown") {
|
123
|
+
this.ctrlPressed = true;
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
this.ctrlPressed = false;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* Zoom according to movement of mouse wheel (also applies to two finger scroll gesture on trackpad).
|
132
|
+
* Can only be executed when container is active Element and when ctrl/meta is pressed.
|
133
|
+
* The scale is accumulated with every call of this method.
|
134
|
+
* @param e
|
135
|
+
* @returns
|
136
|
+
*/
|
137
|
+
wheelZoom(e) {
|
138
|
+
this.updateXY();
|
139
|
+
if (!cq.hasActiveElement(this.containerId))
|
140
|
+
return;
|
141
|
+
if (!this.ctrlPressed)
|
142
|
+
return;
|
143
|
+
e.preventDefault();
|
144
|
+
this.deltaTemp = this.deltaTemp + e.deltaY / 1000;
|
145
|
+
this.zoomSVG(this.deltaTemp);
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* Zoom when Zoombuttons are clicked (In div #zoomGroup).
|
149
|
+
*
|
150
|
+
* @param e
|
151
|
+
*/
|
152
|
+
clickZoom(e) {
|
153
|
+
var t = e.target;
|
154
|
+
if (t.id === "zoomInBtn") {
|
155
|
+
this.deltaTemp = this.deltaTemp + 100 / 1000;
|
156
|
+
}
|
157
|
+
else if (t.id === "zoomOutBtn") {
|
158
|
+
this.deltaTemp = this.deltaTemp - 100 / 1000;
|
159
|
+
}
|
160
|
+
this.zoomSVG(this.deltaTemp);
|
161
|
+
}
|
162
|
+
/**
|
163
|
+
* General zoom logic for all top level svgs (interactionOverlay + vrvSVG (= rendered score by verovio))
|
164
|
+
* @param delta
|
165
|
+
*/
|
166
|
+
zoomSVG(delta) {
|
167
|
+
var _a;
|
168
|
+
var that = this;
|
169
|
+
// ensure that with every call of all obsolete timeouts are deleted so that only one is left to be executed
|
170
|
+
(_a = this.zoomTimer) === null || _a === void 0 ? void 0 : _a.forEach(zt => clearTimeout(zt));
|
171
|
+
this.zoomTimer.push(setTimeout(function () {
|
172
|
+
var svgContainer = cq.getContainer(that.containerId).querySelector("#svgContainer");
|
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
|
+
});
|
195
|
+
}, 10));
|
196
|
+
}
|
197
|
+
/**
|
198
|
+
* Cache container attributes that need to be loaded after the score is loaded.
|
199
|
+
* - Scorllpositions of the containers
|
200
|
+
*
|
201
|
+
* Listens to "loadStart" Event in Core class
|
202
|
+
* @param e Event
|
203
|
+
*/
|
204
|
+
cacheContainerAttr(e) {
|
205
|
+
this.divScrolls = new Map();
|
206
|
+
var container = document.getElementById(this.containerId);
|
207
|
+
container.querySelectorAll(":scope div").forEach(d => {
|
208
|
+
this.divScrolls.set(d.id, { sl: d.scrollLeft, st: d.scrollTop });
|
209
|
+
});
|
210
|
+
}
|
211
|
+
/**
|
212
|
+
* Load all container attributes saved in @function cacheContainerAttr after score is loaded.
|
213
|
+
* Listens to "loadEnd" Event in Core class
|
214
|
+
* @param e Event
|
215
|
+
* @returns
|
216
|
+
*/
|
217
|
+
loadContainerAttr(e) {
|
218
|
+
var _a;
|
219
|
+
if (this.divScrolls == undefined)
|
220
|
+
return;
|
221
|
+
for (const [key, value] of this.divScrolls.entries()) {
|
222
|
+
(_a = document.getElementById(key)) === null || _a === void 0 ? void 0 : _a.scrollTo(value.sl, value.st);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* Set X and Y coordinates of the current boundingbox of the of the VerovioScore (#vrvSVG)
|
227
|
+
*/
|
228
|
+
updateXY() {
|
229
|
+
var _a;
|
230
|
+
var bb = (_a = document.getElementById(this.containerId)) === null || _a === void 0 ? void 0 : _a.querySelector("#vrvSVG").getBoundingClientRect();
|
231
|
+
this.x = bb.x;
|
232
|
+
this.y = bb.y;
|
233
|
+
}
|
234
|
+
resetListeners() {
|
235
|
+
this
|
236
|
+
.removeListeners()
|
237
|
+
.setListeners();
|
238
|
+
return this;
|
239
|
+
}
|
240
|
+
setm2s(m2s) {
|
241
|
+
this.m2s = m2s;
|
242
|
+
return this;
|
243
|
+
}
|
244
|
+
setAnnotations(annotations) {
|
245
|
+
this.annotations = annotations;
|
246
|
+
return this;
|
247
|
+
}
|
248
|
+
setCurrentMEI(mei) {
|
249
|
+
this.currentMEI = mei;
|
250
|
+
return this;
|
251
|
+
}
|
252
|
+
setContainerId(containerId) {
|
253
|
+
this.containerId = containerId;
|
254
|
+
this.container = document.getElementById(this.containerId);
|
255
|
+
this.interactionOverlay = cq.getInteractOverlay(this.containerId);
|
256
|
+
this.vrvSVG = cq.getVrvSVG(this.containerId);
|
257
|
+
return this;
|
258
|
+
}
|
259
|
+
setInsertModeHandler(imh) {
|
260
|
+
this.insertModeHandler = imh;
|
261
|
+
return this;
|
262
|
+
}
|
263
|
+
setLoadDataCallback(loadDataCallback) {
|
264
|
+
this.loadDataCallback = loadDataCallback;
|
265
|
+
return this;
|
266
|
+
}
|
267
|
+
setSVGReloadCallback(svgReloadCallback) {
|
268
|
+
this.svgReloadCallback = svgReloadCallback;
|
269
|
+
return this;
|
270
|
+
}
|
271
|
+
getX() {
|
272
|
+
return this.x;
|
273
|
+
}
|
274
|
+
getY() {
|
275
|
+
return this.y;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
exports.default = WindowHandler;
|