6

我在<p>标签内的tinymce编辑器中有一些文本,没有别的,没有类,没有样式。当我选择文本并单击无序列表按钮时,它就<p>变成了一个列表。但每个<li>看起来都是这样的:

<li><span style="font-size: 12px; line-height: 1.5em;">Some text...</span></li>

这些样式来自哪里,哪个tinymce配置选项,哪个文件,哪个什么???我希望列表按钮只添加列表 html 标记,没有任何跨度和样式。

这是我的 tinymce 配置。配置是直接从 Chrome 检查器复制的(这就是嵌套道具中没有缩进的原因):(断点位于第 13547 行,tinymce.add(t);在 tiny_mce_src.js 中的语句处)

settings: Object
accessibility_focus: true
accessibility_warnings: false
add_form_submit_trigger: true
add_unload_trigger: true
apply_source_formatting: 0
bodyClass: "wysiwygeditor"
button_tile_map: true
content_css: "/sites/all/themes/adaptivetheme/at_core/css/at.layout.css,/sites/all/themes/atsl/css/global.base.css,/sites/all/themes/mytheme/css/global.styles.css
convert_fonts_to_spans: 1
convert_urls: false
delta_height: 0
delta_width: 0
dialog_type: "modal"
directionality: "ltr"
doctype: "<!DOCTYPE>"
document_base_url: "/"
entities: "quot,apos,amp,lt,gt,nbsp,iexcl"
entity_encoding: "named"
extended_valid_elements: ""
fix_table_elements: true
font_size_legacy_values: "xx-small,small,medium,large,x-large,xx-large,300%"
font_size_style_values: "xx-small,x-small,small,medium,large,x-large,xx-large"
forced_root_block: "p"
formats: Object
hidden_input: true
id: "edit-body-und-0-value"
ie7_compat: true
indent: "simple"
indent_after: "p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist"
indent_before: "p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist"
indentation: "30px"
inline_styles: true
language: "en"
mode: "none"
object_resizing: true
padd_empty_editor: true
paste_auto_cleanup_on_paste: 0
plugins: "style,-codemagic"
popup_css: ""
preformatted: 1
relative_urls: true
remove_linebreaks: 1
remove_script_host: true
render_ui: true
skin: "thebigreason"
strict_loading_mode: true
style_formats: Object
submit_patch: true
table_inline_editing: false
table_styles: Array[0]
theme: "advanced"
theme_advanced_blockformats: "p,h3,h4"
theme_advanced_buttons1: "bold,italic,underline,justifyleft,justifycenter,justifyright,separator,bullist,numlist,indent,outdent"
theme_advanced_buttons2: "link,image,media,charmap,blockquote,separator,formatselect,removeformat,styleselect,codemagic"
theme_advanced_buttons3: ""
theme_advanced_resize_horizontal: 0
theme_advanced_resizing: 1
theme_advanced_resizing_use_cookie: false
theme_advanced_statusbar_location: "bottom"
theme_advanced_toolbar_align: "left"
theme_advanced_toolbar_location: "top"
url_converter: function (url, name, elm) {
url_converter_scope: tinymce.create.Editor
validate: true
verify_html: true
visual: true
width: "100%"

“格式”是这样的:

formats: Object
aligncenter: Object
classes: "align-center"
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img"
__proto__: Object
alignleft: Object
classes: "align-left"
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img"
__proto__: Object
alignright: Object
classes: "align-right"
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img"
__proto__: Object
forecolor: Object
classes: "forecolor"
inline: "span"
styles: Object
__proto__: Object
hilitecolor: Object
classes: "hilitecolor"
inline: "span"
styles: Object
__proto__: Object
strikethrough: Object
inline: "line-through"
__proto__: Object
underline: Object
classes: "underline"
exact: true
inline: "span"
__proto__: Object
__proto__: Object

“样式格式”是这样的:

style_formats: Object
blink: Object
attributes: Object
class: "blink"
__proto__: Object
inline: "span"
title: "Blink"
__proto__: Object
__proto__: Object
4

2 回答 2

7

看起来我找到了解决您问题的方法:http ://martinsikora.com/how-to-make-tinymce-to-output-clean-html

关键在于使用extended_valid_elements。这将删除所有没有类属性的跨度

extended_valid_elements : "span[!class]"
于 2013-01-29T11:24:29.237 回答
3

与http://fiddle.tinymce.com相比,我的 tinymce 配置缺少“插件”设置。 当我添加“插件”设置时,tinymce 不再将带有样式的跨度插入列表。

一些使我找到解决方案的附加信息:

在我的网站上调试时(在创建列表时), tiny_mce_src.js 的第 14212 行返回 false - 它在 tinymce fiddle 上返回 true。( if (o = t.execCommands[cmd]) {.....)

在我的网站上,tinymce 以某种方式执行了第 15063 行(execNativeCommand函数),而在 tinymce 小提琴上却没有(可能是缺少插件的结果)

本机 ChromeexecCommand在插入样式跨度时存在问题,如下所述:http: //help.dottoro.com/ljcvtcaw.php我还创建了一个小提琴来确认它:http: //jsfiddle.net/fUsmx/(关闭并重新打开检查器看结果)

于 2013-02-02T15:24:25.650 回答