@teipublisher/pb-components 2.26.1-next.3 → 3.0.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.
- package/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +4 -4
- package/.releaserc.json +2 -2
- package/CHANGELOG.md +262 -11
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/css/leaflet/images/layers.png +0 -0
- package/dist/demo/components.css +46 -1
- package/dist/demo/pb-browse-docs2.html +1 -1
- package/dist/demo/pb-dialog.html +3 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-facsimile.html +2 -2
- package/dist/demo/pb-grid.html +19 -6
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-login.html +0 -2
- package/dist/demo/pb-message.html +1 -2
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-search.html +7 -4
- package/dist/demo/pb-search3.html +1 -1
- package/dist/demo/pb-search4.html +2 -2
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{iron-form-3b8dcaa7.js → iron-form-dfb3e3b1.js} +95 -95
- package/dist/paper-checkbox-645e1077.js +200 -0
- package/dist/{paper-icon-button-b1d31571.js → paper-icon-button-984162bd.js} +1 -1
- package/dist/{paper-checkbox-515a5284.js → paper-inky-focus-behavior-fa16796b.js} +58 -247
- package/dist/{paper-listbox-a3b7175c.js → paper-listbox-5f5d1cec.js} +152 -162
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +68 -64
- package/dist/pb-components-bundle.js +1983 -2293
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +176 -120
- 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 +1023 -782
- package/dist/pb-tify.js +2 -2
- package/dist/vaadin-element-mixin-beb74ffd.js +545 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +6 -6
- package/package.json +3 -3
- package/pb-elements.json +176 -120
- 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 +50 -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 +158 -171
- package/src/pb-authority-lookup.js +191 -156
- 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 +211 -151
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-components.js +1 -0
- package/src/pb-custom-form.js +173 -153
- package/src/pb-dialog.js +98 -62
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +212 -196
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +100 -97
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +474 -410
- 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 +142 -57
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -429
- package/src/pb-login.js +299 -244
- package/src/pb-manage-odds.js +352 -336
- 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 +139 -97
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -95
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1054 -958
- package/src/pb-odd-elementspec-editor.js +349 -298
- package/src/pb-odd-model-editor.js +1075 -909
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -422
- package/src/pb-paginate.js +228 -179
- package/src/pb-panel.js +198 -182
- package/src/pb-popover-themes.js +15 -8
- 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 +256 -228
- 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 +382 -249
- package/src/pb-toggle-feature.js +195 -187
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +135 -98
- package/src/pb-view.js +1282 -1270
- package/src/pb-zoom.js +127 -45
- 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 +98 -91
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
- package/css/pb-styles.css +0 -51
- package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -41
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
|
};
|
|
@@ -268,6 +273,9 @@ class PbViewAnnotate extends PbView {
|
|
|
268
273
|
connectedCallback() {
|
|
269
274
|
super.connectedCallback();
|
|
270
275
|
|
|
276
|
+
// fill should always be 0 when doing annotations!!!
|
|
277
|
+
this.fill = 0;
|
|
278
|
+
|
|
271
279
|
let isMouseDown = false;
|
|
272
280
|
|
|
273
281
|
this._inHandler = false;
|
|
@@ -329,8 +337,12 @@ class PbViewAnnotate extends PbView {
|
|
|
329
337
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges, refresh: true });
|
|
330
338
|
});
|
|
331
339
|
|
|
332
|
-
this.addEventListener('pb-disable', () => {
|
|
333
|
-
|
|
340
|
+
this.addEventListener('pb-disable', () => {
|
|
341
|
+
this._disabled = true;
|
|
342
|
+
});
|
|
343
|
+
this.addEventListener('pb-enable', () => {
|
|
344
|
+
this._disabled = false;
|
|
345
|
+
});
|
|
334
346
|
|
|
335
347
|
this._resizeHandler();
|
|
336
348
|
}
|
|
@@ -425,17 +437,19 @@ class PbViewAnnotate extends PbView {
|
|
|
425
437
|
|
|
426
438
|
_handleContent() {
|
|
427
439
|
super._handleContent();
|
|
428
|
-
this.updateComplete.then(() =>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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
|
+
);
|
|
439
453
|
}
|
|
440
454
|
|
|
441
455
|
_updateAnnotation(teiRange, silent = false, batch = false) {
|
|
@@ -485,7 +499,9 @@ class PbViewAnnotate extends PbView {
|
|
|
485
499
|
console.log('<pb-view-annotate> Range: %o', range);
|
|
486
500
|
const span = document.createElement('span');
|
|
487
501
|
const addClass = teiRange.properties[this.getKey(teiRange.type)] === '' ? 'incomplete' : '';
|
|
488
|
-
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
502
|
+
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
503
|
+
teiRange.before ? 'before' : ''
|
|
504
|
+
}`;
|
|
489
505
|
span.dataset.type = teiRange.type;
|
|
490
506
|
span.dataset.annotation = JSON.stringify(teiRange.properties);
|
|
491
507
|
|
|
@@ -495,7 +511,9 @@ class PbViewAnnotate extends PbView {
|
|
|
495
511
|
if (silent) {
|
|
496
512
|
return null;
|
|
497
513
|
}
|
|
498
|
-
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
|
+
);
|
|
499
517
|
}
|
|
500
518
|
this._rangesMap.set(span, teiRange);
|
|
501
519
|
|
|
@@ -507,7 +525,7 @@ class PbViewAnnotate extends PbView {
|
|
|
507
525
|
}
|
|
508
526
|
|
|
509
527
|
updateAnnotations(silent = false) {
|
|
510
|
-
this._ranges.forEach(
|
|
528
|
+
this._ranges.forEach(teiRange => {
|
|
511
529
|
let span;
|
|
512
530
|
switch (teiRange.type) {
|
|
513
531
|
case 'delete':
|
|
@@ -535,9 +553,7 @@ class PbViewAnnotate extends PbView {
|
|
|
535
553
|
}
|
|
536
554
|
|
|
537
555
|
_getSelection() {
|
|
538
|
-
return this.shadowRoot.getSelection
|
|
539
|
-
? this.shadowRoot.getSelection()
|
|
540
|
-
: window.getSelection();
|
|
556
|
+
return this.shadowRoot.getSelection ? this.shadowRoot.getSelection() : window.getSelection();
|
|
541
557
|
}
|
|
542
558
|
|
|
543
559
|
_selectionChanged() {
|
|
@@ -576,7 +592,11 @@ class PbViewAnnotate extends PbView {
|
|
|
576
592
|
}
|
|
577
593
|
}, 100);
|
|
578
594
|
}
|
|
579
|
-
this.emitTo('pb-selection-changed', {
|
|
595
|
+
this.emitTo('pb-selection-changed', {
|
|
596
|
+
hasContent: true,
|
|
597
|
+
range,
|
|
598
|
+
selected: selection.toString(),
|
|
599
|
+
});
|
|
580
600
|
} else {
|
|
581
601
|
this._clearSelection();
|
|
582
602
|
this.emitTo('pb-selection-changed', { hasContent: false });
|
|
@@ -605,7 +625,7 @@ class PbViewAnnotate extends PbView {
|
|
|
605
625
|
|
|
606
626
|
_clearSelection() {
|
|
607
627
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
608
|
-
markerLayer.querySelectorAll('.selection-marker').forEach(
|
|
628
|
+
markerLayer.querySelectorAll('.selection-marker').forEach(oldMarker => {
|
|
609
629
|
markerLayer.removeChild(oldMarker);
|
|
610
630
|
});
|
|
611
631
|
}
|
|
@@ -633,10 +653,10 @@ class PbViewAnnotate extends PbView {
|
|
|
633
653
|
const endRange = rangeToPoint(range.endContainer, range.endOffset, 'end');
|
|
634
654
|
const adjustedRange = {
|
|
635
655
|
context: startRange.parent,
|
|
636
|
-
start:
|
|
637
|
-
end:
|
|
656
|
+
start: info.position === 'after' ? endRange.offset : startRange.offset,
|
|
657
|
+
end: info === undefined || info.position === 'before' ? startRange.offset : endRange.offset,
|
|
638
658
|
text: info.before ? '' : range.cloneContents().textContent,
|
|
639
|
-
before: info.before
|
|
659
|
+
before: info.before,
|
|
640
660
|
};
|
|
641
661
|
if (info.type) {
|
|
642
662
|
adjustedRange.type = info.type;
|
|
@@ -707,7 +727,7 @@ class PbViewAnnotate extends PbView {
|
|
|
707
727
|
const selection = this._getSelection();
|
|
708
728
|
selection.removeAllRanges();
|
|
709
729
|
selection.addRange(newRange);
|
|
710
|
-
} catch(e) {
|
|
730
|
+
} catch (e) {
|
|
711
731
|
console.error('<pb-view-annotate> %s', e.message);
|
|
712
732
|
} finally {
|
|
713
733
|
this._inHandler = false;
|
|
@@ -731,14 +751,14 @@ class PbViewAnnotate extends PbView {
|
|
|
731
751
|
range = clearProperties(range);
|
|
732
752
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges });
|
|
733
753
|
} else {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
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
|
+
}
|
|
742
762
|
}
|
|
743
763
|
const jsonOld = JSON.parse(span.dataset.annotation);
|
|
744
764
|
const json = Object.assign(jsonOld || {}, properties);
|
|
@@ -801,7 +821,12 @@ class PbViewAnnotate extends PbView {
|
|
|
801
821
|
editBtn.addEventListener('click', () => {
|
|
802
822
|
const data = JSON.parse(span.dataset.annotation);
|
|
803
823
|
const text = span.textContent;
|
|
804
|
-
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
|
+
});
|
|
805
830
|
});
|
|
806
831
|
div.appendChild(editBtn);
|
|
807
832
|
}
|
|
@@ -839,19 +864,21 @@ class PbViewAnnotate extends PbView {
|
|
|
839
864
|
onTrigger: (instance, ev) => {
|
|
840
865
|
ev.preventDefault();
|
|
841
866
|
ev.stopPropagation();
|
|
842
|
-
const type = span.dataset
|
|
867
|
+
const { type } = span.dataset;
|
|
843
868
|
const data = JSON.parse(span.dataset.annotation) || {};
|
|
844
869
|
const color = this._annotationColors.get(type);
|
|
845
870
|
typeInd.innerHTML = type;
|
|
846
871
|
typeInd.style.backgroundColor = `var(--pb-annotation-${type})`;
|
|
847
|
-
typeInd.style.color = `var(${
|
|
872
|
+
typeInd.style.color = `var(${
|
|
873
|
+
color && color.isLight ? '--pb-color-primary' : '--pb-color-inverse'
|
|
874
|
+
})`;
|
|
848
875
|
if (data[this.getKey(type)]) {
|
|
849
876
|
this.emitTo('pb-annotation-detail', {
|
|
850
877
|
type,
|
|
851
878
|
id: data[this.getKey(type)],
|
|
852
879
|
container: info,
|
|
853
880
|
span,
|
|
854
|
-
ready: () => instance.setContent(wrapper)
|
|
881
|
+
ready: () => instance.setContent(wrapper),
|
|
855
882
|
});
|
|
856
883
|
} else {
|
|
857
884
|
// show properties as key/value table
|
|
@@ -863,7 +890,7 @@ class PbViewAnnotate extends PbView {
|
|
|
863
890
|
info.appendChild(p);
|
|
864
891
|
} else {
|
|
865
892
|
const table = document.createElement('table');
|
|
866
|
-
keys.forEach(
|
|
893
|
+
keys.forEach(key => {
|
|
867
894
|
const tr = document.createElement('tr');
|
|
868
895
|
const tdKey = document.createElement('td');
|
|
869
896
|
tdKey.innerHTML = key;
|
|
@@ -879,7 +906,7 @@ class PbViewAnnotate extends PbView {
|
|
|
879
906
|
},
|
|
880
907
|
onClickOutside: (instance, ev) => {
|
|
881
908
|
instance.hideWithInteractivity(ev);
|
|
882
|
-
}
|
|
909
|
+
},
|
|
883
910
|
});
|
|
884
911
|
}
|
|
885
912
|
|
|
@@ -892,7 +919,7 @@ class PbViewAnnotate extends PbView {
|
|
|
892
919
|
*/
|
|
893
920
|
_showMarker(span, root, rootRect, margin = 0) {
|
|
894
921
|
const rects = span.getClientRects();
|
|
895
|
-
const type = span.dataset
|
|
922
|
+
const { type } = span.dataset;
|
|
896
923
|
if (!span.classList.contains('before')) {
|
|
897
924
|
for (let i = 0; i < rects.length; i++) {
|
|
898
925
|
const rect = rects[i];
|
|
@@ -929,20 +956,18 @@ class PbViewAnnotate extends PbView {
|
|
|
929
956
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
930
957
|
markerLayer.style.display = 'none';
|
|
931
958
|
this._clearMarkers();
|
|
932
|
-
root.querySelectorAll('.annotation')
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
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';
|
|
940
966
|
}
|
|
941
967
|
|
|
942
968
|
search(type, tokens) {
|
|
943
969
|
function escape(token) {
|
|
944
|
-
let regex = token.replace(/[/.?+*\\]/g,
|
|
945
|
-
.replace(/[\s\n\t]+/g, '\\s+');
|
|
970
|
+
let regex = token.replace(/[/.?+*\\]/g, m => `\\${m}`).replace(/[\s\n\t]+/g, '\\s+');
|
|
946
971
|
if (/^\w/.test(regex)) {
|
|
947
972
|
regex = `\\b${regex}`;
|
|
948
973
|
}
|
|
@@ -966,7 +991,8 @@ class PbViewAnnotate extends PbView {
|
|
|
966
991
|
if (!tokens || tokens.length === 0) {
|
|
967
992
|
return result;
|
|
968
993
|
}
|
|
969
|
-
const expr = tokens
|
|
994
|
+
const expr = tokens
|
|
995
|
+
.filter(token => token && token.length > 0)
|
|
970
996
|
.map(token => escape(token))
|
|
971
997
|
.join('|');
|
|
972
998
|
console.log(`<pb-view-annotate> Searching content for ${expr}...`);
|
|
@@ -977,7 +1003,7 @@ class PbViewAnnotate extends PbView {
|
|
|
977
1003
|
filter,
|
|
978
1004
|
);
|
|
979
1005
|
while (walker.nextNode()) {
|
|
980
|
-
|
|
1006
|
+
const node = walker.currentNode;
|
|
981
1007
|
const matches = Array.from(node.textContent.matchAll(regex));
|
|
982
1008
|
for (const match of matches) {
|
|
983
1009
|
const end = match.index + match[0].length;
|
|
@@ -1052,8 +1078,8 @@ class PbViewAnnotate extends PbView {
|
|
|
1052
1078
|
}
|
|
1053
1079
|
|
|
1054
1080
|
_markIncompleteAnnotations() {
|
|
1055
|
-
const elem = this.shadowRoot.getElementById('view')
|
|
1056
|
-
elem.querySelectorAll('.annotation.authority').forEach(
|
|
1081
|
+
const elem = this.shadowRoot.getElementById('view');
|
|
1082
|
+
elem.querySelectorAll('.annotation.authority').forEach(annotation => {
|
|
1057
1083
|
if (annotation.dataset.type) {
|
|
1058
1084
|
const data = JSON.parse(annotation.dataset.annotation);
|
|
1059
1085
|
const key = this.getKey(annotation.dataset.type);
|
|
@@ -1070,16 +1096,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1070
1096
|
this._annotationColors = new Map();
|
|
1071
1097
|
const types = new Set();
|
|
1072
1098
|
const elem = this.shadowRoot.getElementById('view');
|
|
1073
|
-
elem.querySelectorAll('.annotation').forEach(
|
|
1099
|
+
elem.querySelectorAll('.annotation').forEach(annotation => {
|
|
1074
1100
|
if (annotation.dataset.type) {
|
|
1075
1101
|
types.add(annotation.dataset.type);
|
|
1076
1102
|
}
|
|
1077
1103
|
});
|
|
1078
|
-
types.forEach(
|
|
1079
|
-
this._annotationColors.set(
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
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
|
+
);
|
|
1083
1112
|
});
|
|
1084
1113
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1085
1114
|
}
|
|
@@ -1089,16 +1118,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1089
1118
|
return;
|
|
1090
1119
|
}
|
|
1091
1120
|
|
|
1092
|
-
this._annotationColors.set(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1121
|
+
this._annotationColors.set(
|
|
1122
|
+
type,
|
|
1123
|
+
uniqolor(`annotation-${type.repeat(4)}`, {
|
|
1124
|
+
saturation: 70,
|
|
1125
|
+
lightness: [30, 60],
|
|
1126
|
+
}),
|
|
1127
|
+
);
|
|
1096
1128
|
this._annotationStyles();
|
|
1097
1129
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1098
1130
|
}
|
|
1099
1131
|
|
|
1100
1132
|
_annotationStyles() {
|
|
1101
|
-
const view = this.shadowRoot.getElementById('view')
|
|
1133
|
+
const view = this.shadowRoot.getElementById('view');
|
|
1102
1134
|
let styles = view.querySelector('_annotation-styles');
|
|
1103
1135
|
if (styles) {
|
|
1104
1136
|
styles.parentNode.removeChild(styles);
|
|
@@ -1119,8 +1151,12 @@ class PbViewAnnotate extends PbView {
|
|
|
1119
1151
|
315deg,
|
|
1120
1152
|
var(--pb-annotation-${type}),
|
|
1121
1153
|
var(--pb-annotation-${type}) 5px,
|
|
1122
|
-
var(${
|
|
1123
|
-
|
|
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
|
|
1124
1160
|
);
|
|
1125
1161
|
color: var(${color.isLight ? '--pb-color-primary' : '--pb-color-inverse'});
|
|
1126
1162
|
}
|
|
@@ -1144,13 +1180,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1144
1180
|
super.styles,
|
|
1145
1181
|
css`
|
|
1146
1182
|
.annotation-type {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1183
|
+
display: inline-block;
|
|
1184
|
+
text-align: right;
|
|
1185
|
+
padding: 4px;
|
|
1150
1186
|
}
|
|
1151
1187
|
|
|
1152
1188
|
.annotation-popup .toolbar {
|
|
1153
|
-
|
|
1189
|
+
margin-top: 1em;
|
|
1154
1190
|
}
|
|
1155
1191
|
|
|
1156
1192
|
.annotation-popup table {
|
|
@@ -1166,21 +1202,21 @@ class PbViewAnnotate extends PbView {
|
|
|
1166
1202
|
}
|
|
1167
1203
|
|
|
1168
1204
|
.annotation {
|
|
1169
|
-
|
|
1170
|
-
|
|
1205
|
+
pointer-events: none;
|
|
1206
|
+
cursor: pointer;
|
|
1171
1207
|
}
|
|
1172
1208
|
|
|
1173
1209
|
.annotation::after {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
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;
|
|
1184
1220
|
}
|
|
1185
1221
|
|
|
1186
1222
|
.annotation.before::after {
|
|
@@ -1188,12 +1224,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1188
1224
|
border-radius: 4px;
|
|
1189
1225
|
}
|
|
1190
1226
|
|
|
1191
|
-
[part=highlight] {
|
|
1227
|
+
[part='highlight'] {
|
|
1192
1228
|
border: 3px solid rgb(255, 174, 0);
|
|
1193
1229
|
border-radius: 8px;
|
|
1194
|
-
}
|
|
1230
|
+
}
|
|
1231
|
+
`,
|
|
1195
1232
|
];
|
|
1196
1233
|
}
|
|
1197
|
-
}
|
|
1234
|
+
}
|
|
1198
1235
|
|
|
1199
1236
|
customElements.define('pb-view-annotate', PbViewAnnotate);
|