( options: TaskCardContextMenuButtonOptions )
| 32 | } |
| 33 | |
| 34 | export function createTaskCardContextMenuButton( |
| 35 | options: TaskCardContextMenuButtonOptions |
| 36 | ): HTMLElement { |
| 37 | const { mainRow, taskPath, plugin, targetDate, promoteOccurrenceControls } = options; |
| 38 | const taskOptionsLabel = tTaskCard(plugin, "taskOptions"); |
| 39 | const contextIcon = mainRow.createEl("div", { |
| 40 | cls: "task-card__context-menu", |
| 41 | attr: { |
| 42 | "aria-label": taskOptionsLabel, |
| 43 | }, |
| 44 | }); |
| 45 | |
| 46 | setIcon(contextIcon, "ellipsis-vertical"); |
| 47 | setTooltip(contextIcon, taskOptionsLabel, { placement: "top" }); |
| 48 | prepareInteractiveControl(contextIcon); |
| 49 | |
| 50 | contextIcon.addEventListener("click", (e) => { |
| 51 | e.stopPropagation(); |
| 52 | e.preventDefault(); |
| 53 | if (promoteOccurrenceControls === undefined) { |
| 54 | void showTaskContextMenu(e, taskPath, plugin, targetDate); |
| 55 | return; |
| 56 | } |
| 57 | void showTaskContextMenu(e, taskPath, plugin, targetDate, { promoteOccurrenceControls }); |
| 58 | }); |
| 59 | |
| 60 | return contextIcon; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Show context menu for task card. |
no test coverage detected