Implement Custom InsertSymbol Tool for Editor
Environment
Product | Progress® Kendo UI® Editor for jQuery |
Operating System | All |
Browser | All |
Preferred Language | JavaScript |
Description
How can I add a custom InsertSymbol
tool to the Editor?
Solution
- Set a template to the custom tool and initialize a DropDownList in it.
- In the
change
event handler of the DropDownList, call theexec
API method of the Editor and execute theinsertHtml
command. - Pass the selected symbol to the method in the DropDownList.
<textarea id="editor" rows="10" cols="30" style="width:100%;height:400px">
</textarea>
<script type="text/x-kendo-template" id="insertSymbol-template">
<label for='templateTool' style='vertical-align:middle;'>Insert Symbol:</label>
<select id='templateTool' style='width:90px'>
<option value='1'>©</option>
<option value='2'>∑</option>
<option value='3'>€</option>
<option value='4'>™</option>
<option value='5'>←</option>
<option value='6'>↑</option>
<option value='7'>→</option>
<option value='8'>↓</option>
</select>
</script>
<script>
$("#editor").kendoEditor({
encoded: false,
tools: [
{
name: "customTemplate",
template: $("#insertSymbol-template").html()
}
]
});
$("#templateTool").kendoDropDownList({
change: function(e) {
var inputValue = e.sender._inputValue();
$('#editor').data('kendoEditor').exec("insertHtml", { html: inputValue });
}
});
</script>