@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.
- package/highlight-helper.js +6 -9
- package/package.json +1 -1
package/highlight-helper.js
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
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