1

I'm using Redactor 2 and I set config air: true and plugin: ['codemirror']. The issue is when I click on html button the air toolbar disappears and is not possible to have toolbar on redactor again.

Is there a solution?

Thanks in advance.

3 Answers 3

1

I found a quick solution to show toolbar when hover code mirror

 callbacks: {   
   init: function() {    
   $('.CodeMirror-scroll').on('hover',function(){
         $('.redactor-air').css('display','block');       
          });
       } 
}

But the issue is the same when i have more then one redactor in same page, because it shows both toolbar...

Any help on this ? Thanks

1
  • Try changing $('.redactor-air') to $(this).closest('.redactor-air') inside the hover event callback function. Oct 29, 2016 at 18:26
1

The right thing to do is

var that = this;
var id = $(that.$editor).attr('id')
$('#'+id).parent('.redactor-box').find('.CodeMirrorscroll').on('hover',function(){
var idnumber = id.replace('redactor-uuid-','')
$('#redactor-air-'+idnumber).css('display','block');
});

on

init: function()
                {

Now its ok, its only opens one if you have more than one

THanks Carlos Vieira

1

I created a callback on click in the .CodeMirror-gutters:

init: function(e) {
    var a = this.codemirror;
    $('.CodeMirror-gutters').on('click',function(e){
        if(a.$textarea.hasClass('open')){ a.hide(); }
    });
},

and added a Material Icons code icon to the .CodeMirror-gutters:after css:

.CodeMirror-gutters:after {
    font-family: 'Material Icons';
    etc...
    content: '\E86F';
}

so that when the user clicks the gutter in 'source' mode, it toggles back to 'visual' mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.