我已经使用了很长一段时间(简单的设置)并且它已经做了相当不错的工作,使用基本样式选项(粗体,斜体,列表等)很好地设计样式。有时虽然,我想当用户将文本复制粘贴到文字框中时,或者某些样式变得非常丑陋,如下面的示例所示。有没有办法将样式限制为简单设置中引用按钮的基本样式?
<p>df</p>
<p><!--[if gte mso 9]><xml> <w:WordDocument>
<w:View>Normal</w:View> <w:Zoom>0</w:Zoom>
<w:TrackMoves />
<w:TrackFormatting /> <w:PunctuationKerning />
<w:ValidateAgainstSchemas />
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF /> <w:LidThemeOther>RU</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell />
<w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx />
<w:Word11KerningPairs /> <w:CachedColBalance />
</w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" />
...
<w:LsdException Locked="false" Priority="70" SemiHidden="false" UnhideWhenUsed="false" Name="Dark List" />
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false" UnhideWhenUsed="false" Name="Colorful List" />
答案 0 :(得分:5)
这是一个非常普遍的问题。通常,当您尝试将文本从Word复制到TinyMCE时,它也将继承格式。它除了Word之外还可以从其他应用程序中发生。为了摆脱所有这些不需要的标签,您需要使用the paste plugin。将这些设置用于init函数:
tinyMCE.init({
// ...
plugins : "paste",
paste_text_sticky : true,
setup : function(ed) {
ed.onInit.add(function(ed) {
ed.pasteAsPlainText = true;
});
}
// ...
});
您也可以使用paste_preprocess和/或paste_postprocess设置对粘贴的代码执行javascript操作。
以下是一些可用于定制功能的更高级设置:
plugins : "paste,...",
paste_use_dialog : false,
paste_auto_cleanup_on_paste : true,
paste_convert_headers_to_strong : false,
paste_strip_class_attributes : "all",
paste_remove_spans : true,
paste_remove_styles : true,
paste_retain_style_properties : "",