11/*!
2- * medium-editor-insert-plugin v2.3.0 - jQuery insert plugin for MediumEditor
2+ * medium-editor-insert-plugin v2.3.1 - jQuery insert plugin for MediumEditor
33 *
44 * http://linkesch.com/medium-editor-insert-plugin
55 *
99
1010( function ( factory ) {
1111 if ( typeof define === 'function' && define . amd ) {
12- define ( [ 'jquery' ] , factory ) ;
12+ define ( [ 'jquery' , 'handlebars' , 'medium-editor' , 'blueimp-file-upload' , 'jquery-sortable' ] , factory ) ;
1313 } else if ( typeof module === 'object' && module . exports ) {
1414 module . exports = function ( root , jQuery ) {
1515 if ( jQuery === undefined ) {
1616 if ( typeof window !== 'undefined' ) {
1717 jQuery = require ( 'jquery' ) ;
18+ Handlebars = require ( 'handlebars' ) ;
19+ MediumEditor = require ( 'medium-editor' ) ;
1820 }
1921 else {
2022 jQuery = require ( 'jquery' ) ( root ) ;
23+ Handlebars = require ( 'handlebars' ) ( root ) ;
24+ MediumEditor = require ( 'medium-editor' ) ( root ) ;
2125 }
2226 }
23- factory ( jQuery ) ;
27+ factory ( jQuery , Handlebars , MediumEditor ) ;
2428 return jQuery ;
2529 } ;
2630 } else {
27- factory ( jQuery ) ;
31+ factory ( jQuery , Handlebars , MediumEditor ) ;
2832 }
29- } ( function ( $ ) {
33+ } ( function ( $ , Handlebars , MediumEditor ) {
3034
3135this [ "MediumInsert" ] = this [ "MediumInsert" ] || { } ;
3236this [ "MediumInsert" ] [ "Templates" ] = this [ "MediumInsert" ] [ "Templates" ] || { } ;
@@ -216,9 +220,15 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
216220
217221 // Extend editor's functions
218222 if ( this . options && this . options . editor ) {
219- this . options . editor . _serialize = this . options . editor . serialize ;
220- this . options . editor . _destroy = this . options . editor . destroy ;
221- this . options . editor . _setup = this . options . editor . setup ;
223+ if ( this . options . editor . _serialize === undefined ) {
224+ this . options . editor . _serialize = this . options . editor . serialize ;
225+ }
226+ if ( this . options . editor . _destroy === undefined ) {
227+ this . options . editor . _destroy = this . options . editor . destroy ;
228+ }
229+ if ( this . options . editor . _setup === undefined ) {
230+ this . options . editor . _setup = this . options . editor . setup ;
231+ }
222232 this . options . editor . _hideInsertButtons = this . hideButtons ;
223233
224234 this . options . editor . serialize = this . editorSerialize ;
@@ -317,7 +327,9 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
317327
318328 Core . prototype . editorDestroy = function ( ) {
319329 $ . each ( this . elements , function ( key , el ) {
320- $ ( el ) . data ( 'plugin_' + pluginName ) . disable ( ) ;
330+ if ( $ ( el ) . data ( 'plugin_' + pluginName ) instanceof Core ) {
331+ $ ( el ) . data ( 'plugin_' + pluginName ) . disable ( ) ;
332+ }
321333 } ) ;
322334
323335 this . _destroy ( ) ;
@@ -333,7 +345,9 @@ this["MediumInsert"]["Templates"]["src/js/templates/images-toolbar.hbs"] = Handl
333345 this . _setup ( ) ;
334346
335347 $ . each ( this . elements , function ( key , el ) {
336- $ ( el ) . data ( 'plugin_' + pluginName ) . enable ( ) ;
348+ if ( $ ( el ) . data ( 'plugin_' + pluginName ) instanceof Core ) {
349+ $ ( el ) . data ( 'plugin_' + pluginName ) . enable ( ) ;
350+ }
337351 } ) ;
338352 } ;
339353
0 commit comments