Fix empty image fields saving null or undefined.
This commit is contained in:
@ -29,15 +29,15 @@ if (module.hot) {
|
|||||||
module.hot.accept('./root', () => { render(Root); });
|
module.hot.accept('./root', () => { render(Root); });
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildtInPlugins = [{
|
const builtInPlugins = [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
id: 'image',
|
id: 'image',
|
||||||
fromBlock: match => match && {
|
fromBlock: match => match && {
|
||||||
image: match[2],
|
image: match[2],
|
||||||
alt: match[1],
|
alt: match[1],
|
||||||
},
|
},
|
||||||
toBlock: data => ``,
|
toBlock: data => ``,
|
||||||
toPreview: (data, getAsset) => <img src={getAsset(data.image)} alt={data.alt} />,
|
toPreview: (data, getAsset) => <img src={getAsset(data.image) || ""} alt={data.alt || ""} />,
|
||||||
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
|
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
|
||||||
fields: [{
|
fields: [{
|
||||||
label: 'Image',
|
label: 'Image',
|
||||||
@ -48,7 +48,7 @@ const buildtInPlugins = [{
|
|||||||
name: 'alt',
|
name: 'alt',
|
||||||
}],
|
}],
|
||||||
}];
|
}];
|
||||||
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
builtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
|
||||||
|
|
||||||
const CMS = {};
|
const CMS = {};
|
||||||
for (const method in registry) { // eslint-disable-line
|
for (const method in registry) { // eslint-disable-line
|
||||||
|
Reference in New Issue
Block a user