Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

DraftJS v0.11.x Support #186

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LICENSE
node_modules
.*
*.gif
*.lock
*.log
*.snap
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"trailingComma": "es5",
"quotes": "single"
"singleQuote": true
}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ script:
- node --version
- yarn --version
- yarn run test
- yarn run flow
cache:
yarn: true
directories:
62 changes: 28 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
draft-js-markdown-plugin
==================================
# draft-js-markdown-plugin

[![Build Status](https://travis-ci.org/withspectrum/draft-js-markdown-plugin.svg?branch=master)](https://travis-ci.org/withspectrum/draft-js-markdown-plugin)
[![npm](https://img.shields.io/npm/v/draft-js-markdown-plugin.svg)][npm]

<!-- [![Coverage Status](https://coveralls.io/repos/github/withspectrum/draft-js-markdown-plugin/badge.svg?branch=master)](https://coveralls.io/github/withspectrum/draft-js-markdown-plugin?branch=master) -->

**IMPORTANT** The current version of `draft-js-markdown-plugin` is updated to work with DraftJS @ `^0.11.0`. Please ensure you've satisfied your peer dependencies in npm/yarn to avoid problems!

An opinionated [DraftJS] plugin for supporting Markdown syntax shortcuts in DraftJS. This plugin works with [DraftJS Plugins], and is a fork of the excellent [`draft-js-markdown-shortcuts-plugin`](https://github.com/ngs/draft-js-markdown-shortcuts-plugin) by [@ngs](https://github.com/ngs). (see [why fork that plugin](#why-fork-the-markdown-shortcuts-plugin) for more info)

![screen](screen.gif)

[View Demo][Demo]
[View Demo][demo]

## Installation

@@ -26,13 +28,12 @@ import createMarkdownPlugin from 'draft-js-markdown-plugin';
import { EditorState } from 'draft-js';

export default class DemoEditor extends Component {

state = {
editorState: EditorState.createEmpty(),
plugins: [createMarkdownPlugin()]
plugins: [createMarkdownPlugin()],
};

onChange = (editorState) => {
onChange = editorState => {
this.setState({
editorState,
});
@@ -62,7 +63,7 @@ import createPrismPlugin from 'draft-js-prism-plugin';
class Editor extends Component {
state = {
plugins: [
// Add the Prism plugin to the plugins array
// Add the Prism plugin to the plugins array
createPrismPlugin({
prism: Prism
}),
@@ -91,7 +92,7 @@ renderLanguageSelect = ({
}) => React.Node
```

Code blocks render a select to switch syntax highlighting - `renderLanguageSelect` is a render function that lets you override how this is rendered.
Code blocks render a select to switch syntax highlighting - `renderLanguageSelect` is a render function that lets you override how this is rendered.

#### Example:

@@ -119,10 +120,10 @@ Dictionary for languages available to code block switcher

```js
const languages = {
js: 'JavaScript'
}
js: 'JavaScript',
};

const markdownPlugin = createMarkdownPlugin({ languages })
const markdownPlugin = createMarkdownPlugin({ languages });
```

### `features`
@@ -144,27 +145,20 @@ features = {
const features = {
inline: ['BOLD'],
block: ['CODE', 'header-one'],
}
const plugin = createMarkdownPlugin({ features })
};
const plugin = createMarkdownPlugin({ features });
```

*Available Inline features*:
_Available Inline features_:

```js
[
'BOLD',
'ITALIC',
'CODE',
'STRIKETHROUGH',
'LINK',
'IMAGE'
]
['BOLD', 'ITALIC', 'CODE', 'STRIKETHROUGH', 'LINK', 'IMAGE'];
```

*Available Block features*:
_Available Block features_:

```js
import { CHECKABLE_LIST_ITEM } from "draft-js-checkable-list-item"
import { CHECKABLE_LIST_ITEM } from 'draft-js-checkable-list-item';
[
'CODE',
'header-one',
@@ -179,7 +173,7 @@ import { CHECKABLE_LIST_ITEM } from "draft-js-checkable-list-item"
// see import statementabove
CHECKABLE_LIST_ITEM,
'blockquote',
]
];
```

### `entityType`
@@ -189,12 +183,12 @@ To interoperate this plugin with other DraftJS plugins, i.e. [`draft-js-plugins`
#### Example:

```js
import createMarkdownPlugin from "draft-js-markdown-plugin";
import createFocusPlugin from "draft-js-focus-plugin";
import createImagePlugin from "draft-js-image-plugin";
import createMarkdownPlugin from 'draft-js-markdown-plugin';
import createFocusPlugin from 'draft-js-focus-plugin';
import createImagePlugin from 'draft-js-image-plugin';

const entityType = {
IMAGE: "IMAGE",
IMAGE: 'IMAGE',
};

const focusPlugin = createFocusPlugin();
@@ -209,16 +203,16 @@ const editorPlugins = [focusPlugin, imagePlugin, markdownPlugin];

## Why fork the `markdown-shortcuts-plugin`?

Writing is a core part of our app, and while the `markdown-shortcuts-plugin` is awesome and battle-tested there are a few opinionated things we wanted to do differently. Rather than bother [@ngs](https://github.com/ngs) with tons of PRs, we figured it'd be better to own that core part of our experience fully.
Writing is a core part of our app, and while the `markdown-shortcuts-plugin` is awesome and battle-tested there are a few opinionated things we wanted to do differently. Rather than bother [@ngs](https://github.com/ngs) with tons of PRs, we figured it'd be better to own that core part of our experience fully.

## License

Licensed under the MIT license, Copyright Ⓒ 2017 Space Program Inc. This plugin is forked from the excellent [`draft-js-markdown-shortcuts-plugin`](https://github.com/ngs/draft-js-markdown-shortcuts-plugin) by [Atsushi Nagase](https://github.com/ngs).

See [LICENSE] for the full license text.

[Demo]: https://markdown-plugin.spectrum.chat/
[DraftJS]: https://facebook.github.io/draft-js/
[DraftJS Plugins]: https://github.com/draft-js-plugins/draft-js-plugins
[LICENSE]: ./LICENSE
[demo]: https://markdown-plugin.spectrum.chat/
[draftjs]: https://facebook.github.io/draft-js/
[draftjs plugins]: https://github.com/draft-js-plugins/draft-js-plugins
[license]: ./LICENSE
[npm]: https://www.npmjs.com/package/draft-js-markdown-plugin
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "draft-js-markdown-plugin",
"version": "3.0.5",
"version": "4.0.0",
"description": "A DraftJS plugin for supporting Markdown syntax shortcuts, fork of draft-js-markdown-shortcuts-plugin",
"main": "lib/index.js",
"scripts": {
@@ -9,6 +9,7 @@
"build:js": "BABEL_DISABLE_CACHE=1 BABEL_ENV=production NODE_ENV=production node_modules/.bin/babel --out-dir='lib' --ignore='**/__test__/*' src",
"clean": "node_modules/.bin/rimraf lib; node_modules/.bin/rimraf demo/public",
"dev": "node_modules/.bin/babel-node ./demo/server.js",
"prettier": "prettier --write \"**/*\"",
"test": "jest",
"precommit": "jest && lint-staged"
},
@@ -50,7 +51,8 @@
"coveralls": "^2.13.3",
"css-loader": "^0.26.0",
"css-modules-require-hook": "^4.2.3",
"draft-js-plugins-editor": "2.0.0-rc2",
"draft-js": "^0.11.0",
"draft-js-plugins-editor": "^3.0.0",
"draft-js-prism": "ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb",
"enzyme": "^2.6.0",
"eslint": "^3.11.1",
@@ -94,16 +96,17 @@
"webpack-hot-middleware": "^2.24.3"
},
"peerDependencies": {
"draft-js-plugins-editor": "~2.0.0-rc.1 || 2.0.0-rc2 || 2.0.0-rc1 || 2.0.0-beta12",
"draft-js-plugins-editor": "^3.0.0",
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"
"react-dom": "^15.0.0 || ^16.0.0",
"draft-js": "^0.11.0",
"prismjs": "^1.0.0"
},
"contributors": [
"Atsushi Nagase <[email protected]>"
],
"dependencies": {
"decorate-component-with-props": "^1.1.0",
"draft-js": "^0.10.4",
"draft-js-checkable-list-item": "^2.0.6",
"draft-js-prism-plugin": "^0.1.3",
"immutable": "~3.7.4",
2 changes: 1 addition & 1 deletion src/__test__/__snapshots__/plugin-new.test.js.snap
Original file line number Diff line number Diff line change
@@ -76,4 +76,4 @@ Object {
],
"entityMap": Object {},
}
`
`;
Loading