Files
orca/src/shared/rich-markdown-context-menu.ts
T
6942871194 feat(editor): add Markdown table structure controls (#11985)
* feat(editor): add markdown table structure controls

* fix(editor): scope table context actions to cells

* Replace table toolbar with context-aware overlay controls

Replace the fixed table toolbar with context-sensitive overlay controls that position themselves around the active table, adding support for direct row/column insertion and full table deletion. This approach is less intrusive and supports click-targeted actions via coordinate-based cell resolution. Enhance structural safety by preventing header removal and ensuring tables never collapse below a single cell, deleting instead when the final row or column is removed. Harden the context-menu query with a 120ms timeout to keep the native menu responsive even if the renderer hangs.

* Replace markdown table context query with IPC coordination

Capture table cell targets on pointerdown and report via IPC channel
instead of executing JavaScript on context-menu events. Eliminates
120ms query timeout and unavailability race conditions. Header cells
now disable incompatible row-level actions.

* fix(editor): make table column rebalancing atomic with insertion

- Refactor rebalanceAddedColumn to mutate the caller's transaction, grouping
  insertion and rebalance into a single undo step
- Add validation for cached cell positions that may outlive the document
- Fix table detection to use isInTable() instead of isActive('table')
- Correct z-index layering to respect menu stacking context
- Fix cleanup of stale animation frames and pending pointer state

---------

Co-authored-by: rainL <WYK15@users.noreply.github.com>
Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
2026-08-05 11:10:05 -07:00

44 lines
921 B
TypeScript

export type RichMarkdownContextMenuCommand =
| 'add-link'
| 'bold'
| 'italic'
| 'strike'
| 'inline-code'
| 'code-block'
| 'blockquote'
| 'paragraph'
| 'heading-1'
| 'heading-2'
| 'heading-3'
| 'heading-4'
| 'heading-5'
| 'bullet-list'
| 'ordered-list'
| 'task-list'
| 'image'
| 'divider'
| 'insert-row-above'
| 'insert-row-below'
| 'delete-row'
| 'insert-column-left'
| 'insert-column-right'
| 'delete-column'
| 'delete-table'
export type RichMarkdownContextMenuCommandPayload = {
command: RichMarkdownContextMenuCommand
tableTargetId?: string
x: number
y: number
}
export type RichMarkdownContextMenuTableTarget = {
cellType: 'body' | 'header'
targetId: string
x: number
y: number
}
export const richMarkdownContextMenuCommandChannel = 'rich-markdown:context-command'
export const richMarkdownContextMenuTargetChannel = 'rich-markdown:context-target'