8
0

elementdefinition.jsdoc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module engine/view/elementdefinition
  7. */
  8. /**
  9. * A plain object that describes a view element in a way that a concrete, exact view element could be created from that description.
  10. *
  11. * const viewDefinition = {
  12. * name: 'h1',
  13. * class: [ 'foo', 'bar' ]
  14. * };
  15. *
  16. * Above describes a view element:
  17. *
  18. * <h1 class="foo bar"></h1>
  19. *
  20. * An example with styles and attributes:
  21. *
  22. * const viewDefinition = {
  23. * name: 'span',
  24. * style: {
  25. * 'font-size': '12px',
  26. * 'font-weight': 'bold'
  27. * },
  28. * attribute: {
  29. * 'data-id': '123'
  30. * }
  31. * };
  32. *
  33. * Describes:
  34. *
  35. * <span style="font-size:12px;font-weight:bold" data-id="123"></span>
  36. *
  37. * Elements without attributes can be given simply as a string:
  38. *
  39. * const viewDefinition = 'p';
  40. *
  41. * Which will be treated as:
  42. *
  43. * const viewDefinition = {
  44. * name: 'p'
  45. * };
  46. *
  47. * @typedef {String|Object} module:engine/view/elementdefinition~ElementDefinition
  48. *
  49. * @property {String} name View element name.
  50. * @property {String|Array.<String>} [class] Class name or array of class names to match. Each name can be
  51. * provided in a form of string.
  52. * @property {Object} [style] Object with key-value pairs representing styles. Each object key represents style name.
  53. * Value under that key must be a string.
  54. * @property {Object} [attribute] Object with key-value pairs representing attributes. Each object key represents
  55. * attribute name. Value under that key must be a string.
  56. */