Skip to content

Commit

Permalink
Merge branch 't/12683'
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Nov 19, 2014
2 parents 7eb88f9 + 92fa5be commit d789182
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -10,6 +10,7 @@ New Features:
Fixed Issues:

* [#12506](http://dev.ckeditor.com/ticket/12506): [Safari] Fixed: Can't paste into inline editor if page has `user-select: none` style. Thanks to [shaohua](https://github.com/shaohua)!
* [#12683](http://dev.ckeditor.com/ticket/12683): Fixed: [Filter](http://docs.ckeditor.com/#!/guide/dev_acf) fails to remove custom tags. Thanks to [timselier](https://github.com/timselier)!
* [#12489](http://dev.ckeditor.com/ticket/12423) and [#12491](http://dev.ckeditor.com/ticket/12423): Fixed: Various issues related to restoring selection after making operations on filler char. See the [fixed cases](http://dev.ckeditor.com/ticket/12491#comment:4).
* [#12621](http://dev.ckeditor.com/ticket/12621): Fixed: Cannot remove inline styles (bold, italic, etc.) in empty lines.
* [#12630](http://dev.ckeditor.com/ticket/12630): [Chrome] Fixed: Selection is placed outside paragraph when clicked the New Page button. This patch significantly simplified the way how the initial selection (a selection after contents of the editable is overwritten) is being fixed. That might have fixed many related scenarios on all browsers.
Expand Down
20 changes: 11 additions & 9 deletions core/filter.js
Expand Up @@ -327,7 +327,8 @@

var node, element, check,
toBeChecked = [],
enterTag = enterModeTags[ enterMode || ( this.editor ? this.editor.enterMode : CKEDITOR.ENTER_P ) ];
enterTag = enterModeTags[ enterMode || ( this.editor ? this.editor.enterMode : CKEDITOR.ENTER_P ) ],
parentDtd;

// Remove elements in reverse order - from leaves to root, to avoid conflicts.
while ( ( node = toBeRemoved.pop() ) ) {
Expand All @@ -345,6 +346,9 @@
if ( !element.parent )
continue;

// Handle custom elements as inline elements (#12683).
parentDtd = DTD[ element.parent.name ] || DTD.span;

switch ( check.check ) {
// Check if element itself is correct.
case 'it':
Expand All @@ -359,17 +363,13 @@
// Check if element is in correct context. If not - remove element.
case 'el-up':
// Check if e.g. li is a child of body after ul has been removed.
if ( element.parent.type != CKEDITOR.NODE_DOCUMENT_FRAGMENT &&
!DTD[ element.parent.name ][ element.name ]
)
if ( element.parent.type != CKEDITOR.NODE_DOCUMENT_FRAGMENT && !parentDtd[ element.name ] )
removeElement( element, enterTag, toBeChecked );
break;

// Check if element is in correct context. If not - remove parent.
case 'parent-down':
if ( element.parent.type != CKEDITOR.NODE_DOCUMENT_FRAGMENT &&
!DTD[ element.parent.name ][ element.name ]
)
if ( element.parent.type != CKEDITOR.NODE_DOCUMENT_FRAGMENT && !parentDtd[ element.name ] )
removeElement( element.parent, enterTag, toBeChecked );
break;
}
Expand Down Expand Up @@ -1813,7 +1813,7 @@

var parent = element.parent,
shouldAutoP = parent.type == CKEDITOR.NODE_DOCUMENT_FRAGMENT || parent.name == 'body',
i, child, p;
i, child, p, parentDtd;

for ( i = children.length; i > 0; ) {
child = children[ --i ];
Expand All @@ -1834,12 +1834,14 @@
// Child which doesn't need to be auto paragraphed.
else {
p = null;
parentDtd = DTD[ parent.name ] || DTD.span;

child.insertAfter( element );
// If inserted into invalid context, mark it and check
// after removing all elements.
if ( parent.type != CKEDITOR.NODE_DOCUMENT_FRAGMENT &&
child.type == CKEDITOR.NODE_ELEMENT &&
!DTD[ parent.name ][ child.name ]
!parentDtd[ child.name ]
)
toBeChecked.push( { check: 'el-up', el: child } );
}
Expand Down
9 changes: 9 additions & 0 deletions tests/core/filter/filter.js
Expand Up @@ -861,6 +861,15 @@
// Make sure we reset the enter mode even if test fails.
editors.themed.setActiveEnterMode( null );
}
},

'test filtering custom tags': function() {
var filter = createFilter( 'p bar' );

filter( '<p><bar>bar</bar></p>', '<p><bar>bar</bar></p>' );
filter( '<bar><foo>bar</foo></bar>', '<bar>bar</bar>' );
// #12683
filter( '<bar><h1>bar</h1></bar>', '<p>bar</p>' );
}
};
} )();

0 comments on commit d789182

Please sign in to comment.