| 1 |
import { ToolbarButton } from "@wordpress/components"; |
| 2 |
import { __ } from "@wordpress/i18n"; |
| 3 |
import { trash } from "@wordpress/icons"; |
| 4 |
import { CellKey } from "../attributes"; |
| 5 |
import { useTableStore } from "../store"; |
| 6 |
|
| 7 |
export function ElementDeleteButton({ |
| 8 |
cellCoords, |
| 9 |
elementIndex, |
| 10 |
}: { |
| 11 |
cellCoords: CellKey; |
| 12 |
elementIndex: number; |
| 13 |
}) { |
| 14 |
const removeElementFromCell = useTableStore( |
| 15 |
state => state.removeElementFromCell |
| 16 |
); |
| 17 |
|
| 18 |
return ( |
| 19 |
<ToolbarButton |
| 20 |
icon={trash} |
| 21 |
label={__("Delete element", "tableberg")} |
| 22 |
title={__("Delete element", "tableberg")} |
| 23 |
isDestructive |
| 24 |
onClick={() => removeElementFromCell(cellCoords, elementIndex)} |
| 25 |
/> |
| 26 |
); |
| 27 |
} |
| 28 |
|