rahul.m
rahul.m

Reputation: 5854

Tinymce on tab press make : symbol in same line

I am using tinymce editor, what I want is when user press tab button before: symbol it should be string alignment. For reference please check screenshot. enter image description here

tinyMCE.init({
    selector: 'textarea',
    indentation : '60pt',
    plugins: 'textcolor print preview importcss searchreplace autolink autosave save directionality visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount imagetools textpattern noneditable',
    paste_as_text:true,
    //menubar: false,
    toolbar: 'bold italic underline strikethrough superscript subscript | fontselect fontsizeselect | alignleft aligncenter alignright alignjustify | outdent indent |  numlist bullist checklist | forecolor backcolor',
    nonbreaking_force_tab: true

});

enter image description here

Upvotes: 3

Views: 770

Answers (1)

Lasithds
Lasithds

Reputation: 2291

You can listen to the Tab key and add 4 spaces. Check the fiddle for a working example. Documentation

tinymce.init({
  selector: '#mytextarea',
  init_instance_callback: function(editor) {
    editor.on('keydown', function(e) {
        if(e.keyCode == 9){
          e.preventDefault();
          tinymce.activeEditor.execCommand('mceInsertContent', false, "    ");
        }
    });
  }
});

Upvotes: 3

Related Questions