keyboard: command palette (Cmd/Ctrl+K)
Fuzzy quick-open overlay: type to jump to any note by title (titles index) or run a command — New note, Go to Board/Graph/Reminders/Archive/Trash, and Open Settings (admins). Arrow keys move the selection, Enter activates, Esc closes; Cmd/Ctrl+K toggles it (works even while typing). Selecting a note navigates to the board with ?open=<id>; BoardView watches that query and opens the editor (fetching the note if it isn't loaded), then clears the param. Added to the ? cheat-sheet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FRgehjoz7Yv8LkUfADxACm
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useNotesStore, type Note, type NoteView } from "../stores/notes";
|
||||
import { useUiStore } from "../stores/ui";
|
||||
import QuickAdd from "../components/QuickAdd.vue";
|
||||
@@ -10,6 +10,7 @@ import NoteEditor from "../components/NoteEditor.vue";
|
||||
const notes = useNotesStore();
|
||||
const route = useRoute();
|
||||
const ui = useUiStore();
|
||||
const router = useRouter();
|
||||
|
||||
const editing = ref<Note | null>(null);
|
||||
const quickAdd = ref<InstanceType<typeof QuickAdd> | null>(null);
|
||||
@@ -21,6 +22,22 @@ watch(
|
||||
() => quickAdd.value?.open(),
|
||||
);
|
||||
|
||||
// The command palette opens a note by navigating here with ?open=<id>.
|
||||
watch(
|
||||
() => route.query.open,
|
||||
(v) => {
|
||||
if (typeof v === "string" && v) void openFromQuery(v);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
async function openFromQuery(id: string) {
|
||||
const found = notes.items.find((n) => n.id === id) ?? (await notes.fetchOne(id));
|
||||
if (found) editing.value = found;
|
||||
const q = { ...route.query };
|
||||
delete q.open;
|
||||
void router.replace({ query: q });
|
||||
}
|
||||
|
||||
function viewForRoute(name: unknown): NoteView {
|
||||
if (name === "archive") return "archived";
|
||||
if (name === "trash") return "trash";
|
||||
|
||||
Reference in New Issue
Block a user