]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/textcolor/plugin.js
WordPress 4.2
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / textcolor / plugin.js
index b33988be8277cc74f10d53470a7aa23822b2ab6b..42aaeaadf0d55526374b7df8125b0ec89210b44f 100644 (file)
@@ -159,15 +159,19 @@ tinymce.PluginManager.add('textcolor', function(editor) {
        }
 
        function applyFormat(format, value) {
-               editor.focus();
-               editor.formatter.apply(format, {value: value});
-               editor.nodeChanged();
+               editor.undoManager.transact(function() {
+                       editor.focus();
+                       editor.formatter.apply(format, {value: value});
+                       editor.nodeChanged();
+               });
        }
 
        function removeFormat(format) {
-               editor.focus();
-               editor.formatter.remove(format, {value: null}, null, true);
-               editor.nodeChanged();
+               editor.undoManager.transact(function() {
+                       editor.focus();
+                       editor.formatter.remove(format, {value: null}, null, true);
+                       editor.nodeChanged();
+               });
        }
 
        function onPanelClick(e) {
@@ -179,6 +183,12 @@ tinymce.PluginManager.add('textcolor', function(editor) {
                        applyFormat(buttonCtrl.settings.format, value);
                }
 
+               function resetColor() {
+                       buttonCtrl.hidePanel();
+                       buttonCtrl.resetColor();
+                       removeFormat(buttonCtrl.settings.format);
+               }
+
                function setDivColor(div, value) {
                        div.style.background = value;
                        div.setAttribute('data-mce-color', value);
@@ -225,12 +235,10 @@ tinymce.PluginManager.add('textcolor', function(editor) {
                        this.lastId = e.target.id;
 
                        if (value == 'transparent') {
-                               removeFormat(buttonCtrl.settings.format);
-                               buttonCtrl.hidePanel();
-                               return;
+                               resetColor();
+                       } else {
+                               selectColor(value);
                        }
-
-                       selectColor(value);
                } else if (value !== null) {
                        buttonCtrl.hidePanel();
                }
@@ -241,6 +249,8 @@ tinymce.PluginManager.add('textcolor', function(editor) {
 
                if (self._color) {
                        applyFormat(self.settings.format, self._color);
+               } else {
+                       removeFormat(self.settings.format);
                }
        }