diff --git a/browser/components/MarkdownEditor.js b/browser/components/MarkdownEditor.js index 2c98f18e..2bd5d951 100644 --- a/browser/components/MarkdownEditor.js +++ b/browser/components/MarkdownEditor.js @@ -283,6 +283,7 @@ class MarkdownEditor extends React.Component { indentSize={editorIndentSize} scrollPastEnd={config.preview.scrollPastEnd} smartQuotes={config.preview.smartQuotes} + breaks={config.preview.breaks} sanitize={config.preview.sanitize} ref='preview' onContextMenu={(e) => this.handleContextMenu(e)} diff --git a/browser/components/MarkdownPreview.js b/browser/components/MarkdownPreview.js index 6646f749..ea5f11c0 100755 --- a/browser/components/MarkdownPreview.js +++ b/browser/components/MarkdownPreview.js @@ -145,10 +145,11 @@ export default class MarkdownPreview extends React.Component { } initMarkdown () { - const { smartQuotes, sanitize } = this.props + const { smartQuotes, sanitize, breaks } = this.props this.markdown = new Markdown({ typographer: smartQuotes, - sanitize + sanitize, + breaks }) } @@ -340,7 +341,9 @@ export default class MarkdownPreview extends React.Component { componentDidUpdate (prevProps) { if (prevProps.value !== this.props.value) this.rewriteIframe() - if (prevProps.smartQuotes !== this.props.smartQuotes || prevProps.sanitize !== this.props.sanitize) { + if (prevProps.smartQuotes !== this.props.smartQuotes || + prevProps.sanitize !== this.props.sanitize || + prevProps.breaks !== this.props.breaks) { this.initMarkdown() this.rewriteIframe() } @@ -599,5 +602,6 @@ MarkdownPreview.propTypes = { value: PropTypes.string, showCopyNotification: PropTypes.bool, storagePath: PropTypes.string, - smartQuotes: PropTypes.bool + smartQuotes: PropTypes.bool, + breaks: PropTypes.bool } diff --git a/browser/components/MarkdownSplitEditor.js b/browser/components/MarkdownSplitEditor.js index 27505a5a..2bee5c24 100644 --- a/browser/components/MarkdownSplitEditor.js +++ b/browser/components/MarkdownSplitEditor.js @@ -131,6 +131,7 @@ class MarkdownSplitEditor extends React.Component { lineNumber={config.preview.lineNumber} scrollPastEnd={config.preview.scrollPastEnd} smartQuotes={config.preview.smartQuotes} + breaks={config.preview.breaks} sanitize={config.preview.sanitize} ref='preview' tabInde='0' diff --git a/browser/lib/markdown.js b/browser/lib/markdown.js index 5848aeea..b9e1a3eb 100644 --- a/browser/lib/markdown.js +++ b/browser/lib/markdown.js @@ -25,7 +25,7 @@ class Markdown { linkify: true, html: true, xhtmlOut: true, - breaks: true, + breaks: config.preview.breaks, highlight: function (str, lang) { const delimiter = ':' const langInfo = lang.split(delimiter) diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 79fe0f5f..8a46911e 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -56,6 +56,7 @@ export const DEFAULT_CONFIG = { plantUMLServerAddress: 'http://www.plantuml.com/plantuml', scrollPastEnd: false, smartQuotes: true, + breaks: true, sanitize: 'STRICT' // 'STRICT', 'ALLOW_STYLES', 'NONE' }, blog: { diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index d8d236b4..1373cf94 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -5,6 +5,7 @@ const findStorage = require('browser/lib/findStorage') const mdurl = require('mdurl') const fse = require('fs-extra') const escapeStringRegexp = require('escape-string-regexp') +const sander = require('sander') const STORAGE_FOLDER_PLACEHOLDER = ':storage' const DESTINATION_FOLDER = 'attachments' @@ -213,6 +214,17 @@ function removeStorageAndNoteReferences (input, noteKey) { return input.replace(new RegExp(mdurl.encode(path.sep), 'g'), path.sep).replace(new RegExp(STORAGE_FOLDER_PLACEHOLDER + escapeStringRegexp(path.sep) + noteKey, 'g'), DESTINATION_FOLDER) } +/** + * @description Deletes the attachment folder specified by the given storageKey and noteKey + * @param storageKey Key of the storage of the note to be deleted + * @param noteKey Key of the note to be deleted + */ +function deleteAttachmentFolder (storageKey, noteKey) { + const storagePath = findStorage.findStorage(storageKey) + const noteAttachmentPath = path.join(storagePath.path, DESTINATION_FOLDER, noteKey) + sander.rimrafSync(noteAttachmentPath) +} + /** * @description Deletes all attachments stored in the attachment folder of the give not that are not referenced in the markdownContent * @param markdownContent Content of the note. All unreferenced notes will be deleted @@ -265,6 +277,7 @@ module.exports = { getAttachmentsInContent, getAbsolutePathsOfAttachmentsInContent, removeStorageAndNoteReferences, + deleteAttachmentFolder, deleteAttachmentsNotPresentInNote, moveAttachments, STORAGE_FOLDER_PLACEHOLDER, diff --git a/browser/main/lib/dataApi/deleteNote.js b/browser/main/lib/dataApi/deleteNote.js index 49498a30..46ec2b55 100644 --- a/browser/main/lib/dataApi/deleteNote.js +++ b/browser/main/lib/dataApi/deleteNote.js @@ -1,6 +1,7 @@ const resolveStorageData = require('./resolveStorageData') const path = require('path') const sander = require('sander') +const attachmentManagement = require('./attachmentManagement') const { findStorage } = require('browser/lib/findStorage') function deleteNote (storageKey, noteKey) { @@ -25,6 +26,10 @@ function deleteNote (storageKey, noteKey) { storageKey } }) + .then(function deleteAttachments (storageInfo) { + attachmentManagement.deleteAttachmentFolder(storageInfo.storageKey, storageInfo.noteKey) + return storageInfo + }) } module.exports = deleteNote diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 1bbcb18d..d2a2f178 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -97,6 +97,7 @@ class UiTab extends React.Component { plantUMLServerAddress: this.refs.previewPlantUMLServerAddress.value, scrollPastEnd: this.refs.previewScrollPastEnd.checked, smartQuotes: this.refs.previewSmartQuotes.checked, + breaks: this.refs.previewBreaks.checked, sanitize: this.refs.previewSanitize.value } } @@ -476,6 +477,16 @@ class UiTab extends React.Component { Enable smart quotes +
This is the first line.
␊
+ This is the second line.
This is the first line.␊ + This is the second line.
␊ + ` + ## Markdown.render() should renders KaTeX correctly > Snapshot 1 diff --git a/tests/lib/snapshots/markdown-test.js.snap b/tests/lib/snapshots/markdown-test.js.snap index 71ff221d..fc310cfd 100644 Binary files a/tests/lib/snapshots/markdown-test.js.snap and b/tests/lib/snapshots/markdown-test.js.snap differ