0

monaco editor在我的反应应用程序中实现,但它只显示一种颜色,我无法弄清楚。我也尝试过使用默认主题,没有自定义主题,仍然是同样的问题

monaco.editor.defineTheme('customTheme', {
  base: 'vs-dark',
  inherit: true,
  rules: [
    { token: 'green', background: '#457EFF', foreground: '#457EFF' },
    {
      token: 'red',
      background: '#457EFF',
      foreground: '#457EFF',
    },
    { token: 'green', background: '#900000', foreground: '900000' },
  ],
  colors: {
    'editor.background': '#0C0F17',
  },
});
if (monacoEl.current) {
  setEditor(
    monaco.editor.create(monacoEl.current!, {
      readOnly: false,
      value: ["function DestinationCard() {\n\talert('Hello DestinationCard!');\n}"].join('\n'),
      // automaticLayout: true,
      language: 'typescript',
      // theme: 'vs-dark',
      theme: 'customTheme',
      minimap: {
        enabled: false,
      },
    }),
  );
}

<div className={style.codeView} ref={monacoEl as RefObject<HTMLDivElement>} />
4

0 回答 0