mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-11-19 10:38:20 +01:00
v1.1.8 - Fix unsaved content lost when switching notes
This commit is contained in:
1 parent
d098066899
commit
0b5db1340c
6 files changed
+35
-4
No files matched your search
+1
-1
@@ -2,7 +2,7 @@
|
||||
"name": "helixnotes",
|
||||
"private": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
||||
Generated
+1
-1
@@ -1750,7 +1750,7 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "helixnotes"
|
||||
version = "1.1.7"
|
||||
version = "1.1.8"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"dirs",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "helixnotes"
|
||||
version = "1.1.7"
|
||||
version = "1.1.8"
|
||||
description = "Local markdown note-taking app"
|
||||
authors = ["HelixNotes"]
|
||||
license = "AGPL-3.0-or-later"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "HelixNotes",
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"identifier": "com.helixnotes.app",
|
||||
"build": {
|
||||
"frontendDist": "../build",
|
||||
|
||||
@@ -1200,6 +1200,21 @@
|
||||
}
|
||||
|
||||
export function loadNote(path: string, content: string) {
|
||||
// Flush any unsaved changes for the CURRENT note before loading the new one
|
||||
if ($editorDirty && $activeNote && $activeNotePath && $activeNotePath !== path) {
|
||||
try {
|
||||
const body = $sourceMode
|
||||
? restoreTitleH1(sourceContent)
|
||||
: editorToMarkdown();
|
||||
const trimmed = body.replace(/^#.*\n?/, '').trim();
|
||||
if (trimmed || !$activeNote.content || $activeNote.content.trim().length <= 10) {
|
||||
saveNote($activeNotePath, $activeNote.meta, body);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Pre-switch save failed:', e);
|
||||
}
|
||||
$editorDirty = false;
|
||||
}
|
||||
loadedPath = path;
|
||||
lastSourceMode = $sourceMode;
|
||||
isLoadingNote = true;
|
||||
@@ -1997,6 +2012,21 @@
|
||||
});
|
||||
|
||||
function destroyEditor() {
|
||||
// Flush unsaved changes before destroying
|
||||
if ($editorDirty && $activeNote && $activeNotePath && editor) {
|
||||
try {
|
||||
const body = $sourceMode
|
||||
? restoreTitleH1(sourceContent)
|
||||
: editorToMarkdown();
|
||||
const trimmed = body.replace(/^#.*\n?/, '').trim();
|
||||
if (trimmed || !$activeNote.content || $activeNote.content.trim().length <= 10) {
|
||||
saveNote($activeNotePath, $activeNote.meta, body);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Destroy-save failed:', e);
|
||||
}
|
||||
$editorDirty = false;
|
||||
}
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
editor = null;
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Go back</span><span class="shortcut-keys"><kbd>Alt</kbd>+<kbd>←</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Go forward</span><span class="shortcut-keys"><kbd>Alt</kbd>+<kbd>→</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Toggle source mode</span><span class="shortcut-keys"><kbd>{modKey}</kbd>+<kbd>Shift</kbd>+<kbd>M</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Open note in new window</span><span class="shortcut-keys"><kbd>{modKey}</kbd>+<kbd>Shift</kbd>+<kbd>W</kbd></span></div>
|
||||
<div class="shortcut-row"><span class="shortcut-desc">Exit focus mode</span><span class="shortcut-keys"><kbd>Esc</kbd></span></div>
|
||||
|
||||
<h4 class="shortcuts-group-title">Editor Commands</h4>
|
||||
|
||||
Reference in new issue
Block a user