Skip to content

Commit

Permalink
Merge branch 'refs/heads/recogito#115-fix-spans-underlying-offset' in…
Browse files Browse the repository at this point in the history
…to staging
  • Loading branch information
oleksandr-danylchenko committed Jul 9, 2024
2 parents bc18234 + 398bafb commit 3f09c77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/text-annotator/src/highlight/span/spansRenderer.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@
border-width: 0;
border-style: solid;
}

.r6o-annotation {
/* `padding` should grow beyond the `height` and be used as the underline offset */
box-sizing: content-box;
}
6 changes: 3 additions & 3 deletions packages/text-annotator/src/highlight/span/spansRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const computeZIndex = (rect: Rect, all: Rect[]): number => {
const intersects = (a: Rect, b: Rect): boolean => (
a.x <= b.x + b.width && a.x + a.width >= b.x &&
a.y <= b.y + b.height && a.y + a.height >= b.y
);
)

return all.filter(other => (
rect !== other &&
Expand Down Expand Up @@ -85,7 +85,7 @@ const createRenderer = (container: HTMLElement): RendererImplementation => {
span.style.borderBottomWidth = `${style.underlineThickness}px`;

if (style.underlineOffset)
span.style.height = `${rect.height + style.underlineOffset}px`
span.style.paddingBottom = `${style.underlineOffset}px`;

highlightLayer.appendChild(span);
}
Expand Down Expand Up @@ -118,4 +118,4 @@ export const createSpansRenderer = (
container: HTMLElement,
state: TextAnnotatorState,
viewport: ViewportState
) => createBaseRenderer(container, state, viewport, createRenderer(container));
) => createBaseRenderer(container, state, viewport, createRenderer(container))

0 comments on commit 3f09c77

Please sign in to comment.