2
0

feat(bubbles): Add image bubble

This commit is contained in:
Baptiste Arnaud
2022-01-20 16:14:47 +01:00
parent c43fd1d386
commit 2d178978ef
33 changed files with 848 additions and 142 deletions

View File

@ -1,6 +1,6 @@
import {
Block,
TextStep,
TextBubbleStep,
PublicTypebot,
BackgroundType,
Settings,
@ -119,7 +119,7 @@ export const parseNewStep = (
const id = `s${shortId.generate()}`
switch (type) {
case BubbleStepType.TEXT: {
const textStep: Pick<TextStep, 'type' | 'content'> = {
const textStep: Pick<TextBubbleStep, 'type' | 'content'> = {
type,
content: { html: '', richText: [], plainText: '' },
}

View File

@ -1,3 +1,4 @@
import imageCompression from 'browser-image-compression'
import { Parser } from 'htmlparser2'
import { Step } from 'models'
@ -78,6 +79,16 @@ export const uploadFile = async (file: File, key: string) => {
}
}
export const compressFile = async (file: File) => {
const options = {
maxSizeMB: 0.5,
maxWidthOrHeight: 1600,
}
return ['image/jpg', 'image/jpeg', 'image/png'].includes(file.type)
? imageCompression(file, options)
: file
}
export const removeUndefinedFields = <T>(obj: T): T =>
Object.keys(obj).reduce(
(acc, key) =>