mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-08 00:50:59 +01:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user