vibe-editor 0.0.0
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 +21 -0
- package/README.md +51 -0
- package/package.json +56 -0
- package/src/fonts/bravura/FONTLOG.txt +243 -0
- package/src/fonts/bravura/OFL-FAQ.txt +369 -0
- package/src/fonts/bravura/OFL.txt +94 -0
- package/src/fonts/bravura/bravura-text.md +153 -0
- package/src/fonts/bravura/bravura_metadata.json +34718 -0
- package/src/fonts/bravura/eot/Bravura.eot +0 -0
- package/src/fonts/bravura/eot/BravuraText.eot +0 -0
- package/src/fonts/bravura/otf/Bravura.otf +0 -0
- package/src/fonts/bravura/otf/BravuraText.otf +0 -0
- package/src/fonts/bravura/svg/Bravura.svg +3517 -0
- package/src/fonts/bravura/svg/BravuraText.svg +18879 -0
- package/src/fonts/bravura/woff/Bravura.woff +0 -0
- package/src/fonts/bravura/woff/BravuraText.woff +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabBol-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabBol-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabLig-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabLig-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabMed-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabMed-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.svg +976 -0
- package/src/fonts/colaborate/ColabReg-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabReg-webfont.woff +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.eot +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.svg +970 -0
- package/src/fonts/colaborate/ColabThi-webfont.ttf +0 -0
- package/src/fonts/colaborate/ColabThi-webfont.woff +0 -0
- package/src/images/GUI/.DS_Store +0 -0
- package/src/images/GUI/backward-fast-solid.svg +1 -0
- package/src/images/GUI/bars-solid.svg +1 -0
- package/src/images/GUI/caret-left-solid.svg +1 -0
- package/src/images/GUI/caret-right-solid.svg +1 -0
- package/src/images/GUI/edit-solid.svg +1 -0
- package/src/images/GUI/pause-solid.svg +1 -0
- package/src/images/GUI/play-solid.svg +1 -0
- package/src/images/GUI/triplet.svg +21 -0
- package/src/images/GUI/zoomin.svg +1 -0
- package/src/images/GUI/zoomout.svg +1 -0
- package/src/images/bravura_notes/.DS_Store +0 -0
- package/src/images/bravura_notes/16th.svg +1 -0
- package/src/images/bravura_notes/32th.svg +1 -0
- package/src/images/bravura_notes/alterDDown.svg +1 -0
- package/src/images/bravura_notes/alterDUp.svg +1 -0
- package/src/images/bravura_notes/alterDown.svg +1 -0
- package/src/images/bravura_notes/alterNeutral.svg +1 -0
- package/src/images/bravura_notes/alterUp.svg +1 -0
- package/src/images/bravura_notes/beams.svg +1 -0
- package/src/images/bravura_notes/eigth.svg +1 -0
- package/src/images/bravura_notes/full.svg +1 -0
- package/src/images/bravura_notes/half.svg +1 -0
- package/src/images/bravura_notes/oneDot.svg +1 -0
- package/src/images/bravura_notes/pauseNote.svg +1 -0
- package/src/images/bravura_notes/quarter.svg +1 -0
- package/src/images/bravura_notes/tie.svg +1 -0
- package/src/images/bravura_notes/twoDot.svg +1 -0
- package/src/scripts/js/.DS_Store +0 -0
- package/src/scripts/js/Core.js +887 -0
- package/src/scripts/js/MusicPlayer.js +572 -0
- package/src/scripts/js/MusicProcessor.js +652 -0
- package/src/scripts/js/VerovioScoreEditor.js +183 -0
- package/src/scripts/js/assets/mei_template.js +161 -0
- package/src/scripts/js/constants.js +20 -0
- package/src/scripts/js/datastructures/MeasureMatrix.js +235 -0
- package/src/scripts/js/datastructures/ScoreGraph.js +432 -0
- package/src/scripts/js/datastructures/ScoreNode.js +78 -0
- package/src/scripts/js/entry.js +4 -0
- package/src/scripts/js/gui/Annotations.js +456 -0
- package/src/scripts/js/gui/Cursor.js +203 -0
- package/src/scripts/js/gui/CustomAnnotationDrawer.js +114 -0
- package/src/scripts/js/gui/CustomAnnotationShapeDrawer.js +114 -0
- package/src/scripts/js/gui/HarmonyLabel.js +104 -0
- package/src/scripts/js/gui/Label.js +2 -0
- package/src/scripts/js/gui/PhantomElement.js +132 -0
- package/src/scripts/js/gui/ScoreManipulator.js +156 -0
- package/src/scripts/js/gui/Tabbar.js +675 -0
- package/src/scripts/js/gui/TempoLabel.js +60 -0
- package/src/scripts/js/gui/Toolbar copy.js +614 -0
- package/src/scripts/js/gui/Toolbar.js +618 -0
- package/src/scripts/js/handlers/AnnotationChangeHandler.js +567 -0
- package/src/scripts/js/handlers/AnnotationDragHandler.js +113 -0
- package/src/scripts/js/handlers/AnnotationLineHandler.js +113 -0
- package/src/scripts/js/handlers/ArticulationHandler.js +20 -0
- package/src/scripts/js/handlers/ClickModeHandler.js +265 -0
- package/src/scripts/js/handlers/CustomAnnotationShapeDrawer.js +131 -0
- package/src/scripts/js/handlers/CustomToolbarHandler.js +297 -0
- package/src/scripts/js/handlers/DeleteHandler.js +102 -0
- package/src/scripts/js/handlers/GlobalKeyboardHandler.js +367 -0
- package/src/scripts/js/handlers/Handler.js +2 -0
- package/src/scripts/js/handlers/HarmonyHandler.js +282 -0
- package/src/scripts/js/handlers/InsertModeHandler copy.js +423 -0
- package/src/scripts/js/handlers/InsertModeHandler.js +380 -0
- package/src/scripts/js/handlers/InsertModeHandler_deprecated.js +424 -0
- package/src/scripts/js/handlers/KeyModeHandler copy.js +407 -0
- package/src/scripts/js/handlers/KeyModeHandler.js +456 -0
- package/src/scripts/js/handlers/KeyModeHandler_deprecated.js +411 -0
- package/src/scripts/js/handlers/LabelHandler.js +461 -0
- package/src/scripts/js/handlers/ModHandler.js +311 -0
- package/src/scripts/js/handlers/NoteDragHandler copy.js +148 -0
- package/src/scripts/js/handlers/NoteDragHandler.js +97 -0
- package/src/scripts/js/handlers/NoteDragHandler_deprecated.js +150 -0
- package/src/scripts/js/handlers/PhantomElementHandler.js +168 -0
- package/src/scripts/js/handlers/ScoreManipulatorHandler.js +135 -0
- package/src/scripts/js/handlers/SelectionHandler.js +218 -0
- package/src/scripts/js/handlers/SideBarHandler.js +499 -0
- package/src/scripts/js/handlers/TooltipHandler.js +132 -0
- package/src/scripts/js/handlers/WindowHandler.js +257 -0
- package/src/scripts/js/utils/DOMCreator.js +174 -0
- package/src/scripts/js/utils/MEIConverter.js +64 -0
- package/src/scripts/js/utils/MEIOperations.js +2112 -0
- package/src/scripts/js/utils/Mouse2MEI.js +735 -0
- package/src/scripts/js/utils/Mouse2SVG.js +737 -0
- package/src/scripts/js/utils/SVGEditor.js +352 -0
- package/src/scripts/js/utils/SVGFiller.js +245 -0
- package/src/scripts/js/utils/Types.js +2 -0
- package/src/scripts/js/utils/VerovioWrapper copy.js +156 -0
- package/src/scripts/js/utils/VerovioWrapper.js +165 -0
- package/src/scripts/js/utils/VerovioWrapperLocal.js +156 -0
- package/src/scripts/js/utils/convenienceQueries.js +37 -0
- package/src/scripts/js/utils/coordinates.js +54 -0
- package/src/scripts/js/utils/firefoxBBoxes.js +143 -0
- package/src/scripts/js/utils/mappings.js +332 -0
- package/src/scripts/js/utils/random.js +45 -0
- package/src/styles/VerovioScoreEditor.css +694 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
const random_1 = require("../utils/random");
|
5
|
+
const constants_1 = require("../constants");
|
6
|
+
class CustomAnnotationDrawer {
|
7
|
+
constructor() {
|
8
|
+
this.shapes = new Array();
|
9
|
+
this.shapeID = "";
|
10
|
+
this.dragged = false;
|
11
|
+
this.canvas = d3.select(constants_1.constants._ROOTSVGID_WITH_IDSELECTOR_); // draw directly in svg
|
12
|
+
this.dragBehaviour = d3.drag()
|
13
|
+
.on('start', drawStart)
|
14
|
+
.on('drag', this.drawing.bind(this))
|
15
|
+
.on('end', this.drawEnd.bind(this));
|
16
|
+
var that = this;
|
17
|
+
function drawStart() {
|
18
|
+
that.initialX = d3.event.x;
|
19
|
+
that.initialY = d3.event.y;
|
20
|
+
if (d3.event.sourceEvent.srcElement.id === constants_1.constants._ROOTSVGID_) {
|
21
|
+
that.initRect(that.initialX, that.initialY);
|
22
|
+
//that.initCircle(that.initialX, that.initialY)
|
23
|
+
}
|
24
|
+
}
|
25
|
+
this.setListeners();
|
26
|
+
}
|
27
|
+
drawing() {
|
28
|
+
//const currentPt =
|
29
|
+
const curX = d3.event.x;
|
30
|
+
const curY = d3.event.y;
|
31
|
+
if (typeof this.shape === "undefined") {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
if (Math.abs(curX - this.initialX) > 20 || Math.abs(curY - this.initialY) > 20) {
|
35
|
+
this.dragged = true;
|
36
|
+
const newX = curX < this.initialX ? curX : this.initialX;
|
37
|
+
const newY = curY < this.initialY ? curY : this.initialY;
|
38
|
+
const width = curX < this.initialX ? this.initialX - curX : curX - this.initialX;
|
39
|
+
const height = curY < this.initialY ? this.initialY - curY : curY - this.initialY;
|
40
|
+
this.updateRect(newX, newY, width, height);
|
41
|
+
//this.updateCircle(newX, newY, width, height);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
drawEnd() {
|
45
|
+
if (!this.dragged) {
|
46
|
+
var elToRemove = document.getElementById(this.shapeID);
|
47
|
+
if (elToRemove !== null) {
|
48
|
+
elToRemove.remove();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
document.getElementById("annotationCanvas").appendChild(this.shape);
|
53
|
+
this.shapes.push(this.shape.cloneNode(true));
|
54
|
+
}
|
55
|
+
this.shape = undefined;
|
56
|
+
this.updateCallback();
|
57
|
+
}
|
58
|
+
initRect(ulx, uly) {
|
59
|
+
this.shapeID = random_1.uuidv4();
|
60
|
+
this.canvas.append('rect')
|
61
|
+
.attr('x', ulx)
|
62
|
+
.attr('y', uly)
|
63
|
+
.attr('width', 0)
|
64
|
+
.attr('height', 0)
|
65
|
+
.attr("class", "customAnnotShape")
|
66
|
+
.attr("id", this.shapeID);
|
67
|
+
this.shape = document.getElementById(this.shapeID);
|
68
|
+
}
|
69
|
+
initCircle(cx, cy) {
|
70
|
+
this.shapeID = random_1.uuidv4();
|
71
|
+
this.canvas.append('ellipse')
|
72
|
+
.attr('cx', cx)
|
73
|
+
.attr('cy', cy)
|
74
|
+
.attr('rx', 0)
|
75
|
+
.attr('ry', 0)
|
76
|
+
.attr("class", "customAnnotShape")
|
77
|
+
.attr("id", this.shapeID);
|
78
|
+
this.shape = document.getElementById(this.shapeID);
|
79
|
+
}
|
80
|
+
updateRect(newX, newY, currentWidth, currentHeight) {
|
81
|
+
this.shape.setAttribute('x', newX.toString());
|
82
|
+
this.shape.setAttribute('y', newY.toString());
|
83
|
+
this.shape.setAttribute('width', currentWidth.toString());
|
84
|
+
this.shape.setAttribute('height', currentHeight.toString());
|
85
|
+
}
|
86
|
+
updateCircle(newX, newY, currentWidth, currentHeight) {
|
87
|
+
this.shape.setAttribute('cx', newX.toString());
|
88
|
+
this.shape.setAttribute('cy', newY.toString());
|
89
|
+
this.shape.setAttribute('rx', currentWidth.toString());
|
90
|
+
this.shape.setAttribute('ry', currentHeight.toString());
|
91
|
+
}
|
92
|
+
removeListeners() {
|
93
|
+
d3.select(constants_1.constants._ROOTSVGID_WITH_IDSELECTOR_).on('mousedown.drag', null);
|
94
|
+
}
|
95
|
+
setListeners() {
|
96
|
+
this.canvas.call(this.dragBehaviour);
|
97
|
+
}
|
98
|
+
resetListeners() {
|
99
|
+
this.removeListeners();
|
100
|
+
this.setListeners();
|
101
|
+
}
|
102
|
+
///////// GETTER/ SETTER ////////
|
103
|
+
setM2M(m2m) {
|
104
|
+
this.m2m = m2m;
|
105
|
+
}
|
106
|
+
getShapes() {
|
107
|
+
return this.shapes;
|
108
|
+
}
|
109
|
+
//////////// CALLBACKS /////////////
|
110
|
+
setUpdateCallback(updateCallback) {
|
111
|
+
this.updateCallback = updateCallback;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
exports.default = CustomAnnotationDrawer;
|
@@ -0,0 +1,114 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
const random_1 = require("../utils/random");
|
5
|
+
const constants_1 = require("../constants");
|
6
|
+
class CustomAnnotationDrawer {
|
7
|
+
constructor() {
|
8
|
+
this.shapes = new Array();
|
9
|
+
this.shapeID = "";
|
10
|
+
this.dragged = false;
|
11
|
+
this.canvas = d3.select(constants_1.constants._ROOTSVGID_WITH_IDSELECTOR_); // draw directly in svg
|
12
|
+
this.dragBehaviour = d3.drag()
|
13
|
+
.on('start', drawStart)
|
14
|
+
.on('drag', this.drawing.bind(this))
|
15
|
+
.on('end', this.drawEnd.bind(this));
|
16
|
+
var that = this;
|
17
|
+
function drawStart() {
|
18
|
+
that.initialX = d3.event.x;
|
19
|
+
that.initialY = d3.event.y;
|
20
|
+
if (d3.event.sourceEvent.srcElement.id === constants_1.constants._ROOTSVGID_) {
|
21
|
+
that.initRect(that.initialX, that.initialY);
|
22
|
+
//that.initCircle(that.initialX, that.initialY)
|
23
|
+
}
|
24
|
+
}
|
25
|
+
this.setListeners();
|
26
|
+
}
|
27
|
+
drawing() {
|
28
|
+
//const currentPt =
|
29
|
+
const curX = d3.event.x;
|
30
|
+
const curY = d3.event.y;
|
31
|
+
if (typeof this.shape === "undefined") {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
if (Math.abs(curX - this.initialX) > 20 || Math.abs(curY - this.initialY) > 20) {
|
35
|
+
this.dragged = true;
|
36
|
+
const newX = curX < this.initialX ? curX : this.initialX;
|
37
|
+
const newY = curY < this.initialY ? curY : this.initialY;
|
38
|
+
const width = curX < this.initialX ? this.initialX - curX : curX - this.initialX;
|
39
|
+
const height = curY < this.initialY ? this.initialY - curY : curY - this.initialY;
|
40
|
+
this.updateRect(newX, newY, width, height);
|
41
|
+
//this.updateCircle(newX, newY, width, height);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
drawEnd() {
|
45
|
+
if (!this.dragged) {
|
46
|
+
var elToRemove = document.getElementById(this.shapeID);
|
47
|
+
if (elToRemove !== null) {
|
48
|
+
elToRemove.remove();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
else {
|
52
|
+
document.getElementById("annotationCanvas").appendChild(this.shape);
|
53
|
+
this.shapes.push(this.shape.cloneNode(true));
|
54
|
+
}
|
55
|
+
this.shape = undefined;
|
56
|
+
this.updateCallback();
|
57
|
+
}
|
58
|
+
initRect(ulx, uly) {
|
59
|
+
this.shapeID = random_1.uuidv4();
|
60
|
+
this.canvas.append('rect')
|
61
|
+
.attr('x', ulx)
|
62
|
+
.attr('y', uly)
|
63
|
+
.attr('width', 0)
|
64
|
+
.attr('height', 0)
|
65
|
+
.attr("class", "customAnnotShape")
|
66
|
+
.attr("id", this.shapeID);
|
67
|
+
this.shape = document.getElementById(this.shapeID);
|
68
|
+
}
|
69
|
+
initCircle(cx, cy) {
|
70
|
+
this.shapeID = random_1.uuidv4();
|
71
|
+
this.canvas.append('ellipse')
|
72
|
+
.attr('cx', cx)
|
73
|
+
.attr('cy', cy)
|
74
|
+
.attr('rx', 0)
|
75
|
+
.attr('ry', 0)
|
76
|
+
.attr("class", "customAnnotShape")
|
77
|
+
.attr("id", this.shapeID);
|
78
|
+
this.shape = document.getElementById(this.shapeID);
|
79
|
+
}
|
80
|
+
updateRect(newX, newY, currentWidth, currentHeight) {
|
81
|
+
this.shape.setAttribute('x', newX.toString());
|
82
|
+
this.shape.setAttribute('y', newY.toString());
|
83
|
+
this.shape.setAttribute('width', currentWidth.toString());
|
84
|
+
this.shape.setAttribute('height', currentHeight.toString());
|
85
|
+
}
|
86
|
+
updateCircle(newX, newY, currentWidth, currentHeight) {
|
87
|
+
this.shape.setAttribute('cx', newX.toString());
|
88
|
+
this.shape.setAttribute('cy', newY.toString());
|
89
|
+
this.shape.setAttribute('rx', currentWidth.toString());
|
90
|
+
this.shape.setAttribute('ry', currentHeight.toString());
|
91
|
+
}
|
92
|
+
removeListeners() {
|
93
|
+
d3.select(constants_1.constants._ROOTSVGID_WITH_IDSELECTOR_).on('mousedown.drag', null);
|
94
|
+
}
|
95
|
+
setListeners() {
|
96
|
+
this.canvas.call(this.dragBehaviour);
|
97
|
+
}
|
98
|
+
resetListeners() {
|
99
|
+
this.removeListeners();
|
100
|
+
this.setListeners();
|
101
|
+
}
|
102
|
+
///////// GETTER/ SETTER ////////
|
103
|
+
setM2M(m2m) {
|
104
|
+
this.m2m = m2m;
|
105
|
+
}
|
106
|
+
getShapes() {
|
107
|
+
return this.shapes;
|
108
|
+
}
|
109
|
+
//////////// CALLBACKS /////////////
|
110
|
+
setUpdateCallback(updateCallback) {
|
111
|
+
this.updateCallback = updateCallback;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
exports.default = CustomAnnotationDrawer;
|
@@ -0,0 +1,104 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const random_1 = require("../utils/random");
|
4
|
+
const constants_1 = require("../constants");
|
5
|
+
const mappings_1 = require("../utils/mappings");
|
6
|
+
class HarmonyLabel {
|
7
|
+
constructor(inputString, startid, mei) {
|
8
|
+
this.isBassoContinuo = false;
|
9
|
+
this.isText = false;
|
10
|
+
this.startid = startid;
|
11
|
+
this.currentMEI = mei;
|
12
|
+
this.inputString = inputString;
|
13
|
+
this.element = this.currentMEI.getElementById(startid);
|
14
|
+
if (["note", "chord"].some(c => this.element.tagName === c)) {
|
15
|
+
this.checkFormat(inputString);
|
16
|
+
this.createElement(inputString);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
checkFormat(inputString) {
|
20
|
+
this.isBassoContinuo = false;
|
21
|
+
this.isText = false;
|
22
|
+
var letters = /[AaBC-Zc-z].*/; // b is allowed character in bc
|
23
|
+
if (inputString.match(letters)) {
|
24
|
+
this.isText = true;
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
this.isBassoContinuo = true;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* Change text of already existing label
|
32
|
+
* @param inputString
|
33
|
+
*/
|
34
|
+
modifyLabel(inputString) {
|
35
|
+
this.checkFormat(inputString);
|
36
|
+
this.parseInput(inputString);
|
37
|
+
}
|
38
|
+
createElement(inputString) {
|
39
|
+
this.element = this.currentMEI.createElement("harm");
|
40
|
+
this.element.setAttribute("id", random_1.uuidv4());
|
41
|
+
this.element.setAttribute("place", "below");
|
42
|
+
Array.from(this.element.children).forEach(c => {
|
43
|
+
c.remove();
|
44
|
+
});
|
45
|
+
this.parseInput(inputString);
|
46
|
+
this.setStartId();
|
47
|
+
}
|
48
|
+
parseInput(inputString) {
|
49
|
+
if (this.isBassoContinuo) {
|
50
|
+
this.parseFB(inputString);
|
51
|
+
}
|
52
|
+
if (this.isText) {
|
53
|
+
this.parseText(inputString);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
parseText(inputString) {
|
57
|
+
inputString = inputString.replace("b", mappings_1.keyToUnicode.get("b"));
|
58
|
+
inputString = inputString.replace(/(?<!&)#/g, mappings_1.keyToUnicode.get("#"));
|
59
|
+
inputString = inputString.replace("n", mappings_1.keyToUnicode.get("n"));
|
60
|
+
inputString = inputString.replace("\\^", mappings_1.keyToUnicode.get("\\^"));
|
61
|
+
inputString = inputString.replace("/(?<!\/)°\/g", mappings_1.keyToUnicode.get("°"));
|
62
|
+
inputString = inputString.replace("/°", mappings_1.keyToUnicode.get("/°"));
|
63
|
+
this.element.textContent = inputString;
|
64
|
+
}
|
65
|
+
parseFB(sa) {
|
66
|
+
var splitArray = sa.split(" ");
|
67
|
+
splitArray = splitArray.filter(s => s !== "");
|
68
|
+
var fb = this.currentMEI.createElementNS(constants_1.constants._MEINS_, "fb");
|
69
|
+
this.element.textContent = "";
|
70
|
+
this.element.appendChild(fb);
|
71
|
+
splitArray.forEach(sa => {
|
72
|
+
var f = this.currentMEI.createElementNS(constants_1.constants._MEINS_, "f");
|
73
|
+
sa = sa.replace("b", mappings_1.keyToUnicode.get("b"));
|
74
|
+
sa = sa.replace(/(?<!&)#/g, mappings_1.keyToUnicode.get("#"));
|
75
|
+
sa = sa.replace("n", mappings_1.keyToUnicode.get("n"));
|
76
|
+
f.textContent = sa;
|
77
|
+
fb.appendChild(f);
|
78
|
+
});
|
79
|
+
}
|
80
|
+
///////// HARMONY HANDLER STUFF ////////////////
|
81
|
+
/**
|
82
|
+
* Has to be set by HarmonyHandler
|
83
|
+
* @param el
|
84
|
+
*/
|
85
|
+
setStartId(startId = this.startid) {
|
86
|
+
this.element.setAttribute("startid", startId);
|
87
|
+
return this;
|
88
|
+
}
|
89
|
+
////////////// GETTER/ SETTER ////////////
|
90
|
+
getElement() {
|
91
|
+
return this.element;
|
92
|
+
}
|
93
|
+
getInput() {
|
94
|
+
return this.inputString;
|
95
|
+
}
|
96
|
+
getStartId() {
|
97
|
+
return this.startid;
|
98
|
+
}
|
99
|
+
setCurrentMEI(mei) {
|
100
|
+
this.currentMEI = mei;
|
101
|
+
return this;
|
102
|
+
}
|
103
|
+
}
|
104
|
+
exports.default = HarmonyLabel;
|
@@ -0,0 +1,132 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const cq = require("../utils/convenienceQueries");
|
4
|
+
const coordinates = require("../utils/coordinates");
|
5
|
+
const mappings_1 = require("../utils/mappings");
|
6
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
7
|
+
class PhantomElement {
|
8
|
+
constructor(elementName, containerId, options = null, canvas = undefined) {
|
9
|
+
elementName = elementName.toLowerCase();
|
10
|
+
this.setContainerId(containerId);
|
11
|
+
this.phantomCanvas = canvas || this.interactionOverlay.querySelector("#phantomCanvas");
|
12
|
+
switch (elementName) {
|
13
|
+
case "note":
|
14
|
+
this.makeNewPhantomNote();
|
15
|
+
break;
|
16
|
+
case "line":
|
17
|
+
this.makeNewPhantomLine(options);
|
18
|
+
break;
|
19
|
+
case "timemarkers":
|
20
|
+
//this.makeNewTimeMarkers(options)
|
21
|
+
break;
|
22
|
+
default:
|
23
|
+
console.log("Element", elementName, "is not supported");
|
24
|
+
break;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
makeNewPhantomNote() {
|
28
|
+
this.removePhantomNote();
|
29
|
+
if (this.container.classList.contains("clickmode") && this.interactionOverlay.querySelector("#phantomNote") === null) {
|
30
|
+
var circle = document.createElementNS(svgNS, "circle");
|
31
|
+
this.phantomCanvas.insertBefore(circle, this.phantomCanvas.firstChild);
|
32
|
+
circle.setAttribute("id", "phantomNote");
|
33
|
+
var r = 5;
|
34
|
+
circle.setAttribute("r", r.toString());
|
35
|
+
circle.setAttribute("fill", "black");
|
36
|
+
circle.setAttribute("opacity", "0.5");
|
37
|
+
circle.setAttribute("visibility", "hidden");
|
38
|
+
this.noteElement = circle;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
makeNewPhantomLine(options) {
|
42
|
+
if (options.lineX == undefined || options.lineY == undefined) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
if (this.container.classList.contains("clickmode")) {
|
46
|
+
new Promise((resolve) => {
|
47
|
+
var _a;
|
48
|
+
var line = document.createElementNS(svgNS, "line");
|
49
|
+
this.phantomCanvas.insertBefore(line, this.phantomCanvas.firstChild);
|
50
|
+
var width = 10;
|
51
|
+
var x1, x2, y1, y2;
|
52
|
+
y1 = y2 = options.lineY;
|
53
|
+
x1 = options.lineX - width;
|
54
|
+
x2 = options.lineX + width;
|
55
|
+
line.setAttribute("x1", x1.toString());
|
56
|
+
line.setAttribute("x2", x2.toString());
|
57
|
+
line.setAttribute("y1", y1.toString());
|
58
|
+
line.setAttribute("y2", y2.toString());
|
59
|
+
line.classList.add("phantomLine");
|
60
|
+
line.setAttribute("visibility", (_a = this.phantomCanvas.querySelector("#phantomNote")) === null || _a === void 0 ? void 0 : _a.getAttribute("visibility"));
|
61
|
+
resolve(true);
|
62
|
+
});
|
63
|
+
}
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* Draw markers in bar to approximate distances between notes.
|
67
|
+
* Division is always based on the selected duration in the toolbar and the time unit.
|
68
|
+
* @param options.lastStaffEnteredId Id of the staff where the markes will be drawn
|
69
|
+
* @returns
|
70
|
+
*/
|
71
|
+
makeNewTimeMarkers(options) {
|
72
|
+
var _a;
|
73
|
+
if (options.lastStaffEnteredId == undefined)
|
74
|
+
return;
|
75
|
+
var staff = cq.getVrvSVG(this.containerId).querySelector("#" + options.lastStaffEnteredId);
|
76
|
+
var staffHeight = Array.from(staff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom - staff.querySelector(".staffLine").getBoundingClientRect().top;
|
77
|
+
var staffBegin = staff.closest(".measure").getAttribute("n") === "1" ?
|
78
|
+
staff.querySelector(".meterSig").getBoundingClientRect().right :
|
79
|
+
staff.getBoundingClientRect().left;
|
80
|
+
var staffWidth = staff.getBoundingClientRect().right - staffBegin;
|
81
|
+
var measureN = staff.closest(".measure").getAttribute("n");
|
82
|
+
var staffN = staff.getAttribute("n");
|
83
|
+
var ratio = parseInt(options.measureMatrix.get(staffN, measureN).meterSig.count) / parseInt(options.measureMatrix.get(staffN, measureN).meterSig.unit);
|
84
|
+
var numLines = mappings_1.NoteButtonIdToNum.get((_a = cq.getContainer(this.containerId).querySelector("#noteGroup > .selected")) === null || _a === void 0 ? void 0 : _a.id) * ratio;
|
85
|
+
var cutUnit = staffWidth / numLines;
|
86
|
+
var linePosX = new Array();
|
87
|
+
var linePosY = staff.querySelector(".staffLine").getBoundingClientRect().top;
|
88
|
+
for (var i = 0; i < numLines; i++) {
|
89
|
+
linePosX.push(staffBegin + i * cutUnit);
|
90
|
+
}
|
91
|
+
linePosX.forEach(l => {
|
92
|
+
var _a;
|
93
|
+
var line = document.createElementNS(svgNS, "line");
|
94
|
+
this.phantomCanvas.insertBefore(line, this.phantomCanvas.firstChild);
|
95
|
+
var x1, x2, y1, y2;
|
96
|
+
y1 = linePosY;
|
97
|
+
y2 = linePosY - staffHeight / 5;
|
98
|
+
x1 = x2 = l; //+ (staffWidth / numLines)
|
99
|
+
var coords1 = coordinates.transformToDOMMatrixCoordinates(x1, y1, this.phantomCanvas);
|
100
|
+
var coords2 = coordinates.transformToDOMMatrixCoordinates(x2, y2, this.phantomCanvas);
|
101
|
+
line.setAttribute("x1", coords1.x.toString());
|
102
|
+
line.setAttribute("x2", coords2.x.toString());
|
103
|
+
line.setAttribute("y1", coords1.y.toString());
|
104
|
+
line.setAttribute("y2", coords2.y.toString());
|
105
|
+
line.classList.add("phantomMarker");
|
106
|
+
line.setAttribute("visibility", (_a = this.phantomCanvas.querySelector("#phantomNote")) === null || _a === void 0 ? void 0 : _a.getAttribute("visibility"));
|
107
|
+
});
|
108
|
+
}
|
109
|
+
removePhantomNote() {
|
110
|
+
if (this.container.querySelector("#phantomNote") !== null) {
|
111
|
+
this.container.querySelector("#phantomNote").remove();
|
112
|
+
}
|
113
|
+
}
|
114
|
+
setNoteRadius(r) {
|
115
|
+
this.noteR = r;
|
116
|
+
}
|
117
|
+
setPhantomCanvas(canvas) {
|
118
|
+
this.phantomCanvas = canvas;
|
119
|
+
return this;
|
120
|
+
}
|
121
|
+
setContainerId(id) {
|
122
|
+
this.containerId = id;
|
123
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
124
|
+
this.vrvSVG = cq.getVrvSVG(id);
|
125
|
+
this.container = document.getElementById(id);
|
126
|
+
return this;
|
127
|
+
}
|
128
|
+
getNoteElement() {
|
129
|
+
return this.noteElement;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
exports.default = PhantomElement;
|
@@ -0,0 +1,156 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const constants_1 = require("../constants");
|
4
|
+
const cq = require("../utils/convenienceQueries");
|
5
|
+
const manipFlag = "manipulator";
|
6
|
+
/**
|
7
|
+
* Class for all manipulators (Buttons, Lists, etc) directly visible in the score
|
8
|
+
*/
|
9
|
+
class ScoreManipulator {
|
10
|
+
constructor() {
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
*
|
14
|
+
* @param id Id for Elment
|
15
|
+
* @param classNames
|
16
|
+
* @param sign Plus or Minus sign
|
17
|
+
* @param posX
|
18
|
+
* @param posY
|
19
|
+
* @param size
|
20
|
+
* @param targetParent Parent to attach element to
|
21
|
+
* @param refId
|
22
|
+
* @returns
|
23
|
+
*/
|
24
|
+
drawButton(id = null, classNames = null, sign, posX, posY, size, targetParent, refId) {
|
25
|
+
var _a;
|
26
|
+
var newSVG = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
27
|
+
if (id !== null)
|
28
|
+
newSVG.setAttribute("id", id);
|
29
|
+
if (Array.from(this.interactionOverlay.querySelectorAll("maniplationCanvas *")).some(el => el.id === id)) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
newSVG.classList.add(manipFlag);
|
33
|
+
newSVG.setAttribute("x", posX.toString());
|
34
|
+
newSVG.setAttribute("y", posY.toString());
|
35
|
+
newSVG.setAttribute("height", size.toString());
|
36
|
+
newSVG.setAttribute("width", size.toString());
|
37
|
+
if (classNames !== null) {
|
38
|
+
var cn = classNames.split(" ");
|
39
|
+
cn.forEach(c => {
|
40
|
+
newSVG.classList.add(c);
|
41
|
+
});
|
42
|
+
}
|
43
|
+
var circle = document.createElementNS(constants_1.constants._SVGNS_, "circle");
|
44
|
+
circle.setAttribute("id", "manipulationButton");
|
45
|
+
circle.setAttribute("cx", "50%");
|
46
|
+
circle.setAttribute("cy", "50%");
|
47
|
+
circle.setAttribute("r", "40%");
|
48
|
+
newSVG.append(circle);
|
49
|
+
if (sign === "-" || sign === "+") {
|
50
|
+
var horizonal = document.createElementNS(constants_1.constants._SVGNS_, "line");
|
51
|
+
horizonal.classList.add("signElement");
|
52
|
+
horizonal.setAttribute("x1", "20%");
|
53
|
+
horizonal.setAttribute("y1", "50%");
|
54
|
+
horizonal.setAttribute("x2", "80%");
|
55
|
+
horizonal.setAttribute("y2", "50%");
|
56
|
+
newSVG.append(horizonal);
|
57
|
+
}
|
58
|
+
if (sign === "+") {
|
59
|
+
var vertical = horizonal.cloneNode(true);
|
60
|
+
vertical.setAttribute("transform", "rotate(90)");
|
61
|
+
vertical.setAttribute("transform-origin", "center");
|
62
|
+
newSVG.append(vertical);
|
63
|
+
}
|
64
|
+
newSVG.setAttribute("refId", refId);
|
65
|
+
(_a = this.interactionOverlay.querySelector("#manipulatorCanvas")) === null || _a === void 0 ? void 0 : _a.appendChild(newSVG);
|
66
|
+
}
|
67
|
+
drawMeasureAdder() {
|
68
|
+
this.lastBline = Array.from(this.vrvSVG.querySelectorAll(".barLine")).reverse()[0].querySelector("path");
|
69
|
+
var lastBlineRect = this.lastBline.getBoundingClientRect();
|
70
|
+
var rootBBox = this.vrvSVG.getBoundingClientRect();
|
71
|
+
var blineTop = lastBlineRect.top - rootBBox.y;
|
72
|
+
//var blineRight = lastBlineRect.right + rootBBox.height*0.001 - rootBBox.x
|
73
|
+
var blineRight = lastBlineRect.right - rootBBox.x;
|
74
|
+
var containerSize = lastBlineRect.height * 0.4;
|
75
|
+
this.drawButton("measureAdder", null, "+", blineRight, blineTop, containerSize, this.lastBline.closest("svg").parentElement, "Add Measure");
|
76
|
+
}
|
77
|
+
drawMeasureRemover() {
|
78
|
+
var _a;
|
79
|
+
this.lastBline = Array.from((_a = document.getElementById(this.containerId)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".barLine")).reverse()[0].querySelector("path");
|
80
|
+
var lastBlineRect = this.lastBline.getBoundingClientRect();
|
81
|
+
var lastBlineRect = this.lastBline.getBoundingClientRect();
|
82
|
+
var rootBBox = this.vrvSVG.getBoundingClientRect();
|
83
|
+
var blineTop = lastBlineRect.top - rootBBox.y + lastBlineRect.height / 2;
|
84
|
+
var blineRight = lastBlineRect.right - rootBBox.x;
|
85
|
+
var containerSize = lastBlineRect.height * 0.4;
|
86
|
+
this.drawButton("measureRemover", null, "-", blineRight, blineTop, containerSize, this.lastBline.closest("svg").parentElement, "Remove Measure");
|
87
|
+
}
|
88
|
+
drawStaffManipulators() {
|
89
|
+
this.vrvSVG.querySelector(".measure").querySelectorAll(".staff").forEach(s => {
|
90
|
+
var rootBBox = this.vrvSVG.getBoundingClientRect();
|
91
|
+
var refStaffCoords = this.getStaffManipulatorCoords(s);
|
92
|
+
var refStaffX = refStaffCoords.x;
|
93
|
+
var refStaffYTop = refStaffCoords.yTop;
|
94
|
+
var refStaffYBottom = refStaffCoords.yBottom;
|
95
|
+
var refStaffWidth = refStaffCoords.width;
|
96
|
+
var refStaffHeight = refStaffCoords.height;
|
97
|
+
var posX = refStaffX - refStaffWidth * 0.5 - rootBBox.x;
|
98
|
+
var topY = refStaffYTop - refStaffHeight * 0.2 - rootBBox.y;
|
99
|
+
var containerSize = refStaffHeight / 4;
|
100
|
+
this.drawButton(null, "addStaff above", "+", posX, topY, containerSize, this.vrvSVG, s.id);
|
101
|
+
if (parseInt(s.getAttribute("n")) > 1) {
|
102
|
+
posX = refStaffX - rootBBox.x;
|
103
|
+
this.drawButton(null, "removeStaff above", "-", posX, topY, containerSize, this.vrvSVG, s.id);
|
104
|
+
}
|
105
|
+
posX = refStaffX - refStaffWidth * 0.5 - rootBBox.x;
|
106
|
+
var bottomY = refStaffYBottom - rootBBox.y;
|
107
|
+
var containerSize = (refStaffHeight / 4);
|
108
|
+
this.drawButton(null, "addStaff below", "+", posX, bottomY, containerSize, this.vrvSVG, s.id);
|
109
|
+
var staffCount = s.parentElement.querySelectorAll(".staff");
|
110
|
+
if (parseInt(s.getAttribute("n")) !== staffCount.length) {
|
111
|
+
posX = refStaffX - rootBBox.x;
|
112
|
+
this.drawButton(null, "removeStaff below", "-", posX, bottomY, containerSize, this.vrvSVG, s.id);
|
113
|
+
}
|
114
|
+
});
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Get Coords for staf manipulators, since some browsers (Firefox) have problems with bounding boxes
|
118
|
+
* @param referenceStaff Staff beside which the staff manipulator should be placed
|
119
|
+
* @returns
|
120
|
+
*/
|
121
|
+
getStaffManipulatorCoords(referenceStaff) {
|
122
|
+
var x;
|
123
|
+
var yTop;
|
124
|
+
var yBottom;
|
125
|
+
var bbox;
|
126
|
+
var width;
|
127
|
+
var height;
|
128
|
+
if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1) {
|
129
|
+
bbox = referenceStaff.querySelector(".staffLine").getBoundingClientRect();
|
130
|
+
x = bbox.left;
|
131
|
+
yTop = bbox.top;
|
132
|
+
yBottom = Array.from(referenceStaff.querySelectorAll(".staffLine")).reverse()[0].getBoundingClientRect().bottom;
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
bbox = referenceStaff.querySelector(".clef").getBoundingClientRect();
|
136
|
+
x = bbox.left;
|
137
|
+
yTop = bbox.top;
|
138
|
+
yBottom = bbox.bottom;
|
139
|
+
}
|
140
|
+
height = referenceStaff.querySelector(".clef").getBoundingClientRect().height;
|
141
|
+
width = referenceStaff.querySelector(".clef").getBoundingClientRect().width;
|
142
|
+
return { x: x, yTop: yTop, yBottom: yBottom, width: width, height: height };
|
143
|
+
}
|
144
|
+
setMEI(mei) {
|
145
|
+
this.mei = mei;
|
146
|
+
return this;
|
147
|
+
}
|
148
|
+
setContainerId(id) {
|
149
|
+
this.containerId = id;
|
150
|
+
this.container = document.getElementById(id);
|
151
|
+
this.interactionOverlay = cq.getInteractOverlay(this.containerId);
|
152
|
+
this.vrvSVG = cq.getVrvSVG(this.containerId);
|
153
|
+
return this;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
exports.default = ScoreManipulator;
|