mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
v1.2.9: mermaid diagrams, math editor, external viewer, manual notebook sort, heading hotkeys
This commit is contained in:
@@ -278,6 +278,17 @@ export async function copyFileTo(
|
||||
return invoke("copy_file_to", { source, destination });
|
||||
}
|
||||
|
||||
export async function writeBytesTo(
|
||||
destination: string,
|
||||
data: Uint8Array,
|
||||
): Promise<void> {
|
||||
return invoke("write_bytes_to", { destination, data: Array.from(data) });
|
||||
}
|
||||
|
||||
export async function copyPngToClipboard(data: Uint8Array): Promise<void> {
|
||||
return invoke("copy_png_to_clipboard", { data: Array.from(data) });
|
||||
}
|
||||
|
||||
// ── Backup ──
|
||||
|
||||
export async function createBackup(): Promise<void> {
|
||||
|
||||
@@ -37,12 +37,16 @@
|
||||
activeTag,
|
||||
updateAvailable as globalUpdateAvailable,
|
||||
settingsTab,
|
||||
navHistory
|
||||
navHistory,
|
||||
viewerNote,
|
||||
notebookSortMode,
|
||||
notebookOrder
|
||||
} from '$lib/stores/app';
|
||||
|
||||
const appWindow = getCurrentWindow();
|
||||
const isMac = navigator.platform.startsWith('Mac');
|
||||
const isMobile = /android|ios/i.test(navigator.userAgent);
|
||||
const isAndroid = /android/i.test(navigator.userAgent);
|
||||
import { loadVaultState, saveVaultState, readNote, createDailyNote, createBackup, getPendingOpenFile, addQuickAccess, removeQuickAccess, getQuickAccess, setTheme } from '$lib/api';
|
||||
import { debounce } from '$lib/utils/debounce';
|
||||
import { openNoteWindow } from '$lib/utils/window';
|
||||
@@ -110,10 +114,32 @@
|
||||
if (!filePath || !filePath.endsWith('.md')) return;
|
||||
const config = get(appConfig);
|
||||
const vaultRoot = config?.active_vault;
|
||||
if (!vaultRoot || !filePath.startsWith(vaultRoot)) return;
|
||||
const isExternal = !vaultRoot || !filePath.startsWith(vaultRoot + '/');
|
||||
|
||||
// External .md → viewer mode (skipped on Android)
|
||||
if (isExternal) {
|
||||
if (isAndroid) return;
|
||||
try {
|
||||
const content = await readNote(filePath);
|
||||
editor?.flushSave();
|
||||
$viewerNote = { path: filePath, content: content.content };
|
||||
$activeNote = content;
|
||||
$activeNotePath = filePath;
|
||||
$editorDirty = false;
|
||||
$readOnly = true;
|
||||
$focusMode = true;
|
||||
editor?.loadNote(filePath, content.content);
|
||||
} catch (e) {
|
||||
console.error('Failed to open external file:', e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Vault file: normal flow
|
||||
try {
|
||||
const content = await readNote(filePath);
|
||||
editor?.flushSave();
|
||||
$viewerNote = null;
|
||||
$activeNote = content;
|
||||
$activeNotePath = filePath;
|
||||
$editorDirty = false;
|
||||
@@ -129,7 +155,9 @@
|
||||
sidebar_width: $sidebarWidth,
|
||||
notelist_width: $notelistWidth,
|
||||
sidebar_collapsed: $sidebarCollapsed,
|
||||
collapsed_notebooks: $collapsedNotebooks
|
||||
collapsed_notebooks: $collapsedNotebooks,
|
||||
notebook_sort_mode: $notebookSortMode,
|
||||
notebook_order: $notebookOrder
|
||||
};
|
||||
try {
|
||||
await saveVaultState(state);
|
||||
@@ -147,6 +175,8 @@
|
||||
}
|
||||
|
||||
function handleNoteSelected(path: string, content: string) {
|
||||
// Selecting a real vault note exits viewer mode
|
||||
$viewerNote = null;
|
||||
editor?.loadNote(path, content);
|
||||
if (isMobile) $mobileView = 'editor';
|
||||
}
|
||||
@@ -197,14 +227,13 @@
|
||||
}
|
||||
const targetDepth = view === 'sidebar' ? 0 : view === 'notelist' ? 1 : 2;
|
||||
if (targetDepth > historyDepth) {
|
||||
// Forward navigation — push entries for each level skipped
|
||||
// Forward navigation - push entries for each level skipped
|
||||
for (let d = historyDepth + 1; d <= targetDepth; d++) {
|
||||
const v = d === 1 ? 'notelist' : 'editor';
|
||||
history.pushState({ mobileView: v, depth: d }, '');
|
||||
}
|
||||
historyDepth = targetDepth;
|
||||
} else if (targetDepth < historyDepth) {
|
||||
// Programmatic back (e.g. mobileBack button) — go back in history
|
||||
const steps = historyDepth - targetDepth;
|
||||
historyDepth = targetDepth;
|
||||
navFromPopstate = true; // suppress the popstate that history.go triggers
|
||||
@@ -313,6 +342,7 @@
|
||||
}
|
||||
if (mod && e.shiftKey && code === 'KeyR') {
|
||||
e.preventDefault();
|
||||
if ($viewerNote) return; // viewer mode is always read-only
|
||||
$readOnly = !$readOnly;
|
||||
return;
|
||||
}
|
||||
@@ -352,6 +382,12 @@
|
||||
persistState();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
$notebookSortMode;
|
||||
$notebookOrder;
|
||||
persistState();
|
||||
});
|
||||
|
||||
onMount(async () => {
|
||||
let lastNotePath: string | null = null;
|
||||
try {
|
||||
@@ -360,6 +396,8 @@
|
||||
$notelistWidth = state.notelist_width;
|
||||
$sidebarCollapsed = state.sidebar_collapsed;
|
||||
$collapsedNotebooks = state.collapsed_notebooks ?? [];
|
||||
$notebookSortMode = state.notebook_sort_mode === 'manual' ? 'manual' : 'alphabetical';
|
||||
$notebookOrder = state.notebook_order ?? {};
|
||||
lastNotePath = state.last_open_note ?? null;
|
||||
} catch (_) {}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,7 @@
|
||||
let canvasW = 0;
|
||||
let canvasH = 0;
|
||||
|
||||
// Style cache — cleared on theme change
|
||||
// Style cache - cleared on theme change
|
||||
let cachedStyles: { border: string; text: string; textSec: string; accent: string; bg: string } | null = null;
|
||||
|
||||
const FOLDER_PALETTE = [
|
||||
@@ -231,14 +231,14 @@
|
||||
}
|
||||
|
||||
function startSimulation() {
|
||||
// Initial settle — enough for a rough layout, camera set after full physics
|
||||
// Initial settle - enough for a rough layout, camera set after full physics
|
||||
for (let i = 0; i < 80; i++) simulate();
|
||||
|
||||
// Show the full graph while physics finishes settling
|
||||
fitToView();
|
||||
draw();
|
||||
|
||||
// Queue remaining physics — camera will snap to active note when done
|
||||
// Queue remaining physics - camera will snap to active note when done
|
||||
physicsRemaining = Math.min(400, Math.max(150, nodes.length * 3));
|
||||
startAnimLoop();
|
||||
}
|
||||
@@ -262,7 +262,7 @@
|
||||
needsDraw = true;
|
||||
}
|
||||
|
||||
// Glow pulse for active node — throttled to ~30fps
|
||||
// Glow pulse for active node - throttled to ~30fps
|
||||
if (activeNodeIdx >= 0) {
|
||||
const elapsed = lastGlowTs > 0 ? Math.min(ts - lastGlowTs, 100) : 16.67;
|
||||
if (lastGlowTs === 0 || ts - lastGlowTs >= 33) {
|
||||
@@ -315,7 +315,7 @@
|
||||
a.vx += fx; a.vy += fy; b.vx -= fx; b.vy -= fy;
|
||||
}
|
||||
|
||||
// Center gravity — weaker for isolated nodes so they spread instead of clustering
|
||||
// Center gravity - weaker for isolated nodes so they spread instead of clustering
|
||||
for (let i = 0; i < nodeCount; i++) {
|
||||
const node = nodes[i];
|
||||
const gravity = (nodeDegree[i] || 0) === 0 ? 0.0002 : 0.0008;
|
||||
@@ -418,7 +418,6 @@
|
||||
ctx.lineTo(nodes[edges[i].targetIdx].x, nodes[edges[i].targetIdx].y);
|
||||
}
|
||||
ctx.stroke();
|
||||
// Edges connected to search matches — brighter
|
||||
ctx.globalAlpha = 0.4;
|
||||
ctx.beginPath();
|
||||
for (let i = 0; i < edges.length; i++) {
|
||||
@@ -497,7 +496,7 @@
|
||||
|
||||
const radius = getNodeRadius(i, isActive);
|
||||
|
||||
// Active glow ring — opacity pulse, no radius change
|
||||
// Active glow ring - opacity pulse, no radius change
|
||||
if (isActive) {
|
||||
const glowR = radius + 12;
|
||||
const glow = ctx.createRadialGradient(node.x, node.y, radius, node.x, node.y, glowR);
|
||||
@@ -524,7 +523,7 @@
|
||||
}
|
||||
ctx.fill();
|
||||
|
||||
// Active outer ring — static, alpha pulse only
|
||||
// Active outer ring - static, alpha pulse only
|
||||
if (isActive) {
|
||||
ctx.globalAlpha = 0.35 + pulse * 0.3;
|
||||
ctx.beginPath();
|
||||
@@ -554,7 +553,7 @@
|
||||
labelQueue.push({ x: node.x, y: node.y - radius - 5, text, fontSize, weight, color, alpha, priority });
|
||||
}
|
||||
|
||||
// Draw labels with collision avoidance — high-priority labels drawn first
|
||||
// Draw labels with collision avoidance - high-priority labels drawn first
|
||||
labelQueue.sort((a, b) => a.priority - b.priority);
|
||||
const drawnRects: LabelRect[] = [];
|
||||
ctx.textAlign = 'center';
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
} from '$lib/api';
|
||||
import { formatRelativeTime } from '$lib/utils/time';
|
||||
import { openNoteWindow } from '$lib/utils/window';
|
||||
import { revealItemInDir } from '@tauri-apps/plugin-opener';
|
||||
import type { NoteEntry, TrashNotebookEntry, SortMode } from '$lib/types';
|
||||
|
||||
let { onNoteSelected = (_path: string, _content: string) => {}, onNoteMoved = () => {}, onBeforeNoteSwitch = () => {}, onNoteCreated = () => {} }: {
|
||||
@@ -714,7 +715,7 @@
|
||||
return;
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
// Range select — use lastClickedPath or active note as anchor
|
||||
// Range select - use lastClickedPath or active note as anchor
|
||||
const anchor = lastClickedPath || $activeNotePath;
|
||||
if (!anchor) { selectNote(note); return; }
|
||||
const paths = $sortedNotes.map(n => n.path);
|
||||
@@ -731,7 +732,6 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Normal click — clear selection, open note
|
||||
clearSelection();
|
||||
selectNote(note);
|
||||
}
|
||||
@@ -1311,6 +1311,14 @@
|
||||
</svg>
|
||||
Open in New Window
|
||||
</button>
|
||||
{#if !isMobile}
|
||||
<button onclick={async () => { const n = contextMenu!.note; contextMenu = null; try { await revealItemInDir(n.path); } catch (e) { console.error('Failed to reveal in file manager:', e); } }}>
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
|
||||
</svg>
|
||||
Show in File Manager
|
||||
</button>
|
||||
{/if}
|
||||
<button onclick={() => startRename(contextMenu!.note)}>
|
||||
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M17 3a2.85 2.85 0 114 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { showSettings, theme, appConfig, updateAvailable as globalUpdateAvailable, updateObj as globalUpdateObj, installType, settingsTab, vaultReady, androidApkUrl, checkForUpdateMobile } from '$lib/stores/app';
|
||||
import { showSettings, theme, appConfig, updateAvailable as globalUpdateAvailable, updateObj as globalUpdateObj, installType, settingsTab, vaultReady, androidApkUrl, checkForUpdateMobile, notebookSortMode } from '$lib/stores/app';
|
||||
import { setTheme, setAccentColor, setFontSize, setFontFamily, setLineHeight, setGeneralSettings, importObsidian, createBackup, listBackups, restoreBackup, deleteBackup, setBackupSettings, setAiSettings, testAiConnection } from '$lib/api';
|
||||
import { open as openDialog } from '@tauri-apps/plugin-dialog';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
@@ -599,6 +599,20 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Notebooks</h3>
|
||||
<label class="setting-toggle">
|
||||
<span class="setting-label">
|
||||
<span class="setting-name">Sort order</span>
|
||||
<span class="setting-desc">Alphabetical (default) or manual. Drag notebooks above/below each other to reorder.</span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="setting-options" style="margin-top: 8px;">
|
||||
<button class="option-btn" class:active={$notebookSortMode === 'alphabetical'} onclick={() => { $notebookSortMode = 'alphabetical'; }}>Alphabetical</button>
|
||||
<button class="option-btn" class:active={$notebookSortMode === 'manual'} onclick={() => { $notebookSortMode = 'manual'; }}>Manual</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section">
|
||||
<h3>Time Format</h3>
|
||||
<div class="setting-options">
|
||||
@@ -717,6 +731,7 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
{#if !isMobile}
|
||||
<div class="settings-section">
|
||||
<h3>PDF Preview</h3>
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
appConfig,
|
||||
quickAccessPaths,
|
||||
collapsedNotebooks,
|
||||
rootNoteCount
|
||||
rootNoteCount,
|
||||
notebookSortMode,
|
||||
notebookOrder
|
||||
} from '$lib/stores/app';
|
||||
import { getNotebooks, getAllTags, createNotebook, deleteNotebook, renameNotebook, moveNotebook, getNotebookIcons, setNotebookIcon, saveAttachment, getQuickAccess, addQuickAccess, removeQuickAccess, emptyTrash, moveNote, readNote, getNotes, countRootNotes } from '$lib/api';
|
||||
import { open as openDialog } from '@tauri-apps/plugin-dialog';
|
||||
@@ -36,7 +38,23 @@
|
||||
let newNotebookName = $state('');
|
||||
let showNewNotebook = $state(false);
|
||||
let dropTargetPath = $state<string | null>(null);
|
||||
let dropPosition = $state<'above' | 'into' | 'below' | null>(null);
|
||||
let draggedNotebookPath = $state<string | null>(null);
|
||||
|
||||
// Apply manual ordering recursively when in 'manual' sort mode.
|
||||
// In 'alphabetical' mode the Rust scanner already sorts, so we pass through unchanged.
|
||||
function sortNotebooksTree(tree: NotebookEntry[]): NotebookEntry[] {
|
||||
if ($notebookSortMode !== 'manual') return tree;
|
||||
const order = $notebookOrder;
|
||||
const sorted = [...tree].sort((a, b) => {
|
||||
const oa = order[a.path] ?? Number.MAX_SAFE_INTEGER;
|
||||
const ob = order[b.path] ?? Number.MAX_SAFE_INTEGER;
|
||||
if (oa !== ob) return oa - ob;
|
||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||
});
|
||||
return sorted.map(nb => ({ ...nb, children: sortNotebooksTree(nb.children) }));
|
||||
}
|
||||
let sortedNotebooks = $derived(sortNotebooksTree($notebooks));
|
||||
let contextMenu = $state<{ x: number; y: number; notebook: NotebookEntry } | null>(null);
|
||||
let trashContextMenu = $state<{ x: number; y: number } | null>(null);
|
||||
let tagsCollapsed = $state(true);
|
||||
@@ -265,6 +283,94 @@
|
||||
}
|
||||
}
|
||||
|
||||
function findSiblingsOfPath(tree: NotebookEntry[], parentPath: string, vaultRoot: string): NotebookEntry[] {
|
||||
if (parentPath === vaultRoot) return tree;
|
||||
for (const nb of tree) {
|
||||
if (nb.path === parentPath) return nb.children;
|
||||
if (nb.children.length > 0) {
|
||||
const found = findSiblingsOfPath(nb.children, parentPath, vaultRoot);
|
||||
if (found.length > 0) return found;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
async function handleNotebookReorder(srcPath: string, targetPath: string, position: 'above' | 'below') {
|
||||
dropTargetPath = null;
|
||||
dropPosition = null;
|
||||
draggedNotebookPath = null;
|
||||
if (srcPath === targetPath) return;
|
||||
if (targetPath.startsWith(srcPath + '/')) return; // can't move into descendant
|
||||
const vaultRoot = $appConfig?.active_vault;
|
||||
if (!vaultRoot) return;
|
||||
|
||||
const srcParent = srcPath.substring(0, srcPath.lastIndexOf('/'));
|
||||
const targetParent = targetPath.substring(0, targetPath.lastIndexOf('/'));
|
||||
let actualSrcPath = srcPath;
|
||||
|
||||
try {
|
||||
// Step 1: if different parents, move src into target's parent first
|
||||
if (srcParent !== targetParent) {
|
||||
const oldName = srcPath.split('/').pop() || '';
|
||||
const newPath = targetParent === vaultRoot
|
||||
? vaultRoot + '/' + oldName
|
||||
: targetParent + '/' + oldName;
|
||||
await moveNotebook(srcPath, targetParent);
|
||||
// Migrate paths in collapsedNotebooks
|
||||
$collapsedNotebooks = $collapsedNotebooks.map(p => {
|
||||
if (p === srcPath) return newPath;
|
||||
if (p.startsWith(srcPath + '/')) return newPath + p.slice(srcPath.length);
|
||||
return p;
|
||||
});
|
||||
// Migrate paths in notebookOrder
|
||||
const migrated: Record<string, number> = {};
|
||||
for (const [p, v] of Object.entries($notebookOrder)) {
|
||||
if (p === srcPath) migrated[newPath] = v;
|
||||
else if (p.startsWith(srcPath + '/')) migrated[newPath + p.slice(srcPath.length)] = v;
|
||||
else migrated[p] = v;
|
||||
}
|
||||
$notebookOrder = migrated;
|
||||
// Update active notebook/note
|
||||
if ($activeNotebook?.path === srcPath || $activeNotebook?.path.startsWith(srcPath + '/')) {
|
||||
selectAllNotes();
|
||||
}
|
||||
if ($activeNotePath && $activeNotePath.startsWith(srcPath + '/')) {
|
||||
const newNotePath = newPath + $activeNotePath.slice(srcPath.length);
|
||||
$activeNotePath = newNotePath;
|
||||
$activeNote = await readNote(newNotePath);
|
||||
}
|
||||
$notebookIcons = await getNotebookIcons();
|
||||
await refresh();
|
||||
actualSrcPath = newPath;
|
||||
}
|
||||
|
||||
// Step 2: reorder within target's parent
|
||||
const siblings = findSiblingsOfPath($notebooks, targetParent, vaultRoot);
|
||||
const sortedSiblings = sortNotebooksTree(siblings);
|
||||
const without = sortedSiblings.filter(s => s.path !== actualSrcPath);
|
||||
const targetIdx = without.findIndex(s => s.path === targetPath);
|
||||
if (targetIdx === -1) return;
|
||||
const insertIdx = position === 'above' ? targetIdx : targetIdx + 1;
|
||||
const newSequence = [
|
||||
...without.slice(0, insertIdx).map(s => s.path),
|
||||
actualSrcPath,
|
||||
...without.slice(insertIdx).map(s => s.path),
|
||||
];
|
||||
|
||||
// Assign sequential positions to all siblings (only within this parent)
|
||||
const newOrder = { ...$notebookOrder };
|
||||
newSequence.forEach((path, idx) => {
|
||||
newOrder[path] = idx;
|
||||
});
|
||||
$notebookOrder = newOrder;
|
||||
|
||||
// Auto-enable manual mode (the act of reordering implies user wants this)
|
||||
if ($notebookSortMode !== 'manual') $notebookSortMode = 'manual';
|
||||
} catch (e) {
|
||||
console.error('Failed to reorder notebook:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function startRename(nb: NotebookEntry) {
|
||||
contextMenu = null;
|
||||
editingNotebook = nb.path;
|
||||
@@ -499,7 +605,7 @@
|
||||
<span class="notebook-name">Unfiled Notes <span class="notebook-count">{$rootNoteCount}</span></span>
|
||||
</button>
|
||||
{/if}
|
||||
{#each $notebooks as nb (nb.path)}
|
||||
{#each sortedNotebooks as nb (nb.path)}
|
||||
{@render notebookItem(nb, 0)}
|
||||
{/each}
|
||||
</div>
|
||||
@@ -649,13 +755,15 @@
|
||||
<button
|
||||
class="notebook-item"
|
||||
class:active={$viewMode === 'notebook' && $activeNotebook?.path === nb.path}
|
||||
class:drop-target={dropTargetPath === nb.path}
|
||||
class:drop-target={dropTargetPath === nb.path && dropPosition === 'into'}
|
||||
class:drop-above={dropTargetPath === nb.path && dropPosition === 'above'}
|
||||
class:drop-below={dropTargetPath === nb.path && dropPosition === 'below'}
|
||||
style="padding-left: {8 + depth * 16}px"
|
||||
draggable="true"
|
||||
onclick={() => selectNotebook(nb)}
|
||||
oncontextmenu={(e) => onContextMenu(e, nb)}
|
||||
ondragstart={(e) => { draggedNotebookPath = nb.path; e.dataTransfer!.setData('text/plain', nb.path); e.dataTransfer!.effectAllowed = 'move'; }}
|
||||
ondragend={() => { draggedNotebookPath = null; }}
|
||||
ondragend={() => { draggedNotebookPath = null; dropPosition = null; }}
|
||||
ondragover={(e) => {
|
||||
e.preventDefault();
|
||||
if (draggedNotebookPath) {
|
||||
@@ -664,17 +772,33 @@
|
||||
e.dataTransfer!.dropEffect = 'none';
|
||||
return;
|
||||
}
|
||||
// Prevent no-op (already in this parent)
|
||||
}
|
||||
// Decide drop position from cursor Y within the row: top 30% = above, bottom 30% = below, middle = into
|
||||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
||||
const relY = (e.clientY - rect.top) / rect.height;
|
||||
let pos: 'above' | 'into' | 'below';
|
||||
if (draggedNotebookPath && relY < 0.3) pos = 'above';
|
||||
else if (draggedNotebookPath && relY > 0.7) pos = 'below';
|
||||
else pos = 'into';
|
||||
// For 'into', reject if already in that parent (no-op)
|
||||
if (pos === 'into' && draggedNotebookPath) {
|
||||
const parentDir = draggedNotebookPath.substring(0, draggedNotebookPath.lastIndexOf('/'));
|
||||
if (parentDir === nb.path) { e.dataTransfer!.dropEffect = 'none'; return; }
|
||||
}
|
||||
e.dataTransfer!.dropEffect = 'move';
|
||||
dropTargetPath = nb.path;
|
||||
dropPosition = pos;
|
||||
}}
|
||||
ondragleave={() => { if (dropTargetPath === nb.path) dropTargetPath = null; }}
|
||||
ondragleave={() => { if (dropTargetPath === nb.path) { dropTargetPath = null; dropPosition = null; } }}
|
||||
ondrop={(e) => {
|
||||
e.preventDefault();
|
||||
const pos = dropPosition;
|
||||
if (draggedNotebookPath) {
|
||||
handleNotebookDrop(e, nb.path);
|
||||
if (pos === 'above' || pos === 'below') {
|
||||
handleNotebookReorder(draggedNotebookPath, nb.path, pos);
|
||||
} else {
|
||||
handleNotebookDrop(e, nb.path);
|
||||
}
|
||||
} else {
|
||||
handleNoteDrop(e, nb);
|
||||
}
|
||||
@@ -909,6 +1033,12 @@
|
||||
outline-offset: -2px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.notebook-item.drop-above {
|
||||
box-shadow: 0 -2px 0 0 var(--accent);
|
||||
}
|
||||
.notebook-item.drop-below {
|
||||
box-shadow: 0 2px 0 0 var(--accent);
|
||||
}
|
||||
|
||||
.chevron {
|
||||
display: flex;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
const target = e.target as HTMLElement;
|
||||
if (target.closest('.titlebar-controls') || target.closest('.titlebar-actions')) return;
|
||||
|
||||
// Don't start dragging near window edges — let Tauri handle resize
|
||||
// Don't start dragging near window edges - let Tauri handle resize
|
||||
if (!maximized) {
|
||||
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
||||
if (e.clientY - rect.top < RESIZE_EDGE || e.clientX - rect.left < RESIZE_EDGE) return;
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
const now = Date.now();
|
||||
if (now - lastMouseDown < 300) {
|
||||
// Double-click detected — maximize/restore
|
||||
appWindow.toggleMaximize();
|
||||
lastMouseDown = 0;
|
||||
return;
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
<span class="vault-path-hint">{fullPath}</span>
|
||||
</div>
|
||||
{:else}
|
||||
<p class="description">Your notes are stored as standard Markdown (.md) files. Pick any folder — existing .md files will be recognized automatically.</p>
|
||||
<p class="description">Your notes are stored as standard Markdown (.md) files. Pick any folder - existing .md files will be recognized automatically.</p>
|
||||
{/if}
|
||||
|
||||
{#if error}
|
||||
|
||||
+21
-1
@@ -29,6 +29,13 @@ export const notebookIcons = writable<Record<string, string>>({});
|
||||
export const quickAccessPaths = writable<string[]>([]);
|
||||
export const collapsedNotebooks = writable<string[]>([]);
|
||||
|
||||
// Notebook sort: 'alphabetical' (default) or 'manual' (drag-to-reorder, persisted in notebookOrder).
|
||||
export const notebookSortMode = writable<"alphabetical" | "manual">(
|
||||
"alphabetical",
|
||||
);
|
||||
// Map from notebook absolute path → ordinal position (lower = earlier). Only consulted when notebookSortMode === 'manual'.
|
||||
export const notebookOrder = writable<Record<string, number>>({});
|
||||
|
||||
// Data
|
||||
export const notebooks = writable<NotebookEntry[]>([]);
|
||||
export const rootNoteCount = writable<number>(0);
|
||||
@@ -39,6 +46,13 @@ export const activeNotePath = writable<string | null>(null);
|
||||
export const activeNotebook = writable<NotebookEntry | null>(null);
|
||||
export const activeTag = writable<string | null>(null);
|
||||
|
||||
// External-file viewer mode: set when an .md file outside the active vault is opened.
|
||||
// While set, the editor is forced read-only, autosave is suppressed, and a banner
|
||||
// offering "Import to vault" / "Close" is shown.
|
||||
export const viewerNote = writable<{ path: string; content: string } | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
// Mobile state
|
||||
export const mobileView = writable<"sidebar" | "notelist" | "editor">(
|
||||
"sidebar",
|
||||
@@ -71,7 +85,7 @@ export async function checkForUpdate() {
|
||||
updateObj.set(update);
|
||||
}
|
||||
} catch {
|
||||
// Silent fail — don't disrupt app startup
|
||||
// Silent fail - don't disrupt app startup
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,6 +188,8 @@ export const vaultState = derived(
|
||||
notelistWidth,
|
||||
sidebarCollapsed,
|
||||
collapsedNotebooks,
|
||||
notebookSortMode,
|
||||
notebookOrder,
|
||||
],
|
||||
([
|
||||
$activeNotePath,
|
||||
@@ -181,6 +197,8 @@ export const vaultState = derived(
|
||||
$notelistWidth,
|
||||
$sidebarCollapsed,
|
||||
$collapsedNotebooks,
|
||||
$notebookSortMode,
|
||||
$notebookOrder,
|
||||
]) => {
|
||||
return {
|
||||
last_open_note: $activeNotePath,
|
||||
@@ -188,6 +206,8 @@ export const vaultState = derived(
|
||||
notelist_width: $notelistWidth,
|
||||
sidebar_collapsed: $sidebarCollapsed,
|
||||
collapsed_notebooks: $collapsedNotebooks,
|
||||
notebook_sort_mode: $notebookSortMode,
|
||||
notebook_order: $notebookOrder,
|
||||
} satisfies VaultState;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -86,6 +86,8 @@ export interface VaultState {
|
||||
notelist_width: number;
|
||||
sidebar_collapsed: boolean;
|
||||
collapsed_notebooks: string[];
|
||||
notebook_sort_mode?: string;
|
||||
notebook_order?: Record<string, number>;
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
|
||||
Reference in New Issue
Block a user