gpt4 book ai didi

javascript - TinyMCE setContent 不清除撤销历史

转载 作者:太空宇宙 更新时间:2023-11-04 14:58:10 24 4
gpt4 key购买 nike

我在表单中使用了 angular tinyMCE 指令。提交后,我使用此命令清除文本区域:

tinyMCE.activeEditor.setContent('');

还有这个:$scope.tinymceModel =''; 来清除模型。我的表单在模态中。当我再次打开模式时,textarea 看起来很清楚,但 TinyMCE 中的“撤消”按钮处于事件状态,如果我单击它,我可以看到旧内容。是否可以重置并清除 TinyMCE 撤消历史记录?这是 html 部分:

<textarea id="elm1" ui-tinymce="tinymceOptions" ng-model="tinymceModel" auto-focus id="elm1" rows="8" cols="100"></textarea>

这是选项

$scope.tinymceModel = '';
$scope.tinymceOptions = {
height: 420,
language:'it',
theme: "modern",
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor"
],
content_css: "css/partials/content.css",
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage",
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
setup : function(ed){
ed.on('keyup', function(e) {
get_ed_content = tinymce.activeEditor.getContent();
if(get_ed_content != '' && get_ed_content != undefined && get_ed_content != null) {
$scope.tinyHasContent = true;
} else {
$scope.tinyHasContent = false;
}
});
ed.on('init', function()
{
this.getDoc().body.style.fontSize = '1.2em';
});

}
};

谢谢

最佳答案

设置新内容后,添加对 undoManager.clear() 的调用。像这样:

tinymce.activeEditor.setContent('');
tinymce.activeEditor.undoManager.clear()

这将清除事件编辑器的撤消历史记录,因此您无法返回到之前的内容。

关于javascript - TinyMCE setContent 不清除撤销历史,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38592498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com