Vue-Codemirror
codemirror component for vuejs.
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code, and comes with a number of language modes and addons that implement more advanced editing functionality.
Events
To make it easier to handle events, the component converts some codemirror built-in native events into a single vue component event, where you can listen for events from both the component itself and from codemirror. If you need to listen for more and more complex events, you can pass in the event names (Array) you need for the global Vue.use(, { events: [] })
and the component parameters :events
, respectively, or by the this.codemirror.on(evennt, hanger)
method of the codemirror instance. Here's a list of events:
codemirror events list:
- scroll
- changes
- beforeChange
- cursorActivity
- keyHandled
- inputRead
- electricInput
- beforeSelectionChange
- viewportChange
- swapDoc
- gutterClick
- gutterContextMenu
- focus
- blur
- refresh
- optionChange
- scrollCursorIntoView
- update
component events list:
- ready
- input
Install
CDN
NPM
Mount
mount with global
mount with component
mount with ssr
defined codemirror mode
Component
Codemirror Merge
Codemirror language mode types
编辑器的模式(mode属性)分为 字符串、对象两种方式,Codemirror 官方文档有说明
mode: 'string' || object