Skip to content
Permalink
Browse files

Merge branch 't/13414'

  • Loading branch information...
oleq committed Aug 12, 2015
2 parents 5bc638d + 6705f23 commit e61966b84b9bd2cd1a779d4325844a7a581331b3
@@ -18,6 +18,7 @@ Fixed Issues:
* [#13568](http://dev.ckeditor.com/ticket/13568): Fixed: Method [`editor.getSelectedHtml()`](http://docs.ckeditor.com/#!/api/CKEDITOR.editor-method-getSelectedHtml) returns invalid results for entire content selection.
* [#13453](http://dev.ckeditor.com/ticket/13453): Fixed: Drag&drop of a whole content of the editor throws an error.
* [#13465](http://dev.ckeditor.com/ticket/13465): Fixed: Error is thrown and widget is lost when drag&drop if it is the only content of the editor.
* [#13414](http://dev.ckeditor.com/ticket/13414): Fixed: Content auto paragraphing in a nested editable despite editor configuration.

Other Changes:

@@ -1510,7 +1510,10 @@
// Check whether pathBlock equals pathBlockLimit to support nested editable (#12162).
return editor.config.autoParagraph !== false &&
editor.activeEnterMode != CKEDITOR.ENTER_BR &&
( editor.editable().equals( pathBlockLimit ) && !pathBlock ) || ( pathBlock && pathBlock.getAttribute( 'contenteditable' ) == 'true' );
(
( editor.editable().equals( pathBlockLimit ) && !pathBlock ) ||
( pathBlock && pathBlock.getAttribute( 'contenteditable' ) == 'true' )
);
}

function autoParagraphTag( editor ) {
@@ -0,0 +1,40 @@
<div id="editor"></div>

<script>
var editor = CKEDITOR.replace( 'editor', {
extraPlugins: 'test1'
} );
CKEDITOR.plugins.add( 'test1', {
requires: 'widget',
init: function( editor ) {
editor.widgets.add( 'test1', {
button: 'Create autoparagraph test',
pathName: 'test-widget',
template:
'<div class="test1">' +
'<div class="content"></div>' +
'</div>',
editables: {
content: {
selector: '.content',
allowedContent: 'br'
}
},
allowedContent: 'div(test1,content)',
requiredContent: 'div(test1)',
upcast: function( element ) {
return element.name == 'div' && element.hasClass( 'test1' );
}
} );
}
} );
editor.once( 'pluginsLoaded', function( evt ) {
editor.setData( '<p>foo</p><div class="test1">x<div class="content">Edit me...</div>y</div> ' );
} );
</script>
@@ -0,0 +1,14 @@
@bender-tags: widget, tc, 4.5.3, 13414
@bender-ui: collapsed
@bender-ckeditor-plugins: widget, wysiwygarea, toolbar, sourcearea, floatingspace, elementspath, htmlwriter, enterkey

### Test if auto paragraphing is disabled in nested editables:

1. Click on widget's editable with _"Edit me..."_ text.
2. Add more characters.
### Expected
Elements path shows: `body` `test-widget` `div`

3. Click "Source"
### Expected
* There's **no** paragraph within `<div class="content">`.
@@ -291,6 +291,121 @@
} );
},

'test nestedEditable auto paragraphing (limited by widgetDef.allowedContent)': function() {
var editor = this.editor;

editor.widgets.add( 'autoparagraphtest', {
allowedContent: 'div',
editables: {
foo: {
selector: '#foo',
allowedContent: 'br'
}
}
} );

this.editorBot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
var widget = getWidgetById( editor, 'w1' ),
editable = widget.editables.foo,
range;

// Move focus to the editable and place selection at the end of its contents.
// This should fire 'selectionChange' event and execute editable.fixDom() method.
editable.focus();
range = editor.createRange();
range.moveToPosition( editable, CKEDITOR.POSITION_BEFORE_END );
range.select();

// Since allowedContent is 'br' auto paragraphing should not be performed.
assert.areEqual( CKEDITOR.ENTER_BR, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_BR.' );
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
} );
},

'test nestedEditable auto paragraphing (limited by config.enterMode)': function() {
bender.editorBot.create( {
name: 'testautoparagraphingconfigentermode',
creator: 'inline',
config: {
enterMode: CKEDITOR.ENTER_BR,
on: {
pluginsLoaded: function( evt ) {
evt.editor.widgets.add( 'autoparagraphtest', {
editables: {
foo: {
selector: '#foo'
}
}
} );

evt.editor.filter.allow( 'div[data-widget,id]' );
}
}
}
}, function( bot ) {
var editor = bot.editor;

bot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
var widget = getWidgetById( editor, 'w1' ),
editable = widget.editables.foo,
range;

// Move focus to the editable and place selection at the end of its contents.
// This should fire 'selectionChange' event and execute editable.fixDom() method.
editable.focus();
range = editor.createRange();
range.moveToPosition( editable.getFirst(), CKEDITOR.POSITION_BEFORE_END );
range.select();

// Since allowedContent is 'br' auto paragraphing should not be performed.
assert.areEqual( CKEDITOR.ENTER_BR, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_BR.' );
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
} );
} );
},

'test nestedEditable auto paragraphing (limited by config.autoParagraph)': function() {
bender.editorBot.create( {
name: 'testautoparagraphingconfigautoparagraph',
creator: 'inline',
config: {
autoParagraph: false,
on: {
pluginsLoaded: function( evt ) {
evt.editor.widgets.add( 'autoparagraphtest', {
editables: {
foo: {
selector: '#foo'
}
}
} );

evt.editor.filter.allow( 'div[data-widget,id]' );
}
}
}
}, function( bot ) {
var editor = bot.editor;

bot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
var widget = getWidgetById( editor, 'w1' ),
editable = widget.editables.foo,
range;

// Move focus to the editable and place selection at the end of its contents.
// This should fire 'selectionChange' event and execute editable.fixDom() method.
editable.focus();
range = editor.createRange();
range.moveToPosition( editable.getFirst(), CKEDITOR.POSITION_BEFORE_END );
range.select();

// Since allowedContent is 'br' auto paragraphing should not be performed.
assert.areEqual( CKEDITOR.ENTER_P, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_P.' );
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
} );
} );
},

'test nestedEditable.setData - data processor integration': function() {
var editor = this.editor,
data = '<p>Foo</p><div data-widget="testsetdata1" id="w1"><p>A</p><p id="foo">B</p></div>';
@@ -1383,4 +1498,4 @@
} );
}
} );
} )();
} )();

0 comments on commit e61966b

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