### Initialize Summernote with jQuery
Source: https://github.com/summernote/summernote/blob/main/README.md
Initialize the Summernote editor on the #summernote element after the document is ready.
```javascript
$(document).ready(function() {
$('#summernote').summernote();
});
```
--------------------------------
### Place a div tag for Summernote editor
Source: https://github.com/summernote/summernote/blob/main/README.md
Place this div in the body tag; it will be replaced with the Summernote editor.
```html
Hello Summernote
```
--------------------------------
### Get HTML source code from Summernote editor
Source: https://github.com/summernote/summernote/blob/main/README.md
Use the 'code' API to retrieve the HTML source code underlying the text in the editor.
```javascript
var html = $('#summernote').summernote('code');
```
--------------------------------
### Initialize Summernote with word hinting
Source: https://github.com/summernote/summernote/blob/main/examples/hint-words.html
Sets up Summernote with a hint mode for words, triggered by '@'. Includes a list of mentions, a regex match, search, template, and content functions. The hintSelect option is set to 'next'.
```javascript
$(document).ready(function () {
$('.summernote').summernote({
height: 300,
placeholder: 'type starting with @',
hintMode: 'words',
hintSelect: 'next',
hint: {
mentions: [
{ name: 'Jayden Smith', url: 'http://example.org/person/jayden-smith' },
{ name: 'Peter Pan', url: 'http://example.org/person/peter-pan' },
{ name: 'Lorca', url: 'http://example.org/person/lorca' },
{ name: 'David Summer', url: 'http://example.org/person/david-summer' }
],
match: /\B@([a-z ]*)/i,
search: function (keyword, callback) {
callback($.grep(this.mentions, function (item) {
return item.name.toLowerCase().indexOf(keyword.toLowerCase()) == 0;
}));
},
template: function(item) {
return item.name;
},
content: function (item) {
return $('')
.attr('href', item.url)
.text('@' + item.name)
.get(0);
}
}
});
});
```
--------------------------------
### Include Summernote JS/CSS in HTML head
Source: https://github.com/summernote/summernote/blob/main/README.md
Add jQuery, Bootstrap 5, and Summernote CSS/JS files to the tag. Required before placing the editor div and initializing Summernote.
```html
```
--------------------------------
### Initialize Summernote with CodeMirror as CodeView
Source: https://github.com/summernote/summernote/blob/main/examples/external-codemirror.html
Configures Summernote to use CodeMirror for the code view. Requires the CodeMirror library to be loaded globally (window.CodeMirror). Sets editor height to 200, tab size to 2, and CodeMirror options for HTML mode, line numbers, and the monokai theme.
```javascript
$(document).ready(function() {
$('.summernote').summernote({
height: 200,
tabsize: 2,
codemirror: {
CodeMirrorConstructor: window.CodeMirror,
mode: 'text/html',
htmlMode: true,
lineNumbers: true,
theme: 'monokai'
}
});
});
```
--------------------------------
### Configure Summernote with historyLimit: 5
Source: https://github.com/summernote/summernote/blob/main/examples/history-limit.html
Initializes Summernote on elements with class 'summernote', setting height to 300, tabsize to 2, enabling the following toolbar, and limiting the history stack size to 5 entries via the historyLimit option. This example uses jQuery and is intended for a page with Bootstrap v4.1.3 and jQuery v3.3.1.
```javascript
$(document).ready(function() {
$('.summernote').summernote({
height: 300,
tabsize: 2,
followingToolbar: true,
historyLimit: 5
});
});
```
--------------------------------
### Initialize Summernote with airMode and tabsize
Source: https://github.com/summernote/summernote/blob/main/examples/airmode.html
Enables Summernote's air-mode editing on elements with the 'summernote' class. Sets tabsize to 2 and turns on airMode so the toolbar appears only when text is selected. Place this script after the DOM is ready.
```JavaScript
$(document).ready(function() {
$('.summernote').summernote({
tabsize: 2,
airMode: true
});
});
```
--------------------------------
### Initialize Summernote on textarea and get code on form submit
Source: https://github.com/summernote/summernote/blob/main/examples/textarea.html
Initializes Summernote on elements with class 'summernote' at 200px height. On form submit, prevents default submission and alerts the editor's HTML content via the 'code' API.
```javascript
$(function() {
$('.summernote').summernote({
height: 200,
});
$('form').on('submit', function (e) {
e.preventDefault();
alert($('.summernote').summernote('code'));
});
});
```
--------------------------------
### Initialize Summernote with linkTargetBlank option
Source: https://github.com/summernote/summernote/blob/main/examples/link-blank.html
Configure Summernote to set the default link target as blank by setting the linkTargetBlank option to false. This example initializes the editor on elements with class 'summernote', with a height of 200 and tabsize of 2.
```javascript
$(document).ready(function() {
$('.summernote').summernote({
height: 200,
tabsize: 2,
linkTargetBlank: false
});
});
```
--------------------------------
### Event List: oninit
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.init' event, which fires when the editor is initialized.
```javascript
$(".summernote").on("summernote.init", ...);
```
--------------------------------
### Initialize Summernote with recordEveryKeystroke
Source: https://github.com/summernote/summernote/blob/main/examples/recordEveryKeyStroke.html
Use this snippet to enable recording of every keystroke in Summernote. It sets the editor height to 200, tab size to 2, and enables the recordEveryKeystroke option.
```javascript
$(document).ready(function() {
$('.summernote').summernote({
height: 200,
tabsize: 2,
recordEveryKeystroke: true
});
});
```
--------------------------------
### Initialize Summernote with custom event handlers
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Sets up a Summernote editor with event listeners for init, change, keyup, and enter events, logging messages to the console. The editor is initialized with a height of 500.
```javascript
$(function() {
$('.summernote').on('summernote.init', function() {
console.log('summernote initialize!')
}).on('summernote.change', function() {
console.log(' changed content ')
}).on('summernote.keyup', function(event) {
console.log('you can use keyboard event', event);
}).on('summernote.enter', function(event) {
console.log('check enter key ');
}).summernote({
height : 500
});
});
```
--------------------------------
### Event List: onkeyup
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.keyup' event, which fires when a key is released.
```javascript
$(".summernote").on("summernote.keyup", ...);
```
--------------------------------
### Set custom event using jQuery style (summernote.focus)
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Shows the jQuery style of attaching a focus event handler using the .on() method with the 'summernote.focus' event.
```javascript
$(".summernote").on("summernote.focus", function(e) {
// to do something
});
```
--------------------------------
### Event List: onenter
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.enter' event, which fires when the Enter key is pressed.
```javascript
$(".summernote").on("summernote.enter", ...);
```
--------------------------------
### Event List: onChange
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.change' event, which fires when the content changes.
```javascript
$(".summernote").on("summernote.change", ...);
```
--------------------------------
### Set custom event using current style (onfocus option)
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Shows the older 'current style' of attaching a focus event handler via the onfocus option in the summernote initialization object.
```javascript
$(".summernote").summernote({
onfocus : function(e) {
// to do something
}
});
```
--------------------------------
### Event List: onfocus
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.focus' event, which fires when the editor gains focus.
```javascript
$(".summernote").on("summernote.focus", ...);
```
--------------------------------
### Event List: onkeydown
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.keydown' event, which fires when a key is pressed down.
```javascript
$(".summernote").on("summernote.keydown", ...);
```
--------------------------------
### Event List: onblur
Source: https://github.com/summernote/summernote/blob/main/examples/jquery-custom-event.html
Attaches a handler to the 'summernote.blur' event, which fires when the editor loses focus.
```javascript
$(".summernote").on("summernote.blur", ...);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.