<commit_before>module.exports = {
    template: __inline('vue-tinymce.tpl'),
    data: function(){
        return {
            vueChange: false
        }
    },
    props: {
        model: {
            required: true,
            type: String,
            twoWay: true,
            default: ""
        }
    },
    ready: function(){
        var self = this
        var config = require('tinymce.config')
        config.target = this.$els.input
        config.style_formats = require('tinymce.config.style_formats')
        config.setup = function(editor){
            //init
            editor.on('init', function(){
                editor.setContent(self.model)
                editor.on('change', function(){
                    if(!self.vueChange) self.model = tinymce.activeEditor.getContent()
                })
            })
        }
        tinymce.init(config)
    },
    beforeDestroy: function(){
        tinymce.remove()
    },
    watch: {
        'model': function(val, oldVal){
            this.vueChange = true
            if(!!tinymce.activeEditor) tinymce.activeEditor.setContent(val)
            this.vueChange = false
        }
    }
}<commit_msg>修复初次编辑时光标重置问题<commit_after>module.exports = {
    template: __inline('vue-tinymce.tpl'),
    data: function(){
        return {
            vueChange: false
        }
    },
    props: {
        model: {
            required: true,
            type: String,
            twoWay: true,
            default: ""
        }
    },
    ready: function(){
        var self = this
        var config = require('tinymce.config')

        var unwatch = this.$watch('model', function(val, oldVal){
            if(!!tinymce.activeEditor) tinymce.activeEditor.setContent(val)
        })

        config.target = this.$els.input
        config.style_formats = require('tinymce.config.style_formats')
        config.setup = function(editor){
            //init
            editor.on('init', function(){
                var change = function(){
                    self.model = editor.getContent()
                }
                editor.setContent(self.model)
                editor.on('change', function(){//undo,redo
                    //由于第一次加载存在刷新机制，需判断是否为
                    if(self.vueChange || editor.undoManager.data.length<=1) return unwatch();
                    change()
                })
                editor.on('undo', change)
                editor.on('redo', change)
            })
        }
        tinymce.init(config)
    },
    beforeDestroy: function(){
        tinymce.remove()
    }
}
{'fraction_non_alphanumeric': 0.12383177570093458, 'fraction_numerical': 0.0003894080996884735, 'mean_word_length': 1.4725697786333012, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2803993', 'n_tokens_mistral': 742, 'n_tokens_neox': 725, 'n_words': 117}