Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
chairuosen committed Jun 18, 2016
0 parents commit 1010454
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
57 changes: 57 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var ace = require('brace');

require(['emmet/emmet'],function (data) {
window.emmet = data.emmet;
});

module.exports = {
template:"<div :style=\"{height: height ? height+'px' : '100%',width: width ? width+'px' : '100%'}\"></div>",
props:{
content:{
type:String,
twoWay:true,
required:true
},
lang:String,
theme:String,
height:true,
width:true
},
data: function () {
return {
editor:null,
contentBackup:""
}
},
methods: {},
components: {},
watch:{
content:function (val) {
if(this.contentBackup !== val)
this.editor.setValue(val,1);
}
},
ready: function () {
var vm = this;
var lang = this.lang||'text';
var theme = this.theme||'chrome';
require('brace/mode/'+lang);
require('brace/theme/'+theme);
require('brace/ext/emmet');

var editor = vm.editor = ace.edit(this.$el);
editor.$blockScrolling = Infinity;
editor.setOption("enableEmmet", true);

editor.getSession().setMode('ace/mode/'+lang);
editor.setTheme('ace/theme/'+theme);

editor.setValue(this.content,1);

editor.on('change',function () {
vm.content = editor.getValue();
vm.contentBackup = vm.content;
});

}
}
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "vue-ace-editor",
"version": "1.0.0",
"description": "A Vue's component based on ace/brace",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/chairuosen/vue-ace-editor.git"
},
"author": "chairuosen",
"license": "MIT",
"bugs": {
"url": "https://github.com/chairuosen/vue-ace-editor/issues"
},
"homepage": "https://github.com/chairuosen/vue-ace-editor#readme",
"dependencies": {
"brace": "^0.8.0",
"emmet": "git+https://github.com/cloud9ide/emmet-core.git"
}
}

0 comments on commit 1010454

Please sign in to comment.