mirror of
https://github.com/outline/outline.git
synced 2026-11-23 06:11:04 +03:00
* Add table cell merge/unmerge functionality - Add new tableCell menu with merge and unmerge options - Update SelectionToolbar to show tableCell menu for CellSelection - Add mergeCells and splitCell commands to Table node - Add dictionary entries for merge/split cell tooltips - Use placeholder icons (PlusIcon for merge, MoreIcon for split) Fixes #6977 * fixes * fix: Header cells end up floating with some effort * refactor * collapse --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
37 lines
968 B
TypeScript
37 lines
968 B
TypeScript
import { TableSplitCellsIcon, TableMergeCellsIcon } from "outline-icons";
|
|
import { EditorState } from "prosemirror-state";
|
|
import { CellSelection } from "prosemirror-tables";
|
|
import {
|
|
isMergedCellSelection,
|
|
isMultipleCellSelection,
|
|
} from "@shared/editor/queries/table";
|
|
import { MenuItem } from "@shared/editor/types";
|
|
import { Dictionary } from "~/hooks/useDictionary";
|
|
|
|
export default function tableCellMenuItems(
|
|
state: EditorState,
|
|
dictionary: Dictionary
|
|
): MenuItem[] {
|
|
const { selection } = state;
|
|
|
|
// Only show menu items if we have a CellSelection
|
|
if (!(selection instanceof CellSelection)) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
{
|
|
name: "mergeCells",
|
|
label: dictionary.mergeCells,
|
|
icon: <TableMergeCellsIcon />,
|
|
visible: isMultipleCellSelection(state),
|
|
},
|
|
{
|
|
name: "splitCell",
|
|
label: dictionary.splitCell,
|
|
icon: <TableSplitCellsIcon />,
|
|
visible: isMergedCellSelection(state),
|
|
},
|
|
];
|
|
}
|