React项目中使用富文本编辑器,使用插件powerpaste(解决了粘贴内容没有格式的问题)、lineheight(行高)、indent2em(首行缩进)。
官方文档中不需要引入,但我的项目中不引入无效!!
import lineheight from 'tinymce/plugins/lineheight'
import indent2em from 'tinymce/plugins/indent2em'
init={{
plugins: ['lineheight', 'powerpaste', 'indent2em'], // powerpaste只需要在plugins配置
toolbar: 'lineheight indent2em',
}}
同时,增加了按下tab键首行缩进的功能
init={{
setup: function (editor) {
editor.on('keydown', function (evt) {
if (evt.keyCode == 9) {
if (evt.shiftKey) {
editor.execCommand('Outdent');
} else {
editor.execCommand('Indent');
}
evt.preventDefault();
evt.stopPropagation();
}
})
}
}}