refactor: remove HTML report export and implement PDF export options in PDF comparison tool

- Deleted the exportCompareHtmlReport function and its related imports.
- Introduced a dropdown menu for exporting comparison results as PDFs with multiple modes (split, alternating, left, right).
- Updated the comparison logic to utilize caching for page models and comparison results.
- Refactored rendering functions to improve code organization and maintainability.
- Enhanced UI elements for better user experience during PDF export.
This commit is contained in:
alam00000
2026-03-09 23:27:40 +05:30
parent 0fe94795cc
commit d2a1450bc0
15 changed files with 953 additions and 526 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
import type { CompareTextItem } from '../types.ts';
import type { CompareRectangle, CompareTextItem } from '../types.ts';
export function normalizeCompareText(text: string) {
return text
@@ -62,3 +62,22 @@ export function isLowQualityExtractedText(text: string) {
return false;
}
export function tokenizeText(text: string): string[] {
return text.split(/\s+/).filter(Boolean);
}
export function tokenizeTextAsSet(text: string): Set<string> {
return new Set(tokenizeText(text));
}
export function calculateBoundingRect(
rects: CompareRectangle[]
): CompareRectangle {
if (rects.length === 0) return { x: 0, y: 0, width: 0, height: 0 };
const minX = Math.min(...rects.map((r) => r.x));
const minY = Math.min(...rects.map((r) => r.y));
const maxX = Math.max(...rects.map((r) => r.x + r.width));
const maxY = Math.max(...rects.map((r) => r.y + r.height));
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
}