Skip to content

Commit

Permalink
Merge 2dc4714 into 7efd053
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfurlong committed Nov 13, 2018
2 parents 7efd053 + 2dc4714 commit 4a0a042
Show file tree
Hide file tree
Showing 23 changed files with 1,166 additions and 1,117 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/components/HotKey/Decorator.js
Expand Up @@ -39,6 +39,7 @@ import {
searchNodeEverywhere
} from '../../selector/editable'

import type { RootState } from '../../types/state'
import type { Editable, ComponetizedCell } from '../../types/editable'

type Props = {
Expand Down Expand Up @@ -131,9 +132,9 @@ class Decorator extends Component {
if (!isEditMode) {
return
}

const maybeNode = this.props.searchNodeEverywhere(focus)
if (!maybeNode) {
if (!maybeNode) {
return
}
const { node: n } = maybeNode
Expand Down Expand Up @@ -192,7 +193,7 @@ const mapStateToProps = createStructuredSelector({
focus,
node: (state: any) => (id: string, editable: string) =>
node(state, { id, editable }),
searchNodeEverywhere: (state: any) => (id: string) =>
searchNodeEverywhere: (state: RootState) => (id: string) =>
searchNodeEverywhere(state, id),
editable: (state: any, props: any) => (id?: string) =>
editable(state, id ? { id } : props),
Expand Down
16 changes: 9 additions & 7 deletions packages/core/src/index.js
Expand Up @@ -30,10 +30,11 @@ import { selectors } from './selector'
import PluginService from './service/plugin'
import pluginDefault from './service/plugin/default'
import type { Editable as EditableType } from './types/editable'
import type Store from './types/redux'
import type { Store } from './types/redux'
import forEach from 'ramda/src/forEach'
import HTML5Backend, { NativeTypes } from 'react-dnd-html5-backend'
import { DragDropContext as dragDropContext } from 'react-dnd'
import { oryReducer } from './reducer'

let instance: Editor

Expand Down Expand Up @@ -82,13 +83,15 @@ class Editor {
middleware = [],
editables = [],
defaultPlugin = pluginDefault,
dragDropBackend
dragDropBackend,
store
}: {
plugins: { content: [], layout: [], native?: any },
middleware: [],
editables: EditableType[],
defaultPlugin: any,
dragDropBackend: any
dragDropBackend: any,
store: Store
} = {}) {
if (instance) {
console.warn(
Expand All @@ -97,7 +100,7 @@ class Editor {
}

instance = this
this.store = createStore(initialState(), middleware)
this.store = store || createStore(initialState(), middleware)
this.plugins = new PluginService(plugins)
this.middleware = middleware
this.trigger = actions(this.store.dispatch)
Expand All @@ -115,7 +118,7 @@ class Editor {
forEach((editable: any) => {
console.log(this.plugins.serialize(editable))
this.trigger.editable.update(this.plugins.serialize(editable))
}, this.store.getState().editables.present)
}, this.store.getState().ory.editables.present)
}

setLayoutPlugins = (plugins: Array<any> = []) => {
Expand All @@ -135,7 +138,6 @@ class Editor {

setContentPlugins = (plugins: Array<any> = []) => {
this.plugins.setContentPlugins(plugins)
console.log(this.store.getState())
this.refreshEditables()
}

Expand All @@ -153,7 +155,7 @@ class Editor {
query = {}
}

export { PluginService, Editable, Editor }
export { PluginService, Editable, Editor, oryReducer }

export const createEmptyState = () => ({ id: v4(), cells: [] })

Expand Down

0 comments on commit 4a0a042

Please sign in to comment.