Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"react-hook-form": "^7.54.2",
"react-markdown": "^10.1.0",
"recharts": "^3.2.1",
"remark-gfm": "^4.0.1",
"reodotdev": "^1.0.0",
"sonner": "^2.0.1",
"swagger-ui-react": "^5.29.0",
Expand Down
195 changes: 195 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions src/features/instance/applications/components/ContentViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { hasImageFileExtension } from '@/lib/string/hasImageFileExtension';
import { parseFileExtension } from '@/lib/string/parseFileExtension';
import { CopyIcon } from 'lucide-react';
import Markdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { newApplication } from './ApplicationsSidebar/specialItems';
import { NewApplication } from './NewApplication';
import { TextEditorView } from './TextEditorView';
Expand All @@ -23,7 +24,13 @@ export function ContentViewer() {
if (isDirectory(openedEntry)) {
return (
<div className="directoryReadMe max-w-3xl">
<Markdown urlTransform={urlTransform} components={{ code: MarkdownCode }}>{openedEntryContents}</Markdown>
<Markdown
urlTransform={urlTransform}
remarkPlugins={[remarkGfm]}
components={{ code: MarkdownCode }}
>
{openedEntryContents}
</Markdown>
</div>
);
}
Expand Down Expand Up @@ -52,15 +59,22 @@ function MarkdownCode({
className?: string;
children?: unknown;
}) {
const code = String(children ?? '');
const code = String(children ?? '').replace(/\n$/, '');
const [copy] = useCopyToClipboard(code);

if (inline || !code.includes('\n')) {
return <code className={className}>{children as any}</code>;
}

return (
<code className="relative">
<Button className="absolute top-2 right-2" type="button" variant="default" size="sm" onClick={copy}>
<Button
className="absolute top-2 right-2"
type="button"
variant="default"
size="sm"
onClick={copy}
>
<CopyIcon className="w-4 h-4" />
</Button>
{code}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,26 @@
}
}
}

.directoryReadMe table {
border-collapse: collapse;
width: 100%;
margin: 1rem 0;
font-size: 0.875rem;
}

.directoryReadMe th,
.directoryReadMe td {
border: 1px solid var(--card);
padding: 0.5rem 0.75rem;
text-align: left;
}

.directoryReadMe th {
background-color: var(--background);
font-weight: 600;
}

.directoryReadMe tr:nth-child(even) {
background-color: var(--black-dark);
}
Loading