#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
feat(settings): add default startup view and reader zoom preferences (#6073)
Vibe Stacka5b259b453f2
diff --git a/frontend/public/locales/en-GB/translation.toml b/frontend/public/locales/en-GB/translation.tomlindex 5a8565d5a5..a91985ee41 100644--- a/frontend/public/locales/en-GB/translation.toml+++ b/frontend/public/locales/en-GB/translation.toml@@ -6638,9 +6638,13 @@ defaultPdfEditorActive = "Stirling PDF is your default PDF editor"defaultPdfEditorChecking = "Checking..."defaultPdfEditorInactive = "Another application is set as default"defaultPdfEditorSet = "Already Default"+defaultStartupView = "Default view on launch"+defaultStartupViewDescription = "Choose which tab is active in the left column when the app starts"defaultToolPickerMode = "Default tool picker mode"defaultToolPickerModeDescription = "Choose whether the tool picker opens in fullscreen or sidebar by default"description = "Configure general application preferences."+defaultViewerZoom = "Default reader zoom"+defaultViewerZoomDescription = "Set the default zoom level when opening PDFs in the reader"hideUnavailableConversions = "Hide unavailable conversions"hideUnavailableConversionsDescription = "Remove disabled conversion options in the Convert tool instead of showing them greyed out."hideUnavailableTools = "Hide unavailable tools"@@ -6663,6 +6667,16 @@ title = "For System Administrators"fullscreen = "Fullscreen"sidebar = "Sidebar"+[settings.general.startupView]+automate = "Automate"+read = "Reader"+tools = "Tools"++[settings.general.zoomLevel]+auto = "Auto"+fitPage = "Fit page"+fitWidth = "Fit width"+[settings.general.updates]checkForUpdates = "Check for Updates"currentBackendVersion = "Current Backend Version"diff --git a/frontend/src/core/components/shared/config/configSections/GeneralSection.tsx b/frontend/src/core/components/shared/config/configSections/GeneralSection.tsxindex 2d4c9f42de..d65bdcc8bf 100644--- a/frontend/src/core/components/shared/config/configSections/GeneralSection.tsx+++ b/frontend/src/core/components/shared/config/configSections/GeneralSection.tsx@@ -7,6 +7,7 @@ import {Tooltip,NumberInput,SegmentedControl,+ Select,Code,Group,Anchor,@@ -19,6 +20,8 @@ import { useTranslation } from "react-i18next";import { usePreferences } from "@app/contexts/PreferencesContext";import { useAppConfig } from "@app/contexts/AppConfigContext";import type { ToolPanelMode } from "@app/constants/toolPanel";+import type { StartupView, ViewerZoomSetting } from "@app/services/preferencesService";+import { Z_INDEX_OVER_CONFIG_MODAL } from "@app/styles/zIndex";import LocalIcon from "@app/components/shared/LocalIcon";import { updateService, UpdateSummary } from "@app/services/updateService";import UpdateModal from "@app/components/shared/UpdateModal";@@ -293,6 +296,61 @@ const GeneralSection: React.FC<GeneralSectionProps> = ({ hideTitle = false, hide]}/></div>+ <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>+ <div>+ <Text fw={500} size="sm">+ {t("settings.general.defaultStartupView", "Default view on launch")}+ </Text>+ <Text size="xs" c="dimmed" mt={4}>+ {t(+ "settings.general.defaultStartupViewDescription",+ "Choose which tab is active in the left column when the app starts",+ )}+ </Text>+ </div>+ <SegmentedControl+ value={preferences.defaultStartupView}+ onChange={(val: string) => updatePreference("defaultStartupView", val as StartupView)}+ data={[+ { label: t("settings.general.startupView.tools", "Tools"), value: "tools" },+ { label: t("settings.general.startupView.read", "Reader"), value: "read" },+ { label: t("settings.general.startupView.automate", "Automate"), value: "automate" },+ ]}+ />+ </div>+ <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>+ <div>+ <Text fw={500} size="sm">+ {t("settings.general.defaultViewerZoom", "Default reader zoom")}+ </Text>+ <Text size="xs" c="dimmed" mt={4}>+ {t(+ "settings.general.defaultViewerZoomDescription",+ "Set the default zoom level when opening PDFs in the reader",+ )}+ </Text>+ </div>+ <Select+ value={preferences.defaultViewerZoom}+ onChange={(val: string | null) => {+ if (val) updatePreference("defaultViewerZoom", val as ViewerZoomSetting);+ }}+ data={[+ { label: t("settings.general.zoomLevel.auto", "Auto"), value: "auto" },+ { label: t("settings.general.zoomLevel.fitWidth", "Fit width"), value: "fitWidth" },+ { label: t("settings.general.zoomLevel.fitPage", "Fit page"), value: "fitPage" },+ { label: "50%", value: "50" },+ { label: "75%", value: "75" },+ { label: "100%", value: "100" },+ { label: "125%", value: "125" },+ { label: "150%", value: "150" },+ { label: "200%", value: "200" },+ ]}+ style={{ width: 140 }}+ allowDeselect={false}+ comboboxProps={{ withinPortal: true, zIndex: Z_INDEX_OVER_CONFIG_MODAL }}+ />+ </div><div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}><div><Text fw={500} size="sm">diff --git a/frontend/src/core/components/viewer/ZoomAPIBridge.tsx b/frontend/src/core/components/viewer/ZoomAPIBridge.tsxindex 1b0ea744d4..836716682b 100644--- a/frontend/src/core/components/viewer/ZoomAPIBridge.tsx+++ b/frontend/src/core/components/viewer/ZoomAPIBridge.tsx@@ -12,6 +12,7 @@ import {} from '@app/utils/viewerZoom';import { getFirstPageAspectRatioFromStub } from '@app/utils/pageMetadata';import { useDocumentReady } from '@app/components/viewer/hooks/useDocumentReady';+import { preferencesService, type ViewerZoomSetting } from '@app/services/preferencesService';/*** Connects the PDF zoom plugin to the shared ViewerContext.@@ -155,6 +156,21 @@ function ZoomAPIBridgeInner({ documentId }: { documentId: string }) {return;}+ // Check user preference for default viewer zoom+ const zoomPref: ViewerZoomSetting = preferencesService.getPreference('defaultViewerZoom');+ if (zoomPref !== 'auto') {+ if (zoomPref === 'fitWidth') {+ applyTrackedZoom(ZoomMode.FitWidth, fitWidthZoom);+ } else if (zoomPref === 'fitPage') {+ applyTrackedZoom(ZoomMode.FitPage, fitWidthZoom);+ } else {+ // Numeric zoom: '50', '75', '100', '125', '150', '200'+ const numericZoom = parseInt(zoomPref, 10) / 100;+ applyTrackedZoom(numericZoom, numericZoom);+ }+ return;+ }+const viewportWidth = window.innerWidth ?? 0;const viewportHeight = window.innerHeight ?? 0;diff --git a/frontend/src/core/contexts/ToolWorkflowContext.tsx b/frontend/src/core/contexts/ToolWorkflowContext.tsxindex 564dfa004c..6cd83598c8 100644--- a/frontend/src/core/contexts/ToolWorkflowContext.tsx+++ b/frontend/src/core/contexts/ToolWorkflowContext.tsx@@ -258,6 +258,28 @@ export function ToolWorkflowProvider({ children }: ToolWorkflowProviderProps) {}}, [preferences.defaultToolPanelMode, state.toolPanelMode]);+ // Apply default startup view preference on initial load.+ // This runs once to navigate to the user's preferred tab (read/automate)+ // instead of always starting on the tools tab.+ const hasAppliedStartupView = React.useRef(false);+ useEffect(() => {+ if (hasAppliedStartupView.current) return;+ const startupView = preferences.defaultStartupView;+ if (startupView === 'read') {+ hasAppliedStartupView.current = true;+ setReaderMode(true);+ actions.setSelectedTool('read');+ } else if (startupView === 'automate') {+ hasAppliedStartupView.current = true;+ actions.setSelectedTool('automate');+ setLeftPanelView('toolContent');+ }+ // 'tools' is the default — no action needed+ if (startupView === 'tools') {+ hasAppliedStartupView.current = true;+ }+ }, [preferences.defaultStartupView, actions, setReaderMode, setLeftPanelView]);+// Tool reset methodsconst registerToolReset = useCallback((toolId: string, resetFunction: () => void) => {setToolResetFunctions(prev => ({ ...prev, [toolId]: resetFunction }));diff --git a/frontend/src/core/services/preferencesService.ts b/frontend/src/core/services/preferencesService.tsindex d951099a9e..34ea05e6d2 100644--- a/frontend/src/core/services/preferencesService.ts+++ b/frontend/src/core/services/preferencesService.ts@@ -5,10 +5,16 @@ export type LogoVariant = 'modern' | 'classic';export type PdfRenderMode = 'normal' | 'dark' | 'sepia';+export type StartupView = 'tools' | 'read' | 'automate';++export type ViewerZoomSetting = 'auto' | 'fitWidth' | 'fitPage' | '50' | '75' | '100' | '125' | '150' | '200';+export interface UserPreferences {autoUnzip: boolean;autoUnzipFileLimit: number;defaultToolPanelMode: ToolPanelMode;+ defaultStartupView: StartupView;+ defaultViewerZoom: ViewerZoomSetting;theme: ThemeMode;toolPanelModePromptSeen: boolean;hasSelectedToolPanelMode: boolean;@@ -26,6 +32,8 @@ export const DEFAULT_PREFERENCES: UserPreferences = {autoUnzip: true,autoUnzipFileLimit: 4,defaultToolPanelMode: DEFAULT_TOOL_PANEL_MODE,+ defaultStartupView: 'tools',+ defaultViewerZoom: 'auto',theme: getSystemTheme(),toolPanelModePromptSeen: false,hasSelectedToolPanelMode: false,