From cf68b565849083ad964b2840c81512271c5733df Mon Sep 17 00:00:00 2001 From: Sebastian Brzuzek Date: Wed, 4 Sep 2013 15:55:06 +0200 Subject: [PATCH] update editor selection only if it has focus - fix related to problem with adding link --- bootstrap-wysiwyg.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bootstrap-wysiwyg.js b/bootstrap-wysiwyg.js index 69f64a7..0f00009 100644 --- a/bootstrap-wysiwyg.js +++ b/bootstrap-wysiwyg.js @@ -21,6 +21,7 @@ $.fn.wysiwyg = function (userOptions) { var editor = this, selectedRange, + focused, options, toolbarBtnSelector, updateToolbar = function () { @@ -161,8 +162,15 @@ bindToolbar($(options.toolbarSelector), options); editor.attr('contenteditable', true) .on('mouseup keyup mouseout', function () { + if (!focused) return; saveSelection(); updateToolbar(); + }) + .on('focus', function () { + focused = true; + }) + .on('blur', function () { + focused = false; }); $(window).bind('touchend', function (e) { var isInside = (editor.is(e.target) || editor.has(e.target).length > 0),