Report an issue
Class

CKEDITOR.plugins.clipboard.fallbackDataTransfer

class since 4.8.0

Fallback dataTransfer object which is used together with CKEDITOR.plugins.clipboard.dataTransfer for browsers supporting Clipboard API, but not supporting custom MIME types (Edge 16+, see ckeditor4/issues/#962).

Filtering

Properties

  • private

    _customDataFallbackType : String

    A MIME type used for storing custom MIME types.

    Defaults to 'text/html'

  • private

    _dataTransfer : dataTransfer

    DataTransfer object which internal cache and data transfer objects will be modified if needed.

Static properties

  • private static

    _customTypes : String[]

    Array containing MIME types which are not supported by native setData. Those types are recognized by error which is thrown when using native setData with a given type (see _isUnsupportedMimeTypeError).

    Defaults to []

  • private static

    _isCustomMimeTypeSupported : Boolean

    True if the environment supports custom MIME types in CKEDITOR.plugins.clipboard.dataTransfer.getData and CKEDITOR.plugins.clipboard.dataTransfer.setData methods.

    Introduced to distinguish between browsers which support only some whitelisted types (like text/html, application/xml), but do not support custom MIME types (like cke/id). When the value of this property equals null it means it was not yet initialized.

    This property should not be accessed directly, use isRequired method instead.

Methods

  • constructor( dataTransfer ) → fallbackDataTransfer

    Parameters

    dataTransfer : dataTransfer

    DataTransfer object which internal cache and data transfer objects will be reused.

    Returns

    fallbackDataTransfer
  • getData( type, [ getNative ] ) → String

    Returns the data of the given MIME type if stored in a regular way or in a special comment. If given type is the same as _customDataFallbackType the whole data without special comment is returned.

    Parameters

    type : String
    [ getNative ] : Boolean

    Indicates if the whole, original content of the dataTransfer should be returned.

    Defaults to false

    Returns

    String
  • isRequired() → Boolean

    Whether fallbackDataTransfer object should be used when operating on native dataTransfer. If true is returned, it means custom MIME types are not supported in the current browser (see _isCustomMimeTypeSupported).

    Returns

    Boolean
  • setData( type, value ) → String

    Sets given data in native dataTransfer object. If given MIME type is not supported it uses _customDataFallbackType MIME type to save data using special comment format:

        <!--cke-data:{ type: value }-->
    

    It is important to keep in mind that { type: value } object is stringified (using JSON.stringify) and encoded (using encodeURIComponent).

    Parameters

    type : String
    value : String

    Returns

    String

    The value which was set.

  • private

    _applyDataComment( content, data ) → String

    Creates cke-data comment containing stringified and encoded data object which is prepended to a given content.

    Parameters

    content : String
    data : Object

    Returns

    String
  • private

    _extractDataComment( content ) → Object

    Extracts cke-data comment from the given content.

    Parameters

    content : String

    Returns

    Object

    Returns an object containing extracted data as data and content (without cke-data comment) as content.

    Properties
    data : null

    Object containing MIME type : value pairs or null if cke-data comment is not present.

    content : String

    Regular content without cke-data comment.

  • private

    _getData( type, [ skipCache ] ) → null

    Native getData wrapper.

    Parameters

    type : String
    [ skipCache ] : Boolean

    Defaults to false

    Returns

    null
  • private

    _getFallbackTypeContent() → String

    Returns content stored in _customDataFallbackType. Content is always first retrieved from _dataTransfer cache and then from native dataTransfer object.

    Returns

    String
  • private

    _getFallbackTypeData() → Object

    Returns custom data stored in _customDataFallbackType. Custom data is always first retrieved from _dataTransfer cache and then from native dataTransfer object.

    Returns

    Object
  • private

    _isUnsupportedMimeTypeError( error ) → Boolean

    Whether provided error means that unsupported MIME type was used when calling native dataTransfer.setData method.

    Parameters

    error : Error

    Returns

    Boolean