fix: restore note window opening
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user