Skip to content

Commit eadfe17

Browse files
committed
feat(menu): show insert-op keybinds as tooltips in the right-click menu
Hovering one of the four "Insert row above/below" or "Insert column left/right" items in the inline-table right-click menu now surfaces the matching default keybind (Alt+Shift+Arrow) as a native title tooltip, so the discoverable shortcut is one hover away from the menu the user is already in. Implemented by adding an optional `shortcut` field to the shared item model and setting `mi.title` from it when the menu is built; items without a shortcut (move/delete/sort) are unaffected. The toolbar surface continues to use the label-as-tooltip behaviour.
1 parent 3781ba4 commit eadfe17

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/utils/inlineEditable.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ const buildItems = (root, opts, cell) => {
398398
const L = opts.menuLabels || {}
399399
const items = [
400400
{ icon: ICONS.insertRowAbove, label: L.insertRowAbove || 'Insert row above', enabled: rowIdx >= 1,
401-
run: m => tableOps.insertRowAbove(m, rowIdx) },
401+
shortcut: 'Alt+Shift+Up', run: m => tableOps.insertRowAbove(m, rowIdx) },
402402
{ icon: ICONS.insertRowBelow, label: L.insertRowBelow || 'Insert row below', enabled: true,
403-
run: m => tableOps.insertRowBelow(m, rowIdx) },
403+
shortcut: 'Alt+Shift+Down', run: m => tableOps.insertRowBelow(m, rowIdx) },
404404
{ icon: ICONS.moveRowUp, label: L.moveRowUp || 'Move row up', enabled: rowIdx >= 2,
405405
run: m => tableOps.moveRowUp(m, rowIdx) },
406406
{ icon: ICONS.moveRowDown, label: L.moveRowDown || 'Move row down', enabled: rowIdx >= 1 && rowIdx < rowCount - 1,
@@ -409,9 +409,9 @@ const buildItems = (root, opts, cell) => {
409409
run: m => tableOps.deleteRow(m, rowIdx) },
410410
{ sep: true },
411411
{ icon: ICONS.insertColLeft, label: L.insertColLeft || 'Insert column left', enabled: true,
412-
run: m => tableOps.insertColLeft(m, rowIdx, colIdx) },
412+
shortcut: 'Alt+Shift+Left', run: m => tableOps.insertColLeft(m, rowIdx, colIdx) },
413413
{ icon: ICONS.insertColRight, label: L.insertColRight || 'Insert column right', enabled: true,
414-
run: m => tableOps.insertColRight(m, rowIdx, colIdx) },
414+
shortcut: 'Alt+Shift+Right', run: m => tableOps.insertColRight(m, rowIdx, colIdx) },
415415
{ icon: ICONS.moveColLeft, label: L.moveColLeft || 'Move column left', enabled: colIdx >= 1,
416416
run: m => tableOps.moveColLeft(m, rowIdx, colIdx) },
417417
{ icon: ICONS.moveColRight, label: L.moveColRight || 'Move column right', enabled: colIdx < colCount - 1,
@@ -592,6 +592,11 @@ const openContextMenu = (root, opts, cell, ev) => {
592592
if (it.sep) { const s = doc.createElement('div'); s.className = 'lsp-mdt-menu-sep'; menu.appendChild(s); return }
593593
const mi = doc.createElement('div')
594594
mi.className = 'lsp-mdt-menu-item' + (it.enabled ? '' : ' disabled')
595+
// Native tooltip surfaces the keybind on hover for items that have
596+
// one. Reflects the hardcoded default in `attachInlineEditing`; an
597+
// extra shortcut the user assigned via Logseq's keymap UI would
598+
// fire too, but isn't shown here.
599+
if (it.shortcut) mi.title = it.shortcut
595600
const ic = doc.createElement('span')
596601
ic.className = 'lsp-mdt-menu-icon'
597602
ic.innerHTML = it.icon || ''

0 commit comments

Comments
 (0)