Skip to content

Instantly share code, notes, and snippets.

@hypeJunction
Created July 4, 2019 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hypeJunction/5e4b2eb3246ea5c41cddf5aaf0dc07d5 to your computer and use it in GitHub Desktop.
Save hypeJunction/5e4b2eb3246ea5c41cddf5aaf0dc07d5 to your computer and use it in GitHub Desktop.
export default {
install (Vue) {
Vue.prototype.$codemirror = {
async load (options) {
await import('codemirror/lib/codemirror.css');
const module = await import('codemirror/lib/codemirror.js');
const CodeMirror = module.default;
const modes = options.modes || [];
const modeImports = modes.map((mode) => {
return import(`codemirror/mode/${mode}/${mode}.js`);
});
await Promise.all(modeImports);
return CodeMirror;
},
};
Vue.component('vue-codemirror', () => import('./VueCodemirror.vue'));
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment