diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index 2f2b1551..667708a4 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -26,6 +26,7 @@ import {languageMaps} from '../lib/CMLanguageList' import snippetManager from '../lib/SnippetManager' import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-generator' import markdownlint from 'markdownlint' +import ConfigManager from '../main/lib/ConfigManager' CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' @@ -39,11 +40,14 @@ function translateHotkey (hotkey) { } const validatorOfMarkdown = (text, updateLinting) => { + const config = ConfigManager.get() const lintOptions = { 'strings': { 'content': text - } + }, + 'config': JSON.parse(config.editor.customMarkdownLintConfig) } + console.log(config.editor.customMarkdownLintConfig) return markdownlint(lintOptions, (err, result) => { if (!err) { diff --git a/browser/main/lib/ConfigManager.js b/browser/main/lib/ConfigManager.js index 05f3d822..616fdc88 100644 --- a/browser/main/lib/ConfigManager.js +++ b/browser/main/lib/ConfigManager.js @@ -59,7 +59,8 @@ export const DEFAULT_CONFIG = { enableFrontMatterTitle: true, frontMatterTitleField: 'title', spellcheck: false, - enableSmartPaste: false + enableSmartPaste: false, + customMarkdownLintConfig: '' }, preview: { fontSize: '14', diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 316b7f9d..310e1e59 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -30,7 +30,9 @@ class UiTab extends React.Component { componentDidMount () { CodeMirror.autoLoadMode(this.codeMirrorInstance.getCodeMirror(), 'javascript') CodeMirror.autoLoadMode(this.customCSSCM.getCodeMirror(), 'css') + CodeMirror.autoLoadMode(this.customMarkdownLintConfigCM.getCodeMirror(), 'json') this.customCSSCM.getCodeMirror().setSize('400px', '400px') + this.customMarkdownLintConfigCM.getCodeMirror().setSize('400px', '400px') this.handleSettingDone = () => { this.setState({UiAlert: { type: 'success', @@ -101,7 +103,8 @@ class UiTab extends React.Component { matchingTriples: this.refs.matchingTriples.value, explodingPairs: this.refs.explodingPairs.value, spellcheck: this.refs.spellcheck.checked, - enableSmartPaste: this.refs.enableSmartPaste.checked + enableSmartPaste: this.refs.enableSmartPaste.checked, + customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue() }, preview: { fontSize: this.refs.previewFontSize.value, @@ -632,6 +635,25 @@ class UiTab extends React.Component { /> +
+
+ {i18n.__('Custom MarkdownLint Rules')} +
+
+
+ this.handleUIChange(e)} + ref={e => (this.customMarkdownLintConfigCM = e)} + value={config.editor.customMarkdownLintConfig} + options={{ + lineNumbers: true, + theme: codemirrorTheme + }} /> +
+
+
{i18n.__('Preview')}