@@ -323,12 +323,14 @@ function initSimpleMDEImagePaste(simplemde, files) {
323
323
} ) ;
324
324
}
325
325
326
+ let autoSimpleMDE ;
327
+
326
328
function initCommentForm ( ) {
327
329
if ( $ ( '.comment.form' ) . length === 0 ) {
328
330
return ;
329
331
}
330
332
331
- setCommentSimpleMDE ( $ ( '.comment.form textarea:not(.review-textarea)' ) ) ;
333
+ autoSimpleMDE = setCommentSimpleMDE ( $ ( '.comment.form textarea:not(.review-textarea)' ) ) ;
332
334
initBranchSelector ( ) ;
333
335
initCommentPreviewTab ( $ ( '.comment.form' ) ) ;
334
336
initImagePaste ( $ ( '.comment.form textarea' ) ) ;
@@ -826,25 +828,27 @@ function initRepository() {
826
828
$ ( '.quote-reply' ) . click ( function ( event ) {
827
829
$ ( this ) . closest ( '.dropdown' ) . find ( '.menu' ) . toggle ( 'visible' ) ;
828
830
const target = $ ( this ) . data ( 'target' ) ;
831
+ const quote = $ ( `#comment-${ target } ` ) . text ( ) . replace ( / \n / g, '\n> ' ) ;
832
+ const content = `> ${ quote } \n\n` ;
829
833
830
834
let $content ;
831
835
if ( $ ( this ) . hasClass ( 'quote-reply-diff' ) ) {
832
836
const $parent = $ ( this ) . closest ( '.comment-code-cloud' ) ;
833
837
$parent . find ( 'button.comment-form-reply' ) . click ( ) ;
834
838
$content = $parent . find ( '[name="content"]' ) ;
835
- } else {
836
- $content = $ ( '#content' ) ;
837
- }
838
-
839
- const quote = $ ( `#comment-${ target } ` ) . text ( ) . replace ( / \n / g, '\n> ' ) ;
840
- const content = `> ${ quote } \n\n` ;
841
-
842
- if ( $content . val ( ) !== '' ) {
843
- $content . val ( `${ $content . val ( ) } \n\n${ content } ` ) ;
844
- } else {
845
- $content . val ( `${ content } ` ) ;
839
+ if ( $content . val ( ) !== '' ) {
840
+ $content . val ( `${ $content . val ( ) } \n\n${ content } ` ) ;
841
+ } else {
842
+ $content . val ( `${ content } ` ) ;
843
+ }
844
+ $content . focus ( ) ;
845
+ } else if ( autoSimpleMDE !== null ) {
846
+ if ( autoSimpleMDE . value ( ) !== '' ) {
847
+ autoSimpleMDE . value ( `${ autoSimpleMDE . value ( ) } \n\n${ content } ` ) ;
848
+ } else {
849
+ autoSimpleMDE . value ( `${ content } ` ) ;
850
+ }
846
851
}
847
- $content . focus ( ) ;
848
852
event . preventDefault ( ) ;
849
853
} ) ;
850
854
0 commit comments