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