Jquery的bootstrap在线文本编辑器插件Summernote

http://www.jqcool.net/demo/201407/bootstrap-summernote/
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器。Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox、Opera、Internet Explorer 9 +(IE8支持即将到来)。
特点:
世界上最好的WYSIWYG在线编辑器
极易安装
开源
自定义初化选项
支持快捷键
适用于各种后端程序言语
使用方法
使用html5文档
<!DOCTYPE html><html>...</html> |
引入核心文件,Summernote需要几个JS库的支持,所以得先引入其它库
<!-- 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
<div id="summernote">Hello Summernote</div> |
写入JS初始化插件
$(document).ready(function() { $('#summernote').summernote(); }); |
API
初始化Summernote
$('.summernote').summernote(); |
使用参数初始化
设定高度与焦点
$('.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时,打开页面后焦点定位到编辑器中。
自定义工具栏
$('.summernote').summernote({ toolbar: [ //[groupname, [button list]] ['style', ['bold', 'italic', 'underline', 'clear']], ['font', ['strikethrough']], ['fontsize', ['fontsize']], ['color', ['color']], ['para', ['ul', 'ol', 'paragraph']], ['height', ['height']], ]}); |
预设参数
| 类型 | 按钮id | 方法 |
|---|---|---|
| Insert | picture | Insert a picture |
| link | Insert a hyperlink | |
| video | Insert a video | |
| table | Insert a table | |
| hr | Insert a horizontal rule | |
| Style | 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 | |
| Layout | ul | Make an un-ordered list |
| ol | Make an ordered list | |
| paragraph | Set text alignment | |
| height | Set height of text | |
| Misc | fullscreen | Toggle fullscreen editing mode |
| codeview | Toggle wysiwyg and html editing mode | |
| undo | Undo | |
| redo | Redo | |
| help | Show help dialog |
极简模式Air-mode
$('.summernote').summernote({ airPopover: [ ['color', ['color']], ['font', ['bold', 'underline', 'clear']], ['para', ['ul', 'paragraph']], ['table', ['table']], ['insert', ['link', 'picture']] ]}); |
释放Summernote
$('.summernote').destroy(); |
取值与赋值
//取值var sHTML = $('.summernote').code();//同一页面多个summernote时,取第二个的值var sHTML = $('.summernote').eq(1).code();//赋值$('.summernote').code(sHTML); |
事件
oninit
$('#summernote').summernote({ oninit: function() { console.log('Summernote is launched'); }}); |
onenter
$('#summernote').summernote({ onenter: function(e) { console.log('Enter/Return key pressed'); }}); |
onfocus
$('#summernote').summernote({ onfocus: function(e) { console.log('Editable area is focused'); }}); |
onblur
$('#summernote').summernote({ onblur: function(e) { console.log('Editable area loses focus'); }}); |
onkeyup
$('#summernote').summernote({ onkeyup: function(e) { console.log('Key is released:', e.keyCode); }}); |
onkeydown
$('#summernote').summernote({ onkeydown: function(e) { console.log('Key is pressed:', e.keyCode); }}); |
onpaste
$('#summernote').summernote({ onpaste: function(e) { console.log('Called event paste'); }}); |
onImageUpload
可以重写图片上传句柄
$('#summernote').summernote({ onImageUpload: function(files, editor, $editable) { console.log('image upload:', files, editor, $editable); }}); |
onChange
IE9-10: DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted
Chrome, FF: input
$('#summernote').summernote({ onChange: function(contents, $editable) { console.log('onChange:', contents, $editable); }}); |
支持18国语言,使用时引入你需要的语言文件,lang值设为你需要的语言
<!-- include summernote-ko-KR --><script src="lang/summernote-ko-KR.js"></script>$(document).ready(function() { $('#summernote').summernote({ lang: 'ko-KR' // default: 'en-US' });}); |
更多参数请查看实例与官方文档
转载请注明:jQ酷 » 基于jquery的bootstrap在线文本编辑器插件Summernote
Jquery的bootstrap在线文本编辑器插件Summernote的更多相关文章
- 基于jquery的bootstrap在线文本编辑器插件Summernote
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
- Bootstrap-基于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 简单强大
Summernote是一个基于jquery的bootstrap超级简单WYSIWYG在线编辑器.Summernote非常的轻量级,大小只有30KB,支持Safari,Chrome,Firefox.Op ...
- Bootstrap 可视化HTML编辑器,summernote
Bootstrap 可视化HTML编辑器之summernote,用其官网上的介绍就是"Super Simple WYSIWYG editor",不过在我看来,与bootstrap中 ...
- 百度umeditor富文本编辑器插件扩展
富文本编辑器在WEB开发中经常用到,个人比较喜欢用百度出的ueditor这款,ueditor这款本身支持插件扩展的,但是ueditor的mini版本 umeditor 就没有那么方便了,不过找了很多资 ...
- javascript 在线文本编辑器
javascript 在线文本编辑器实现代码. 效果例如以下: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcGhwZmVuZ2h1bw==/font/5 ...
- Summernote – 基于 Bootstrap 的文本编辑器
Summernote 是一个简单,灵活,所见即所得(WYSIWYG)的编辑器,基于 jQuery 和 Bootstrap 构建.Summernote 所有主要的操作都支持快捷键,有一个功能强大的 AP ...
- Textarea - 百度富文本编辑器插件UEditor
UEditor各种实例演示 Ueditor 是百度推出的一款开源在线 HTML 编辑器. 主要特点: 轻量级:代码精简,加载迅速. 定制化:全新的分层理念,满足多元化的需求.采用三层架构:1. 核心层 ...
随机推荐
- Java集合的实现细节—Set集合和Map集合
Set:代表无序.不可重复的集合 Map:代表key-value对集合,也称为关联数组 从表面上看,Set和Map相似性很少,但实际上可以说Map集合时Set集合的扩展. 1.Set集合和Map集合的 ...
- HBase二级索引的设计(案例讲解)
摘要 最近做的一个项目涉及到了多条件的组合查询,数据存储用的是HBase,恰恰HBase对于这种场景的查询特别不给力,一般HBase的查询都是通过RowKey(要把多条件组合查询的字段都拼接在RowK ...
- python (3):wxPython打包app,报错
1,打包app报错 如图: 使用py2app,mac下打包成app.异常.程序直接退出. 没有详细的错误信息,client程序直接崩溃了. 2.原因 代码没有几行: #!/usr/bin/python ...
- js中indexof()简单使用
indexOf()方法返回某个指定的字符串值在字符串中首次出现的位置. stringObject.indexOf(searchvalue,fromindex):indexOf()方法对大小写敏感如果要 ...
- Android 自定义UI--指南针
有了之前的基础,下面开始实现一个简单的指南针.首先来看一下效果图, 我们可以粗略将这个指南针分为三个部分,一是圆形背景,二是刻度,三是文本.那么在写代码的时候,就可以声明三个Paint画笔来画以上三个 ...
- ASE中的主要数据库
Adaptive Server包括多种类型数据库: 必需数据库. “附加功能”数据库 .例子数据库 .应用数据库 1.必需数据库 master 数据库包含系统表,这些系统表中存储的数据被用来管理,有 ...
- .NET基础拾遗(3)字符串、集合和流3
三.流和序列化 3.1 流概念及.NET中常见流 无论什么信息,文字,声音,图像,只要进入了计算机就都被转化为数字,以数字方式运算.存储.由于计算机中使用二进制运算,因此数字只有两个:0 与 1,就是 ...
- 如何让网页打开就运行JS代码,不用onclick
打开网页直接运行是要调用window.onload( )函数: <html> <head> </head> <body> < ...
- 在mac平台运行debug.exe
最近准备学习操作系统,想先复习一下汇编语言.因为用的是mac,而看的汇编教材(<汇编语言>王爽)使用到DOS下的debug,在网上搜了一圈发现,mac 也可以模拟运行debug. 先到网上 ...
- CSSOM视图模式
相关技术文章: CSSOM视图模式(CSSOM View Module)相关整理 W3C CSSOM View Module