mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 06:39:01 +02:00
- Create NavigationAdapter interface (push, replace, back, pathname, searchParams) - Create AppLink component replacing next/link in 4 files - Replace useRouter → useNavigation in 3 files (issue-detail, create-issue, create-workspace) - Create WebNavigationProvider wrapping Next.js useRouter/usePathname/useSearchParams - Move ~85 feature UI files (issues, editor, modals, my-issues, skills, runtimes) to packages/views/ - Add store singleton registration pattern (registerAuthStore, registerWorkspaceStore) - Create data-aware wrappers in packages/views/common/ (ActorAvatar, Markdown) - Update all app-layer imports to @multica/views/* - Add @source directive for Tailwind to scan views package - packages/views/ has zero next/* imports Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { NodeViewWrapper, NodeViewContent } from "@tiptap/react";
|
|
import type { NodeViewProps } from "@tiptap/react";
|
|
import { Copy, Check } from "lucide-react";
|
|
|
|
function CodeBlockView({ node }: NodeViewProps) {
|
|
const [copied, setCopied] = useState(false);
|
|
const language = node.attrs.language || "";
|
|
|
|
const handleCopy = async () => {
|
|
const text = node.textContent;
|
|
if (!text) return;
|
|
await navigator.clipboard.writeText(text);
|
|
setCopied(true);
|
|
setTimeout(() => setCopied(false), 2000);
|
|
};
|
|
|
|
return (
|
|
<NodeViewWrapper className="code-block-wrapper group/code relative my-2">
|
|
<div
|
|
contentEditable={false}
|
|
className="code-block-header absolute top-0 right-0 z-10 flex items-center gap-1.5 px-2 py-1.5 opacity-0 transition-opacity group-hover/code:opacity-100"
|
|
>
|
|
{language && (
|
|
<span className="text-xs text-muted-foreground select-none">
|
|
{language}
|
|
</span>
|
|
)}
|
|
<button
|
|
type="button"
|
|
onClick={handleCopy}
|
|
className="flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground transition-colors"
|
|
title="Copy code"
|
|
>
|
|
{copied ? (
|
|
<Check className="h-3.5 w-3.5" />
|
|
) : (
|
|
<Copy className="h-3.5 w-3.5" />
|
|
)}
|
|
</button>
|
|
</div>
|
|
<pre spellCheck={false}>
|
|
{/* @ts-expect-error -- NodeViewContent supports as="code" at runtime */}
|
|
<NodeViewContent as="code" />
|
|
</pre>
|
|
</NodeViewWrapper>
|
|
);
|
|
}
|
|
|
|
export { CodeBlockView };
|