@samuelbradshaw/highlight-helper-js 0.7.4 → 0.7.5

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.
@@ -457,7 +457,7 @@ function Highlighter(options = hhDefaultOptions) {
457
457
  this.activateHighlight(highlightId);
458
458
  } else if (activeHighlightId && highlightId === activeHighlightId && appearanceChanges.length > 0) {
459
459
  updateSelectionUi('appearance');
460
- } else {
460
+ } else if (highlightId !== activeHighlightId) {
461
461
  this.drawHighlights([highlightId]);
462
462
  }
463
463
 
@@ -916,10 +916,8 @@ function Highlighter(options = hhDefaultOptions) {
916
916
 
917
917
  // Bring active highlight to the front
918
918
  const svgHighlight = svgBackground.querySelector(`g[data-highlight-id="${activeHighlightId}"]`);
919
- if (svgHighlight) {
920
- svgBackground.appendChild(svgHighlight);
921
- svgBackground.appendChild(svgActiveOverlay);
922
- }
919
+ if (svgHighlight) svgBackground.appendChild(svgHighlight);
920
+ svgBackground.appendChild(svgActiveOverlay);
923
921
  }
924
922
 
925
923
  if (changeType === 'appearance') {
@@ -1014,7 +1012,7 @@ function Highlighter(options = hhDefaultOptions) {
1014
1012
 
1015
1013
  // Prevent the range from starting or ending in an element that doesn't match the paragraph selector
1016
1014
  if (this.annotatableContainer.contains(range.commonAncestorContainer) && (!startNode.parentElement.closest(options.paragraphSelector) || !endNode.parentElement.closest(options.paragraphSelector))) {
1017
- let annotatableParagraphsInRange = Array.from(this.annotatableParagraphs).filter((paragraph) => {
1015
+ const annotatableParagraphsInRange = Array.from(this.annotatableParagraphs).filter((paragraph) => {
1018
1016
  const relativeStartPosition = startNode.compareDocumentPosition(paragraph);
1019
1017
  const relativeEndPosition = endNode.compareDocumentPosition(paragraph);
1020
1018
  return (relativeStartPosition & Node.DOCUMENT_POSITION_FOLLOWING || relativeStartPosition & Node.DOCUMENT_POSITION_CONTAINS) && (relativeEndPosition & Node.DOCUMENT_POSITION_PRECEDING || relativeEndPosition & Node.DOCUMENT_POSITION_CONTAINS);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samuelbradshaw/highlight-helper-js",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "JavaScript tool that enables highlighting or underlining text in an HTML page.",
5
5
  "type": "module",
6
6
  "main": "highlight-helper.mjs",