Skip to content

Commit

Permalink
fix: table table style
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Jul 26, 2024
1 parent 8fec859 commit 443c46d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
23 changes: 23 additions & 0 deletions src/renderer/src/components/ui/markdown/renderers/BlockImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { cn } from "@renderer/lib/utils"
import { useWrappedElementSize } from "@renderer/providers/wrapped-element-provider"

import { Media } from "../../media"

export const MarkdownBlockImage = (
props: React.ImgHTMLAttributes<HTMLImageElement>,
) => {
const size = useWrappedElementSize()

return (
<Media
type="photo"
{...props}
mediaContainerClassName={cn(
"rounded",
size.w < Number.parseInt(props.width as string) && "w-full",
)}
popper
className="flex justify-center"
/>
)
}
20 changes: 9 additions & 11 deletions src/renderer/src/lib/parse-html.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Checkbox } from "@renderer/components/ui/checkbox"
import { ShikiHighLighter } from "@renderer/components/ui/code-highlighter"
import { MarkdownLink } from "@renderer/components/ui/link"
import { MarkdownBlockImage } from "@renderer/components/ui/markdown/renderers/BlockImage"
import { Media } from "@renderer/components/ui/media"
import { toJsxRuntime } from "hast-util-to-jsx-runtime"
import { createElement } from "react"
Expand Down Expand Up @@ -58,24 +59,21 @@ export const parseHtml = async (
createElement(MarkdownLink, { ...props } as any),
img: ({ node, ...props }) => {
if (node?.properties.inline) {
return createElement("img", {
src: props.src,
style: { maxWidth: "100%", display: "inline" },
return createElement(Media, {
type: "photo",
...props,
mediaContainerClassName: tw`max-w-full inline size-auto`,
popper: true,
className: tw`inline`,
})
}
return createElement(Media, {
...props,
mediaContainerClassName: "w-full rounded",
className: "flex justify-center",

popper: true,
type: "photo",
})
return createElement(MarkdownBlockImage, props)
},
video: ({ node, ...props }) =>
createElement(Media, { ...props, popper: true, type: "video" }),
p: ({ node, ...props }) => {
if (node?.children) {
if (node?.children && node.children.length !== 1) {
for (const item of node.children) {
item.type === "element" &&
item.tagName === "img" &&
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/src/modules/entry-column/list-item-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ export function ListItem({
<span className="truncate">{feed.title}</span>
<span>·</span>
<span className="shrink-0">
{!!displayTime && (
<RelativeTime
date={displayTime}
/>
)}
{!!displayTime && <RelativeTime date={displayTime} />}
</span>
</div>
<div
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@
table * {
font-size: 1rem;
}

table table {
margin: 0;
}
}

0 comments on commit 443c46d

Please sign in to comment.