From db4126f1ff4ca9f5db23febdf020bbab61b93746 Mon Sep 17 00:00:00 2001 From: ehhc Date: Mon, 26 Aug 2019 18:07:04 +0200 Subject: [PATCH] Add option to disable the automiatic deletion of un-referenced attachments -> might fix #3203 --- browser/components/CodeEditor.js | 13 ++++++++++--- browser/components/MarkdownEditor.js | 1 + browser/components/MarkdownSplitEditor.js | 1 + browser/main/lib/ConfigManager.js | 4 ++-- browser/main/modals/PreferencesModal/UiTab.js | 14 ++++++++++++-- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 4126e580c..4917db3bf 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -70,7 +70,9 @@ export default class CodeEditor extends React.Component { storageKey, noteKey } = this.props - debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey) + if (this.props.deleteUnusedAttachments === true) { + debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey) + } } this.pasteHandler = (editor, e) => { e.preventDefault() @@ -632,6 +634,9 @@ export default class CodeEditor extends React.Component { this.editor.addPanel(this.createSpellCheckPanel(), {position: 'bottom'}) } } + if (prevProps.deleteUnusedAttachments !== this.props.deleteUnusedAttachments) { + this.editor.setOption('deleteUnusedAttachments', this.props.deleteUnusedAttachments) + } if (needRefresh) { this.editor.refresh() @@ -1204,7 +1209,8 @@ CodeEditor.propTypes = { autoDetect: PropTypes.bool, spellCheck: PropTypes.bool, enableMarkdownLint: PropTypes.bool, - customMarkdownLintConfig: PropTypes.string + customMarkdownLintConfig: PropTypes.string, + deleteUnusedAttachments: PropTypes.bool } CodeEditor.defaultProps = { @@ -1219,5 +1225,6 @@ CodeEditor.defaultProps = { spellCheck: false, enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint, customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig, - prettierConfig: DEFAULT_CONFIG.editor.prettierConfig + prettierConfig: DEFAULT_CONFIG.editor.prettierConfig, + deleteUnusedAttachments: DEFAULT_CONFIG.editor.deleteUnusedAttachments } diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index c38aa99b4..cd885fd93 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -324,6 +324,7 @@ class MarkdownEditor extends React.Component { enableMarkdownLint={config.editor.enableMarkdownLint} customMarkdownLintConfig={config.editor.customMarkdownLintConfig} prettierConfig={config.editor.prettierConfig} + deleteUnusedAttachments={config.editor.deleteUnusedAttachments} />
this.handleMouseDown(e)} >
diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 7fba00d88..b753c5159 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -75,8 +75,8 @@ export const DEFAULT_CONFIG = { "tabWidth": 4, "semi": false, "singleQuote": true - }` - + }`, + deleteUnusedAttachments: true }, preview: { fontSize: '14', diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 9014de422..329dbfa42 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -111,8 +111,8 @@ class UiTab extends React.Component { enableSmartPaste: this.refs.enableSmartPaste.checked, enableMarkdownLint: this.refs.enableMarkdownLint.checked, customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue(), - prettierConfig: this.prettierConfigCM.getCodeMirror().getValue() - + prettierConfig: this.prettierConfigCM.getCodeMirror().getValue(), + deleteUnusedAttachments: this.refs.deleteUnusedAttachments.checked }, preview: { fontSize: this.refs.previewFontSize.value, @@ -618,6 +618,16 @@ class UiTab extends React.Component { {i18n.__('Enable spellcheck - Experimental feature!! :)')}
+
+ +