Report an issue
Class

CKEDITOR.plugins.clipboard.dataTransfer

class since 4.5.0

Facade for the native dataTransfer/clipboadData object to hide all differences between browsers.

Filtering

Properties

  • readonly

    $ : Object

    A native DOM event object.

  • readonly

    id : String

    Data transfer ID used to bind all dataTransfer objects based on the same event (e.g. in drag and drop events).

  • readonly

    sourceEditor : editor

    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

    _ : Object

    Private properties and methods.

Methods

  • constructor( [ nativeDataTransfer ], [ editor ] ) → dataTransfer

    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()

    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

    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

    Gets the file at the index given.

    Parameters

    i : Number

    Index.

    Returns

    File

    File instance.

  • getFilesCount() → Number

    Gets the number of files in the dataTransfer object.

    Returns

    Number

    The number of files.

  • getTransferType( targetEditor ) → Number

    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.

  • since 4.13.1

    getTypes() → String[]

    Returns all MIME types inside the clipboard data.

    Returns

    String[]
  • isEmpty() → Boolean

    Checks if the data transfer contains any data.

    Returns

    Boolean

    true if the object contains no data.

  • since 4.17.0

    isFileTransfer() → Boolean

    Checks if the data transfer contains only files.

    Returns

    Boolean

    true if the object contains only files.

  • setData( type, value )

    Facade for the native setData method.

    Parameters

    type : String

    The type of data to retrieve.

    value : String

    The data to add.

  • since 4.8.0

    storeId()

    Stores dataTransfer id in native data transfer object so it can be retrieved by other events.

  • private

    _getImageFromClipboard() → File

    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 as items[0].getAsFile(); (https://dev.ckeditor.com/ticket/12961).

    Returns

    File

    File instance or null if not found.

  • private

    _stripHtml( html ) → String

    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