Discuz! X3.4 发帖换行兼容方案(换行丢失问题解决)

修正discuz发帖首次换行无效的问题

修改static/js/bbcode.js

if((allowhtml && fetchCheckbox('htmlon')) || trim(str) == '') {
    for(i in EXTRAFUNC['html2bbcode']) {
        EXTRASTR = str;
        try {
            eval('str = ' + EXTRAFUNC['html2bbcode'][i] + '()');
        } catch(e) {}
    }
    str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);});
    str = str.replace(/<img([^>]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);});
    return str;
}

修改为

if((allowhtml && fetchCheckbox('htmlon')) || trim(str) == '') {
    for(i in EXTRAFUNC['html2bbcode']) {
        EXTRASTR = str;
        try {
            eval('str = ' + EXTRAFUNC['html2bbcode'][i] + '()');
        } catch(e) {}
    }
    str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);});
    str = str.replace(/<img([^>]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);});
    return str;
}

//fix first enter cannot start new line
var divPos = strpos(str,"<div>");
if(divPos > 0 ){
    if(divPos > 4 && str.substr(divPos - 4,4) == '</p>'){}
    else{
        str = str.substr(0,divPos) + '<br>'+ str.substr(divPos);
    }
}
//end

 

思羽布丁的黑苹果动力QQ群:15971419
欢迎赞助一下思羽布丁:https://www.mfpud.com/donations/
思羽布丁 » Discuz! X3.4 发帖换行兼容方案(换行丢失问题解决)