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.
- package/LICENSE +1 -1
- package/README.md +12 -9
- package/package.json +11 -5
- package/src/scripts/js/Core.js +212 -186
- package/src/scripts/js/MusicProcessor.js +286 -128
- package/src/scripts/js/{VerovioScoreEditor.js → VIBE.js} +62 -28
- package/src/scripts/js/assets/mei_template.js +5 -1
- package/src/scripts/js/datastructures/MeasureMatrix.js +6 -85
- package/src/scripts/js/datastructures/ScoreGraph.js +1 -1
- package/src/scripts/js/entry.js +3 -2
- package/src/scripts/js/gui/Annotations.js +188 -111
- package/src/scripts/js/gui/HarmonyLabel.js +26 -2
- package/src/scripts/js/gui/ScoreManipulator.js +61 -31
- package/src/scripts/js/gui/Tabbar.js +41 -21
- package/src/scripts/js/gui/Toolbar.js +4 -4
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +131 -60
- package/src/scripts/js/handlers/ClickModeHandler.js +406 -143
- package/src/scripts/js/handlers/CustomToolbarHandler.js +26 -24
- package/src/scripts/js/handlers/GlobalKeyboardHandler.js +12 -7
- package/src/scripts/js/handlers/InsertModeHandler.js +26 -32
- package/src/scripts/js/handlers/KeyModeHandler.js +12 -86
- package/src/scripts/js/handlers/LabelHandler.js +3 -2
- package/src/scripts/js/handlers/PhantomElementHandler.js +1 -1
- package/src/scripts/js/handlers/ScoreManipulatorHandler.js +101 -14
- package/src/scripts/js/handlers/SelectionHandler.js +80 -36
- package/src/scripts/js/handlers/SideBarHandler.js +10 -3
- package/src/scripts/js/handlers/WindowHandler.js +25 -4
- package/src/scripts/js/utils/DOMCreator.js +1 -1
- package/src/scripts/js/utils/MEIConverter.js +13 -1
- package/src/scripts/js/utils/MEIOperations.js +180 -187
- package/src/scripts/js/utils/Mouse2SVG.js +200 -43
- package/src/scripts/js/utils/ReactWrapper.js +46 -0
- package/src/scripts/js/utils/RectWrapper.js +10 -0
- package/src/scripts/js/utils/SVGEditor.js +94 -3
- package/src/scripts/js/utils/VerovioWrapper.js +6 -1
- package/src/scripts/js/utils/convenienceQueries.js +2 -0
- package/src/scripts/js/utils/mappings.js +322 -56
- package/src/styles/VerovioScoreEditor.css +0 -694
@@ -30,7 +30,7 @@ class Mouse2SVG {
|
|
30
30
|
var enteredFlag = "lastEntered";
|
31
31
|
var activeContainerFlag = "activeContainer";
|
32
32
|
this.container.addEventListener("mouseenter", function (e) {
|
33
|
-
Array.from(document.getElementsByClassName("
|
33
|
+
Array.from(document.getElementsByClassName("vibe-container")).forEach(ac => {
|
34
34
|
if (ac === that.container) {
|
35
35
|
if (!that.container.classList.contains(activeContainerFlag)) {
|
36
36
|
that.container.classList.add(activeContainerFlag);
|
@@ -42,7 +42,7 @@ class Mouse2SVG {
|
|
42
42
|
});
|
43
43
|
});
|
44
44
|
this.container.addEventListener("mouseleave", function (e) {
|
45
|
-
Array.from(document.getElementsByClassName("
|
45
|
+
Array.from(document.getElementsByClassName("vibe-container")).forEach(ac => {
|
46
46
|
if (ac === that.container) {
|
47
47
|
ac.classList.remove(activeContainerFlag);
|
48
48
|
}
|
@@ -93,7 +93,8 @@ class Mouse2SVG {
|
|
93
93
|
}
|
94
94
|
});
|
95
95
|
});
|
96
|
-
this.interactionOverlay.querySelectorAll(".layer").forEach(layer => {
|
96
|
+
//this.interactionOverlay.querySelectorAll(".layer.activeLayer").forEach(layer => {
|
97
|
+
this.container.querySelectorAll(".layer.activeLayer").forEach(layer => {
|
97
98
|
layer.addEventListener(mouseEventName, function (e) {
|
98
99
|
e.preventDefault();
|
99
100
|
var target = e.target;
|
@@ -104,6 +105,7 @@ class Mouse2SVG {
|
|
104
105
|
});
|
105
106
|
that.lastLayerMouseEnter.classList.add(enteredFlag);
|
106
107
|
}
|
108
|
+
console.log(that.lastLayerMouseEnter);
|
107
109
|
});
|
108
110
|
});
|
109
111
|
return this;
|
@@ -157,28 +159,66 @@ class Mouse2SVG {
|
|
157
159
|
this.measureMatrix.populateFromMEI(this.currentMEI);
|
158
160
|
var staves = this.currentMEI.querySelectorAll("staff"); //cq.getVrvSVG(this.containerId).querySelectorAll(".staff")
|
159
161
|
Array.from(staves).forEach(element => {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
162
|
+
const g = cq.getVrvSVG(this.containerId).querySelectorAll("#" + element.id + " > path");
|
163
|
+
const staff = element;
|
164
|
+
const idxStaff = parseInt(element.getAttribute("n")) - 1;
|
165
|
+
const closestMeasure = element.closest("measure");
|
166
|
+
const idxParentMeasure = parseInt(closestMeasure.getAttribute("n")) - 1;
|
167
|
+
const clefShape = this.measureMatrix.get(idxParentMeasure, idxStaff).clef;
|
168
|
+
const clefline = this.measureMatrix.get(idxParentMeasure, idxStaff).clefline;
|
169
|
+
const clefDisplacement = this.measureMatrix.get(idxParentMeasure, idxStaff).clefdisplacement;
|
166
170
|
Array.from(g).forEach((staffLine, idx) => {
|
167
171
|
if (staffLine.id === "") {
|
168
172
|
staffLine.id = random_1.uuidv4();
|
169
173
|
}
|
170
174
|
staffLine.classList.add("staffLine");
|
171
|
-
staffLine.classList.add("Clef" + clefShape);
|
175
|
+
staffLine.classList.add("Clef" + clefShape + clefline + clefDisplacement);
|
172
176
|
var map = null;
|
173
177
|
switch (clefShape) {
|
174
178
|
case "G":
|
175
|
-
|
179
|
+
switch (clefDisplacement) {
|
180
|
+
case "8below":
|
181
|
+
map = mappings_1.idxNoteMapGClefOctDown;
|
182
|
+
break;
|
183
|
+
case "8above":
|
184
|
+
map = mappings_1.idxNoteMapGClefOctUp;
|
185
|
+
break;
|
186
|
+
case null:
|
187
|
+
map = mappings_1.idxNoteMapGClef;
|
188
|
+
break;
|
189
|
+
}
|
176
190
|
break;
|
177
191
|
case "F":
|
178
|
-
|
192
|
+
switch (clefDisplacement) {
|
193
|
+
case "8below":
|
194
|
+
map = mappings_1.idxNoteMapFClefOctDown;
|
195
|
+
break;
|
196
|
+
case "8above":
|
197
|
+
map = mappings_1.idxNoteMapFClefOctUp;
|
198
|
+
break;
|
199
|
+
case null:
|
200
|
+
map = mappings_1.idxNoteMapFClef;
|
201
|
+
break;
|
202
|
+
}
|
179
203
|
break;
|
180
204
|
case "C":
|
181
|
-
|
205
|
+
switch (clefline) {
|
206
|
+
case "1":
|
207
|
+
map = mappings_1.idxNoteMapCClefSoprano;
|
208
|
+
break;
|
209
|
+
case "2":
|
210
|
+
map = mappings_1.idxNoteMapCClefMezzo;
|
211
|
+
break;
|
212
|
+
case "3":
|
213
|
+
map = mappings_1.idxNoteMapCClefAlto;
|
214
|
+
break;
|
215
|
+
case "4":
|
216
|
+
map = mappings_1.idxNoteMapCClefTenor;
|
217
|
+
break;
|
218
|
+
case "5":
|
219
|
+
map = mappings_1.idxNoteMapCClefBariton;
|
220
|
+
break;
|
221
|
+
}
|
182
222
|
break;
|
183
223
|
default:
|
184
224
|
console.error("No Clef found");
|
@@ -233,7 +273,7 @@ class Mouse2SVG {
|
|
233
273
|
* @param y client Coordinate
|
234
274
|
*/
|
235
275
|
defineNote(x, y, options) {
|
236
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
276
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
237
277
|
let staffIsEmpty = true;
|
238
278
|
let isLeftOfNote;
|
239
279
|
//let isRightOfNote: Boolean
|
@@ -261,23 +301,26 @@ class Mouse2SVG {
|
|
261
301
|
staffIsEmpty = false;
|
262
302
|
}
|
263
303
|
});
|
264
|
-
var currentStaffClef
|
265
|
-
var entries =
|
266
|
-
if
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
304
|
+
// var currentStaffClef: string
|
305
|
+
// var entries = this.getElementinVrvSVG(this.lastStaffMouseEnter?.getAttribute("refId"))?.querySelector(".staffLine")?.classList?.entries()
|
306
|
+
// if([null, undefined].some(n => entries == n)) return
|
307
|
+
// for (const [key, value] of entries) {
|
308
|
+
// if (value.includes("Clef")) {
|
309
|
+
// currentStaffClef = value
|
310
|
+
// break;
|
311
|
+
// }
|
312
|
+
// }
|
313
|
+
const col = (_g = this.getElementinVrvSVG((_f = this.lastStaffMouseEnter) === null || _f === void 0 ? void 0 : _f.getAttribute("refId"))) === null || _g === void 0 ? void 0 : _g.getAttribute("n");
|
314
|
+
const row = (_j = this.getElementinVrvSVG((_h = this.lastStaffMouseEnter) === null || _h === void 0 ? void 0 : _h.getAttribute("refId"))) === null || _j === void 0 ? void 0 : _j.closest(".measure").getAttribute("n");
|
315
|
+
const currentStaff = this.measureMatrix.get(row, col);
|
274
316
|
// Define relative position for click insert
|
275
317
|
// position should also consider right border of bounding box. Position should be
|
276
318
|
if (!staffIsEmpty) {
|
277
319
|
let nbb = [];
|
278
320
|
this.noteBBoxes.forEach(bb => {
|
279
321
|
var _a;
|
280
|
-
|
322
|
+
//console.log(bb.parentStaff.id === this.lastStaffMouseEnter?.getAttribute("refId"), Array.from(this.container.querySelectorAll(".activeLayer")).some(l => bb.parentLayer.id === l.id), Array.from(this.container.querySelectorAll(".activeLayer")), bb.parentLayer)
|
323
|
+
if (bb.parentStaff.id === ((_a = this.lastStaffMouseEnter) === null || _a === void 0 ? void 0 : _a.getAttribute("refId")) && Array.from(this.container.querySelectorAll(".activeLayer")).some(l => bb.parentLayer.id === l.id)) {
|
281
324
|
nbb.push(bb);
|
282
325
|
}
|
283
326
|
});
|
@@ -311,21 +354,93 @@ class Mouse2SVG {
|
|
311
354
|
let lineArr = aboveSystem ? this.phantomStaffLinesAbove : this.phantomStaffLinesBelow;
|
312
355
|
let aboveMap;
|
313
356
|
let belowMap;
|
314
|
-
switch (currentStaffClef) {
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
357
|
+
// switch (currentStaffClef) {
|
358
|
+
// case "ClefG2":
|
359
|
+
// aboveMap = idxNotePhantomMapAboveG
|
360
|
+
// belowMap = idxNotePhantomMapBelowG
|
361
|
+
// break;
|
362
|
+
// case "ClefF4":
|
363
|
+
// aboveMap = idxNotePhantomMapAboveF
|
364
|
+
// belowMap = idxNotePhantomMapBelowF
|
365
|
+
// break;
|
366
|
+
// case "ClefC1":
|
367
|
+
// aboveMap = idxNotePhantomMapAboveCSoprano
|
368
|
+
// belowMap = idxNotePhantomMapBelowCSoprano
|
369
|
+
// break;
|
370
|
+
// case "ClefC2":
|
371
|
+
// aboveMap = idxNotePhantomMapAboveCMezzo
|
372
|
+
// belowMap = idxNotePhantomMapBelowCMezzo
|
373
|
+
// break;
|
374
|
+
// case "ClefC3":
|
375
|
+
// aboveMap = idxNotePhantomMapAboveCAlto
|
376
|
+
// belowMap = idxNotePhantomMapBelowCAlto
|
377
|
+
// break;
|
378
|
+
// case "ClefC4":
|
379
|
+
// aboveMap = idxNotePhantomMapAboveCTenor
|
380
|
+
// belowMap = idxNotePhantomMapBelowCTenor
|
381
|
+
// break;
|
382
|
+
// case "ClefC5":
|
383
|
+
// aboveMap = idxNotePhantomMapAboveCBariton
|
384
|
+
// belowMap = idxNotePhantomMapBelowCBariton
|
385
|
+
// break;
|
386
|
+
// default:
|
387
|
+
// console.log("NO CLEF FOUND")
|
388
|
+
// }
|
389
|
+
if (currentStaff.clef === "G") {
|
390
|
+
switch (currentStaff.clefdisplacement) {
|
391
|
+
case null:
|
392
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveG;
|
393
|
+
belowMap = mappings_1.idxNotePhantomMapBelowG;
|
394
|
+
break;
|
395
|
+
case "8above":
|
396
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveGOctUp;
|
397
|
+
belowMap = mappings_1.idxNotePhantomMapBelowGOctUp;
|
398
|
+
break;
|
399
|
+
case "8below":
|
400
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveGOctDown;
|
401
|
+
belowMap = mappings_1.idxNotePhantomMapBelowGOctDown;
|
402
|
+
break;
|
403
|
+
}
|
404
|
+
}
|
405
|
+
else if (currentStaff.clef === "F") {
|
406
|
+
switch (currentStaff.clefdisplacement) {
|
407
|
+
case null:
|
408
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveF;
|
409
|
+
belowMap = mappings_1.idxNotePhantomMapBelowF;
|
410
|
+
break;
|
411
|
+
case "8above":
|
412
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveFOctUp;
|
413
|
+
belowMap = mappings_1.idxNotePhantomMapBelowFOctUp;
|
414
|
+
break;
|
415
|
+
case "8below":
|
416
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveFOctDown;
|
417
|
+
belowMap = mappings_1.idxNotePhantomMapBelowFOctDown;
|
418
|
+
break;
|
419
|
+
}
|
420
|
+
}
|
421
|
+
else if (currentStaff.clef === "C") {
|
422
|
+
switch (currentStaff.clefline) {
|
423
|
+
case "1":
|
424
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveCSoprano;
|
425
|
+
belowMap = mappings_1.idxNotePhantomMapBelowCSoprano;
|
426
|
+
break;
|
427
|
+
case "2":
|
428
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveCMezzo;
|
429
|
+
belowMap = mappings_1.idxNotePhantomMapBelowCMezzo;
|
430
|
+
break;
|
431
|
+
case "3":
|
432
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveCAlto;
|
433
|
+
belowMap = mappings_1.idxNotePhantomMapBelowCAlto;
|
434
|
+
break;
|
435
|
+
case "4":
|
436
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveCTenor;
|
437
|
+
belowMap = mappings_1.idxNotePhantomMapBelowCTenor;
|
438
|
+
break;
|
439
|
+
case "5":
|
440
|
+
aboveMap = mappings_1.idxNotePhantomMapAboveCBariton;
|
441
|
+
belowMap = mappings_1.idxNotePhantomMapBelowCBariton;
|
442
|
+
break;
|
443
|
+
}
|
329
444
|
}
|
330
445
|
let map = aboveSystem ? aboveMap : belowMap;
|
331
446
|
let mappingidx = 0;
|
@@ -398,12 +513,38 @@ class Mouse2SVG {
|
|
398
513
|
let map = null;
|
399
514
|
if (currentNearestStaffLine.classList.contains("ClefG")) {
|
400
515
|
map = mappings_1.idxNoteMapGClef;
|
516
|
+
if (currentNearestStaffLine.classList.contains("ClefG28above")) {
|
517
|
+
map = mappings_1.idxNoteMapGClefOctUp;
|
518
|
+
}
|
519
|
+
else if (currentNearestStaffLine.classList.contains("ClefG28below")) {
|
520
|
+
map = mappings_1.idxNoteMapGClefOctDown;
|
521
|
+
}
|
401
522
|
}
|
402
523
|
else if (currentNearestStaffLine.classList.contains("ClefF")) {
|
403
524
|
map = mappings_1.idxNoteMapFClef;
|
525
|
+
if (currentNearestStaffLine.classList.contains("ClefF48above")) {
|
526
|
+
map = mappings_1.idxNoteMapFClefOctUp;
|
527
|
+
}
|
528
|
+
else if (currentNearestStaffLine.classList.contains("ClefF48below")) {
|
529
|
+
map = mappings_1.idxNoteMapFClefOctDown;
|
530
|
+
}
|
404
531
|
}
|
405
532
|
else if (currentNearestStaffLine.classList.contains("ClefC")) {
|
406
|
-
|
533
|
+
if (Array.from(currentNearestStaffLine.classList).some(c => c.includes("ClefC1"))) {
|
534
|
+
map = mappings_1.idxNoteMapCClefSoprano;
|
535
|
+
}
|
536
|
+
else if (Array.from(currentNearestStaffLine.classList).some(c => c.includes("ClefC2"))) {
|
537
|
+
map = mappings_1.idxNoteMapCClefMezzo;
|
538
|
+
}
|
539
|
+
else if (Array.from(currentNearestStaffLine.classList).some(c => c.includes("ClefC3"))) {
|
540
|
+
map = mappings_1.idxNoteMapCClefAlto;
|
541
|
+
}
|
542
|
+
else if (Array.from(currentNearestStaffLine.classList).some(c => c.includes("ClefC4"))) {
|
543
|
+
map = mappings_1.idxNoteMapCClefTenor;
|
544
|
+
}
|
545
|
+
else if (Array.from(currentNearestStaffLine.classList).some(c => c.includes("ClefC5"))) {
|
546
|
+
map = mappings_1.idxNoteMapCClefBariton;
|
547
|
+
}
|
407
548
|
}
|
408
549
|
else {
|
409
550
|
throw new Error("No Note to Clef Mapping found");
|
@@ -419,7 +560,7 @@ class Mouse2SVG {
|
|
419
560
|
try {
|
420
561
|
pitch = cq.getInteractOverlay(this.containerId).querySelector("#" + options.staffLineId).getAttribute("class").split(" ");
|
421
562
|
}
|
422
|
-
catch (
|
563
|
+
catch (_q) {
|
423
564
|
return;
|
424
565
|
}
|
425
566
|
let p = pitch.filter(function (obj) {
|
@@ -468,8 +609,9 @@ class Mouse2SVG {
|
|
468
609
|
nearestNoteId: nearestNoteId,
|
469
610
|
relPosX: leftRightPos,
|
470
611
|
staffId: (_l = this.lastStaffMouseEnter) === null || _l === void 0 ? void 0 : _l.getAttribute("refId"),
|
612
|
+
layerId: (_o = this.container.querySelector(`#${(_m = this.lastStaffMouseEnter) === null || _m === void 0 ? void 0 : _m.getAttribute("refId")} .activeLayer`)) === null || _o === void 0 ? void 0 : _o.id,
|
471
613
|
chordElement: options.targetChord,
|
472
|
-
rest: (
|
614
|
+
rest: (_p = this.container.querySelector("#pauseNote")) === null || _p === void 0 ? void 0 : _p.classList.contains("selected")
|
473
615
|
};
|
474
616
|
this.newNote = newNote;
|
475
617
|
}
|
@@ -514,6 +656,7 @@ class Mouse2SVG {
|
|
514
656
|
}
|
515
657
|
var dist = Math.abs(x - posX);
|
516
658
|
var staffCondition = n.parentStaff === this.getElementinVrvSVG((_d = this.lastStaffMouseEnter) === null || _d === void 0 ? void 0 : _d.getAttribute("refId"));
|
659
|
+
staffCondition && (staffCondition = Array.from(this.container.querySelectorAll(".activeLayer")).some(l => n.parentLayer === l));
|
517
660
|
if (checkStaff === false) {
|
518
661
|
staffCondition = true;
|
519
662
|
dist = Math.sqrt(Math.abs(x - posX) ** 2 + Math.abs(y - posY) ** 2);
|
@@ -528,6 +671,17 @@ class Mouse2SVG {
|
|
528
671
|
});
|
529
672
|
return nextNote;
|
530
673
|
}
|
674
|
+
/**
|
675
|
+
* change to current VOice to interact with.
|
676
|
+
* createLayer if not does not exist
|
677
|
+
* @param staffN
|
678
|
+
* @param voiceN
|
679
|
+
*/
|
680
|
+
changeLayer(staffN, voiceN) {
|
681
|
+
if (!this.currentMEI.querySelector(`staff[n='${staffN}'] layer[n='${voiceN}']`)) {
|
682
|
+
meiOperation.addLayerForStaff(this.currentMEI, staffN, voiceN);
|
683
|
+
}
|
684
|
+
}
|
531
685
|
///// GETTER/ SETTER ///////
|
532
686
|
getLastMouseEnter() {
|
533
687
|
return { layer: this.lastLayerMouseEnter, staff: this.lastStaffMouseEnter, measure: this.lastMeasureMouseEnter, system: this.lastSystemMouseEnter };
|
@@ -681,6 +835,9 @@ class Mouse2SVG {
|
|
681
835
|
return "4";
|
682
836
|
}
|
683
837
|
switch (selEl.id) {
|
838
|
+
case "breveNote":
|
839
|
+
dur = 0.5;
|
840
|
+
break;
|
684
841
|
case "fullNote":
|
685
842
|
dur = 1;
|
686
843
|
break;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createColorPicker = void 0;
|
4
|
+
const React = require("react");
|
5
|
+
const react_color_1 = require("react-color");
|
6
|
+
const client_1 = require("react-dom/client");
|
7
|
+
const buttonStyleDarkOutline = "btn btn-outline-dark btn-md";
|
8
|
+
function createColorPicker(id, onColorChange) {
|
9
|
+
const domNode = document.createElement("div");
|
10
|
+
domNode.setAttribute("id", id);
|
11
|
+
const root = client_1.createRoot(domNode);
|
12
|
+
root.render(React.createElement(ColorPickerWrapper, { onColorChange: onColorChange }));
|
13
|
+
return domNode;
|
14
|
+
}
|
15
|
+
exports.createColorPicker = createColorPicker;
|
16
|
+
function ColorPickerWrapper(props) {
|
17
|
+
const [color, setColor] = React.useState("");
|
18
|
+
const [displayColorPicker, setDispalyColorPicker] = React.useState(false);
|
19
|
+
function handleColor(e) {
|
20
|
+
setColor(e.hex.toString());
|
21
|
+
console.log(e);
|
22
|
+
props.onColorChange(color);
|
23
|
+
}
|
24
|
+
const handleClick = () => {
|
25
|
+
setDispalyColorPicker(!displayColorPicker);
|
26
|
+
};
|
27
|
+
const handleClose = () => {
|
28
|
+
setDispalyColorPicker(false);
|
29
|
+
};
|
30
|
+
const popover = {
|
31
|
+
position: 'absolute',
|
32
|
+
zIndex: '2',
|
33
|
+
};
|
34
|
+
const cover = {
|
35
|
+
position: 'fixed',
|
36
|
+
top: '0px',
|
37
|
+
right: '0px',
|
38
|
+
bottom: '0px',
|
39
|
+
left: '0px',
|
40
|
+
};
|
41
|
+
return (React.createElement("div", null,
|
42
|
+
React.createElement("button", { id: "colorPickerBtn", className: buttonStyleDarkOutline, onClick: handleClick }, "Color"),
|
43
|
+
displayColorPicker ? React.createElement("div", { style: popover },
|
44
|
+
React.createElement("div", { style: cover, onClick: handleClose }),
|
45
|
+
React.createElement(react_color_1.CompactPicker, { onChange: handleColor })) : null));
|
46
|
+
}
|
@@ -0,0 +1,10 @@
|
|
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
|
+
}
|
@@ -4,6 +4,7 @@
|
|
4
4
|
* E.g. Cache and Load Information from previous version of the SVG; Copy information form MEI to SVG (and vice versa); Edit DOM structure of Elements
|
5
5
|
*/
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7
|
+
const cq = require("../utils/convenienceQueries");
|
7
8
|
const meiOperation = require("./MEIOperations");
|
8
9
|
const coords = require("../utils/coordinates");
|
9
10
|
const random_1 = require("./random");
|
@@ -51,7 +52,7 @@ class SVGEditor {
|
|
51
52
|
svg.querySelectorAll("*").forEach(el => {
|
52
53
|
var _a;
|
53
54
|
//if(el.tagName.toLowerCase() === "g" && el.getAttribute("id") !== null){
|
54
|
-
if (el.getAttribute("id") !== null) {
|
55
|
+
if (el.getAttribute("id") !== null && !el.classList.contains("lastAdded")) {
|
55
56
|
if (!this.classListMap.has(el.id)) {
|
56
57
|
this.classListMap.set(el.id, new Array());
|
57
58
|
}
|
@@ -65,6 +66,36 @@ class SVGEditor {
|
|
65
66
|
});
|
66
67
|
return this;
|
67
68
|
}
|
69
|
+
cacheStyles() {
|
70
|
+
//var svg = document.querySelector("#"+this.containerId + " #vrvSVG")
|
71
|
+
var svg = document.querySelector("#" + this.containerId);
|
72
|
+
if (svg === null) {
|
73
|
+
return this;
|
74
|
+
}
|
75
|
+
this.styleListMap = new Map();
|
76
|
+
svg.querySelectorAll("[style]").forEach(el => {
|
77
|
+
if (el.getAttribute("id")) {
|
78
|
+
const styles = el.getAttribute("style");
|
79
|
+
if (!this.styleListMap.has(el.id)) {
|
80
|
+
this.styleListMap.set(el.id, "");
|
81
|
+
}
|
82
|
+
this.styleListMap.set(el.id, styles);
|
83
|
+
}
|
84
|
+
});
|
85
|
+
return this;
|
86
|
+
}
|
87
|
+
loadStyles() {
|
88
|
+
if (this.styleListMap == undefined) {
|
89
|
+
return this;
|
90
|
+
}
|
91
|
+
for (const [key, value] of this.styleListMap.entries()) {
|
92
|
+
var el = this.container.querySelector("#" + key);
|
93
|
+
if (el) {
|
94
|
+
el.setAttribute("style", value);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return this;
|
98
|
+
}
|
68
99
|
cacheScales() {
|
69
100
|
var svg = document.querySelector("#" + this.containerId);
|
70
101
|
if (svg === null) {
|
@@ -113,11 +144,13 @@ class SVGEditor {
|
|
113
144
|
if (this.classListMap == undefined) {
|
114
145
|
return this;
|
115
146
|
}
|
116
|
-
if (element
|
147
|
+
if (element) {
|
117
148
|
var value = this.classListMap.get(element.id);
|
118
149
|
if (value == undefined)
|
119
150
|
return this;
|
120
151
|
value.forEach(v => {
|
152
|
+
if (v === "hideUI")
|
153
|
+
return;
|
121
154
|
if (v !== "") {
|
122
155
|
element.classList.add(v);
|
123
156
|
}
|
@@ -129,6 +162,8 @@ class SVGEditor {
|
|
129
162
|
if (el !== null) {
|
130
163
|
//el.removeAttribute("class")
|
131
164
|
value.forEach(v => {
|
165
|
+
if (v === "hideUI")
|
166
|
+
return;
|
132
167
|
if (v !== "") {
|
133
168
|
el.classList.add(v);
|
134
169
|
}
|
@@ -276,7 +311,7 @@ class SVGEditor {
|
|
276
311
|
});
|
277
312
|
}
|
278
313
|
/**
|
279
|
-
* Mark the current
|
314
|
+
* Mark the current Measure as overfilled by writing "+!" over the barline
|
280
315
|
* @param currentMEI
|
281
316
|
*/
|
282
317
|
markOverfilledMeasures(currentMEI) {
|
@@ -318,6 +353,48 @@ class SVGEditor {
|
|
318
353
|
});
|
319
354
|
});
|
320
355
|
}
|
356
|
+
/**
|
357
|
+
* Hide Rests of same duration in parallel layers. Also hide rests, when layer (n >= 2) is just rests.
|
358
|
+
* @param currentMEI MEI to parse and compute relationships. Provides IDs for elements in SVG.
|
359
|
+
* @returns this
|
360
|
+
*/
|
361
|
+
hideRedundantRests(currentMEI) {
|
362
|
+
currentMEI.querySelectorAll("staff").forEach(s => {
|
363
|
+
var prevLayerElements;
|
364
|
+
const vrv = cq.getVrvSVG(this.containerId);
|
365
|
+
s.querySelectorAll("layer").forEach(l => {
|
366
|
+
if (parseInt(l.getAttribute("n")) === 1) {
|
367
|
+
prevLayerElements = Array.from(l.children);
|
368
|
+
return;
|
369
|
+
}
|
370
|
+
if (parseInt(l.getAttribute("n")) >= 2) {
|
371
|
+
if (!prevLayerElements) {
|
372
|
+
prevLayerElements = Array.from(l.children);
|
373
|
+
return;
|
374
|
+
}
|
375
|
+
const notes = l.querySelectorAll("note");
|
376
|
+
if (notes.length === 0) {
|
377
|
+
Array.from(l.children).forEach(c => vrv.querySelectorAll(`#${c.id} use`).forEach(u => u.setAttribute("visibility", "hidden")));
|
378
|
+
}
|
379
|
+
else {
|
380
|
+
Array.from(l.children).forEach(c => {
|
381
|
+
prevLayerElements.forEach(ple => {
|
382
|
+
var _a;
|
383
|
+
const isRest = ple.tagName.toLowerCase().includes("rest") && c.tagName.toLowerCase().includes("rest");
|
384
|
+
const sameDur = ple.getAttribute("dur") === c.getAttribute("dur");
|
385
|
+
const sameTstamp = meiOperation.getTimestamp(ple) === meiOperation.getTimestamp(c);
|
386
|
+
if (isRest && sameDur && sameTstamp) {
|
387
|
+
(_a = vrv.querySelector(`#${c.id} use`)) === null || _a === void 0 ? void 0 : _a.setAttribute("visibility", "hidden");
|
388
|
+
}
|
389
|
+
});
|
390
|
+
});
|
391
|
+
}
|
392
|
+
prevLayerElements = Array.from(l.children);
|
393
|
+
}
|
394
|
+
});
|
395
|
+
});
|
396
|
+
return this;
|
397
|
+
}
|
321
398
|
distributeIds(element, propagation = false) {
|
322
399
|
if (propagation) {
|
323
400
|
var id = element.id !== "" ? element.id : element.getAttribute("refId");
|
@@ -338,6 +415,20 @@ class SVGEditor {
|
|
338
415
|
}
|
339
416
|
return this;
|
340
417
|
}
|
418
|
+
setActiveLayer() {
|
419
|
+
var container = cq.getContainer(this.containerId);
|
420
|
+
if (!container.querySelector(".layer.activeLayer")) {
|
421
|
+
container.querySelectorAll(".layer[n='1']").forEach(l => l.classList.add("activeLayer"));
|
422
|
+
}
|
423
|
+
container.querySelectorAll(".activeLayer").forEach(al => {
|
424
|
+
var staffN = al.closest(".staff").getAttribute("n");
|
425
|
+
var layerN = al.getAttribute("n");
|
426
|
+
container.querySelectorAll(`.staff[n='${staffN}'] > .layer[n='${layerN}']`).forEach(layer => {
|
427
|
+
layer.classList.add("activeLayer");
|
428
|
+
});
|
429
|
+
});
|
430
|
+
return this;
|
431
|
+
}
|
341
432
|
setContainerId(containerId) {
|
342
433
|
this.containerId = containerId;
|
343
434
|
this.container = document.getElementById(containerId);
|
@@ -24,7 +24,7 @@ class VerovioWrapper {
|
|
24
24
|
pageMarginTop: 50,
|
25
25
|
adjustPageHeight: true,
|
26
26
|
font: 'Bravura',
|
27
|
-
pageWidth: pageWidth
|
27
|
+
pageWidth: pageWidth,
|
28
28
|
//pageHeight: pageWidth / 4,
|
29
29
|
//justifyVertically: true,
|
30
30
|
svgViewBox: true,
|
@@ -140,6 +140,9 @@ class VerovioWrapper {
|
|
140
140
|
var buffer = buffer_1.Buffer.from(midiString, "base64");
|
141
141
|
return new midi_1.Midi(buffer);
|
142
142
|
}
|
143
|
+
getTimemap() {
|
144
|
+
return this.vrvToolkit.renderToTimemap();
|
145
|
+
}
|
143
146
|
/**
|
144
147
|
* Get Toolkit instance to use any method of verovio outside of score editor.
|
145
148
|
* FOr all available methods go to: https://book.verovio.org/toolkit-reference/toolkit-methods.html
|
@@ -152,6 +155,8 @@ class VerovioWrapper {
|
|
152
155
|
return this.options;
|
153
156
|
}
|
154
157
|
setWidthValue(wv) {
|
158
|
+
if (typeof wv === "string")
|
159
|
+
wv = parseFloat(wv);
|
155
160
|
this.options.pageWidth = wv;
|
156
161
|
this.vrvToolkit.setOptions(this.options);
|
157
162
|
}
|
@@ -32,6 +32,8 @@ function getBySelector(parent, parentModulator, target, targetModulator, selecto
|
|
32
32
|
}
|
33
33
|
exports.getBySelector = getBySelector;
|
34
34
|
function hasActiveElement(containerId) {
|
35
|
+
if (!document.getElementById(containerId))
|
36
|
+
return false;
|
35
37
|
return document.getElementById(containerId).classList.contains("activeContainer");
|
36
38
|
}
|
37
39
|
exports.hasActiveElement = hasActiveElement;
|