Skip to content
Permalink
Browse files

Merge pull request #350 from cksource/t/16982

Enable clipboard API for Safari.
  • Loading branch information...
mlewand committed Apr 25, 2017
2 parents 2062bfc + 8fbc222 commit 87ff1a5046da13468d6dccab80b6a42f6d0edbdd
Showing with 26 additions and 2 deletions.
  1. +1 −0 CHANGES.md
  2. +6 −1 plugins/clipboard/plugin.js
  3. +19 −1 tests/plugins/clipboard/paste.js
@@ -53,6 +53,7 @@ Other Changes:
* Fixed: The DOM Exception after click "Remove Language" on a selected word with enabled Language plugin in SCAYT.
* [#16958](http://dev.ckeditor.com/ticket/16958): Switched default MathJax CDN provider from `cdn.mathjax.org` to [cdnjs](https://cdnjs.com/), due to closing of `cdn.mathjax.org` scheduled on April 30, 2017.
* [#16954](http://dev.ckeditor.com/ticket/16954): Remove paste dialog.
* [#16982](http://dev.ckeditor.com/ticket/16982): Latest Safari now supports enhanced clipboard API introduced in CKEditor 4.5.0.

## CKEditor 4.6.2

@@ -1577,7 +1577,12 @@
return true;
}

// In Safari and IE HTML data is not available though the Clipboard API.
// Safari fixed clipboard in 10.1 (https://bugs.webkit.org/show_bug.cgi?id=19893) (#16982).
if ( CKEDITOR.env.safari && CKEDITOR.env.version >= 603 ) {
return true;
}

// In older Safari and IE HTML data is not available though the Clipboard API.
// In Edge things are a bit messy at the moment -
// https://connect.microsoft.com/IE/feedback/details/1572456/edge-clipboard-api-text-html-content-messed-up-in-event-clipboarddata
// It is safer to use the paste bin in unknown cases.
@@ -49,6 +49,8 @@
} );
}

var trustySafari = CKEDITOR.env.safari && CKEDITOR.env.version >= 603;

bender.test( {
setUp: function() {
// Force result data un-formatted.
@@ -1335,6 +1337,22 @@
assert.isTrue( canClipboardApiBeTrusted( dataTransfer ), 'Clipboard API should be used in Chrome.' );
},

'test canClipboardApiBeTrusted in Safari': function() {
if ( !trustySafari ) {
assert.ignore();
}

var canClipboardApiBeTrusted = CKEDITOR.plugins.clipboard.canClipboardApiBeTrusted,
nativeData = bender.tools.mockNativeDataTransfer();

nativeData.setData( 'text/html', '<b>foo</b>' );

var evt = { data: { $: { clipboardData: nativeData } } },
dataTransfer = CKEDITOR.plugins.clipboard.initPasteDataTransfer( evt );

assert.isTrue( canClipboardApiBeTrusted( dataTransfer ), 'Clipboard API should be marked as trusted.' );
},

'test canClipboardApiBeTrusted in Android Chrome (no dataTransfer support)': function() {
if ( !CKEDITOR.env.chrome ) {
assert.ignore();
@@ -1398,7 +1416,7 @@
},

'test canClipboardApiBeTrusted on other browser': function() {
if ( CKEDITOR.env.chrome || CKEDITOR.env.gecko ) {
if ( CKEDITOR.env.chrome || CKEDITOR.env.gecko || trustySafari ) {
assert.ignore();
}

0 comments on commit 87ff1a5

Please sign in to comment.
You can’t perform that action at this time.