admin管理员组

文章数量:1277896

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).

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).

Share Improve this question edited Oct 8, 2017 at 19:42 Ninjakannon 3,8197 gold badges55 silver badges81 bronze badges asked Dec 23, 2015 at 14:25 JANJAN 21.9k66 gold badges188 silver badges335 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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',
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 }'
            });
        }
}

本文标签: javascriptAdd properties to TinyMce after init()Stack Overflow