百度ueditor1.4.3几个bug修复

4 篇文章 0 订阅

1.多图在线管理无法显示图片:

下载ueditor源码包,将jsp/src下的com/baidu/ueditor/hunter/FileManger.java中的getPath(file)方法:

private String getPath ( File file ) {
      //String path = file.getAbsolutePath();
        String path = PathFormat.format(file.getAbsolutePath());
    return path.replace(this.rootPath, "" );
}
然后按照ueditor文档中的打包方法打包为jsp版


2.自动保存无法取消:

方法一:先在ueditor.config.js里设置:

 //启用自动保存
,enableAutoSave: false

然后在引入ueditor.all.min.js的script标签后添加以下js代码:

UE.plugin.register('autosave', function (){

    var me = this,
        //无限循环保护
        lastSaveTime = new Date(),
        //最小保存间隔时间
        MIN_TIME = 20,
        //auto save key
        saveKey = null;

    function save ( editor ) {

        var saveData;

        if ( new Date() - lastSaveTime < MIN_TIME ) {
            return;
        }

        if ( !editor.hasContents() ) {
            //这里不能调用命令来删除, 会造成事件死循环
            saveKey && me.removePreferences( saveKey );
            return;
        }

        lastSaveTime = new Date();

        editor._saveFlag = null;

        saveData = me.body.innerHTML;

        if ( editor.fireEvent( "beforeautosave", {
            content: saveData
        } ) === false ) {
            return;
        }

        me.setPreferences( saveKey, saveData );

        editor.fireEvent( "afterautosave", {
            content: saveData
        } );

    }

    return {
        defaultOptions: {
            //默认间隔时间
            saveInterval: 500,
            enableAutoSave: true
        },
        bindEvents:{
            'ready':function(){

                var _suffix = "-drafts-data",
                    key = null;

                if ( me.key ) {
                    key = me.key + _suffix;
                } else {
                    key = ( me.container.parentNode.id || 'ue-common' ) + _suffix;
                }

                //页面地址+编辑器ID 保持唯一
                saveKey = ( location.protocol + location.host + location.pathname ).replace( /[.:\/]/g, '_' ) + key;

            },

            'contentchange': function () {

                if (!me.getOpt('enableAutoSave')) {
                    return;
                }

                if ( !saveKey ) {
                    return;
                }

                if ( me._saveFlag ) {
                    window.clearTimeout( me._saveFlag );
                }

                if ( me.options.saveInterval > 0 ) {

                    me._saveFlag = window.setTimeout( function () {

                        save( me );

                    }, me.options.saveInterval );

                } else {

                    save(me);

                }


            }
        },
        commands:{
            'clearlocaldata':{
                execCommand:function (cmd, name) {
                    if ( saveKey && me.getPreferences( saveKey ) ) {
                        me.removePreferences( saveKey )
                    }
                },
                notNeedUndo: true,
                ignoreContentChange:true
            },

            'getlocaldata':{
                execCommand:function (cmd, name) {
                    return saveKey ? me.getPreferences( saveKey ) || '' : '';
                },
                notNeedUndo: true,
                ignoreContentChange:true
            },

            'drafts':{
                execCommand:function (cmd, name) {
                    if ( saveKey ) {
                        me.body.innerHTML = me.getPreferences( saveKey ) || '<p>'+domUtils.fillHtml+'</p>';
                        me.focus(true);
                    }
                },
                queryCommandState: function () {
                    return saveKey ? ( me.getPreferences( saveKey ) === null ? -1 : 0 ) : -1;
                },
                notNeedUndo: true,
                ignoreContentChange:true
            }
        }
    }

});

方法二:修改ueditor源码包中的_src\plugins\autosave.js,将代码改为上述代码,然后打包


3.jsp版控制台提示:Parameters: Invalid chunk '' ignored

方法一:修改ueditor.all.js:

 xhr.open(method, str, ajaxOpts.async);   ----》 xhr.open(method, str.replace("&&","&"), ajaxOpts.async);

要修改ueditor.all.min.js,可以搜索“method.toUpperCase()”,

,y=f.method.toUpperCase(),u=a+(-1==a.indexOf("?")?"?":"&")+("POST"==y?"":h+"&noCache="+ +new Date);e.open(y,u,f.async);

将e.open(y,u,f.async); 改为e.open(y,u.replace("&&","&"),f.async);

方法二:按上述方法修改源码包中的_src\core\ajax.js文件,然后打包.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值