8
0

utils.js 838 B

1234567891011121314151617181920212223242526
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module enter/utils
  7. */
  8. /**
  9. * Returns attributes that should be preserved on the enter key.
  10. *
  11. * Filtering is realized based on `copyOnEnter` attribute property. Read more about attribute properties
  12. * {@link module:engine/model/schema~Schema#setAttributeProperties here}.
  13. *
  14. * @param {module:engine/model/schema~Schema} schema
  15. * @param {Iterable.<*>} allAttributes attributes to filter.
  16. * @returns {Iterable.<*>}
  17. */
  18. export function* getCopyOnEnterAttributes( schema, allAttributes ) {
  19. for ( const attribute of allAttributes ) {
  20. if ( attribute && schema.getAttributeProperties( attribute[ 0 ] ).copyOnEnter ) {
  21. yield attribute;
  22. }
  23. }
  24. }