简体   繁体   English

如何在 Monaco 编辑器中以编程方式设置 `tabFocusMode`

[英]How to programatically set `tabFocusMode` in Monaco editor

I'm attempting to create a single line Monaco editor, which will exist on a larger forms page.我正在尝试创建单行 Monaco 编辑器,它将存在于更大的 forms 页面上。

For accessibility reasons, I want to the tab key to not be trapped by Monaco, and rather let the browser handle tabbing to the next input field.出于可访问性原因,我希望 Tab 键不被 Monaco 困住,而是让浏览器处理跳转到下一个输入字段。

Internally, the tabFocusMode setting is what controls this, but it is initialized to false and I can't seem to find a way to override it programatically.在内部, tabFocusMode设置是控制它的,但它被初始化为false ,我似乎无法找到一种方法来以编程方式覆盖它。

The only other thing I've found is this feature request for the same thing我发现的唯一另一件事是对同一事物的此功能请求

I was struggling with the same thing and found a "hacky" solution which uses the internal API. It works with the current version of Monaco (0.34.1).我一直在为同样的事情苦苦挣扎,发现了一个使用内部 API 的“hacky”解决方案。它适用于当前版本的 Monaco (0.34.1)。

import { TabFocus } from 'monaco-editor/esm/vs/editor/browser/config/tabFocus.js';

TabFocus.setTabFocusMode(true);

Keep in mind that TabFocus is a singleton, so this setting will affect all your Monaco Editor instances.请记住, TabFocus是 singleton,因此此设置将影响您的所有 Monaco Editor 实例。 I ended up setting it in the editor.onDidFocusEditorWidget(() => {});我最终在editor.onDidFocusEditorWidget(() => {});中设置了它event.事件。

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

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