Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit e640c38

Browse files
committed
Enhance Electron API and add PDF preview functionality
- Added `setWindowTitle` and `updateWindowPreview` methods to the Electron API for better window management. - Implemented a new SVG icon for PDF previews to improve user interface. - Updated the main Electron process to handle window title updates and thumbnail previews for ALT+TAB functionality on Windows. - Integrated the new search functionality in the FileReader component, allowing users to find text within documents and manage recent searches. - Refactored various components to streamline search and navigation features, enhancing overall user experience.
1 parent a7bfd90 commit e640c38

23 files changed

Lines changed: 1273 additions & 420 deletions
Lines changed: 20 additions & 0 deletions
Loading

src/electron/main.ts

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,30 @@ const toggleDevTools = () => {
4040
}
4141
};
4242

43+
// Helper to update the window title
44+
const updateWindowTitle = (title: string) => {
45+
if (mainWindow) {
46+
// Append CloudNotes to the title for branding
47+
const appTitle = title ? `${title} - CloudNotes` : 'CloudNotes';
48+
mainWindow.setTitle(appTitle);
49+
}
50+
};
51+
52+
// Function to update the thumbnail preview for ALT+TAB on Windows
53+
const updateThumbnailClip = () => {
54+
if (mainWindow && process.platform === 'win32') {
55+
const { width, height } = mainWindow.getContentBounds();
56+
// Create a clip area that excludes the title bar to show just the document content
57+
mainWindow.setThumbnailClip({ x: 0, y: 48, width, height: height - 48 });
58+
}
59+
};
60+
4361
function createWindow() {
4462
mainWindow = new BrowserWindow({
4563
frame: false, // Remove the window frame (toolbar and title bar)
4664
show: false, // Run in windowless mode (do not display the window)
4765
autoHideMenuBar: true, // Ensure the menu bar is hidden
66+
title: 'CloudNotes', // Set default window title
4867
webPreferences: {
4968
preload: getPreloadPath(),
5069
nodeIntegration: false,
@@ -58,6 +77,18 @@ function createWindow() {
5877
mainWindow.show();
5978
mainWindow.webContents.session.setSpellCheckerEnabled(false);
6079

80+
// Set the window title for taskbar and ALT+TAB
81+
mainWindow.setTitle('CloudNotes');
82+
83+
// Set a thumbnail clip area for the ALT+TAB preview on Windows
84+
// This will create a preview of the main content area, not including the custom titlebar
85+
if (process.platform === 'win32') {
86+
// Clip area starts below the title bar (48px height)
87+
// Width and height are set to the main content area
88+
const { width, height } = mainWindow.getContentBounds();
89+
mainWindow.setThumbnailClip({ x: 0, y: 48, width, height: height - 48 });
90+
}
91+
6192
// Load the app
6293
if (isDev()) {
6394
mainWindow.loadURL('http://localhost:5123');
@@ -73,18 +104,15 @@ function createWindow() {
73104

74105
// Listen for navigation events to update state
75106
mainWindow.webContents.on('did-navigate', () => {
76-
console.log('did-navigate event triggered');
77107
updateNavigationState();
78108
});
79109

80110
mainWindow.webContents.on('did-navigate-in-page', () => {
81-
console.log('did-navigate-in-page event triggered');
82111
updateNavigationState();
83112
});
84113

85114
// Add this event listener for SPA navigation
86115
mainWindow.webContents.on('page-title-updated', () => {
87-
console.log('page-title-updated event triggered');
88116
updateNavigationState();
89117
});
90118

@@ -125,9 +153,6 @@ function createWindow() {
125153
app.on('ready', () => {
126154
createWindow();
127155

128-
// Log global shortcuts registered
129-
console.log('Registering global shortcuts for DevTools');
130-
131156
// Add IPC handler for toggling DevTools
132157
ipcMain.handle('toggle-dev-tools', () => {
133158
toggleDevTools();
@@ -256,6 +281,16 @@ ipcMain.on('request-navigation-state-update', () => {
256281
updateNavigationState();
257282
});
258283

284+
// Set window title handler
285+
ipcMain.on('set-window-title', (_event, title: string) => {
286+
updateWindowTitle(title);
287+
});
288+
289+
// Update window preview handler
290+
ipcMain.on('update-window-preview', () => {
291+
updateThumbnailClip();
292+
});
293+
259294
// Quit application when all windows are closed on macOS
260295
app.on('window-all-closed', () => {
261296
if (process.platform !== 'darwin') {

src/electron/preload.cts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ contextBridge.exposeInMainWorld('electron', {
77
minimize: () => ipcRenderer.send('minimize-window'),
88
maximize: () => ipcRenderer.send('maximize-window'),
99
close: () => ipcRenderer.send('close-window'),
10+
setWindowTitle: (title: string) => ipcRenderer.send('set-window-title', title),
11+
updateWindowPreview: () => ipcRenderer.send('update-window-preview'),
1012

1113
// Navigation controls
1214
goBack: () => ipcRenderer.send('go-back'),

src/frontend/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function App() {
1818
const handleKeyDown = (e: KeyboardEvent) => {
1919
// Alternative way to toggle dev tools with Ctrl+Shift+I
2020
if (e.ctrlKey && e.shiftKey && e.key === 'I') {
21-
console.log('Keyboard shortcut detected: Ctrl+Shift+I');
2221
toggleDevTools();
2322
}
2423
};

src/frontend/components/form-fields/FormContainer.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ export function FormContainer<TFieldValues extends FieldValues>({
5656

5757
// Trigger form validation and submission
5858
form.handleSubmit((data: TFieldValues) => {
59-
console.log("Form submitted", form.formState.isValid);
60-
console.log("Form data", data);
61-
6259
// At this point, if we have the data, the form is valid
6360
onSubmit(data);
6461
})(event);

0 commit comments

Comments
 (0)