{"id":15912399,"url":"https://github.com/cnu4/vue-codemirror-lite","last_synced_at":"2025-04-04T14:05:00.242Z","repository":{"id":48422903,"uuid":"78834998","full_name":"cnu4/vue-codemirror-lite","owner":"cnu4","description":"Lightweight Codemirror Component for Vue.js","archived":false,"fork":false,"pushed_at":"2021-07-27T06:26:34.000Z","size":271,"stargazers_count":281,"open_issues_count":5,"forks_count":48,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T13:06:29.748Z","etag":null,"topics":["codemirror","javascript","vue"],"latest_commit_sha":null,"homepage":"https://cnu4.github.io/vue-codemirror-lite/","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnu4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-13T09:28:55.000Z","updated_at":"2024-11-05T06:48:54.000Z","dependencies_parsed_at":"2022-08-27T11:10:56.969Z","dependency_job_id":null,"html_url":"https://github.com/cnu4/vue-codemirror-lite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnu4%2Fvue-codemirror-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnu4%2Fvue-codemirror-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnu4%2Fvue-codemirror-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnu4%2Fvue-codemirror-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnu4","download_url":"https://codeload.github.com/cnu4/vue-codemirror-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247190175,"owners_count":20898697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codemirror","javascript","vue"],"created_at":"2024-10-06T16:04:34.551Z","updated_at":"2025-04-04T14:05:00.196Z","avatar_url":"https://github.com/cnu4.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vue-Codemirror-Lite\n\n[CodeMirror](http://codemirror.net/) Component For Vue.js (support 1.x and 2.x).\n\n[中文文档](https://github.com/cnu4/vue-codemirror-lite/blob/master/README_CN.md)\n\n## Lightweight\n\nBy default (to optimise bundle size) all modes and addons are not included. To enable them, see [Using Language Modes and Addons](#using-language-modes-and-addons).\n\n## Demo\n\nLive Demo: [https://cnu4.github.io/vue-codemirror-lite](https://cnu4.github.io/vue-codemirror-lite)\n\nTo run the demo locally, run\n\n`npm install \u0026\u0026 npm run dev`\n\nView demo in browser on [JSFiddle](https://jsfiddle.net/cnu4/r33vk618)\n\n## Installation\n\n### npm\n\n`npm install vue-codemirror-lite`\n\n```js\n// Install the plugin\nvar Vue = require('vue')\nvar VueCodeMirror = require('vue-codemirror-lite')\n\nVue.use(VueCodeMirror)\n\n// Or use as component (ES6)\nimport Vue from 'vue'\nimport { codemirror } from 'vue-codemirror-lite'\n\nexport default {\n  components: {\n    codemirror\n  }\n}\n```\n\n### browser\n\nInclude in the page\n\n`\u003cscript src=\"https://unpkg.com/vue-codemirror-lite/dist/vuecodemirror.min.js\"\u003e\u003c/script\u003e`\n\ninstall into vue\n\n`Vue.use(VueCodeMirror)`\n\nor use as components\n\n`Vue.component('codemirror', VueCodeMirror.codemirror)`\n\nCodeMirror itself was built into `vuecodemirror.min.js`, get `CodeMirror` by\n\n`window.CodeMirror = VueCodeMirror.CodeMirror`\n\nView demo in browser on [JSFiddle](https://jsfiddle.net/cnu4/r33vk618)\n\n## Usage\n\n### Usage in Component\n\n```html\n\n\u003c!-- simple --\u003e\n\u003ccodemirror :value=\"code\"\u003e\u003c/codemirror\u003e\n\n\u003c!-- simple (with bindings in Vue1.x) --\u003e\n\u003ccodemirror :value.sync=\"code\"\u003e\u003c/codemirror\u003e\n\n\u003c!-- simple (with bindings in Vue2.x) --\u003e\n\u003ccodemirror v-model=\"code\"\u003e\u003c/codemirror\u003e\n\n\u003c!-- advanced --\u003e\n\u003ccodemirror\n  :value=\"code\"\n  :options=\"editorOption\"\n  ref=\"myEditor\"\n  @change=\"yourCodeChangeMethod\"\u003e\n\u003c/codemirror\u003e\n```\n\n```js\nexport default {\n  data () {\n    return {\n      code: 'const str = \"hello world\"'\n    }\n  },\n  computed: {\n    editor() {\n      // get current editor object\n      return this.$refs.myEditor.editor\n    }\n  },\n  mounted() {\n    // use editor object...\n    this.editor.focus()\n    console.log('this is current editor object', this.editor)\n  }\n}\n```\n\n## Properties\n\n - `value` `String` the editor value\n - `options` `Object (newValue)` options passed to the CodeMirror instance\n\nSee the [CodeMirror Configuration](http://codemirror.net/doc/manual.html#config) for the available options.\n\n## Using Language Modes and Addons\n\nSeveral [language modes](https://codemirror.net/mode/) are included with CodeMirror.\n\nBy default (to optimise bundle size) all modes and addons are not included. To enable:\n\n - install `vue-codemirror-lite` \n - require the language modes or addons after you require `vue-codemirror-lite` itself (If use browser version, you need to include necessary script file of mode and addons. View demo in browser on [JSFiddle](https://jsfiddle.net/cnu4/r33vk618))\n - set the mode option in the options object\n\n```html\n\u003ctemplate\u003e\n  \u003ccodemirror :options=\"{\n    mode: 'javascript',\n    extraKeys: {'Ctrl-Space': 'autocomplete'}\n  }\"\u003e\u003c/codemirror\u003e\n\u003c/template\u003e\n\n\u003cscript\u003e\n  import { codemirror } from 'vue-codemirror-lite'\n  require('codemirror/mode/javascript/javascript')\n  require('codemirror/mode/vue/vue')\n\n  require('codemirror/addon/hint/show-hint.js')\n  require('codemirror/addon/hint/show-hint.css')\n  require('codemirror/addon/hint/javascript-hint.js')\n\n  export default {\n    ...\n  }\n\u003c/script\u003e\n```\n\nSee the demo source which implement JavaScript and vue syntax highlighting and JavaScript hint addon.\n\nSee the [CodeMirror Manual](http://codemirror.net/doc/manual.html) for the more modes and addons.\n\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnu4%2Fvue-codemirror-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnu4%2Fvue-codemirror-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnu4%2Fvue-codemirror-lite/lists"}