Last active
April 29, 2016 08:21
-
-
Save grebaldi/d5a687ab1da88d64621ec5946a98ca68 to your computer and use it in GitHub Desktop.
How runtime dependencies could work for Guevara
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Neos => { | |
const {React, Components, api} = Neos; | |
const {Component} = React; | |
const {Button, Input, PageTree} = Components; | |
// | |
// How to connect this to the store? Should we expose @connect? | |
// | |
return class MyCustomComponent extends Component { | |
render() { | |
return ( | |
<div> | |
<Input placeholder="Search for pages..." /> | |
<PageTree /> | |
<Button onClick={() => api.searchFor(...)}>Search!</Button> | |
</div> | |
); | |
} | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import neos from 'neos'; | |
import myCustomComponentFactory from './myEditor'; | |
// | |
// Some Mechanism to make the UI aware of the extension | |
// | |
neos.ui.registerCustomInspectorEditorFactory(myCustomComponentFactory); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This would be a separate npm package, that you'll need | |
// as a dependency in order to use | |
// | |
// | |
// Check for global neos API | |
// | |
if (window.neos === undefined) { | |
throw new Error('Neos API not found!'); | |
} | |
// | |
// Check for version constraint | |
// | |
if (!isCompatibleVersion(window.neos.version)) { | |
console.warn(`Detected incompatible JSAPI ${window.neos.version}`); | |
} | |
export default window.neos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment