ueditor 判断内容是否为空_百度编辑器(ueditor)的代码块显示功能的设置

百度编辑器(ueditor)功能丰富,在移动端的适配也做的不错,而且自带了代码块的编辑和高亮显示功能。

打开代码块的编辑和显示功能,有下面3个步骤:

1/3 编辑器的菜单配置

注意菜单项的配置是否包括了插入代码的菜单项;

菜单名称:insertcode ,菜单项的默认配置文件是 ueditor.config.js

toolbars = [[    'source','insertcode',    'bold', 'italic', 'underline', 'strikethrough', 'customstyle', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|',    'lineheight', '|','fontfamily', 'fontsize', '|',    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify','indent' ,'removeformat', '|',    'link',    'insertimage',  'insertvideo', 'attachment', '|', 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells',    'spechars']];

2/3 编辑器中插入代码块

配置好菜单后,编辑器工具菜单栏里会显示【代码语言】项的菜单

ab7c955ee83970ed18a7eee6509d74a8.png

编辑代码块内容

f65b66714b8ca0f6f8b1d6c24b93a5b5.png

从html模式可以看到,代码是放在

标签中

3/3 内容显示时代码块的渲染

前端显示内容时,需要引入SyntaxHighlighter插件,并调用初始化方法后才会进行渲染

渲染效果

651afeea3af10cb8144954c416400228.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值