MM-9547 Added CustomUrlSchemes option (#1718)
* MM-9547 Added CustomUrlSchemes option * Switched mattermost-redux back to master
This commit is contained in:
parent
6179c031cd
commit
861b46d605
5 changed files with 30 additions and 7 deletions
|
|
@ -3,12 +3,14 @@
|
|||
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import {getAutolinkedUrlSchemes} from 'mattermost-redux/selectors/entities/general';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
|
||||
import Markdown from './markdown';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
autolinkedUrlSchemes: getAutolinkedUrlSchemes(state),
|
||||
theme: getTheme(state),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import Emoji from 'app/components/emoji';
|
|||
import FormattedText from 'app/components/formatted_text';
|
||||
import CustomPropTypes from 'app/constants/custom_prop_types';
|
||||
import {blendColors, concatStyles, makeStyleSheetFromTheme} from 'app/utils/theme';
|
||||
import {getScheme} from 'app/utils/url';
|
||||
|
||||
import MarkdownBlockQuote from './markdown_block_quote';
|
||||
import MarkdownCodeBlock from './markdown_code_block';
|
||||
|
|
@ -32,6 +33,7 @@ import {addListItemIndices, pullOutImages} from './transform';
|
|||
|
||||
export default class Markdown extends PureComponent {
|
||||
static propTypes = {
|
||||
autolinkedUrlSchemes: PropTypes.array.isRequired,
|
||||
baseTextStyle: CustomPropTypes.Style,
|
||||
blockStyles: PropTypes.object,
|
||||
isEdited: PropTypes.bool,
|
||||
|
|
@ -54,10 +56,22 @@ export default class Markdown extends PureComponent {
|
|||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.parser = new Parser();
|
||||
this.parser = this.createParser();
|
||||
this.renderer = this.createRenderer();
|
||||
}
|
||||
|
||||
createParser = () => {
|
||||
return new Parser({
|
||||
urlFilter: this.urlFilter,
|
||||
});
|
||||
}
|
||||
|
||||
urlFilter = (url) => {
|
||||
const scheme = getScheme(url);
|
||||
|
||||
return !scheme || this.props.autolinkedUrlSchemes.indexOf(scheme) !== -1;
|
||||
}
|
||||
|
||||
createRenderer = () => {
|
||||
return new Renderer({
|
||||
renderers: {
|
||||
|
|
|
|||
|
|
@ -88,3 +88,9 @@ export function cleanUpUrlable(input) {
|
|||
cleaned = cleaned.replace(/-+$/, '');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
export function getScheme(url) {
|
||||
const match = (/([a-z0-9+.-]+):/i).exec(url);
|
||||
|
||||
return match && match[1];
|
||||
}
|
||||
|
|
|
|||
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -4932,8 +4932,8 @@
|
|||
"integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs="
|
||||
},
|
||||
"commonmark": {
|
||||
"version": "github:mattermost/commonmark.js#21742b9d51070b6abba82d88590a0c51ee552a47",
|
||||
"from": "commonmark@github:mattermost/commonmark.js#21742b9d51070b6abba82d88590a0c51ee552a47",
|
||||
"version": "github:mattermost/commonmark.js#e5c34706cafa2924370772ff47937b833648a6de",
|
||||
"from": "github:mattermost/commonmark.js#e5c34706cafa2924370772ff47937b833648a6de",
|
||||
"requires": {
|
||||
"entities": "~ 1.1.1",
|
||||
"mdurl": "~ 1.0.1",
|
||||
|
|
@ -9878,8 +9878,8 @@
|
|||
}
|
||||
},
|
||||
"mattermost-redux": {
|
||||
"version": "github:mattermost/mattermost-redux#1cc600992b9560a4d41cc622352cf440ae905ab1",
|
||||
"from": "github:mattermost/mattermost-redux#1cc600992b9560a4d41cc622352cf440ae905ab1",
|
||||
"version": "github:mattermost/mattermost-redux#74440af4513c2a77c3a17ecede72cb5c9cd59774",
|
||||
"from": "github:mattermost/mattermost-redux#74440af4513c2a77c3a17ecede72cb5c9cd59774",
|
||||
"requires": {
|
||||
"deep-equal": "1.0.1",
|
||||
"eslint-plugin-header": "1.2.0",
|
||||
|
|
|
|||
|
|
@ -8,14 +8,15 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"analytics-react-native": "1.2.0",
|
||||
"commonmark": "github:mattermost/commonmark.js#21742b9d51070b6abba82d88590a0c51ee552a47",
|
||||
"commonmark": "github:mattermost/commonmark.js#e5c34706cafa2924370772ff47937b833648a6de",
|
||||
"commonmark-react-renderer": "mattermost/commonmark-react-renderer#86fa63f898802953842526c2030f3b63c5d1ae7a",
|
||||
"deep-equal": "1.0.1",
|
||||
"fuse.js": "^3.2.0",
|
||||
"intl": "1.2.5",
|
||||
"jail-monkey": "1.0.0",
|
||||
"jsc-android": "216113.0.3",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#1cc600992b9560a4d41cc622352cf440ae905ab1",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#74440af4513c2a77c3a17ecede72cb5c9cd59774",
|
||||
"mime-db": "1.33.0",
|
||||
"prop-types": "15.6.1",
|
||||
"react": "16.3.2",
|
||||
"react-intl": "2.4.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue