Upload folder using huggingface_hub
Browse files- 5.49.1/markdown/Example.svelte +42 -0
- 5.49.1/markdown/Index.svelte +92 -0
- 5.49.1/markdown/package.json +42 -0
- 5.49.1/markdown/shared/Markdown.svelte +108 -0
5.49.1/markdown/Example.svelte
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { MarkdownCode } from "@gradio/markdown-code";
|
| 3 |
+
|
| 4 |
+
export let value: string | null;
|
| 5 |
+
export let type: "gallery" | "table";
|
| 6 |
+
export let selected = false;
|
| 7 |
+
export let sanitize_html: boolean;
|
| 8 |
+
export let line_breaks: boolean;
|
| 9 |
+
export let latex_delimiters: {
|
| 10 |
+
left: string;
|
| 11 |
+
right: string;
|
| 12 |
+
display: boolean;
|
| 13 |
+
}[];
|
| 14 |
+
|
| 15 |
+
function truncate_text(text: string | null, max_length = 60): string {
|
| 16 |
+
if (!text) return "";
|
| 17 |
+
const str = String(text);
|
| 18 |
+
if (str.length <= max_length) return str;
|
| 19 |
+
return str.slice(0, max_length) + "...";
|
| 20 |
+
}
|
| 21 |
+
</script>
|
| 22 |
+
|
| 23 |
+
<div
|
| 24 |
+
class:table={type === "table"}
|
| 25 |
+
class:gallery={type === "gallery"}
|
| 26 |
+
class:selected
|
| 27 |
+
class="prose"
|
| 28 |
+
>
|
| 29 |
+
<MarkdownCode
|
| 30 |
+
message={truncate_text(value)}
|
| 31 |
+
{latex_delimiters}
|
| 32 |
+
{sanitize_html}
|
| 33 |
+
{line_breaks}
|
| 34 |
+
chatbot={false}
|
| 35 |
+
/>
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
<style>
|
| 39 |
+
.gallery {
|
| 40 |
+
padding: var(--size-1) var(--size-2);
|
| 41 |
+
}
|
| 42 |
+
</style>
|
5.49.1/markdown/Index.svelte
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script context="module" lang="ts">
|
| 2 |
+
export { default as BaseMarkdown } from "./shared/Markdown.svelte";
|
| 3 |
+
export { default as BaseExample } from "./Example.svelte";
|
| 4 |
+
</script>
|
| 5 |
+
|
| 6 |
+
<script lang="ts">
|
| 7 |
+
import type { Gradio, CopyData } from "@gradio/utils";
|
| 8 |
+
import Markdown from "./shared/Markdown.svelte";
|
| 9 |
+
import type { ThemeMode } from "@gradio/core";
|
| 10 |
+
|
| 11 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 12 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 13 |
+
import { Block } from "@gradio/atoms";
|
| 14 |
+
|
| 15 |
+
export let elem_id = "";
|
| 16 |
+
export let elem_classes: string[] = [];
|
| 17 |
+
export let visible: boolean | "hidden" = true;
|
| 18 |
+
export let value = "";
|
| 19 |
+
export let loading_status: LoadingStatus;
|
| 20 |
+
export let rtl = false;
|
| 21 |
+
export let sanitize_html = true;
|
| 22 |
+
export let line_breaks = false;
|
| 23 |
+
export let gradio: Gradio<{
|
| 24 |
+
change: never;
|
| 25 |
+
copy: CopyData;
|
| 26 |
+
clear_status: LoadingStatus;
|
| 27 |
+
}>;
|
| 28 |
+
export let latex_delimiters: {
|
| 29 |
+
left: string;
|
| 30 |
+
right: string;
|
| 31 |
+
display: boolean;
|
| 32 |
+
}[];
|
| 33 |
+
export let header_links = false;
|
| 34 |
+
export let height: number | string | undefined;
|
| 35 |
+
export let min_height: number | string | undefined;
|
| 36 |
+
export let max_height: number | string | undefined;
|
| 37 |
+
export let show_copy_button = false;
|
| 38 |
+
export let container = false;
|
| 39 |
+
export let theme_mode: ThemeMode;
|
| 40 |
+
export let padding = false;
|
| 41 |
+
</script>
|
| 42 |
+
|
| 43 |
+
<Block
|
| 44 |
+
{visible}
|
| 45 |
+
{elem_id}
|
| 46 |
+
{elem_classes}
|
| 47 |
+
{container}
|
| 48 |
+
allow_overflow={true}
|
| 49 |
+
overflow_behavior="auto"
|
| 50 |
+
{height}
|
| 51 |
+
{min_height}
|
| 52 |
+
{max_height}
|
| 53 |
+
>
|
| 54 |
+
<StatusTracker
|
| 55 |
+
autoscroll={gradio.autoscroll}
|
| 56 |
+
i18n={gradio.i18n}
|
| 57 |
+
{...loading_status}
|
| 58 |
+
variant="center"
|
| 59 |
+
on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
|
| 60 |
+
/>
|
| 61 |
+
<div class:padding class:pending={loading_status?.status === "pending"}>
|
| 62 |
+
<Markdown
|
| 63 |
+
{value}
|
| 64 |
+
{elem_classes}
|
| 65 |
+
{visible}
|
| 66 |
+
{rtl}
|
| 67 |
+
on:change={() => gradio.dispatch("change")}
|
| 68 |
+
on:copy={(e) => gradio.dispatch("copy", e.detail)}
|
| 69 |
+
{latex_delimiters}
|
| 70 |
+
{sanitize_html}
|
| 71 |
+
{line_breaks}
|
| 72 |
+
{header_links}
|
| 73 |
+
{show_copy_button}
|
| 74 |
+
{loading_status}
|
| 75 |
+
{theme_mode}
|
| 76 |
+
/>
|
| 77 |
+
</div>
|
| 78 |
+
</Block>
|
| 79 |
+
|
| 80 |
+
<style>
|
| 81 |
+
div {
|
| 82 |
+
transition: 150ms;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
.pending {
|
| 86 |
+
opacity: 0.2;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
.padding {
|
| 90 |
+
padding: var(--block-padding);
|
| 91 |
+
}
|
| 92 |
+
</style>
|
5.49.1/markdown/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/markdown",
|
| 3 |
+
"version": "0.13.22",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"main": "Index.svelte",
|
| 11 |
+
"exports": {
|
| 12 |
+
".": {
|
| 13 |
+
"gradio": "./Index.svelte",
|
| 14 |
+
"svelte": "./dist/Index.svelte",
|
| 15 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 16 |
+
},
|
| 17 |
+
"./example": {
|
| 18 |
+
"gradio": "./Example.svelte",
|
| 19 |
+
"svelte": "./dist/Example.svelte",
|
| 20 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 21 |
+
},
|
| 22 |
+
"./package.json": "./package.json"
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"@gradio/atoms": "workspace:^",
|
| 26 |
+
"@gradio/icons": "workspace:^",
|
| 27 |
+
"@gradio/statustracker": "workspace:^",
|
| 28 |
+
"@gradio/utils": "workspace:^",
|
| 29 |
+
"@gradio/markdown-code": "workspace:^"
|
| 30 |
+
},
|
| 31 |
+
"devDependencies": {
|
| 32 |
+
"@gradio/preview": "workspace:^"
|
| 33 |
+
},
|
| 34 |
+
"peerDependencies": {
|
| 35 |
+
"svelte": "^4.0.0"
|
| 36 |
+
},
|
| 37 |
+
"repository": {
|
| 38 |
+
"type": "git",
|
| 39 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 40 |
+
"directory": "js/markdown"
|
| 41 |
+
}
|
| 42 |
+
}
|
5.49.1/markdown/shared/Markdown.svelte
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher } from "svelte";
|
| 3 |
+
import { copy, css_units } from "@gradio/utils";
|
| 4 |
+
import type { CopyData } from "@gradio/utils";
|
| 5 |
+
import { Copy, Check } from "@gradio/icons";
|
| 6 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 7 |
+
import { IconButton, IconButtonWrapper } from "@gradio/atoms";
|
| 8 |
+
import type { ThemeMode } from "@gradio/core";
|
| 9 |
+
|
| 10 |
+
import { MarkdownCode } from "@gradio/markdown-code";
|
| 11 |
+
|
| 12 |
+
export let elem_classes: string[] = [];
|
| 13 |
+
export let visible: boolean | "hidden" = true;
|
| 14 |
+
export let value: string;
|
| 15 |
+
export let min_height: number | string | undefined = undefined;
|
| 16 |
+
export let rtl = false;
|
| 17 |
+
export let sanitize_html = true;
|
| 18 |
+
export let line_breaks = false;
|
| 19 |
+
export let latex_delimiters: {
|
| 20 |
+
left: string;
|
| 21 |
+
right: string;
|
| 22 |
+
display: boolean;
|
| 23 |
+
}[];
|
| 24 |
+
export let header_links = false;
|
| 25 |
+
export let height: number | string | undefined = undefined;
|
| 26 |
+
export let show_copy_button = false;
|
| 27 |
+
export let loading_status: LoadingStatus | undefined = undefined;
|
| 28 |
+
export let theme_mode: ThemeMode;
|
| 29 |
+
let copied = false;
|
| 30 |
+
let timer: NodeJS.Timeout;
|
| 31 |
+
|
| 32 |
+
const dispatch = createEventDispatcher<{
|
| 33 |
+
change: undefined;
|
| 34 |
+
copy: CopyData;
|
| 35 |
+
}>();
|
| 36 |
+
|
| 37 |
+
$: value, dispatch("change");
|
| 38 |
+
|
| 39 |
+
async function handle_copy(): Promise<void> {
|
| 40 |
+
if ("clipboard" in navigator) {
|
| 41 |
+
await navigator.clipboard.writeText(value);
|
| 42 |
+
dispatch("copy", { value: value });
|
| 43 |
+
copy_feedback();
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
function copy_feedback(): void {
|
| 48 |
+
copied = true;
|
| 49 |
+
if (timer) clearTimeout(timer);
|
| 50 |
+
timer = setTimeout(() => {
|
| 51 |
+
copied = false;
|
| 52 |
+
}, 1000);
|
| 53 |
+
}
|
| 54 |
+
</script>
|
| 55 |
+
|
| 56 |
+
<div
|
| 57 |
+
class="prose {elem_classes?.join(' ') || ''}"
|
| 58 |
+
class:hide={!visible}
|
| 59 |
+
data-testid="markdown"
|
| 60 |
+
dir={rtl ? "rtl" : "ltr"}
|
| 61 |
+
use:copy
|
| 62 |
+
style={height ? `max-height: ${css_units(height)}; overflow-y: auto;` : ""}
|
| 63 |
+
style:min-height={min_height && loading_status?.status !== "pending"
|
| 64 |
+
? css_units(min_height)
|
| 65 |
+
: undefined}
|
| 66 |
+
>
|
| 67 |
+
{#if show_copy_button}
|
| 68 |
+
<IconButtonWrapper>
|
| 69 |
+
<IconButton
|
| 70 |
+
Icon={copied ? Check : Copy}
|
| 71 |
+
on:click={handle_copy}
|
| 72 |
+
label={copied ? "Copied conversation" : "Copy conversation"}
|
| 73 |
+
></IconButton>
|
| 74 |
+
</IconButtonWrapper>
|
| 75 |
+
{/if}
|
| 76 |
+
<MarkdownCode
|
| 77 |
+
message={value}
|
| 78 |
+
{latex_delimiters}
|
| 79 |
+
{sanitize_html}
|
| 80 |
+
{line_breaks}
|
| 81 |
+
chatbot={false}
|
| 82 |
+
{header_links}
|
| 83 |
+
{theme_mode}
|
| 84 |
+
/>
|
| 85 |
+
</div>
|
| 86 |
+
|
| 87 |
+
<style>
|
| 88 |
+
div :global(.math.inline) {
|
| 89 |
+
fill: var(--body-text-color);
|
| 90 |
+
display: inline-block;
|
| 91 |
+
vertical-align: middle;
|
| 92 |
+
padding: var(--size-1-5) -var(--size-1);
|
| 93 |
+
color: var(--body-text-color);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
div :global(.math.inline svg) {
|
| 97 |
+
display: inline;
|
| 98 |
+
margin-bottom: 0.22em;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
div {
|
| 102 |
+
max-width: 100%;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.hide {
|
| 106 |
+
display: none;
|
| 107 |
+
}
|
| 108 |
+
</style>
|