Skip to content

Commit 58e03f1

Browse files
committed
fix(commands): declare default keybindings so commands show in Keymap
`registerCommandPalette` without a `keybinding` only surfaces in the command palette — Logseq's Settings → Keymap UI lists plugin commands only when a default binding is declared. Add `keybinding` to each of the caret-nav, insert and move command registrations so users can rebind them from Keymap. The defaults mirror the local in-renderer keydown handlers (ctrl+alt for caret nav, ctrl+alt+shift for insert, alt+shift for move).
1 parent ad18260 commit 58e03f1

1 file changed

Lines changed: 35 additions & 27 deletions

File tree

src/index.js

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,70 +126,78 @@ if (isInBrowser) {
126126

127127
logseqEditor.registerSlashCommand('Markdown Table Editor', insertEmptyTableCallback)
128128

129-
// Row caret navigation inside an inline table cell. Registered so
130-
// the commands appear in Logseq's command palette / keymap UI and
131-
// can be assigned a host-level shortcut. The default Ctrl+Enter /
132-
// Ctrl+Shift+Enter behaviour is still driven by a local keydown
133-
// handler in `attachInlineEditing` (the contenteditable cell would
134-
// otherwise eat Enter before Logseq's dispatcher saw it), so any
135-
// shortcut assigned here fires in addition to the built-in keys.
129+
// Row/column caret navigation inside an inline table cell. A
130+
// `keybinding` is required for these to show up in Logseq's Keymap
131+
// UI (commands without one only appear in the command palette).
132+
// Defaults mirror the local keydown handler in `attachInlineEditing`;
133+
// since that local path swallows the keys before Logseq's dispatcher
134+
// sees them, the registered binding is effectively a hint the user
135+
// can rebind from Settings → Keymap.
136136
logseq.App.registerCommandPalette({
137137
key: 'mdtable-move-caret-down',
138-
label: i18n.t('Markdown table: move caret to cell below')
138+
label: i18n.t('Markdown table: move caret to cell below'),
139+
keybinding: { binding: 'ctrl+alt+down' }
139140
}, () => moveCaretInFocusedTableCell('down'))
140141
logseq.App.registerCommandPalette({
141142
key: 'mdtable-move-caret-up',
142-
label: i18n.t('Markdown table: move caret to cell above')
143+
label: i18n.t('Markdown table: move caret to cell above'),
144+
keybinding: { binding: 'ctrl+alt+up' }
143145
}, () => moveCaretInFocusedTableCell('up'))
144146
logseq.App.registerCommandPalette({
145147
key: 'mdtable-move-caret-left',
146-
label: i18n.t('Markdown table: move caret to cell left')
148+
label: i18n.t('Markdown table: move caret to cell left'),
149+
keybinding: { binding: 'ctrl+alt+left' }
147150
}, () => moveCaretInFocusedTableCell('left'))
148151
logseq.App.registerCommandPalette({
149152
key: 'mdtable-move-caret-right',
150-
label: i18n.t('Markdown table: move caret to cell right')
153+
label: i18n.t('Markdown table: move caret to cell right'),
154+
keybinding: { binding: 'ctrl+alt+right' }
151155
}, () => moveCaretInFocusedTableCell('right'))
152156

153-
// Row/column insertion. Default Alt+Ctrl+Shift+Arrow keys are wired up
154-
// by a local handler in `attachInlineEditing` (see Ctrl+Enter
155-
// comment for why the local path is needed); these palette entries
156-
// mirror those actions so they show up in Logseq's keymap UI and
157-
// can be invoked from the command palette.
157+
// Row/column insertion. Defaults match the local Alt+Ctrl+Shift+Arrow
158+
// handler in `attachInlineEditing`.
158159
logseq.App.registerCommandPalette({
159160
key: 'mdtable-insert-row-below',
160-
label: i18n.t('Markdown table: insert row below')
161+
label: i18n.t('Markdown table: insert row below'),
162+
keybinding: { binding: 'ctrl+alt+shift+down' }
161163
}, () => insertInFocusedTableCell('rowBelow'))
162164
logseq.App.registerCommandPalette({
163165
key: 'mdtable-insert-row-above',
164-
label: i18n.t('Markdown table: insert row above')
166+
label: i18n.t('Markdown table: insert row above'),
167+
keybinding: { binding: 'ctrl+alt+shift+up' }
165168
}, () => insertInFocusedTableCell('rowAbove'))
166169
logseq.App.registerCommandPalette({
167170
key: 'mdtable-insert-col-right',
168-
label: i18n.t('Markdown table: insert column right')
171+
label: i18n.t('Markdown table: insert column right'),
172+
keybinding: { binding: 'ctrl+alt+shift+right' }
169173
}, () => insertInFocusedTableCell('colRight'))
170174
logseq.App.registerCommandPalette({
171175
key: 'mdtable-insert-col-left',
172-
label: i18n.t('Markdown table: insert column left')
176+
label: i18n.t('Markdown table: insert column left'),
177+
keybinding: { binding: 'ctrl+alt+shift+left' }
173178
}, () => insertInFocusedTableCell('colLeft'))
174179

175-
// Row/column move. Default Alt+Shift+Arrow keys are wired up by a
176-
// local handler in `attachInlineEditing`; these palette entries
177-
// mirror them for the command palette / keymap UI.
180+
// Row/column move. Defaults match the local Alt+Shift+Arrow handler
181+
// in `attachInlineEditing`.
178182
logseq.App.registerCommandPalette({
179183
key: 'mdtable-move-row-up',
180-
label: i18n.t('Markdown table: move row up')
184+
label: i18n.t('Markdown table: move row up'),
185+
keybinding: { binding: 'alt+shift+up' }
181186
}, () => moveInFocusedTableCell('rowUp'))
182187
logseq.App.registerCommandPalette({
183188
key: 'mdtable-move-row-down',
184-
label: i18n.t('Markdown table: move row down')
189+
label: i18n.t('Markdown table: move row down'),
190+
keybinding: { binding: 'alt+shift+down' }
185191
}, () => moveInFocusedTableCell('rowDown'))
186192
logseq.App.registerCommandPalette({
187193
key: 'mdtable-move-col-left',
188-
label: i18n.t('Markdown table: move column left')
194+
label: i18n.t('Markdown table: move column left'),
195+
keybinding: { binding: 'alt+shift+left' }
189196
}, () => moveInFocusedTableCell('colLeft'))
190197
logseq.App.registerCommandPalette({
191198
key: 'mdtable-move-col-right',
192-
label: i18n.t('Markdown table: move column right')
199+
label: i18n.t('Markdown table: move column right'),
200+
keybinding: { binding: 'alt+shift+right' }
193201
}, () => moveInFocusedTableCell('colRight'))
194202

195203
// Inline block renderer: replace Logseq's native view for markdown-table

0 commit comments

Comments
 (0)