mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
Remove logs tweak visuals, use fit text component
This commit is contained in:
parent
69cb8e7aec
commit
93fcfb280a
@ -2,6 +2,7 @@ import React from 'react';
|
||||
import { Menu, Loader, Group, Text } from '@mantine/core';
|
||||
import VisibilityIcon from '@mui/icons-material/Visibility';
|
||||
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
|
||||
import FitText from './FitText';
|
||||
|
||||
interface FileDropdownMenuProps {
|
||||
displayName: string;
|
||||
@ -30,7 +31,7 @@ export const FileDropdownMenu: React.FC<FileDropdownMenuProps> = ({
|
||||
) : (
|
||||
<VisibilityIcon fontSize="small" />
|
||||
)}
|
||||
<span>{displayName}</span>
|
||||
<FitText text={displayName} fontSize={14} minimumFontScale={0.6} />
|
||||
<KeyboardArrowDownIcon fontSize="small" />
|
||||
</div>
|
||||
</Menu.Target>
|
||||
@ -44,7 +45,6 @@ export const FileDropdownMenu: React.FC<FileDropdownMenuProps> = ({
|
||||
}}>
|
||||
{activeFiles.map((file, index) => {
|
||||
const itemName = file?.name || 'Untitled';
|
||||
const itemDisplayName = itemName.length > 50 ? `${itemName.substring(0, 50)}...` : itemName;
|
||||
const isActive = index === currentFileIndex;
|
||||
return (
|
||||
<Menu.Item
|
||||
@ -60,9 +60,9 @@ export const FileDropdownMenu: React.FC<FileDropdownMenuProps> = ({
|
||||
}}
|
||||
>
|
||||
<Group gap="xs" style={{ width: '100%', justifyContent: 'space-between' }}>
|
||||
<Text size="sm" style={{ flex: 1, textAlign: 'left' }}>
|
||||
{itemDisplayName}
|
||||
</Text>
|
||||
<div style={{ flex: 1, textAlign: 'left', minWidth: 0 }}>
|
||||
<FitText text={itemName} fontSize={14} minimumFontScale={0.7} />
|
||||
</div>
|
||||
{file.versionNumber && file.versionNumber > 1 && (
|
||||
<Text size="xs" c="dimmed">
|
||||
v{file.versionNumber}
|
||||
|
||||
@ -30,9 +30,7 @@ const createViewOptions = (
|
||||
const currentFile = activeFiles[currentFileIndex];
|
||||
const isInViewer = currentView === 'viewer';
|
||||
const fileName = currentFile?.name || '';
|
||||
const displayName = isInViewer && fileName
|
||||
? (fileName.length > 30 ? `${fileName.substring(0, 30)}...` : fileName)
|
||||
: 'Viewer';
|
||||
const displayName = isInViewer && fileName ? fileName : 'Viewer';
|
||||
const hasMultipleFiles = activeFiles.length > 1;
|
||||
const showDropdown = isInViewer && hasMultipleFiles;
|
||||
|
||||
|
||||
@ -59,5 +59,5 @@ code {
|
||||
}
|
||||
|
||||
.viewer-file-tab[data-active] {
|
||||
background-color: rgba(147, 197, 253, 0.8);
|
||||
background-color: rgba(147, 197, 253, 0.5);
|
||||
}
|
||||
|
||||
@ -81,10 +81,6 @@ const Sign = (props: BaseToolProps) => {
|
||||
const fileIndex = activeFileIndex < allFiles.length ? activeFileIndex : 0;
|
||||
const originalFile = allFiles[fileIndex];
|
||||
|
||||
console.log('[Sign] Active file index:', activeFileIndex);
|
||||
console.log('[Sign] All files:', allFiles.map(f => ({ name: f.name, id: f.fileId })));
|
||||
console.log('[Sign] Selected file for signing:', { name: originalFile?.name, id: originalFile?.fileId });
|
||||
|
||||
if (!originalFile) {
|
||||
console.error('No file available to replace');
|
||||
return;
|
||||
@ -102,9 +98,6 @@ const Sign = (props: BaseToolProps) => {
|
||||
});
|
||||
|
||||
if (flattenResult) {
|
||||
console.log('[Sign] About to consume - input IDs:', flattenResult.inputFileIds);
|
||||
console.log('[Sign] About to consume - output file:', { name: flattenResult.outputStirlingFile.name, id: flattenResult.outputStirlingFile.fileId });
|
||||
|
||||
// Now consume the files - this triggers the viewer reload
|
||||
await consumeFiles(
|
||||
flattenResult.inputFileIds,
|
||||
@ -112,24 +105,9 @@ const Sign = (props: BaseToolProps) => {
|
||||
[flattenResult.outputStub]
|
||||
);
|
||||
|
||||
// Find the new file's position in the updated file list and update activeFileIndex
|
||||
const updatedFiles = selectors.getFiles();
|
||||
console.log('[Sign] After consume - updated files:', updatedFiles.map(f => ({ name: f.name, id: f.fileId })));
|
||||
console.log('[Sign] Looking for file ID:', flattenResult.outputStirlingFile.fileId);
|
||||
|
||||
const newFileIndex = updatedFiles.findIndex(f => {
|
||||
console.log('[Sign] Comparing:', f.fileId, 'with', flattenResult.outputStirlingFile.fileId, 'match:', f.fileId === flattenResult.outputStirlingFile.fileId);
|
||||
return f.fileId === flattenResult.outputStirlingFile.fileId;
|
||||
});
|
||||
console.log('[Sign] New file index:', newFileIndex);
|
||||
|
||||
if (newFileIndex !== -1) {
|
||||
setActiveFileIndex(newFileIndex);
|
||||
console.log('[Sign] Set active file index to:', newFileIndex);
|
||||
} else {
|
||||
console.error('[Sign] Failed to find new file in updated list! Defaulting to index 0');
|
||||
setActiveFileIndex(0);
|
||||
}
|
||||
// According to FileReducer.processFileSwap, new files are inserted at the beginning
|
||||
// So the new file will be at index 0
|
||||
setActiveFileIndex(0);
|
||||
|
||||
// Mark signatures as applied
|
||||
setSignaturesApplied(true);
|
||||
|
||||
@ -290,9 +290,6 @@ export async function flattenSignatures(options: SignatureFlatteningOptions): Pr
|
||||
// Prepare input file data for replacement
|
||||
const inputFileIds: FileId[] = [currentFile.fileId];
|
||||
|
||||
console.log('[flattenSignatures] Current file:', { name: currentFile.name, id: currentFile.fileId });
|
||||
console.log('[flattenSignatures] Input file IDs to consume:', inputFileIds);
|
||||
|
||||
const record = selectors.getStirlingFileStub(currentFile.fileId);
|
||||
if (!record) {
|
||||
console.error('No file record found for:', currentFile.fileId);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user