continue-custom/gui/src/components/mainInput/CodeBlockComponent.tsx
2024-11-20 17:38:29 -08:00

33 lines
1.1 KiB
TypeScript

import { NodeViewWrapper } from "@tiptap/react";
import { ContextItemWithId } from "core";
import { vscBadgeBackground } from "..";
import CodeSnippetPreview from "../markdown/CodeSnippetPreview";
export const CodeBlockComponent = (props: any) => {
const { node, deleteNode, selected, editor, updateAttributes } = props;
const item: ContextItemWithId = node.attrs.item;
// const contextItems = useSelector(
// (store: RootState) =>
// store.state.history[store.state.history.length - 1].contextItems,
// );
// const isFirstContextItem = item.id === contextItems[0]?.id;
const isFirstContextItem = false; // TODO: fix this, decided not worth the insane renders for now
return (
<NodeViewWrapper className="code-block-with-content" as="div">
<CodeSnippetPreview
borderColor={
isFirstContextItem
? "#d0d"
: selected
? vscBadgeBackground
: undefined
}
item={item}
onDelete={() => {
deleteNode();
}}
/>
</NodeViewWrapper>
);
};