Add keyboard shortcuts: Ctrl+E to edit, Ctrl+S to save, Ctrl+D to discard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -656,6 +656,15 @@ function render_entry_detail(container) {
|
||||
const et = state.entry_types.find(t => t.id === entry.type);
|
||||
const back_hash = 'type/' + entry.type;
|
||||
|
||||
const on_keydown = e => {
|
||||
if (e.ctrlKey && e.key === 'e') { e.preventDefault(); navigate('edit/' + entry.id); }
|
||||
};
|
||||
document.addEventListener('keydown', on_keydown);
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!container.isConnected) { document.removeEventListener('keydown', on_keydown); observer.disconnect(); }
|
||||
});
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
|
||||
// Header
|
||||
const header = document.createElement('div');
|
||||
header.className = 'detail-header';
|
||||
@@ -853,6 +862,7 @@ function render_edit_view(container) {
|
||||
...historyKeymap,
|
||||
indentWithTab,
|
||||
{ key: 'Ctrl-s', mac: 'Cmd-s', run: () => { save_btn.click(); return true; } },
|
||||
{ key: 'Ctrl-d', run: () => { cancel_btn.click(); return true; } },
|
||||
]),
|
||||
EditorView.lineWrapping,
|
||||
placeholder('Body (markdown)'),
|
||||
@@ -901,6 +911,7 @@ function render_edit_view(container) {
|
||||
// Ctrl+S on title input
|
||||
title_input.addEventListener('keydown', e => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 's') { e.preventDefault(); save_btn.click(); }
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'd') { e.preventDefault(); cancel_btn.click(); }
|
||||
});
|
||||
|
||||
// --- Sidebar ---
|
||||
|
||||
Reference in New Issue
Block a user