Skip to content

Commit 232f8bb

Browse files
bug fixes related to chat input element
1 parent d614b81 commit 232f8bb

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ It is compatible with all Chromium and Gecko-based browsers: Chrome, Vivaldi, Op
4343
- **Model Management:** Select, refresh, download, and delete models.
4444
- **Advanced Capture Tools:** Options for capturing both text and images are available. Captured content is inserted directly into your chat using special tags (`@captured-text` for text and `@captured-image` for images).
4545
- **Prompt Customization:** Adjust and customize prompts to instruct the AI model on how to generate responses.
46+
- **File Attachments:** Upload files to the chat interface and reference them in discussions using the `@attached-files` tag.
4647

4748
## Prerequisites
4849

@@ -203,6 +204,7 @@ To install the the compiled extension, for:
203204
- A responsive, draggable chat box will open on the active webpage.
204205
- Use the chat interface to send messages to the Ollama AI service, review conversation history, and manage models.
205206
- Additional features include capturing selected HTML content (that can be referenced in the discussion with `@captured-text` tag), capturing an image of an area on the page (that can be referenced in the discussion with `@captured-image` tag) for VISION LLMs, and customizing prompts (to instruct the loaded model on how to answer).
207+
- You can also attach files to the chat using the **Attach Files** button. Uploaded files can be referenced in the discussion using the `@attached-files` tag.
206208
207209
4. **Interacting with the Chat:**
208210
- Type your query in the chat input and press Enter or click the `Send` button.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scribe-pal",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "ScribePal is an intelligent browser extension that leverages AI to empower your web experience.",
55
"author": "Code Forge Temple",
66
"type": "module",

src/popup/popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<body>
88
<div class="menu-item input-with-button">
99
<label for="ollama-url">Ollama Server URL:</label>
10-
<input type="text" id="ollama-url" placeholder="http://your-server:port">
10+
<input type="text" id="ollama-url" placeholder="http://ollama-server:11434">
1111
<button id="save-ollama-url">Save</button>
1212
</div>
1313
<div class="menu-item theme-selection">

src/tab/components/ChatBox/components/ChatInput/ChatInput.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
display: flex;
66
margin: 10px 0 0 0;
77

8-
input[type="text"] {
8+
textarea {
99
flex-grow: 1;
1010
padding: 5px;
1111
border: 1px solid #ccc;
1212
border-radius: 4px 0 0 4px;
1313
background: white;
1414
color: black;
15+
white-space: nowrap;
16+
overflow: hidden;
17+
resize: none;
18+
font-family: monospace;
1519
}
1620

1721
button {
@@ -23,7 +27,7 @@
2327

2428
.dark-theme {
2529
.chat-input-container {
26-
input {
30+
textarea {
2731
background: commonVars.$dark-theme-secondary-color;
2832
border-color: commonVars.$dark-theme-secondary-color;
2933
color: white;

src/tab/components/ChatBox/components/ChatInput/ChatInput.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type ChatInputProps = {
1818
}
1919

2020
export const ChatInput = withShadowStyles(({message, onMessageChange, onSend}: ChatInputProps) => {
21-
const inputRef = useRef<HTMLInputElement>(null);
21+
const inputRef = useRef<HTMLTextAreaElement>(null);
2222
const [caret, setCaret] = useState<number>(0);
2323
const [suggestionsVisible, setSuggestionsVisible] = useState(false);
2424
const [suggestionPosition, setSuggestionPosition] = useState({top: 0, left: 0});
@@ -43,7 +43,7 @@ export const ChatInput = withShadowStyles(({message, onMessageChange, onSend}: C
4343
const visibleWidth = inputRef.current.clientWidth;
4444

4545
if (caretPixelPos > scrollLeft + visibleWidth) {
46-
inputRef.current.scrollLeft = caretPixelPos - visibleWidth + 15;
46+
inputRef.current.scrollLeft = caretPixelPos - visibleWidth + ctx.measureText('M').width;
4747
}
4848
}
4949
}
@@ -92,16 +92,18 @@ export const ChatInput = withShadowStyles(({message, onMessageChange, onSend}: C
9292

9393
return (
9494
<div className="chat-input-container">
95-
<input
95+
<textarea
9696
ref={inputRef}
97-
type="text"
97+
rows={1}
9898
placeholder="Type your message..."
9999
value={message}
100-
onChange={(e) => onMessageChange(e.target.value)}
101100
onPaste={(e) => {
102101
e.preventDefault();
103102

104-
const pastedText = e.clipboardData.getData('text');
103+
const pastedText = e.clipboardData.getData('text')
104+
.replace(/\r\n/g, ' ')
105+
.replace(/\n/g, ' ')
106+
.replace(/\t/g, ' ');
105107
const input = inputRef.current;
106108

107109
if (!input) return;

0 commit comments

Comments
 (0)