feat(ui): code blocks and chat messages from shadcn-vue's code-block, message and bubble
This commit is contained in:
1 parent
d876c150eb
commit
63adbc71ef
67 files changed
+1770
-310
No files matched your search
@@ -0,0 +1,38 @@
|
||||
<script setup lang="ts">
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
CodeBlock,
|
||||
CodeBlockActions,
|
||||
CodeBlockContent,
|
||||
CodeBlockCopyButton,
|
||||
CodeBlockLine,
|
||||
CodeBlockToken,
|
||||
useHighlightedCode,
|
||||
} from "@/components/ui/code-block";
|
||||
|
||||
/**
|
||||
* Code or a payload with a copy button that appears on hover or focus. The
|
||||
* text is shown verbatim and wrapped: stored payloads are mostly long unbroken
|
||||
* tokens (URLs, hashes, base64), which must not push the panel past its edge.
|
||||
* A language the highlighter does not know renders plain.
|
||||
*/
|
||||
const props = defineProps<{ code: string; lang?: string; class?: string }>();
|
||||
|
||||
const lines = useHighlightedCode(
|
||||
() => props.code,
|
||||
() => props.lang || "text",
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CodeBlock :class="cn('bg-muted', props.class)">
|
||||
<CodeBlockActions>
|
||||
<CodeBlockCopyButton :value="code" />
|
||||
</CodeBlockActions>
|
||||
<CodeBlockContent wrap class="max-h-[60vh] pe-10 text-xs">
|
||||
<CodeBlockLine v-for="(line, index) in lines" :key="index">
|
||||
<CodeBlockToken v-for="(token, i) in line" :key="i" :token="token" />
|
||||
</CodeBlockLine>
|
||||
</CodeBlockContent>
|
||||
</CodeBlock>
|
||||
</template>
|
||||
Reference in new issue
Block a user