el-text-editor 0.0.60 → 0.0.61

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.
@@ -1356,13 +1356,35 @@ class ElTextEditorComponent {
1356
1356
  const rows = text.split('\n');
1357
1357
  return rows.length > 1 && rows[0].split('\t').length > 1;
1358
1358
  }
1359
+ // convertTextToTable(text: string): string {
1360
+ // const rows = text.split('\n').filter(row => row.trim() !== '');
1361
+ // const tableRows = rows.map(row => {
1362
+ // const cells = row.split('\t').map(cell => `<td class="px-1 py-1" >${cell}</td>`).join('');
1363
+ // return `<tr class="table-border-top" style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important">${cells}</tr>`;
1364
+ // }).join('');
1365
+ // return `<table>${tableRows}</table>`;
1366
+ // }
1359
1367
  convertTextToTable(text) {
1360
1368
  const rows = text.split('\n').filter(row => row.trim() !== '');
1369
+ const columnCount = rows[0]?.split('\t').length || 1; // Get the number of columns from the first row
1370
+ // Define the column width percentage
1371
+ const columnWidth = 100 / columnCount;
1361
1372
  const tableRows = rows.map(row => {
1362
- const cells = row.split('\t').map(cell => `<td class="px-1 py-1" >${cell}</td>`).join('');
1363
- return `<tr class="table-border-top" style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important">${cells}</tr>`;
1373
+ const cells = row.split('\t').map(cell => `
1374
+ <td class="px-1 py-1 text-truncate"
1375
+ style="max-width: ${columnWidth}%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
1376
+ ${cell}
1377
+ </td>`).join('');
1378
+ return `
1379
+ <tr class="table-border-top"
1380
+ style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important;">
1381
+ ${cells}
1382
+ </tr>`;
1364
1383
  }).join('');
1365
- return `<table>${tableRows}</table>`;
1384
+ return `
1385
+ <table style="table-layout: fixed; width: 100%;">
1386
+ ${tableRows}
1387
+ </table>`;
1366
1388
  }
1367
1389
  insertHtmlAtCaret(html) {
1368
1390
  const range = window.getSelection()?.getRangeAt(0);