Ckeditor plugin : how to unwrap text? <p>I have created a ckeditor plugin that wraps the selected text into a span. I wonder how can I unwrap the selected when I apply this plugin on a text that has been previously wrapped into the span.</p> <pre><code>CKEDITOR.plugins.add('important', { // Register the icons. They must match command names. //trick to get a 16*16 icon : http://www.favicomatic.com icons: 'important', init: function (editor) { editor.addCommand('important', { // Define the function that will be fired when the command is executed. exec: function (editor) { var selected_text = editor.getSelection().getSelectedText(); console.log(editor.getSelection()) ; var newElement = new CKEDITOR.dom.element("span"); newElement.setAttributes({class: 'important'}); newElement.setText(selected_text); editor.insertElement(newElement); //how to unwrap the selected text ? }); // Create the toolbar button that executes the above command. editor.ui.addButton('important', { label: 'Set this as important', command: 'important', toolbar: 'insert' }); } }); </code></pre>