问题
My client desires to have a dropdown similar to Symbols Dropdown in the RTE (sitecore version 7.0). The client wants different dropdowns for different symbol types, for example, a dropdown having Greek Symbols Upper case, a dropdown having Greek Symbols Lower case, a dropdown having Mathematical Symbols and a dropdown having Other/Misc types of symbols.
I have tried to understand how RadControls work and how to add this on Telerik RadControl but I am unable to map the concept to sitecore's rich text editor. Additionally, I have tried to understand how existent Symbols Dropdown in RTE works but since its code is embedded in Sitecore.Client dll I cant understand much from it.
Can some one please detail the steps to achieve this?
Thanks, Vaibhav.
回答1:
You can add your own custom drop list or drop button to the RTE.
Switch to the core
database and add a new button in the toolbar of the RTE profile you are using (e.g. /sitecore/system/Settings/Html Editor Profiles/Rich Text Full/Toolbar 1
)
Make sure the template of the button is of type Html Editor Custom Drop Down
or Html Editor Custom Drop Down Button
, these can be found in /sitecore/templates/System/Html Editor Profiles
. Give a name in the 'Click' field, e.g. InsertCustomSymbols
Add child items to your button to create the "symbols" or text you need using Html Editor List Item
template. The 'Header' value is what will be displayed in the dropdown list and 'Value' is what will get inserted (e.g. your greek symbols).
You now need to handle the click event of the button, create a file with the following JS:
RadEditorCommandList["InsertCustomSymbols"] = function(commandName, editor, args) {
var val = args.get_value();
editor.pasteHtml(val);
args.set_cancel(true);
}
Create a patch config to add the JS file:
<clientscripts>
<htmleditor>
<script src="/location/to/custom.js" language="javascript" key="customJs" />
</htmleditor>
</clientscripts>
If you used the Drop Down Button then also add a css style to set the icon, it should also be the same name as the 'Click' field.
<style type="text/css">
span.InsertCustomSymbols
{
background-image:url('/path/to/icon.gif');
}
</style>
I didn't style it but you get the idea. Add as many as you need, make sure you set the correct RTE profile.
You can find a bit more info in this Telerik Custom Dropdown demo
来源:https://stackoverflow.com/questions/24246306/custom-rte-dropdown-in-sitecore-7-0