Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/components/tiptap/floatingMenu/floatingMenuSuggestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { FloatingMenu } from './FloatingMenu'
import { TiptapEditorUtils } from '@/utils/tiptapEditorUtils'
import { ImagePickerUtils } from '@/utils/imagePickerUtils'
import { handleBannerImageUpload } from '@/utils/handleBannerImageUpload'
import { calculateFileSize } from '@/utils/calculateFileSize'
import toast from 'react-hot-toast'

export const floatingMenuSuggestion = {
items: ({ query }: any) => {
Expand Down Expand Up @@ -76,7 +78,16 @@ export const floatingMenuSuggestion = {
'token',
)
if (file && token) {
// file size validation
const size = calculateFileSize(file)
if (size > 4.5) {
toast.error('File size is too large!')
return
}

const data = await handleBannerImageUpload(file, token)
if (!data) toast.error('Something went wrong while uploading file')

if (data.contentType === 'application/pdf') {
tiptapEditorUtils.insertPdf(data.filename, data.url)
} else {
Expand Down
Loading