Files
windmill/frontend/src/lib/components/GraphqlSchemaViewer.svelte
T
GuilhemandClaude Opus 4.7 de76668c10 fix(frontend): align Monaco editor font size with text-xs (#9161)
* fix(frontend): align Monaco editor font size with text-xs across viewports

* fix(frontend): make placeholder lineHeight reactive to fontSize

* fix(frontend): align GraphQL schema viewer font size with text-xs

The read-only GraphQL schema viewer was the lone Monaco instance still
inheriting Monaco's 14px default. Wire it through editorFontSize like
the other editors so it stays in sync with text-xs across viewports.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 23:29:19 +00:00

61 lines
1.3 KiB
Svelte

<script lang="ts">
import { BROWSER } from 'esm-env'
import { editor as meditor, KeyMod, KeyCode } from 'monaco-editor'
import { editorFontSize } from '$lib/editorFontSize.svelte'
import { onDestroy, onMount } from 'svelte'
let divEl: HTMLDivElement | null = $state(null)
let editor: meditor.IStandaloneCodeEditor
interface Props {
code?: string
class?: string
}
let { code = '', class: className = '' }: Props = $props()
async function loadMonaco() {
editor = meditor.create(divEl as HTMLDivElement, {
value: code,
language: 'graphql',
readOnly: true,
automaticLayout: true,
scrollBeyondLastLine: false,
lineNumbers: 'off',
fontSize: editorFontSize.regular,
minimap: { enabled: false }
})
// In VSCode webview (iframe), clipboard operations need to use execCommand
// because the webview has restricted clipboard API access
if (window.parent !== window) {
editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyC, function () {
document.execCommand('copy')
})
}
}
onMount(async () => {
if (BROWSER) {
await loadMonaco()
}
})
$effect(() => {
const fontSize = editorFontSize.regular
if (editor) {
editor.updateOptions({ fontSize })
}
})
onDestroy(() => {
try {
editor && editor.dispose()
} catch (err) {}
})
</script>
<div bind:this={divEl} class="{className} editor"></div>