Do not underline inline LaTeX, inline code, images
All checks were successful
Build on Push and create Release on Tag / build (push) Successful in 4m7s

This commit is contained in:
MassiveBox 2025-10-19 10:48:45 +02:00
parent 0442ac2bac
commit 8fcc1c76e9
Signed by: massivebox
GPG key ID: 9B74D3A59181947D
3 changed files with 47 additions and 13 deletions

View file

@ -41,6 +41,28 @@ export class ProtyleHelper {
return document.querySelector(`div.underline-overlay[for-block-id="${blockID}"]`)
}
public static getElementAtTextIndex(root: Element, index: number): Node {
let currentOffset = 0;
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, null);
while (walker.nextNode()) {
let node = walker.currentNode
const textLength = node.textContent.length;
if (currentOffset + textLength >= index) {
let parent: Element = node.parentElement;
while (parent && parent != root) {
node = parent
parent = node.parentElement
}
return node; // The element containing this text
}
currentOffset += textLength;
}
return null;
}
// given an element such as a span inside a block, return its blockID
public static getNodeId(el: Element) {
let i = 0;