Hi Shae,
You can map template for HtmlField and specify "MaxUploadFileSize" value which will set the default restriction for the Flash Manager in our content editor. To map the template, please follow the below steps:
1. Create a custom template based on the below sample (name is not important in this case, as long as
you specify the correct application relative path when mapping the template):
<%@ Control Language="C#" CodeFile="~/Controls/EditorTemplate.ascx.cs" Inherits="SitefinityWebApp.Controls.EditorTemplate"%>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<sf:ConditionalTemplateContainer ID="conditionalTemplate" runat="server">
<Templates>
<sf:ConditionalTemplate ID="ConditionalTemplate1" Left="DisplayMode" Operator="Equal" Right="Read" runat="server">
<sf:SitefinityLabel id="titleLabel_read" runat="server" WrapperTagName="div" HideIfNoText="false" CssClass="sfTxtLbl" />
<sf:SitefinityLabel id="viewControl" runat="server" WrapperTagName="div" HideIfNoText="false" CssClass="sfRTFContent" />
</sf:ConditionalTemplate>
<sf:ConditionalTemplate ID="ConditionalTemplate2" Left="DisplayMode" Operator="Equal" Right="Write" runat="server">
<sf:ResourceLinks id="resourcesLinks2" runat="server">
<sf:EmbeddedResourcePropertySetter Name="Telerik.Sitefinity.Resources.Themes.Default.Styles.EditorDialogs.css" Static="true" ControlID="editControl" ControlPropertyName="DialogsCssFile" />
<sf:ResourceFile Name="Telerik.Sitefinity.Resources.Themes.Default.Styles.Window.css" Static="true" />
</sf:ResourceLinks>
<asp:Label ID="titleLabel_write" runat="server" CssClass="sfTxtLbl" AssociatedControlID="editControl" />
<asp:LinkButton ID="expandLink" runat="server" OnClientClick="return false;" CssClass="sfOptionalExpander" />
<asp:Panel ID="expandableTarget" runat="server" CssClass="sfEditorWrp sfClearfix">
<telerik:RadEditor
ID="editControl"
runat="server"
Skin="Sitefinity"
Width="100%"
Height="550px"
EnableResize="False"
EditModes="Design,HTML"
DialogHandlerUrl="~/Telerik.Web.UI.DialogHandler.axd"
Content=""
NewLineBr="False"
StripFormattingOptions="Css,Font,Span"
OnClientLoad="Telerik$Sitefinity$Web$UI$Fields$HtmlField$radEditorToggleAdvancedToolbars"
OnClientPasteHtml="OnClientPasteHtml"
OnClientCommandExecuting="OnClientCommandExecuting">
<FlashManager ViewPaths="~/Files" UploadPaths="~/Files" DeletePaths="~/Files" MaxUploadFileSize="1208000" />
</telerik:RadEditor>
<sf:SitefinityLabel id="descriptionLabel" runat="server" WrapperTagName="div" HideIfNoText="true" CssClass="sfDescription" />
<sf:SitefinityLabel id="exampleLabel" runat="server" WrapperTagName="div" HideIfNoText="true" CssClass="sfExample" />
</asp:Panel>
<script type="text/javascript">
/* <![CDATA[ */
var className = null;
var toRemove = false;
var handlersAdded = false;
function OnClientPasteHtml(sender, args)
{
var newContent = args.get_value();
newContent = newContent.replace(new RegExp("<b(\\s([^>])*?)?>", "ig"), "<strong$1>");
newContent = newContent.replace(new RegExp("</b(\\s([^>])*?)?>", "ig"), "</strong$1>");
newContent = newContent.replace(new RegExp("<i(\\s([^>])*?)?>", "ig"), "<em$1>");
newContent = newContent.replace(new RegExp("</i(\\s([^>])*?)?>", "ig"), "</em$1>");
var regex = /<([a-zA-Z]+) ?[^>]*?>\s*<\/\1>/gi;
newContent = newContent.replace(regex, "");
args.set_value(newContent);
}
function OnClientCommandExecuting(editor, args) {
var name = args.get_name();
var val = args.get_value();
var commandName = args.get_commandName();
className = "re" + commandName;
if (editor.get_dialogOpener())
{
if (editor.get_dialogOpener()._container && !handlersAdded)
{
editor.get_dialogOpener()._container.add_show(AddRemoveCSSClass);
editor.get_dialogOpener()._container.add_close(AddRemoveCSSClass);
handlersAdded = true;
}
}
if (name == "MergeTags")
{
editor.pasteHtml(val);
//Cancel the further execution of the command as such a command does not exist in the editor command list
args.set_cancel(true);
}
if (commandName == "ToggleScreenMode") {
var containerWnd = GetRadWindow();
if (!editor.isFullScreen()) //if the editor is placed in fullscreen mode specify the needed content area width
{
$(editor.get_element()).addClass("sfFullScreenEditor");
if(containerWnd != null && !containerWnd.isMaximized())
{
containerWnd.maximize();
$(containerWnd.get_element()).addClass("sfWndToBeRestored");
}
editor.get_document().body.style.maxWidth = "640px";
}
else
{
$(editor.get_element()).removeClass("sfFullScreenEditor");
if(containerWnd != null && $(containerWnd.get_element()).hasClass("sfWndToBeRestored"))
{
$(containerWnd.get_element()).removeClass("sfWndToBeRestored");
containerWnd.restore();
}
editor.get_document().body.style.maxWidth = "100%";
}
}
}
function AddRemoveCSSClass(sender, args)
{
var popupElement = sender.get_popupElement();
if (!toRemove)
{
Sys.UI.DomElement.addCssClass(popupElement, className);
}
else
{
Sys.UI.DomElement.removeCssClass(popupElement, className);
}
}
function GetRadWindow()
{
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
/* ]]> */
</script>
</sf:ConditionalTemplate>
</Templates>
</sf:ConditionalTemplateContainer>
2. Next step is to create a codefile (in my case EditorTemplate.ascx.cs) where you point the Editor control to the location of your custom ToolsFile:
3. Please find the default ToolsFile we're using for the Editor, you can add your custom buttons to it according to
this article from our RadEditor documentation. In the same section you can find guidance on adding custom dialogs as well
<?xml version="1.0" encoding="utf-8" ?>
<root>
<modules>
<module name="RadEditorStatistics" dockingZone="Bottom" visible="false" />
<module name="RadEditorDomInspector" visible="false" />
<module name="RadEditorNodeInspector" visible="false" />
<module name="RadEditorHtmlInspector" visible="false" />
</modules>
<tools name="MainToolbar">
<tool name="ToggleAdvancedToolbars"/>
<tool name="Bold" shortcut="CTRL+B"/>
<tool name="Italic" shortcut="CTRL+I"/>
<tool name="ApplyClass" />
<tool separator="true"/>
<tool name="InsertOrderedList" />
<tool name="InsertUnorderedList" />
<tool separator="true"/>
<tool name="LinkManager" shortcut="CTRL+K"/>
<tool name="Unlink" shortcut="CTRL+SHIFT+K"/>
<tool name="ImageManager" shortcut="CTRL+G"/>
<tool separator="true"/>
<tool name="AjaxSpellCheck"/>
<tool separator="true"/>
<tool name="PasteFromWord" />
</tools>
<tools>
<tool separator="true"/>
<tool name="JustifyLeft" />
<tool name="JustifyRight" />
<tool name="JustifyCenter" />
<tool name="JustifyFull" />
<tool separator="true"/>
<tool name="Indent" />
<tool name="Outdent" />
</tools>
<tools>
<tool name="FontName" shortcut="CTRL+SHIFT+F"/>
<tool separator="true"/>
<tool name="RealFontSize"/>
<tool separator="true"/>
<tool name="FormatBlock"/>
<tool separator="true"/>
<tool name="ForeColor"/>
<tool name="BackColor"/>
<tool separator="true"/>
<tool name="MediaManager" />
<tool name="FlashManager" />
<tool name="DocumentManager" />
</tools>
<tools>
<tool name="InsertParagraph" />
<tool name="InsertTable" />
<tool name="InsertSymbol"/>
<tool name="InsertHorizontalRule" />
<tool separator="true"/>
<tool name="Superscript" />
<tool name="Subscript" />
<tool separator="true"/>
<tool name="FormatStripper"/>
<tool separator="true"/>
<tool name="FindAndReplace" shortcut="CTRL+F"/>
<tool name="Print" shortcut="CTRL+P"/>
<tool name="ToggleScreenMode" />
</tools>
</root>
4. Once you have built the project, go to Sitefinity Backend -> Administration->Settings->Advanced->Controls->ViewMap and create and click on the Creae new button.
Fill in the fields accordingly (all without the quotes):
HostType: "Telerik.Sitefinity.Web.UI.Fields.HtmlField"
LayoutTemplatePath:"relative path to the template where you have declared HtmlField control"
Build the project, and restart the application, and you should have your custom template loaded globally throughout your website in all instances of the Content editor.
All the best,
Victor Velev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the
Telerik Public Issue Tracking system and vote to affect the priority of the items