-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
PrintContainer.vue
56 lines (46 loc) · 1.41 KB
/
PrintContainer.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<script setup lang="ts">
import { parseRangeString } from '@slidev/parser/core'
import { computed, provide } from 'vue'
import { configs, slideAspect, slideWidth } from '../env'
import { injectionSlideScale } from '../constants'
import { rawRoutes, route } from '../logic/nav'
import PrintSlide from './PrintSlide.vue'
const props = defineProps<{
width: number
}>()
const width = computed(() => props.width)
const height = computed(() => props.width / slideAspect)
const screenAspect = computed(() => width.value / height.value)
const scale = computed(() => {
if (screenAspect.value < slideAspect)
return width.value / slideWidth
return (height.value * slideAspect) / slideWidth
})
// Remove the "end" slide
let routes = rawRoutes.slice(0, -1)
if (route.value.query.range) {
const r = parseRangeString(routes.length, route.value.query.range)
routes = r.map(i => routes[i - 1])
}
const className = computed(() => ({
'select-none': !configs.selectable,
'slidev-code-line-numbers': configs.lineNumbers,
}))
provide(injectionSlideScale, scale)
</script>
<template>
<div id="print-container" :class="className">
<div id="print-content">
<PrintSlide v-for="route of routes" :key="route.path" :route="route" />
</div>
<slot name="controls" />
</div>
</template>
<style lang="postcss">
#print-content {
@apply bg-main;
}
.slide-container {
@apply relative overflow-hidden break-after-page;
}
</style>