From 146e33ef3f655c369ad7e420774bb3fcb7f738e8 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Sat, 7 Dec 2024 00:01:22 +0100 Subject: [PATCH] Set window title to name of current buffer #build --- electron/main/index.ts | 3 +++ electron/preload/index.ts | 4 ++++ src/components/App.vue | 5 +++++ src/editor/block/block.js | 12 ++++++------ webapp/bridge.js | 4 ++++ 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 7c06d463..2dd5624b 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -359,6 +359,9 @@ ipcMain.handle('dark-mode:set', (event, mode) => { ipcMain.handle('dark-mode:get', () => nativeTheme.themeSource) +ipcMain.handle("setWindowTitle", (event, title) => { + win?.setTitle(title) +}) // Initialize note/file library async function initFileLibrary(win) { diff --git a/electron/preload/index.ts b/electron/preload/index.ts index 1dd2eb15..3f4410c0 100644 --- a/electron/preload/index.ts +++ b/electron/preload/index.ts @@ -161,6 +161,10 @@ contextBridge.exposeInMainWorld("heynote", { async getInitErrors() { return await ipcRenderer.invoke("getInitErrors") }, + + setWindowTitle(title) { + ipcRenderer.invoke("setWindowTitle", title) + }, }) diff --git a/src/components/App.vue b/src/components/App.vue index d546834d..1de94f0f 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -74,11 +74,16 @@ currentBufferPath() { this.focusEditor() }, + + currentBufferName() { + window.heynote.setWindowTitle(this.currentBufferName) + }, }, computed: { ...mapState(useHeynoteStore, [ "currentBufferPath", + "currentBufferName", "showLanguageSelector", "showBufferSelector", "showCreateBuffer", diff --git a/src/editor/block/block.js b/src/editor/block/block.js index 0dfb9f38..cb382969 100644 --- a/src/editor/block/block.js +++ b/src/editor/block/block.js @@ -414,7 +414,7 @@ export function triggerCursorChange({state, dispatch}) { } const emitCursorChange = (editor) => { - const notesStore = useHeynoteStore() + const heynoteStore = useHeynoteStore() return ViewPlugin.fromClass( class { update(update) { @@ -430,11 +430,11 @@ const emitCursorChange = (editor) => { const block = getActiveNoteBlock(update.state) if (block && cursorLine) { - notesStore.currentCursorLine = cursorLine - notesStore.currentSelectionSize = selectionSize - notesStore.currentLanguage = block.language.name - notesStore.currentLanguageAuto = block.language.auto - notesStore.currentBufferName = editor.name + heynoteStore.currentCursorLine = cursorLine + heynoteStore.currentSelectionSize = selectionSize + heynoteStore.currentLanguage = block.language.name + heynoteStore.currentLanguageAuto = block.language.auto + heynoteStore.currentBufferName = editor.name } } } diff --git a/webapp/bridge.js b/webapp/bridge.js index 48bf02e0..21866c57 100644 --- a/webapp/bridge.js +++ b/webapp/bridge.js @@ -260,6 +260,10 @@ const Heynote = { async getInitErrors() { }, + + setWindowTitle(title) { + document.title = title + " - Heynote" + }, } export { Heynote, ipcRenderer}