mirror of
https://github.com/docmost/docmost.git
synced 2025-11-14 09:11:15 +10:00
feat: toggle table header row and column
This commit is contained in:
@ -17,9 +17,9 @@ import {
|
|||||||
IconColumnRemove,
|
IconColumnRemove,
|
||||||
IconRowInsertBottom,
|
IconRowInsertBottom,
|
||||||
IconRowInsertTop,
|
IconRowInsertTop,
|
||||||
IconRowRemove,
|
IconRowRemove, IconTableColumn, IconTableRow,
|
||||||
IconTrashX,
|
IconTrashX,
|
||||||
} from "@tabler/icons-react";
|
} from '@tabler/icons-react';
|
||||||
import { isCellSelection } from "@docmost/editor-ext";
|
import { isCellSelection } from "@docmost/editor-ext";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
@ -50,6 +50,14 @@ export const TableMenu = React.memo(
|
|||||||
return posToDOMRect(editor.view, selection.from, selection.to);
|
return posToDOMRect(editor.view, selection.from, selection.to);
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
|
|
||||||
|
const toggleHeaderColumn = useCallback(() => {
|
||||||
|
editor.chain().focus().toggleHeaderColumn().run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
|
const toggleHeaderRow = useCallback(() => {
|
||||||
|
editor.chain().focus().toggleHeaderRow().run();
|
||||||
|
}, [editor]);
|
||||||
|
|
||||||
const addColumnLeft = useCallback(() => {
|
const addColumnLeft = useCallback(() => {
|
||||||
editor.chain().focus().addColumnBefore().run();
|
editor.chain().focus().addColumnBefore().run();
|
||||||
}, [editor]);
|
}, [editor]);
|
||||||
@ -113,6 +121,30 @@ export const TableMenu = React.memo(
|
|||||||
shouldShow={shouldShow}
|
shouldShow={shouldShow}
|
||||||
>
|
>
|
||||||
<ActionIcon.Group>
|
<ActionIcon.Group>
|
||||||
|
<Tooltip position="top" label={t("Toggle header row")}
|
||||||
|
>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={toggleHeaderRow}
|
||||||
|
variant="default"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Toggle header row")}
|
||||||
|
>
|
||||||
|
<IconTableRow size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip position="top" label={t("Toggle header column")}
|
||||||
|
>
|
||||||
|
<ActionIcon
|
||||||
|
onClick={toggleHeaderColumn}
|
||||||
|
variant="default"
|
||||||
|
size="lg"
|
||||||
|
aria-label={t("Toggle header column")}
|
||||||
|
>
|
||||||
|
<IconTableColumn size={18} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
<Tooltip position="top" label={t("Add left column")}
|
<Tooltip position="top" label={t("Add left column")}
|
||||||
>
|
>
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
|
|||||||
Reference in New Issue
Block a user