|
2 | 2 | import { shortcuts } from '$lib/actions/shortcut'; |
3 | 3 | import { zoomImageAction } from '$lib/actions/zoom-image'; |
4 | 4 | import FaceEditor from '$lib/components/asset-viewer/face-editor/face-editor.svelte'; |
| 5 | + import OcrBoundingBox from '$lib/components/asset-viewer/ocr-bounding-box.svelte'; |
5 | 6 | import BrokenAsset from '$lib/components/assets/broken-asset.svelte'; |
6 | 7 | import { assetViewerFadeDuration } from '$lib/constants'; |
7 | 8 | import { castManager } from '$lib/managers/cast-manager.svelte'; |
8 | 9 | import type { TimelineAsset } from '$lib/managers/timeline-manager/types'; |
9 | 10 | import { photoViewerImgElement } from '$lib/stores/assets-store.svelte'; |
10 | 11 | import { isFaceEditMode } from '$lib/stores/face-edit.svelte'; |
| 12 | + import { ocrManager } from '$lib/stores/ocr.svelte'; |
11 | 13 | import { boundingBoxesArray } from '$lib/stores/people.store'; |
12 | 14 | import { alwaysLoadOriginalFile } from '$lib/stores/preferences.store'; |
13 | 15 | import { SlideshowLook, SlideshowState, slideshowLookCssMapping, slideshowStore } from '$lib/stores/slideshow.store'; |
14 | 16 | import { photoZoomState } from '$lib/stores/zoom-image.store'; |
15 | 17 | import { getAssetOriginalUrl, getAssetThumbnailUrl, handlePromiseError } from '$lib/utils'; |
16 | 18 | import { canCopyImageToClipboard, copyImageToClipboard, isWebCompatibleImage } from '$lib/utils/asset-utils'; |
17 | 19 | import { handleError } from '$lib/utils/handle-error'; |
| 20 | + import { getOcrBoundingBoxes } from '$lib/utils/ocr-utils'; |
18 | 21 | import { getBoundingBox } from '$lib/utils/people-utils'; |
19 | 22 | import { cancelImageUrl } from '$lib/utils/sw-messaging'; |
20 | 23 | import { getAltText } from '$lib/utils/thumbnail-util'; |
|
71 | 74 | $boundingBoxesArray = []; |
72 | 75 | }); |
73 | 76 |
|
| 77 | + let ocrBoxes = $derived( |
| 78 | + ocrManager.showOverlay && $photoViewerImgElement |
| 79 | + ? getOcrBoundingBoxes(ocrManager.data, $photoZoomState, $photoViewerImgElement) |
| 80 | + : [], |
| 81 | + ); |
| 82 | +
|
| 83 | + let isOcrActive = $derived(ocrManager.showOverlay); |
| 84 | +
|
74 | 85 | const preload = (targetSize: AssetMediaSize | 'original', preloadAssets?: TimelineAsset[]) => { |
75 | 86 | for (const preloadAsset of preloadAssets || []) { |
76 | 87 | if (preloadAsset.isImage) { |
|
130 | 141 | if ($photoZoomState.currentZoom > 1) { |
131 | 142 | return; |
132 | 143 | } |
| 144 | +
|
| 145 | + if (ocrManager.showOverlay) { |
| 146 | + return; |
| 147 | + } |
| 148 | +
|
133 | 149 | if (onNextAsset && event.detail.direction === 'left') { |
134 | 150 | onNextAsset(); |
135 | 151 | } |
| 152 | +
|
136 | 153 | if (onPreviousAsset && event.detail.direction === 'right') { |
137 | 154 | onPreviousAsset(); |
138 | 155 | } |
|
235 | 252 | </div> |
236 | 253 | {:else if !imageError} |
237 | 254 | <div |
238 | | - use:zoomImageAction |
| 255 | + use:zoomImageAction={{ disabled: isOcrActive }} |
239 | 256 | {...useSwipe(onSwipe)} |
240 | 257 | class="h-full w-full" |
241 | 258 | transition:fade={{ duration: haveFadeTransition ? assetViewerFadeDuration : 0 }} |
|
264 | 281 | style="top: {boundingbox.top}px; left: {boundingbox.left}px; height: {boundingbox.height}px; width: {boundingbox.width}px;" |
265 | 282 | ></div> |
266 | 283 | {/each} |
| 284 | + |
| 285 | + {#each ocrBoxes as ocrBox (ocrBox.id)} |
| 286 | + <OcrBoundingBox {ocrBox} /> |
| 287 | + {/each} |
267 | 288 | </div> |
268 | 289 |
|
269 | 290 | {#if isFaceEditMode.value} |
|
0 commit comments