Handle all whitespace nodes when creating highlights, improve highlight view styling

This commit is contained in:
Jackson Harper
2023-06-28 15:42:31 +08:00
parent e0c59434d7
commit d511d43593
2 changed files with 6 additions and 1 deletions

View File

@ -118,7 +118,7 @@ export function HighlightView(props: HighlightViewProps): JSX.Element {
display: 'inline',
padding: '2px',
backgroundColor: `rgba(var(--colors-highlightBackground), ${highlightAlpha})`,
boxShadow: `1px 0 0 rgba(var(--colors-highlightBackground), ${highlightAlpha}), -1px 0 0 rgba(var(--colors-highlightBackground), ${highlightAlpha})`,
boxShadow: `3px 0 0 rgba(var(--colors-highlightBackground), ${highlightAlpha}), -3px 0 0 rgba(var(--colors-highlightBackground), ${highlightAlpha})`,
boxDecorationBreak: 'clone',
borderRadius: '2px',
},

View File

@ -115,6 +115,11 @@ export function makeHighlightNodeAttributes(
})
const { parentNode, nextSibling } = node
if (node.textContent && !/[^\t\n\r ]/.test(node.textContent)) {
startingTextNodeIndex++
continue
}
let isPre = false
const nodeElement = node instanceof HTMLElement ? node : node.parentElement
if (nodeElement) {