【发布时间】:2020-04-20 15:39:48
【问题描述】:
QuillJS 没有默认的撤消/重做按钮。我正在尝试将它们添加到工具栏。 Quill 有一个保存了撤消/重做图标的文件夹。在 node_modules 中,还有 undo() 和 redo() 函数。我对编码有点陌生,不知道如何访问这些东西并使它们工作。我正在使用反应。到目前为止,这是我的代码:
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';
import 'react-quill/dist/quill.bubble.css';
class QuillTextEditor extends Component {
constructor(props) {
super(props);
this.modules = {
toolbar: [
[{ 'header': [false, 1, 2, 3] }],
[{ 'align': [] }],
['bold', 'italic', 'underline',],
[{'list': 'ordered'}, {'list': 'bullet'}],
[{ 'indent': '-1'}, { 'indent': '+1' }],
[{ 'script': 'super' }, 'strike'],
[{ 'color': [] }, { 'background': [] }],
['link', 'image'],
]
};
this.formats = [
'header',
'align',
'bold', 'italic', 'underline',
'list', 'bullet',
'indent', 'indent',
'script', 'strike',
'color', 'background',
'link', 'image',
];
}
render() {
return (
<div>
<ReactQuill
theme="snow"
modules={this.modules}
formats={this.formats}
value={''}/>
</div>
</div>
);
}
}
export default QuillTextEditor;
有谁知道我需要写什么代码以及在哪里添加撤消/重做图标到工具栏,这些图标连接到 Quill 中内置的撤消/重做功能?我已经尝试了几天,但无法弄清楚。
【问题讨论】: