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.
@@ -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
- // Define the column width percentage
1371
- const columnWidth = 100 / columnCount;
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
- <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('');
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
- <tr class="table-border-top"
1380
- style="border-top: ${this.themeModeTableBorderTop()}; width: 100% !important;">
1381
- ${cells}
1382
- </tr>`;
1381
+ <tr
1382
+ style="${borderTop} ${borderBottom} width: 100% !important;">
1383
+ ${cells}
1384
+ </tr>`;
1383
1385
  }).join('');
1384
1386
  return `
1385
- <table style="table-layout: fixed; width: 100%;">
1386
- ${tableRows}
1387
- </table>`;
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);
@@ -1490,6 +1492,21 @@ class ElTextEditorComponent {
1490
1492
  }
1491
1493
  }
1492
1494
  }
1495
+ // formatTextWithDates(text: string): string {
1496
+ // // Regular expression to detect YYYY-MM-DD formatted dates
1497
+ // const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
1498
+ // // Replace found dates with a formatted version
1499
+ // return text.replace(dateRegex, (dateStr) => {
1500
+ // // Convert the detected date string into a Date object
1501
+ // const dateObj = new Date(dateStr);
1502
+ // // Format the date to 'Month Day, Year' (e.g., October 10, 2024)
1503
+ // return dateObj.toLocaleDateString('en-US', {
1504
+ // year: 'numeric',
1505
+ // month: 'long',
1506
+ // day: 'numeric',
1507
+ // });
1508
+ // });
1509
+ // }
1493
1510
  formatTextWithDates(text) {
1494
1511
  // Regular expression to detect YYYY-MM-DD formatted dates
1495
1512
  const dateRegex = /\b\d{4}-\d{2}-\d{2}\b/g;
@@ -1497,12 +1514,12 @@ class ElTextEditorComponent {
1497
1514
  return text.replace(dateRegex, (dateStr) => {
1498
1515
  // Convert the detected date string into a Date object
1499
1516
  const dateObj = new Date(dateStr);
1500
- // Format the date to 'Month Day, Year' (e.g., October 10, 2024)
1501
- return dateObj.toLocaleDateString('en-US', {
1502
- year: 'numeric',
1503
- month: 'long',
1504
- day: 'numeric',
1505
- });
1517
+ // Extract day, month, and year
1518
+ const day = dateObj.getDate().toString().padStart(2, '0'); // Ensure day is two digits
1519
+ const month = dateObj.toLocaleString('en-US', { month: 'short' }); // Get abbreviated month name
1520
+ const year = dateObj.getFullYear(); // Get full year
1521
+ // Format the date as 'dd/mmm/yyyy'
1522
+ return `${day}/${month}/${year}`;
1506
1523
  });
1507
1524
  }
1508
1525
  }