| 1 | Index: _source/plugins/styles/plugin.js
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- _source/plugins/styles/plugin.js (revision 3495)
|
|---|
| 4 | +++ _source/plugins/styles/plugin.js (working copy)
|
|---|
| 5 | @@ -283,17 +283,33 @@
|
|---|
| 6 | function applyInlineStyle( range )
|
|---|
| 7 | {
|
|---|
| 8 | var document = range.document;
|
|---|
| 9 | +
|
|---|
| 10 | + var wasCollapsed = range.collapsed;
|
|---|
| 11 |
|
|---|
| 12 | - if ( range.collapsed )
|
|---|
| 13 | + // Get next element after range. If it's a Gecko-appended BR,
|
|---|
| 14 | + // we want to include it in the range, so that the style will
|
|---|
| 15 | + // be maintained in new text added at the end of the line.
|
|---|
| 16 | + var nextElement = range.endContainer.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT );
|
|---|
| 17 | + if ( CKEDITOR.env.gecko && nextElement && nextElement.is( 'br' ))
|
|---|
| 18 | {
|
|---|
| 19 | + if (range.endContainer.type != CKEDITOR.NODE_TEXT || range.endOffset === range.endContainer.getLength() )
|
|---|
| 20 | + range.setEndAfter(nextElement);
|
|---|
| 21 | + }
|
|---|
| 22 | +
|
|---|
| 23 | + if ( wasCollapsed )
|
|---|
| 24 | + {
|
|---|
| 25 | // Create the element to be inserted in the DOM.
|
|---|
| 26 | var collapsedElement = getElement( this, document );
|
|---|
| 27 | +
|
|---|
| 28 | + // Even though the range was collapsed, it may now contain a single BR.
|
|---|
| 29 | + var contents = range.extractContents();
|
|---|
| 30 |
|
|---|
| 31 | // Insert the empty element into the DOM at the range position.
|
|---|
| 32 | range.insertNode( collapsedElement );
|
|---|
| 33 | + contents.appendTo( collapsedElement );
|
|---|
| 34 |
|
|---|
| 35 | // Place the selection right inside the empty element.
|
|---|
| 36 | - range.moveToPosition( collapsedElement, CKEDITOR.POSITION_BEFORE_END );
|
|---|
| 37 | + range.moveToPosition( collapsedElement, CKEDITOR.POSITION_AFTER_START );
|
|---|
| 38 |
|
|---|
| 39 | return;
|
|---|
| 40 | }
|
|---|
| 41 | Index: _source/plugins/enterkey/plugin.js
|
|---|
| 42 | ===================================================================
|
|---|
| 43 | --- _source/plugins/enterkey/plugin.js (revision 3502)
|
|---|
| 44 | +++ _source/plugins/enterkey/plugin.js (working copy)
|
|---|
| 45 | @@ -139,6 +139,11 @@
|
|---|
| 46 | if ( !newBlock )
|
|---|
| 47 | newBlock = doc.createElement( blockTag );
|
|---|
| 48 |
|
|---|
| 49 | + // We need to insert the bogus element inside all of the inline
|
|---|
| 50 | + // style elements, so that clicking after the line or pressing end
|
|---|
| 51 | + // and typing makes the typed text keep these inline styles.
|
|---|
| 52 | + var blockWithBogus = newBlock;
|
|---|
| 53 | +
|
|---|
| 54 | // Recreate the inline elements tree, which was available
|
|---|
| 55 | // before hitting enter, so the same styles will be available in
|
|---|
| 56 | // the new block.
|
|---|
| 57 | @@ -157,12 +162,14 @@
|
|---|
| 58 | element = element.clone();
|
|---|
| 59 | newBlock.moveChildren( element );
|
|---|
| 60 | newBlock.append( element );
|
|---|
| 61 | +
|
|---|
| 62 | + blockWithBogus = element;
|
|---|
| 63 | }
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | if ( !CKEDITOR.env.ie )
|
|---|
| 68 | - newBlock.appendBogus();
|
|---|
| 69 | + blockWithBogus.appendBogus();
|
|---|
| 70 |
|
|---|
| 71 | range.insertNode( newBlock );
|
|---|
| 72 |
|
|---|
| 73 | Index: _source/core/dom/element.js
|
|---|
| 74 | ===================================================================
|
|---|
| 75 | --- _source/core/dom/element.js (revision 3502)
|
|---|
| 76 | +++ _source/core/dom/element.js (working copy)
|
|---|
| 77 | @@ -243,10 +243,11 @@
|
|---|
| 78 | lastChild = lastChild.getPrevious();
|
|---|
| 79 | if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) )
|
|---|
| 80 | {
|
|---|
| 81 | - this.append(
|
|---|
| 82 | - CKEDITOR.env.opera ?
|
|---|
| 83 | - this.getDocument().createText('') :
|
|---|
| 84 | - this.getDocument().createElement( 'br' ) );
|
|---|
| 85 | + var bogusElement = CKEDITOR.env.opera ?
|
|---|
| 86 | + this.getDocument().createText( '' ) :
|
|---|
| 87 | + this.getDocument().createElement( 'br' );
|
|---|
| 88 | + this.append( bogusElement );
|
|---|
| 89 | + return bogusElement;
|
|---|
| 90 | }
|
|---|
| 91 | },
|
|---|
| 92 |
|
|---|
| 93 | Index: _source/core/dom/range.js
|
|---|
| 94 | ===================================================================
|
|---|
| 95 | --- _source/core/dom/range.js (revision 3509)
|
|---|
| 96 | +++ _source/core/dom/range.js (working copy)
|
|---|
| 97 | @@ -1299,6 +1299,17 @@
|
|---|
| 98 |
|
|---|
| 99 | this.collapse( isStart );
|
|---|
| 100 |
|
|---|
| 101 | + // If endContainer is at the end of the document, we need to create
|
|---|
| 102 | + // a bogus element so that the range can include the entire endContainer.
|
|---|
| 103 | + // (This isn't necessary otherwise, but doesn't hurt.)
|
|---|
| 104 | + var tempBogus = null;
|
|---|
| 105 | + if ( !CKEDITOR.env.ie )
|
|---|
| 106 | + {
|
|---|
| 107 | + var endPath = new CKEDITOR.dom.elementPath( this.endContainer );
|
|---|
| 108 | + tempBogus = endPath.blockLimit.appendBogus();
|
|---|
| 109 | +
|
|---|
| 110 | + }
|
|---|
| 111 | +
|
|---|
| 112 | this.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS );
|
|---|
| 113 |
|
|---|
| 114 | this.extractContents().appendTo( fixedBlock );
|
|---|
| 115 | @@ -1307,6 +1318,9 @@
|
|---|
| 116 | if ( !CKEDITOR.env.ie )
|
|---|
| 117 | fixedBlock.appendBogus();
|
|---|
| 118 |
|
|---|
| 119 | + if ( tempBogus )
|
|---|
| 120 | + tempBogus.remove();
|
|---|
| 121 | +
|
|---|
| 122 | this.insertNode( fixedBlock );
|
|---|
| 123 |
|
|---|
| 124 | this.moveToBookmark( bookmark );
|
|---|