58 | | |
| 58 | |
| 59 | // Normalize text range |
| 60 | range.trim( false, true ); |
| 61 | var insertingParent = range.startContainer, |
| 62 | bm, |
| 63 | insertingPoint, |
| 64 | isValid = true; |
| 65 | // Figure out the if insertion point is of valid schema, if not, break the inserting parent. |
| 66 | while( insertingParent.getName() != 'body' && |
| 67 | !CKEDITOR.dtd[ insertingParent.getName() ][ clone.getName() ] ) |
| 68 | { |
| 69 | isValid = false; |
| 70 | // Lazy creating position marker for the breaking. |
| 71 | if( !bm ) |
| 72 | { |
| 73 | bm = range.createBookmark(); |
| 74 | insertingPoint = bm.startNode; |
| 75 | } |
| 76 | insertingParent = insertingParent.getParent(); |
| 77 | } |
| 78 | if( !isValid ) |
| 79 | { |
| 80 | insertingPoint.breakParent( insertingParent.getFirst() ); |
| 81 | range.moveToBookmark( bm ); |
| 82 | } |
| 83 | |