我想在
ACE editor中重置撤消堆栈.行为应该是:
>我在编辑器上做了一些修改.
>调用一些魔术功能重置撤消堆栈
>当尝试撤消时,这将不可能,因为撤消栈被重置.
我想这与ACE的UndoManager
有关,但我不知道如何在下面的例子中使用它.
var editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/markdown"); setTimeout(function() { editor.setValue("And now how can I reset the\nundo stack,so pressing\nCTRL+Z (or Command + Z) will *NOT*\ngo back to prevIoUs value?",-1); },3000);
#editor { position: absolute; top: 0; right: 0; bottom: 0; left: 0; font-size: 25px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script> <div id="editor">This value will be changed in 3 seconds.</div>
我已经看过编辑器和editor.session的原型找到一些帮助功能,但没有成功.
解决方法
是的,UndoManager是保持所有历史的课程.
解决方案是使用空白/新创建的类初始化会话.
解决方案是使用空白/新创建的类初始化会话.
查看该片段.
var editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/markdown"); setTimeout(function() { editor.setValue("And now how can I reset the\nundo stack,-1); editor.getSession().setUndoManager(new ace.UndoManager()) },3000);
#editor { position: absolute; top: 0; right: 0; bottom: 0; left: 0; font-size: 25px; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/ace.js"></script> <div id="editor">This value will be changed in 3 seconds.</div>