mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-29 09:35:38 -05:00
Table with no headings gets corrupted when editing (#13293)
* fix data loss issue when modifying table with no headings * fix comment * Add tests and extra empty space to empty header format
This commit is contained in:
@@ -95,10 +95,19 @@ rules['table'] = {
|
||||
filter: function (node) {
|
||||
return node.nodeName === 'TABLE' && isHeadingRow(node.rows[0]);
|
||||
},
|
||||
|
||||
replacement: function (content) {
|
||||
replacement: function (content, node) {
|
||||
// Ensure there are no blank lines
|
||||
content = content.replace('\n\n', '\n');
|
||||
// if the headings are empty, add border line and headings to keep table format
|
||||
if (node.tHead.innerText === '') {
|
||||
let emptyHeader = '\n\n|';
|
||||
let border = '\n|';
|
||||
for (let i = 0; i < node.rows[0].childNodes.length; i++) {
|
||||
emptyHeader += ' |';
|
||||
border += ' --- |'
|
||||
}
|
||||
return emptyHeader + border + content + '\n\n';
|
||||
}
|
||||
return '\n\n' + content + '\n\n';
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user