fix: restore code block loading states (#728)

This commit is contained in:
Jeremy 2025-01-27 19:23:16 +05:30 committed by GitHub
parent 38527ff92e
commit 085f4a8ac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 269 additions and 136 deletions

View file

@ -1,6 +1,7 @@
import { Block } from '@/components/create-block';
import { CopyIcon, RedoIcon, UndoIcon } from '@/components/icons';
import { ImageEditor } from '@/components/image-editor';
import { toast } from 'sonner';
export const imageBlock = new Block({
kind: 'image',
@ -23,6 +24,13 @@ export const imageBlock = new Block({
onClick: ({ handleVersionChange }) => {
handleVersionChange('prev');
},
isDisabled: ({ currentVersionIndex }) => {
if (currentVersionIndex === 0) {
return true;
}
return false;
},
},
{
icon: <RedoIcon size={18} />,
@ -30,6 +38,13 @@ export const imageBlock = new Block({
onClick: ({ handleVersionChange }) => {
handleVersionChange('next');
},
isDisabled: ({ isCurrentVersion }) => {
if (isCurrentVersion) {
return true;
}
return false;
},
},
{
icon: <CopyIcon size={18} />,
@ -52,6 +67,8 @@ export const imageBlock = new Block({
}
}, 'image/png');
};
toast.success('Copied image to clipboard!');
},
},
],