1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

Added markdownlint rules form

This commit is contained in:
roottool
2019-04-29 03:23:25 +09:00
parent 03b1adca12
commit 788900e31a
3 changed files with 30 additions and 3 deletions

View File

@@ -26,6 +26,7 @@ import {languageMaps} from '../lib/CMLanguageList'
import snippetManager from '../lib/SnippetManager' import snippetManager from '../lib/SnippetManager'
import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-generator' import {generateInEditor, tocExistsInEditor} from 'browser/lib/markdown-toc-generator'
import markdownlint from 'markdownlint' import markdownlint from 'markdownlint'
import ConfigManager from '../main/lib/ConfigManager'
CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js' CodeMirror.modeURL = '../node_modules/codemirror/mode/%N/%N.js'
@@ -39,11 +40,14 @@ function translateHotkey (hotkey) {
} }
const validatorOfMarkdown = (text, updateLinting) => { const validatorOfMarkdown = (text, updateLinting) => {
const config = ConfigManager.get()
const lintOptions = { const lintOptions = {
'strings': { 'strings': {
'content': text 'content': text
} },
'config': JSON.parse(config.editor.customMarkdownLintConfig)
} }
console.log(config.editor.customMarkdownLintConfig)
return markdownlint(lintOptions, (err, result) => { return markdownlint(lintOptions, (err, result) => {
if (!err) { if (!err) {

View File

@@ -59,7 +59,8 @@ export const DEFAULT_CONFIG = {
enableFrontMatterTitle: true, enableFrontMatterTitle: true,
frontMatterTitleField: 'title', frontMatterTitleField: 'title',
spellcheck: false, spellcheck: false,
enableSmartPaste: false enableSmartPaste: false,
customMarkdownLintConfig: ''
}, },
preview: { preview: {
fontSize: '14', fontSize: '14',

View File

@@ -30,7 +30,9 @@ class UiTab extends React.Component {
componentDidMount () { componentDidMount () {
CodeMirror.autoLoadMode(this.codeMirrorInstance.getCodeMirror(), 'javascript') CodeMirror.autoLoadMode(this.codeMirrorInstance.getCodeMirror(), 'javascript')
CodeMirror.autoLoadMode(this.customCSSCM.getCodeMirror(), 'css') CodeMirror.autoLoadMode(this.customCSSCM.getCodeMirror(), 'css')
CodeMirror.autoLoadMode(this.customMarkdownLintConfigCM.getCodeMirror(), 'json')
this.customCSSCM.getCodeMirror().setSize('400px', '400px') this.customCSSCM.getCodeMirror().setSize('400px', '400px')
this.customMarkdownLintConfigCM.getCodeMirror().setSize('400px', '400px')
this.handleSettingDone = () => { this.handleSettingDone = () => {
this.setState({UiAlert: { this.setState({UiAlert: {
type: 'success', type: 'success',
@@ -101,7 +103,8 @@ class UiTab extends React.Component {
matchingTriples: this.refs.matchingTriples.value, matchingTriples: this.refs.matchingTriples.value,
explodingPairs: this.refs.explodingPairs.value, explodingPairs: this.refs.explodingPairs.value,
spellcheck: this.refs.spellcheck.checked, spellcheck: this.refs.spellcheck.checked,
enableSmartPaste: this.refs.enableSmartPaste.checked enableSmartPaste: this.refs.enableSmartPaste.checked,
customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue()
}, },
preview: { preview: {
fontSize: this.refs.previewFontSize.value, fontSize: this.refs.previewFontSize.value,
@@ -632,6 +635,25 @@ class UiTab extends React.Component {
/> />
</div> </div>
</div> </div>
<div styleName='group-section'>
<div styleName='group-section-label'>
{i18n.__('Custom MarkdownLint Rules')}
</div>
<div styleName='group-section-control'>
<div style={{fontFamily}}>
<ReactCodeMirror
width='400px'
height='400px'
onChange={e => this.handleUIChange(e)}
ref={e => (this.customMarkdownLintConfigCM = e)}
value={config.editor.customMarkdownLintConfig}
options={{
lineNumbers: true,
theme: codemirrorTheme
}} />
</div>
</div>
</div>
<div styleName='group-header2'>{i18n.__('Preview')}</div> <div styleName='group-header2'>{i18n.__('Preview')}</div>
<div styleName='group-section'> <div styleName='group-section'>