view-to-model-converters.js 695 B

12345678910111213141516171819202122232425
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. 'use strict';
  6. import ModelDocumentFragment from '../treemodel/documentfragment.js';
  7. import ModelText from '../treemodel/text.js';
  8. export function convertChildren() {
  9. return ( data, controller ) => {
  10. if ( !data.output && controller.consumable.test( data.input ) ) {
  11. data.output = new ModelDocumentFragment( controller.convertChildren( data.input, data.context ) );
  12. }
  13. };
  14. }
  15. export function convertText() {
  16. return ( data, controller ) => {
  17. if ( controller.consumable.consume( data.input ) ) {
  18. data.output = new ModelText( data.input.data );
  19. }
  20. };
  21. }