Added MarkdownImage component (#6774)
* Added MarkdownImage component * Fixed unit tests
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
0f69920342
Коммит
2dea567dcf
19
webapp/components/markdown_image.jsx
Обычный файл
19
webapp/components/markdown_image.jsx
Обычный файл
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React, {PureComponent} from 'react';
|
||||
|
||||
import {postListScrollChange} from 'actions/global_actions.jsx';
|
||||
|
||||
export default class MarkdownImage extends PureComponent {
|
||||
handleLoad = () => {
|
||||
postListScrollChange();
|
||||
}
|
||||
|
||||
render() {
|
||||
const props = {...this.props};
|
||||
props.onLoad = this.handleLoad;
|
||||
|
||||
return <img {...props}/>;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import React from 'react';
|
||||
import {FormattedMessage} from 'react-intl';
|
||||
|
||||
import AtMention from 'components/at_mention';
|
||||
import MarkdownImage from 'components/markdown_image';
|
||||
|
||||
import store from 'stores/redux_store.jsx';
|
||||
|
||||
@@ -113,6 +114,22 @@ export default class PostMessageView extends React.PureComponent {
|
||||
return <AtMention mentionName={mentionName}/>;
|
||||
}
|
||||
},
|
||||
{
|
||||
shouldProcessNode: (node) => node.type === 'tag' && node.name === 'img',
|
||||
processNode: (node) => {
|
||||
const {
|
||||
class: className,
|
||||
...attribs
|
||||
} = node.attribs;
|
||||
|
||||
return (
|
||||
<MarkdownImage
|
||||
className={className}
|
||||
{...attribs}
|
||||
/>
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
shouldProcessNode: () => true,
|
||||
processNode: processNodeDefinitions.processDefaultNode
|
||||
|
||||
Ссылка в новой задаче
Block a user