'use client' import { createReactBlockSpec } from '@blocknote/react' import { FileUp, LoaderCircle } from 'lucide-react' import { useTranslation } from 'react-i18next' // Only live requests count as uploading. A saved placeholder reopened after a // tab closes offers retry instead of displaying an endless spinner. export const activeNoteUploads = new Set() export const noteUpload = createReactBlockSpec( { type: 'noteUpload', content: 'none', propSchema: { name: { default: '' }, error: { default: '' } }, }, { render: function UploadBlock({ block }) { const { t } = useTranslation() const pending = activeNoteUploads.has(block.id) return (
{pending ? : }
{block.props.name}

{pending ? t('Uploading…') : block.props.error || t('Choose the file again to finish uploading.')}

{!pending && ( )}
) }, } )