@teipublisher/pb-components 2.26.0-next-3.12 → 2.26.0-next-3.13
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/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +3 -3
- package/CHANGELOG.md +30 -0
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +58 -54
- package/dist/pb-components-bundle.js +1937 -1782
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +45 -45
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +923 -756
- package/dist/pb-tify.js +2 -2
- package/dist/{vaadin-element-mixin-49ab4037.js → vaadin-element-mixin-84fb7d82.js} +178 -163
- package/gh-pages.js +5 -3
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +1 -1
- package/package.json +2 -2
- package/pb-elements.json +45 -45
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +47 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +150 -146
- package/src/pb-authority-lookup.js +183 -146
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +212 -207
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-custom-form.js +151 -149
- package/src/pb-dialog.js +94 -85
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +210 -198
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +98 -96
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +411 -413
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +132 -128
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -426
- package/src/pb-login.js +291 -248
- package/src/pb-manage-odds.js +364 -318
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +144 -144
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -82
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1053 -955
- package/src/pb-odd-elementspec-editor.js +348 -297
- package/src/pb-odd-model-editor.js +1061 -901
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -421
- package/src/pb-paginate.js +202 -190
- package/src/pb-panel.js +191 -179
- package/src/pb-popover-themes.js +7 -5
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +252 -241
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +271 -229
- package/src/pb-toggle-feature.js +182 -175
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +132 -98
- package/src/pb-view.js +1289 -1270
- package/src/pb-zoom.js +75 -59
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +96 -96
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
package/src/pb-view-annotate.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '@polymer/paper-icon-button';
|
|
2
|
-
import { css, html } from
|
|
2
|
+
import { css, html } from 'lit-element';
|
|
3
3
|
import tippy from 'tippy.js';
|
|
4
|
-
import uniqolor from
|
|
5
|
-
import { PbView } from
|
|
6
|
-
import { loadTippyStyles } from
|
|
4
|
+
import uniqolor from 'uniqolor/src/index';
|
|
5
|
+
import { PbView } from './pb-view.js';
|
|
6
|
+
import { loadTippyStyles } from './pb-popover.js';
|
|
7
7
|
import { get as i18n } from './pb-i18n.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -79,7 +79,10 @@ function rangeToPoint(node, offset, position = 'start') {
|
|
|
79
79
|
const child = container.childNodes[offset];
|
|
80
80
|
return {
|
|
81
81
|
parent: container.getAttribute('data-tei'),
|
|
82
|
-
offset:
|
|
82
|
+
offset:
|
|
83
|
+
position === 'end'
|
|
84
|
+
? absoluteOffset(container, child, 0) - 1
|
|
85
|
+
: absoluteOffset(container, child, 0),
|
|
83
86
|
};
|
|
84
87
|
}
|
|
85
88
|
const container = /** @type {Element} */ (node.parentNode).closest('[data-tei]');
|
|
@@ -88,9 +91,8 @@ function rangeToPoint(node, offset, position = 'start') {
|
|
|
88
91
|
parent: container.getAttribute('data-tei'),
|
|
89
92
|
offset: absoluteOffset(container, node, offset),
|
|
90
93
|
};
|
|
91
|
-
} else {
|
|
92
|
-
console.error('No container with data-tei found for %o', node.parentNode);
|
|
93
94
|
}
|
|
95
|
+
console.error('No container with data-tei found for %o', node.parentNode);
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
function ancestors(node, selector) {
|
|
@@ -173,7 +175,10 @@ function kwicText(str, start, end, words = 3) {
|
|
|
173
175
|
}
|
|
174
176
|
p1 += 1;
|
|
175
177
|
}
|
|
176
|
-
return `... ${str.substring(p0, start)}<mark>${str.substring(start, end)}</mark>${str.substring(
|
|
178
|
+
return `... ${str.substring(p0, start)}<mark>${str.substring(start, end)}</mark>${str.substring(
|
|
179
|
+
end,
|
|
180
|
+
p1 + 1,
|
|
181
|
+
)} ...`;
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
function collectText(node) {
|
|
@@ -197,7 +202,7 @@ function collectText(node) {
|
|
|
197
202
|
|
|
198
203
|
function clearProperties(teiRange) {
|
|
199
204
|
const cleaned = {};
|
|
200
|
-
Object.keys(teiRange.properties).forEach(
|
|
205
|
+
Object.keys(teiRange.properties).forEach(key => {
|
|
201
206
|
const val = teiRange.properties[key];
|
|
202
207
|
if (val && val.length > 0) {
|
|
203
208
|
cleaned[key] = val;
|
|
@@ -234,21 +239,21 @@ class PbViewAnnotate extends PbView {
|
|
|
234
239
|
* like to use @key for some elements, but @corresp for others.
|
|
235
240
|
*/
|
|
236
241
|
key: {
|
|
237
|
-
type: String
|
|
242
|
+
type: String,
|
|
238
243
|
},
|
|
239
244
|
/**
|
|
240
245
|
* Optional mapping of annotation type names to key properties
|
|
241
246
|
*/
|
|
242
247
|
keyMap: {
|
|
243
248
|
type: Object,
|
|
244
|
-
attribute: 'key-map'
|
|
249
|
+
attribute: 'key-map',
|
|
245
250
|
},
|
|
246
251
|
/**
|
|
247
252
|
* When searching the displayed text for other potential occurrences of an entity,
|
|
248
253
|
* should the search be done in case-sensitive manner?
|
|
249
254
|
*/
|
|
250
255
|
caseSensitive: {
|
|
251
|
-
type: Boolean
|
|
256
|
+
type: Boolean,
|
|
252
257
|
},
|
|
253
258
|
...super.properties,
|
|
254
259
|
};
|
|
@@ -332,8 +337,12 @@ class PbViewAnnotate extends PbView {
|
|
|
332
337
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges, refresh: true });
|
|
333
338
|
});
|
|
334
339
|
|
|
335
|
-
this.addEventListener('pb-disable', () => {
|
|
336
|
-
|
|
340
|
+
this.addEventListener('pb-disable', () => {
|
|
341
|
+
this._disabled = true;
|
|
342
|
+
});
|
|
343
|
+
this.addEventListener('pb-enable', () => {
|
|
344
|
+
this._disabled = false;
|
|
345
|
+
});
|
|
337
346
|
|
|
338
347
|
this._resizeHandler();
|
|
339
348
|
}
|
|
@@ -428,17 +437,19 @@ class PbViewAnnotate extends PbView {
|
|
|
428
437
|
|
|
429
438
|
_handleContent() {
|
|
430
439
|
super._handleContent();
|
|
431
|
-
this.updateComplete.then(() =>
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
440
|
+
this.updateComplete.then(() =>
|
|
441
|
+
setTimeout(() => {
|
|
442
|
+
this._initAnnotationColors();
|
|
443
|
+
this._annotationStyles();
|
|
444
|
+
this.updateAnnotations();
|
|
445
|
+
this._markIncompleteAnnotations();
|
|
446
|
+
if (this._scrollTop) {
|
|
447
|
+
this.scrollTop = this._scrollTop;
|
|
448
|
+
this._scrollTop = undefined;
|
|
449
|
+
}
|
|
450
|
+
this.emitTo('pb-annotations-loaded');
|
|
451
|
+
}, 300),
|
|
452
|
+
);
|
|
442
453
|
}
|
|
443
454
|
|
|
444
455
|
_updateAnnotation(teiRange, silent = false, batch = false) {
|
|
@@ -488,7 +499,9 @@ class PbViewAnnotate extends PbView {
|
|
|
488
499
|
console.log('<pb-view-annotate> Range: %o', range);
|
|
489
500
|
const span = document.createElement('span');
|
|
490
501
|
const addClass = teiRange.properties[this.getKey(teiRange.type)] === '' ? 'incomplete' : '';
|
|
491
|
-
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
502
|
+
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
503
|
+
teiRange.before ? 'before' : ''
|
|
504
|
+
}`;
|
|
492
505
|
span.dataset.type = teiRange.type;
|
|
493
506
|
span.dataset.annotation = JSON.stringify(teiRange.properties);
|
|
494
507
|
|
|
@@ -498,7 +511,9 @@ class PbViewAnnotate extends PbView {
|
|
|
498
511
|
if (silent) {
|
|
499
512
|
return null;
|
|
500
513
|
}
|
|
501
|
-
throw new Error(
|
|
514
|
+
throw new Error(
|
|
515
|
+
'An error occurred. The annotation may not be displayed. You should consider saving and reloading the document.',
|
|
516
|
+
);
|
|
502
517
|
}
|
|
503
518
|
this._rangesMap.set(span, teiRange);
|
|
504
519
|
|
|
@@ -510,7 +525,7 @@ class PbViewAnnotate extends PbView {
|
|
|
510
525
|
}
|
|
511
526
|
|
|
512
527
|
updateAnnotations(silent = false) {
|
|
513
|
-
this._ranges.forEach(
|
|
528
|
+
this._ranges.forEach(teiRange => {
|
|
514
529
|
let span;
|
|
515
530
|
switch (teiRange.type) {
|
|
516
531
|
case 'delete':
|
|
@@ -538,9 +553,7 @@ class PbViewAnnotate extends PbView {
|
|
|
538
553
|
}
|
|
539
554
|
|
|
540
555
|
_getSelection() {
|
|
541
|
-
return this.shadowRoot.getSelection
|
|
542
|
-
? this.shadowRoot.getSelection()
|
|
543
|
-
: window.getSelection();
|
|
556
|
+
return this.shadowRoot.getSelection ? this.shadowRoot.getSelection() : window.getSelection();
|
|
544
557
|
}
|
|
545
558
|
|
|
546
559
|
_selectionChanged() {
|
|
@@ -579,7 +592,11 @@ class PbViewAnnotate extends PbView {
|
|
|
579
592
|
}
|
|
580
593
|
}, 100);
|
|
581
594
|
}
|
|
582
|
-
this.emitTo('pb-selection-changed', {
|
|
595
|
+
this.emitTo('pb-selection-changed', {
|
|
596
|
+
hasContent: true,
|
|
597
|
+
range,
|
|
598
|
+
selected: selection.toString(),
|
|
599
|
+
});
|
|
583
600
|
} else {
|
|
584
601
|
this._clearSelection();
|
|
585
602
|
this.emitTo('pb-selection-changed', { hasContent: false });
|
|
@@ -608,7 +625,7 @@ class PbViewAnnotate extends PbView {
|
|
|
608
625
|
|
|
609
626
|
_clearSelection() {
|
|
610
627
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
611
|
-
markerLayer.querySelectorAll('.selection-marker').forEach(
|
|
628
|
+
markerLayer.querySelectorAll('.selection-marker').forEach(oldMarker => {
|
|
612
629
|
markerLayer.removeChild(oldMarker);
|
|
613
630
|
});
|
|
614
631
|
}
|
|
@@ -636,10 +653,10 @@ class PbViewAnnotate extends PbView {
|
|
|
636
653
|
const endRange = rangeToPoint(range.endContainer, range.endOffset, 'end');
|
|
637
654
|
const adjustedRange = {
|
|
638
655
|
context: startRange.parent,
|
|
639
|
-
start:
|
|
640
|
-
end:
|
|
656
|
+
start: info.position === 'after' ? endRange.offset : startRange.offset,
|
|
657
|
+
end: info === undefined || info.position === 'before' ? startRange.offset : endRange.offset,
|
|
641
658
|
text: info.before ? '' : range.cloneContents().textContent,
|
|
642
|
-
before: info.before
|
|
659
|
+
before: info.before,
|
|
643
660
|
};
|
|
644
661
|
if (info.type) {
|
|
645
662
|
adjustedRange.type = info.type;
|
|
@@ -710,7 +727,7 @@ class PbViewAnnotate extends PbView {
|
|
|
710
727
|
const selection = this._getSelection();
|
|
711
728
|
selection.removeAllRanges();
|
|
712
729
|
selection.addRange(newRange);
|
|
713
|
-
} catch(e) {
|
|
730
|
+
} catch (e) {
|
|
714
731
|
console.error('<pb-view-annotate> %s', e.message);
|
|
715
732
|
} finally {
|
|
716
733
|
this._inHandler = false;
|
|
@@ -734,14 +751,14 @@ class PbViewAnnotate extends PbView {
|
|
|
734
751
|
range = clearProperties(range);
|
|
735
752
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges });
|
|
736
753
|
} else {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
754
|
+
let range = this._rangesMap.get(span);
|
|
755
|
+
if (range) {
|
|
756
|
+
range.properties = properties;
|
|
757
|
+
range = clearProperties(range);
|
|
758
|
+
this.emitTo('pb-annotations-changed', { ranges: this._ranges });
|
|
759
|
+
} else {
|
|
760
|
+
console.error('no range found for edit span %o', span);
|
|
761
|
+
}
|
|
745
762
|
}
|
|
746
763
|
const jsonOld = JSON.parse(span.dataset.annotation);
|
|
747
764
|
const json = Object.assign(jsonOld || {}, properties);
|
|
@@ -804,7 +821,12 @@ class PbViewAnnotate extends PbView {
|
|
|
804
821
|
editBtn.addEventListener('click', () => {
|
|
805
822
|
const data = JSON.parse(span.dataset.annotation);
|
|
806
823
|
const text = span.textContent;
|
|
807
|
-
this.emitTo('pb-annotation-edit',
|
|
824
|
+
this.emitTo('pb-annotation-edit', {
|
|
825
|
+
target: span,
|
|
826
|
+
type: span.dataset.type,
|
|
827
|
+
properties: data,
|
|
828
|
+
text,
|
|
829
|
+
});
|
|
808
830
|
});
|
|
809
831
|
div.appendChild(editBtn);
|
|
810
832
|
}
|
|
@@ -842,19 +864,21 @@ class PbViewAnnotate extends PbView {
|
|
|
842
864
|
onTrigger: (instance, ev) => {
|
|
843
865
|
ev.preventDefault();
|
|
844
866
|
ev.stopPropagation();
|
|
845
|
-
const type = span.dataset
|
|
867
|
+
const { type } = span.dataset;
|
|
846
868
|
const data = JSON.parse(span.dataset.annotation) || {};
|
|
847
869
|
const color = this._annotationColors.get(type);
|
|
848
870
|
typeInd.innerHTML = type;
|
|
849
871
|
typeInd.style.backgroundColor = `var(--pb-annotation-${type})`;
|
|
850
|
-
typeInd.style.color = `var(${
|
|
872
|
+
typeInd.style.color = `var(${
|
|
873
|
+
color && color.isLight ? '--pb-color-primary' : '--pb-color-inverse'
|
|
874
|
+
})`;
|
|
851
875
|
if (data[this.getKey(type)]) {
|
|
852
876
|
this.emitTo('pb-annotation-detail', {
|
|
853
877
|
type,
|
|
854
878
|
id: data[this.getKey(type)],
|
|
855
879
|
container: info,
|
|
856
880
|
span,
|
|
857
|
-
ready: () => instance.setContent(wrapper)
|
|
881
|
+
ready: () => instance.setContent(wrapper),
|
|
858
882
|
});
|
|
859
883
|
} else {
|
|
860
884
|
// show properties as key/value table
|
|
@@ -866,7 +890,7 @@ class PbViewAnnotate extends PbView {
|
|
|
866
890
|
info.appendChild(p);
|
|
867
891
|
} else {
|
|
868
892
|
const table = document.createElement('table');
|
|
869
|
-
keys.forEach(
|
|
893
|
+
keys.forEach(key => {
|
|
870
894
|
const tr = document.createElement('tr');
|
|
871
895
|
const tdKey = document.createElement('td');
|
|
872
896
|
tdKey.innerHTML = key;
|
|
@@ -882,7 +906,7 @@ class PbViewAnnotate extends PbView {
|
|
|
882
906
|
},
|
|
883
907
|
onClickOutside: (instance, ev) => {
|
|
884
908
|
instance.hideWithInteractivity(ev);
|
|
885
|
-
}
|
|
909
|
+
},
|
|
886
910
|
});
|
|
887
911
|
}
|
|
888
912
|
|
|
@@ -895,7 +919,7 @@ class PbViewAnnotate extends PbView {
|
|
|
895
919
|
*/
|
|
896
920
|
_showMarker(span, root, rootRect, margin = 0) {
|
|
897
921
|
const rects = span.getClientRects();
|
|
898
|
-
const type = span.dataset
|
|
922
|
+
const { type } = span.dataset;
|
|
899
923
|
if (!span.classList.contains('before')) {
|
|
900
924
|
for (let i = 0; i < rects.length; i++) {
|
|
901
925
|
const rect = rects[i];
|
|
@@ -932,20 +956,18 @@ class PbViewAnnotate extends PbView {
|
|
|
932
956
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
933
957
|
markerLayer.style.display = 'none';
|
|
934
958
|
this._clearMarkers();
|
|
935
|
-
root.querySelectorAll('.annotation')
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
markerLayer.style.display = 'block';
|
|
959
|
+
root.querySelectorAll('.annotation').forEach(span => {
|
|
960
|
+
if (span._tippy) {
|
|
961
|
+
span._tippy.destroy();
|
|
962
|
+
}
|
|
963
|
+
this._showMarker(span, markerLayer, rootRect, ancestors(span, 'annotation') * 5);
|
|
964
|
+
});
|
|
965
|
+
markerLayer.style.display = 'block';
|
|
943
966
|
}
|
|
944
967
|
|
|
945
968
|
search(type, tokens) {
|
|
946
969
|
function escape(token) {
|
|
947
|
-
let regex = token.replace(/[/.?+*\\]/g,
|
|
948
|
-
.replace(/[\s\n\t]+/g, '\\s+');
|
|
970
|
+
let regex = token.replace(/[/.?+*\\]/g, m => `\\${m}`).replace(/[\s\n\t]+/g, '\\s+');
|
|
949
971
|
if (/^\w/.test(regex)) {
|
|
950
972
|
regex = `\\b${regex}`;
|
|
951
973
|
}
|
|
@@ -969,7 +991,8 @@ class PbViewAnnotate extends PbView {
|
|
|
969
991
|
if (!tokens || tokens.length === 0) {
|
|
970
992
|
return result;
|
|
971
993
|
}
|
|
972
|
-
const expr = tokens
|
|
994
|
+
const expr = tokens
|
|
995
|
+
.filter(token => token && token.length > 0)
|
|
973
996
|
.map(token => escape(token))
|
|
974
997
|
.join('|');
|
|
975
998
|
console.log(`<pb-view-annotate> Searching content for ${expr}...`);
|
|
@@ -980,7 +1003,7 @@ class PbViewAnnotate extends PbView {
|
|
|
980
1003
|
filter,
|
|
981
1004
|
);
|
|
982
1005
|
while (walker.nextNode()) {
|
|
983
|
-
|
|
1006
|
+
const node = walker.currentNode;
|
|
984
1007
|
const matches = Array.from(node.textContent.matchAll(regex));
|
|
985
1008
|
for (const match of matches) {
|
|
986
1009
|
const end = match.index + match[0].length;
|
|
@@ -1055,8 +1078,8 @@ class PbViewAnnotate extends PbView {
|
|
|
1055
1078
|
}
|
|
1056
1079
|
|
|
1057
1080
|
_markIncompleteAnnotations() {
|
|
1058
|
-
const elem = this.shadowRoot.getElementById('view')
|
|
1059
|
-
elem.querySelectorAll('.annotation.authority').forEach(
|
|
1081
|
+
const elem = this.shadowRoot.getElementById('view');
|
|
1082
|
+
elem.querySelectorAll('.annotation.authority').forEach(annotation => {
|
|
1060
1083
|
if (annotation.dataset.type) {
|
|
1061
1084
|
const data = JSON.parse(annotation.dataset.annotation);
|
|
1062
1085
|
const key = this.getKey(annotation.dataset.type);
|
|
@@ -1073,16 +1096,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1073
1096
|
this._annotationColors = new Map();
|
|
1074
1097
|
const types = new Set();
|
|
1075
1098
|
const elem = this.shadowRoot.getElementById('view');
|
|
1076
|
-
elem.querySelectorAll('.annotation').forEach(
|
|
1099
|
+
elem.querySelectorAll('.annotation').forEach(annotation => {
|
|
1077
1100
|
if (annotation.dataset.type) {
|
|
1078
1101
|
types.add(annotation.dataset.type);
|
|
1079
1102
|
}
|
|
1080
1103
|
});
|
|
1081
|
-
types.forEach(
|
|
1082
|
-
this._annotationColors.set(
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1104
|
+
types.forEach(type => {
|
|
1105
|
+
this._annotationColors.set(
|
|
1106
|
+
type,
|
|
1107
|
+
uniqolor(`annotation-${type.repeat(4)}`, {
|
|
1108
|
+
saturation: 70,
|
|
1109
|
+
lightness: [30, 60],
|
|
1110
|
+
}),
|
|
1111
|
+
);
|
|
1086
1112
|
});
|
|
1087
1113
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1088
1114
|
}
|
|
@@ -1092,16 +1118,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1092
1118
|
return;
|
|
1093
1119
|
}
|
|
1094
1120
|
|
|
1095
|
-
this._annotationColors.set(
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1121
|
+
this._annotationColors.set(
|
|
1122
|
+
type,
|
|
1123
|
+
uniqolor(`annotation-${type.repeat(4)}`, {
|
|
1124
|
+
saturation: 70,
|
|
1125
|
+
lightness: [30, 60],
|
|
1126
|
+
}),
|
|
1127
|
+
);
|
|
1099
1128
|
this._annotationStyles();
|
|
1100
1129
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1101
1130
|
}
|
|
1102
1131
|
|
|
1103
1132
|
_annotationStyles() {
|
|
1104
|
-
const view = this.shadowRoot.getElementById('view')
|
|
1133
|
+
const view = this.shadowRoot.getElementById('view');
|
|
1105
1134
|
let styles = view.querySelector('_annotation-styles');
|
|
1106
1135
|
if (styles) {
|
|
1107
1136
|
styles.parentNode.removeChild(styles);
|
|
@@ -1122,8 +1151,12 @@ class PbViewAnnotate extends PbView {
|
|
|
1122
1151
|
315deg,
|
|
1123
1152
|
var(--pb-annotation-${type}),
|
|
1124
1153
|
var(--pb-annotation-${type}) 5px,
|
|
1125
|
-
var(${
|
|
1126
|
-
|
|
1154
|
+
var(${
|
|
1155
|
+
color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'
|
|
1156
|
+
}) 5px,
|
|
1157
|
+
var(${
|
|
1158
|
+
color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'
|
|
1159
|
+
}) 10px
|
|
1127
1160
|
);
|
|
1128
1161
|
color: var(${color.isLight ? '--pb-color-primary' : '--pb-color-inverse'});
|
|
1129
1162
|
}
|
|
@@ -1147,13 +1180,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1147
1180
|
super.styles,
|
|
1148
1181
|
css`
|
|
1149
1182
|
.annotation-type {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1183
|
+
display: inline-block;
|
|
1184
|
+
text-align: right;
|
|
1185
|
+
padding: 4px;
|
|
1153
1186
|
}
|
|
1154
1187
|
|
|
1155
1188
|
.annotation-popup .toolbar {
|
|
1156
|
-
|
|
1189
|
+
margin-top: 1em;
|
|
1157
1190
|
}
|
|
1158
1191
|
|
|
1159
1192
|
.annotation-popup table {
|
|
@@ -1169,21 +1202,21 @@ class PbViewAnnotate extends PbView {
|
|
|
1169
1202
|
}
|
|
1170
1203
|
|
|
1171
1204
|
.annotation {
|
|
1172
|
-
|
|
1173
|
-
|
|
1205
|
+
pointer-events: none;
|
|
1206
|
+
cursor: pointer;
|
|
1174
1207
|
}
|
|
1175
1208
|
|
|
1176
1209
|
.annotation::after {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1210
|
+
content: attr(data-type);
|
|
1211
|
+
margin-left: 4px;
|
|
1212
|
+
pointer-events: all;
|
|
1213
|
+
font-family: var(--pb-base-font-family);
|
|
1214
|
+
font-size: 0.8rem;
|
|
1215
|
+
font-style: normal;
|
|
1216
|
+
font-weight: normal;
|
|
1217
|
+
text-decoration: none;
|
|
1218
|
+
font-variant: normal;
|
|
1219
|
+
padding: 2px;
|
|
1187
1220
|
}
|
|
1188
1221
|
|
|
1189
1222
|
.annotation.before::after {
|
|
@@ -1191,12 +1224,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1191
1224
|
border-radius: 4px;
|
|
1192
1225
|
}
|
|
1193
1226
|
|
|
1194
|
-
[part=highlight] {
|
|
1227
|
+
[part='highlight'] {
|
|
1195
1228
|
border: 3px solid rgb(255, 174, 0);
|
|
1196
1229
|
border-radius: 8px;
|
|
1197
|
-
}
|
|
1230
|
+
}
|
|
1231
|
+
`,
|
|
1198
1232
|
];
|
|
1199
1233
|
}
|
|
1200
|
-
}
|
|
1234
|
+
}
|
|
1201
1235
|
|
|
1202
1236
|
customElements.define('pb-view-annotate', PbViewAnnotate);
|