mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
WIP: Add MarkdownLint enable setting. Gutter toggle not working as expected.
This commit is contained in:
@@ -40,6 +40,8 @@ function translateHotkey (hotkey) {
|
|||||||
return hotkey.replace(/\s*\+\s*/g, '-').replace(/Command/g, 'Cmd').replace(/Control/g, 'Ctrl')
|
return hotkey.replace(/\s*\+\s*/g, '-').replace(/Command/g, 'Cmd').replace(/Control/g, 'Ctrl')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DEFAULT_GUTTERS = ['CodeMirror-linenumbers', 'CodeMirror-foldgutter']
|
||||||
|
|
||||||
export default class CodeEditor extends React.Component {
|
export default class CodeEditor extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
super(props)
|
super(props)
|
||||||
@@ -255,7 +257,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { rulers, enableRulers } = this.props
|
const { rulers, enableRulers, enableMarkdownLint } = this.props
|
||||||
eventEmitter.on('line:jump', this.scrollToLineHandeler)
|
eventEmitter.on('line:jump', this.scrollToLineHandeler)
|
||||||
|
|
||||||
snippetManager.init()
|
snippetManager.init()
|
||||||
@@ -277,8 +279,8 @@ export default class CodeEditor extends React.Component {
|
|||||||
inputStyle: 'textarea',
|
inputStyle: 'textarea',
|
||||||
dragDrop: false,
|
dragDrop: false,
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
lint: this.setCodeEditorLintConfig(),
|
lint: enableMarkdownLint ? this.setCodeEditorLintConfig() : false,
|
||||||
gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter', 'CodeMirror-lint-markers'],
|
gutters: [...DEFAULT_GUTTERS, enableMarkdownLint && 'CodeMirror-lint-markers'],
|
||||||
autoCloseBrackets: {
|
autoCloseBrackets: {
|
||||||
pairs: this.props.matchingPairs,
|
pairs: this.props.matchingPairs,
|
||||||
triples: this.props.matchingTriples,
|
triples: this.props.matchingTriples,
|
||||||
@@ -515,6 +517,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
const {
|
const {
|
||||||
rulers,
|
rulers,
|
||||||
enableRulers,
|
enableRulers,
|
||||||
|
enableMarkdownLint,
|
||||||
customMarkdownLintConfig
|
customMarkdownLintConfig
|
||||||
} = this.props
|
} = this.props
|
||||||
if (prevProps.mode !== this.props.mode) {
|
if (prevProps.mode !== this.props.mode) {
|
||||||
@@ -533,8 +536,14 @@ export default class CodeEditor extends React.Component {
|
|||||||
if (prevProps.keyMap !== this.props.keyMap) {
|
if (prevProps.keyMap !== this.props.keyMap) {
|
||||||
needRefresh = true
|
needRefresh = true
|
||||||
}
|
}
|
||||||
if (prevProps.customMarkdownLintConfig !== customMarkdownLintConfig) {
|
if (prevProps.enableMarkdownLint !== enableMarkdownLint || prevProps.customMarkdownLintConfig !== customMarkdownLintConfig) {
|
||||||
this.editor.setOption('lint', this.setCodeEditorLintConfig())
|
if (!enableMarkdownLint) {
|
||||||
|
this.editor.setOption('lint', {default: false})
|
||||||
|
this.editor.setOption('gutters', DEFAULT_GUTTERS)
|
||||||
|
} else {
|
||||||
|
this.editor.setOption('lint', this.setCodeEditorLintConfig())
|
||||||
|
this.editor.setOption('gutters', [...DEFAULT_GUTTERS, 'CodeMirror-lint-markers'])
|
||||||
|
}
|
||||||
|
|
||||||
needRefresh = true
|
needRefresh = true
|
||||||
}
|
}
|
||||||
@@ -1128,13 +1137,11 @@ export default class CodeEditor extends React.Component {
|
|||||||
}
|
}
|
||||||
ref='root'
|
ref='root'
|
||||||
tabIndex='-1'
|
tabIndex='-1'
|
||||||
style={
|
style={{
|
||||||
{
|
|
||||||
fontFamily,
|
fontFamily,
|
||||||
fontSize: fontSize,
|
fontSize: fontSize,
|
||||||
width: width
|
width: width
|
||||||
}
|
}}
|
||||||
}
|
|
||||||
onDrop={
|
onDrop={
|
||||||
e => this.handleDropImage(e)
|
e => this.handleDropImage(e)
|
||||||
}
|
}
|
||||||
@@ -1173,6 +1180,7 @@ CodeEditor.propTypes = {
|
|||||||
readOnly: PropTypes.bool,
|
readOnly: PropTypes.bool,
|
||||||
autoDetect: PropTypes.bool,
|
autoDetect: PropTypes.bool,
|
||||||
spellCheck: PropTypes.bool,
|
spellCheck: PropTypes.bool,
|
||||||
|
enableMarkdownLint: PropTypes.bool,
|
||||||
customMarkdownLintConfig: PropTypes.string
|
customMarkdownLintConfig: PropTypes.string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1186,5 +1194,6 @@ CodeEditor.defaultProps = {
|
|||||||
indentType: 'space',
|
indentType: 'space',
|
||||||
autoDetect: false,
|
autoDetect: false,
|
||||||
spellCheck: false,
|
spellCheck: false,
|
||||||
|
enableMarkdownLint: DEFAULT_CONFIG.editor.enableMarkdownLint,
|
||||||
customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig
|
customMarkdownLintConfig: DEFAULT_CONFIG.editor.customMarkdownLintConfig
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ class MarkdownEditor extends React.Component {
|
|||||||
enableSmartPaste={config.editor.enableSmartPaste}
|
enableSmartPaste={config.editor.enableSmartPaste}
|
||||||
hotkey={config.hotkey}
|
hotkey={config.hotkey}
|
||||||
switchPreview={config.editor.switchPreview}
|
switchPreview={config.editor.switchPreview}
|
||||||
|
enableMarkdownLint={config.editor.enableMarkdownLint}
|
||||||
customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
|
customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
|
||||||
/>
|
/>
|
||||||
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
|
<MarkdownPreview styleName={this.state.status === 'PREVIEW'
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ class MarkdownSplitEditor extends React.Component {
|
|||||||
enableSmartPaste={config.editor.enableSmartPaste}
|
enableSmartPaste={config.editor.enableSmartPaste}
|
||||||
hotkey={config.hotkey}
|
hotkey={config.hotkey}
|
||||||
switchPreview={config.editor.switchPreview}
|
switchPreview={config.editor.switchPreview}
|
||||||
|
enableMarkdownLint={config.editor.enableMarkdownLint}
|
||||||
customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
|
customMarkdownLintConfig={config.editor.customMarkdownLintConfig}
|
||||||
/>
|
/>
|
||||||
<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)} >
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
frontMatterTitleField: 'title',
|
frontMatterTitleField: 'title',
|
||||||
spellcheck: false,
|
spellcheck: false,
|
||||||
enableSmartPaste: false,
|
enableSmartPaste: false,
|
||||||
|
enableMarkdownLint: false,
|
||||||
customMarkdownLintConfig: DEFAULT_MARKDOWN_LINT_CONFIG
|
customMarkdownLintConfig: DEFAULT_MARKDOWN_LINT_CONFIG
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class UiTab extends React.Component {
|
|||||||
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,
|
||||||
|
enableMarkdownLint: this.refs.enableMarkdownLint.checked,
|
||||||
customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue()
|
customMarkdownLintConfig: this.customMarkdownLintConfigCM.getCodeMirror().getValue()
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
@@ -599,6 +600,17 @@ class UiTab extends React.Component {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div styleName='group-checkBoxSection'>
|
||||||
|
<label>
|
||||||
|
<input onChange={(e) => this.handleUIChange(e)}
|
||||||
|
checked={this.state.config.editor.enableMarkdownLint}
|
||||||
|
ref='enableMarkdownLint'
|
||||||
|
type='checkbox'
|
||||||
|
/>
|
||||||
|
{i18n.__('Enable MarkdownLint')}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div styleName='group-section'>
|
<div styleName='group-section'>
|
||||||
<div styleName='group-section-label'>
|
<div styleName='group-section-label'>
|
||||||
{i18n.__('Matching character pairs')}
|
{i18n.__('Matching character pairs')}
|
||||||
|
|||||||
54
yarn.lock
54
yarn.lock
@@ -101,6 +101,11 @@
|
|||||||
version "8.10.17"
|
version "8.10.17"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.17.tgz#d48cf10f0dc6dcf59f827f5a3fc7a4a6004318d3"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.17.tgz#d48cf10f0dc6dcf59f827f5a3fc7a4a6004318d3"
|
||||||
|
|
||||||
|
"JSV@>= 4.0.x":
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/JSV/-/JSV-4.0.2.tgz#d077f6825571f82132f9dffaed587b4029feff57"
|
||||||
|
integrity sha1-0Hf2glVx+CEy+d/67Vh7QCn+/1c=
|
||||||
|
|
||||||
abab@^1.0.3, abab@^1.0.4:
|
abab@^1.0.3, abab@^1.0.4:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"
|
||||||
@@ -1620,9 +1625,10 @@ chalk@0.5.1:
|
|||||||
strip-ansi "^0.3.0"
|
strip-ansi "^0.3.0"
|
||||||
supports-color "^0.2.0"
|
supports-color "^0.2.0"
|
||||||
|
|
||||||
chalk@^0.4.0:
|
chalk@^0.4.0, chalk@~0.4.0:
|
||||||
version "0.4.0"
|
version "0.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.4.0.tgz#5199a3ddcd0c1efe23bc08c1b027b06176e0c64f"
|
||||||
|
integrity sha1-UZmj3c0MHv4jvAjBsCewYXbgxk8=
|
||||||
dependencies:
|
dependencies:
|
||||||
ansi-styles "~1.0.0"
|
ansi-styles "~1.0.0"
|
||||||
has-color "~0.1.0"
|
has-color "~0.1.0"
|
||||||
@@ -5587,6 +5593,14 @@ jsonify@~0.0.0:
|
|||||||
version "0.0.0"
|
version "0.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
|
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
|
||||||
|
|
||||||
|
jsonlint-mod@^1.7.4:
|
||||||
|
version "1.7.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/jsonlint-mod/-/jsonlint-mod-1.7.4.tgz#310390e1a6a85cef99f45f200e662ef23b48f7a6"
|
||||||
|
integrity sha512-FYOkwHqiuBbdVCHgXYlmtL+iUOz9AxCgjotzXl+edI0Hc1km1qK6TrBEAyPpO+5R0/IX3XENRp66mfob4jwxow==
|
||||||
|
dependencies:
|
||||||
|
JSV ">= 4.0.x"
|
||||||
|
nomnom ">= 1.5.x"
|
||||||
|
|
||||||
jsonpointer@^4.0.0:
|
jsonpointer@^4.0.0:
|
||||||
version "4.0.1"
|
version "4.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9"
|
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9"
|
||||||
@@ -5685,6 +5699,13 @@ levn@^0.3.0, levn@~0.3.0:
|
|||||||
prelude-ls "~1.1.2"
|
prelude-ls "~1.1.2"
|
||||||
type-check "~0.3.2"
|
type-check "~0.3.2"
|
||||||
|
|
||||||
|
linkify-it@^2.0.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.1.0.tgz#c4caf38a6cd7ac2212ef3c7d2bde30a91561f9db"
|
||||||
|
integrity sha512-4REs8/062kV2DSHxNfq5183zrqXMl7WP0WzABH9IeJI+NLm429FgE1PDecltYfnOoFDFlZGh2T8PfZn0r+GTRg==
|
||||||
|
dependencies:
|
||||||
|
uc.micro "^1.0.1"
|
||||||
|
|
||||||
linkify-it@~1.2.0, linkify-it@~1.2.2:
|
linkify-it@~1.2.0, linkify-it@~1.2.2:
|
||||||
version "1.2.4"
|
version "1.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-1.2.4.tgz#0773526c317c8fd13bd534ee1d180ff88abf881a"
|
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-1.2.4.tgz#0773526c317c8fd13bd534ee1d180ff88abf881a"
|
||||||
@@ -5968,6 +5989,17 @@ markdown-it-sup@^1.0.0:
|
|||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3"
|
resolved "https://registry.yarnpkg.com/markdown-it-sup/-/markdown-it-sup-1.0.0.tgz#cb9c9ff91a5255ac08f3fd3d63286e15df0a1fc3"
|
||||||
|
|
||||||
|
markdown-it@8.4.2:
|
||||||
|
version "8.4.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.4.2.tgz#386f98998dc15a37722aa7722084f4020bdd9b54"
|
||||||
|
integrity sha512-GcRz3AWTqSUphY3vsUqQSFMbgR38a4Lh3GWlHRh/7MRwz8mcu9n2IO7HOh+bXHrR9kOPDl5RNCaEsrneb+xhHQ==
|
||||||
|
dependencies:
|
||||||
|
argparse "^1.0.7"
|
||||||
|
entities "~1.1.1"
|
||||||
|
linkify-it "^2.0.0"
|
||||||
|
mdurl "^1.0.1"
|
||||||
|
uc.micro "^1.0.5"
|
||||||
|
|
||||||
markdown-it@^5.0.3:
|
markdown-it@^5.0.3:
|
||||||
version "5.1.0"
|
version "5.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-5.1.0.tgz#25286b8465bac496f3f1b77eed544643e9bd718d"
|
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-5.1.0.tgz#25286b8465bac496f3f1b77eed544643e9bd718d"
|
||||||
@@ -6009,6 +6041,13 @@ markdown-toc@^1.2.0:
|
|||||||
repeat-string "^1.6.1"
|
repeat-string "^1.6.1"
|
||||||
strip-color "^0.1.0"
|
strip-color "^0.1.0"
|
||||||
|
|
||||||
|
markdownlint@^0.11.0:
|
||||||
|
version "0.11.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.11.0.tgz#3858bbdbc1ab78abf0c098d841c72b63dd3206a0"
|
||||||
|
integrity sha512-wE5WdKD6zW2DQaPQ5TFBTXh5j76DnWd/IFffnDQgHmi6Y61DJXBDfLftZ/suJHuv6cwPjM6gKw2GaRLJMOR+Mg==
|
||||||
|
dependencies:
|
||||||
|
markdown-it "8.4.2"
|
||||||
|
|
||||||
match-at@^0.1.1:
|
match-at@^0.1.1:
|
||||||
version "0.1.1"
|
version "0.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/match-at/-/match-at-0.1.1.tgz#25d040d291777704d5e6556bbb79230ec2de0540"
|
resolved "https://registry.yarnpkg.com/match-at/-/match-at-0.1.1.tgz#25d040d291777704d5e6556bbb79230ec2de0540"
|
||||||
@@ -6470,6 +6509,14 @@ nodeify@^1.0.1:
|
|||||||
is-promise "~1.0.0"
|
is-promise "~1.0.0"
|
||||||
promise "~1.3.0"
|
promise "~1.3.0"
|
||||||
|
|
||||||
|
"nomnom@>= 1.5.x":
|
||||||
|
version "1.8.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/nomnom/-/nomnom-1.8.1.tgz#2151f722472ba79e50a76fc125bb8c8f2e4dc2a7"
|
||||||
|
integrity sha1-IVH3Ikcrp55Qp2/BJbuMjy5Nwqc=
|
||||||
|
dependencies:
|
||||||
|
chalk "~0.4.0"
|
||||||
|
underscore "~1.6.0"
|
||||||
|
|
||||||
nopt@^3.0.1:
|
nopt@^3.0.1:
|
||||||
version "3.0.6"
|
version "3.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
|
resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9"
|
||||||
@@ -9048,6 +9095,11 @@ uc.micro@^1.0.0, uc.micro@^1.0.1:
|
|||||||
version "1.0.5"
|
version "1.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376"
|
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376"
|
||||||
|
|
||||||
|
uc.micro@^1.0.5:
|
||||||
|
version "1.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
|
||||||
|
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
|
||||||
|
|
||||||
uglify-js@^2.6:
|
uglify-js@^2.6:
|
||||||
version "2.8.29"
|
version "2.8.29"
|
||||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
|
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"
|
||||||
|
|||||||
Reference in New Issue
Block a user