@mdxeditor/editor
Version:
React component for rich text markdown editing
26 lines (25 loc) • 895 B
JavaScript
import { ButtonWithTooltip } from "../primitives/toolbar.js";
import React__default from "react";
import { insertTable$ } from "../../table/index.js";
import { useCellValue, usePublisher } from "@mdxeditor/gurx";
import { iconComponentFor$, useTranslation, editorInTable$ } from "../../core/index.js";
const InsertTable = () => {
const iconComponentFor = useCellValue(iconComponentFor$);
const insertTable = usePublisher(insertTable$);
const t = useTranslation();
const isDisabled = useCellValue(editorInTable$);
return /* @__PURE__ */ React__default.createElement(
ButtonWithTooltip,
{
title: t("toolbar.table", "Insert Table"),
onClick: () => {
insertTable({ rows: 3, columns: 3 });
},
...isDisabled ? { "aria-disabled": true, "data-disabled": true, disabled: true } : {}
},
iconComponentFor("table")
);
};
export {
InsertTable
};