🚸 (buttons) Detect multi items pasting with br…
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import {
|
||||
EditablePreview,
|
||||
EditableInput,
|
||||
Editable,
|
||||
Fade,
|
||||
IconButton,
|
||||
@ -13,6 +12,7 @@ import {
|
||||
Portal,
|
||||
useColorModeValue,
|
||||
SlideFade,
|
||||
EditableTextarea,
|
||||
} from '@chakra-ui/react'
|
||||
import { PlusIcon, SettingsIcon } from '@/components/icons'
|
||||
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
||||
@ -65,10 +65,14 @@ export const ButtonsItemNode = ({ item, indices, isMouseOver }: Props) => {
|
||||
}
|
||||
|
||||
const handleEditableChange = (val: string) => {
|
||||
const splittedBreakLines = val.split('\n')
|
||||
const splittedCommas = val.split(',')
|
||||
const isPastingMultipleItems =
|
||||
val.length - itemValue.length > 1 && val.includes(',')
|
||||
val.length - itemValue.length > 1 &&
|
||||
(splittedBreakLines.length > 2 || splittedCommas.length > 2)
|
||||
if (isPastingMultipleItems) {
|
||||
const values = val.split(',')
|
||||
const values =
|
||||
splittedBreakLines.length > 2 ? splittedBreakLines : splittedCommas
|
||||
return values.forEach((v, i) => {
|
||||
if (i === 0) {
|
||||
setItemValue(v)
|
||||
@ -120,7 +124,7 @@ export const ButtonsItemNode = ({ item, indices, isMouseOver }: Props) => {
|
||||
}
|
||||
cursor="pointer"
|
||||
/>
|
||||
<EditableInput onMouseDownCapture={(e) => e.stopPropagation()} />
|
||||
<EditableTextarea onMouseDownCapture={(e) => e.stopPropagation()} />
|
||||
</Editable>
|
||||
<HitboxExtension />
|
||||
<SlideFade
|
||||
|
@ -170,6 +170,7 @@ const itemsAction = (setTypebot: SetTypebot): ItemsActions => ({
|
||||
const block = typebot.groups[groupIndex].blocks[
|
||||
blockIndex
|
||||
] as BlockWithItems
|
||||
if (block.items.length === 1) return
|
||||
const removingItem = block.items[itemIndex]
|
||||
block.items.splice(itemIndex, 1)
|
||||
deleteConnectedEdgesDraft(typebot, removingItem.id)
|
||||
|
Reference in New Issue
Block a user