mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-18 05:02:24 +08:00
Merge pull request #3731 from Keraito/notes-md-table
Remove linebreaks in notes text when it are html elements
This commit is contained in:
commit
aea6f48300
@ -45,7 +45,12 @@ export class Notes extends React.Component {
|
||||
|
||||
render() {
|
||||
const { text } = this.state;
|
||||
const textAfterFormatted = text ? text.trim().replace(/\n/g, '<br />') : '';
|
||||
const textAfterFormatted = text
|
||||
? text
|
||||
.trim()
|
||||
.replace(/(<\S+.*>)\n/g, '$1')
|
||||
.replace(/\n/g, '<br />')
|
||||
: '';
|
||||
|
||||
return (
|
||||
<Panel
|
||||
|
@ -12,6 +12,12 @@ exports[`Storyshots Addons|Notes using decorator arguments, withNotes 1`] = `
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Storyshots Addons|Notes with a markdown table 1`] = `
|
||||
<button>
|
||||
Button with notes - check the notes panel for details
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Storyshots Addons|Notes withNotes 1`] = `
|
||||
<button>
|
||||
Button with notes - check the notes panel for details
|
||||
|
@ -26,6 +26,15 @@ storiesOf('Addons|Notes', module)
|
||||
~~~
|
||||
`;
|
||||
|
||||
const markdownTable = `
|
||||
| Column1 | Column2 | Column3 |
|
||||
|---------|---------|---------|
|
||||
| Row1.1 | Row1.2 | Row1.3 |
|
||||
| Row2.1 | Row2.2 | Row2.3 |
|
||||
| Row3.1 | Row3.2 | Row3.3 |
|
||||
| Row4.1 | Row4.2 | Row4.3 |
|
||||
`;
|
||||
|
||||
storiesOf('Addons|Notes', module)
|
||||
.addDecorator(withNotes)
|
||||
.add('withNotes', baseStory, {
|
||||
@ -39,7 +48,7 @@ storiesOf('Addons|Notes', module)
|
||||
notes: { markdown: markdownString },
|
||||
})
|
||||
.add('using decorator arguments, withNotes', withNotes('Notes into withNotes')(baseStory))
|
||||
.add(
|
||||
'using decorator arguments, withMarkdownNotes',
|
||||
withMarkdownNotes(markdownString)(baseStory)
|
||||
);
|
||||
.add('using decorator arguments, withMarkdownNotes', withMarkdownNotes(markdownString)(baseStory))
|
||||
.add('with a markdown table', baseStory, {
|
||||
notes: { markdown: markdownTable },
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user