editoruiview.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import View from '../view.js';
  6. import Template from '../template.js';
  7. /**
  8. * The editor UI view class. Base class for the editor main views.
  9. *
  10. * See {@link ui.editorUI.EditorUI}.
  11. *
  12. * @memberOf ui.editorUI
  13. * @extends ui.View
  14. */
  15. export default class EditorUIView extends View {
  16. /**
  17. * Creates an instance of the editor UI view class.
  18. *
  19. * @param {utils.Locale} [locale] The {@link core.editor.Editor#locale editor's locale} instance.
  20. */
  21. constructor( locale ) {
  22. super( locale );
  23. this._createBodyRegion();
  24. /**
  25. * The element holding elements of the 'body' region.
  26. *
  27. * @private
  28. * @member {HTMLElement} ui.editorUI.EditorUIView#_bodyRegionContainer
  29. */
  30. }
  31. destroy() {
  32. this._bodyRegionContainer.remove();
  33. this._bodyRegionContainer = null;
  34. }
  35. /**
  36. * Creates and appends to `<body>` the 'body' region container.
  37. *
  38. * @private
  39. */
  40. _createBodyRegion() {
  41. const bodyElement = document.createElement( 'div' );
  42. document.body.appendChild( bodyElement );
  43. new Template( {
  44. attributes: {
  45. class: 'ck-body ck-reset-all'
  46. }
  47. } ).apply( bodyElement );
  48. this._bodyRegionContainer = bodyElement;
  49. this.register( 'body', () => bodyElement );
  50. }
  51. }