简体   繁体   English

在monaco编辑器中,是否有一个用于捕获格式事件的事件?

[英]In monaco editor, is there an event for catching format event?

cont editor = monaco.editor.create(element, {
            value: text,
            language: mode,
            automaticLayout: true,
            autoIndent: true,
            contextmenu: false,
            formatOnType: true
        });
editor.trigger('any', 'editor.action.formatDocument');

Is there a way to pass a callback to the trigger method, or catch an event for the format finished action? 有没有办法将回调传递给trigger方法,或为格式化完成操作捕获事件?

The following syntax will run the console.log statement after the action has been executed, using a promise. 执行动作后,将使用promise运行以下console.log语句。

editor.getAction('editor.action.formatDocument').run().then(() => console.log('finished'));

Answer from: 答案来自:

https://github.com/Microsoft/monaco-editor/issues/978 https://github.com/Microsoft/monaco-editor/issues/978

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

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