Monaco 编辑器如何突出显示函数参数名称

问题描述 投票:0回答:2

我想突出显示参数名称标题并在 Monaco 编辑器中键入(这是我自己编写的语言)

myfunc(1, title ="aab", type="int")

我添加了这个正则表达式。它不起作用(测试网址https://microsoft.github.io/monaco-editor/monarch.html,选择python语言)

argname:[
        [/(?<=[(,])\s*([a-z]+)\s*(?=\=)/g,'argname']
    ],
regex highlight monaco-editor
2个回答
0
投票

我相信在 React 中做到这一点的最佳方法是:

      editorRef.current.editor.createDecorationsCollection([
        {
          range: new editorRef.current.monaco.Range(1, 7, 1, 11), // 1 is line, 7-11 is column
          options: {
            className: "bg-green-800 border border-green-200 rounded-md",
            inlineClassName: `px-0.5`,
            hoverMessage: { value: "HERE WE GO" },
          },
        },
      ]);

-1
投票

颜色由摩纳哥编辑器中的主题定义。定义您自己的主题,如游乐场中所示。

© www.soinside.com 2019 - 2024. All rights reserved.