From ebdd6d77f7dbda65383d262fd9b8916db4ee38ab Mon Sep 17 00:00:00 2001 From: Peter Urda Date: Sun, 1 Oct 2017 02:48:54 -0700 Subject: [PATCH] Allow users to disable "Saved to clipboard" notification. --- browser/components/MarkdownEditor.js | 1 + browser/components/MarkdownPreview.js | 14 +++++++++----- browser/finder/NoteDetail.js | 1 + browser/main/lib/ConfigManager.js | 1 + browser/main/modals/PreferencesModal/UiTab.js | 11 +++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index f20ec087..65b52f86 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -266,6 +266,7 @@ class MarkdownEditor extends React.Component { onMouseUp={(e) => this.handlePreviewMouseUp(e)} onMouseDown={(e) => this.handlePreviewMouseDown(e)} onCheckboxClick={(e) => this.handleCheckboxClick(e)} + showCopyNotification={config.ui.showCopyNotification} storagePath={storage.path} /> diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 2fb190bb..8bee23a5 100644 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -223,6 +223,7 @@ export default class MarkdownPreview extends React.Component { prevProps.codeBlockFontFamily !== this.props.codeBlockFontFamily || prevProps.codeBlockTheme !== this.props.codeBlockTheme || prevProps.lineNumber !== this.props.lineNumber || + prevProps.showCopyNotification !== this.props.showCopyNotification || prevProps.theme !== this.props.theme) { this.applyStyle() this.rewriteIframe() @@ -261,7 +262,7 @@ export default class MarkdownPreview extends React.Component { el.removeEventListener('click', this.linkClickHandler) }) - let { value, theme, indentSize, codeBlockTheme, storagePath } = this.props + let { value, theme, indentSize, codeBlockTheme, showCopyNotification, storagePath } = this.props this.refs.root.contentWindow.document.body.setAttribute('data-theme', theme) @@ -308,10 +309,12 @@ export default class MarkdownPreview extends React.Component { copyIcon.innerHTML = '' copyIcon.onclick = (e) => { copy(content) - this.notify('Saved to Clipboard!', { - body: 'Paste it wherever you want!', - silent: true - }) + if (showCopyNotification) { + this.notify('Saved to Clipboard!', { + body: 'Paste it wherever you want!', + silent: true + }) + } } el.parentNode.appendChild(copyIcon) el.innerHTML = '' @@ -425,5 +428,6 @@ MarkdownPreview.propTypes = { onMouseDown: PropTypes.func, className: PropTypes.string, value: PropTypes.string, + showCopyNotification: PropTypes.bool, storagePath: PropTypes.string } diff --git a/browser/finder/NoteDetail.js b/browser/finder/NoteDetail.js index 1539a8af..6fda851e 100644 --- a/browser/finder/NoteDetail.js +++ b/browser/finder/NoteDetail.js @@ -196,6 +196,7 @@ class NoteDetail extends React.Component { lineNumber={config.preview.lineNumber} indentSize={editorIndentSize} value={note.content} + showCopyNotification={config.ui.showCopyNotification} storagePath={storage.path} /> ) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 543c7e5b..fd374cf1 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -25,6 +25,7 @@ export const DEFAULT_CONFIG = { }, ui: { theme: 'default', + showCopyNotification: true, disableDirectWrite: false, defaultNote: 'ALWAYS_ASK' // 'ALWAYS_ASK', 'SNIPPET_NOTE', 'MARKDOWN_NOTE' }, diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 7bbd3e8c..217306f6 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -36,6 +36,7 @@ class UiTab extends React.Component { const newConfig = { ui: { theme: this.refs.uiTheme.value, + showCopyNotification: this.refs.showCopyNotification.checked, disableDirectWrite: this.refs.uiD2w != null ? this.refs.uiD2w.checked : false @@ -102,6 +103,16 @@ class UiTab extends React.Component { +
+ +
{ global.process.platform === 'win32' ?