1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-21 06:57:30 +02:00

Use prettier on Shift+tab inside codemirror

This commit is contained in:
Kushagra Gour
2018-10-24 19:23:57 +05:30
parent 6361034933
commit 2091df6916
3 changed files with 35 additions and 3 deletions

View File

@ -32,6 +32,7 @@ import 'codemirror/keymap/vim.js';
import 'code-blast-codemirror/code-blast.js';
import emmet from '@emmetio/codemirror-plugin';
import { prettify } from '../utils';
emmet(CodeMirror);
@ -79,7 +80,13 @@ export default class UserCodeMirror extends Component {
CodeMirror.commands.goLineDown(editor);
},
'Shift-Tab': function(editor) {
CodeMirror.commands.indentAuto(editor);
if (options.prettier) {
editor.setValue(
prettify(editor.getValue(), options.prettierParser)
);
} else {
CodeMirror.commands.indentAuto(editor);
}
},
Tab: function(editor) {
if (options.emmet) {