QuillJS没有默认的撤消/重做按钮。我正在尝试将它们添加到工具栏。 Quill有一个保存了撤消/重做图标的文件夹。在node_modules中,还有undo()和redo()函数。我对编码有点陌生,不知道如何访问这些东西并使它们工作。我正在使用React。到目前为止,这是我的代码:
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中吗?
嗨。不幸的是,我仍然不知道如何将按钮连接到本地Quill函数。但是您可以做一些其他的事情来达到预期的效果。
看看this。 搜索项目020、021和026。
您可以添加一个新按钮,并将其设置为调用以下代码:
quill.history.undo();
[如果还有其他问题,请发表评论。我会尽快答复您。