Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/client/composables/useNav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { slides } from '#slidev/slides'
import { clamp } from '@antfu/utils'
import { parseRangeString } from '@slidev/parser/utils'
import { createSharedComposable } from '@vueuse/core'
import { hideAllPoppers } from 'floating-vue'
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { CLICKS_MAX } from '../constants'
Expand Down Expand Up @@ -118,6 +119,8 @@ export function useNavBase(

watch(currentSlideRoute, (next, prev) => {
navDirection.value = next.no - prev.no
if (prev)
hideAllPoppers()
})

async function openInEditor(url?: string) {
Expand Down
3 changes: 3 additions & 0 deletions packages/slidev/node/syntax/markdown-it/markdown-it-shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ResolvedSlidevOptions } from '@slidev/types'
import type { ShikiTransformer } from 'shiki'
import { isTruthy } from '@antfu/utils'
import { fromHighlighter } from '@shikijs/markdown-it/core'
import { transformerTwoslashConditional } from '../transform/twoslash-conditional'
import { escapeVueInCode } from '../transform/utils'

export default async function MarkdownItShiki({ data: { config }, mode, utils }: ResolvedSlidevOptions) {
Expand All @@ -16,6 +17,8 @@ export default async function MarkdownItShiki({ data: { config }, mode, utils }:
},
},
}),
(config.twoslash === true || config.twoslash === mode)
&& transformerTwoslashConditional(),
{
pre(pre) {
this.addClassToHast(pre, 'slidev-code')
Expand Down
17 changes: 17 additions & 0 deletions packages/slidev/node/syntax/transform/twoslash-conditional.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ShikiTransformer } from 'shiki'

/**
* Custom Twoslash transformer that replaces :shown='true' with conditional logic
* to prevent poppers from being shown during preload
*/
export function transformerTwoslashConditional(): ShikiTransformer {
return {
name: 'slidev:twoslash-conditional',
postprocess(code) {
return code.replace(
/(<v-menu[^>]*):shown=['"]true['"]/g,
'$1:shown="false"',
)
},
}
}
Loading