@samuelbradshaw/highlight-helper-js 0.7.2 → 0.7.3

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.
@@ -702,7 +702,7 @@ function Highlighter(options = hhDefaultOptions) {
702
702
 
703
703
  // Long press in annotatable container (triggered by setTimeout() in pointerdown event)
704
704
  const respondToLongPress = (event) => {
705
- respondToPointerUp(event, isLongPress = true);
705
+ respondToPointerUp(event, true);
706
706
  tapResult = null;
707
707
  }
708
708
 
@@ -1271,7 +1271,6 @@ function Highlighter(options = hhDefaultOptions) {
1271
1271
  for (const paragraph of paragraphs) {
1272
1272
  const paragraphRect = paragraph.getBoundingClientRect();
1273
1273
  const computedParagraphStyle = window.getComputedStyle(paragraph);
1274
- const paragraphLineHeight = parseInt((computedParagraphStyle.lineHeight === 'normal' ? computedParagraphStyle.fontSize : computedParagraphStyle.lineHeight).replace('px', ''));
1275
1274
  const paragraphTopPadding = parseInt(computedParagraphStyle.getPropertyValue('padding-top').replace('px', ''));
1276
1275
 
1277
1276
  // Get line positions (bottom edge of each line)
@@ -1279,13 +1278,11 @@ function Highlighter(options = hhDefaultOptions) {
1279
1278
  let lineWalker = document.createTreeWalker(paragraph, NodeFilter.SHOW_TEXT);
1280
1279
  let textNode;
1281
1280
  while (textNode = lineWalker.nextNode()) {
1282
- const computedStyle = window.getComputedStyle(textNode.parentElement);
1283
- const lineHeight = parseInt((computedStyle.lineHeight === 'normal' ? computedStyle.fontSize : computedStyle.lineHeight).replace('px', ''));
1284
- if (lineHeight >= paragraphLineHeight) {
1285
- const referenceRange = document.createRange();
1286
- referenceRange.selectNode(textNode);
1287
- for (const rangeRect of referenceRange.getClientRects()) linePositions.add(rangeRect.bottom);
1288
- }
1281
+ // Skip text nodes in elements that are higher or lower than surrounding text
1282
+ if (textNode.parentElement.closest('sup, sub, rt')) continue;
1283
+ const referenceRange = document.createRange();
1284
+ referenceRange.selectNode(textNode);
1285
+ for (const rangeRect of referenceRange.getClientRects()) linePositions.add(rangeRect.bottom);
1289
1286
  }
1290
1287
  linePositions = Array.from(linePositions);
1291
1288
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samuelbradshaw/highlight-helper-js",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
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",