@@ -1414,6 +1414,7 @@ function initWikiForm() {
14141414 const $editArea = $ ( '.repository.wiki textarea#edit_area' ) ;
14151415 let sideBySideChanges = 0 ;
14161416 let sideBySideTimeout = null ;
1417+ let hasSimpleMDE = true ;
14171418 if ( $editArea . length > 0 ) {
14181419 const simplemde = new SimpleMDE ( {
14191420 autoDownloadFontAwesome : false ,
@@ -1510,6 +1511,12 @@ function initWikiForm() {
15101511 name : 'revert-to-textarea' ,
15111512 action ( e ) {
15121513 e . toTextArea ( ) ;
1514+ hasSimpleMDE = false ;
1515+ const $form = $ ( '.repository.wiki.new .ui.form' ) ;
1516+ const $root = $form . find ( '.field.content' ) ;
1517+ const loading = $root . data ( 'loading' ) ;
1518+ $root . append ( `<div class="ui bottom tab markdown" data-tab="preview">${ loading } </div>` ) ;
1519+ initCommentPreviewTab ( $form ) ;
15131520 } ,
15141521 className : 'fa fa-file' ,
15151522 title : 'Revert to simple textarea' ,
@@ -1524,15 +1531,26 @@ function initWikiForm() {
15241531 const $toolbar = $ ( '.editor-toolbar' ) ;
15251532 const $bPreview = $ ( '.editor-toolbar button.preview' ) ;
15261533 const $bSideBySide = $ ( '.editor-toolbar a.fa-columns' ) ;
1527- $bEdit . on ( 'click' , ( ) => {
1534+ $bEdit . on ( 'click' , ( e ) => {
1535+ if ( ! hasSimpleMDE ) {
1536+ return false ;
1537+ }
1538+ e . stopImmediatePropagation ( ) ;
15281539 if ( $toolbar . hasClass ( 'disabled-for-preview' ) ) {
15291540 $bPreview . trigger ( 'click' ) ;
15301541 }
1542+
1543+ return false ;
15311544 } ) ;
1532- $bPrev . on ( 'click' , ( ) => {
1545+ $bPrev . on ( 'click' , ( e ) => {
1546+ if ( ! hasSimpleMDE ) {
1547+ return false ;
1548+ }
1549+ e . stopImmediatePropagation ( ) ;
15331550 if ( ! $toolbar . hasClass ( 'disabled-for-preview' ) ) {
15341551 $bPreview . trigger ( 'click' ) ;
15351552 }
1553+ return false ;
15361554 } ) ;
15371555 $bPreview . on ( 'click' , ( ) => {
15381556 setTimeout ( ( ) => {
@@ -1552,6 +1570,8 @@ function initWikiForm() {
15521570 }
15531571 }
15541572 } , 0 ) ;
1573+
1574+ return false ;
15551575 } ) ;
15561576 $bSideBySide . on ( 'click' , ( ) => {
15571577 sideBySideChanges = 10 ;
0 commit comments