Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Add missing flowtyped for @djsp/atomic-block and fix flow error in travis #53

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ script:
- ./node_modules/.bin/lerna bootstrap --hoist
- npm run build
- npm run lint
- npm run flow
3 changes: 3 additions & 0 deletions examples/counter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"draft-js": "^0.10.5"
}
}
3 changes: 3 additions & 0 deletions examples/mentions-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"draft-js": "^0.10.5"
}
}
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"examples/*",
"packages/*"
],
"nohoist": ["**/draft-js"],
"version": "0.1.5"
}
2 changes: 1 addition & 1 deletion packages/atomic-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "./node_modules/.bin/rollup -c",
"start": "./node_modules/.bin/rollup -c -w",
"prepare": "yarn run build",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"predeploy": "cd example && yarn install && yarn run build",
"deploy": "gh-pages -d example/build"
},
Expand Down
17 changes: 12 additions & 5 deletions packages/atomic-block/src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import React, { Component } from 'react'
import type { Node } from 'react'
import { withPluginContext, constants } from '@djsp/core'
import type { PluginProps } from '@djsp/core'
import { ContentBlock, EditorState, Modifier, SelectionState } from 'draft-js'
Expand All @@ -13,7 +14,7 @@ const _BlockChildren = ({
editorState,
setEditorState,
...props
}: Object) => {
}: Object): Node => {
const blockKey = props.block.getKey()
const { children, focusBlock } = props.blockProps
const selection = editorState.getSelection()
Expand Down Expand Up @@ -43,7 +44,7 @@ type Props = PluginProps & {
// Set selection of editor to next/previous block
const setSelection = (
editorState: EditorState,
setEditorState: EditorState,
setEditorState: (editorState: EditorState) => void,
newActiveBlock: ContentBlock
): void => {
// TODO verify that always a key-0-0 exists
Expand Down Expand Up @@ -91,7 +92,10 @@ class AtomicBlockPlugin extends Component<Props> {
this.unregister()
}

handleKeyCommand = (command, editorState) => {
handleKeyCommand = (
command: string,
editorState: EditorState
): DraftHandleValue => {
const { setEditorState } = this.props

let contentState = editorState.getCurrentContent()
Expand Down Expand Up @@ -189,7 +193,10 @@ class AtomicBlockPlugin extends Component<Props> {
)
}

handleReturn = (event, editorState) => {
handleReturn = (
event: SyntheticKeyboardEvent<*>,
editorState: EditorState
): DraftHandleValue => {
const { setEditorState } = this.props
const selection = editorState.getSelection()

Expand All @@ -205,7 +212,7 @@ class AtomicBlockPlugin extends Component<Props> {
return constants.NOT_HANDLED
}

blockRendererFn = block => {
blockRendererFn = (block: ContentBlock): ?Object => {
const { type, children, editorState } = this.props

const content = editorState.getCurrentContent()
Expand Down
2 changes: 1 addition & 1 deletion packages/autocomplete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"build": "./node_modules/.bin/rollup -c",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"start": "./node_modules/.bin/rollup -c -w",
"prepare": "yarn run build",
"predeploy": "cd example && yarn install && yarn run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-type-toggle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test:watch": "react-scripts test --env=jsdom",
"build": "./node_modules/.bin/rollup -c",
"start": "./node_modules/.bin/rollup -c -w",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"prepare": "yarn run build",
"predeploy": "cd example && yarn install && yarn run build",
"deploy": "gh-pages -d example/build"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "rimraf dist && ./node_modules/.bin/rollup -c && yarn build:flow",
"build:flow": "./node_modules/.bin/flow-copy-source -v -i '**/__tests__/**' src dist",
"start": "./node_modules/.bin/rollup -c -w",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"prepare": "yarn run build && yarn build:flow",
"predeploy": "cd example && yarn install && yarn run build",
"deploy": "gh-pages -d example/build"
Expand Down
2 changes: 1 addition & 1 deletion packages/inline-style-toggle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"jsnext:main": "dist/index.es.js",
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"test:watch": "react-scripts test --env=jsdom",
"build": "./node_modules/.bin/rollup -c",
"start": "./node_modules/.bin/rollup -c -w",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"flow": "./node_modules/.bin/flow",
"flow": "./node_modules/.bin/flow check",
"build": "./node_modules/.bin/rollup -c",
"start": "./node_modules/.bin/rollup -c -w",
"prepare": "yarn run build",
Expand Down