Testing helpers
The getData()
and setData()
functions exposed by model developer utilities and view developer utilities are useful development helpers.
They allow for “stringifying” the model and view structures, selections, ranges, and positions as well as for loading them from a string. They are often used when writing tests.
Both tools are designed for prototyping, debugging, and testing purposes. Do not use them in production-grade code.
For instance, to take a peek at the editor model, you could use the getData()
helper:
import { _getModelData } from 'ckeditor5';
// More imports.
// ...
ClassicEditor
.create( '<p>Hello <b>world</b>!</p>' )
.then( editor => {
console.log( getData( editor.model ) );
// -> '<paragraph>[]Hello <$text bold="true">world</$text>!</paragraph>'
} );
See the helper documentation to learn more about useful options.
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.
With the release of version 42.0.0, we have rewritten much of our documentation to reflect the new import paths and features. We appreciate your feedback to help us ensure its accuracy and completeness.