import { CornerDownLeft } from 'lucide-react'; import { MarkdownView, Plugin } from 'obsidian'; import React, { useEffect, useRef, useState } from 'react'; import { APPLY_VIEW_TYPE } from '../../constants'; import LLMManager from '../../core/llm/manager'; import { InfioSettings } from '../../types/settings'; import { GetProviderModelIds } from '../../utils/api'; import { ApplyEditToFile } from '../../utils/apply'; import { removeAITags } from '../../utils/content-filter'; import { PromptGenerator } from '../../utils/prompt-generator'; type InlineEditProps = { source: string; secStartLine: number; secEndLine: number; plugin: Plugin; settings: InfioSettings; } type InputAreaProps = { value: string; onChange: (value: string) => void; handleSubmit: () => void; handleClose: () => void; } const InputArea: React.FC = ({ value, onChange, handleSubmit, handleClose }) => { const textareaRef = useRef(null); useEffect(() => { textareaRef.current?.focus(); }, []); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { if (e.shiftKey) { // Shift + Enter: 允许换行,使用默认行为 return; } // 普通 Enter: 阻止默认行为并触发提交 e.preventDefault(); handleSubmit(); } else if (e.key === 'Escape') { // 当按下 Esc 键时关闭编辑器 handleClose(); } }; return (