2

I want to make tinymce input to read only. i have tried with the below code. Please help me with this issue.

tinymce.init({
    selector: '#deliberations',
    menubar: false,
    readonly: true, 
    branding: false,
    height: 100,
    max_height: 400,
    theme: 'modern',
    toolbar: false,
                toolbar_items_size: 'small',
                plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak','searchreplace wordcount visualblocks visualchars code fullscreen','insertdatetime media nonbreaking save table contextmenu directionality','emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help'],

                toolbar1: 'insert | undo redo |  styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image print preview media | forecolor backcolor emoticons | fullscreen | table',

    image_advtab: true,
    templates: [{
            title: 'Test template 1',
            content: 'Test 1'
        },
        {
            title: 'Test template 2',
            content: 'Test 2'

        }
    ],
    content_css: [

    ]

});
Krzysztof Janiszewski
  • 3,763
  • 3
  • 18
  • 38
Boga Ravali
  • 41
  • 2
  • 4

2 Answers2

2

If you are using version 4.x, remove the readonly: true option and try

setup: function (editor) {
    editor.setMode("readonly")
    },

http://fiddle.tinymce.com/Lugaab/2

TheRobQ
  • 108
  • 8
0

As stated in the TinyMCE docs https://www.tinymce.com/docs-3x/reference/configuration/Configuration3x@readonly/ the readonly attribute should be set to '1' not to 'true'.

tinymce.init({
    selector: '#deliberations',
    menubar: false,
    readonly: 1, 
    branding: false,
    height: 100,
    max_height: 400,
    theme: 'modern',
    toolbar: false,
                toolbar_items_size: 'small',
                plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak','searchreplace wordcount visualblocks visualchars code fullscreen','insertdatetime media nonbreaking save table contextmenu directionality','emoticons template paste textcolor colorpicker textpattern imagetools codesample toc help'],

                toolbar1: 'insert | undo redo |  styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image print preview media | forecolor backcolor emoticons | fullscreen | table',

    image_advtab: true,
    templates: [{
            title: 'Test template 1',
            content: 'Test 1'
        },
        {
            title: 'Test template 2',
            content: 'Test 2'

        }
    ],
    content_css: [

    ]

});
peeebeee
  • 2,541
  • 6
  • 21
  • 26