el-text-editor 0.0.61 → 0.0.63
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.
@@ -1372,24 +1372,26 @@ class ElTextEditorComponent {
|
|
1372
1372
|
var _a;
|
1373
1373
|
const rows = text.split('\n').filter(row => row.trim() !== '');
|
1374
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
|
-
//
|
1376
|
-
const
|
1377
|
-
const tableRows = rows.map(row => {
|
1375
|
+
const columnWidth = 100 / columnCount; // Calculate column width
|
1376
|
+
const tableRows = rows.map((row, index) => {
|
1378
1377
|
const cells = row.split('\t').map(cell => `
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
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()};` : '';
|
1383
1385
|
return `
|
1384
|
-
|
1385
|
-
style="
|
1386
|
-
|
1387
|
-
|
1386
|
+
<tr
|
1387
|
+
style="${borderTop} ${borderBottom} width: 100% !important;">
|
1388
|
+
${cells}
|
1389
|
+
</tr>`;
|
1388
1390
|
}).join('');
|
1389
1391
|
return `
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1392
|
+
<table style="table-layout: fixed; width: 100%;">
|
1393
|
+
${tableRows}
|
1394
|
+
</table>`;
|
1393
1395
|
}
|
1394
1396
|
insertHtmlAtCaret(html) {
|
1395
1397
|
var _a;
|
@@ -1496,6 +1498,21 @@ class ElTextEditorComponent {
|
|
1496
1498
|
}
|
1497
1499
|
}
|
1498
1500
|
}
|
1501
|
+
// formatTextWithDates(text: string): string {
|
1502
|
+
// // Regular expression to detect YYYY-MM-DD formatted dates
|
1503
|
+
// const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
|
1504
|
+
// // Replace found dates with a formatted version
|
1505
|
+
// return text.replace(dateRegex, (dateStr) => {
|
1506
|
+
// // Convert the detected date string into a Date object
|
1507
|
+
// const dateObj = new Date(dateStr);
|
1508
|
+
// // Format the date to 'Month Day, Year' (e.g., October 10, 2024)
|
1509
|
+
// return dateObj.toLocaleDateString('en-US', {
|
1510
|
+
// year: 'numeric',
|
1511
|
+
// month: 'long',
|
1512
|
+
// day: 'numeric',
|
1513
|
+
// });
|
1514
|
+
// });
|
1515
|
+
// }
|
1499
1516
|
formatTextWithDates(text) {
|
1500
1517
|
// Regular expression to detect YYYY-MM-DD formatted dates
|
1501
1518
|
const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
|
@@ -1503,12 +1520,12 @@ class ElTextEditorComponent {
|
|
1503
1520
|
return text.replace(dateRegex, (dateStr) => {
|
1504
1521
|
// Convert the detected date string into a Date object
|
1505
1522
|
const dateObj = new Date(dateStr);
|
1506
|
-
//
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
}
|
1523
|
+
// Extract day, month, and year
|
1524
|
+
const day = dateObj.getDate().toString().padStart(2, '0'); // Ensure day is two digits
|
1525
|
+
const month = dateObj.toLocaleString('en-US', { month: 'short' }); // Get abbreviated month name
|
1526
|
+
const year = dateObj.getFullYear(); // Get full year
|
1527
|
+
// Format the date as 'dd/mmm/yyyy'
|
1528
|
+
return `${day}/${month}/${year}`;
|
1512
1529
|
});
|
1513
1530
|
}
|
1514
1531
|
}
|