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

Commit e72ad25

Browse files
committed
all examples working again
1 parent e36931a commit e72ad25

File tree

8 files changed

+18
-28
lines changed

8 files changed

+18
-28
lines changed

examples/add-video-block/src/App.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default class App extends Component {
8181
<iframe
8282
src={src}
8383
frameBorder="0"
84+
title="youtube video"
8485
allow="autoplay; encrypted-media"
8586
allowFullScreen
8687
/>

examples/emoji-example/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class App extends Component {
2323
if (isFocused) classNames.push('list__item--focused')
2424
return (
2525
<span className={`${classNames.join(' ')}`}>
26-
{suggestion.char} {`{suggestion.name}`}
26+
{suggestion.char} {suggestion.name}
2727
</span>
2828
)
2929
}

packages/atomic-block/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"build": "./node_modules/.bin/rollup -c",
1515
"start": "./node_modules/.bin/rollup -c -w",
1616
"prepare": "yarn run build",
17+
"flow": "./node_modules/.bin/flow",
1718
"predeploy": "cd example && yarn install && yarn run build",
1819
"deploy": "gh-pages -d example/build"
1920
},

packages/atomic-block/src/index.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const { EditorState } = Draft
1111
type Props = PluginProps & {
1212
type: string,
1313
children: any,
14-
editorProps: Object,
1514
}
1615

1716
type State = {
@@ -58,19 +57,9 @@ class AtomicBlockPlugin extends Component<Props, State> {
5857
console.log('event.key', event.key)
5958
}
6059

61-
handleReturn = () => {
62-
// const {
63-
// editorProps: { editorState },
64-
// } = this.props
65-
66-
// const selection = editorState.getSelection()
67-
68-
console.log('handle return')
69-
}
70-
7160
renderChildren = (props: Object) => {
7261
const {
73-
editorProps: { editorState },
62+
editorState,
7463
} = this.props
7564

7665
const blockKey = props.block.getKey()
@@ -90,7 +79,7 @@ class AtomicBlockPlugin extends Component<Props, State> {
9079
blockRendererFn = block => {
9180
const {
9281
type,
93-
editorProps: { editorState },
82+
editorState,
9483
} = this.props
9584
const content = editorState.getCurrentContent()
9685

packages/autocomplete/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"test": "cross-env CI=1 react-scripts test --env=jsdom",
1313
"test:watch": "react-scripts test --env=jsdom",
1414
"build": "./node_modules/.bin/rollup -c",
15+
"flow": "./node_modules/.bin/flow",
1516
"start": "./node_modules/.bin/rollup -c -w",
1617
"prepare": "yarn run build",
1718
"predeploy": "cd example && yarn install && yarn run build",

packages/autocomplete/src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import React, { Component } from 'react'
44
import type { Node } from 'react'
55
import { withPluginContext, constants } from '@djsp/core'
6+
import type { PluginProps } from '@djsp/core'
67
import styles from './styles.css'
78

8-
type Props = {
9+
type Props = PluginProps & {
910
trigger: string | ((textUntilCursor: string) => ?string),
1011
renderSuggestion: ({ isFocused: boolean, suggestion: any }) => Node,
1112
onSelect: (suggestion: any, searchText: ?string) => void,
1213
onSearch: (searchText: string) => void,
1314
suggestions: Array<any>,
14-
pluginProps: Object,
1515
}
1616

1717
type State = {
@@ -45,7 +45,7 @@ class Suggestions extends Component<Props, State> {
4545

4646
componentDidMount() {
4747
const {
48-
pluginProps: { registerPlugin },
48+
registerPlugin,
4949
} = this.props
5050

5151
this._unregister = registerPlugin({
@@ -103,7 +103,7 @@ class Suggestions extends Component<Props, State> {
103103
const {
104104
trigger,
105105
suggestions,
106-
editorProps: { editorState },
106+
editorState,
107107
} = props
108108

109109
const selection = editorState.getSelection()

packages/core/src/EditorContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@ export default class EditorContainer extends Component<Props, State> {
305305

306306
// yepyepyep this gets the editorState lazily
307307
// avoids having to have a `getEditorState` prop
308+
// $FlowFixMe
308309
Object.defineProperty(editorProps, 'editorState', {
309310
get: () => this.state.editorState,
310-
value: this.state.editorState,
311311
})
312312

313313
const pluginProps = {
@@ -320,9 +320,9 @@ export default class EditorContainer extends Component<Props, State> {
320320
}),
321321
}
322322

323+
// $FlowFixMe
323324
Object.defineProperty(pluginProps, 'editorState', {
324325
get: () => this.state.editorState,
325-
value: this.state.editorState,
326326
})
327327

328328
return (

packages/inline-style-toggle/src/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22

33
import { Component } from 'react'
44
import { EditorState, RichUtils } from 'draft-js'
5-
import { withEditorContext } from '@djsp/core'
5+
import { withPluginContext } from '@djsp/core'
6+
import type { PluginProps } from '@djsp/core'
67

78
type InlineStyleRenderProps = {
89
toggleStyle: () => void,
910
hasStyle: boolean,
1011
}
1112

12-
type InlineStyleProps = {
13-
pluginProps: {
14-
setEditorState: (editorState: EditorState) => void,
15-
editorState: EditorState,
16-
},
13+
type InlineStyleProps = PluginProps & {
1714
children: InlineStyleRenderProps => React.Element,
1815
inlineStyle: string,
1916
}
2017

2118
class InlineStyleToggle extends Component<InlineStyleProps> {
2219
render() {
2320
const {
24-
pluginProps: { setEditorState, editorState },
21+
setEditorState,
22+
editorState,
2523
inlineStyle,
2624
children,
2725
} = this.props
@@ -37,4 +35,4 @@ class InlineStyleToggle extends Component<InlineStyleProps> {
3735
}
3836
}
3937

40-
export default withEditorContext(InlineStyleToggle)
38+
export default withPluginContext(InlineStyleToggle)

0 commit comments

Comments
 (0)