Skip to content

Commit 87a14bc

Browse files
committed
Add title attributes to keyword spans to improve tooltip visibility for pasted content and selections
1 parent 82e7d18 commit 87a14bc

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

‎packages/ui/src/components/editor/panel/PromptField/utils/get-highlighted-text.tsx‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@ export const get_highlighted_text = (params: {
8181
return `<span class="${cn(
8282
styles['keyword'],
8383
styles['keyword--pasted-lines']
84-
)}" data-type="pasted-lines-keyword" data-path="${escape_html(
85-
path
86-
)}" data-content="${escape_html(content)}"${
87-
start ? ` data-start="${escape_html(start)}"` : ''
88-
}${end ? ` data-end="${escape_html(end)}"` : ''}><span class="${
84+
)}" data-type="pasted-lines-keyword" title="${escape_html(
85+
content
86+
)}" data-path="${escape_html(path)}" data-content="${escape_html(
87+
content
88+
)}"${start ? ` data-start="${escape_html(start)}"` : ''}${
89+
end ? ` data-end="${escape_html(end)}"` : ''
90+
}><span class="${
8991
styles['keyword__icon']
9092
}" data-role="keyword-icon"></span><span class="${
9193
styles['keyword__text']
@@ -98,10 +100,14 @@ export const get_highlighted_text = (params: {
98100
})
99101
const title = !params.current_selection
100102
? 'Missing text selection'
101-
: `Selection: ${params.current_selection.text
102-
.substring(0, 100)
103-
.replace(/\n/g, ' ')}...`
104-
return `<span class="${className}" data-type="selection-keyword" title="${escape_html(title)}"><span class="${styles['keyword__icon']}" data-role="keyword-icon"></span><span class="${styles['keyword__text']}" data-role="keyword-text">Selection</span></span>`
103+
: params.current_selection.text
104+
return `<span class="${className}" data-type="selection-keyword" title="${escape_html(
105+
title
106+
)}"><span class="${
107+
styles['keyword__icon']
108+
}" data-role="keyword-icon"></span><span class="${
109+
styles['keyword__text']
110+
}" data-role="keyword-text">Selection</span></span>`
105111
}
106112
if (part && /^#Changes:[^\s,;:!?]+$/.test(part)) {
107113
const branch_name = part.substring('#Changes:'.length)

0 commit comments

Comments
 (0)