mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
feat(prettierOnMarkdown): Forced prettier options to always have parser set to markdown when used.
This commit is contained in:
@@ -236,11 +236,15 @@ export default class CodeEditor extends React.Component {
|
|||||||
[translateHotkey(hotkey.prettifyMarkdown)]: cm => {
|
[translateHotkey(hotkey.prettifyMarkdown)]: cm => {
|
||||||
// Default / User configured prettier options
|
// Default / User configured prettier options
|
||||||
const currentConfig = JSON.parse(self.props.prettierConfig)
|
const currentConfig = JSON.parse(self.props.prettierConfig)
|
||||||
// Get current cursor position.
|
|
||||||
|
// Parser type will always need to be markdown so we override the option before use
|
||||||
|
currentConfig.parser = 'markdown'
|
||||||
|
|
||||||
|
// Get current cursor position
|
||||||
const cursorPos = cm.getCursor()
|
const cursorPos = cm.getCursor()
|
||||||
currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos)
|
currentConfig.cursorOffset = cm.doc.indexFromPos(cursorPos)
|
||||||
|
|
||||||
// Prettify contents of editor.
|
// Prettify contents of editor
|
||||||
const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig)
|
const formattedTextDetails = prettier.formatWithCursor(cm.doc.getValue(), currentConfig)
|
||||||
|
|
||||||
const formattedText = formattedTextDetails.formatted
|
const formattedText = formattedTextDetails.formatted
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"tabWidth": 4,
|
"tabWidth": 4,
|
||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": true
|
||||||
"parser":"markdown"
|
|
||||||
}`
|
}`
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user