@teipublisher/pb-components 2.26.1-next.3 → 3.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/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +158 -171
- package/src/pb-authority-lookup.js +191 -156
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +256 -228
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
package/src/pb-mei.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
|
-
import
|
|
3
|
+
import '@lrnwebcomponents/es-global-bridge';
|
|
4
4
|
import createVerovioModule from 'verovio/dist/verovio-module.mjs';
|
|
5
5
|
import { VerovioToolkit } from 'verovio/dist/verovio.mjs';
|
|
6
6
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
@@ -15,34 +15,30 @@ let _verovio = null;
|
|
|
15
15
|
|
|
16
16
|
/** Import external script dynamically */
|
|
17
17
|
function _import(name, location) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
() => resolve(),
|
|
24
|
-
{ once: true }
|
|
25
|
-
);
|
|
26
|
-
});
|
|
18
|
+
window.ESGlobalBridge.requestAvailability();
|
|
19
|
+
return new Promise(resolve => {
|
|
20
|
+
window.ESGlobalBridge.instance.load(name, location);
|
|
21
|
+
window.addEventListener(`es-bridge-${name}-loaded`, () => resolve(), { once: true });
|
|
22
|
+
});
|
|
27
23
|
}
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
26
|
* A viewer and player for MEI musical notation based on [Verovio](https://www.verovio.org/).
|
|
31
27
|
* Supports optional MIDI playback using [web-midi-player](https://midi.yvesgurcan.com/).
|
|
32
28
|
* Both libraries are loaded dynamically when the component is used the first time.
|
|
33
|
-
*
|
|
29
|
+
*
|
|
34
30
|
* Viewing options to be selected by the user can be defined via nested `pb-option` elements:
|
|
35
|
-
*
|
|
31
|
+
*
|
|
36
32
|
* ```html
|
|
37
|
-
* <pb-mei id="viewer" player url="http://www.marenzio.org/mei/M-06-5/M_06_5_01_S_io_parto_i_moro_e_pur_partir_conviene.mei"
|
|
33
|
+
* <pb-mei id="viewer" player url="http://www.marenzio.org/mei/M-06-5/M_06_5_01_S_io_parto_i_moro_e_pur_partir_conviene.mei"
|
|
38
34
|
* footer="none">
|
|
39
35
|
* <pb-option name="appXPath" on="./rdg[contains(@label, 'original')]" off="">Original Clefs</pb-option>
|
|
40
36
|
* </pb-mei>
|
|
41
37
|
* ```
|
|
42
|
-
*
|
|
38
|
+
*
|
|
43
39
|
* The MEI document to display can either be given directly in the `data` property or loaded from an URL
|
|
44
40
|
* specified in `url`.
|
|
45
|
-
*
|
|
41
|
+
*
|
|
46
42
|
* @prop {"auto" | "encoded" | "none" | "always"} footer - Control footer layout
|
|
47
43
|
* @prop {"auto" | "encoded" | "none"} header - Control footer layout
|
|
48
44
|
* @prop {"auto" | "none" | "line" | "encoded" | "smart"} breaks - Define page and system breaks layout (default: "auto")
|
|
@@ -51,323 +47,338 @@ function _import(name, location) {
|
|
|
51
47
|
* @csspart music - the music output area
|
|
52
48
|
*/
|
|
53
49
|
export class PbMei extends pbMixin(LitElement) {
|
|
50
|
+
static get properties() {
|
|
51
|
+
return {
|
|
52
|
+
/**
|
|
53
|
+
* MEI data to display specified as a string. This should represent a complete
|
|
54
|
+
* MEI document.
|
|
55
|
+
*/
|
|
56
|
+
data: {
|
|
57
|
+
type: String,
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* URL of the MEI file to load. Will be used if no `data` property is present.
|
|
61
|
+
* A relative URL would be resolved relative to the TEI Publisher endpoint.
|
|
62
|
+
*/
|
|
63
|
+
url: {
|
|
64
|
+
type: String,
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Set to enable MIDI player
|
|
68
|
+
*/
|
|
69
|
+
player: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
},
|
|
72
|
+
header: {
|
|
73
|
+
type: String,
|
|
74
|
+
},
|
|
75
|
+
footer: {
|
|
76
|
+
type: String,
|
|
77
|
+
},
|
|
78
|
+
breaks: {
|
|
79
|
+
type: String,
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Set the XPath query for selecting <app> child elements, for example: "./rdg[contains(@source, 'source-id')]";
|
|
83
|
+
* by default the <lem> or the first <rdg> is selected
|
|
84
|
+
*/
|
|
85
|
+
appXPath: {
|
|
86
|
+
type: String,
|
|
87
|
+
attribute: 'app-xpath',
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* Set the xPath query for selecting <choice> child elements, for example: "./orig"; by default the first child is selected
|
|
91
|
+
*/
|
|
92
|
+
choiceXPath: {
|
|
93
|
+
type: String,
|
|
94
|
+
attribute: 'choice-xpath',
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Set the xPath query for selecting the <mdiv> to be rendered; only one <mdiv> can be rendered (default: "")
|
|
98
|
+
*/
|
|
99
|
+
mdivXPath: {
|
|
100
|
+
type: String,
|
|
101
|
+
attribute: 'mdiv-xpath',
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Set the xPath query for selecting <subst> child elements, for example: "./del"; by default the first child is selected
|
|
105
|
+
*/
|
|
106
|
+
substXPath: {
|
|
107
|
+
type: String,
|
|
108
|
+
attribute: 'subst-xpath',
|
|
109
|
+
},
|
|
110
|
+
_svg: {
|
|
111
|
+
type: String,
|
|
112
|
+
},
|
|
113
|
+
...super.properties,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
54
116
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Set to enable MIDI player
|
|
73
|
-
*/
|
|
74
|
-
player: {
|
|
75
|
-
type: Boolean,
|
|
76
|
-
},
|
|
77
|
-
header: {
|
|
78
|
-
type: String,
|
|
79
|
-
},
|
|
80
|
-
footer: {
|
|
81
|
-
type: String,
|
|
82
|
-
},
|
|
83
|
-
breaks: {
|
|
84
|
-
type: String,
|
|
85
|
-
},
|
|
86
|
-
/**
|
|
87
|
-
* Set the XPath query for selecting <app> child elements, for example: "./rdg[contains(@source, 'source-id')]";
|
|
88
|
-
* by default the <lem> or the first <rdg> is selected
|
|
89
|
-
*/
|
|
90
|
-
appXPath: {
|
|
91
|
-
type: String,
|
|
92
|
-
attribute: 'app-xpath',
|
|
93
|
-
},
|
|
94
|
-
/**
|
|
95
|
-
* Set the xPath query for selecting <choice> child elements, for example: "./orig"; by default the first child is selected
|
|
96
|
-
*/
|
|
97
|
-
choiceXPath: {
|
|
98
|
-
type: String,
|
|
99
|
-
attribute: 'choice-xpath',
|
|
100
|
-
},
|
|
101
|
-
/**
|
|
102
|
-
* Set the xPath query for selecting the <mdiv> to be rendered; only one <mdiv> can be rendered (default: "")
|
|
103
|
-
*/
|
|
104
|
-
mdivXPath: {
|
|
105
|
-
type: String,
|
|
106
|
-
attribute: 'mdiv-xpath',
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* Set the xPath query for selecting <subst> child elements, for example: "./del"; by default the first child is selected
|
|
110
|
-
*/
|
|
111
|
-
substXPath: {
|
|
112
|
-
type: String,
|
|
113
|
-
attribute: 'subst-xpath',
|
|
114
|
-
},
|
|
115
|
-
_svg: {
|
|
116
|
-
type: String,
|
|
117
|
-
},
|
|
118
|
-
...super.properties,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
117
|
+
constructor() {
|
|
118
|
+
super();
|
|
119
|
+
this._data = null;
|
|
120
|
+
this._svg = null;
|
|
121
|
+
this._pages = 0;
|
|
122
|
+
this._page = 0;
|
|
123
|
+
this._midiPlayer = null;
|
|
124
|
+
this.footer = 'auto';
|
|
125
|
+
this.header = 'auto';
|
|
126
|
+
this.breaks = 'auto';
|
|
127
|
+
this.appXPath = null;
|
|
128
|
+
this.choiceXPath = null;
|
|
129
|
+
this.mdivXPath = null;
|
|
130
|
+
this.substXPath = null;
|
|
131
|
+
this._options = [];
|
|
132
|
+
}
|
|
121
133
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this._data = null;
|
|
125
|
-
this._svg = null;
|
|
126
|
-
this._pages = 0;
|
|
127
|
-
this._page = 0;
|
|
128
|
-
this._midiPlayer = null;
|
|
129
|
-
this.footer = 'auto';
|
|
130
|
-
this.header = 'auto';
|
|
131
|
-
this.breaks = 'auto';
|
|
132
|
-
this.appXPath = null;
|
|
133
|
-
this.choiceXPath = null;
|
|
134
|
-
this.mdivXPath = null;
|
|
135
|
-
this.substXPath = null;
|
|
136
|
-
this._options = [];
|
|
137
|
-
}
|
|
134
|
+
connectedCallback() {
|
|
135
|
+
super.connectedCallback();
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
this.querySelectorAll('pb-option').forEach(option => {
|
|
138
|
+
this._options.push({
|
|
139
|
+
name: option.getAttribute('name'),
|
|
140
|
+
on: option.getAttribute('on'),
|
|
141
|
+
off: option.getAttribute('off'),
|
|
142
|
+
label: option.innerHTML,
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
147
|
+
firstUpdated() {
|
|
148
|
+
super.firstUpdated();
|
|
149
|
+
|
|
150
|
+
if (this.player) {
|
|
151
|
+
_import('midiPlayer', resolveURL('../lib/web-midi-player/index.js')).then(() => {
|
|
152
|
+
const {
|
|
153
|
+
'web-midi-player': { default: MidiPlayer },
|
|
154
|
+
} = window;
|
|
155
|
+
this._midiPlayer = new MidiPlayer();
|
|
156
|
+
});
|
|
150
157
|
}
|
|
151
158
|
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
if (!_verovio) {
|
|
160
|
+
createVerovioModule().then(VerovioModule => {
|
|
161
|
+
_verovio = new VerovioToolkit(VerovioModule);
|
|
154
162
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (!_verovio) {
|
|
164
|
-
createVerovioModule().then(VerovioModule => {
|
|
165
|
-
_verovio = new VerovioToolkit(VerovioModule);
|
|
166
|
-
|
|
167
|
-
waitOnce('pb-page-ready', () => {
|
|
168
|
-
this.load();
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
} else {
|
|
172
|
-
waitOnce('pb-page-ready', () => {
|
|
173
|
-
this.load();
|
|
174
|
-
});
|
|
175
|
-
}
|
|
163
|
+
waitOnce('pb-page-ready', () => {
|
|
164
|
+
this.load();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
waitOnce('pb-page-ready', () => {
|
|
169
|
+
this.load();
|
|
170
|
+
});
|
|
176
171
|
}
|
|
172
|
+
}
|
|
177
173
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
174
|
+
update(changedProps) {
|
|
175
|
+
super.update(changedProps);
|
|
176
|
+
if (changedProps.get('url') || changedProps.get('data')) {
|
|
177
|
+
this.load();
|
|
178
|
+
} else if (
|
|
179
|
+
(changedProps.has('appXPath') ||
|
|
180
|
+
changedProps.has('choiceXPath') ||
|
|
181
|
+
changedProps.has('mdivXPath') ||
|
|
182
|
+
changedProps.has('substXPath')) &&
|
|
183
|
+
_verovio
|
|
184
|
+
) {
|
|
185
|
+
_verovio.setOptions(this._getOptions());
|
|
186
|
+
_verovio.loadData(this._data);
|
|
187
|
+
this.showPage();
|
|
193
188
|
}
|
|
189
|
+
}
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
load() {
|
|
192
|
+
if (this.data) {
|
|
193
|
+
console.log('<pb-mei> Rendering data');
|
|
194
|
+
this.show(this.data);
|
|
195
|
+
} else if (this.url) {
|
|
196
|
+
const link = this.toAbsoluteURL(this.url);
|
|
201
197
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
198
|
+
fetch(link)
|
|
199
|
+
.then(response => response.text())
|
|
200
|
+
.then(async str => {
|
|
201
|
+
this.show(str);
|
|
202
|
+
});
|
|
208
203
|
}
|
|
204
|
+
}
|
|
209
205
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
206
|
+
show(str) {
|
|
207
|
+
this._data = str;
|
|
208
|
+
_verovio.setOptions(this._getOptions());
|
|
209
|
+
_verovio.loadData(this._data);
|
|
210
|
+
this._pages = _verovio.getPageCount();
|
|
211
|
+
this._page = 1;
|
|
212
|
+
console.log('<pb-mei> Loaded %d pages', this._pages);
|
|
213
|
+
this.showPage();
|
|
214
|
+
}
|
|
219
215
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
216
|
+
showPage() {
|
|
217
|
+
this._svg = _verovio.renderToSVG(this._page, {});
|
|
218
|
+
}
|
|
223
219
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
220
|
+
async play() {
|
|
221
|
+
const button = this.shadowRoot.getElementById('play');
|
|
222
|
+
if (!button.active) {
|
|
223
|
+
this._midiPlayer.stop();
|
|
224
|
+
button.icon = 'av:play-arrow';
|
|
225
|
+
} else {
|
|
226
|
+
button.icon = 'av:stop';
|
|
227
|
+
if (this._midiPaused) {
|
|
228
|
+
this._midiPaused = false;
|
|
229
|
+
this._midiPlayer.resume();
|
|
230
|
+
} else {
|
|
231
|
+
_verovio.loadData(this._data);
|
|
232
|
+
const mdata = _verovio.renderToMIDI();
|
|
233
|
+
const raw = window.atob(mdata);
|
|
234
|
+
const rawLength = raw.length;
|
|
235
|
+
const array = new Uint8Array(new ArrayBuffer(rawLength));
|
|
240
236
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
this._midiPlayer.play({ arrayBuffer: array });
|
|
245
|
-
}
|
|
237
|
+
for (let i = 0; i < rawLength; i += 1) {
|
|
238
|
+
array[i] = raw.charCodeAt(i);
|
|
246
239
|
}
|
|
240
|
+
this._midiPlayer.play({ arrayBuffer: array });
|
|
241
|
+
}
|
|
247
242
|
}
|
|
243
|
+
}
|
|
248
244
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
245
|
+
pause() {
|
|
246
|
+
const button = this.shadowRoot.getElementById('play');
|
|
247
|
+
if (button.active) {
|
|
248
|
+
this._midiPaused = this._midiPlayer.pause();
|
|
249
|
+
if (this._midiPaused) {
|
|
250
|
+
button.icon = 'av:play-arrow';
|
|
251
|
+
button.active = false;
|
|
252
|
+
}
|
|
258
253
|
}
|
|
254
|
+
}
|
|
259
255
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
256
|
+
render() {
|
|
257
|
+
return html`
|
|
258
|
+
<div id="toolbar" part="toolbar">
|
|
259
|
+
<div class="${this._pages === 1 ? 'hidden' : ''}">
|
|
260
|
+
<paper-icon-button
|
|
261
|
+
id="pageLeft"
|
|
262
|
+
icon="icons:chevron-left"
|
|
263
|
+
@click="${this._previousPage}"
|
|
264
|
+
?disabled="${this._page === 1}"
|
|
265
|
+
></paper-icon-button>
|
|
266
|
+
<paper-icon-button
|
|
267
|
+
id="pageRight"
|
|
268
|
+
icon="icons:chevron-right"
|
|
269
|
+
@click="${this._nextPage}"
|
|
270
|
+
?disabled="${this._page === this._pages}"
|
|
271
|
+
></paper-icon-button>
|
|
272
|
+
</div>
|
|
273
|
+
${this._renderPlayer()}
|
|
274
|
+
<div>${this._renderOptions()}</div>
|
|
275
|
+
</div>
|
|
276
|
+
${this._svg
|
|
277
|
+
? html`<div id="output" part="music">${unsafeHTML(this._svg)}</div>`
|
|
278
|
+
: html`<div id="output" part="music">${translate('dialogs.loading')}</div>`}
|
|
279
|
+
`;
|
|
280
|
+
}
|
|
278
281
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
282
|
+
_renderPlayer() {
|
|
283
|
+
if (this.player) {
|
|
284
|
+
return html`
|
|
285
|
+
<div id="player">
|
|
286
|
+
<paper-icon-button
|
|
287
|
+
id="play"
|
|
288
|
+
icon="av:play-arrow"
|
|
289
|
+
toggles
|
|
290
|
+
@click="${this.play}"
|
|
291
|
+
></paper-icon-button>
|
|
292
|
+
<paper-icon-button icon="av:pause" @click="${this.pause}"></paper-icon-button>
|
|
293
|
+
</div>
|
|
294
|
+
`;
|
|
289
295
|
}
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
290
298
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
)
|
|
295
|
-
|
|
299
|
+
_renderOptions() {
|
|
300
|
+
return this._options.map(
|
|
301
|
+
option =>
|
|
302
|
+
html`<paper-checkbox @change="${ev => this._setOption(option, ev.target.checked)}"
|
|
303
|
+
>${option.label}</paper-checkbox
|
|
304
|
+
>`,
|
|
305
|
+
);
|
|
306
|
+
}
|
|
296
307
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
this[option.name] = value;
|
|
308
|
+
_setOption(option, checked) {
|
|
309
|
+
let value;
|
|
310
|
+
if (checked) {
|
|
311
|
+
value = option.on && option.on.length > 0 ? option.on : null;
|
|
312
|
+
} else {
|
|
313
|
+
value = option.off && option.off.length > 0 ? option.off : null;
|
|
305
314
|
}
|
|
315
|
+
this[option.name] = value;
|
|
316
|
+
}
|
|
306
317
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}
|
|
318
|
+
_nextPage(ev) {
|
|
319
|
+
ev.preventDefault();
|
|
320
|
+
if (this._page < this._pages) {
|
|
321
|
+
this._page += 1;
|
|
322
|
+
this.showPage();
|
|
313
323
|
}
|
|
324
|
+
}
|
|
314
325
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
326
|
+
_previousPage(ev) {
|
|
327
|
+
ev.preventDefault();
|
|
328
|
+
if (this._page > 1) {
|
|
329
|
+
this._page -= 1;
|
|
330
|
+
this.showPage();
|
|
321
331
|
}
|
|
332
|
+
}
|
|
322
333
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}
|
|
338
|
-
return options;
|
|
334
|
+
_getOptions() {
|
|
335
|
+
const options = {
|
|
336
|
+
// svg content should scale with the width of the component
|
|
337
|
+
svgViewBox: true,
|
|
338
|
+
adjustPageHeight: true,
|
|
339
|
+
footer: this.footer,
|
|
340
|
+
header: this.header,
|
|
341
|
+
breaks: this.breaks,
|
|
342
|
+
appXPathQuery: [this.appXPath],
|
|
343
|
+
substXPathQuery: [this.substXPath],
|
|
344
|
+
choiceXPathQuery: [this.choiceXPath],
|
|
345
|
+
};
|
|
346
|
+
if (this.mdivXPath) {
|
|
347
|
+
options.mdivXPathQuery = this.mdivXPath;
|
|
339
348
|
}
|
|
349
|
+
return options;
|
|
350
|
+
}
|
|
340
351
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
352
|
+
static get styles() {
|
|
353
|
+
return css`
|
|
354
|
+
:host {
|
|
355
|
+
display: grid;
|
|
356
|
+
grid-template-rows: auto 1fr;
|
|
357
|
+
min-width: var(--pb-mei-min-width, auto);
|
|
358
|
+
}
|
|
348
359
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
360
|
+
#toolbar {
|
|
361
|
+
display: flex;
|
|
362
|
+
align-items: center;
|
|
363
|
+
}
|
|
353
364
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
365
|
+
#toolbar div {
|
|
366
|
+
margin-right: 1rem;
|
|
367
|
+
}
|
|
357
368
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
369
|
+
#toolbar div:last-child {
|
|
370
|
+
margin-right: 0;
|
|
371
|
+
}
|
|
361
372
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
#output {
|
|
374
|
+
width: 100%;
|
|
375
|
+
overflow: auto;
|
|
376
|
+
}
|
|
366
377
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
378
|
+
.hidden {
|
|
379
|
+
display: none;
|
|
380
|
+
}
|
|
381
|
+
`;
|
|
382
|
+
}
|
|
372
383
|
}
|
|
373
|
-
customElements.define('pb-mei', PbMei);
|
|
384
|
+
customElements.define('pb-mei', PbMei);
|