fix(editor-component-image): fix null on empty markdown image alt (#1778)
This commit is contained in:
parent
87768ee2c8
commit
9b72419096
@ -71,7 +71,8 @@ exports[`Markdown Preview renderer Markdown rendering General should render mark
|
||||
<p><a href=\\"http://google.com\\">link title</a></p>
|
||||
<h5>H5</h5>
|
||||
<p>![alt text](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg)</p>
|
||||
<h6>H6</h6>",
|
||||
<h6>H6</h6>
|
||||
<p>![](https://pbs.twimg.com/profile_images/678903331176214528/TQTdqGwD.jpg)</p>",
|
||||
}
|
||||
}
|
||||
/>
|
||||
|
@ -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(<MarkdownPreview value={markdownToHtml(value)} />).toJSON(),
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user