From 5271e0f7e762ed3d8be19130dade0cf2dcdcf1c1 Mon Sep 17 00:00:00 2001
From: Caleb <inchristalway-tech4him@yahoo.com>
Date: Fri, 17 Nov 2017 15:45:42 -0700
Subject: [PATCH] Fix empty image fields saving null or undefined.

---
 src/index.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/index.js b/src/index.js
index f517d586..e7842650 100644
--- a/src/index.js
+++ b/src/index.js
@@ -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',
@@ -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