Skip to content

Commit

Permalink
Merge pull request #7308 from ckeditor/i/6007
Browse files Browse the repository at this point in the history
Feature (markdown-gfm): Introduced the `Markdown` plugin. Closes #6007.
  • Loading branch information
jodator authored Aug 17, 2020
2 parents e876bc7 + d989e84 commit 7cd5fc1
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articleplugi
import EasyImage from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud-services-config';

import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';

function Markdown( editor ) {
editor.data.processor = new GFMDataProcessor( editor.editing.view.document );
}
import Markdown from '@ckeditor/ckeditor5-markdown-gfm/src/markdown';

ClassicEditor
.create( document.querySelector( '#snippet-markdown' ), {
Expand Down
9 changes: 2 additions & 7 deletions packages/ckeditor5-markdown-gfm/docs/features/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ To enable this data processor in your editor install the [`@ckeditor/ckeditor5-m
npm install --save @ckeditor/ckeditor5-markdown-gfm
```

Then, you can enable this data processor by creating a simple plugin which will load it:
Then, you can enable this data processor by using {@link module:markdown-gfm/markdown~Markdown} plugin which will change default {@link module:engine/dataprocessor/dataprocessor~DataProcessor data processor} with {@link module:markdown-gfm/gfmdataprocessor~GFMDataProcessor}:

```js
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
Expand All @@ -41,12 +41,7 @@ import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';
// ...

import GFMDataProcessor from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';

// Simple plugin which loads the data processor.
function Markdown( editor ) {
editor.data.processor = new GFMDataProcessor( editor.editing.view.document );
}
import Markdown from '@ckeditor/ckeditor5-markdown-gfm/src/markdown';

ClassicEditor
.create( document.querySelector( '#snippet-markdown' ), {
Expand Down
1 change: 1 addition & 0 deletions packages/ckeditor5-markdown-gfm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"ckeditor5-plugin"
],
"dependencies": {
"@ckeditor/ckeditor5-core": "^21.0.0",
"@ckeditor/ckeditor5-engine": "^21.0.0",
"marked": "^0.7.0",
"turndown": "^6.0.0",
Expand Down
36 changes: 36 additions & 0 deletions packages/ckeditor5-markdown-gfm/src/markdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @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( editor.data.viewDocument );
}

/**
* @inheritDoc
*/
static get pluginName() {
return 'Markdown';
}
}
26 changes: 26 additions & 0 deletions packages/ckeditor5-markdown-gfm/tests/markdown.js
Original file line number Diff line number Diff line change
@@ -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.
} );
} );
} );
88 changes: 51 additions & 37 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -959,10 +959,10 @@
style-loader "^1.2.1"
webpack "^4.43.0"

"@ckeditor/ckeditor5-dev-utils@^20.0.0":
version "20.0.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-dev-utils/-/ckeditor5-dev-utils-20.0.0.tgz#f4d467845b7d2a859edb41acf5297f693feed72d"
integrity sha512-dJTrmIixAgWrozC9JlMg8GOCXd5v36Wnat8auFTvrUnwf5DM8fGLZ1S+XXhYfOfQTCV8wxwSv+aC3FUHLcHy1A==
"@ckeditor/ckeditor5-dev-utils@>=13.0.0", "@ckeditor/ckeditor5-dev-utils@^23.1.1":
version "23.1.1"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-dev-utils/-/ckeditor5-dev-utils-23.1.1.tgz#bf758fb798ca1205e73cbbdbeaeae2eee02fff2c"
integrity sha512-2Oq6ycNhCX53pTaVH4rXCZ5SedYOI4VIrs2p1kEPpnP5dSMQG3v1aoYee4+NWJKD0mUUFyYjPtvPeA2PPI4Urg==
dependencies:
acorn "^6.2.1"
acorn-walk "^6.2.0"
Expand All @@ -980,10 +980,10 @@
shelljs "^0.8.1"
through2 "^3.0.1"

"@ckeditor/ckeditor5-dev-utils@^23.1.1":
version "23.1.1"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-dev-utils/-/ckeditor5-dev-utils-23.1.1.tgz#bf758fb798ca1205e73cbbdbeaeae2eee02fff2c"
integrity sha512-2Oq6ycNhCX53pTaVH4rXCZ5SedYOI4VIrs2p1kEPpnP5dSMQG3v1aoYee4+NWJKD0mUUFyYjPtvPeA2PPI4Urg==
"@ckeditor/ckeditor5-dev-utils@^20.0.0":
version "20.0.0"
resolved "https://registry.yarnpkg.com/@ckeditor/ckeditor5-dev-utils/-/ckeditor5-dev-utils-20.0.0.tgz#f4d467845b7d2a859edb41acf5297f693feed72d"
integrity sha512-dJTrmIixAgWrozC9JlMg8GOCXd5v36Wnat8auFTvrUnwf5DM8fGLZ1S+XXhYfOfQTCV8wxwSv+aC3FUHLcHy1A==
dependencies:
acorn "^6.2.1"
acorn-walk "^6.2.0"
Expand Down Expand Up @@ -1189,9 +1189,9 @@
universal-user-agent "^6.0.0"

"@octokit/graphql@^4.3.1":
version "4.5.3"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.3.tgz#d5ff0d4a8a33e98614a2a7359dac98bc285e062f"
integrity sha512-JyYvi3j2tOb5ofASEpcg1Advs07H+Ag+I+ez7buuZfNVAmh1IYcDTuxd4gnYH8S2PSGu+f5IdDGxMmkK+5zsdA==
version "4.5.4"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.5.4.tgz#c9ef75b0406ebf195bf5f4ed2304a77ed7df27c7"
integrity sha512-ITpZ+dQc0cXAW1FmDkHJJM+8Lb6anUnin0VB5hLBilnYVdLC0ICFU/KIvT7OXfW9S81DE3U4Vx2EypDG1OYaPA==
dependencies:
"@octokit/request" "^5.3.0"
"@octokit/types" "^5.0.0"
Expand Down Expand Up @@ -1595,6 +1595,20 @@
"@webassemblyjs/wast-parser" "1.9.0"
"@xtuc/long" "4.2.2"

"@webspellchecker/wproofreader-ckeditor5@^1.0.5":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@webspellchecker/wproofreader-ckeditor5/-/wproofreader-ckeditor5-1.0.5.tgz#f6652f7705fd4132ed7adae419acd9d6998895df"
integrity sha512-uw5FfEZcWRagCO26yRaXzbV9xyjFR3VRGzWexlp465ZFwm0At9KtXUrvbkMF+RLhuKmXvo4df1v957pG103dWg==
dependencies:
"@ckeditor/ckeditor5-basic-styles" ">=16.0.0"
"@ckeditor/ckeditor5-dev-utils" ">=13.0.0"
"@ckeditor/ckeditor5-editor-classic" ">=16.0.0"
"@ckeditor/ckeditor5-essentials" ">=16.0.0"
"@ckeditor/ckeditor5-heading" ">=16.0.0"
"@ckeditor/ckeditor5-list" ">=16.0.0"
"@ckeditor/ckeditor5-paragraph" ">=16.0.0"
"@ckeditor/ckeditor5-theme-lark" ">=16.0.0"

"@wiris/mathtype-ckeditor5@7.20.0":
version "7.20.0"
resolved "https://registry.yarnpkg.com/@wiris/mathtype-ckeditor5/-/mathtype-ckeditor5-7.20.0.tgz#fcbefc2c6934d2ca94721021f05fb912880f4142"
Expand Down Expand Up @@ -1743,9 +1757,9 @@ ajv@^5.0.0:
json-schema-traverse "^0.3.0"

ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3:
version "6.12.3"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706"
integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==
version "6.12.4"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.4.tgz#0614facc4522127fa713445c6bfd3ebd376e2234"
integrity sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==
dependencies:
fast-deep-equal "^3.1.1"
fast-json-stable-stringify "^2.0.0"
Expand Down Expand Up @@ -2378,9 +2392,9 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.4.0:
integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==

bn.js@^5.1.1:
version "5.1.2"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.2.tgz#c9686902d3c9a27729f43ab10f9d79c2004da7b0"
integrity sha512-40rZaf3bUNKTVYu9sIeeEGOg7g14Yvnj9kH7b50EiwX0Q7A6umbvfI5tvHaOERH0XigqKkfLkFQxzb4e6CIXnA==
version "5.1.3"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==

body-parser@^1.19.0:
version "1.19.0"
Expand Down Expand Up @@ -2722,9 +2736,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"

caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001111:
version "1.0.30001113"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001113.tgz#22016ab55b5a8b04fa00ca342d9ee1b98df48065"
integrity sha512-qMvjHiKH21zzM/VDZr6oosO6Ri3U0V2tC015jRXjOecwQCJtsU5zklTNTk31jQbIOP8gha0h1ccM/g0ECP+4BA==
version "1.0.30001114"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001114.tgz#2e88119afb332ead5eaa330e332e951b1c4bfea9"
integrity sha512-ml/zTsfNBM+T1+mjglWRPgVsu2L76GAaADKX5f4t0pbhttEp0WMawJsHDYlFkVZkoA+89uvBRrVrEE4oqenzXQ==

caseless@~0.12.0:
version "0.12.0"
Expand Down Expand Up @@ -4414,9 +4428,9 @@ eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.3.0:
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==

eslint@^7.1.0:
version "7.6.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.6.0.tgz#522d67cfaea09724d96949c70e7a0550614d64d6"
integrity sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==
version "7.7.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.7.0.tgz#18beba51411927c4b64da0a8ceadefe4030d6073"
integrity sha512-1KUxLzos0ZVsyL81PnRN335nDtQ8/vZUD6uMtWbF+5zDtjKcsklIi78XoE0MVL93QvWTu+E5y44VyyCsOMBrIg==
dependencies:
"@babel/code-frame" "^7.0.0"
ajv "^6.10.0"
Expand Down Expand Up @@ -7020,9 +7034,9 @@ lint-staged@^10.2.6:
stringify-object "^3.3.0"

listr2@^2.1.0:
version "2.5.1"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-2.5.1.tgz#f265dddf916c8a9b475437b34ae85a7d8f495c7a"
integrity sha512-qkNRW70SwfwWLD/eiaTf2tfgWT/ZvjmMsnEFJOCzac0cjcc8rYHDBr1eQhRxopj6lZO7Oa5sS/pZzS6q+BsX+w==
version "2.6.0"
resolved "https://registry.yarnpkg.com/listr2/-/listr2-2.6.0.tgz#788a3d202978a1b8582062952cbc49272c8e206a"
integrity sha512-nwmqTJYQQ+AsKb4fCXH/6/UmLCEDL1jkRAdSn9M6cEUzoRGrs33YD/3N86gAZQnGZ6hxV18XSdlBcJ1GTmetJA==
dependencies:
chalk "^4.1.0"
cli-truncate "^2.1.0"
Expand Down Expand Up @@ -7203,9 +7217,9 @@ lodash.uniq@^4.5.0:
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=

lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@~4.17.10, lodash@~4.17.14:
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==

log-driver@^1.2.7:
version "1.2.7"
Expand Down Expand Up @@ -7751,10 +7765,10 @@ minipass@^3.0.0, minipass@^3.1.1:
dependencies:
yallist "^4.0.0"

minizlib@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.0.tgz#fd52c645301ef09a63a2c209697c294c6ce02cf3"
integrity sha512-EzTZN/fjSvifSX0SlqUERCN39o6T40AMarPbv0MrarSFtIITCBh7bi+dU8nxGFHuqs9jdIAeoYoKuQAAASsPPA==
minizlib@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==
dependencies:
minipass "^3.0.0"
yallist "^4.0.0"
Expand Down Expand Up @@ -11216,14 +11230,14 @@ tar@^2.0.0:
inherits "2"

tar@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.0.2.tgz#5df17813468a6264ff14f766886c622b84ae2f39"
integrity sha512-Glo3jkRtPcvpDlAs/0+hozav78yoXKFr+c4wgw62NNMO3oo4AaJdCo21Uu7lcwr55h39W2XD1LMERc64wtbItg==
version "6.0.5"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.0.5.tgz#bde815086e10b39f1dcd298e89d596e1535e200f"
integrity sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==
dependencies:
chownr "^2.0.0"
fs-minipass "^2.0.0"
minipass "^3.0.0"
minizlib "^2.1.0"
minizlib "^2.1.1"
mkdirp "^1.0.3"
yallist "^4.0.0"

Expand Down

0 comments on commit 7cd5fc1

Please sign in to comment.