export default function() {
    return function(scribe) {
        var backColorCommand = new scribe.api.Command('backColor');

        var clean = function(root) {
            for (var i=0; i < root.childNodes.length; i++) {
                var node = root.childNodes[i];
                if (node.nodeType !== 1) {
                    continue;
                }

                node.style.backgroundColor = "";
                clean(node);

                if (node.attributes.length == 1 && !node.getAttribute('style')) {
                    while (node.childNodes.length > 0) {
                        root.insertBefore(node.firstChild, node);
                    }
                    root.removeChild(node);
                    i--;
                }
            }

            root.normalize();
        };

        backColorCommand.execute = function(color) {
            var selection = new scribe.api.Selection();
            var range = selection.range;
            var rangeContent = range.extractContents();

            var wrapper = document.createElement("span");
            wrapper.style.backgroundColor = color;

            scribe.transactionManager.run(function () {
                clean(rangeContent);

                range.insertNode(rangeContent);
                range.surroundContents(wrapper);
            }.bind(this));
        };

        scribe.commands.backColor = backColorCommand;
    };
}

@@ -1,8 +1,58 @@
+import Element from 'scribe-common/src/element';%0A%0A
 export d
@@ -592,170 +592,29 @@
     
-while (node.childNodes.length %3E 0) %7B%0A                        root.insertBefore(node.firstChild, node);%0A                    %7D%0A                    root.removeChild(
+Element.unwrap(root, 
 node
@@ -676,39 +676,8 @@
    %7D
-%0A%0A            root.normalize();
 %0A   

Remove duplicate code