DataApiMixin (core/editor/utils)
@ckeditor/ckeditor5-core/src/editor/utils/dataapimixin
Implementation of the DataApi.
Filtering
Methods
-
getData( [ options ] = { [options.rootName], [options.trim] } ) → Stringmodule:core/editor/utils/dataapimixin~DataApiMixin#getDataGets 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 the 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 DOMDocumentFragmentif you consider this the right format for you.Parameters
[ options ] : ObjectAdditional configuration for the retrieved data. Editor features may introduce more configuration options that can be set through this parameter.
Properties[ options.rootName ] : StringRoot name.
Defaults to
'main'[ options.trim ] : StringWhether returned data should be trimmed. This option is set to
'empty'by default, which means that whenever editor content is considered empty, an empty string is returned. To turn off trimming use'none'. In such cases exact content will be returned (for example'<p> </p>'for an empty editor).Defaults to
'empty'
Returns
StringOutput data.
-
setData( data )module:core/editor/utils/dataapimixin~DataApiMixin#setDataSets 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 the 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 DOMDocumentFragmentif you consider this the right format for you.Parameters
data : StringInput data.
Every day, we work hard to keep our documentation complete. Have you spotted outdated information? Is something missing? Please report it via our issue tracker.