mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-09-19 17:37:29 +02:00
v1.1.6 - Multi-window, single-instance file handling, line height setting
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
|
||||
const openNoteWindows = new Map<string, string>();
|
||||
|
||||
export async function openNoteWindow(notePath: string, noteTitle: string) {
|
||||
const existingLabel = openNoteWindows.get(notePath);
|
||||
if (existingLabel) {
|
||||
const existing = await WebviewWindow.getByLabel(existingLabel);
|
||||
if (existing) {
|
||||
await existing.show();
|
||||
await existing.unminimize();
|
||||
await existing.setFocus();
|
||||
return;
|
||||
}
|
||||
openNoteWindows.delete(notePath);
|
||||
}
|
||||
|
||||
const label = `note-${Date.now()}`;
|
||||
const url = `/?note=${encodeURIComponent(notePath)}`;
|
||||
|
||||
const noteWindow = new WebviewWindow(label, {
|
||||
url,
|
||||
title: `${noteTitle} - HelixNotes`,
|
||||
width: 900,
|
||||
height: 700,
|
||||
minWidth: 500,
|
||||
minHeight: 400,
|
||||
decorations: false,
|
||||
center: true
|
||||
});
|
||||
|
||||
openNoteWindows.set(notePath, label);
|
||||
|
||||
noteWindow.once('tauri://destroyed', () => {
|
||||
openNoteWindows.delete(notePath);
|
||||
});
|
||||
|
||||
noteWindow.once('tauri://error', (e) => {
|
||||
console.error('Failed to create note window:', e);
|
||||
openNoteWindows.delete(notePath);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user