@teipublisher/pb-components 2.26.1-next.3 → 3.0.0-next-4.2

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.
Files changed (262) hide show
  1. package/.github/workflows/docker-cypress.yml +53 -0
  2. package/.github/workflows/node.js.yml +70 -21
  3. package/.releaserc.json +7 -2
  4. package/CHANGELOG.md +363 -11
  5. package/Dockerfile +78 -70
  6. package/README.md +112 -4
  7. package/css/components.css +5 -5
  8. package/css/gridjs/mermaid.min.css +1 -1
  9. package/css/leaflet/Control.Geocoder.css +1 -126
  10. package/css/leaflet/images/layers.png +0 -0
  11. package/css/tify/tify.css +6 -5
  12. package/css/tom-select/tom-select.bootstrap4.min.css +1 -1
  13. package/css/tom-select/tom-select.bootstrap5.min.css +1 -1
  14. package/css/tom-select/tom-select.default.min.css +1 -1
  15. package/css/tom-select/tom-select.default.min.css.map +1 -0
  16. package/css/tom-select/tom-select.min.css +1 -1
  17. package/cypress.config.js +84 -0
  18. package/dist/api.html +1 -1
  19. package/dist/css/design-system.css +607 -0
  20. package/dist/demo/bundle-test.html +4 -3
  21. package/dist/demo/components.css +46 -1
  22. package/dist/demo/design-system.html +710 -0
  23. package/dist/demo/dts-client.html +2 -2
  24. package/dist/demo/pb-autocomplete.html +23 -11
  25. package/dist/demo/pb-autocomplete2.html +66 -55
  26. package/dist/demo/pb-autocomplete3.html +17 -8
  27. package/dist/demo/pb-blacklab-highlight.html +28 -11
  28. package/dist/demo/pb-blacklab-results.html +3 -2
  29. package/dist/demo/pb-browse-docs.html +24 -24
  30. package/dist/demo/pb-browse-docs2.html +3 -3
  31. package/dist/demo/pb-clipboard.html +32 -28
  32. package/dist/demo/pb-code-editor.html +6 -6
  33. package/dist/demo/pb-code-highlight.html +63 -63
  34. package/dist/demo/pb-codepen.html +1 -1
  35. package/dist/demo/pb-collapse.html +1 -1
  36. package/dist/demo/pb-collapse2.html +2 -2
  37. package/dist/demo/pb-combo-box.html +135 -130
  38. package/dist/demo/pb-custom-form.html +64 -55
  39. package/dist/demo/pb-dialog.html +12 -6
  40. package/dist/demo/pb-document.html +1 -1
  41. package/dist/demo/pb-download.html +68 -59
  42. package/dist/demo/pb-drawer.html +67 -46
  43. package/dist/demo/pb-drawer2.html +65 -58
  44. package/dist/demo/pb-edit-app.html +2 -2
  45. package/dist/demo/pb-edit-xml.html +1 -1
  46. package/dist/demo/pb-facsimile-2.html +26 -11
  47. package/dist/demo/pb-facsimile-3.html +25 -10
  48. package/dist/demo/pb-facsimile-dedup-test-2.html +48 -0
  49. package/dist/demo/pb-facsimile-dedup-test.html +48 -0
  50. package/dist/demo/pb-facsimile.html +4 -4
  51. package/dist/demo/pb-formula.html +1 -1
  52. package/dist/demo/pb-grid.html +22 -8
  53. package/dist/demo/pb-highlight.html +2 -2
  54. package/dist/demo/pb-i18n-simple.html +1 -0
  55. package/dist/demo/pb-i18n.html +15 -5
  56. package/dist/demo/pb-image-strip-standalone.html +2 -2
  57. package/dist/demo/pb-image-strip-view.html +2 -2
  58. package/dist/demo/pb-leaflet-map.html +3 -3
  59. package/dist/demo/pb-leaflet-map2.html +2 -2
  60. package/dist/demo/pb-leaflet-map3.html +3 -3
  61. package/dist/demo/pb-link.html +1 -1
  62. package/dist/demo/pb-load.html +2 -6
  63. package/dist/demo/pb-login.html +1 -3
  64. package/dist/demo/pb-manage-odds.html +9 -4
  65. package/dist/demo/pb-markdown.html +1 -1
  66. package/dist/demo/pb-media-query.html +2 -2
  67. package/dist/demo/pb-mei.html +2 -2
  68. package/dist/demo/pb-mei2.html +2 -2
  69. package/dist/demo/pb-message.html +2 -3
  70. package/dist/demo/pb-odd-editor.html +54 -52
  71. package/dist/demo/pb-page-header.html +27 -0
  72. package/dist/demo/pb-popover.html +1 -1
  73. package/dist/demo/pb-print-preview.html +2 -2
  74. package/dist/demo/pb-progress.html +4 -4
  75. package/dist/demo/pb-repeat.html +32 -36
  76. package/dist/demo/pb-search.html +16 -5
  77. package/dist/demo/pb-search2.html +4 -4
  78. package/dist/demo/pb-search3.html +3 -3
  79. package/dist/demo/pb-search4.html +3 -3
  80. package/dist/demo/pb-select-feature.html +4 -4
  81. package/dist/demo/pb-select-feature2.html +4 -4
  82. package/dist/demo/pb-select-feature3.html +2 -2
  83. package/dist/demo/pb-select-i18n.html +58 -53
  84. package/dist/demo/pb-select-odd.html +1 -1
  85. package/dist/demo/pb-select.html +190 -75
  86. package/dist/demo/pb-select2.html +91 -37
  87. package/dist/demo/pb-select3.html +109 -41
  88. package/dist/demo/pb-svg.html +1 -1
  89. package/dist/demo/pb-table-grid.html +26 -15
  90. package/dist/demo/pb-tabs.html +15 -7
  91. package/dist/demo/pb-tify.html +7 -7
  92. package/dist/demo/pb-timeline.html +1 -1
  93. package/dist/demo/pb-timeline2.html +1 -1
  94. package/dist/demo/pb-toggle-feature.html +26 -23
  95. package/dist/demo/pb-toggle-feature2.html +4 -4
  96. package/dist/demo/pb-toggle-feature3.html +2 -2
  97. package/dist/demo/pb-toggle-feature4.html +56 -54
  98. package/dist/demo/pb-version.html +2 -2
  99. package/dist/demo/pb-view.html +78 -40
  100. package/dist/demo/pb-view2.html +69 -46
  101. package/dist/demo/pb-view3.html +53 -48
  102. package/dist/demo/pb-view4.html +70 -49
  103. package/dist/demo/pb-zoom.html +2 -2
  104. package/dist/{es-global-bridge-d8ce175d.js → es-global-bridge-D8ZcUcx_.js} +0 -4
  105. package/dist/focus-mixin-VCsFap6b.js +768 -0
  106. package/dist/images/icons.svg +217 -0
  107. package/dist/jinn-codemirror-DETLdm08.js +1 -0
  108. package/dist/lib/openseadragon.min.js +80 -0
  109. package/dist/lib/openseadragon.min.js.map +1 -0
  110. package/dist/pb-code-editor.js +25 -20
  111. package/dist/pb-component-docs.js +414 -3225
  112. package/dist/pb-components-bundle.js +3046 -4402
  113. package/dist/pb-dialog-tklYGWfc.js +121 -0
  114. package/dist/pb-edit-app.js +208 -107
  115. package/dist/pb-elements.json +716 -249
  116. package/dist/pb-facsimile.js +46 -0
  117. package/dist/pb-i18n-C0NDma4h.js +1 -0
  118. package/dist/pb-leaflet-map.js +23 -23
  119. package/dist/pb-mei.js +152 -134
  120. package/dist/pb-mixin-DHoWQheB.js +1 -0
  121. package/dist/pb-odd-editor.js +1671 -1231
  122. package/dist/pb-tify.js +1 -27
  123. package/dist/unsafe-html-D5VGo9Oq.js +1 -0
  124. package/dist/urls-BEONu_g4.js +1 -0
  125. package/eslint.config.mjs +92 -0
  126. package/gh-pages.js +5 -3
  127. package/i18n/common/en.json +6 -0
  128. package/i18n/common/pl.json +2 -2
  129. package/images/icons.svg +217 -0
  130. package/index.html +0 -5
  131. package/lib/leaflet-src.js.map +1 -0
  132. package/lib/leaflet.markercluster-src.js.map +1 -0
  133. package/lib/openseadragon.min.js +6 -6
  134. package/package.json +56 -81
  135. package/pb-elements.json +716 -249
  136. package/rollup.config.mjs +312 -0
  137. package/src/assets/components.css +5 -5
  138. package/src/assets/design-system.css +607 -0
  139. package/src/authority/airtable.js +20 -21
  140. package/src/authority/anton.js +129 -129
  141. package/src/authority/custom.js +70 -27
  142. package/src/authority/geonames.js +38 -32
  143. package/src/authority/gnd.js +50 -42
  144. package/src/authority/kbga.js +136 -134
  145. package/src/authority/metagrid.js +44 -46
  146. package/src/authority/reconciliation.js +66 -68
  147. package/src/authority/registry.js +4 -4
  148. package/src/docs/demo-utils.js +91 -0
  149. package/src/docs/pb-component-docs.js +287 -147
  150. package/src/docs/pb-component-view.js +380 -273
  151. package/src/docs/pb-components-list.js +115 -51
  152. package/src/docs/pb-demo-snippet.js +199 -174
  153. package/src/dts-client.js +306 -303
  154. package/src/dts-select-endpoint.js +125 -85
  155. package/src/parse-date-service.js +184 -135
  156. package/src/pb-ajax.js +175 -173
  157. package/src/pb-authority-lookup.js +198 -158
  158. package/src/pb-autocomplete.js +731 -313
  159. package/src/pb-blacklab-highlight.js +266 -260
  160. package/src/pb-blacklab-results.js +230 -225
  161. package/src/pb-browse-docs.js +601 -484
  162. package/src/pb-browse.js +68 -65
  163. package/src/pb-clipboard.js +97 -76
  164. package/src/pb-code-editor.js +111 -103
  165. package/src/pb-code-highlight.js +234 -204
  166. package/src/pb-codepen.js +81 -73
  167. package/src/pb-collapse.js +265 -152
  168. package/src/pb-combo-box.js +191 -191
  169. package/src/pb-components-bundle.js +1 -7
  170. package/src/pb-components.js +2 -6
  171. package/src/pb-custom-form.js +230 -141
  172. package/src/pb-dialog.js +99 -63
  173. package/src/pb-document.js +118 -91
  174. package/src/pb-download.js +214 -198
  175. package/src/pb-drawer.js +146 -149
  176. package/src/pb-edit-app.js +471 -240
  177. package/src/pb-edit-xml.js +101 -98
  178. package/src/pb-events.js +126 -107
  179. package/src/pb-facs-link.js +130 -101
  180. package/src/pb-facsimile.js +494 -410
  181. package/src/pb-fetch.js +389 -0
  182. package/src/pb-formula.js +152 -154
  183. package/src/pb-geolocation.js +130 -132
  184. package/src/pb-grid-action.js +59 -56
  185. package/src/pb-grid.js +388 -228
  186. package/src/pb-highlight.js +142 -142
  187. package/src/pb-hotkeys.js +40 -42
  188. package/src/pb-i18n.js +115 -127
  189. package/src/pb-icon-button.js +108 -0
  190. package/src/pb-icon.js +283 -0
  191. package/src/pb-image-strip.js +85 -79
  192. package/src/pb-lang.js +142 -57
  193. package/src/pb-leaflet-map.js +551 -483
  194. package/src/pb-link.js +132 -126
  195. package/src/pb-load.js +495 -428
  196. package/src/pb-login.js +303 -248
  197. package/src/pb-manage-odds.js +384 -338
  198. package/src/pb-map-icon.js +90 -90
  199. package/src/pb-map-layer.js +86 -86
  200. package/src/pb-markdown.js +107 -110
  201. package/src/pb-media-query.js +75 -73
  202. package/src/pb-mei.js +523 -303
  203. package/src/pb-message.js +144 -98
  204. package/src/pb-mixin.js +268 -265
  205. package/src/pb-navigation.js +83 -96
  206. package/src/pb-observable.js +39 -39
  207. package/src/pb-odd-editor.js +1209 -948
  208. package/src/pb-odd-elementspec-editor.js +375 -310
  209. package/src/pb-odd-model-editor.js +1189 -941
  210. package/src/pb-odd-parameter-editor.js +269 -170
  211. package/src/pb-odd-rendition-editor.js +184 -131
  212. package/src/pb-page.js +451 -422
  213. package/src/pb-paginate.js +260 -178
  214. package/src/pb-panel.js +217 -183
  215. package/src/pb-popover-themes.js +16 -9
  216. package/src/pb-popover.js +297 -288
  217. package/src/pb-print-preview.js +128 -128
  218. package/src/pb-progress.js +52 -52
  219. package/src/pb-repeat.js +141 -108
  220. package/src/pb-restricted.js +85 -78
  221. package/src/pb-search.js +258 -230
  222. package/src/pb-select-feature.js +210 -126
  223. package/src/pb-select-odd.js +184 -118
  224. package/src/pb-select-template.js +113 -78
  225. package/src/pb-select.js +330 -229
  226. package/src/pb-split-list.js +181 -176
  227. package/src/pb-svg.js +81 -80
  228. package/src/pb-table-column.js +55 -55
  229. package/src/pb-table-grid.js +334 -205
  230. package/src/pb-tabs.js +238 -61
  231. package/src/pb-tify.js +3331 -126
  232. package/src/pb-timeline.js +394 -255
  233. package/src/pb-toggle-feature.js +196 -188
  234. package/src/pb-upload.js +201 -176
  235. package/src/pb-version.js +22 -34
  236. package/src/pb-view-annotate.js +138 -102
  237. package/src/pb-view.js +1722 -1272
  238. package/src/pb-zoom.js +144 -46
  239. package/src/search-result-service.js +256 -223
  240. package/src/seed-element.js +14 -22
  241. package/src/settings.js +4 -4
  242. package/src/theming.js +98 -91
  243. package/src/urls.js +403 -289
  244. package/src/utils.js +53 -51
  245. package/vite.config.js +86 -0
  246. package/.github/workflows/main.yml +0 -24
  247. package/.github/workflows/release.js.yml +0 -34
  248. package/css/pb-styles.css +0 -51
  249. package/dist/iron-form-3b8dcaa7.js +0 -210
  250. package/dist/jinn-codemirror-da0e2d1f.js +0 -1
  251. package/dist/paper-checkbox-515a5284.js +0 -1597
  252. package/dist/paper-icon-button-b1d31571.js +0 -398
  253. package/dist/paper-listbox-a3b7175c.js +0 -1265
  254. package/dist/pb-i18n-0611135a.js +0 -1
  255. package/dist/pb-mixin-b1caa22e.js +0 -158
  256. package/dist/polymer-hack.js +0 -1
  257. package/dist/vaadin-element-mixin-fe4a4883.js +0 -527
  258. package/lib/Control.Geocoder.min.js +0 -2
  259. package/lib/Control.Geocoder.min.js.map +0 -1
  260. package/src/assets/pb-styles.css +0 -51
  261. package/src/pb-light-dom.js +0 -41
  262. package/src/polymer-hack.js +0 -6
@@ -1,9 +1,9 @@
1
- import '@polymer/paper-icon-button';
2
- import { css, html } from "lit-element";
1
+ import './pb-icon-button.js';
2
+ import { css, html } from 'lit';
3
3
  import tippy from 'tippy.js';
4
- import uniqolor from "uniqolor/src/index";
5
- import { PbView } from "./pb-view.js";
6
- import { loadTippyStyles } from "./pb-popover.js";
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: position === 'end' ? absoluteOffset(container, child, 0) - 1 : absoluteOffset(container, child, 0),
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(end, p1 + 1)} ...`;
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((key) => {
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', () => { this._disabled = true; });
333
- this.addEventListener('pb-enable', () => { this._disabled = false; });
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(() => setTimeout(() => {
429
- this._initAnnotationColors();
430
- this._annotationStyles();
431
- this.updateAnnotations();
432
- this._markIncompleteAnnotations();
433
- if (this._scrollTop) {
434
- this.scrollTop = this._scrollTop;
435
- this._scrollTop = undefined;
436
- }
437
- this.emitTo('pb-annotations-loaded');
438
- }, 300));
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} ${teiRange.before ? 'before' : ''}`;
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('An error occurred. The annotation may not be displayed. You should consider saving and reloading the document.');
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((teiRange) => {
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', { hasContent: true, range, selected: selection.toString()});
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((oldMarker) => {
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: (info.position === 'after') ? endRange.offset : startRange.offset,
637
- end: (info === undefined || info.position === 'before') ? startRange.offset : endRange.offset,
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
- let range = this._rangesMap.get(span);
735
- if (range) {
736
- range.properties = properties;
737
- range = clearProperties(range);
738
- this.emitTo('pb-annotations-changed', { ranges: this._ranges });
739
- } else {
740
- console.error('no range found for edit span %o', span);
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('paper-icon-button');
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', Object.assign({}, { target: span, type: span.dataset.type, properties: data, text }));
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('paper-icon-button');
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.type;
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(${color && color.isLight ? '--pb-color-primary' : '--pb-color-inverse'})`;
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((key) => {
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.type;
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
- .forEach(span => {
934
- if (span._tippy) {
935
- span._tippy.destroy();
936
- }
937
- this._showMarker(span, markerLayer, rootRect, ancestors(span, 'annotation') * 5);
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, (m) => `\\${m}`)
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.filter(token => token && token.length > 0)
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
- let node = walker.currentNode;
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((annotation) => {
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((annotation) => {
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((type) => {
1079
- this._annotationColors.set(type, uniqolor(`annotation-${type.repeat(4)}`, {
1080
- saturation: 70,
1081
- lightness: [30, 60]
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(type, uniqolor(`annotation-${type.repeat(4)}`, {
1093
- saturation: 70,
1094
- lightness: [30, 60]
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(${color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'}) 5px,
1123
- var(${color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'}) 10px
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
- display: inline-block;
1148
- text-align: right;
1149
- padding: 4px;
1182
+ display: inline-block;
1183
+ text-align: right;
1184
+ padding: 4px;
1150
1185
  }
1151
1186
 
1152
1187
  .annotation-popup .toolbar {
1153
- margin-top: 1em;
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
- pointer-events: none;
1170
- cursor: pointer;
1204
+ pointer-events: none;
1205
+ cursor: pointer;
1171
1206
  }
1172
1207
 
1173
1208
  .annotation::after {
1174
- content: attr(data-type);
1175
- margin-left: 4px;
1176
- pointer-events: all;
1177
- font-family: var(--pb-base-font-family);
1178
- font-size: .8rem;
1179
- font-style: normal;
1180
- font-weight: normal;
1181
- text-decoration: none;
1182
- font-variant: normal;
1183
- padding: 2px;
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);