From f717438e1c833c870fb7df9f8cec5a4e93b5affc Mon Sep 17 00:00:00 2001 From: Maxim Solodovnik Date: Mon, 27 Apr 2020 22:31:49 +0700 Subject: [PATCH] getCurrentRange was always undefined on mobile devices --- src/bootstrap-wysiwyg.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bootstrap-wysiwyg.js b/src/bootstrap-wysiwyg.js index 8d7f214..4d4b3cb 100644 --- a/src/bootstrap-wysiwyg.js +++ b/src/bootstrap-wysiwyg.js @@ -58,18 +58,19 @@ this.updateToolbar( editor, toolbarBtnSelector, options ); }.bind( this ) ); + var self = this; $( window ).bind( "touchend", function( e ) { - if(!this.getCurrentRange) + if(!self.getCurrentRange) return; var isInside = ( editor.is( e.target ) || editor.has( e.target ).length > 0 ), - currentRange = this.getCurrentRange(), + currentRange = self.getCurrentRange(), clear = currentRange && ( currentRange.startContainer === currentRange.endContainer && currentRange.startOffset === currentRange.endOffset ); if ( !clear || isInside ) { - this.saveSelection(); - this.updateToolbar( editor, toolbarBtnSelector, options ); + self.saveSelection(); + self.updateToolbar( editor, toolbarBtnSelector, options ); } } ); }