From 3e2a366dc6084ec99e7ba85009be1bda019a8781 Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Sun, 30 Sep 2018 16:57:58 -0500 Subject: [PATCH 1/2] Add a Copy button the Snippets tab --- browser/main/modals/PreferencesModal/SnippetTab.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/browser/main/modals/PreferencesModal/SnippetTab.js b/browser/main/modals/PreferencesModal/SnippetTab.js index e35ecd69..f16bac7b 100644 --- a/browser/main/modals/PreferencesModal/SnippetTab.js +++ b/browser/main/modals/PreferencesModal/SnippetTab.js @@ -6,6 +6,7 @@ import i18n from 'browser/lib/i18n' import dataApi from 'browser/main/lib/dataApi' import SnippetList from './SnippetList' import eventEmitter from 'browser/main/lib/eventEmitter' +import copy from 'copy-to-clipboard' class SnippetTab extends React.Component { constructor (props) { @@ -54,6 +55,10 @@ class SnippetTab extends React.Component { } } + handleCopySnippet (e) { + copy(this.state.currentSnippet.content) + } + render () { const { config, storageKey } = this.props const { currentSnippet } = this.state @@ -70,6 +75,13 @@ class SnippetTab extends React.Component { onSnippetDeleted={this.handleDeleteSnippet.bind(this)} currentSnippet={currentSnippet} />
+
+
+ +
+
{i18n.__('Snippet name')}
From 33b40bf35fbd04e1895ca74598716a6a0bbfca2f Mon Sep 17 00:00:00 2001 From: jacobherrington Date: Tue, 2 Oct 2018 05:26:30 -0500 Subject: [PATCH 2/2] Add notification for copying snippets --- .../modals/PreferencesModal/SnippetTab.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/browser/main/modals/PreferencesModal/SnippetTab.js b/browser/main/modals/PreferencesModal/SnippetTab.js index f16bac7b..460d33d6 100644 --- a/browser/main/modals/PreferencesModal/SnippetTab.js +++ b/browser/main/modals/PreferencesModal/SnippetTab.js @@ -8,6 +8,8 @@ import SnippetList from './SnippetList' import eventEmitter from 'browser/main/lib/eventEmitter' import copy from 'copy-to-clipboard' +const path = require('path') + class SnippetTab extends React.Component { constructor (props) { super(props) @@ -17,6 +19,17 @@ class SnippetTab extends React.Component { 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 () { clearTimeout(this.changeDelay) this.changeDelay = setTimeout(() => { @@ -56,7 +69,14 @@ class SnippetTab extends React.Component { } handleCopySnippet (e) { + const showCopyNotification = this.props.config.ui.showCopyNotification copy(this.state.currentSnippet.content) + if (showCopyNotification) { + this.notify('Saved to Clipboard!', { + body: 'Paste it wherever you want!', + silent: true + }) + } } render () {