最近做一个项目需要富文本编辑器,使用ueditor以后发现图片选择左对齐或右对齐后,并不能直接保存到源码中。花了点时间跟踪源码后发现问题其实是配置问题。
解决办法:
找到ueditor的配置文件ueditor.config.js,里面搜索 whiteList 然后在下面找到img,在里面添加 'style'。
添加后如下:
img : [ 'src', 'alt', 'title', 'width', 'height', 'id', '_src','loadingclass', 'class', 'data-latex', 'style' ]