-
-
Save akoenig/8decc1c002845ec361567be62c0d02c3 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 [ | |
// | |
// 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> | |
); | |
} | |
} | |
} | |
]; |
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