import type {FilePreviewHandle, ImageViewportHandle, StudioOptions} from '@useflex/media-studio';
let preview: FilePreviewHandle | null = null;
let image: ImageViewportHandle | null = null;
const options: StudioOptions = {
transport,
previewTitleEditable: true,
onPreviewReady(handle) { preview = handle; },
imagePreview: {
zoomControls: 'header', // 'hidden' for custom controls
gestures: true,
wheelBehavior: 'zoom', // default; use 'pan' for ordinary-wheel panning
fitPadding: 0.1, // 90% of the full viewport fit
maxRelativeZoom: 8, // relative to the unpadded fit; additionally texture-limited
animationMs: 200,
onReady(handle, entry) { image = handle; },
onViewport(state, entry) { /* ready, zoom, fit, fitZoom, x, y, minZoom, maxZoom */ },
},
};
preview?.setZoom(2);
preview?.showPanel('comments'); // information | comments | assistant | none
preview?.navigate('next');
preview?.search('invoice'); // false when the current format has no search
await preview?.print(); // false when printing is unavailable or forbidden
await preview?.rename('Updated photograph.jpg', new AbortController().signal);
preview?.close();
image?.zoomTo(1); // animated actual intrinsic image size
image?.zoomTo('fit');
image?.zoomBy(1.5, {point: {x: 400, y: 300}}); // viewport/client coordinates
image?.panBy(-80, 0);
const unsubscribe = image?.subscribe(state => { /* discrete commands / settled gestures */ });
unsubscribe?.();