Note moving
Some checks failed
Build Electron App / build (macos-latest, build:mac) (push) Has been cancelled
Build Electron App / build (ubuntu-latest, build:linux) (push) Has been cancelled
Build Electron App / build (windows-latest, build:win) (push) Has been cancelled

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

@@ -7,14 +7,17 @@ import PluginRegistry from './core/PluginRegistry.js'
import Config from './core/Config.js'
import { join } from 'path'
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')
// Main window
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: {
@@ -42,8 +45,8 @@ function createWindow() {
// Open note in new window
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,
@@ -138,6 +141,30 @@ app.whenReady().then(async () => {
broadcastNoteChange(event, data)
})
// Handle resizing for note "move" functionality
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) => {