preview.vue 742 B

12345678910111213141516171819202122232425262728293031323334
  1. <script setup lang="ts">
  2. import type { TipTapPreviewProps } from './types';
  3. import { computed } from 'vue';
  4. import { cn } from '@vben-core/shared/utils';
  5. import './style.css';
  6. const props = withDefaults(defineProps<TipTapPreviewProps>(), {
  7. content: '',
  8. minHeight: 160,
  9. });
  10. const contentMinHeight = computed(() =>
  11. typeof props.minHeight === 'number'
  12. ? `${props.minHeight}px`
  13. : props.minHeight,
  14. );
  15. const previewClass = computed(() =>
  16. cn(
  17. 'vben-tiptap-content',
  18. 'text-foreground bg-transparent p-0 leading-7',
  19. props.class,
  20. ),
  21. );
  22. </script>
  23. <template>
  24. <!-- eslint-disable vue/no-v-html -->
  25. <div
  26. :class="previewClass"
  27. :style="{ minHeight: contentMinHeight }"
  28. v-html="content"
  29. ></div>
  30. </template>