Skip to content

Instantly share code, notes, and snippets.

@akoenig
Forked from grebaldi/myEditor.js
Last active April 29, 2016 08:29
Show Gist options
  • Save akoenig/8decc1c002845ec361567be62c0d02c3 to your computer and use it in GitHub Desktop.
Save akoenig/8decc1c002845ec361567be62c0d02c3 to your computer and use it in GitHub Desktop.
How runtime dependencies could work for Guevara
export default [
//
// The store shard function
//
({user}) => ({
user
}),
//
// The sandbox dependency injection
//
({
api
React: {Component},
Components: {Button, Input, PageTree}
}) => {
return class MyCustomComponent extends Component {
render() {
const {user} = this.props;
return (
<div>
<Input placeholder="Search for pages..." />
<PageTree />
<Button onClick={() => api.searchFor(...)}>Search!</Button>
</div>
);
}
}
}
];
import neos from 'neos';
import myCustomComponentFactory from './myEditor';
//
// Some Mechanism to make the UI aware of the extension
//
neos.ui.registerCustomInspectorEditorFactory(myCustomComponentFactory);
//
// 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