下划线格式问题 [英] Underline format problem
问题描述
根据文档,我想使用以下设置覆盖预定义的格式:
格式:{
bold:{inline:'b'},
italic:{inline:'i'},
下划线:{inline:'u'}
},
这是一个文本进入编辑器并按下下划线按钮。
这就是结果(这也得到保存到数据库):
< p> thi< span style = text-decoration:underline;> s是一个t< / span> ext< / p>
为什么我没有u-tags,但是带有下划线样式的预定义跨度?
我如何在这里获得可爱的标签?
编辑: 我知道
编辑2:我的解决方案归功于接受的答案:
我能够使用legacyoutput插件中的一些代码。我使用了 nline_styles设置
<$ p $
inline_styles:false,
另外还将以下代码转换为我的插件onInit
serializer = ed.serializer;
//强制解析串行器规则
serializer._setup();
//检查不允许使用的元素是否允许添加
tinymce.each('b,i,u'.split(','),function(name){
var rule = serializer.rules [name];
if(!rule)serializer.addRules(name);
});
真正的答案在这里变成: h2>
http://tinymce.moxiecode.com/wiki.php /插件:legacyoutput
(请参阅注释)
我不知道这是否正确,我只是重申我在在这里找到:
首先,您会收到警告:
<$ c
$ p
$
禁用inline_styles选项。
内联样式将大多数属性转换为CSS样式属性 - 所以它将使用span标签而不是< ; u>
,< strike>
等等,所以禁用这个选项(现在默认启用)寻找。
或者:
这样做:
$ / b
$ b $ pre $tinyMCE.init({
...
格式:{
下划线: {inline:'u',exact:true}
}
...
祝你好运!
According to the documentation i would like to overwrite predefined formats using this settings:
formats: { bold : {inline : 'b' }, italic : {inline : 'i' }, underline: { inline: 'u' } },
I insert "this is a text" into the editor and press the underline-button. This is the result (this gets saved to database too):
<p>thi<span style="text-decoration: underline;">s is a t</span>ext</p>
Why do i get no u-tags, but the predefined span with underlined style? How do i get my lovely u-tags here?
EDIT: I do know that u-tags are deprecated, but i need them for compatibility reasons!
EDIT2: My solution thanks to the accepted answer:
I was able to use some code from the legacyoutput plugin. I used the inline_styles setting
inline_styles: false,
additionally ia dded the following code into one of my plugins onInit
serializer = ed.serializer; // Force parsing of the serializer rules serializer._setup(); // Check that deprecated elements are allowed if not add them tinymce.each('b,i,u'.split(','), function(name) { var rule = serializer.rules[name]; if (!rule) serializer.addRules(name); });
解决方案The real answer here turned out to be:
http://tinymce.moxiecode.com/wiki.php/Plugin:legacyoutput
(see comments)
I don't know whether this is correct, I'm just reiterating what I found here:
Firstly, you're warned that:
<u>
is deprecated.Then:
Disable inline_styles option.
Inline styles converts most attributes into CSS style attributes - so it will use span tags rather than<u>
,<strike>
, etc. So, disabling this option (which is now enabled by default) gives the behaviour you're looking for.Alternatively:
This will do it:
tinyMCE.init({ ... formats : { underline : {inline : 'u', exact : true} } ...
Good luck!
这篇关于下划线格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!