From b2d379d4f958833f74057878a442d0584cc24a7f Mon Sep 17 00:00:00 2001 From: packy Date: Mon, 15 Feb 2016 17:39:25 +0800 Subject: [PATCH] init --- src/tinymce.config.json | 18 ++++++++++++ src/tinymce.config.style_formats.json | 11 +++++++ src/vue-tinymce.js | 42 +++++++++++++++++++++++++++ src/vue-tinymce.tpl | 1 + 4 files changed, 72 insertions(+) create mode 100644 src/tinymce.config.json create mode 100644 src/tinymce.config.style_formats.json create mode 100644 src/vue-tinymce.js create mode 100644 src/vue-tinymce.tpl diff --git a/src/tinymce.config.json b/src/tinymce.config.json new file mode 100644 index 0000000..55ad967 --- /dev/null +++ b/src/tinymce.config.json @@ -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" +} \ No newline at end of file diff --git a/src/tinymce.config.style_formats.json b/src/tinymce.config.style_formats.json new file mode 100644 index 0000000..ae71306 --- /dev/null +++ b/src/tinymce.config.style_formats.json @@ -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"} + ]} +] \ No newline at end of file diff --git a/src/vue-tinymce.js b/src/vue-tinymce.js new file mode 100644 index 0000000..e77f4c2 --- /dev/null +++ b/src/vue-tinymce.js @@ -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) + } + } + } +} \ No newline at end of file diff --git a/src/vue-tinymce.tpl b/src/vue-tinymce.tpl new file mode 100644 index 0000000..cae1d53 --- /dev/null +++ b/src/vue-tinymce.tpl @@ -0,0 +1 @@ + \ No newline at end of file