Skip to content
Permalink
Browse files

Merge branch 't/11083' into major

  • Loading branch information...
Reinmar committed Nov 6, 2013
2 parents ca5b94a + 26a9b87 commit 8af211e9309a53f68eb5f35606be2a7d641be50a
Showing with 80 additions and 15 deletions.
  1. +1 −0 CHANGES.md
  2. +2 −2 core/dom/elementpath.js
  3. +4 −2 core/editable.js
  4. +6 −1 plugins/div/dialogs/div.js
  5. +4 −1 plugins/div/plugin.js
  6. +62 −8 plugins/list/plugin.js
  7. +1 −1 plugins/widget/plugin.js
@@ -47,6 +47,7 @@ Fixed Issues:
* [#10430](http://dev.ckeditor.com/ticket/10430): Resolve dependence of image plugin if forms plugin.
* [#10911](http://dev.ckeditor.com/ticket/10911): Browser alt hotkeys will no longer be blocked while widget is focused.
* [#11082](http://dev.ckeditor.com/ticket/11082): Selected widget is not copied/cut when using toolbar buttons or context menu.
* [#11083](http://dev.ckeditor.com/ticket/11083): Fixed lists and divs application to block widgets.

## CKEditor 4.3 Beta

@@ -64,9 +64,9 @@
if ( !this.lastElement ) {
this.lastElement = e;

// If a table is fully selected at the end of the element path,
// If an object or non-editable element is fully selected at the end of the element path,
// it must not become the block limit.
if ( e.is( CKEDITOR.dtd.$object ) )
if ( e.is( CKEDITOR.dtd.$object ) || e.getAttribute( 'contenteditable' ) == 'false' )
continue;
}

@@ -818,7 +818,6 @@
// Returns truly value when dom was changed, falsy otherwise.
function fixDom( evt ) {
var editor = evt.editor,
editable = editor.editable(),
path = evt.data.path,
blockLimit = path.blockLimit,
selection = evt.data.selection,
@@ -838,7 +837,10 @@

// When we're in block enter mode, a new paragraph will be established
// to encapsulate inline contents inside editable. (#3657)
if ( shouldAutoParagraph( editor, path.block, blockLimit ) && range.collapsed ) {
// Don't autoparagraph if browser (namely - IE) incorrectly anchored selection
// inside non-editable content. This happens e.g. if non-editable block is the only
// content of editable.
if ( shouldAutoParagraph( editor, path.block, blockLimit ) && range.collapsed && !range.getCommonAncestor().isReadOnly() ) {
var testRng = range.clone();
testRng.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
var walker = new CKEDITOR.dom.walker( testRng );
@@ -54,6 +54,11 @@
function getDivContainer( element ) {
var container = editor.elementPath( element ).blockLimit;

// Never consider read-only (i.e. contenteditable=false) element as
// a first div limit (#11083).
if ( container.isReadOnly() )
container = container.getParent();

// Dont stop at 'td' and 'th' when div should wrap entire table.
if ( editor.config.div_wrapTable && container.is( [ 'td', 'th' ] ) ) {
var parentPath = editor.elementPath( container.getParent() );
@@ -120,7 +125,7 @@
iterator = ranges[ i ].createIterator();
while ( ( block = iterator.getNextParagraph() ) ) {
// include contents of blockLimit elements.
if ( block.getName() in divLimitDefinition ) {
if ( block.getName() in divLimitDefinition && !block.isReadOnly() ) {
var j,
childNodes = block.getChildren();
for ( j = 0; j < childNodes.count(); j++ )
@@ -120,7 +120,10 @@
CKEDITOR.plugins.div = {
getSurroundDiv: function( editor, start ) {
var path = editor.elementPath( start );
return editor.elementPath( path.blockLimit ).contains( 'div', 1 );
return editor.elementPath( path.blockLimit ).contains( function( node ) {
// Avoid read-only (i.e. contenteditable="false") divs (#11083).
return node.is( 'div' ) && !node.isReadOnly();
}, 1 );
}
};
})();
@@ -164,33 +164,74 @@
var needsBlock = currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT && ( paragraphMode != CKEDITOR.ENTER_BR || dirLoose || style || className );

var child,
count = item.contents.length;
count = item.contents.length,
cachedBookmark;

for ( i = 0; i < count; i++ ) {
child = item.contents[ i ];

if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() ) {
// Append bookmark if we can, or cache it and append it when we'll know
// what to do with it. Generally - we want to keep it next to its original neighbour.
// Exception: if bookmark is the only child it hasn't got any neighbour, so handle it normally
// (wrap with block if needed).
if ( bookmarks( child ) && count > 1 ) {
// If we don't need block, it's simple - append bookmark directly to the current list item.
if ( !needsBlock )
currentListItem.append( child.clone( 1, 1 ) );
else
cachedBookmark = child.clone( 1, 1 );
}
// Block content goes directly to the current list item, without wrapping.
else if ( child.type == CKEDITOR.NODE_ELEMENT && child.isBlockBoundary() ) {
// Apply direction on content blocks.
if ( dirLoose && !child.getDirection() )
child.setAttribute( 'dir', orgDir );

inheirtInlineStyles( li, child );

className && child.addClass( className );
} else if ( needsBlock ) {

// Close the block which we started for inline content.
block = null;
// Append bookmark directly before current child.
if ( cachedBookmark ) {
currentListItem.append( cachedBookmark );
cachedBookmark = null;
}
// Append this block element to the list item.
currentListItem.append( child.clone( 1, 1 ) );
}
// Some inline content was found - wrap it with block and append that
// block to the current list item or append it to the block previously created.
else if ( needsBlock ) {
// Establish new block to hold text direction and styles.
if ( !block ) {
block = doc.createElement( paragraphName );
currentListItem.append( block );
dirLoose && block.setAttribute( 'dir', orgDir );
}

// Copy over styles to new block;
style && block.setAttribute( 'style', style );
className && block.setAttribute( 'class', className );

// Append bookmark directly before current child.
if ( cachedBookmark ) {
block.append( cachedBookmark );
cachedBookmark = null;
}
block.append( child.clone( 1, 1 ) );
}
// E.g. BR mode - inline content appended directly to the list item.
else
currentListItem.append( child.clone( 1, 1 ) );
}

currentListItem.append( block || child.clone( 1, 1 ) );
// No content after bookmark - append it to the block if we had one
// or directly to the current list item if we finished directly in the current list item.
if ( cachedBookmark ) {
( block || currentListItem ).append( cachedBookmark );
cachedBookmark = null;
}

if ( currentListItem.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT && currentIndex != listArray.length - 1 ) {
@@ -295,8 +336,6 @@
editor.fire( 'contentDomInvalidated' );
}

var headerTagRegex = /^h[1-6]$/;

function createList( editor, groupObj, listsCreated ) {
var contents = groupObj.contents,
doc = groupObj.root.getDocument(),
@@ -366,8 +405,9 @@
contentBlock = listContents.shift();
listItem = doc.createElement( 'li' );

// Preserve preformat block and heading structure when converting to list item. (#5335) (#5271)
if ( contentBlock.is( 'pre' ) || headerTagRegex.test( contentBlock.getName() ) )
// If current block should be preserved, append it to list item instead of
// transforming it to <li> element.
if ( shouldPreserveBlock( contentBlock ) )
contentBlock.appendTo( listItem );
else {
contentBlock.copyAttributes( listItem );
@@ -449,6 +489,20 @@
editor.fire( 'contentDomInvalidated' );
}

var headerTagRegex = /^h[1-6]$/;

// Checks wheather this block should be element preserved (not transformed to <li>) when creating list.
function shouldPreserveBlock( block ) {
return (
// #5335
block.is( 'pre' ) ||
// #5271 - this is a header.
headerTagRegex.test( block.getName() ) ||
// 11083 - this is a non-editable element.
block.getAttribute( 'contenteditable' ) == 'false'
);
}

function listCommand( name, type ) {
this.name = name;
this.type = type;
@@ -58,7 +58,7 @@
'cursor:move;' +
'width:' + DRAG_HANDLER_SIZE + 'px;' +
'height:' + DRAG_HANDLER_SIZE + 'px;' +
'display:block' +
'display:inline-block' +
'}' +
'.cke_widget_mask{' +
'position:absolute;' +

0 comments on commit 8af211e

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