mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-26 17:52:59 +02:00
Fix lintineg errors
This commit is contained in:
parent
50e60d4972
commit
3fdbf425b4
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Stack, Tabs, Alert, Text } from '@mantine/core';
|
import { Stack, Alert, Text } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { DrawingControls } from './DrawingControls';
|
import { DrawingControls } from './DrawingControls';
|
||||||
import { ColorPicker } from './ColorPicker';
|
import { ColorPicker } from './ColorPicker';
|
||||||
@ -29,10 +29,8 @@ export const BaseAnnotationTool: React.FC<BaseAnnotationToolProps> = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const {
|
const {
|
||||||
activateSignaturePlacementMode,
|
activateSignaturePlacementMode,
|
||||||
deactivateDrawMode,
|
|
||||||
undo,
|
undo,
|
||||||
redo,
|
redo
|
||||||
isPlacementMode
|
|
||||||
} = usePDFAnnotation();
|
} = usePDFAnnotation();
|
||||||
|
|
||||||
const [selectedColor, setSelectedColor] = useState('#000000');
|
const [selectedColor, setSelectedColor] = useState('#000000');
|
||||||
|
@ -41,7 +41,7 @@ export const DrawingCanvas: React.FC<DrawingCanvasProps> = ({
|
|||||||
const [isDrawing, setIsDrawing] = useState(false);
|
const [isDrawing, setIsDrawing] = useState(false);
|
||||||
const [isModalDrawing, setIsModalDrawing] = useState(false);
|
const [isModalDrawing, setIsModalDrawing] = useState(false);
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [signatureData, setSignatureData] = useState<string | null>(null);
|
const [, setSignatureData] = useState<string | null>(null);
|
||||||
|
|
||||||
// Drawing functions for main canvas
|
// Drawing functions for main canvas
|
||||||
const startDrawing = useCallback((e: React.MouseEvent<HTMLCanvasElement>) => {
|
const startDrawing = useCallback((e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Stack, Paper, Text, Group } from '@mantine/core';
|
import { Stack } from '@mantine/core';
|
||||||
import { BaseAnnotationTool } from '../shared/BaseAnnotationTool';
|
import { BaseAnnotationTool } from '../shared/BaseAnnotationTool';
|
||||||
import { DrawingCanvas } from '../shared/DrawingCanvas';
|
import { DrawingCanvas } from '../shared/DrawingCanvas';
|
||||||
import { ColorSwatchButton } from '../shared/ColorPicker';
|
|
||||||
import PenSizeSelector from '../../tools/sign/PenSizeSelector';
|
|
||||||
|
|
||||||
interface DrawingToolProps {
|
interface DrawingToolProps {
|
||||||
onDrawingChange?: (data: string | null) => void;
|
onDrawingChange?: (data: string | null) => void;
|
||||||
@ -14,7 +12,7 @@ export const DrawingTool: React.FC<DrawingToolProps> = ({
|
|||||||
onDrawingChange,
|
onDrawingChange,
|
||||||
disabled = false
|
disabled = false
|
||||||
}) => {
|
}) => {
|
||||||
const [selectedColor, setSelectedColor] = useState('#000000');
|
const [selectedColor] = useState('#000000');
|
||||||
const [penSize, setPenSize] = useState(2);
|
const [penSize, setPenSize] = useState(2);
|
||||||
const [penSizeInput, setPenSizeInput] = useState('2');
|
const [penSizeInput, setPenSizeInput] = useState('2');
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ export const ImageTool: React.FC<ImageToolProps> = ({
|
|||||||
onImageChange,
|
onImageChange,
|
||||||
disabled = false
|
disabled = false
|
||||||
}) => {
|
}) => {
|
||||||
const [imageData, setImageData] = useState<string | null>(null);
|
const [, setImageData] = useState<string | null>(null);
|
||||||
|
|
||||||
const handleImageUpload = async (file: File | null) => {
|
const handleImageUpload = async (file: File | null) => {
|
||||||
if (file && !disabled) {
|
if (file && !disabled) {
|
||||||
|
@ -17,11 +17,6 @@ import { ViewerContext } from '../../contexts/ViewerContext';
|
|||||||
import { useSignature } from '../../contexts/SignatureContext';
|
import { useSignature } from '../../contexts/SignatureContext';
|
||||||
|
|
||||||
import { parseSelection } from '../../utils/bulkselection/parseSelection';
|
import { parseSelection } from '../../utils/bulkselection/parseSelection';
|
||||||
import { flattenSignatures } from '../../utils/signatureFlattening';
|
|
||||||
import { PDFDocument, rgb } from 'pdf-lib';
|
|
||||||
import { generateThumbnailWithMetadata } from '../../utils/thumbnailUtils';
|
|
||||||
import { createProcessedFile } from '../../contexts/file/fileActions';
|
|
||||||
import { createNewStirlingFileStub, createStirlingFile } from '../../types/fileContext';
|
|
||||||
|
|
||||||
|
|
||||||
export default function RightRail() {
|
export default function RightRail() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Stack, Button, Text, Alert, Tabs, Group, Paper } from '@mantine/core';
|
import { Stack, Button, Text, Alert, Tabs } from '@mantine/core';
|
||||||
import { SignParameters } from "../../../hooks/tools/sign/useSignParameters";
|
import { SignParameters } from "../../../hooks/tools/sign/useSignParameters";
|
||||||
import { SuggestedToolsSection } from "../shared/SuggestedToolsSection";
|
import { SuggestedToolsSection } from "../shared/SuggestedToolsSection";
|
||||||
|
|
||||||
@ -28,10 +28,8 @@ const SignSettings = ({
|
|||||||
parameters,
|
parameters,
|
||||||
onParameterChange,
|
onParameterChange,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
onActivateDrawMode,
|
|
||||||
onActivateSignaturePlacement,
|
onActivateSignaturePlacement,
|
||||||
onDeactivateSignature,
|
onDeactivateSignature,
|
||||||
onUpdateDrawSettings,
|
|
||||||
onUndo,
|
onUndo,
|
||||||
onRedo,
|
onRedo,
|
||||||
onSave
|
onSave
|
||||||
|
@ -189,7 +189,7 @@ const EmbedPdfViewerContent = ({
|
|||||||
enableSignature={isSignatureMode}
|
enableSignature={isSignatureMode}
|
||||||
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={() => {
|
||||||
// Handle signature added - for debugging, enable console logs as needed
|
// Handle signature added - for debugging, enable console logs as needed
|
||||||
// Future: Handle signature completion
|
// Future: Handle signature completion
|
||||||
}}
|
}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useImperativeHandle, forwardRef, useEffect } from 'react';
|
import { useImperativeHandle, forwardRef, useEffect } from 'react';
|
||||||
import { useHistoryCapability } from '@embedpdf/plugin-history/react';
|
import { useHistoryCapability } from '@embedpdf/plugin-history/react';
|
||||||
import { useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
import { useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
||||||
import { useSignature } from '../../contexts/SignatureContext';
|
import { useSignature } from '../../contexts/SignatureContext';
|
||||||
@ -11,9 +11,10 @@ export interface HistoryAPI {
|
|||||||
canRedo: () => boolean;
|
canRedo: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||||
export interface HistoryAPIBridgeProps {}
|
export interface HistoryAPIBridgeProps {}
|
||||||
|
|
||||||
export const HistoryAPIBridge = forwardRef<HistoryAPI, HistoryAPIBridgeProps>((props, ref) => {
|
export const HistoryAPIBridge = forwardRef<HistoryAPI, HistoryAPIBridgeProps>(function HistoryAPIBridge(_props, ref) {
|
||||||
const { provides: historyApi } = useHistoryCapability();
|
const { provides: historyApi } = useHistoryCapability();
|
||||||
const { provides: annotationApi } = useAnnotationCapability();
|
const { provides: annotationApi } = useAnnotationCapability();
|
||||||
const { getImageData, storeImageData } = useSignature();
|
const { getImageData, storeImageData } = useSignature();
|
||||||
@ -38,7 +39,7 @@ export const HistoryAPIBridge = forwardRef<HistoryAPI, HistoryAPIBridgeProps>((p
|
|||||||
if (event.type === 'create' && event.committed) {
|
if (event.type === 'create' && event.committed) {
|
||||||
// Check if this is a STAMP annotation (signature) that might need image data restoration
|
// Check if this is a STAMP annotation (signature) that might need image data restoration
|
||||||
if (annotation && annotation.type === 13 && annotation.id) {
|
if (annotation && annotation.type === 13 && annotation.id) {
|
||||||
const storedImageData = getImageData(annotation.id);
|
getImageData(annotation.id);
|
||||||
|
|
||||||
// Delay the check to allow the annotation to be fully created
|
// Delay the check to allow the annotation to be fully created
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useMemo, useState, useRef } from 'react';
|
import React, { useEffect, useMemo, useState } from 'react';
|
||||||
import { createPluginRegistration } from '@embedpdf/core';
|
import { createPluginRegistration } from '@embedpdf/core';
|
||||||
import { EmbedPDF } from '@embedpdf/core/react';
|
import { EmbedPDF } from '@embedpdf/core/react';
|
||||||
import { usePdfiumEngine } from '@embedpdf/engines/react';
|
import { usePdfiumEngine } from '@embedpdf/engines/react';
|
||||||
@ -22,7 +22,7 @@ import { Rotation } from '@embedpdf/models';
|
|||||||
|
|
||||||
// Import annotation plugins
|
// Import annotation plugins
|
||||||
import { HistoryPluginPackage } from '@embedpdf/plugin-history/react';
|
import { HistoryPluginPackage } from '@embedpdf/plugin-history/react';
|
||||||
import { AnnotationLayer, AnnotationPluginPackage, useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
import { AnnotationLayer, AnnotationPluginPackage } from '@embedpdf/plugin-annotation/react';
|
||||||
import { PdfAnnotationSubtype } from '@embedpdf/models';
|
import { PdfAnnotationSubtype } from '@embedpdf/models';
|
||||||
import { CustomSearchLayer } from './CustomSearchLayer';
|
import { CustomSearchLayer } from './CustomSearchLayer';
|
||||||
import { ZoomAPIBridge } from './ZoomAPIBridge';
|
import { ZoomAPIBridge } from './ZoomAPIBridge';
|
||||||
@ -50,7 +50,7 @@ interface LocalEmbedPDFProps {
|
|||||||
|
|
||||||
export function LocalEmbedPDF({ file, url, enableSignature = false, onSignatureAdded, signatureApiRef, historyApiRef }: LocalEmbedPDFProps) {
|
export function LocalEmbedPDF({ file, url, enableSignature = false, onSignatureAdded, signatureApiRef, historyApiRef }: LocalEmbedPDFProps) {
|
||||||
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
|
const [pdfUrl, setPdfUrl] = useState<string | null>(null);
|
||||||
const [annotations, setAnnotations] = useState<Array<{id: string, pageIndex: number, rect: any}>>([]);
|
const [, setAnnotations] = useState<Array<{id: string, pageIndex: number, rect: any}>>([]);
|
||||||
|
|
||||||
// Convert File to URL if needed
|
// Convert File to URL if needed
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -21,7 +21,7 @@ import { Rotation } from '@embedpdf/models';
|
|||||||
|
|
||||||
// Import annotation plugins
|
// Import annotation plugins
|
||||||
import { HistoryPluginPackage } from '@embedpdf/plugin-history/react';
|
import { HistoryPluginPackage } from '@embedpdf/plugin-history/react';
|
||||||
import { AnnotationLayer, AnnotationPluginPackage, useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
import { AnnotationLayer, AnnotationPluginPackage } from '@embedpdf/plugin-annotation/react';
|
||||||
import { PdfAnnotationSubtype } from '@embedpdf/models';
|
import { PdfAnnotationSubtype } from '@embedpdf/models';
|
||||||
|
|
||||||
import { CustomSearchLayer } from './CustomSearchLayer';
|
import { CustomSearchLayer } from './CustomSearchLayer';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useImperativeHandle, forwardRef, useEffect } from 'react';
|
import { useImperativeHandle, forwardRef, useEffect } from 'react';
|
||||||
import { useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
import { useAnnotationCapability } from '@embedpdf/plugin-annotation/react';
|
||||||
import { PdfAnnotationSubtype, PdfStandardFont, PdfTextAlignment, PdfVerticalAlignment, uuidV4 } from '@embedpdf/models';
|
import { PdfAnnotationSubtype, PdfStandardFont, PdfTextAlignment, PdfVerticalAlignment, uuidV4 } from '@embedpdf/models';
|
||||||
import { SignParameters } from '../../hooks/tools/sign/useSignParameters';
|
import { SignParameters } from '../../hooks/tools/sign/useSignParameters';
|
||||||
@ -17,9 +17,10 @@ export interface SignatureAPI {
|
|||||||
getPageAnnotations: (pageIndex: number) => Promise<any[]>;
|
getPageAnnotations: (pageIndex: number) => Promise<any[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||||
export interface SignatureAPIBridgeProps {}
|
export interface SignatureAPIBridgeProps {}
|
||||||
|
|
||||||
export const SignatureAPIBridge = forwardRef<SignatureAPI, SignatureAPIBridgeProps>((props, ref) => {
|
export const SignatureAPIBridge = forwardRef<SignatureAPI, SignatureAPIBridgeProps>((_props, ref) => {
|
||||||
const { provides: annotationApi } = useAnnotationCapability();
|
const { provides: annotationApi } = useAnnotationCapability();
|
||||||
const { signatureConfig, storeImageData } = useSignature();
|
const { signatureConfig, storeImageData } = useSignature();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { createContext, useContext, useState, ReactNode, useCallback, useRef, useEffect } from 'react';
|
import React, { createContext, useContext, useState, ReactNode, useCallback, useRef } from 'react';
|
||||||
import { SignParameters } from '../hooks/tools/sign/useSignParameters';
|
import { SignParameters } from '../hooks/tools/sign/useSignParameters';
|
||||||
import { SignatureAPI } from '../components/viewer/SignatureAPIBridge';
|
import { SignatureAPI } from '../components/viewer/SignatureAPIBridge';
|
||||||
import { HistoryAPI } from '../components/viewer/HistoryAPIBridge';
|
import { HistoryAPI } from '../components/viewer/HistoryAPIBridge';
|
||||||
|
@ -210,7 +210,7 @@ export const ViewerProvider: React.FC<ViewerProviderProps> = ({ children }) => {
|
|||||||
const [isThumbnailSidebarVisible, setIsThumbnailSidebarVisible] = useState(false);
|
const [isThumbnailSidebarVisible, setIsThumbnailSidebarVisible] = useState(false);
|
||||||
|
|
||||||
// Get current navigation state to check if we're in sign mode
|
// Get current navigation state to check if we're in sign mode
|
||||||
const { workbench } = useNavigation();
|
useNavigation();
|
||||||
|
|
||||||
// Bridge registry - bridges register their state and APIs here
|
// Bridge registry - bridges register their state and APIs here
|
||||||
const bridgeRefs = useRef({
|
const bridgeRefs = useRef({
|
||||||
|
@ -8,19 +8,14 @@ import { BaseToolProps, ToolComponent } from "../types/tool";
|
|||||||
import SignSettings from "../components/tools/sign/SignSettings";
|
import SignSettings from "../components/tools/sign/SignSettings";
|
||||||
import { useNavigation } from "../contexts/NavigationContext";
|
import { useNavigation } from "../contexts/NavigationContext";
|
||||||
import { useSignature } from "../contexts/SignatureContext";
|
import { useSignature } from "../contexts/SignatureContext";
|
||||||
import { useFileActions, useFileContext } from "../contexts/FileContext";
|
import { useFileContext } from "../contexts/FileContext";
|
||||||
import { useViewer } from "../contexts/ViewerContext";
|
import { useViewer } from "../contexts/ViewerContext";
|
||||||
import { generateThumbnailWithMetadata } from "../utils/thumbnailUtils";
|
|
||||||
import { createNewStirlingFileStub, createStirlingFile, StirlingFileStub, StirlingFile, FileId, extractFiles } from "../types/fileContext";
|
|
||||||
import { createProcessedFile } from "../contexts/file/fileActions";
|
|
||||||
import { PDFDocument, PDFName, PDFDict, PDFArray, rgb } from 'pdf-lib';
|
|
||||||
import { flattenSignatures } from "../utils/signatureFlattening";
|
import { flattenSignatures } from "../utils/signatureFlattening";
|
||||||
|
|
||||||
const Sign = (props: BaseToolProps) => {
|
const Sign = (props: BaseToolProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { setWorkbench } = useNavigation();
|
const { setWorkbench } = useNavigation();
|
||||||
const { setSignatureConfig, activateDrawMode, activateSignaturePlacementMode, deactivateDrawMode, updateDrawSettings, undo, redo, isPlacementMode, signatureApiRef, getImageData, setSignaturesApplied } = useSignature();
|
const { setSignatureConfig, activateDrawMode, activateSignaturePlacementMode, deactivateDrawMode, updateDrawSettings, undo, redo, signatureApiRef, getImageData, setSignaturesApplied } = useSignature();
|
||||||
const { actions } = useFileActions();
|
|
||||||
const { consumeFiles, selectors } = useFileContext();
|
const { consumeFiles, selectors } = useFileContext();
|
||||||
const { exportActions } = useViewer();
|
const { exportActions } = useViewer();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ export async function flattenSignatures(options: SignatureFlatteningOptions): Pr
|
|||||||
console.log(`Found ${sessionAnnotations.length} session annotations on page ${pageIndex + 1} (out of ${pageAnnotations.length} total)`);
|
console.log(`Found ${sessionAnnotations.length} session annotations on page ${pageIndex + 1} (out of ${pageAnnotations.length} total)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
if (pageIndex > 2) break; // Stop after checking first few pages
|
if (pageIndex > 2) break; // Stop after checking first few pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ export async function flattenSignatures(options: SignatureFlatteningOptions): Pr
|
|||||||
console.log('Attempting to load PDF with PDF-lib...');
|
console.log('Attempting to load PDF with PDF-lib...');
|
||||||
|
|
||||||
// Convert ArrayBuffer to File
|
// Convert ArrayBuffer to File
|
||||||
let blob = new Blob([pdfArrayBuffer], { type: 'application/pdf' });
|
const blob = new Blob([pdfArrayBuffer], { type: 'application/pdf' });
|
||||||
|
|
||||||
// Get the current file - try from originalFile first, then from all files
|
// Get the current file - try from originalFile first, then from all files
|
||||||
let currentFile = originalFile;
|
let currentFile = originalFile;
|
||||||
@ -130,7 +130,7 @@ export async function flattenSignatures(options: SignatureFlatteningOptions): Pr
|
|||||||
throwOnInvalidObject: false
|
throwOnInvalidObject: false
|
||||||
});
|
});
|
||||||
console.log('✓ PDF loaded successfully with standard options');
|
console.log('✓ PDF loaded successfully with standard options');
|
||||||
} catch (loadError) {
|
} catch {
|
||||||
console.warn('Failed to load with standard options, trying createProxy...');
|
console.warn('Failed to load with standard options, trying createProxy...');
|
||||||
try {
|
try {
|
||||||
// Create a fresh PDF and copy pages instead of modifying
|
// Create a fresh PDF and copy pages instead of modifying
|
||||||
|
Loading…
Reference in New Issue
Block a user