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,113 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
//@ts-ignore
|
5
|
+
//const $ = H5P.jQuery;
|
6
|
+
/**
|
7
|
+
* Class that handles insert mode, events, and actions.
|
8
|
+
*/
|
9
|
+
class AnnotationLineHandler {
|
10
|
+
constructor() {
|
11
|
+
this.initDragRects();
|
12
|
+
this.initAnnots();
|
13
|
+
//this.initCustomShapes()
|
14
|
+
}
|
15
|
+
setListeners() {
|
16
|
+
// if(typeof this.customShapes !== "undefined"){
|
17
|
+
// this.customShapes.call(this.dragShapeBehaviour)
|
18
|
+
// }
|
19
|
+
if (typeof this.annotations !== "undefined") {
|
20
|
+
//this.annotations.call(this.dragAnnotBehaviour);
|
21
|
+
this.lines.call(this.dragLineBehaviour);
|
22
|
+
}
|
23
|
+
return this;
|
24
|
+
}
|
25
|
+
removeListeners() {
|
26
|
+
// if(typeof this.customShapes !== "undefined"){
|
27
|
+
// this.customShapes.on(".drag", null);
|
28
|
+
// }
|
29
|
+
if (typeof this.annotations !== "undefined") {
|
30
|
+
//this.annotations.on(".drag", null);
|
31
|
+
this.lines.on(".drag", null);
|
32
|
+
}
|
33
|
+
return this;
|
34
|
+
}
|
35
|
+
resetListeners() {
|
36
|
+
this.removeListeners();
|
37
|
+
this.setListeners();
|
38
|
+
}
|
39
|
+
dragStarted() {
|
40
|
+
this.draggedAnnot = d3.event.sourceEvent.currentTarget;
|
41
|
+
this.draggedLine = d3.event.sourceEvent.currentTarget;
|
42
|
+
this.draggedShape = d3.event.sourceEvent.currentTarget;
|
43
|
+
try {
|
44
|
+
this.attachedLine = this.draggedAnnot.closest("g").getElementsByTagName("line")[0];
|
45
|
+
}
|
46
|
+
catch (_a) {
|
47
|
+
this.attachedLine = undefined;
|
48
|
+
}
|
49
|
+
this.dragStartCoords = [d3.event.x, d3.event.y];
|
50
|
+
this.dx = this.dragStartCoords[0];
|
51
|
+
this.dy = this.dragStartCoords[1];
|
52
|
+
}
|
53
|
+
////////// ANNOTS //////////
|
54
|
+
initAnnots() {
|
55
|
+
this.dragAnnotBehaviour = d3.drag()
|
56
|
+
.on('start', this.dragStarted.bind(this))
|
57
|
+
.on('drag', this.draggingAnnot.bind(this))
|
58
|
+
.on('end', this.dragAnnotEnded.bind(this));
|
59
|
+
this.annotations = d3.selectAll(".annotText");
|
60
|
+
this.dragStartCoords = new Array(this.annotations.size());
|
61
|
+
this.draggedAnnot = null;
|
62
|
+
this.resetListeners();
|
63
|
+
}
|
64
|
+
draggingAnnot() {
|
65
|
+
this.dx = d3.event.x;
|
66
|
+
this.dy = d3.event.y;
|
67
|
+
this.draggedAnnot.setAttribute("x", (this.dx).toString());
|
68
|
+
this.draggedAnnot.setAttribute("y", (this.dy).toString());
|
69
|
+
this.attachedLine.setAttribute("x1", this.draggedAnnot.getAttribute("x"));
|
70
|
+
this.attachedLine.setAttribute("y1", this.draggedAnnot.getAttribute("y"));
|
71
|
+
}
|
72
|
+
dragAnnotEnded() {
|
73
|
+
}
|
74
|
+
//////////// LINE ////////////////////
|
75
|
+
initDragRects() {
|
76
|
+
this.dragLineBehaviour = d3.drag()
|
77
|
+
.on('start', this.dragStarted.bind(this))
|
78
|
+
.on('drag', this.draggingLine.bind(this))
|
79
|
+
.on('end', this.dragLineEnded.bind(this));
|
80
|
+
this.lines = d3.selectAll(".lineDragRect");
|
81
|
+
this.dragStartCoords = new Array(this.lines.size());
|
82
|
+
this.draggedLine = null;
|
83
|
+
this.resetListeners();
|
84
|
+
}
|
85
|
+
draggingLine() {
|
86
|
+
this.dx = d3.event.x;
|
87
|
+
this.dy = d3.event.y;
|
88
|
+
this.draggedLine.setAttribute("x", (this.dx).toString());
|
89
|
+
this.draggedLine.setAttribute("y", (this.dy).toString());
|
90
|
+
this.attachedLine.setAttribute("x2", this.draggedLine.getAttribute("x"));
|
91
|
+
this.attachedLine.setAttribute("y2", this.draggedLine.getAttribute("y"));
|
92
|
+
this.highlightObjectCallback(this.draggedLine);
|
93
|
+
}
|
94
|
+
dragLineEnded() {
|
95
|
+
this.snapToObjCallback(this.attachedLine);
|
96
|
+
}
|
97
|
+
//////////// CALLBACKS ////////////
|
98
|
+
setSnapToObjCallback(snapToObj) {
|
99
|
+
this.snapToObjCallback = snapToObj;
|
100
|
+
return this;
|
101
|
+
}
|
102
|
+
removeUpdateAnnotationIDsCallback() {
|
103
|
+
this.snapToObjCallback = undefined;
|
104
|
+
return this;
|
105
|
+
}
|
106
|
+
sethighlightObjectCallback(highlightObjectCallback) {
|
107
|
+
this.highlightObjectCallback = highlightObjectCallback;
|
108
|
+
}
|
109
|
+
setUpdateCallback(updateCallback) {
|
110
|
+
this.updateCallback = updateCallback;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
exports.default = AnnotationLineHandler;
|
@@ -0,0 +1,113 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
//@ts-ignore
|
5
|
+
//const $ = H5P.jQuery;
|
6
|
+
/**
|
7
|
+
* Class that handles insert mode, events, and actions.
|
8
|
+
*/
|
9
|
+
class AnnotationLineHandler {
|
10
|
+
constructor() {
|
11
|
+
this.initDragRects();
|
12
|
+
this.initAnnots();
|
13
|
+
//this.initCustomShapes()
|
14
|
+
}
|
15
|
+
setListeners() {
|
16
|
+
// if(typeof this.customShapes !== "undefined"){
|
17
|
+
// this.customShapes.call(this.dragShapeBehaviour)
|
18
|
+
// }
|
19
|
+
if (typeof this.annotations !== "undefined") {
|
20
|
+
//this.annotations.call(this.dragAnnotBehaviour);
|
21
|
+
this.lines.call(this.dragLineBehaviour);
|
22
|
+
}
|
23
|
+
return this;
|
24
|
+
}
|
25
|
+
removeListeners() {
|
26
|
+
// if(typeof this.customShapes !== "undefined"){
|
27
|
+
// this.customShapes.on(".drag", null);
|
28
|
+
// }
|
29
|
+
if (typeof this.annotations !== "undefined") {
|
30
|
+
//this.annotations.on(".drag", null);
|
31
|
+
this.lines.on(".drag", null);
|
32
|
+
}
|
33
|
+
return this;
|
34
|
+
}
|
35
|
+
resetListeners() {
|
36
|
+
this.removeListeners();
|
37
|
+
this.setListeners();
|
38
|
+
}
|
39
|
+
dragStarted() {
|
40
|
+
this.draggedAnnot = d3.event.sourceEvent.currentTarget;
|
41
|
+
this.draggedLine = d3.event.sourceEvent.currentTarget;
|
42
|
+
this.draggedShape = d3.event.sourceEvent.currentTarget;
|
43
|
+
try {
|
44
|
+
this.attachedLine = this.draggedAnnot.closest("g").getElementsByTagName("line")[0];
|
45
|
+
}
|
46
|
+
catch (_a) {
|
47
|
+
this.attachedLine = undefined;
|
48
|
+
}
|
49
|
+
this.dragStartCoords = [d3.event.x, d3.event.y];
|
50
|
+
this.dx = this.dragStartCoords[0];
|
51
|
+
this.dy = this.dragStartCoords[1];
|
52
|
+
}
|
53
|
+
////////// ANNOTS //////////
|
54
|
+
initAnnots() {
|
55
|
+
this.dragAnnotBehaviour = d3.drag()
|
56
|
+
.on('start', this.dragStarted.bind(this))
|
57
|
+
.on('drag', this.draggingAnnot.bind(this))
|
58
|
+
.on('end', this.dragAnnotEnded.bind(this));
|
59
|
+
this.annotations = d3.selectAll(".annotText");
|
60
|
+
this.dragStartCoords = new Array(this.annotations.size());
|
61
|
+
this.draggedAnnot = null;
|
62
|
+
this.resetListeners();
|
63
|
+
}
|
64
|
+
draggingAnnot() {
|
65
|
+
this.dx = d3.event.x;
|
66
|
+
this.dy = d3.event.y;
|
67
|
+
this.draggedAnnot.setAttribute("x", (this.dx).toString());
|
68
|
+
this.draggedAnnot.setAttribute("y", (this.dy).toString());
|
69
|
+
this.attachedLine.setAttribute("x1", this.draggedAnnot.getAttribute("x"));
|
70
|
+
this.attachedLine.setAttribute("y1", this.draggedAnnot.getAttribute("y"));
|
71
|
+
}
|
72
|
+
dragAnnotEnded() {
|
73
|
+
}
|
74
|
+
//////////// LINE ////////////////////
|
75
|
+
initDragRects() {
|
76
|
+
this.dragLineBehaviour = d3.drag()
|
77
|
+
.on('start', this.dragStarted.bind(this))
|
78
|
+
.on('drag', this.draggingLine.bind(this))
|
79
|
+
.on('end', this.dragLineEnded.bind(this));
|
80
|
+
this.lines = d3.selectAll(".lineDragRect");
|
81
|
+
this.dragStartCoords = new Array(this.lines.size());
|
82
|
+
this.draggedLine = null;
|
83
|
+
this.resetListeners();
|
84
|
+
}
|
85
|
+
draggingLine() {
|
86
|
+
this.dx = d3.event.x;
|
87
|
+
this.dy = d3.event.y;
|
88
|
+
this.draggedLine.setAttribute("x", (this.dx).toString());
|
89
|
+
this.draggedLine.setAttribute("y", (this.dy).toString());
|
90
|
+
this.attachedLine.setAttribute("x2", this.draggedLine.getAttribute("x"));
|
91
|
+
this.attachedLine.setAttribute("y2", this.draggedLine.getAttribute("y"));
|
92
|
+
this.highlightObjectCallback(this.draggedLine);
|
93
|
+
}
|
94
|
+
dragLineEnded() {
|
95
|
+
this.snapToObjCallback(this.attachedLine);
|
96
|
+
}
|
97
|
+
//////////// CALLBACKS ////////////
|
98
|
+
setSnapToObjCallback(snapToObj) {
|
99
|
+
this.snapToObjCallback = snapToObj;
|
100
|
+
return this;
|
101
|
+
}
|
102
|
+
removeUpdateAnnotationIDsCallback() {
|
103
|
+
this.snapToObjCallback = undefined;
|
104
|
+
return this;
|
105
|
+
}
|
106
|
+
sethighlightObjectCallback(highlightObjectCallback) {
|
107
|
+
this.highlightObjectCallback = highlightObjectCallback;
|
108
|
+
}
|
109
|
+
setUpdateCallback(updateCallback) {
|
110
|
+
this.updateCallback = updateCallback;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
exports.default = AnnotationLineHandler;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const cq = require("../utils/convenienceQueries");
|
4
|
+
class ArticulatioHandler {
|
5
|
+
setListeners() {
|
6
|
+
}
|
7
|
+
removeListeners() {
|
8
|
+
throw new Error("Method not implemented.");
|
9
|
+
}
|
10
|
+
setM2S(m2s) {
|
11
|
+
this.m2s = m2s;
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
setContainerId(containerId) {
|
15
|
+
this.containerId = containerId;
|
16
|
+
this.container = cq.
|
17
|
+
;
|
18
|
+
return this;
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,265 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const coordinates = require("../utils/coordinates");
|
4
|
+
const cq = require("../utils/convenienceQueries");
|
5
|
+
class ClickModeHandler {
|
6
|
+
constructor() {
|
7
|
+
/**
|
8
|
+
* Event handler for inserting Notes
|
9
|
+
*/
|
10
|
+
this.clickHandler = (function clickHandler(e) {
|
11
|
+
var _a;
|
12
|
+
var t = e.target;
|
13
|
+
if (this.interactionOverlay.querySelector(".moving") !== null)
|
14
|
+
return;
|
15
|
+
if (["clef", "meterSig", "keySig", "rest", "notehead"].some(c => t.parentElement.classList.contains(c))) {
|
16
|
+
this.hideCursor();
|
17
|
+
return;
|
18
|
+
}
|
19
|
+
// when over other interactable elements discard event
|
20
|
+
if (!this.phantomElementHandler.getIsTrackingMouse()) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
if (this.musicPlayer.getIsPlaying() === true) {
|
24
|
+
return;
|
25
|
+
} // getIsPlaying could also be undefined
|
26
|
+
// var pt = new DOMPoint(e.clientX, e.clientY)
|
27
|
+
// var vrvSVG = this.vrvSVG as unknown as SVGGraphicsElement
|
28
|
+
// var pospt = pt.matrixTransform(vrvSVG.getScreenCTM().inverse())
|
29
|
+
var pospt = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.vrvSVG);
|
30
|
+
var posx = pospt.x;
|
31
|
+
var posy = pospt.y;
|
32
|
+
var target = e.target;
|
33
|
+
var options = {};
|
34
|
+
if (target.classList.contains("staffLine")) {
|
35
|
+
options["staffLineId"] = target.id;
|
36
|
+
}
|
37
|
+
if ((_a = this.interactionOverlay.querySelector("#phantomNote")) === null || _a === void 0 ? void 0 : _a.classList.contains("onChord")) {
|
38
|
+
options["targetChord"] = this.findScoreTarget(posx, posy);
|
39
|
+
}
|
40
|
+
//this.m2s.defineNote(e.pageX, e.pageY, options);
|
41
|
+
this.m2s.defineNote(posx, posy, options);
|
42
|
+
var newNote = this.m2s.getNewNote();
|
43
|
+
if (newNote == undefined)
|
44
|
+
return; //Eingabemaske in Chrome: zusätzliche Notenlinien in Noteneditor #10
|
45
|
+
var meiDoc = this.m2s.getCurrentMei();
|
46
|
+
var pitchExists = false;
|
47
|
+
// do not insert same note more than once in chord
|
48
|
+
if (newNote.chordElement != undefined) {
|
49
|
+
var chordEl = meiDoc.getElementById(newNote.chordElement.id);
|
50
|
+
if (chordEl.getAttribute("pname") === newNote.pname && chordEl.getAttribute("oct") === newNote.oct) {
|
51
|
+
pitchExists = true;
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
for (let c of chordEl.children) {
|
55
|
+
if (c.getAttribute("pname") === newNote.pname && c.getAttribute("oct") === newNote.oct) {
|
56
|
+
pitchExists = true;
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
if (!pitchExists) {
|
63
|
+
var replace = true; //(this.container.querySelector("#insertToggle") as HTMLInputElement).checked && newNote.chordElement == undefined
|
64
|
+
this.insertCallback(this.m2s.getNewNote(), replace).then(() => {
|
65
|
+
this.musicPlayer.generateTone(this.m2s.getNewNote());
|
66
|
+
}).catch(() => {
|
67
|
+
//alert("Your bar is to small")
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}).bind(this);
|
71
|
+
this.hideCursor = function () {
|
72
|
+
if (this.interactionOverlay.querySelector(".moving") !== null)
|
73
|
+
return;
|
74
|
+
this.container.querySelectorAll("#phantomCanvas > *").forEach(ph => {
|
75
|
+
ph.setAttribute("visibility", "hidden");
|
76
|
+
}); // make phantoms invisible
|
77
|
+
}.bind(this);
|
78
|
+
this.showCursor = function () {
|
79
|
+
this.container.querySelectorAll("#phantomCanvas > *").forEach(ph => ph.setAttribute("visibility", "visible")); // make phantoms invisible
|
80
|
+
}.bind(this);
|
81
|
+
this.mouseOverChordHandler = (function mouseOverHandler(e) {
|
82
|
+
var _a;
|
83
|
+
if (!this.phantomElementHandler.getIsTrackingMouse()) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
var coords = coordinates.transformToDOMMatrixCoordinates(e.clientX, e.clientY, this.interactionOverlay);
|
87
|
+
var posx = coords.x; //e.offsetX
|
88
|
+
var posy = coords.y; //e.offsetY
|
89
|
+
var elementToHighlight = this.findScoreTarget(posx, posy);
|
90
|
+
if (elementToHighlight == undefined || elementToHighlight.closest(".mRest") !== null || elementToHighlight.closest(".rest") !== null) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
if (this.prevElementToHighlight == undefined || this.currentElementToHighlight !== elementToHighlight) {
|
94
|
+
//update focussed layer if element and layer do not match
|
95
|
+
if (elementToHighlight.closest(".layer").id !== ((_a = this.m2s.getMouseEnterElementByName("layer")) === null || _a === void 0 ? void 0 : _a.id) && this.m2s.getMouseEnterElementByName("layer") !== null) {
|
96
|
+
this.m2s.setMouseEnterElements(elementToHighlight);
|
97
|
+
}
|
98
|
+
//snap note to closest Chord
|
99
|
+
var phantom = this.interactionOverlay.querySelector("#phantomNote");
|
100
|
+
var cx = parseFloat(phantom.getAttribute("cx"));
|
101
|
+
var bboxElement = this.interactionOverlay.querySelector("[refId=" + elementToHighlight.id + "]");
|
102
|
+
var ptLeft = new DOMPoint(bboxElement.getBoundingClientRect().left, 0);
|
103
|
+
var ptRight = new DOMPoint(bboxElement.getBoundingClientRect().right, 0);
|
104
|
+
var vrvSVG = this.interactionOverlay; //cq.getVrvSVG(this.containerId) as unknown as SVGGraphicsElement
|
105
|
+
var left = ptLeft.matrixTransform(vrvSVG.getScreenCTM().inverse()).x;
|
106
|
+
var right = ptRight.matrixTransform(vrvSVG.getScreenCTM().inverse()).x;
|
107
|
+
//snap only when within boundaries of target Chord
|
108
|
+
if (cx > left && cx < right) {
|
109
|
+
var snapTarget;
|
110
|
+
var snapTargetBBox;
|
111
|
+
var phantomSnapX;
|
112
|
+
var targetwidth;
|
113
|
+
var snapCoord;
|
114
|
+
// if(navigator.userAgent.toLowerCase().includes("firefox")){ // special rules for buggy firefox
|
115
|
+
// if(elementToHighlight.querySelector(".notehead") === null) return
|
116
|
+
// targetwidth = right - left//elementToHighlight.querySelector(".notehead")?.getBoundingClientRect().width
|
117
|
+
// snapTarget = elementToHighlight.classList.contains("chord") ? elementToHighlight : elementToHighlight.querySelector(".note") || elementToHighlight
|
118
|
+
// console.log("snapTarget", snapTarget)
|
119
|
+
// snapTargetBBox = snapTarget.getBoundingClientRect()
|
120
|
+
// // phantomSnapX = snapTargetBBox.x - window.scrollX - rootBBox.x - root.scrollLeft
|
121
|
+
// snapCoord = snapTargetBBox.x
|
122
|
+
// }else{
|
123
|
+
snapTarget = bboxElement; //elementToHighlight.querySelector(".notehead")|| elementToHighlight
|
124
|
+
snapTargetBBox = snapTarget.getBoundingClientRect();
|
125
|
+
// phantomSnapX = snapTargetBBox.x + snapTargetBBox.width/2 - window.scrollX - rootBBox.x - root.scrollLeft
|
126
|
+
snapCoord = snapTargetBBox.x + snapTargetBBox.width / 2;
|
127
|
+
//}
|
128
|
+
let snappt = new DOMPoint(snapCoord, 0);
|
129
|
+
phantomSnapX = snappt.matrixTransform(vrvSVG.getScreenCTM().inverse()).x;
|
130
|
+
if (elementToHighlight.querySelector(".chord") !== null) {
|
131
|
+
console.log(phantomSnapX);
|
132
|
+
}
|
133
|
+
phantom.setAttribute("cx", phantomSnapX.toString());
|
134
|
+
if (!phantom.classList.contains("onChord")) {
|
135
|
+
phantom.classList.add("onChord");
|
136
|
+
phantom.classList.add("l" + elementToHighlight.closest(".layer").getAttribute("n"));
|
137
|
+
if (!elementToHighlight.classList.contains("chord")) {
|
138
|
+
elementToHighlight.classList.add("highlighted");
|
139
|
+
}
|
140
|
+
else {
|
141
|
+
elementToHighlight.querySelectorAll(".note").forEach((c) => {
|
142
|
+
c.classList.add("highlighted");
|
143
|
+
});
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
for (const [key, value] of phantom.classList.entries()) {
|
149
|
+
if (value.indexOf("l") === 0) {
|
150
|
+
phantom.classList.remove(value);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
phantom.classList.remove("onChord");
|
154
|
+
phantom.setAttribute("fill", "black");
|
155
|
+
this.container.querySelectorAll(".highlighted").forEach(h => {
|
156
|
+
h.classList.remove("highlighted");
|
157
|
+
});
|
158
|
+
}
|
159
|
+
this.currentElementToHighlight = elementToHighlight;
|
160
|
+
}
|
161
|
+
}).bind(this);
|
162
|
+
}
|
163
|
+
setListeners() {
|
164
|
+
this.interactionOverlay.addEventListener('click', this.clickHandler);
|
165
|
+
this.interactionOverlay.addEventListener("mousemove", this.mouseOverChordHandler);
|
166
|
+
this.interactionOverlay.querySelectorAll("#scoreRects > *").forEach(sr => {
|
167
|
+
if (["clef", "meterSig", "keySig", "rest", "notehead", "harm",].some(c => sr.classList.contains(c))) {
|
168
|
+
sr.addEventListener("mouseover", this.hideCursor);
|
169
|
+
}
|
170
|
+
else {
|
171
|
+
sr.addEventListener("mouseover", this.showCursor);
|
172
|
+
}
|
173
|
+
});
|
174
|
+
this.interactionOverlay.querySelectorAll("#manipulatorCanvas *, #annotationCanvas *").forEach(sr => {
|
175
|
+
sr.addEventListener("mouseover", this.hideCursor);
|
176
|
+
sr.addEventListener("mouseleave", this.showCursor);
|
177
|
+
});
|
178
|
+
// Listener just for staves
|
179
|
+
var staves = this.interactionOverlay.querySelectorAll(".staffLine");
|
180
|
+
Array.from(staves).forEach(element => {
|
181
|
+
element.addEventListener('click', this.clickHandler);
|
182
|
+
});
|
183
|
+
}
|
184
|
+
removeListeners() {
|
185
|
+
this.interactionOverlay.removeEventListener('click', this.clickHandler);
|
186
|
+
this.interactionOverlay.removeEventListener("mousemove", this.mouseOverChordHandler);
|
187
|
+
if (this.annotations != undefined) {
|
188
|
+
var highLightElements = this.annotations.getAnnotationCanvas().querySelectorAll(".highlightChord");
|
189
|
+
Array.from(highLightElements).forEach(el => {
|
190
|
+
el.remove();
|
191
|
+
});
|
192
|
+
}
|
193
|
+
this.container.querySelectorAll(".highlighted").forEach((c) => {
|
194
|
+
c.classList.remove("highlighted");
|
195
|
+
});
|
196
|
+
this.interactionOverlay.querySelectorAll("#scoreRects > *").forEach(sr => {
|
197
|
+
if (["clef", "meterSig", "keySig", "rest", "notehead", "harm"].some(c => sr.classList.contains(c))) {
|
198
|
+
sr.removeEventListener("mouseover", this.hideCursor);
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
sr.removeEventListener("mouseover", this.showCursor);
|
202
|
+
}
|
203
|
+
});
|
204
|
+
// Listener just for staves
|
205
|
+
var staves = this.interactionOverlay.querySelectorAll(".staffLine");
|
206
|
+
Array.from(staves).forEach(element => {
|
207
|
+
element.removeEventListener('click', this.clickHandler);
|
208
|
+
});
|
209
|
+
}
|
210
|
+
resetListeners() {
|
211
|
+
this.removeListeners();
|
212
|
+
this.setListeners();
|
213
|
+
}
|
214
|
+
/**
|
215
|
+
* Find Score Element nearest to given Position (e.g. Mouse)
|
216
|
+
* @param posx client position
|
217
|
+
* @param posy client position
|
218
|
+
* @returns
|
219
|
+
*/
|
220
|
+
findScoreTarget(posx, posy) {
|
221
|
+
var _a;
|
222
|
+
var nextNote = this.m2s.findScoreTarget(posx, posy);
|
223
|
+
if (nextNote != undefined) {
|
224
|
+
var el = ((_a = this.vrvSVG.querySelector("#" + nextNote.id)) === null || _a === void 0 ? void 0 : _a.closest(".chord")) || this.vrvSVG.querySelector("#" + nextNote.id);
|
225
|
+
if (el.classList.contains("notehead")) {
|
226
|
+
el = el.parentElement;
|
227
|
+
}
|
228
|
+
return el;
|
229
|
+
}
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
///// GETTER / SETTER////////////////
|
233
|
+
setm2s(m2s) {
|
234
|
+
this.m2s = m2s;
|
235
|
+
return this;
|
236
|
+
}
|
237
|
+
setMusicProcessor(musicPlayer) {
|
238
|
+
this.musicPlayer = musicPlayer;
|
239
|
+
return this;
|
240
|
+
}
|
241
|
+
setContainerId(id) {
|
242
|
+
this.containerId = id;
|
243
|
+
this.vrvSVG = cq.getVrvSVG(id);
|
244
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
245
|
+
this.container = document.getElementById(id);
|
246
|
+
return this;
|
247
|
+
}
|
248
|
+
setAnnotations(annotations) {
|
249
|
+
this.annotations = annotations;
|
250
|
+
return this;
|
251
|
+
}
|
252
|
+
setInsertCallback(insertCallback) {
|
253
|
+
this.insertCallback = insertCallback;
|
254
|
+
return this;
|
255
|
+
}
|
256
|
+
setDeleteCallback(deleteCallback) {
|
257
|
+
this.deleteCallback = deleteCallback;
|
258
|
+
return this;
|
259
|
+
}
|
260
|
+
setPhantomCursor(peh) {
|
261
|
+
this.phantomElementHandler = peh;
|
262
|
+
return this;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
exports.default = ClickModeHandler;
|
@@ -0,0 +1,131 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const d3 = require("d3");
|
4
|
+
const random_1 = require("../utils/random");
|
5
|
+
const coordinates = require("../utils/coordinates");
|
6
|
+
const cq = require("../utils/convenienceQueries");
|
7
|
+
class CustomAnnotationShapeDrawer {
|
8
|
+
constructor(containerId) {
|
9
|
+
this.setContainerId(containerId);
|
10
|
+
this.shapes = new Array();
|
11
|
+
this.shapeID = "";
|
12
|
+
this.dragged = false;
|
13
|
+
this.canvas = d3.select("#" + this.containerId + " #interactionOverlay"); // draw directly in svg
|
14
|
+
this.dragBehaviour = d3.drag()
|
15
|
+
.on('start', drawStart)
|
16
|
+
.on('drag', this.drawing.bind(this))
|
17
|
+
.on('end', this.drawEnd.bind(this));
|
18
|
+
var that = this;
|
19
|
+
function drawStart() {
|
20
|
+
var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, that.interactionOverlay);
|
21
|
+
that.initialX = pt.x; //d3.event.x
|
22
|
+
that.initialY = pt.y; //d3.event.y
|
23
|
+
if (d3.event.sourceEvent.srcElement.id === that.interactionOverlay.id) {
|
24
|
+
that.initRect(that.initialX, that.initialY);
|
25
|
+
//that.initCircle(that.initialX, that.initialY)
|
26
|
+
}
|
27
|
+
}
|
28
|
+
this.setListeners();
|
29
|
+
}
|
30
|
+
drawing() {
|
31
|
+
var pt = coordinates.transformToDOMMatrixCoordinates(d3.event.sourceEvent.clientX, d3.event.sourceEvent.clientY, this.interactionOverlay);
|
32
|
+
const curX = pt.x; //d3.event.x
|
33
|
+
const curY = pt.y; //d3.event.y
|
34
|
+
if (this.shape == undefined) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
if (Math.abs(curX - this.initialX) > 20 || Math.abs(curY - this.initialY) > 20) {
|
38
|
+
this.dragged = true;
|
39
|
+
const newX = curX < this.initialX ? curX : this.initialX;
|
40
|
+
const newY = curY < this.initialY ? curY : this.initialY;
|
41
|
+
const width = curX < this.initialX ? this.initialX - curX : curX - this.initialX;
|
42
|
+
const height = curY < this.initialY ? this.initialY - curY : curY - this.initialY;
|
43
|
+
this.updateRect(newX, newY, width, height);
|
44
|
+
//this.updateCircle(newX, newY, width, height);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
drawEnd() {
|
48
|
+
if (this.shapeID === "")
|
49
|
+
return;
|
50
|
+
if (!this.dragged) {
|
51
|
+
var elToRemove = this.interactionOverlay.querySelector("#" + this.shapeID);
|
52
|
+
if (elToRemove !== null) {
|
53
|
+
elToRemove.remove();
|
54
|
+
}
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
var annotCanvas = this.interactionOverlay.querySelector("#annotationCanvas");
|
58
|
+
var pt = coordinates.getDOMMatrixCoordinates(this.shape, annotCanvas);
|
59
|
+
this.interactionOverlay.querySelector("#annotationCanvas").appendChild(this.shape);
|
60
|
+
this.shape.setAttribute("x", pt.left.toString());
|
61
|
+
this.shape.setAttribute("y", pt.top.toString());
|
62
|
+
this.shape.setAttribute("width", pt.width.toString());
|
63
|
+
this.shape.setAttribute("height", pt.height.toString());
|
64
|
+
this.shapes.push(this.shape.cloneNode(true));
|
65
|
+
}
|
66
|
+
this.shape = undefined;
|
67
|
+
this.updateCallback();
|
68
|
+
}
|
69
|
+
initRect(ulx, uly) {
|
70
|
+
this.shapeID = random_1.uuidv4();
|
71
|
+
this.canvas.append('rect')
|
72
|
+
.attr('x', ulx)
|
73
|
+
.attr('y', uly)
|
74
|
+
.attr('width', 0)
|
75
|
+
.attr('height', 0)
|
76
|
+
.attr("class", "customAnnotShape")
|
77
|
+
.attr("id", this.shapeID);
|
78
|
+
this.shape = document.getElementById(this.shapeID);
|
79
|
+
}
|
80
|
+
initCircle(cx, cy) {
|
81
|
+
this.shapeID = random_1.uuidv4();
|
82
|
+
this.canvas.append('ellipse')
|
83
|
+
.attr('cx', cx)
|
84
|
+
.attr('cy', cy)
|
85
|
+
.attr('rx', 0)
|
86
|
+
.attr('ry', 0)
|
87
|
+
.attr("class", "customAnnotShape")
|
88
|
+
.attr("id", this.shapeID);
|
89
|
+
this.shape = document.getElementById(this.shapeID);
|
90
|
+
}
|
91
|
+
updateRect(newX, newY, currentWidth, currentHeight) {
|
92
|
+
this.shape.setAttribute('x', newX.toString());
|
93
|
+
this.shape.setAttribute('y', newY.toString());
|
94
|
+
this.shape.setAttribute('width', currentWidth.toString());
|
95
|
+
this.shape.setAttribute('height', currentHeight.toString());
|
96
|
+
}
|
97
|
+
updateCircle(newX, newY, currentWidth, currentHeight) {
|
98
|
+
this.shape.setAttribute('cx', newX.toString());
|
99
|
+
this.shape.setAttribute('cy', newY.toString());
|
100
|
+
this.shape.setAttribute('rx', currentWidth.toString());
|
101
|
+
this.shape.setAttribute('ry', currentHeight.toString());
|
102
|
+
}
|
103
|
+
removeListeners() {
|
104
|
+
d3.select("#" + this.containerId + " #interactionOverlay").on('mousedown.drag', null);
|
105
|
+
}
|
106
|
+
setListeners() {
|
107
|
+
this.canvas.call(this.dragBehaviour);
|
108
|
+
}
|
109
|
+
resetListeners() {
|
110
|
+
this.removeListeners();
|
111
|
+
this.setListeners();
|
112
|
+
}
|
113
|
+
///////// GETTER/ SETTER ////////
|
114
|
+
setm2s(m2s) {
|
115
|
+
this.m2s = m2s;
|
116
|
+
}
|
117
|
+
setContainerId(id) {
|
118
|
+
this.containerId = id;
|
119
|
+
this.container = document.getElementById(id);
|
120
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
121
|
+
this.vrvSVG = cq.getVrvSVG(id);
|
122
|
+
}
|
123
|
+
getShapes() {
|
124
|
+
return this.shapes;
|
125
|
+
}
|
126
|
+
//////////// CALLBACKS /////////////
|
127
|
+
setUpdateCallback(updateCallback) {
|
128
|
+
this.updateCallback = updateCallback;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
exports.default = CustomAnnotationShapeDrawer;
|