Skip to content

Commit

Permalink
MET-3209 ignore empty spans for css class on first span
Browse files Browse the repository at this point in the history
  • Loading branch information
agentschmitt committed May 16, 2024
1 parent 896c839 commit dbc90c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/highlighter/Highlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ export default class Highlighter {
// apply extra classes if there are any; ensure .r6o-annotation added regardless
spans.forEach(span => span.className = `r6o-annotation ${extraClasses}`.trim());

// apply special class for first element
spans[0].className = spans[0].className + " r6o-first";
// get first span with content & apply special class
const firstSpan = spans.find(s => s.innerText) ?? spans[0];
firstSpan.className = firstSpan.className + " r6o-first";
}

bindAnnotation = (annotation, elements) => {
Expand Down

0 comments on commit dbc90c7

Please sign in to comment.