|
175 | 175 | setupMouseObserver( this );
|
176 | 176 | setupKeyboardObserver( this );
|
177 | 177 | setupDragAndDrop( this );
|
| 178 | + setupNativeCutAndCopy( this ); |
178 | 179 | }
|
179 | 180 |
|
180 | 181 | Repository.prototype = {
|
|
2015 | 2016 | }, null, null, 1 );
|
2016 | 2017 | }
|
2017 | 2018 |
|
| 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 | + |
2018 | 2039 | // Setup selection observer which will trigger:
|
2019 | 2040 | // * widget select & focus on selection change,
|
2020 | 2041 | // * nested editable focus (related properites and classes) on selection change,
|
|
2281 | 2302 | doc = editor.document;
|
2282 | 2303 |
|
2283 | 2304 | // 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. |
2284 | 2307 | if ( doc.getById( 'cke_copybin' ) )
|
2285 | 2308 | return;
|
2286 | 2309 |
|
|
0 commit comments