Sfoglia il codice sorgente

Introduced the Markdown plugin.

fredck 5 anni fa
parent
commit
41491015a7

+ 1 - 0
packages/ckeditor5-markdown-gfm/package.json

@@ -10,6 +10,7 @@
     "ckeditor5-plugin"
   ],
   "dependencies": {
+    "@ckeditor/ckeditor5-core": "^21.0.0",
     "@ckeditor/ckeditor5-engine": "^21.0.0"
   },
   "engines": {

+ 35 - 0
packages/ckeditor5-markdown-gfm/src/markdown.js

@@ -0,0 +1,35 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+/**
+ * @module markdown-gfm/markdown
+ */
+
+import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
+import GFMDataProcessor from './gfmdataprocessor';
+
+/**
+ * The GitHub Flavored Markdown (GFM) plugin.
+ *
+ * For a detailed overview, check the {@glink features/markdown Markdown feature documentation}.
+ *
+ * @extends module:core/plugin~Plugin
+ */
+export default class Markdown extends Plugin {
+	/**
+	 * @inheritDoc
+	 */
+	constructor( editor ) {
+		super( editor );
+		editor.data.processor = new GFMDataProcessor();
+	}
+
+	/**
+	 * @inheritDoc
+	 */
+	static get pluginName() {
+		return 'Markdown';
+	}
+}

+ 26 - 0
packages/ckeditor5-markdown-gfm/tests/markdown.js

@@ -0,0 +1,26 @@
+/**
+ * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
+ */
+
+import Markdown from '../src/markdown';
+import GFMDataProcessor from '../src/gfmdataprocessor';
+import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
+
+describe( 'Markdown', () => {
+	it( 'has proper name', () => {
+		expect( Markdown.pluginName ).to.equal( 'Markdown' );
+	} );
+
+	it( 'should set editor.data.processor', () => {
+		return ClassicTestEditor
+			.create( '', {
+				plugins: [ Markdown ]
+			} )
+			.then( editor => {
+				expect( editor.data.processor ).to.be.an.instanceof( GFMDataProcessor );
+
+				editor.destroy(); // Tests cleanup.
+			} );
+	} );
+} );