//手写了一个插入带属性的表格的事件,但是组合键会将自定义属性(data-table)去掉,怎么办?
function createTable(attr) {
let width = attr.tableWidth ? attr.tableWidth + attr.widthUnit : 'auto',
height = attr.tableHeight ? attr.tableHeight + attr.heightUnit : 'auto',
border = attr.tableBorder ? attr.tableBorder : '1',
borderColor = attr.borderColor,
bgColor = attr.bgColor,
cellspacing = attr.tableMargin,
cellpadding = attr.tablePadding,
align = attr.alignment ? attr.alignment : '';
let table = `<table class="dataTable" ${align ? 'align=' + align : ''} border="${border}" bordercolor="${borderColor}" style="width:${width};height:${height};background-color:${bgColor}" data-table="${attr.tableSource}" cellspacing="${cellspacing}" cellpadding="${cellpadding}"><tbody>`;
for (let i = 1; i <= attr.tableRow; i++) {
table += `<tr>`;
for (let j = 1; j <= attr.tableCol; j++) {
table += `<td> </td>`;
}
table += `</tr>`;
}
table += `</tbody></table> `;
editor.insertHtml(table);
_body.find('table.dataTable').unbind().on('click', function (e) {
window.event ? window.event.cancelBubble = true : e.stopPropagation();
curDataSource = $(this).attr('data-table');
})
}