8
0

classictesteditor.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. export default class ClassicTestEditor extends StandardEditor {
  11. constructor( element, config ) {
  12. super( element, config );
  13. const editableElement = document.createElement( 'div' );
  14. document.body.appendChild( editableElement );
  15. this.document.createRoot();
  16. this.editing.createRoot( editableElement );
  17. this.data.processor = new HtmlDataProcessor();
  18. }
  19. destroy() {
  20. return this.ui.destroy()
  21. .then( () => super.destroy() );
  22. }
  23. static create( element, config ) {
  24. return new Promise( ( resolve ) => {
  25. const editor = new this( element, config );
  26. resolve(
  27. editor._createUI()
  28. .then( () => editor.initPlugins() )
  29. .then( () => editor._initUI() )
  30. .then( () => editor.loadDataFromEditorElement() )
  31. .then( () => editor )
  32. );
  33. } );
  34. }
  35. _createUI() {
  36. const editorUI = new BoxedEditorUI( this );
  37. const editorUIView = new BoxedEditorUIView( editorUI.viewModel, this.locale );
  38. editorUI.view = editorUIView;
  39. this.ui = editorUI;
  40. return Promise.resolve();
  41. }
  42. _initUI() {
  43. return this.ui.init();
  44. }
  45. }