How to add Summernote Editor in webpage ?

In this article, we will know about the Summernote Editor & its usage along with will understand its implementation through the example. The Summernote Editor is a free & open-source super simple WYSIWYG editor based on Bootstrap & jQuery. It is a JavaScript library that can be useful to build the WYSIWYG editors online. It is maintained under MIT license by a large community. It is easy to use & contains many customizable options. It can easily be implemented in any framework like React, Django, Angular, etc.
Features:
- Lightweight Rich Text Editor
 - Easy installation
 - Easy integration with any framework
 - Simple UI
 - Lots of customization available.
 - Free & Open-source
 - Interactive WYSIWYG editing
 
There are 2 ways to use the Summernote Editor on our web page:
- Using the downloaded precompiled and minified versions of CSS and JavaScript files from their official site.
 - Using the available CDN links for summernote CSS & js, jQuery, and Bootstrap.
 
We can use either of the methods to build the static site with the text editor and the content.
Approach:
- First, download the minified precompiled version of Summernote from the official website.
 - Extract it & place it in the current working folder.
 - Create an index.html file & declare the Bootstrap & jQuery links inside the <head> tag.
 - After completing these steps, the project structure will look like the following image.
 
Import the Summernote:
- First, let us import the Bootstrap from CDNs in the index.html file. All the following codes should be placed inside the Head Tags.
 
<!– Include libraries(jQuery, bootstrap) –>
<link href=”https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css” rel=”stylesheet”/>
<script src=”https://code.jquery.com/jquery-3.5.1.min.js”></script>
<script src=”https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script>
- Next import the summernote CSS and JS files.
 
<link href=”/src/summernote-0.8.18-dist/summernote-bs4.min.css” rel=”stylesheet”/>
<script src=”/src/summernote-0.8.18-dist/summernote-bs4.min.js”></script>
- Now in the <body> tag, initialize the summernote editor.
 
<div id=”myeditor”></div>
<script>
$(document).ready(function() {
    $("#myeditor").summernote({
        placeholder: "Write your content here",
        height: 200,
    });
});
</script>
Now, our Text Editor has been initialized.
Example: This example illustrates the use of the Summernote Editor to build & facilitate the editor in the web pages.
HTML
<!DOCTYPE html> <html lang="en">   <head>     <meta charset="UTF-8" />     <meta http-equiv="X-UA-Compatible" content="IE=edge" />     <meta name="viewport"           content="width=device-width, initial-scale=1.0" />     <title>zambiatek Editor</title>     <link href=           rel="stylesheet" />     <script src=     </script>     <script src=     </script>     <link rel="stylesheet"           href="/src/summernote-0.8.18-dist/summernote-bs4.min.css" />     <script src="/src/summernote-0.8.18-dist/summernote-bs4.min.js"></script>     <link rel="stylesheet"           href="/src/summernote-0.8.18-dist/summernote.css" />     <script src="/src/summernote-0.8.18-dist/summernote.js"></script> </head>   <body>     <h1>zambiatek Editor</h1>     <div id="myeditor"></div>     <button type="button"             class="btn btn-success"             onclick="showContent()"> Show      </button>       <div id="myContent" class="container"></div>       <script>     $(document).ready(function() {         $("#myeditor").summernote({             placeholder: "Write your content here",             height: 200,         });     });       function showContent() {         document.getElementById("myContent").innerHTML =          $("#myeditor").summernote("code");     }     </script> </body>   </html> | 
Output:
Supported Browsers:
- Google Chrome
 - Firefox
 - Microsoft Edge
 - Internet Explorer
 - Opera
 - Safari
 
Reference: https://summernote.org/
				
					



