TerryMooreII / angular-wysiwyg

An AngularJS WYSIWYG directive that multiple instances and two-way data-binding.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with spacebar

pidompa opened this issue · comments

Hi,
first of all congratulation for the great and lighweight module.
I had an issue when pressing spacebar. The editor doesn't print the space but it falls down with the default behaviour of scrolling the whole webpage.
I checked the code and fixed it by adding

event.stopPropagation();

at the end of the event handler on keydown

Following the piece of code

textarea.on('keydown', function (event) {
            if (event.keyCode == 9) {
              var TAB_SPACES = 4;
              var html = textarea.html();
              var selection = window.getSelection();
              var position = selection.anchorOffset;
              event.preventDefault();  // html = insertTab(html, position);
                                       // textarea.html(html);
                                       // selection.collapse(textarea[0].firstChild, position + TAB_SPACES);    
            }

            // THIS IS THE LINE I ADDED <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            event.stopPropagation();
          });