classictesteditor.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. import BoxedEditorUI from '/ckeditor5/ui/editorui/boxed/boxededitorui.js';
  9. import BoxedEditorUIView from '/ckeditor5/ui/editorui/boxed/boxededitoruiview.js';
  10. /**
  11. * A simplified classic editor. Useful for testing features.
  12. *
  13. * @memberOf tests.ckeditor5._utils
  14. * @extends ckeditor5.editor.StandardEditor
  15. */
  16. export default class ClassicTestEditor extends StandardEditor {
  17. /**
  18. * @inheritDoc
  19. */
  20. constructor( element, config ) {
  21. super( element, config );
  22. this.document.createRoot();
  23. this.editing.createRoot( 'div' );
  24. this.data.processor = new HtmlDataProcessor();
  25. this.ui = new BoxedEditorUI( this );
  26. this.ui.view = new BoxedEditorUIView( this.locale );
  27. }
  28. /**
  29. * @inheritDoc
  30. */
  31. destroy() {
  32. return this.ui.destroy()
  33. .then( () => super.destroy() );
  34. }
  35. /**
  36. * @inheritDoc
  37. */
  38. static create( element, config ) {
  39. return new Promise( ( resolve ) => {
  40. const editor = new this( element, config );
  41. resolve(
  42. editor.initPlugins()
  43. .then( () => editor.ui.init() )
  44. .then( () => editor.loadDataFromEditorElement() )
  45. .then( () => editor )
  46. );
  47. } );
  48. }
  49. }