Skip to content

Commit

Permalink
Add option to disable the automiatic deletion of un-referenced attach…
Browse files Browse the repository at this point in the history
…ments -> might fix BoostIO#3203
  • Loading branch information
ehhc committed Aug 26, 2019
1 parent 857e755 commit db4126f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
13 changes: 10 additions & 3 deletions browser/components/CodeEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
}
1 change: 1 addition & 0 deletions browser/components/MarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
? 'preview'
Expand Down
1 change: 1 addition & 0 deletions browser/components/MarkdownSplitEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class MarkdownSplitEditor extends React.Component {
switchPreview={config.editor.switchPreview}
enableMarkdownLint={config.editor.enableMarkdownLint}
customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
deleteUnusedAttachments={config.editor.deleteUnusedAttachments}
/>
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
<div styleName='slider-hitbox' />
Expand Down
4 changes: 2 additions & 2 deletions browser/main/lib/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const DEFAULT_CONFIG = {
"tabWidth": 4,
"semi": false,
"singleQuote": true
}`

}`,
deleteUnusedAttachments: true
},
preview: {
fontSize: '14',
Expand Down
14 changes: 12 additions & 2 deletions browser/main/modals/PreferencesModal/UiTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -618,6 +618,16 @@ class UiTab extends React.Component {
{i18n.__('Enable spellcheck - Experimental feature!! :)')}
</label>
</div>
<div styleName='group-checkBoxSection'>
<label>
<input onChange={(e) => this.handleUIChange(e)}
checked={this.state.config.editor.deleteUnusedAttachments}
ref='deleteUnusedAttachments'
type='checkbox'
/>&nbsp;
{i18n.__('Delete attachments, that are not referenced in the text anymore')}
</label>
</div>

<div styleName='group-section'>
<div styleName='group-section-label'>
Expand Down

0 comments on commit db4126f

Please sign in to comment.