@teipublisher/pb-components 2.11.1 → 2.12.1
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/CHANGELOG.md +14 -0
- package/dist/demo/demos.json +1 -2
- package/dist/demo/pb-mei.html +3 -3
- package/dist/{iron-form-89b60473.js → iron-form-a25b58de.js} +1 -1
- package/dist/paper-checkbox-c9177e35.js +1596 -0
- package/dist/paper-icon-button-be4dc644.js +398 -0
- package/dist/paper-listbox-1fc346ac.js +1463 -0
- package/dist/pb-components-bundle.js +264 -402
- package/dist/pb-edit-app.js +1 -1
- package/dist/pb-elements.json +30 -3
- package/dist/pb-mei.js +139 -0
- package/dist/pb-odd-editor.js +1 -1
- package/dist/vaadin-element-mixin-660b2157.js +516 -0
- package/lib/airtable.browser.js +3753 -0
- package/lib/web-midi-player/index.js +1 -0
- package/package.json +6 -3
- package/pb-elements.json +30 -3
- package/src/authority/airtable.js +4 -3
- package/src/pb-components.js +0 -1
- package/src/pb-mei.js +67 -33
- package/dist/paper-checkbox-56ead3d4.js +0 -3069
- package/dist/vaadin-element-mixin-67c5648d.js +0 -913
- package/lib/openseadragon.min.js +0 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teipublisher/pb-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.1",
|
|
4
4
|
"description": "Collection of webcomponents underlying TEI Publisher",
|
|
5
5
|
"repository": "https://github.com/eeditiones/tei-publisher-components.git",
|
|
6
6
|
"main": "index.html",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
29
29
|
"format": "npm run format:eslint && npm run format:prettier",
|
|
30
30
|
"clean": "npm run clean-lib && rimraf dist css images/leaflet demo/build docs",
|
|
31
|
-
"clean-lib": "rimraf -g lib/leaflet* lib/paged*",
|
|
31
|
+
"clean-lib": "rimraf -g lib/leaflet* lib/paged* lib/web-midi-player.js lib/openseadragon* lib/airtable.browser.js",
|
|
32
32
|
"prepare": "npm run docs && npm run build:production",
|
|
33
33
|
"semantic-release": "semantic-release",
|
|
34
34
|
"gh-pages": "node gh-pages.js"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@vaadin/vaadin-tabs": "^3.2.0",
|
|
69
69
|
"@vaadin/vaadin-upload": "^4.4.0",
|
|
70
70
|
"@webcomponents/webcomponentsjs": "latest",
|
|
71
|
+
"airtable": "^0.12.2",
|
|
71
72
|
"animejs": "^3.2.0",
|
|
72
73
|
"browser-fs-access": "^0.34.1",
|
|
73
74
|
"construct-style-sheets-polyfill": "^3.1.0",
|
|
@@ -90,7 +91,9 @@
|
|
|
90
91
|
"tippy.js": "^6.3.7",
|
|
91
92
|
"tom-select": "^2.2.2",
|
|
92
93
|
"uniqolor": "^1.1.0",
|
|
93
|
-
"
|
|
94
|
+
"verovio": "^3.16.0",
|
|
95
|
+
"web-animations-js": "^2.3.2",
|
|
96
|
+
"web-midi-player": "^1.4.1"
|
|
94
97
|
},
|
|
95
98
|
"devDependencies": {
|
|
96
99
|
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
|
package/pb-elements.json
CHANGED
|
@@ -6808,11 +6808,16 @@
|
|
|
6808
6808
|
{
|
|
6809
6809
|
"name": "pb-mei",
|
|
6810
6810
|
"path": "./src/pb-mei.js",
|
|
6811
|
-
"description": "A viewer and player for MEI musical notation based on [Verovio](https://www.verovio.org/).\nSupports optional MIDI playback using [web-midi-player](https://midi.yvesgurcan.com/).\nBoth libraries are loaded dynamically when the component is used the first time.\n\nViewing options to be selected by the user can be defined via nested `pb-option` elements:\n\n```html\n<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\" \n footer=\"none\">\n <pb-option name=\"appXPath\" on=\"./rdg[contains(@label, 'original')]\" off=\"\">Original Clefs</pb-option>\n
|
|
6811
|
+
"description": "A viewer and player for MEI musical notation based on [Verovio](https://www.verovio.org/).\nSupports optional MIDI playback using [web-midi-player](https://midi.yvesgurcan.com/).\nBoth libraries are loaded dynamically when the component is used the first time.\n\nViewing options to be selected by the user can be defined via nested `pb-option` elements:\n\n```html\n<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\" \n footer=\"none\">\n <pb-option name=\"appXPath\" on=\"./rdg[contains(@label, 'original')]\" off=\"\">Original Clefs</pb-option>\n</pb-mei>\n```\n\nThe MEI document to display can either be given directly in the `data` property or loaded from an URL\nspecified in `url`.",
|
|
6812
6812
|
"attributes": [
|
|
6813
|
+
{
|
|
6814
|
+
"name": "data",
|
|
6815
|
+
"description": "MEI data to display specified as a string. This should represent a complete\nMEI document.",
|
|
6816
|
+
"type": "string"
|
|
6817
|
+
},
|
|
6813
6818
|
{
|
|
6814
6819
|
"name": "url",
|
|
6815
|
-
"description": "URL of the MEI file to load.
|
|
6820
|
+
"description": "URL of the MEI file to load. Will be used if no `data` property is present. \nA relative URL would be resolved relative to the TEI Publisher endpoint.",
|
|
6816
6821
|
"type": "string"
|
|
6817
6822
|
},
|
|
6818
6823
|
{
|
|
@@ -6891,10 +6896,16 @@
|
|
|
6891
6896
|
}
|
|
6892
6897
|
],
|
|
6893
6898
|
"properties": [
|
|
6899
|
+
{
|
|
6900
|
+
"name": "data",
|
|
6901
|
+
"attribute": "data",
|
|
6902
|
+
"description": "MEI data to display specified as a string. This should represent a complete\nMEI document.",
|
|
6903
|
+
"type": "string"
|
|
6904
|
+
},
|
|
6894
6905
|
{
|
|
6895
6906
|
"name": "url",
|
|
6896
6907
|
"attribute": "url",
|
|
6897
|
-
"description": "URL of the MEI file to load.
|
|
6908
|
+
"description": "URL of the MEI file to load. Will be used if no `data` property is present. \nA relative URL would be resolved relative to the TEI Publisher endpoint.",
|
|
6898
6909
|
"type": "string"
|
|
6899
6910
|
},
|
|
6900
6911
|
{
|
|
@@ -6985,6 +6996,22 @@
|
|
|
6985
6996
|
"type": "boolean",
|
|
6986
6997
|
"default": "false"
|
|
6987
6998
|
}
|
|
6999
|
+
],
|
|
7000
|
+
"cssProperties": [
|
|
7001
|
+
{
|
|
7002
|
+
"name": "--pb-mei-min-width",
|
|
7003
|
+
"description": "minimal width"
|
|
7004
|
+
}
|
|
7005
|
+
],
|
|
7006
|
+
"cssParts": [
|
|
7007
|
+
{
|
|
7008
|
+
"name": "toolbar",
|
|
7009
|
+
"description": "toolbar with pagination and midi player controls"
|
|
7010
|
+
},
|
|
7011
|
+
{
|
|
7012
|
+
"name": "music",
|
|
7013
|
+
"description": "the music output area"
|
|
7014
|
+
}
|
|
6988
7015
|
]
|
|
6989
7016
|
},
|
|
6990
7017
|
{
|
|
@@ -55,7 +55,7 @@ export class Airtable extends Registry {
|
|
|
55
55
|
|
|
56
56
|
_init() {
|
|
57
57
|
window.ESGlobalBridge.requestAvailability();
|
|
58
|
-
const path = resolveURL('
|
|
58
|
+
const path = resolveURL('../lib/airtable.browser.js');
|
|
59
59
|
window.ESGlobalBridge.instance.load('airtable', path);
|
|
60
60
|
window.addEventListener(
|
|
61
61
|
'es-bridge-airtable-loaded',
|
|
@@ -149,11 +149,12 @@ export class Airtable extends Registry {
|
|
|
149
149
|
});
|
|
150
150
|
const regex = new RegExp(this.tokenizeChars);
|
|
151
151
|
this.tokenize.forEach((key) => {
|
|
152
|
-
|
|
152
|
+
if (data[key]) {
|
|
153
|
+
strings = strings.concat(data[key].split(regex));
|
|
154
|
+
}
|
|
153
155
|
});
|
|
154
156
|
strings = strings.filter(tok => !/^\d+$/.test(tok));
|
|
155
157
|
strings.sort((s1, s2) => s2.length - s1.length);
|
|
156
|
-
console.log(strings);
|
|
157
158
|
container.innerHTML = expandTemplate(this.infoExpr, data);
|
|
158
159
|
|
|
159
160
|
resolve({
|
package/src/pb-components.js
CHANGED
package/src/pb-mei.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
|
3
3
|
import "@lrnwebcomponents/es-global-bridge";
|
|
4
|
+
import createVerovioModule from 'verovio/dist/verovio-module.mjs';
|
|
5
|
+
import { VerovioToolkit } from 'verovio/dist/verovio.mjs';
|
|
4
6
|
import { pbMixin, waitOnce } from './pb-mixin.js';
|
|
5
7
|
import { translate } from './pb-i18n.js';
|
|
8
|
+
import { resolveURL } from './utils.js';
|
|
6
9
|
import '@polymer/paper-icon-button';
|
|
7
10
|
import '@polymer/paper-checkbox';
|
|
8
11
|
import '@polymer/iron-icons';
|
|
9
12
|
import '@polymer/iron-icons/av-icons';
|
|
10
13
|
|
|
14
|
+
let _verovio = null;
|
|
15
|
+
|
|
11
16
|
/** Import external script dynamically */
|
|
12
17
|
function _import(name, location) {
|
|
13
18
|
window.ESGlobalBridge.requestAvailability();
|
|
@@ -32,19 +37,33 @@ function _import(name, location) {
|
|
|
32
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
38
|
* footer="none">
|
|
34
39
|
* <pb-option name="appXPath" on="./rdg[contains(@label, 'original')]" off="">Original Clefs</pb-option>
|
|
35
|
-
*
|
|
40
|
+
* </pb-mei>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* The MEI document to display can either be given directly in the `data` property or loaded from an URL
|
|
44
|
+
* specified in `url`.
|
|
36
45
|
*
|
|
37
46
|
* @prop {"auto" | "encoded" | "none" | "always"} footer - Control footer layout
|
|
38
47
|
* @prop {"auto" | "encoded" | "none"} header - Control footer layout
|
|
39
48
|
* @prop {"auto" | "none" | "line" | "encoded" | "smart"} breaks - Define page and system breaks layout (default: "auto")
|
|
49
|
+
* @cssprop --pb-mei-min-width - minimal width
|
|
50
|
+
* @csspart toolbar - toolbar with pagination and midi player controls
|
|
51
|
+
* @csspart music - the music output area
|
|
40
52
|
*/
|
|
41
53
|
export class PbMei extends pbMixin(LitElement) {
|
|
42
54
|
|
|
43
55
|
static get properties() {
|
|
44
56
|
return {
|
|
57
|
+
/**
|
|
58
|
+
* MEI data to display specified as a string. This should represent a complete
|
|
59
|
+
* MEI document.
|
|
60
|
+
*/
|
|
61
|
+
data: {
|
|
62
|
+
type: String
|
|
63
|
+
},
|
|
45
64
|
/**
|
|
46
|
-
* URL of the MEI file to load.
|
|
47
|
-
* relative to the TEI Publisher endpoint.
|
|
65
|
+
* URL of the MEI file to load. Will be used if no `data` property is present.
|
|
66
|
+
* A relative URL would be resolved relative to the TEI Publisher endpoint.
|
|
48
67
|
*/
|
|
49
68
|
url: {
|
|
50
69
|
type: String,
|
|
@@ -107,7 +126,6 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
107
126
|
this._pages = 0;
|
|
108
127
|
this._page = 0;
|
|
109
128
|
this._midiPlayer = null;
|
|
110
|
-
this._verovio = null;
|
|
111
129
|
this.footer = 'auto';
|
|
112
130
|
this.header = 'auto';
|
|
113
131
|
this.breaks = 'auto';
|
|
@@ -120,6 +138,7 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
120
138
|
|
|
121
139
|
connectedCallback() {
|
|
122
140
|
super.connectedCallback();
|
|
141
|
+
|
|
123
142
|
this.querySelectorAll('pb-option').forEach((option) => {
|
|
124
143
|
this._options.push({
|
|
125
144
|
name: option.getAttribute('name'),
|
|
@@ -134,58 +153,72 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
134
153
|
super.firstUpdated();
|
|
135
154
|
|
|
136
155
|
if (this.player) {
|
|
137
|
-
_import("midiPlayer", '
|
|
156
|
+
_import("midiPlayer", resolveURL('../lib/web-midi-player/index.js'))
|
|
138
157
|
.then(() => {
|
|
139
158
|
const { 'web-midi-player': { default: MidiPlayer } } = window;
|
|
140
159
|
this._midiPlayer = new MidiPlayer();
|
|
141
160
|
});
|
|
142
161
|
}
|
|
143
162
|
|
|
144
|
-
|
|
145
|
-
.then(
|
|
146
|
-
|
|
147
|
-
|
|
163
|
+
if (!_verovio) {
|
|
164
|
+
createVerovioModule().then(VerovioModule => {
|
|
165
|
+
_verovio = new VerovioToolkit(VerovioModule);
|
|
166
|
+
|
|
148
167
|
waitOnce('pb-page-ready', () => {
|
|
149
|
-
this.load();
|
|
168
|
+
this.load();
|
|
150
169
|
});
|
|
151
170
|
});
|
|
171
|
+
} else {
|
|
172
|
+
waitOnce('pb-page-ready', () => {
|
|
173
|
+
this.load();
|
|
174
|
+
});
|
|
175
|
+
}
|
|
152
176
|
}
|
|
153
177
|
|
|
154
178
|
update(changedProps) {
|
|
155
179
|
super.update(changedProps);
|
|
156
|
-
if (changedProps.get('url')) {
|
|
180
|
+
if (changedProps.get('url') || changedProps.get('data')) {
|
|
157
181
|
this.load();
|
|
158
182
|
} else if (
|
|
159
183
|
(changedProps.has('appXPath') ||
|
|
160
184
|
changedProps.has('choiceXPath') ||
|
|
161
185
|
changedProps.has('mdivXPath') ||
|
|
162
186
|
changedProps.has('substXPath')) &&
|
|
163
|
-
|
|
187
|
+
_verovio
|
|
164
188
|
) {
|
|
165
|
-
|
|
166
|
-
|
|
189
|
+
_verovio.setOptions(this._getOptions());
|
|
190
|
+
_verovio.loadData(this._data);
|
|
167
191
|
this.showPage();
|
|
168
192
|
}
|
|
169
193
|
}
|
|
170
194
|
|
|
171
195
|
load() {
|
|
172
|
-
|
|
196
|
+
if (this.data) {
|
|
197
|
+
console.log('<pb-mei> Rendering data');
|
|
198
|
+
this.show(this.data);
|
|
199
|
+
} else if (this.url) {
|
|
200
|
+
const link = this.toAbsoluteURL(this.url);
|
|
173
201
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
202
|
+
fetch(link)
|
|
203
|
+
.then(response => response.text())
|
|
204
|
+
.then(async str => {
|
|
205
|
+
this.show(str);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
show(str) {
|
|
211
|
+
this._data = str;
|
|
212
|
+
_verovio.setOptions(this._getOptions());
|
|
213
|
+
_verovio.loadData(this._data);
|
|
214
|
+
this._pages = _verovio.getPageCount();
|
|
215
|
+
this._page = 1;
|
|
216
|
+
console.log('<pb-mei> Loaded %d pages', this._pages);
|
|
217
|
+
this.showPage();
|
|
185
218
|
}
|
|
186
219
|
|
|
187
220
|
showPage() {
|
|
188
|
-
this._svg =
|
|
221
|
+
this._svg = _verovio.renderToSVG(this._page, {});
|
|
189
222
|
}
|
|
190
223
|
|
|
191
224
|
async play() {
|
|
@@ -199,8 +232,8 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
199
232
|
this._midiPaused = false;
|
|
200
233
|
this._midiPlayer.resume();
|
|
201
234
|
} else {
|
|
202
|
-
|
|
203
|
-
const mdata =
|
|
235
|
+
_verovio.loadData(this._data);
|
|
236
|
+
const mdata = _verovio.renderToMIDI();
|
|
204
237
|
const raw = window.atob(mdata);
|
|
205
238
|
const rawLength = raw.length;
|
|
206
239
|
const array = new Uint8Array(new ArrayBuffer(rawLength));
|
|
@@ -226,7 +259,7 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
226
259
|
|
|
227
260
|
render() {
|
|
228
261
|
return html`
|
|
229
|
-
<div id="toolbar">
|
|
262
|
+
<div id="toolbar" part="toolbar">
|
|
230
263
|
<div class="${this._pages === 1 ? 'hidden' : ''}">
|
|
231
264
|
<paper-icon-button id="pageLeft" icon="icons:chevron-left" @click="${this._previousPage}"
|
|
232
265
|
?disabled="${this._page === 1}"></paper-icon-button>
|
|
@@ -237,8 +270,8 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
237
270
|
<div>${ this._renderOptions() }</div>
|
|
238
271
|
</div>
|
|
239
272
|
${ this._svg ?
|
|
240
|
-
html`<div id="output">${unsafeHTML(this._svg)}</div>` :
|
|
241
|
-
html`<div id="output">${translate('dialogs.loading')}</div>`
|
|
273
|
+
html`<div id="output" part="music">${unsafeHTML(this._svg)}</div>` :
|
|
274
|
+
html`<div id="output" part="music">${translate('dialogs.loading')}</div>`
|
|
242
275
|
}
|
|
243
276
|
`;
|
|
244
277
|
}
|
|
@@ -310,6 +343,7 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
310
343
|
:host {
|
|
311
344
|
display: grid;
|
|
312
345
|
grid-template-rows: auto 1fr;
|
|
346
|
+
min-width: var(--pb-mei-min-width, auto);
|
|
313
347
|
}
|
|
314
348
|
|
|
315
349
|
#toolbar {
|
|
@@ -318,7 +352,7 @@ export class PbMei extends pbMixin(LitElement) {
|
|
|
318
352
|
}
|
|
319
353
|
|
|
320
354
|
#toolbar div {
|
|
321
|
-
margin-right:
|
|
355
|
+
margin-right: 1rem;
|
|
322
356
|
}
|
|
323
357
|
|
|
324
358
|
#toolbar div:last-child {
|