react-markdown-table-ts 0.3.11 → 0.3.13
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.
- package/dist/index.cjs.js +9 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -4085,20 +4085,19 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4085
4085
|
// Retrieve the cell value; default to an empty string if undefined or null.
|
4086
4086
|
var cellValue = currentRow[columnIndex];
|
4087
4087
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4088
|
-
// Replace newlines with the appropriate character based on canReplaceNewlines.
|
4089
4088
|
if (canReplaceNewlines) {
|
4090
|
-
//
|
4091
|
-
var
|
4092
|
-
|
4093
|
-
|
4094
|
-
var
|
4095
|
-
// Update column width
|
4096
|
-
if (
|
4097
|
-
columnWidths[columnIndex] =
|
4089
|
+
// Split the cell into lines based on newline characters.
|
4090
|
+
var lines = cellString.split('\n');
|
4091
|
+
// For display, replace '\n' with '<br>' (handled elsewhere, e.g., when rendering).
|
4092
|
+
// For width calculation, find the length of the longest line.
|
4093
|
+
var maxLineLength = lines.reduce(function (max, line) { return Math.max(max, line.length); }, 0);
|
4094
|
+
// Update the column width if the longest line is greater than the current width.
|
4095
|
+
if (maxLineLength > columnWidths[columnIndex]) {
|
4096
|
+
columnWidths[columnIndex] = maxLineLength;
|
4098
4097
|
}
|
4099
4098
|
}
|
4100
4099
|
else {
|
4101
|
-
// Replace newlines with
|
4100
|
+
// Replace newlines with spaces and calculate the total length.
|
4102
4101
|
cellString = cellString.replace(/\n/g, ' ');
|
4103
4102
|
// Update the column width if the current cell's length is greater.
|
4104
4103
|
if (cellString.length > columnWidths[columnIndex]) {
|