// Register the plugin within the editor. CKEDITOR.plugins.add( 'contentTextWidget', { // This plugin requires the Widgets System defined in the 'widget' plugin. requires: 'widget', // Register the icon used for the toolbar button. It must be the same // as the name of the widget. icons: 'contentTextWidget', // The plugin initialization logic goes inside this method. init: function( editor ) { // Register the simplebox widget. editor.widgets.add( 'contentTextWidget', { init: function() { }, // Allow all HTML elements and classes that this widget requires. // Read more about the Advanced Content Filter here: // * http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter // * http://docs.ckeditor.com/#!/guide/plugin_sdk_integration_with_acf allowedContent: 'div(!ckw_Div_content){text-align};table(!ckw_content_tbl);td(!ckw_content_td);tr(!ckw_content_tr);', // Minimum HTML which is required by this widget to work. requiredContent: 'table(ckw_content_tbl)', // Define two nested editable areas. editables: { content: { selector: '.ckw_Div_content', allowedContent: 'strong sub sup u em s br ul ol li strong h1 h2 h3 h4 h5 hr; a[!href,name,id]; span[!style]{color,text-align};h6[!style]{text-align};' } }, // Define the template of a new Simple Box widget. // The template will be used when creating new instances of the Simple Box widget. template:'
Enter your text here...
 
 
', // Define the label for a widget toolbar button which will be automatically // created by the Widgets System. This button will insert a new widget instance // created from the template defined above, or will edit selected widget // (see second part of this tutorial to learn about editing widgets). // // Note: In order to be able to translate your widget you should use the // editor.lang.simplebox.* property. A string was used directly here to simplify this tutorial. button: 'Text', // Check the elements that need to be converted to widgets. // // Note: The "element" argument is an instance of http://docs.ckeditor.com/#!/api/CKEDITOR.htmlParser.element // so it is not a real DOM element yet. This is caused by the fact that upcasting is performed // during data processing which is done on DOM represented by JavaScript objects. upcast: function( element ) { // Return "true" (that element needs to converted to a Simple Box widget) // for all
elements with a "simplebox" class. return element.name == 'table' && element.hasClass( 'ckw_content_tbl' ); }, data: function(){ } } ); } } );