Skip to content

Commit 50f6cd7

Browse files
committed
more cleanup
1 parent 2a46c76 commit 50f6cd7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/components/SlateEditor/plugins/table/slateHelpers.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
*
77
*/
88

9-
import { Editor, Element, Path } from "slate";
9+
import { Editor, Path } from "slate";
1010
import { jsx as slatejsx } from "slate-hyperscript";
1111
import { defaultTableCellBlock } from "./defaultBlocks";
1212
import { TableBodyElement, TableCellElement, TableHeadElement, TableRowElement } from "./interfaces";
13-
import { TYPE_TABLE_CELL_HEADER, TYPE_TABLE_ROW } from "./types";
14-
import { isAnyTableCellElement, isTableRowElement } from "./queries";
13+
import { TABLE_ROW_ELEMENT_TYPE } from "./types";
14+
import { isAnyTableCellElement, isTableCellHeaderElement, isTableRowElement } from "./queries";
1515

1616
export const hasCellAlignOfType = (editor: Editor, type: string) => {
1717
// For all selected table cells
@@ -48,7 +48,7 @@ export const getTableBodyWidth = (element: TableHeadElement | TableBodyElement)
4848
export const createIdenticalRow = (element: TableRowElement) => {
4949
return slatejsx(
5050
"element",
51-
{ type: TYPE_TABLE_ROW },
51+
{ type: TABLE_ROW_ELEMENT_TYPE },
5252
element.children.map((child) => {
5353
if (isAnyTableCellElement(child)) {
5454
return {
@@ -65,9 +65,5 @@ export const createIdenticalRow = (element: TableRowElement) => {
6565
};
6666

6767
export const isInTableCellHeader = (editor: Editor, path?: Path) => {
68-
if (path) {
69-
const [parent] = Editor.parent(editor, path);
70-
return Element.isElement(parent) && parent.type === TYPE_TABLE_CELL_HEADER;
71-
}
72-
return false;
68+
return path ? isTableCellHeaderElement(Editor.parent(editor, path)?.[0]) : false;
7369
};

0 commit comments

Comments
 (0)