@teipublisher/pb-components 1.35.2 → 1.36.2

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.
@@ -3487,6 +3487,18 @@
3487
3487
  "type": "boolean",
3488
3488
  "default": "false"
3489
3489
  },
3490
+ {
3491
+ "name": "reference-strip",
3492
+ "description": "If set, thumbnails of all images are shown in a reference strip at the\nbottom of the viewer.",
3493
+ "type": "boolean",
3494
+ "default": "false"
3495
+ },
3496
+ {
3497
+ "name": "reference-strip-size-ratio",
3498
+ "description": "Size ratio for the reference strip thumbnails. 0.2 by default.",
3499
+ "type": "number",
3500
+ "default": "0.2"
3501
+ },
3490
3502
  {
3491
3503
  "name": "src",
3492
3504
  "type": "string",
@@ -3610,6 +3622,20 @@
3610
3622
  "type": "boolean",
3611
3623
  "default": "false"
3612
3624
  },
3625
+ {
3626
+ "name": "referenceStrip",
3627
+ "attribute": "reference-strip",
3628
+ "description": "If set, thumbnails of all images are shown in a reference strip at the\nbottom of the viewer.",
3629
+ "type": "boolean",
3630
+ "default": "false"
3631
+ },
3632
+ {
3633
+ "name": "referenceStripSizeRatio",
3634
+ "attribute": "reference-strip-size-ratio",
3635
+ "description": "Size ratio for the reference strip thumbnails. 0.2 by default.",
3636
+ "type": "number",
3637
+ "default": "0.2"
3638
+ },
3613
3639
  {
3614
3640
  "name": "src",
3615
3641
  "attribute": "src",
@@ -10131,10 +10157,16 @@
10131
10157
  "attributes": [
10132
10158
  {
10133
10159
  "name": "key",
10134
- "description": "Configures the annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.",
10160
+ "description": "Configures the default annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.\n\nYou can also define a custom mapping of annotation types to key properties, e.g. if you would\nlike to use @key for some elements, but @corresp for others.",
10135
10161
  "type": "string",
10136
10162
  "default": "\"ref\""
10137
10163
  },
10164
+ {
10165
+ "name": "key-map",
10166
+ "description": "Optional mapping of annotation type names to key properties",
10167
+ "type": "object",
10168
+ "default": "{}"
10169
+ },
10138
10170
  {
10139
10171
  "name": "caseSensitive",
10140
10172
  "description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
@@ -10309,10 +10341,17 @@
10309
10341
  {
10310
10342
  "name": "key",
10311
10343
  "attribute": "key",
10312
- "description": "Configures the annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.",
10344
+ "description": "Configures the default annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.\n\nYou can also define a custom mapping of annotation types to key properties, e.g. if you would\nlike to use @key for some elements, but @corresp for others.",
10313
10345
  "type": "string",
10314
10346
  "default": "\"ref\""
10315
10347
  },
10348
+ {
10349
+ "name": "keyMap",
10350
+ "attribute": "key-map",
10351
+ "description": "Optional mapping of annotation type names to key properties",
10352
+ "type": "object",
10353
+ "default": "{}"
10354
+ },
10316
10355
  {
10317
10356
  "name": "caseSensitive",
10318
10357
  "attribute": "caseSensitive",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "1.35.2",
3
+ "version": "1.36.2",
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",
package/pb-elements.json CHANGED
@@ -3487,6 +3487,18 @@
3487
3487
  "type": "boolean",
3488
3488
  "default": "false"
3489
3489
  },
3490
+ {
3491
+ "name": "reference-strip",
3492
+ "description": "If set, thumbnails of all images are shown in a reference strip at the\nbottom of the viewer.",
3493
+ "type": "boolean",
3494
+ "default": "false"
3495
+ },
3496
+ {
3497
+ "name": "reference-strip-size-ratio",
3498
+ "description": "Size ratio for the reference strip thumbnails. 0.2 by default.",
3499
+ "type": "number",
3500
+ "default": "0.2"
3501
+ },
3490
3502
  {
3491
3503
  "name": "src",
3492
3504
  "type": "string",
@@ -3610,6 +3622,20 @@
3610
3622
  "type": "boolean",
3611
3623
  "default": "false"
3612
3624
  },
3625
+ {
3626
+ "name": "referenceStrip",
3627
+ "attribute": "reference-strip",
3628
+ "description": "If set, thumbnails of all images are shown in a reference strip at the\nbottom of the viewer.",
3629
+ "type": "boolean",
3630
+ "default": "false"
3631
+ },
3632
+ {
3633
+ "name": "referenceStripSizeRatio",
3634
+ "attribute": "reference-strip-size-ratio",
3635
+ "description": "Size ratio for the reference strip thumbnails. 0.2 by default.",
3636
+ "type": "number",
3637
+ "default": "0.2"
3638
+ },
3613
3639
  {
3614
3640
  "name": "src",
3615
3641
  "attribute": "src",
@@ -10131,10 +10157,16 @@
10131
10157
  "attributes": [
10132
10158
  {
10133
10159
  "name": "key",
10134
- "description": "Configures the annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.",
10160
+ "description": "Configures the default annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.\n\nYou can also define a custom mapping of annotation types to key properties, e.g. if you would\nlike to use @key for some elements, but @corresp for others.",
10135
10161
  "type": "string",
10136
10162
  "default": "\"ref\""
10137
10163
  },
10164
+ {
10165
+ "name": "key-map",
10166
+ "description": "Optional mapping of annotation type names to key properties",
10167
+ "type": "object",
10168
+ "default": "{}"
10169
+ },
10138
10170
  {
10139
10171
  "name": "caseSensitive",
10140
10172
  "description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
@@ -10309,10 +10341,17 @@
10309
10341
  {
10310
10342
  "name": "key",
10311
10343
  "attribute": "key",
10312
- "description": "Configures the annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.",
10344
+ "description": "Configures the default annotation property containing the key for authority entries.\nDefault: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when\nusing those attributes instead.\n\nYou can also define a custom mapping of annotation types to key properties, e.g. if you would\nlike to use @key for some elements, but @corresp for others.",
10313
10345
  "type": "string",
10314
10346
  "default": "\"ref\""
10315
10347
  },
10348
+ {
10349
+ "name": "keyMap",
10350
+ "attribute": "key-map",
10351
+ "description": "Optional mapping of annotation type names to key properties",
10352
+ "type": "object",
10353
+ "default": "{}"
10354
+ },
10316
10355
  {
10317
10356
  "name": "caseSensitive",
10318
10357
  "attribute": "caseSensitive",
@@ -11,7 +11,8 @@ export class KBGA extends Registry {
11
11
  const results = [];
12
12
 
13
13
  const register = this.getRegister();
14
- const url = `https://meta.karl-barth.ch/api/${register}?search=${encodeURIComponent(key)}`;
14
+ const searchParam = register === 'bibls' ? 'biblsearch' : 'search';
15
+ const url = `https://meta.karl-barth.ch/api/${register}?${searchParam}=${encodeURIComponent(key)}`;
15
16
  const label = this.getLabelField();
16
17
  return new Promise((resolve) => {
17
18
  fetch(url)
@@ -26,10 +27,10 @@ export class KBGA extends Registry {
26
27
  const result = {
27
28
  register: this._register,
28
29
  id: (this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id']),
29
- label: item[label],
30
+ label: typeof label === "string" ? item[label] : label(item),
30
31
  details: `${item['full-id']}`,
31
32
  link: `https://meta.karl-barth.ch/${register}/${item.id}`,
32
- strings: [item[label]],
33
+ strings: [typeof label === "string" ? item[label] : label(item)],
33
34
  provider: 'KBGA'
34
35
  };
35
36
  results.push(result);
@@ -54,14 +55,14 @@ export class KBGA extends Registry {
54
55
  const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
55
56
  const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
56
57
  const output = `
57
- <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${json.data[label]}</a></h3>
58
+ <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${typeof label === 'string' ? json.data[label] : label(json.data)}</a></h3>
58
59
  ${dates}
59
60
  ${note}
60
61
  `;
61
62
  container.innerHTML = output;
62
63
  resolve({
63
64
  id: json.data['full-id'],
64
- strings: [json.data[label]]
65
+ strings: [typeof label === 'string' ? json.data[label] : label(json.data)]
65
66
  });
66
67
  });
67
68
  });
@@ -112,6 +113,9 @@ export class KBGA extends Registry {
112
113
  case 'abbreviation':
113
114
  label = 'label';
114
115
  break;
116
+ case 'bibl':
117
+ label = 'asHtml';
118
+ break;
115
119
  default:
116
120
  label = 'persName_full';
117
121
  break;
@@ -138,6 +142,9 @@ export class KBGA extends Registry {
138
142
  case 'abbreviation':
139
143
  register = 'abbreviations';
140
144
  break;
145
+ case 'bibl':
146
+ register = 'bibls';
147
+ break;
141
148
  default:
142
149
  register = this._register;
143
150
  }
@@ -1,4 +1,5 @@
1
1
  import { LitElement, html, css } from 'lit-element';
2
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
2
3
  import { pbMixin } from './pb-mixin.js';
3
4
  import { translate } from "./pb-i18n.js";
4
5
  import { createConnectors } from "./authority/connectors.js";
@@ -121,8 +122,9 @@ export class PbAuthorityLookup extends pbMixin(LitElement) {
121
122
  <td>
122
123
  <div>
123
124
  ${item.link
124
- ? html`<a target="_blank" href="${item.link}">${item.label}</a>`
125
- : item.label}
125
+ ? html`<a target="_blank" href="${item.link}">${unsafeHTML(item.label)}</a>`
126
+ : html`${unsafeHTML(item.label)}`
127
+ }
126
128
  </div>
127
129
  ${item.details ? html`<div class="details" part="details">${item.details}</div>` : null}
128
130
  </td>
@@ -85,6 +85,21 @@ export class PbFacsimile extends pbMixin(LitElement) {
85
85
  type: Number,
86
86
  attribute: 'visibility-ratio'
87
87
  },
88
+ /**
89
+ * If set, thumbnails of all images are shown in a reference strip at the
90
+ * bottom of the viewer.
91
+ */
92
+ referenceStrip: {
93
+ type: Boolean,
94
+ attribute: 'reference-strip'
95
+ },
96
+ /**
97
+ * Size ratio for the reference strip thumbnails. 0.2 by default.
98
+ */
99
+ referenceStripSizeRatio: {
100
+ type: Number,
101
+ attribute: 'reference-strip-size-ratio'
102
+ },
88
103
  /**
89
104
  * Type of the source of the image to display: either 'iiif' or 'image'
90
105
  * (for simple image links not served via IIIF).
@@ -134,6 +149,8 @@ export class PbFacsimile extends pbMixin(LitElement) {
134
149
  this.showFullPageControl = false;
135
150
  this.showRotationControl = false;
136
151
  this.constrainDuringPan = false;
152
+ this.referenceStrip = false;
153
+ this.referenceStripSizeRatio = 0.2;
137
154
  this.src = '';
138
155
  this.prefixUrl = '../images/openseadragon/';
139
156
  this.loaded = false;
@@ -197,7 +214,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
197
214
  // Init openseadragon
198
215
  _initOpenSeadragon() {
199
216
  const prefixUrl = resolveURL(this.prefixUrl + (this.prefixUrl.endsWith("/") ? "" : "/"));
200
- this.viewer = OpenSeadragon({
217
+ const options = {
201
218
  element: this.shadowRoot.getElementById('viewer'),
202
219
  prefixUrl,
203
220
  preserveViewport: true,
@@ -213,7 +230,12 @@ export class PbFacsimile extends pbMixin(LitElement) {
213
230
  minZoomLevel: 1,
214
231
  defaultZoomLevel: this.defaultZoomLevel,
215
232
  constrainDuringPan: true
216
- });
233
+ };
234
+ if (this.referenceStrip) {
235
+ options.showReferenceStrip = true;
236
+ options.referenceStripSizeRatio = this.referenceStripSizeRatio;
237
+ }
238
+ this.viewer = OpenSeadragon(options);
217
239
 
218
240
  this.viewer.addHandler('open', () => {
219
241
  this.resetZoom();
@@ -223,13 +223,23 @@ class PbViewAnnotate extends PbView {
223
223
  static get properties() {
224
224
  return {
225
225
  /**
226
- * Configures the annotation property containing the key for authority entries.
226
+ * Configures the default annotation property containing the key for authority entries.
227
227
  * Default: 'ref', corresponding to TEI attribute @ref. Change to 'corresp' or 'key' when
228
228
  * using those attributes instead.
229
+ *
230
+ * You can also define a custom mapping of annotation types to key properties, e.g. if you would
231
+ * like to use @key for some elements, but @corresp for others.
229
232
  */
230
233
  key: {
231
234
  type: String
232
235
  },
236
+ /**
237
+ * Optional mapping of annotation type names to key properties
238
+ */
239
+ keyMap: {
240
+ type: Object,
241
+ attribute: 'key-map'
242
+ },
233
243
  /**
234
244
  * When searching the displayed text for other potential occurrences of an entity,
235
245
  * should the search be done in case-sensitive manner?
@@ -244,6 +254,7 @@ class PbViewAnnotate extends PbView {
244
254
  constructor() {
245
255
  super();
246
256
  this.key = 'ref';
257
+ this.keyMap = {};
247
258
  this.caseSensitive = false;
248
259
  this._ranges = [];
249
260
  this._rangesMap = new Map();
@@ -373,6 +384,10 @@ class PbViewAnnotate extends PbView {
373
384
  window.requestAnimationFrame(() => this.refreshMarkers());
374
385
  }
375
386
 
387
+ getKey(type) {
388
+ return this.keyMap[type] || this.key;
389
+ }
390
+
376
391
  _resizeHandler() {
377
392
  let _pendingCallback = null;
378
393
 
@@ -406,6 +421,7 @@ class PbViewAnnotate extends PbView {
406
421
  this._initAnnotationColors();
407
422
  this._annotationStyles();
408
423
  this.updateAnnotations();
424
+ this._markIncompleteAnnotations();
409
425
  if (this._scrollTop) {
410
426
  this.scrollTop = this._scrollTop;
411
427
  this._scrollTop = undefined;
@@ -459,7 +475,7 @@ class PbViewAnnotate extends PbView {
459
475
 
460
476
  console.log('<pb-view-annotate> Range: %o', range);
461
477
  const span = document.createElement('span');
462
- const addClass = teiRange.properties[this.key] === '' ? 'incomplete' : '';
478
+ const addClass = teiRange.properties[this.getKey(teiRange.type)] === '' ? 'incomplete' : '';
463
479
  span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass}`;
464
480
  span.dataset.type = teiRange.type;
465
481
  span.dataset.annotation = JSON.stringify(teiRange.properties);
@@ -669,7 +685,7 @@ class PbViewAnnotate extends PbView {
669
685
  const jsonOld = JSON.parse(span.dataset.annotation);
670
686
  const json = Object.assign(jsonOld || {}, properties);
671
687
  span.dataset.annotation = JSON.stringify(json);
672
- if (json[this.key] !== '') {
688
+ if (json[this.getKey(span.dataset.type)] !== '') {
673
689
  span.classList.remove('incomplete');
674
690
  }
675
691
  }
@@ -770,10 +786,10 @@ class PbViewAnnotate extends PbView {
770
786
  typeInd.innerHTML = type;
771
787
  typeInd.style.backgroundColor = `var(--pb-annotation-${type})`;
772
788
  typeInd.style.color = `var(${color && color.isLight ? '--pb-color-primary' : '--pb-color-inverse'})`;
773
- if (data[this.key]) {
789
+ if (data[this.getKey(type)]) {
774
790
  this.emitTo('pb-annotation-detail', {
775
791
  type,
776
- id: data[this.key],
792
+ id: data[this.getKey(type)],
777
793
  container: info,
778
794
  span,
779
795
  });
@@ -910,7 +926,7 @@ class PbViewAnnotate extends PbView {
910
926
  if (annoData && annoType) {
911
927
  const parsed = JSON.parse(annoData) || {};
912
928
  isAnnotated = annoType === type;
913
- ref = parsed[this.key];
929
+ ref = parsed[this.getKey(type)];
914
930
  }
915
931
 
916
932
  const startRange = rangeToPoint(node, match.index);
@@ -925,7 +941,7 @@ class PbViewAnnotate extends PbView {
925
941
  textNode: node,
926
942
  kwic: kwicText(str, start + match.index, start + end),
927
943
  };
928
- entry[this.key] = ref;
944
+ entry[this.getKey(type)] = ref;
929
945
  result.push(entry);
930
946
  }
931
947
  }
@@ -973,10 +989,23 @@ class PbViewAnnotate extends PbView {
973
989
  }
974
990
  }
975
991
 
992
+ _markIncompleteAnnotations() {
993
+ const elem = this.shadowRoot.getElementById('view')
994
+ elem.querySelectorAll('.annotation.authority').forEach((annotation) => {
995
+ if (annotation.dataset.type) {
996
+ const data = JSON.parse(annotation.dataset.annotation);
997
+ const key = this.getKey(annotation.dataset.type);
998
+ if (!data[key] || data[key].length === 0) {
999
+ annotation.classList.add('incomplete');
1000
+ }
1001
+ }
1002
+ });
1003
+ }
1004
+
976
1005
  _initAnnotationColors() {
977
1006
  this._annotationColors = new Map();
978
1007
  const types = new Set();
979
- const elem = this.shadowRoot.getElementById('view')
1008
+ const elem = this.shadowRoot.getElementById('view');
980
1009
  elem.querySelectorAll('.annotation').forEach((annotation) => {
981
1010
  if (annotation.dataset.type) {
982
1011
  types.add(annotation.dataset.type);
@@ -1043,7 +1072,7 @@ class PbViewAnnotate extends PbView {
1043
1072
  styles = document.createElement('style');
1044
1073
  styles.className = '_annotation-styles';
1045
1074
  styles.innerHTML = css;
1046
- view.appendChild(styles);
1075
+ view.insertBefore(styles, view.firstChild);
1047
1076
  }
1048
1077
 
1049
1078
  static get styles() {