Skip to content

Commit d25e66d

Browse files
committed
fix(monaco): height calculate
1 parent 493f26a commit d25e66d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/client/builtin/Monaco.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Learn more: https://sli.dev/guide/syntax.html#monaco-editor
1212
-->
1313

1414
<template>
15-
<iframe ref="iframe" class="text-base w-full" :style="{ height }"></iframe>
15+
<iframe ref="iframe" class="text-base w-full rounded" :style="{ height }"></iframe>
1616
</template>
1717

1818
<script setup lang="ts">
@@ -42,7 +42,8 @@ const props = defineProps({
4242
4343
const id = nanoid()
4444
const code = ref(decode(props.code).trimEnd())
45-
const height = computed(() => props.height === 'auto' ? `${code.value.split(/\r?\n/g).length * 18 + 20}px` : props.height)
45+
const lineHeight = +(getComputedStyle(document.body).getPropertyValue('--slidev-code-line-height') || '18').replace('px', '') || 18
46+
const height = computed(() => props.height === 'auto' ? `${code.value.split(/\r?\n/g).length * lineHeight + 20}px` : props.height)
4647
const isReady = ref(false)
4748
4849
const iframe = ref<HTMLIFrameElement>()

0 commit comments

Comments
 (0)