-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49055d7
commit cacf2ef
Showing
6 changed files
with
1,565 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.