Is there a way to make the tinymce code editor read-only?
I created this sample: http://codepen.io/costa_b/pen/woRpKO. Source code here for initialization of the tinymce component:
tinymce.init({
selector: 'textarea',
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link charmap code ',
'searchreplace ',
'insertdatetime paste contextmenu'
],
toolbar: 'undo redo | insert | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link | code ',
//content_css: '//www.tinymce.com/css/codepen.min.css',
content_style: 'p {margin: 0px; border: 0px solid red; padding: 0px}'
});
When you click on the code button (<>), the editor shows the source code dialog, but it is editable. I want to make it read-only. Is it doable?
Thanks
I had the same need as you recently so I took the
code
plugin source code from the development version on TinyMCE website and modified it to disable source code editing while inReadOnly
mode.I advise you to do like me, instead of modifying directly your code plugin, you should create a new one. Create a new folder named
customCode
under theplugins
directory and create a file namedplugin.min.js
if you are callingtinymce.min.js
otherwise your file should be namedplugin.js
. Then paste this code insideThen your TinyMCE initialization should become