diff --git a/README.md b/README.md index 77c49ae72..804346223 100644 --- a/README.md +++ b/README.md @@ -115,45 +115,45 @@ Stirling-PDF currently supports 40 languages! | Language | Progress | | -------------------------------------------- | -------------------------------------- | -| Arabic (العربية) (ar_AR) | ![37%](https://geps.dev/progress/37) | -| Azerbaijani (Azərbaycan Dili) (az_AZ) | ![37%](https://geps.dev/progress/37) | +| Arabic (العربية) (ar_AR) | ![97%](https://geps.dev/progress/97) | +| Azerbaijani (Azərbaycan Dili) (az_AZ) | ![36%](https://geps.dev/progress/36) | | Basque (Euskara) (eu_ES) | ![21%](https://geps.dev/progress/21) | -| Bulgarian (Български) (bg_BG) | ![40%](https://geps.dev/progress/40) | -| Catalan (Català) (ca_CA) | ![39%](https://geps.dev/progress/39) | -| Croatian (Hrvatski) (hr_HR) | ![36%](https://geps.dev/progress/36) | +| Bulgarian (Български) (bg_BG) | ![39%](https://geps.dev/progress/39) | +| Catalan (Català) (ca_CA) | ![38%](https://geps.dev/progress/38) | +| Croatian (Hrvatski) (hr_HR) | ![35%](https://geps.dev/progress/35) | | Czech (Česky) (cs_CZ) | ![39%](https://geps.dev/progress/39) | | Danish (Dansk) (da_DK) | ![35%](https://geps.dev/progress/35) | -| Dutch (Nederlands) (nl_NL) | ![35%](https://geps.dev/progress/35) | +| Dutch (Nederlands) (nl_NL) | ![34%](https://geps.dev/progress/34) | | English (English) (en_GB) | ![100%](https://geps.dev/progress/100) | | English (US) (en_US) | ![100%](https://geps.dev/progress/100) | -| French (Français) (fr_FR) | ![42%](https://geps.dev/progress/42) | -| German (Deutsch) (de_DE) | ![98%](https://geps.dev/progress/98) | +| French (Français) (fr_FR) | ![96%](https://geps.dev/progress/96) | +| German (Deutsch) (de_DE) | ![97%](https://geps.dev/progress/97) | | Greek (Ελληνικά) (el_GR) | ![39%](https://geps.dev/progress/39) | -| Hindi (हिंदी) (hi_IN) | ![40%](https://geps.dev/progress/40) | +| Hindi (हिंदी) (hi_IN) | ![39%](https://geps.dev/progress/39) | | Hungarian (Magyar) (hu_HU) | ![43%](https://geps.dev/progress/43) | -| Indonesian (Bahasa Indonesia) (id_ID) | ![36%](https://geps.dev/progress/36) | -| Irish (Gaeilge) (ga_IE) | ![40%](https://geps.dev/progress/40) | -| Italian (Italiano) (it_IT) | ![98%](https://geps.dev/progress/98) | -| Japanese (日本語) (ja_JP) | ![41%](https://geps.dev/progress/41) | -| Korean (한국어) (ko_KR) | ![40%](https://geps.dev/progress/40) | +| Indonesian (Bahasa Indonesia) (id_ID) | ![35%](https://geps.dev/progress/35) | +| Irish (Gaeilge) (ga_IE) | ![39%](https://geps.dev/progress/39) | +| Italian (Italiano) (it_IT) | ![97%](https://geps.dev/progress/97) | +| Japanese (日本語) (ja_JP) | ![72%](https://geps.dev/progress/72) | +| Korean (한국어) (ko_KR) | ![39%](https://geps.dev/progress/39) | | Norwegian (Norsk) (no_NB) | ![37%](https://geps.dev/progress/37) | -| Persian (فارسی) (fa_IR) | ![39%](https://geps.dev/progress/39) | +| Persian (فارسی) (fa_IR) | ![38%](https://geps.dev/progress/38) | | Polish (Polski) (pl_PL) | ![41%](https://geps.dev/progress/41) | -| Portuguese (Português) (pt_PT) | ![40%](https://geps.dev/progress/40) | -| Portuguese Brazilian (Português) (pt_BR) | ![42%](https://geps.dev/progress/42) | +| Portuguese (Português) (pt_PT) | ![39%](https://geps.dev/progress/39) | +| Portuguese Brazilian (Português) (pt_BR) | ![97%](https://geps.dev/progress/97) | | Romanian (Română) (ro_RO) | ![33%](https://geps.dev/progress/33) | -| Russian (Русский) (ru_RU) | ![43%](https://geps.dev/progress/43) | +| Russian (Русский) (ru_RU) | ![96%](https://geps.dev/progress/96) | | Serbian Latin alphabet (Srpski) (sr_LATN_RS) | ![43%](https://geps.dev/progress/43) | -| Simplified Chinese (简体中文) (zh_CN) | ![99%](https://geps.dev/progress/99) | -| Slovakian (Slovensky) (sk_SK) | ![30%](https://geps.dev/progress/30) | -| Slovenian (Slovenščina) (sl_SI) | ![41%](https://geps.dev/progress/41) | -| Spanish (Español) (es_ES) | ![98%](https://geps.dev/progress/98) | +| Simplified Chinese (简体中文) (zh_CN) | ![98%](https://geps.dev/progress/98) | +| Slovakian (Slovensky) (sk_SK) | ![29%](https://geps.dev/progress/29) | +| Slovenian (Slovenščina) (sl_SI) | ![40%](https://geps.dev/progress/40) | +| Spanish (Español) (es_ES) | ![97%](https://geps.dev/progress/97) | | Swedish (Svenska) (sv_SE) | ![38%](https://geps.dev/progress/38) | | Thai (ไทย) (th_TH) | ![35%](https://geps.dev/progress/35) | | Tibetan (བོད་ཡིག་) (bo_CN) | ![65%](https://geps.dev/progress/65) | | Traditional Chinese (繁體中文) (zh_TW) | ![43%](https://geps.dev/progress/43) | -| Turkish (Türkçe) (tr_TR) | ![43%](https://geps.dev/progress/43) | -| Ukrainian (Українська) (uk_UA) | ![42%](https://geps.dev/progress/42) | +| Turkish (Türkçe) (tr_TR) | ![42%](https://geps.dev/progress/42) | +| Ukrainian (Українська) (uk_UA) | ![41%](https://geps.dev/progress/41) | | Vietnamese (Tiếng Việt) (vi_VN) | ![32%](https://geps.dev/progress/32) | | Malayalam (മലയാളം) (ml_IN) | ![73%](https://geps.dev/progress/73) | diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 5c0d44f23..7f9cdaa10 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -255,6 +255,22 @@ "cacheInputs": { "name": "Save form inputs", "help": "Enable to store previously used inputs for future runs" + }, + "hotkeys": { + "title": "Keyboard Shortcuts", + "description": "Hover a tool to see its shortcut or customise it below. Click \"Change shortcut\" and press a new key combination. Press Esc to cancel.", + "errorModifier": { + "mac": "Include ⌘ (Command), ⌥ (Option), or another modifier in your shortcut.", + "windows": "Include Ctrl, Alt, or another modifier in your shortcut." + }, + "errorConflict": "Shortcut already used by {{tool}}.", + "none": "Not assigned", + "customBadge": "Custom", + "defaultLabel": "Default: {{shortcut}}", + "capturing": "Press keys… (Esc to cancel)", + "change": "Change shortcut", + "reset": "Reset", + "shortcut": "Shortcut" } }, "changeCreds": { @@ -868,6 +884,7 @@ "rotate": { "title": "Rotate PDF", "submit": "Apply Rotation", + "selectRotation": "Select Rotation Angle (Clockwise)", "error": { "failed": "An error occurred while rotating the PDF." }, diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 529da2643..d926b9f0d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,6 +4,7 @@ import { FileContextProvider } from "./contexts/FileContext"; import { NavigationProvider } from "./contexts/NavigationContext"; import { FilesModalProvider } from "./contexts/FilesModalContext"; import { ToolWorkflowProvider } from "./contexts/ToolWorkflowContext"; +import { HotkeyProvider } from "./contexts/HotkeyContext"; import { SidebarProvider } from "./contexts/SidebarContext"; import ErrorBoundary from "./components/shared/ErrorBoundary"; import HomePage from "./pages/HomePage"; @@ -44,15 +45,17 @@ export default function App() { - - - - + + + + + - - - + + + + diff --git a/frontend/src/components/hotkeys/HotkeyDisplay.tsx b/frontend/src/components/hotkeys/HotkeyDisplay.tsx new file mode 100644 index 000000000..e240f987e --- /dev/null +++ b/frontend/src/components/hotkeys/HotkeyDisplay.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { HotkeyBinding } from '../../utils/hotkeys'; +import { useHotkeys } from '../../contexts/HotkeyContext'; + +interface HotkeyDisplayProps { + binding: HotkeyBinding | null | undefined; + size?: 'sm' | 'md'; + muted?: boolean; +} + +const baseKeyStyle: React.CSSProperties = { + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + borderRadius: '0.375rem', + background: 'var(--mantine-color-gray-1)', + border: '1px solid var(--mantine-color-gray-3)', + padding: '0.125rem 0.35rem', + fontSize: '0.75rem', + lineHeight: 1, + fontFamily: 'var(--mantine-font-family-monospace, monospace)', + minWidth: '1.35rem', + color: 'var(--mantine-color-text)', +}; + +export const HotkeyDisplay: React.FC = ({ binding, size = 'sm', muted = false }) => { + const { getDisplayParts } = useHotkeys(); + const parts = getDisplayParts(binding); + + if (!binding || parts.length === 0) { + return null; + } + + const keyStyle = size === 'md' + ? { ...baseKeyStyle, fontSize: '0.85rem', padding: '0.2rem 0.5rem' } + : baseKeyStyle; + + return ( + + {parts.map((part, index) => ( + + {part} + {index < parts.length - 1 && +} + + ))} + + ); +}; + +export default HotkeyDisplay; \ No newline at end of file diff --git a/frontend/src/components/shared/AppConfigModal.css b/frontend/src/components/shared/AppConfigModal.css new file mode 100644 index 000000000..2ada07184 --- /dev/null +++ b/frontend/src/components/shared/AppConfigModal.css @@ -0,0 +1,130 @@ +/* AppConfigModal styles */ +.modal-container { + display: flex; + gap: 0; + height: 37.5rem; /* 600px */ +} + +.modal-nav { + width: 15rem; /* 240px */ + height: 37.5rem; /* 600px */ + border-top-left-radius: 0.75rem; /* 12px */ + border-bottom-left-radius: 0.75rem; /* 12px */ + overflow: hidden; + display: flex; + flex-direction: column; +} + +/* Mobile: compact icon-only navigation */ +@media (max-width: 1024px) { + .modal-container { + height: 100vh !important; + max-height: none !important; + } + + .modal-nav { + width: 5rem; /* 80px - wider for larger icons */ + height: 100vh !important; + max-height: none !important; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + + .modal-nav-scroll { + padding: 1rem 0.5rem; + } + + .modal-nav-section { + margin-bottom: 1.5rem; + } + + .modal-nav-item.mobile { + padding: 1rem; + justify-content: center; + border-radius: 0.75rem; + margin-bottom: 0.75rem; + } + + .modal-content { + height: 100vh !important; + max-height: none !important; + border-radius: 0; + } +} + +.modal-nav-scroll { + flex: 1; + overflow-y: auto; + padding: 1rem; + padding-bottom: 2rem; + scrollbar-width: none; + -ms-overflow-style: none; +} + +.modal-nav-scroll::-webkit-scrollbar { + display: none; +} + +.modal-nav-section { + margin-bottom: 1rem; +} + +.modal-nav-section-items { + margin-top: 0.5rem; +} + +.modal-nav-item { + cursor: pointer; + padding: 0.5rem 0.625rem; /* 8px 10px */ + border-radius: 0.5rem; /* 8px */ + display: flex; + align-items: center; + gap: 0.5rem; + margin-bottom: 0.25rem; /* 4px */ +} + +.modal-content { + flex: 1; + height: 37.5rem; /* 600px */ + display: flex; + flex-direction: column; + overflow: hidden; +} + +.modal-content-scroll { + flex: 1; + overflow-y: auto; + scrollbar-width: none; + -ms-overflow-style: none; +} + +.modal-content-scroll::-webkit-scrollbar { + display: none; +} + +.modal-header { + position: sticky; + top: 0; + z-index: 5; + display: flex; + justify-content: space-between; + align-items: center; + padding: 1rem; +} + +.modal-body { + padding: 2rem; + padding-top: 1rem; +} + +.confirm-modal-content { + display: flex; + flex-direction: column; + gap: 1rem; +} + +.confirm-modal-buttons { + display: flex; + justify-content: flex-end; + gap: 0.5rem; +} \ No newline at end of file diff --git a/frontend/src/components/shared/AppConfigModal.tsx b/frontend/src/components/shared/AppConfigModal.tsx index a73e3ff73..2ed7f71b7 100644 --- a/frontend/src/components/shared/AppConfigModal.tsx +++ b/frontend/src/components/shared/AppConfigModal.tsx @@ -1,6 +1,11 @@ -import React from 'react'; -import { Modal, Button, Stack, Text, Code, ScrollArea, Group, Badge, Alert, Loader } from '@mantine/core'; -import { useAppConfig } from '../../hooks/useAppConfig'; +import React, { useMemo, useState, useEffect } from 'react'; +import { Modal, Text, ActionIcon } from '@mantine/core'; +import { useMediaQuery } from '@mantine/hooks'; +import LocalIcon from './LocalIcon'; +import Overview from './config/configSections/Overview'; +import { createConfigNavSections } from './config/configNavSections'; +import { NavKey } from './config/types'; +import './AppConfigModal.css'; interface AppConfigModalProps { opened: boolean; @@ -8,131 +13,143 @@ interface AppConfigModalProps { } const AppConfigModal: React.FC = ({ opened, onClose }) => { - const { config, loading, error, refetch } = useAppConfig(); + const [active, setActive] = useState('overview'); + const isMobile = useMediaQuery("(max-width: 1024px)"); - const renderConfigSection = (title: string, data: any) => { - if (!data || typeof data !== 'object') return null; + useEffect(() => { + const handler = (ev: Event) => { + const detail = (ev as CustomEvent).detail as { key?: NavKey } | undefined; + if (detail?.key) { + setActive(detail.key); + } + }; + window.addEventListener('appConfig:navigate', handler as EventListener); + return () => window.removeEventListener('appConfig:navigate', handler as EventListener); + }, []); - return ( - - {title} - - {Object.entries(data).map(([key, value]) => ( - - - {key}: - - {typeof value === 'boolean' ? ( - - {value ? 'true' : 'false'} - - ) : typeof value === 'object' ? ( - {JSON.stringify(value, null, 2)} - ) : ( - String(value) || 'null' - )} - - ))} - - - ); + const colors = useMemo(() => ({ + navBg: 'var(--modal-nav-bg)', + sectionTitle: 'var(--modal-nav-section-title)', + navItem: 'var(--modal-nav-item)', + navItemActive: 'var(--modal-nav-item-active)', + navItemActiveBg: 'var(--modal-nav-item-active-bg)', + contentBg: 'var(--modal-content-bg)', + headerBorder: 'var(--modal-header-border)', + }), []); + + // Placeholder logout handler (not needed in open-source but keeps SaaS compatibility) + const handleLogout = () => { + // In SaaS this would sign out, in open-source it does nothing + console.log('Logout placeholder for SaaS compatibility'); }; - const basicConfig = config ? { - appName: config.appName, - appNameNavbar: config.appNameNavbar, - baseUrl: config.baseUrl, - contextPath: config.contextPath, - serverPort: config.serverPort, - } : null; + // Left navigation structure and icons + const configNavSections = useMemo(() => + createConfigNavSections( + Overview, + handleLogout + ), + [] + ); - const securityConfig = config ? { - enableLogin: config.enableLogin, - } : null; + const activeLabel = useMemo(() => { + for (const section of configNavSections) { + const found = section.items.find(i => i.key === active); + if (found) return found.label; + } + return ''; + }, [configNavSections, active]); - const systemConfig = config ? { - enableAlphaFunctionality: config.enableAlphaFunctionality, - enableAnalytics: config.enableAnalytics, - } : null; - - const premiumConfig = config ? { - premiumEnabled: config.premiumEnabled, - premiumKey: config.premiumKey ? '***hidden***' : null, - runningProOrHigher: config.runningProOrHigher, - runningEE: config.runningEE, - license: config.license, - } : null; - - const integrationConfig = config ? { - GoogleDriveEnabled: config.GoogleDriveEnabled, - SSOAutoLogin: config.SSOAutoLogin, - } : null; - - const legalConfig = config ? { - termsAndConditions: config.termsAndConditions, - privacyPolicy: config.privacyPolicy, - cookiePolicy: config.cookiePolicy, - impressum: config.impressum, - accessibilityStatement: config.accessibilityStatement, - } : null; + const activeComponent = useMemo(() => { + for (const section of configNavSections) { + const found = section.items.find(i => i.key === active); + if (found) return found.component; + } + return null; + }, [configNavSections, active]); return ( - - - - This modal shows the current application configuration for testing purposes only. - - - +
+ {/* Left navigation */} +
+
+ {configNavSections.map(section => ( +
+ {!isMobile && ( + + {section.title} + + )} +
+ {section.items.map(item => { + const isActive = active === item.key; + const color = isActive ? colors.navItemActive : colors.navItem; + const iconSize = isMobile ? 28 : 18; + return ( +
setActive(item.key)} + className={`modal-nav-item ${isMobile ? 'mobile' : ''}`} + style={{ + background: isActive ? colors.navItemActiveBg : 'transparent', + }} + > + + {!isMobile && ( + + {item.label} + + )} +
+ ); + })} +
+
+ ))} +
+
- {loading && ( - - - Loading configuration... - - )} - - {error && ( - - {error} - - )} - - {config && ( - - - {renderConfigSection('Basic Configuration', basicConfig)} - {renderConfigSection('Security Configuration', securityConfig)} - {renderConfigSection('System Configuration', systemConfig)} - {renderConfigSection('Premium/Enterprise Configuration', premiumConfig)} - {renderConfigSection('Integration Configuration', integrationConfig)} - {renderConfigSection('Legal Configuration', legalConfig)} - - {config.error && ( - - {config.error} - - )} - - - Raw Configuration - - {JSON.stringify(config, null, 2)} - - - - - )} - + {/* Right content */} +
+
+ {/* Sticky header with section title and small close button */} +
+ {activeLabel} + + + +
+
+ {activeComponent} +
+
+
+
); }; diff --git a/frontend/src/components/shared/QuickAccessBar.tsx b/frontend/src/components/shared/QuickAccessBar.tsx index 8bc536bdb..b7206fa93 100644 --- a/frontend/src/components/shared/QuickAccessBar.tsx +++ b/frontend/src/components/shared/QuickAccessBar.tsx @@ -12,6 +12,7 @@ import { ButtonConfig } from '../../types/sidebar'; import './quickAccessBar/QuickAccessBar.css'; import AllToolsNavButton from './AllToolsNavButton'; import ActiveToolButton from "./quickAccessBar/ActiveToolButton"; +import AppConfigModal from './AppConfigModal'; import { isNavButtonActive, getNavButtonStyle, @@ -217,7 +218,7 @@ const QuickAccessBar = forwardRef((_, ref) => {
{/* Config button at the bottom */} - {/* {buttonConfigs + {buttonConfigs .filter(config => config.id === 'config') .map(config => (
@@ -237,14 +238,14 @@ const QuickAccessBar = forwardRef((_, ref) => { {config.name}
- ))} */} + ))}
- {/* setConfigModalOpen(false)} - /> */} + /> ); }); diff --git a/frontend/src/components/shared/config/configNavSections.tsx b/frontend/src/components/shared/config/configNavSections.tsx new file mode 100644 index 000000000..912ad8647 --- /dev/null +++ b/frontend/src/components/shared/config/configNavSections.tsx @@ -0,0 +1,57 @@ +import React from 'react'; +import { NavKey } from './types'; +import HotkeysSection from './configSections/HotkeysSection'; + +export interface ConfigNavItem { + key: NavKey; + label: string; + icon: string; + component: React.ReactNode; +} + +export interface ConfigNavSection { + title: string; + items: ConfigNavItem[]; +} + +export interface ConfigColors { + navBg: string; + sectionTitle: string; + navItem: string; + navItemActive: string; + navItemActiveBg: string; + contentBg: string; + headerBorder: string; +} + +export const createConfigNavSections = ( + Overview: React.ComponentType<{ onLogoutClick: () => void }>, + onLogoutClick: () => void +): ConfigNavSection[] => { + const sections: ConfigNavSection[] = [ + { + title: 'Account', + items: [ + { + key: 'overview', + label: 'Overview', + icon: 'person-rounded', + component: + }, + ], + }, + { + title: 'Preferences', + items: [ + { + key: 'hotkeys', + label: 'Keyboard Shortcuts', + icon: 'keyboard-rounded', + component: + }, + ], + }, + ]; + + return sections; +}; \ No newline at end of file diff --git a/frontend/src/components/shared/config/configSections/HotkeysSection.tsx b/frontend/src/components/shared/config/configSections/HotkeysSection.tsx new file mode 100644 index 000000000..e0240f55a --- /dev/null +++ b/frontend/src/components/shared/config/configSections/HotkeysSection.tsx @@ -0,0 +1,171 @@ +import React, { useEffect, useMemo, useState } from 'react'; +import { Alert, Badge, Box, Button, Divider, Group, Paper, Stack, Text } from '@mantine/core'; +import { useTranslation } from 'react-i18next'; +import { useToolWorkflow } from '../../../../contexts/ToolWorkflowContext'; +import { useHotkeys } from '../../../../contexts/HotkeyContext'; +import HotkeyDisplay from '../../../hotkeys/HotkeyDisplay'; +import { bindingEquals, eventToBinding } from '../../../../utils/hotkeys'; + +const rowStyle: React.CSSProperties = { + display: 'flex', + flexDirection: 'column', + gap: '0.5rem', +}; + +const rowHeaderStyle: React.CSSProperties = { + display: 'flex', + flexWrap: 'wrap', + alignItems: 'center', + justifyContent: 'space-between', + gap: '0.5rem', +}; + +const HotkeysSection: React.FC = () => { + const { t } = useTranslation(); + const { toolRegistry } = useToolWorkflow(); + const { hotkeys, defaults, updateHotkey, resetHotkey, pauseHotkeys, resumeHotkeys, getDisplayParts, isMac } = useHotkeys(); + const [editingTool, setEditingTool] = useState(null); + const [error, setError] = useState(null); + + const tools = useMemo(() => Object.entries(toolRegistry), [toolRegistry]); + + useEffect(() => { + if (!editingTool) { + return; + } + pauseHotkeys(); + return () => { + resumeHotkeys(); + }; + }, [editingTool, pauseHotkeys, resumeHotkeys]); + + useEffect(() => { + if (!editingTool) { + return; + } + + const handleKeyDown = (event: KeyboardEvent) => { + event.preventDefault(); + event.stopPropagation(); + + if (event.key === 'Escape') { + setEditingTool(null); + setError(null); + return; + } + + const binding = eventToBinding(event as KeyboardEvent); + if (!binding) { + const osKey = isMac ? 'mac' : 'windows'; + const fallbackText = isMac + ? 'Include ⌘ (Command), ⌥ (Option), or another modifier in your shortcut.' + : 'Include Ctrl, Alt, or another modifier in your shortcut.'; + setError(t(`settings.hotkeys.errorModifier.${osKey}`, fallbackText)); + return; + } + + const conflictEntry = Object.entries(hotkeys).find(([toolId, existing]) => ( + toolId !== editingTool && bindingEquals(existing, binding) + )); + + if (conflictEntry) { + const conflictTool = toolRegistry[conflictEntry[0]]?.name ?? conflictEntry[0]; + setError(t('settings.hotkeys.errorConflict', 'Shortcut already used by {{tool}}.', { tool: conflictTool })); + return; + } + + updateHotkey(editingTool, binding); + setEditingTool(null); + setError(null); + }; + + window.addEventListener('keydown', handleKeyDown, true); + return () => { + window.removeEventListener('keydown', handleKeyDown, true); + }; + }, [editingTool, hotkeys, toolRegistry, updateHotkey, t]); + + const handleStartCapture = (toolId: string) => { + setEditingTool(toolId); + setError(null); + }; + + return ( + +
+ Keyboard Shortcuts + + Customize keyboard shortcuts for quick tool access. Click "Change shortcut" and press a new key combination. Press Esc to cancel. + +
+ + + + {tools.map(([toolId, tool], index) => { + const currentBinding = hotkeys[toolId]; + const defaultBinding = defaults[toolId]; + const isEditing = editingTool === toolId; + const defaultParts = getDisplayParts(defaultBinding); + const defaultLabel = defaultParts.length > 0 + ? defaultParts.join(' + ') + : t('settings.hotkeys.none', 'Not assigned'); + + return ( + + +
+
+ {tool.name} + + + {!bindingEquals(currentBinding, defaultBinding) && ( + + {t('settings.hotkeys.customBadge', 'Custom')} + + )} + + {t('settings.hotkeys.defaultLabel', 'Default: {{shortcut}}', { shortcut: defaultLabel })} + + +
+ + + + + +
+ + {isEditing && error && ( + + {error} + + )} +
+ + {index < tools.length - 1 && } +
+ ); + })} +
+
+
+ ); +}; + +export default HotkeysSection; \ No newline at end of file diff --git a/frontend/src/components/shared/config/configSections/Overview.tsx b/frontend/src/components/shared/config/configSections/Overview.tsx new file mode 100644 index 000000000..e591655e0 --- /dev/null +++ b/frontend/src/components/shared/config/configSections/Overview.tsx @@ -0,0 +1,102 @@ +import React from 'react'; +import { Stack, Text, Code, Group, Badge, Alert, Loader } from '@mantine/core'; +import { useAppConfig } from '../../../../hooks/useAppConfig'; + +const Overview: React.FC = () => { + const { config, loading, error } = useAppConfig(); + + const renderConfigSection = (title: string, data: any) => { + if (!data || typeof data !== 'object') return null; + + return ( + + {title} + + {Object.entries(data).map(([key, value]) => ( + + + {key}: + + {typeof value === 'boolean' ? ( + + {value ? 'true' : 'false'} + + ) : typeof value === 'object' ? ( + {JSON.stringify(value, null, 2)} + ) : ( + String(value) || 'null' + )} + + ))} + + + ); + }; + + const basicConfig = config ? { + appName: config.appName, + appNameNavbar: config.appNameNavbar, + baseUrl: config.baseUrl, + contextPath: config.contextPath, + serverPort: config.serverPort, + } : null; + + const securityConfig = config ? { + enableLogin: config.enableLogin, + } : null; + + const systemConfig = config ? { + enableAlphaFunctionality: config.enableAlphaFunctionality, + enableAnalytics: config.enableAnalytics, + } : null; + + const integrationConfig = config ? { + GoogleDriveEnabled: config.GoogleDriveEnabled, + SSOAutoLogin: config.SSOAutoLogin, + } : null; + + if (loading) { + return ( + + + Loading configuration... + + ); + } + + if (error) { + return ( + + {error} + + ); + } + + return ( + +
+ Application Configuration + + Current application settings and configuration details. + +
+ + {config && ( + <> + {renderConfigSection('Basic Configuration', basicConfig)} + {renderConfigSection('Security Configuration', securityConfig)} + {renderConfigSection('System Configuration', systemConfig)} + {renderConfigSection('Integration Configuration', integrationConfig)} + + {config.error && ( + + {config.error} + + )} + + )} +
+ ); +}; + +export default Overview; \ No newline at end of file diff --git a/frontend/src/components/shared/config/types.ts b/frontend/src/components/shared/config/types.ts new file mode 100644 index 000000000..2ef734422 --- /dev/null +++ b/frontend/src/components/shared/config/types.ts @@ -0,0 +1,19 @@ +export type NavKey = + | 'overview' + | 'preferences' + | 'notifications' + | 'connections' + | 'general' + | 'people' + | 'teams' + | 'security' + | 'identity' + | 'plan' + | 'payments' + | 'requests' + | 'developer' + | 'api-keys' + | 'hotkeys'; + + + // some of these are not used yet, but appear in figma designs \ No newline at end of file diff --git a/frontend/src/components/tools/addAttachments/AddAttachmentsSettings.tsx b/frontend/src/components/tools/addAttachments/AddAttachmentsSettings.tsx new file mode 100644 index 000000000..632ed71f1 --- /dev/null +++ b/frontend/src/components/tools/addAttachments/AddAttachmentsSettings.tsx @@ -0,0 +1,119 @@ +/** + * AddAttachmentsSettings - Shared settings component for both tool UI and automation + * + * Allows selecting files to attach to PDFs. + */ + +import { Stack, Text, Group, ActionIcon, Alert, ScrollArea, Button } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { AddAttachmentsParameters } from "../../../hooks/tools/addAttachments/useAddAttachmentsParameters"; +import LocalIcon from "../../shared/LocalIcon"; + +interface AddAttachmentsSettingsProps { + parameters: AddAttachmentsParameters; + onParameterChange: (key: K, value: AddAttachmentsParameters[K]) => void; + disabled?: boolean; +} + +const AddAttachmentsSettings = ({ parameters, onParameterChange, disabled = false }: AddAttachmentsSettingsProps) => { + const { t } = useTranslation(); + + return ( + + + + {t("AddAttachmentsRequest.info", "Select files to attach to your PDF. These files will be embedded and accessible through the PDF's attachment panel.")} + + + + + + {t("AddAttachmentsRequest.selectFiles", "Select Files to Attach")} + + { + const files = Array.from(e.target.files || []); + // Append to existing attachments instead of replacing + const newAttachments = [...(parameters.attachments || []), ...files]; + onParameterChange('attachments', newAttachments); + // Reset the input so the same file can be selected again + e.target.value = ''; + }} + disabled={disabled} + style={{ display: 'none' }} + id="attachments-input" + /> + + + + {parameters.attachments?.length > 0 && ( + + + {t("AddAttachmentsRequest.selectedFiles", "Selected Files")} ({parameters.attachments.length}) + + + + {parameters.attachments.map((file, index) => ( + + + {/* Filename (two-line clamp, wraps, no icon on the left) */} +
+
+ {file.name} +
+
+ + ({(file.size / 1024).toFixed(1)} KB) + +
+ { + const newAttachments = (parameters.attachments || []).filter((_, i) => i !== index); + onParameterChange('attachments', newAttachments); + }} + disabled={disabled} + > + + +
+ ))} +
+
+
+ )} +
+ ); +}; + +export default AddAttachmentsSettings; diff --git a/frontend/src/components/tools/addPageNumbers/AddPageNumbersAppearanceSettings.tsx b/frontend/src/components/tools/addPageNumbers/AddPageNumbersAppearanceSettings.tsx new file mode 100644 index 000000000..0b7ecb02e --- /dev/null +++ b/frontend/src/components/tools/addPageNumbers/AddPageNumbersAppearanceSettings.tsx @@ -0,0 +1,77 @@ +/** + * AddPageNumbersAppearanceSettings - Customize Appearance step + */ + +import { Stack, Select, TextInput, NumberInput } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { AddPageNumbersParameters } from "./useAddPageNumbersParameters"; +import { Tooltip } from "../../shared/Tooltip"; + +interface AddPageNumbersAppearanceSettingsProps { + parameters: AddPageNumbersParameters; + onParameterChange: (key: K, value: AddPageNumbersParameters[K]) => void; + disabled?: boolean; +} + +const AddPageNumbersAppearanceSettings = ({ + parameters, + onParameterChange, + disabled = false +}: AddPageNumbersAppearanceSettingsProps) => { + const { t } = useTranslation(); + + return ( + + + onParameterChange('fontType', (v as any) || 'Times')} + data={[ + { value: 'Times', label: 'Times Roman' }, + { value: 'Helvetica', label: 'Helvetica' }, + { value: 'Courier', label: 'Courier New' }, + ]} + disabled={disabled} + /> + + + + onParameterChange('customText', e.currentTarget.value)} + placeholder={t('addPageNumbers.customNumberDesc', 'e.g., "Page {n}" or leave blank for just numbers')} + disabled={disabled} + /> + + + ); +}; + +export default AddPageNumbersAppearanceSettings; diff --git a/frontend/src/components/tools/addPageNumbers/AddPageNumbersAutomationSettings.tsx b/frontend/src/components/tools/addPageNumbers/AddPageNumbersAutomationSettings.tsx new file mode 100644 index 000000000..86888d0e4 --- /dev/null +++ b/frontend/src/components/tools/addPageNumbers/AddPageNumbersAutomationSettings.tsx @@ -0,0 +1,55 @@ +/** + * AddPageNumbersAutomationSettings - Used for automation only + * + * Combines both position and appearance settings into a single view + */ + +import { Stack, Divider, Text } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { AddPageNumbersParameters } from "./useAddPageNumbersParameters"; +import AddPageNumbersPositionSettings from "./AddPageNumbersPositionSettings"; +import AddPageNumbersAppearanceSettings from "./AddPageNumbersAppearanceSettings"; + +interface AddPageNumbersAutomationSettingsProps { + parameters: AddPageNumbersParameters; + onParameterChange: (key: K, value: AddPageNumbersParameters[K]) => void; + disabled?: boolean; +} + +const AddPageNumbersAutomationSettings = ({ + parameters, + onParameterChange, + disabled = false +}: AddPageNumbersAutomationSettingsProps) => { + const { t } = useTranslation(); + + return ( + + {/* Position & Pages Section */} + + {t("addPageNumbers.positionAndPages", "Position & Pages")} + + + + + + {/* Appearance Section */} + + {t("addPageNumbers.customize", "Customize Appearance")} + + + + ); +}; + +export default AddPageNumbersAutomationSettings; diff --git a/frontend/src/components/tools/addPageNumbers/AddPageNumbersPositionSettings.tsx b/frontend/src/components/tools/addPageNumbers/AddPageNumbersPositionSettings.tsx new file mode 100644 index 000000000..be79f4e46 --- /dev/null +++ b/frontend/src/components/tools/addPageNumbers/AddPageNumbersPositionSettings.tsx @@ -0,0 +1,70 @@ +/** + * AddPageNumbersPositionSettings - Position & Pages step + */ + +import { Stack, TextInput, NumberInput, Divider, Text } from "@mantine/core"; +import { useTranslation } from "react-i18next"; +import { AddPageNumbersParameters } from "./useAddPageNumbersParameters"; +import { Tooltip } from "../../shared/Tooltip"; +import PageNumberPreview from "./PageNumberPreview"; + +interface AddPageNumbersPositionSettingsProps { + parameters: AddPageNumbersParameters; + onParameterChange: (key: K, value: AddPageNumbersParameters[K]) => void; + disabled?: boolean; + file?: File | null; + showQuickGrid?: boolean; +} + +const AddPageNumbersPositionSettings = ({ + parameters, + onParameterChange, + disabled = false, + file = null, + showQuickGrid = true +}: AddPageNumbersPositionSettingsProps) => { + const { t } = useTranslation(); + + return ( + + {/* Position Selection */} + + + + + + + {/* Pages & Starting Number Section */} + + {t('addPageNumbers.pagesAndStarting', 'Pages & Starting Number')} + + + onParameterChange('pagesToNumber', e.currentTarget.value)} + placeholder={t('addPageNumbers.numberPagesDesc', 'e.g., 1,3,5-8 or leave blank for all pages')} + disabled={disabled} + /> + + + + onParameterChange('startingNumber', typeof v === 'number' ? v : 1)} + min={1} + disabled={disabled} + /> + + + + ); +}; + +export default AddPageNumbersPositionSettings; diff --git a/frontend/src/components/tools/addStamp/AddStampAutomationSettings.tsx b/frontend/src/components/tools/addStamp/AddStampAutomationSettings.tsx new file mode 100644 index 000000000..25091d854 --- /dev/null +++ b/frontend/src/components/tools/addStamp/AddStampAutomationSettings.tsx @@ -0,0 +1,43 @@ +/** + * AddStampAutomationSettings - Used for automation only + * + * This component combines all stamp settings into a single step interface + * for use in the automation system. It includes setup and formatting + * settings in one unified component. + */ + +import { Stack } from "@mantine/core"; +import { AddStampParameters } from "./useAddStampParameters"; +import StampSetupSettings from "./StampSetupSettings"; +import StampPositionFormattingSettings from "./StampPositionFormattingSettings"; + +interface AddStampAutomationSettingsProps { + parameters: AddStampParameters; + onParameterChange: (key: K, value: AddStampParameters[K]) => void; + disabled?: boolean; +} + +const AddStampAutomationSettings = ({ parameters, onParameterChange, disabled = false }: AddStampAutomationSettingsProps) => { + return ( + + {/* Stamp Setup (Type, Text/Image, Page Selection) */} + + + {/* Position and Formatting Settings */} + {parameters.stampType && ( + + )} + + ); +}; + +export default AddStampAutomationSettings; diff --git a/frontend/src/components/tools/addStamp/StampPositionFormattingSettings.tsx b/frontend/src/components/tools/addStamp/StampPositionFormattingSettings.tsx new file mode 100644 index 000000000..d1c0d0c9f --- /dev/null +++ b/frontend/src/components/tools/addStamp/StampPositionFormattingSettings.tsx @@ -0,0 +1,201 @@ +import { useTranslation } from "react-i18next"; +import { Group, Select, Stack, ColorInput, Button, Slider, Text, NumberInput } from "@mantine/core"; +import { AddStampParameters } from "./useAddStampParameters"; +import LocalIcon from "../../shared/LocalIcon"; +import styles from "./StampPreview.module.css"; +import { Tooltip } from "../../shared/Tooltip"; + +interface StampPositionFormattingSettingsProps { + parameters: AddStampParameters; + onParameterChange: (key: K, value: AddStampParameters[K]) => void; + disabled?: boolean; + showPositionGrid?: boolean; // When true, show the 9-position grid for automation +} + +const StampPositionFormattingSettings = ({ parameters, onParameterChange, disabled = false, showPositionGrid = false }: StampPositionFormattingSettingsProps) => { + const { t } = useTranslation(); + + return ( + + {/* Position Grid - shown in automation settings */} + {showPositionGrid && ( + + {t('AddStampRequest.position', 'Stamp Position')} +
+ {Array.from({ length: 9 }).map((_, i) => { + const idx = (i + 1) as 1|2|3|4|5|6|7|8|9; + const selected = parameters.position === idx; + return ( + + ); + })} +
+
+ )} + {/* Icon pill buttons row */} +
+ + + + + + + + + +
+ + {/* Single slider bound to selected pill */} + {parameters._activePill === 'fontSize' && ( + + + {parameters.stampType === 'image' + ? t('AddStampRequest.imageSize', 'Image Size') + : t('AddStampRequest.fontSize', 'Font Size') + } + + + onParameterChange('fontSize', typeof v === 'number' ? v : 1)} + min={1} + max={400} + step={1} + size="sm" + className={styles.numberInput} + disabled={disabled} + /> + onParameterChange('fontSize', v as number)} + min={1} + max={400} + step={1} + className={styles.slider} + /> + + + )} + {parameters._activePill === 'rotation' && ( + + {t('AddStampRequest.rotation', 'Rotation')} + + onParameterChange('rotation', typeof v === 'number' ? v : 0)} + min={-180} + max={180} + step={1} + size="sm" + className={styles.numberInput} + hideControls + disabled={disabled} + /> + onParameterChange('rotation', v as number)} + min={-180} + max={180} + step={1} + className={styles.sliderWide} + /> + + + )} + {parameters._activePill === 'opacity' && ( + + {t('AddStampRequest.opacity', 'Opacity')} + + onParameterChange('opacity', typeof v === 'number' ? v : 0)} + min={0} + max={100} + step={1} + size="sm" + className={styles.numberInput} + disabled={disabled} + /> + onParameterChange('opacity', v as number)} + min={0} + max={100} + step={1} + className={styles.slider} + /> + + + )} + + {parameters.stampType !== 'image' && ( + onParameterChange('customColor', value)} + format="hex" + disabled={disabled} + /> + )} + + {/* Margin selection for text stamps */} + {parameters.stampType === 'text' && ( +