8
0

1.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console:false, document, window */
  6. import ClassicEditor from '/ckeditor5/editor-classic/classic.js';
  7. import { getData as getModelData } from '/ckeditor5/engine/dev-utils/model.js';
  8. import { getData as getViewData } from '/ckeditor5/engine/dev-utils/view.js';
  9. ClassicEditor.create( document.querySelector( '#editor' ), {
  10. features: [ 'enter', 'typing', 'paragraph' ],
  11. toolbar: []
  12. } )
  13. .then( editor => {
  14. window.editor = editor;
  15. editor.document.schema.allow( { name: '$text', inside: '$root' } );
  16. const editable = editor.ui.editableElement;
  17. editor.document.on( 'change', () => {
  18. console.clear();
  19. const modelData = getModelData( editor.document, { withoutSelection: true } );
  20. console.log( 'model:', modelData.replace( /\u00A0/g, '_' ) );
  21. const viewData = getViewData( editor.editing.view, { withoutSelection: true } );
  22. console.log( 'view:', viewData.replace( /\u00A0/g, '_' ) );
  23. console.log( 'dom:', editable.innerHTML );
  24. console.log( 'editor.getData', editor.getData() );
  25. } );
  26. } )
  27. .catch( err => {
  28. console.error( err.stack );
  29. } );