我想使用class属性来定位特定的iframe,以便用CSS设置宽度。
iframes是像这样的google地图嵌入:
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.uk/?ie=UTF8&t=m&ll=52.8382,-2.327815&spn=4.646012,9.338379&z=6&output=embed"></iframe>它们被复制并粘贴到tinyMCE的HTML源编辑器中。我需要将一个class属性应用于iframe,但是在源代码编辑器上单击更新时,它被删除了。
我尝试过在配置中使用valid_elements和extended_valid_elements,但都不适用于iframeclass。
我运行的是3.4.3版本。我下载了3.5.7,它似乎也有同样的问题。该行为也在tinyMCE网站(http://www.tinymce.com/tryit/full.php)上的演示中展示,尽管valid_elements的文档表明支持类属性(http://www.tinymce.com/wiki.php/Configuration:valid_elements)。
下面是完整的配置:
tinyMCE.init({
// General options
mode : "specific_textareas",
editor_selector : "formInputWysiwyg",
theme : "advanced",
plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,wordcount,advlist",
// Theme options
theme_advanced_buttons1 : "bold,italic,strikethrough,formatselect,styleselect,undo,redo,|,code,|,fullscreen,",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,|,search,replace,|,bullist,numlist,|,blockquote,nonbreaking,|,charmap,media,|,link,unlink,anchor,image",
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
width : "500",
height : "600",
apply_source_formatting : true,
remove_linebreaks: true,
theme_advanced_blockformats : "p,blockquote,h1,h2,h3,h4,h5,h6",
forced_root_block : false,
plugin_preview_width : "1050",
plugin_preview_height : "800",
convert_urls : false,
extended_valid_elements : "figure,figcaption",
// Skin options
skin : "o2k7",
skin_variant : "silver",
// Example content CSS (should be your site CSS)
content_css : "/admin/includes/css/tinymce.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Style formats
style_formats : [
{title : 'Google Maps', selector : 'iframe', classes : 'google-maps-embed'},
{title : 'Intro', selector : 'p', classes : 'intro'},
{title : 'News Image', selector : 'img', classes : 'news-image'}
],
});发布于 2012-11-10 00:19:17
你启用了'media‘插件了吗?我看到了类似的问题,我想知道媒体插件是否干扰了编辑器对HTML元素的正常操作。我尝试创建一个style_formats选项来操作iframe,但是没有成功。
发布于 2012-11-28 11:45:45
在\tinymce\jscripts\tiny_mce\plugins\media\editor_plugin_src.js,中,我已经修复了这个问题,我从rootAttributes中删除了第12行中的"class“,然后使用jscompress.com缩小并替换了editor_plugin.js文件的内容(在相同的文件夹中)。
已更改:
var rootAttributes = tinymce.explode('id,name,width,height,style,align,class,hspace,vspace,bgcolor,type')至:
var rootAttributes = tinymce.explode('id,name,width,height,style,align,hspace,vspace,bgcolor,type')这在3.5.8中仍然是一个问题,并已将其作为错误提交。
发布于 2017-12-21 16:45:17
对于遇到媒体插件冲突,但仍然需要媒体插件的用户,可以在tinymce初始化时设置以下选项,以消除冲突:
media_live_embeds: false在tinymce v4.6.1中测试
https://stackoverflow.com/questions/13161323
复制相似问题