Note moving
Some checks are pending
Build Electron App / build (macos-latest, build:mac) (push) Waiting to run
Build Electron App / build (ubuntu-latest, build:linux) (push) Waiting to run
Build Electron App / build (windows-latest, build:win) (push) Waiting to run

This commit is contained in:
nicwands
2026-03-12 13:25:56 -04:00
parent 93edf204ce
commit c93fc2cc58
24 changed files with 10210 additions and 2518 deletions

View File

@@ -91,12 +91,14 @@ class Config {
);
}
}
const DEFAULT_WINDOW_SIZE = { width: 354, height: 549 };
const DEFAULT_MOVE_WINDOW_SIZE = { width: 708, height: 549 };
const preloadPath = join(__dirname, "../preload/index.mjs");
const rendererPath = join(__dirname, "../renderer/index.html");
function createWindow() {
const mainWindow = new BrowserWindow({
width: 354,
height: 549,
width: DEFAULT_WINDOW_SIZE.width,
height: DEFAULT_WINDOW_SIZE.height,
show: false,
autoHideMenuBar: true,
webPreferences: {
@@ -119,8 +121,8 @@ function createWindow() {
}
function createNoteWindow(noteId) {
const noteWindow = new BrowserWindow({
width: 354,
height: 549,
width: DEFAULT_WINDOW_SIZE.width,
height: DEFAULT_WINDOW_SIZE.height,
autoHideMenuBar: true,
webPreferences: {
preload: preloadPath,
@@ -186,6 +188,26 @@ app.whenReady().then(async () => {
ipcMain.on("note-changed", (_, event, data) => {
broadcastNoteChange(event, data);
});
ipcMain.handle("move-opened", (_) => {
const activeWindow = BrowserWindow.getFocusedWindow();
const windowSize = activeWindow.getSize();
if (windowSize[0] < DEFAULT_MOVE_WINDOW_SIZE.width) {
activeWindow.setSize(
DEFAULT_MOVE_WINDOW_SIZE.width,
DEFAULT_MOVE_WINDOW_SIZE.height
);
}
});
ipcMain.handle("move-closed", (_) => {
const activeWindow = BrowserWindow.getFocusedWindow();
const windowSize = activeWindow.getSize();
if (windowSize[0] === 708) {
activeWindow.setSize(
DEFAULT_WINDOW_SIZE.width,
DEFAULT_WINDOW_SIZE.height
);
}
});
electronApp.setAppUserModelId("com.electron");
app.on("browser-window-created", (_, window) => {
optimizer.watchWindowShortcuts(window);