Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
lpreterite committed Feb 15, 2016
1 parent 3c40b18 commit b2d379d
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tinymce.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"selector": "#input",
"mode": "specific_textareas",
"height": 500,
"powerpaste_word_import": "clean",
"powerpaste_html_import": "merge",
"language": "zh_CN",
"plugins": [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"table contextmenu directionality emoticons template textcolor paste fullpage textcolor colorpicker textpattern"
],
"toolbar_items_size": "small",
"menubar": false,
"block_formats": "Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;",
"toolbar1": "insertfile undo redo | formatselect | bullist numlist | link unlink | image media | fullscreen",
"toolbar2": "styleselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | removeformat"
}
11 changes: 11 additions & 0 deletions src/tinymce.config.style_formats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{"title": "Inline", "items": [
{"title": "Bold", "icon": "bold", "format": "bold"},
{"title": "Italic", "icon": "italic", "format": "italic"},
{"title": "Underline", "icon": "underline", "format": "underline"},
{"title": "Strikethrough", "icon": "strikethrough", "format": "strikethrough"},
{"title": "Superscript", "icon": "superscript", "format": "superscript"},
{"title": "Subscript", "icon": "subscript", "format": "subscript"},
{"title": "Code", "icon": "code", "format": "code"}
]}
]
42 changes: 42 additions & 0 deletions src/vue-tinymce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
var inChange = false
module.exports = {
template: __inline('vue-tinymce.tpl'),
props: {
model: {
required: true,
type: String,
twoWay: true,
default: ""
}
},
ready: function(){

var self = this
var config = __inline('tinymce.config.json')
config.style_formats = __inline('tinymce.config.style_formats.json')
config.setup = function(editor){
editor.on('init', function(){
editor.setContent(self.model)
editor.on('change', function(){
inChange = true
self.model = tinymce.activeEditor.getContent()
console.log(self.model)
inChange = false
})
})
}
tinymce.init(config)
},
beforeDestroy: function(){
tinymce.remove()
},
watch: {
'model': function(val, oldVal){
if(!inChange) return
if(!!tinymce.activeEditor){
console.log('in watch')
tinymce.activeEditor.setContent(val)
}
}
}
}
1 change: 1 addition & 0 deletions src/vue-tinymce.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<textarea class="textarea" id="input" v-el:input></textarea>

0 comments on commit b2d379d

Please sign in to comment.