fix: Edit view — auto-width columns, 1px solid black borders on pasted tables
This commit is contained in:
@@ -108,11 +108,15 @@
|
|||||||
paste_data_images: true,
|
paste_data_images: true,
|
||||||
paste_webkit_styles: 'all',
|
paste_webkit_styles: 'all',
|
||||||
paste_postprocess: function(editor, args) {
|
paste_postprocess: function(editor, args) {
|
||||||
|
args.node.querySelectorAll('colgroup').forEach(function(cg) { cg.remove(); });
|
||||||
args.node.querySelectorAll('*').forEach(function(el) {
|
args.node.querySelectorAll('*').forEach(function(el) {
|
||||||
var tag = el.tagName.toLowerCase();
|
var tag = el.tagName.toLowerCase();
|
||||||
var isTablePart = (tag === 'td' || tag === 'th' || tag === 'table' || tag === 'tr');
|
var isTablePart = (tag === 'td' || tag === 'th' || tag === 'table' || tag === 'tr');
|
||||||
if (el.style.color && !isTablePart) el.style.color = '#000';
|
if (el.style.color && !isTablePart) el.style.color = '#000';
|
||||||
if (el.style.backgroundColor && !isTablePart) el.style.backgroundColor = '';
|
if (el.style.backgroundColor && !isTablePart) el.style.backgroundColor = '';
|
||||||
|
if (tag === 'col' || tag === 'td' || tag === 'th' || tag === 'table') { el.removeAttribute('width'); el.style.width = ''; }
|
||||||
|
if (tag === 'td' || tag === 'th') { el.style.border = '1px solid #000'; el.style.padding = '6px 10px'; }
|
||||||
|
if (tag === 'table') { el.style.borderCollapse = 'collapse'; el.removeAttribute('border'); el.removeAttribute('cellspacing'); el.removeAttribute('cellpadding'); }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
valid_styles: {
|
valid_styles: {
|
||||||
|
|||||||
Reference in New Issue
Block a user