classictesteditor.js 1.4 KB

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