Skip to content

Commit

Permalink
fix: simplify drauu setup
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 17, 2021
1 parent b6c10c9 commit 2340f07
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 17 deletions.
3 changes: 1 addition & 2 deletions packages/client/constants.ts
@@ -1,10 +1,9 @@
import { ComputedRef, InjectionKey, Ref } from 'vue'
import { InjectionKey, Ref } from 'vue'

export const injectionClicks: InjectionKey<Ref<number>> = Symbol('v-click-clicks')
export const injectionClicksElements: InjectionKey<Ref<(Element | string)[]>> = Symbol('v-click-clicks-elements')
export const injectionOrderMap: InjectionKey<Ref<Map<number, HTMLElement[]>>> = Symbol('v-click-clicks-order-map')
export const injectionClicksDisabled: InjectionKey<Ref<boolean>> = Symbol('v-click-clicks-disabled')
export const injectionSlideScale: InjectionKey<ComputedRef<number>> = Symbol('slidev-slide-scale')

export const CLASS_VCLICK_TARGET = 'slidev-vclick-target'
export const CLASS_VCLICK_HIDDEN = 'slidev-vclick-hidden'
Expand Down
5 changes: 1 addition & 4 deletions packages/client/internals/DrawingLayer.vue
@@ -1,14 +1,11 @@
<script setup lang="ts">
import { onMounted, ref, watch, inject, onBeforeUnmount } from 'vue'
import { onMounted, ref, onBeforeUnmount } from 'vue'
import { drauu, loadCanvas } from '../logic/drawings'
import { injectionSlideScale } from '../constants'
const scale = inject(injectionSlideScale)!
const svg = ref<SVGSVGElement>()
onMounted(() => {
drauu.mount(svg.value!, svg.value!.parentElement!)
watch(scale, scale => drauu.options.coordinateScale = 1 / scale, { immediate: true })
loadCanvas()
})
Expand Down
3 changes: 0 additions & 3 deletions packages/client/internals/SlideContainer.vue
Expand Up @@ -2,7 +2,6 @@
import { useElementSize } from '@vueuse/core'
import { computed, provide, ref, watchEffect } from 'vue'
import { slideAspect, slideWidth, slideHeight, configs } from '../env'
import { injectionSlideScale } from '../constants'
const props = defineProps({
width: {
Expand Down Expand Up @@ -51,8 +50,6 @@ const className = computed(() => ({
'select-none': !configs.selectable,
'slidev-code-line-numbers': configs.lineNumbers,
}))
provide(injectionSlideScale, scale)
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Expand Up @@ -19,7 +19,7 @@
"@vueuse/head": "^0.6.0",
"@vueuse/motion": "^1.6.0",
"codemirror": "^5.62.3",
"drauu": "0.1.0",
"drauu": "^0.1.2",
"file-saver": "^2.0.5",
"js-base64": "^3.7.1",
"js-yaml": "^4.1.0",
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2340f07

Please sign in to comment.