Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there a way to be able to insert <iframe> in tinymce?

Tags:

iframe

tinymce

i'm trying,

But it strip its :S

My Tinymce init:

           // General options
      tinyMCE.init({
        // General options
        mode : "textareas",
        theme : "advanced",
        plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,

        // Skin options
        skin : "o2k7",
        skin_variant : "silver",

        // Example content CSS (should be your site CSS)
        content_css : "css/style.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "js/template_list.js",
        external_link_list_url : "js/link_list.js",
        external_image_list_url : "js/image_list.js",
        media_external_list_url : "js/media_list.js",

        // Replace values for the template plugin
        template_replace_values : {
                username : "Some User",
                staffid : "991234"
        }
});
like image 491
Toni Michel Caubet Avatar asked Mar 07 '11 14:03

Toni Michel Caubet


People also ask

How do I put content in TinyMCE?

How to setContent with multiple editors. Running the setContent() function on specifically editorOne with the tinymce. get('editorOne'). setContent(contentOne); method, you can change just editorOne.

How do I save HTML content of TinyMCE into a file?

To save the page, you have to insert TinyMCE in a HTML form and add a submit button. Then you'll have to handle the submitted form with a language like PHP. A call to the file_put_contents() function should do it.

Does TinyMCE support markdown?

Tiny Markdown is a markdown syntax plugin for TinyMCE, providing flexible rich text and markdown content creation options for authors, and also provides robust, reliable markdown output for developer projects.


1 Answers

I was looking for the same answer and found most of the links mentioned above misleading (e.g. mentioning to add new elements to valid_elements, or too cms(drupal)-driven). So I thought of adding this more direct answer:

On the default settings of tinyMCE, there are no iframes on settings.valid_elements, and the right place to extend/customize it would be adding new elements to the settings.extended_valid_elements like this:

tinyMCE.init({
    ...
    extended_valid_elements : "iframe[src|frameborder|style|scrolling|class|width|height|name|align]"
});

BTW, you can check/debug tinyMCE's settings easily within the console of Firebug or Chrome's Developer Tools. Just type: tinyMCE.settings.extended_valid_elements, to see if your settings are being loaded correctly or not.

like image 178
andzep Avatar answered Sep 29 '22 12:09

andzep