Skip to content

Commit e61966b

Browse files
committed
Merge branch 't/13414'
2 parents 5bc638d + 6705f23 commit e61966b

File tree

5 files changed

+175
-2
lines changed

5 files changed

+175
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Fixed Issues:
1818
* [#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.
1919
* [#13453](http://dev.ckeditor.com/ticket/13453): Fixed: Drag&drop of a whole content of the editor throws an error.
2020
* [#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.
21+
* [#13414](http://dev.ckeditor.com/ticket/13414): Fixed: Content auto paragraphing in a nested editable despite editor configuration.
2122

2223
Other Changes:
2324

core/editable.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,10 @@
15101510
// Check whether pathBlock equals pathBlockLimit to support nested editable (#12162).
15111511
return editor.config.autoParagraph !== false &&
15121512
editor.activeEnterMode != CKEDITOR.ENTER_BR &&
1513-
( editor.editable().equals( pathBlockLimit ) && !pathBlock ) || ( pathBlock && pathBlock.getAttribute( 'contenteditable' ) == 'true' );
1513+
(
1514+
( editor.editable().equals( pathBlockLimit ) && !pathBlock ) ||
1515+
( pathBlock && pathBlock.getAttribute( 'contenteditable' ) == 'true' )
1516+
);
15141517
}
15151518

15161519
function autoParagraphTag( editor ) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<div id="editor"></div>
2+
3+
<script>
4+
var editor = CKEDITOR.replace( 'editor', {
5+
extraPlugins: 'test1'
6+
} );
7+
8+
CKEDITOR.plugins.add( 'test1', {
9+
requires: 'widget',
10+
init: function( editor ) {
11+
editor.widgets.add( 'test1', {
12+
button: 'Create autoparagraph test',
13+
pathName: 'test-widget',
14+
15+
template:
16+
'<div class="test1">' +
17+
'<div class="content"></div>' +
18+
'</div>',
19+
20+
editables: {
21+
content: {
22+
selector: '.content',
23+
allowedContent: 'br'
24+
}
25+
},
26+
27+
allowedContent: 'div(test1,content)',
28+
requiredContent: 'div(test1)',
29+
30+
upcast: function( element ) {
31+
return element.name == 'div' && element.hasClass( 'test1' );
32+
}
33+
} );
34+
}
35+
} );
36+
37+
editor.once( 'pluginsLoaded', function( evt ) {
38+
editor.setData( '<p>foo</p><div class="test1">x<div class="content">Edit me...</div>y</div> ' );
39+
} );
40+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@bender-tags: widget, tc, 4.5.3, 13414
2+
@bender-ui: collapsed
3+
@bender-ckeditor-plugins: widget, wysiwygarea, toolbar, sourcearea, floatingspace, elementspath, htmlwriter, enterkey
4+
5+
### Test if auto paragraphing is disabled in nested editables:
6+
7+
1. Click on widget's editable with _"Edit me..."_ text.
8+
2. Add more characters.
9+
### Expected
10+
Elements path shows: `body` `test-widget` `div`
11+
12+
3. Click "Source"
13+
### Expected
14+
* There's **no** paragraph within `<div class="content">`.

tests/plugins/widget/nestededitables.js

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,121 @@
291291
} );
292292
},
293293

294+
'test nestedEditable auto paragraphing (limited by widgetDef.allowedContent)': function() {
295+
var editor = this.editor;
296+
297+
editor.widgets.add( 'autoparagraphtest', {
298+
allowedContent: 'div',
299+
editables: {
300+
foo: {
301+
selector: '#foo',
302+
allowedContent: 'br'
303+
}
304+
}
305+
} );
306+
307+
this.editorBot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
308+
var widget = getWidgetById( editor, 'w1' ),
309+
editable = widget.editables.foo,
310+
range;
311+
312+
// Move focus to the editable and place selection at the end of its contents.
313+
// This should fire 'selectionChange' event and execute editable.fixDom() method.
314+
editable.focus();
315+
range = editor.createRange();
316+
range.moveToPosition( editable, CKEDITOR.POSITION_BEFORE_END );
317+
range.select();
318+
319+
// Since allowedContent is 'br' auto paragraphing should not be performed.
320+
assert.areEqual( CKEDITOR.ENTER_BR, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_BR.' );
321+
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
322+
} );
323+
},
324+
325+
'test nestedEditable auto paragraphing (limited by config.enterMode)': function() {
326+
bender.editorBot.create( {
327+
name: 'testautoparagraphingconfigentermode',
328+
creator: 'inline',
329+
config: {
330+
enterMode: CKEDITOR.ENTER_BR,
331+
on: {
332+
pluginsLoaded: function( evt ) {
333+
evt.editor.widgets.add( 'autoparagraphtest', {
334+
editables: {
335+
foo: {
336+
selector: '#foo'
337+
}
338+
}
339+
} );
340+
341+
evt.editor.filter.allow( 'div[data-widget,id]' );
342+
}
343+
}
344+
}
345+
}, function( bot ) {
346+
var editor = bot.editor;
347+
348+
bot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
349+
var widget = getWidgetById( editor, 'w1' ),
350+
editable = widget.editables.foo,
351+
range;
352+
353+
// Move focus to the editable and place selection at the end of its contents.
354+
// This should fire 'selectionChange' event and execute editable.fixDom() method.
355+
editable.focus();
356+
range = editor.createRange();
357+
range.moveToPosition( editable.getFirst(), CKEDITOR.POSITION_BEFORE_END );
358+
range.select();
359+
360+
// Since allowedContent is 'br' auto paragraphing should not be performed.
361+
assert.areEqual( CKEDITOR.ENTER_BR, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_BR.' );
362+
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
363+
} );
364+
} );
365+
},
366+
367+
'test nestedEditable auto paragraphing (limited by config.autoParagraph)': function() {
368+
bender.editorBot.create( {
369+
name: 'testautoparagraphingconfigautoparagraph',
370+
creator: 'inline',
371+
config: {
372+
autoParagraph: false,
373+
on: {
374+
pluginsLoaded: function( evt ) {
375+
evt.editor.widgets.add( 'autoparagraphtest', {
376+
editables: {
377+
foo: {
378+
selector: '#foo'
379+
}
380+
}
381+
} );
382+
383+
evt.editor.filter.allow( 'div[data-widget,id]' );
384+
}
385+
}
386+
}
387+
}, function( bot ) {
388+
var editor = bot.editor;
389+
390+
bot.setData( '<p>x</p><div data-widget="autoparagraphtest" id="w1"><div id="foo">foo</div></div>', function() {
391+
var widget = getWidgetById( editor, 'w1' ),
392+
editable = widget.editables.foo,
393+
range;
394+
395+
// Move focus to the editable and place selection at the end of its contents.
396+
// This should fire 'selectionChange' event and execute editable.fixDom() method.
397+
editable.focus();
398+
range = editor.createRange();
399+
range.moveToPosition( editable.getFirst(), CKEDITOR.POSITION_BEFORE_END );
400+
range.select();
401+
402+
// Since allowedContent is 'br' auto paragraphing should not be performed.
403+
assert.areEqual( CKEDITOR.ENTER_P, editable.enterMode, 'Enter mode should be CKEDTIOR.ENTER_P.' );
404+
assert.areEqual( 'foo', editable.getData(), 'Test data should not be changed.' );
405+
} );
406+
} );
407+
},
408+
294409
'test nestedEditable.setData - data processor integration': function() {
295410
var editor = this.editor,
296411
data = '<p>Foo</p><div data-widget="testsetdata1" id="w1"><p>A</p><p id="foo">B</p></div>';
@@ -1383,4 +1498,4 @@
13831498
} );
13841499
}
13851500
} );
1386-
} )();
1501+
} )();

0 commit comments

Comments
 (0)