<commit_before>/**
 * 目录大纲支持插件
 * @file
 * @since 1.3.0
 */
UE.plugin.register('section', function (){
    /* 目录节点对象 */
    function Section(option){
        this.tag = '';
        this.level = -1,
            this.dom = null;
        this.nextSection = null;
        this.previousSection = null;
        this.parentSection = null;
        this.startAddress = [];
        this.endAddress = [];
        this.children = [];
    }
    function getSection(option) {
        var section = new Section();
        return utils.extend(section, option);
    }
    function getNodeFromAddress(startAddress, root) {
        var current = root;
        for(var i = 0;i < startAddress.length; i++) {
            if(!current.childNodes) return null;
            current = current.childNodes[startAddress[i]];
        }
        return current;
    }

    var me = this;

    return {
        bindEvents:{
            /* 初始化、拖拽、粘贴、执行setcontent之后 */
            'ready': function (){
                me.fireEvent('updateSections');
                domUtils.on(me.body, 'drop paste aftersetcontent', function(){
                    me.fireEvent('updateSections');
                });
            },
            /* 执行setcontent之后 */
            'aftersetcontent': function(e){
                me.fireEvent('updateSections');
            },
            'aftersetcontent': function () {
                me.fireEvent('updateSections');
            },
            /* 执行paragraph命令之后 */
            'afterexeccommand': function (type, cmd) {
                if(cmd == 'paragraph') {
                    me.fireEvent('updateSections');
                }
            },
            /* 部分键盘操作，触发updateSections事件 */
            'keyup': function (type, e) {
                var me = this,
                    range = me.selection.getRange();
                if(range.collapsed != true) {
                    me.fireEvent('updateSections');
                } else {
                    var keyCode = e.keyCode || e.which;
                    if(keyCode == 13 || keyCode == 8 || keyCode == 46) {
                        me.fireEvent('updateSections');
                    }
                }
            }
        },
        commands:{
            'getsections': {
                execCommand: function (cmd, levels) {<commit_msg>[fix]by Jinqn目录大纲支持undo、redo触发事件<commit_after>/**
 * 目录大纲支持插件
 * @file
 * @since 1.3.0
 */
UE.plugin.register('section', function (){
    /* 目录节点对象 */
    function Section(option){
        this.tag = '';
        this.level = -1,
            this.dom = null;
        this.nextSection = null;
        this.previousSection = null;
        this.parentSection = null;
        this.startAddress = [];
        this.endAddress = [];
        this.children = [];
    }
    function getSection(option) {
        var section = new Section();
        return utils.extend(section, option);
    }
    function getNodeFromAddress(startAddress, root) {
        var current = root;
        for(var i = 0;i < startAddress.length; i++) {
            if(!current.childNodes) return null;
            current = current.childNodes[startAddress[i]];
        }
        return current;
    }

    var me = this;

    return {
        bindEvents:{
            /* 初始化、拖拽、粘贴、执行setcontent之后 */
            'ready': function (){
                me.fireEvent('updateSections');
                domUtils.on(me.body, 'drop paste aftersetcontent', function(){
                    me.fireEvent('updateSections');
                });
            },
            /* 执行setcontent之后 */
            'aftersetcontent': function(e){
                me.fireEvent('updateSections');
            },
            'aftersetcontent': function () {
                me.fireEvent('updateSections');
            },
            /* 执行paragraph命令之后 */
            'afterexeccommand': function (type, cmd) {
                if(cmd == 'paragraph' || cmd == 'undo' || cmd == 'redo') {
                    me.fireEvent('updateSections');
                }
            },
            /* 部分键盘操作，触发updateSections事件 */
            'keyup': function (type, e) {
                var me = this,
                    range = me.selection.getRange();
                if(range.collapsed != true) {
                    me.fireEvent('updateSections');
                } else {
                    var keyCode = e.keyCode || e.which;
                    if(keyCode == 13 || keyCode == 8 || keyCode == 46) {
                        me.fireEvent('updateSections');
                    }
                }
            }
        },
        commands:{
            'getsections': {
                execCommand: function (cmd, levels) {
{'fraction_non_alphanumeric': 0.1283043197936815, 'fraction_numerical': 0.004298302170642596, 'mean_word_length': 1.3624365482233503, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7184642', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1310, 'n_words': 229}