Skip to content

Commit eba1946

Browse files
committed
add copy button
1 parent 65c78df commit eba1946

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

browser/main/HomePage/ArticleDetail.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import TagSelect from 'boost/components/TagSelect'
2525
import ModeSelect from 'boost/components/ModeSelect'
2626
import activityRecord from 'boost/activityRecord'
2727

28+
const electron = require('electron')
29+
const clipboard = electron.clipboard
30+
2831
const BRAND_COLOR = '#18AF90'
2932

3033
const editDeleteTutorialElement = (
@@ -84,6 +87,10 @@ const modeSelectTutorialElement = (
8487
</svg>
8588
)
8689

90+
function notify (...args) {
91+
return new window.Notification(...args)
92+
}
93+
8794
function makeInstantArticle (article) {
8895
return Object.assign({}, article)
8996
}
@@ -154,6 +161,13 @@ export default class ArticleDetail extends React.Component {
154161
)
155162
}
156163

164+
handleClipboardButtonClick (e) {
165+
clipboard.writeText(this.props.activeArticle.content)
166+
notify('Saved to Clipboard!', {
167+
body: 'Paste it wherever you want!'
168+
})
169+
}
170+
157171
handleEditButtonClick (e) {
158172
let { dispatch } = this.props
159173
dispatch(switchMode(EDIT_MODE))
@@ -219,6 +233,9 @@ export default class ArticleDetail extends React.Component {
219233
<div className='tags'><i className='fa fa-fw fa-tags'/>{tags}</div>
220234
</div>
221235
<div className='right'>
236+
<button onClick={e => this.handleClipboardButtonClick(e)} className='editBtn'>
237+
<i className='fa fa-fw fa-clipboard'/><span className='tooltip'>Copy to clipboard</span>
238+
</button>
222239
<button onClick={e => this.handleEditButtonClick(e)} className='editBtn'>
223240
<i className='fa fa-fw fa-edit'/><span className='tooltip'>Edit (e)</span>
224241
</button>

0 commit comments

Comments
 (0)