From 86c16d5ccba997445cd8eb9f40e9838dfc6d5fb2 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 12 Feb 2025 22:08:55 -0500 Subject: [PATCH] tsc --- app/editor/menus/block.tsx | 2 +- shared/editor/commands/table.ts | 12 ++++++------ shared/editor/types/index.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/editor/menus/block.tsx b/app/editor/menus/block.tsx index b35d7917aa..19d7665800 100644 --- a/app/editor/menus/block.tsx +++ b/app/editor/menus/block.tsx @@ -127,7 +127,7 @@ export default function blockMenuItems( attrs: { rowsCount: 3, colsCount: 3, - columnWidths: [documentWidth / 3, documentWidth / 3], + colWidth: documentWidth / 3, }, }, { diff --git a/shared/editor/commands/table.ts b/shared/editor/commands/table.ts index f08d5797fb..e4461e905d 100644 --- a/shared/editor/commands/table.ts +++ b/shared/editor/commands/table.ts @@ -20,19 +20,19 @@ import { collapseSelection } from "./collapseSelection"; export function createTable({ rowsCount, colsCount, - columnWidths = [], + colWidth, }: { /** The number of rows in the table. */ rowsCount: number; /** The number of columns in the table. */ colsCount: number; /** The widths of each column in the table. */ - columnWidths: number[]; + colWidth: number; }): Command { return (state, dispatch) => { if (dispatch) { const offset = state.tr.selection.anchor + 1; - const nodes = createTableInner(state, rowsCount, colsCount, columnWidths); + const nodes = createTableInner(state, rowsCount, colsCount, colWidth); const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView(); const resolvedPos = tr.doc.resolve(offset); tr.setSelection(TextSelection.near(resolvedPos)); @@ -46,7 +46,7 @@ function createTableInner( state: EditorState, rowsCount: number, colsCount: number, - columnWidths: number[], + colWidth: number, withHeaderRow = true, cellContent?: Node ) { @@ -61,9 +61,9 @@ function createTableInner( : cellType.createAndFill(attrs); for (let index = 0; index < colsCount; index += 1) { - const attrs = columnWidths[index] + const attrs = colWidth ? { - colwidth: [columnWidths[index]], + colwidth: [colWidth], colspan: 1, rowspan: 1, } diff --git a/shared/editor/types/index.ts b/shared/editor/types/index.ts index f7a5a49f5c..ef4b90d806 100644 --- a/shared/editor/types/index.ts +++ b/shared/editor/types/index.ts @@ -35,8 +35,8 @@ export type MenuItem = { children?: MenuItem[]; defaultHidden?: boolean; attrs?: - | Record - | ((state: EditorState) => Record); + | Record + | ((state: EditorState) => Record); visible?: boolean; active?: (state: EditorState) => boolean; appendSpace?: boolean;