Gathering detailed insights and metrics for vue-codemirror
Gathering detailed insights and metrics for vue-codemirror
@codemirror code editor component for @vuejs
npm install vue-codemirror
Typescript
Module System
Node Version
NPM Version
TypeScript (65.97%)
Vue (29.46%)
JavaScript (1.98%)
HTML (1.47%)
Shell (1.12%)
Total Downloads
10,995,604
Last Day
9,901
Last Week
43,435
Last Month
202,122
Last Year
2,994,840
3,337 Stars
191 Commits
385 Forks
41 Watching
5 Branches
14 Contributors
Minified
Minified + Gzipped
Latest Version
6.1.1
Package Id
vue-codemirror@6.1.1
Unpacked Size
83.06 kB
Size
15.96 kB
File Count
10
NPM Version
8.11.0
Node Version
16.16.0
Cumulative downloads
Total Downloads
Last day
-7.4%
9,901
Compared to previous day
Last week
-18.9%
43,435
Compared to previous week
Last month
-3.4%
202,122
Compared to previous month
Last year
5.2%
2,994,840
Compared to previous year
2
31
CodeMirror(6) component for Vue(3).
vue-codemirror
v5/v6 has been released. This is a new version based on CodeMirror@6 and is available to Vue3 only. Since CodeMirror@6 is developed with native ES Modules, the new version will no longer support direct browser references to UMD modules. In short, the new version is ⚠️ completely NOT compatible with previous versions. If you wish to continue using Vue2 or a lower version of CodeMirror, please refer to the legacy versions below.
This example site contains most of what you want.
1yarn add codemirror vue-codemirror
1npm install codemirror vue-codemirror --save
1# CodeMirror languages... 2yarn add @codemirror/lang-html 3yarn add @codemirror/lang-json 4yarn add @codemirror/lang-javascript 5 6# CodeMirror themes... 7yarn add @codemirror/theme-one-dark 8 9# more CodeMirror packages...
package.json
e.g.
1"dependencies": { 2 "@codemirror/state": "6.x" 3}
1import { EditorState } from '@codemirror/state'
1<template> 2 <codemirror 3 v-model="code" 4 placeholder="Code goes here..." 5 :style="{ height: '400px' }" 6 :autofocus="true" 7 :indent-with-tab="true" 8 :tab-size="2" 9 :extensions="extensions" 10 @ready="handleReady" 11 @change="log('change', $event)" 12 @focus="log('focus', $event)" 13 @blur="log('blur', $event)" 14 /> 15</template> 16 17<script> 18 import { defineComponent } from 'vue' 19 import { Codemirror } from 'vue-codemirror' 20 import { javascript } from '@codemirror/lang-javascript' 21 import { oneDark } from '@codemirror/theme-one-dark' 22 23 export default defineComponent({ 24 components: { 25 Codemirror 26 }, 27 setup() { 28 const code = ref(`console.log('Hello, world!')`) 29 const extensions = [javascript(), oneDark] 30 31 // Codemirror EditorView instance ref 32 const view = shallowRef() 33 const handleReady = (payload) => { 34 view.value = payload.view 35 } 36 37 // Status is available at all times via Codemirror EditorView 38 const getCodemirrorStates = () => { 39 const state = view.value.state 40 const ranges = state.selection.ranges 41 const selected = ranges.reduce((r, range) => r + range.to - range.from, 0) 42 const cursor = ranges[0].anchor 43 const length = state.doc.length 44 const lines = state.doc.lines 45 // more state info ... 46 // return ... 47 } 48 49 return { 50 code, 51 extensions, 52 handleReady, 53 log: console.log 54 } 55 } 56 }) 57</script>
1import { createApp } from 'vue' 2import { basicSetup } from 'codemirror' 3import VueCodemirror from 'vue-codemirror' 4 5const app = createApp() 6 7app.use(VueCodemirror, { 8 // optional default global options 9 autofocus: true, 10 disabled: false, 11 indentWithTab: true, 12 tabSize: 2, 13 placeholder: 'Code goes here...', 14 extensions: [basicSetup] 15 // ... 16})
prop | description | type | default |
---|---|---|---|
modelValue | The input values accepted by the component also support two-way binding. | String | '' |
autofocus | Focus editor immediately after mounted. | Boolean | false |
disabled | Disable input behavior and disable change state. | Boolean | false |
indentWithTab | Bind keyboard Tab key event. | Boolean | true |
tabSize | Specify the indent when the Tab key is pressed. | Number | 2 |
placeholder | Display when empty. | String | '' |
style | The CSS style object that acts on the CodeMirror itself. | Object | {} |
phrases | Codemirror internationalization phrases. | Object | {} |
autoDestroy | Auto destroy the CodeMirror instance before the component unmount. | Boolean | true |
extensions | Passed to CodeMirror EditorState.create({ extensions }) | Extension | [] |
selection | Passed to CodeMirror EditorState.create({ selection }) | EditorSelection | - |
root | Passed to CodeMirror new EditorView({ root }) | ShadowRoot | Document | - |
event | description | params |
---|---|---|
update:modelValue | Only when the CodeMirror content (doc) has changed. | (value: string, viewUpdate: ViewUpdate) |
change | ditto | ditto |
update | When any state of CodeMirror changes. | (viewUpdate: ViewUpdate) |
focus | When CodeMirror focused. | (viewUpdate: ViewUpdate) |
blur | When CodeMirror blurred. | (viewUpdate: ViewUpdate) |
ready | When edirot component mounted. | (payload: { view: EditorView; state: EditorState; container: HTMLDivElement }) |
The basic-setup extension is integrated by default in the vue-codemirror configuration and is intended as a handy helper to quickly set up CodeMirror without having to install and import a lot of standalone packages. If you want to override the default behavior of the config, just pass the empty array when installing the component globally.
1app.use(VueCodemirror, { 2 // keep the global default extensions empty 3 extensions: [] 4})
Detailed changes for each release are documented in the release notes.
Licensed under the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 5/23 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
20 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More