摩纳哥编辑-跟随链接钩

Sjo*_*erd 6 monaco-editor

研究员,

我很难找到“ ctrl + click”(跟随链接)编辑器选项的钩子。

在演示页面上,该链接在新选项卡中打开:https : //microsoft.github.io/monaco-editor/index.html

经过彻底的谷歌搜索,什么都没找到,我搜索了api,但只找到不包含跟随链接或ctrl + click动作的上下文动作。

我想解析文件路径并触发自己的一些自定义方法,而不是在新选项卡中打开。

你们中有人发现在哪里添加/修改行为的线索吗?

先感谢您。

the*_*MGN 0

window.open除了挂钩和检查堆栈跟踪之外,我找不到更好的方法来执行此操作。不理想,但它有效。

const realopen = window.open;
function openShim(url?: string | URL, target?: string, features?: string) {
    const calledFromMonaco = new Error().stack?.includes("windowOpenNoOpener");
    if (calledFromMonaco) {
        return null;
    }
    return realopen(url, target, features);
}
window.open = openShim;
Run Code Online (Sandbox Code Playgroud)