TerryMooreII / angular-wysiwyg

An AngularJS WYSIWYG directive that multiple instances and two-way data-binding.
MIT License
121 stars 76 forks source link

Problems with spacebar #52

Open pidompa opened 9 years ago

pidompa commented 9 years ago

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();
          });