diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fad94e..e86d1255 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### :bug: Bug Fix +- [Table dragging creates an issue #1128](https://github.com/xdan/jodit/issues/1128) - AddNewLine plugin shown incorrect position after CleanHTML plugin - Inserting a new table - added extra spaces before the table - When merging multiple table cells after the TR tag, the CleanHTML plugin added `
` diff --git a/src/modules/table/table.test.js b/src/modules/table/table.test.js index f286c122..af0e7f79 100644 --- a/src/modules/table/table.test.js +++ b/src/modules/table/table.test.js @@ -4,7 +4,7 @@ * Copyright (c) 2013-2024 Valeriy Chupurnov. All rights reserved. https://xdsoft.net */ -describe.only('Tables Jodit Editor Tests', () => { +describe('Tables Jodit Editor Tests', () => { describe('Methods', () => { it('After init container must have one element .jodit-table-resizer', () => { const editor = getJodit(); @@ -255,7 +255,11 @@ describe.only('Tables Jodit Editor Tests', () => { editor .getInstance(Jodit.modules.Table) - .appendColumn(editor.editor.firstChild); + .appendColumn( + editor.editor.firstChild, + editor.editor.querySelectorAll('td')[1], + true + ); await waitingForEvent(editor, 'finishedCleanHTMLWorker'); @@ -535,6 +539,44 @@ describe.only('Tables Jodit Editor Tests', () => { '', 2, false + ], + [ + '' + + '' + + '' + + '' + + '' + + '' + + '
1
', + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '

1
', + 0, + false + ], + [ + '' + + '' + + '' + + '' + + '' + + '' + + '
1
', + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
1
', + 0, + true ] ].forEach(([value, result, column, after], index) => { describe(`Case #${index} Value is ${value} and column is ${column} and after is ${after}`, () => { diff --git a/src/modules/table/table.ts b/src/modules/table/table.ts index 504b14cd..bcc68850 100644 --- a/src/modules/table/table.ts +++ b/src/modules/table/table.ts @@ -406,10 +406,18 @@ export class Table extends ViewComponent { appendColumn( table: HTMLTableElement, selectedCell: HTMLTableCellElement, - insertAfter: boolean + insertAfter: boolean = true ): void { const box = Table.__formalMatrix(table); + if (!insertAfter && Dom.isCell(selectedCell.previousElementSibling)) { + return this.appendColumn( + table, + selectedCell.previousElementSibling as HTMLTableCellElement, + true + ); + } + const columnIndex = insertAfter ? selectedCell.cellIndex + ((selectedCell.colSpan || 1) - 1) : selectedCell.cellIndex;