mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-26 17:52:59 +02:00
Reduce logs
This commit is contained in:
parent
023fd43b72
commit
51caad636c
@ -88,7 +88,7 @@ http {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
}
|
||||
n }
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
|
@ -190,15 +190,7 @@ const EmbedPdfViewerContent = ({
|
||||
signatureApiRef={signatureApiRef as React.RefObject<any>}
|
||||
historyApiRef={historyApiRef as React.RefObject<any>}
|
||||
onSignatureAdded={(annotation) => {
|
||||
console.log('Signature added:', annotation);
|
||||
if (annotation.type === 13) {
|
||||
console.log('- imageSrc:', !!annotation.imageSrc, annotation.imageSrc?.length);
|
||||
console.log('- contents:', !!annotation.contents, annotation.contents?.length);
|
||||
console.log('- data:', !!annotation.data, annotation.data?.length);
|
||||
console.log('- imageData:', !!annotation.imageData, annotation.imageData?.length);
|
||||
console.log('- appearance:', !!annotation.appearance, typeof annotation.appearance);
|
||||
console.log('- All keys:', Object.keys(annotation));
|
||||
}
|
||||
// Handle signature added - for debugging, enable console logs as needed
|
||||
// Future: Handle signature completion
|
||||
}}
|
||||
/>
|
||||
|
@ -148,29 +148,20 @@ export const SignatureAPIBridge = forwardRef<SignatureAPI, SignatureAPIBridgePro
|
||||
},
|
||||
|
||||
activateSignaturePlacementMode: () => {
|
||||
console.log('SignatureAPIBridge.activateSignaturePlacementMode called');
|
||||
console.log('annotationApi:', !!annotationApi, 'signatureConfig:', !!signatureConfig);
|
||||
if (!annotationApi || !signatureConfig) return;
|
||||
|
||||
try {
|
||||
console.log('Signature type:', signatureConfig.signatureType);
|
||||
console.log('Font settings:', { fontFamily: signatureConfig.fontFamily, fontSize: signatureConfig.fontSize });
|
||||
if (signatureConfig.signatureType === 'text' && signatureConfig.signerName) {
|
||||
console.log('Trying different text tool names');
|
||||
|
||||
// Try different tool names for text annotations
|
||||
const textToolNames = ['freetext', 'text', 'textbox', 'annotation-text'];
|
||||
let activatedTool = null;
|
||||
|
||||
for (const toolName of textToolNames) {
|
||||
console.log(`Trying tool: ${toolName}`);
|
||||
annotationApi.setActiveTool(toolName);
|
||||
const tool = annotationApi.getActiveTool();
|
||||
console.log(`Tool result for ${toolName}:`, tool);
|
||||
|
||||
if (tool && tool.id === toolName) {
|
||||
activatedTool = tool;
|
||||
console.log(`Successfully activated ${toolName}`);
|
||||
annotationApi.setToolDefaults(toolName, {
|
||||
contents: signatureConfig.signerName,
|
||||
fontSize: signatureConfig.fontSize || 16,
|
||||
@ -184,7 +175,6 @@ export const SignatureAPIBridge = forwardRef<SignatureAPI, SignatureAPIBridgePro
|
||||
}
|
||||
|
||||
if (!activatedTool) {
|
||||
console.log('No text tool could be activated, trying stamp as fallback');
|
||||
// Fallback: create a simple text image as stamp
|
||||
const canvas = document.createElement('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
@ -212,11 +202,9 @@ export const SignatureAPIBridge = forwardRef<SignatureAPI, SignatureAPIBridgePro
|
||||
}
|
||||
}
|
||||
} else if (signatureConfig.signatureData) {
|
||||
console.log('Activating stamp tool');
|
||||
// Use stamp tool for image/canvas signatures
|
||||
annotationApi.setActiveTool('stamp');
|
||||
const activeTool = annotationApi.getActiveTool();
|
||||
console.log('Stamp tool activated:', activeTool);
|
||||
if (activeTool && activeTool.id === 'stamp') {
|
||||
annotationApi.setToolDefaults('stamp', {
|
||||
imageSrc: signatureConfig.signatureData,
|
||||
|
@ -50,16 +50,10 @@ export const SignatureProvider: React.FC<{ children: ReactNode }> = ({ children
|
||||
|
||||
// Actions
|
||||
const setSignatureConfig = useCallback((config: SignParameters | null) => {
|
||||
console.log('SignatureContext: setSignatureConfig called with:', config);
|
||||
setState(prev => {
|
||||
console.log('SignatureContext: Previous state:', prev);
|
||||
const newState = {
|
||||
...prev,
|
||||
signatureConfig: config,
|
||||
};
|
||||
console.log('SignatureContext: New state:', newState);
|
||||
return newState;
|
||||
});
|
||||
setState(prev => ({
|
||||
...prev,
|
||||
signatureConfig: config,
|
||||
}));
|
||||
}, []);
|
||||
|
||||
const setPlacementMode = useCallback((enabled: boolean) => {
|
||||
@ -84,14 +78,9 @@ export const SignatureProvider: React.FC<{ children: ReactNode }> = ({ children
|
||||
}, [setPlacementMode]);
|
||||
|
||||
const activateSignaturePlacementMode = useCallback(() => {
|
||||
console.log('SignatureContext.activateSignaturePlacementMode called');
|
||||
console.log('Current signature config:', state.signatureConfig);
|
||||
if (signatureApiRef.current) {
|
||||
console.log('Calling signatureApiRef.current.activateSignaturePlacementMode()');
|
||||
signatureApiRef.current.activateSignaturePlacementMode();
|
||||
setPlacementMode(true);
|
||||
} else {
|
||||
console.log('signatureApiRef.current is null');
|
||||
}
|
||||
}, [state.signatureConfig, setPlacementMode]);
|
||||
|
||||
|
@ -61,17 +61,10 @@ const Sign = (props: BaseToolProps) => {
|
||||
// Save signed files to the system - apply signatures using EmbedPDF and replace original
|
||||
const handleSaveToSystem = useCallback(async () => {
|
||||
try {
|
||||
console.log('Save started - attempting to get PDF from viewer...');
|
||||
|
||||
// Use EmbedPDF's saveAsCopy to apply signatures and get ArrayBuffer
|
||||
const pdfArrayBuffer = await exportActions.saveAsCopy();
|
||||
console.log('Got PDF ArrayBuffer:', pdfArrayBuffer ? `${pdfArrayBuffer.byteLength} bytes` : 'null');
|
||||
|
||||
console.log('Checking conditions - ArrayBuffer exists:', !!pdfArrayBuffer, 'Selected files:', base.selectedFiles.length);
|
||||
|
||||
if (pdfArrayBuffer) {
|
||||
console.log('Conditions met, starting file processing...');
|
||||
|
||||
// Convert ArrayBuffer to File
|
||||
const blob = new Blob([pdfArrayBuffer], { type: 'application/pdf' });
|
||||
|
||||
@ -94,12 +87,8 @@ const Sign = (props: BaseToolProps) => {
|
||||
console.error('No file available to replace');
|
||||
return;
|
||||
}
|
||||
console.log('Original file:', originalFile.name, 'ID:', originalFile.fileId);
|
||||
|
||||
const signedFile = new File([blob], originalFile.name, { type: 'application/pdf' });
|
||||
console.log('Created signed file:', signedFile.name, 'Size:', signedFile.size);
|
||||
|
||||
console.log('Processing signed file...');
|
||||
|
||||
// Generate thumbnail and metadata for the signed file
|
||||
const thumbnailResult = await generateThumbnailWithMetadata(signedFile);
|
||||
@ -109,39 +98,29 @@ const Sign = (props: BaseToolProps) => {
|
||||
const inputFileIds: FileId[] = [originalFile.fileId];
|
||||
const inputStirlingFileStubs: StirlingFileStub[] = [];
|
||||
|
||||
console.log('Original file ID:', originalFile.fileId);
|
||||
const record = selectors.getStirlingFileStub(originalFile.fileId);
|
||||
if (record) {
|
||||
inputStirlingFileStubs.push(record);
|
||||
console.log('Found file record for replacement');
|
||||
} else {
|
||||
console.error('No file record found for:', originalFile.fileId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create output stub and file
|
||||
const outputStub = createNewStirlingFileStub(signedFile, undefined, thumbnailResult.thumbnail, processedFileMetadata);
|
||||
const outputStirlingFile = createStirlingFile(signedFile, outputStub.id);
|
||||
console.log('Created new file with ID:', outputStub.id);
|
||||
|
||||
// Replace the original file with the signed version
|
||||
console.log('Replacing file in context...');
|
||||
await consumeFiles(inputFileIds, [outputStirlingFile], [outputStub]);
|
||||
console.log('File replacement complete');
|
||||
|
||||
// Reactivate the signature mode that was active before save
|
||||
setTimeout(() => {
|
||||
if (activeModeRef.current === 'draw') {
|
||||
console.log('Reactivating draw mode');
|
||||
activateDrawMode();
|
||||
} else if (activeModeRef.current === 'placement') {
|
||||
console.log('Reactivating placement mode');
|
||||
handleSignaturePlacement();
|
||||
}
|
||||
}, 200);
|
||||
} else {
|
||||
console.log('Save aborted - conditions not met');
|
||||
if (!pdfArrayBuffer) console.log('No PDF ArrayBuffer received');
|
||||
if (base.selectedFiles.length === 0) console.log('No selected files');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving signed document:', error);
|
||||
|
Loading…
Reference in New Issue
Block a user