Report an issue
Interface

DataApi (core/editor/utils)

@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin

interface

Interface defining an editor methods for setting and getting data to/from the editor's main root element using the data pipeline.

This interface is not part of the Editor class because one may want to implement an editor with multiple root elements, in which case the methods for setting/getting data will need to be implemented differently.

Filtering

Methods

  • getData() → String

    Gets the data from the editor.

    editor.getData(); // -> '<p>This is editor!</p>'

    By default the editor outputs HTML. This can be controlled by injecting a different data processor. See Markdown output guide for more details.

    Note: Not only is the format of the data configurable, but the type of the getData()'s return value does not have to be a string either. You can e.g. return an object or a DOM DocumentFragment if you consider this the right format for you.

    Returns

    String

    Output data.

  • setData( data )

    Sets the data in the editor.

    editor.setData( '<p>This is editor!</p>' );

    By default the editor accepts HTML. This can be controlled by injecting a different data processor. See Markdown output guide for more details.

    Note: Not only is the format of the data configurable, but the type of the setData()'s parameter does not have to be a string either. You can e.g. accept an object or a DOM DocumentFragment if you consider this the right format for you.

    Parameters

    data : String

    Input data.