resolve conversation

This commit is contained in:
ilya-bkv 2023-05-09 14:25:40 +03:00
parent 28e0e4e33a
commit 21f84f2292
3 changed files with 7 additions and 10 deletions

View File

@ -110,7 +110,7 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => {
</div> </div>
<Modal variant="narrow" name="uploadImage" onClose={closeUploadModalHandler}> <Modal variant="narrow" name="uploadImage" onClose={closeUploadModalHandler}>
<UploadModalContent <UploadModalContent
closeCallback={(value) => { onClose={(value) => {
renderImage(value) renderImage(value)
setSelectedMenuItem() setSelectedMenuItem()
}} }}

View File

@ -8,13 +8,11 @@ import { hideModal } from '../../../stores/ui'
import { createDropzone, createFileUploader, UploadFile } from '@solid-primitives/upload' import { createDropzone, createFileUploader, UploadFile } from '@solid-primitives/upload'
import { handleFileUpload } from '../../../utils/handleFileUpload' import { handleFileUpload } from '../../../utils/handleFileUpload'
import { useLocalize } from '../../../context/localize' import { useLocalize } from '../../../context/localize'
import { Editor } from '@tiptap/core'
import { Loading } from '../../_shared/Loading' import { Loading } from '../../_shared/Loading'
import { verifyImg } from '../../../utils/verifyImg' import { verifyImg } from '../../../utils/verifyImg'
import { imageProxy } from '../../../utils/imageProxy'
type Props = { type Props = {
closeCallback: (imgUrl?: string) => void onClose: (imgUrl?: string) => void
} }
export const UploadModalContent = (props: Props) => { export const UploadModalContent = (props: Props) => {
@ -30,7 +28,7 @@ export const UploadModalContent = (props: Props) => {
setIsUploading(true) setIsUploading(true)
const fileUrl = await handleFileUpload(file) const fileUrl = await handleFileUpload(file)
setIsUploading(false) setIsUploading(false)
props.closeCallback(fileUrl) props.onClose(fileUrl)
} catch (error) { } catch (error) {
setIsUploading(false) setIsUploading(false)
setUploadError(t('Error')) setUploadError(t('Error'))
@ -113,9 +111,9 @@ export const UploadModalContent = (props: Props) => {
showInput={true} showInput={true}
onClose={() => { onClose={() => {
hideModal() hideModal()
props.closeCallback() props.onClose()
}} }}
// validate={(value) => verifyImg(value)} validate={(value) => verifyImg(value)}
onSubmit={handleImageFormSubmit} onSubmit={handleImageFormSubmit}
errorMessage={t('Invalid image link')} errorMessage={t('Invalid image link')}
/> />

View File

@ -90,9 +90,8 @@ export const EditView = (props: EditViewProps) => {
setForm('slug', slug) setForm('slug', slug)
} }
const handleSetCover = (imgUrl: string) => { const handleUploadModalContentCloseSetCover = (imgUrl: string) => {
hideModal() hideModal()
console.log('!!! imgUrl:', imgUrl)
setCoverImage(imgUrl) setCoverImage(imgUrl)
setForm('coverImageUrl', imgUrl) setForm('coverImageUrl', imgUrl)
} }
@ -253,7 +252,7 @@ export const EditView = (props: EditViewProps) => {
</form> </form>
</div> </div>
<Modal variant="narrow" name="uploadImage"> <Modal variant="narrow" name="uploadImage">
<UploadModalContent closeCallback={(value) => handleSetCover(value)} /> <UploadModalContent onClose={(value) => handleUploadModalContentCloseSetCover(value)} />
</Modal> </Modal>
<Panel shoutSlug={props.shout.slug} /> <Panel shoutSlug={props.shout.slug} />
</> </>