Skip to content
Permalink
Browse files

Merge branch 't/10027' into major

  • Loading branch information...
oleq committed Jul 5, 2013
2 parents 597a99f + d8ca727 commit 41cbd9d8b7c5420ae3e6337815f6e7723bf86387
Showing with 1,445 additions and 365 deletions.
  1. +1 −0 CHANGES.md
  2. +2 −1 config.js
  3. +178 −9 plugins/enterkey/plugin.js
  4. +290 −0 plugins/indent/dev/indent.html
  5. +393 −355 plugins/indent/plugin.js
  6. +289 −0 plugins/indentblock/plugin.js
  7. +292 −0 plugins/indentlist/plugin.js
@@ -8,6 +8,7 @@ CKEditor 4 Changelog
* [#10370](http://dev.ckeditor.com/ticket/10370): Inconsistency in data events between framed and inline editors.
* [#9794](http://dev.ckeditor.com/ticket/9794): OnChange event.
* [#9923](http://dev.ckeditor.com/ticket/9923): HiDPI support in editor UI. HiDPI icons for Moono skin.
* [#10027](http://dev.ckeditor.com/ticket/10027): Separated list and block indentation.

## CKEditor 4.1.2

@@ -34,7 +34,8 @@ CKEDITOR.editorConfig = function( config ) {
'htmlwriter,' +
'image,' +
'iframe,' +
'indent,' +
'indentlist,' +
'indentblock,' +
'justify,' +
'link,' +
'list,' +
@@ -5,9 +5,6 @@

(function() {
CKEDITOR.plugins.add( 'enterkey', {
// TODO: should not depend on a particular format plugin.
requires: 'indent',

init: function( editor ) {
editor.addCommand( 'enter', { modes:{wysiwyg:1 },
editorFocus: false,
@@ -48,13 +45,188 @@
var atBlockStart = range.checkStartOfBlock(),
atBlockEnd = range.checkEndOfBlock(),
path = editor.elementPath( range.startContainer ),
block = path.block;
block = path.block,

// Determine the block element to be used.
blockTag = ( mode == CKEDITOR.ENTER_DIV ? 'div' : 'p' ),

newBlock;

// Exit the list when we're inside an empty list item block. (#5376)
if ( atBlockStart && atBlockEnd ) {
// Exit the list when we're inside an empty list item block. (#5376)
if ( block && ( block.is( 'li' ) || block.getParent().is( 'li' ) ) ) {
editor.execCommand( 'outdent' );
var blockParent = block.getParent(),
blockGrandParent = blockParent.getParent(),

firstChild = !block.hasPrevious(),
lastChild = !block.hasNext(),

selection = editor.getSelection(),
bookmarks = selection.createBookmarks(),

orgDir = block.getDirection( 1 ),
className = block.getAttribute( 'class' ),
style = block.getAttribute( 'style' ),
dirLoose = blockGrandParent.getDirection( 1 ) != orgDir,

enterMode = editor.config.enterMode,
needsBlock = enterMode != CKEDITOR.ENTER_BR || dirLoose || style || className,

child;

if ( blockGrandParent.is( 'li' ) ) {

// If block is the first or the last child of the parent
// list, degrade it and move to the outer list:
// before the parent list if block is first child and after
// the parent list if block is the last child, respectively.
//
// <ul> => <ul>
// <li> => <li>
// <ul> => <ul>
// <li>x</li> => <li>x</li>
// <li>^</li> => </ul>
// </ul> => </li>
// </li> => <li>^</li>
// </ul> => </ul>
//
// AND
//
// <ul> => <ul>
// <li> => <li>^</li>
// <ul> => <li>
// <li>^</li> => <ul>
// <li>x</li> => <li>x</li>
// </ul> => </ul>
// </li> => </li>
// </ul> => </ul>

if ( firstChild || lastChild )
block[ firstChild ? 'insertBefore' : 'insertAfter' ]( blockGrandParent );

// If the empty block is neither first nor last child
// then split the list and the block as an element
// of outer list.
//
// => <ul>
// => <li>
// <ul> => <ul>
// <li> => <li>x</li>
// <ul> => </ul>
// <li>x</li> => </li>
// <li>^</li> => <li>^</li>
// <li>y</li> => <li>
// </ul> => <ul>
// </li> => <li>y</li>
// </ul> => </ul>
// => </li>
// => </ul>

else
block.breakParent( blockGrandParent );
}

else if ( !needsBlock ) {
block.appendBogus();

// If block is the first or last child of the parent
// list, move all block's children out of the list:
// before the list if block is first child and after the list
// if block is the last child, respectively.
//
// <ul> => <ul>
// <li>x</li> => <li>x</li>
// <li>^</li> => </ul>
// </ul> => ^
//
// AND
//
// <ul> => ^
// <li>^</li> => <ul>
// <li>x</li> => <li>x</li>
// </ul> => </ul>

if ( firstChild || lastChild ) {
while ( ( child = block[ firstChild ? 'getFirst' : 'getLast' ]() ) )
child[ firstChild ? 'insertBefore' : 'insertAfter' ]( blockParent );
}

// If the empty block is neither first nor last child
// then split the list and put all the block contents
// between two lists.
//
// <ul> => <ul>
// <li>x</li> => <li>x</li>
// <li>^</li> => </ul>
// <li>y</li> => ^
// </ul> => <ul>
// => <li>y</li>
// => </ul>

else {
block.breakParent( blockParent );

while ( ( child = block.getLast() ) )
child.insertAfter( blockParent );
}

block.remove();
} else {
// Use <div> block for ENTER_BR and ENTER_DIV.
newBlock = doc.createElement( mode == CKEDITOR.ENTER_P ? 'p' : 'div' );

if ( dirLoose )
newBlock.setAttribute( 'dir', orgDir );

style && newBlock.setAttribute( 'style', style );
className && newBlock.setAttribute( 'class', className );

// Move all the child nodes to the new block.
block.moveChildren( newBlock );

// If block is the first or last child of the parent
// list, move it out of the list:
// before the list if block is first child and after the list
// if block is the last child, respectively.
//
// <ul> => <ul>
// <li>x</li> => <li>x</li>
// <li>^</li> => </ul>
// </ul> => <p>^</p>
//
// AND
//
// <ul> => <p>^</p>
// <li>^</li> => <ul>
// <li>x</li> => <li>x</li>
// </ul> => </ul>

if ( firstChild || lastChild )
newBlock[ firstChild ? 'insertBefore' : 'insertAfter' ]( blockParent );

// If the empty block is neither first nor last child
// then split the list and put the new block between
// two lists.
//
// => <ul>
// <ul> => <li>x</li>
// <li>x</li> => </ul>
// <li>^</li> => <p>^</p>
// <li>y</li> => <ul>
// </ul> => <li>y</li>
// => </ul>

else {
block.breakParent( blockParent );
newBlock.insertAfter( blockParent );
}

block.remove();
}

selection.selectBookmarks( bookmarks );

return;
}

@@ -82,9 +254,6 @@
}
}

// Determine the block element to be used.
var blockTag = ( mode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );

// Split the range.
var splitInfo = range.splitBlock( blockTag );

@@ -139,7 +308,7 @@
if ( nextBlock )
range.moveToElementEditStart( nextBlock );
} else {
var newBlock, newBlockDir;
var newBlockDir;

if ( previousBlock ) {
// Do not enter this block if it's a header tag, or we are in

0 comments on commit 41cbd9d

Please sign in to comment.
You can’t perform that action at this time.