title: Custom TinyMCE 4.x button to increase letter spacing not working
body: <p>I implemented a TinyMCE button to increase the letter spacing at <a href="http://fiddle.tinymce.com/Z9eaab/31" rel="nofollow noreferrer">http://fiddle.tinymce.com/Z9eaab/31</a>. If you enter the words "some text" in the text area at the bottom and then select "some" and hit the "Increase letter spacing" button multiple times, the letter spacing only increases the first time. If you select the second word, "text," the spacing increases each time you hit "Increase letter spacing." as it should.</p>
  
  <p>I can see from the console.log on line 9 that when it doesn't work it's because the current spacing read doesn't reflect the last increase, so it just keeps redoing the first one.</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;script type="text/javascript"&gt;
    tinymce.PluginManager.add('example', function(editor, url) {
      // Add a button that opens a window
      editor.addButton('example1', {
        text: 'Increase letter spacing',
        icon: false,
        onclick: function() {
          var currentSpacing = new Number($(tinyMCE.activeEditor.selection.getNode()).css('letter-spacing').replace('px', ''));
          console.log("spacing read is" + currentSpacing);
          currentSpacing = currentSpacing + 1;
  
          tinymce.activeEditor.formatter.register('increaseSpacing', {
            inline: 'span',
            styles: {
              'letter-spacing': currentSpacing + 'px'
            }
          });
  
          tinymce.activeEditor.formatter.apply('increaseSpacing');
        }
      });
  
      editor.addButton('example2', {
        text: 'Decrease letter spacing',
        icon: false,
        onclick: function() {
          var currentSpacing = new Number($(tinyMCE.activeEditor.selection.getNode()).css('letter-spacing').replace('px', ''));
          currentSpacing = currentSpacing - 1;
  
          tinymce.activeEditor.formatter.register('decreaseSpacing', {
            inline: 'span',
            styles: {
              'letter-spacing': currentSpacing + 'px'
            }
          });
  
          tinymce.activeEditor.formatter.apply('decreaseSpacing');
        }
      });
  
      // Adds a menu item to the tools menu
      editor.addMenuItem('example', {
        text: 'Example plugin',
        context: 'tools',
        onclick: function() {
          // Open window with a specific url
          editor.windowManager.open({
            title: 'TinyMCE site',
            url: 'http://www.tinymce.com',
            width: 400,
            height: 300,
            buttons: [{
              text: 'Close',
              onclick: 'close'
            }]
          });
        }
      });
    });
  
    tinymce.init({
      selector: "textarea",
      plugins: "example",
      toolbar: "example1 example2 undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    });
  &lt;/script&gt;
  
  &lt;form method="post" action="dump.php"&gt;
    &lt;textarea name="content"&gt;&lt;/textarea&gt;
  &lt;/form&gt;
  </code></pre>
  
  
  
  <p>Does anyone know what's going on?</p>