如何阻止TinyMCE用span替换不推荐使用的标记

如何阻止TinyMCE用span替换不推荐使用的标记,tinymce,html,Tinymce,Html,我使用TinyMCE在其行单击上捕获表行数据。我通过其配置UI屏幕为每个表格行内容设置不同的颜色、字体样式(如粗体和斜体)值。在单击行时,我想使用具有特定颜色和字体样式的文本设置TinyMCE内容。但是,它将不推荐的字体样式放在span标记中,我不希望这样。我希望它在编辑器接收HTML文本时保留它,因为以后我必须处理它。我试过: tinymce.init( { selector:'textarea', theme:"advanced",

我使用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
。此外,尽管设置了
有效的\u元素:“*[*]”
,不推荐使用的标记,如
,仍被放入span标记的style属性中

我找到了解决办法..我所要做的就是

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,
});

我找到了解决办法我所要做的就是

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,
});

下面是我对字体颜色、字体大小的处理方法。您可以将此技术应用于任何其他内容。这是给TinyMCE 4的

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

注意:您不能只将字体转换为span:false,您还需要格式。

以下是我对字体颜色、字体大小的处理方法。您可以将此技术应用于任何其他内容。这是给TinyMCE 4的

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

注意:您不能只将字体转换为span:false,您也需要格式。

为此,我实际上是在添加格式,它们似乎在开发人员工具中工作,但在保存或检查编辑器源代码时不起作用。我缺少
convert\u font\u to\u span:false
,对我来说这并不完全明显。为此,我实际上是在添加格式,它们似乎在开发人员工具中工作,但在保存或检查编辑器源代码时却不起作用。我缺少
convert\u font\u to\u span:false
,对我来说这并不完全明显。