react-markdown-table-ts 0.3.12 → 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 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -4094,16 +4094,18 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4094
4094
|
var cellValue = currentRow[columnIndex];
|
4095
4095
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4096
4096
|
if (canReplaceNewlines) {
|
4097
|
-
//
|
4098
|
-
var
|
4099
|
-
|
4100
|
-
//
|
4101
|
-
|
4102
|
-
|
4097
|
+
// Split the cell into lines based on newline characters.
|
4098
|
+
var lines = cellString.split('\n');
|
4099
|
+
// For display, replace '\n' with '<br>' (handled elsewhere, e.g., when rendering).
|
4100
|
+
// For width calculation, find the length of the longest line.
|
4101
|
+
var maxLineLength = lines.reduce(function (max, line) { return Math.max(max, line.length); }, 0);
|
4102
|
+
// Update the column width if the longest line is greater than the current width.
|
4103
|
+
if (maxLineLength > columnWidths[columnIndex]) {
|
4104
|
+
columnWidths[columnIndex] = maxLineLength;
|
4103
4105
|
}
|
4104
4106
|
}
|
4105
4107
|
else {
|
4106
|
-
// Replace newlines with
|
4108
|
+
// Replace newlines with spaces and calculate the total length.
|
4107
4109
|
cellString = cellString.replace(/\n/g, ' ');
|
4108
4110
|
// Update the column width if the current cell's length is greater.
|
4109
4111
|
if (cellString.length > columnWidths[columnIndex]) {
|