@teipublisher/pb-components 3.6.4 → 3.6.6
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/node.js.yml +14 -0
- package/CHANGELOG.md +15 -0
- package/Dockerfile +30 -41
- package/ci/setup-tei-publisher-app.sh +70 -0
- package/ci/tp_config.json +31 -0
- package/dist/pb-components-bundle.js +51 -24
- package/package.json +2 -2
- package/src/pb-authority-lookup.js +29 -2
- package/src/pb-page.js +4 -12
- package/src/pb-view.js +55 -14
- package/tei-publisher-app/tei-publisher.xar +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teipublisher/pb-components",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.6",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"start": "npm run build && npm run docs && es-dev-server",
|
|
19
19
|
"test": "karma start",
|
|
20
20
|
"test:watch": "karma start --auto-watch=true --single-run=false",
|
|
21
|
-
"docker": "npm run build:production && docker build --no-cache --pull --rm -f 'Dockerfile' -t pbcomponents:master '.'",
|
|
21
|
+
"docker": "npm run build:production && ci/setup-tei-publisher-app.sh && docker build --no-cache --pull --rm -f 'Dockerfile' -t pbcomponents:master '.'",
|
|
22
22
|
"docker:run": "docker run --rm -it -p 8080:8080/tcp -p 8443:8443/tcp pbcomponents:master",
|
|
23
23
|
"docs": "wca src -f json --outFile pb-elements.json",
|
|
24
24
|
"lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore",
|
|
@@ -146,7 +146,11 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
146
146
|
${this._authorities[this.type] && this._authorities[this.type].editable
|
|
147
147
|
? html`
|
|
148
148
|
<pb-restricted group="${this.group}">
|
|
149
|
-
<button
|
|
149
|
+
<button
|
|
150
|
+
part="add-entity"
|
|
151
|
+
@click="${this._addEntity}"
|
|
152
|
+
title="${translate('annotations.add-entity')}"
|
|
153
|
+
>
|
|
150
154
|
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
|
|
151
155
|
<path
|
|
152
156
|
fill="none"
|
|
@@ -197,7 +201,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
197
201
|
return html`
|
|
198
202
|
<li>
|
|
199
203
|
<div>
|
|
200
|
-
<button @click="${() => this._select(item)}" title="link to">
|
|
204
|
+
<button part="select" @click="${() => this._select(item)}" title="link to">
|
|
201
205
|
<svg xmlns="http://www.w3.org/2000/svg" class="ionicon" viewBox="0 0 512 512">
|
|
202
206
|
<path
|
|
203
207
|
d="M208 352h-64a96 96 0 010-192h64M304 160h64a96 96 0 010 192h-64M163.29 256h187.42"
|
|
@@ -223,6 +227,7 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
223
227
|
${this._authorities[this.type] && this._authorities[this.type].editable
|
|
224
228
|
? html` <pb-restricted group="${this.group}">
|
|
225
229
|
<button
|
|
230
|
+
part="edit-entity"
|
|
226
231
|
@click="${() => this._editEntity(item)}"
|
|
227
232
|
title="${translate('annotations.edit-entity')}"
|
|
228
233
|
>
|
|
@@ -305,6 +310,28 @@ export class PbAuthorityLookup extends themableMixin(pbMixin(LitElement)) {
|
|
|
305
310
|
align-items: center;
|
|
306
311
|
}
|
|
307
312
|
|
|
313
|
+
button {
|
|
314
|
+
display: inline-flex;
|
|
315
|
+
align-items: center;
|
|
316
|
+
justify-content: center;
|
|
317
|
+
border: none;
|
|
318
|
+
background: transparent;
|
|
319
|
+
color: inherit;
|
|
320
|
+
cursor: pointer;
|
|
321
|
+
padding: 0.25rem;
|
|
322
|
+
border-radius: 4px;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
button:hover {
|
|
326
|
+
background: rgba(0, 0, 0, 0.08);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.ionicon {
|
|
330
|
+
width: 1.1rem;
|
|
331
|
+
height: 1.1rem;
|
|
332
|
+
flex: none;
|
|
333
|
+
}
|
|
334
|
+
|
|
308
335
|
.badge {
|
|
309
336
|
font-size: 0.75rem;
|
|
310
337
|
border-radius: 4px;
|
package/src/pb-page.js
CHANGED
|
@@ -281,19 +281,11 @@ export class PbPage extends pbMixin(LitElement) {
|
|
|
281
281
|
console.log('<pb-page> Loading component theme stylesheets from %s', stylesheetURLs.join(', '));
|
|
282
282
|
this._themeSheet = await loadStylesheets(stylesheetURLs);
|
|
283
283
|
|
|
284
|
-
//
|
|
284
|
+
// Determine the server API version. Jinks-generated apps expose a /login
|
|
285
|
+
// page (HTTP 200), so probing that URL is no longer a reliable indicator
|
|
286
|
+
// of a pre-7 server — use /api/version directly.
|
|
285
287
|
if (!this.apiVersion) {
|
|
286
|
-
|
|
287
|
-
// this is necessary to prevent a CORS failure
|
|
288
|
-
const json = await fetch(`${this.endpoint}/login`)
|
|
289
|
-
.then(res => {
|
|
290
|
-
if (res.ok) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
// if not, access the actual /api/version endpoint to retrieve the API version
|
|
294
|
-
return fetch(`${this.endpoint}/api/version`).then(res2 => res2.json());
|
|
295
|
-
})
|
|
296
|
-
.catch(() => fetch(`${this.endpoint}/api/version`).then(res2 => res2.json()));
|
|
288
|
+
const json = await fetch(`${this.endpoint}/api/version`).then(res2 => res2.json());
|
|
297
289
|
|
|
298
290
|
if (json) {
|
|
299
291
|
this.apiVersion = json.api;
|
package/src/pb-view.js
CHANGED
|
@@ -384,28 +384,26 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
if (!this.disableHistory) {
|
|
387
|
-
|
|
388
|
-
this.xmlId = registry.state.id;
|
|
389
|
-
}
|
|
387
|
+
this._syncPositionFromRegistry();
|
|
390
388
|
|
|
391
389
|
if (registry.state.action && registry.state.action === 'search') {
|
|
392
390
|
this.highlight = true;
|
|
393
391
|
}
|
|
394
392
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
} else if (registry.state.root && !this.nodeId) {
|
|
398
|
-
this.nodeId = registry.state.root;
|
|
399
|
-
}
|
|
400
|
-
|
|
393
|
+
const doc = this.getDocument();
|
|
394
|
+
const prevState = { ...registry.state, ...registry.getState(this) };
|
|
401
395
|
const newState = {
|
|
402
|
-
id: this.xmlId,
|
|
403
396
|
view: this.getView(),
|
|
404
397
|
odd: this.getOdd(),
|
|
405
|
-
path:
|
|
398
|
+
path: doc.path,
|
|
406
399
|
};
|
|
407
|
-
if (this.
|
|
400
|
+
if (this.xmlId) {
|
|
401
|
+
newState.id = this.xmlId;
|
|
402
|
+
}
|
|
403
|
+
if (this.view !== 'single' && this.nodeId) {
|
|
408
404
|
newState.root = this.nodeId;
|
|
405
|
+
} else if (prevState.path && prevState.path !== doc.path) {
|
|
406
|
+
newState.root = null;
|
|
409
407
|
}
|
|
410
408
|
if (this.fill) {
|
|
411
409
|
newState.fill = this.fill;
|
|
@@ -567,6 +565,43 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
567
565
|
}
|
|
568
566
|
}
|
|
569
567
|
|
|
568
|
+
_refreshHasPosition(detail) {
|
|
569
|
+
if (!detail) {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
return (
|
|
573
|
+
Object.prototype.hasOwnProperty.call(detail, 'id') ||
|
|
574
|
+
Object.prototype.hasOwnProperty.call(detail, 'root') ||
|
|
575
|
+
Object.prototype.hasOwnProperty.call(detail, 'position') ||
|
|
576
|
+
Object.prototype.hasOwnProperty.call(detail, 'path') ||
|
|
577
|
+
Object.prototype.hasOwnProperty.call(detail, 'xpath')
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
_syncPositionFromRegistry() {
|
|
582
|
+
if (this.disableHistory || this.getAttribute('xml-id')) {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
const doc = this.getDocument();
|
|
586
|
+
if (!doc?.path) {
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
const state = { ...registry.state, ...registry.getState(this) };
|
|
590
|
+
if (state.path && state.path !== doc.path) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
if (!this.xmlId && state.id) {
|
|
594
|
+
this.xmlId = state.id;
|
|
595
|
+
}
|
|
596
|
+
if (!this.nodeId) {
|
|
597
|
+
if (this.getView() === 'single') {
|
|
598
|
+
this.nodeId = null;
|
|
599
|
+
} else if (state.root) {
|
|
600
|
+
this.nodeId = state.root;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
570
605
|
_refresh(ev) {
|
|
571
606
|
if (ev && ev.detail) {
|
|
572
607
|
if (
|
|
@@ -588,6 +623,7 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
588
623
|
}
|
|
589
624
|
if (ev.detail.id) {
|
|
590
625
|
this.xmlId = ev.detail.id;
|
|
626
|
+
this.nodeId = null;
|
|
591
627
|
} else if (ev.detail.id == null) {
|
|
592
628
|
this.xmlId = null;
|
|
593
629
|
}
|
|
@@ -619,6 +655,9 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
619
655
|
this._scrollTarget = ev.detail.hash;
|
|
620
656
|
}
|
|
621
657
|
}
|
|
658
|
+
if (!this._refreshHasPosition(ev?.detail)) {
|
|
659
|
+
this._syncPositionFromRegistry();
|
|
660
|
+
}
|
|
622
661
|
this._updateStyles();
|
|
623
662
|
if (this.infiniteScroll) {
|
|
624
663
|
this._clear();
|
|
@@ -1264,7 +1303,7 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
1264
1303
|
if (this.view === 'single') {
|
|
1265
1304
|
// when switching to single view, clear current node id
|
|
1266
1305
|
this.nodeId = null;
|
|
1267
|
-
} else {
|
|
1306
|
+
} else if (this.switchView) {
|
|
1268
1307
|
// otherwise use value for alternate view returned from server
|
|
1269
1308
|
this.nodeId = this.switchView;
|
|
1270
1309
|
}
|
|
@@ -1279,7 +1318,9 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
|
|
|
1279
1318
|
this.columnSeparator = properties.columnSeparator;
|
|
1280
1319
|
}
|
|
1281
1320
|
this.xmlId = (!this.getAttribute('xml-id') && properties.id) || this.xmlId;
|
|
1282
|
-
|
|
1321
|
+
if (Object.prototype.hasOwnProperty.call(properties, 'root')) {
|
|
1322
|
+
this.nodeId = (!this.getAttribute('xml-id') && properties.root) || null;
|
|
1323
|
+
}
|
|
1283
1324
|
|
|
1284
1325
|
if (properties.path) {
|
|
1285
1326
|
this.getDocument().path = properties.path;
|
|
Binary file
|