Skip to content

Commit

Permalink
fix: copy to clipboard on codeblock + added asm support
Browse files Browse the repository at this point in the history
  • Loading branch information
kujo205 committed Apr 18, 2024
1 parent 913a5f4 commit feb52cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/components/mdPreview/components/Pre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { useCopyToClipboard } from "@/hooks/useCopyToClipboard";
type PreChildren = {
props: {
className: string;
children: string;
};
};

const Pre: React.FC<
DetailedHTMLProps<HTMLAttributes<HTMLPreElement>, HTMLPreElement>
> = ({ children, ...props }) => {
const lang = (children as PreChildren).props.className.split("-")[1];
const preContent = (children as PreChildren).props.children;

const { copy } = useCopyToClipboard();

Expand All @@ -25,7 +27,7 @@ const Pre: React.FC<
</span>
<Button
className="bg-transparent opacity-75 hover:bg-transparent hover:opacity-100"
onClick={() => copy("children", "Text copied to clipboard")}
onClick={() => copy(preContent, "Text copied to clipboard")}
>
<CopyIcon />
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/providers/PrismJsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import "prismjs/components/prism-typescript";
import "prismjs/components/prism-javascript";
import "prismjs/components/prism-css";
import "prismjs/components/prism-jsx";
import "prismjs/components/prism-asm6502";
import "prismjs/components/prism-bash";
import { usePathname, useSearchParams } from "next/navigation";

Expand Down

0 comments on commit feb52cf

Please sign in to comment.