LaravelTest
82 строки · 2.5 Кб
1(function(factory) {2if (typeof define === 'function' && define.amd) {3// AMD. Register as an anonymous module.4define(['jquery'], factory);5} else if (typeof module === 'object' && module.exports) {6// Node/CommonJS7module.exports = factory(require('jquery'));8} else {9// Browser globals10factory(window.jQuery);11}12}(function($) {13// Extends plugins for adding hello.14// - plugin is external module for customizing.15$.extend($.summernote.plugins, {16/**17* @param {Object} context - context object has status of editor.
18*/
19'hello': function(context) {20var self = this;21
22// ui has renders to build ui elements.23// - you can create a button with `ui.button`24var ui = $.summernote.ui;25
26// add hello button27context.memo('button.hello', function() {28// create button29var button = ui.button({30contents: '<i class="fa fa-child"/> Hello',31tooltip: 'hello',32click: function() {33self.$panel.show();34self.$panel.hide(500);35// invoke insertText method with 'hello' on editor module.36context.invoke('editor.insertText', 'hello');37},38});39
40// create jQuery object from button instance.41var $hello = button.render();42return $hello;43});44
45// This events will be attached when editor is initialized.46this.events = {47// This will be called after modules are initialized.48'summernote.init': function(we, e) {49// eslint-disable-next-line50console.log('summernote initialized', we, e);51},52// This will be called when user releases a key on editable.53'summernote.keyup': function(we, e) {54// eslint-disable-next-line55console.log('summernote keyup', we, e);56},57};58
59// This method will be called when editor is initialized by $('..').summernote();60// You can create elements for plugin61this.initialize = function() {62this.$panel = $('<div class="hello-panel"/>').css({63position: 'absolute',64width: 100,65height: 100,66left: '50%',67top: '50%',68background: 'red',69}).hide();70
71this.$panel.appendTo('body');72};73
74// This methods will be called when editor is destroyed by $('..').summernote('destroy');75// You should remove elements on `initialize`.76this.destroy = function() {77this.$panel.remove();78this.$panel = null;79};80},81});82}));83