Skip to content

Commit 8b3854b

Browse files
committed
add renderLastLine method to overriding if it need
1 parent 373aa7a commit 8b3854b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Truncate.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ export default class Truncate extends Component {
171171
const {
172172
elements,
173173
props: {
174-
lines: numLines,
175-
ellipsis
174+
lines: numLines
176175
},
177176
state: {
178177
targetWidth
179178
},
180179
innerText,
181180
measureWidth,
181+
renderLastLine,
182182
onTruncate
183183
} = this;
184184

@@ -230,7 +230,7 @@ export default class Truncate extends Component {
230230
}
231231
}
232232

233-
resultLine = <span>{textRest.slice(0, lower)}{ellipsis}</span>;
233+
resultLine = renderLastLine(textRest.slice(0, lower), textWords);
234234
} else {
235235
// Binary search determining when the line breaks
236236
let lower = 0;
@@ -284,6 +284,11 @@ export default class Truncate extends Component {
284284
}
285285
}
286286

287+
renderLastLine(splicedText, originalArray) {
288+
const { ellipsis } = this.props;
289+
return (<span>{splicedText}{ellipsis}</span>);
290+
}
291+
287292
render() {
288293
const {
289294
elements: {

0 commit comments

Comments
 (0)