Skip to content

Commit

Permalink
feat(50%): typst
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Sep 14, 2024
1 parent 49055d7 commit cacf2ef
Show file tree
Hide file tree
Showing 6 changed files with 1,565 additions and 53 deletions.
2 changes: 2 additions & 0 deletions extensions/typst/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"access": "public"
},
"dependencies": {
"@myriaddreamin/typst-ts-web-compiler": "0.5.0-rc7",
"@myriaddreamin/typst.ts": "0.5.0-rc7",
"@vue-motion/core": "workspace:*",
"@vue-motion/lib": "workspace:*",
"vue": "^3.4.26"
Expand Down
2 changes: 2 additions & 0 deletions extensions/typst/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Typst } from './index.vue'
export type { TypstOptions } from './index.vue'

Check failure on line 2 in extensions/typst/src/index.ts

View workflow job for this annotation

GitHub Actions / type-check

Module '"*.vue"' has no exported member 'TypstOptions'. Did you mean to use 'import TypstOptions from "*.vue"' instead?
30 changes: 30 additions & 0 deletions extensions/typst/src/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<g v-bind="widget(options)" v-html="compiled"></g>
</template>

<script setup lang="ts">
import { defineWidget } from '@vue-motion/core'
import { widget, type WidgetOptions } from '@vue-motion/lib'
import { onMounted, ref, useSlots } from 'vue'
import { $typst } from '@myriaddreamin/typst.ts/dist/esm/contrib/snippet'
export interface TypstOptions extends WidgetOptions {
width?: number
height?: number
}
const props = defineProps<TypstOptions>()
const options = defineWidget<TypstOptions>(props)
const compiled = ref()
const slots = useSlots()
const content = slots.default ? slots.default().map(vnode => vnode.children).join('') : ''
onMounted(async () => {
console.log(content)
compiled.value = await $typst.svg({
mainContent: content,
})
})
</script>
Loading

0 comments on commit cacf2ef

Please sign in to comment.