Skip to content

Commit

Permalink
Fix empty image fields saving null or undefined.
Browse files Browse the repository at this point in the history
  • Loading branch information
tech4him1 authored and erquhart committed Nov 27, 2017
1 parent 0515a70 commit 5271e0f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ if (module.hot) {
module.hot.accept('./root', () => { render(Root); });
}

const buildtInPlugins = [{
const builtInPlugins = [{
label: 'Image',
id: 'image',
fromBlock: match => match && {
image: match[2],
alt: match[1],
},
toBlock: data => `![${ data.alt }](${ data.image })`,
toPreview: (data, getAsset) => <img src={getAsset(data.image)} alt={data.alt} />,
toBlock: data => `![${ data.alt || "" }](${ data.image || "" })`,
toPreview: (data, getAsset) => <img src={getAsset(data.image) || ""} alt={data.alt || ""} />,
pattern: /^!\[([^\]]+)]\(([^)]+)\)$/,
fields: [{
label: 'Image',
Expand All @@ -48,7 +48,7 @@ const buildtInPlugins = [{
name: 'alt',
}],
}];
buildtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));
builtInPlugins.forEach(plugin => registry.registerEditorComponent(plugin));

const CMS = {};
for (const method in registry) { // eslint-disable-line
Expand Down

0 comments on commit 5271e0f

Please sign in to comment.