|
587 | 587 | evt.preventDefault();
|
588 | 588 | } );
|
589 | 589 |
|
| 590 | + var backspaceOrDelete = { 8:1,46:1 }; |
| 591 | + |
590 | 592 | // Override keystrokes which should have deletion behavior
|
591 | 593 | // on fully selected element . (#4047) (#7645)
|
592 | 594 | this.attachListener( editor, 'key', function( evt ) {
|
|
596 | 598 | var keyCode = evt.data.keyCode, isHandled;
|
597 | 599 |
|
598 | 600 | // Backspace OR Delete.
|
599 |
| - if ( keyCode in { 8:1,46:1 } ) { |
| 601 | + if ( keyCode in backspaceOrDelete ) { |
600 | 602 | var sel = editor.getSelection(),
|
601 | 603 | selected,
|
602 | 604 | range = sel.getRanges()[ 0 ],
|
|
678 | 680 | return !isHandled;
|
679 | 681 | } );
|
680 | 682 |
|
| 683 | + // On IE>=11 we need to fill blockless editable with <br> if it was deleted. |
| 684 | + if ( editor.blockless && CKEDITOR.env.ie && CKEDITOR.env.needsBrFiller ) { |
| 685 | + this.attachListener( this, 'keyup', function( evt ) { |
| 686 | + if ( evt.data.getKeystroke() in backspaceOrDelete && !this.getFirst( isNotEmpty ) ) { |
| 687 | + this.appendBogus(); |
| 688 | + |
| 689 | + // Set the selection before bogus, because IE tends to put it after. |
| 690 | + var range = editor.createRange(); |
| 691 | + range.moveToPosition( this, CKEDITOR.POSITION_AFTER_START ); |
| 692 | + range.select(); |
| 693 | + } |
| 694 | + } ); |
| 695 | + } |
| 696 | + |
681 | 697 | this.attachListener( this, 'dblclick', function( evt ) {
|
682 | 698 | if ( editor.readOnly )
|
683 | 699 | return false;
|
|
807 | 823 | blockLimit = path.blockLimit,
|
808 | 824 | selection = evt.data.selection,
|
809 | 825 | range = selection.getRanges()[ 0 ],
|
810 |
| - enterMode = editor.activeEnterMode; |
811 |
| - |
812 |
| - if ( CKEDITOR.env.gecko ) { |
813 |
| - // v3: check if this is needed. |
814 |
| - // activateEditing( editor ); |
815 |
| - |
816 |
| - // Ensure bogus br could help to move cursor (out of styles) to the end of block. (#7041) |
817 |
| - var pathBlock = path.block || path.blockLimit || path.root, |
818 |
| - lastNode = pathBlock && pathBlock.getLast( isNotEmpty ); |
819 |
| - |
820 |
| - // Check some specialities of the current path block: |
821 |
| - // 1. It is really displayed as block; (#7221) |
822 |
| - // 2. It doesn't end with one inner block; (#7467) |
823 |
| - // 3. It doesn't have bogus br yet. |
824 |
| - if ( pathBlock && pathBlock.isBlockBoundary() && |
825 |
| - !( lastNode && lastNode.type == CKEDITOR.NODE_ELEMENT && lastNode.isBlockBoundary() ) && |
826 |
| - !pathBlock.is( 'pre' ) && !pathBlock.getBogus() ) { |
827 |
| - |
828 |
| - pathBlock.appendBogus(); |
| 826 | + enterMode = editor.activeEnterMode, |
| 827 | + selectionUpdateNeeded; |
| 828 | + |
| 829 | + if ( CKEDITOR.env.gecko || ( CKEDITOR.env.ie && CKEDITOR.env.needsBrFiller ) ) { |
| 830 | + var blockNeedsFiller = needsBrFiller( selection, path ); |
| 831 | + if ( blockNeedsFiller ) { |
| 832 | + blockNeedsFiller.appendBogus(); |
| 833 | + // IE tends to place selection after appended bogus, so we need to |
| 834 | + // select the original range (placed before bogus). |
| 835 | + selectionUpdateNeeded = CKEDITOR.env.ie; |
829 | 836 | }
|
830 | 837 | }
|
831 | 838 |
|
|
848 | 855 |
|
849 | 856 | var fixedBlock = range.fixBlock( true, editor.activeEnterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
|
850 | 857 |
|
851 |
| - // For IE, we should remove any filler node which was introduced before. |
852 |
| - if ( CKEDITOR.env.ie ) { |
| 858 | + // For IE<11, we should remove any filler node which was introduced before. |
| 859 | + if ( !CKEDITOR.env.needsBrFiller ) { |
853 | 860 | var first = fixedBlock.getFirst( isNotEmpty );
|
854 |
| - if ( first && isNbsp( first ) ) { |
| 861 | + if ( first && isNbsp( first ) ) |
855 | 862 | first.remove();
|
856 |
| - } |
857 | 863 | }
|
858 | 864 |
|
859 |
| - range.select(); |
860 |
| - // Cancel this selection change in favor of the next (correct). (#6811) |
| 865 | + selectionUpdateNeeded = 1; |
| 866 | + |
| 867 | + // Cancel this selection change in favor of the next (correct). (#6811) |
861 | 868 | evt.cancel();
|
862 | 869 | }
|
863 | 870 | }
|
| 871 | + |
| 872 | + if ( selectionUpdateNeeded ) |
| 873 | + range.select(); |
| 874 | + } |
| 875 | + |
| 876 | + // Checks whether current selection requires br filler to be appended. |
| 877 | + // @returns Block which needs filler or falsy value. |
| 878 | + function needsBrFiller( selection, path ) { |
| 879 | + // Fake selection does not need filler, because it is fake. |
| 880 | + if ( selection.isFake ) |
| 881 | + return 0; |
| 882 | + |
| 883 | + // Ensure bogus br could help to move cursor (out of styles) to the end of block. (#7041) |
| 884 | + var pathBlock = path.block || path.blockLimit, |
| 885 | + lastNode = pathBlock && pathBlock.getLast( isNotEmpty ); |
| 886 | + |
| 887 | + // Check some specialities of the current path block: |
| 888 | + // 1. It is really displayed as block; (#7221) |
| 889 | + // 2. It doesn't end with one inner block; (#7467) |
| 890 | + // 3. It doesn't have bogus br yet. |
| 891 | + if ( |
| 892 | + pathBlock && pathBlock.isBlockBoundary() && |
| 893 | + !( lastNode && lastNode.type == CKEDITOR.NODE_ELEMENT && lastNode.isBlockBoundary() ) && |
| 894 | + !pathBlock.is( 'pre' ) && !pathBlock.getBogus() |
| 895 | + ) |
| 896 | + return pathBlock; |
864 | 897 | }
|
865 | 898 |
|
866 | 899 | function blockInputClick( evt ) {
|
|
1321 | 1354 | // Auto paragraphing.
|
1322 | 1355 | if ( !nodeData.isBlock && shouldAutoParagraph( that.editor, path.block, path.blockLimit ) && ( fixBlock = autoParagraphTag( that.editor ) ) ) {
|
1323 | 1356 | fixBlock = doc.createElement( fixBlock );
|
1324 |
| - !CKEDITOR.env.ie && fixBlock.appendBogus(); |
| 1357 | + fixBlock.appendBogus(); |
1325 | 1358 | range.insertNode( fixBlock );
|
1326 |
| - if ( !CKEDITOR.env.ie && ( bogus = fixBlock.getBogus() ) ) |
| 1359 | + if ( CKEDITOR.env.needsBrFiller && ( bogus = fixBlock.getBogus() ) ) |
1327 | 1360 | bogus.remove();
|
1328 | 1361 | range.moveToPosition( fixBlock, CKEDITOR.POSITION_BEFORE_END );
|
1329 | 1362 | }
|
|
1427 | 1460 |
|
1428 | 1461 | if ( bogusNeededBlocks ) {
|
1429 | 1462 | // Bring back all block bogus nodes.
|
1430 |
| - while ( ( node = bogusNeededBlocks.pop() ) ) |
1431 |
| - node.append( CKEDITOR.env.ie ? range.document.createText( '\u00a0' ) : range.document.createElement( 'br' ) ); |
| 1463 | + while ( ( node = bogusNeededBlocks.pop() ) ) { |
| 1464 | + if ( CKEDITOR.env.needsBrFiller ) |
| 1465 | + node.appendBogus(); |
| 1466 | + else |
| 1467 | + node.append( range.document.createText( '\u00a0' ) ); |
| 1468 | + } |
1432 | 1469 | }
|
1433 | 1470 |
|
1434 | 1471 | // Eventually merge identical inline elements.
|
|
0 commit comments