@teipublisher/pb-components 1.35.0 → 1.36.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.
@@ -8284,6 +8284,11 @@
8284
8284
  "type": "string",
8285
8285
  "default": "\"search.placeholder\""
8286
8286
  },
8287
+ {
8288
+ "name": "disable-autocomplete",
8289
+ "type": "boolean",
8290
+ "default": "false"
8291
+ },
8287
8292
  {
8288
8293
  "name": "subscribe",
8289
8294
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -8356,6 +8361,12 @@
8356
8361
  "type": "string",
8357
8362
  "default": "\"search.placeholder\""
8358
8363
  },
8364
+ {
8365
+ "name": "disableAutocomplete",
8366
+ "attribute": "disable-autocomplete",
8367
+ "type": "boolean",
8368
+ "default": "false"
8369
+ },
8359
8370
  {
8360
8371
  "name": "subscribe",
8361
8372
  "attribute": "subscribe",
@@ -10120,10 +10131,16 @@
10120
10131
  "attributes": [
10121
10132
  {
10122
10133
  "name": "key",
10123
- "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.",
10134
+ "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.",
10124
10135
  "type": "string",
10125
10136
  "default": "\"ref\""
10126
10137
  },
10138
+ {
10139
+ "name": "key-map",
10140
+ "description": "Optional mapping of annotation type names to key properties",
10141
+ "type": "object",
10142
+ "default": "{}"
10143
+ },
10127
10144
  {
10128
10145
  "name": "caseSensitive",
10129
10146
  "description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
@@ -10248,6 +10265,12 @@
10248
10265
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10249
10266
  "type": "string"
10250
10267
  },
10268
+ {
10269
+ "name": "no-scroll",
10270
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10271
+ "type": "boolean",
10272
+ "default": "false"
10273
+ },
10251
10274
  {
10252
10275
  "name": "static",
10253
10276
  "description": "If set, rewrite URLs to load pages as static HTML files,\nso no TEI Publisher instance is required. Use this in combination with\n[tei-publisher-static](https://github.com/eeditiones/tei-publisher-static).\nThe value should point to the HTTP root path under which the static version\nwill be hosted. This is used to resolve CSS stylesheets.",
@@ -10292,10 +10315,17 @@
10292
10315
  {
10293
10316
  "name": "key",
10294
10317
  "attribute": "key",
10295
- "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.",
10318
+ "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.",
10296
10319
  "type": "string",
10297
10320
  "default": "\"ref\""
10298
10321
  },
10322
+ {
10323
+ "name": "keyMap",
10324
+ "attribute": "key-map",
10325
+ "description": "Optional mapping of annotation type names to key properties",
10326
+ "type": "object",
10327
+ "default": "{}"
10328
+ },
10299
10329
  {
10300
10330
  "name": "caseSensitive",
10301
10331
  "attribute": "caseSensitive",
@@ -10448,6 +10478,13 @@
10448
10478
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10449
10479
  "type": "string"
10450
10480
  },
10481
+ {
10482
+ "name": "noScroll",
10483
+ "attribute": "no-scroll",
10484
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10485
+ "type": "boolean",
10486
+ "default": "false"
10487
+ },
10451
10488
  {
10452
10489
  "name": "static",
10453
10490
  "attribute": "static",
@@ -10714,6 +10751,12 @@
10714
10751
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10715
10752
  "type": "string"
10716
10753
  },
10754
+ {
10755
+ "name": "no-scroll",
10756
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10757
+ "type": "boolean",
10758
+ "default": "false"
10759
+ },
10717
10760
  {
10718
10761
  "name": "static",
10719
10762
  "description": "If set, rewrite URLs to load pages as static HTML files,\nso no TEI Publisher instance is required. Use this in combination with\n[tei-publisher-static](https://github.com/eeditiones/tei-publisher-static).\nThe value should point to the HTTP root path under which the static version\nwill be hosted. This is used to resolve CSS stylesheets.",
@@ -10897,6 +10940,13 @@
10897
10940
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10898
10941
  "type": "string"
10899
10942
  },
10943
+ {
10944
+ "name": "noScroll",
10945
+ "attribute": "no-scroll",
10946
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10947
+ "type": "boolean",
10948
+ "default": "false"
10949
+ },
10900
10950
  {
10901
10951
  "name": "static",
10902
10952
  "attribute": "static",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
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
@@ -8284,6 +8284,11 @@
8284
8284
  "type": "string",
8285
8285
  "default": "\"search.placeholder\""
8286
8286
  },
8287
+ {
8288
+ "name": "disable-autocomplete",
8289
+ "type": "boolean",
8290
+ "default": "false"
8291
+ },
8287
8292
  {
8288
8293
  "name": "subscribe",
8289
8294
  "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
@@ -8356,6 +8361,12 @@
8356
8361
  "type": "string",
8357
8362
  "default": "\"search.placeholder\""
8358
8363
  },
8364
+ {
8365
+ "name": "disableAutocomplete",
8366
+ "attribute": "disable-autocomplete",
8367
+ "type": "boolean",
8368
+ "default": "false"
8369
+ },
8359
8370
  {
8360
8371
  "name": "subscribe",
8361
8372
  "attribute": "subscribe",
@@ -10120,10 +10131,16 @@
10120
10131
  "attributes": [
10121
10132
  {
10122
10133
  "name": "key",
10123
- "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.",
10134
+ "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.",
10124
10135
  "type": "string",
10125
10136
  "default": "\"ref\""
10126
10137
  },
10138
+ {
10139
+ "name": "key-map",
10140
+ "description": "Optional mapping of annotation type names to key properties",
10141
+ "type": "object",
10142
+ "default": "{}"
10143
+ },
10127
10144
  {
10128
10145
  "name": "caseSensitive",
10129
10146
  "description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
@@ -10248,6 +10265,12 @@
10248
10265
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10249
10266
  "type": "string"
10250
10267
  },
10268
+ {
10269
+ "name": "no-scroll",
10270
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10271
+ "type": "boolean",
10272
+ "default": "false"
10273
+ },
10251
10274
  {
10252
10275
  "name": "static",
10253
10276
  "description": "If set, rewrite URLs to load pages as static HTML files,\nso no TEI Publisher instance is required. Use this in combination with\n[tei-publisher-static](https://github.com/eeditiones/tei-publisher-static).\nThe value should point to the HTTP root path under which the static version\nwill be hosted. This is used to resolve CSS stylesheets.",
@@ -10292,10 +10315,17 @@
10292
10315
  {
10293
10316
  "name": "key",
10294
10317
  "attribute": "key",
10295
- "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.",
10318
+ "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.",
10296
10319
  "type": "string",
10297
10320
  "default": "\"ref\""
10298
10321
  },
10322
+ {
10323
+ "name": "keyMap",
10324
+ "attribute": "key-map",
10325
+ "description": "Optional mapping of annotation type names to key properties",
10326
+ "type": "object",
10327
+ "default": "{}"
10328
+ },
10299
10329
  {
10300
10330
  "name": "caseSensitive",
10301
10331
  "attribute": "caseSensitive",
@@ -10448,6 +10478,13 @@
10448
10478
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10449
10479
  "type": "string"
10450
10480
  },
10481
+ {
10482
+ "name": "noScroll",
10483
+ "attribute": "no-scroll",
10484
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10485
+ "type": "boolean",
10486
+ "default": "false"
10487
+ },
10451
10488
  {
10452
10489
  "name": "static",
10453
10490
  "attribute": "static",
@@ -10714,6 +10751,12 @@
10714
10751
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10715
10752
  "type": "string"
10716
10753
  },
10754
+ {
10755
+ "name": "no-scroll",
10756
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10757
+ "type": "boolean",
10758
+ "default": "false"
10759
+ },
10717
10760
  {
10718
10761
  "name": "static",
10719
10762
  "description": "If set, rewrite URLs to load pages as static HTML files,\nso no TEI Publisher instance is required. Use this in combination with\n[tei-publisher-static](https://github.com/eeditiones/tei-publisher-static).\nThe value should point to the HTTP root path under which the static version\nwill be hosted. This is used to resolve CSS stylesheets.",
@@ -10897,6 +10940,13 @@
10897
10940
  "description": "If set to the name of an event, the content of the pb-view will not be replaced\nimmediately upon updates. Instead, an event is emitted, which contains the new content\nin property `root`. An event handler intercepting the event can thus modify the content.\nOnce it is done, it should pass the modified content to the callback function provided\nin the event detail under the name `render`. See the demo for an example.",
10898
10941
  "type": "string"
10899
10942
  },
10943
+ {
10944
+ "name": "noScroll",
10945
+ "attribute": "no-scroll",
10946
+ "description": "If set, do not scroll the view to target node (e.g. given in URL hash) \nafter content was loaded.",
10947
+ "type": "boolean",
10948
+ "default": "false"
10949
+ },
10900
10950
  {
10901
10951
  "name": "static",
10902
10952
  "attribute": "static",
@@ -11,8 +11,10 @@ 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();
17
+ console.log(label);
16
18
  return new Promise((resolve) => {
17
19
  fetch(url)
18
20
  .then(response => response.json())
@@ -26,10 +28,10 @@ export class KBGA extends Registry {
26
28
  const result = {
27
29
  register: this._register,
28
30
  id: (this._prefix ? `${this._prefix}:${item['full-id']}` : item['full-id']),
29
- label: item[label],
31
+ label: typeof label === "string" ? item[label] : label(item),
30
32
  details: `${item['full-id']}`,
31
33
  link: `https://meta.karl-barth.ch/${register}/${item.id}`,
32
- strings: [item[label]],
34
+ strings: [typeof label === "string" ? item[label] : label(item)],
33
35
  provider: 'KBGA'
34
36
  };
35
37
  results.push(result);
@@ -54,7 +56,7 @@ export class KBGA extends Registry {
54
56
  const dates = json.data.birth ? `<p>* ${json.data.birth} ${died}</p>` : '';
55
57
  const note = json.data.note_bio ? `<p>${json.data.note_bio}</p>` : '';
56
58
  const output = `
57
- <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${json.data[label]}</a></h3>
59
+ <h3 class="label"><a href="https://${json.wikipediaURL}" target="_blank">${typeof label === 'string' ? json.data[label] : label(json.data)}</a></h3>
58
60
  ${dates}
59
61
  ${note}
60
62
  `;
@@ -112,6 +114,9 @@ export class KBGA extends Registry {
112
114
  case 'abbreviation':
113
115
  label = 'label';
114
116
  break;
117
+ case 'bibl':
118
+ label = (data) => data.title.m || data.title.s;
119
+ break;
115
120
  default:
116
121
  label = 'persName_full';
117
122
  break;
@@ -138,6 +143,9 @@ export class KBGA extends Registry {
138
143
  case 'abbreviation':
139
144
  register = 'abbreviations';
140
145
  break;
146
+ case 'bibl':
147
+ register = 'bibls';
148
+ break;
141
149
  default:
142
150
  register = this._register;
143
151
  }
package/src/pb-search.js CHANGED
@@ -51,6 +51,10 @@ export class PbSearch extends pbMixin(LitElement) {
51
51
  },
52
52
  subforms: {
53
53
  type: String
54
+ },
55
+ disableAutocomplete: {
56
+ type: Boolean,
57
+ attribute: 'disable-autocomplete'
54
58
  }
55
59
  };
56
60
  }
@@ -61,6 +65,7 @@ export class PbSearch extends pbMixin(LitElement) {
61
65
  this.redirect = false;
62
66
  this.submitOnLoad = false;
63
67
  this.placeHolder = 'search.placeholder';
68
+ this.disableAutocomplete = false;
64
69
  }
65
70
 
66
71
  connectedCallback() {
@@ -70,8 +75,10 @@ export class PbSearch extends pbMixin(LitElement) {
70
75
  }
71
76
 
72
77
  firstUpdated() {
73
- const autocomplete = this.shadowRoot.getElementById('autocomplete');
74
- autocomplete.addEventListener('autocomplete-change', this._autocomplete.bind(this));
78
+ if (!this.disableAutocomplete) {
79
+ const autocomplete = this.shadowRoot.getElementById('autocomplete');
80
+ autocomplete.addEventListener('autocomplete-change', this._autocomplete.bind(this));
81
+ }
75
82
  const ironform = this.shadowRoot.getElementById('ironform');
76
83
  ironform.addEventListener('iron-form-response', (event) =>
77
84
  event.detail.completes.then((r) => this.emitTo('pb-search', r.parseResponse()))
@@ -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() {
package/src/pb-view.js CHANGED
@@ -294,6 +294,14 @@ export class PbView extends pbMixin(LitElement) {
294
294
  type: String,
295
295
  attribute: 'before-update-event'
296
296
  },
297
+ /**
298
+ * If set, do not scroll the view to target node (e.g. given in URL hash)
299
+ * after content was loaded.
300
+ */
301
+ noScroll: {
302
+ type: Boolean,
303
+ attribute: 'no-scroll'
304
+ },
297
305
  _features: {
298
306
  type: Object
299
307
  },
@@ -335,6 +343,7 @@ export class PbView extends pbMixin(LitElement) {
335
343
  this.infiniteScrollMax = 10;
336
344
  this.disableHistory = false;
337
345
  this.beforeUpdate = null;
346
+ this.noScroll = false;
338
347
  this._features = {};
339
348
  this._selector = new Map();
340
349
  this._chunks = [];
@@ -520,7 +529,7 @@ export class PbView extends pbMixin(LitElement) {
520
529
 
521
530
  _refresh(ev) {
522
531
  if (ev && ev.detail) {
523
- if (ev.detail.hash && !(ev.detail.id || ev.detail.path || ev.detail.odd || ev.detail.view || ev.detail.position)) {
532
+ if (ev.detail.hash && !this.noScroll && !(ev.detail.id || ev.detail.path || ev.detail.odd || ev.detail.view || ev.detail.position)) {
524
533
  // if only the scroll target has changed: scroll to the element without reloading
525
534
  this._scrollTarget = ev.detail.hash;
526
535
  const target = this.shadowRoot.getElementById(this._scrollTarget);
@@ -551,7 +560,9 @@ export class PbView extends pbMixin(LitElement) {
551
560
  } else {
552
561
  this.nodeId = ev.detail.position || this.nodeId;
553
562
  }
554
- this._scrollTarget = ev.detail.hash;
563
+ if (!this.noScroll) {
564
+ this._scrollTarget = ev.detail.hash;
565
+ }
555
566
  }
556
567
  this._updateStyles();
557
568
  if (this.infiniteScroll) {
@@ -867,12 +878,19 @@ export class PbView extends pbMixin(LitElement) {
867
878
  }
868
879
 
869
880
  _scroll() {
881
+ if (this.noScroll) {
882
+ return;
883
+ }
870
884
  const { hash } = this.getUrl();
871
885
  if (hash) {
872
886
  const target = this.shadowRoot.getElementById(hash.substring(1));
873
887
  console.log('hash target: %o', target);
874
888
  if (target) {
875
- target.scrollIntoView({ block: "center", inline: "nearest" });
889
+ window.requestAnimationFrame(() =>
890
+ setTimeout(() => {
891
+ target.scrollIntoView({block: 'nearest'});
892
+ }, 400)
893
+ );
876
894
  }
877
895
  }
878
896
  }