diff --git a/app/commit.json b/app/commit.json index 9a2ede76..38e00b14 100644 --- a/app/commit.json +++ b/app/commit.json @@ -1 +1 @@ -{ "commit": "eb53146937cbe49a84aaaaa59882df6db4a1e459" } +{ "commit": "eb53146937cbe49a84aaaaa59882df6db4a1e459" } \ No newline at end of file diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 0ed6a30b..09f3c168 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -26,6 +26,7 @@ import FilePreview from './FilePreview'; import { ModelSelector } from '~/components/chat/ModelSelector'; import { SpeechRecognitionButton } from '~/components/chat/SpeechRecognition'; import type { IProviderSetting, ProviderInfo } from '~/types/model'; +import { ScreenshotStateManager } from './ScreenshotStateManager'; const TEXTAREA_MIN_HEIGHT = 76; @@ -376,6 +377,16 @@ export const BaseChat = React.forwardRef( setImageDataList?.(imageDataList.filter((_, i) => i !== index)); }} /> + + {() => ( + + )} +
( } event.preventDefault(); - + if (isStreaming) { handleStop?.(); return; } + // ignore if using input method engine if (event.nativeEvent.isComposing) { - return + return; } + handleSendMessage?.(event); } }} diff --git a/app/components/chat/ScreenshotStateManager.tsx b/app/components/chat/ScreenshotStateManager.tsx new file mode 100644 index 00000000..7dfdd768 --- /dev/null +++ b/app/components/chat/ScreenshotStateManager.tsx @@ -0,0 +1,33 @@ +import { useEffect } from 'react'; + +interface ScreenshotStateManagerProps { + setUploadedFiles?: (files: File[]) => void; + setImageDataList?: (dataList: string[]) => void; + uploadedFiles: File[]; + imageDataList: string[]; +} + +export const ScreenshotStateManager = ({ + setUploadedFiles, + setImageDataList, + uploadedFiles, + imageDataList, +}: ScreenshotStateManagerProps) => { + useEffect(() => { + if (setUploadedFiles && setImageDataList) { + (window as any).__BOLT_SET_UPLOADED_FILES__ = setUploadedFiles; + (window as any).__BOLT_SET_IMAGE_DATA_LIST__ = setImageDataList; + (window as any).__BOLT_UPLOADED_FILES__ = uploadedFiles; + (window as any).__BOLT_IMAGE_DATA_LIST__ = imageDataList; + } + + return () => { + delete (window as any).__BOLT_SET_UPLOADED_FILES__; + delete (window as any).__BOLT_SET_IMAGE_DATA_LIST__; + delete (window as any).__BOLT_UPLOADED_FILES__; + delete (window as any).__BOLT_IMAGE_DATA_LIST__; + }; + }, [setUploadedFiles, setImageDataList, uploadedFiles, imageDataList]); + + return null; +}; diff --git a/app/components/workbench/Preview.tsx b/app/components/workbench/Preview.tsx index 8235bc2b..b2d97e31 100644 --- a/app/components/workbench/Preview.tsx +++ b/app/components/workbench/Preview.tsx @@ -3,6 +3,7 @@ import { memo, useCallback, useEffect, useRef, useState } from 'react'; import { IconButton } from '~/components/ui/IconButton'; import { workbenchStore } from '~/lib/stores/workbench'; import { PortDropdown } from './PortDropdown'; +import { ScreenshotSelector } from './ScreenshotSelector'; type ResizeSide = 'left' | 'right' | null; @@ -20,6 +21,7 @@ export const Preview = memo(() => { const [url, setUrl] = useState(''); const [iframeUrl, setIframeUrl] = useState(); + const [isSelectionMode, setIsSelectionMode] = useState(false); // Toggle between responsive mode and device mode const [isDeviceModeOn, setIsDeviceModeOn] = useState(false); @@ -218,12 +220,17 @@ export const Preview = memo(() => { )}
- + setIsSelectionMode(!isSelectionMode)} + className={isSelectionMode ? 'bg-bolt-elements-background-depth-3' : ''} + />
{ }} > {activePreview ? ( -