MCPcopy Create free account
hub / github.com/SyntaxUI/syntaxui / handlePaste

Function handlePaste

src/showcase/components/input/TagInput.tsx:43–59  ·  view source on GitHub ↗
(event: React.ClipboardEvent<HTMLInputElement>)

Source from the content-addressed store, hash-verified

41
42 // Handles pasting keywords separated by commas, new lines, or tabs
43 const handlePaste = (event: React.ClipboardEvent<HTMLInputElement>) => {
44 event.preventDefault()
45 const paste = event.clipboardData.getData('text')
46 const keywordsToAdd = paste
47 .split(/[\n\t,]+/)
48 .map((keyword) => keyword.trim())
49 .filter(Boolean)
50 if (keywordsToAdd.length) {
51 const newKeywords = unique
52 ? [...new Set([...keywords, ...keywordsToAdd])]
53 : [...keywords, ...keywordsToAdd]
54
55 setKeywords(newKeywords)
56 onKeywordsChange(newKeywords)
57 setInputValue('')
58 }
59 }
60
61 // Updates the inputValue state as the user types
62 const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {

Callers

nothing calls this directly

Calls 1

onKeywordsChangeFunction · 0.85

Tested by

no test coverage detected