/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ import type { Node as ProseMirrorNode } from "@tiptap/pm/model"; import { NodeViewWrapper, NodeViewContent } from "@tiptap/react"; import ts from "highlight.js/lib/languages/typescript"; import { common, createLowlight } from "lowlight"; import { CheckIcon } from "lucide-react"; import { useState } from "react"; import { CopyIcon } from "@plane/propel/icons"; // ui import { Tooltip } from "@plane/propel/tooltip"; // plane utils import { cn } from "@plane/utils"; // types import type { TCodeBlockAttributes } from "./types"; import { ECodeBlockAttributeNames } from "./types"; // we just have ts support for now const lowlight = createLowlight(common); lowlight.register("ts", ts); type Props = { node: ProseMirrorNode; }; export function CodeBlockComponent({ node }: Props) { const [copied, setCopied] = useState(false); // derived values const attrs = node.attrs as TCodeBlockAttributes; const copyToClipboard = async (e: React.MouseEvent) => { try { await navigator.clipboard.writeText(node.textContent); setCopied(true); setTimeout(() => setCopied(false), 1000); } catch { setCopied(false); } e.preventDefault(); e.stopPropagation(); }; return (
        
      
); }