owl-rich-table
Version:
富文本编辑表格,react组件
42 lines • 2.15 kB
JavaScript
import { useContext } from 'react';
import TableDataContext from "../../../context/TableDataContext";
import TableWorkLoopContext from "../../../context/TableWorkLoopContext";
import "./style.css";
/**
* @description 行头部操作栏 - 扩展操作栏
* @author Huang Wenjie
* @createDate 2023-11-03
*/
import { jsx as _jsx } from "react/jsx-runtime";
export default function ColButton() {
var _tableRenderData$heig;
var _useContext = useContext(TableDataContext),
tableRenderData = _useContext.tableRenderData,
removeRow = _useContext.removeRow;
var _useContext2 = useContext(TableWorkLoopContext),
dispatch = _useContext2.dispatch;
return /*#__PURE__*/_jsx("div", {
className: "rich-table-bar-col",
children: tableRenderData === null || tableRenderData === void 0 ? void 0 : (_tableRenderData$heig = tableRenderData.height) === null || _tableRenderData$heig === void 0 ? void 0 : _tableRenderData$heig.map(function (height, index) {
var _tableRenderData$heig2;
return /*#__PURE__*/_jsx("div", {
className: "bar-col-button",
id: "RICH_TABLE_COL_BUTTON",
style: {
height: index === (tableRenderData === null || tableRenderData === void 0 ? void 0 : (_tableRenderData$heig2 = tableRenderData.height) === null || _tableRenderData$heig2 === void 0 ? void 0 : _tableRenderData$heig2.length) - 1 ? height + 1 : height
},
tabIndex: 0,
children: /*#__PURE__*/_jsx("div", {
className: "bar-col-button-delete",
onClick: function onClick(e) {
var _e$currentTarget, _e$currentTarget$pare;
e === null || e === void 0 ? void 0 : (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : (_e$currentTarget$pare = _e$currentTarget.parentElement) === null || _e$currentTarget$pare === void 0 ? void 0 : _e$currentTarget$pare.blur();
dispatch === null || dispatch === void 0 ? void 0 : dispatch.action(function () {
return removeRow === null || removeRow === void 0 ? void 0 : removeRow(index);
});
}
})
}, index);
})
});
}