2015-09-09 54 views
1

我正在尝试使用RTE按钮,发现粘贴从单词到RTE的副本允许所有样式完好无损。所以我读了一个post并摆脱了额外的格式。现在我想处理空格和换行符。所以,通过一些分析,我决定允许:Sitecore:RTE粘贴为纯文本定制

单行换行的一个空格。报表显示为单paragraph.For例如

"This is new. </br> This is weird." should become "<p>This is new. &nbsp;This is weird.</p>" 

如果找到多个换行符,然后各个击破分离报表应采取行动,它们之间仅有一个休息的一个段落。例如

"This is new. </br></br></br> This is weird." should become "<p>This is new.</p> </br> <p>This is weird.</p>" 

这对于以前需要在粘贴词后需要调整整个废料的作者是非常有效的。

我已经使用“粘贴为纯文本”按钮尝试,但它并不需要换行的照顾。所以我想知道如何自定义按钮功能来调整它以满足我的需求?在哪里,我应该怎么做?

回答

0

您必须在Javascript中进行此更改......您可以在创作模式下捕获粘贴事件并在javascript中执行HTML操作时可以拥有自定义JS ... 其他选项可用作那么在ContentTree中就是在RTE中添加一个调用此javascript的按钮,在这里您可以找到关于如何将按钮添加到RTE的一些解释。 https://markstiles.net/Blog/2011/02/05/adding-button-to-rich-text-editor.aspx

1

在web.config文件中,您可以更改和更新HTMLEditor设置。
但是,您可能在HTML编辑器中有不同的方面和动态用户输入。所以,我建议你在Core DB中创建一个自定义RichText Editor,并根据需要创建一个程序集。然后,在App_include文件夹中创建另一个配置文件来修补并添加具有不同设置的自定义HTML编辑器。

以下内容来自web.config文件,如果您想继续使用默认的RichText Editor,则可以更新此配置。

<!-- HTML EDITOR DEFAULT CONFIGURATION TYPE 
    Specifies the type responsible for setting up the rich text editor. Can be overriden at profile level. Must inherit from 
    Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client. 
    Default value: Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client 
--> 
    <setting name="HtmlEditor.DefaultConfigurationType" value="Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration,Sitecore.Client" /> 
<!-- HTML EDITOR DEFAULT PROFILE 
Path to the default html editor profile. 
Default value: /sitecore/system/Settings/Html Editor Profiles/Rich Text Default 
--> 
    <setting name="HtmlEditor.DefaultProfile" value="/sitecore/system/Settings/Html Editor Profiles/Rich Text Default" /> 
<!-- HTML EDITOR LINE BREAK 
Specifies the tag that the HTML editor inserts on Enter. Values can be 
"br", "div" and "p". 
--> 
    <setting name="HtmlEditor.LineBreak" value="p" /> 
<!-- HTML EDITOR REMOVE SCRIPTS 
If true, the rich text editor removes script tags from RTE field values before saving. Setting the value to true reduces the potential for cross-site scripting and other script-related issues. 
Default value: true 
--> 
    <setting name="HtmlEditor.RemoveScripts" value="true" /> 
<!-- HTML EDITOR SUPPORT WEB CONTROLS 
Indicates if the Html Editor supports web controls. If true, Web Controls are shown as yellow boxes. 
Default value: true 
--> 
    <setting name="HtmlEditor.SupportWebControls" value="true" /> 
<!-- HTML EDITOR VALIDATOR SERVICE URL 
Specifies the url that validates XHtml. 
--> 
    <setting name="HtmlEditor.ValidatorServiceUrl" value="http://validator.w3.org/check" />