From 9b72419096b5da1c6edcfa6e8665c804c3ddfb89 Mon Sep 17 00:00:00 2001 From: Leonardo Dino Date: Fri, 26 Oct 2018 14:00:11 -0400 Subject: [PATCH] fix(editor-component-image): fix null on empty markdown image alt (#1778) --- .../src/__tests__/__snapshots__/renderer.spec.js.snap | 3 ++- .../src/__tests__/renderer.spec.js | 2 ++ .../src/serializers/remarkImagesToText.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/netlify-cms-widget-markdown/src/__tests__/__snapshots__/renderer.spec.js.snap b/packages/netlify-cms-widget-markdown/src/__tests__/__snapshots__/renderer.spec.js.snap index 32bb3838..b01b761f 100644 --- a/packages/netlify-cms-widget-markdown/src/__tests__/__snapshots__/renderer.spec.js.snap +++ b/packages/netlify-cms-widget-markdown/src/__tests__/__snapshots__/renderer.spec.js.snap @@ -71,7 +71,8 @@ exports[`Markdown Preview renderer Markdown rendering General should render mark

link title

H5

![alt text](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg)

-
H6
", +
H6
+

![](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg)

", } } /> diff --git a/packages/netlify-cms-widget-markdown/src/__tests__/renderer.spec.js b/packages/netlify-cms-widget-markdown/src/__tests__/renderer.spec.js index 65b75b50..9497f9dc 100644 --- a/packages/netlify-cms-widget-markdown/src/__tests__/renderer.spec.js +++ b/packages/netlify-cms-widget-markdown/src/__tests__/renderer.spec.js @@ -33,6 +33,8 @@ Text with **bold** & _em_ elements ![alt text](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg) ###### H6 + +![](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg) `; expect( renderer.create().toJSON(), diff --git a/packages/netlify-cms-widget-markdown/src/serializers/remarkImagesToText.js b/packages/netlify-cms-widget-markdown/src/serializers/remarkImagesToText.js index 3e36cd2d..6159eee3 100644 --- a/packages/netlify-cms-widget-markdown/src/serializers/remarkImagesToText.js +++ b/packages/netlify-cms-widget-markdown/src/serializers/remarkImagesToText.js @@ -15,8 +15,8 @@ export default function remarkImagesToText() { child.children.length === 1 && child.children[0].type === 'image' ) { - const { alt = '', url = '', title = '' } = child.children[0]; - const value = `![${alt}](${url}${title ? ' title' : ''})`; + const { alt, url } = child.children[0]; + const value = `![${alt || ''}](${url || ''})`; child.children = [{ type: 'text', value }]; } return child;