rooteditableelement.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module engine/view/rooteditableelement
  7. */
  8. import EditableElement from './editableelement';
  9. const rootNameSymbol = Symbol( 'rootName' );
  10. /**
  11. * Class representing a single root in the data view. A root can be either {@link #isReadOnly editable or read-only}, but
  12. * in both cases it is called "an editable". Roots can contain other {@link module:engine/view/editableelement~EditableElement editable
  13. * elements}
  14. * making them "nested editables".
  15. *
  16. * @extends module:engine/view/editableelement~EditableElement
  17. */
  18. export default class RootEditableElement extends EditableElement {
  19. /**
  20. * Creates root editable element.
  21. *
  22. * @param {module:engine/view/document~Document} document {@link module:engine/view/document~Document} that is an owner of the root.
  23. * @param {String} name Node name.
  24. */
  25. constructor( name ) {
  26. super( name );
  27. /**
  28. * Name of this root inside {@link module:engine/view/document~Document} that is an owner of this root. If no
  29. * other name is set, `main` name is used.
  30. *
  31. * @member {String}
  32. */
  33. this.rootName = 'main';
  34. }
  35. get rootName() {
  36. return this.getCustomProperty( rootNameSymbol );
  37. }
  38. set rootName( rootName ) {
  39. this.setCustomProperty( rootNameSymbol, rootName );
  40. }
  41. }