Skip to content

Commit aaf0613

Browse files
Merge pull request #52 from Detaysoft/next
Next Version 0.8.2
2 parents 881ad74 + 9e92b2a commit aaf0613

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import { MessageBox } from 'react-chat-elements'
113113
| notch | true | boolean | message box notch |
114114
| avatar | none | url | message box avatar url |
115115
| renderAddCmp | none | function (component) | adding custom components to message box |
116+
| copiableDate | false | boolean | message box date text copiable |
116117

117118

118119
## SystemMessage Component

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "0.8.1",
3+
"version": "0.8.2",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/MessageBox/MessageBox.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
bottom: -5px;
9797
}
9898

99+
.rce-mbox-time.non-copiable:before {
100+
content: attr(data-text);
101+
}
102+
99103
.rce-mbox-time-block {
100104
/*position: relative;*/
101105
right: 0;

src/MessageBox/MessageBox.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export class MessageBox extends Component {
2525
var positionCls = classNames('rce-mbox', { 'rce-mbox-right': this.props.position === 'right' });
2626
var thatAbsoluteTime = this.props.type !== 'text' && this.props.type !== 'file' && !(this.props.type === 'location' && this.props.text);
2727

28+
29+
const dateText = this.props.date && !isNaN(this.props.date) && (
30+
this.props.dateString ||
31+
moment(this.props.date).fromNow()
32+
);
33+
2834
return (
2935
<div
3036
className={classNames('rce-container-mbox', this.props.className)}
@@ -130,8 +136,15 @@ export class MessageBox extends Component {
130136
uri={this.props.uri || this.props.text} />
131137
}
132138

133-
<div className={classNames('rce-mbox-time', { 'rce-mbox-time-block': thatAbsoluteTime })}>
139+
<div
140+
className={classNames(
141+
'rce-mbox-time',
142+
{ 'rce-mbox-time-block': thatAbsoluteTime },
143+
{ 'non-copiable': !this.props.copiableDate },
144+
)}
145+
data-text={this.props.copiableDate ? undefined : dateText}>
134146
{
147+
this.props.copiableDate &&
135148
this.props.date &&
136149
!isNaN(this.props.date) &&
137150
(
@@ -213,6 +226,7 @@ MessageBox.defaultProps = {
213226
notch: true,
214227
avatar: null,
215228
renderAddCmp: null,
229+
copiableDate: false,
216230
};
217231

218232

0 commit comments

Comments
 (0)