fix: restore note window opening

This commit is contained in:
lucaronin
2026-05-21 10:19:49 +02:00
parent b2a94b482e
commit ecfc76af59
2 changed files with 37 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ import { shouldUseLinuxWindowChrome } from './platform'
import { rememberNoteWindowParams } from './windowMode'
const MACOS_TRAFFIC_LIGHT_POSITION = { x: 18, y: 24 } as const
const APP_ORIGIN_PROTOCOLS = new Set(['http:', 'https:'])
export function buildNoteWindowUrl(notePath: string, vaultPath: string, noteTitle: string, windowLabel?: string): string {
const params = new URLSearchParams({
@@ -19,6 +20,21 @@ export function buildNoteWindowUrl(notePath: string, vaultPath: string, noteTitl
return `/?${params.toString()}`
}
function resolveNoteWindowUrlForRuntime(route: string): string {
if (!APP_ORIGIN_PROTOCOLS.has(window.location.protocol)) return route
return new URL(route, window.location.origin).toString()
}
export function buildRuntimeNoteWindowUrl(
notePath: string,
vaultPath: string,
noteTitle: string,
windowLabel?: string,
): string {
return resolveNoteWindowUrlForRuntime(buildNoteWindowUrl(notePath, vaultPath, noteTitle, windowLabel))
}
/**
* Opens a note in a new Tauri window with a minimal editor-only layout.
* In browser mode (non-Tauri), this is a no-op.
@@ -32,7 +48,7 @@ export async function openNoteInNewWindow(notePath: string, vaultPath: string, n
rememberNoteWindowParams(label, { notePath, vaultPath, noteTitle })
new WebviewWindow(label, {
url: buildNoteWindowUrl(notePath, vaultPath, noteTitle, label),
url: buildRuntimeNoteWindowUrl(notePath, vaultPath, noteTitle, label),
title: noteTitle,
width: 800,
height: 700,