Monaco Editor is the code editor that powers VS Code.
yarn add vue-monaco
You need to include monaco-editor first.
Then use the component:
<script src="/path/to/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: '/path/to/monaco-editor/min/vs'
}
})
</script>
<template>
<monaco-editor
v-model="code"
language="javascript">
</monaco-editor>
</template>
<script>
import MonacoEditor from 'vue-monaco'
export default {
components: {
MonacoEditor
},
data() {
return {
code: 'const noop = () => {}'
}
}
}
</script>
code
language
theme
options
change
: Emitted when the value is changed, args:newValue
focus
: Emitted when the editor is focused.blur
: Emitted when the editor loses focus.
getMonaco(): IStandaloneCodeEditor
: Return the editor instance.
Use ref
to interact with the MonacoEditor
component in order to access methods: <MonacoEditor ref="editor"></MonacoEditor>
, then this.$refs.editor.getMonaco()
will be available.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
vue-monaco © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
egoist.moe · GitHub @egoist · Twitter @_egoistlily