feat: Introduce configurable icon and card sizes for document views and desktop workspace.
This commit is contained in:
@@ -38,8 +38,9 @@ interface DocumentSizeInfo {
|
||||
}
|
||||
|
||||
// Fallback size computation
|
||||
const computeFallbackCardSize = (_doc: DeskDocument): DocumentSizeInfo => {
|
||||
return { width: 200, height: 200, source: 'fallback' };
|
||||
const computeFallbackCardSize = (_doc: DeskDocument, defaultSize: number = 200): DocumentSizeInfo => {
|
||||
const size = Math.round(defaultSize * (1 / Math.SQRT2));
|
||||
return { width: size, height: size, source: 'fallback' };
|
||||
};
|
||||
|
||||
export interface DesktopWorkspaceProps {
|
||||
@@ -52,6 +53,7 @@ export interface DesktopWorkspaceProps {
|
||||
onDocumentTagDetach?: (docId: Identifier, tagId: Identifier) => void;
|
||||
tenantId?: Identifier | null;
|
||||
viewId?: string | null;
|
||||
defaultCardSize?: number;
|
||||
}
|
||||
|
||||
// Wrapper to handle hooks per card
|
||||
@@ -86,6 +88,7 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
||||
onDocumentTagDetach,
|
||||
tenantId,
|
||||
viewId,
|
||||
defaultCardSize = 200,
|
||||
}) => {
|
||||
const { openPreview } = usePreviewContext();
|
||||
const { addPointer, removePointer } = usePointerTracking();
|
||||
@@ -179,8 +182,8 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
||||
return { width: meta.width, height: meta.height, source: 'metadata' };
|
||||
}
|
||||
|
||||
return computeFallbackCardSize(doc);
|
||||
}, [metadataMap]);
|
||||
return computeFallbackCardSize(doc, defaultCardSize);
|
||||
}, [metadataMap, defaultCardSize]);
|
||||
|
||||
// Sync LayoutStore to layoutRef
|
||||
useEffect(() => {
|
||||
@@ -371,9 +374,10 @@ const DesktopWorkspaceContent: React.FC<DesktopWorkspaceProps> = ({
|
||||
const pageCount = metadata?.page_count ?? 1;
|
||||
|
||||
const layoutCard = layoutStore.initialize(docId, null, {
|
||||
width: Number.isFinite(size.width) && size.width > 0 ? size.width : 200,
|
||||
height: Number.isFinite(size.height) && size.height > 0 ? size.height : 200,
|
||||
pageCount
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
pageCount,
|
||||
maxSize: defaultCardSize
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user