| 1 | <script setup lang="ts"> |
| 2 | import type { SlidevContextNav } from '../composables/useNav' |
| 3 | import { provideLocal } from '@vueuse/core' |
| 4 | import { computed, reactive, shallowRef, useTemplateRef } from 'vue' |
| 5 | import { GlobalBottom, GlobalTop } from '#slidev/global-layers' |
| 6 | import { injectionSlideElement, injectionSlidevContext } from '../constants' |
| 7 | import { configs, slideHeight, slideWidth } from '../env' |
| 8 | import { getSlideClass } from '../utils' |
| 9 | import SlideWrapper from './SlideWrapper.vue' |
| 10 | |
| 11 | const { nav } = defineProps<{ |
| 12 | nav: SlidevContextNav |
| 13 | }>() |
| 14 | |
| 15 | const route = computed(() => nav.currentSlideRoute.value) |
| 16 | |
| 17 | const style = computed(() => ({ |
| 18 | height: `${slideHeight.value}px`, |
| 19 | width: `${slideWidth.value}px`, |
| 20 | })) |
| 21 | |
| 22 | const DrawingPreview = shallowRef<any>() |
| 23 | if (__SLIDEV_FEATURE_DRAWINGS__ || __SLIDEV_FEATURE_DRAWINGS_PERSIST__) |
| 24 | import('./DrawingPreview.vue').then(v => (DrawingPreview.value = v.default)) |
| 25 | |
| 26 | const id = computed(() => |
| 27 | `${route.value.no.toString().padStart(3, '0')}-${(nav.clicks.value + 1).toString().padStart(2, '0')}`, |
| 28 | ) |
| 29 | |
| 30 | provideLocal(injectionSlidevContext, reactive({ |
| 31 | nav, |
| 32 | configs, |
| 33 | themeConfigs: computed(() => configs.themeConfig), |
| 34 | })) |
| 35 | |
| 36 | provideLocal(injectionSlideElement, useTemplateRef('slide-element')) |
| 37 | </script> |
| 38 | |
| 39 | <template> |
| 40 | <div :id="id" ref="slide-element" class="print-slide-container" :style="style"> |
| 41 | <GlobalBottom /> |
| 42 | |
| 43 | <SlideWrapper |
| 44 | :clicks-context="nav.clicksContext.value" |
| 45 | :class="getSlideClass(route)" |
| 46 | :route="route" |
| 47 | /> |
| 48 | <template |
| 49 | v-if=" |
| 50 | (__SLIDEV_FEATURE_DRAWINGS__ |
| 51 | || __SLIDEV_FEATURE_DRAWINGS_PERSIST__) |
| 52 | && DrawingPreview |
| 53 | " |
| 54 | > |
| 55 | <DrawingPreview :page="route.no" /> |
| 56 | </template> |
| 57 | |
| 58 | <GlobalTop /> |
| 59 | </div> |
| 60 | </template> |
| 61 | |
| 62 | <style scoped lang="postcss"> |
| 63 | .print-slide-container { |
| 64 | @apply relative overflow-hidden break-after-page translate-0 bg-main; |
| 65 | } |
| 66 | </style> |
| 67 |