File tree Expand file tree Collapse file tree 2 files changed +46
-13
lines changed
Expand file tree Collapse file tree 2 files changed +46
-13
lines changed Original file line number Diff line number Diff line change 99 export let path: number [] = [];
1010 export let selectedPath: number [] | null = null ;
1111 export let selectMessage: (path : number []) => void = () => {};
12+ export let startEditing: (path : number []) => void = () => {};
1213 export let apiBaseUrl = ' ' ;
1314 export let getAuthHeaders: () => Promise <Record <string , string >> = async () => ({
1415 Accept: ' application/json'
459460 </button >
460461 </div >
461462 {/if }
463+ {#if isSelected && message .key && message .isText && message .status === ' saved' }
464+ <button
465+ type =" button"
466+ class =" edit-message-button"
467+ on:click |stopPropagation ={() => startEditing (path )}
468+ aria-label =" Edit message"
469+ title =" Edit message"
470+ >
471+ <svg viewBox =" 0 0 24 24" width =" 14" height =" 14" fill =" currentColor"
472+ ><path
473+ d =" M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"
474+ /></svg
475+ >
476+ </button >
477+ {/if }
462478 <div class ={` status ${statusClass } ` }>{statusText }</div >
463479 {#if childNodes .length > 0 }
464480 <div class =" children" >
471487 {selectMessage }
472488 {apiBaseUrl }
473489 {getAuthHeaders }
490+ {startEditing }
474491 />
475492 {/each }
476493 </div >
542559
543560<style >
544561 .message {
562+ position : relative ;
545563 background : #00000019 ;
546564 border-top-right-radius : 0.75rem ;
547565 border-bottom-right-radius : 0.75rem ;
969987 .message.selected {
970988 outline : 1px solid #fff ;
971989 }
990+
991+ .edit-message-button {
992+ position : absolute ;
993+ top : 0.5rem ;
994+ right : 0.5rem ;
995+ background : transparent ;
996+ border : none ;
997+ color : #94a3b8 ;
998+ cursor : pointer ;
999+ padding : 0.25rem ;
1000+ border-radius : 0.25rem ;
1001+ line-height : 0 ;
1002+ transition :
1003+ color 0.15s ease ,
1004+ background 0.15s ease ;
1005+ }
1006+
1007+ .edit-message-button :hover {
1008+ color : #e2e8f0 ;
1009+ background : rgba (255 , 255 , 255 , 0.1 );
1010+ }
9721011 </style >
Original file line number Diff line number Diff line change 21662166 </button >
21672167 </div >
21682168 {/if }
2169- {#if ! newThreadMode && canEditMessage ( selectedMessage ) }
2169+ {#if editMode }
21702170 <div class =" edit-controls" >
2171- <button
2172- type =" button"
2173- on:click ={() => void startEditingSelected ()}
2174- disabled ={statusState === ' sending' }
2175- >
2176- {editMode ? ' Editing…' : ' Edit message' }
2171+ <button type ="button" on:click ={cancelEdit } disabled ={statusState === ' sending' }>
2172+ Cancel edit
21772173 </button >
2178- {#if editMode }
2179- <button type ="button" on:click ={cancelEdit } disabled ={statusState === ' sending' }>
2180- Cancel edit
2181- </button >
2182- {/if }
21832174 </div >
21842175 {/if }
21852176 {#if newThreadMode }
22432234 selectMessage ={handleSelectMessage }
22442235 apiBaseUrl ={API_BASE_URL }
22452236 getAuthHeaders ={buildAuthHeaders }
2237+ startEditing ={startEditingSelected }
22462238 />
22472239 {/each }
22482240 {/if }
23382330 <textarea
23392331 bind:value ={inputValue }
23402332 rows =" 3"
2341- placeholder ={editMode ? ' Edit message and press Enter' : ' Type a message and press Enter' }
2333+ placeholder ={editMode
2334+ ? ' Edit message and press Enter'
2335+ : ' Type a message and press Enter' }
23422336 on:keydown ={handleKeydown }
23432337 ></textarea >
23442338 {:else }
You can’t perform that action at this time.
0 commit comments