2016-07-26 123 views
1

我在窗体中使用angular tinyMCE指令。提交后,我用这个命令来清除textarea的:TinyMCE setContent不清除撤消历史

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'; 
       }); 

      } 
     }; 

感谢

回答

3

在您设定的新内容添加调用undoManager.clear()。类似这样的:

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

这将清除活动编辑器的撤消历史记录,因此您不能回到以前的内容。