1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Add option to disable the automiatic deletion of un-referenced attachments -> might fix #3203

This commit is contained in:
ehhc
2019-08-26 18:07:04 +02:00
committed by Junyoung Choi
parent 857e75594d
commit cf324d93fe
5 changed files with 26 additions and 7 deletions

View File

@@ -70,7 +70,9 @@ export default class CodeEditor extends React.Component {
storageKey, storageKey,
noteKey noteKey
} = this.props } = this.props
debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey) if (this.props.deleteUnusedAttachments === true) {
debouncedDeletionOfAttachments(this.editor.getValue(), storageKey, noteKey)
}
} }
this.pasteHandler = (editor, e) => { this.pasteHandler = (editor, e) => {
e.preventDefault() e.preventDefault()
@@ -632,6 +634,9 @@ export default class CodeEditor extends React.Component {
this.editor.addPanel(this.createSpellCheckPanel(), {position: 'bottom'}) this.editor.addPanel(this.createSpellCheckPanel(), {position: 'bottom'})
} }
} }
if (prevProps.deleteUnusedAttachments !== this.props.deleteUnusedAttachments) {
this.editor.setOption('deleteUnusedAttachments', this.props.deleteUnusedAttachments)
}
if (needRefresh) { if (needRefresh) {
this.editor.refresh() this.editor.refresh()
@@ -1204,7 +1209,8 @@ CodeEditor.propTypes = {
autoDetect: PropTypes.bool, autoDetect: PropTypes.bool,
spellCheck: PropTypes.bool, spellCheck: PropTypes.bool,
enableMarkdownLint: PropTypes.bool, enableMarkdownLint: PropTypes.bool,
customMarkdownLintConfig: PropTypes.string customMarkdownLintConfig: PropTypes.string,
deleteUnusedAttachments: PropTypes.bool
} }
CodeEditor.defaultProps = { CodeEditor.defaultProps = {
@@ -1219,5 +1225,6 @@ CodeEditor.defaultProps = {
spellCheck: false, spellCheck: false,
enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint, enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint,
customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig, customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig,
prettierConfig: DEFAULT_CONFIG.editor.prettierConfig prettierConfig: DEFAULT_CONFIG.editor.prettierConfig,
deleteUnusedAttachments: DEFAULT_CONFIG.editor.deleteUnusedAttachments
} }

View File

@@ -324,6 +324,7 @@ class MarkdownEditor extends React.Component {
enableMarkdownLint={config.editor.enableMarkdownLint} enableMarkdownLint={config.editor.enableMarkdownLint}
customMarkdownLintConfig={config.editor.customMarkdownLintConfig} customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
prettierConfig={config.editor.prettierConfig} prettierConfig={config.editor.prettierConfig}
deleteUnusedAttachments={config.editor.deleteUnusedAttachments}
/> />
<MarkdownPreview styleName={this.state.status === 'PREVIEW' <MarkdownPreview styleName={this.state.status === 'PREVIEW'
? 'preview' ? 'preview'

View File

@@ -182,6 +182,7 @@ class MarkdownSplitEditor extends React.Component {
switchPreview={config.editor.switchPreview} switchPreview={config.editor.switchPreview}
enableMarkdownLint={config.editor.enableMarkdownLint} enableMarkdownLint={config.editor.enableMarkdownLint}
customMarkdownLintConfig={config.editor.customMarkdownLintConfig} customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
deleteUnusedAttachments={config.editor.deleteUnusedAttachments}
/> />
<div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} > <div styleName='slider' style={{left: this.state.codeEditorWidthInPercent + '%'}} onMouseDown={e => this.handleMouseDown(e)} >
<div styleName='slider-hitbox' /> <div styleName='slider-hitbox' />

View File

@@ -75,8 +75,8 @@ export const DEFAULT_CONFIG = {
"tabWidth": 4, "tabWidth": 4,
"semi": false, "semi": false,
"singleQuote": true "singleQuote": true
}` }`,
deleteUnusedAttachments: true
}, },
preview: { preview: {
fontSize: '14', fontSize: '14',

View File

@@ -111,8 +111,8 @@ class UiTab extends React.Component {
enableSmartPaste: this.refs.enableSmartPaste.checked, enableSmartPaste: this.refs.enableSmartPaste.checked,
enableMarkdownLint: this.refs.enableMarkdownLint.checked, enableMarkdownLint: this.refs.enableMarkdownLint.checked,
customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue(), customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue(),
prettierConfig: this.prettierConfigCM.getCodeMirror().getValue() prettierConfig: this.prettierConfigCM.getCodeMirror().getValue(),
deleteUnusedAttachments: this.refs.deleteUnusedAttachments.checked
}, },
preview: { preview: {
fontSize: this.refs.previewFontSize.value, fontSize: this.refs.previewFontSize.value,
@@ -618,6 +618,16 @@ class UiTab extends React.Component {
{i18n.__('Enable spellcheck - Experimental feature!! :)')} {i18n.__('Enable spellcheck - Experimental feature!! :)')}
</label> </label>
</div> </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'>
<div styleName='group-section-label'> <div styleName='group-section-label'>