找回密码
 注册账号
搜索
查看: 2819|回复: 0

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

[复制链接]

3087

主题

688

回帖

3万

积分

管理员

积分
31443

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

发表于 2019.10.13 23:18 | 显示全部楼层 |阅读模式
修正discuz发帖首次换行无效的问题


修改static/js/bbcode.js


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


修改为

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

  12. //fix first enter cannot start new line
  13. var divPos = strpos(str,"<div>");
  14. if(divPos > 0 ){
  15.     if(divPos > 4 && str.substr(divPos - 4,4) == '</p>'){}
  16.     else{
  17.         str = str.substr(0,divPos) + '<br>'+ str.substr(divPos);
  18.     }
  19. }
  20. //end
复制代码


您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

站点地图|童话镇

GMT+8, 2024.5.2 12:49 , Processed in 0.038575 second(s), 3 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表