mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
Add notification for copying snippets
This commit is contained in:
@@ -8,6 +8,8 @@ import SnippetList from './SnippetList'
|
|||||||
import eventEmitter from 'browser/main/lib/eventEmitter'
|
import eventEmitter from 'browser/main/lib/eventEmitter'
|
||||||
import copy from 'copy-to-clipboard'
|
import copy from 'copy-to-clipboard'
|
||||||
|
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
class SnippetTab extends React.Component {
|
class SnippetTab extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
@@ -17,6 +19,17 @@ class SnippetTab extends React.Component {
|
|||||||
this.changeDelay = null
|
this.changeDelay = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notify (title, options) {
|
||||||
|
if (global.process.platform === 'win32') {
|
||||||
|
options.icon = path.join(
|
||||||
|
'file://',
|
||||||
|
global.__dirname,
|
||||||
|
'../../resources/app.png'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return new window.Notification(title, options)
|
||||||
|
}
|
||||||
|
|
||||||
handleSnippetNameOrPrefixChange () {
|
handleSnippetNameOrPrefixChange () {
|
||||||
clearTimeout(this.changeDelay)
|
clearTimeout(this.changeDelay)
|
||||||
this.changeDelay = setTimeout(() => {
|
this.changeDelay = setTimeout(() => {
|
||||||
@@ -56,7 +69,14 @@ class SnippetTab extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleCopySnippet (e) {
|
handleCopySnippet (e) {
|
||||||
|
const showCopyNotification = this.props.config.ui.showCopyNotification
|
||||||
copy(this.state.currentSnippet.content)
|
copy(this.state.currentSnippet.content)
|
||||||
|
if (showCopyNotification) {
|
||||||
|
this.notify('Saved to Clipboard!', {
|
||||||
|
body: 'Paste it wherever you want!',
|
||||||
|
silent: true
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|||||||
Reference in New Issue
Block a user