memos/web/src/components/MemoContent/DefaultLink.tsx
Claude 739fd2cde6 refactor: update markdown parser
- Removed the `nodes` field from the `Memo` interface in `memo_service.ts`.
- Updated the `createBaseMemo` function and the `Memo` message functions to reflect the removal of `nodes`.
- Cleaned up the serialization and deserialization logic accordingly.

chore: remove code-inspector-plugin from Vite configuration

- Deleted the `codeInspectorPlugin` from the Vite configuration in `vite.config.mts`.
- Simplified the plugins array to include only `react` and `tailwindcss`.
2025-10-26 11:28:40 +08:00

30 lines
831 B
TypeScript

import React from "react";
/**
* Default link component for regular markdown links
*
* Handles external links with proper target and rel attributes.
*/
interface DefaultLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
node?: any; // AST node from react-markdown
href?: string;
children?: React.ReactNode;
}
export const DefaultLink: React.FC<DefaultLinkProps> = ({ href, children, ...props }) => {
const isExternal = href?.startsWith("http://") || href?.startsWith("https://");
return (
<a
{...props}
href={href}
className="text-primary hover:opacity-80 transition-colors underline"
target={isExternal ? "_blank" : undefined}
rel={isExternal ? "noopener noreferrer" : undefined}
onClick={(e) => e.stopPropagation()}
>
{children}
</a>
);
};