(options?: { includeUnavailable?: boolean })
| 54 | } |
| 55 | |
| 56 | export function buildCommands(options?: { includeUnavailable?: boolean }): Command[] { |
| 57 | const getState = (): ReturnType<typeof useStore.getState> => useStore.getState() |
| 58 | const labels = () => resolveSystemFolderLabels(getState().systemFolderLabels) |
| 59 | const pathLabel = (): string => |
| 60 | getState().workspaceMode === 'remote' ? 'Server Path' : 'Absolute Path' |
| 61 | const shortcut = (id: KeymapId): string => getKeymapDisplay(getState().keymapOverrides, id) |
| 62 | const leaderShortcut = (id: KeymapId): string => |
| 63 | `${shortcut('vim.leaderPrefix')} ${shortcut(id)}` |
| 64 | const paneShortcut = (id: KeymapId): string => |
| 65 | `${shortcut('vim.panePrefix')} ${shortcut(id)}` |
| 66 | const searchShortcut = (): string => { |
| 67 | const state = getState() |
| 68 | const primary = shortcut('global.searchNotes') |
| 69 | if (state.vimMode) return primary |
| 70 | return `${primary} / ${shortcut('global.searchNotesNonVim')}` |
| 71 | } |
| 72 | const openExternal = (url: string): void => { |
| 73 | window.open(url, '_blank') |
| 74 | } |
| 75 | const cmds: Command[] = [] |
| 76 | |
| 77 | /* ---------------- Note actions ---------------- */ |
| 78 | cmds.push( |
| 79 | { |
| 80 | id: 'note.new.quick', |
| 81 | title: 'New Quick Note', |
| 82 | category: 'Note', |
| 83 | shortcut: shortcut('global.newQuickNote'), |
| 84 | keywords: 'scratch capture jot', |
| 85 | run: () => { |
| 86 | const s = getState() |
| 87 | const title = resolveQuickNoteTitle( |
| 88 | s.notes, |
| 89 | s.quickNoteDateTitle, |
| 90 | s.quickNoteTitlePrefix ?? undefined |
| 91 | ) |
| 92 | return s.createAndOpen('quick', '', { title, focusTitle: true }) |
| 93 | } |
| 94 | }, |
| 95 | { |
| 96 | id: 'note.new.inbox', |
| 97 | title: |
| 98 | getState().vaultSettings.primaryNotesLocation === 'root' |
| 99 | ? 'New Note in Vault Root' |
| 100 | : `New Note in ${labels().inbox}`, |
| 101 | category: 'Note', |
| 102 | keywords: 'create add write', |
| 103 | run: () => getState().createAndOpen('inbox', '', { focusTitle: true }) |
| 104 | }, |
| 105 | { |
| 106 | id: 'database.new', |
| 107 | title: 'New Database', |
| 108 | category: 'Note', |
| 109 | keywords: 'database table csv records spreadsheet board kanban base', |
| 110 | run: () => getState().createDatabase('inbox', '') |
| 111 | }, |
| 112 | { |
| 113 | id: 'note.daily.today', |
no test coverage detected