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 committed 2026-03-09 23:27:40 +05:30
1 parent 0fe94795cc
commit d2a1450bc0
15 files changed
+953 -526

No files matched your search

+10 -6
View File
@@ -33,8 +33,10 @@ const textMeasurementCache: Map<string, number> | null = measurementContext
: null;
let lastMeasurementFont = '';
const DEFAULT_CHAR_WIDTH = 1;
const DEFAULT_SPACE_WIDTH = 0.33;
import { COMPARE_TEXT, COMPARE_GEOMETRY } from '../config.ts';
const DEFAULT_CHAR_WIDTH = COMPARE_TEXT.DEFAULT_CHAR_WIDTH;
const DEFAULT_SPACE_WIDTH = COMPARE_TEXT.DEFAULT_SPACE_WIDTH;
function shouldJoinTokenWithPrevious(previous: string, current: string) {
if (!previous) return false;
@@ -261,8 +263,9 @@ function toRect(
export function sortCompareTextItems(items: CompareTextItem[]) {
return [...items].sort((left, right) => {
const lineTolerance = Math.max(
Math.min(left.rect.height, right.rect.height) * 0.6,
4
Math.min(left.rect.height, right.rect.height) *
COMPARE_GEOMETRY.LINE_TOLERANCE_FACTOR,
COMPARE_GEOMETRY.MIN_LINE_TOLERANCE
);
const topDiff = left.rect.y - right.rect.y;
@@ -450,8 +453,9 @@ export function mergeIntoLines(
const anchor = currentLine[0];
const curr = sortedItems[i];
const lineTolerance = Math.max(
Math.min(anchor.rect.height, curr.rect.height) * 0.6,
4
Math.min(anchor.rect.height, curr.rect.height) *
COMPARE_GEOMETRY.LINE_TOLERANCE_FACTOR,
COMPARE_GEOMETRY.MIN_LINE_TOLERANCE
);
if (Math.abs(curr.rect.y - anchor.rect.y) <= lineTolerance) {