如何配置TinyMCE以允许锚(a)标记内的块级元素? [英] How to configure TinyMCE to allow block-level elements inside anchor (a) tag?

查看:600
本文介绍了如何配置TinyMCE以允许锚(a)标记内的块级元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的情景:

我希望能够创建内容,例如

I want to be able to create content like


< div> < a id =supportTileclass =contentModule
href =/ Support> < H2>载体< / H2> < / A>
< / div>

<div> <a id="supportTile" class="contentModule" href="/Support"> <h2>Support</h2> </a> </div>

然而,tinyMCE将其剥离为

However tinyMCE strips it to

< div> < H2>载体< / H2> < / div>

<div> <h2>Support</h2> </div>

我的配置目前是这样的(使用TinyMCE jQuery):

My configuration is currently like this (using TinyMCE jQuery):


script_url: _applicationRoot + "Scripts/tiny_mce/tiny_mce.js",
theme: "advanced",                    
plugins: "paste,filemanager,imagemanager,advimage,inlinepopups",
...
extended_valid_elements: "img[!src|border:0|alt|title|width|height|style|name|id|class],a[href|target|title|onclick|name|id|class],article[name|id|class],div[name|id|class],section[name|id|class]",
schema: "html5",               
...
convert_urls: true,
document_base_url: _applicationRoot


我尝试设置verify_html:false但没有运气。

I tried setting verify_html: false but no luck.

我尝试删除extended_valid_elements并将其替换为:

I tried removing extended_valid_elements and replacing it with:


valid_elements: "*[*]",
verify_html: false


没有运气她。

你能看到我的配置有问题吗?这是否可以实现?

Can you see something wrong with my configuration? Is this achievable at all?

谢谢!

推荐答案

是的,这应该是可以实现的。为了能够产生类似

Yes, this should be achievable. In order to be able to produce output like

<div> <a id="supportTile" class="contentModule" href="/Support"> <h2>Support</h2> </a> </div>

你必须修改tinymce设置 valid_children 和valid_elements。您需要注意有一个默认设置,您可能需要放大。

you will have to modify the tinymce setting valid_children and valid_elements. You need to be aware that there is a default setting which you might need to enlarge.

valid_elements:* [*]将无效,因为有希望在最新版本或下一版本中删除的错误。

valid_elements: "*[*]" won't work because of a bug that hopefully will be removed in the newest or next version.

我使用此设置(我不使用div也不是h2s)

I use this settings (i don't use divs nor h2s)

valid_elements: "@[id|class|title|style],"
+ "a[name|href|target|title|alt],"
+ "#p,-ol,-ul,-li,br,img[src|unselectable],-sub,-sup,-b,-i,-u,"
+ "-span[data-mce-type],hr",

valid_child_elements : "body[p,ol,ul]"
+ ",p[a|span|b|i|u|sup|sub|img|hr|#text]"
+ ",span[a|b|i|u|sup|sub|img|#text]"
+ ",a[span|b|i|u|sup|sub|img|#text]"
+ ",b[span|a|i|u|sup|sub|img|#text]"
+ ",i[span|a|b|u|sup|sub|img|#text]"
+ ",sup[span|a|i|b|u|sub|img|#text]"
+ ",sub[span|a|i|b|u|sup|img|#text]"
+ ",li[span|a|b|i|u|sup|sub|img|ol|ul|#text]"
+ ",ol[li]"
+ ",ul[li]",

这篇关于如何配置TinyMCE以允许锚(a)标记内的块级元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆