import { message } from '@tauri-apps/plugin-dialog'; import { Editor } from '@tiptap/react'; import { useState } from 'react'; import { useArk } from '@libs/ark'; import { MediaIcon } from '@shared/icons'; export function MediaUploader({ editor }: { editor: Editor }) { const { ark } = useArk(); const [loading, setLoading] = useState(false); const uploadToNostrBuild = async () => { try { // start loading setLoading(true); const image = await ark.upload({ fileExts: ['mp4', 'mp3', 'webm', 'mkv', 'avi', 'mov'], }); if (image) { editor.commands.setImage({ src: image }); editor.commands.createParagraphNear(); setLoading(false); } } catch (e) { // stop loading setLoading(false); await message(`Upload failed, error: ${e}`, { title: 'Lume', type: 'error' }); } }; return ( ); }