Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: extract URLs embedded within OCR text blocks

Louis Beaumont9824b99a81ed
diff --git a/apps/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx b/apps/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
index e897682c6..47fb91e78 100644
--- a/apps/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
+++ b/apps/screenpipe-app-tauri/components/__tests__/text-overlay.test.tsx
@@ -1,7 +1,12 @@
import { describe, it, expect, vi } from "vitest";
import "../../vitest.setup";
-import { render, screen, fireEvent } from "@testing-library/react";
-import { TextOverlay, isUrl, normalizeUrl } from "../text-overlay";
+import { render, fireEvent } from "@testing-library/react";
+import {
+ TextOverlay,
+ isUrl,
+ normalizeUrl,
+ extractUrlsFromText,
+} from "../text-overlay";
import type { TextPosition } from "@/lib/hooks/use-frame-ocr-data";
// Mock @tauri-apps/plugin-shell
@@ -33,16 +38,14 @@ describe("TextOverlay", () => {
displayedHeight={540}
/>
);
-
expect(container.firstChild).toBeNull();
});
- it("should render nothing when no URLs in text positions (only URLs rendered)", () => {
+ it("should render nothing when no URLs in text positions", () => {
const positions = [
createTextPosition("Hello", 0.1, 0.05, 0.08, 0.02),
createTextPosition("World", 0.2, 0.05, 0.1, 0.02),
];
-
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -52,17 +55,13 @@ describe("TextOverlay", () => {
displayedHeight={540}
/>
);
-
- // Only URLs are rendered, so non-URL text produces null
expect(container.firstChild).toBeNull();
});
- it("should render URLs as clickable links", () => {
+ it("should render a whole-block URL as clickable link", () => {
const positions = [
createTextPosition("https://example.com", 0.1, 0.05, 0.2, 0.02),
- createTextPosition("Regular text", 0.1, 0.1, 0.15, 0.02),
];
-
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -73,34 +72,54 @@ describe("TextOverlay", () => {
clickableUrls={true}
/>
);
-
const link = container.querySelector("a");
expect(link).toBeInTheDocument();
expect(link).toHaveAttribute("href", "https://example.com");
});
- it("should render nothing when displayed dimensions are invalid", () => {
- const positions = [createTextPosition("https://example.com", 0.1, 0.05, 0.2, 0.02)];
-
+ it("should extract and render URLs embedded in longer text", () => {
+ const positions = [
+ createTextPosition(
+ "GitHub: https://github.com/mediar-ai/screenpipe Demo: https://screenpi.pe/demo",
+ 0.1,
+ 0.3,
+ 0.5,
+ 0.02
+ ),
+ ];
const { container } = render(
<TextOverlay
textPositions={positions}
originalWidth={1920}
originalHeight={1080}
- displayedWidth={0}
+ displayedWidth={960}
displayedHeight={540}
+ clickableUrls={true}
/>
);
-
- expect(container.firstChild).toBeNull();
+ const links = container.querySelectorAll("a");
+ expect(links.length).toBe(2);
+ expect(links[0]).toHaveAttribute(
+ "href",
+ "https://github.com/mediar-ai/screenpipe"
+ );
+ expect(links[1]).toHaveAttribute(
+ "href",
+ "https://screenpi.pe/demo"
+ );
});
- it("should filter out positions outside the display bounds", () => {
+ it("should filter out off-screen positions (bounds > 1.0)", () => {
const positions = [
- createTextPosition("https://inside.com", 0.1, 0.05, 0.2, 0.02),
- createTextPosition("https://outside.com", 1.5, 0.05, 0.2, 0.02),
+ createTextPosition("https://onscreen.com", 0.1, 0.05, 0.2, 0.02),
+ createTextPosition(
+ "https://offscreen.com",
+ 1.5,
+ 0.05,
+ 0.2,
+ 0.02
+ ),
];
-
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -111,17 +130,24 @@ describe("TextOverlay", () => {
clickableUrls={true}
/>
);
-
const links = container.querySelectorAll("a");
expect(links.length).toBe(1);
- expect(links[0]).toHaveAttribute("href", "https://inside.com");
+ expect(links[0]).toHaveAttribute("href", "https://onscreen.com");
});
- it("should use shell.open on click via Tauri plugin", async () => {
- const { open: mockShellOpen } = await import("@tauri-apps/plugin-shell");
-
- const positions = [createTextPosition("https://test.com/page", 0.1, 0.05, 0.2, 0.02)];
-
+ it("should use shell.open on click", async () => {
+ const { open: mockShellOpen } = await import(
+ "@tauri-apps/plugin-shell"
+ );
+ const positions = [
+ createTextPosition(
+ "https://test.com/page",
+ 0.1,
+ 0.05,
+ 0.2,
+ 0.02
+ ),
+ ];
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -132,18 +158,21 @@ describe("TextOverlay", () => {
clickableUrls={true}
/>
);
-
const link = container.querySelector("a");
- expect(link).toBeInTheDocument();
-
fireEvent.click(link!);
-
expect(mockShellOpen).toHaveBeenCalledWith("https://test.com/page");
});
- it("should show visible underline on URL links (not invisible)", () => {
- const positions = [createTextPosition("https://example.com", 0.1, 0.3, 0.2, 0.02)];
-
+ it("should show visible underline on links", () => {
+ const positions = [
+ createTextPosition(
+ "https://example.com",
+ 0.1,
+ 0.3,
+ 0.2,
+ 0.02
+ ),
+ ];
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -154,18 +183,15 @@ describe("TextOverlay", () => {
clickableUrls={true}
/>
);
-
const link = container.querySelector("a") as HTMLElement;
- expect(link).toBeInTheDocument();
- // Should have a visible border-bottom (underline)
expect(link.style.borderBottom).toContain("solid");
expect(link.style.cursor).toBe("pointer");
});
it("should expand small click targets to minimum height", () => {
- // OCR box is only 10px tall at display size (0.02 * 500 = 10px)
- const positions = [createTextPosition("https://tiny.com", 0.1, 0.3, 0.2, 0.02)];
-
+ const positions = [
+ createTextPosition("https://tiny.com", 0.1, 0.3, 0.2, 0.02),
+ ];
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -175,21 +201,16 @@ describe("TextOverlay", () => {
displayedHeight={500}
/>
);
-
const link = container.querySelector("a") as HTMLElement;
- expect(link).toBeInTheDocument();
- // Height should be expanded to at least 24px (MIN_LINK_HEIGHT)
const height = parseFloat(link.style.height);
expect(height).toBeGreaterThanOrEqual(24);
});
- it("should detect domain-like URLs with various TLDs", () => {
+ it("should detect URLs with uncommon TLDs", () => {
const positions = [
createTextPosition("app.crisp.chat", 0.1, 0.1, 0.15, 0.02),
createTextPosition("screenpi.pe", 0.1, 0.2, 0.1, 0.02),
- createTextPosition("youtube.com", 0.1, 0.3, 0.1, 0.02),
];
-
const { container } = render(
<TextOverlay
textPositions={positions}
@@ -200,9 +221,96 @@ describe("TextOverlay", () => {
clickableUrls={true}
/>
);
-
const links = container.querySelectorAll("a");
- expect(links.length).toBe(3);
+ expect(links.length).toBe(2);
+ });
+
+ it("should render nothing when displayed dimensions are invalid", () => {
+ const positions = [
+ createTextPosition(
+ "https://example.com",
+ 0.1,
+ 0.05,
+ 0.2,
+ 0.02
+ ),
+ ];
+ const { container } = render(
+ <TextOverlay
+ textPositions={positions}
+ originalWidth={1920}
+ originalHeight={1080}
+ displayedWidth={0}
+ displayedHeight={540}
+ />
+ );
+ expect(container.firstChild).toBeNull();
+ });
+});
+
+describe("extractUrlsFromText", () => {
+ it("should extract https URLs from mixed text", () => {
+ const urls = extractUrlsFromText(
+ "GitHub: https://github.com/mediar-ai/screenpipe Demo: https://screenpi.pe/demo"
+ );
+ expect(urls.length).toBe(2);
+ expect(urls[0].normalizedUrl).toBe(
+ "https://github.com/mediar-ai/screenpipe"
+ );
+ expect(urls[1].normalizedUrl).toBe("https://screenpi.pe/demo");
+ });
+
+ it("should extract www URLs", () => {
+ const urls = extractUrlsFromText(
+ "Visit www.example.com for more info"
+ );
+ expect(urls.length).toBe(1);
+ expect(urls[0].normalizedUrl).toBe("https://www.example.com");
+ });
+
+ it("should extract domain URLs with known TLDs", () => {
+ const urls = extractUrlsFromText(
+ "Check app.crisp.chat and screenpi.pe/demo"
+ );
+ expect(urls.length).toBe(2);
+ });
+
+ it("should compute approximate position fractions", () => {
+ const text = "Go to https://example.com now";
+ const urls = extractUrlsFromText(text);
+ expect(urls.length).toBe(1);
+ // "Go to " is 6 chars, URL starts at index 6
+ expect(urls[0].startFraction).toBeCloseTo(6 / text.length, 1);
+ expect(urls[0].widthFraction).toBeCloseTo(
+ "https://example.com".length / text.length,
+ 1
+ );
+ });
+
+ it("should return empty for text with no URLs", () => {
+ expect(extractUrlsFromText("Hello world")).toEqual([]);
+ expect(extractUrlsFromText("No urls here")).toEqual([]);
+ });
+
+ it("should strip trailing punctuation", () => {
+ const urls = extractUrlsFromText(
+ "See https://example.com. Also check https://test.com)"
+ );
+ expect(urls.length).toBe(2);
+ expect(urls[0].normalizedUrl).toBe("https://example.com");
+ expect(urls[1].normalizedUrl).toBe("https://test.com");
+ });
+
+ it("should handle concatenated URLs (no space between)", () => {
+ // OCR sometimes concatenates: "https://github.com/orgDemo: https://site.com"
+ const urls = extractUrlsFromText(
+ "https://github.com/mediar-ai/screenpipeDemo: https://screenpi.pe/demo"
+ );
+ // The first URL will grab "https://github.com/mediar-ai/screenpipeDemo:"
+ // but trailing punctuation strip removes the colon
+ // The second URL is clean
+ expect(urls.length).toBe(2);
+ expect(urls[1].normalizedUrl).toBe("https://screenpi.pe/demo");
});
});
@@ -210,7 +318,6 @@ describe("isUrl", () => {
it("should detect https URLs", () => {
expect(isUrl("https://example.com")).toBe(true);
expect(isUrl("https://example.com/path")).toBe(true);
- expect(isUrl("https://sub.example.com/path?query=1")).toBe(true);
});
it("should detect http URLs", () => {
@@ -219,59 +326,37 @@ describe("isUrl", () => {
it("should detect www URLs", () => {
expect(isUrl("www.example.com")).toBe(true);
- expect(isUrl("www.example.com/path")).toBe(true);
});
- it("should detect domain-like strings with common TLDs", () => {
+ it("should detect domain-like strings", () => {
expect(isUrl("example.com")).toBe(true);
expect(isUrl("example.io")).toBe(true);
- expect(isUrl("app.example.dev")).toBe(true);
- });
-
- it("should detect domain-like strings with less common TLDs", () => {
expect(isUrl("app.crisp.chat")).toBe(true);
expect(isUrl("screenpi.pe")).toBe(true);
- expect(isUrl("example.cafe")).toBe(true);
- expect(isUrl("my.site.agency")).toBe(true);
});
- it("should not detect regular text as URLs", () => {
+ it("should not detect regular text", () => {
expect(isUrl("hello")).toBe(false);
expect(isUrl("hello world")).toBe(false);
- expect(isUrl("email@example")).toBe(false);
- expect(isUrl("just some text")).toBe(false);
- });
-
- it("should not match text with spaces", () => {
expect(isUrl("reddit .com")).toBe(false);
- expect(isUrl("hello .world")).toBe(false);
- });
-
- it("should not match single-char TLDs", () => {
expect(isUrl("test.a")).toBe(false);
});
});
describe("normalizeUrl", () => {
it("should keep https URLs unchanged", () => {
- expect(normalizeUrl("https://example.com")).toBe("https://example.com");
- });
-
- it("should keep http URLs unchanged", () => {
- expect(normalizeUrl("http://example.com")).toBe("http://example.com");
+ expect(normalizeUrl("https://example.com")).toBe(
+ "https://example.com"
+ );
});
it("should add https to www URLs", () => {
- expect(normalizeUrl("www.example.com")).toBe("https://www.example.com");
+ expect(normalizeUrl("www.example.com")).toBe(
+ "https://www.example.com"
+ );
});
it("should add https to bare domains", () => {
expect(normalizeUrl("example.com")).toBe("https://example.com");
});
-
- it("should trim whitespace", () => {
- expect(normalizeUrl(" https://example.com ")).toBe(
- "https://example.com"
- );
- });
});
diff --git a/apps/screenpipe-app-tauri/components/text-overlay.tsx b/apps/screenpipe-app-tauri/components/text-overlay.tsx
index 51a697e22..4adfa4c93 100644
--- a/apps/screenpipe-app-tauri/components/text-overlay.tsx
+++ b/apps/screenpipe-app-tauri/components/text-overlay.tsx
@@ -8,14 +8,11 @@ import type { TextPosition } from "@/lib/hooks/use-frame-ocr-data";
/**
* Check if a string looks like a URL.
* Matches http(s)://, www., and domain-like patterns.
- * Uses a permissive TLD check: any 2-13 char alphabetic TLD is accepted
- * because OCR text won't produce false positives like "hello.world"
- * in a screenshot context — the text is already rendered UI.
*/
export function isUrl(text: string): boolean {
const trimmed = text.trim();
- // Reject if contains spaces (URLs don't have spaces)
+ // Reject if contains spaces
if (/\s/.test(trimmed)) {
return false;
}
@@ -30,14 +27,66 @@ export function isUrl(text: string): boolean {
return true;
}
- // Check for domain-like patterns: word.tld or sub.word.tld
- // Accept any alphabetic TLD with 2-13 chars (covers .com, .chat, .pe, .website, etc.)
+ // Check for domain-like patterns with any 2-13 char alphabetic TLD
const domainPattern =
/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,13}(\/[^\s]*)?$/;
return domainPattern.test(trimmed);
}
+/**
+ * Regex to find URLs embedded within arbitrary text.
+ * Matches:
+ * - https://... or http://... (up to whitespace)
+ * - www.domain.tld/path
+ * - domain.tld/path (common TLDs only, to avoid false positives in prose)
+ */
+const URL_IN_TEXT_RE =
+ /https?:\/\/[^\s]+|www\.[a-zA-Z0-9-]+\.[a-zA-Z]{2,13}[^\s]*|[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.(?:com|org|net|io|dev|app|co|ai|edu|gov|me|tv|pe|chat|xyz|live|news|pro|tech|cloud|page|link|site|store|blog)(?:\/[^\s]*)?|[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+\.(?:com|org|net|io|dev|app|co|ai|edu|gov|me|tv|pe|chat|xyz|live|news|pro|tech|cloud|page|link|site|store|blog)(?:\/[^\s]*)?/gi;
+
+/**
+ * Extract URLs from a text block and compute their approximate bounding boxes
+ * based on character offset within the block.
+ */
+export interface ExtractedUrl {
+ url: string;
+ normalizedUrl: string;
+ /** Fraction of the text block width where this URL starts (0-1) */
+ startFraction: number;
+ /** Fraction of the text block width this URL spans (0-1) */
+ widthFraction: number;
+}
+
+export function extractUrlsFromText(text: string): ExtractedUrl[] {
+ const results: ExtractedUrl[] = [];
+ const totalLen = text.length;
+ if (totalLen === 0) return results;
+
+ let match: RegExpExecArray | null;
+ // Reset lastIndex for global regex
+ URL_IN_TEXT_RE.lastIndex = 0;
+
+ while ((match = URL_IN_TEXT_RE.exec(text)) !== null) {
+ const url = match[0];
+ // Clean trailing punctuation that's unlikely part of the URL
+ const cleaned = url.replace(/[),;:!?.'"\]]+$/, "");
+ if (cleaned.length < 4) continue;
+
+ const startIdx = match.index;
+ const startFraction = startIdx / totalLen;
+ const widthFraction = cleaned.length / totalLen;
+
+ results.push({
+ url: cleaned,
+ normalizedUrl: normalizeUrl(cleaned),
+ startFraction,
+ widthFraction,
+ });
+ }
+
+ return results;
+}
+
/**
* Normalize a URL for opening (add protocol if missing)
*/
@@ -49,7 +98,6 @@ export function normalizeUrl(url: string): string {
if (trimmed.startsWith("www.")) {
return `https://${trimmed}`;
}
- // If it looks like a domain, add https
return `https://${trimmed}`;
}
@@ -74,29 +122,27 @@ interface TextOverlayProps {
clickableUrls?: boolean;
}
-interface ScaledTextPosition extends TextPosition {
- scaledBounds: {
- left: number;
- top: number;
- width: number;
- height: number;
- };
+/** A URL link to render, with pixel coordinates */
+interface UrlLink {
+ key: string;
+ normalizedUrl: string;
+ displayUrl: string;
+ left: number;
+ top: number;
+ width: number;
+ height: number;
}
-interface ScaledTextPositionWithUrl extends ScaledTextPosition {
- isUrl: boolean;
- normalizedUrl?: string;
-}
-
-// Minimum click target height in pixels — OCR boxes can be tiny (8-13px)
+// Minimum click target height in pixels
const MIN_LINK_HEIGHT = 24;
-// Extra horizontal padding on each side for easier clicking
+// Extra horizontal padding on each side
const LINK_PADDING_X = 4;
/**
* TextOverlay renders clickable URL links positioned over a screenshot.
- * URLs are detected from OCR text and rendered as visible, hoverable links.
- * Clicking opens the URL in the system default browser via Tauri shell.
+ * URLs are detected from OCR text (even embedded in longer text blocks)
+ * and rendered as visible, hoverable links. Clicking opens the URL in
+ * the system default browser via Tauri shell.
*/
export const TextOverlay = memo(function TextOverlay({
textPositions,
@@ -111,41 +157,70 @@ export const TextOverlay = memo(function TextOverlay({
}: TextOverlayProps) {
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
- // Scale and filter text positions, detect URLs
- // Note: OCR bounds are normalized (0-1 range), so we multiply directly by displayed dimensions
- const scaledPositions = useMemo<ScaledTextPositionWithUrl[]>(() => {
- if (!displayedWidth || !displayedHeight) {
- return [];
+ // Find all URLs across all text positions and compute their pixel positions
+ const urlLinks = useMemo<UrlLink[]>(() => {
+ if (!displayedWidth || !displayedHeight) return [];
+
+ const links: UrlLink[] = [];
+
+ for (const pos of textPositions) {
+ if (pos.confidence < minConfidence) continue;
+
+ // Scale the block's bounding box to display pixels
+ const blockLeft = pos.bounds.left * displayedWidth;
+ const blockTop = pos.bounds.top * displayedHeight;
+ const blockWidth = pos.bounds.width * displayedWidth;
+ const blockHeight = pos.bounds.height * displayedHeight;
+
+ // Skip off-screen or invalid blocks
+ if (
+ blockWidth <= 0 ||
+ blockHeight <= 0 ||
+ blockLeft < 0 ||
+ blockTop < 0 ||
+ blockLeft + blockWidth > displayedWidth + 1 ||
+ blockTop + blockHeight > displayedHeight + 1
+ ) {
+ continue;
+ }
+
+ // First: check if the entire text is a URL
+ if (isUrl(pos.text)) {
+ links.push({
+ key: `${links.length}-${pos.text.slice(0, 20)}`,
+ normalizedUrl: normalizeUrl(pos.text),
+ displayUrl: pos.text,
+ left: blockLeft,
+ top: blockTop,
+ width: blockWidth,
+ height: blockHeight,
+ });
+ continue;
+ }
+
+ // Second: extract URLs embedded within the text
+ const extracted = extractUrlsFromText(pos.text);
+ for (const ext of extracted) {
+ const urlLeft = blockLeft + ext.startFraction * blockWidth;
+ const urlWidth = ext.widthFraction * blockWidth;
+
+ // Skip if the computed URL region is too small or off-screen
+ if (urlWidth < 10) continue;
+ if (urlLeft + urlWidth > displayedWidth + 1) continue;
+
+ links.push({
+ key: `${links.length}-${ext.url.slice(0, 20)}`,
+ normalizedUrl: ext.normalizedUrl,
+ displayUrl: ext.url,
+ left: urlLeft,
+ top: blockTop,
+ width: urlWidth,
+ height: blockHeight,
+ });
+ }
}
- return textPositions
- .filter((pos) => pos.confidence >= minConfidence)
- .map((pos) => {
- const textIsUrl = isUrl(pos.text);
- return {
- ...pos,
- scaledBounds: {
- left: pos.bounds.left * displayedWidth,
- top: pos.bounds.top * displayedHeight,
- width: pos.bounds.width * displayedWidth,
- height: pos.bounds.height * displayedHeight,
- },
- isUrl: textIsUrl,
- normalizedUrl: textIsUrl ? normalizeUrl(pos.text) : undefined,
- };
- })
- .filter(
- (pos) =>
- pos.scaledBounds.width > 0 &&
- pos.scaledBounds.height > 0 &&
- pos.scaledBounds.left >= 0 &&
- pos.scaledBounds.top >= 0 &&
- // Allow small overflow (1px tolerance) for rounding
- pos.scaledBounds.left + pos.scaledBounds.width <=
- displayedWidth + 1 &&
- pos.scaledBounds.top + pos.scaledBounds.height <=
- displayedHeight + 1
- );
+ return links;
}, [textPositions, displayedWidth, displayedHeight, minConfidence]);
const handleUrlClick = useCallback(
@@ -156,19 +231,13 @@ export const TextOverlay = memo(function TextOverlay({
await shellOpen(url);
} catch (err) {
console.error("failed to open URL:", url, err);
- // Fallback: try window.open
window.open(url, "_blank", "noopener,noreferrer");
}
},
[]
);
- // Only render URLs (text selection is disabled for now)
- const positionsToRender = scaledPositions.filter(
- (pos) => pos.isUrl && pos.normalizedUrl
- );
-
- if (positionsToRender.length === 0) {
+ if (!clickableUrls || urlLinks.length === 0) {
return null;
}
@@ -181,33 +250,32 @@ export const TextOverlay = memo(function TextOverlay({
pointerEvents: "none",
}}
>
- {positionsToRender.map((pos, index) => {
- if (!clickableUrls || !pos.normalizedUrl) return null;
-
+ {urlLinks.map((link, index) => {
const isHovered = hoveredIndex === index;
- // Enlarge the click target for small OCR boxes
- const rawH = pos.scaledBounds.height;
+ // Enlarge click target for small OCR boxes
+ const rawH = link.height;
const targetH = Math.max(rawH, MIN_LINK_HEIGHT);
const extraY = (targetH - rawH) / 2;
- const targetW = pos.scaledBounds.width + LINK_PADDING_X * 2;
+ const targetW = link.width + LINK_PADDING_X * 2;
return (
<a
- key={`${index}-${pos.text.slice(0, 20)}`}
- href={pos.normalizedUrl}
- onClick={(e) => handleUrlClick(pos.normalizedUrl!, e)}
+ key={link.key}
+ href={link.normalizedUrl}
+ onClick={(e) =>
+ handleUrlClick(link.normalizedUrl, e)
+ }
onMouseEnter={() => setHoveredIndex(index)}
onMouseLeave={() => setHoveredIndex(null)}
className="absolute block"
style={{
- left: pos.scaledBounds.left - LINK_PADDING_X,
- top: pos.scaledBounds.top - extraY,
+ left: link.left - LINK_PADDING_X,
+ top: link.top - extraY,
width: targetW,
height: targetH,
cursor: "pointer",
pointerEvents: "auto",
- // Visible underline always, highlight on hover
borderBottom: isHovered
? "2px solid rgba(96, 165, 250, 0.9)"
: "2px solid rgba(96, 165, 250, 0.45)",
@@ -217,7 +285,6 @@ export const TextOverlay = memo(function TextOverlay({
borderRadius: "2px",
transition:
"background-color 0.15s, border-color 0.15s",
- // Debug mode
...(debug
? {
border: "1px solid rgba(59, 130, 246, 0.7)",
@@ -226,25 +293,26 @@ export const TextOverlay = memo(function TextOverlay({
}
: {}),
}}
- title={`Open ${pos.normalizedUrl}`}
+ title={`Open ${link.normalizedUrl}`}
target="_blank"
rel="noopener noreferrer"
>
- {/* Tooltip on hover showing the URL */}
{isHovered && (
<span
className="absolute left-0 whitespace-nowrap text-xs px-2 py-1 rounded shadow-lg border z-50"
style={{
bottom: targetH + 4,
- backgroundColor: "rgba(0, 0, 0, 0.85)",
+ backgroundColor:
+ "rgba(0, 0, 0, 0.85)",
color: "rgba(96, 165, 250, 1)",
- borderColor: "rgba(96, 165, 250, 0.3)",
+ borderColor:
+ "rgba(96, 165, 250, 0.3)",
maxWidth: "400px",
overflow: "hidden",
textOverflow: "ellipsis",
}}
>
- {pos.normalizedUrl}
+ {link.normalizedUrl}
</span>
)}
</a>
@@ -272,7 +340,6 @@ interface TextOverlayWithImageProps {
/**
* A wrapper that renders TextOverlay positioned correctly relative to an image.
- * Use this when you have an image ref and want to overlay text on it.
*/
export const TextOverlayForImage = memo(function TextOverlayForImage({
textPositions,