基于jquery的bootstrap在线文本编辑器插件Summernote (转)

Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器。Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox、Opera、Internet Explorer 9 +(IE8支持即将到来)。
特点:
世界上最好的WYSIWYG在线编辑器
极易安装
开源
自定义初化选项
支持快捷键
适用于各种后端程序言语
使用方法
使用HTML5文档
| 
 1 
2 
3 
4 
 | 
<!DOCTYPE html><html>...</html> | 
引入核心文件,Summernote需要几个JS库的支持,所以得先引入其它库
| 
 1 
2 
3 
4 
5 
6 
7 
8 
9 
 | 
<!-- include libries(jQuery, bootstrap, fontawesome) --><script src="//code.jquery.com/jquery-1.9.1.min.js"></script><link href="//netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap.min.css"><script src="//netdna.bootstrapcdn.com/bootstrap/3.0.1/js/bootstrap.min.js"></script><link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"><!-- include summernote css/js--><link href="summernote.css" /><script src="summernote.min.js"></script> | 
写入html,只需加入一个DIV元素,写上ID
| 
 1 
 | 
<div id="summernote">Hello Summernote</div> | 
写入JS初始化插件
| 
 1 
2 
3 
 | 
$(document).ready(function() {        $('#summernote').summernote();    }); | 
API
初始化Summernote
| 
 
1 
 | 
$('.summernote').summernote(); | 
使用参数初始化
设定高度与焦点
| 
 
1 
2 
3 
4 
5 
6 
7 
 | 
$('.summernote').summernote({  height: 300,                 // set editor height  minHeight: null,             // set minimum height of editor  maxHeight: null,             // set maximum height of editor  focus: true,                 // set focus to editable area after initializing summernote}); | 
设定高度后,如果内容高度超过设定高度将出现滚动条,如果没有设定高度则一直往下挣开。设定focus为true时,打开页面后焦点定位到编辑器中。
自定义工具栏
| 
 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
 | 
$('.summernote').summernote({  toolbar: [    //[groupname, [button list]]          ['style', ['bold', 'italic', 'underline', 'clear']],    ['font', ['strikethrough']],    ['fontsize', ['fontsize']],    ['color', ['color']],    ['para', ['ul', 'ol', 'paragraph']],    ['height', ['height']],  ]}); | 
预设参数
类型
| 方法 | |
|---|---|
| picture | Insert a picture | 
| link | Insert a hyperlink | 
| video | Insert a video | 
| table | Insert a table | 
| hr | Insert a horizontal rule | 
| style | Format selected block | 
| fontname | Set font family | 
| fontsize | Set font size | 
| color | Set foreground and background color | 
| bold | Toggle weight | 
| italic | Toggle italic | 
| underline | Toggle underline | 
| strikethrough | Toggle strikethrough | 
| clear | Clearing all styles | 
| ul | Make an un-ordered list | 
| ol | Make an ordered list | 
| paragraph | Set text alignment | 
| height | Set height of text | 
| fullscreen | Toggle fullscreen editing mode | 
| codeview | Toggle wysiwyg and html editing mode | 
| undo | Undo | 
| redo | Redo | 
| help | Show help dialog | 
极简模式Air-mode
| 
 
1 
2 
3 
4 
5 
6 
7 
8 
9 
 | 
$('.summernote').summernote({  airPopover: [    ['color', ['color']],    ['font', ['bold', 'underline', 'clear']],    ['para', ['ul', 'paragraph']],    ['table', ['table']],    ['insert', ['link', 'picture']]  ]}); | 
释放Summernote
| 
 
1 
 | 
$('.summernote').destroy(); | 
取值与赋值
| 
 
1 
2 
3 
4 
5 
6 
 | 
//取值var sHTML = $('.summernote').code();//同一页面多个summernote时,取第二个的值var sHTML = $('.summernote').eq(1).code();//赋值$('.summernote').code(sHTML); | 
事件
oninit
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  oninit: function() {    console.log('Summernote is launched');  }}); | 
onenter
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onenter: function(e) {    console.log('Enter/Return key pressed');  }}); | 
onfocus
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onfocus: function(e) {    console.log('Editable area is focused');  }}); | 
onblur
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onblur: function(e) {    console.log('Editable area loses focus');  }}); | 
onkeyup
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onkeyup: function(e) {    console.log('Key is released:', e.keyCode);  }}); | 
onkeydown
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onkeydown: function(e) {    console.log('Key is pressed:', e.keyCode);  }}); | 
onpaste
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onpaste: function(e) {    console.log('Called event paste');  }}); | 
onImageUpload
可以重写图片上传句柄
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onImageUpload: function(files, editor, $editable) {    console.log('image upload:', files, editor, $editable);  }}); | 
onChange
IE9-10: DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted
Chrome, FF: input
| 
 
1 
2 
3 
4 
5 
 | 
$('#summernote').summernote({  onChange: function(contents, $editable) {    console.log('onChange:', contents, $editable);  }}); | 
支持18国语言,使用时引入你需要的语言文件,lang值设为你需要的语言
| 
 
1 
2 
3 
4 
5 
6 
7 
8 
 | 
<!-- include summernote-ko-KR --><script src="lang/summernote-ko-KR.js"></script>$(document).ready(function() {  $('#summernote').summernote({    lang: 'ko-KR' // default: 'en-US'  });}); | 
基于jquery的bootstrap在线文本编辑器插件Summernote (转)的更多相关文章
- 基于jquery的bootstrap在线文本编辑器插件Summernote
		
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
 - 基于jquery的bootstrap在线文本编辑器插件Summernote 简单强大
		
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
 - Jquery的bootstrap在线文本编辑器插件Summernote
		
http://www.jqcool.net/demo/201407/bootstrap-summernote/ Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线 ...
 - Bootstrap-基于jquery的bootstrap在线文本编辑器插件Summernote
		
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
 - 基于JQuery的简单富文本编辑器
		
利用jQuery实现最简单的编辑器 我试了很多种方法,目前最快捷能够实现及其简单的编辑可以使用 document.execCommand("ForeColor", "fa ...
 - 基于jquery、bootstrap的数据验证插件bootstrapValidator使用
		
实时验证用户名是否存在,密码不能和用户名相同,两次密码需要相同,提交之后需要验证返回值: <form id="defaultForm" role="form&quo ...
 - Summernote – 基于 Bootstrap 的文本编辑器
		
Summernote 是一个简单,灵活,所见即所得(WYSIWYG)的编辑器,基于 jQuery 和 Bootstrap 构建.Summernote 所有主要的操作都支持快捷键,有一个功能强大的 AP ...
 - 百度umeditor富文本编辑器插件扩展
		
富文本编辑器在WEB开发中经常用到,个人比较喜欢用百度出的ueditor这款,ueditor这款本身支持插件扩展的,但是ueditor的mini版本 umeditor 就没有那么方便了,不过找了很多资 ...
 - 基于jQuery点击图像居中放大插件Zoom
		
分享一款基于jQuery点击图像居中放大插件Zoom是一款放大的时候会从原图像的位置以动画方式放大到画面中间,支持点击图像或者按ESC键来关闭效果.效果图如下: 在线预览 源码下载 实现的代码. ...
 
随机推荐
- appium Parameters were incorrect
			
raise exception_class(value) selenium.common.exceptions.WebDriverException: Message: Parameters were ...
 - BAT文件使程序具有以系统权限运行的效果
			
@echo off if "%1" == "h" goto begin mshta vbscript:createobject("wscript.sh ...
 - kibana显示elasticsearch集群中flume到入的日志
			
日志通过flume导入elasticsearch集群见这里:flume 日志导入elasticsearch kibana介绍 kibana主页 kibana是一个功能强大的elasticsearch数 ...
 - Json,String,Map之间的转换
			
前提是String的格式是map或json类型的 String 转Json JSONObject jasonObject = JSONObject.fromObject(str); String 转 ...
 - Sublime Text 3 文档
			
中文版:http://feliving.github.io/Sublime-Text-3-Documentation/ 英文版:http://www.sublimetext.com/docs/3/
 - 倍福TwinCAT(贝福Beckhoff)基础教程6.1 TwinCAT如何与高级语言通讯
			
因为使用TwinCAT的人用途不同,重视点就不同.如果用来代替传统PLC+HMI做项目的,很少会需要用到跟高级语言通讯,但是如果是用来做运动控制平台如做机器人运动控制器的,就肯定会用到.不管是否用得上 ...
 - Visual Prolog 的 Web 专家系统 (10)
			
GENI的核心 -- 推理机(4)求证过程分析 1.GENI知识库结构 专家系统推理机的设计执行,与其知识库结构紧密相关. GENI知识库结构是一棵逻辑推理树. 根节点是animal,即求证的目标. ...
 - Python类定义和类继承详解
			
类实例化后,可以使用其属性,实际上,创建一个实例之后,可以通过类名访问其属性,如果直接使用类名修改其属性,那么直接影响已经实例化的对象. 类的私有属性: __private_attrs 两个下划线开头 ...
 - SQL语句练习手册--第三篇
			
一.CASE的两种用法 1.1 等值判断->相当于switch case (1)具体用法模板: CASE expression WHEN value1 THEN returnvalue1 WHE ...
 - CSS——如何清除浮动
			
众所周知,平时在写HTML代码时,难免少不了使用Float样式,这样一来,假使您没有清除浮动,那么有浮动元素的父元素容器将元素将无法自动撑开.换句简单好理解的话来说,假如你在写CODE时,其中div. ...