el-text-editor 0.0.60 → 0.0.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1360,13 +1360,38 @@ class ElTextEditorComponent {
1360
1360
  const rows = text.split('\n');
1361
1361
  return rows.length > 1 && rows[0].split('\t').length > 1;
1362
1362
  }
1363
+ // convertTextToTable(text: string): string {
1364
+ // const rows = text.split('\n').filter(row => row.trim() !== '');
1365
+ // const tableRows = rows.map(row => {
1366
+ // const cells = row.split('\t').map(cell => `<td class="px-1 py-1" >${cell}</td>`).join('');
1367
+ // return `<tr class="table-border-top" style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important">${cells}</tr>`;
1368
+ // }).join('');
1369
+ // return `<table>${tableRows}</table>`;
1370
+ // }
1363
1371
  convertTextToTable(text) {
1372
+ var _a;
1364
1373
  const rows = text.split('\n').filter(row => row.trim() !== '');
1365
- const tableRows = rows.map(row => {
1366
- const cells = row.split('\t').map(cell => `<td class="px-1 py-1" >${cell}</td>`).join('');
1367
- return `<tr class="table-border-top" style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important">${cells}</tr>`;
1374
+ const columnCount = ((_a = rows[0]) === null || _a === void 0 ? void 0 : _a.split('\t').length) || 1; // Get the number of columns from the first row
1375
+ const columnWidth = 100 / columnCount; // Calculate column width
1376
+ const tableRows = rows.map((row, index) => {
1377
+ const cells = row.split('\t').map(cell => `
1378
+ <td class="px-1 py-1 text-truncate"
1379
+ style="max-width: ${columnWidth}%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
1380
+ ${cell}
1381
+ </td>`).join('');
1382
+ // Add a border-top for all rows except the first and border-bottom for the last row
1383
+ const borderTop = index === 0 ? '' : `border-top: ${this.themeModeTableBorderTop()};`;
1384
+ const borderBottom = index === rows.length - 1 ? `border-bottom: ${this.themeModeTableBorderTop()};` : '';
1385
+ return `
1386
+ <tr
1387
+ style="${borderTop} ${borderBottom} width: 100% !important;">
1388
+ ${cells}
1389
+ </tr>`;
1368
1390
  }).join('');
1369
- return `<table>${tableRows}</table>`;
1391
+ return `
1392
+ <table style="table-layout: fixed; width: 100%;">
1393
+ ${tableRows}
1394
+ </table>`;
1370
1395
  }
1371
1396
  insertHtmlAtCaret(html) {
1372
1397
  var _a;