v1.0.4 - Quick Access reorder, performance improvements, search fixes

- Quick Access drag-to-reorder: drag notes to rearrange, order persists
- Quick Access preserves order when moving notes between notebooks
- In-note search: debounced input, proper scroll-to-match
- Panel resize: RAF-batched updates, editor containment during resize
- Thinner resize handles (3px)
- Note list: removed transition, added CSS containment for 1200+ notes
- Escape closes Settings and Info panels
- Fix Quick Access cache invalidation on remove
This commit is contained in:
Yuri Karamian committed 2026-02-10 21:14:50 +01:00
1 parent a95e240bcd
commit f688cf4bd4
12 files changed
+193 -51

No files matched your search

+26 -17
View File
@@ -1192,7 +1192,10 @@
}
// ── In-note search functions ──
let noteSearchTimer: ReturnType<typeof setTimeout> | null = null;
function updateNoteSearch(query: string) {
if (noteSearchTimer) clearTimeout(noteSearchTimer);
if (!editor) return;
if (!query) {
noteSearchResults = [];
@@ -1201,20 +1204,23 @@
editor.view.dispatch(tr);
return;
}
const results: {from: number, to: number}[] = [];
const lowerQuery = query.toLowerCase();
editor.state.doc.descendants((node, pos) => {
if (!node.isText || !node.text) return;
const text = node.text.toLowerCase();
let idx = text.indexOf(lowerQuery);
while (idx !== -1) {
results.push({ from: pos + idx, to: pos + idx + query.length });
idx = text.indexOf(lowerQuery, idx + 1);
}
});
noteSearchResults = results;
if (noteSearchIndex >= results.length) noteSearchIndex = 0;
applySearchDecorations();
noteSearchTimer = setTimeout(() => {
if (!editor) return;
const results: {from: number, to: number}[] = [];
const lowerQuery = query.toLowerCase();
editor.state.doc.descendants((node, pos) => {
if (!node.isText || !node.text) return;
const text = node.text.toLowerCase();
let idx = text.indexOf(lowerQuery);
while (idx !== -1) {
results.push({ from: pos + idx, to: pos + idx + query.length });
idx = text.indexOf(lowerQuery, idx + 1);
}
});
noteSearchResults = results;
if (noteSearchIndex >= results.length) noteSearchIndex = 0;
applySearchDecorations();
}, 100);
}
function applySearchDecorations() {
@@ -1230,9 +1236,12 @@
function scrollToCurrentMatch() {
if (!editor || noteSearchResults.length === 0) return;
const match = noteSearchResults[noteSearchIndex];
editor.commands.setTextSelection(match.from);
editor.commands.scrollIntoView();
requestAnimationFrame(() => {
const el = editor?.view.dom.querySelector('.note-search-active');
if (el) {
el.scrollIntoView({ block: 'center', behavior: 'smooth' });
}
});
}
function noteSearchNext() {
+65 -3
View File
@@ -26,6 +26,7 @@
getQuickAccess,
addQuickAccess,
removeQuickAccess,
reorderQuickAccess,
moveNote
} from '$lib/api';
import { formatRelativeTime } from '$lib/utils/time';
@@ -48,6 +49,11 @@
let lastClickedPath = $state<string | null>(null);
let batchMovePicker = $state(false);
// Quick Access drag-to-reorder
let qaDragFrom = $state<number | null>(null);
let qaDragOver = $state<number | null>(null);
let qaDragHalf = $state<'top' | 'bottom'>('bottom');
function clearSelection() {
selectedPaths = new Set();
lastClickedPath = null;
@@ -260,12 +266,33 @@
await removeQuickAccess(note.relative_path);
const qaNotes = await getQuickAccess();
$quickAccessPaths = qaNotes.map(n => n.relative_path);
if ($viewMode === 'quickaccess') await refresh();
if ($viewMode === 'quickaccess') await refresh(true);
} catch (e) {
console.error('Failed to remove from quick access:', e);
}
}
async function handleQaDrop(targetIndex: number) {
if (qaDragFrom === null) { qaDragFrom = null; qaDragOver = null; return; }
// Compute the actual insert position based on which half we're hovering
let insertAt = qaDragHalf === 'bottom' ? targetIndex + 1 : targetIndex;
if (qaDragFrom === insertAt || qaDragFrom + 1 === insertAt) {
qaDragFrom = null; qaDragOver = null; return;
}
const arr = [...$sortedNotes];
const [moved] = arr.splice(qaDragFrom, 1);
if (insertAt > qaDragFrom) insertAt--;
arr.splice(insertAt, 0, moved);
$notes = arr;
qaDragFrom = null;
qaDragOver = null;
try {
await reorderQuickAccess(arr.map(n => n.relative_path));
} catch (e) {
console.error('Failed to reorder quick access:', e);
}
}
async function handleMoveNote(note: NoteEntry, destPath: string) {
contextMenu = null;
movePickerNote = null;
@@ -491,7 +518,7 @@
</div>
{/if}
{#each $sortedNotes as note (note.path)}
{#each $sortedNotes as note, noteIndex (note.path)}
{#if editingNote === note.path}
<div class="note-item active">
<input
@@ -512,6 +539,8 @@
class:selected={selectedPaths.has(note.path)}
class:pinned={note.meta.pinned}
class:compact={compact}
class:qa-drag-above={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'top'}
class:qa-drag-below={$viewMode === 'quickaccess' && qaDragOver === noteIndex && qaDragFrom !== null && qaDragHalf === 'bottom'}
onclick={(e) => handleNoteClick(e, note)}
oncontextmenu={(e) => {
e.preventDefault();
@@ -528,6 +557,12 @@
}}
draggable="true"
ondragstart={(e) => {
if ($viewMode === 'quickaccess') {
qaDragFrom = noteIndex;
e.dataTransfer!.setData('text/plain', note.path);
e.dataTransfer!.effectAllowed = 'move';
return;
}
if (selectedPaths.size > 1 && selectedPaths.has(note.path)) {
e.dataTransfer!.setData('text/plain', [...selectedPaths].join('\n'));
} else {
@@ -535,6 +570,25 @@
}
e.dataTransfer!.effectAllowed = 'move';
}}
ondragover={(e) => {
if ($viewMode === 'quickaccess' && qaDragFrom !== null) {
e.preventDefault();
e.dataTransfer!.dropEffect = 'move';
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect();
qaDragHalf = e.clientY < rect.top + rect.height / 2 ? 'top' : 'bottom';
qaDragOver = noteIndex;
}
}}
ondragleave={() => {
if (qaDragOver === noteIndex) qaDragOver = null;
}}
ondrop={(e) => {
if ($viewMode === 'quickaccess' && qaDragFrom !== null) {
e.preventDefault();
handleQaDrop(noteIndex);
}
}}
ondragend={() => { qaDragFrom = null; qaDragOver = null; }}
>
{#if compact}
<div class="note-compact-row">
@@ -761,8 +815,8 @@
border-radius: 6px;
cursor: pointer;
text-align: left;
transition: background 0.1s;
margin-bottom: 1px;
contain: content;
}
.note-item:hover {
@@ -1133,4 +1187,12 @@
color: var(--accent);
font-size: 14px;
}
.note-item.qa-drag-above {
border-top: 2px solid var(--accent);
}
.note-item.qa-drag-below {
border-bottom: 2px solid var(--accent);
}
</style>
+14 -2
View File
@@ -2,23 +2,35 @@
let { onResize }: { onResize: (delta: number) => void } = $props();
let active = $state(false);
let startX = 0;
let rafId = 0;
let pendingDelta = 0;
function onMouseDown(e: MouseEvent) {
e.preventDefault();
active = true;
startX = e.clientX;
document.body.classList.add('resizing');
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
}
function onMouseMove(e: MouseEvent) {
const delta = e.clientX - startX;
pendingDelta += e.clientX - startX;
startX = e.clientX;
onResize(delta);
if (!rafId) {
rafId = requestAnimationFrame(() => {
onResize(pendingDelta);
pendingDelta = 0;
rafId = 0;
});
}
}
function onMouseUp() {
active = false;
document.body.classList.remove('resizing');
if (rafId) { cancelAnimationFrame(rafId); rafId = 0; }
if (pendingDelta) { onResize(pendingDelta); pendingDelta = 0; }
window.removeEventListener('mousemove', onMouseMove);
window.removeEventListener('mouseup', onMouseUp);
}