@teipublisher/pb-components 1.35.1 → 1.36.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 +23 -0
- package/dist/pb-components-bundle.js +31 -31
- package/dist/pb-elements.json +41 -2
- package/package.json +1 -1
- package/pb-elements.json +41 -2
- package/src/authority/kbga.js +12 -5
- package/src/pb-authority-lookup.js +4 -2
- package/src/pb-view-annotate.js +38 -9
- package/src/pb-view.js +21 -3
package/dist/pb-elements.json
CHANGED
|
@@ -10131,10 +10131,16 @@
|
|
|
10131
10131
|
"attributes": [
|
|
10132
10132
|
{
|
|
10133
10133
|
"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.",
|
|
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.",
|
|
10135
10135
|
"type": "string",
|
|
10136
10136
|
"default": "\"ref\""
|
|
10137
10137
|
},
|
|
10138
|
+
{
|
|
10139
|
+
"name": "key-map",
|
|
10140
|
+
"description": "Optional mapping of annotation type names to key properties",
|
|
10141
|
+
"type": "object",
|
|
10142
|
+
"default": "{}"
|
|
10143
|
+
},
|
|
10138
10144
|
{
|
|
10139
10145
|
"name": "caseSensitive",
|
|
10140
10146
|
"description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
|
|
@@ -10259,6 +10265,12 @@
|
|
|
10259
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.",
|
|
10260
10266
|
"type": "string"
|
|
10261
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
|
+
},
|
|
10262
10274
|
{
|
|
10263
10275
|
"name": "static",
|
|
10264
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.",
|
|
@@ -10303,10 +10315,17 @@
|
|
|
10303
10315
|
{
|
|
10304
10316
|
"name": "key",
|
|
10305
10317
|
"attribute": "key",
|
|
10306
|
-
"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.",
|
|
10307
10319
|
"type": "string",
|
|
10308
10320
|
"default": "\"ref\""
|
|
10309
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
|
+
},
|
|
10310
10329
|
{
|
|
10311
10330
|
"name": "caseSensitive",
|
|
10312
10331
|
"attribute": "caseSensitive",
|
|
@@ -10459,6 +10478,13 @@
|
|
|
10459
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.",
|
|
10460
10479
|
"type": "string"
|
|
10461
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
|
+
},
|
|
10462
10488
|
{
|
|
10463
10489
|
"name": "static",
|
|
10464
10490
|
"attribute": "static",
|
|
@@ -10725,6 +10751,12 @@
|
|
|
10725
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.",
|
|
10726
10752
|
"type": "string"
|
|
10727
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
|
+
},
|
|
10728
10760
|
{
|
|
10729
10761
|
"name": "static",
|
|
10730
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.",
|
|
@@ -10908,6 +10940,13 @@
|
|
|
10908
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.",
|
|
10909
10941
|
"type": "string"
|
|
10910
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
|
+
},
|
|
10911
10950
|
{
|
|
10912
10951
|
"name": "static",
|
|
10913
10952
|
"attribute": "static",
|
package/package.json
CHANGED
package/pb-elements.json
CHANGED
|
@@ -10131,10 +10131,16 @@
|
|
|
10131
10131
|
"attributes": [
|
|
10132
10132
|
{
|
|
10133
10133
|
"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.",
|
|
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.",
|
|
10135
10135
|
"type": "string",
|
|
10136
10136
|
"default": "\"ref\""
|
|
10137
10137
|
},
|
|
10138
|
+
{
|
|
10139
|
+
"name": "key-map",
|
|
10140
|
+
"description": "Optional mapping of annotation type names to key properties",
|
|
10141
|
+
"type": "object",
|
|
10142
|
+
"default": "{}"
|
|
10143
|
+
},
|
|
10138
10144
|
{
|
|
10139
10145
|
"name": "caseSensitive",
|
|
10140
10146
|
"description": "When searching the displayed text for other potential occurrences of an entity,\nshould the search be done in case-sensitive manner?",
|
|
@@ -10259,6 +10265,12 @@
|
|
|
10259
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.",
|
|
10260
10266
|
"type": "string"
|
|
10261
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
|
+
},
|
|
10262
10274
|
{
|
|
10263
10275
|
"name": "static",
|
|
10264
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.",
|
|
@@ -10303,10 +10315,17 @@
|
|
|
10303
10315
|
{
|
|
10304
10316
|
"name": "key",
|
|
10305
10317
|
"attribute": "key",
|
|
10306
|
-
"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.",
|
|
10307
10319
|
"type": "string",
|
|
10308
10320
|
"default": "\"ref\""
|
|
10309
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
|
+
},
|
|
10310
10329
|
{
|
|
10311
10330
|
"name": "caseSensitive",
|
|
10312
10331
|
"attribute": "caseSensitive",
|
|
@@ -10459,6 +10478,13 @@
|
|
|
10459
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.",
|
|
10460
10479
|
"type": "string"
|
|
10461
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
|
+
},
|
|
10462
10488
|
{
|
|
10463
10489
|
"name": "static",
|
|
10464
10490
|
"attribute": "static",
|
|
@@ -10725,6 +10751,12 @@
|
|
|
10725
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.",
|
|
10726
10752
|
"type": "string"
|
|
10727
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
|
+
},
|
|
10728
10760
|
{
|
|
10729
10761
|
"name": "static",
|
|
10730
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.",
|
|
@@ -10908,6 +10940,13 @@
|
|
|
10908
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.",
|
|
10909
10941
|
"type": "string"
|
|
10910
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
|
+
},
|
|
10911
10950
|
{
|
|
10912
10951
|
"name": "static",
|
|
10913
10952
|
"attribute": "static",
|
package/src/authority/kbga.js
CHANGED
|
@@ -11,7 +11,8 @@ export class KBGA extends Registry {
|
|
|
11
11
|
const results = [];
|
|
12
12
|
|
|
13
13
|
const register = this.getRegister();
|
|
14
|
-
const
|
|
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>
|
package/src/pb-view-annotate.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
789
|
+
if (data[this.getKey(type)]) {
|
|
774
790
|
this.emitTo('pb-annotation-detail', {
|
|
775
791
|
type,
|
|
776
|
-
id: data[this.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
889
|
+
window.requestAnimationFrame(() =>
|
|
890
|
+
setTimeout(() => {
|
|
891
|
+
target.scrollIntoView({block: 'nearest'});
|
|
892
|
+
}, 400)
|
|
893
|
+
);
|
|
876
894
|
}
|
|
877
895
|
}
|
|
878
896
|
}
|