virtualtesteditor.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import StandardEditor from '/ckeditor5/editor/standardeditor.js';
  6. import HtmlDataProcessor from '/ckeditor5/engine/dataprocessor/htmldataprocessor.js';
  7. /**
  8. * A simple editor implementation useful for testing the engine part of the features.
  9. * It contains full data pipepilne and the engine pipeline but without rendering to DOM.
  10. *
  11. * Should work in Node.js. If not now, then in the future :).
  12. *
  13. * @memberOf tests.ckeditor5._utils
  14. */
  15. export default class VirtualTestEditor extends StandardEditor {
  16. constructor( config ) {
  17. super( null, config );
  18. this.document.createRoot();
  19. this.editing.createRoot( 'div' );
  20. this.data.processor = new HtmlDataProcessor();
  21. }
  22. /**
  23. * Creates a virtual, element-less editor instance.
  24. *
  25. * @param {Object} config See {@link ckeditor5.editor.StandardEditor}'s param.
  26. * @returns {Promise} Promise resolved once editor is ready.
  27. * @returns {ckeditor5.editor.VirtualTestEditor} return.editor The editor instance.
  28. */
  29. static create( config ) {
  30. return new Promise( ( resolve ) => {
  31. const editor = new this( config );
  32. resolve(
  33. editor.initPlugins()
  34. .then( () => editor )
  35. );
  36. } );
  37. }
  38. }