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.
- package/package.json +65 -61
- package/src/scripts/js/Core.js +32 -13
- package/src/scripts/js/entry.js +6 -5
- package/src/scripts/js/gui/Annotations.js +28 -13
- package/src/scripts/js/gui/ScoreManipulator.js +13 -11
- package/src/scripts/js/gui/Tabbar.js +14 -5
- package/src/scripts/js/gui/Toolbar.js +1 -1
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +16 -4
- package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +2 -2
- package/src/scripts/js/handlers/InsertModeHandler.js +7 -7
- package/src/scripts/js/handlers/KeyModeHandler.js +1 -1
- package/src/scripts/js/handlers/LabelHandler.js +1 -1
- package/src/scripts/js/handlers/NoteDragHandler.js +1 -1
- package/src/scripts/js/handlers/PhantomElementHandler.js +3 -10
- package/src/scripts/js/handlers/{SideBarHandler.js → SidebarHandler.js} +1 -1
- package/src/scripts/js/handlers/TooltipHandler.js +1 -1
- 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/{assets → scripts/assets}/mei_template.js +2 -2
- 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/{gui → scripts/gui}/HarmonyLabel.js +1 -1
- 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 → scripts/gui}/TempoLabel.js +1 -1
- 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/{utils → scripts/utils}/ReactWrapper.js +1 -1
- 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/MEIOperations.js +22 -22
- package/src/scripts/js/utils/Mouse2SVG.js +13 -6
- package/src/scripts/js/utils/SVGEditor.js +2 -2
- 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/{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}/Label.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}/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
@@ -206,7 +206,7 @@ function addToMEI(newSound, currentMEI, replace = false, scoreGraph = null) {
|
|
206
206
|
}
|
207
207
|
else {
|
208
208
|
chord = document.createElement("chord");
|
209
|
-
chord.setAttribute("id",
|
209
|
+
chord.setAttribute("id", random_1.uuidv4());
|
210
210
|
chord.setAttribute("dur", meiChordEl.getAttribute("dur"));
|
211
211
|
if (meiChordEl.getAttribute("dots") !== null) {
|
212
212
|
chord.setAttribute("dots", meiChordEl.getAttribute("dots"));
|
@@ -224,7 +224,7 @@ function addToMEI(newSound, currentMEI, replace = false, scoreGraph = null) {
|
|
224
224
|
if (Array.from(chord.querySelectorAll("note")).some(n => t.getAttribute("startid") === "#" + n.id)) {
|
225
225
|
if (!currentMEI.querySelector("tie[startid='#" + newNote.id + "']")) { // just make the tie once (since this can be called twice in recursion)
|
226
226
|
var addToChord = Object.assign({}, newNote);
|
227
|
-
addToChord.id =
|
227
|
+
addToChord.id = random_1.uuidv4();
|
228
228
|
var tieEnd = currentMEI.querySelector(t.getAttribute("endid"));
|
229
229
|
tieEnd = tieEnd.closest("chord") || tieEnd;
|
230
230
|
addToChord.chordElement = tieEnd;
|
@@ -408,7 +408,7 @@ function tieToNextMeasure(currentMEI, newElem, currMeiClone, replace, newSound)
|
|
408
408
|
changeDur(lastElement, newRatio);
|
409
409
|
// create new Element and if needed, new measure
|
410
410
|
var splittedElement = lastElement.tagName === "note" ? convertToNewNote(lastElement) : convertToNewChord(lastElement);
|
411
|
-
splittedElement.id =
|
411
|
+
splittedElement.id = random_1.uuidv4();
|
412
412
|
var newDur = ratioToDur(measureOverhead);
|
413
413
|
splittedElement.dur = newDur[0].toString();
|
414
414
|
splittedElement.dots = newDur[1].toString();
|
@@ -494,7 +494,7 @@ function doShiftRight(arr, meterRatio, currentLayer) {
|
|
494
494
|
}
|
495
495
|
else {
|
496
496
|
targetLayer = document.createElement("layer");
|
497
|
-
targetLayer.setAttribute("id", "layer-" +
|
497
|
+
targetLayer.setAttribute("id", "layer-" + random_1.uuidv4());
|
498
498
|
targetLayer.setAttribute("n", layerLevel);
|
499
499
|
targetStaff.appendChild(targetLayer);
|
500
500
|
}
|
@@ -512,7 +512,7 @@ function doShiftRight(arr, meterRatio, currentLayer) {
|
|
512
512
|
if (Number.isInteger(1 / chunkDurLeft) && Number.isInteger(1 / chunkDurRight)) {
|
513
513
|
element.removeAttribute("dots");
|
514
514
|
var splitRightElement = element.cloneNode(true);
|
515
|
-
splitRightElement.setAttribute("id",
|
515
|
+
splitRightElement.setAttribute("id", random_1.uuidv4());
|
516
516
|
splitRightElement.setAttribute("dur", (Math.abs(1 / chunkDurRight)).toString());
|
517
517
|
var beforeElement = elementIdx === 0 ? targetLayer.firstChild : targetLayer.children.item(elementIdx);
|
518
518
|
targetLayer.insertBefore(splitRightElement, beforeElement);
|
@@ -524,10 +524,10 @@ function doShiftRight(arr, meterRatio, currentLayer) {
|
|
524
524
|
dottedElements.left.forEach(lel => currentLayer.appendChild(lel));
|
525
525
|
var beforeElement = elementIdx === 0 ? targetLayer.firstChild : targetLayer.children.item(elementIdx);
|
526
526
|
dottedElements.right.forEach(rel => {
|
527
|
-
rel.setAttribute("id",
|
527
|
+
rel.setAttribute("id", random_1.uuidv4());
|
528
528
|
if (rel.tagName === "chord") {
|
529
529
|
rel.querySelectorAll("note").forEach(rl => {
|
530
|
-
rl.setAttribute("id",
|
530
|
+
rl.setAttribute("id", random_1.uuidv4());
|
531
531
|
});
|
532
532
|
}
|
533
533
|
targetLayer.insertBefore(rel, beforeElement);
|
@@ -548,10 +548,10 @@ function createEmptyCopy(element) {
|
|
548
548
|
child.parentNode.removeChild(child);
|
549
549
|
});
|
550
550
|
//set new ids for everything
|
551
|
-
copy.setAttribute("id",
|
551
|
+
copy.setAttribute("id", random_1.uuidv4());
|
552
552
|
copy.setAttribute("n", (parseInt(element.getAttribute("n")) + 1).toString());
|
553
553
|
let allElements = copy.querySelectorAll("*");
|
554
|
-
allElements.forEach(e => e.setAttribute("id",
|
554
|
+
allElements.forEach(e => e.setAttribute("id", random_1.uuidv4()));
|
555
555
|
return copy;
|
556
556
|
}
|
557
557
|
function connectNotes(left, right, connectionShape) {
|
@@ -579,7 +579,7 @@ function connectNotes(left, right, connectionShape) {
|
|
579
579
|
var tieElement = currentMEI.createElementNS(constants_1.constants._MEINS_, connectionShape);
|
580
580
|
tieElement.setAttribute("startid", "#" + left.id);
|
581
581
|
tieElement.setAttribute("endid", "#" + right.id);
|
582
|
-
tieElement.setAttribute("id",
|
582
|
+
tieElement.setAttribute("id", random_1.uuidv4());
|
583
583
|
currentMEI.getElementById(left.id).closest("measure").append(tieElement);
|
584
584
|
}
|
585
585
|
}
|
@@ -649,7 +649,7 @@ function doShiftLeft(arr, meterRatio) {
|
|
649
649
|
if (Number.isInteger(1 / chunkDurLeft) && Number.isInteger(1 / chunkDurRight)) {
|
650
650
|
element.removeAttribute("dots");
|
651
651
|
var splitLeftElement = element.cloneNode(true);
|
652
|
-
splitLeftElement.setAttribute("id",
|
652
|
+
splitLeftElement.setAttribute("id", random_1.uuidv4());
|
653
653
|
splitLeftElement.setAttribute("dur", (Math.abs(1 / chunkDurLeft)).toString());
|
654
654
|
targetLayer.appendChild(splitLeftElement);
|
655
655
|
//change already existing element
|
@@ -658,10 +658,10 @@ function doShiftLeft(arr, meterRatio) {
|
|
658
658
|
else {
|
659
659
|
var elements = splitDottedNote(element, chunkDurLeft, chunkDurRight);
|
660
660
|
elements.left.forEach(lel => {
|
661
|
-
lel.setAttribute("id",
|
661
|
+
lel.setAttribute("id", random_1.uuidv4());
|
662
662
|
if (lel.tagName === "chord") {
|
663
663
|
lel.querySelectorAll("note").forEach(ll => {
|
664
|
-
ll.setAttribute("id",
|
664
|
+
ll.setAttribute("id", random_1.uuidv4());
|
665
665
|
});
|
666
666
|
}
|
667
667
|
targetLayer.appendChild(lel);
|
@@ -1397,7 +1397,7 @@ function reorganizeBeams(currentMEI) {
|
|
1397
1397
|
}
|
1398
1398
|
else { // else make new beam
|
1399
1399
|
var newBeam = currentMEI.createElementNS(constants_1.constants._MEINS_, "beam");
|
1400
|
-
newBeam.setAttribute("id",
|
1400
|
+
newBeam.setAttribute("id", random_1.uuidv4());
|
1401
1401
|
n.parentElement.insertBefore(newBeam, n);
|
1402
1402
|
newBeam.append(n);
|
1403
1403
|
}
|
@@ -1554,10 +1554,10 @@ function addMeasure(currentMEI) {
|
|
1554
1554
|
m.setAttribute("n", i.toString());
|
1555
1555
|
i++;
|
1556
1556
|
});
|
1557
|
-
newMeasure.setAttribute("id",
|
1557
|
+
newMeasure.setAttribute("id", random_1.uuidv4());
|
1558
1558
|
newMeasure.querySelectorAll("*").forEach(el => {
|
1559
1559
|
if (el.id === null || el.id === "") {
|
1560
|
-
el.setAttribute("id",
|
1560
|
+
el.setAttribute("id", random_1.uuidv4());
|
1561
1561
|
}
|
1562
1562
|
});
|
1563
1563
|
cleanUp(currentMEI);
|
@@ -1708,7 +1708,7 @@ function createTuplet(meiElements, currentMEI) {
|
|
1708
1708
|
if (ratio < 1) {
|
1709
1709
|
if (durRest > 0) {
|
1710
1710
|
var rest = currentMEI.createElement("rest");
|
1711
|
-
rest.setAttribute("id",
|
1711
|
+
rest.setAttribute("id", random_1.uuidv4());
|
1712
1712
|
rest.setAttribute("dur", durRest.toString());
|
1713
1713
|
if (dotsRest > 0) {
|
1714
1714
|
rest.setAttribute("dots", dotsRest.toString());
|
@@ -1740,7 +1740,7 @@ function paste(ids, pastePosition, currentMEI) {
|
|
1740
1740
|
meiElements[num] = new Array();
|
1741
1741
|
}
|
1742
1742
|
var cel = el.cloneNode(true);
|
1743
|
-
cel.setAttribute("id",
|
1743
|
+
cel.setAttribute("id", random_1.uuidv4());
|
1744
1744
|
meiElements[num].push(cel);
|
1745
1745
|
}
|
1746
1746
|
}
|
@@ -1853,7 +1853,7 @@ function insertClef(target, newClef, currentMEI) {
|
|
1853
1853
|
}
|
1854
1854
|
var disPlace = newClef.includes("OctDown") ? "below" : newClef.includes("OctUp") ? "above" : null;
|
1855
1855
|
var clefElement = currentMEI.createElement("clef");
|
1856
|
-
clefElement.setAttribute("id",
|
1856
|
+
clefElement.setAttribute("id", random_1.uuidv4());
|
1857
1857
|
clefElement.setAttribute("shape", shape);
|
1858
1858
|
clefElement.setAttribute("line", line);
|
1859
1859
|
if (disPlace) {
|
@@ -2054,7 +2054,7 @@ exports.setArticulation = setArticulation;
|
|
2054
2054
|
//PRIVATE
|
2055
2055
|
function convertToNewNote(element) {
|
2056
2056
|
var newNote = {
|
2057
|
-
id:
|
2057
|
+
id: random_1.uuidv4(),
|
2058
2058
|
pname: element.getAttribute("pname"),
|
2059
2059
|
dur: element.getAttribute("dur"),
|
2060
2060
|
dots: element.getAttribute("dots"),
|
@@ -2091,7 +2091,7 @@ function convertToNewChord(element) {
|
|
2091
2091
|
return convertToNewNote(n);
|
2092
2092
|
});
|
2093
2093
|
var newChord = {
|
2094
|
-
id:
|
2094
|
+
id: random_1.uuidv4(),
|
2095
2095
|
dur: element.getAttribute("dur"),
|
2096
2096
|
dots: element.getAttribute("dots"),
|
2097
2097
|
noteElements: newNotes
|
@@ -2103,6 +2103,6 @@ function createNewRestElement(dur, dots = undefined) {
|
|
2103
2103
|
newElem.setAttribute("dur", dur.toString());
|
2104
2104
|
if (dots != undefined)
|
2105
2105
|
newElem.setAttribute("dots", dots.toString());
|
2106
|
-
newElem.setAttribute("id",
|
2106
|
+
newElem.setAttribute("id", random_1.uuidv4());
|
2107
2107
|
return newElem;
|
2108
2108
|
}
|
@@ -169,7 +169,7 @@ class Mouse2SVG {
|
|
169
169
|
const clefDisplacement = this.measureMatrix.get(idxParentMeasure, idxStaff).clefdisplacement;
|
170
170
|
Array.from(g).forEach((staffLine, idx) => {
|
171
171
|
if (staffLine.id === "") {
|
172
|
-
staffLine.id =
|
172
|
+
staffLine.id = random_1.uuidv4();
|
173
173
|
}
|
174
174
|
staffLine.classList.add("staffLine");
|
175
175
|
staffLine.classList.add("Clef" + clefShape + clefline + clefDisplacement);
|
@@ -600,7 +600,7 @@ class Mouse2SVG {
|
|
600
600
|
}
|
601
601
|
var artic = mappings_1.articButtonToAttr.get((_l = this.container.querySelector("#articGroup > .selected")) === null || _l === void 0 ? void 0 : _l.id);
|
602
602
|
var newNote = {
|
603
|
-
id:
|
603
|
+
id: random_1.uuidv4(),
|
604
604
|
pname: pname,
|
605
605
|
dur: this.getDurationNewNote(),
|
606
606
|
dots: this.getDotsNewNote(),
|
@@ -626,13 +626,20 @@ class Mouse2SVG {
|
|
626
626
|
* @param orientation only consider elements which are left or right of given coordinates
|
627
627
|
* @returns
|
628
628
|
*/
|
629
|
-
findScoreTarget(posX, posY, checkStaff = true, orientation =
|
629
|
+
findScoreTarget(posX, posY, checkStaff = true, orientation = null, blackList = null) {
|
630
|
+
if (!orientation)
|
631
|
+
orientation = { left: true, right: true };
|
630
632
|
var notes = this.getNoteBBoxes();
|
631
633
|
var nextNote;
|
632
634
|
var tempDist = Math.pow(10, 10);
|
633
635
|
var i = 0;
|
634
636
|
notes.forEach(n => {
|
635
637
|
var _a, _b, _c, _d;
|
638
|
+
if (blackList) {
|
639
|
+
var blackListFilter = Array.from(this.getElementinVrvSVG(n.id).classList).filter(element => blackList.includes(element));
|
640
|
+
if (blackListFilter.length > 0)
|
641
|
+
return;
|
642
|
+
}
|
636
643
|
var x;
|
637
644
|
var y;
|
638
645
|
if (((_a = this.getElementinVrvSVG(n.id)) === null || _a === void 0 ? void 0 : _a.closest(".chord")) && navigator.userAgent.toLowerCase().indexOf("firefox") > -1) { // special rule for firefox browsers
|
@@ -647,11 +654,11 @@ class Mouse2SVG {
|
|
647
654
|
if (this.vrvSVG.querySelector("#" + n.id) === null)
|
648
655
|
return;
|
649
656
|
if (!this.vrvSVG.querySelector("#" + n.id).classList.contains("mRest")) { //mRest are excluded from this rule
|
650
|
-
if (orientation.left
|
657
|
+
if (!orientation.left) {
|
651
658
|
if (x < posX)
|
652
659
|
return; //exclude left elements
|
653
660
|
}
|
654
|
-
else if (orientation.right
|
661
|
+
else if (!orientation.right) {
|
655
662
|
if (x > posX)
|
656
663
|
return; // exclude right elements
|
657
664
|
}
|
@@ -659,7 +666,7 @@ class Mouse2SVG {
|
|
659
666
|
var dist = Math.abs(x - posX);
|
660
667
|
var staffCondition = n.parentStaff === this.getElementinVrvSVG((_d = this.lastStaffMouseEnter) === null || _d === void 0 ? void 0 : _d.getAttribute("refId"));
|
661
668
|
staffCondition && (staffCondition = Array.from(this.container.querySelectorAll(".activeLayer")).some(l => n.parentLayer === l));
|
662
|
-
if (checkStaff
|
669
|
+
if (!checkStaff) {
|
663
670
|
staffCondition = true;
|
664
671
|
dist = Math.sqrt(Math.abs(x - posX) ** 2 + Math.abs(y - posY) ** 2);
|
665
672
|
}
|
@@ -336,7 +336,7 @@ class SVGEditor {
|
|
336
336
|
var barLine = measureSVG.querySelector(".barLine");
|
337
337
|
var coordinates = coords.getDOMMatrixCoordinates(barLine, barLine.closest("g"));
|
338
338
|
var textGroup = document.createElementNS(constants_1.constants._SVGNS_, "g");
|
339
|
-
textGroup.setAttribute("id",
|
339
|
+
textGroup.setAttribute("id", random_1.uuidv4());
|
340
340
|
textGroup.setAttribute("targetId", barLine.id);
|
341
341
|
var text = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
342
342
|
var textForeignObject = document.createElementNS(constants_1.constants._SVGNS_, "foreignObject");
|
@@ -419,7 +419,7 @@ class SVGEditor {
|
|
419
419
|
else {
|
420
420
|
Array.from(element.querySelectorAll("*")).forEach(el => {
|
421
421
|
if (el.id === "") {
|
422
|
-
el.setAttribute("id",
|
422
|
+
el.setAttribute("id", random_1.uuidv4());
|
423
423
|
}
|
424
424
|
});
|
425
425
|
}
|
@@ -12,9 +12,9 @@ class VerovioWrapper {
|
|
12
12
|
//@ts-ignore
|
13
13
|
this.vrvToolkit = new verovio.toolkit() || null;
|
14
14
|
this.r = 1;
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
if (this.isRetina()) {
|
16
|
+
this.r = 2;
|
17
|
+
}
|
18
18
|
this.widthValue = 1500;
|
19
19
|
var pageWidth = (this.widthValue / (window.devicePixelRatio / this.r)) / (screen.availHeight / window.innerWidth);
|
20
20
|
this.options = {
|
@@ -24,7 +24,7 @@ class VerovioWrapper {
|
|
24
24
|
pageMarginTop: 50,
|
25
25
|
adjustPageHeight: true,
|
26
26
|
font: 'Bravura',
|
27
|
-
pageWidth: pageWidth,
|
27
|
+
//pageWidth: pageWidth, // adjust size with window size
|
28
28
|
//pageHeight: pageWidth / 4,
|
29
29
|
//justifyVertically: true,
|
30
30
|
svgViewBox: true,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.transformToDOMMatrixCoordinates = exports.getDOMMatrixCoordinates = void 0;
|
3
|
+
exports.transformToDOMMatrixCoordinates = exports.getCanvasCordinates = exports.getDOMMatrixCoordinates = void 0;
|
4
4
|
/**
|
5
5
|
* Get DOMMatrix coordnates of element according to parent canvas class. Returns null if no canvas is found. If element is DOMRect, canvas must be provided
|
6
6
|
* @param element
|
@@ -33,9 +33,33 @@ function getDOMMatrixCoordinates(element, canvas = null) {
|
|
33
33
|
ptRB = ptRB.matrixTransform(canvasMatrix);
|
34
34
|
var width = ptRB.x - ptLT.x;
|
35
35
|
var height = ptRB.y - ptLT.y;
|
36
|
-
return { left: ptLT.x, top: ptLT.y, right: ptRB.x, bottom: ptRB.y, width: width, height: height, x: ptLT.x, y: ptLT.y };
|
36
|
+
return { left: ptLT.x, top: ptLT.y, right: ptRB.x, bottom: ptRB.y, width: width, height: height, x: ptLT.x, y: ptLT.y, matrix: canvasMatrix };
|
37
37
|
}
|
38
38
|
exports.getDOMMatrixCoordinates = getDOMMatrixCoordinates;
|
39
|
+
function getCanvasCordinates(coords, canvas = null) {
|
40
|
+
if (!coords.matrix) {
|
41
|
+
throw new Error("DOMMatrix is missing.");
|
42
|
+
}
|
43
|
+
if (canvas === null) {
|
44
|
+
canvas = canvas instanceof Element ? canvas.closest(".canvas") : null;
|
45
|
+
if (canvas instanceof DOMRect) {
|
46
|
+
throw new Error("Canvas must be provided, if input is instance of DOMRect. Actual instance: " + canvas.constructor.name);
|
47
|
+
}
|
48
|
+
if (canvas === null)
|
49
|
+
return;
|
50
|
+
}
|
51
|
+
// Reverse the transformation
|
52
|
+
var canvasMatrix = coords.matrix.inverse();
|
53
|
+
var ptLT = new DOMPoint(coords.left, coords.top);
|
54
|
+
ptLT = ptLT.matrixTransform(canvasMatrix);
|
55
|
+
var ptRB = new DOMPoint(coords.right, coords.bottom);
|
56
|
+
ptRB = ptRB.matrixTransform(canvasMatrix);
|
57
|
+
var width = ptRB.x - ptLT.x;
|
58
|
+
var height = ptRB.y - ptLT.y;
|
59
|
+
// Create and return the DOMRect
|
60
|
+
return new DOMRect(ptLT.x, ptLT.y, width, height);
|
61
|
+
}
|
62
|
+
exports.getCanvasCordinates = getCanvasCordinates;
|
39
63
|
/**
|
40
64
|
* Transforms the given coordinates for a given canvas
|
41
65
|
* @param x
|
package/src/scripts/js/.DS_Store
DELETED
Binary file
|