|
86 | 86 | * @typedef {(ctx: LinkPopoverContext) => LinkPopoverResolution | null | undefined} LinkPopoverResolver |
87 | 87 | */ |
88 | 88 |
|
| 89 | +// --------------------------------------------------------------------------- |
| 90 | +// Context menu types |
| 91 | +// --------------------------------------------------------------------------- |
| 92 | + |
| 93 | +/** |
| 94 | + * Context object passed to context menu callbacks (showWhen, render, action, menuProvider). |
| 95 | + * @typedef {Object} ContextMenuContext |
| 96 | + * @property {Editor} editor The editor instance |
| 97 | + * @property {string} selectedText Currently selected text (empty string if no selection) |
| 98 | + * @property {boolean} hasSelection Whether there is an expanded selection |
| 99 | + * @property {number} selectionStart ProseMirror start position of the selection |
| 100 | + * @property {number} selectionEnd ProseMirror end position of the selection |
| 101 | + * @property {'click' | 'slash'} trigger How the menu was opened |
| 102 | + * @property {boolean} isInTable Whether the cursor is inside a table |
| 103 | + * @property {boolean} isInList Whether the cursor is inside a list |
| 104 | + * @property {boolean} isInSectionNode Whether the cursor is inside a document section |
| 105 | + * @property {boolean} isCellSelection Whether a table cell selection is active |
| 106 | + * @property {string | null} tableSelectionKind Kind of table selection (row, column, etc.) |
| 107 | + * @property {string | null} currentNodeType ProseMirror node type name at the cursor |
| 108 | + * @property {string[]} activeMarks Names of marks active at the cursor |
| 109 | + * @property {boolean} isTrackedChange Whether the cursor is on a tracked change |
| 110 | + * @property {string | null} trackedChangeId ID of the tracked change at the cursor |
| 111 | + * @property {string} documentMode Current document mode (editing, viewing, suggesting) |
| 112 | + * @property {boolean} canUndo Whether undo is available |
| 113 | + * @property {boolean} canRedo Whether redo is available |
| 114 | + * @property {boolean} isEditable Whether the editor is editable |
| 115 | + * @property {{ x: number, y: number } | null} cursorPosition Screen coordinates of the cursor |
| 116 | + */ |
| 117 | + |
| 118 | +/** |
| 119 | + * A single item inside a context menu section. |
| 120 | + * @typedef {Object} ContextMenuItem |
| 121 | + * @property {string} id Unique identifier for the menu item |
| 122 | + * @property {string} label Display text |
| 123 | + * @property {string} [icon] Icon identifier |
| 124 | + * @property {unknown} [component] Custom Vue component to render this item |
| 125 | + * @property {(editor: Editor, context: ContextMenuContext) => void} [action] Callback invoked when the item is clicked |
| 126 | + * @property {(context: ContextMenuContext) => boolean} [showWhen] Predicate controlling visibility |
| 127 | + * @property {(context: ContextMenuContext) => HTMLElement} [render] Custom renderer returning an HTML element |
| 128 | + * @property {string} [shortcut] Keyboard shortcut label displayed beside the item |
| 129 | + */ |
| 130 | + |
| 131 | +/** |
| 132 | + * A section (group) of items in the context menu. |
| 133 | + * @typedef {Object} ContextMenuSection |
| 134 | + * @property {string} id Unique identifier for the section |
| 135 | + * @property {ContextMenuItem[]} items Menu items in this section |
| 136 | + */ |
| 137 | + |
| 138 | +/** |
| 139 | + * Configuration for the context menu module. |
| 140 | + * @typedef {Object} ContextMenuConfig |
| 141 | + * @property {ContextMenuSection[]} [customItems] Custom menu sections appended (or merged by id) to the default menu |
| 142 | + * @property {(context: ContextMenuContext, sections: ContextMenuSection[]) => ContextMenuSection[] | null | undefined} [menuProvider] Advanced: transform the final section list before render. Return null/undefined to keep the original sections. |
| 143 | + * @property {boolean} [includeDefaultItems] Whether to include default menu items (default: true) |
| 144 | + */ |
| 145 | + |
89 | 146 | // --------------------------------------------------------------------------- |
90 | 147 | // Surface system types |
91 | 148 | // --------------------------------------------------------------------------- |
|
469 | 526 | * @property {Object} [toolbar] Toolbar module configuration |
470 | 527 | * @property {Object} [links] Link click popover configuration |
471 | 528 | * @property {LinkPopoverResolver} [links.popoverResolver] Custom resolver for the link click popover. |
472 | | - * @property {Object} [contextMenu] Context menu module configuration |
473 | | - * @property {Array} [contextMenu.customItems] Array of custom menu sections with items |
474 | | - * @property {Function} [contextMenu.menuProvider] Function to customize menu items |
475 | | - * @property {boolean} [contextMenu.includeDefaultItems] Whether to include default menu items |
| 529 | + * @property {ContextMenuConfig} [contextMenu] Context menu module configuration |
476 | 530 | * @property {Object} [slashMenu] @deprecated Use contextMenu instead |
477 | 531 | * @property {SurfacesModuleConfig} [surfaces] Surface system configuration |
478 | 532 | */ |
|
0 commit comments