From 386778251aedf845f50d2e1e427466c7b921bfc2 Mon Sep 17 00:00:00 2001 From: Alexander Bentkamp Date: Mon, 29 Jul 2024 22:02:59 +0200 Subject: [PATCH] fix colors in infoview --- demo/src/LeanMonaco.tsx | 2 +- src/infowebview.ts | 9 ++++----- src/leanmonaco.ts | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/demo/src/LeanMonaco.tsx b/demo/src/LeanMonaco.tsx index b8c34aa..2328bd9 100644 --- a/demo/src/LeanMonaco.tsx +++ b/demo/src/LeanMonaco.tsx @@ -12,7 +12,7 @@ function LeanMonacoComponent({options} : {options: LeanMonacoOptions}) { ;(async () => { await leanMonaco.start(options) leanMonaco.setInfoviewElement(infoviewRef.current!) - await leanMonacoEditor.start(codeviewRef.current!, `/project/test${Math.random()}.lean`, '#check Nat') + await leanMonacoEditor.start(codeviewRef.current!, `/project/test.lean`, '#check Nat') })() return () => { diff --git a/src/infowebview.ts b/src/infowebview.ts index 0be95da..81e4b5f 100644 --- a/src/infowebview.ts +++ b/src/infowebview.ts @@ -79,14 +79,13 @@ export class IFrameInfoWebviewFactory implements InfoWebviewFactory { private updateCssVars() { const theme = this.themeService.getColorTheme(); - const vscodeColors = ((colorUtils as any).getColorRegistry().getColors() as Array<{id:string}>).reduce((colors, entry) => { + const documentStyle = this.iframe.contentDocument?.documentElement.style; + for (const entry of ((colorUtils as any).getColorRegistry().getColors() as Array<{id:string}>)) { const color = theme.getColor(entry.id); if (color) { - colors = colors + '--vscode-' + entry.id.replace('.', '-') + ': ' + color.toString() + "; "; + documentStyle?.setProperty('--vscode-' + entry.id.replace('.', '-'), color.toString()); } - return colors - }, ''); - this.iframe.contentDocument?.documentElement.setAttribute('style', vscodeColors) + } this.iframe.contentDocument?.documentElement.setAttribute('class', this.apiThemeClassName(theme)) } diff --git a/src/leanmonaco.ts b/src/leanmonaco.ts index 468d123..983a844 100644 --- a/src/leanmonaco.ts +++ b/src/leanmonaco.ts @@ -200,6 +200,7 @@ export class LeanMonaco { "configuration": "./language-configuration.json" } ], + colors: packageJson.contributes.colors as any, "grammars": [ { "language": "lean4",