markdown.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. import CodeBlockEditing from '../src/codeblockediting';
  6. import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
  7. import Enter from '@ckeditor/ckeditor5-enter/src/enter';
  8. import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
  9. import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
  10. import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
  11. // A simple plugin that enables the GFM data processor.
  12. class Markdown extends Plugin {
  13. constructor( editor ) {
  14. super( editor );
  15. editor.data.processor = new GFMDataProcessor( editor.data.viewDocument );
  16. }
  17. }
  18. function getEditor( initialData = '' ) {
  19. return ClassicTestEditor
  20. .create( initialData, {
  21. plugins: [ Markdown, CodeBlockEditing, Enter, Paragraph ]
  22. } );
  23. }
  24. describe( 'Markdown', () => {
  25. it( 'should be loaded and returned from the editor', () => {
  26. const markdown =
  27. '```\n' +
  28. 'test()\n' +
  29. '```';
  30. return getEditor( markdown ).then( editor => {
  31. // This is to account to the new behavior of the markdown plugin after its code revamp.
  32. // This cleanup could be removed later on, once the revamp is merged.
  33. let data = editor.getData();
  34. data = data.replace( 'plaintext', '' );
  35. expect( data ).to.equal( markdown );
  36. editor.destroy(); // Tests cleanup.
  37. } );
  38. } );
  39. } );