@@ -1414,6 +1414,7 @@ function initWikiForm() {
1414
1414
const $editArea = $ ( '.repository.wiki textarea#edit_area' ) ;
1415
1415
let sideBySideChanges = 0 ;
1416
1416
let sideBySideTimeout = null ;
1417
+ let hasSimpleMDE = true ;
1417
1418
if ( $editArea . length > 0 ) {
1418
1419
const simplemde = new SimpleMDE ( {
1419
1420
autoDownloadFontAwesome : false ,
@@ -1510,6 +1511,12 @@ function initWikiForm() {
1510
1511
name : 'revert-to-textarea' ,
1511
1512
action ( e ) {
1512
1513
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 ) ;
1513
1520
} ,
1514
1521
className : 'fa fa-file' ,
1515
1522
title : 'Revert to simple textarea' ,
@@ -1524,15 +1531,26 @@ function initWikiForm() {
1524
1531
const $toolbar = $ ( '.editor-toolbar' ) ;
1525
1532
const $bPreview = $ ( '.editor-toolbar button.preview' ) ;
1526
1533
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 ( ) ;
1528
1539
if ( $toolbar . hasClass ( 'disabled-for-preview' ) ) {
1529
1540
$bPreview . trigger ( 'click' ) ;
1530
1541
}
1542
+
1543
+ return false ;
1531
1544
} ) ;
1532
- $bPrev . on ( 'click' , ( ) => {
1545
+ $bPrev . on ( 'click' , ( e ) => {
1546
+ if ( ! hasSimpleMDE ) {
1547
+ return false ;
1548
+ }
1549
+ e . stopImmediatePropagation ( ) ;
1533
1550
if ( ! $toolbar . hasClass ( 'disabled-for-preview' ) ) {
1534
1551
$bPreview . trigger ( 'click' ) ;
1535
1552
}
1553
+ return false ;
1536
1554
} ) ;
1537
1555
$bPreview . on ( 'click' , ( ) => {
1538
1556
setTimeout ( ( ) => {
@@ -1552,6 +1570,8 @@ function initWikiForm() {
1552
1570
}
1553
1571
}
1554
1572
} , 0 ) ;
1573
+
1574
+ return false ;
1555
1575
} ) ;
1556
1576
$bSideBySide . on ( 'click' , ( ) => {
1557
1577
sideBySideChanges = 10 ;
0 commit comments