尽管我在tinymce.init中使用了'forced_root_block',但p标签并未被删除。
下面是我的初始化函数
<script type="text/javascript" src="https://tinymce.cachefly.net/4.1/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea#fulldis",
mode : "textareas",
editor_selector : "fulldis",
setup: function (editor) { editor.on('change', function () {editor.save(); }); },
forced_root_block : "",
force_br_newlines : true,
force_p_newlines : false,
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify "
});
</script>
这是看起来:
关于如何删除上面的圆圈中的“ p”的任何想法。
答案 0 :(得分:0)
将此行添加到您的init语句中。
forced_root_block : ""
完整行可以为
<script>
tinymce.init({
forced_root_block : "",
selector:'textarea'});
</script>
答案 1 :(得分:0)
使用它。 TinyMce自动添加“
”标签。您可以在tinyMce初始化中像在脚本上这样设置此选项...
public class KoalaAppBar extends RelativeLayout {
private static final String DEFAULT_TITLE = "default";
private static final int DEFAULT_TITLE_COLOR = ResourcesCompat.getColor(AppController.getContext().getResources(), R.color.colorPrimary , null);
private static final float DEFAULT_TITLE_FONT_SIZE = AppController.getContext().getResources().getDimension(R.dimen.TextSize_small);
protected CustomTextView txtTitle;
protected CustomImageView imgBack;
protected ImageView imgLogo;
public KoalaAppBar(Context context) {
super(context);
init(context , null);
}
public KoalaAppBar(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context , attrs);
}
public KoalaAppBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context , attrs);
}
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public KoalaAppBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs);
}
private void init(Context context, AttributeSet attrs) {
if(context != null){
findViews(context);
}
if(attrs != null){
initAttribute(context,attrs);
}
}
private void initAttribute(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KoalaAppBar);
String title = a.getString(R.styleable.KoalaAppBar_appTitle);
if(title == null || title.isEmpty()){
title = DEFAULT_TITLE;
}
int titleColor = a.getColor(R.styleable.KoalaAppBar_appTitleColor, DEFAULT_TITLE_COLOR);
float fontSize = a.getDimension(R.styleable.KoalaAppBar_appTitleFontSize, DEFAULT_TITLE_FONT_SIZE);
boolean logoVisibility = a.getBoolean(R.styleable.KoalaAppBar_appLogoVisibility , true);
initTitle(title , titleColor , fontSize);
initLogo(logoVisibility);
a.recycle();
}
private void initLogo(boolean logoVisibility) {
if(logoVisibility){
this.imgLogo.setVisibility(VISIBLE);
}else{
this.imgLogo.setVisibility(GONE);
}
}
private void initTitle(String title, int titleColor, float fontSize) {
this.txtTitle.setText(title);
this.txtTitle.setTextColor(titleColor);
this.txtTitle.setTextSize(fontSize);
}
private void findViews(Context context) {
View rootView =
LayoutInflater.from(context).inflate(
R.layout.koala_appbar,
this,
true
);
this.txtTitle = rootView.findViewById(R.id.appBar_txtTitle);
this.imgBack = rootView.findViewById(R.id.appBar_imgBack);
this.imgLogo = rootView.findViewById(R.id.appbar_imgLogo);
}
}
或者您可以使用它。...
这在Chrome上也应该可以正常工作。您正在使用哪个版本的TinyMCE?
顺便说一句,要解决此问题,请先打开tiny_mce_src.js文件并查找
tinyMCE.init({
mode : "textareas",
theme : "advanced",
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : '',
});
并将其设置为
forced_root_block : 'p',
谢谢