diff --git a/packages/nc-gui/components/project/InviteProjectCollabSection.vue b/packages/nc-gui/components/project/InviteProjectCollabSection.vue index dd67518176..9c232409f4 100644 --- a/packages/nc-gui/components/project/InviteProjectCollabSection.vue +++ b/packages/nc-gui/components/project/InviteProjectCollabSection.vue @@ -155,6 +155,33 @@ onKeyStroke('Backspace', () => { emailBadges.value.pop() } }) + +// when bulk email is pasted +const onPaste = (e: ClipboardEvent) => { + const pastedText = e.clipboardData?.getData('text') + const inputArray = pastedText?.split(',') + inputArray?.forEach((el) => { + if (el.length < 1) { + emailValidation.isError = true + emailValidation.message = 'EMAIL SHOULD NOT BE EMPTY' + return + } + if (!validateEmail(el.trim())) { + emailValidation.isError = true + emailValidation.message = 'INVALID EMAIL' + return + } + // if email is already enterd we just ignore the input + // no error is thrown + if (emailBadges.value.includes(el)) { + return + } + + emailBadges.value.push(el) + inviteData.email = '' + }) + inviteData.email = '' +}