11import IconButton from "@mui/material/IconButton" ;
2- import ListItemIcon from "@mui/material/ListItemIcon" ;
32import { TableColumn } from "cdm/FolderModel" ;
43import DragIndicatorIcon from "@mui/icons-material/DragIndicator" ;
5- import DeleteIcon from "@mui/icons-material/Delete" ;
64import {
75 DEFAULT_COLUMN_CONFIG ,
86 InputType ,
97 MetadataDatabaseColumns ,
108} from "helpers/Constants" ;
119import React from "react" ;
12- import Menu from "@mui/material/Menu" ;
13- import MenuItem from "@mui/material/MenuItem" ;
10+ import { showFileMenu } from "components/obsidianArq/commands" ;
1411
1512const rowContextMenuColumn : TableColumn = {
1613 ...MetadataDatabaseColumns . ROW_CONTEXT_MENU ,
@@ -21,32 +18,21 @@ const rowContextMenuColumn: TableColumn = {
2118 cell : ( { row, table } ) => {
2219 const { tableState } = table . options . meta ;
2320 const rowActions = tableState . data ( ( state ) => state . actions ) ;
24- const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
25- const open = Boolean ( anchorEl ) ;
26-
27- const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
28- row . getToggleSelectedHandler ( ) ( {
29- event : {
30- target : {
31- checked : ! row . getIsSelected ( ) ,
32- } ,
33- } ,
34- } ) ;
35- setAnchorEl ( event . currentTarget ) ;
21+ const handleDeleteRow = ( ) => {
22+ rowActions . removeRow ( row . original ) ;
3623 } ;
37- const handleMenuClose = ( ) => {
38- setAnchorEl ( null ) ;
39- row . getToggleSelectedHandler ( ) ( {
40- event : {
41- target : {
42- checked : ! row . getIsSelected ( ) ,
43- } ,
44- } ,
45- } ) ;
24+
25+ const handleRenameRow = ( ) => {
26+ rowActions . renameFile ( row . index ) ;
4627 } ;
4728
48- const handleDeleteRow = ( ) => {
49- rowActions . removeRow ( row . original ) ;
29+ const handleClick = ( event : React . MouseEvent < HTMLElement > ) => {
30+ showFileMenu (
31+ row . original . __note__ . getFile ( ) ,
32+ event . nativeEvent ,
33+ handleDeleteRow ,
34+ handleRenameRow
35+ ) ;
5036 } ;
5137
5238 return (
@@ -66,31 +52,6 @@ const rowContextMenuColumn: TableColumn = {
6652 >
6753 < DragIndicatorIcon />
6854 </ IconButton >
69- < Menu
70- anchorEl = { anchorEl }
71- id = { `row-context-menu-${ row . id } ` }
72- open = { open }
73- onClose = { handleMenuClose }
74- onClick = { handleMenuClose }
75- transformOrigin = { { horizontal : "left" , vertical : "top" } }
76- anchorOrigin = { { horizontal : "left" , vertical : "bottom" } }
77- key = { `row-context-Menu-${ row . id } ` }
78- >
79- < MenuItem
80- onClick = { handleDeleteRow }
81- key = { `row-context-Menu-MenuItem-Delete-${ row . id } ` }
82- >
83- < ListItemIcon
84- key = { `row-context-Menu-MenuItem-ListItemIcon-${ row . id } ` }
85- >
86- < DeleteIcon
87- fontSize = "small"
88- key = { `row-context-Menu-MenuItem-DeleteIcon-${ row . id } ` }
89- />
90- </ ListItemIcon >
91- Delete
92- </ MenuItem >
93- </ Menu >
9455 </ >
9556 ) ;
9657 } ,
0 commit comments