@teipublisher/pb-components 1.24.20 → 1.27.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.
@@ -454,7 +454,8 @@ class PbViewAnnotate extends PbView {
454
454
 
455
455
  console.log('<pb-view-annotate> Range: %o', range);
456
456
  const span = document.createElement('span');
457
- span.className = `annotation annotation-${teiRange.type} ${teiRange.type}`;
457
+ const addClass = teiRange.properties[this.key] === '' ? 'incomplete' : '';
458
+ span.className = `annotation annotation-${teiRange.type} ${teiRange.type} ${addClass}`;
458
459
  span.dataset.type = teiRange.type;
459
460
  span.dataset.annotation = JSON.stringify(teiRange.properties);
460
461
 
@@ -657,9 +658,12 @@ class PbViewAnnotate extends PbView {
657
658
  range = clearProperties(range);
658
659
  this.emitTo('pb-annotations-changed', { ranges: this._ranges });
659
660
  }
660
-
661
- const json = Object.assign(JSON.parse(span.dataset.annotation), properties);
661
+ const jsonOld = JSON.parse(span.dataset.annotation);
662
+ const json = Object.assign(jsonOld || {}, properties);
662
663
  span.dataset.annotation = JSON.stringify(json);
664
+ if (json[this.key] !== '') {
665
+ span.classList.remove('incomplete');
666
+ }
663
667
  }
664
668
 
665
669
  _editAnnotation(ev) {
@@ -753,7 +757,7 @@ class PbViewAnnotate extends PbView {
753
757
  ev.preventDefault();
754
758
  ev.stopPropagation();
755
759
  const type = span.dataset.type;
756
- const data = JSON.parse(span.dataset.annotation);
760
+ const data = JSON.parse(span.dataset.annotation) || {};
757
761
  const color = this._annotationColors.get(type);
758
762
  typeInd.innerHTML = type;
759
763
  typeInd.style.backgroundColor = `var(--pb-annotation-${type})`;
@@ -896,7 +900,7 @@ class PbViewAnnotate extends PbView {
896
900
  const annoData = node.parentNode.dataset.annotation;
897
901
  const annoType = node.parentNode.dataset.type;
898
902
  if (annoData && annoType) {
899
- const parsed = JSON.parse(annoData);
903
+ const parsed = JSON.parse(annoData) || {};
900
904
  isAnnotated = annoType === type;
901
905
  ref = parsed[this.key];
902
906
  }
@@ -1004,6 +1008,17 @@ class PbViewAnnotate extends PbView {
1004
1008
  classes.push(`
1005
1009
  .annotation-${type}::after {
1006
1010
  background-color: var(--pb-annotation-${type});
1011
+ border-color: var(--pb-annotation-${type});
1012
+ color: var(${color.isLight ? '--pb-color-primary' : '--pb-color-inverse'});
1013
+ }
1014
+ .annotation-${type}.incomplete::after {
1015
+ background: repeating-linear-gradient(
1016
+ 315deg,
1017
+ var(--pb-annotation-${type}),
1018
+ var(--pb-annotation-${type}) 5px,
1019
+ var(${color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'}) 5px,
1020
+ var(${color.isLight ? '--pb-annotation-stripes-light' : '--pb-annotation-stripes-dark'}) 10px
1021
+ );
1007
1022
  color: var(${color.isLight ? '--pb-color-primary' : '--pb-color-inverse'});
1008
1023
  }
1009
1024
  `);
@@ -1064,7 +1079,7 @@ class PbViewAnnotate extends PbView {
1064
1079
  font-variant: normal;
1065
1080
  padding: 2px;
1066
1081
  }
1067
-
1082
+
1068
1083
  [part=highlight] {
1069
1084
  border: 3px solid rgb(255, 174, 0);
1070
1085
  border-radius: 8px;