Skip to content

Instantly share code, notes, and snippets.

@transcendr
Created November 29, 2018 02:28
Show Gist options
  • Save transcendr/287246e0c5d9d8739aad2a1ca9f56b63 to your computer and use it in GitHub Desktop.
Save transcendr/287246e0c5d9d8739aad2a1ca9f56b63 to your computer and use it in GitHub Desktop.
plugin refactor
import { organizeParagraphs } from './utils'
declare var define: any
export default ($editor: any) => {
;(function(factory: any) {
/* global define */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory)
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = factory(require('jquery'))
} else {
// Browser globals
factory(window.$, $editor)
}
})(function($: any, editorId: any) {
window.$.extend(window.$.summernote.plugins, {
/**
* Handles the insertion of a new paragraph via
* the enter key.
*/
observeChanges: function() {
// const $editor = $(editorId)
this.events = {
'summernote.change': function(
we: any,
contents: any,
$editable: any
) {
organizeParagraphs($)
}
}
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment