MCPcopy Create free account
hub / github.com/dailydotdev/apps / onPaste

Function onPaste

packages/shared/src/hooks/input/useMarkdownInput.ts:581–608  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

579 };
580
581 const onPaste: ClipboardEventHandler<HTMLTextAreaElement> = async (e) => {
582 const pastedText = e.clipboardData.getData('text');
583 if (isValidHttpUrl(pastedText)) {
584 const cursor = getCursorType(textarea);
585
586 if (cursor === CursorType.Highlighted) {
587 const isInMarkdownLink = isSelectionInMarkdownLink(
588 textarea,
589 textarea.selectionStart,
590 textarea.selectionEnd,
591 );
592
593 if (!isInMarkdownLink) {
594 e.preventDefault();
595 await onLinkPaste(pastedText);
596 return;
597 }
598 }
599 }
600
601 if (e.clipboardData.files?.length && isUploadEnabled) {
602 e.preventDefault();
603
604 Array.from(e.clipboardData.files).forEach(verifyFile);
605
606 startUploading();
607 }
608 };
609
610 const onCloseMention = useCallback(() => setQuery(undefined), []);
611 const onCloseEmoji = useCallback(() => setEmojiQuery(undefined), []);

Callers

nothing calls this directly

Calls 5

isValidHttpUrlFunction · 0.90
getCursorTypeFunction · 0.90
onLinkPasteFunction · 0.85
startUploadingFunction · 0.85

Tested by

no test coverage detected