1
1
import { __ } from "i18n" ;
2
- import { api } from "@converse/headless" ;
2
+ import { api , u } from "@converse/headless" ;
3
3
import { html } from "lit" ;
4
4
import { resetElementHeight } from "plugins/chatview/utils.js" ;
5
5
@@ -16,12 +16,10 @@ export default (el) => {
16
16
const show_send_button = api . settings . get ( "show_send_button" ) ;
17
17
const show_spoiler_button = api . settings . get ( "visible_toolbar_buttons" ) . spoiler ;
18
18
const show_toolbar = api . settings . get ( "show_toolbar" ) ;
19
- const hint_value = /** @type {HTMLInputElement } */ ( el . querySelector ( ".spoiler-hint" ) ) ?. value ;
20
- const message_value = /** @type {HTMLInputElement } */ ( el . querySelector ( ".chat-textarea" ) ) ?. value ;
21
19
return html ` < form class ="setNicknameButtonForm hidden ">
22
20
< input type ="submit " class ="btn btn-primary " name ="join " value ="Join " />
23
21
</ form >
24
- < form class ="chat-message-form " @submit =${ ( ev ) => el . onFormSubmitted ( ev ) } >
22
+ < form class ="chat-message-form " @submit =" ${ /** @param { SubmitEvent } ev */ ( ev ) => el . onFormSubmitted ( ev ) } " >
25
23
${ show_toolbar
26
24
? html ` < converse-chat-toolbar
27
25
class ="btn-toolbar chat-toolbar no-text-select "
@@ -40,27 +38,33 @@ export default (el) => {
40
38
< input
41
39
type ="text "
42
40
placeholder ="${ label_spoiler_hint || "" } "
43
- value ="${ hint_value || "" } "
41
+ .value ="${ el . model . get ( "draft_hint" ) ?? "" } "
42
+ @change ="${
43
+ /** @param {Event } ev */ ( ev ) =>
44
+ u . safeSave ( el . model , { draft_hint : /** @type {HTMLInputElement } */ ( ev . target ) . value } )
45
+ } "
44
46
class ="${ composing_spoiler ? "" : "hidden" } spoiler-hint "
45
47
/>
46
48
< div class ="suggestion-box ">
47
49
< ul class ="suggestion-box__results suggestion-box__results--above " hidden =""> </ ul >
48
50
< textarea
49
51
autofocus
50
52
type ="text "
51
- @drop =${ ( ev ) => el . onDrop ( ev ) }
53
+ .value ="${ el . model . get ( "draft" ) ?? "" } "
54
+ @drop ="${ /** @param {DragEvent } ev */ ( ev ) => el . onDrop ( ev ) } "
52
55
@input =${ resetElementHeight }
53
56
@keydown ="${ /** @param {KeyboardEvent } ev */ ( ev ) => el . onKeyDown ( ev ) } "
54
57
@keyup="${ /** @param {KeyboardEvent } ev */ ( ev ) => el . onKeyUp ( ev ) } "
55
58
@paste="${ /** @param {ClipboardEvent } ev */ ( ev ) => el . onPaste ( ev ) } "
56
- @change=${ ( ev ) => el . model . set ( { "draft" : ev . target . value } ) }
59
+ @change="${
60
+ /** @param {Event } ev */ ( ev ) =>
61
+ u . safeSave ( el . model , { draft : /** @type {HTMLTextAreaElement } */ ( ev . target ) . value } )
62
+ } "
57
63
class="chat-textarea suggestion-box__input
58
64
${ show_send_button ? "chat-textarea-send-button" : "" }
59
65
${ composing_spoiler ? "spoiler" : "" } "
60
66
placeholder="${ label_message } "
61
- >
62
- ${ message_value || "" } </ textarea
63
- >
67
+ > </ textarea >
64
68
< span
65
69
class ="suggestion-box__additions visually-hidden "
66
70
role ="status "
0 commit comments