diff --git a/src/__tests__/table-insert-remove-merge.test.ts b/src/__tests__/table-insert-remove-merge.test.ts
index 41e033a..3e11146 100644
--- a/src/__tests__/table-insert-remove-merge.test.ts
+++ b/src/__tests__/table-insert-remove-merge.test.ts
@@ -350,6 +350,39 @@ describe('remove column from table', () => {
);
});
+ it('remove column in not full table', async () => {
+ const quill = await createTable(1, 3, false, 100);
+ const tableModule = quill.getModule('tableUp') as TableUp;
+ await vi.runAllTimersAsync();
+ const table = quill.root.querySelector('table')!;
+ tableModule.tableSelection = new TableSelection(tableModule, table, quill);
+ const tds = quill.scroll.descendants(TableCellInnerFormat, 0);
+ tableModule.tableSelection.selectedTds = [tds[0]];
+ tableModule.removeCol();
+ await vi.runAllTimersAsync();
+ expect(quill.root).toEqualHTML(
+ `
+
+
+
+ `,
+ { ignoreAttrs: ['class', 'data-table-id', 'data-row-id', 'data-col-id', 'data-rowspan', 'data-colspan', 'contenteditable'] },
+ );
+ });
+
it('remove column. remove colspan start cell and rowspan cell', async () => {
const quill = createQuillWithTableModule(`
`);
const tableModule = quill.getModule('tableUp') as TableUp;
diff --git a/src/formats/table-colgroup-format.ts b/src/formats/table-colgroup-format.ts
index 16dd738..d4a8b96 100644
--- a/src/formats/table-colgroup-format.ts
+++ b/src/formats/table-colgroup-format.ts
@@ -67,13 +67,16 @@ export class TableColgroupFormat extends ContainerFormat {
}
const col = this.findCol(index);
if (col) {
- if (col.next) {
- (col.next as TableColFormat).width += col.width;
- }
- else if (col.prev) {
- (col.prev as TableColFormat).width += col.width;
+ if (table.full) {
+ if (col.next) {
+ (col.next as TableColFormat).width += col.width;
+ }
+ else if (col.prev) {
+ (col.prev as TableColFormat).width += col.width;
+ }
}
col.remove();
+ table.colWidthFillTable();
}
}