Introduction
Kendo Editor is a widget which allows the users to create a rich text content in a user-friendly way. In my last
article, I explained how to work with Kendo Editor. In this blog, I’m going to discuss how to implement custom styles in the Kendo Editor.
Kendo Editor
Create an HTML page and name it. I have named it KendoEditor.html.
Write the following code in KendoEditor.html.
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Untitled</title>
-
- <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.common.min.css">
- <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.rtl.min.css">
- <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.default.min.css">
- <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.3.1017/styles/kendo.mobile.all.min.css">
-
- <script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
- <script src="https://kendo.cdn.telerik.com/2018.3.1017/js/angular.min.js"></script>
- <script src="https://kendo.cdn.telerik.com/2018.3.1017/js/jszip.min.js"></script>
- <script src="https://kendo.cdn.telerik.com/2018.3.1017/js/kendo.all.min.js"></script></head>
- </head>
- <body>
- <div id="example">
- <textarea id="editor" rows="10" cols="30" style="height:440px">
- </textarea>
- </div>
- </body>
- <script>
- $(document).ready(function() {
- $("#editor").kendoEditor({
-
- tools: [
- { name: "formatting", width: 150, items: [
- { text: "Custom Title", value: ".title" },
-
- ] }
- ],
- stylesheets: [
- "style.css"
- ]
- });
- });
- </script>
- </html>
style.css
- .title
- {
- font-size: large;
- font-weight: 400;
- font-style: italic;
-
- }
In the above code, the tools object is used to initialize our custom formation option. The item is used to contain the list of formatting options in the key-value pair.
In the value of the items object, we need to provide the style which should be applied to the selected text in our Kendo Editor. The stylesheets object is used to load our custom style sheet while .title is our CSS class which is going to be applied on the selected text when the user uses the custom style option.
Select the content and choose the custom formatting option.
That's it. We have successfully implemented the custom style. I hope you have enjoyed this blog.
Thank you! Happy Coding!