/** * @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ /** * @fileOverview Handles the indentation of block elements. */ ( function() { 'use strict'; var $listItem = CKEDITOR.dtd.$listItem, $list = CKEDITOR.dtd.$list, TRISTATE_DISABLED = CKEDITOR.TRISTATE_DISABLED, TRISTATE_OFF = CKEDITOR.TRISTATE_OFF; CKEDITOR.plugins.add( 'indentblock', { requires: 'indent', init: function( editor ) { var globalHelpers = CKEDITOR.plugins.indent, classes = editor.config.indentClasses; // Register commands. globalHelpers.registerCommands( editor, { indentblock: new commandDefinition( editor, 'indentblock', true ), outdentblock: new commandDefinition( editor, 'outdentblock' ) } ); function commandDefinition( editor, name ) { globalHelpers.specificDefinition.apply( this, arguments ); this.allowedContent = { 'div h1 h2 h3 h4 h5 h6 ol p pre ul': { // Do not add elements, but only text-align style if element is validated by other rule. propertiesOnly: true, styles: !classes ? 'margin-left,margin-right' : null, classes: classes || null } }; if ( this.enterBr ) this.allowedContent.div = true; this.requiredContent = ( this.enterBr ? 'div' : 'p' ) + ( classes ? '(' + classes.join( ',' ) + ')' : '{margin-left}' ); this.jobs = { '20': { refresh: function( editor, path ) { var firstBlock = path.block || path.blockLimit; // Switch context from list item to list // because indentblock can indent entire list // but not a single list element. if ( firstBlock.is( $listItem ) ) firstBlock = firstBlock.getParent(); // If firstBlock isn't list item, but still there's // some ascendant (i.e.