virtualtesteditor.js 1.3 KB

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