Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add properties to TinyMce after init()?

Consider the initialization:

function initMyTinymce() {
    tinymce.init({
        selector: $(this).attr("id"),
        directionality: "ltr",
    });
}

Is it possible to add properties to tinyMCE after init()?

For example:

plugins: "link,code,textcolor",
relative_urls: false,
convert_urls: false,
remove_script_host: false

I'm using TinyMce 4.1.6 (2014-10-08).

like image 746
JAN Avatar asked Dec 23 '15 14:12

JAN


2 Answers

Yes, this is possible, but parameters that get read on initialisation only won't have an impact if they get set later on. Example: To change the parameter plugins changes nothing because the tinymce UI has been rendered already.

To set a paramter after initialization use:

editor.settings.my_setting = 'abcd',
like image 63
Thariama Avatar answered Oct 14 '22 04:10

Thariama


function Tiny_readonly(id, action) {
    tinymce.get(id).remove();
        if (action == 0) {
            tinymce.init({
                selector: 'textarea#' + id,
                skin: 'dark',
                height: 200,
                readonly: true,
                toolbar: false,
                menubar: false,
                statusbar: false,
                init_instance_callback: function(editor) {},
            });
        } else {
            tinymce.init({
                selector: 'textarea#' + id,
                height: 250,
                menubar: false,
                skin: 'default',
                plugins: [
                    'advlist autolink lists link  charmap print preview anchor',
                    'searchreplace visualblocks code fullscreen',
                    'insertdatetime media table paste code help wordcount'
                ],
                toolbar: 'undo redo | formatselect | ' +
                    'bold italic backcolor | alignleft aligncenter ' +
                    'alignright alignjustify | bullist numlist outdent indent | ' +
                    'removeformat | table',
                content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }'
            });
        }
}
like image 41
Panthelis Avatar answered Oct 14 '22 05:10

Panthelis