editoruiview.js 1.3 KB

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