Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app-core/src/components/EditorPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import type { PaneEdge, PaneLeaf } from '../lib/pane-layout'
import { findLeaf, inferPaneDropEdge } from '../lib/pane-layout'
import { livePreviewPlugin } from '../lib/cm-live-preview'
import { codeBlockFlairPlugin } from '../lib/cm-code-block-flair'
import { tablePlugin, tableVimEntry } from '../lib/cm-table'
import { tablePlugin, tableVimEntry, tableSelectionHighlight } from '../lib/cm-table'
import { wysiwygBlocksPlugin } from '../lib/cm-wysiwyg-blocks'
import { hashtagExtension } from '../lib/cm-hashtags'
import { taskMetadataExtension } from '../lib/cm-task-metadata'
Expand Down Expand Up @@ -415,7 +415,7 @@ function wysiwygExtensions(
codeBlockFlairPlugin,
// Table widgets are gated on a setting — off keeps tables as plain editable
// markdown for full keyboard/Vim editing (#232).
...(renderTables ? [tablePlugin, tableVimEntry] : []),
...(renderTables ? [tablePlugin, tableVimEntry, tableSelectionHighlight] : []),
wysiwygBlocksPlugin,
...hashtagExtension,
...taskMetadataExtension,
Expand Down
9 changes: 9 additions & 0 deletions packages/app-core/src/lib/cm-slash-commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { CompletionContext, CompletionResult, Completion } from '@codemirror/autocomplete'
import type { EditorView } from '@codemirror/view'
import { useStore } from '../store'
import { focusFirstTableCell } from './cm-table'

interface SlashCmd {
label: string
Expand Down Expand Up @@ -232,6 +233,14 @@ export function slashCommandSource(context: CompletionContext): CompletionResult
changes: { from: slashStart, to, insert },
selection: { anchor: cursorPos }
})
// `/table`: once the widget renders, drop into the first header cell
// so the user can rename the columns right away instead of landing on
// the trailing line. The CM caret stays put (#340); this only moves
// DOM focus into the cell. Retries internally until the parse catches
// up and the decoration exists.
if (tableCaretAfter) {
focusFirstTableCell(view, slashStart + leadPad.length)
}
}
} as Completion & { _icon: string })
),
Expand Down
3 changes: 3 additions & 0 deletions packages/app-core/src/lib/cm-table-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,16 @@ export function openTableContextMenu(req: TableMenuRequest): void {
}
}
// Defer so the originating contextmenu/right-click doesn't immediately close it.
let tornDown = false
setTimeout(() => {
if (tornDown) return
window.addEventListener('mousedown', onDown, true)
window.addEventListener('keydown', onKey, true)
applyFilter()
}, 0)

teardown = () => {
tornDown = true
window.removeEventListener('mousedown', onDown, true)
window.removeEventListener('keydown', onKey, true)
menu.remove()
Expand Down
Loading