mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-22 19:46:39 +00:00
Make Viewer always accessible (#4468)
# Description of Changes Make Viewer always accessible. Also deletes some dead code I noticed while I was working. --------- Co-authored-by: EthanHealy01 <80844253+EthanHealy01@users.noreply.github.com> Co-authored-by: Reece Browne <74901996+reecebrowne@users.noreply.github.com>
This commit is contained in:
parent
28177d9509
commit
f6df414425
@ -19,8 +19,8 @@ const viewOptionStyle = {
|
|||||||
|
|
||||||
|
|
||||||
// Build view options showing text always
|
// Build view options showing text always
|
||||||
const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null) => [
|
const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchType | null, isToolSelected: boolean) => {
|
||||||
{
|
const viewerOption = {
|
||||||
label: (
|
label: (
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
{switchingTo === "viewer" ? (
|
{switchingTo === "viewer" ? (
|
||||||
@ -32,8 +32,9 @@ const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchTyp
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
value: "viewer",
|
value: "viewer",
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const pageEditorOption = {
|
||||||
label: (
|
label: (
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
{currentView === "pageEditor" ? (
|
{currentView === "pageEditor" ? (
|
||||||
@ -50,8 +51,9 @@ const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchTyp
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
value: "pageEditor",
|
value: "pageEditor",
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const fileEditorOption = {
|
||||||
label: (
|
label: (
|
||||||
<div style={viewOptionStyle as React.CSSProperties}>
|
<div style={viewOptionStyle as React.CSSProperties}>
|
||||||
{currentView === "fileEditor" ? (
|
{currentView === "fileEditor" ? (
|
||||||
@ -68,8 +70,15 @@ const createViewOptions = (currentView: WorkbenchType, switchingTo: WorkbenchTyp
|
|||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
value: "fileEditor",
|
value: "fileEditor",
|
||||||
},
|
};
|
||||||
];
|
|
||||||
|
// Build options array conditionally
|
||||||
|
return [
|
||||||
|
viewerOption,
|
||||||
|
...(isToolSelected ? [] : [pageEditorOption]),
|
||||||
|
fileEditorOption,
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
interface TopControlsProps {
|
interface TopControlsProps {
|
||||||
currentView: WorkbenchType;
|
currentView: WorkbenchType;
|
||||||
@ -91,7 +100,7 @@ const TopControls = ({
|
|||||||
if (!isValidWorkbench(view)) {
|
if (!isValidWorkbench(view)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const workbench = view;
|
const workbench = view;
|
||||||
|
|
||||||
// Show immediate feedback
|
// Show immediate feedback
|
||||||
@ -111,39 +120,37 @@ const TopControls = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="absolute left-0 w-full top-0 z-[100] pointer-events-none">
|
<div className="absolute left-0 w-full top-0 z-[100] pointer-events-none">
|
||||||
{!isToolSelected && (
|
<div className="flex justify-center mt-[0.5rem]">
|
||||||
<div className="flex justify-center mt-[0.5rem]">
|
<SegmentedControl
|
||||||
<SegmentedControl
|
data={createViewOptions(currentView, switchingTo, isToolSelected)}
|
||||||
data={createViewOptions(currentView, switchingTo)}
|
value={currentView}
|
||||||
value={currentView}
|
onChange={handleViewChange}
|
||||||
onChange={handleViewChange}
|
color="blue"
|
||||||
color="blue"
|
fullWidth
|
||||||
fullWidth
|
className={isRainbowMode ? rainbowStyles.rainbowSegmentedControl : ''}
|
||||||
className={isRainbowMode ? rainbowStyles.rainbowSegmentedControl : ''}
|
style={{
|
||||||
style={{
|
transition: 'all 0.2s ease',
|
||||||
transition: 'all 0.2s ease',
|
opacity: switchingTo ? 0.8 : 1,
|
||||||
opacity: switchingTo ? 0.8 : 1,
|
pointerEvents: 'auto'
|
||||||
pointerEvents: 'auto'
|
}}
|
||||||
}}
|
styles={{
|
||||||
styles={{
|
root: {
|
||||||
root: {
|
borderRadius: 9999,
|
||||||
borderRadius: 9999,
|
maxHeight: '2.6rem',
|
||||||
maxHeight: '2.6rem',
|
},
|
||||||
},
|
control: {
|
||||||
control: {
|
borderRadius: 9999,
|
||||||
borderRadius: 9999,
|
},
|
||||||
},
|
indicator: {
|
||||||
indicator: {
|
borderRadius: 9999,
|
||||||
borderRadius: 9999,
|
maxHeight: '2rem',
|
||||||
maxHeight: '2rem',
|
},
|
||||||
},
|
label: {
|
||||||
label: {
|
paddingTop: '0rem',
|
||||||
paddingTop: '0rem',
|
}
|
||||||
}
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -8,26 +8,6 @@ import { FileId, BaseFileMetadata } from './file';
|
|||||||
// Re-export FileId for convenience
|
// Re-export FileId for convenience
|
||||||
export type { FileId };
|
export type { FileId };
|
||||||
|
|
||||||
export type ModeType =
|
|
||||||
| 'viewer'
|
|
||||||
| 'pageEditor'
|
|
||||||
| 'fileEditor'
|
|
||||||
| 'merge'
|
|
||||||
| 'split'
|
|
||||||
| 'compress'
|
|
||||||
| 'ocr'
|
|
||||||
| 'convert'
|
|
||||||
| 'sanitize'
|
|
||||||
| 'addPassword'
|
|
||||||
| 'changePermissions'
|
|
||||||
| 'addWatermark'
|
|
||||||
| 'removePassword'
|
|
||||||
| 'single-large-page'
|
|
||||||
| 'repair'
|
|
||||||
| 'unlockPdfForms'
|
|
||||||
| 'removeCertificateSign'
|
|
||||||
| 'auto-rename-pdf-file';
|
|
||||||
|
|
||||||
// Normalized state types
|
// Normalized state types
|
||||||
export interface ProcessedFilePage {
|
export interface ProcessedFilePage {
|
||||||
thumbnail?: string;
|
thumbnail?: string;
|
||||||
@ -209,32 +189,6 @@ export function revokeFileResources(record: StirlingFileStub): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OperationType = 'merge' | 'split' | 'compress' | 'add' | 'remove' | 'replace' | 'convert' | 'upload' | 'ocr' | 'sanitize';
|
|
||||||
|
|
||||||
export interface FileOperation {
|
|
||||||
id: string;
|
|
||||||
type: OperationType;
|
|
||||||
timestamp: number;
|
|
||||||
fileIds: FileId[];
|
|
||||||
status: 'pending' | 'applied' | 'failed';
|
|
||||||
data?: any;
|
|
||||||
metadata?: {
|
|
||||||
originalFileName?: string;
|
|
||||||
outputFileNames?: string[];
|
|
||||||
fileSize?: number;
|
|
||||||
pageCount?: number;
|
|
||||||
error?: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FileOperationHistory {
|
|
||||||
fileId: FileId;
|
|
||||||
fileName: string;
|
|
||||||
operations: (FileOperation | PageOperation)[];
|
|
||||||
createdAt: number;
|
|
||||||
lastModified: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ViewerConfig {
|
export interface ViewerConfig {
|
||||||
zoom: number;
|
zoom: number;
|
||||||
currentPage: number;
|
currentPage: number;
|
||||||
|
@ -9,4 +9,4 @@ export const getDefaultWorkbench = (): WorkbenchType => 'fileEditor';
|
|||||||
// Type guard using the same source of truth
|
// Type guard using the same source of truth
|
||||||
export const isValidWorkbench = (value: string): value is WorkbenchType => {
|
export const isValidWorkbench = (value: string): value is WorkbenchType => {
|
||||||
return WORKBENCH_TYPES.includes(value as WorkbenchType);
|
return WORKBENCH_TYPES.includes(value as WorkbenchType);
|
||||||
};
|
};
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
import { FileId } from '../types/file';
|
|
||||||
import { FileOperation } from '../types/fileContext';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates operation tracking data for FileContext integration
|
|
||||||
*/
|
|
||||||
export const createOperation = <TParams = void>(
|
|
||||||
operationType: string,
|
|
||||||
_params: TParams,
|
|
||||||
selectedFiles: File[]
|
|
||||||
): { operation: FileOperation; operationId: string; fileId: FileId } => {
|
|
||||||
const operationId = `${operationType}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
||||||
const fileId = selectedFiles.map(f => f.name).join(',') as FileId;
|
|
||||||
|
|
||||||
const operation: FileOperation = {
|
|
||||||
id: operationId,
|
|
||||||
type: operationType,
|
|
||||||
timestamp: Date.now(),
|
|
||||||
fileIds: selectedFiles.map(f => f.name),
|
|
||||||
status: 'pending',
|
|
||||||
metadata: {
|
|
||||||
originalFileName: selectedFiles[0]?.name,
|
|
||||||
fileSize: selectedFiles.reduce((sum, f) => sum + f.size, 0)
|
|
||||||
}
|
|
||||||
} as any /* FIX ME*/;
|
|
||||||
|
|
||||||
return { operation, operationId, fileId };
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user