Skip to content

Commit 1baa4c5

Browse files
committed
Merge branch 't/10644'
2 parents e16981c + ba1f401 commit 1baa4c5

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CKEditor 4 Changelog
44
## CKEditor 4.1.3
55

66
* Added new translation: Indonesian.
7+
* [#10644](http://dev.ckeditor.com/ticket/10644): Fixed critical bug when pasting plain text in Blink based browsers.
78
* [#5189](http://dev.ckeditor.com/ticket/5189): Find/Replace dialog window: rename "Cancel" button to "Close".
89
* [#10562](http://dev.ckeditor.com/ticket/10562): [Housekeeping] Unified CSS gradient filter formats in the Moono skin.
910
* [#10537](http://dev.ckeditor.com/ticket/10537): ACF should register a default rule for [config.shiftEnterMode](http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-shiftEnterMode).

plugins/clipboard/plugin.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@
660660
cancel = function( evt ) {
661661
evt.cancel();
662662
},
663-
ff3x = CKEDITOR.env.gecko && CKEDITOR.env.version <= 10902;
663+
ff3x = CKEDITOR.env.gecko && CKEDITOR.env.version <= 10902,
664+
blurListener;
664665

665666
// Avoid recursions on 'paste' event or consequent paste too fast. (#5730)
666667
if ( doc.getById( 'cke_pastebin' ) )
@@ -679,7 +680,7 @@
679680
// what is indistinguishable from pasted <br> (copying <br> in Opera isn't possible,
680681
// but it can be copied from other browser).
681682
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 );
683684

684685
pastebin.setAttribute( 'id', 'cke_pastebin' );
685686

@@ -688,6 +689,7 @@
688689
pastebin.appendBogus();
689690

690691
var containerOffset = 0,
692+
offsetParent,
691693
win = doc.getWindow();
692694

693695
// Seems to be the only way to avoid page scroll in Fx 3.x.
@@ -701,8 +703,19 @@
701703
editable.append( pastebin );
702704
// Style pastebin like .cke_editable, to minimize differences between origin and destination. (#9754)
703705
pastebin.addClass( 'cke_editable' );
706+
704707
// 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+
}
706719
} else {
707720
// Opera and IE doesn't allow to append to html element.
708721
editable.getAscendant( CKEDITOR.env.ie || CKEDITOR.env.opera ? 'body' : 'html', 1 ).append( pastebin );
@@ -739,6 +752,12 @@
739752

740753
editor.on( 'selectionChange', cancel, null, null, 0 );
741754

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+
742761
// Temporarily move selection to the pastebin.
743762
isEditingHost && pastebin.focus();
744763
var range = new CKEDITOR.dom.range( pastebin );
@@ -750,7 +769,7 @@
750769
// this selection will be restored. We overwrite stored selection, so it's restored
751770
// in pastebin. (#9552)
752771
if ( CKEDITOR.env.ie ) {
753-
var blurListener = editable.once( 'blur', function( evt ) {
772+
blurListener = editable.once( 'blur', function( evt ) {
754773
editor.lockSelection( selPastebin );
755774
} );
756775
}

0 commit comments

Comments
 (0)