feat: enhance PDF comparison with new change types and zoom functionality

- Added support for 'moved' and 'style-changed' change types in PDF comparison.
- Implemented category filters for changes, allowing users to filter by text, images, headers, annotations, formatting, and background.
- Introduced zoom functionality with buttons for zooming in, out, and resetting to default.
- Updated UI to reflect new change types and categories, including visual indicators for moved and style-changed items.
- Enhanced summary display to include counts for moved and style-changed changes.
- Refactored rendering logic to accommodate zoom levels and improve performance.
- Added tests for new change detection features and category assignments.
This commit is contained in:
alam00000
2026-03-10 13:51:23 +05:30
parent 89d7cd8e3d
commit 5232102ac0
31 changed files with 2503 additions and 183 deletions
@@ -71,6 +71,32 @@ export function tokenizeTextAsSet(text: string): Set<string> {
return new Set(tokenizeText(text));
}
const CJK_REGEX =
/[\u2E80-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\u{20000}-\u{2FA1F}]/u;
export function containsCJK(text: string): boolean {
return CJK_REGEX.test(text);
}
let cachedSegmenter: Intl.Segmenter | null = null;
function getWordSegmenter(): Intl.Segmenter | null {
if (cachedSegmenter) return cachedSegmenter;
if (typeof Intl !== 'undefined' && Intl.Segmenter) {
cachedSegmenter = new Intl.Segmenter(undefined, { granularity: 'word' });
return cachedSegmenter;
}
return null;
}
export function segmentCJKText(text: string): string[] {
const segmenter = getWordSegmenter();
if (!segmenter) return [text];
return [...segmenter.segment(text)]
.filter((seg) => seg.isWordLike)
.map((seg) => seg.segment);
}
export function calculateBoundingRect(
rects: CompareRectangle[]
): CompareRectangle {