MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / openFloatingNoteWindow

Function openFloatingNoteWindow

apps/desktop/src/main/index.ts:2858–2933  ·  view source on GitHub ↗
(relPath: string)

Source from the content-addressed store, hash-verified

2856 */
2857const floatingNoteWindows = new Map<string, BrowserWindow>()
2858function openFloatingNoteWindow(relPath: string): void {
2859 const floatingWindowStartedAt = performance.now()
2860 const sourceWindow = currentIpcWindow() ?? mainWindow
2861 const sourceVault =
2862 sourceWindow && !sourceWindow.isDestroyed() ? windowVaults.vaultForWindow(sourceWindow.id) : currentVault
2863 const floatingKey = `${sourceVault?.root ?? 'no-vault'}:${relPath}`
2864 const existing = floatingNoteWindows.get(floatingKey)
2865 if (existing && !existing.isDestroyed()) {
2866 if (existing.isMinimized()) existing.restore()
2867 existing.focus()
2868 return
2869 }
2870 const mac = isMac()
2871 const win = new BrowserWindow({
2872 width: 720,
2873 height: 720,
2874 minWidth: 360,
2875 minHeight: 320,
2876 show: false,
2877 autoHideMenuBar: true,
2878 titleBarStyle: mac ? 'hiddenInset' : 'hidden',
2879 trafficLightPosition: { x: 12, y: 12 },
2880 ...(mac
2881 ? {
2882 backgroundColor: MAC_WINDOW_BACKGROUND_COLOR
2883 }
2884 : {
2885 backgroundColor: '#faf7f0',
2886 icon: windowIconPath()
2887 }),
2888 webPreferences: {
2889 preload: path.join(__dirname, '../preload/index.js'),
2890 // Keep the renderer isolated and node-free, but the current preload
2891 // still relies on Node/Electron APIs that are not available inside a
2892 // fully sandboxed preload context.
2893 sandbox: false,
2894 contextIsolation: true,
2895 nodeIntegration: false
2896 }
2897 })
2898
2899 floatingNoteWindows.set(floatingKey, win)
2900 win.on('closed', () => {
2901 floatingNoteWindows.delete(floatingKey)
2902 windowVaults.clearWindow(win.id)
2903 })
2904 win.on('ready-to-show', () => {
2905 recordMainPerf('main.floating-window.ready-to-show', performance.now() - floatingWindowStartedAt, {
2906 path: relPath
2907 })
2908 win.show()
2909 })
2910 win.webContents.once('did-finish-load', () => {
2911 recordMainPerf(
2912 'main.floating-window.did-finish-load',
2913 performance.now() - floatingWindowStartedAt,
2914 { path: relPath }
2915 )

Callers 2

registerIpcFunction · 0.85

Calls 12

recordMainPerfFunction · 0.90
currentIpcWindowFunction · 0.85
isMacFunction · 0.85
windowIconPathFunction · 0.85
installNavigationGuardsFunction · 0.85
installZoomControlsFunction · 0.85
applyZoomFactorFunction · 0.85
vaultForWindowMethod · 0.80
deleteMethod · 0.80
clearWindowMethod · 0.80
onMethod · 0.45

Tested by

no test coverage detected