Skip to content

Commit 09d6b51

Browse files
authored
feat: support markdown (#5)
1 parent 646b1d9 commit 09d6b51

5 files changed

Lines changed: 1309 additions & 1 deletion

File tree

.yarn/install-state.gz

109 KB
Binary file not shown.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@
2929
"@radix-ui/react-label": "2.1.7",
3030
"@radix-ui/react-popover": "1.1.14",
3131
"@radix-ui/react-slot": "1.2.3",
32+
"@tailwindcss/typography": "0.5.19",
3233
"@tailwindcss/vite": "4.1.10",
3334
"class-variance-authority": "0.7.1",
3435
"clsx": "2.1.1",
3536
"lucide-react": "0.516.0",
37+
"react-markdown": "10.1.0",
38+
"rehype-raw": "7.0.0",
39+
"remark-gfm": "4.0.1",
3640
"tailwind-merge": "2.5.5",
3741
"tailwindcss-animate": "1.0.7",
3842
"tw-animate-css": "1.3.4"

src/extensions/inspector_block/main/PropertyValue.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { FC } from "react";
2+
import ReactMarkdown from "react-markdown";
3+
import rehypeRaw from "rehype-raw";
4+
import remarkGfm from "remark-gfm";
25

36
export type SingleValueProperty = {
47
id: string;
@@ -12,6 +15,8 @@ export type Props = {
1215
};
1316

1417
const PropertyValue: FC<Props> = ({ property }) => {
18+
console.log("property", property);
19+
1520
return property.type === "asset" ? (
1621
isImageUrl(property.value as string) ? (
1722
<img
@@ -36,6 +41,27 @@ const PropertyValue: FC<Props> = ({ property }) => {
3641
>
3742
{property.value}
3843
</a>
44+
) : property.type === "markdown" ? (
45+
<div className="prose">
46+
<ReactMarkdown
47+
remarkPlugins={[remarkGfm]}
48+
rehypePlugins={[rehypeRaw]}
49+
components={{
50+
a: ({ href, children, ...props }) => (
51+
<a
52+
href={href}
53+
target="_blank"
54+
rel="noopener noreferrer"
55+
{...props}
56+
>
57+
{children}
58+
</a>
59+
)
60+
}}
61+
>
62+
{property.value as string}
63+
</ReactMarkdown>
64+
</div>
3965
) : property.type === "bool" ? (
4066
<div className="whitespace-pre-wrap break-words">
4167
{property.value ? "True" : "False"}

src/shared/global.css

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@import "tailwindcss";
22
@import "tw-animate-css";
33

4+
@plugin "@tailwindcss/typography";
5+
46
@custom-variant dark (&:is(.dark *));
57

68
:root {
@@ -133,3 +135,97 @@ input[type="number"]::-webkit-inner-spin-button {
133135
input[type="number"] {
134136
-moz-appearance: textfield;
135137
}
138+
139+
/* Override prose styles with smaller spacing and 12px base text */
140+
@layer utilities {
141+
.prose {
142+
@apply text-xs leading-relaxed max-w-none;
143+
font-size: 12px;
144+
}
145+
146+
.prose p {
147+
@apply my-1 leading-relaxed;
148+
}
149+
150+
.prose h1 {
151+
@apply text-lg font-bold mt-3 mb-2 leading-tight;
152+
}
153+
154+
.prose h2 {
155+
@apply text-base font-semibold mt-3 mb-1 leading-tight;
156+
}
157+
158+
.prose h3 {
159+
@apply text-sm font-medium mt-2 mb-1 leading-tight;
160+
}
161+
162+
.prose h4 {
163+
@apply text-xs font-medium mt-2 mb-1 leading-tight;
164+
}
165+
166+
.prose h5 {
167+
@apply text-xs font-normal mt-2 mb-1 leading-tight;
168+
}
169+
170+
.prose h6 {
171+
@apply text-xs font-normal mt-2 mb-1 leading-tight opacity-75;
172+
}
173+
174+
.prose ul,
175+
.prose ol {
176+
@apply my-1 pl-4;
177+
}
178+
179+
.prose li {
180+
@apply my-0.5;
181+
}
182+
183+
.prose blockquote {
184+
@apply my-2 pl-3 border-l-2 border-muted italic;
185+
}
186+
187+
.prose hr {
188+
@apply my-2 border-border;
189+
}
190+
191+
.prose code {
192+
@apply text-xs bg-muted px-1 py-0.5 rounded font-mono;
193+
}
194+
195+
.prose pre {
196+
@apply my-2 p-2 bg-muted rounded text-xs overflow-x-auto;
197+
}
198+
199+
.prose pre code {
200+
@apply bg-transparent p-0 text-gray-700;
201+
}
202+
203+
.prose a {
204+
@apply text-primary underline hover:no-underline;
205+
}
206+
207+
.prose strong {
208+
@apply font-semibold;
209+
}
210+
211+
.prose em {
212+
@apply italic;
213+
}
214+
215+
.prose table {
216+
@apply my-2 w-full border-collapse;
217+
}
218+
219+
.prose th,
220+
.prose td {
221+
@apply border border-border px-2 py-1 text-left;
222+
}
223+
224+
.prose th {
225+
@apply bg-muted font-medium;
226+
}
227+
228+
.prose img {
229+
@apply my-1 max-w-full h-auto;
230+
}
231+
}

0 commit comments

Comments
 (0)