UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

35 lines 1.61 kB
import { PlaceholderType, } from '../types/hooks.js'; export function handlePaste(pastedText, currentDisplayValue, currentPlaceholderContent, detectionMethod) { // No minimum threshold - any detected paste gets a placeholder // This is especially important for multi-line pastes where only the first line // may be captured by the input component if (pastedText.length === 0) { return null; } // Generate simple incrementing ID based on existing paste placeholders const existingPasteCount = Object.values(currentPlaceholderContent).filter(content => content.type === PlaceholderType.PASTE).length; const pasteId = (existingPasteCount + 1).toString(); const placeholder = `[Paste #${pasteId}: ${pastedText.length} chars]`; const pasteContent = { type: PlaceholderType.PASTE, displayText: placeholder, content: pastedText, originalSize: pastedText.length, detectionMethod, timestamp: Date.now(), }; const newPlaceholderContent = { ...currentPlaceholderContent, [pasteId]: pasteContent, }; // For CLI paste detection, we need to replace the pasted text in the display value // If the pasted text is at the end, replace it. Otherwise append the placeholder. const newDisplayValue = currentDisplayValue.includes(pastedText) ? currentDisplayValue.replace(pastedText, placeholder) : currentDisplayValue + placeholder; return { displayValue: newDisplayValue, placeholderContent: newPlaceholderContent, }; } //# sourceMappingURL=paste-utils.js.map