2016-02-25 00:45:56 -08:00
|
|
|
import React from 'react';
|
|
|
|
import { render } from 'react-dom';
|
2016-09-15 18:53:24 +02:00
|
|
|
import { AppContainer } from 'react-hot-loader';
|
2016-02-25 00:45:56 -08:00
|
|
|
import 'file?name=index.html!../example/index.html';
|
2016-09-15 18:53:24 +02:00
|
|
|
import 'react-toolbox/lib/commons.scss';
|
2016-10-06 16:11:11 +02:00
|
|
|
import Root from './root';
|
|
|
|
import registry from './lib/registry';
|
2016-07-08 07:12:52 -03:00
|
|
|
import './index.css';
|
2016-02-25 00:45:56 -08:00
|
|
|
|
2016-10-06 16:11:11 +02:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
require('./utils.css'); // eslint-disable-line
|
|
|
|
}
|
|
|
|
|
2017-04-15 01:35:08 +01:00
|
|
|
// Log the version number
|
|
|
|
console.log(`Netlify CMS version ${NETLIFY_CMS_VERSION}`);
|
|
|
|
|
2016-09-13 17:08:26 +02:00
|
|
|
// Create mount element dynamically
|
2016-02-25 00:45:56 -08:00
|
|
|
const el = document.createElement('div');
|
2016-07-05 15:48:18 -03:00
|
|
|
el.id = 'root';
|
2016-02-25 00:45:56 -08:00
|
|
|
document.body.appendChild(el);
|
|
|
|
|
|
|
|
render((
|
2016-09-13 17:08:26 +02:00
|
|
|
<AppContainer>
|
|
|
|
<Root />
|
|
|
|
</AppContainer>
|
2016-02-25 00:45:56 -08:00
|
|
|
), el);
|
2016-09-11 17:53:44 +02:00
|
|
|
|
2016-10-26 19:51:35 +02:00
|
|
|
if (process.env.NODE_ENV !== 'production' && module.hot) {
|
2016-09-13 17:08:26 +02:00
|
|
|
module.hot.accept('./root', () => {
|
2016-11-23 12:26:15 -08:00
|
|
|
const NextRoot = require('./root').default; // eslint-disable-line
|
2016-09-13 17:08:26 +02:00
|
|
|
render((
|
|
|
|
<AppContainer>
|
|
|
|
<NextRoot />
|
|
|
|
</AppContainer>
|
|
|
|
), el);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-17 04:08:37 -08:00
|
|
|
const buildtInPlugins = [{
|
|
|
|
label: 'Image',
|
|
|
|
id: 'image',
|
|
|
|
fromBlock: match => match && {
|
|
|
|
image: match[2],
|
|
|
|
alt: match[1],
|
|
|
|
},
|
|
|
|
toBlock: data => `![${ data.alt }](${ data.image })`,
|
2016-11-23 12:26:15 -08:00
|
|
|
toPreview: data => <img src={data.image} alt={data.alt} />,
|
2017-03-16 20:45:46 -04:00
|
|
|
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
|
2016-11-17 04:08:37 -08:00
|
|
|
fields: [{
|
|
|
|
label: 'Image',
|
|
|
|
name: 'image',
|
|
|
|
widget: 'image',
|
|
|
|
}, {
|
|
|
|
label: 'Alt Text',
|
|
|
|
name: 'alt',
|
|
|
|
}],
|
|
|
|
}];
|
|
|
|
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
2016-11-23 12:26:15 -08:00
|
|
|
|
|
|
|
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;
|