import { useState } from 'react'; import { CreateView } from '@toeverything/framework/virgo'; import { Upload } from '../../components/upload/upload'; import { SourceView } from '../../components/source-view'; import { LinkContainer } from '../../components/style-container'; import { useOnSelect } from '@toeverything/components/editor-core'; const _messages = { addYoutubeLink: 'Add youtube link', }; type YoutubeView = CreateView; export const YoutubeView = ({ block }: YoutubeView) => { const [youtubeUrl, setYoutubeUrl] = useState( block.getProperty('embedLink')?.value ); const onYoutubeUrlChange = async (link: string) => { setYoutubeUrl(link); block.setProperty('embedLink', { value: link, name: 'youtube' }); }; const [isSelect, setIsSelect] = useState(); useOnSelect(block.id, (isSelect: boolean) => { setIsSelect(isSelect); }); return ( {youtubeUrl ? ( ) : ( { block.remove(); }} defaultAddBtnText={_messages.addYoutubeLink} isSelected={isSelect} /> )} ); };