@teipublisher/pb-components 2.26.1-next.2 → 3.0.0-next-4.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/.github/workflows/docker-cypress.yml +54 -0
- package/.github/workflows/main.yml +6 -4
- package/.github/workflows/node.js.yml +56 -21
- package/.github/workflows/release.js.yml +19 -17
- package/.releaserc.json +1 -1
- package/CHANGELOG.md +351 -9
- package/Dockerfile +78 -70
- package/README.md +112 -4
- package/css/components.css +5 -5
- package/css/gridjs/mermaid.min.css +1 -1
- package/css/leaflet/Control.Geocoder.css +1 -126
- package/css/leaflet/images/layers.png +0 -0
- package/css/tify/tify.css +6 -5
- package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
- package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css +1 -1
- package/css/tom-select/tom-select.default.min.css.map +1 -0
- package/css/tom-select/tom-select.min.css +1 -1
- package/cypress.config.js +84 -0
- package/dist/api.html +1 -1
- package/dist/css/design-system.css +607 -0
- package/dist/demo/bundle-test.html +4 -3
- package/dist/demo/components.css +46 -1
- package/dist/demo/design-system.html +710 -0
- package/dist/demo/dts-client.html +2 -2
- package/dist/demo/pb-autocomplete.html +23 -11
- package/dist/demo/pb-autocomplete2.html +66 -55
- package/dist/demo/pb-autocomplete3.html +17 -8
- package/dist/demo/pb-blacklab-highlight.html +28 -11
- package/dist/demo/pb-blacklab-results.html +3 -2
- package/dist/demo/pb-browse-docs.html +24 -24
- package/dist/demo/pb-browse-docs2.html +3 -3
- package/dist/demo/pb-clipboard.html +32 -28
- package/dist/demo/pb-code-editor.html +6 -6
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-codepen.html +1 -1
- package/dist/demo/pb-collapse.html +1 -1
- package/dist/demo/pb-collapse2.html +2 -2
- package/dist/demo/pb-combo-box.html +135 -130
- package/dist/demo/pb-custom-form.html +64 -55
- package/dist/demo/pb-dialog.html +12 -6
- package/dist/demo/pb-document.html +1 -1
- package/dist/demo/pb-download.html +68 -59
- package/dist/demo/pb-drawer.html +67 -46
- package/dist/demo/pb-drawer2.html +65 -58
- package/dist/demo/pb-edit-app.html +2 -2
- package/dist/demo/pb-edit-xml.html +1 -1
- package/dist/demo/pb-facsimile-2.html +26 -11
- package/dist/demo/pb-facsimile-3.html +25 -10
- package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
- package/dist/demo/pb-facsimile-dedup-test.html +48 -0
- package/dist/demo/pb-facsimile.html +4 -4
- package/dist/demo/pb-formula.html +1 -1
- package/dist/demo/pb-grid.html +22 -8
- package/dist/demo/pb-highlight.html +2 -2
- package/dist/demo/pb-i18n-simple.html +1 -0
- package/dist/demo/pb-i18n.html +15 -5
- package/dist/demo/pb-image-strip-standalone.html +2 -2
- package/dist/demo/pb-image-strip-view.html +2 -2
- package/dist/demo/pb-leaflet-map.html +3 -3
- package/dist/demo/pb-leaflet-map2.html +2 -2
- package/dist/demo/pb-leaflet-map3.html +3 -3
- package/dist/demo/pb-link.html +1 -1
- package/dist/demo/pb-load.html +2 -6
- package/dist/demo/pb-login.html +1 -3
- package/dist/demo/pb-manage-odds.html +9 -4
- package/dist/demo/pb-markdown.html +1 -1
- package/dist/demo/pb-media-query.html +2 -2
- package/dist/demo/pb-mei.html +2 -2
- package/dist/demo/pb-mei2.html +2 -2
- package/dist/demo/pb-message.html +2 -3
- package/dist/demo/pb-odd-editor.html +54 -52
- package/dist/demo/pb-page-header.html +27 -0
- package/dist/demo/pb-popover.html +1 -1
- package/dist/demo/pb-print-preview.html +2 -2
- package/dist/demo/pb-progress.html +4 -4
- package/dist/demo/pb-repeat.html +32 -36
- package/dist/demo/pb-search.html +16 -5
- package/dist/demo/pb-search2.html +4 -4
- package/dist/demo/pb-search3.html +3 -3
- package/dist/demo/pb-search4.html +3 -3
- package/dist/demo/pb-select-feature.html +4 -4
- package/dist/demo/pb-select-feature2.html +4 -4
- package/dist/demo/pb-select-feature3.html +2 -2
- package/dist/demo/pb-select-i18n.html +58 -53
- package/dist/demo/pb-select-odd.html +1 -1
- package/dist/demo/pb-select.html +190 -75
- package/dist/demo/pb-select2.html +91 -37
- package/dist/demo/pb-select3.html +109 -41
- package/dist/demo/pb-svg.html +1 -1
- package/dist/demo/pb-table-grid.html +26 -15
- package/dist/demo/pb-tabs.html +15 -7
- package/dist/demo/pb-tify.html +7 -7
- package/dist/demo/pb-timeline.html +1 -1
- package/dist/demo/pb-timeline2.html +1 -1
- package/dist/demo/pb-toggle-feature.html +26 -23
- package/dist/demo/pb-toggle-feature2.html +4 -4
- package/dist/demo/pb-toggle-feature3.html +2 -2
- package/dist/demo/pb-toggle-feature4.html +56 -54
- package/dist/demo/pb-version.html +2 -2
- package/dist/demo/pb-view.html +78 -40
- package/dist/demo/pb-view2.html +69 -46
- package/dist/demo/pb-view3.html +53 -48
- package/dist/demo/pb-view4.html +70 -49
- package/dist/demo/pb-zoom.html +2 -2
- package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
- package/dist/focus-mixin-VCsFap6b.js +768 -0
- package/dist/images/icons.svg +217 -0
- package/dist/jinn-codemirror-DETLdm08.js +1 -0
- package/dist/lib/openseadragon.min.js +80 -0
- package/dist/lib/openseadragon.min.js.map +1 -0
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +414 -3225
- package/dist/pb-components-bundle.js +3046 -4402
- package/dist/pb-dialog-tklYGWfc.js +121 -0
- package/dist/pb-edit-app.js +208 -107
- package/dist/pb-elements.json +716 -249
- package/dist/pb-facsimile.js +46 -0
- package/dist/pb-i18n-C0NDma4h.js +1 -0
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +152 -134
- package/dist/pb-mixin-DHoWQheB.js +1 -0
- package/dist/pb-odd-editor.js +1671 -1231
- package/dist/pb-tify.js +1 -27
- package/dist/unsafe-html-D5VGo9Oq.js +1 -0
- package/dist/urls-BEONu_g4.js +1 -0
- package/eslint.config.mjs +92 -0
- package/gh-pages.js +5 -3
- package/i18n/common/en.json +6 -0
- package/i18n/common/pl.json +2 -2
- package/images/icons.svg +217 -0
- package/index.html +0 -5
- package/lib/leaflet-src.js.map +1 -0
- package/lib/leaflet.markercluster-src.js.map +1 -0
- package/lib/openseadragon.min.js +6 -6
- package/package.json +56 -81
- package/pb-elements.json +716 -249
- package/rollup.config.mjs +312 -0
- package/src/assets/components.css +5 -5
- package/src/assets/design-system.css +607 -0
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +70 -27
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +50 -42
- package/src/authority/kbga.js +136 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -68
- package/src/authority/registry.js +4 -4
- package/src/docs/demo-utils.js +91 -0
- package/src/docs/pb-component-docs.js +287 -147
- package/src/docs/pb-component-view.js +380 -273
- package/src/docs/pb-components-list.js +115 -51
- package/src/docs/pb-demo-snippet.js +199 -174
- package/src/dts-client.js +306 -303
- package/src/dts-select-endpoint.js +125 -85
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +175 -173
- package/src/pb-authority-lookup.js +198 -158
- package/src/pb-autocomplete.js +731 -313
- package/src/pb-blacklab-highlight.js +266 -260
- package/src/pb-blacklab-results.js +230 -225
- package/src/pb-browse-docs.js +601 -484
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +97 -76
- package/src/pb-code-editor.js +111 -103
- package/src/pb-code-highlight.js +234 -204
- package/src/pb-codepen.js +81 -73
- package/src/pb-collapse.js +265 -152
- package/src/pb-combo-box.js +191 -191
- package/src/pb-components-bundle.js +1 -7
- package/src/pb-components.js +2 -6
- package/src/pb-custom-form.js +230 -141
- package/src/pb-dialog.js +99 -63
- package/src/pb-document.js +118 -91
- package/src/pb-download.js +214 -198
- package/src/pb-drawer.js +146 -149
- package/src/pb-edit-app.js +471 -240
- package/src/pb-edit-xml.js +101 -98
- package/src/pb-events.js +126 -107
- package/src/pb-facs-link.js +130 -101
- package/src/pb-facsimile.js +494 -410
- package/src/pb-fetch.js +389 -0
- package/src/pb-formula.js +152 -154
- package/src/pb-geolocation.js +130 -132
- package/src/pb-grid-action.js +59 -56
- package/src/pb-grid.js +388 -228
- package/src/pb-highlight.js +142 -142
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +115 -127
- package/src/pb-icon-button.js +108 -0
- package/src/pb-icon.js +283 -0
- package/src/pb-image-strip.js +85 -79
- package/src/pb-lang.js +142 -57
- package/src/pb-leaflet-map.js +551 -483
- package/src/pb-link.js +132 -126
- package/src/pb-load.js +495 -428
- package/src/pb-login.js +303 -248
- package/src/pb-manage-odds.js +384 -338
- package/src/pb-map-icon.js +90 -90
- package/src/pb-map-layer.js +86 -86
- package/src/pb-markdown.js +107 -110
- package/src/pb-media-query.js +75 -73
- package/src/pb-mei.js +523 -303
- package/src/pb-message.js +144 -98
- package/src/pb-mixin.js +268 -265
- package/src/pb-navigation.js +83 -96
- package/src/pb-observable.js +39 -39
- package/src/pb-odd-editor.js +1209 -948
- package/src/pb-odd-elementspec-editor.js +375 -310
- package/src/pb-odd-model-editor.js +1189 -941
- package/src/pb-odd-parameter-editor.js +269 -170
- package/src/pb-odd-rendition-editor.js +184 -131
- package/src/pb-page.js +451 -422
- package/src/pb-paginate.js +260 -178
- package/src/pb-panel.js +217 -183
- package/src/pb-popover-themes.js +16 -9
- package/src/pb-popover.js +297 -288
- package/src/pb-print-preview.js +128 -128
- package/src/pb-progress.js +52 -52
- package/src/pb-repeat.js +141 -108
- package/src/pb-restricted.js +85 -78
- package/src/pb-search.js +258 -230
- package/src/pb-select-feature.js +210 -126
- package/src/pb-select-odd.js +184 -118
- package/src/pb-select-template.js +113 -78
- package/src/pb-select.js +330 -229
- package/src/pb-split-list.js +181 -176
- package/src/pb-svg.js +81 -80
- package/src/pb-table-column.js +55 -55
- package/src/pb-table-grid.js +334 -205
- package/src/pb-tabs.js +238 -61
- package/src/pb-tify.js +3331 -126
- package/src/pb-timeline.js +394 -255
- package/src/pb-toggle-feature.js +196 -188
- package/src/pb-upload.js +201 -176
- package/src/pb-version.js +22 -34
- package/src/pb-view-annotate.js +138 -102
- package/src/pb-view.js +1722 -1272
- package/src/pb-zoom.js +144 -46
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +14 -22
- package/src/settings.js +4 -4
- package/src/theming.js +98 -91
- package/src/urls.js +403 -289
- package/src/utils.js +53 -51
- package/vite.config.js +86 -0
- package/css/pb-styles.css +0 -51
- package/dist/iron-form-3b8dcaa7.js +0 -210
- package/dist/jinn-codemirror-da0e2d1f.js +0 -1
- package/dist/paper-checkbox-515a5284.js +0 -1597
- package/dist/paper-icon-button-b1d31571.js +0 -398
- package/dist/paper-listbox-a3b7175c.js +0 -1265
- package/dist/pb-i18n-0611135a.js +0 -1
- package/dist/pb-mixin-b1caa22e.js +0 -158
- package/dist/polymer-hack.js +0 -1
- package/dist/vaadin-element-mixin-6e4cee3a.js +0 -527
- package/lib/Control.Geocoder.min.js +0 -2
- package/lib/Control.Geocoder.min.js.map +0 -1
- package/src/assets/pb-styles.css +0 -51
- package/src/pb-light-dom.js +0 -40
- package/src/polymer-hack.js +0 -6
package/src/pb-view-annotate.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { css, html } from
|
|
1
|
+
import './pb-icon-button.js';
|
|
2
|
+
import { css, html } from 'lit';
|
|
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
|
/**
|
|
@@ -52,7 +52,6 @@ function absoluteOffset(container, node, offset) {
|
|
|
52
52
|
while (walker.previousNode()) {
|
|
53
53
|
const sibling = walker.currentNode;
|
|
54
54
|
if (!(sibling.nodeType === Node.ELEMENT_NODE || isSkippedNode(sibling))) {
|
|
55
|
-
// eslint-disable-next-line no-param-reassign
|
|
56
55
|
offset += sibling.textContent.length;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
@@ -79,7 +78,10 @@ function rangeToPoint(node, offset, position = 'start') {
|
|
|
79
78
|
const child = container.childNodes[offset];
|
|
80
79
|
return {
|
|
81
80
|
parent: container.getAttribute('data-tei'),
|
|
82
|
-
offset:
|
|
81
|
+
offset:
|
|
82
|
+
position === 'end'
|
|
83
|
+
? absoluteOffset(container, child, 0) - 1
|
|
84
|
+
: absoluteOffset(container, child, 0),
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
const container = /** @type {Element} */ (node.parentNode).closest('[data-tei]');
|
|
@@ -88,9 +90,8 @@ function rangeToPoint(node, offset, position = 'start') {
|
|
|
88
90
|
parent: container.getAttribute('data-tei'),
|
|
89
91
|
offset: absoluteOffset(container, node, offset),
|
|
90
92
|
};
|
|
91
|
-
} else {
|
|
92
|
-
console.error('No container with data-tei found for %o', node.parentNode);
|
|
93
93
|
}
|
|
94
|
+
console.error('No container with data-tei found for %o', node.parentNode);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
function ancestors(node, selector) {
|
|
@@ -173,7 +174,10 @@ function kwicText(str, start, end, words = 3) {
|
|
|
173
174
|
}
|
|
174
175
|
p1 += 1;
|
|
175
176
|
}
|
|
176
|
-
return `... ${str.substring(p0, start)}<mark>${str.substring(start, end)}</mark>${str.substring(
|
|
177
|
+
return `... ${str.substring(p0, start)}<mark>${str.substring(start, end)}</mark>${str.substring(
|
|
178
|
+
end,
|
|
179
|
+
p1 + 1,
|
|
180
|
+
)} ...`;
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
function collectText(node) {
|
|
@@ -197,7 +201,7 @@ function collectText(node) {
|
|
|
197
201
|
|
|
198
202
|
function clearProperties(teiRange) {
|
|
199
203
|
const cleaned = {};
|
|
200
|
-
Object.keys(teiRange.properties).forEach(
|
|
204
|
+
Object.keys(teiRange.properties).forEach(key => {
|
|
201
205
|
const val = teiRange.properties[key];
|
|
202
206
|
if (val && val.length > 0) {
|
|
203
207
|
cleaned[key] = val;
|
|
@@ -234,21 +238,21 @@ class PbViewAnnotate extends PbView {
|
|
|
234
238
|
* like to use @key for some elements, but @corresp for others.
|
|
235
239
|
*/
|
|
236
240
|
key: {
|
|
237
|
-
type: String
|
|
241
|
+
type: String,
|
|
238
242
|
},
|
|
239
243
|
/**
|
|
240
244
|
* Optional mapping of annotation type names to key properties
|
|
241
245
|
*/
|
|
242
246
|
keyMap: {
|
|
243
247
|
type: Object,
|
|
244
|
-
attribute: 'key-map'
|
|
248
|
+
attribute: 'key-map',
|
|
245
249
|
},
|
|
246
250
|
/**
|
|
247
251
|
* When searching the displayed text for other potential occurrences of an entity,
|
|
248
252
|
* should the search be done in case-sensitive manner?
|
|
249
253
|
*/
|
|
250
254
|
caseSensitive: {
|
|
251
|
-
type: Boolean
|
|
255
|
+
type: Boolean,
|
|
252
256
|
},
|
|
253
257
|
...super.properties,
|
|
254
258
|
};
|
|
@@ -268,6 +272,9 @@ class PbViewAnnotate extends PbView {
|
|
|
268
272
|
connectedCallback() {
|
|
269
273
|
super.connectedCallback();
|
|
270
274
|
|
|
275
|
+
// fill should always be 0 when doing annotations!!!
|
|
276
|
+
this.fill = 0;
|
|
277
|
+
|
|
271
278
|
let isMouseDown = false;
|
|
272
279
|
|
|
273
280
|
this._inHandler = false;
|
|
@@ -329,8 +336,12 @@ class PbViewAnnotate extends PbView {
|
|
|
329
336
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges, refresh: true });
|
|
330
337
|
});
|
|
331
338
|
|
|
332
|
-
this.addEventListener('pb-disable', () => {
|
|
333
|
-
|
|
339
|
+
this.addEventListener('pb-disable', () => {
|
|
340
|
+
this._disabled = true;
|
|
341
|
+
});
|
|
342
|
+
this.addEventListener('pb-enable', () => {
|
|
343
|
+
this._disabled = false;
|
|
344
|
+
});
|
|
334
345
|
|
|
335
346
|
this._resizeHandler();
|
|
336
347
|
}
|
|
@@ -425,17 +436,19 @@ class PbViewAnnotate extends PbView {
|
|
|
425
436
|
|
|
426
437
|
_handleContent() {
|
|
427
438
|
super._handleContent();
|
|
428
|
-
this.updateComplete.then(() =>
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
+
this.updateComplete.then(() =>
|
|
440
|
+
setTimeout(() => {
|
|
441
|
+
this._initAnnotationColors();
|
|
442
|
+
this._annotationStyles();
|
|
443
|
+
this.updateAnnotations();
|
|
444
|
+
this._markIncompleteAnnotations();
|
|
445
|
+
if (this._scrollTop) {
|
|
446
|
+
this.scrollTop = this._scrollTop;
|
|
447
|
+
this._scrollTop = undefined;
|
|
448
|
+
}
|
|
449
|
+
this.emitTo('pb-annotations-loaded');
|
|
450
|
+
}, 300),
|
|
451
|
+
);
|
|
439
452
|
}
|
|
440
453
|
|
|
441
454
|
_updateAnnotation(teiRange, silent = false, batch = false) {
|
|
@@ -485,7 +498,9 @@ class PbViewAnnotate extends PbView {
|
|
|
485
498
|
console.log('<pb-view-annotate> Range: %o', range);
|
|
486
499
|
const span = document.createElement('span');
|
|
487
500
|
const addClass = teiRange.properties[this.getKey(teiRange.type)] === '' ? 'incomplete' : '';
|
|
488
|
-
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
501
|
+
span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass} ${
|
|
502
|
+
teiRange.before ? 'before' : ''
|
|
503
|
+
}`;
|
|
489
504
|
span.dataset.type = teiRange.type;
|
|
490
505
|
span.dataset.annotation = JSON.stringify(teiRange.properties);
|
|
491
506
|
|
|
@@ -495,7 +510,9 @@ class PbViewAnnotate extends PbView {
|
|
|
495
510
|
if (silent) {
|
|
496
511
|
return null;
|
|
497
512
|
}
|
|
498
|
-
throw new Error(
|
|
513
|
+
throw new Error(
|
|
514
|
+
'An error occurred. The annotation may not be displayed. You should consider saving and reloading the document.',
|
|
515
|
+
);
|
|
499
516
|
}
|
|
500
517
|
this._rangesMap.set(span, teiRange);
|
|
501
518
|
|
|
@@ -507,7 +524,7 @@ class PbViewAnnotate extends PbView {
|
|
|
507
524
|
}
|
|
508
525
|
|
|
509
526
|
updateAnnotations(silent = false) {
|
|
510
|
-
this._ranges.forEach(
|
|
527
|
+
this._ranges.forEach(teiRange => {
|
|
511
528
|
let span;
|
|
512
529
|
switch (teiRange.type) {
|
|
513
530
|
case 'delete':
|
|
@@ -535,9 +552,7 @@ class PbViewAnnotate extends PbView {
|
|
|
535
552
|
}
|
|
536
553
|
|
|
537
554
|
_getSelection() {
|
|
538
|
-
return this.shadowRoot.getSelection
|
|
539
|
-
? this.shadowRoot.getSelection()
|
|
540
|
-
: window.getSelection();
|
|
555
|
+
return this.shadowRoot.getSelection ? this.shadowRoot.getSelection() : window.getSelection();
|
|
541
556
|
}
|
|
542
557
|
|
|
543
558
|
_selectionChanged() {
|
|
@@ -576,7 +591,11 @@ class PbViewAnnotate extends PbView {
|
|
|
576
591
|
}
|
|
577
592
|
}, 100);
|
|
578
593
|
}
|
|
579
|
-
this.emitTo('pb-selection-changed', {
|
|
594
|
+
this.emitTo('pb-selection-changed', {
|
|
595
|
+
hasContent: true,
|
|
596
|
+
range,
|
|
597
|
+
selected: selection.toString(),
|
|
598
|
+
});
|
|
580
599
|
} else {
|
|
581
600
|
this._clearSelection();
|
|
582
601
|
this.emitTo('pb-selection-changed', { hasContent: false });
|
|
@@ -605,7 +624,7 @@ class PbViewAnnotate extends PbView {
|
|
|
605
624
|
|
|
606
625
|
_clearSelection() {
|
|
607
626
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
608
|
-
markerLayer.querySelectorAll('.selection-marker').forEach(
|
|
627
|
+
markerLayer.querySelectorAll('.selection-marker').forEach(oldMarker => {
|
|
609
628
|
markerLayer.removeChild(oldMarker);
|
|
610
629
|
});
|
|
611
630
|
}
|
|
@@ -633,10 +652,10 @@ class PbViewAnnotate extends PbView {
|
|
|
633
652
|
const endRange = rangeToPoint(range.endContainer, range.endOffset, 'end');
|
|
634
653
|
const adjustedRange = {
|
|
635
654
|
context: startRange.parent,
|
|
636
|
-
start:
|
|
637
|
-
end:
|
|
655
|
+
start: info.position === 'after' ? endRange.offset : startRange.offset,
|
|
656
|
+
end: info === undefined || info.position === 'before' ? startRange.offset : endRange.offset,
|
|
638
657
|
text: info.before ? '' : range.cloneContents().textContent,
|
|
639
|
-
before: info.before
|
|
658
|
+
before: info.before,
|
|
640
659
|
};
|
|
641
660
|
if (info.type) {
|
|
642
661
|
adjustedRange.type = info.type;
|
|
@@ -707,7 +726,7 @@ class PbViewAnnotate extends PbView {
|
|
|
707
726
|
const selection = this._getSelection();
|
|
708
727
|
selection.removeAllRanges();
|
|
709
728
|
selection.addRange(newRange);
|
|
710
|
-
} catch(e) {
|
|
729
|
+
} catch (e) {
|
|
711
730
|
console.error('<pb-view-annotate> %s', e.message);
|
|
712
731
|
} finally {
|
|
713
732
|
this._inHandler = false;
|
|
@@ -731,14 +750,14 @@ class PbViewAnnotate extends PbView {
|
|
|
731
750
|
range = clearProperties(range);
|
|
732
751
|
this.emitTo('pb-annotations-changed', { ranges: this._ranges });
|
|
733
752
|
} else {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
753
|
+
let range = this._rangesMap.get(span);
|
|
754
|
+
if (range) {
|
|
755
|
+
range.properties = properties;
|
|
756
|
+
range = clearProperties(range);
|
|
757
|
+
this.emitTo('pb-annotations-changed', { ranges: this._ranges });
|
|
758
|
+
} else {
|
|
759
|
+
console.error('no range found for edit span %o', span);
|
|
760
|
+
}
|
|
742
761
|
}
|
|
743
762
|
const jsonOld = JSON.parse(span.dataset.annotation);
|
|
744
763
|
const json = Object.assign(jsonOld || {}, properties);
|
|
@@ -795,17 +814,22 @@ class PbViewAnnotate extends PbView {
|
|
|
795
814
|
div.appendChild(typeInd);
|
|
796
815
|
|
|
797
816
|
if (span.dataset.annotation) {
|
|
798
|
-
const editBtn = document.createElement('
|
|
817
|
+
const editBtn = document.createElement('pb-icon-button');
|
|
799
818
|
editBtn.setAttribute('icon', 'icons:create');
|
|
800
819
|
editBtn.setAttribute('title', i18n('annotations.edit'));
|
|
801
820
|
editBtn.addEventListener('click', () => {
|
|
802
821
|
const data = JSON.parse(span.dataset.annotation);
|
|
803
822
|
const text = span.textContent;
|
|
804
|
-
this.emitTo('pb-annotation-edit',
|
|
823
|
+
this.emitTo('pb-annotation-edit', {
|
|
824
|
+
target: span,
|
|
825
|
+
type: span.dataset.type,
|
|
826
|
+
properties: data,
|
|
827
|
+
text,
|
|
828
|
+
});
|
|
805
829
|
});
|
|
806
830
|
div.appendChild(editBtn);
|
|
807
831
|
}
|
|
808
|
-
const delBtn = document.createElement('
|
|
832
|
+
const delBtn = document.createElement('pb-icon-button');
|
|
809
833
|
delBtn.setAttribute('icon', 'icons:delete');
|
|
810
834
|
delBtn.setAttribute('title', i18n('annotations.delete'));
|
|
811
835
|
delBtn.addEventListener('click', () => {
|
|
@@ -839,19 +863,21 @@ class PbViewAnnotate extends PbView {
|
|
|
839
863
|
onTrigger: (instance, ev) => {
|
|
840
864
|
ev.preventDefault();
|
|
841
865
|
ev.stopPropagation();
|
|
842
|
-
const type = span.dataset
|
|
866
|
+
const { type } = span.dataset;
|
|
843
867
|
const data = JSON.parse(span.dataset.annotation) || {};
|
|
844
868
|
const color = this._annotationColors.get(type);
|
|
845
869
|
typeInd.innerHTML = type;
|
|
846
870
|
typeInd.style.backgroundColor = `var(--pb-annotation-${type})`;
|
|
847
|
-
typeInd.style.color = `var(${
|
|
871
|
+
typeInd.style.color = `var(${
|
|
872
|
+
color && color.isLight ? '--pb-color-primary' : '--pb-color-inverse'
|
|
873
|
+
})`;
|
|
848
874
|
if (data[this.getKey(type)]) {
|
|
849
875
|
this.emitTo('pb-annotation-detail', {
|
|
850
876
|
type,
|
|
851
877
|
id: data[this.getKey(type)],
|
|
852
878
|
container: info,
|
|
853
879
|
span,
|
|
854
|
-
ready: () => instance.setContent(wrapper)
|
|
880
|
+
ready: () => instance.setContent(wrapper),
|
|
855
881
|
});
|
|
856
882
|
} else {
|
|
857
883
|
// show properties as key/value table
|
|
@@ -863,7 +889,7 @@ class PbViewAnnotate extends PbView {
|
|
|
863
889
|
info.appendChild(p);
|
|
864
890
|
} else {
|
|
865
891
|
const table = document.createElement('table');
|
|
866
|
-
keys.forEach(
|
|
892
|
+
keys.forEach(key => {
|
|
867
893
|
const tr = document.createElement('tr');
|
|
868
894
|
const tdKey = document.createElement('td');
|
|
869
895
|
tdKey.innerHTML = key;
|
|
@@ -879,7 +905,7 @@ class PbViewAnnotate extends PbView {
|
|
|
879
905
|
},
|
|
880
906
|
onClickOutside: (instance, ev) => {
|
|
881
907
|
instance.hideWithInteractivity(ev);
|
|
882
|
-
}
|
|
908
|
+
},
|
|
883
909
|
});
|
|
884
910
|
}
|
|
885
911
|
|
|
@@ -892,7 +918,7 @@ class PbViewAnnotate extends PbView {
|
|
|
892
918
|
*/
|
|
893
919
|
_showMarker(span, root, rootRect, margin = 0) {
|
|
894
920
|
const rects = span.getClientRects();
|
|
895
|
-
const type = span.dataset
|
|
921
|
+
const { type } = span.dataset;
|
|
896
922
|
if (!span.classList.contains('before')) {
|
|
897
923
|
for (let i = 0; i < rects.length; i++) {
|
|
898
924
|
const rect = rects[i];
|
|
@@ -929,20 +955,18 @@ class PbViewAnnotate extends PbView {
|
|
|
929
955
|
const markerLayer = this.shadowRoot.getElementById('marker-layer');
|
|
930
956
|
markerLayer.style.display = 'none';
|
|
931
957
|
this._clearMarkers();
|
|
932
|
-
root.querySelectorAll('.annotation')
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
markerLayer.style.display = 'block';
|
|
958
|
+
root.querySelectorAll('.annotation').forEach(span => {
|
|
959
|
+
if (span._tippy) {
|
|
960
|
+
span._tippy.destroy();
|
|
961
|
+
}
|
|
962
|
+
this._showMarker(span, markerLayer, rootRect, ancestors(span, 'annotation') * 5);
|
|
963
|
+
});
|
|
964
|
+
markerLayer.style.display = 'block';
|
|
940
965
|
}
|
|
941
966
|
|
|
942
967
|
search(type, tokens) {
|
|
943
968
|
function escape(token) {
|
|
944
|
-
let regex = token.replace(/[/.?+*\\]/g,
|
|
945
|
-
.replace(/[\s\n\t]+/g, '\\s+');
|
|
969
|
+
let regex = token.replace(/[/.?+*\\]/g, m => `\\${m}`).replace(/[\s\n\t]+/g, '\\s+');
|
|
946
970
|
if (/^\w/.test(regex)) {
|
|
947
971
|
regex = `\\b${regex}`;
|
|
948
972
|
}
|
|
@@ -966,7 +990,8 @@ class PbViewAnnotate extends PbView {
|
|
|
966
990
|
if (!tokens || tokens.length === 0) {
|
|
967
991
|
return result;
|
|
968
992
|
}
|
|
969
|
-
const expr = tokens
|
|
993
|
+
const expr = tokens
|
|
994
|
+
.filter(token => token && token.length > 0)
|
|
970
995
|
.map(token => escape(token))
|
|
971
996
|
.join('|');
|
|
972
997
|
console.log(`<pb-view-annotate> Searching content for ${expr}...`);
|
|
@@ -977,7 +1002,7 @@ class PbViewAnnotate extends PbView {
|
|
|
977
1002
|
filter,
|
|
978
1003
|
);
|
|
979
1004
|
while (walker.nextNode()) {
|
|
980
|
-
|
|
1005
|
+
const node = walker.currentNode;
|
|
981
1006
|
const matches = Array.from(node.textContent.matchAll(regex));
|
|
982
1007
|
for (const match of matches) {
|
|
983
1008
|
const end = match.index + match[0].length;
|
|
@@ -1052,8 +1077,8 @@ class PbViewAnnotate extends PbView {
|
|
|
1052
1077
|
}
|
|
1053
1078
|
|
|
1054
1079
|
_markIncompleteAnnotations() {
|
|
1055
|
-
const elem = this.shadowRoot.getElementById('view')
|
|
1056
|
-
elem.querySelectorAll('.annotation.authority').forEach(
|
|
1080
|
+
const elem = this.shadowRoot.getElementById('view');
|
|
1081
|
+
elem.querySelectorAll('.annotation.authority').forEach(annotation => {
|
|
1057
1082
|
if (annotation.dataset.type) {
|
|
1058
1083
|
const data = JSON.parse(annotation.dataset.annotation);
|
|
1059
1084
|
const key = this.getKey(annotation.dataset.type);
|
|
@@ -1070,16 +1095,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1070
1095
|
this._annotationColors = new Map();
|
|
1071
1096
|
const types = new Set();
|
|
1072
1097
|
const elem = this.shadowRoot.getElementById('view');
|
|
1073
|
-
elem.querySelectorAll('.annotation').forEach(
|
|
1098
|
+
elem.querySelectorAll('.annotation').forEach(annotation => {
|
|
1074
1099
|
if (annotation.dataset.type) {
|
|
1075
1100
|
types.add(annotation.dataset.type);
|
|
1076
1101
|
}
|
|
1077
1102
|
});
|
|
1078
|
-
types.forEach(
|
|
1079
|
-
this._annotationColors.set(
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1103
|
+
types.forEach(type => {
|
|
1104
|
+
this._annotationColors.set(
|
|
1105
|
+
type,
|
|
1106
|
+
uniqolor(`annotation-${type.repeat(4)}`, {
|
|
1107
|
+
saturation: 70,
|
|
1108
|
+
lightness: [30, 60],
|
|
1109
|
+
}),
|
|
1110
|
+
);
|
|
1083
1111
|
});
|
|
1084
1112
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1085
1113
|
}
|
|
@@ -1089,16 +1117,19 @@ class PbViewAnnotate extends PbView {
|
|
|
1089
1117
|
return;
|
|
1090
1118
|
}
|
|
1091
1119
|
|
|
1092
|
-
this._annotationColors.set(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1120
|
+
this._annotationColors.set(
|
|
1121
|
+
type,
|
|
1122
|
+
uniqolor(`annotation-${type.repeat(4)}`, {
|
|
1123
|
+
saturation: 70,
|
|
1124
|
+
lightness: [30, 60],
|
|
1125
|
+
}),
|
|
1126
|
+
);
|
|
1096
1127
|
this._annotationStyles();
|
|
1097
1128
|
this.emitTo('pb-annotation-colors', { colors: this._annotationColors });
|
|
1098
1129
|
}
|
|
1099
1130
|
|
|
1100
1131
|
_annotationStyles() {
|
|
1101
|
-
const view = this.shadowRoot.getElementById('view')
|
|
1132
|
+
const view = this.shadowRoot.getElementById('view');
|
|
1102
1133
|
let styles = view.querySelector('_annotation-styles');
|
|
1103
1134
|
if (styles) {
|
|
1104
1135
|
styles.parentNode.removeChild(styles);
|
|
@@ -1119,8 +1150,12 @@ class PbViewAnnotate extends PbView {
|
|
|
1119
1150
|
315deg,
|
|
1120
1151
|
var(--pb-annotation-${type}),
|
|
1121
1152
|
var(--pb-annotation-${type}) 5px,
|
|
1122
|
-
var(${
|
|
1123
|
-
|
|
1153
|
+
var(${
|
|
1154
|
+
color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'
|
|
1155
|
+
}) 5px,
|
|
1156
|
+
var(${
|
|
1157
|
+
color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'
|
|
1158
|
+
}) 10px
|
|
1124
1159
|
);
|
|
1125
1160
|
color: var(${color.isLight ? '--pb-color-primary' : '--pb-color-inverse'});
|
|
1126
1161
|
}
|
|
@@ -1144,13 +1179,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1144
1179
|
super.styles,
|
|
1145
1180
|
css`
|
|
1146
1181
|
.annotation-type {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1182
|
+
display: inline-block;
|
|
1183
|
+
text-align: right;
|
|
1184
|
+
padding: 4px;
|
|
1150
1185
|
}
|
|
1151
1186
|
|
|
1152
1187
|
.annotation-popup .toolbar {
|
|
1153
|
-
|
|
1188
|
+
margin-top: 1em;
|
|
1154
1189
|
}
|
|
1155
1190
|
|
|
1156
1191
|
.annotation-popup table {
|
|
@@ -1166,21 +1201,21 @@ class PbViewAnnotate extends PbView {
|
|
|
1166
1201
|
}
|
|
1167
1202
|
|
|
1168
1203
|
.annotation {
|
|
1169
|
-
|
|
1170
|
-
|
|
1204
|
+
pointer-events: none;
|
|
1205
|
+
cursor: pointer;
|
|
1171
1206
|
}
|
|
1172
1207
|
|
|
1173
1208
|
.annotation::after {
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1209
|
+
content: attr(data-type);
|
|
1210
|
+
margin-left: 4px;
|
|
1211
|
+
pointer-events: all;
|
|
1212
|
+
font-family: var(--pb-base-font-family);
|
|
1213
|
+
font-size: 0.8rem;
|
|
1214
|
+
font-style: normal;
|
|
1215
|
+
font-weight: normal;
|
|
1216
|
+
text-decoration: none;
|
|
1217
|
+
font-variant: normal;
|
|
1218
|
+
padding: 2px;
|
|
1184
1219
|
}
|
|
1185
1220
|
|
|
1186
1221
|
.annotation.before::after {
|
|
@@ -1188,12 +1223,13 @@ class PbViewAnnotate extends PbView {
|
|
|
1188
1223
|
border-radius: 4px;
|
|
1189
1224
|
}
|
|
1190
1225
|
|
|
1191
|
-
[part=highlight] {
|
|
1226
|
+
[part='highlight'] {
|
|
1192
1227
|
border: 3px solid rgb(255, 174, 0);
|
|
1193
1228
|
border-radius: 8px;
|
|
1194
|
-
}
|
|
1229
|
+
}
|
|
1230
|
+
`,
|
|
1195
1231
|
];
|
|
1196
1232
|
}
|
|
1197
|
-
}
|
|
1233
|
+
}
|
|
1198
1234
|
|
|
1199
1235
|
customElements.define('pb-view-annotate', PbViewAnnotate);
|