简体   繁体   English

无法在摩纳哥编辑器中撤消

[英]Not able to do Undo in monaco editor

In my angular 7 project I'm using monaco editor for the coding.在我的 angular 7 项目中,我使用 monaco 编辑器进行编码。 If I do some change in the code and then press ctrl+z then it will undo the code, but when I do some change then I am changing the coding language after that if I press ctrl+z then it will not restore the previous code.如果我对代码进行了一些更改,然后按 ctrl+z 则它将撤消代码,但是当我进行一些更改时,如果我按 ctrl+z 之后我将更改编码语言,则它不会恢复以前的代码. So the issue is that after changing the coding language the previous code is not restored by pressing ctrl+z.所以问题是,更改编码语言后,按ctrl+z无法恢复之前的代码。

Please help me solve the above issue.请帮我解决上述问题。

Use executeEdits to apply changes while keeping the undo stack:使用executeEdits应用更改,同时保留撤消堆栈:

const myText = 'the replacement text';

// Select all text
const fullRange = editor.getModel().getFullModelRange();

// Apply the text over the range
editor.executeEdits(null, [{
  text: myText,
  range: fullRange
}]);

Editor API: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandalonecodeeditor.html#executeedits编辑器 API: https : //microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandalonecodeeditor.html#executeedits

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM