mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
feat(markdown): enhance code block rendering for local web files and improve inline code styling
This commit is contained in:
parent
a1d3356bf5
commit
b5921bf139
2 changed files with 22 additions and 3 deletions
|
|
@ -405,6 +405,14 @@ const defaultComponents = memoizeMarkdownComponents({
|
||||||
const openEditorPanel = useSetAtom(openEditorPanelAtom);
|
const openEditorPanel = useSetAtom(openEditorPanelAtom);
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const electronAPI = useElectronAPI();
|
const electronAPI = useElectronAPI();
|
||||||
|
const language = /language-(\w+)/.exec(className || "")?.[1] ?? "text";
|
||||||
|
const codeString = String(children).replace(/\n$/, "");
|
||||||
|
const isWebLocalFileCodeBlock =
|
||||||
|
isCodeBlock &&
|
||||||
|
!electronAPI &&
|
||||||
|
isVirtualFilePathToken(codeString.trim()) &&
|
||||||
|
!codeString.trim().startsWith("//") &&
|
||||||
|
!codeString.includes("\n");
|
||||||
if (!isCodeBlock) {
|
if (!isCodeBlock) {
|
||||||
const inlineValue = String(children ?? "").trim();
|
const inlineValue = String(children ?? "").trim();
|
||||||
const isLocalPath =
|
const isLocalPath =
|
||||||
|
|
@ -451,8 +459,19 @@ const defaultComponents = memoizeMarkdownComponents({
|
||||||
</code>
|
</code>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const language = /language-(\w+)/.exec(className || "")?.[1] ?? "text";
|
if (isWebLocalFileCodeBlock) {
|
||||||
const codeString = String(children).replace(/\n$/, "");
|
return (
|
||||||
|
<code
|
||||||
|
className={cn(
|
||||||
|
"aui-md-inline-code rounded-md border bg-muted px-1.5 py-0.5 font-mono text-[0.9em] font-normal",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{codeString.trim()}
|
||||||
|
</code>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<LazyMarkdownCodeBlock
|
<LazyMarkdownCodeBlock
|
||||||
className={className}
|
className={className}
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ export function EditorPanelContent({
|
||||||
{showDesktopHeader ? (
|
{showDesktopHeader ? (
|
||||||
<div className="shrink-0 border-b">
|
<div className="shrink-0 border-b">
|
||||||
<div className="flex h-12 items-center justify-between px-4">
|
<div className="flex h-12 items-center justify-between px-4">
|
||||||
<h2 className="text-lg font-medium text-muted-foreground">File</h2>
|
<h2 className="text-lg font-medium text-muted-foreground select-none">File</h2>
|
||||||
<div className="flex items-center gap-1 shrink-0">
|
<div className="flex items-center gap-1 shrink-0">
|
||||||
<Button variant="ghost" size="icon" onClick={onClose} className="size-7 shrink-0">
|
<Button variant="ghost" size="icon" onClick={onClose} className="size-7 shrink-0">
|
||||||
<XIcon className="size-4" />
|
<XIcon className="size-4" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue