@teipublisher/pb-components 1.30.1 → 1.31.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.
@@ -323,7 +323,7 @@ class PbViewAnnotate extends PbView {
323
323
 
324
324
  set annotations(annoData) {
325
325
  this._ranges = annoData;
326
- this.updateAnnotations();
326
+ this.updateAnnotations(true);
327
327
  this._initAnnotationColors();
328
328
  this._annotationStyles();
329
329
  }
@@ -413,7 +413,7 @@ class PbViewAnnotate extends PbView {
413
413
  }, 300));
414
414
  }
415
415
 
416
- _updateAnnotation(teiRange, batch = false) {
416
+ _updateAnnotation(teiRange, silent = false, batch = false) {
417
417
  const view = this.shadowRoot.getElementById('view');
418
418
  const context = Array.from(view.querySelectorAll(`[data-tei="${teiRange.context}"]`)).filter(
419
419
  node => node.closest('pb-popover') === null && node.getAttribute('rel') !== 'footnote',
@@ -467,6 +467,9 @@ class PbViewAnnotate extends PbView {
467
467
  try {
468
468
  range.surroundContents(span);
469
469
  } catch (e) {
470
+ if (silent) {
471
+ return null;
472
+ }
470
473
  throw new Error('An error occurred. The annotation may not be displayed. You should consider saving and reloading the document.');
471
474
  }
472
475
  this._rangesMap.set(span, teiRange);
@@ -478,7 +481,7 @@ class PbViewAnnotate extends PbView {
478
481
  return span;
479
482
  }
480
483
 
481
- updateAnnotations() {
484
+ updateAnnotations(silent = false) {
482
485
  this._ranges.forEach((teiRange) => {
483
486
  let span;
484
487
  switch (teiRange.type) {
@@ -495,7 +498,7 @@ class PbViewAnnotate extends PbView {
495
498
  span.dataset.annotation = JSON.stringify(teiRange.properties);
496
499
  break;
497
500
  default:
498
- this._updateAnnotation(teiRange, true);
501
+ this._updateAnnotation(teiRange, silent, true);
499
502
  break;
500
503
  }
501
504
  });