Merge pull request #2442 from omnivore-app/fix/web-highlight-tables

Handle all whitespace nodes when creating highlights, improve highlight view styling
This commit is contained in:
Jackson Harper
2023-06-29 07:54:41 +08:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@ -113,12 +113,12 @@ export function HighlightView(props: HighlightViewProps): JSX.Element {
<StyledQuote>
<SpanBox
css={{
'> *': {
'*': {
m: '0px',
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) {