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
@@ -1,113 +0,0 @@
|
|
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;
|
@@ -1,20 +0,0 @@
|
|
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
|
-
}
|
@@ -1,282 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const meiConverter = require("../utils/MEIConverter");
|
4
|
-
const constants_1 = require("../constants");
|
5
|
-
const random_1 = require("../utils/random");
|
6
|
-
const HarmonyLabel_1 = require("../gui/HarmonyLabel");
|
7
|
-
const coordinates = require("../utils/coordinates");
|
8
|
-
class HarmonyHandler {
|
9
|
-
constructor() {
|
10
|
-
this.setHarmonyLabelHandlerClick = (function setHarmonyLabelHandler(e) {
|
11
|
-
if (document.body.classList.contains("harmonyMode")) {
|
12
|
-
this.harmonyLabelHandler(e);
|
13
|
-
}
|
14
|
-
}).bind(this);
|
15
|
-
this.setHarmonyLabelHandlerKey = (function setHarmonyLabelHandler(e) {
|
16
|
-
if (e.ctrlKey || e.metaKey) {
|
17
|
-
if (e.key === "k" && Array.from(document.querySelectorAll(".note, .chord, .rest, .mrest")).some(el => el.classList.contains("marked"))) {
|
18
|
-
e.preventDefault();
|
19
|
-
this.harmonyLabelHandler(e);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}).bind(this);
|
23
|
-
this.activateHarmonyHighlight = (function highlightNextHarmonyHandler(e) {
|
24
|
-
if (e.type === "mouseleave" && !this.isGlobal) {
|
25
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).addEventListener("mousemove", this.activateHarmonyHighlight);
|
26
|
-
}
|
27
|
-
if (!this.isGlobal) {
|
28
|
-
this.highlightNextHarmony(e);
|
29
|
-
}
|
30
|
-
}).bind(this);
|
31
|
-
this.deactivateHarmonyHighlight = (function deactivateHighlight(e) {
|
32
|
-
// document.querySelectorAll(".marked").forEach(m => {
|
33
|
-
// m.classList.remove("marked")
|
34
|
-
// })
|
35
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).removeEventListener("mousemove", this.activateHarmonyHighlight);
|
36
|
-
}).bind(this);
|
37
|
-
this.modifyLabelHandler = (function modifyLabelHandler(e) {
|
38
|
-
document.querySelectorAll(".marked").forEach(m => {
|
39
|
-
m.classList.remove("marked");
|
40
|
-
});
|
41
|
-
this.modifyLabel(e);
|
42
|
-
}).bind(this);
|
43
|
-
this.submitLabelHandler = (function submitHandler(e) {
|
44
|
-
if (e.key === "Enter" && this.harmonyCanvas.hasChildNodes()) {
|
45
|
-
this.submitLabel();
|
46
|
-
}
|
47
|
-
}).bind(this);
|
48
|
-
this.closeModifyWindowHandler = (function closeModifyWindow(e) {
|
49
|
-
if (e.key === "Escape") {
|
50
|
-
this.closeModifyWindow();
|
51
|
-
}
|
52
|
-
}).bind(this);
|
53
|
-
this.addCanvas();
|
54
|
-
this.harmonyElements = new Map();
|
55
|
-
}
|
56
|
-
addCanvas() {
|
57
|
-
if (typeof this.harmonyCanvas === "undefined") {
|
58
|
-
this.harmonyCanvas = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
59
|
-
this.harmonyCanvas.setAttribute("id", "harmonyCanvas");
|
60
|
-
}
|
61
|
-
this.root = document.getElementById(constants_1.constants._ROOTSVGID_);
|
62
|
-
this.root.insertBefore(this.harmonyCanvas, this.root.firstChild);
|
63
|
-
}
|
64
|
-
setListeners() {
|
65
|
-
document.querySelectorAll(".sylTextRect").forEach(s => {
|
66
|
-
s.remove();
|
67
|
-
});
|
68
|
-
if (!this.isGlobal) {
|
69
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).addEventListener("click", this.setHarmonyLabelHandlerClick, true);
|
70
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).addEventListener("mousemove", this.activateHarmonyHighlight);
|
71
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).addEventListener("keydown", this.closeModifyWindowHandler, true);
|
72
|
-
}
|
73
|
-
document.addEventListener("keydown", this.setHarmonyLabelHandlerKey);
|
74
|
-
document.querySelectorAll(".harm").forEach(h => {
|
75
|
-
h.addEventListener("mouseover", this.deactivateHarmonyHighlight);
|
76
|
-
h.addEventListener("mouseleave", this.activateHarmonyHighlight);
|
77
|
-
h.addEventListener("dblclick", this.modifyLabelHandler);
|
78
|
-
});
|
79
|
-
return this;
|
80
|
-
}
|
81
|
-
removeListeners() {
|
82
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).removeEventListener("click", this.setHarmonyLabelHandlerClick);
|
83
|
-
document.removeEventListener("keydown", this.setHarmonyLabelHandlerKey);
|
84
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).removeEventListener("mousemove", this.activateHarmonyHighlight);
|
85
|
-
document.getElementById(constants_1.constants._ROOTSVGID_).removeEventListener("keydown", this.closeModifyWindowHandler);
|
86
|
-
document.querySelectorAll(".harm").forEach(h => {
|
87
|
-
h.removeEventListener("mouseenter", this.deactivateHarmonyHighlight);
|
88
|
-
h.removeEventListener("mouseleave", this.activateHarmonyHighlight);
|
89
|
-
h.removeEventListener("dblclick", this.modifyLabelHandler);
|
90
|
-
});
|
91
|
-
return this;
|
92
|
-
}
|
93
|
-
/**
|
94
|
-
* Open Inputbox for (first) selected Note
|
95
|
-
*/
|
96
|
-
harmonyLabelHandler(e) {
|
97
|
-
var root = document.getElementById(constants_1.constants._ROOTSVGID_);
|
98
|
-
var rootBBox = root.getBoundingClientRect();
|
99
|
-
var nextNote = document.querySelector(".note.marked, .chord.marked");
|
100
|
-
if (nextNote === null) {
|
101
|
-
return;
|
102
|
-
}
|
103
|
-
var nextNoteBBox = nextNote.getBoundingClientRect();
|
104
|
-
var staffBBox = nextNote.closest(".staff").getBoundingClientRect();
|
105
|
-
var posx = nextNoteBBox.left - nextNoteBBox.width / 2 - window.scrollX - rootBBox.x - root.scrollLeft;
|
106
|
-
var posy = staffBBox.bottom - window.scrollY - rootBBox.y - root.scrollLeft;
|
107
|
-
if (this.currentMEI.querySelector("harm[startid=\"" + nextNote.id + "\"]") === null && !this.harmonyCanvas.hasChildNodes()) {
|
108
|
-
this.createInputBox(posx, posy, nextNote.id);
|
109
|
-
}
|
110
|
-
else if (this.harmonyCanvas.hasChildNodes()) {
|
111
|
-
this.closeModifyWindow();
|
112
|
-
}
|
113
|
-
}
|
114
|
-
setHarmonyLabel(label, bboxId) {
|
115
|
-
var harmonyLabel = new HarmonyLabel_1.default(label, bboxId, this.currentMEI); // TODO: Make Dynamically
|
116
|
-
this.harmonyElements.set(harmonyLabel.getHarmElement().id, harmonyLabel);
|
117
|
-
var measure = this.currentMEI.getElementById(bboxId).closest("measure");
|
118
|
-
measure.appendChild(harmonyLabel.getHarmElement());
|
119
|
-
var mei = meiConverter.restoreXmlIdTags(this.currentMEI);
|
120
|
-
this.loadDataCallback("", mei, false, constants_1.constants._TARGETDIVID_).then(() => {
|
121
|
-
this.reset();
|
122
|
-
});
|
123
|
-
return harmonyLabel;
|
124
|
-
}
|
125
|
-
highlightNextHarmony(e, active = true) {
|
126
|
-
if (!active) {
|
127
|
-
return;
|
128
|
-
}
|
129
|
-
var posx = coordinates.adjustToPage(e.pageX, "x");
|
130
|
-
var posy = coordinates.adjustToPage(e.pageY, "y");
|
131
|
-
var nextNoteBBox = this.m2m.findScoreTarget(posx, posy);
|
132
|
-
var el = document.getElementById(nextNoteBBox.id);
|
133
|
-
if (el.closest(".chord") !== null) {
|
134
|
-
el = el.closest(".chord");
|
135
|
-
}
|
136
|
-
if (!el.classList.contains("marked")) {
|
137
|
-
document.querySelectorAll(".marked").forEach(m => {
|
138
|
-
m.classList.remove("marked");
|
139
|
-
});
|
140
|
-
el.classList.add("marked");
|
141
|
-
}
|
142
|
-
}
|
143
|
-
modifyLabel(e) {
|
144
|
-
var target = e.target;
|
145
|
-
target = target.closest(".harm");
|
146
|
-
target.setAttribute("visibility", "hidden");
|
147
|
-
this.harmId = target.id;
|
148
|
-
var targetBBox = target.getBoundingClientRect();
|
149
|
-
var root = document.getElementById(constants_1.constants._ROOTSVGID_);
|
150
|
-
var rootBBox = root.getBoundingClientRect();
|
151
|
-
var posx = targetBBox.x - window.scrollX - rootBBox.left - root.scrollLeft; //coordinates.adjustToPage(e.pageX, "x")
|
152
|
-
var posy = targetBBox.y - window.scrollY - rootBBox.top - root.scrollTop; //coordinates.adjustToPage(e.pageY, "y")
|
153
|
-
if (document.querySelector("*[refHarmId=\"" + target.id + "\"]") !== null) {
|
154
|
-
return;
|
155
|
-
}
|
156
|
-
this.createInputBox(posx, posy, target.id);
|
157
|
-
}
|
158
|
-
closeModifyWindow() {
|
159
|
-
Array.from(this.harmonyCanvas.children).forEach(c => {
|
160
|
-
c.remove();
|
161
|
-
});
|
162
|
-
// clean MEI from empty harm Elements
|
163
|
-
this.currentMEI.querySelectorAll("harm").forEach(h => {
|
164
|
-
var _a;
|
165
|
-
(_a = document.getElementById(h.id)) === null || _a === void 0 ? void 0 : _a.setAttribute("visibility", "visible");
|
166
|
-
if (h.childElementCount > 0) {
|
167
|
-
if (h.firstElementChild.childElementCount === 0) {
|
168
|
-
h.remove();
|
169
|
-
}
|
170
|
-
}
|
171
|
-
else if (h.textContent.length === 0) {
|
172
|
-
h.remove();
|
173
|
-
}
|
174
|
-
});
|
175
|
-
}
|
176
|
-
submitLabel() {
|
177
|
-
var harmonyDiv = this.harmonyCanvas.getElementsByClassName("harmonyDiv")[0];
|
178
|
-
var text = harmonyDiv.textContent;
|
179
|
-
var harmLabel = this.harmonyElements.get(harmonyDiv.closest("g").getAttribute("refHarmId"));
|
180
|
-
if (typeof harmLabel !== "undefined") {
|
181
|
-
harmLabel.modifyLabel(text);
|
182
|
-
var currentHarm = this.currentMEI.getElementById(harmLabel.getHarmElement().id);
|
183
|
-
currentHarm.parentElement.replaceChild(harmLabel.getHarmElement(), currentHarm);
|
184
|
-
}
|
185
|
-
else {
|
186
|
-
harmLabel = this.setHarmonyLabel(harmonyDiv.textContent, harmonyDiv.closest("g").getAttribute("refHarmId"));
|
187
|
-
var oldLabel = this.currentMEI.getElementById(this.harmId);
|
188
|
-
harmLabel.getHarmElement().setAttribute("tstamp", oldLabel.getAttribute("tstamp"));
|
189
|
-
harmLabel.getHarmElement().setAttribute("startid", oldLabel.getAttribute("startid"));
|
190
|
-
oldLabel.remove();
|
191
|
-
}
|
192
|
-
this.closeModifyWindow();
|
193
|
-
var mei = meiConverter.restoreXmlIdTags(this.currentMEI);
|
194
|
-
this.loadDataCallback("", mei, false, constants_1.constants._TARGETDIVID_).then(() => {
|
195
|
-
this.reset();
|
196
|
-
});
|
197
|
-
}
|
198
|
-
createInputBox(posx, posy, targetId) {
|
199
|
-
var textGroup = document.createElementNS(constants_1.constants._SVGNS_, "g");
|
200
|
-
textGroup.setAttribute("id", random_1.uuidv4());
|
201
|
-
textGroup.setAttribute("refHarmId", targetId);
|
202
|
-
var text = document.createElementNS(constants_1.constants._SVGNS_, "svg");
|
203
|
-
text.classList.add("harmonyText");
|
204
|
-
var textForeignObject = document.createElementNS(constants_1.constants._SVGNS_, "foreignObject");
|
205
|
-
textForeignObject.classList.add("harmonyFO");
|
206
|
-
var textDiv = document.createElement("div");
|
207
|
-
textDiv.setAttribute("contenteditable", "true");
|
208
|
-
textDiv.textContent = typeof this.harmonyElements.get(targetId) !== "undefined" ? this.harmonyElements.get(targetId).getInputString() : "";
|
209
|
-
textDiv.classList.add("harmonyDiv");
|
210
|
-
text.append(textForeignObject);
|
211
|
-
document.body.appendChild(textDiv);
|
212
|
-
var rectPadding = 5;
|
213
|
-
text.setAttribute("x", (posx + rectPadding).toString());
|
214
|
-
text.setAttribute("y", (posy).toString());
|
215
|
-
textForeignObject.setAttribute("x", "0");
|
216
|
-
textForeignObject.setAttribute("y", "0");
|
217
|
-
textForeignObject.setAttribute("height", (textDiv.clientHeight + 2 * rectPadding).toString());
|
218
|
-
textForeignObject.setAttribute("width", (100 + 2 * rectPadding).toString());
|
219
|
-
this.harmonyCanvas.appendChild(textGroup);
|
220
|
-
textGroup.appendChild(text);
|
221
|
-
textForeignObject.appendChild(textDiv);
|
222
|
-
// Special Listeners while Editing Harmonies
|
223
|
-
var that = this;
|
224
|
-
textDiv.addEventListener("focus", function () {
|
225
|
-
that.removeListeners();
|
226
|
-
that.musicPlayer.removePlayListener();
|
227
|
-
});
|
228
|
-
textDiv.addEventListener("blur", function () {
|
229
|
-
that.setListeners();
|
230
|
-
that.musicPlayer.setPlayListener();
|
231
|
-
});
|
232
|
-
textDiv.addEventListener("keydown", this.submitLabelHandler);
|
233
|
-
textDiv.focus();
|
234
|
-
}
|
235
|
-
getTimestamp(note) {
|
236
|
-
var layer = note.closest("layer");
|
237
|
-
var elements = Array.from(layer.querySelectorAll("*[dur]"));
|
238
|
-
elements = elements.filter((v, i) => i <= elements.indexOf(note));
|
239
|
-
var tstamp;
|
240
|
-
elements.forEach(e => {
|
241
|
-
var dur = parseInt(e.getAttribute("dur"));
|
242
|
-
tstamp += 4 / dur;
|
243
|
-
var dots = e.getAttribute("dots");
|
244
|
-
var add = dur;
|
245
|
-
if (dots !== null) {
|
246
|
-
for (var i = 0; i < parseInt(dots); i++) {
|
247
|
-
add = add / 2;
|
248
|
-
tstamp += add;
|
249
|
-
}
|
250
|
-
}
|
251
|
-
});
|
252
|
-
return tstamp;
|
253
|
-
}
|
254
|
-
reset() {
|
255
|
-
this.setListeners();
|
256
|
-
this.addCanvas();
|
257
|
-
}
|
258
|
-
setM2M(m2m) {
|
259
|
-
this.m2m = m2m;
|
260
|
-
return this;
|
261
|
-
}
|
262
|
-
setCurrentMEI(mei) {
|
263
|
-
this.currentMEI = mei;
|
264
|
-
return this;
|
265
|
-
}
|
266
|
-
setMusicPlayer(musicPlayer) {
|
267
|
-
this.musicPlayer = musicPlayer;
|
268
|
-
return this;
|
269
|
-
}
|
270
|
-
setGlobal(global) {
|
271
|
-
this.isGlobal = global;
|
272
|
-
return this;
|
273
|
-
}
|
274
|
-
getGlobal() {
|
275
|
-
return this.isGlobal;
|
276
|
-
}
|
277
|
-
setLoadDataCallback(loadDataCallback) {
|
278
|
-
this.loadDataCallback = loadDataCallback;
|
279
|
-
return this;
|
280
|
-
}
|
281
|
-
}
|
282
|
-
exports.default = HarmonyHandler;
|