Ion*_*zău 17 javascript undo ace-editor
我想在ACE编辑器中重置撤消堆栈.行为应该是:
我想这与UndoManagerACE有关,但我不知道如何在以下示例中使用它.
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);Run Code Online (Sandbox Code Playgroud)
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
font-size: 25px;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
我已经调查editor和editor.session原型找一些辅助功能,但没有成功.
skb*_*ly7 23
是的,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);
editor.getSession().setUndoManager(new ace.UndoManager())
}, 3000);Run Code Online (Sandbox Code Playgroud)
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
font-size: 25px;
}Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
使用editor.session.setValue()或致电editor.session.getUndoManager().reset();请参阅https://github.com/ajaxorg/ace/blob/v1.1.9/lib/ace/edit_session.js#L279
| 归档时间: |
|
| 查看次数: |
4316 次 |
| 最近记录: |