-
-
Save quezo/994678f74bac733198d651849402fc20 to your computer and use it in GitHub Desktop.
A simple example of how we use Emmet CodeMirror with Webpack/ES6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as emmet from 'emmet-codemirror'; | |
import _ from 'lodash'; | |
export const initEmmet = (CodeMirror) => { | |
// Initialize emmet Library by passing it a copy of | |
// CodeMirror library | |
emmet.setup(CodeMirror); | |
}; | |
const emmetSupportedFileTypes = [ | |
"html", "haml", "slim", "markdown", "jade", | |
"css", "scss", "postcss", "sass", "stylus", "less" | |
]; | |
const enableEmmetOnFileType = (fileType) => { | |
return _.includes(emmetSupportedFileTypes, fileType); | |
}; | |
export const configureEmmetForCMMode = (codeMirror, fileType) => { | |
if (enableEmmetOnFileType(fileType)) { | |
emmet.default(codeMirror); | |
} else { | |
emmet.dispose(codeMirror); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment