1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

FinderにCopy to clipboard button追加

This commit is contained in:
Rokt33r
2015-11-15 01:22:56 +09:00
parent fb1462f669
commit 3e980fd2d4
4 changed files with 51 additions and 8 deletions

View File

@@ -11,7 +11,16 @@ export default class FinderDetail extends React.Component {
return ( return (
<div className='FinderDetail'> <div className='FinderDetail'>
<div className='header'> <div className='header'>
<ModeIcon mode={activeArticle.mode}/> {activeArticle.title}</div> <div className='left'>
<ModeIcon mode={activeArticle.mode}/> {activeArticle.title}
</div>
<div className='right'>
<button onClick={this.props.saveToClipboard} className='clipboardBtn'>
<i className='fa fa-clipboard fa-fw'/>
<span className='tooltip'>Copy to clipboard (Enter)</span>
</button>
</div>
</div>
<div className='content'> <div className='content'>
{activeArticle.mode === 'markdown' {activeArticle.mode === 'markdown'
? <MarkdownPreview content={activeArticle.content}/> ? <MarkdownPreview content={activeArticle.content}/>
@@ -30,5 +39,6 @@ export default class FinderDetail extends React.Component {
} }
FinderDetail.propTypes = { FinderDetail.propTypes = {
activeArticle: PropTypes.shape() activeArticle: PropTypes.shape(),
saveToClipboard: PropTypes.func
} }

View File

@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title>CodeXen Popup</title> <title>Boost Finder</title>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>

View File

@@ -45,10 +45,7 @@ class FinderMain extends React.Component {
} }
if (e.keyCode === 13) { if (e.keyCode === 13) {
let { activeArticle } = this.props this.saveToClipboard()
clipboard.writeText(activeArticle.content)
activityRecord.emit('FINDER_COPY')
hideFinder()
e.preventDefault() e.preventDefault()
} }
if (e.keyCode === 27) { if (e.keyCode === 27) {
@@ -57,6 +54,13 @@ class FinderMain extends React.Component {
} }
} }
saveToClipboard () {
let { activeArticle } = this.props
clipboard.writeText(activeArticle.content)
activityRecord.emit('FINDER_COPY')
hideFinder()
}
handleSearchChange (e) { handleSearchChange (e) {
let { dispatch } = this.props let { dispatch } = this.props
@@ -83,6 +87,7 @@ class FinderMain extends React.Component {
render () { render () {
let { articles, activeArticle, status, dispatch } = this.props let { articles, activeArticle, status, dispatch } = this.props
let saveToClipboard = () => this.saveToClipboard()
return ( return (
<div onClick={e => this.handleClick(e)} onKeyDown={e => this.handleKeyDown(e)} className='Finder'> <div onClick={e => this.handleClick(e)} onKeyDown={e => this.handleKeyDown(e)} className='Finder'>
<FinderInput <FinderInput
@@ -98,7 +103,10 @@ class FinderMain extends React.Component {
dispatch={dispatch} dispatch={dispatch}
selectArticle={article => this.selectArticle(article)} selectArticle={article => this.selectArticle(article)}
/> />
<FinderDetail activeArticle={activeArticle}/> <FinderDetail
activeArticle={activeArticle}
saveToClipboard={saveToClipboard}
/>
</div> </div>
) )
} }

View File

@@ -79,6 +79,31 @@ body
white-space nowrap white-space nowrap
text-overflow ellipsis text-overflow ellipsis
overflow-x hidden overflow-x hidden
clearfix()
.left
float left
.right
float right
button
border-radius 16.5px
cursor pointer
height 33px
width 33px
border none
margin-right 5px
font-size 18px
color inactiveTextColor
background-color transparent
padding 0
.tooltip
tooltip()
&.clipboardBtn .tooltip
margin-left -160px
margin-top 25px
&:hover
color textColor
.tooltip
opacity 1
.content .content
position absolute position absolute
top 55px top 55px