Skip to content

Commit 122721e

Browse files
committed
Refactor the chat input component to use a contentEditable div instead of a textarea for improved highlighting and cursor management over displayed file paths
1 parent 4241dcb commit 122721e

5 files changed

Lines changed: 488 additions & 228 deletions

File tree

‎packages/ui/src/components/editor/panel/ChatInput/ChatInput.module.scss‎

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
}
6060

61-
.textarea {
61+
.input {
6262
padding: var(--padding);
6363
background-color: transparent;
6464
border: none;
@@ -69,11 +69,18 @@
6969
overflow-wrap: break-word;
7070
word-break: break-word;
7171
letter-spacing: normal;
72-
overflow: hidden;
72+
min-height: 48px;
7373

7474
&:focus {
7575
outline: none;
7676
}
77+
78+
&:empty:before {
79+
content: attr(data-placeholder);
80+
position: absolute;
81+
color: var(--vscode-input-placeholderForeground);
82+
pointer-events: none;
83+
}
7784
}
7885

7986
.clear-button {
@@ -99,37 +106,22 @@
99106
}
100107
}
101108

102-
.highlight-container {
103-
position: absolute;
104-
top: 0;
105-
left: 0;
106-
right: 0;
107-
bottom: 0;
108-
padding: var(--padding);
109-
font-family: sans-serif;
110-
font-size: inherit;
111-
pointer-events: none;
112-
white-space: pre-wrap;
113-
overflow-wrap: break-word;
114-
word-break: break-word;
115-
z-index: 0;
116-
color: transparent;
117-
letter-spacing: normal;
118-
margin: 0;
119-
}
120-
121-
.tab-hint {
122-
display: inline-flex;
123-
align-items: center;
124-
justify-content: center;
125-
color: var(--cwc-text-color);
126-
opacity: 0.5;
127-
font-size: var(--font-size-10px);
128-
padding: 0 3px;
129-
margin-left: 2px;
130-
font-weight: 500;
131-
border: 1px solid var(--cwc-border-color);
132-
border-radius: 5px;
109+
.input-with-tab-hint {
110+
&::after {
111+
content: 'TAB';
112+
display: inline-flex;
113+
align-items: center;
114+
justify-content: center;
115+
color: var(--cwc-text-color);
116+
opacity: 0.5;
117+
font-size: var(--font-size-10px);
118+
padding: 0 3px;
119+
margin-left: 2px;
120+
font-weight: 500;
121+
border: 1px solid var(--cwc-border-color);
122+
border-radius: 5px;
123+
pointer-events: none;
124+
}
133125
}
134126

135127
.selection-keyword {

0 commit comments

Comments
 (0)