Back to all examples
PHP
<?php
require_once '../lib/Kendo/Autoload.php';
?>
<div class="configuration k-widget k-header" style="float:none;max-width:none;margin:0 0 2em;">
<span class="infoHead">Information</span>
<p>
The following demo shows how to customize some of the native Editor tools (font size, font name and block format) by modifying the tools' item
collections, as well as how to create completely custom tools.
</p>
</div>
<?php
$editor = new \Kendo\UI\Editor('editor');
// configure custom tools
// - font name
$fontGaramond = new \Kendo\UI\EditorToolItem();
$fontGaramond->text("Verdana")->value("Verdana, Geneva, sans-serif");
$fontVerdana = new \Kendo\UI\EditorToolItem();
$fontVerdana->text("Garamond")->value("Garamond, serif");
$fontName = new \Kendo\UI\EditorTool();
$fontName->name("fontName");
$fontName->addItem($fontGaramond, $fontVerdana);
// - font size
$xxsmall = new \Kendo\UI\EditorToolItem();
$xxsmall->text("1 (8pt)")->value("xx-small");
$medium = new \Kendo\UI\EditorToolItem();
$medium->text("16px")->value("16px");
$fontSize = new \Kendo\UI\EditorTool();
$fontSize->name("fontSize");
$fontSize->addItem($xxsmall, $medium);
// - format block
$paragraph = new \Kendo\UI\EditorToolItem();
$paragraph->text("Paragraph")->value("p");
$fieldset = new \Kendo\UI\EditorToolItem();
$fieldset->text("Fieldset")->value("fieldset");
$formatting = new \Kendo\UI\EditorTool();
$formatting->name("formatting");
$formatting->addItem($paragraph, $fieldset);
// - tool with custom template
$customTemplate = new \Kendo\UI\EditorTool();
$customTemplate
->name("customTemplate")
->template(
"<label for='templateTool' style='vertical-align:middle;'>Background:</label>"
. "<select id='templateTool' style='width:90px'><option value=''>none</option><option value='\#ff9'>yellow</option><option value='\#dfd'>green</option></select>"
);
// - tool with custom action
$hr = new \Kendo\UI\EditorTool();
$hr->name("custom")
->tooltip("Insert a horizontal rule")
->exec("insertHr");
// add all custom tools to the toolbar
$editor->addTool($fontName, $fontSize, $formatting, $customTemplate, $hr);
$editor
->attr('style', 'width:100%;height:400px')
->startContent();
?>
<p><img src="../content/web/editor/kendo-ui-web.png" alt="Editor for ASP.NET MVC logo" style="display:block;margin-left:auto;margin-right:auto;" /></p>
<p>
Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.<br />
In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists,
and image handling. The widget <strong>outputs identical HTML</strong> across all major browsers, follows
accessibility standards and provides API for content manipulation.
</p>
<p>Features include:</p>
<ul>
<li>Text formatting & alignment</li>
<li>Bulleted and numbered lists</li>
<li>Hyperlink and image dialogs</li>
<li>Cross-browser support</li>
<li>Identical HTML output across browsers</li>
<li>Gracefully degrades to a <code>textarea</code> when JavaScript is turned off</li>
</ul>
<p>
Read <a href="http://docs.telerik.com/kendo-ui">more details</a> or send us your
<a href="http://www.telerik.com/forums">feedback</a>!
</p>
<?php
$editor->endContent();
echo $editor->render();
?>
<script type="text/x-kendo-template" id="backgroundColor-template">
</script>
<script>
function insertHr(e) {
var editor = $(this).data("kendoEditor");
editor.exec("inserthtml", { value: "<hr />" });
}
$(document).ready(function() {
$("#templateTool").kendoDropDownList({
change: function(e) {
$("#editor").data("kendoEditor").body.style.backgroundColor = e.sender.value();
}
});
});
</script>