我想突出显示参数名称标题并在 Monaco 编辑器中键入(这是我自己编写的语言)
myfunc(1, title ="aab", type="int")
我添加了这个正则表达式。它不起作用(测试网址https://microsoft.github.io/monaco-editor/monarch.html,选择python语言)
argname:[
[/(?<=[(,])\s*([a-z]+)\s*(?=\=)/g,'argname']
],
我相信在 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" },
},
},
]);
颜色由摩纳哥编辑器中的主题定义。定义您自己的主题,如游乐场中所示。