feat: add image block type (#709)

This commit is contained in:
Jeremy 2025-01-15 19:59:29 +05:30 committed by GitHub
parent 6c23a8a604
commit df449a408a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 229 additions and 92 deletions

View file

@ -34,8 +34,9 @@ import { Console } from './console';
import { useSidebar } from './ui/sidebar';
import { useBlock } from '@/hooks/use-block';
import equal from 'fast-deep-equal';
import { ImageEditor } from './image-editor';
export type BlockKind = 'text' | 'code';
export type BlockKind = 'text' | 'code' | 'image';
export interface UIBlock {
title: string;
@ -476,7 +477,7 @@ function PureBlock({
})}
>
{isDocumentsFetching && !block.content ? (
<DocumentSkeleton />
<DocumentSkeleton blockKind={block.kind} />
) : block.kind === 'code' ? (
<CodeEditor
content={
@ -512,9 +513,22 @@ function PureBlock({
newContent={getDocumentContentById(currentVersionIndex)}
/>
)
) : block.kind === 'image' ? (
<ImageEditor
title={block.title}
content={
isCurrentVersion
? block.content
: getDocumentContentById(currentVersionIndex)
}
isCurrentVersion={isCurrentVersion}
currentVersionIndex={currentVersionIndex}
status={block.status}
isInline={false}
/>
) : null}
{suggestions ? (
{suggestions && suggestions.length > 0 ? (
<div className="md:hidden h-dvh w-12 shrink-0" />
) : null}