@topconsultnpm/sdkui-react-beta 6.8.23 → 6.8.24
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.
|
@@ -70,10 +70,21 @@ const TMTextArea = (props) => {
|
|
|
70
70
|
const textareaWidth = inputRef.current.offsetWidth;
|
|
71
71
|
const charWidth = 8;
|
|
72
72
|
const maxCharsPerLine = Math.floor(textareaWidth / charWidth);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
// Split content into lines by line breaks (`\n`)
|
|
74
|
+
const lines = content.split('\n');
|
|
75
|
+
// Calculate total rows by considering lines and their character lengths
|
|
76
|
+
let totalRows = 0;
|
|
77
|
+
lines.forEach(line => {
|
|
78
|
+
// Every line, regardless of length, contributes at least one row
|
|
79
|
+
totalRows += Math.ceil(line.length / maxCharsPerLine);
|
|
80
|
+
});
|
|
81
|
+
// If the last line is empty, it should still count as a row
|
|
82
|
+
// This handles cases where you press "Enter" at the end (i.e., the last line is empty)
|
|
83
|
+
if (content.endsWith('\n')) {
|
|
84
|
+
totalRows += 1;
|
|
85
|
+
}
|
|
86
|
+
// Return the number of rows, limiting to a maximum of 10
|
|
87
|
+
return Math.min(totalRows, 10);
|
|
77
88
|
};
|
|
78
89
|
// Inserts text at the cursor position
|
|
79
90
|
const insertText = (textToInsert) => {
|