图片插入:

insertImage

Insert an image.

// @param {String} url
// @param {String|Function} filename - optional
$('#summernote').summernote('insertImage', url, filename);

You can modify image with passing callback as second argument.

$('#summernote').summernote('insertImage', url, function ($image) {$image.css('width', $image.width() / 3);$image.attr('data-filename', 'retriever');
});

insertNode

Insert an element or textnode.

var node = document.createElement('div');
// @param {Node} node
$('#summernote').summernote('insertNode', node);

insertText

Insert text.

// @param {String} text
$('#summernote').summernote('insertText', 'Hello, world');

pasteHTML

Paste HTML string.

// @param {String} HTML string
var HTMLstring = '<div><p>Hello, world</p><p>Summernote can insert HTML string</p></div>';
$('#summernote').summernote('pasteHTML', HTMLstring);

Callbacks

Summernote support initialize callbacks and jquery’s custom event style callbacks.

Position of callbacks in options is changed after v0.7.0

After v0.7.0, every callbacks should be wrapped by callbacks object.

Callback only works with camel case string after v0.6.5

Lowercase string has been used for basic event name(ex: oninitonenteronfocusonbluronkeyuponkeydownonpaste). In contrast, callbacks name for advanced feature has been used with camel case string. This is inconsistent and confusing to use. So we rename all lowercase callback to camel case string.

onBeforeCommand

WIP: Need to work on an explanation

onChange

  • IE9-10: DOMCharacterDataModified, DOMSubtreeModified, DOMNodeInserted
  • Chrome, FF: input
// onChange callback
$('#summernote').summernote({callbacks: {onChange: function(contents, $editable) {console.log('onChange:', contents, $editable);}}
});// summernote.change
$('#summernote').on('summernote.change', function(we, contents, $editable) {console.log('summernote\'s content is changed.');
});

onChangeCodeview

WIP: Need to work on an explanation

onDialogShown

WIP: Need to work on an explanation

onEnter

// onEnter callback
$('#summernote').summernote({callbacks: {onEnter: function() {console.log('Enter/Return key pressed');}}
});// summernote.enter
$('#summernote').on('summernote.enter', function() {console.log('Enter/Return key pressed');
});

onFocus, onBlur, onBlurCodeview

// onFocus callback
$('#summernote').summernote({callbacks: {onFocus: function() {console.log('Editable area is focused');}}
});// summernote.focus
$('#summernote').on('summernote.focus', function() {console.log('Editable area is focused');
});
// onBlur callback
$('#summernote').summernote({callbacks: {onBlur: function() {console.log('Editable area loses focus');}}
});// summernote.blur
$('#summernote').on('summernote.blur', function() {console.log('Editable area loses focus');
});
// onBlurCodeview callback
$('#summernote').summernote({callbacks: {onBlurCodeview: function() {console.log('Codeview area loses focus');}}
});// summernote.blur.codeview
$('#summernote').on('summernote.blur.codeview', function() {console.log('Codeview area loses focus');
});

onImageLinkInsert

WIP: Need to work on an explanation

onImageUpload

Override image upload handler(default: base64 dataURL on IMG tag). You can upload image to server or AWS S3: more…

// onImageUpload callback
$('#summernote').summernote({callbacks: {onImageUpload: function(files) {// upload image to server and create imgNode...$summernote.summernote('insertNode', imgNode);}}
});// summernote.image.upload
$('#summernote').on('summernote.image.upload', function(we, files) {// upload image to server and create imgNode...$summernote.summernote('insertNode', imgNode);
});

onImageUploadError

WIP: Need to work on an explanation

onInit

// onInit callback
$('#summernote').summernote({callbacks: {onInit: function() {console.log('Summernote is launched');}}
});// summernote.init
$('#summernote').on('summernote.init', function() {console.log('Summernote is launched');
});

onKeyup, onKeydown

// onKeyup callback
$('#summernote').summernote({callbacks: {onKeyup: function(e) {console.log('Key is released:', e.keyCode);}}
});// summernote.keyup
$('#summernote').on('summernote.keyup', function(we, e) {console.log('Key is released:', e.keyCode);
});
// onKeydown callback
$('#summernote').summernote({callbacks: {onKeydown: function(e) {console.log('Key is downed:', e.keyCode);}}
});// summernote.keydown
$('#summernote').on('summernote.keydown', function(we, e) {console.log('Key is downed:', e.keyCode);
});

onMouseDown,onMouseUp

onPaste

// onPaste callback
$('#summernote').summernote({callbacks: {onPaste: function(e) {console.log('Called event paste');}}
});// summernote.paste
$('#summernote').on('summernote.paste', function(e) {console.log('Called event paste');
});

onScroll

WIP: Need to work on an explanation

Custom button

Summernote also supports custom buttons. If you want to create your own button, you can simply define and use with options.

Define button

You can create a button object with $.summernote.ui. This buttons objects have the below properties.

  • contents: contents to be displayed on the button
  • tooltip: tooltip text when mouse over
  • click: callback function to be called when mouse is clicked

Below codes is about simple button for inserting text ‘hello’.

var HelloButton = function (context) {var ui = $.summernote.ui;// create buttonvar button = ui.button({contents: '<i class="fa fa-child"/> Hello',tooltip: 'hello',click: function () {// invoke insertText method with 'hello' on editor module.context.invoke('editor.insertText', 'hello');}});return button.render();   // return button as jquery object
}

You can see render() which returns jquery object as button.

Using button with options

Let’s learn how to use the button on toolbar.

First, you can define buttons with option named buttons which is a set of key-value. You can define custom button on toolbar options.

$('.summernote').summernote({toolbar: [['mybutton', ['hello']]],buttons: {hello: HelloButton}
});

You can also use custom button on popover in the same way.

Summernote个性化定制使用帮助(二)相关推荐

  1. editor修改样式 vue_vue-quill-editor的使用及个性化定制操作

    最近在用vue + element ui写一个小应用要用到富文本编辑器,以前做项目都一直都用ueditor,但是看了一下它与vue的兼容性并不好,又对比了几个后,选择了vue-quill-editor ...

  2. 产品三维展示|3D可视化解决方案|产品3D个性化定制案例分享

    看到不少优质的3D展示案例,想跟大家分享一下! 案例一:智慧园区3D可视化 展示整个园区的3D建筑风貌,独栋以及单层楼宇信息,查看消防和电路管道.同时集成展示园区的多功能运行和运维管理系统,对接线下的 ...

  3. U盘图标更改 简单三步教你个性化定制U盘图标!自定义修改你的U盘

    U盘图标 教你个性化定制U盘图标! 先看看效果图 一.首先 1. 在U盘的根目录中创建一个TXT文本文件 (U盘的根目录也就是刚打开U盘的那个目录界面) 文档中输入代码: [autorun] ICON ...

  4. ISPO Beijing 2019盛大开幕,双驰个性化定制设备强势参展,人气爆棚

    1月16日至19日,ISPO Beijing 2019-第十五届亚洲运动用品与时尚展在北京中国国际展览中心(新馆)举行,作为亚太地区运动时尚行业最具规模.最具影响力的行业标杆展会,本次展览用高达50, ...

  5. 2019鞋服行业市场分析 全面个性化定制将成主流

    近几年随着全民健身运动空前高涨,运动消费成为居民消费的一个新热点,加上消费者对于运动服饰的认识不断刷新,消费观念也随着人民生活水平的提高呈现出不同的消费偏好,再加以中国为主的新兴市场运动鞋服渗透率提升 ...

  6. 毕业设计-基于微信小程序的服装个性化定制系统

    目录 前言 课题背景与简介 实现设计思路 一.服装定制的要素分析 二.服装个性化定制小程序设计原则 三.系统需求分析 四.服装个性化定制小程序架构 五.总结 实现效果样例 更多帮助 前言

  7. 个性化定制企业管理系统对企业来说有什么优势?

    随着企业的快速发展,现有的企业管理系统已经无法适应企业的发展了.企业的个性化发展和需求,使得个性化定制企业管理系统在中大型企业市场里如鱼得水,备受欢迎.究其原因,正是因为定制化的企业管理系统弥补了固定 ...

  8. 业务流程管理的未来趋势:个性化定制

    自进入互联网时代以来.甚至更早,无论是从物质还是精神层面,"个性化"已经成为大众所普遍追求的东西.个性化定制允许买家按照自身偏好对产品进行二次改造,例如许多汽车品牌,就可以根据车主 ...

  9. 基于Android+Django+Python的服饰管理与个性化定制系统的设计与实现

    资源下载地址:https://download.csdn.net/download/sheziqiong/87904742 资源下载地址:https://download.csdn.net/downl ...

  10. 汽车行业如何个性化定制转型?看APS系统在这家企业的运用

    传统汽车行业中往往采用的是按库存推动式生产,一旦市场产生变动就会造成大量的生产,给企业带来大批的资金压力,而另一方面采用按单生产的方式企业往往面临供应链,产能的诸多约束条件限制,稍有不慎就会带来产线停 ...

最新文章

  1. Java(15) _Runtime类 内存方法
  2. rfm模型分析与客户细分_如何使用基于RFM的细分来确定最佳客户
  3. Bootstrap表格内容垂直水平居中
  4. JSPatch真强大!
  5. Android--序列化XML数据
  6. 安全漏洞问题6:SQL注入
  7. 在Seismic.NET下用最少的语句写出一个剖面显示程序
  8. 在网页上获取当前日期,数字时钟
  9. vfp 生成html,利用VFP脚本开发动态Web系统
  10. 6-28小组会议记录
  11. AIX系统怎么更换服务器硬盘(mirrorvg)
  12. vue中的事件修饰符.self、.capture和.passive
  13. msl3等级烘烤时间_msl湿敏等级对应表
  14. 百度实时热点词采集工具
  15. 为知笔记保存为html,为知笔记 | 如何保存微信内容到为知笔记?
  16. 魔域手游安卓修改服务器地址,魔域互通端游手游架设
  17. 【golang】golang使用cmd去ping网址在window和linux的区别
  18. 虚拟化存储和非虚拟化存储
  19. 如何使用matlab读取excel中的表格数据
  20. 始祖双碳新闻 | 2022年7月19日碳中和行业早知道

热门文章

  1. jQuery打印插件JQPRINT
  2. PADS Router 布线不显示粗细问题的解决
  3. 宁波户外广告调查报告
  4. matlab求最大公约数和最小公倍数
  5. jQuery中的live绑定多个事件整理
  6. 转换整形数字为16进制字符串
  7. Guava - Collections - Immutable collections
  8. 判断某个值是否存在指定枚举类中
  9. 作为开发你必须知道的WebSocket详解
  10. VS2022编译项目出现““csc.exe”已退出,代码为 -1073741819”的错误解决办法