This commit is contained in:
Tom Moor committed 2025-02-12 22:08:55 -05:00
1 parent 33b7c8940f
commit 86c16d5ccb
3 files changed
+9 -9

No files matched your search

+1 -1
View File
@@ -127,7 +127,7 @@ export default function blockMenuItems(
attrs: {
rowsCount: 3,
colsCount: 3,
columnWidths: [documentWidth / 3, documentWidth / 3],
colWidth: documentWidth / 3,
},
},
{
+6 -6
View File
@@ -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,
}
+2 -2
View File
@@ -35,8 +35,8 @@ export type MenuItem = {
children?: MenuItem[];
defaultHidden?: boolean;
attrs?:
| Record<string, Primitive | Primitive[] | null>
| ((state: EditorState) => Record<string, Primitive | Primitive[] | null>);
| Record<string, Primitive | null>
| ((state: EditorState) => Record<string, Primitive | null>);
visible?: boolean;
active?: (state: EditorState) => boolean;
appendSpace?: boolean;