|
660 | 660 | cancel = function( evt ) {
|
661 | 661 | evt.cancel();
|
662 | 662 | },
|
663 |
| - ff3x = CKEDITOR.env.gecko && CKEDITOR.env.version <= 10902; |
| 663 | + ff3x = CKEDITOR.env.gecko && CKEDITOR.env.version <= 10902, |
| 664 | + blurListener; |
664 | 665 |
|
665 | 666 | // Avoid recursions on 'paste' event or consequent paste too fast. (#5730)
|
666 | 667 | if ( doc.getById( 'cke_pastebin' ) )
|
|
679 | 680 | // what is indistinguishable from pasted <br> (copying <br> in Opera isn't possible,
|
680 | 681 | // but it can be copied from other browser).
|
681 | 682 | var pastebin = new CKEDITOR.dom.element(
|
682 |
| - editable.is( 'body' ) && !( CKEDITOR.env.ie || CKEDITOR.env.opera ) ? 'body' : 'div', doc ); |
| 683 | + ( CKEDITOR.env.webkit || editable.is( 'body' ) ) && !( CKEDITOR.env.ie || CKEDITOR.env.opera ) ? 'body' : 'div', doc ); |
683 | 684 |
|
684 | 685 | pastebin.setAttribute( 'id', 'cke_pastebin' );
|
685 | 686 |
|
|
688 | 689 | pastebin.appendBogus();
|
689 | 690 |
|
690 | 691 | var containerOffset = 0,
|
| 692 | + offsetParent, |
691 | 693 | win = doc.getWindow();
|
692 | 694 |
|
693 | 695 | // Seems to be the only way to avoid page scroll in Fx 3.x.
|
|
701 | 703 | editable.append( pastebin );
|
702 | 704 | // Style pastebin like .cke_editable, to minimize differences between origin and destination. (#9754)
|
703 | 705 | pastebin.addClass( 'cke_editable' );
|
| 706 | + |
704 | 707 | // Compensate position of offsetParent.
|
705 |
| - containerOffset = ( editable.is( 'body' ) ? editable : CKEDITOR.dom.element.get( pastebin.$.offsetParent ) ).getDocumentPosition().y; |
| 708 | + if ( !editable.is( 'body' ) ) { |
| 709 | + // We're not able to get offsetParent from pastebin (body element), so check whether |
| 710 | + // its parent (editable) is positioned. |
| 711 | + if ( editable.getComputedStyle( 'position' ) != 'static' ) |
| 712 | + offsetParent = editable; |
| 713 | + // And if not - safely get offsetParent from editable. |
| 714 | + else |
| 715 | + offsetParent = CKEDITOR.dom.element.get( editable.$.offsetParent ); |
| 716 | + |
| 717 | + containerOffset = offsetParent.getDocumentPosition().y; |
| 718 | + } |
706 | 719 | } else {
|
707 | 720 | // Opera and IE doesn't allow to append to html element.
|
708 | 721 | editable.getAscendant( CKEDITOR.env.ie || CKEDITOR.env.opera ? 'body' : 'html', 1 ).append( pastebin );
|
|
739 | 752 |
|
740 | 753 | editor.on( 'selectionChange', cancel, null, null, 0 );
|
741 | 754 |
|
| 755 | + // Webkit fill fire blur on editable when moving selection to |
| 756 | + // pastebin (if body is used). Cancel it because it causes incorrect |
| 757 | + // selection lock in case of inline editor. |
| 758 | + if ( CKEDITOR.env.webkit ) |
| 759 | + blurListener = editable.once( 'blur', cancel, null, null, -100 ); |
| 760 | + |
742 | 761 | // Temporarily move selection to the pastebin.
|
743 | 762 | isEditingHost && pastebin.focus();
|
744 | 763 | var range = new CKEDITOR.dom.range( pastebin );
|
|
750 | 769 | // this selection will be restored. We overwrite stored selection, so it's restored
|
751 | 770 | // in pastebin. (#9552)
|
752 | 771 | if ( CKEDITOR.env.ie ) {
|
753 |
| - var blurListener = editable.once( 'blur', function( evt ) { |
| 772 | + blurListener = editable.once( 'blur', function( evt ) { |
754 | 773 | editor.lockSelection( selPastebin );
|
755 | 774 | } );
|
756 | 775 | }
|
|
0 commit comments