0

我正在使用 TinyMCE 在其行单击时捕获表行数据。我通过其配置 UI 屏幕为每个表格行内容设置不同的颜色、字体样式(如粗体和斜体)值。在行单击时,我想使用具有特定颜色和字体样式的文本设置 TinyMCE 内容。但是,它将弃用的字体样式放在 span 标记中,我不希望这样。我希望它保留编辑器收到的 HTML 文本,因为稍后我必须处理它。我努力了:

tinymce.init(
  {
    selector:'textarea',
    theme:"advanced",                   
    theme_advanced_statusbar_location : "none",
    theme_advanced_menubar_location : "none",
    theme_advanced_toolbar_location : "none",
    convert_fonts_to_spans : "false",
    extended_valid_elements : "span[!class]",
    valid_elements : "*[*]",
    valid_children : "*[*]",
    cleanup_on_startup : false,
    cleanup : false,
  }
);

即使 TinyMCE 的主要开发人员建议不要cleanup =false在他们的论坛页面上进行设置。此外,尽管设置valid_elements : "*[*]"了 ,但不推荐使用的标签如<b><u>被放入 span 标签的 style 属性中。

4

2 回答 2

2

这是我为字体颜色,字体大小做的方式。您可以将此技术应用于其他任何事物。这适用于 TinyMCE 4

    convert_fonts_to_spans : false,
    formats: {
        forecolor : {inline : 'font', attributes: { color: "%value" }},
        fontsize: {inline : 'font', attributes: { size: "%value" }}
    },

注意:你不能只做 convert_fonts_to_spans : false,你也需要格式。

于 2014-12-09T16:16:39.873 回答
1

我找到了解决方案..我所要做的就是

tinymce.init({

    selector:'textarea',
    theme:"advanced",                   
    theme_advanced_statusbar_location : "none",
    theme_advanced_menubar_location : "none",
    theme_advanced_toolbar_location : "none",
    convert_fonts_to_spans : false,
    valid_elements : "b,u,i,font[color|size]",
    valid_children : "b,u,i,font[color|size}",
    cleanup_on_startup : false,
    cleanup : false,
});
于 2013-08-15T09:13:12.147 回答