Skip to content

Commit

Permalink
Update to match method signature changes in draft-js v0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
makenosound committed Jun 18, 2017
1 parent 99e69f9 commit 221a0ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
22 changes: 9 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,14 @@ function autoListPlugin() {
* Means that lists act as you’d expect while typing.
*
* @param {KeyboardEvent} e Synthetic keyboard event from draftjs
* @param {Function} options.getEditorState Getter function passed by
* the draft-js-plugin-editor
* @param {Object} editorState Current editor state
* @param {Function} options.setEditorState Setter function passed by
* the draft-js-plugin-editor
* @return {Boolean} Did we handle the return or not?
* @return {String} Did we handle the return or not?
*/
handleReturn: function handleReturn(e, _ref) {
var getEditorState = _ref.getEditorState;
handleReturn: function handleReturn(e, editorState, _ref) {
var setEditorState = _ref.setEditorState;

var editorState = getEditorState();
var content = editorState.getCurrentContent();

// Retrieve current block
Expand All @@ -131,13 +128,13 @@ function autoListPlugin() {

/**
* Handle our custom `commands`
* @param {[type]} command [description]
* @param {[type]} options.getEditorState [description]
* @param {[type]} options.setEditorState [description]
* @return {[type]} [description]
* @param {String} command The current command to respond to
* @param {Object} editorState Current editor state
* @param {Function} options.setEditorState Setter function passed by
* the draft-js-plugin-editor
* @return {String} Did we handle the return or not?
*/
handleKeyCommand: function handleKeyCommand(command, _ref2) {
var getEditorState = _ref2.getEditorState;
handleKeyCommand: function handleKeyCommand(command, editorState, _ref2) {
var setEditorState = _ref2.setEditorState;

if (command === commands.UL || command === commands.OL) {
Expand All @@ -153,7 +150,6 @@ function autoListPlugin() {
};
}

var editorState = getEditorState();
var content = editorState.getCurrentContent();

// Retrieve the focused block
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://github.com/icelab/draft-js-autolist-plugin",
"peerDependencies": {
"draft-js": ">=0.5.0"
"draft-js": ">=0.10.1"
},
"devDependencies": {
"babel-cli": "6.7.5",
Expand Down
20 changes: 9 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ function autoListPlugin () {
* Means that lists act as you’d expect while typing.
*
* @param {KeyboardEvent} e Synthetic keyboard event from draftjs
* @param {Function} options.getEditorState Getter function passed by
* the draft-js-plugin-editor
* @param {Object} editorState Current editor state
* @param {Function} options.setEditorState Setter function passed by
* the draft-js-plugin-editor
* @return {Boolean} Did we handle the return or not?
* @return {String} Did we handle the return or not?
*/
handleReturn (e, { getEditorState, setEditorState }) {
let editorState = getEditorState()
handleReturn (e, editorState, { setEditorState }) {
let content = editorState.getCurrentContent()

// Retrieve current block
Expand All @@ -114,12 +112,13 @@ function autoListPlugin () {

/**
* Handle our custom `commands`
* @param {[type]} command [description]
* @param {[type]} options.getEditorState [description]
* @param {[type]} options.setEditorState [description]
* @return {[type]} [description]
* @param {String} command The current command to respond to
* @param {Object} editorState Current editor state
* @param {Function} options.setEditorState Setter function passed by
* the draft-js-plugin-editor
* @return {String} Did we handle the return or not?
*/
handleKeyCommand (command, { getEditorState, setEditorState }) {
handleKeyCommand (command, editorState, { setEditorState }) {
if (command === commands.UL || command === commands.OL) {
// Set up the base types/checks
let listType = blockTypes.UL
Expand All @@ -129,7 +128,6 @@ function autoListPlugin () {
listTest = (text) => OL_INTERCEPT_REGEX.test(text)
}

let editorState = getEditorState()
let content = editorState.getCurrentContent()

// Retrieve the focused block
Expand Down

0 comments on commit 221a0ab

Please sign in to comment.