File size: 1,938 Bytes
27b0d61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<script context="module" lang="ts">
	export { default as BaseMarkdown } from "./shared/Markdown.svelte";
	export { default as BaseExample } from "./Example.svelte";
</script>

<script lang="ts">
	import { Gradio } from "@gradio/utils";
	import Markdown from "./shared/Markdown.svelte";

	import { StatusTracker } from "@gradio/statustracker";
	import { Block } from "@gradio/atoms";

	import type { MarkdownProps, MarkdownEvents } from "./types";

	let props = $props();
	const gradio = new Gradio<MarkdownEvents, MarkdownProps>(props);
</script>

<Block
	visible={gradio.shared.visible}
	elem_id={gradio.shared.elem_id}
	elem_classes={gradio.shared.elem_classes}
	container={gradio.shared.container}
	allow_overflow={true}
	overflow_behavior="auto"
	height={gradio.props.height}
	min_height={gradio.props.min_height}
	max_height={gradio.props.max_height}
>
	<StatusTracker
		autoscroll={gradio.shared.autoscroll}
		i18n={gradio.i18n}
		{...gradio.shared.loading_status}
		variant="center"
		on:clear_status={() =>
			gradio.dispatch("clear_status", gradio.shared.loading_status)}
	/>
	<div
		class:padding={gradio.props.padding}
		class:pending={gradio.shared.loading_status?.status === "pending"}
	>
		<Markdown
			value={gradio.props.value}
			elem_classes={gradio.shared.elem_classes}
			visible={gradio.shared.visible}
			rtl={gradio.props.rtl}
			on:change={() => gradio.dispatch("change")}
			on:copy={(e) => gradio.dispatch("copy", e.detail)}
			latex_delimiters={gradio.props.latex_delimiters}
			sanitize_html={gradio.props.sanitize_html}
			line_breaks={gradio.props.line_breaks}
			header_links={gradio.props.header_links}
			show_copy_button={gradio.props.buttons?.includes("copy")}
			loading_status={gradio.shared.loading_status}
			theme_mode={gradio.shared.theme_mode}
		/>
	</div>
</Block>

<style>
	div {
		transition: 150ms;
	}

	.pending {
		opacity: 0.2;
	}

	.padding {
		padding: var(--block-padding);
	}
</style>