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,257 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const cq = require("../utils/convenienceQueries");
|
4
|
+
const meiConverter = require("../utils/MEIConverter");
|
5
|
+
class WindowHandler {
|
6
|
+
constructor() {
|
7
|
+
/**
|
8
|
+
* Update all elements that are affected by a window size change
|
9
|
+
*/
|
10
|
+
this.scrollingTimer = new Array();
|
11
|
+
this.updateFunction = this.update.bind(this);
|
12
|
+
/**
|
13
|
+
* Reload svg when registered events ended
|
14
|
+
*/
|
15
|
+
this.reloadTimer = new Array();
|
16
|
+
this.reloadSVGFunction = this.reloadSVG.bind(this);
|
17
|
+
this.toggleCTRLFunction = this.toggleCTRL.bind(this);
|
18
|
+
this.deltaTemp = 1;
|
19
|
+
this.zoomTimer = new Array();
|
20
|
+
this.wheelZoomFunction = this.wheelZoom.bind(this);
|
21
|
+
this.clickZoomFunction = this.clickZoom.bind(this);
|
22
|
+
this.cacheContainerAttrFunction = this.cacheContainerAttr.bind(this);
|
23
|
+
this.loadContainerAttrFunction = this.loadContainerAttr.bind(this);
|
24
|
+
this.ctrlPressed = false;
|
25
|
+
this.w = window;
|
26
|
+
while (this.w !== this.w.parent) {
|
27
|
+
this.w = this.w.parent;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
setListeners() {
|
31
|
+
this.eventContainer = this.container;
|
32
|
+
window.addEventListener("scroll", this.updateFunction);
|
33
|
+
//window.addEventListener("resize", this.update)
|
34
|
+
this.w.addEventListener("resize", this.reloadSVGFunction);
|
35
|
+
this.w.addEventListener("deviceorientation", this.updateFunction);
|
36
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("transitionend", this.updateFunction);
|
37
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("transitionend", this.reloadSVGFunction);
|
38
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("resizemove", this.updateFunction);
|
39
|
+
this.eventContainer.querySelector("#sidebarContainer").addEventListener("resizemove", this.reloadSVGFunction);
|
40
|
+
this.vrvSVG.addEventListener("scroll", this.updateFunction);
|
41
|
+
//this.vrvSVG.addEventListener("resize", this.update)
|
42
|
+
this.vrvSVG.addEventListener("deviceorientation", this.updateFunction);
|
43
|
+
document.addEventListener("fullscreenchange", this.updateFunction);
|
44
|
+
this.eventContainer.addEventListener("wheel", this.wheelZoomFunction);
|
45
|
+
this.eventContainer.querySelectorAll("#zoomGroup > button").forEach(b => b.addEventListener("click", this.clickZoomFunction));
|
46
|
+
document.addEventListener("keydown", this.toggleCTRLFunction);
|
47
|
+
document.addEventListener("keyup", this.toggleCTRLFunction);
|
48
|
+
this.eventContainer.addEventListener("loadingStart", this.cacheContainerAttrFunction);
|
49
|
+
this.eventContainer.addEventListener("loadingEnd", this.loadContainerAttrFunction);
|
50
|
+
return this;
|
51
|
+
}
|
52
|
+
removeListeners() {
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
54
|
+
window.removeEventListener("scroll", this.updateFunction);
|
55
|
+
this.w.removeEventListener("resize", this.updateFunction);
|
56
|
+
this.w.removeEventListener("resize", this.reloadSVGFunction);
|
57
|
+
this.w.removeEventListener("deviceorientation", this.updateFunction);
|
58
|
+
(_a = this.eventContainer) === null || _a === void 0 ? void 0 : _a.querySelector("#sidebarContainer").removeEventListener("transitionend", this.updateFunction);
|
59
|
+
(_b = this.eventContainer) === null || _b === void 0 ? void 0 : _b.querySelector("#sidebarContainer").removeEventListener("transitionend", this.reloadSVGFunction);
|
60
|
+
(_c = this.eventContainer) === null || _c === void 0 ? void 0 : _c.querySelector("#sidebarContainer").removeEventListener("resizemove", this.updateFunction);
|
61
|
+
(_d = this.eventContainer) === null || _d === void 0 ? void 0 : _d.querySelector("#sidebarContainer").removeEventListener("resizemove", this.reloadSVGFunction);
|
62
|
+
this.vrvSVG.removeEventListener("scroll", this.updateFunction);
|
63
|
+
//this.vrvSVG.removeEventListener("resize", this.update)
|
64
|
+
this.vrvSVG.removeEventListener("deviceorientation", this.updateFunction);
|
65
|
+
document.removeEventListener("fullscreenchange", this.updateFunction);
|
66
|
+
(_e = this.eventContainer) === null || _e === void 0 ? void 0 : _e.removeEventListener("wheel", this.wheelZoomFunction);
|
67
|
+
(_f = this.eventContainer) === null || _f === void 0 ? void 0 : _f.querySelectorAll("#zoomGroup > button").forEach(b => b.removeEventListener("click", this.clickZoomFunction));
|
68
|
+
document.removeEventListener("keydown", this.toggleCTRLFunction);
|
69
|
+
document.removeEventListener("keyup", this.toggleCTRLFunction);
|
70
|
+
(_g = this.eventContainer) === null || _g === void 0 ? void 0 : _g.removeEventListener("loadingStart", this.cacheContainerAttrFunction);
|
71
|
+
(_h = this.eventContainer) === null || _h === void 0 ? void 0 : _h.removeEventListener("loadingEnd", this.loadContainerAttrFunction);
|
72
|
+
return this;
|
73
|
+
}
|
74
|
+
update(e) {
|
75
|
+
var _a;
|
76
|
+
// special rule for transition events since so much with different propertynames are fired
|
77
|
+
if (e instanceof TransitionEvent) {
|
78
|
+
if (!e.propertyName.includes("width"))
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
var that = this;
|
82
|
+
(_a = this.scrollingTimer) === null || _a === void 0 ? void 0 : _a.forEach(s => clearTimeout(s));
|
83
|
+
this.scrollingTimer.push(setTimeout(function () {
|
84
|
+
var _a, _b, _c, _d;
|
85
|
+
that.updateXY();
|
86
|
+
(_a = that.m2s) === null || _a === void 0 ? void 0 : _a.update();
|
87
|
+
(_b = that.annotations) === null || _b === void 0 ? void 0 : _b.updateCanvas();
|
88
|
+
(_d = (_c = that.insertModeHandler) === null || _c === void 0 ? void 0 : _c.getPhantomNoteHandler()) === null || _d === void 0 ? void 0 : _d.resetCanvas();
|
89
|
+
that.scrollingTimer = new Array();
|
90
|
+
}, 500));
|
91
|
+
}
|
92
|
+
reloadSVG(e) {
|
93
|
+
var _a;
|
94
|
+
var t = e.target;
|
95
|
+
var that = this;
|
96
|
+
(_a = this.reloadTimer) === null || _a === void 0 ? void 0 : _a.forEach(r => clearTimeout(r));
|
97
|
+
if (t.id === "sidebarContainer" && !(e.propertyName.includes("width"))) {
|
98
|
+
// Timeout is needed to ensure, that transition has been completed and in eventphase 0
|
99
|
+
// Must be a slighty longer than transitiontime
|
100
|
+
this.reloadTimer.push(setTimeout(function () {
|
101
|
+
that.updateXY();
|
102
|
+
var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
|
103
|
+
that.loadDataCallback("", mei, false);
|
104
|
+
that.reloadTimer = new Array();
|
105
|
+
}, e.elapsedTime * 1000 + 10));
|
106
|
+
}
|
107
|
+
else if (e.type === "resize" || e.type === "resizemove") {
|
108
|
+
this.reloadTimer.push(setTimeout(function () {
|
109
|
+
that.updateXY();
|
110
|
+
var mei = meiConverter.restoreXmlIdTags(that.currentMEI);
|
111
|
+
that.loadDataCallback("", mei, false);
|
112
|
+
that.reloadTimer = new Array();
|
113
|
+
}, 500));
|
114
|
+
}
|
115
|
+
}
|
116
|
+
/**
|
117
|
+
* Toggle ctrl or meta button. Is used to activte zoom function
|
118
|
+
* @param e
|
119
|
+
*/
|
120
|
+
toggleCTRL(e) {
|
121
|
+
if (e.key === "Meta" || e.key === "Control") {
|
122
|
+
if (e.type === "keydown") {
|
123
|
+
this.ctrlPressed = true;
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
this.ctrlPressed = false;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* Zoom according to movement of mouse wheel (also applies to two finger scroll gesture on trackpad).
|
132
|
+
* Can only be executed when container is active Element and when ctrl/meta is pressed.
|
133
|
+
* The scale is accumulated with every call of this method.
|
134
|
+
* @param e
|
135
|
+
* @returns
|
136
|
+
*/
|
137
|
+
wheelZoom(e) {
|
138
|
+
this.updateXY();
|
139
|
+
if (!cq.hasActiveElement(this.containerId))
|
140
|
+
return;
|
141
|
+
if (!this.ctrlPressed)
|
142
|
+
return;
|
143
|
+
e.preventDefault();
|
144
|
+
this.deltaTemp = this.deltaTemp + e.deltaY / 1000;
|
145
|
+
this.zoomSVG(this.deltaTemp);
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* Zoom when Zoombuttons are clicked (In div #zoomGroup).
|
149
|
+
*
|
150
|
+
* @param e
|
151
|
+
*/
|
152
|
+
clickZoom(e) {
|
153
|
+
var t = e.target;
|
154
|
+
if (t.id === "zoomInBtn") {
|
155
|
+
this.deltaTemp = this.deltaTemp + 100 / 1000;
|
156
|
+
}
|
157
|
+
else if (t.id === "zoomOutBtn") {
|
158
|
+
this.deltaTemp = this.deltaTemp - 100 / 1000;
|
159
|
+
}
|
160
|
+
this.zoomSVG(this.deltaTemp);
|
161
|
+
}
|
162
|
+
/**
|
163
|
+
* General zoom logic for all top level svgs (interactionOverlay + vrvSVG (= rendered score by verovio))
|
164
|
+
* @param delta
|
165
|
+
*/
|
166
|
+
zoomSVG(delta) {
|
167
|
+
var _a;
|
168
|
+
var that = this;
|
169
|
+
// ensure that with every call of all obsolete timeouts are deleted so that only one is left to be executed
|
170
|
+
(_a = this.zoomTimer) === null || _a === void 0 ? void 0 : _a.forEach(zt => clearTimeout(zt));
|
171
|
+
this.zoomTimer.push(setTimeout(function () {
|
172
|
+
var svgContainer = cq.getContainer(that.containerId).querySelector("#svgContainer");
|
173
|
+
svgContainer.style.width = (100 * delta).toString() + "%";
|
174
|
+
}, 10));
|
175
|
+
}
|
176
|
+
/**
|
177
|
+
* Cache container attributes that need to be loaded after the score is loaded.
|
178
|
+
* - Scorllpositions of the containers
|
179
|
+
*
|
180
|
+
* Listens to "loadStart" Event in Core class
|
181
|
+
* @param e Event
|
182
|
+
*/
|
183
|
+
cacheContainerAttr(e) {
|
184
|
+
this.divScrolls = new Map();
|
185
|
+
var container = document.getElementById(this.containerId);
|
186
|
+
container.querySelectorAll(":scope div").forEach(d => {
|
187
|
+
this.divScrolls.set(d.id, { sl: d.scrollLeft, st: d.scrollTop });
|
188
|
+
});
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Load all container attributes saved in @function cacheContainerAttr after score is loaded.
|
192
|
+
* Listens to "loadEnd" Event in Core class
|
193
|
+
* @param e Event
|
194
|
+
* @returns
|
195
|
+
*/
|
196
|
+
loadContainerAttr(e) {
|
197
|
+
var _a;
|
198
|
+
if (this.divScrolls == undefined)
|
199
|
+
return;
|
200
|
+
for (const [key, value] of this.divScrolls.entries()) {
|
201
|
+
(_a = document.getElementById(key)) === null || _a === void 0 ? void 0 : _a.scrollTo(value.sl, value.st);
|
202
|
+
}
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* Set X and Y coordinates of the current boundingbox of the of the VerovioScore (#vrvSVG)
|
206
|
+
*/
|
207
|
+
updateXY() {
|
208
|
+
var _a;
|
209
|
+
var bb = (_a = document.getElementById(this.containerId)) === null || _a === void 0 ? void 0 : _a.querySelector("#vrvSVG").getBoundingClientRect();
|
210
|
+
this.x = bb.x;
|
211
|
+
this.y = bb.y;
|
212
|
+
}
|
213
|
+
resetListeners() {
|
214
|
+
this
|
215
|
+
.removeListeners()
|
216
|
+
.setListeners();
|
217
|
+
return this;
|
218
|
+
}
|
219
|
+
setm2s(m2s) {
|
220
|
+
this.m2s = m2s;
|
221
|
+
return this;
|
222
|
+
}
|
223
|
+
setAnnotations(annotations) {
|
224
|
+
this.annotations = annotations;
|
225
|
+
return this;
|
226
|
+
}
|
227
|
+
setCurrentMEI(mei) {
|
228
|
+
this.currentMEI = mei;
|
229
|
+
return this;
|
230
|
+
}
|
231
|
+
setContainerId(containerId) {
|
232
|
+
this.containerId = containerId;
|
233
|
+
this.container = document.getElementById(this.containerId);
|
234
|
+
this.interactionOverlay = cq.getInteractOverlay(this.containerId);
|
235
|
+
this.vrvSVG = cq.getVrvSVG(this.containerId);
|
236
|
+
return this;
|
237
|
+
}
|
238
|
+
setInsertModeHandler(imh) {
|
239
|
+
this.insertModeHandler = imh;
|
240
|
+
return this;
|
241
|
+
}
|
242
|
+
setLoadDataCallback(loadDataCallback) {
|
243
|
+
this.loadDataCallback = loadDataCallback;
|
244
|
+
return this;
|
245
|
+
}
|
246
|
+
setSVGReloadCallback(svgReloadCallback) {
|
247
|
+
this.svgReloadCallback = svgReloadCallback;
|
248
|
+
return this;
|
249
|
+
}
|
250
|
+
getX() {
|
251
|
+
return this.x;
|
252
|
+
}
|
253
|
+
getY() {
|
254
|
+
return this.y;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
exports.default = WindowHandler;
|
@@ -0,0 +1,174 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.makeNewAudioSlider = exports.makeNewToggle = exports.makeNewSelect = exports.makeNewDatalist = exports.makeNewInput = exports.makeNewAccordionItem = exports.makeNewDiv = exports.makeNewDivH5P = exports.makeNewAElement = exports.makeNewButton = exports.makeNewButtonH5P = void 0;
|
4
|
+
class Toolbar {
|
5
|
+
}
|
6
|
+
function makeNewButtonH5P(text, id, className) {
|
7
|
+
return "<button type=\"button\" id=\"" + id + "\" class=\"" + className + "\">" + text + "</button>";
|
8
|
+
}
|
9
|
+
exports.makeNewButtonH5P = makeNewButtonH5P;
|
10
|
+
function makeNewButton(text, id, className, toggle = "", textInnerHTML = false) {
|
11
|
+
var b = document.createElement("button");
|
12
|
+
b.setAttribute("id", id);
|
13
|
+
//b.setAttribute("type", "button")
|
14
|
+
var classList = className.split(" ");
|
15
|
+
classList.forEach(c => b.classList.add(c));
|
16
|
+
if (toggle === "dropdown") {
|
17
|
+
b.setAttribute("data-bs-toggle", toggle);
|
18
|
+
b.classList.add("dropdown-toggle");
|
19
|
+
//b.classList.add("dd")
|
20
|
+
//b.setAttribute("aria-haspopup", "true")
|
21
|
+
//b.setAttribute("aria-expanded", "false")
|
22
|
+
}
|
23
|
+
if (toggle === "button") {
|
24
|
+
b.setAttribute("data-toggle", toggle);
|
25
|
+
b.setAttribute("autocomplete", "off");
|
26
|
+
}
|
27
|
+
if (text.indexOf(" ") > -1 || textInnerHTML === true) {
|
28
|
+
b.innerHTML = text;
|
29
|
+
}
|
30
|
+
else {
|
31
|
+
b.textContent = text;
|
32
|
+
}
|
33
|
+
return b;
|
34
|
+
}
|
35
|
+
exports.makeNewButton = makeNewButton;
|
36
|
+
function makeNewAElement(text, id, className, href, textInnerHTML = false) {
|
37
|
+
var a = document.createElement("a");
|
38
|
+
var classList = className.split(" ");
|
39
|
+
classList.forEach(c => a.classList.add(c));
|
40
|
+
a.setAttribute("href", href);
|
41
|
+
if (id.length > 0)
|
42
|
+
a.setAttribute("id", id);
|
43
|
+
if (textInnerHTML === true) {
|
44
|
+
a.innerHTML = text;
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
a.textContent = text;
|
48
|
+
}
|
49
|
+
return a;
|
50
|
+
}
|
51
|
+
exports.makeNewAElement = makeNewAElement;
|
52
|
+
function makeNewDivH5P(id, className, role = "") {
|
53
|
+
if (role !== "") {
|
54
|
+
role = "role=\"" + role + "\"";
|
55
|
+
}
|
56
|
+
return "<div id=\"" + id + "\" class=\"" + className + "\"" + role + "></div>";
|
57
|
+
}
|
58
|
+
exports.makeNewDivH5P = makeNewDivH5P;
|
59
|
+
function makeNewDiv(id, className, attributes = null) {
|
60
|
+
var div = document.createElement("div");
|
61
|
+
div.setAttribute("id", id);
|
62
|
+
if (["", " "].indexOf(className) === -1) {
|
63
|
+
var classList = className.split(" ");
|
64
|
+
classList.forEach(c => div.classList.add(c));
|
65
|
+
}
|
66
|
+
if (div.classList.contains("dropdown-menu")) {
|
67
|
+
div.setAttribute("aria-labelledby", "insertMode");
|
68
|
+
}
|
69
|
+
if (attributes !== null) {
|
70
|
+
for (const [key, value] of Object.entries(attributes)) {
|
71
|
+
div.setAttribute(key, value);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return div;
|
75
|
+
}
|
76
|
+
exports.makeNewDiv = makeNewDiv;
|
77
|
+
function makeNewAccordionItem(parentId, itemId, headerId, btnId, btnText, btnStyle = null, targetDivId) {
|
78
|
+
var item = makeNewDiv(itemId, "accordion-item");
|
79
|
+
var header = document.createElement("div");
|
80
|
+
header.classList.add("accordion-header");
|
81
|
+
header.setAttribute("id", headerId);
|
82
|
+
var btn = makeNewButton(btnText, btnId, "container-fluid accordion-button collapsed " + btnStyle);
|
83
|
+
btn.setAttribute("data-bs-toggle", "collapse");
|
84
|
+
btn.setAttribute("data-bs-target", "#" + targetDivId);
|
85
|
+
btn.setAttribute("aria-expanded", "false");
|
86
|
+
btn.setAttribute("aria-controls", targetDivId);
|
87
|
+
header.appendChild(btn);
|
88
|
+
var div = makeNewDiv(targetDivId, "accordion-collapse collapse");
|
89
|
+
div.setAttribute("aria-labelledby", headerId);
|
90
|
+
div.setAttribute("data-bs-parent", "#" + parentId);
|
91
|
+
item.appendChild(header);
|
92
|
+
item.appendChild(div);
|
93
|
+
return item;
|
94
|
+
}
|
95
|
+
exports.makeNewAccordionItem = makeNewAccordionItem;
|
96
|
+
function makeNewInput(id, type, className, value = null, listname = null, readonly = false) {
|
97
|
+
var input = document.createElement("input");
|
98
|
+
input.setAttribute("id", id);
|
99
|
+
input.setAttribute("type", type);
|
100
|
+
if (value !== null) {
|
101
|
+
input.setAttribute("value", value);
|
102
|
+
}
|
103
|
+
if (className.length > 0) {
|
104
|
+
var classList = className.split(" ");
|
105
|
+
classList.forEach(c => input.classList.add(c));
|
106
|
+
}
|
107
|
+
if (listname !== null) {
|
108
|
+
input.setAttribute("list", listname);
|
109
|
+
}
|
110
|
+
input.readOnly = readonly;
|
111
|
+
return input;
|
112
|
+
}
|
113
|
+
exports.makeNewInput = makeNewInput;
|
114
|
+
function makeNewDatalist(id, optionValues) {
|
115
|
+
var dataList = document.createElement("datalist");
|
116
|
+
dataList.setAttribute("id", id);
|
117
|
+
optionValues.forEach(value => {
|
118
|
+
var option = document.createElement("option");
|
119
|
+
option.setAttribute("value", value);
|
120
|
+
dataList.append(option);
|
121
|
+
});
|
122
|
+
return dataList;
|
123
|
+
}
|
124
|
+
exports.makeNewDatalist = makeNewDatalist;
|
125
|
+
function makeNewSelect(id, optionValues, placeHolder = null) {
|
126
|
+
var dataList = document.createElement("select");
|
127
|
+
dataList.setAttribute("id", id);
|
128
|
+
if (placeHolder !== null) {
|
129
|
+
var option = document.createElement("option");
|
130
|
+
option.setAttribute("value", " ");
|
131
|
+
option.textContent = placeHolder;
|
132
|
+
option.setAttribute("disabled", "");
|
133
|
+
option.setAttribute("selected", "");
|
134
|
+
dataList.append(option);
|
135
|
+
}
|
136
|
+
optionValues.forEach(value => {
|
137
|
+
var option = document.createElement("option");
|
138
|
+
option.setAttribute("value", value);
|
139
|
+
option.textContent = value;
|
140
|
+
dataList.append(option);
|
141
|
+
});
|
142
|
+
return dataList;
|
143
|
+
}
|
144
|
+
exports.makeNewSelect = makeNewSelect;
|
145
|
+
function makeNewToggle(id, classNames, labelText, divId) {
|
146
|
+
var input = makeNewInput(id, "checkBox", "btn-check");
|
147
|
+
input.checked = true;
|
148
|
+
var label = document.createElement("label");
|
149
|
+
if ((classNames === null || classNames === void 0 ? void 0 : classNames.length) > 0) {
|
150
|
+
var classList = classNames.split(" ");
|
151
|
+
classList.forEach(c => label.classList.add(c));
|
152
|
+
}
|
153
|
+
label.setAttribute("for", id);
|
154
|
+
label.textContent = labelText;
|
155
|
+
var div = makeNewDiv(divId, "toggleDiv");
|
156
|
+
div.append(input);
|
157
|
+
div.append(label);
|
158
|
+
return div;
|
159
|
+
}
|
160
|
+
exports.makeNewToggle = makeNewToggle;
|
161
|
+
function makeNewAudioSlider(id, classNames, audioFile) {
|
162
|
+
var audioCtrl = document.createElement("audio");
|
163
|
+
audioCtrl.setAttribute("id", id);
|
164
|
+
audioCtrl.setAttribute("controls", "");
|
165
|
+
if ((classNames === null || classNames === void 0 ? void 0 : classNames.length) > 0) {
|
166
|
+
var classList = classNames.split(" ");
|
167
|
+
classList.forEach(c => audioCtrl.classList.add(c));
|
168
|
+
}
|
169
|
+
var source = document.createElement("source");
|
170
|
+
source.setAttribute("src", audioFile);
|
171
|
+
audioCtrl.append(source);
|
172
|
+
return audioCtrl;
|
173
|
+
}
|
174
|
+
exports.makeNewAudioSlider = makeNewAudioSlider;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
//@ts-ignore
|
3
|
+
//const $ = H5P.jQuery
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
+
exports.restoreXmlIdTags = exports.standardizeAccid = exports.docToMei = exports.meiToDoc = exports.reformatMEI = void 0;
|
6
|
+
/**
|
7
|
+
* clean mei to make it parsable as document
|
8
|
+
* @param mei the mei to be cleaned
|
9
|
+
* @returns cleaned mei
|
10
|
+
*/
|
11
|
+
function cleanMEI(mei) {
|
12
|
+
mei = mei.replace(/\xml:id/gi, "id");
|
13
|
+
mei = mei.replace(/\n/g, ""); // delete all unnecessary newline
|
14
|
+
mei = mei.replace(/\s{2,}/g, ""); // delete all unnecessary whitespaces
|
15
|
+
return mei;
|
16
|
+
}
|
17
|
+
function reformatMEI(mei) {
|
18
|
+
mei = mei.replace(/\n/g, ""); // delete all unnecessary newline
|
19
|
+
mei = mei.replace(/\s{2,}/g, ""); // delete all unnecessary whitespaces
|
20
|
+
mei = mei.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<").replace(/"/g, "\"");
|
21
|
+
return mei;
|
22
|
+
}
|
23
|
+
exports.reformatMEI = reformatMEI;
|
24
|
+
/**
|
25
|
+
* Converts MEI-String to DOM-conform objec
|
26
|
+
* @param mei
|
27
|
+
* @returns MEI as Document
|
28
|
+
*/
|
29
|
+
function meiToDoc(mei) {
|
30
|
+
var meiCopy = (" " + mei).slice(1); //deep copy
|
31
|
+
meiCopy = cleanMEI(meiCopy);
|
32
|
+
var parser = new DOMParser();
|
33
|
+
return parser.parseFromString(meiCopy, "text/xml");
|
34
|
+
}
|
35
|
+
exports.meiToDoc = meiToDoc;
|
36
|
+
function docToMei(meiDoc) {
|
37
|
+
return new XMLSerializer().serializeToString(restoreXmlIdTags(meiDoc));
|
38
|
+
}
|
39
|
+
exports.docToMei = docToMei;
|
40
|
+
/**
|
41
|
+
* Copys all accid attributes into the note Element, if it has accid Element
|
42
|
+
* @param xmlDoc
|
43
|
+
* @returns xmlDoc
|
44
|
+
*/
|
45
|
+
function standardizeAccid(xmlDoc) {
|
46
|
+
xmlDoc.querySelectorAll("accid").forEach(a => {
|
47
|
+
var note = a.closest("note");
|
48
|
+
var aAccid = a.getAttribute("accid");
|
49
|
+
if (aAccid !== null)
|
50
|
+
note.setAttribute("accid", aAccid);
|
51
|
+
var aAccidGes = a.getAttribute("accid.ges");
|
52
|
+
if (aAccidGes !== null)
|
53
|
+
note.setAttribute("accid.ges", aAccidGes);
|
54
|
+
a.remove();
|
55
|
+
});
|
56
|
+
return xmlDoc;
|
57
|
+
}
|
58
|
+
exports.standardizeAccid = standardizeAccid;
|
59
|
+
function restoreXmlIdTags(xmlDoc) {
|
60
|
+
var parser = new DOMParser();
|
61
|
+
var mei = new XMLSerializer().serializeToString(xmlDoc).replace(/\ id/gi, " xml:id");
|
62
|
+
return parser.parseFromString(mei, "text/xml");
|
63
|
+
}
|
64
|
+
exports.restoreXmlIdTags = restoreXmlIdTags;
|