8
0

utils.js 937 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module list/utils
  7. */
  8. /**
  9. * Creates list item {@link module:engine/view/containerelement~ContainerElement}.
  10. *
  11. * @param {module:engine/view/downcastwriter~DowncastWriter} writer The writer instance.
  12. * @returns {module:engine/view/containerelement~ContainerElement}
  13. */
  14. export function createViewListItemElement( writer ) {
  15. const viewItem = writer.createContainerElement( 'li' );
  16. viewItem.getFillerOffset = getFillerOffset;
  17. return viewItem;
  18. }
  19. // Implementation of getFillerOffset for view list item element.
  20. //
  21. // @returns {Number|null} Block filler offset or `null` if block filler is not needed.
  22. function getFillerOffset() {
  23. const hasOnlyLists = !this.isEmpty && ( this.getChild( 0 ).name == 'ul' || this.getChild( 0 ).name == 'ol' );
  24. return this.isEmpty || hasOnlyLists ? 0 : null;
  25. }