Skip to content

Commit 57081f7

Browse files
committed
Refactor clear button rendering out of text highlighting and update prompt field layout
- last chnages broke 'clear' button rendering and function [Commit] (it's show on left side now, whereas the right-side placed (correct UI) one doesn't register clicks) - "X" before first 'pasted tokens' should not be there ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ └── i18n │ └── translations │ └── prompt-field.ts └── packages └── ui └── src └── components └── editor └── common └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── components │ │ ├── Tooltip.module.scss │ │ ├── Tooltip.tsx │ │ └── index.ts │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent 97c9802 commit 57081f7

4 files changed

Lines changed: 5 additions & 18 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ export const MainView: React.FC<Props> = (props) => {
378378
/>
379379
</div>
380380

381+
<UiSeparator height={10} />
382+
381383
{props.mode == MODE.WEB && (
382384
<UiConfigurations
383385
configurations={web_configurations}

‎packages/ui/src/components/editor/common/prompts/PromptField/PromptField.module.scss‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
display: flex;
5858
align-items: center;
5959
margin: 5px 4px 0 4px;
60+
position: relative;
61+
z-index: 2;
6062

6163
&__prompt-token-count {
6264
font-size: 10px;

‎packages/ui/src/components/editor/common/prompts/Template/Template.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ export const Template = forwardRef<TemplateHandle, TemplateProps>(
8585
const highlighted_html = useMemo(() => {
8686
return get_highlighted_text({
8787
text: props.value || '',
88-
context_file_paths: [],
89-
show_clear_button: false
88+
context_file_paths: []
9089
})
9190
}, [props.value])
9291

‎packages/ui/src/components/editor/common/prompts/shared/symbols/get-highlighted-text.tsx‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const get_highlighted_text = (params: {
4949
current_selection?: SelectionState | null
5050
context_file_paths: string[]
5151
is_web_mode?: boolean
52-
show_clear_button?: boolean
5352
tabs_config?: {
5453
count: number
5554
active_index: number
@@ -319,21 +318,6 @@ export const get_highlighted_text = (params: {
319318
header_html += `<span class="${pfStyles['tabs']}" data-role="tabs-container">${tabs_items}</span>`
320319
}
321320

322-
let show_clear_button = params.show_clear_button
323-
if (show_clear_button === undefined) {
324-
show_clear_button =
325-
!!params.text || (params.tabs_config && params.tabs_config.count > 1)
326-
}
327-
328-
if (show_clear_button) {
329-
const title = params.text ? 'Clear' : 'Close tab'
330-
header_html += `<span class="${cn(
331-
pfStyles['clear-button'],
332-
'codicon',
333-
'codicon-close'
334-
)}" data-role="clear-button" title="${title}"></span>`
335-
}
336-
337321
if (header_html) {
338322
result = `<span contenteditable="false">${header_html}</span>` + result
339323
}

0 commit comments

Comments
 (0)