@@ -87,10 +87,12 @@ export class GmailElementReplacer extends WebmailElementReplacer {
8787 ] ;
8888 } ;
8989
90- public setReplyBoxEditable = async ( ) => {
90+ public setReplyBoxEditable = async ( replyOption ?: ReplyOption ) => {
9191 const replyContainerIframe = $ ( '.reply_message_iframe_container > iframe' ) . last ( ) ;
9292 if ( replyContainerIframe . length ) {
93- $ ( replyContainerIframe ) . replaceWith ( this . factory . embeddedReply ( this . getLastMsgReplyParams ( this . getConvoRootEl ( replyContainerIframe [ 0 ] ) ) , true ) ) ; // xss-safe-value
93+ $ ( replyContainerIframe ) . replaceWith (
94+ this . factory . embeddedReply ( this . getLastMsgReplyParams ( this . getConvoRootEl ( replyContainerIframe [ 0 ] ) , replyOption ) , true )
95+ ) ; // xss-safe-value
9496 } else {
9597 await this . replaceStandardReplyBox ( undefined , true ) ;
9698 }
@@ -365,7 +367,8 @@ export class GmailElementReplacer extends WebmailElementReplacer {
365367
366368 private actionActivateSecureReplyHandler = async ( btn : HTMLElement , event : JQuery . Event ) => {
367369 event . stopImmediatePropagation ( ) ;
368- const secureReplyInvokedFromMenu = btn . className . includes ( 'action_reply_message_button' ) ;
370+ const secureReplyInvokedFromMenu = btn . className . includes ( 'action_menu_message_button' ) ;
371+ const replyOption : ReplyOption = btn . className . includes ( 'reply' ) ? 'a_reply' : 'a_forward' ;
369372 if ( $ ( '#switch_to_encrypted_reply' ) . length ) {
370373 $ ( '#switch_to_encrypted_reply' ) . trigger ( 'click' ) ;
371374 return ;
@@ -374,12 +377,12 @@ export class GmailElementReplacer extends WebmailElementReplacer {
374377 const messageContainer = secureReplyInvokedFromMenu ? $ ( '.T-I-JO.T-I-Kq' ) . closest ( '.h7' ) : $ ( btn . closest ( '.h7' ) ! ) ;
375378 if ( messageContainer . is ( ':last-child' ) ) {
376379 if ( this . isEncrypted ( ) ) {
377- await this . setReplyBoxEditable ( ) ;
380+ await this . setReplyBoxEditable ( replyOption ) ;
378381 } else {
379382 await this . replaceStandardReplyBox ( undefined , true ) ;
380383 }
381384 } else {
382- this . insertEncryptedReplyBox ( messageContainer ) ;
385+ this . insertEncryptedReplyBox ( messageContainer , replyOption ) ;
383386 }
384387 if ( secureReplyInvokedFromMenu ) {
385388 $ ( this . sel . msgActionsBtn ) . removeClass ( 'T-I-JO T-I-Kq' ) ;
@@ -613,18 +616,18 @@ export class GmailElementReplacer extends WebmailElementReplacer {
613616 return from ? Str . parseEmail ( from ) : undefined ;
614617 } ;
615618
616- private getLastMsgReplyParams = ( convoRootEl : JQuery ) : FactoryReplyParams => {
617- return { replyMsgId : this . determineMsgId ( $ ( convoRootEl ) . find ( this . sel . msgInner ) . last ( ) ) } ;
619+ private getLastMsgReplyParams = ( convoRootEl : JQuery , replyOption ?: ReplyOption ) : FactoryReplyParams => {
620+ return { replyMsgId : this . determineMsgId ( $ ( convoRootEl ) . find ( this . sel . msgInner ) . last ( ) ) , replyOption } ;
618621 } ;
619622
620623 private getConvoRootEl = ( anyInnerElement : HTMLElement ) => {
621624 return $ ( anyInnerElement ) . closest ( 'div.if, div.aHU, td.Bu' ) . first ( ) ;
622625 } ;
623626
624- private insertEncryptedReplyBox = ( messageContainer : JQuery < Element > ) => {
627+ private insertEncryptedReplyBox = ( messageContainer : JQuery < Element > , replyOption : ReplyOption ) => {
625628 const msgIdElement = messageContainer . find ( '[data-legacy-message-id], [data-message-id]' ) ;
626629 const msgId = msgIdElement . attr ( 'data-legacy-message-id' ) || msgIdElement . attr ( 'data-message-id' ) ;
627- const replyParams : FactoryReplyParams = { replyMsgId : msgId , removeAfterClose : true } ;
630+ const replyParams : FactoryReplyParams = { replyMsgId : msgId , removeAfterClose : true , replyOption } ;
628631 const secureReplyBoxXssSafe = /* xss-safe-factory */ `<div class="remove_borders reply_message_iframe_container inserted">${ this . factory . embeddedReply (
629632 replyParams ,
630633 true ,
0 commit comments