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 ] ) → dataTransferCKEDITOR.plugins.clipboard.dataTransfer#constructorCreates a class instance.
Parameters
[ nativeDataTransfer ] : ObjectA native data transfer object.
[ editor ] : editorThe 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#cacheDataCopies 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 ] ) → StringCKEDITOR.plugins.clipboard.dataTransfer#getDataFacade for the native
getDatamethod.Parameters
type : StringThe type of data to retrieve.
[ getNative ] : BooleanIndicates if the whole, original content of the dataTransfer should be returned. Introduced in CKEditor 4.7.0.
Defaults to
false
Returns
Stringtype Stored data for the given type or an empty string if the data for that type does not exist.
getFile( i ) → FileCKEDITOR.plugins.clipboard.dataTransfer#getFilegetFilesCount() → NumberCKEDITOR.plugins.clipboard.dataTransfer#getFilesCountgetTransferType( targetEditor ) → NumberCKEDITOR.plugins.clipboard.dataTransfer#getTransferTypeGets the data transfer type.
Parameters
targetEditor : editorThe drop/paste target editor instance.
Returns
NumberPossible values: CKEDITOR.DATA_TRANSFER_INTERNAL, CKEDITOR.DATA_TRANSFER_CROSS_EDITORS, CKEDITOR.DATA_TRANSFER_EXTERNAL.
-
isEmpty() → BooleanCKEDITOR.plugins.clipboard.dataTransfer#isEmptyChecks if the data transfer contains any data.
Returns
Booleantrueif the object contains no data.
-
Checks if the data transfer contains only files.
Returns
Booleantrueif the object contains only files.
setData( type, value )CKEDITOR.plugins.clipboard.dataTransfer#setDataFacade for the native
setDatamethod.Parameters
type : StringThe type of data to retrieve.
value : StringThe data to add.
-
Stores dataTransfer id in native data transfer object so it can be retrieved by other events.
private
_getImageFromClipboard() → FileCKEDITOR.plugins.clipboard.dataTransfer#_getImageFromClipboardWhen the content of the clipboard is pasted in Chrome, the clipboard data object has an empty
filesproperty, but it is possible to get the file asitems[0].getAsFile();(https://dev.ckeditor.com/ticket/12961).Returns
FileFile instance or
nullif 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