CKEDITOR.plugins.clipboard.dataTransfer
Facade for the native dataTransfer
/clipboadData
object to hide all differences
between browsers.
Filtering
Properties
-
A native DOM event object.
-
Data transfer ID used to bind all dataTransfer objects based on the same event (e.g. in drag and drop events).
-
Source editor — the editor where the drag starts. Might be undefined if the drag starts outside the editor (e.g. when dropping files to the editor).
-
Private properties and methods.
Methods
-
constructor( [ nativeDataTransfer ], [ editor ] ) → dataTransfer
CKEDITOR.plugins.clipboard.dataTransfer#constructor
Creates a class instance.
Parameters
[ nativeDataTransfer ] : Object
A native data transfer object.
[ editor ] : editor
The source editor instance. If the editor is defined, dataValue will be created based on the editor content and the type will be 'html'.
Returns
dataTransfer
-
cacheData()
CKEDITOR.plugins.clipboard.dataTransfer#cacheData
Copies the data from the native data transfer to a private cache. This function is needed because the data from the native data transfer is available only synchronously to the event listener. It is not possible to get the data asynchronously, after a timeout, and the CKEDITOR.editor.paste event is fired asynchronously — hence the need for caching the data.
-
getData( type, [ getNative ] ) → String
CKEDITOR.plugins.clipboard.dataTransfer#getData
Facade for the native
getData
method.Parameters
type : String
The type of data to retrieve.
[ getNative ] : Boolean
Indicates if the whole, original content of the dataTransfer should be returned. Introduced in CKEditor 4.7.0.
Defaults to
false
Returns
String
type Stored data for the given type or an empty string if the data for that type does not exist.
-
getFile( i ) → File
CKEDITOR.plugins.clipboard.dataTransfer#getFile
Gets the file at the index given.
Parameters
i : Number
Index.
Returns
File
File instance.
-
getFilesCount() → Number
CKEDITOR.plugins.clipboard.dataTransfer#getFilesCount
-
getTransferType( targetEditor ) → Number
CKEDITOR.plugins.clipboard.dataTransfer#getTransferType
Gets the data transfer type.
Parameters
targetEditor : editor
The drop/paste target editor instance.
Returns
Number
Possible values: CKEDITOR.DATA_TRANSFER_INTERNAL, CKEDITOR.DATA_TRANSFER_CROSS_EDITORS, CKEDITOR.DATA_TRANSFER_EXTERNAL.
-
-
isEmpty() → Boolean
CKEDITOR.plugins.clipboard.dataTransfer#isEmpty
Checks if the data transfer contains any data.
Returns
Boolean
true
if the object contains no data.
-
Checks if the data transfer contains only files.
Returns
Boolean
true
if the object contains only files.
-
setData( type, value )
CKEDITOR.plugins.clipboard.dataTransfer#setData
Facade for the native
setData
method.Parameters
type : String
The type of data to retrieve.
value : String
The data to add.
-
Stores dataTransfer id in native data transfer object so it can be retrieved by other events.
-
private
_getImageFromClipboard() → File
CKEDITOR.plugins.clipboard.dataTransfer#_getImageFromClipboard
When the content of the clipboard is pasted in Chrome, the clipboard data object has an empty
files
property, but it is possible to get the file asitems[0].getAsFile();
(https://dev.ckeditor.com/ticket/12961).Returns
File
File instance or
null
if not found.
-
This function removes this meta information and returns only the contents of the
<body>
element if found.Various environments use miscellaneous meta tags in HTML clipboard, e.g.
<meta http-equiv="content-type" content="text/html; charset=utf-8">
at the begging of the HTML data.- Surrounding HTML with
<!--StartFragment-->
and<!--EndFragment-->
nested within<html><body>
elements.
Parameters
html : String
Returns
String