-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Docs panel: add support for loading images from the Cloud (#11884)
- Loading branch information
1 parent
9dfd470
commit 7b8ae38
Showing
9 changed files
with
140 additions
and
73 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
46 changes: 46 additions & 0 deletions
46
app/gui/src/dashboard/components/MarkdownViewer/defaultRenderer.ts
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,46 @@ | ||
/** @file The default renderer for Markdown. */ | ||
import type { RendererObject } from 'marked' | ||
import { BUTTON_STYLES, TEXT_STYLE } from '../AriaComponents' | ||
|
||
/** The default renderer for Markdown. */ | ||
export const DEFAULT_RENDERER: Readonly<RendererObject> = { | ||
/** The renderer for headings. */ | ||
heading({ depth, tokens }) { | ||
const variant = depth === 1 ? 'h1' : 'subtitle' | ||
return `<h${depth} class="${TEXT_STYLE({ variant: variant, className: 'my-2' })}">${this.parser.parseInline(tokens)}</h${depth}>` | ||
}, | ||
/** The renderer for paragraphs. */ | ||
paragraph({ tokens }) { | ||
return `<p class="${TEXT_STYLE({ variant: 'body', className: 'my-1' })}">${this.parser.parseInline(tokens)}</p>` | ||
}, | ||
/** The renderer for list items. */ | ||
listitem({ tokens }) { | ||
return `<li class="${TEXT_STYLE({ variant: 'body' })}">${this.parser.parseInline(tokens)}</li>` | ||
}, | ||
/** The renderer for lists. */ | ||
list({ items }) { | ||
return `<ul class="my-1 list-disc pl-3">${items.map((item) => this.listitem(item)).join('\n')}</ul>` | ||
}, | ||
/** The renderer for links. */ | ||
link({ href, tokens }) { | ||
return `<a href="${href}" target="_blank" rel="noopener noreferrer" class="${BUTTON_STYLES({ variant: 'link' }).base()}">${this.parser.parseInline(tokens)}</a>` | ||
}, | ||
/** The renderer for images. */ | ||
image({ href, title, raw }) { | ||
const alt = title ?? '' | ||
|
||
return ` | ||
<img src="${href}" alt="${alt}" class="my-1 h-auto max-w-full" data-raw=${raw}> | ||
` | ||
}, | ||
/** The renderer for code. */ | ||
code({ text }) { | ||
return `<code class="block my-1 p-2 bg-primary/5 rounded-lg max-w-full overflow-auto max-h-48" > | ||
<pre class="${TEXT_STYLE({ variant: 'body-sm' })}">${text}</pre> | ||
</code>` | ||
}, | ||
/** The renderer for blockquotes. */ | ||
blockquote({ tokens }) { | ||
return `<blockquote class="${'relative my-1 pl-2 before:bg-primary/20 before:absolute before:left-0 before:top-0 before:h-full before:w-[1.5px] before:rounded-full'}">${this.parser.parse(tokens)}</blockquote>` | ||
}, | ||
} |
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
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