Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get width, height or tinymce editor

Tags:

jquery

tinymce

i'm trying to get width and height of tinymce editor.

i'm trying to set width and height of textarea fit with rich text editor.

tried with jquery, but default it returns width=100px only :|

setup : function(ed) {
        // Add a custom button
        ed.addButton('bbcodemode', {
            title : 'View BBcode source',
            image : '{link}/tiny_mce/themes/advanced/img/bbcodemode.gif',
            onclick : function() {
                $.ajax({
                    type: "POST",
                    url: "{link}/htmltobbcode/",
                    data: "ctn="+encodeURIComponent(tinyMCE.activeEditor.getContent()),
                    success: function(msg){
                        $('#post_content').val(msg);
                        //tinyMCE.activeEditor.setContent(msg);


                    }
                });

                alert($('#post_content_ifr').width());
                $('#post_content').css("width",$('#post_content_ifr').width());
                $('#post_content').css("height",$('#post_content_ifr').height());

                // Add you own code to execute something on click
                tinyMCE.execCommand('mceToggleEditor',false,'post_content');


            }
        });
    }
like image 272
TomSawyer Avatar asked Apr 24 '26 15:04

TomSawyer


2 Answers

If the height and width of your editor have been set in the tinymce configuration you are able to get those settings from there using

tinymce.get('post_content').getParam('height');

and

tinymce.get('post_content').getParam('width');
like image 181
Thariama Avatar answered Apr 26 '26 04:04

Thariama


$(tinyMCE.activeEditor.getContainer()).height()

like image 24
Dušan Stanojević Avatar answered Apr 26 '26 06:04

Dušan Stanojević