在 tinymce 中单击我的自定义按钮时调用撤消?
Call undo when click my custom button in tinymce?
在 tinymce 中点击我的自定义按钮后如何运行撤消功能。
到运行撤消功能:
editor.undoManager.undo();
键入此代码
function updateButtons(history) {
$('#undo').attr('disabled',!history.canUndo());
}
function setEditorContents(contents) {$('#editor').val(contents);}
$(function(){
var history = new SimpleUndo({
maxLength: 200,
provider: function(done) {
done($('#editor').val());
},
onUpdate: function() {
//onUpdate is called in constructor, making history undefined
if (!history) return;
updateButtons(history);
}
});
$('#undo').click(function() {
history.undo(setEditorContents);
});
$('#editor').keypress(function() {
history.save();
});
updateButtons(history);
});
在 tinymce 中点击我的自定义按钮后如何运行撤消功能。
到运行撤消功能:
editor.undoManager.undo();
键入此代码
function updateButtons(history) {
$('#undo').attr('disabled',!history.canUndo());
}
function setEditorContents(contents) {$('#editor').val(contents);}
$(function(){
var history = new SimpleUndo({
maxLength: 200,
provider: function(done) {
done($('#editor').val());
},
onUpdate: function() {
//onUpdate is called in constructor, making history undefined
if (!history) return;
updateButtons(history);
}
});
$('#undo').click(function() {
history.undo(setEditorContents);
});
$('#editor').keypress(function() {
history.save();
});
updateButtons(history);
});