Skip to content

Commit 176e843

Browse files
committed
Merge branch 't/11082b' into major
2 parents 900177c + 5cd60b6 commit 176e843

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Fixed Issues:
4545
* [#11057](http://dev.ckeditor.com/ticket/11057): Fixed: Regression in #10212 test.
4646
* [#10430](http://dev.ckeditor.com/ticket/10430): Resolve dependence of image plugin if forms plugin.
4747
* [#10911](http://dev.ckeditor.com/ticket/10911): Browser alt hotkeys will no longer be blocked while widget is focused.
48+
* [#11082](http://dev.ckeditor.com/ticket/11082): Selected widget is not copied/cut when using toolbar buttons or context menu.
4849

4950
## CKEditor 4.3 Beta
5051

plugins/widget/plugin.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
setupMouseObserver( this );
176176
setupKeyboardObserver( this );
177177
setupDragAndDrop( this );
178+
setupNativeCutAndCopy( this );
178179
}
179180

180181
Repository.prototype = {
@@ -2015,6 +2016,26 @@
20152016
}, null, null, 1 );
20162017
}
20172018

2019+
// Setup copybin on native copy and cut events in order to handle copy and cut commands
2020+
// if user accepted security alert on IEs.
2021+
// Note: when copying or cutting using keystroke, copySingleWidget will be first executed
2022+
// by the keydown listener. Conflict between two calls will be resolved by copy_bin existence check.
2023+
function setupNativeCutAndCopy( widgetsRepo ) {
2024+
var editor = widgetsRepo.editor;
2025+
2026+
editor.on( 'contentDom', function() {
2027+
var editable = editor.editable();
2028+
2029+
editable.attachListener( editable, 'copy', eventListener );
2030+
editable.attachListener( editable, 'cut', eventListener );
2031+
} );
2032+
2033+
function eventListener( evt ) {
2034+
if ( widgetsRepo.focused )
2035+
copySingleWidget( widgetsRepo.focused, evt.name == 'cut' );
2036+
}
2037+
}
2038+
20182039
// Setup selection observer which will trigger:
20192040
// * widget select & focus on selection change,
20202041
// * nested editable focus (related properites and classes) on selection change,
@@ -2281,6 +2302,8 @@
22812302
doc = editor.document;
22822303

22832304
// We're still handling previous copy/cut.
2305+
// When keystroke is used to copy/cut this will also prevent
2306+
// conflict with copySingleWidget called again for native copy/cut event.
22842307
if ( doc.getById( 'cke_copybin' ) )
22852308
return;
22862309

0 commit comments

Comments
 (0)