el-text-editor 0.0.61 → 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.
@@ -1367,24 +1367,26 @@ class ElTextEditorComponent {
|
|
1367
1367
|
convertTextToTable(text) {
|
1368
1368
|
const rows = text.split('\n').filter(row => row.trim() !== '');
|
1369
1369
|
const columnCount = rows[0]?.split('\t').length || 1; // Get the number of columns from the first row
|
1370
|
-
//
|
1371
|
-
const
|
1372
|
-
const tableRows = rows.map(row => {
|
1370
|
+
const columnWidth = 100 / columnCount; // Calculate column width
|
1371
|
+
const tableRows = rows.map((row, index) => {
|
1373
1372
|
const cells = row.split('\t').map(cell => `
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1373
|
+
<td class="px-1 py-1 text-truncate"
|
1374
|
+
style="max-width: ${columnWidth}%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
|
1375
|
+
${cell}
|
1376
|
+
</td>`).join('');
|
1377
|
+
// Add a border-top for all rows except the first and border-bottom for the last row
|
1378
|
+
const borderTop = index === 0 ? '' : `border-top: ${this.themeModeTableBorderTop()};`;
|
1379
|
+
const borderBottom = index === rows.length - 1 ? `border-bottom: ${this.themeModeTableBorderTop()};` : '';
|
1378
1380
|
return `
|
1379
|
-
|
1380
|
-
style="
|
1381
|
-
|
1382
|
-
|
1381
|
+
<tr
|
1382
|
+
style="${borderTop} ${borderBottom} width: 100% !important;">
|
1383
|
+
${cells}
|
1384
|
+
</tr>`;
|
1383
1385
|
}).join('');
|
1384
1386
|
return `
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1387
|
+
<table style="table-layout: fixed; width: 100%;">
|
1388
|
+
${tableRows}
|
1389
|
+
</table>`;
|
1388
1390
|
}
|
1389
1391
|
insertHtmlAtCaret(html) {
|
1390
1392
|
const range = window.getSelection()?.getRangeAt(0);
|