@@ -25,6 +25,7 @@ function Clampy(props) {
2525 const options = {
2626 clamp : props . clampSize ,
2727 truncationChar : props . truncationChar ,
28+ splitOnChars : props . splitOnChars ,
2829 // truncationHTML: truncationHTML,
2930 // Clampy will try to use native clamp if available in the browser
3031 // however this can leads to unexpected results so we need to explicitely
@@ -40,7 +41,7 @@ function Clampy(props) {
4041 clampy . clamp ( containerRef . current , options ) ;
4142 setOpacity ( 1 ) ;
4243 }
43- } , [ initialContent , props . clampSize , props . truncationChar ] ) ;
44+ } , [ initialContent , props . clampSize , props . truncationChar , props . splitOnChars ] ) ;
4445
4546 useEffect ( ( ) => {
4647 truncate ( ) ;
@@ -72,12 +73,14 @@ function Clampy(props) {
7273Clampy . propTypes = {
7374 children : PropTypes . node ,
7475 clampSize : PropTypes . string ,
75- truncationChar : PropTypes . string
76+ truncationChar : PropTypes . string ,
77+ splitOnChars : PropTypes . array
7678} ;
7779
7880Clampy . defaultProps = {
7981 clampSize : "auto" , // Default clamp size based on available height
80- truncationChar : "…"
82+ truncationChar : "…" ,
83+ splitOnChars : [ '.' , '-' , '–' , '—' , ' ' ] ,
8184 // truncationHTML: ''
8285} ;
8386
0 commit comments