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.
@@ -1356,13 +1356,37 @@ 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() !== '');
|
1361
|
-
const
|
1362
|
-
|
1363
|
-
|
1369
|
+
const columnCount = rows[0]?.split('\t').length || 1; // Get the number of columns from the first row
|
1370
|
+
const columnWidth = 100 / columnCount; // Calculate column width
|
1371
|
+
const tableRows = rows.map((row, index) => {
|
1372
|
+
const cells = row.split('\t').map(cell => `
|
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()};` : '';
|
1380
|
+
return `
|
1381
|
+
<tr
|
1382
|
+
style="${borderTop} ${borderBottom} width: 100% !important;">
|
1383
|
+
${cells}
|
1384
|
+
</tr>`;
|
1364
1385
|
}).join('');
|
1365
|
-
return
|
1386
|
+
return `
|
1387
|
+
<table style="table-layout: fixed; width: 100%;">
|
1388
|
+
${tableRows}
|
1389
|
+
</table>`;
|
1366
1390
|
}
|
1367
1391
|
insertHtmlAtCaret(html) {
|
1368
1392
|
const range = window.getSelection()?.getRangeAt(0);
|