Merge pull request #168 from netlify/npm-module-usage
Prepare CMS to be used as an npm module
This commit is contained in:
commit
60570dbecb
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "netlify-cms",
|
"name": "netlify-cms",
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"description": "Netlify CMS lets content editors work on structured content stored in git",
|
"description": "Netlify CMS lets content editors work on structured content stored in git",
|
||||||
"main": "index.js",
|
"main": "dist/cms.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "webpack-dev-server --config webpack.dev.js",
|
"start": "webpack-dev-server --config webpack.dev.js",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
@ -25,11 +25,6 @@
|
|||||||
"eslint --fix",
|
"eslint --fix",
|
||||||
"jest --findRelatedTests",
|
"jest --findRelatedTests",
|
||||||
"git add"
|
"git add"
|
||||||
],
|
|
||||||
"*.css": [
|
|
||||||
"stylefmt",
|
|
||||||
"stylelint",
|
|
||||||
"git add"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
26
src/index.js
26
src/index.js
@ -24,7 +24,7 @@ render((
|
|||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production' && module.hot) {
|
if (process.env.NODE_ENV !== 'production' && module.hot) {
|
||||||
module.hot.accept('./root', () => {
|
module.hot.accept('./root', () => {
|
||||||
const NextRoot = require('./root').default;
|
const NextRoot = require('./root').default; // eslint-disable-line
|
||||||
render((
|
render((
|
||||||
<AppContainer>
|
<AppContainer>
|
||||||
<NextRoot />
|
<NextRoot />
|
||||||
@ -33,13 +33,6 @@ if (process.env.NODE_ENV !== 'production' && module.hot) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.CMS = {};
|
|
||||||
for (const method in registry) {
|
|
||||||
window.CMS[method] = registry[method];
|
|
||||||
}
|
|
||||||
window.createClass = React.createClass;
|
|
||||||
window.h = React.createElement;
|
|
||||||
|
|
||||||
const buildtInPlugins = [{
|
const buildtInPlugins = [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
id: 'image',
|
id: 'image',
|
||||||
@ -48,9 +41,7 @@ const buildtInPlugins = [{
|
|||||||
alt: match[1],
|
alt: match[1],
|
||||||
},
|
},
|
||||||
toBlock: data => `![${ data.alt }](${ data.image })`,
|
toBlock: data => `![${ data.alt }](${ data.image })`,
|
||||||
toPreview: (data) => {
|
toPreview: data => <img src={data.image} alt={data.alt} />,
|
||||||
return <img src={data.image} alt={data.alt} />;
|
|
||||||
},
|
|
||||||
pattern: /^!\[([^\]]+)\]\(([^\)]+)\)$/,
|
pattern: /^!\[([^\]]+)\]\(([^\)]+)\)$/,
|
||||||
fields: [{
|
fields: [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
@ -62,3 +53,16 @@ const buildtInPlugins = [{
|
|||||||
}],
|
}],
|
||||||
}];
|
}];
|
||||||
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
||||||
|
|
||||||
|
const CMS = {};
|
||||||
|
for (const method in registry) { // eslint-disable-line
|
||||||
|
CMS[method] = registry[method];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
window.CMS = CMS;
|
||||||
|
window.createClass = window.createClass || React.createClass;
|
||||||
|
window.h = window.h || React.createElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CMS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user