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,407 @@
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
2
|
+
const Cursor_1 = require("../gui/Cursor");
|
3
|
+
const mappings_1 = require("../utils/mappings");
|
4
|
+
const random_1 = require("../utils/random");
|
5
|
+
const cq = require("../utils/convenienceQueries");
|
6
|
+
const marked = "marked";
|
7
|
+
class KeyModeHandler {
|
8
|
+
constructor(containerId) {
|
9
|
+
/**
|
10
|
+
* Event handler for inserting Notes
|
11
|
+
*/
|
12
|
+
this.keyModeHandler = (function keyModeHandler(e) {
|
13
|
+
var _a;
|
14
|
+
if (!cq.hasActiveElement(this.containerId))
|
15
|
+
return;
|
16
|
+
if (this.musicPlayer.getIsPlaying() === true) {
|
17
|
+
return;
|
18
|
+
} // getIsPlaying could also be undefined
|
19
|
+
if (mappings_1.keyCodeNoteMap.has(e.code) && typeof this.cursor != undefined) {
|
20
|
+
e.preventDefault();
|
21
|
+
var pname = mappings_1.keyCodeNoteMap.get(e.code);
|
22
|
+
var oct = mappings_1.octToNum.get((_a = this.container.querySelector("#octaveGroupKM .selected")) === null || _a === void 0 ? void 0 : _a.id) || "4";
|
23
|
+
const newNote = this.createNewNote(pname, oct, null);
|
24
|
+
if (newNote == undefined)
|
25
|
+
return;
|
26
|
+
var noteExists = false;
|
27
|
+
var noteToDelete;
|
28
|
+
if (this.cursor.nextElement.classList.contains("chord")) {
|
29
|
+
var chordNotes = Array.from(this.cursor.nextElement.querySelectorAll(".note"));
|
30
|
+
chordNotes.forEach((n) => {
|
31
|
+
var meiNote = this.m2m.getCurrentMei().getElementById(n.id);
|
32
|
+
var sameOct = meiNote.getAttribute("oct") === newNote.oct;
|
33
|
+
var samePname = meiNote.getAttribute("pname") === newNote.pname;
|
34
|
+
if (sameOct && samePname) {
|
35
|
+
noteExists = true;
|
36
|
+
noteToDelete = n;
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
if (!noteExists) {
|
41
|
+
var replace = this.container.querySelector("#insertToggle").checked;
|
42
|
+
this.insertCallback(newNote, replace).then(() => {
|
43
|
+
this.m2m.update();
|
44
|
+
this.resetListeners();
|
45
|
+
var currentTargetId;
|
46
|
+
if (newNote.chordElement != undefined) {
|
47
|
+
currentTargetId = this.rootSVG.querySelector("#" + newNote.chordElement.id).closest(".chord").id; // new chord with own ID is created, if note is added
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
currentTargetId = newNote.id;
|
51
|
+
}
|
52
|
+
this.scoreGraph.setCurrentNodeById(currentTargetId);
|
53
|
+
if (this.scoreGraph.getCurrentNode() != undefined) {
|
54
|
+
this.cursor.definePosById(this.scoreGraph.getCurrentNode().getId());
|
55
|
+
}
|
56
|
+
this.musicPlayer.generateTone(newNote);
|
57
|
+
}).catch(() => {
|
58
|
+
//alert("your bar is too small")
|
59
|
+
});
|
60
|
+
}
|
61
|
+
else {
|
62
|
+
this.deleteCallback([noteToDelete]).then(() => {
|
63
|
+
var _a;
|
64
|
+
this.m2m.update();
|
65
|
+
this.resetListeners();
|
66
|
+
this.scoreGraph.setCurrentNodeById(newNote.chordElement.id);
|
67
|
+
this.cursor.definePosById((_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId());
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}).bind(this);
|
72
|
+
this.pressedHandler = (function pressedHandler(e) {
|
73
|
+
this.assignKeys(e);
|
74
|
+
}).bind(this);
|
75
|
+
/**
|
76
|
+
* Event Handler for any Keyboard input (except inserting)
|
77
|
+
*/
|
78
|
+
this.keyInputHandler = (function keyInputHandler(e) {
|
79
|
+
var _a, _b;
|
80
|
+
if (!cq.hasActiveElement(this.containerId))
|
81
|
+
return;
|
82
|
+
if (e.ctrlKey || e.metaKey)
|
83
|
+
return; //prevent confusion with global keyboard functionalities
|
84
|
+
if (this.interactionOverlay.querySelector("div[contenteditable=true]") !== null)
|
85
|
+
return; // prevent navigating in scrore, when label editor is open
|
86
|
+
//this.setCurrentNodeScoreGraph()
|
87
|
+
if (this.scoreGraph.getCurrentNode() == undefined) {
|
88
|
+
(_a = this.scoreGraph) === null || _a === void 0 ? void 0 : _a.setCurrentNodeById((_b = this.cursor) === null || _b === void 0 ? void 0 : _b.getNextElement().id);
|
89
|
+
}
|
90
|
+
if (e.shiftKey && e.key.includes("Arrow")) {
|
91
|
+
e.preventDefault();
|
92
|
+
this.navigateSelection(e.key);
|
93
|
+
}
|
94
|
+
else if (e.key.includes("Arrow")) {
|
95
|
+
e.preventDefault();
|
96
|
+
this.endSelection();
|
97
|
+
this.navigateCursor(e.key);
|
98
|
+
}
|
99
|
+
else if (["Delete", "Backspace"].indexOf(e.key) > -1) {
|
100
|
+
e.preventDefault();
|
101
|
+
//this.deleteByKey(e.key)
|
102
|
+
}
|
103
|
+
}).bind(this);
|
104
|
+
/**
|
105
|
+
* Set Cursor to new position after pasting
|
106
|
+
*/
|
107
|
+
this.pastedHandler = (function pastedHandler(e) {
|
108
|
+
var _a;
|
109
|
+
console.log("PASTED ", e);
|
110
|
+
this.scoreGraph.setCurrentNodeById(e.detail);
|
111
|
+
this.cursor.definePosById((_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId());
|
112
|
+
}).bind(this);
|
113
|
+
this.setContainerId(containerId);
|
114
|
+
this.cursor = new Cursor_1.default(containerId);
|
115
|
+
}
|
116
|
+
setListeners() {
|
117
|
+
document.addEventListener("keydown", this.pressedHandler);
|
118
|
+
document.addEventListener("keyup", this.pressedHandler);
|
119
|
+
document.addEventListener('keydown', this.keyModeHandler);
|
120
|
+
document.addEventListener('keydown', this.keyInputHandler);
|
121
|
+
document.addEventListener("pasted", this.pastedHandler);
|
122
|
+
this.cursor.setClickListener();
|
123
|
+
}
|
124
|
+
removeListeners() {
|
125
|
+
document.removeEventListener("keydown", this.pressedHandler);
|
126
|
+
document.removeEventListener("keyup", this.pressedHandler);
|
127
|
+
document.removeEventListener('keydown', this.keyModeHandler);
|
128
|
+
document.removeEventListener('keydown', this.keyInputHandler);
|
129
|
+
document.removeEventListener("pasted", this.pastedHandler);
|
130
|
+
this.cursor.flashStop();
|
131
|
+
this.cursor.removeClickListener();
|
132
|
+
}
|
133
|
+
resetListeners() {
|
134
|
+
this.removeListeners();
|
135
|
+
this.setListeners();
|
136
|
+
}
|
137
|
+
assignKeys(e) {
|
138
|
+
var b = false;
|
139
|
+
if (e.type === "keydown") {
|
140
|
+
b = true;
|
141
|
+
}
|
142
|
+
else if (e.type === "keyup") {
|
143
|
+
b = false;
|
144
|
+
}
|
145
|
+
switch (e.key) {
|
146
|
+
case "Shift":
|
147
|
+
this.shiftDown = b;
|
148
|
+
break;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* create a newNote
|
153
|
+
* @param pname pitch name
|
154
|
+
* @param oct octave
|
155
|
+
* @param options
|
156
|
+
* @returns
|
157
|
+
*/
|
158
|
+
createNewNote(pname, oct, options) {
|
159
|
+
var _a, _b;
|
160
|
+
//get relevant staffinfo
|
161
|
+
this.setCurrentNodeScoreGraph();
|
162
|
+
var nearestNodeId = (_a = this.scoreGraph.getCurrentNode()) === null || _a === void 0 ? void 0 : _a.getId();
|
163
|
+
if (nearestNodeId == undefined)
|
164
|
+
return;
|
165
|
+
var closestStaff = ((_b = this.m2m.getCurrentMei().getElementById(nearestNodeId)) === null || _b === void 0 ? void 0 : _b.closest("staff")) || this.m2m.getCurrentMei().querySelector("measure > staff"); //asume first measure first staff
|
166
|
+
var closestMeasure = closestStaff.closest("measure");
|
167
|
+
var closestStaffIdx = parseInt(closestStaff.getAttribute("n")) - 1;
|
168
|
+
var closestMeasureIdx = parseInt(closestMeasure.getAttribute("n")) - 1;
|
169
|
+
var keysig = this.m2m.getMeasureMatrix().get(closestMeasureIdx, closestStaffIdx).keysig;
|
170
|
+
var accids;
|
171
|
+
var accid;
|
172
|
+
if (keysig == undefined) {
|
173
|
+
accids = mappings_1.keysigToNotes.get(keysig);
|
174
|
+
accids = accids.filter((s) => { return s === pname; });
|
175
|
+
if (accids.length === 1) {
|
176
|
+
accid = keysig.charAt(1);
|
177
|
+
}
|
178
|
+
}
|
179
|
+
var targetChord;
|
180
|
+
//if(this.container.querySelector("#chordButton")?.classList.contains("selected")){
|
181
|
+
if (this.shiftDown) {
|
182
|
+
targetChord = this.rootSVG.querySelector("#" + nearestNodeId);
|
183
|
+
if ((targetChord === null || targetChord === void 0 ? void 0 : targetChord.closest(".chord")) !== null) {
|
184
|
+
targetChord = targetChord.closest(".chord");
|
185
|
+
}
|
186
|
+
}
|
187
|
+
var relPosX = this.cursor.isBOL() ? "left" : "right";
|
188
|
+
this.setContainerId(this.containerId);
|
189
|
+
var newNote = {
|
190
|
+
pname: pname,
|
191
|
+
id: random_1.uuidv4(),
|
192
|
+
dur: this.m2m.getDurationNewNote(),
|
193
|
+
dots: this.m2m.getDotsNewNote(),
|
194
|
+
oct: oct,
|
195
|
+
keysig: keysig,
|
196
|
+
accid: accid,
|
197
|
+
nearestNoteId: nearestNodeId,
|
198
|
+
relPosX: relPosX,
|
199
|
+
staffId: this.rootSVG.querySelector("#" + nearestNodeId).closest(".staff").id,
|
200
|
+
chordElement: targetChord,
|
201
|
+
rest: this.container.querySelector("#pauseNote").classList.contains("selected")
|
202
|
+
};
|
203
|
+
return newNote;
|
204
|
+
}
|
205
|
+
/**
|
206
|
+
* Navigate through Scoregraph with Arrow Keys
|
207
|
+
* @param direction Key Code for Arrows
|
208
|
+
*/
|
209
|
+
navigateCursor(direction) {
|
210
|
+
var _a, _b, _c, _d, _e;
|
211
|
+
var prevNode = this.scoreGraph.getCurrentNode();
|
212
|
+
var container = document.getElementById(this.containerId);
|
213
|
+
this.rootSVG.querySelectorAll(".marked").forEach(m => m.classList.remove("marked"));
|
214
|
+
var cbs = (_a = container.querySelector("#chordButton")) === null || _a === void 0 ? void 0 : _a.classList.contains("selected");
|
215
|
+
if (cbs) {
|
216
|
+
this.scoreGraph.nextClass(["chord", "note"], direction);
|
217
|
+
}
|
218
|
+
else {
|
219
|
+
switch (direction) {
|
220
|
+
case "ArrowLeft":
|
221
|
+
(_b = document.querySelectorAll(".lastAdded")) === null || _b === void 0 ? void 0 : _b.forEach(la => la.classList.remove("lastAdded"));
|
222
|
+
this.scoreGraph.nextLeft();
|
223
|
+
break;
|
224
|
+
case "ArrowRight":
|
225
|
+
(_c = document.querySelectorAll(".lastAdded")) === null || _c === void 0 ? void 0 : _c.forEach(la => la.classList.remove("lastAdded"));
|
226
|
+
this.scoreGraph.nextRight();
|
227
|
+
break;
|
228
|
+
// case "ArrowUp":
|
229
|
+
// this.scoreGraph.nextUp()
|
230
|
+
// break;
|
231
|
+
// case "ArrowDown":
|
232
|
+
// this.scoreGraph.nextDown()
|
233
|
+
// break;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
if (this.scoreGraph.getCurrentNode() == undefined)
|
237
|
+
return;
|
238
|
+
(_d = this.rootSVG.querySelector("#" + prevNode.getId())) === null || _d === void 0 ? void 0 : _d.classList.remove("marked");
|
239
|
+
this.cursor.definePosById(this.scoreGraph.getCurrentNode().getId());
|
240
|
+
(_e = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getId())) === null || _e === void 0 ? void 0 : _e.classList.add("marked");
|
241
|
+
if (this.scoreGraph.getCurrentNode().getId().indexOf("BOL") === -1) {
|
242
|
+
this.setCurrentNodeScoreGraph(this.scoreGraph.getCurrentNode().getId());
|
243
|
+
}
|
244
|
+
}
|
245
|
+
// navigateSelection(direction: string){
|
246
|
+
// if(typeof this.startSelect === "undefined"){
|
247
|
+
// this.startSelect = document.getElementById(this.scoreGraph.getCurrentNode().getId()).getBoundingClientRect()
|
248
|
+
// }
|
249
|
+
// this.navigateCursor(direction)
|
250
|
+
// if(this.selectRect == undefined){
|
251
|
+
// this.selectRect = document.createElementNS(c._SVGNS_, "rect")
|
252
|
+
// this.selectRect.setAttribute("id", "keyModeSelectRect")
|
253
|
+
// document.getElementById("canvasG").appendChild(this.selectRect)
|
254
|
+
// }
|
255
|
+
// var cursorPos = this.cursor.getPos() //document.getElementById("cursor").getBoundingClientRect()
|
256
|
+
// var startSelectX = coord.adjustToPage(this.startSelect.left, "x")
|
257
|
+
// var cursorX = cursorPos.x
|
258
|
+
// var startSelectY = coord.adjustToPage(this.startSelect.top, "y") + window.pageYOffset
|
259
|
+
// var cursorY = cursorPos.y //+ window.pageYOffset
|
260
|
+
// if(cursorX < startSelectX){ // draw rect to right
|
261
|
+
// this.selectRect.setAttribute("x", cursorX.toString())
|
262
|
+
// this.selectRect.setAttribute("width", Math.abs(cursorX - startSelectX).toString())
|
263
|
+
// }else{ // else right
|
264
|
+
// this.selectRect.setAttribute("x", startSelectX.toString())
|
265
|
+
// this.selectRect.setAttribute("width", Math.abs(coord.adjustToPage(this.startSelect.left, "x") - cursorX).toString())
|
266
|
+
// }
|
267
|
+
// if(cursorY < startSelectY){ // draw rect to top
|
268
|
+
// this.selectRect.setAttribute("y", cursorY.toString())
|
269
|
+
// //this.selectRect.setAttribute("height", Math.abs(cursorPos.y - coord.adjustToPage(this.startSelect.top, "y")).toString())
|
270
|
+
// this.selectRect.setAttribute("height", Math.abs(cursorY - startSelectY).toString())
|
271
|
+
// //console.log(cursorY, startSelectY, this.selectRect.getAttribute("height"))
|
272
|
+
// }else{ // else bottom
|
273
|
+
// this.selectRect.setAttribute("y", startSelectY.toString())
|
274
|
+
// this.selectRect.setAttribute("height", Math.abs(coord.adjustToPage(this.startSelect.bottom, "y") - cursorY).toString())
|
275
|
+
// //this.selectRect.setAttribute("height", Math.abs(coord.adjustToPage(this.startSelect.top, "y") - coord.adjustToPage(cursorPos.y, "y")).toString())
|
276
|
+
// //console.log(cursorY, startSelectY, this.selectRect.getAttribute("height"))
|
277
|
+
// }
|
278
|
+
// var rectBBox = this.selectRect.getBoundingClientRect()
|
279
|
+
// var rx = rectBBox.x + window.pageXOffset //accomodate for scrolling
|
280
|
+
// var ry = rectBBox.y + window.pageYOffset
|
281
|
+
// this.m2m.getNoteBBoxes().forEach(bb => {
|
282
|
+
// var note = document.getElementById(bb.id)
|
283
|
+
// let stem = note.querySelector(".stem") as HTMLElement
|
284
|
+
// if( bb.x >= rx &&
|
285
|
+
// bb.x <= rx + rectBBox.width &&
|
286
|
+
// bb.y >= ry &&
|
287
|
+
// bb.y <= ry + rectBBox.height) {
|
288
|
+
// note.classList.add(marked)
|
289
|
+
// if(stem !== null) stem.classList.add(marked)
|
290
|
+
// var chord = note.closest(".chord")
|
291
|
+
// if(chord !== null){
|
292
|
+
// if(!chord.classList.contains(marked)) chord.classList.add(marked)
|
293
|
+
// }
|
294
|
+
// }else{
|
295
|
+
// note.classList.remove(marked)
|
296
|
+
// if(stem !== null) stem.classList.remove(marked)
|
297
|
+
// var chord = note.closest(".chord")
|
298
|
+
// if(chord !== null) chord.classList.remove(marked)
|
299
|
+
// }
|
300
|
+
// })
|
301
|
+
// }
|
302
|
+
/**
|
303
|
+
* End selection in Keyboardmode
|
304
|
+
*/
|
305
|
+
endSelection() {
|
306
|
+
this.startSelect = undefined;
|
307
|
+
if (this.selectRect !== null && typeof this.selectRect !== "undefined") {
|
308
|
+
this.selectRect.remove();
|
309
|
+
this.rootSVG.querySelectorAll(".marked").forEach(m => {
|
310
|
+
m.classList.remove("marked");
|
311
|
+
});
|
312
|
+
}
|
313
|
+
this.selectRect = undefined;
|
314
|
+
}
|
315
|
+
/**
|
316
|
+
*
|
317
|
+
* @param elementId Id of the current Element to be set in the ScoreGrap
|
318
|
+
*/
|
319
|
+
setCurrentNodeScoreGraph(elementId = null) {
|
320
|
+
if (this.scoreGraph.getCurrentNode() == undefined || elementId === null) {
|
321
|
+
var nextEl = this.cursor.getNextElement();
|
322
|
+
if (nextEl == undefined)
|
323
|
+
return;
|
324
|
+
if (nextEl.classList.contains("staff")) {
|
325
|
+
nextEl = nextEl.querySelector(".layer");
|
326
|
+
}
|
327
|
+
this.scoreGraph.setCurrentNodeById(nextEl.id);
|
328
|
+
}
|
329
|
+
else if (elementId !== null) {
|
330
|
+
this.scoreGraph.setCurrentNodeById(elementId);
|
331
|
+
}
|
332
|
+
return this;
|
333
|
+
}
|
334
|
+
/**
|
335
|
+
* Delete next element depending on Keyboad input (Backspace: left, Delete: right)
|
336
|
+
* @param key "Backspace" or "Delete"
|
337
|
+
*/
|
338
|
+
deleteByKey(key) {
|
339
|
+
var _a, _b;
|
340
|
+
var elementToDelete;
|
341
|
+
var currNodeId;
|
342
|
+
var isFocusedChord = ((_a = this.container.querySelector("#chordButton")) === null || _a === void 0 ? void 0 : _a.classList.contains("selected")) ? true : false;
|
343
|
+
if (isFocusedChord) {
|
344
|
+
key = "Backspace";
|
345
|
+
}
|
346
|
+
switch (key) {
|
347
|
+
case "Delete":
|
348
|
+
//elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getRight().getId())
|
349
|
+
//break;
|
350
|
+
case "Backspace":
|
351
|
+
elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getId());
|
352
|
+
if (this.scoreGraph.getCurrentNode().isLayer()) {
|
353
|
+
elementToDelete = this.rootSVG.querySelector("#" + this.scoreGraph.getCurrentNode().getLeft().getId());
|
354
|
+
this.navigateCursor("ArrowLeft");
|
355
|
+
}
|
356
|
+
if (!((_b = this.scoreGraph.getCurrentNode().getLeft()) === null || _b === void 0 ? void 0 : _b.isBOL())) {
|
357
|
+
this.navigateCursor("ArrowLeft");
|
358
|
+
}
|
359
|
+
else {
|
360
|
+
this.navigateCursor("ArrowRight");
|
361
|
+
}
|
362
|
+
break;
|
363
|
+
}
|
364
|
+
currNodeId = this.scoreGraph.getCurrentNode().getId();
|
365
|
+
// if(this.rootSVG.querySelector(".marked") === null){
|
366
|
+
// this.deleteCallback([elementToDelete]).then(() => {
|
367
|
+
// this.m2m.update();
|
368
|
+
// this.resetListeners()
|
369
|
+
// this.cursor.definePosById(currNodeId)
|
370
|
+
// })
|
371
|
+
// }
|
372
|
+
}
|
373
|
+
///// GETTER / SETTER////////////////
|
374
|
+
setM2M(m2m) {
|
375
|
+
this.m2m = m2m;
|
376
|
+
this.cursor.setM2M(m2m);
|
377
|
+
return this;
|
378
|
+
}
|
379
|
+
setMusicPlayer(musicPlayer) {
|
380
|
+
this.musicPlayer = musicPlayer;
|
381
|
+
return this;
|
382
|
+
}
|
383
|
+
setScoreGraph(scoreGraph) {
|
384
|
+
this.scoreGraph = scoreGraph;
|
385
|
+
return this;
|
386
|
+
}
|
387
|
+
setCurrentMEI(mei) {
|
388
|
+
this.currentMEI = mei;
|
389
|
+
return this;
|
390
|
+
}
|
391
|
+
setContainerId(id) {
|
392
|
+
this.containerId = id;
|
393
|
+
this.rootSVG = cq.getRootSVG(id);
|
394
|
+
this.interactionOverlay = cq.getInteractOverlay(id);
|
395
|
+
this.container = document.getElementById(id);
|
396
|
+
return this;
|
397
|
+
}
|
398
|
+
setInsertCallback(insertCallback) {
|
399
|
+
this.insertCallback = insertCallback;
|
400
|
+
return this;
|
401
|
+
}
|
402
|
+
setDeleteCallback(deleteCallback) {
|
403
|
+
this.deleteCallback = deleteCallback;
|
404
|
+
return this;
|
405
|
+
}
|
406
|
+
}
|
407
|
+
exports.default = KeyModeHandler;
|